@sentry/junior 0.131.0 → 0.133.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 (73) hide show
  1. package/dist/{agent-hooks-M5V454P5.js → agent-hooks-5BUIXVIX.js} +9 -9
  2. package/dist/api/conversations/list.d.ts +13 -2
  3. package/dist/api/schema/task.d.ts +0 -3
  4. package/dist/api/schema.js +1 -1
  5. package/dist/api.js +24 -23
  6. package/dist/app.js +84 -37
  7. package/dist/{catalog-runtime-PI2IFWZ5.js → catalog-runtime-VGB3DWXZ.js} +5 -5
  8. package/dist/chat/config.d.ts +2 -0
  9. package/dist/chat/conversations/location.d.ts +10 -0
  10. package/dist/chat/conversations/projection.d.ts +3 -1
  11. package/dist/chat/conversations/sql/bindings.d.ts +13 -0
  12. package/dist/chat/conversations/sql/location.d.ts +9 -0
  13. package/dist/chat/conversations/sql/store.d.ts +3 -0
  14. package/dist/chat/conversations/store.d.ts +17 -0
  15. package/dist/chat/runtime/reply-executor.d.ts +1 -0
  16. package/dist/chat/runtime/slack-runtime.d.ts +2 -0
  17. package/dist/chat/scheduled-tasks/tool-support.d.ts +2 -5
  18. package/dist/chat/scheduled-tasks/tools/create.d.ts +2 -2
  19. package/dist/chat/scheduled-tasks/tools/delete.d.ts +2 -2
  20. package/dist/chat/scheduled-tasks/tools/list.d.ts +2 -2
  21. package/dist/chat/scheduled-tasks/tools/run-now.d.ts +2 -2
  22. package/dist/chat/scheduled-tasks/tools/update.d.ts +3 -3
  23. package/dist/chat/scheduled-tasks/types.d.ts +1 -1
  24. package/dist/chat/slack/dispatch-turn.d.ts +1 -0
  25. package/dist/chat/slack/reply.d.ts +1 -1
  26. package/dist/{chunk-UYYSD255.js → chunk-5ZAZHLIW.js} +1 -1
  27. package/dist/{chunk-JKHK3LM2.js → chunk-AH5HTUYX.js} +1 -1
  28. package/dist/{chunk-HZ5EVSPV.js → chunk-ECUILEUX.js} +24 -15
  29. package/dist/{chunk-HSPYTFMD.js → chunk-EJRJWBKG.js} +1 -1
  30. package/dist/{chunk-TD2A27ET.js → chunk-FX6BLEDP.js} +1 -1
  31. package/dist/{chunk-7Y2OKB5K.js → chunk-HJ4KDO4N.js} +1 -1
  32. package/dist/{chunk-DRFI6CW3.js → chunk-HTGXUNEC.js} +7 -7
  33. package/dist/{chunk-SVX4JDOR.js → chunk-IKO5LFIU.js} +1 -1
  34. package/dist/{chunk-J4I2GVGH.js → chunk-IVTHTAVK.js} +2 -2
  35. package/dist/{chunk-APUL3Y63.js → chunk-JLN4XSPR.js} +1 -1
  36. package/dist/{chunk-ZMIO64MA.js → chunk-LDRO4OQ4.js} +19 -3
  37. package/dist/{chunk-5ONXE2GF.js → chunk-LNYNTR27.js} +305 -235
  38. package/dist/{chunk-BVKP37NE.js → chunk-QVEXYYFM.js} +1 -1
  39. package/dist/{chunk-KB2M27DL.js → chunk-QWGZ273D.js} +78 -36
  40. package/dist/{chunk-TRKWWIB3.js → chunk-T5FPIBU2.js} +21 -21
  41. package/dist/{chunk-XXGCQCFJ.js → chunk-TBVS7GBE.js} +4 -4
  42. package/dist/{chunk-XMDY52DJ.js → chunk-TLN54TOQ.js} +1 -1
  43. package/dist/{chunk-VMPL77IK.js → chunk-TU7P77FI.js} +36 -24
  44. package/dist/{chunk-NGJEC4MF.js → chunk-V365UVCU.js} +2 -2
  45. package/dist/{chunk-KWYCUXJX.js → chunk-VL7OYSHD.js} +1 -1
  46. package/dist/{chunk-D6ZMP3FC.js → chunk-VQA25AL4.js} +6 -6
  47. package/dist/{chunk-MLIJGLW5.js → chunk-WHEMUEXT.js} +5 -5
  48. package/dist/{chunk-7X62XOC4.js → chunk-XTQGVNM3.js} +54 -19
  49. package/dist/cli/chat.js +24 -24
  50. package/dist/cli/check.js +6 -6
  51. package/dist/cli/init.js +1 -0
  52. package/dist/cli/plugins.js +12 -12
  53. package/dist/cli/snapshot-create.js +9 -9
  54. package/dist/cli/upgrade.js +9 -8
  55. package/dist/db/executor.d.ts +2 -1
  56. package/dist/db/neon.d.ts +1 -0
  57. package/dist/db/postgres.d.ts +1 -0
  58. package/dist/db/schema/conversation-bindings.d.ts +110 -0
  59. package/dist/db/schema.d.ts +111 -1
  60. package/dist/{db-5P6K3ZCM.js → db-RICMPUFT.js} +7 -7
  61. package/dist/instrumentation.js +4 -4
  62. package/dist/nitro.js +2 -2
  63. package/dist/{oauth-callback-server-RIMCKQZX.js → oauth-callback-server-YFVS4SAX.js} +17 -17
  64. package/dist/{runner-CAD3BVML.js → runner-A3LVGZR6.js} +11 -11
  65. package/dist/{skills-WVPCTBUT.js → skills-P7Q6Z6PN.js} +6 -6
  66. package/dist/{validation-GLEXIFFI.js → validation-RYHOWBET.js} +6 -6
  67. package/dist/version.js +1 -1
  68. package/migrations/0017_drop_paused_scheduled_tasks.sql +19 -0
  69. package/migrations/0018_curvy_excalibur.sql +12 -0
  70. package/migrations/meta/0017_snapshot.json +1666 -0
  71. package/migrations/meta/0018_snapshot.json +1756 -0
  72. package/migrations/meta/_journal.json +15 -1
  73. package/package.json +5 -5
@@ -1,15 +1,16 @@
1
1
  import {
2
2
  createJuniorSqlExecutor,
3
+ juniorConversationBindings,
3
4
  juniorConversationEvents,
4
5
  juniorConversations,
5
6
  juniorIdentities,
6
7
  juniorUsers
7
- } from "./chunk-KB2M27DL.js";
8
+ } from "./chunk-QWGZ273D.js";
8
9
  import {
9
10
  TURN_REASONING_LEVELS,
10
11
  getChatConfig,
11
12
  modelProfileSchema
12
- } from "./chunk-ZMIO64MA.js";
13
+ } from "./chunk-LDRO4OQ4.js";
13
14
  import {
14
15
  juniorDestinations
15
16
  } from "./chunk-VFUK3X5B.js";
