@sentry/junior 0.283.0 → 0.285.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 (83) hide show
  1. package/dist/{adapter-D8-lqOBF.js → adapter-DN5AB4VU.js} +37 -3
  2. package/dist/{admin-Dnw5SCXp.js → admin-DOITMKnn.js} +1 -1
  3. package/dist/{agent-runner-Bj7GhysW.js → agent-runner-BsWhHe4N.js} +583 -1655
  4. package/dist/api/schema.d.ts +2 -2
  5. package/dist/api/schema.js +8 -6
  6. package/dist/api.d.ts +1 -1
  7. package/dist/api.js +214 -43
  8. package/dist/{app-CMBP-N43.d.ts → app-DyMs9330.d.ts} +2 -2
  9. package/dist/app.d.ts +1 -1
  10. package/dist/app.js +230 -187
  11. package/dist/{assistant-reply-CdYsLbXL.js → assistant-reply-9Jip5bsr.js} +1 -1
  12. package/dist/{automation-MLWOrghe.js → automation-Mk8aaHzy.js} +2 -2
  13. package/dist/{background-compaction-queue-Bbsqx8Vm.js → background-compaction-queue-DXkLsWoH.js} +2 -2
  14. package/dist/{briefs-C4qBY-jb.js → briefs-Cl8-nK9B.js} +5 -5
  15. package/dist/{catalog-runtime-B7NRB7eH.js → catalog-runtime-Bte6jRB2.js} +1 -1
  16. package/dist/cli/chat.js +19 -16
  17. package/dist/cli/check.js +3 -3
  18. package/dist/cli/init.js +3 -0
  19. package/dist/cli/main.js +3 -3
  20. package/dist/cli/plugins.js +4 -4
  21. package/dist/cli/snapshot-create.js +4 -4
  22. package/dist/cli/upgrade.d.ts +1 -1
  23. package/dist/cli/upgrade.js +25 -4
  24. package/dist/{client-a3Ib6wxr.js → client-DDbBucBw.js} +2 -2
  25. package/dist/{config-DFVlYCeY.js → config-DqFnykQT.js} +1 -1
  26. package/dist/{connections-BtnvpBEV.js → connections-DA4LT9LL.js} +10 -10
  27. package/dist/{conversation-DdT7SNar.js → conversation-D8kVoCrP.js} +58 -6
  28. package/dist/{conversation-pending-messages-Dct5pheX.js → conversation-pending-messages-BvROq1bq.js} +1 -1
  29. package/dist/{conversation-privacy-DLq-abjU.js → conversation-privacy-D0j_h70R.js} +1 -1
  30. package/dist/{credential-sync-B4XFVcjM.js → credential-sync-hcsYatw-.js} +13 -13
  31. package/dist/{db-A_WrTY-s.d.ts → db-BhHZSuFw.d.ts} +18 -2
  32. package/dist/{executor-HPgHGAWK.js → executor-BLEMIgIZ.js} +29 -4
  33. package/dist/instrumentation.js +37 -13
  34. package/dist/{logging-2BXvW7Mp.js → logging-BfORLKoq.js} +1 -1
  35. package/dist/{message-BG1v1lXX.js → message-DqjuKzUx.js} +13 -23
  36. package/dist/nitro.d.ts +1 -1
  37. package/dist/nitro.js +3 -3
  38. package/dist/{oauth-callback-server-CXNZJymo.js → oauth-callback-server-CFSRzu1n.js} +2 -2
  39. package/dist/{projection-BfKkpOGQ.js → projection-DliWYrnT.js} +575 -74
  40. package/dist/{prompt-CCtaGgbI.js → prompt-BvIUzY4y.js} +8 -6
  41. package/dist/push-endpoint-CO-nomUd.js +36 -0
  42. package/dist/{registry-CLooHPAz.js → registry-rC7MCxu8.js} +1 -1
  43. package/dist/{reporting-window-B-QP9zX1.js → reporting-window-B4TwyuJo.js} +14 -14
  44. package/dist/{resolve-D3MK9oRJ.js → resolve-Biu8Qw3u.js} +3 -3
  45. package/dist/result-DxJMCX47.js +299 -0
  46. package/dist/result-event-type-DD6BAgT7.js +11 -0
  47. package/dist/{runner-Ds31u3rB.js → runner-BQJSFLKg.js} +11 -11
  48. package/dist/{sandbox-egress-signals-CLd5RPUw.js → sandbox-egress-signals-6aMxJSDn.js} +1 -1
  49. package/dist/{cadence-R7Em4RjE.js → schedule-BTp__wrw.js} +81 -1
  50. package/dist/{schema-jW3ccLjp.d.ts → schema-BUviRAs8.d.ts} +196 -220
  51. package/dist/{schema-CHNP0GfH.js → schema-BasXTvi2.js} +94 -5
  52. package/dist/{service-account-D6AMahy7.js → service-account-BI5Wgx22.js} +3 -3
  53. package/dist/{service-account-CWpTsoIM.js → service-account-CAE-_1dR.js} +3 -3
  54. package/dist/session-stop-CA-jOJ84.js +2924 -0
  55. package/dist/{skills-DuOKByQH.js → skills-B22duVJU.js} +2 -2
  56. package/dist/{spawn-CNIQGgAS.js → spawn-BB2_4VYn.js} +2 -2
  57. package/dist/{stop-DX2oOIgl.js → stop-DioIcEAu.js} +4830 -4200
  58. package/dist/{store-61mD4ZSh.js → store-B26LV6UP.js} +78 -311
  59. package/dist/{store-DAJntSEv.js → store-Dn4W7qgH.js} +30 -5
  60. package/dist/{task-queue-BE70Pb9p.js → task-queue-Bt0IoR2i.js} +3 -3
  61. package/dist/{task-runner-CmmfddSZ.js → task-runner-D8lddjzp.js} +17 -8
  62. package/dist/{thread-state-0UfRMWYd.js → thread-state-CrFk3K_7.js} +4 -4
  63. package/dist/{turn-failure-response-DKdzxJHE.js → turn-failure-response-DaJ04qVj.js} +7 -7
  64. package/dist/{turn-lifecycle-24sBZ4Ip.js → turn-lifecycle-C2mXS7AZ.js} +1 -1
  65. package/dist/{turn-session-routing-CzCnNAUO.js → turn-session-routing-CGMKrYOj.js} +10 -10
  66. package/dist/{validation-Cs_knhR8.js → validation-TzhfQABF.js} +1 -1
  67. package/dist/{version-ZMC4cXWN.js → version-DSk8CFvA.js} +1 -1
  68. package/dist/version.js +1 -1
  69. package/dist/{viewer-CYB9T4rm.js → viewer-1Ea81s0b.js} +190 -53
  70. package/dist/{work-J1n6RQkY.js → work-ybG4_q5C.js} +238 -32
  71. package/dist/{worker-s1fCvj1z.js → worker-ccSyZRNz.js} +6 -6
  72. package/migrations/0082_push_notifications.sql +14 -0
  73. package/migrations/0083_conversation_kind.sql +11 -0
  74. package/migrations/0084_read_position_backfill.sql +25 -0
  75. package/migrations/0085_child_archived_at.sql +1 -0
  76. package/migrations/meta/0082_snapshot.json +4373 -0
  77. package/migrations/meta/0083_snapshot.json +4388 -0
  78. package/migrations/meta/0084_snapshot.json +4388 -0
  79. package/migrations/meta/0085_snapshot.json +4394 -0
  80. package/migrations/meta/_journal.json +28 -0
  81. package/package.json +7 -5
  82. package/dist/result-BPCjUefO.js +0 -483
  83. package/dist/session-stop-D8LGC3H6.js +0 -1438
