@sentry/junior 0.179.0 → 0.180.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 (126) hide show
  1. package/dist/{agent-hooks-32IDCLMW.js → agent-hooks-DKDDRKZA.js} +16 -18
  2. package/dist/api/schema.js +0 -1
  3. package/dist/api.js +199 -197
  4. package/dist/app.d.ts +4 -0
  5. package/dist/app.js +300 -1259
  6. package/dist/catalog-runtime-WXKGUF3W.js +14 -0
  7. package/dist/chat/agent/sandbox.d.ts +0 -2
  8. package/dist/chat/api-turns/routing.d.ts +4 -0
  9. package/dist/chat/api-turns/work.d.ts +5 -0
  10. package/dist/chat/config.d.ts +5 -2
  11. package/dist/chat/configuration/defaults.d.ts +1 -1
  12. package/dist/chat/conversations/projection.d.ts +6 -4
  13. package/dist/chat/ingress/message-router.d.ts +3 -0
  14. package/dist/chat/model-profile.d.ts +8 -10
  15. package/dist/chat/pi/conversation-events.d.ts +3 -2
  16. package/dist/chat/plugins/task-queue.d.ts +40 -3
  17. package/dist/chat/plugins/task-runner.d.ts +1 -1
  18. package/dist/chat/queue/callback.d.ts +26 -0
  19. package/dist/chat/queue/sign.d.ts +30 -0
  20. package/dist/chat/sandbox/sandbox.d.ts +0 -2
  21. package/dist/chat/sandbox/session.d.ts +0 -2
  22. package/dist/chat/sandbox/skill-sync.d.ts +1 -1
  23. package/dist/chat/sandbox/snapshot/events.d.ts +23 -0
  24. package/dist/chat/sandbox/snapshot/job-callback.d.ts +5 -0
  25. package/dist/chat/sandbox/snapshot/job-queue.d.ts +26 -0
  26. package/dist/chat/sandbox/snapshot/job-runner.d.ts +11 -0
  27. package/dist/chat/sandbox/snapshot/not-ready-error.d.ts +6 -0
  28. package/dist/chat/sandbox/snapshot/workspace.d.ts +9 -3
  29. package/dist/chat/services/turn-router.d.ts +4 -3
  30. package/dist/chat/task-execution/queue-signing.d.ts +10 -21
  31. package/dist/chat/task-execution/state.d.ts +48 -0
  32. package/dist/chat/task-execution/store.d.ts +28 -2
  33. package/dist/chat/task-execution/worker.d.ts +4 -1
  34. package/dist/chat/tools/handoff/tool.d.ts +1 -1
  35. package/dist/{chunk-B6ECUSVX.js → chunk-2AYEVN7K.js} +8 -8
  36. package/dist/{chunk-SLGGOASN.js → chunk-2YIRH4E3.js} +46 -46
  37. package/dist/{chunk-KJLHIHFF.js → chunk-3ILJBWP7.js} +35 -227
  38. package/dist/{chunk-RZRYOLCE.js → chunk-5PUMIMNQ.js} +2292 -1147
  39. package/dist/{chunk-CJLBLELR.js → chunk-5TUR4M3M.js} +8 -61
  40. package/dist/{chunk-6ZWRNC4D.js → chunk-6Y5B5PEX.js} +1 -1
  41. package/dist/{chunk-XSPSCWLH.js → chunk-6YCEWOLO.js} +4 -4
  42. package/dist/chunk-7H2VZTWN.js +103 -0
  43. package/dist/{chunk-FAS6AIMF.js → chunk-CCDXTDSY.js} +8 -8
  44. package/dist/{chunk-CGA4ERJ5.js → chunk-CEMMLV5L.js} +1 -1
  45. package/dist/{chunk-XZY6G5YZ.js → chunk-CK6EINVZ.js} +180 -87
  46. package/dist/{chunk-FIANEE7Z.js → chunk-CM5HNV2W.js} +6 -6
  47. package/dist/{chunk-JT4WMD3C.js → chunk-CP73FKME.js} +144 -218
  48. package/dist/{chunk-3I7XE3PA.js → chunk-DHLOGWYH.js} +36 -36
  49. package/dist/chunk-DKIJ2RP5.js +68 -0
  50. package/dist/{chunk-YFNAMRGE.js → chunk-DRHEGXTZ.js} +1 -1
  51. package/dist/{chunk-OOUNJNMR.js → chunk-DWPN6SCH.js} +1 -1
  52. package/dist/chunk-EWHP2IRG.js +209 -0
  53. package/dist/{chunk-R6U7N4FS.js → chunk-FGC3PHNH.js} +3 -3
  54. package/dist/{chunk-3TM3FYLQ.js → chunk-GA5NS74S.js} +1 -1
  55. package/dist/{chunk-FIDMHAO6.js → chunk-GPXAHUQH.js} +84 -274
  56. package/dist/chunk-GUKXEPMX.js +218 -0
  57. package/dist/{chunk-GENV6KF2.js → chunk-I6IFTAPF.js} +108 -76
  58. package/dist/{chunk-R5NWWYIS.js → chunk-IANUX7HX.js} +5 -5
  59. package/dist/{chunk-G2CAC4CV.js → chunk-KCL6AWYW.js} +74 -68
  60. package/dist/{chunk-5IRROPA5.js → chunk-L7LTGN4Z.js} +129 -31
  61. package/dist/{chunk-Q5B3WTGG.js → chunk-LGVQLNLS.js} +42 -41
  62. package/dist/chunk-M3QYTBQ6.js +55 -0
  63. package/dist/{chunk-FTGD2FBP.js → chunk-MXEUIGHO.js} +2 -2
  64. package/dist/{chunk-M63DETLL.js → chunk-N7TMSOZH.js} +6 -6
  65. package/dist/{chunk-2HIPYNQI.js → chunk-O4QYZTDK.js} +33 -32
  66. package/dist/chunk-PEQXYSSE.js +45 -0
  67. package/dist/{chunk-RTRBYSF3.js → chunk-QSO7B5JO.js} +1 -1
  68. package/dist/{chunk-HQNE5APD.js → chunk-RAZG3YHC.js} +100 -79
  69. package/dist/{chunk-VP4OVRDD.js → chunk-S7YRTOSQ.js} +69 -73
  70. package/dist/{chunk-U4TKB6F6.js → chunk-SDBKZ5LV.js} +108 -5
  71. package/dist/{chunk-GPLAT6H7.js → chunk-TC5DE5KJ.js} +22 -18
  72. package/dist/{chunk-H4HBKISO.js → chunk-TXKUKMVO.js} +1 -1
  73. package/dist/chunk-U5EUCUBH.js +164 -0
  74. package/dist/{chunk-3AFVR5UC.js → chunk-VG722ONZ.js} +18 -16
  75. package/dist/{chunk-ZQMG3CL5.js → chunk-VGPPWWHF.js} +16 -16
  76. package/dist/{chunk-JMJNFEDC.js → chunk-WVAMRKYG.js} +9 -54
  77. package/dist/chunk-X6GDDWQH.js +60 -0
  78. package/dist/{chunk-4GWXAILB.js → chunk-ZE2KOV3G.js} +1 -1
  79. package/dist/{chunk-TIEKUH4Q.js → chunk-ZM7ZURJS.js} +4 -3
  80. package/dist/cli/chat.js +47 -43
  81. package/dist/cli/check.js +13 -15
  82. package/dist/cli/env.js +0 -1
  83. package/dist/cli/init.js +0 -1
  84. package/dist/cli/main.js +2 -3
  85. package/dist/cli/plugins.js +18 -20
  86. package/dist/cli/run.js +0 -1
  87. package/dist/cli/snapshot-create.js +14 -16
  88. package/dist/cli/upgrade.js +16 -18
  89. package/dist/{conversation-work-KATFHLG3.js → conversation-work-VIOQ5ZF3.js} +0 -2
  90. package/dist/{db-EJAV7JL6.js → db-6SBHIAJK.js} +8 -10
  91. package/dist/deployment.d.ts +1 -0
  92. package/dist/{discovery-GUFTFBTL.js → discovery-DWVDM7UK.js} +1 -2
  93. package/dist/{experimental-XVDOSRBS.js → experimental-SIJSRDJD.js} +0 -1
  94. package/dist/instrumentation.js +7 -9
  95. package/dist/nitro.js +39 -13
  96. package/dist/{oauth-callback-server-GAVSUBTQ.js → oauth-callback-server-WSDQPZZS.js} +34 -32
  97. package/dist/{oauth-relay-3ZU72UGL.js → oauth-relay-5XPVRPYB.js} +0 -1
  98. package/dist/{plugins-HW4VWW6G.js → plugins-YTYJMMJF.js} +1 -2
  99. package/dist/{runner-34JL64JF.js → runner-GWTSWESR.js} +39 -33
  100. package/dist/{sandbox-egress-signals-DXOOBSBI.js → sandbox-egress-signals-FIL7EGPR.js} +5 -6
  101. package/dist/{sentry-JMWTS32N.js → sentry-MB3NL3IR.js} +1 -2
  102. package/dist/skills-F32BPFYW.js +27 -0
  103. package/dist/spawn-X5BPP5OE.js +37 -0
  104. package/dist/task-runner-2FPBV5PP.js +32 -0
  105. package/dist/validation-62WO524A.js +17 -0
  106. package/dist/vercel.js +0 -1
  107. package/dist/version.js +1 -2
  108. package/dist/work-3C3CMZ24.js +45 -0
  109. package/dist/worker-MFAI6ZEK.js +22 -0
  110. package/package.json +8 -7
  111. package/dist/catalog-runtime-FBVA6WAQ.js +0 -16
  112. package/dist/chat/plugins/task-callback.d.ts +0 -5
  113. package/dist/chat/plugins/task-message.d.ts +0 -23
  114. package/dist/chat/plugins/task-signing.d.ts +0 -31
  115. package/dist/chat/sandbox/snapshot/waiting-error.d.ts +0 -15
  116. package/dist/chat/services/workspace-snapshot-wait.d.ts +0 -27
  117. package/dist/chunk-5I6ORJUY.js +0 -127
  118. package/dist/chunk-6GWA276C.js +0 -72
  119. package/dist/chunk-MLKGABMK.js +0 -9
  120. package/dist/chunk-UT6X7XN7.js +0 -51
  121. package/dist/chunk-WR76IVA5.js +0 -130
  122. package/dist/skills-U545HALM.js +0 -29
  123. package/dist/spawn-I2S4IDUQ.js +0 -37
  124. package/dist/validation-EVXVGA44.js +0 -19
  125. package/dist/work-QOAUPDBU.js +0 -45
  126. package/dist/worker-5GX2IKLZ.js +0 -24
