@sentry/junior 0.187.0 → 0.188.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 (69) hide show
  1. package/dist/{agent-hooks-XVAE2554.js → agent-hooks-5RQEVLQD.js} +11 -11
  2. package/dist/api.js +31 -31
  3. package/dist/app.js +52 -46
  4. package/dist/{catalog-runtime-DWFAC562.js → catalog-runtime-L4A6BJ3U.js} +4 -4
  5. package/dist/chat/agent/types.d.ts +8 -12
  6. package/dist/chat/agent-invocations/types.d.ts +72 -0
  7. package/dist/chat/conversations/location.d.ts +3 -8
  8. package/dist/chat/conversations/store.d.ts +4 -7
  9. package/dist/chat/event-tasks/tool-support.d.ts +6 -0
  10. package/dist/chat/services/turn-session-routing.d.ts +5 -5
  11. package/dist/chat/task-execution/slack-resource-event.d.ts +13 -5
  12. package/dist/{chunk-7LRRVMPH.js → chunk-32XSSFZV.js} +1 -1
  13. package/dist/{chunk-Z6OHCDXP.js → chunk-3HEZWDS5.js} +2 -2
  14. package/dist/{chunk-WRDW3A3D.js → chunk-6JZGXLL2.js} +5 -5
  15. package/dist/{chunk-D5BWM37G.js → chunk-6YGFBU3A.js} +12 -12
  16. package/dist/{chunk-WL3R2KTS.js → chunk-AW77HH54.js} +92 -10
  17. package/dist/{chunk-TQHCZXN7.js → chunk-CDSLOYOR.js} +5 -5
  18. package/dist/{chunk-27T5HZHO.js → chunk-CIG6WI7Q.js} +6 -87
  19. package/dist/{chunk-4A2R3AQB.js → chunk-CVBDVIF4.js} +1 -1
  20. package/dist/{chunk-2VUDJGB6.js → chunk-CZRWU4ZM.js} +1 -1
  21. package/dist/{chunk-OM4SFFJK.js → chunk-ERZMACYA.js} +2 -2
  22. package/dist/{chunk-Q6OCUQ7W.js → chunk-FIUCHYT6.js} +1 -1
  23. package/dist/{chunk-U3KMII5Y.js → chunk-HCIVBCP5.js} +1 -1
  24. package/dist/{chunk-WKIS4VRK.js → chunk-IUUQWIG2.js} +14 -31
  25. package/dist/{chunk-4YD3DET6.js → chunk-LODJKINF.js} +19 -20
  26. package/dist/{chunk-NIKLTFBP.js → chunk-MQDIIFZM.js} +4 -4
  27. package/dist/{chunk-QH3I7ZOK.js → chunk-NZLZ4KYZ.js} +1 -1
  28. package/dist/{chunk-ITLYUKGZ.js → chunk-PSHMPRIU.js} +1 -1
  29. package/dist/{chunk-URZ7UD4P.js → chunk-Q7O74WOO.js} +2 -2
  30. package/dist/{chunk-DUE4EUNL.js → chunk-QCGNHSMA.js} +6 -6
  31. package/dist/{chunk-EIWYZXSM.js → chunk-QDHJTKPE.js} +5 -5
  32. package/dist/{chunk-6YCIYOVA.js → chunk-QIMN3FXL.js} +1 -1
  33. package/dist/{chunk-X5SXFVZT.js → chunk-QIOUTXTZ.js} +1 -1
  34. package/dist/{chunk-HXR3FHTE.js → chunk-QVH6FW3T.js} +1 -1
  35. package/dist/{chunk-U5POFCKM.js → chunk-RMB7CERI.js} +26 -26
  36. package/dist/{chunk-KRYJ5VOD.js → chunk-SC67CH3C.js} +13 -15
  37. package/dist/{chunk-6FKNNUSN.js → chunk-UVUXFRYN.js} +6 -6
  38. package/dist/{chunk-MUPPP7A7.js → chunk-VFZAUQ5V.js} +6 -6
  39. package/dist/{chunk-BITZUBPJ.js → chunk-W2DDJCPS.js} +8 -8
  40. package/dist/{chunk-VC343WHM.js → chunk-W42ENMJW.js} +1 -1
  41. package/dist/{chunk-JCRXXEMC.js → chunk-WGZJ5SU4.js} +1 -1
  42. package/dist/{chunk-P2VU5JNH.js → chunk-WW2Y7JIA.js} +27 -26
  43. package/dist/{chunk-JZPDYKRG.js → chunk-X55FOVZO.js} +3 -3
  44. package/dist/{chunk-STF4GSK4.js → chunk-XI4PVY2T.js} +3 -3
  45. package/dist/{chunk-D3GDGREI.js → chunk-XJIPMHKI.js} +3 -3
  46. package/dist/{chunk-NU775DLU.js → chunk-Z5SKZE5B.js} +1 -1
  47. package/dist/{chunk-U6ZQHRIP.js → chunk-ZX7RSBQ6.js} +1 -1
  48. package/dist/cli/chat.js +32 -32
  49. package/dist/cli/check.js +5 -5
  50. package/dist/cli/plugins.js +12 -12
  51. package/dist/cli/snapshot-create.js +9 -9
  52. package/dist/cli/upgrade.js +6 -6
  53. package/dist/db/schema/agent-invocations.d.ts +36 -0
  54. package/dist/db/schema.d.ts +36 -0
  55. package/dist/{db-FBHAWVXU.js → db-YPRZAA2T.js} +6 -6
  56. package/dist/instrumentation.js +3 -3
  57. package/dist/nitro.js +6 -6
  58. package/dist/{oauth-callback-server-5HS5ULC6.js → oauth-callback-server-DBBIR3XG.js} +27 -27
  59. package/dist/{runner-46W6NV6B.js → runner-FKVFFPLO.js} +20 -20
  60. package/dist/{skills-TG3QC4B6.js → skills-4RBAZEMV.js} +5 -5
  61. package/dist/spawn-CO7QFCNJ.js +41 -0
  62. package/dist/task-runner-DUGZGI7V.js +34 -0
  63. package/dist/{validation-GMRIDBC5.js → validation-E6Z5LHZM.js} +5 -5
  64. package/dist/version.js +1 -1
  65. package/dist/{work-W4ULBJTU.js → work-OFTXWOK4.js} +20 -20
  66. package/dist/{worker-M6NVACS2.js → worker-OMWNOKTJ.js} +10 -10
  67. package/package.json +5 -5
  68. package/dist/spawn-Y6YWBIJS.js +0 -41
  69. package/dist/task-runner-YSGBPN4U.js +0 -34