@@ -1,11 +1,11 @@
1
- import { g as TURN_REASONING_LEVELS } from "./config-DFVlYCeY.js";
2
- import { C as getSqlExecutor, x as getConversationStore } from "./viewer-CYB9T4rm.js";
3
- import { h as juniorAgentInvocations, m as juniorAgentBindings } from "./executor-HPgHGAWK.js";
4
- import { p as credentialContextSchema } from "./registry-CLooHPAz.js";
5
- import { S as AGENT_INVOCATION_PARENT_MAILBOX_STATUSES, x as AGENT_INVOCATION_MAILBOX_STATUSES } from "./reporting-window-B-QP9zX1.js";
1
+ import { g as TURN_REASONING_LEVELS } from "./config-DqFnykQT.js";
2
+ import { C as getSqlExecutor } from "./viewer-1Ea81s0b.js";
3
+ import { g as juniorAgentInvocations } from "./executor-BLEMIgIZ.js";
4
+ import { p as credentialContextSchema } from "./registry-rC7MCxu8.js";
5
+ import { S as AGENT_INVOCATION_PARENT_MAILBOX_STATUSES, x as AGENT_INVOCATION_MAILBOX_STATUSES } from "./reporting-window-B4TwyuJo.js";
6
6
  import { createHash } from "node:crypto";
7
7
  import * as z from "zod";
8
- import { and, asc, count, countDistinct, desc, eq, inArray, lt, ne, or, sql } from "drizzle-orm";
8
+ import { and, asc, desc, eq, inArray, or, sql } from "drizzle-orm";
9
9
  import { actorSchema, destinationSchema, sourceSchema } from "@sentry/junior-plugin-api";
10
10
  // src/chat/runtime/turn.ts
11
11
  /** Classified Slack turn failure carrying the owning Sentry capture outward. */
@@ -98,6 +98,71 @@ function markTurnFailed(args) {
98
98
  skippedReason: "reply failed"
99
99
  });
100
100
  }
101
+ // src/chat/agent-invocations/ids.ts
102
+ const CREATE_LOCK_PREFIX = "junior:agent_invocation:create";
103
+ /**
104
+ * Return the SQL lock that one parent Conversation takes to start, message,
105
+ * or stop its child agents.
106
+ */
107
+ function getChildAgentLockName(parentConversationId) {
108
+ return `${CREATE_LOCK_PREFIX}:${parentConversationId}`;
109
+ }
110
+ function stableId(prefix, ...parts) {
111
+ return `${prefix}:${createHash("sha256").update(parts.join("\0")).digest("hex").slice(0, 32)}`;
112
+ }
113
+ /** Return the stable identity for one retry-safe delegated task. */
114
+ function getAgentInvocationId(parentConversationId, idempotencyKey) {
115
+ return stableId("agent-invocation", parentConversationId, idempotencyKey);
116
+ }
117
+ /** Return the stable child identity for one invocation without a named binding. */
118
+ function getUnnamedAgentConversationId(invocationId) {
119
+ return stableId("agent", invocationId);
120
+ }
121
+ /** Return the stable child identity for one named binding. */
122
+ function getNamedAgentConversationId(parentConversationId, name) {
123
+ return stableId("agent", parentConversationId, name);
124
+ }
125
+ /**
126
+ * Return the stable identity of the agent invocation that gives one child
127
+ * agent result to the child Conversation that started that child agent.
128
+ */
129
+ function getAgentInvocationIdForResult(resultInvocationId) {
130
+ return stableId("agent-invocation", "result", resultInvocationId);
131
+ }
132
+ /**
133
+ * Return the stable identity of the agent invocation that gives one message
134
+ * from a child agent to the child Conversation that started that child agent.
135
+ */
136
+ function getAgentInvocationIdForMessage(messageId) {
137
+ return stableId("agent-invocation", "message", messageId);
138
+ }
139
+ /**
140
+ * Return the stable identity of the agent invocation that gives one batch of
141
+ * watch events to a child Conversation. The first message of the batch names
142
+ * it.
143
+ */
144
+ function getAgentInvocationIdForEvents(messageId) {
145
+ return stableId("agent-invocation", "events", messageId);
146
+ }
147
+ /** Return the stable turn identity advanced by one agent invocation. */
148
+ function getAgentInvocationTurnId(invocationId) {
149
+ return `agent-invocation:${invocationId}`;
150
+ }
151
+ /** Return the stable mailbox identity for one agent invocation. */
152
+ function getAgentInvocationMessageId(invocationId) {
153
+ return `agent-invocation:${invocationId}:input`;
154
+ }
155
+ const RESULT_MESSAGE_PREFIX = "agent-invocation:";
156
+ const RESULT_MESSAGE_SUFFIX = ":result";
157
+ /** Return the stable parent mailbox identity for one terminal result. */
158
+ function getAgentInvocationResultMessageId(invocationId) {
159
+ return `${RESULT_MESSAGE_PREFIX}${invocationId}${RESULT_MESSAGE_SUFFIX}`;
160
+ }
161
+ /** Read the invocation identity from one parent result mailbox identity. */
162
+ function parseAgentInvocationResultMessageId(messageId) {
163
+ if (!messageId.startsWith(RESULT_MESSAGE_PREFIX) || !messageId.endsWith(RESULT_MESSAGE_SUFFIX)) return;
164
+ return messageId.slice(17, -7) || void 0;
165
+ }
101
166
  // src/chat/agent-invocations/agent-types.ts