@@ -8,23 +8,23 @@ import {
8
8
  juniorConversations,
9
9
  juniorIdentities,
10
10
  juniorUsers
11
- } from "./chunk-R6U7N4FS.js";
11
+ } from "./chunk-FGC3PHNH.js";
12
+ import {
13
+ juniorDestinations
14
+ } from "./chunk-VFUK3X5B.js";
12
15
  import {
13
16
  TURN_REASONING_LEVELS,
14
17
  getChatConfig,
15
18
  modelProfileSchema
16
- } from "./chunk-GENV6KF2.js";
17
- import {
18
- juniorDestinations
19
- } from "./chunk-VFUK3X5B.js";
19
+ } from "./chunk-I6IFTAPF.js";
20
20
  import {
21
21
  parseActorUserId,
22
22
  parseSlackChannelReferenceId,
23
23
  parseSlackTeamId
24
- } from "./chunk-M63DETLL.js";
24
+ } from "./chunk-N7TMSOZH.js";
25
25
  import {
26
26
  normalizeIdentityEmail
27
- } from "./chunk-HQNE5APD.js";
27
+ } from "./chunk-RAZG3YHC.js";
28
28
 
29
29
  // src/chat/conversations/sql/store.ts
30
30
  import { randomUUID as randomUUID2 } from "crypto";