@@ -19,11 +20,11 @@ import {
19
20
  } from "./chunk-F3B2YJ76.js";
20
21
  import {
21
22
  normalizeIdentityEmail
22
- } from "./chunk-HSPYTFMD.js";
23
+ } from "./chunk-EJRJWBKG.js";
23
24
 
24
25
  // src/chat/conversations/sql/store.ts
25
26
  import { randomUUID as randomUUID2 } from "crypto";
26
- import { and as and2, asc, desc, eq as eq2, isNull, sql as sql2 } from "drizzle-orm";
27
+ import { and as and3, asc, desc, eq as eq3, isNull, sql as sql2 } from "drizzle-orm";
27
28
 
28
29
  // src/chat/destination.ts
29
30
  import {
@@ -197,6 +198,68 @@ function parseSessionSource(value) {
197
198
  return parsed.success ? normalizeSessionSource(parsed.data) : void 0;
198
199
  }
199
200
 
201
+ // src/chat/conversations/sql/bindings.ts
202
+ import { and as and2, eq as eq2 } from "drizzle-orm";
203
+ async function getConversationIdByProviderConversation(executor, args) {
204
+ const rows = await executor.db().select({ conversationId: juniorConversationBindings.conversationId }).from(juniorConversationBindings).where(
205
+ and2(
206
+ eq2(juniorConversationBindings.provider, args.provider),
207
+ eq2(juniorConversationBindings.providerTenantId, args.providerTenantId),
208
+ eq2(
209
+ juniorConversationBindings.providerDestinationId,
210
+ args.providerDestinationId
211
+ ),
212
+ eq2(
213
+ juniorConversationBindings.providerConversationId,
214
+ args.providerConversationId
215
+ )
216
+ )
217
+ ).limit(1);
218
+ return rows[0]?.conversationId;
219
+ }
220
+ async function bindProviderConversation(executor, args) {
221
+ const rows = await executor.db().insert(juniorConversationBindings).values({ ...args, createdAt: /* @__PURE__ */ new Date() }).onConflictDoNothing().returning({ conversationId: juniorConversationBindings.conversationId });
222
+ const boundConversationId = rows[0]?.conversationId ?? await getConversationIdByProviderConversation(executor, args);
223
+ if (boundConversationId !== args.conversationId) {
224
+ throw new Error(
225
+ "Provider conversation is already bound to another conversation"
226
+ );
227
+ }
228
+ }
229
+
230
+ // src/chat/conversations/location.ts
231
+ import { nonBlankStringSchema } from "@sentry/junior-plugin-api";
232
+ import { z } from "zod";
233
+ var locationSchema = z.object({
234
+ /** Junior-owned stable identity for this location. */
235
+ id: nonBlankStringSchema,
236
+ /** Provider namespace that owns the provider and tenant identifiers. */
237
+ provider: nonBlankStringSchema,
238
+ /** Optional provider-native workspace, account, or tenant scope. */
239
+ tenantId: nonBlankStringSchema.optional(),
240
+ /** Provider-native identifier for the container within its tenant scope. */
241
+ providerId: nonBlankStringSchema
242
+ }).strict();
243
+
244
+ // src/chat/conversations/sql/location.ts
245
+ function locationFromRow(row) {
246
+ if (!row || row.provider === "local") {
247
+ return void 0;
248
+ }
249
+ return locationSchema.parse({
250
+ id: row.id,
251
+ provider: row.provider,
252
+ ...row.providerTenantId ? { tenantId: row.providerTenantId } : {},
253
+ providerId: row.providerDestinationId
254
+ });
255
+ }
256
+ function privacyFromLocationRow(row) {
257
+ if (!row) {
258
+ return void 0;
259
+ }
260
+ return row.visibility === "public" ? "public" : "private";
261
+ }
262
+
200
263
  // src/chat/conversations/sql/store.ts
201
264
  var CONVERSATION_MUTATION_LOCK_PREFIX = "junior_conversation";
202
265
  function now() {
@@ -315,12 +378,6 @@ function executionStatusFromValue(value) {
315
378
  }
316
379
  throw new Error("Conversation record execution status is invalid");
317
380
  }
318
- function privacyFromRow(row) {
319
- if (row.destination === null) {
320
- return void 0;
321
- }
322
- return row.destination.visibility === "public" ? "public" : "private";
323
- }
324
381
  function actorFromIdentityRow(identity, userDisplayName) {
325
382
  if (!identity) {
326
383
  return void 0;
@@ -351,7 +408,7 @@ function destinationFromRow(destination) {
351
408
  }
352
409
  function conversationFromRow(readRow) {
353
410
  const row = readRow.conversation;
354
- const visibility = privacyFromRow(readRow);
411
+ const visibility = privacyFromLocationRow(readRow.destination);
355
412
  if (row.schemaVersion !== 1) {
356
413
  throw new Error("Conversation record schema version is invalid");
357
414
  }
@@ -384,6 +441,7 @@ function conversationFromRow(readRow) {
384
441
  ...row.runId ? { runId: row.runId } : {},
385
442
  updatedAtMs: msFromDate(row.executionUpdatedAt) ?? requiredMsFromDate(row.updatedAt)
386
443
  };
444
+ const location = locationFromRow(readRow.destination);
387
445
  return {
388
446
  schemaVersion: 1,
389
447
  conversationId: row.conversationId,
@@ -397,6 +455,7 @@ function conversationFromRow(readRow) {
397
455
  }
398
456
  } : {},
399
457
  ...destination ? { destination } : {},
458
+ ...location ? { location } : {},
400
459
  ...actor ? { actor } : {},
401
460
  ...msFromDate(row.archivedAt) !== void 0 ? { archivedAtMs: msFromDate(row.archivedAt) } : {},
402
461
  ...row.channelName ? { channelName: row.channelName } : {},
@@ -487,6 +546,12 @@ var SqlStore = class {
487
546
  this.executor = executor;
488
547
  }
489
548
  executor;
549
+ async getConversationIdByProviderConversation(args) {
550
+ return await getConversationIdByProviderConversation(this.executor, args);
551
+ }
552
+ async bindProviderConversation(args) {
553
+ await bindProviderConversation(this.executor, args);
554
+ }
490
555
  async get(args) {
491
556
  const row = await this.readConversationRow(args.conversationId);
492
557
  if (!row) {
@@ -580,7 +645,7 @@ var SqlStore = class {
580
645
  metricRunId: args.execution.runId ?? null,
581
646
  executionDurationMs: args.metrics.durationMs,
582
647
  executionUsage: args.metrics.usage ?? (sameRun ? row?.executionUsage ?? null : null)
583
- }).where(eq2(juniorConversations.conversationId, args.conversationId));
648
+ }).where(eq3(juniorConversations.conversationId, args.conversationId));
584
649
  }
585
650
  });