102
167
  /**
103
168
  * Child agent types. A type is plain data: when to pick it, whether the child
@@ -225,76 +290,7 @@ const CHILD_AGENT_RESULTS = [
225
290
  "blocked",
226
291
  "failed"
227
292
  ];
228
- // src/chat/agent-invocations/bindings.ts
229
- function bindingFromRow(row) {
230
- return agentBindingSchema.parse({
231
- childConversationId: row.childConversationId,
232
- name: row.name,
233
- parentConversationId: row.parentConversationId
234
- });
235
- }
236
- /** Read one named child binding in its parent-agent scope. */
237
- async function getAgentBinding(args) {
238
- const rows = await getSqlExecutor().db().select().from(juniorAgentBindings).where(and(eq(juniorAgentBindings.parentConversationId, args.parentConversationId), eq(juniorAgentBindings.name, args.name)));
239
- return rows[0] ? bindingFromRow(rows[0]) : void 0;
240
- }
241
- /** Find a direct child agent of one parent by name or child Conversation id. */
242
- async function findChildAgentConversationId(args) {
243
- const binding = await getAgentBinding({
244
- name: args.target,
245
- parentConversationId: args.parentConversationId
246
- });
247
- if (binding) return binding.childConversationId;
248
- return (await getSqlExecutor().db().select({ childConversationId: juniorAgentInvocations.childConversationId }).from(juniorAgentInvocations).where(and(eq(juniorAgentInvocations.parentConversationId, args.parentConversationId), eq(juniorAgentInvocations.childConversationId, args.target))).limit(1))[0]?.childConversationId;
249
- }
250
- // src/chat/agent-invocations/errors.ts
251
- /** A child agent already uses this name in the parent Conversation. */
252
- var AgentNameInUseError = class extends Error {
253
- constructor(name) {
254
- super(`A child agent named "${name}" already exists`);
255
- this.name = "AgentNameInUseError";
256
- }
257
- };
258
- /** Parent already has the maximum number of non-terminal child invocations. */
259
- var AgentInvocationLimitError = class extends Error {
260
- constructor(limit) {
261
- super(`Parent already has ${limit} active child agent invocations (limit ${limit})`);
262
- this.name = "AgentInvocationLimitError";
263
- }
264
- };
265
- /** A child agent already has the maximum number of open tasks. */
266
- var AgentMessageQueueFullError = class extends Error {
267
- constructor(limit) {
268
- super(`The child agent already has ${limit} open tasks`);
269
- this.name = "AgentMessageQueueFullError";
270
- }
271
- };
272
- /**
273
- * A messageAgent target is not the parent, a child, or a top-level agent that
274
- * the sender can message.
275
- */
276
- var AgentMessageTargetError = class extends Error {
277
- constructor(message) {
278
- super(message);
279
- this.name = "AgentMessageTargetError";
280
- }
281
- };
282
- /** A top-level agent paused automated Turns, so it takes no agent message. */
283
- var AgentMessagePausedError = class extends Error {
284
- constructor(conversationId) {
285
- super(`${conversationId} paused automated work until a person replies there`);
286
- this.name = "AgentMessagePausedError";
287
- }
288
- };
289
293
  // src/chat/agent-invocations/store.ts