@@ -118,7 +118,7 @@ async function upsertIdentityRecord(executor, identity, linkedUserId, nowMs) {
118
118
  email: userEmail ?? userEmailNormalized,
119
119
  emailNormalized: userEmailNormalized,
120
120
  nowMs,
121
- ...existing?.displayName || identity.displayName ? { displayName: existing?.displayName ?? identity.displayName } : {}
121
+ ...existing?.displayName || identity.displayName ? { displayName: existing?.displayName ?? identity.displayName } : void 0
122
122
  }) : void 0;
123
123
  if (existing?.userId && verifiedUserId && existing.userId !== verifiedUserId) {
124
124
  throw new Error("Identity verified email conflicts with linked user");
@@ -166,7 +166,7 @@ async function upsertIdentityRecord(executor, identity, linkedUserId, nowMs) {
166
166
  },
167
167
  ...linkedUserId ? {
168
168
  setWhere: sql`${juniorIdentities.userId} IS NULL OR ${juniorIdentities.userId} = excluded.user_id`
169
- } : {}
169
+ } : void 0
170
170
  }).returning({
171
171
  id: juniorIdentities.id,
172
172
  userId: juniorIdentities.userId
@@ -180,7 +180,7 @@ async function upsertIdentityRecord(executor, identity, linkedUserId, nowMs) {
180
180
  }
181
181
  return {
182
182
  id: row.id,
183
- ...row.userId ? { userId: row.userId } : {}
183
+ ...row.userId ? { userId: row.userId } : void 0
184
184
  };
185
185
  }
186
186
  async function upsertIdentity(executor, identity, nowMs = Date.now()) {
@@ -242,7 +242,7 @@ async function recordConversationParticipant(executor, args) {
242
242
  ],
243
243
  set: {
244
244
  lastMessageAt: sql2`greatest(${juniorConversationParticipants.lastMessageAt}, excluded.last_message_at)`,
245
- ...args.restoreArchive ? { archivedAt: null } : {}
245
+ ...args.restoreArchive ? { archivedAt: null } : void 0
246
246
  }
247
247
  });
248
248
  }
@@ -273,7 +273,7 @@ function normalizeSessionSource(value) {
273
273
  visibility: value.visibility,
274
274
  teamId: value.teamId,
275
275
  channelId: value.channelId,
276
- ...threadTs ? { threadTs } : {}
276
+ ...threadTs ? { threadTs } : void 0
277
277
  };
278
278
  }
279
279
  function parseSessionSource(value) {
@@ -318,9 +318,9 @@ function identityFromActor(actor) {
318
318
  provider: "slack",
319
319
  providerTenantId: actor.teamId,
320
320
  providerSubjectId: actor.slackUserId,
321
- ...actor.fullName ? { displayName: actor.fullName } : {},
322
- ...actor.slackUserName ? { handle: actor.slackUserName } : {},
323
- ...actor.email ? { email: actor.email, emailVerified: true } : {},
321
+ ...actor.fullName ? { displayName: actor.fullName } : void 0,
322
+ ...actor.slackUserName ? { handle: actor.slackUserName } : void 0,
323
+ ...actor.email ? { email: actor.email, emailVerified: true } : void 0,
324
324
  metadata: { platform: "slack" }
325
325
  };
326
326
  }
@@ -334,7 +334,7 @@ function identityFromActor(actor) {
334
334
  providerSubjectId: email,
335
335
  email,
336
336
  emailVerified: true,
337
- ...actor?.fullName ? { displayName: actor.fullName } : {},
337
+ ...actor?.fullName ? { displayName: actor.fullName } : void 0,
338
338
  metadata: { platform: "web" }
339
339
  };
340
340
  }
