@sentry/junior 0.179.0 → 0.181.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 (137) hide show
  1. package/dist/{agent-hooks-32IDCLMW.js → agent-hooks-IQUW6ERD.js} +16 -18
  2. package/dist/api/schema/workspace.d.ts +2 -0
  3. package/dist/api/schema.js +1 -2
  4. package/dist/api.js +202 -199
  5. package/dist/app.d.ts +4 -0
  6. package/dist/app.js +300 -1259
  7. package/dist/catalog-runtime-PMQWNIXA.js +14 -0
  8. package/dist/chat/agent/sandbox.d.ts +0 -2
  9. package/dist/chat/api-turns/routing.d.ts +4 -0
  10. package/dist/chat/api-turns/work.d.ts +5 -0
  11. package/dist/chat/config.d.ts +5 -2
  12. package/dist/chat/configuration/defaults.d.ts +1 -1
  13. package/dist/chat/conversations/projection.d.ts +6 -4
  14. package/dist/chat/ingress/message-router.d.ts +3 -0
  15. package/dist/chat/model-profile.d.ts +8 -10
  16. package/dist/chat/pi/conversation-events.d.ts +3 -2
  17. package/dist/chat/plugins/agent-hooks.d.ts +1 -1
  18. package/dist/chat/plugins/task-queue.d.ts +40 -3
  19. package/dist/chat/plugins/task-runner.d.ts +1 -1
  20. package/dist/chat/queue/callback.d.ts +26 -0
  21. package/dist/chat/queue/sign.d.ts +30 -0
  22. package/dist/chat/sandbox/sandbox.d.ts +0 -2
  23. package/dist/chat/sandbox/session.d.ts +0 -2
  24. package/dist/chat/sandbox/skill-sync.d.ts +1 -1
  25. package/dist/chat/sandbox/snapshot/events.d.ts +23 -0
  26. package/dist/chat/sandbox/snapshot/job-callback.d.ts +5 -0
  27. package/dist/chat/sandbox/snapshot/job-queue.d.ts +26 -0
  28. package/dist/chat/sandbox/snapshot/job-runner.d.ts +11 -0
  29. package/dist/chat/sandbox/snapshot/not-ready-error.d.ts +6 -0
  30. package/dist/chat/sandbox/snapshot/workspace.d.ts +9 -3
  31. package/dist/chat/services/turn-router.d.ts +4 -3
  32. package/dist/chat/services/turn-session-routing.d.ts +1 -0
  33. package/dist/chat/task-execution/queue-signing.d.ts +10 -21
  34. package/dist/chat/task-execution/state.d.ts +48 -0
  35. package/dist/chat/task-execution/store.d.ts +28 -2
  36. package/dist/chat/task-execution/worker.d.ts +4 -1
  37. package/dist/chat/tools/handoff/tool.d.ts +1 -1
  38. package/dist/chat/tools/types.d.ts +2 -0
  39. package/dist/chat/workspaces/types.d.ts +2 -0
  40. package/dist/{chunk-Q5B3WTGG.js → chunk-3KCQEG6W.js} +42 -41
  41. package/dist/{chunk-XZY6G5YZ.js → chunk-3KSSALN4.js} +180 -87
  42. package/dist/{chunk-3AFVR5UC.js → chunk-3X55QRAG.js} +18 -16
  43. package/dist/{chunk-SLGGOASN.js → chunk-4IX32NSL.js} +46 -46
  44. package/dist/{chunk-6ZWRNC4D.js → chunk-6Y5B5PEX.js} +1 -1
  45. package/dist/chunk-7H2VZTWN.js +103 -0
  46. package/dist/{chunk-CGA4ERJ5.js → chunk-CEMMLV5L.js} +1 -1
  47. package/dist/{chunk-FIANEE7Z.js → chunk-CM5HNV2W.js} +6 -6
  48. package/dist/{chunk-TKB25A3L.js → chunk-CZYNWPWD.js} +2 -1
  49. package/dist/{chunk-3I7XE3PA.js → chunk-D6ZD7VXP.js} +49 -38
  50. package/dist/chunk-DKIJ2RP5.js +68 -0
  51. package/dist/{chunk-G2CAC4CV.js → chunk-DSA6WTRP.js} +74 -68
  52. package/dist/{chunk-OOUNJNMR.js → chunk-DWPN6SCH.js} +1 -1
  53. package/dist/{chunk-HQNE5APD.js → chunk-EBMRB6Z6.js} +100 -79
  54. package/dist/{chunk-ZQMG3CL5.js → chunk-EM7EECT5.js} +16 -16
  55. package/dist/{chunk-XSPSCWLH.js → chunk-ETJTXYHY.js} +4 -4
  56. package/dist/{chunk-FTGD2FBP.js → chunk-EU7KJDOG.js} +2 -2
  57. package/dist/{chunk-CJLBLELR.js → chunk-FWILPBVQ.js} +8 -61
  58. package/dist/{chunk-4GWXAILB.js → chunk-GPA3ZSYY.js} +1 -1
  59. package/dist/{chunk-U4TKB6F6.js → chunk-GREV5PJK.js} +108 -5
  60. package/dist/{chunk-KJLHIHFF.js → chunk-GWFRPQNP.js} +43 -230
  61. package/dist/{chunk-YFNAMRGE.js → chunk-HEBMSITT.js} +1 -1
  62. package/dist/chunk-HJ27A6YB.js +218 -0
  63. package/dist/{chunk-R5NWWYIS.js → chunk-HZHUMCNV.js} +5 -5
  64. package/dist/{chunk-RTRBYSF3.js → chunk-IJ6SS4WB.js} +1 -1
  65. package/dist/{chunk-B6ECUSVX.js → chunk-IKKETMQC.js} +8 -8
  66. package/dist/{chunk-R6U7N4FS.js → chunk-KKSVCHDO.js} +10 -3
  67. package/dist/{chunk-JMJNFEDC.js → chunk-KMBU4PJP.js} +9 -54
  68. package/dist/chunk-KQZX24QQ.js +164 -0
  69. package/dist/{chunk-GPLAT6H7.js → chunk-LCNPXLE7.js} +22 -18
  70. package/dist/{chunk-2HIPYNQI.js → chunk-LG5MYY6U.js} +33 -32
  71. package/dist/chunk-LZOQFC5F.js +209 -0
  72. package/dist/chunk-M3QYTBQ6.js +55 -0
  73. package/dist/{chunk-M63DETLL.js → chunk-N7TMSOZH.js} +6 -6
  74. package/dist/{chunk-FIDMHAO6.js → chunk-NQTA72Q3.js} +84 -274
  75. package/dist/{chunk-RZRYOLCE.js → chunk-PBKZQAUA.js} +2315 -1150
  76. package/dist/chunk-PEQXYSSE.js +45 -0
  77. package/dist/{chunk-3TM3FYLQ.js → chunk-PL57B6NC.js} +1 -1
  78. package/dist/{chunk-JT4WMD3C.js → chunk-PPYDHUEL.js} +144 -218
  79. package/dist/{chunk-5IRROPA5.js → chunk-Q2KY27IX.js} +129 -31
  80. package/dist/{chunk-VP4OVRDD.js → chunk-RNMASWLP.js} +69 -73
  81. package/dist/{chunk-FAS6AIMF.js → chunk-TDT2R77B.js} +8 -8
  82. package/dist/{chunk-TIEKUH4Q.js → chunk-TJHSAHQN.js} +4 -3
  83. package/dist/{chunk-H4HBKISO.js → chunk-TXKUKMVO.js} +1 -1
  84. package/dist/chunk-X6GDDWQH.js +60 -0
  85. package/dist/{chunk-GENV6KF2.js → chunk-XYTJUHRZ.js} +108 -76
  86. package/dist/cli/chat.js +47 -43
  87. package/dist/cli/check.js +13 -15
  88. package/dist/cli/env.js +0 -1
  89. package/dist/cli/init.js +0 -1
  90. package/dist/cli/main.js +2 -3
  91. package/dist/cli/plugins.js +18 -20
  92. package/dist/cli/run.js +0 -1
  93. package/dist/cli/snapshot-create.js +14 -16
  94. package/dist/cli/upgrade.js +16 -18
  95. package/dist/{conversation-work-KATFHLG3.js → conversation-work-VIOQ5ZF3.js} +0 -2
  96. package/dist/db/schema/snapshots.d.ts +17 -0
  97. package/dist/db/schema.d.ts +17 -0
  98. package/dist/{db-EJAV7JL6.js → db-QNPVCQPT.js} +8 -10
  99. package/dist/deployment.d.ts +1 -0
  100. package/dist/{discovery-GUFTFBTL.js → discovery-DWVDM7UK.js} +1 -2
  101. package/dist/{experimental-XVDOSRBS.js → experimental-SIJSRDJD.js} +0 -1
  102. package/dist/instrumentation.js +7 -9
  103. package/dist/nitro.js +39 -13
  104. package/dist/{oauth-callback-server-GAVSUBTQ.js → oauth-callback-server-KYMPJOTC.js} +34 -32
  105. package/dist/{oauth-relay-3ZU72UGL.js → oauth-relay-5XPVRPYB.js} +0 -1
  106. package/dist/{plugins-HW4VWW6G.js → plugins-YTYJMMJF.js} +1 -2
  107. package/dist/{runner-34JL64JF.js → runner-3RS2D2ZR.js} +39 -33
  108. package/dist/{sandbox-egress-signals-DXOOBSBI.js → sandbox-egress-signals-FIL7EGPR.js} +5 -6
  109. package/dist/{sentry-JMWTS32N.js → sentry-MB3NL3IR.js} +1 -2
  110. package/dist/skills-5B3Y6XX6.js +27 -0
  111. package/dist/spawn-VYARS3DU.js +37 -0
  112. package/dist/task-runner-4IXKKZHL.js +32 -0
  113. package/dist/validation-Q65QD27B.js +17 -0
  114. package/dist/vercel.js +0 -1
  115. package/dist/version.js +1 -2
  116. package/dist/work-DCMQWAAP.js +45 -0
  117. package/dist/worker-QL3CHLZL.js +22 -0
  118. package/migrations/0035_workspace_snapshot_size_bytes.sql +2 -0
  119. package/migrations/meta/0035_snapshot.json +3048 -0
  120. package/migrations/meta/_journal.json +7 -0
  121. package/package.json +7 -6
  122. package/dist/catalog-runtime-FBVA6WAQ.js +0 -16
  123. package/dist/chat/plugins/task-callback.d.ts +0 -5
  124. package/dist/chat/plugins/task-message.d.ts +0 -23
  125. package/dist/chat/plugins/task-signing.d.ts +0 -31
  126. package/dist/chat/sandbox/snapshot/waiting-error.d.ts +0 -15
  127. package/dist/chat/services/workspace-snapshot-wait.d.ts +0 -27
  128. package/dist/chunk-5I6ORJUY.js +0 -127
  129. package/dist/chunk-6GWA276C.js +0 -72
  130. package/dist/chunk-MLKGABMK.js +0 -9
  131. package/dist/chunk-UT6X7XN7.js +0 -51
  132. package/dist/chunk-WR76IVA5.js +0 -130
  133. package/dist/skills-U545HALM.js +0 -29
  134. package/dist/spawn-I2S4IDUQ.js +0 -37
  135. package/dist/validation-EVXVGA44.js +0 -19
  136. package/dist/work-QOAUPDBU.js +0 -45
  137. package/dist/worker-5GX2IKLZ.js +0 -24