290
- const CREATE_LOCK_PREFIX = "junior:agent_invocation:create";
291
- /**
292
- * Return the SQL lock that one parent Conversation takes to start, message,
293
- * or stop its child agents.
294
- */
295
- function getChildAgentLockName(parentConversationId) {
296
- return `${CREATE_LOCK_PREFIX}:${parentConversationId}`;
297
- }
298
294
  const TERMINAL_AGENT_INVOCATION_STATUSES = [
299
295
  "blocked",
300
296
  "completed",
@@ -309,62 +305,6 @@ const NON_TERMINAL_AGENT_INVOCATION_STATUSES = [
309
305
  "running",
310
306
  "paused"
311
307
  ];
312
- function stableId(prefix, ...parts) {
313
- return `${prefix}:${createHash("sha256").update(parts.join("\0")).digest("hex").slice(0, 32)}`;
314
- }
315
- /** Return the stable identity for one retry-safe delegated task. */
316
- function getAgentInvocationId(parentConversationId, idempotencyKey) {
317
- return stableId("agent-invocation", parentConversationId, idempotencyKey);
318
- }
319
- /** Return the stable child identity for one invocation without a named binding. */
320
- function getUnnamedAgentConversationId(invocationId) {
321
- return stableId("agent", invocationId);
322
- }
323
- /** Return the stable child identity for one named binding. */
324
- function getNamedAgentConversationId(parentConversationId, name) {
325
- return stableId("agent", parentConversationId, name);
326
- }
327
- /**
328
- * Return the stable identity of the agent invocation that gives one child
329
- * agent result to the child Conversation that started that child agent.
330
- */
331
- function getAgentInvocationIdForResult(resultInvocationId) {
332
- return stableId("agent-invocation", "result", resultInvocationId);
333
- }
334
- /**
335
- * Return the stable identity of the agent invocation that gives one message
336
- * from a child agent to the child Conversation that started that child agent.
337
- */
338
- function getAgentInvocationIdForMessage(messageId) {
339
- return stableId("agent-invocation", "message", messageId);
340
- }
341
- /**
342
- * Return the stable identity of the agent invocation that gives one batch of
343
- * watch events to a child Conversation. The first message of the batch names
344
- * it.
345
- */
346
- function getAgentInvocationIdForEvents(messageId) {
347
- return stableId("agent-invocation", "events", messageId);
348
- }
349
- /** Return the stable turn identity advanced by one agent invocation. */
350
- function getAgentInvocationTurnId(invocationId) {
351
- return `agent-invocation:${invocationId}`;
352
- }
353
- /** Return the stable mailbox identity for one agent invocation. */
354
- function getAgentInvocationMessageId(invocationId) {
355
- return `agent-invocation:${invocationId}:input`;
356
- }
357
- const RESULT_MESSAGE_PREFIX = "agent-invocation:";
358
- const RESULT_MESSAGE_SUFFIX = ":result";
359
- /** Return the stable parent mailbox identity for one terminal result. */
360
- function getAgentInvocationResultMessageId(invocationId) {
361
- return `${RESULT_MESSAGE_PREFIX}${invocationId}${RESULT_MESSAGE_SUFFIX}`;
362
- }
363
- /** Read the invocation identity from one parent result mailbox identity. */
364
- function parseAgentInvocationResultMessageId(messageId) {
365
- if (!messageId.startsWith(RESULT_MESSAGE_PREFIX) || !messageId.endsWith(RESULT_MESSAGE_SUFFIX)) return;
366
- return messageId.slice(17, -7) || void 0;
367
- }
368
308
  /** Parse one agent invocation row. */
369
309
  function invocationFromRow(row) {
370
310
  return agentInvocationSchema.parse({
@@ -391,14 +331,6 @@ function invocationFromRow(row) {
391
331
  updatedAtMs: row.updatedAt.getTime()
392
332
  });
393
333
  }
394
- /**
395
- * Require every durable creation input to match before replaying one key.
396
- * The title is not compared: a retry can generate a different one, and the
397
- * stored title wins.
398
- */
399
- function sameCreateInput(invocation, input) {
400
- return invocation.parentConversationId === input.parentConversationId && invocation.agentName === input.agentName && invocation.input === input.input && invocation.agentType === input.agentType && invocation.reasoningLevel === input.reasoningLevel && JSON.stringify(invocation.actor) === JSON.stringify(input.actor) && JSON.stringify(invocation.credentialContext) === JSON.stringify(input.credentialContext) && JSON.stringify(invocation.destination) === JSON.stringify(input.destination);
401
- }
402
334
  /** Read one durable agent invocation. */
403
335
  async function getAgentInvocation(invocationId) {
404
336
  const rows = await getSqlExecutor().db().select().from(juniorAgentInvocations).where(eq(juniorAgentInvocations.invocationId, invocationId));
@@ -431,177 +363,12 @@ async function getChildAgentLabel(childConversationId) {
431
363
  }).from(juniorAgentInvocations).where(eq(juniorAgentInvocations.childConversationId, childConversationId)).orderBy(sql`${juniorAgentInvocations.title} is null`, desc(juniorAgentInvocations.createdAt)).limit(1);
432
364
  return row;
433
365
  }
434
- async function getNonTerminalAgentInvocationForConversation(childConversationId) {
435
- const rows = await getSqlExecutor().db().select().from(juniorAgentInvocations).where(and(eq(juniorAgentInvocations.childConversationId, childConversationId), inArray(juniorAgentInvocations.status, NON_TERMINAL_AGENT_INVOCATION_STATUSES))).orderBy(asc(juniorAgentInvocations.createdAt)).limit(1);
436
- return rows[0] ? invocationFromRow(rows[0]) : void 0;
437
- }
438
- async function countNonTerminalAgentInvocationsForChild(childConversationId) {
439
- return (await getSqlExecutor().db().select({ value: count() }).from(juniorAgentInvocations).where(and(eq(juniorAgentInvocations.childConversationId, childConversationId), inArray(juniorAgentInvocations.status, NON_TERMINAL_AGENT_INVOCATION_STATUSES))))[0]?.value ?? 0;
440
- }
441
- /**
442
- * A child agent can only start or give work to child agents while it has
443
- * open work. A stopped child has none. A root Conversation has no agent
444
- * invocation, so it always passes.
445
- */
446
- async function assertCanGiveChildWork(parentConversationId) {
447
- if (await getLatestAgentInvocationForConversation(parentConversationId) && !await getNonTerminalAgentInvocationForConversation(parentConversationId)) throw new Error(`Agent conversation ${parentConversationId} has no open work and cannot give work to child agents`);
448
- }
449
366
  /**
450
- * Count the child agents of one parent that have open work. Messages queued
451
- * for a busy child do not count again.
367
+ * List the open agent invocations that run on one Conversation or on its
368
+ * child agents, oldest first. Open-work checks read this once and filter it.
452
369
  */
453
- async function countActiveChildAgentsForParent(parentConversationId) {
454
- return (await getSqlExecutor().db().select({ value: countDistinct(juniorAgentInvocations.childConversationId) }).from(juniorAgentInvocations).where(and(eq(juniorAgentInvocations.parentConversationId, parentConversationId), inArray(juniorAgentInvocations.status, NON_TERMINAL_AGENT_INVOCATION_STATUSES))))[0]?.value ?? 0;
455
- }
456
- /**
457
- * Create or replay the first invocation of one new child agent. A name gives
458
- * the child a stable Conversation id that later messages can address. A name
459
- * that is already used throws: later work for that child goes through
460
- * `createAgentInvocationForMessage`.
461
- */
462
- async function createAgentInvocation(rawInput, nowMs = Date.now()) {
463
- const input = createAgentInvocationSchema.parse(rawInput);
464
- const invocationId = getAgentInvocationId(input.parentConversationId, input.idempotencyKey);
465
- const childConversationId = input.agentName ? getNamedAgentConversationId(input.parentConversationId, input.agentName) : getUnnamedAgentConversationId(invocationId);
466
- const lockName = getChildAgentLockName(input.parentConversationId);
467
- return await getSqlExecutor().withLock(lockName, async () => {
468
- const existing = await getAgentInvocation(invocationId);
469
- if (existing) {
470
- if (!sameCreateInput(existing, input)) throw new Error(`Agent invocation idempotency key was reused with different input for ${invocationId}`);
471
- return existing;
472
- }
473
- await assertCanGiveChildWork(input.parentConversationId);
474
- if (input.agentName && await getAgentBinding({
475
- name: input.agentName,
476
- parentConversationId: input.parentConversationId
477
- })) throw new AgentNameInUseError(input.agentName);
478
- if (await countActiveChildAgentsForParent(input.parentConversationId) >= 8) throw new AgentInvocationLimitError(8);
479
- await getConversationStore().createChild({
480
- childConversationId,
481
- parentConversationId: input.parentConversationId,
482
- nowMs,
483
- source: "internal"
484
- });
485
- if (input.agentName) await getSqlExecutor().db().insert(juniorAgentBindings).values({
486
- childConversationId,
487
- name: input.agentName,
488
- parentConversationId: input.parentConversationId
489
- });
490
- await getSqlExecutor().db().insert(juniorAgentInvocations).values({
491
- invocationId,
492
- parentConversationId: input.parentConversationId,
493
- childConversationId,
494
- agentName: input.agentName ?? null,
495
- input: input.input,
496
- title: input.title ?? null,
497
- actor: input.actor,
498
- credentialContext: input.credentialContext ?? null,
499
- source: { kind: "agent_invocation" },
500
- destination: input.destination,
501
- agentType: input.agentType ?? null,
502
- reasoningLevel: input.reasoningLevel ?? null,
503
- parentToolCallId: input.parentToolCallId ?? null,
504
- status: "pending",
505
- mailboxStatus: "pending",
506
- createdAt: new Date(nowMs),
507
- updatedAt: new Date(nowMs),
508
- terminalAt: null
509
- }).onConflictDoNothing();
510
- const invocation = await getAgentInvocation(invocationId);
511
- if (!invocation || !sameCreateInput(invocation, input)) throw new Error(`Agent invocation creation raced for ${invocationId}`);
512
- return invocation;
513
- });
514
- }
515
- /**
516
- * Create or replay the agent invocation that gives one input to a child
517
- * Conversation: a result or message from its own child agent, or its own
518
- * watch events. It continues that Conversation for the same parent as
519
- * `latest`, and for the same Actor and credentials unless `runAs` sets them.
520
- * It skips the queue and active-count checks because it continues work that
521
- * already passed them.
522
- */
523
- async function createAgentInvocationFromLatest(args, nowMs = Date.now()) {
524
- const { invocationId } = args;
525
- await getSqlExecutor().db().insert(juniorAgentInvocations).values({
526
- invocationId,
527
- parentConversationId: args.latest.parentConversationId,
528
- childConversationId: args.latest.childConversationId,
529
- agentName: args.latest.agentName ?? null,
530
- input: args.input,
531
- actor: (args.runAs ?? args.latest).actor,
532
- credentialContext: (args.runAs ?? args.latest).credentialContext ?? null,
533
- source: args.runAs?.source ?? { kind: "agent_invocation" },
534
- destination: args.latest.destination,
535
- agentType: args.latest.agentType ?? null,
536
- reasoningLevel: args.latest.reasoningLevel ?? null,
537
- status: "pending",
538
- mailboxStatus: "pending",
539
- createdAt: new Date(nowMs),
540
- updatedAt: new Date(nowMs),
541
- terminalAt: null
542
- }).onConflictDoNothing();
543
- const invocation = await getAgentInvocation(invocationId);
544
- if (!invocation || invocation.childConversationId !== args.latest.childConversationId) throw new Error(`Agent invocation creation raced for ${invocationId}`);
545
- return invocation;
546
- }
547
- /**
548
- * Return whether a pending agent invocation still waits for older open work
549
- * on its child.
550
- */
551
- async function isQueuedBehindOpenWork(invocation) {
552
- if (invocation.status !== "pending") return false;
553
- return (await getSqlExecutor().db().select({ invocationId: juniorAgentInvocations.invocationId }).from(juniorAgentInvocations).where(and(eq(juniorAgentInvocations.childConversationId, invocation.childConversationId), lt(juniorAgentInvocations.createdAt, new Date(invocation.createdAtMs)), inArray(juniorAgentInvocations.status, NON_TERMINAL_AGENT_INVOCATION_STATUSES))).limit(1)).length > 0;
554
- }
555
- /**
556
- * Create or replay the agent invocation for one message from a parent to one
557
- * of its child agents. The child continues its history. If the child already
558
- * has open work, the new agent invocation waits for that work and the parent
559
- * gets one report for both. A stopped child starts again.
560
- */
561
- async function createAgentInvocationForMessage(input, nowMs = Date.now()) {
562
- const invocationId = getAgentInvocationId(input.parentConversationId, input.idempotencyKey);
563
- return await getSqlExecutor().withLock(getChildAgentLockName(input.parentConversationId), async () => {
564
- const existing = await getAgentInvocation(invocationId);
565
- if (existing) {
566
- if (existing.childConversationId !== input.childConversationId || existing.input !== input.input) throw new Error(`Agent invocation idempotency key was reused with different input for ${invocationId}`);
567
- return {
568
- invocation: existing,
569
- queued: await isQueuedBehindOpenWork(existing)
570
- };
571
- }
572
- const latest = await getLatestAgentInvocationForConversation(input.childConversationId);
573
- if (!latest || latest.parentConversationId !== input.parentConversationId) throw new Error(`${input.childConversationId} is not a child agent of ${input.parentConversationId}`);
574
- await assertCanGiveChildWork(input.parentConversationId);
575
- const openCount = await countNonTerminalAgentInvocationsForChild(input.childConversationId);
576
- if (openCount >= 4) throw new AgentMessageQueueFullError(4);
577
- if (openCount === 0 && await countActiveChildAgentsForParent(input.parentConversationId) >= 8) throw new AgentInvocationLimitError(8);
578
- await getSqlExecutor().db().insert(juniorAgentInvocations).values({
579
- invocationId,
580
- parentConversationId: input.parentConversationId,
581
- childConversationId: input.childConversationId,
582
- agentName: latest.agentName ?? null,
583
- input: input.input,
584
- title: null,
585
- actor: input.actor,
586
- credentialContext: input.credentialContext ?? null,
587
- source: { kind: "agent_invocation" },
588
- destination: input.destination,
589
- agentType: latest.agentType ?? null,
590
- reasoningLevel: latest.reasoningLevel ?? null,
591
- parentToolCallId: input.parentToolCallId,
592
- status: "pending",
593
- mailboxStatus: "pending",
594
- createdAt: new Date(nowMs),
595
- updatedAt: new Date(nowMs),
596
- terminalAt: null
597
- }).onConflictDoNothing();
598
- const invocation = await getAgentInvocation(invocationId);
599
- if (!invocation) throw new Error(`Agent invocation creation raced for ${invocationId}`);
600
- return {
601
- invocation,
602
- queued: openCount > 0
603
- };
604
- });
370
+ async function listOpenAgentInvocations(conversationId) {
371
+ return (await getSqlExecutor().db().select().from(juniorAgentInvocations).where(and(or(eq(juniorAgentInvocations.childConversationId, conversationId), eq(juniorAgentInvocations.parentConversationId, conversationId)), inArray(juniorAgentInvocations.status, NON_TERMINAL_AGENT_INVOCATION_STATUSES))).orderBy(asc(juniorAgentInvocations.createdAt))).map(invocationFromRow);
605
372
  }
606
373
  /**
607
374
  * Return whether a child Conversation has work that will start another agent
@@ -609,9 +376,9 @@ async function createAgentInvocationForMessage(input, nowMs = Date.now()) {
609
376
  * sent child agent result that no agent invocation has received yet.
610
377
  */
611
378
  async function hasOpenChildWork(invocation) {
612
- const db = getSqlExecutor().db();
613
379
  const conversationId = invocation.childConversationId;
614
- if ((await db.select({ invocationId: juniorAgentInvocations.invocationId }).from(juniorAgentInvocations).where(and(or(eq(juniorAgentInvocations.childConversationId, conversationId), eq(juniorAgentInvocations.parentConversationId, conversationId)), ne(juniorAgentInvocations.invocationId, invocation.invocationId), inArray(juniorAgentInvocations.status, NON_TERMINAL_AGENT_INVOCATION_STATUSES))).limit(1)).length > 0) return true;
380
+ if ((await listOpenAgentInvocations(conversationId)).some((row) => row.invocationId !== invocation.invocationId)) return true;
381
+ const db = getSqlExecutor().db();
615
382
  const sent = await db.select({ invocationId: juniorAgentInvocations.invocationId }).from(juniorAgentInvocations).where(and(eq(juniorAgentInvocations.parentConversationId, conversationId), inArray(juniorAgentInvocations.parentMailboxStatus, ["pending", "appended"])));
616
383
  if (sent.length === 0) return false;
617
384
  return (await db.select({ invocationId: juniorAgentInvocations.invocationId }).from(juniorAgentInvocations).where(inArray(juniorAgentInvocations.invocationId, sent.map((row) => getAgentInvocationIdForResult(row.invocationId))))).length < sent.length;
@@ -706,4 +473,4 @@ async function markAgentInvocationSteered(invocationId, nowMs = Date.now()) {
706
473
  function isTerminalAgentInvocation(invocation) {
707
474
  return TERMINAL_AGENT_INVOCATION_STATUSES.includes(invocation.status);
708
475
  }
709
- export { markTurnFailed as $, AgentInvocationLimitError as A, agentTypeInstructions as B, markAgentInvocationMailboxAppended as C, markAgentInvocationSteered as D, markAgentInvocationRunning as E, findChildAgentConversationId as F, TurnInputCommitLostError as G, formatAgentTypes as H, CHILD_AGENT_RESULTS as I, isCooperativeTurnYieldError as J, TurnInputDeferredError as K, PARENT_AGENT_TARGET as L, AgentMessageQueueFullError as M, AgentMessageTargetError as N, parseAgentInvocationResultMessageId as O, AgentNameInUseError as P, markTurnCompleted as Q, agentNameSchema as R, listPendingAgentInvocationResults as S, markAgentInvocationPaused as T, ConversationTurnBoundaryError as U, agentTypeStartsWithParentHistory as V, CooperativeTurnYieldError as W, isTurnInputDeferredError as X, isTurnInputCommitLostError as Y, markTurnClosed as Z, getLatestAgentInvocationForConversation as _, createAgentInvocationForMessage as a, listAgentInvocationsForConversation as b, getAgentInvocation as c, getAgentInvocationIdForResult as d, startActiveTurn as et, getAgentInvocationMessageId as f, getChildAgentLockName as g, getChildAgentLabel as h, createAgentInvocation as i, AgentMessagePausedError as j, reportReplacedAgentInvocation as k, getAgentInvocationIdForEvents as l, getAgentInvocationTurnId as m, NON_TERMINAL_AGENT_INVOCATION_STATUSES as n, createAgentInvocationFromLatest as o, getAgentInvocationResultMessageId as p, getConversationTurnBoundaryError as q, completeAgentInvocation as r, getActiveAgentInvocationForConversation as s, ACTIVE_AGENT_INVOCATION_STATUSES as t, getAgentInvocationIdForMessage as u, invocationFromRow as v, markAgentInvocationParentMailboxAppended as w, listPendingAgentInvocationMailboxAppends as x, isTerminalAgentInvocation as y, AGENT_TYPES as z };
476
+ export { getAgentInvocationIdForEvents as A, ConversationTurnBoundaryError as B, agentNameSchema as C, agentTypeStartsWithParentHistory as D, agentTypeInstructions as E, getAgentInvocationTurnId as F, isCooperativeTurnYieldError as G, TurnInputCommitLostError as H, getChildAgentLockName as I, markTurnClosed as J, isTurnInputCommitLostError as K, getNamedAgentConversationId as L, getAgentInvocationIdForResult as M, getAgentInvocationMessageId as N, formatAgentTypes as O, getAgentInvocationResultMessageId as P, getUnnamedAgentConversationId as R, agentBindingSchema as S, AGENT_TYPES as T, TurnInputDeferredError as U, CooperativeTurnYieldError as V, getConversationTurnBoundaryError as W, markTurnFailed as X, markTurnCompleted as Y, startActiveTurn as Z, markAgentInvocationRunning as _, getAgentInvocation as a, CHILD_AGENT_RESULTS as b, invocationFromRow as c, listOpenAgentInvocations as d, listPendingAgentInvocationMailboxAppends as f, markAgentInvocationPaused as g, markAgentInvocationParentMailboxAppended as h, getActiveAgentInvocationForConversation as i, getAgentInvocationIdForMessage as j, getAgentInvocationId as k, isTerminalAgentInvocation as l, markAgentInvocationMailboxAppended as m, NON_TERMINAL_AGENT_INVOCATION_STATUSES as n, getChildAgentLabel as o, listPendingAgentInvocationResults as p, isTurnInputDeferredError as q, completeAgentInvocation as r, getLatestAgentInvocationForConversation as s, ACTIVE_AGENT_INVOCATION_STATUSES as t, listAgentInvocationsForConversation as u, markAgentInvocationSteered as v, createAgentInvocationSchema as w, PARENT_AGENT_TARGET as x, reportReplacedAgentInvocation as y, parseAgentInvocationResultMessageId as z };
@@ -1,6 +1,6 @@
1
- import { At as requestAnotherSlice$1, Dt as recordConversationRetry$1, Et as recordAttemptFailure$1, Mt as startConversationWork$1, Nt as steerWebPendingMessages$1, Ot as releaseConversationWork$1, Pt as stopConversationWork$1, Tt as markConversationWorkEnqueued$1, _t as drainConversationMailbox$1, ct as appendInboundMessage, dt as checkInConversationWork$1, ft as clearConsumedConversationWake$1, gt as deadLetterAttempt$1, ht as completeConversationWork$1, jt as requestConversationWork$1, kt as removeActiveConversation$1, lt as beginConversationResume$1, mt as completeConversationStop$1, ot as ackMessages$1, pt as clearExpiredConversationLease$1, st as appendExclusiveInboundMessage, ut as cancelHumanFacingPendingMessages$1, vt as getConversation$1, wt as listActiveConversationIds$1, yt as getConversationWorkState$1 } from "./projection-BfKkpOGQ.js";
2
- import { x as getConversationStore } from "./viewer-CYB9T4rm.js";
3
- import "./background-compaction-queue-Bbsqx8Vm.js";
1
+ import { At as recordConversationRetry$1, Dt as markConversationWorkEnqueued$1, Et as listActiveConversationIds$1, Ft as requestConversationWork$1, It as startConversationWork$1, Lt as steerWebPendingMessages$1, Mt as releaseInboundMessage, Nt as removeActiveConversation$1, Pt as requestAnotherSlice$1, Rt as stopConversationWork$1, _t as completeConversationWork$1, bt as getConversation$1, ct as appendExclusiveInboundMessage, dt as cancelHumanFacingPendingMessages$1, ft as checkInConversationWork$1, gt as completeConversationStop$1, ht as clearExpiredConversationLease$1, jt as releaseConversationWork$1, kt as recordAttemptFailure$1, lt as appendInboundMessage, mt as clearConsumedConversationWake$1, pt as claimInboundMessage$1, st as ackMessages$1, ut as beginConversationResume$1, vt as deadLetterAttempt$1, xt as getConversationWorkState$1, yt as drainConversationMailbox$1 } from "./projection-DliWYrnT.js";
2
+ import { x as getConversationStore } from "./viewer-1Ea81s0b.js";
3
+ import "./background-compaction-queue-DXkLsWoH.js";
4
4
  // src/chat/task-execution/store.ts
5
5
  function metadataStore(options) {
6
6
  return options.conversationStore ?? getConversationStore();
@@ -97,6 +97,28 @@ async function ensureConversationWake(args) {
97
97
  queueMessageId: queueResult?.messageId
98
98
  };
99
99
  }
100
+ /**
101
+ * Record an inbound message id that skips the mailbox. When the claim is
102
+ * saved but its metadata write fails, this releases the claim, so a
103
+ * redelivery can claim it again.
104
+ */
105
+ async function claimInboundMessage(args) {
106
+ const result = await claimInboundMessage$1(args);
107
+ if (result.status === "claimed") try {
108
+ await recordExecutionMetadata({
109
+ conversationId: args.message.conversationId,
110
+ conversationStore: args.conversationStore,
111
+ state: args.state
112
+ });
113
+ } catch (error) {
114
+ await releaseInboundMessage({
115
+ message: args.message,
116
+ state: args.state
117
+ });
118
+ throw error;
119
+ }
120
+ return result;
121
+ }
100
122
  async function enqueueAfterAppend(args) {
101
123
  const nowMs = args.nowMs ?? now();
102
124
  const appendResult = args.appendResult;
@@ -178,7 +200,10 @@ async function appendAndEnqueueExclusiveInboundMessage(args) {
178
200
  /** Persist a stop request for the current Conversation run. */
179
201
  async function stopConversationWork(args) {
180
202
  const result = await stopConversationWork$1(args);
181
- if (result.status === "requested") await recordExecutionMetadata(args);
203
+ if (result.status === "requested") {
204
+ args.onStopSaved?.();
205
+ await recordExecutionMetadata(args);
206
+ }
182
207
  return result;
183
208
  }
184
209
  /** Finish an observed stop request under the current worker lease. */
@@ -292,4 +317,4 @@ async function removeActiveConversation(args) {
292
317
  async function listActiveConversationIds(args = {}) {
293
318
  return await listActiveConversationIds$1(args);
294
319
  }
295
- export { requestAnotherSlice as C, stopConversationWork as D, steerWebPendingMessages as E, removeActiveConversation as S, startConversationWork as T, hasRunnableConversationWork as _, cancelHumanFacingPendingMessages as a, recordConversationRetry as b, clearExpiredConversationLease as c, countPendingConversationMessages as d, deadLetterAttempt as f, getConversationWorkState as g, getConversation as h, beginConversationResume as i, completeConversationStop as l, ensureConversationWake as m, appendAndEnqueueExclusiveInboundMessage as n, checkInConversationWork as o, drainConversationMailbox as p, appendAndEnqueueInboundMessage as r, clearConsumedConversationWake as s, ackMessages as t, completeConversationWork as u, listActiveConversationIds as v, requestConversationWork as w, releaseConversationWork as x, recordAttemptFailure as y };
320
+ export { removeActiveConversation as C, steerWebPendingMessages as D, startConversationWork as E, stopConversationWork as O, releaseConversationWork as S, requestConversationWork as T, getConversationWorkState as _, cancelHumanFacingPendingMessages as a, recordAttemptFailure as b, clearConsumedConversationWake as c, completeConversationWork as d, countPendingConversationMessages as f, getConversation as g, ensureConversationWake as h, beginConversationResume as i, clearExpiredConversationLease as l, drainConversationMailbox as m, appendAndEnqueueExclusiveInboundMessage as n, checkInConversationWork as o, deadLetterAttempt as p, appendAndEnqueueInboundMessage as r, claimInboundMessage as s, ackMessages as t, completeConversationStop as u, hasRunnableConversationWork as v, requestAnotherSlice as w, recordConversationRetry as x, listActiveConversationIds as y };
@@ -1,5 +1,5 @@
1
- import { h as logWarn } from "./logging-2BXvW7Mp.js";
2
- import { _ as runWithTurnRequestDeadline, f as QUEUE_SIGNATURE_MAX_AGE_MS, h as getQueueProvider, m as verifyQueueMessage, p as signQueueMessage } from "./background-compaction-queue-Bbsqx8Vm.js";
1
+ import { h as logWarn } from "./logging-BfORLKoq.js";
2
+ import { _ as runWithTurnRequestDeadline, f as QUEUE_SIGNATURE_MAX_AGE_MS, h as getQueueProvider, m as verifyQueueMessage, p as signQueueMessage } from "./background-compaction-queue-DXkLsWoH.js";
3
3
  import { createHash } from "node:crypto";
4
4
  import * as z from "zod";
5
5
  // src/chat/queue/callback.ts
@@ -110,7 +110,7 @@ function pluginTaskCallback() {
110
110
  maxDeliveries: PLUGIN_TASK_MAX_DELIVERIES,
111
111
  onRejected: logPluginTaskQueueMessageRejected,
112
112
  run: async (message) => {
113
- const { processPluginTask } = await import("./task-runner-CmmfddSZ.js").then((n) => n.r);
113
+ const { processPluginTask } = await import("./task-runner-D8lddjzp.js").then((n) => n.r);
114
114
  await processPluginTask(message);
115
115
  },
116
116
  topic: PLUGIN_TASK_QUEUE_TOPIC,
@@ -1,12 +1,13 @@
1
1
  import { v as __exportAll } from "./sentry-BRTJqumy.js";
2
- import { Aa as createPluginLogger, Bn as coreTaskRegistrations, Gr as createPluginState, Gt as getPiMessageRole, Ln as getPlugins, Wa as createPluginConversationEvents, Xt as instructionTextForProjection, en as isToolResultError, ga as createPluginModel, ha as createPluginEmbedder, in as stripRuntimeTurnContext, ka as createPluginModelCostRecorder, mo as createPluginCache, nn as normalizeToolNameFromResult, tn as isToolResultMessage, tt as getTurnRecord, v as hydrateConversationMessages } from "./projection-BfKkpOGQ.js";
2
+ import { Fa as createPluginEmbedder, Ia as createPluginModel, Ja as createPluginModelCostRecorder, Xn as coreTaskRegistrations, Ya as createPluginLogger, Yt as getPiMessageRole, an as isToolResultMessage, cn as stripRuntimeTurnContext, di as createPluginState, en as instructionTextForProjection, in as isToolResultError, jo as createPluginCache, nt as getTurnRecord, on as normalizeToolNameFromResult, qn as getPlugins, so as createPluginConversationEvents, v as hydrateConversationMessages } from "./projection-DliWYrnT.js";
3
+ import { E as withSpan } from "./logging-BfORLKoq.js";
3
4
  import { h as parseSlackMessageTs } from "./actor-6jsm_v96.js";
4
- import { S as getDb, i as readActorIdentity, x as getConversationStore } from "./viewer-CYB9T4rm.js";
5
+ import { S as getDb, i as readActorIdentity, x as getConversationStore } from "./viewer-1Ea81s0b.js";
5
6
  import { v as sameActorIdentity } from "./media-Bu9C6lz0.js";
6
- import { r as getStateAdapter } from "./adapter-D8-lqOBF.js";
7
- import { t as resolveConversationRouting, u as getDispatchRecord } from "./turn-session-routing-CzCnNAUO.js";
8
- import { o as coerceThreadConversationState, r as getPersistedThreadState } from "./thread-state-0UfRMWYd.js";
9
- import { i as pluginTaskParamsSchema, r as pluginTaskId, s as sendVercelPluginTask } from "./task-queue-BE70Pb9p.js";
7
+ import { r as getStateAdapter } from "./adapter-DN5AB4VU.js";
8
+ import { t as resolveConversationRouting, u as getDispatchRecord } from "./turn-session-routing-CGMKrYOj.js";
9
+ import { o as coerceThreadConversationState, r as getPersistedThreadState } from "./thread-state-CrFk3K_7.js";
10
+ import { i as pluginTaskParamsSchema, r as pluginTaskId, s as sendVercelPluginTask } from "./task-queue-Bt0IoR2i.js";
10
11
  import { pluginRunContextSchema } from "@sentry/junior-plugin-api";
11
12
  // src/chat/plugins/task-runner.ts
12
13
  /**
@@ -270,12 +271,20 @@ async function scheduleSessionCompletedPluginTasks(params, options = {}) {
270
271
  await send(message);
271
272
  }));
272
273
  }
273
- /** Execute one parsed plugin task request. */
274
+ /**
275
+ * Execute one parsed plugin task request in a `plugin.task` span. The span
276
+ * includes the lock wait, because both delay the work that runs the task.
277
+ */
274
278
  async function processPluginTask(message, options = {}) {
275
- await withPluginTaskLock(pluginTaskId(message), async () => {
279
+ const params = pluginTaskParamsSchema.parse(message.params);
280
+ await withSpan(`plugin.task ${message.plugin}.${message.name}`, "plugin.task", { conversationId: params.conversationId }, () => withPluginTaskLock(pluginTaskId(message), async () => {
276
281
  const resolved = findPluginTask(message);
277
282
  if (!resolved?.task) throw new Error(`Plugin task "${message.plugin}.${message.name}" is not registered`);
278
283
  await resolved.task.run(taskPluginContext(resolved.plugin, message, options));
284
+ }), {
285
+ "app.ai.turn.session_id": params.sessionId,
286
+ "app.plugin.name": message.plugin,
287
+ "app.plugin.task": message.name
279
288
  });
280
289
  }
281
290
  export { scheduleSessionCompletedPluginTasks as n, task_runner_exports as r, processPluginTask as t };
@@ -1,7 +1,7 @@
1
- import { Rr as JUNIOR_THREAD_STATE_TTL_MS, ho as createDurableLocationConfigurationService, y as persistConversationMessages } from "./projection-BfKkpOGQ.js";
2
- import { G as toOptionalNumber, K as toOptionalString, W as isRecord } from "./logging-2BXvW7Mp.js";
3
- import { S as getDb } from "./viewer-CYB9T4rm.js";
4
- import { r as getStateAdapter } from "./adapter-D8-lqOBF.js";
1
+ import { Mo as createDurableLocationConfigurationService, ri as JUNIOR_THREAD_STATE_TTL_MS, y as persistConversationMessages } from "./projection-DliWYrnT.js";
2
+ import { G as toOptionalNumber, K as toOptionalString, W as isRecord } from "./logging-BfORLKoq.js";
3
+ import { S as getDb } from "./viewer-1Ea81s0b.js";
4
+ import { r as getStateAdapter } from "./adapter-DN5AB4VU.js";
5
5
  // src/chat/state/conversation.ts
6
6
  function defaultConversationState() {
7
7
  return {
@@ -1,11 +1,11 @@
1
- import { K as clearPendingAuth, M as markConversationMessage, lo as listConversationAnnotations, un as buildDeterministicTurnId, v as hydrateConversationMessages } from "./projection-BfKkpOGQ.js";
2
- import { b as getProviderErrorUserMessage, g as ProviderError, v as findProviderError, y as getProviderErrorAttributes } from "./client-a3Ib6wxr.js";
3
- import { W as isRecord, t as buildTurnFailureResponse } from "./logging-2BXvW7Mp.js";
1
+ import { Eo as listConversationAnnotations, N as markConversationMessage, bn as buildDeterministicTurnId, q as clearPendingAuth, v as hydrateConversationMessages } from "./projection-DliWYrnT.js";
2
+ import { b as getProviderErrorUserMessage, g as ProviderError, v as findProviderError, y as getProviderErrorAttributes } from "./client-DDbBucBw.js";
3
+ import { W as isRecord, t as buildTurnFailureResponse } from "./logging-BfORLKoq.js";
4
4
  import { h as parseSlackMessageTs } from "./actor-6jsm_v96.js";
5
- import { S as getDb, y as getConversationEventStore } from "./viewer-CYB9T4rm.js";
6
- import { M as readMessageCardRefs, N as removedCardSchema, P as resolveMessageCards } from "./conversation-DdT7SNar.js";
7
- import { O as parseAgentInvocationResultMessageId, Q as markTurnCompleted, Z as markTurnClosed, c as getAgentInvocation, m as getAgentInvocationTurnId } from "./store-61mD4ZSh.js";
8
- import { a as persistThreadStateById, o as coerceThreadConversationState, r as getPersistedThreadState } from "./thread-state-0UfRMWYd.js";
5
+ import { S as getDb, y as getConversationEventStore } from "./viewer-1Ea81s0b.js";
6
+ import { F as removedCardSchema, I as resolveMessageCards, P as readMessageCardRefs } from "./conversation-D8kVoCrP.js";
7
+ import { F as getAgentInvocationTurnId, J as markTurnClosed, Y as markTurnCompleted, a as getAgentInvocation, z as parseAgentInvocationResultMessageId } from "./store-B26LV6UP.js";
8
+ import { a as persistThreadStateById, o as coerceThreadConversationState, r as getPersistedThreadState } from "./thread-state-CrFk3K_7.js";
9
9
  // src/chat/conversations/pending-cards.ts
10
10
  /**
11
11
  * Add the cards that tool results selected since the last visible assistant
@@ -1,4 +1,4 @@
1
- import { y as getConversationEventStore } from "./viewer-CYB9T4rm.js";
1
+ import { y as getConversationEventStore } from "./viewer-1Ea81s0b.js";
2
2
  // src/chat/conversations/turn-lifecycle.ts
3
3
  /** Persist correlated turn lifecycle facts with retry-safe terminal exclusion. */
4
4
  var ConversationTurnLifecycleService = class {