@@ -376,18 +376,18 @@ function actorFromIdentityRow(identity, userDisplayName) {
376
376
  const email = identity.emailNormalized ?? identity.email ?? void 0;
377
377
  if (identity.provider === "slack") {
378
378
  return {
379
- ...email ? { email } : {},
380
- ...fullName ? { fullName } : {},
379
+ ...email ? { email } : void 0,
380
+ ...fullName ? { fullName } : void 0,
381
381
  platform: "slack",
382
382
  slackUserId: identity.providerSubjectId,
383
- ...identity.handle ? { slackUserName: identity.handle } : {},
384
- ...identity.providerTenantId ? { teamId: identity.providerTenantId } : {}
383
+ ...identity.handle ? { slackUserName: identity.handle } : void 0,
384
+ ...identity.providerTenantId ? { teamId: identity.providerTenantId } : void 0
385
385
  };
386
386
  }
387
387
  if (identity.provider === "junior" && email) {
388
388
  return {
389
389
  email,
390
- ...fullName ? { fullName } : {}
390
+ ...fullName ? { fullName } : void 0
391
391
  };
392
392
  }
393
393
  return void 0;
@@ -404,12 +404,12 @@ function mergeActor(current2, next) {
404
404
  }
405
405
  return {
406
406
  ...current2,
407
- ...current2.email ?? next.email ? { email: current2.email ?? next.email } : {},
408
- ...current2.fullName ?? next.fullName ? { fullName: current2.fullName ?? next.fullName } : {},
409
- ...current2.platform ?? next.platform ? { platform: current2.platform ?? next.platform } : {},
410
- ...current2.slackUserId ?? next.slackUserId ? { slackUserId: current2.slackUserId ?? next.slackUserId } : {},
411
- ...current2.slackUserName ?? next.slackUserName ? { slackUserName: current2.slackUserName ?? next.slackUserName } : {},
412
- ...current2.teamId ?? next.teamId ? { teamId: current2.teamId ?? next.teamId } : {}
407
+ ...current2.email ?? next.email ? { email: current2.email ?? next.email } : void 0,
408
+ ...current2.fullName ?? next.fullName ? { fullName: current2.fullName ?? next.fullName } : void 0,
409
+ ...current2.platform ?? next.platform ? { platform: current2.platform ?? next.platform } : void 0,
410
+ ...current2.slackUserId ?? next.slackUserId ? { slackUserId: current2.slackUserId ?? next.slackUserId } : void 0,
411
+ ...current2.slackUserName ?? next.slackUserName ? { slackUserName: current2.slackUserName ?? next.slackUserName } : void 0,
412
+ ...current2.teamId ?? next.teamId ? { teamId: current2.teamId ?? next.teamId } : void 0
413
413
  };
414
414
  }
415
415
 
@@ -435,7 +435,7 @@ function locationFromRow(row) {
435
435
  return locationSchema.parse({
436
436
  id: row.id,
437
437
  provider: row.provider,
438
- ...row.providerTenantId ? { tenantId: row.providerTenantId } : {},
438
+ ...row.providerTenantId ? { tenantId: row.providerTenantId } : void 0,
439
439
  providerId: row.providerDestinationId
440
440
  });
441
441
  }
@@ -505,7 +505,7 @@ function destinationUpsertFromDestination(args) {
505
505
  providerDestinationId: channelId,
506
506
  refreshVisibility: args.visibility !== void 0,
507
507
  visibility: args.visibility ?? "unknown",
508
- ...args.channelName ? { displayName: args.channelName } : {},
508
+ ...args.channelName ? { displayName: args.channelName } : void 0,
509
509
  metadata: { platform: "slack" }
510
510
  };
511
511
  }
@@ -574,7 +574,7 @@ function conversationFromRow(readRow) {
574
574
  status: executionStatusFromValue(row.executionStatus),
575
575
  lastCheckpointAtMs: msFromDate(row.lastCheckpointAt),
576
576
  lastEnqueuedAtMs: msFromDate(row.lastEnqueuedAt),
577
- ...row.runId ? { runId: row.runId } : {},
577
+ ...row.runId ? { runId: row.runId } : void 0,
578
578
  updatedAtMs: msFromDate(row.executionUpdatedAt) ?? requiredMsFromDate(row.updatedAt)
579
579
  };
580
580
  const location = locationFromRow(readRow.destination);
@@ -587,23 +587,23 @@ function conversationFromRow(readRow) {
587
587
  execution,
588
588
  executionMetrics: {
589
589
  durationMs: row.executionDurationMs,
590
- ...row.metricRunId ? { runId: row.metricRunId } : {},
591
- ...row.executionUsage ? { usage: row.executionUsage } : {}
590
+ ...row.metricRunId ? { runId: row.metricRunId } : void 0,
591
+ ...row.executionUsage ? { usage: row.executionUsage } : void 0
592
592
  },
593
593
  ...row.parentConversationId ? {
594
594
  lineage: {
595
595
  parentConversationId: row.parentConversationId
596
596
  }
597
- } : {},
598
- ...destination ? { destination } : {},
599
- ...location ? { location } : {},
600
- ...actor ? { actor } : {},
601
- ...row.channelName ? { channelName: row.channelName } : {},
602
- ...source ? { source } : {},
603
- ...sessionSource ? { sessionSource } : {},
604
- ...row.title ? { title: row.title } : {},
605
- ...msFromDate(row.transcriptPurgedAt) !== void 0 ? { transcriptPurgedAtMs: msFromDate(row.transcriptPurgedAt) } : {},
606
- ...visibility ? { visibility } : {}
597
+ } : void 0,
598
+ ...destination ? { destination } : void 0,
599
+ ...location ? { location } : void 0,
600
+ ...actor ? { actor } : void 0,
601
+ ...row.channelName ? { channelName: row.channelName } : void 0,
602
+ ...source ? { source } : void 0,
603
+ ...sessionSource ? { sessionSource } : void 0,
604
+ ...row.title ? { title: row.title } : void 0,
605
+ ...msFromDate(row.transcriptPurgedAt) !== void 0 ? { transcriptPurgedAtMs: msFromDate(row.transcriptPurgedAt) } : void 0,
606
+ ...visibility ? { visibility } : void 0
607
607
  };