586
651
  }
@@ -592,11 +657,11 @@ var SqlStore = class {
592
657
  actorUserDisplayName: juniorUsers.displayName
593
658
  }).from(juniorConversations).leftJoin(
594
659
  juniorDestinations,
595
- eq2(juniorDestinations.id, juniorConversations.destinationId)
660
+ eq3(juniorDestinations.id, juniorConversations.destinationId)
596
661
  ).leftJoin(
597
662
  juniorIdentities,
598
- eq2(juniorIdentities.id, juniorConversations.actorIdentityId)
599
- ).leftJoin(juniorUsers, eq2(juniorUsers.id, juniorIdentities.userId)).where(isNull(juniorConversations.parentConversationId)).orderBy(
663
+ eq3(juniorIdentities.id, juniorConversations.actorIdentityId)
664
+ ).leftJoin(juniorUsers, eq3(juniorUsers.id, juniorIdentities.userId)).where(isNull(juniorConversations.parentConversationId)).orderBy(
600
665
  desc(juniorConversations.lastActivityAt),
601
666
  asc(juniorConversations.conversationId)
602
667
  ).limit(Math.max(0, args.limit ?? 1e4)).offset(Math.max(0, args.offset ?? 0));
@@ -610,13 +675,13 @@ var SqlStore = class {
610
675
  const rows = await this.executor.db().select({
611
676
  visibility: juniorDestinations.visibility
612
677
  }).from(juniorDestinations).where(
613
- and2(
614
- eq2(juniorDestinations.provider, args.provider),
615
- eq2(
678
+ and3(
679
+ eq3(juniorDestinations.provider, args.provider),
680
+ eq3(
616
681
  juniorDestinations.providerTenantId,
617
682
  tenantId2(args.providerTenantId)
618
683
  ),
619
- eq2(
684
+ eq3(
620
685
  juniorDestinations.providerDestinationId,
621
686
  args.providerDestinationId
622
687
  )
@@ -646,11 +711,11 @@ var SqlStore = class {
646
711
  actorUserDisplayName: juniorUsers.displayName
647
712
  }).from(juniorConversations).leftJoin(
648
713
  juniorDestinations,
649
- eq2(juniorDestinations.id, juniorConversations.destinationId)
714
+ eq3(juniorDestinations.id, juniorConversations.destinationId)
650
715
  ).leftJoin(
651
716
  juniorIdentities,
652
- eq2(juniorIdentities.id, juniorConversations.actorIdentityId)
653
- ).leftJoin(juniorUsers, eq2(juniorUsers.id, juniorIdentities.userId)).where(eq2(juniorConversations.conversationId, conversationId));
717
+ eq3(juniorIdentities.id, juniorConversations.actorIdentityId)
718
+ ).leftJoin(juniorUsers, eq3(juniorUsers.id, juniorIdentities.userId)).where(eq3(juniorConversations.conversationId, conversationId));
654
719
  return rows[0];
655
720
  }
656
721
  /** Upsert the conversation row while preserving previously discovered nullable metadata fields. */
@@ -779,10 +844,10 @@ function createSqlStore(executor) {
779
844
 
780
845
  // src/chat/conversations/sql/history.ts
781
846
  import {
782
- and as and3,
847
+ and as and4,
783
848
  asc as asc2,
784
849
  desc as desc2,
785
- eq as eq3,
850
+ eq as eq4,
786
851
  gt,
787
852
  gte,
788
853
  inArray,
@@ -793,16 +858,16 @@ import {
793
858
  } from "drizzle-orm";
794
859
 
795
860
  // src/chat/conversations/history.ts
796
- import { z as z2 } from "zod";
861
+ import { z as z3 } from "zod";
797
862
 
798
863
  // src/chat/conversations/provenance.ts
799
864
  import { actorSchema } from "@sentry/junior-plugin-api";
800
- import { z } from "zod";
801
- var conversationMessageAuthoritySchema = z.union([
802
- z.literal("instruction"),
803
- z.literal("context")
865
+ import { z as z2 } from "zod";
866
+ var conversationMessageAuthoritySchema = z2.union([
867
+ z2.literal("instruction"),
868
+ z2.literal("context")
804
869
  ]);
805
- var conversationMessageProvenanceSchema = z.object({
870
+ var conversationMessageProvenanceSchema = z2.object({
806
871
  authority: conversationMessageAuthoritySchema,
807
872
  actor: actorSchema.optional()
808
873
  }).strict();
@@ -845,214 +910,214 @@ var handoffModelProfileSchema = modelProfileSchema.refine(
845
910
  (profile) => profile !== "standard",
846
911
  "handoff profile must not be standard"
847
912
  );
848
- var userMessageEventDataSchema = z2.object({
849
- type: z2.literal("user_message"),
850
- role: z2.never().optional(),
913
+ var userMessageEventDataSchema = z3.object({
914
+ type: z3.literal("user_message"),
915
+ role: z3.never().optional(),
851
916
  provenance: conversationMessageProvenanceSchema
852
917
  }).passthrough();
853
- var assistantMessageEventDataSchema = z2.object({
854
- type: z2.literal("assistant_message"),
855
- role: z2.never().optional()
918
+ var assistantMessageEventDataSchema = z3.object({
919
+ type: z3.literal("assistant_message"),
920
+ role: z3.never().optional()
856
921
  }).passthrough();
857
- var toolResultEventDataSchema = z2.object({
858
- type: z2.literal("tool_result"),
859
- role: z2.never().optional()
922
+ var toolResultEventDataSchema = z3.object({
923
+ type: z3.literal("tool_result"),
924
+ role: z3.never().optional()
860
925
  }).passthrough();
861
- var agentHistoryItemSchema = z2.discriminatedUnion("type", [
926
+ var agentHistoryItemSchema = z3.discriminatedUnion("type", [
862
927
  userMessageEventDataSchema,
863
928
  assistantMessageEventDataSchema,
864
929
  toolResultEventDataSchema
865
930
  ]);
866
- var nativeReplacementHistoryItemSchema = z2.object({
931
+ var nativeReplacementHistoryItemSchema = z3.object({
867
932
  item: agentHistoryItemSchema,
868
933
  // Preserve the copied item's position when a turn resumes. Synthetic
869
934
  // summary and handoff items have no source event.
870
- sourceEventSeq: z2.number().int().nonnegative().optional()
935
+ sourceEventSeq: z3.number().int().nonnegative().optional()
871
936
  }).strict();
872
- var replacementHistorySchema = z2.array(nativeReplacementHistoryItemSchema);
873
- var compactionDetailsSchema = z2.object({
874
- reason: z2.literal("capacity"),
875
- estimatedInputTokens: z2.number().int().nonnegative(),
876
- replacementInputTokens: z2.number().int().nonnegative().optional(),
877
- triggerTokens: z2.number().int().nonnegative(),
878
- inputLimitTokens: z2.number().int().positive(),
879
- inputMessageCount: z2.number().int().nonnegative(),
880
- retainedMessageCount: z2.number().int().nonnegative(),
881
- summaryChars: z2.number().int().nonnegative()
937
+ var replacementHistorySchema = z3.array(nativeReplacementHistoryItemSchema);
938
+ var compactionDetailsSchema = z3.object({
939
+ reason: z3.literal("capacity"),
940
+ estimatedInputTokens: z3.number().int().nonnegative(),
941
+ replacementInputTokens: z3.number().int().nonnegative().optional(),
942
+ triggerTokens: z3.number().int().nonnegative(),
943
+ inputLimitTokens: z3.number().int().positive(),
944
+ inputMessageCount: z3.number().int().nonnegative(),
945
+ retainedMessageCount: z3.number().int().nonnegative(),
946
+ summaryChars: z3.number().int().nonnegative()
882
947
  }).strict();
883
- var historyReplacementEventDataSchema = z2.discriminatedUnion("type", [
884
- z2.object({
885
- type: z2.literal("handoff"),
948
+ var historyReplacementEventDataSchema = z3.discriminatedUnion("type", [
949
+ z3.object({
950
+ type: z3.literal("handoff"),
886
951
  modelProfile: handoffModelProfileSchema,
887
- modelId: z2.string().min(1),
888
- reasoningLevel: z2.string().min(1).optional(),
889
- triggeringToolCallId: z2.string().min(1).optional(),
890
- summary: z2.string().min(1).optional(),
952
+ modelId: z3.string().min(1),
953
+ reasoningLevel: z3.string().min(1).optional(),
954
+ triggeringToolCallId: z3.string().min(1).optional(),
955
+ summary: z3.string().min(1).optional(),
891
956
  replacementHistory: replacementHistorySchema
892
957
  }).strict(),
893
- z2.object({
894
- type: z2.literal("compaction"),
958
+ z3.object({
959
+ type: z3.literal("compaction"),
895
960
  modelProfile: modelProfileSchema,
896
- modelId: z2.string().min(1),
961
+ modelId: z3.string().min(1),
897
962
  details: compactionDetailsSchema.optional(),
898
- summary: z2.string().min(1).optional(),
963
+ summary: z3.string().min(1).optional(),
899
964
  replacementHistory: replacementHistorySchema
900
965
  }).strict()
901
966
  ]);
902
- var historyReplacementSchema = z2.object({
967
+ var historyReplacementSchema = z3.object({
903
968
  data: historyReplacementEventDataSchema,
904
- createdAtMs: z2.number().finite()
969
+ createdAtMs: z3.number().finite()
905
970
  }).strict();
906
- var mcpProviderConnectedEventDataSchema = z2.object({
907
- type: z2.literal("mcp_provider_connected"),
908
- provider: z2.string().min(1)
971
+ var mcpProviderConnectedEventDataSchema = z3.object({
972
+ type: z3.literal("mcp_provider_connected"),
973
+ provider: z3.string().min(1)
909
974
  }).strict();
910
- var authorizationKindSchema = z2.union([
911
- z2.literal("plugin"),
912
- z2.literal("mcp")
975
+ var authorizationKindSchema = z3.union([
976
+ z3.literal("plugin"),
977
+ z3.literal("mcp")
913
978
  ]);
914
- var authorizationRequestedEventDataSchema = z2.object({
915
- type: z2.literal("authorization_requested"),
979
+ var authorizationRequestedEventDataSchema = z3.object({
980
+ type: z3.literal("authorization_requested"),
916
981
  kind: authorizationKindSchema,
917
- provider: z2.string().min(1),
918
- actorId: z2.string().min(1),
919
- authorizationId: z2.string().min(1),
920
- delivery: z2.union([
921
- z2.literal("private_link_sent"),
922
- z2.literal("private_link_reused")
982
+ provider: z3.string().min(1),
983
+ actorId: z3.string().min(1),
984
+ authorizationId: z3.string().min(1),
985
+ delivery: z3.union([
986
+ z3.literal("private_link_sent"),
987
+ z3.literal("private_link_reused")
923
988
  ])
924
989
  }).strict();
925
- var authorizationCompletedEventDataSchema = z2.object({
926
- type: z2.literal("authorization_completed"),
990
+ var authorizationCompletedEventDataSchema = z3.object({
991
+ type: z3.literal("authorization_completed"),
927
992
  kind: authorizationKindSchema,
928
- provider: z2.string().min(1),
929
- actorId: z2.string().min(1),
930
- authorizationId: z2.string().min(1)
993
+ provider: z3.string().min(1),
994
+ actorId: z3.string().min(1),
995
+ authorizationId: z3.string().min(1)
931
996
  }).strict();
932
- var toolExecutionStartedEventDataSchema = z2.object({
933
- type: z2.literal("tool_execution_started"),
934
- toolCallId: z2.string().min(1),
935
- toolName: z2.string().min(1)
997
+ var toolExecutionStartedEventDataSchema = z3.object({
998
+ type: z3.literal("tool_execution_started"),
999
+ toolCallId: z3.string().min(1),
1000
+ toolName: z3.string().min(1)
936
1001
  }).strict();
937
- var guardianActionReviewedEventDataSchema = z2.object({
938
- type: z2.literal("guardian_action_reviewed"),
939
- turnId: z2.string().min(1),
940
- toolCallId: z2.string().min(1),
941
- toolName: z2.string().min(1),
942
- costUsd: z2.number().finite().nonnegative().optional(),
943
- decision: z2.enum(["allow", "ask", "deny"]),
944
- riskLevel: z2.enum(["low", "medium", "high", "critical"]),
945
- userAuthorization: z2.enum(["high", "medium", "low", "unknown"])
1002
+ var guardianActionReviewedEventDataSchema = z3.object({
1003
+ type: z3.literal("guardian_action_reviewed"),
1004
+ turnId: z3.string().min(1),
1005
+ toolCallId: z3.string().min(1),
1006
+ toolName: z3.string().min(1),
1007
+ costUsd: z3.number().finite().nonnegative().optional(),
1008
+ decision: z3.enum(["allow", "ask", "deny"]),
1009
+ riskLevel: z3.enum(["low", "medium", "high", "critical"]),
1010
+ userAuthorization: z3.enum(["high", "medium", "low", "unknown"])
946
1011
  }).strict();
947
- var conversationMessageRoleSchema = z2.union([
948
- z2.literal("user"),
949
- z2.literal("assistant"),
950
- z2.literal("system")
1012
+ var conversationMessageRoleSchema = z3.union([
1013
+ z3.literal("user"),
1014
+ z3.literal("assistant"),
1015
+ z3.literal("system")
951
1016
  ]);
952
- var messageEventDataSchema = z2.object({
953
- type: z2.literal("message"),
954
- messageId: z2.string().min(1),
1017
+ var messageEventDataSchema = z3.object({
1018
+ type: z3.literal("message"),
1019
+ messageId: z3.string().min(1),
955
1020
  role: conversationMessageRoleSchema,
956
- text: z2.string(),
957
- authorIdentityId: z2.string().min(1).optional(),
958
- meta: z2.record(z2.string(), z2.unknown()).optional()
1021
+ text: z3.string(),
1022
+ authorIdentityId: z3.string().min(1).optional(),
1023
+ meta: z3.record(z3.string(), z3.unknown()).optional()
959
1024
  }).strict();
960
1025
  var messageUpdatedEventDataSchema = messageEventDataSchema.extend({
961
- type: z2.literal("message_updated")
1026
+ type: z3.literal("message_updated")
962
1027
  });
963
- var messageHandledEventDataSchema = z2.object({
964
- type: z2.literal("message_handled"),
965
- messageId: z2.string().min(1)
1028
+ var messageHandledEventDataSchema = z3.object({
1029
+ type: z3.literal("message_handled"),
1030
+ messageId: z3.string().min(1)
966
1031
  }).strict();
967
- var messagesSummarizedEventDataSchema = z2.object({
968
- type: z2.literal("messages_summarized"),
969
- historyFromSeq: z2.number().int().nonnegative(),
970
- compactions: z2.array(
971
- z2.object({
972
- coveredMessageCount: z2.number().int().nonnegative(),
973
- createdAtMs: z2.number(),
974
- id: z2.string().min(1),
975
- summary: z2.string()
1032
+ var messagesSummarizedEventDataSchema = z3.object({
1033
+ type: z3.literal("messages_summarized"),
1034
+ historyFromSeq: z3.number().int().nonnegative(),
1035
+ compactions: z3.array(
1036
+ z3.object({
1037
+ coveredMessageCount: z3.number().int().nonnegative(),
1038
+ createdAtMs: z3.number(),
1039
+ id: z3.string().min(1),
1040
+ summary: z3.string()
976
1041
  }).strict()
977
1042
  )
978
1043
  }).strict();
979
- var conversationTurnSurfaceSchema = z2.enum([
1044
+ var conversationTurnSurfaceSchema = z3.enum([
980
1045
  "slack",
981
1046
  "api",
982
1047
  "scheduler",
983
1048
  "internal"
984
1049
  ]);
985
- var conversationTurnFailureCodeSchema = z2.enum([
1050
+ var conversationTurnFailureCodeSchema = z3.enum([
986
1051
  "agent_run_failed",
987
1052
  "delivery_failed",
988
1053
  "model_execution_failed",
989
1054
  "persistence_failed"
990
1055
  ]);
991
- var turnStartedEventDataSchema = z2.object({
992
- type: z2.literal("turn_started"),
993
- turnId: z2.string().min(1),
994
- inputMessageIds: z2.array(z2.string().min(1)).min(1),
1056
+ var turnStartedEventDataSchema = z3.object({
1057
+ type: z3.literal("turn_started"),
1058
+ turnId: z3.string().min(1),
1059
+ inputMessageIds: z3.array(z3.string().min(1)).min(1),
995
1060
  surface: conversationTurnSurfaceSchema
996
1061
  }).strict().refine(
997
1062
  (data) => new Set(data.inputMessageIds).size === data.inputMessageIds.length,
998
1063
  "turn input message ids must be unique"
999
1064
  );
1000
- var turnRoutedEventDataSchema = z2.object({
1001
- type: z2.literal("turn_routed"),
1002
- turnId: z2.string().min(1),
1065
+ var turnRoutedEventDataSchema = z3.object({
1066
+ type: z3.literal("turn_routed"),
1067
+ turnId: z3.string().min(1),
1003
1068
  modelProfile: modelProfileSchema,
1004
- modelId: z2.string().min(1),
1005
- reasoningLevel: z2.enum(TURN_REASONING_LEVELS),
1006
- confidence: z2.number().min(0).max(1).optional(),
1007
- source: z2.enum(["configured", "inherited", "router"])
1069
+ modelId: z3.string().min(1),
1070
+ reasoningLevel: z3.enum(TURN_REASONING_LEVELS),
1071
+ confidence: z3.number().min(0).max(1).optional(),
1072
+ source: z3.enum(["configured", "inherited", "router"])
1008
1073
  }).strict();
1009
- var turnContextEventDataSchema = z2.object({
1010
- type: z2.literal("turn_context"),
1011
- turnId: z2.string().min(1),
1012
- pluginName: z2.string().min(1),
1013
- kind: z2.string().min(1).max(64),
1014
- version: z2.number().int().positive(),
1015
- content: z2.record(z2.string(), z2.unknown())
1074
+ var turnContextEventDataSchema = z3.object({
1075
+ type: z3.literal("turn_context"),
1076
+ turnId: z3.string().min(1),
1077
+ pluginName: z3.string().min(1),
1078
+ kind: z3.string().min(1).max(64),
1079
+ version: z3.number().int().positive(),
1080
+ content: z3.record(z3.string(), z3.unknown())
1016
1081
  }).strict();
1017
- var structuredConversationEventDataSchema = z2.object({
1018
- type: z2.literal("structured_event"),
1019
- namespace: z2.string().regex(/^[a-z][a-z0-9-]*$/),
1020
- name: z2.string().regex(/^[a-z][a-z0-9_]*$/),
1021
- version: z2.number().int().positive(),
1022
- turnId: z2.string().min(1).optional(),
1023
- content: z2.record(z2.string(), z2.unknown())
1082
+ var structuredConversationEventDataSchema = z3.object({
1083
+ type: z3.literal("structured_event"),
1084
+ namespace: z3.string().regex(/^[a-z][a-z0-9-]*$/),
1085
+ name: z3.string().regex(/^[a-z][a-z0-9_]*$/),
1086
+ version: z3.number().int().positive(),
1087
+ turnId: z3.string().min(1).optional(),
1088
+ content: z3.record(z3.string(), z3.unknown())
1024
1089
  }).strict();
1025
- var turnCompletedEventDataSchema = z2.object({
1026
- type: z2.literal("turn_completed"),
1027
- turnId: z2.string().min(1),
1028
- outcome: z2.enum(["success", "no_reply"])
1090
+ var turnCompletedEventDataSchema = z3.object({
1091
+ type: z3.literal("turn_completed"),
1092
+ turnId: z3.string().min(1),
1093
+ outcome: z3.enum(["success", "no_reply"])
1029
1094
  }).strict();
1030
- var turnFailedEventDataSchema = z2.object({
1031
- type: z2.literal("turn_failed"),
1032
- turnId: z2.string().min(1),
1095
+ var turnFailedEventDataSchema = z3.object({
1096
+ type: z3.literal("turn_failed"),
1097
+ turnId: z3.string().min(1),
1033
1098
  failureCode: conversationTurnFailureCodeSchema,
1034
- eventId: z2.string().regex(/^[a-f0-9]{32}$/i).optional()
1099
+ eventId: z3.string().regex(/^[a-f0-9]{32}$/i).optional()
1035
1100
  }).strict();
1036
- var subagentStartedEventDataSchema = z2.object({
1037
- type: z2.literal("subagent_started"),
1038
- subagentInvocationId: z2.string().min(1),
1039
- subagentKind: z2.string().min(1),
1040
- modelId: z2.string().min(1).optional(),
1041
- parentToolCallId: z2.string().min(1).optional(),
1042
- reasoningLevel: z2.string().min(1).optional(),
1043
- childConversationId: z2.string().min(1)
1101
+ var subagentStartedEventDataSchema = z3.object({
1102
+ type: z3.literal("subagent_started"),
1103
+ subagentInvocationId: z3.string().min(1),
1104
+ subagentKind: z3.string().min(1),
1105
+ modelId: z3.string().min(1).optional(),
1106
+ parentToolCallId: z3.string().min(1).optional(),
1107
+ reasoningLevel: z3.string().min(1).optional(),
1108
+ childConversationId: z3.string().min(1)
1044
1109
  }).strict();
1045
- var subagentEndedEventDataSchema = z2.object({
1046
- type: z2.literal("subagent_ended"),
1047
- subagentInvocationId: z2.string().min(1),
1048
- outcome: z2.union([
1049
- z2.literal("success"),
1050
- z2.literal("error"),
1051
- z2.literal("aborted")
1110
+ var subagentEndedEventDataSchema = z3.object({
1111
+ type: z3.literal("subagent_ended"),
1112
+ subagentInvocationId: z3.string().min(1),
1113
+ outcome: z3.union([
1114
+ z3.literal("success"),
1115
+ z3.literal("error"),
1116
+ z3.literal("aborted")
1052
1117
  ]),
1053
- errorCode: z2.string().min(1).optional()
1118
+ errorCode: z3.string().min(1).optional()
1054
1119
  }).strict();
1055
- var appendableConversationEventDataSchema = z2.union([
1120
+ var appendableConversationEventDataSchema = z3.union([
1056
1121
  messageEventDataSchema,
1057
1122
  messageUpdatedEventDataSchema,
1058
1123
  agentHistoryItemSchema,
@@ -1072,7 +1137,7 @@ var appendableConversationEventDataSchema = z2.union([
1072
1137
  subagentStartedEventDataSchema,
1073
1138
  subagentEndedEventDataSchema
1074
1139
  ]);
1075
- var conversationEventDataSchema = z2.union([
1140
+ var conversationEventDataSchema = z3.union([
1076
1141
  appendableConversationEventDataSchema,
1077
1142
  historyReplacementEventDataSchema
1078
1143
  ]);
@@ -1100,22 +1165,22 @@ var KNOWN_CONVERSATION_EVENT_TYPES = [
1100
1165
  "handoff",
1101
1166
  "compaction"
1102
1167
  ];
1103
- var knownConversationEventTypeSchema = z2.enum(KNOWN_CONVERSATION_EVENT_TYPES);
1104
- var unknownConversationEventDataSchema = z2.object({
1105
- type: z2.literal("unknown"),
1106
- originalType: z2.string().min(1),
1107
- payload: z2.unknown()
1168
+ var knownConversationEventTypeSchema = z3.enum(KNOWN_CONVERSATION_EVENT_TYPES);
1169
+ var unknownConversationEventDataSchema = z3.object({
1170
+ type: z3.literal("unknown"),
1171
+ originalType: z3.string().min(1),
1172
+ payload: z3.unknown()
1108
1173
  }).strict();
1109
- var conversationEventEnvelopeSchema = z2.object({
1110
- schemaVersion: z2.number().int().nonnegative(),
1111
- seq: z2.number().int().nonnegative(),
1112
- historyVersion: z2.number().int().nonnegative(),
1113
- idempotencyKey: z2.string().min(1).optional(),
1114
- createdAtMs: z2.number().finite()
1174
+ var conversationEventEnvelopeSchema = z3.object({
1175
+ schemaVersion: z3.number().int().nonnegative(),
1176
+ seq: z3.number().int().nonnegative(),
1177
+ historyVersion: z3.number().int().nonnegative(),
1178
+ idempotencyKey: z3.string().min(1).optional(),
1179
+ createdAtMs: z3.number().finite()
1115
1180
  }).strict();
1116
- var conversationEventSchema = z2.union([
1181
+ var conversationEventSchema = z3.union([
1117
1182
  conversationEventEnvelopeSchema.extend({
1118
- schemaVersion: z2.literal(1),
1183
+ schemaVersion: z3.literal(1),
1119
1184
  data: conversationEventDataSchema
1120
1185
  }),
1121
1186
  conversationEventEnvelopeSchema.extend({
@@ -1123,8 +1188,8 @@ var conversationEventSchema = z2.union([
1123
1188
  })
1124
1189
  ]);
1125
1190
  var storedConversationEventSchema = conversationEventEnvelopeSchema.extend({
1126
- type: z2.string().min(1),
1127
- payload: z2.unknown()
1191
+ type: z3.string().min(1),
1192
+ payload: z3.unknown()
1128
1193
  });
1129
1194
  function decodeStoredConversationEvent(value) {
1130
1195
  const stored = storedConversationEventSchema.parse(value);
@@ -1139,10 +1204,10 @@ function decodeStoredConversationEvent(value) {
1139
1204
  data: { type: "unknown", originalType: type, payload }
1140
1205
  });
1141
1206
  }
1142
- var newConversationEventSchema = z2.object({
1207
+ var newConversationEventSchema = z3.object({
1143
1208
  data: appendableConversationEventDataSchema,
1144
- idempotencyKey: z2.string().min(1).optional(),
1145
- createdAtMs: z2.number().finite()
1209
+ idempotencyKey: z3.string().min(1).optional(),
1210
+ createdAtMs: z3.number().finite()
1146
1211
  }).strict();
1147
1212
 
1148
1213
  // src/chat/conversations/sql/conversation-row.ts
@@ -1258,8 +1323,8 @@ var SqlConversationEventStore = class {
1258
1323
  const existingKeys = parsed.map((event) => event.idempotencyKey).filter((key) => key !== void 0);
1259
1324
  const persistedKeys = existingKeys.length === 0 ? /* @__PURE__ */ new Set() : new Set(
1260
1325
  (await this.executor.db().select({ key: juniorConversationEvents.idempotencyKey }).from(juniorConversationEvents).where(
1261
- and3(
1262
- eq3(
1326
+ and4(
1327
+ eq4(
1263
1328
  juniorConversationEvents.conversationId,
1264
1329
  conversationId
1265
1330
  ),
@@ -1291,8 +1356,8 @@ var SqlConversationEventStore = class {
1291
1356
  );
1292
1357
  if (options.activity !== "preserve") {
1293
1358
  await this.executor.db().update(juniorConversations).set({ archivedAt: null }).where(
1294
- and3(
1295
- eq3(juniorConversations.conversationId, conversationId),
1359
+ and4(
1360
+ eq4(juniorConversations.conversationId, conversationId),
1296
1361
  isNotNull(juniorConversations.archivedAt)
1297
1362
  )
1298
1363
  );
@@ -1311,8 +1376,8 @@ var SqlConversationEventStore = class {
1311
1376
  await withConversationEventLock(this.executor, conversationId, async () => {
1312
1377
  await ensureConversationRow(this.executor, conversationId, Date.now());
1313
1378
  await this.executor.db().update(juniorConversations).set({ archivedAt: null }).where(
1314
- and3(
1315
- eq3(juniorConversations.conversationId, conversationId),
1379
+ and4(
1380
+ eq4(juniorConversations.conversationId, conversationId),
1316
1381
  isNotNull(juniorConversations.archivedAt)
1317
1382
  )
1318
1383
  );
@@ -1334,34 +1399,34 @@ var SqlConversationEventStore = class {
1334
1399
  return [];
1335
1400
  }
1336
1401
  const rows = await this.executor.db().select().from(juniorConversationEvents).where(
1337
- and3(
1338
- eq3(juniorConversationEvents.conversationId, conversationId),
1339
- eq3(juniorConversationEvents.historyVersion, cursor.maxHistoryVersion)
1402
+ and4(
1403
+ eq4(juniorConversationEvents.conversationId, conversationId),
1404
+ eq4(juniorConversationEvents.historyVersion, cursor.maxHistoryVersion)
1340
1405
  )
1341
1406
  ).orderBy(asc2(juniorConversationEvents.seq));
1342
1407
  return rows.map(eventFromRow);
1343
1408
  }
1344
1409
  async loadByIdempotencyKey(conversationId, idempotencyKey) {
1345
1410
  const [row] = await this.executor.db().select().from(juniorConversationEvents).where(
1346
- and3(
1347
- eq3(juniorConversationEvents.conversationId, conversationId),
1348
- eq3(juniorConversationEvents.idempotencyKey, idempotencyKey)
1411
+ and4(
1412
+ eq4(juniorConversationEvents.conversationId, conversationId),
1413
+ eq4(juniorConversationEvents.idempotencyKey, idempotencyKey)
1349
1414
  )
1350
1415
  ).limit(1);
1351
1416
  return row ? eventFromRow(row) : void 0;
1352
1417
  }
1353
1418
  async loadHistoryContaining(conversationId, seq, throughSeq) {
1354
1419
  const [boundary] = await this.executor.db().select({ historyVersion: juniorConversationEvents.historyVersion }).from(juniorConversationEvents).where(
1355
- and3(
1356
- eq3(juniorConversationEvents.conversationId, conversationId),
1357
- eq3(juniorConversationEvents.seq, seq)
1420
+ and4(
1421
+ eq4(juniorConversationEvents.conversationId, conversationId),
1422
+ eq4(juniorConversationEvents.seq, seq)
1358
1423
  )
1359
1424
  ).limit(1);
1360
1425
  if (!boundary) return void 0;
1361
1426
  const rows = await this.executor.db().select().from(juniorConversationEvents).where(
1362
- and3(
1363
- eq3(juniorConversationEvents.conversationId, conversationId),
1364
- eq3(juniorConversationEvents.historyVersion, boundary.historyVersion),
1427
+ and4(
1428
+ eq4(juniorConversationEvents.conversationId, conversationId),
1429
+ eq4(juniorConversationEvents.historyVersion, boundary.historyVersion),
1365
1430
  throughSeq === void 0 ? void 0 : lte(juniorConversationEvents.seq, throughSeq)
1366
1431
  )
1367
1432
  ).orderBy(asc2(juniorConversationEvents.seq));
@@ -1369,9 +1434,9 @@ var SqlConversationEventStore = class {
1369
1434
  }
1370
1435
  async loadLatestInstruction(conversationId) {
1371
1436
  const [row] = await this.executor.db().select().from(juniorConversationEvents).where(
1372
- and3(
1373
- eq3(juniorConversationEvents.conversationId, conversationId),
1374
- eq3(juniorConversationEvents.type, "user_message"),
1437
+ and4(
1438
+ eq4(juniorConversationEvents.conversationId, conversationId),
1439
+ eq4(juniorConversationEvents.type, "user_message"),
1375
1440
  sql4`${juniorConversationEvents.payload}->'provenance'->>'authority' = 'instruction'`
1376
1441
  )
1377
1442
  ).orderBy(desc2(juniorConversationEvents.seq)).limit(1);
@@ -1379,16 +1444,16 @@ var SqlConversationEventStore = class {
1379
1444
  }
1380
1445
  async loadMessageHistory(conversationId) {
1381
1446
  const [compactionRow] = await this.executor.db().select().from(juniorConversationEvents).where(
1382
- and3(
1383
- eq3(juniorConversationEvents.conversationId, conversationId),
1384
- eq3(juniorConversationEvents.type, "messages_summarized")
1447
+ and4(
1448
+ eq4(juniorConversationEvents.conversationId, conversationId),
1449
+ eq4(juniorConversationEvents.type, "messages_summarized")
1385
1450
  )
1386
1451
  ).orderBy(desc2(juniorConversationEvents.seq)).limit(1);
1387
1452
  const compaction = compactionRow ? messagesSummarizedEventFromRow(compactionRow) : void 0;
1388
1453
  const historyFromSeq = compaction?.data.historyFromSeq ?? 0;
1389
1454
  const rows = await this.executor.db().select().from(juniorConversationEvents).where(
1390
- and3(
1391
- eq3(juniorConversationEvents.conversationId, conversationId),
1455
+ and4(
1456
+ eq4(juniorConversationEvents.conversationId, conversationId),
1392
1457
  inArray(juniorConversationEvents.type, messageHistoryEventTypes),
1393
1458
  gte(juniorConversationEvents.seq, historyFromSeq)
1394
1459
  )
@@ -1396,7 +1461,7 @@ var SqlConversationEventStore = class {
1396
1461
  return { events: rows.map(eventFromRow), compaction, historyFromSeq };
1397
1462
  }
1398
1463
  async loadHistory(conversationId) {
1399
- const rows = await this.executor.db().select().from(juniorConversationEvents).where(eq3(juniorConversationEvents.conversationId, conversationId)).orderBy(asc2(juniorConversationEvents.seq));
1464
+ const rows = await this.executor.db().select().from(juniorConversationEvents).where(eq4(juniorConversationEvents.conversationId, conversationId)).orderBy(asc2(juniorConversationEvents.seq));
1400
1465
  return rows.map(eventFromRow);
1401
1466
  }
1402
1467
  async query(conversationId, query) {
@@ -1407,8 +1472,8 @@ var SqlConversationEventStore = class {
1407
1472
  return { events: [], hasOlder: false, hasNewer: false };
1408
1473
  }
1409
1474
  const typeFilter = query.types && query.types.length > 0 ? inArray(juniorConversationEvents.type, [...query.types]) : void 0;
1410
- const bounds = and3(
1411
- eq3(juniorConversationEvents.conversationId, conversationId),
1475
+ const bounds = and4(
1476
+ eq4(juniorConversationEvents.conversationId, conversationId),
1412
1477
  query.afterSeq === void 0 ? void 0 : gt(juniorConversationEvents.seq, query.afterSeq),
1413
1478
  query.beforeSeq === void 0 ? void 0 : lt(juniorConversationEvents.seq, query.beforeSeq),
1414
1479
  typeFilter
@@ -1445,8 +1510,8 @@ var SqlConversationEventStore = class {
1445
1510
  return false;
1446
1511
  }
1447
1512
  const [row] = await this.executor.db().select({ seq: juniorConversationEvents.seq }).from(juniorConversationEvents).where(
1448
- and3(
1449
- eq3(juniorConversationEvents.conversationId, args.conversationId),
1513
+ and4(
1514
+ eq4(juniorConversationEvents.conversationId, args.conversationId),
1450
1515
  args.afterSeq === void 0 ? void 0 : gt(juniorConversationEvents.seq, args.afterSeq),
1451
1516
  args.beforeSeq === void 0 ? void 0 : lt(juniorConversationEvents.seq, args.beforeSeq),
1452
1517
  args.typeFilter
@@ -1459,7 +1524,7 @@ var SqlConversationEventStore = class {
1459
1524
  const rows = await this.executor.db().select({
1460
1525
  maxSeq: sql4`max(${juniorConversationEvents.seq})`,
1461
1526
  maxHistoryVersion: sql4`max(${juniorConversationEvents.historyVersion})`
1462
- }).from(juniorConversationEvents).where(eq3(juniorConversationEvents.conversationId, conversationId));
1527
+ }).from(juniorConversationEvents).where(eq4(juniorConversationEvents.conversationId, conversationId));
1463
1528
  const maxSeq = rows[0]?.maxSeq;
1464
1529
  const maxHistoryVersion = rows[0]?.maxHistoryVersion;
1465
1530
  return {
@@ -1473,7 +1538,7 @@ function createSqlConversationEventStore(executor) {
1473
1538
  }
1474
1539
 
1475
1540
  // src/chat/conversations/sql/search.ts
1476
- import { and as and4, desc as desc3, eq as eq4, isNull as isNull2, ne, sql as sql5 } from "drizzle-orm";
1541
+ import { and as and5, desc as desc3, eq as eq5, isNull as isNull2, ne, sql as sql5 } from "drizzle-orm";
1477
1542
  var SqlConversationSearchStore = class {
1478
1543
  constructor(executor) {
1479
1544
  this.executor = executor;
@@ -1498,23 +1563,23 @@ var SqlConversationSearchStore = class {
1498
1563
  role: role.as("role")
1499
1564
  }).from(juniorConversationEvents).innerJoin(
1500
1565
  juniorConversations,
1501
- eq4(
1566
+ eq5(
1502
1567
  juniorConversations.conversationId,
1503
1568
  juniorConversationEvents.conversationId
1504
1569
  )
1505
1570
  ).innerJoin(
1506
1571
  juniorDestinations,
1507
- eq4(juniorDestinations.id, juniorConversations.destinationId)
1572
+ eq5(juniorDestinations.id, juniorConversations.destinationId)
1508
1573
  ).where(
1509
- and4(
1510
- eq4(juniorConversations.source, "slack"),
1574
+ and5(
1575
+ eq5(juniorConversations.source, "slack"),
1511
1576
  isNull2(juniorConversations.parentConversationId),
1512
1577
  isNull2(juniorConversations.transcriptPurgedAt),
1513
1578
  ne(juniorConversations.conversationId, args.currentConversationId),
1514
- eq4(juniorDestinations.provider, args.scope.provider),
1515
- eq4(juniorDestinations.providerTenantId, args.scope.providerTenantId),
1516
- eq4(juniorDestinations.visibility, "public"),
1517
- eq4(juniorConversationEvents.type, "message"),
1579
+ eq5(juniorDestinations.provider, args.scope.provider),
1580
+ eq5(juniorDestinations.providerTenantId, args.scope.providerTenantId),
1581
+ eq5(juniorDestinations.visibility, "public"),
1582
+ eq5(juniorConversationEvents.type, "message"),
1518
1583
  sql5`${role} in ('user', 'assistant')`,
1519
1584
  sql5`to_tsvector('english', ${text}) @@ ${tsquery}`
1520
1585
  )
@@ -1546,12 +1611,13 @@ var current;
1546
1611
  function createDb(args) {
1547
1612
  return createJuniorSqlExecutor({
1548
1613
  connectionString: args.databaseUrl,
1549
- driver: args.driver
1614
+ driver: args.driver,
1615
+ statementTimeoutMs: args.statementTimeoutMs
1550
1616
  });
1551
1617
  }
1552
1618
  function getSqlExecutor() {
1553
1619
  const { sql: sql6 } = getChatConfig();
1554
- if (current?.databaseUrl !== sql6.databaseUrl || current.driver !== sql6.driver) {
1620
+ if (current?.databaseUrl !== sql6.databaseUrl || current.driver !== sql6.driver || current.statementTimeoutMs !== sql6.statementTimeoutMs) {
1555
1621
  if (current) {
1556
1622
  const previous = current;
1557
1623
  current = void 0;
@@ -1559,11 +1625,13 @@ function getSqlExecutor() {
1559
1625
  }
1560
1626
  const db = createDb({
1561
1627
  databaseUrl: sql6.databaseUrl,
1562
- driver: sql6.driver
1628
+ driver: sql6.driver,
1629
+ statementTimeoutMs: sql6.statementTimeoutMs
1563
1630
  });
1564
1631
  current = {
1565
1632
  databaseUrl: sql6.databaseUrl,
1566
1633
  driver: sql6.driver,
1634
+ statementTimeoutMs: sql6.statementTimeoutMs,
1567
1635
  db,
1568
1636
  store: createSqlStore(db),
1569
1637
  eventStore: createSqlConversationEventStore(db),
@@ -1599,6 +1667,8 @@ export {
1599
1667
  requireSlackDestination,
1600
1668
  sameDestination,
1601
1669
  parseSessionSource,
1670
+ bindProviderConversation,
1671
+ locationFromRow,
1602
1672
  instructionProvenanceFor,
1603
1673
  contextProvenance,
1604
1674
  sameActorIdentity,