@@ -8,22 +8,22 @@ import {
8
8
  getConversationStore,
9
9
  parseDestination,
10
10
  sameDestination
11
- } from "./chunk-VP4OVRDD.js";
11
+ } from "./chunk-RNMASWLP.js";
12
12
  import {
13
13
  getDefaultRedisStateAdapterFor,
14
14
  getStateAdapter
15
- } from "./chunk-3TM3FYLQ.js";
15
+ } from "./chunk-PL57B6NC.js";
16
16
  import {
17
17
  getChatConfig
18
- } from "./chunk-GENV6KF2.js";
18
+ } from "./chunk-XYTJUHRZ.js";
19
19
  import {
20
20
  parseStoredSlackActor
21
- } from "./chunk-M63DETLL.js";
21
+ } from "./chunk-N7TMSOZH.js";
22
22
  import {
23
23
  isRecord,
24
24
  toOptionalNumber,
25
25
  toOptionalString
26
- } from "./chunk-HQNE5APD.js";
26
+ } from "./chunk-EBMRB6Z6.js";
27
27
 
28
28
  // src/chat/task-execution/state.ts
29
29
  import { randomUUID } from "crypto";
@@ -118,7 +118,7 @@ function upgradedPendingMessage(stored, duplicate) {
118
118
  const delivery = promotesInterrupt ? "interrupt" : stored.delivery;
119
119
  const input = promotesInterrupt ? {
120
120
  ...duplicate.input,
121
- ...inputHasAttachments(duplicate.input) || !inputHasAttachments(stored.input) ? {} : { attachments: stored.input.attachments }
121
+ ...inputHasAttachments(duplicate.input) || !inputHasAttachments(stored.input) ? void 0 : { attachments: stored.input.attachments }
122
122
  } : inputHasAttachments(duplicate.input) && !inputHasAttachments(stored.input) ? duplicate.input : stored.input;
123
123
  if (input === stored.input && delivery === stored.delivery) {
124
124
  return stored;
@@ -175,6 +175,18 @@ function normalizeLease(value) {
175
175
  expiresAtMs
176
176
  };
177
177
  }
178
+ function normalizeStop(value) {
179
+ if (!isRecord(value)) {
180
+ return void 0;
181
+ }
182
+ const inboundMessageIds = Array.isArray(value.inboundMessageIds) ? uniqueStrings(
183
+ value.inboundMessageIds.filter(
184
+ (id) => typeof id === "string"
185
+ )
186
+ ) : [];
187
+ const runId = toOptionalString(value.runId);
188
+ return runId ? { inboundMessageIds, runId } : void 0;
189
+ }
178
190
  function normalizeExecution(conversationId, value) {
179
191
  if (!isRecord(value)) {
180
192
  return void 0;
@@ -201,6 +213,9 @@ function normalizeExecution(conversationId, value) {
201
213
  value.inboundMessageIds.map((id) => typeof id === "string" ? id : void 0).filter((id) => Boolean(id))
202
214
  ) : [];
203
215
  const lease = normalizeLease(value.lease);
216
+ const runId = toOptionalString(value.runId);
217
+ const normalizedStop = normalizeStop(value.stop);
218
+ const stop = normalizedStop?.runId === runId ? normalizedStop : void 0;
204
219
  const normalizedStatus = status === "idle" && lease ? "running" : status === "idle" && pendingMessages2.length > 0 ? "pending" : status;
205
220
  return {
206
221
  status: normalizedStatus,
@@ -215,7 +230,8 @@ function normalizeExecution(conversationId, value) {
215
230
  lastEnqueuedAtMs: toOptionalNumber(value.lastEnqueuedAtMs),
216
231
  lastProgressAtMs: toOptionalNumber(value.lastProgressAtMs),
217
232
  retryCount: toOptionalNumber(value.retryCount),
218
- runId: toOptionalString(value.runId),
233
+ runId,
234
+ stop,
219
235
  updatedAtMs: toOptionalNumber(value.updatedAtMs)
220
236
  };
221
237
  }
@@ -244,11 +260,11 @@ function normalizeConversation(conversationId, value) {
244
260
  lastActivityAtMs,
245
261
  updatedAtMs,
246
262
  execution,
247
- ...destination ? { destination } : {},
248
- ...toOptionalString(value.title) ? { title: toOptionalString(value.title) } : {},
249
- ...toOptionalString(value.channelName) ? { channelName: toOptionalString(value.channelName) } : {},
250
- ...normalizeActor(value.actor) ? { actor: normalizeActor(value.actor) } : {},
251
- ...normalizeSource(value.source) ? { source: normalizeSource(value.source) } : {}
263
+ ...destination ? { destination } : void 0,
264
+ ...toOptionalString(value.title) ? { title: toOptionalString(value.title) } : void 0,
265
+ ...toOptionalString(value.channelName) ? { channelName: toOptionalString(value.channelName) } : void 0,
266
+ ...normalizeActor(value.actor) ? { actor: normalizeActor(value.actor) } : void 0,
267
+ ...normalizeSource(value.source) ? { source: normalizeSource(value.source) } : void 0
252
268
  };
253
269
  }
254
270
  function emptyConversation(args) {
@@ -258,8 +274,8 @@ function emptyConversation(args) {
258
274
  createdAtMs: args.nowMs,
259
275
  lastActivityAtMs: args.nowMs,
260
276
  updatedAtMs: args.nowMs,
261
- ...args.destination ? { destination: args.destination } : {},
262
- ...args.source ? { source: args.source } : {},
277
+ ...args.destination ? { destination: args.destination } : void 0,
278
+ ...args.source ? { source: args.source } : void 0,
263
279
  execution: {
264
280
  status: "idle",
265
281
  inboundMessageIds: [],
@@ -642,7 +658,7 @@ function conversationWorkState(conversation) {
642
658
  leaseExpiresAtMs: lease.expiresAtMs,
643
659
  leaseToken: lease.token
644
660
  }
645
- } : {},
661
+ } : void 0,
646
662
  messages: pendingMessages(conversation),
647
663
  needsRun: hasRunnableWork(conversation)
648
664
  };
@@ -655,7 +671,7 @@ async function getConversationWorkState(args) {
655
671
  const conversation = await getConversation(args);
656
672
  return conversation ? conversationWorkState(conversation) : void 0;
657
673
  }
658
- async function appendInboundMessage(args) {
674
+ async function appendInboundMessageWithAdmission(args) {
659
675
  const nowMs = args.nowMs ?? now();
660
676
  return await withConversationMutation(
661
677
  { conversationId: args.message.conversationId, state: args.state },
@@ -705,6 +721,9 @@ async function appendInboundMessage(args) {
705
721
  );
706
722
  return { status: "duplicate" };
707
723
  }
724
+ if (args.exclusive && hasRunnableWork(current)) {
725
+ return { status: "active" };
726
+ }
708
727
  const status = current.execution.lease && current.execution.status === "running" ? "running" : current.execution.lease ? "paused" : "pending";
709
728
  const next = {
710
729
  ...current,
@@ -736,6 +755,16 @@ async function appendInboundMessage(args) {
736
755
  }
737
756
  );
738
757
  }
758
+ async function appendInboundMessage(args) {
759
+ const result = await appendInboundMessageWithAdmission({
760
+ ...args,
761
+ exclusive: false
762
+ });
763
+ if (result.status === "active") {
764
+ throw new Error("Non-exclusive mailbox append returned active");
765
+ }
766
+ return result;
767
+ }
739
768
  async function requestConversationWork(args) {
740
769
  const nowMs = args.nowMs ?? now();
741
770
  return await withConversationMutation(args, async (state, lock) => {
@@ -984,6 +1013,50 @@ async function ackMessages(args) {
984
1013
  return true;
985
1014
  });
986
1015
  }
1016
+ function isHumanFacingMessage(message) {
1017
+ return message.source === "web" || message.source === "slack";
1018
+ }
1019
+ async function completeConversationStop(args) {
1020
+ const nowMs = args.nowMs ?? now();
1021
+ return await withConversationMutation(args, async (state, lock) => {
1022
+ const current = await readConversation(state, args.conversationId);
1023
+ if (!current || current.execution.lease?.token !== args.leaseToken) {
1024
+ return { status: "lost_lease", removedInboundMessageIds: [] };
1025
+ }
1026
+ const stop = current.execution.stop;
1027
+ if (!stop || stop.runId !== args.runId) {
1028
+ return { status: "none", removedInboundMessageIds: [] };
1029
+ }
1030
+ const stoppedInboundMessageIds = new Set(stop.inboundMessageIds);
1031
+ const removedInboundMessageIds = [];
1032
+ const pendingMessages2 = current.execution.pendingMessages.filter(
1033
+ (message) => {
1034
+ const shouldStop = stoppedInboundMessageIds.has(
1035
+ message.inboundMessageId
1036
+ );
1037
+ if (shouldStop) {
1038
+ removedInboundMessageIds.push(message.inboundMessageId);
1039
+ }
1040
+ return !shouldStop;
1041
+ }
1042
+ );
1043
+ await writeConversation(
1044
+ state,
1045
+ lock,
1046
+ withExecutionUpdate(
1047
+ current,
1048
+ {
1049
+ ...current.execution,
1050
+ lastEnqueuedAtMs: pendingMessages2.length === 0 ? void 0 : current.execution.lastEnqueuedAtMs,
1051
+ pendingMessages: pendingMessages2,
1052
+ stop: void 0
1053
+ },
1054
+ nowMs
1055
+ )
1056
+ );
1057
+ return { status: "cleared", removedInboundMessageIds };
1058
+ });
1059
+ }
987
1060
  async function cancelHumanFacingPendingMessages(args) {
988
1061
  const nowMs = args.nowMs ?? now();
989
1062
  const requestedIds = args.inboundMessageIds === void 0 ? void 0 : new Set(args.inboundMessageIds);
@@ -995,10 +1068,9 @@ async function cancelHumanFacingPendingMessages(args) {
995
1068
  const cancelledInboundMessageIds = [];
996
1069
  const pendingMessages2 = [];
997
1070
  for (const message of current.execution.pendingMessages) {
998
- const isHumanFacing = message.source === "web" || message.source === "slack";
999
1071
  const isRequested = requestedIds === void 0 || requestedIds.has(message.inboundMessageId);
1000
1072
  const isInSnapshot = args.receivedBeforeMs === void 0 || message.receivedAtMs <= args.receivedBeforeMs;
1001
- if (isHumanFacing && isRequested && isInSnapshot) {
1073
+ if (isHumanFacingMessage(message) && isRequested && isInSnapshot) {
1002
1074
  cancelledInboundMessageIds.push(message.inboundMessageId);
1003
1075
  continue;
1004
1076
  }
@@ -1019,7 +1091,8 @@ async function cancelHumanFacingPendingMessages(args) {
1019
1091
  pendingMessages: pendingMessages2,
1020
1092
  retryCount: becomesIdle ? 0 : current.execution.retryCount,
1021
1093
  runId: becomesIdle ? void 0 : current.execution.runId,
1022
- status: becomesIdle ? "idle" : current.execution.status
1094
+ status: becomesIdle ? "idle" : current.execution.status,
1095
+ stop: becomesIdle ? void 0 : current.execution.stop
1023
1096
  },
1024
1097
  nowMs
1025
1098
  )
@@ -1120,7 +1193,8 @@ async function recordConversationRetry(args) {
1120
1193
  retryCount: count,
1121
1194
  pendingMessages: stopped ? [] : current.execution.pendingMessages,
1122
1195
  runId: stopped ? void 0 : current.execution.runId,
1123
- status: stopped ? "failed" : "paused"
1196
+ status: stopped ? "failed" : "paused",
1197
+ stop: stopped ? void 0 : current.execution.stop
1124
1198
  },
1125
1199
  nowMs
1126
1200
  )
@@ -1136,7 +1210,7 @@ async function completeConversationWork(args) {
1136
1210
  return "lost_lease";
1137
1211
  }
1138
1212
  const hasPending = pendingMessages(current).length > 0;
1139
- const needsRun = current.execution.status === "paused";
1213
+ const needsRun = current.execution.status === "paused" || args.resumeIfStopped === true && current.execution.stop !== void 0;
1140
1214
  const runnable = needsRun || hasPending;
1141
1215
  await writeConversation(
1142
1216
  state,
@@ -1149,7 +1223,8 @@ async function completeConversationWork(args) {
1149
1223
  status: needsRun ? "paused" : hasPending ? "pending" : "idle",
1150
1224
  lastProgressAtMs: args.madeProgress === false ? current.execution.lastProgressAtMs : nowMs,
1151
1225
  retryCount: runnable || args.madeProgress === false ? current.execution.retryCount : 0,
1152
- runId: runnable ? current.execution.runId : void 0
1226
+ runId: runnable ? current.execution.runId : void 0,
1227
+ stop: runnable ? current.execution.stop : void 0
1153
1228
  },
1154
1229
  nowMs
1155
1230
  )
@@ -1244,7 +1319,8 @@ async function deadLetterAttempt(args) {
1244
1319
  ...current.execution,
1245
1320
  lease: void 0,
1246
1321
  status: runnable ? "pending" : "failed",
1247
- runId: runnable ? current.execution.runId : void 0
1322
+ runId: runnable ? current.execution.runId : void 0,
1323
+ stop: runnable ? current.execution.stop : void 0
1248
1324
  },
1249
1325
  nowMs
1250
1326
  )
@@ -1273,7 +1349,8 @@ async function clearExpiredConversationLease(args) {
1273
1349
  retryCount,
1274
1350
  pendingMessages: stopped ? [] : current.execution.pendingMessages,
1275
1351
  runId: stopped ? void 0 : current.execution.runId,
1276
- status: stopped ? "failed" : "paused"
1352
+ status: stopped ? "failed" : "paused",
1353
+ stop: stopped ? void 0 : current.execution.stop
1277
1354
  },
1278
1355
  nowMs
1279
1356
  )
@@ -1393,13 +1470,10 @@ async function ensureConversationWake(args) {
1393
1470
  });
1394
1471
  return { status: "enqueued", queueMessageId: queueResult?.messageId };
1395
1472
  }
1396
- async function appendAndEnqueueInboundMessage(args) {
1473
+ async function enqueueAfterAppend(args) {
1397
1474
  const nowMs = args.nowMs ?? now2();
1398
- const appendResult = await appendInboundMessage({
1399
- message: args.message,
1400
- nowMs,
1401
- state: args.state
1402
- });
1475
+ const appendResult = args.appendResult;
1476
+ if (appendResult.status === "active") return appendResult;
1403
1477
  let idempotencyKey = args.message.inboundMessageId;
1404
1478
  if (appendResult.status === "duplicate") {
1405
1479
  const conversation = await getConversation({
@@ -1447,9 +1521,32 @@ async function appendAndEnqueueInboundMessage(args) {
1447
1521
  }
1448
1522
  return {
1449
1523
  ...appendResult,
1450
- ...wake.status === "enqueued" ? { queueMessageId: wake.queueMessageId } : {}
1524
+ ...wake.status === "enqueued" ? { queueMessageId: wake.queueMessageId } : void 0
1451
1525
  };
1452
1526
  }
1527
+ async function appendAndEnqueueInboundMessage(args) {
1528
+ const nowMs = args.nowMs ?? now2();
1529
+ const result = await enqueueAfterAppend({
1530
+ ...args,
1531
+ appendResult: await appendInboundMessage({
1532
+ message: args.message,
1533
+ nowMs,
1534
+ state: args.state
1535
+ }),
1536
+ nowMs
1537
+ });
1538
+ if (result.status === "active") {
1539
+ throw new Error("Non-exclusive mailbox enqueue returned active");
1540
+ }
1541
+ return result;
1542
+ }
1543
+ async function completeConversationStop2(args) {
1544
+ const result = await completeConversationStop(args);
1545
+ if (result.status === "cleared") {
1546
+ await recordExecutionMetadata(args);
1547
+ }
1548
+ return result;
1549
+ }
1453
1550
  async function clearConsumedConversationWake2(args) {
1454
1551
  const result = await clearConsumedConversationWake(args);
1455
1552
  if (result) {
@@ -1560,6 +1657,7 @@ export {
1560
1657
  hasRunnableConversationWork,
1561
1658
  ensureConversationWake,
1562
1659
  appendAndEnqueueInboundMessage,
1660
+ completeConversationStop2 as completeConversationStop,
1563
1661
  clearConsumedConversationWake2 as clearConsumedConversationWake,
1564
1662
  requestConversationWork2 as requestConversationWork,
1565
1663
  startConversationWork2 as startConversationWork,
@@ -8,23 +8,23 @@ import {
8
8
  juniorConversations,
9
9
  juniorIdentities,
10
10
  juniorUsers
11
- } from "./chunk-R6U7N4FS.js";
11
+ } from "./chunk-KKSVCHDO.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-XYTJUHRZ.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-EBMRB6Z6.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
  };