608
608
  }
609
609
  function emptyConversation(args) {
@@ -613,9 +613,9 @@ function emptyConversation(args) {
613
613
  createdAtMs: args.nowMs,
614
614
  lastActivityAtMs: args.nowMs,
615
615
  updatedAtMs: args.nowMs,
616
- ...args.destination ? { destination: args.destination } : {},
617
- ...args.source ? { source: args.source } : {},
618
- ...args.sessionSource ? { sessionSource: args.sessionSource } : {},
616
+ ...args.destination ? { destination: args.destination } : void 0,
617
+ ...args.source ? { source: args.source } : void 0,
618
+ ...args.sessionSource ? { sessionSource: args.sessionSource } : void 0,
619
619
  execution: {
620
620
  status: "idle",
621
621
  updatedAtMs: args.nowMs
@@ -742,7 +742,7 @@ var SqlStore = class {
742
742
  destination: args.destination,
743
743
  nowMs,
744
744
  source: args.source,
745
- ...sessionSource ? { sessionSource } : {}
745
+ ...sessionSource ? { sessionSource } : void 0
746
746
  });
747
747
  const {
748
748
  sessionSource: _persistedSessionSource,
@@ -754,7 +754,7 @@ var SqlStore = class {
754
754
  ...currentWithoutPersistedSignals,
755
755
  destination: current2.destination ?? args.destination,
756
756
  source: current2.source ?? args.source,
757
- ...sessionSource ? { sessionSource } : {},
757
+ ...sessionSource ? { sessionSource } : void 0,
758
758
  channelName: current2.channelName ?? args.channelName,
759
759
  actor: mergeActor(current2.actor, args.actor),
760
760
  title: current2.title ?? args.title,
@@ -764,7 +764,7 @@ var SqlStore = class {
764
764
  ...current2.execution,
765
765
  updatedAtMs: current2.execution.updatedAtMs ?? nowMs
766
766
  },
767
- ...args.visibility ? { visibility: args.visibility } : {}
767
+ ...args.visibility ? { visibility: args.visibility } : void 0
768
768
  }
769
769
  });
770
770
  });
@@ -786,12 +786,12 @@ var SqlStore = class {
786
786
  createdAtMs: args.createdAtMs,
787
787
  lastActivityAtMs: args.lastActivityAtMs,
788
788
  updatedAtMs: args.updatedAtMs,
789
- ...args.channelName ? { channelName: args.channelName } : {},
790
- ...args.destination ? { destination: args.destination } : {},
791
- ...args.actor ? { actor: args.actor } : {},
792
- ...args.source ? { source: args.source } : {},
793
- ...args.title ? { title: args.title } : {},
794
- ...args.visibility ? { visibility: args.visibility } : {},
789
+ ...args.channelName ? { channelName: args.channelName } : void 0,
790
+ ...args.destination ? { destination: args.destination } : void 0,
791
+ ...args.actor ? { actor: args.actor } : void 0,
792
+ ...args.source ? { source: args.source } : void 0,
793
+ ...args.title ? { title: args.title } : void 0,
794
+ ...args.visibility ? { visibility: args.visibility } : void 0,
795
795
  execution
796
796
  }
797
797
  });
@@ -884,7 +884,7 @@ var SqlStore = class {
884
884
  }
885
885
  return {
886
886
  channelId: row.channelId,
887
- ...row.channelName ? { channelName: row.channelName } : {}
887
+ ...row.channelName ? { channelName: row.channelName } : void 0
888
888
  };
889
889
  }
890
890
  /** Serialize all durable mutations for one conversation inside a SQL transaction. */
@@ -921,7 +921,7 @@ var SqlStore = class {
921
921
  channelName: conversation.channelName,
922
922
  conversationId: conversation.conversationId,
923
923
  destination: conversation.destination,
924
- ...conversation.visibility ? { visibility: conversation.visibility } : {}
924
+ ...conversation.visibility ? { visibility: conversation.visibility } : void 0
925
925
  }),
926
926
  conversation.updatedAtMs
927
927
  );
@@ -1108,10 +1108,6 @@ function instructionActors(provenance) {
1108
1108
  }
1109
1109
 
1110
1110
  // src/chat/conversations/history.ts