@@ -107,6 +107,12 @@ export declare const agentInvocationSchema: z.ZodDiscriminatedUnion<[z.ZodObject
107
107
  platform: z.ZodLiteral<"slack">;
108
108
  teamId: z.ZodString;
109
109
  channelId: z.ZodString;
110
+ location: z.ZodOptional<z.ZodObject<{
111
+ id: z.ZodString;
112
+ provider: z.ZodString;
113
+ tenantId: z.ZodOptional<z.ZodString>;
114
+ providerId: z.ZodString;
115
+ }, z.core.$strict>>;
110
116
  visibility: z.ZodEnum<{
111
117
  private: "private";
112
118
  public: "public";
@@ -114,10 +120,22 @@ export declare const agentInvocationSchema: z.ZodDiscriminatedUnion<[z.ZodObject
114
120
  messageTs: z.ZodOptional<z.ZodString>;
115
121
  threadTs: z.ZodOptional<z.ZodString>;
116
122
  }, z.core.$strict>, z.ZodObject<{
123
+ location: z.ZodOptional<z.ZodObject<{
124
+ id: z.ZodString;
125
+ provider: z.ZodString;
126
+ tenantId: z.ZodOptional<z.ZodString>;
127
+ providerId: z.ZodString;
128
+ }, z.core.$strict>>;
117
129
  platform: z.ZodLiteral<"local">;
118
130
  visibility: z.ZodLiteral<"private">;
119
131
  conversationId: z.ZodString;
120
132
  }, z.core.$strict>, z.ZodObject<{
133
+ location: z.ZodOptional<z.ZodObject<{
134
+ id: z.ZodString;
135
+ provider: z.ZodString;
136
+ tenantId: z.ZodOptional<z.ZodString>;
137
+ providerId: z.ZodString;
138
+ }, z.core.$strict>>;
121
139
  platform: z.ZodLiteral<"web">;
122
140
  visibility: z.ZodEnum<{
123
141
  private: "private";
@@ -232,6 +250,12 @@ export declare const agentInvocationSchema: z.ZodDiscriminatedUnion<[z.ZodObject
232
250
  platform: z.ZodLiteral<"slack">;
233
251
  teamId: z.ZodString;
234
252
  channelId: z.ZodString;
253
+ location: z.ZodOptional<z.ZodObject<{
254
+ id: z.ZodString;
255
+ provider: z.ZodString;
256
+ tenantId: z.ZodOptional<z.ZodString>;
257
+ providerId: z.ZodString;
258
+ }, z.core.$strict>>;
235
259
  visibility: z.ZodEnum<{
236
260
  private: "private";
237
261
  public: "public";
@@ -239,10 +263,22 @@ export declare const agentInvocationSchema: z.ZodDiscriminatedUnion<[z.ZodObject
239
263
  messageTs: z.ZodOptional<z.ZodString>;
240
264
  threadTs: z.ZodOptional<z.ZodString>;
241
265
  }, z.core.$strict>, z.ZodObject<{
266
+ location: z.ZodOptional<z.ZodObject<{
267
+ id: z.ZodString;
268
+ provider: z.ZodString;
269
+ tenantId: z.ZodOptional<z.ZodString>;
270
+ providerId: z.ZodString;
271
+ }, z.core.$strict>>;
242
272
  platform: z.ZodLiteral<"local">;
243
273
  visibility: z.ZodLiteral<"private">;
244
274
  conversationId: z.ZodString;
245
275
  }, z.core.$strict>, z.ZodObject<{
276
+ location: z.ZodOptional<z.ZodObject<{
277
+ id: z.ZodString;
278
+ provider: z.ZodString;
279
+ tenantId: z.ZodOptional<z.ZodString>;
280
+ providerId: z.ZodString;
281
+ }, z.core.$strict>>;
246
282
  platform: z.ZodLiteral<"web">;
247
283
  visibility: z.ZodEnum<{
248
284
  private: "private";
@@ -355,6 +391,12 @@ export declare const agentInvocationSchema: z.ZodDiscriminatedUnion<[z.ZodObject
355
391
  platform: z.ZodLiteral<"slack">;
356
392
  teamId: z.ZodString;
357
393
  channelId: z.ZodString;
394
+ location: z.ZodOptional<z.ZodObject<{
395
+ id: z.ZodString;
396
+ provider: z.ZodString;
397
+ tenantId: z.ZodOptional<z.ZodString>;
398
+ providerId: z.ZodString;
399
+ }, z.core.$strict>>;
358
400
  visibility: z.ZodEnum<{
359
401
  private: "private";
360
402
  public: "public";
@@ -362,10 +404,22 @@ export declare const agentInvocationSchema: z.ZodDiscriminatedUnion<[z.ZodObject
362
404
  messageTs: z.ZodOptional<z.ZodString>;
363
405
  threadTs: z.ZodOptional<z.ZodString>;
364
406
  }, z.core.$strict>, z.ZodObject<{
407
+ location: z.ZodOptional<z.ZodObject<{
408
+ id: z.ZodString;
409
+ provider: z.ZodString;
410
+ tenantId: z.ZodOptional<z.ZodString>;
411
+ providerId: z.ZodString;
412
+ }, z.core.$strict>>;
365
413
  platform: z.ZodLiteral<"local">;
366
414
  visibility: z.ZodLiteral<"private">;
367
415
  conversationId: z.ZodString;
368
416
  }, z.core.$strict>, z.ZodObject<{
417
+ location: z.ZodOptional<z.ZodObject<{
418
+ id: z.ZodString;
419
+ provider: z.ZodString;
420
+ tenantId: z.ZodOptional<z.ZodString>;
421
+ providerId: z.ZodString;
422
+ }, z.core.$strict>>;
369
423
  platform: z.ZodLiteral<"web">;
370
424
  visibility: z.ZodEnum<{
371
425
  private: "private";
@@ -476,6 +530,12 @@ export declare const createAgentInvocationSchema: z.ZodObject<{
476
530
  platform: z.ZodLiteral<"slack">;
477
531
  teamId: z.ZodString;
478
532
  channelId: z.ZodString;
533
+ location: z.ZodOptional<z.ZodObject<{
534
+ id: z.ZodString;
535
+ provider: z.ZodString;
536
+ tenantId: z.ZodOptional<z.ZodString>;
537
+ providerId: z.ZodString;
538
+ }, z.core.$strict>>;
479
539
  visibility: z.ZodEnum<{
480
540
  private: "private";
481
541
  public: "public";
@@ -483,10 +543,22 @@ export declare const createAgentInvocationSchema: z.ZodObject<{
483
543
  messageTs: z.ZodOptional<z.ZodString>;
484
544
  threadTs: z.ZodOptional<z.ZodString>;
485
545
  }, z.core.$strict>, z.ZodObject<{
546
+ location: z.ZodOptional<z.ZodObject<{
547
+ id: z.ZodString;
548
+ provider: z.ZodString;
549
+ tenantId: z.ZodOptional<z.ZodString>;
550
+ providerId: z.ZodString;
551
+ }, z.core.$strict>>;
486
552
  platform: z.ZodLiteral<"local">;
487
553
  visibility: z.ZodLiteral<"private">;
488
554
  conversationId: z.ZodString;
489
555
  }, z.core.$strict>, z.ZodObject<{
556
+ location: z.ZodOptional<z.ZodObject<{
557
+ id: z.ZodString;
558
+ provider: z.ZodString;
559
+ tenantId: z.ZodOptional<z.ZodString>;
560
+ providerId: z.ZodString;
561
+ }, z.core.$strict>>;
490
562
  platform: z.ZodLiteral<"web">;
491
563
  visibility: z.ZodEnum<{
492
564
  private: "private";
@@ -1,10 +1,5 @@
1
- import { z } from "zod";
2
- /** One place outside Junior where a Conversation can be delivered. */
3
- export declare const locationSchema: z.ZodObject<{
4
- id: z.ZodString;
5
- provider: z.ZodString;
6
- tenantId: z.ZodOptional<z.ZodString>;
7
- providerId: z.ZodString;
8
- }, z.core.$strict>;
1
+ import { locationSchema } from "@sentry/junior-plugin-api";
2
+ import type { z } from "zod";
3
+ export { locationSchema };
9
4
  /** Validated Location associated with a Conversation. */
10
5
  export type Location = z.output<typeof locationSchema>;
@@ -1,7 +1,7 @@
1
1
  import type { Destination, Source } from "@sentry/junior-plugin-api";
2
+ import type { Location } from "@/chat/conversations/location";
2
3
  import type { ConversationPrivacy } from "@/chat/conversation-privacy";
3
4
  import type { StoredSlackActor } from "@/chat/actor";
4
- import type { Location } from "@/chat/conversations/location";
5
5
  import type { SessionSource } from "@/chat/source";
6
6
  import type { AgentTurnUsage } from "@/chat/usage";
7
7
  export type ConversationSource = "api" | "internal" | "local" | "plugin" | "resource_event" | "scheduler" | "slack" | "web";
@@ -13,10 +13,6 @@ export interface ConversationExecution {
13
13
  status: ConversationStatus;
14
14
  updatedAtMs?: number;
15
15
  }
16
- /** Immutable parent correlation for a child conversation. */
17
- export interface ConversationLineage {
18
- parentConversationId: string;
19
- }
20
16
  /**
21
17
  * Durable Conversation owned by Junior.
22
18
  *
@@ -41,7 +37,8 @@ export interface Conversation {
41
37
  usage?: AgentTurnUsage;
42
38
  };
43
39
  lastActivityAtMs: number;
44
- lineage?: ConversationLineage;
40
+ /** Immutable parent Conversation. */
41
+ parentConversationId?: string;
45
42
  /** Optional provider coordinates associated with this Conversation. */
46
43
  location?: Location;
47
44
  actor?: StoredSlackActor;
@@ -66,7 +63,7 @@ export interface Conversation {
66
63
  }
67
64
  /** Persist and read durable conversation metadata for reporting surfaces. */
68
65
  export interface ConversationStore {
69
- /** Create one destinationless child with immutable parent lineage. */
66
+ /** Create one Conversation with an immutable parent. */
70
67
  createChild(args: {
71
68
  childConversationId: string;
72
69
  parentConversationId: string;
@@ -97,6 +97,12 @@ export declare function requireEventTaskSlackContext(context: ToolRuntimeContext
97
97
  teamId: string;
98
98
  channelId: string;
99
99
  visibility: "private" | "public";
100
+ location?: {
101
+ id: string;
102
+ provider: string;
103
+ providerId: string;
104
+ tenantId?: string | undefined;
105
+ } | undefined;
100
106
  messageTs?: string | undefined;
101
107
  threadTs?: string | undefined;
102
108
  };
@@ -1,13 +1,13 @@
1
1
  /**
2
2
  * Load Location, Destination, and session Source from the Conversation record.
3
3
  *
4
- * Destination is set once on the root conversation. Child conversations
5
- * inherit through parent lineage. Later turns and mailbox wakes use that
6
- * same destination so tools stay consistent for the whole conversation.
4
+ * Destination is set once on the root Conversation. A Conversation with a
5
+ * parent reads through that relation. Later Turns and mailbox wakes use the
6
+ * same Destination so tools stay consistent for the whole Conversation.
7
7
  */
8
8
  import type { Destination, Source } from "@sentry/junior-plugin-api";
9
- import type { ConversationStore } from "@/chat/conversations/store";
10
9
  import type { Location } from "@/chat/conversations/location";
10
+ import type { ConversationStore } from "@/chat/conversations/store";
11
11
  export interface TurnSessionRouting {
12
12
  destination: Destination;
13
13
  location?: Location;
@@ -21,7 +21,7 @@ export type RequiredTurnSessionRouting = TurnSessionRouting & {
21
21
  /**
22
22
  * Resolve the Conversation's Location, Destination, and session Source.
23
23
  *
24
- * Walks parent lineage when the conversation has no destination of its own.
24
+ * Reads parent Conversations when this Conversation has no Destination.
25
25
  */
26
26
  export declare function resolveConversationRouting(args: {
27
27
  conversationId: string;
@@ -16,15 +16,23 @@ import type { SlackAdapter } from "@chat-adapter/slack";
16
16
  import type { Destination, SlackDestination } from "@sentry/junior-plugin-api";
17
17
  import type { ConversationStore } from "@/chat/conversations/store";
18
18
  import type { InboundMessage } from "@/chat/task-execution/store";
19
- /** Load Slack destination and threadTs for a resource-event wake. */
19
+ /** Resolved Slack place for one plain resource-event wake, when a thread exists. */
20
+ export type SlackResourceEventThread = {
21
+ destination: SlackDestination;
22
+ threadTs: string;
23
+ };
24
+ /**
25
+ * Load Slack destination and threadTs for a resource-event wake.
26
+ *
27
+ * Returns undefined when the Conversation has no Slack thread. The temporary
28
+ * synthetic Message/Thread bridge cannot invent one; the Slack worker must drop
29
+ * that wake instead of retrying.
30
+ */
20
31
  export declare function resolveSlackResourceEventThread(args: {
21
32
  conversationId: string;
22
33
  conversationStore?: ConversationStore;
23
34
  destination?: Destination;
24
- }): Promise<{
25
- destination: SlackDestination;
26
- threadTs: string;
27
- }>;
35
+ }): Promise<SlackResourceEventThread | undefined>;
28
36
  /** Whether a mailbox row is a plain resource-event wake (no Slack envelope). */
29
37
  export declare function isPlainResourceEventRecord(record: InboundMessage): boolean;
30
38
  /**
@@ -1,7 +1,7 @@
1
1
  // package.json
2
2
  var package_default = {
3
3
  name: "@sentry/junior",
4
- version: "0.187.0",
4
+ version: "0.188.0",
5
5
  private: false,
6
6
  publishConfig: {
7
7
  access: "public"
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  pluginCatalogRuntime
3
- } from "./chunk-QH3I7ZOK.js";
3
+ } from "./chunk-NZLZ4KYZ.js";
4
4
  import {
5
5
  skillRoots
6
6
  } from "./chunk-TXKUKMVO.js";
7
7
  import {
8
8
  logWarn
9
- } from "./chunk-6YCIYOVA.js";
9
+ } from "./chunk-QIMN3FXL.js";
10
10
 
11
11
  // src/chat/skills.ts
12
12
  import fs from "fs/promises";
@@ -7,23 +7,23 @@ import {
7
7
  import {
8
8
  formatProviderLabel,
9
9
  startOAuthFlow
10
- } from "./chunk-6FKNNUSN.js";
10
+ } from "./chunk-UVUXFRYN.js";
11
11
  import {
12
12
  abandonReplacedPendingAuth,
13
13
  canReusePendingAuthLink
14
- } from "./chunk-NU775DLU.js";
14
+ } from "./chunk-Z5SKZE5B.js";
15
15
  import {
16
16
  recordAuthorizationRequested
17
- } from "./chunk-D5BWM37G.js";
17
+ } from "./chunk-6YGFBU3A.js";
18
18
  import {
19
19
  AGENT_INVOCATION_MAILBOX_STATUSES
20
- } from "./chunk-HXR3FHTE.js";
20
+ } from "./chunk-QVH6FW3T.js";
21
21
  import {
22
22
  TURN_REASONING_LEVELS
23
23
  } from "./chunk-D4YV5TDV.js";
24
24
  import {
25
25
  pluginCatalogRuntime
26
- } from "./chunk-QH3I7ZOK.js";
26
+ } from "./chunk-NZLZ4KYZ.js";
27
27
  import {
28
28
  credentialContextSchema
29
29
  } from "./chunk-CEMMLV5L.js";
@@ -9,18 +9,18 @@ import {
9
9
  getSqlExecutor,
10
10
  sanitizePostgresJson,
11
11
  withConversationEventLock
12
- } from "./chunk-WKIS4VRK.js";
12
+ } from "./chunk-IUUQWIG2.js";
13
13
  import {
14
14
  SANDBOX_REPOS_ROOT,
15
15
  SANDBOX_WORKSPACE_ROOT,
16
16
  sleep
17
- } from "./chunk-JZPDYKRG.js";
17
+ } from "./chunk-X55FOVZO.js";
18
18
  import {
19
19
  MUTATION_LOCK_TTL_MS,
20
20
  fenceLock,
21
21
  getStateAdapter,
22
22
  withLock
23
- } from "./chunk-U6ZQHRIP.js";
23
+ } from "./chunk-ZX7RSBQ6.js";
24
24
  import {
25
25
  agentHistoryItemSchema,
26
26
  contextProvenance,
@@ -33,7 +33,7 @@ import {
33
33
  escapeXml,
34
34
  resolveGatewayModel,
35
35
  unwrapCurrentInstruction
36
- } from "./chunk-URZ7UD4P.js";
36
+ } from "./chunk-Q7O74WOO.js";
37
37
  import {
38
38
  parseSlackMessageTs,
39
39
  toStoredSlackActor
@@ -43,7 +43,7 @@ import {
43
43
  logException,
44
44
  logWarn,
45
45
  setSpanAttributes
46
- } from "./chunk-6YCIYOVA.js";
46
+ } from "./chunk-QIMN3FXL.js";
47
47
 
48
48
  // src/chat/turn-context-tag.ts
49
49
  var TURN_CONTEXT_TAG = "runtime-turn-context";
@@ -653,7 +653,7 @@ async function ensureConversationTitleOnce(args) {
653
653
  if (stored?.title?.trim()) {
654
654
  return void 0;
655
655
  }
656
- if (stored?.lineage) {
656
+ if (stored?.parentConversationId) {
657
657
  return void 0;
658
658
  }
659
659
  const titleSourceMessage = getThreadTitleSourceMessage(args.conversation);
@@ -2306,12 +2306,12 @@ async function recordConversationActivityMetadata(args) {
2306
2306
  const conversation = await conversationStore.get({
2307
2307
  conversationId: args.summary.conversationId
2308
2308
  });
2309
- const isChild = Boolean(conversation?.lineage);
2310
- const destination = isChild ? void 0 : args.destination;
2311
- if (!isChild && !destination && !conversation) {
2309
+ const hasParent = Boolean(conversation?.parentConversationId);
2310
+ const destination = hasParent ? void 0 : args.destination;
2311
+ if (!hasParent && !destination && !conversation) {
2312
2312
  return;
2313
2313
  }
2314
- const activitySource = isChild ? "internal" : args.source?.platform === "web" ? "web" : destination?.platform === "local" ? "local" : destination ? args.summary.surface : void 0;
2314
+ const activitySource = hasParent ? "internal" : args.source?.platform === "web" ? "web" : destination?.platform === "local" ? "local" : destination ? args.summary.surface : void 0;
2315
2315
  await conversationStore.recordActivity({
2316
2316
  activityAtMs: args.summary.updatedAtMs,
2317
2317
  channelName: args.summary.channelName,
@@ -2321,7 +2321,7 @@ async function recordConversationActivityMetadata(args) {
2321
2321
  actor: sessionLogActor(args.actor),
2322
2322
  ...definedProps({ source: activitySource }),
2323
2323
  ...args.source ? { sessionSource: args.source } : void 0,
2324
- visibility: isChild ? void 0 : args.destinationVisibility
2324
+ visibility: hasParent ? void 0 : args.destinationVisibility
2325
2325
  });
2326
2326
  await conversationStore.recordExecution({
2327
2327
  channelName: args.summary.channelName,
@@ -2337,7 +2337,7 @@ async function recordConversationActivityMetadata(args) {
2337
2337
  actor: sessionLogActor(args.actor),
2338
2338
  ...definedProps({ source: activitySource }),
2339
2339
  updatedAtMs: args.nowMs,
2340
- visibility: isChild ? void 0 : args.destinationVisibility
2340
+ visibility: hasParent ? void 0 : args.destinationVisibility
2341
2341
  });
2342
2342
  }
2343
2343
  function materializeTurnRecord(stored, piProjection, turnStartMessageIndex, restoreVolatileContext = true, runtimeMetrics) {
@@ -1,13 +1,12 @@
1
1
  import {
2
2
  coerceThreadConversationState,
3
- getPersistedThreadState,
4
- resolveTurnSessionRouting
5
- } from "./chunk-27T5HZHO.js";
3
+ getPersistedThreadState
4
+ } from "./chunk-CIG6WI7Q.js";
6
5
  import {
7
6
  pluginTaskId,
8
7
  pluginTaskParamsSchema,
9
8
  sendVercelPluginTask
10
- } from "./chunk-STF4GSK4.js";
9
+ } from "./chunk-XI4PVY2T.js";
11
10
  import {
12
11
  getPiMessageRole,
13
12
  getTurnRecord,
@@ -17,7 +16,7 @@ import {
17
16
  isToolResultMessage,
18
17
  normalizeToolNameFromResult,
19
18
  stripRuntimeTurnContext
20
- } from "./chunk-D5BWM37G.js";
19
+ } from "./chunk-6YGFBU3A.js";
21
20
  import {
22
21
  createPluginConversationEvents,
23
22
  createPluginEmbedder,
@@ -26,21 +25,21 @@ import {
26
25
  createPluginState,
27
26
  getPlugins,
28
27
  readActorIdentity
29
- } from "./chunk-DUE4EUNL.js";
28
+ } from "./chunk-QCGNHSMA.js";
30
29
  import {
31
30
  JUNIOR_THREAD_STATE_TTL_MS
32
31
  } from "./chunk-3Y47VMHV.js";
33
32
  import {
34
33
  getConversationStore,
35
34
  getDb
36
- } from "./chunk-WKIS4VRK.js";
35
+ } from "./chunk-IUUQWIG2.js";
37
36
  import {
38
37
  juniorConversations,
39
38
  juniorTaskExecutions
40
- } from "./chunk-HXR3FHTE.js";
39
+ } from "./chunk-QVH6FW3T.js";
41
40
  import {
42
41
  getStateAdapter
43
- } from "./chunk-U6ZQHRIP.js";
42
+ } from "./chunk-ZX7RSBQ6.js";
44
43
  import {
45
44
  sameActorIdentity
46
45
  } from "./chunk-GFBR4S3Q.js";
@@ -52,11 +51,92 @@ import {
52
51
  } from "./chunk-N7TMSOZH.js";
53
52
  import {
54
53
  logWarn
55
- } from "./chunk-6YCIYOVA.js";
54
+ } from "./chunk-QIMN3FXL.js";
56
55
 
57
56
  // src/chat/plugins/task-runner.ts
58
57
  import { pluginRunContextSchema } from "@sentry/junior-plugin-api";
59
58
 
59
+ // src/chat/services/turn-session-routing.ts
60
+ async function loadConversationChain(conversationId, conversationStore) {
61
+ const chain = [];
62
+ const seen = /* @__PURE__ */ new Set();
63
+ let cursor = conversationId;
64
+ while (cursor && !seen.has(cursor)) {
65
+ seen.add(cursor);
66
+ const conversation = await conversationStore.get({
67
+ conversationId: cursor
68
+ });
69
+ if (!conversation) {
70
+ break;
71
+ }
72
+ chain.push(conversation);
73
+ cursor = conversation.parentConversationId;
74
+ }
75
+ return chain;
76
+ }
77
+ function slackSourceForDestination(args) {
78
+ if (args.source?.platform !== "slack" || args.source.channelId !== args.destination.channelId) {
79
+ return void 0;
80
+ }
81
+ const threadTs = args.source.threadTs?.trim();
82
+ return {
83
+ platform: "slack",
84
+ visibility: args.source.visibility ?? "public",
85
+ teamId: args.source.teamId?.trim() || args.destination.teamId,
86
+ channelId: args.source.channelId,
87
+ ...threadTs ? { threadTs } : void 0
88
+ };
89
+ }
90
+ async function resolveConversationRouting(args) {
91
+ const conversationStore = args.conversationStore ?? (await import("./db-YPRZAA2T.js")).getConversationStore();
92
+ const chain = await loadConversationChain(
93
+ args.conversationId,
94
+ conversationStore
95
+ );
96
+ let destination;
97
+ let source;
98
+ let location;
99
+ for (const conversation of chain) {
100
+ destination ??= conversation.destination;
101
+ source ??= conversation.sessionSource;
102
+ location ??= conversation.location;
103
+ if (destination && source) {
104
+ break;
105
+ }
106
+ }
107
+ if (!destination) {
108
+ return void 0;
109
+ }
110
+ if (destination.platform === "slack") {
111
+ const slackSource = slackSourceForDestination({ destination, source });
112
+ return {
113
+ destination,
114
+ ...location ? { location } : void 0,
115
+ ...slackSource ? {
116
+ source: location ? { ...slackSource, location } : slackSource
117
+ } : void 0
118
+ };
119
+ }
120
+ return {
121
+ destination,
122
+ ...location ? { location } : void 0,
123
+ ...source ? { source: location ? { ...source, location } : source } : void 0
124
+ };
125
+ }
126
+ async function resolveTurnSessionRouting(args) {
127
+ const routing = await resolveConversationRouting(args);
128
+ if (!routing?.destination || !routing.source) {
129
+ throw new Error(
130
+ `Conversation ${args.conversationId} is missing durable routing metadata`
131
+ );
132
+ }
133
+ return {
134
+ destination: routing.destination,
135
+ source: routing.source,
136
+ ...routing.location ? { location: routing.location } : void 0
137
+ };
138
+ }
139
+
60
140
  // src/chat/agent-dispatch/store.ts
61
141
  import { createHash } from "crypto";
62
142
  import {
@@ -1006,6 +1086,8 @@ export {
1006
1086
  listPendingDispatchMailboxAppends,
1007
1087
  claimDispatchMailboxAppend,
1008
1088
  getPluginDispatchProjection,
1089
+ resolveConversationRouting,
1090
+ resolveTurnSessionRouting,
1009
1091
  scheduleSessionCompletedPluginTasks,
1010
1092
  processPluginTask
1011
1093
  };
@@ -19,23 +19,23 @@ import {
19
19
  releaseConversationWork,
20
20
  requestAnotherSlice,
21
21
  startConversationWork
22
- } from "./chunk-NIKLTFBP.js";
22
+ } from "./chunk-MQDIIFZM.js";
23
23
  import {
24
24
  ConversationQueueMessageRejectedError
25
25
  } from "./chunk-JAL3CH4G.js";
26
26
  import {
27
27
  getTurnRequestDeadline
28
- } from "./chunk-JCRXXEMC.js";
28
+ } from "./chunk-WGZJ5SU4.js";
29
29
  import {
30
30
  getChatConfig,
31
31
  isProviderRetryError
32
- } from "./chunk-URZ7UD4P.js";
32
+ } from "./chunk-Q7O74WOO.js";
33
33
  import {
34
34
  logException,
35
35
  logInfo,
36
36
  logWarn,
37
37
  withLogContext
38
- } from "./chunk-6YCIYOVA.js";
38
+ } from "./chunk-QIMN3FXL.js";
39
39
 
40
40
  // src/chat/task-execution/worker.ts
41
41
  var CONVERSATION_WORK_DEFER_DELAY_MS = 15e3;
@@ -279,7 +279,7 @@ async function processConversationWorkInContext(message, options) {
279
279
  let destination = initial.destination;
280
280
  if (!destination && options.conversationStore) {
281
281
  const stored = await options.conversationStore.get({ conversationId });
282
- if (stored && !stored.lineage) {
282
+ if (stored && !stored.parentConversationId) {
283
283
  destination = stored.destination;
284
284
  }
285
285
  }