1111
- var handoffModelProfileSchema = modelProfileSchema.refine(
1112
- (profile) => profile !== "standard",
1113
- "handoff profile must not be standard"
1114
- );
1115
1111
  var userMessageEventDataSchema = z3.object({
1116
1112
  type: z3.literal("user_message"),
1117
1113
  role: z3.never().optional(),
@@ -1150,7 +1146,7 @@ var compactionDetailsSchema = z3.object({
1150
1146
  var historyReplacementEventDataSchema = z3.discriminatedUnion("type", [
1151
1147
  z3.object({
1152
1148
  type: z3.literal("handoff"),
1153
- modelProfile: handoffModelProfileSchema,
1149
+ modelProfile: modelProfileSchema,
1154
1150
  modelId: z3.string().min(1),
1155
1151
  reasoningLevel: z3.string().min(1).optional(),
1156
1152
  triggeringToolCallId: z3.string().min(1).optional(),
@@ -1473,11 +1469,11 @@ function readAuthor(meta) {
1473
1469
  }
1474
1470
  const author = meta.author;
1475
1471
  return {
1476
- ...typeof author.email === "string" ? { email: author.email } : {},
1477
- ...typeof author.fullName === "string" ? { fullName: author.fullName } : {},
1478
- ...typeof author.isBot === "boolean" ? { isBot: author.isBot } : {},
1479
- ...typeof author.userId === "string" ? { userId: author.userId } : {},
1480
- ...typeof author.userName === "string" ? { userName: author.userName } : {}
1472
+ ...typeof author.email === "string" ? { email: author.email } : void 0,
1473
+ ...typeof author.fullName === "string" ? { fullName: author.fullName } : void 0,
1474
+ ...typeof author.isBot === "boolean" ? { isBot: author.isBot } : void 0,
1475
+ ...typeof author.userId === "string" ? { userId: author.userId } : void 0,
1476
+ ...typeof author.userName === "string" ? { userName: author.userName } : void 0
1481
1477
  };
1482
1478
  }
1483
1479
  async function loadConversationSlackTenantId(executor, conversationId) {
@@ -1573,10 +1569,10 @@ async function resolveEventActorIdentityId(executor, args) {
1573
1569
  kind: "user",
1574
1570
  provider: "slack",
1575
1571
  providerSubjectId: userId,
1576
- ...tenantId3 ? { providerTenantId: tenantId3 } : {},
1577
- ...author.fullName ? { displayName: author.fullName } : {},
1578
- ...author.userName ? { handle: author.userName } : {},
1579
- ...author.email ? { email: author.email, emailVerified: true } : {}
1572
+ ...tenantId3 ? { providerTenantId: tenantId3 } : void 0,
1573
+ ...author.fullName ? { displayName: author.fullName } : void 0,
1574
+ ...author.userName ? { handle: author.userName } : void 0,
1575
+ ...author.email ? { email: author.email, emailVerified: true } : void 0
1580
1576
  };
1581
1577
  if (tenantId3) {
1582
1578
  const stored = await upsertIdentity(executor, observation, args.nowMs);
@@ -1597,7 +1593,7 @@ async function resolveEventActorIdentityId(executor, args) {
1597
1593
  providerSubjectId: email,
1598
1594
  email,
1599
1595
  emailVerified: true,
1600
- ...author.fullName ? { displayName: author.fullName } : {},
1596
+ ...author.fullName ? { displayName: author.fullName } : void 0,
1601
1597
  metadata: { platform: "web" }
1602
1598
  },
1603
1599
  args.nowMs
@@ -1695,7 +1691,7 @@ function eventFromRow(row) {
1695
1691
  schemaVersion: row.schemaVersion,
1696
1692
  seq: row.seq,
1697
1693
  historyVersion: row.historyVersion,
1698
- ...row.idempotencyKey ? { idempotencyKey: row.idempotencyKey } : {},
1694
+ ...row.idempotencyKey ? { idempotencyKey: row.idempotencyKey } : void 0,
1699
1695
  createdAtMs: row.createdAt.getTime(),
1700
1696
  type: row.type,
1701
1697
  payload
@@ -2078,7 +2074,7 @@ var SqlConversationMessageSearchStore = class {
2078
2074
  messageId: row.messageId,
2079
2075
  providerDestinationId: row.providerDestinationId,
2080
2076
  role: row.role,
2081
- ...row.channelName ? { channelName: row.channelName } : {}
2077
+ ...row.channelName ? { channelName: row.channelName } : void 0
2082
2078
  }));
2083
2079
  }
2084
2080
  };
@@ -5,6 +5,7 @@ import {
5
5
  beginConversationResume,
6
6
  checkInConversationWork,
7
7
  clearConsumedConversationWake,
8
+ completeConversationStop,
8
9
  completeConversationWork,
9
10
  countPendingConversationMessages,
10
11
  deadLetterAttempt,
@@ -18,26 +19,27 @@ import {
18
19
  releaseConversationWork,
19
20
  requestAnotherSlice,
20
21
  startConversationWork
21
- } from "./chunk-5IRROPA5.js";
22
+ } from "./chunk-L7LTGN4Z.js";
22
23
  import {
23
24
  ConversationQueueMessageRejectedError
24
25
  } from "./chunk-JAL3CH4G.js";
25
26
  import {
26
27
  getTurnRequestDeadline
27
- } from "./chunk-4GWXAILB.js";
28
+ } from "./chunk-ZE2KOV3G.js";
28
29
  import {
29
30
  getChatConfig,
30
31
  isProviderRetryError
31
- } from "./chunk-GENV6KF2.js";
32
+ } from "./chunk-I6IFTAPF.js";
32
33
  import {
33
34
  logException,
34
35
  logInfo,
35
36
  logWarn,
36
37
  withLogContext
37
- } from "./chunk-HQNE5APD.js";
38
+ } from "./chunk-RAZG3YHC.js";
38
39
 
39
40
  // src/chat/task-execution/worker.ts
40
41
  var CONVERSATION_WORK_DEFER_DELAY_MS = 15e3;
42
+ var CONVERSATION_STOP_CHECK_INTERVAL_MS = 500;
41
43
  function now(options) {
42
44
  return options.nowMs?.() ?? Date.now();
43
45
  }
@@ -182,6 +184,63 @@ function startLeaseCheckIn(args) {
182
184
  timer.unref?.();
183
185
  return timer;
184
186
  }
187
+ function createConversationStopSignal(args) {
188
+ const controller = new AbortController();
189
+ let checking = false;
190
+ let failureCaptured = false;
191
+ let listening = false;
192
+ let timer;
193
+ const requestStop = () => {
194
+ if (!controller.signal.aborted) {
195
+ controller.abort(new Error("Conversation work stopped"));
196
+ }
197
+ };
198
+ if (args.initialStopRunId === args.runId) {
199
+ requestStop();
200
+ }
201
+ const check = async () => {
202
+ if (checking || controller.signal.aborted) return;
203
+ checking = true;
204
+ try {
205
+ const current = await getConversationWorkState({
206
+ conversationId: args.conversationId,
207
+ state: args.options.state
208
+ });
209
+ if (current?.execution.stop?.runId === args.runId) {
210
+ requestStop();
211
+ }
212
+ } catch (error) {
213
+ if (!failureCaptured) {
214
+ failureCaptured = true;
215
+ logException(error, "conversation.work.stop_check.failed");
216
+ }
217
+ } finally {
218
+ checking = false;
219
+ }
220
+ };
221
+ return {
222
+ close() {
223
+ if (timer) clearInterval(timer);
224
+ },
225
+ isEnabled() {
226
+ return listening;
227
+ },
228
+ wasObserved() {
229
+ return listening && controller.signal.aborted;
230
+ },
231
+ signal() {
232
+ listening = true;
233
+ if (!timer && !controller.signal.aborted) {
234
+ timer = setInterval(
235
+ () => void check(),
236
+ CONVERSATION_STOP_CHECK_INTERVAL_MS
237
+ );
238
+ timer.unref?.();
239
+ }
240
+ return controller.signal;
241
+ }
242
+ };
243
+ }
185
244
  async function processConversationWork(message, options) {
186
245
  return withLogContext(
187
246
  { conversationId: message.conversationId },
@@ -336,6 +395,7 @@ async function processConversationWorkInContext(message, options) {
336
395
  };
337
396
  try {
338
397
  let hasRun = false;
398
+ let resumeIfStopped = false;
339
399
  while (true) {
340
400
  attemptMessageIds = [];
341
401
  const leasedWork = await getConversationWorkState({
@@ -355,6 +415,10 @@ async function processConversationWorkInContext(message, options) {
355
415
  }
356
416
  const resumePending = leasedWork.execution.status === "paused";
357
417
  const attemptMessages = selectAttemptMessages(leasedWork);
418
+ const runId = leasedWork.execution.runId;
419
+ if (!runId) {
420
+ throw new Error(`Conversation run is missing for ${conversationId}`);
421
+ }
358
422
  attemptStartMessageIds = new Set(
359
423
  leasedWork.messages.map((message2) => message2.inboundMessageId)
360
424
  );
@@ -405,6 +469,12 @@ async function processConversationWorkInContext(message, options) {
405
469
  );
406
470
  }
407
471
  };
472
+ const stop = createConversationStopSignal({
473
+ conversationId,
474
+ initialStopRunId: leasedWork.execution.stop?.runId,
475
+ options,
476
+ runId
477
+ });
408
478
  const workerContext = {
409
479
  attempt: {
410
480
  ack,
@@ -420,9 +490,16 @@ async function processConversationWorkInContext(message, options) {
420
490
  destination,
421
491
  publishExternally,
422
492
  shouldYield,
493
+ stopSignal: stop.signal,
423
494
  checkIn
424
495
  };
425
- const result = await options.run(workerContext);
496
+ let result;
497
+ try {
498
+ result = await options.run(workerContext);
499
+ } finally {
500
+ stop.close();
501
+ }
502
+ resumeIfStopped ||= stop.isEnabled();
426
503
  hasRun = true;
427
504
  if (result.status === "lost_lease") {
428
505
  await requestLostLeaseRecovery({
@@ -444,6 +521,27 @@ async function processConversationWorkInContext(message, options) {
444
521
  });
445
522
  return { status: "lost_lease" };
446
523
  }
524
+ if (result.status === "completed" && stop.wasObserved()) {
525
+ const stopped = await completeConversationStop({
526
+ conversationId,
527
+ conversationStore: options.conversationStore,
528
+ leaseToken: lease.leaseToken,
529
+ nowMs: now(options),
530
+ runId,
531
+ state: options.state
532
+ });
533
+ if (stopped.status === "lost_lease") {
534
+ markLeaseLost();
535
+ await requestLostLeaseRecovery({
536
+ conversationId,
537
+ destination,
538
+ leaseToken: lease.leaseToken,
539
+ nowMs: now(options),
540
+ options
541
+ });
542
+ return { status: "lost_lease" };
543
+ }
544
+ }
447
545
  if (result.status === "yielded") {
448
546
  const sliceRequested = await requestAnotherSlice({
449
547
  conversationId,
@@ -519,6 +617,9 @@ async function processConversationWorkInContext(message, options) {
519
617
  break;
520
618
  }
521
619
  }
620
+ if (result.status === "paused") {
621
+ break;
622
+ }
522
623
  const next = await getConversationWorkState({
523
624
  conversationId,
524
625
  state: options.state
@@ -534,6 +635,8 @@ async function processConversationWorkInContext(message, options) {
534
635
  conversationId,
535
636
  leaseToken: lease.leaseToken,
536
637
  madeProgress: !failedWithoutProgress,
638
+ // A stop that raced an external pause must reach the paused Turn.
639
+ resumeIfStopped,
537
640
  conversationStore: options.conversationStore,
538
641
  nowMs: now(options),
539
642
  state: options.state
@@ -1,12 +1,11 @@
1
1
  import {
2
- appendAndEnqueueInboundMessage
3
- } from "./chunk-5IRROPA5.js";
2
+ ConversationTurnLifecycleService
3
+ } from "./chunk-M3QYTBQ6.js";
4
4
  import {
5
- ConversationTurnLifecycleService,
6
5
  getPersistedSandboxState,
7
6
  getPersistedThreadState,
8
7
  persistThreadStateById
9
- } from "./chunk-CJLBLELR.js";
8
+ } from "./chunk-5TUR4M3M.js";
10
9
  import {
11
10
  AgentInvocationBusyError,
12
11
  AgentInvocationLimitError,
@@ -15,27 +14,32 @@ import {
15
14
  agentBindingSchema,
16
15
  agentInvocationSchema,
17
16
  createAgentInvocationSchema
18
- } from "./chunk-3AFVR5UC.js";
17
+ } from "./chunk-VG722ONZ.js";
18
+ import {
19
+ appendAndEnqueueInboundMessage
20
+ } from "./chunk-L7LTGN4Z.js";
19
21
  import {
20
22
  TurnInputCommitLostError,
21
- failTurnRecord,
22
23
  getAssistantReplyText,
23
24
  getConversationTurnBoundaryError,
25
+ isTurnInputCommitLostError
26
+ } from "./chunk-GUKXEPMX.js";
27
+ import {
28
+ failTurnRecord,
24
29
  getTerminalAssistantMessages,
25
30
  getTurnRecord,
26
- isTurnInputCommitLostError,
27
31
  openConversationProjection,
28
32
  saveTurnCheckpoint
29
- } from "./chunk-FIDMHAO6.js";
33
+ } from "./chunk-GPXAHUQH.js";
30
34
  import {
31
35
  getConversationEventStore,
32
36
  getConversationStore,
33
37
  getSqlExecutor
34
- } from "./chunk-VP4OVRDD.js";
38
+ } from "./chunk-S7YRTOSQ.js";
35
39
  import {
36
40
  juniorAgentBindings,
37
41
  juniorAgentInvocations
38
- } from "./chunk-R6U7N4FS.js";
42
+ } from "./chunk-FGC3PHNH.js";
39
43
 
40
44
  // src/chat/agent-invocations/work.ts
41
45
  import { z } from "zod";
@@ -84,22 +88,22 @@ function bindingFromRow(row) {
84
88
  function invocationFromRow(row) {
85
89
  return agentInvocationSchema.parse({
86
90
  actor: row.actor,
87
- ...row.agentName ? { agentName: row.agentName } : {},
91
+ ...row.agentName ? { agentName: row.agentName } : void 0,
88
92
  childConversationId: row.childConversationId,
89
93
  createdAtMs: row.createdAt.getTime(),
90
- ...row.credentialContext ? { credentialContext: row.credentialContext } : {},
94
+ ...row.credentialContext ? { credentialContext: row.credentialContext } : void 0,
91
95
  destination: row.destination,
92
- ...row.destinationVisibility ? { destinationVisibility: row.destinationVisibility } : {},
93
- ...row.errorMessage !== null ? { errorMessage: row.errorMessage } : {},
96
+ ...row.destinationVisibility ? { destinationVisibility: row.destinationVisibility } : void 0,
97
+ ...row.errorMessage !== null ? { errorMessage: row.errorMessage } : void 0,
94
98
  input: row.input,
95
99
  invocationId: row.invocationId,
96
100
  mailboxStatus: row.mailboxStatus,
97
101
  parentConversationId: row.parentConversationId,
98
- ...row.reasoningLevel ? { reasoningLevel: row.reasoningLevel } : {},
99
- ...row.result !== null ? { result: row.result } : {},
102
+ ...row.reasoningLevel ? { reasoningLevel: row.reasoningLevel } : void 0,
103
+ ...row.result !== null ? { result: row.result } : void 0,
100
104
  source: row.source,
101
105
  status: row.status,
102
- ...row.terminalAt ? { terminalAtMs: row.terminalAt.getTime() } : {},
106
+ ...row.terminalAt ? { terminalAtMs: row.terminalAt.getTime() } : void 0,
103
107
  updatedAtMs: row.updatedAt.getTime()
104
108
  });
105
109
  }
@@ -619,7 +623,7 @@ function createAgentInvocationWorker(options) {
619
623
  destinationVisibility: invocation.destinationVisibility,
620
624
  ...failed ? {
621
625
  errorMessage: result.diagnostics.errorMessage ?? "Agent invocation failed"
622
- } : {},
626
+ } : void 0,
623
627
  messages: result.piMessages,
624
628
  actor: invocation.actor,
625
629
  source: invocation.source,
@@ -112,7 +112,7 @@ function resolvePackageWithNode(cwd, packageName) {
112
112
  const nodeModulesDir = findPackageNodeModulesDir(dir, packageName);
113
113
  return {
114
114
  dir,
115
- ...nodeModulesDir ? { nodeModulesDir } : {}
115
+ ...nodeModulesDir ? { nodeModulesDir } : void 0
116
116
  };
117
117
  } catch {
118
118
  }