@sentry/junior 0.275.0 → 0.276.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 (71) hide show
  1. package/dist/{adapter-dE2BiWP_.js → adapter-DoPR2jS-.js} +1 -1
  2. package/dist/{admin-CkPaAYuZ.js → admin-BJTT-kXb.js} +1 -1
  3. package/dist/{agent-invocations-C1RNOCs8.js → agent-invocations-CUWrrzkc.js} +1 -0
  4. package/dist/{agent-runner-bE7aH7ew.js → agent-runner-sMpA5qGM.js} +266 -202
  5. package/dist/api/schema.d.ts +2 -2
  6. package/dist/api/schema.js +3 -3
  7. package/dist/api.d.ts +1 -1
  8. package/dist/api.js +75 -66
  9. package/dist/{app-CgkquhZ8.d.ts → app-DTj-yAQt.d.ts} +10 -2
  10. package/dist/app.d.ts +1 -1
  11. package/dist/app.js +192 -86
  12. package/dist/{assistant-reply-CjRU9Z59.js → assistant-reply-DbxKnBQF.js} +1 -1
  13. package/dist/{automation-BGrd03QO.js → automation-B8_mC68r.js} +42 -13
  14. package/dist/{background-compaction-queue-BYuOt3qK.js → background-compaction-queue-Bywqo1WJ.js} +2 -2
  15. package/dist/{briefs-6xUvmGos.js → briefs-IL7QnCCR.js} +4 -4
  16. package/dist/{catalog-runtime-DcJ5NHDW.js → catalog-runtime--sC2CYLQ.js} +1 -1
  17. package/dist/cli/chat.js +14 -14
  18. package/dist/cli/check.js +3 -3
  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 +3 -3
  24. package/dist/{client-gnKpkpqP.js → client-7diKvInp.js} +2 -2
  25. package/dist/{config-D0GKc9sC.js → config-Cb--cuv-.js} +2 -2
  26. package/dist/{connections-DLqP5Bp1.js → connections-C4-4fxaE.js} +14 -14
  27. package/dist/{conversation-BjTo9ZFL.js → conversation-DppJ83Hw.js} +32 -7
  28. package/dist/{conversation-privacy-BCXFshP9.js → conversation-privacy-DTwdT3Pi.js} +1 -1
  29. package/dist/{credential-sync-BjihXFF2.js → credential-sync-Sl5RQCkS.js} +13 -13
  30. package/dist/{db-BMZhoYKj.d.ts → db-Ck6TXQIx.d.ts} +1 -1
  31. package/dist/{executor-j8VMt-To.js → executor-BFKmqxYe.js} +3 -3
  32. package/dist/instrumentation.d.ts +14 -0
  33. package/dist/instrumentation.js +29 -6
  34. package/dist/{logging-CFHIO4Vs.js → logging-B04X_eCB.js} +1 -1
  35. package/dist/{message-DH0cqFRS.js → message-DQMFyyE-.js} +9 -9
  36. package/dist/nitro.d.ts +1 -1
  37. package/dist/nitro.js +3 -3
  38. package/dist/{oauth-callback-server-BgU4EZsJ.js → oauth-callback-server-BGq0_vQI.js} +2 -2
  39. package/dist/{projection-CTvLSwcm.js → projection-6dXaN0n-.js} +99 -17
  40. package/dist/{prompt-JEWUUpLW.js → prompt-B4fQKGZR.js} +1 -1
  41. package/dist/{registry-OsyWR4GO.js → registry-CEqKR_ld.js} +1 -1
  42. package/dist/{resolve-DCrKjmVP.js → resolve-8I5DkrfI.js} +3 -3
  43. package/dist/{result-Btdt5bSl.js → result-BgAW90IM.js} +9 -9
  44. package/dist/{runner-C1AwS93W.js → runner-CSKDr_19.js} +12 -12
  45. package/dist/{sandbox-egress-signals-C-5i7Zxm.js → sandbox-egress-signals-BxAT276e.js} +1 -1
  46. package/dist/{schema-DfdHlBnb.d.ts → schema-CaUWl2EV.d.ts} +74 -6
  47. package/dist/{schema-CX9XGKCm.js → schema-Cal-EFdi.js} +9 -7
  48. package/dist/{service-account-CQIW6At4.js → service-account-CUuVJCKT.js} +3 -3
  49. package/dist/{service-account-DZX1KlQl.js → service-account-CtOab1Xz.js} +3 -3
  50. package/dist/{session-stop-DjIyORJw.js → session-stop-DK8LuPZW.js} +155 -54
  51. package/dist/{skills-BEfAAT6p.js → skills-Bc0D7BGy.js} +2 -2
  52. package/dist/{spawn-Dgj4xxvO.js → spawn-DF_GUcd8.js} +2 -2
  53. package/dist/{stop-DomyNvuv.js → stop-DthSy-z8.js} +130 -81
  54. package/dist/{store-Dp3RMEQd.js → store-BgH2P3X9.js} +3 -3
  55. package/dist/{store-B7Z6zIc7.js → store-C5uVTx2G.js} +11 -9
  56. package/dist/{task-queue-CVQ9cWnC.js → task-queue-C6ROM_XJ.js} +3 -3
  57. package/dist/{task-runner-DHBG47gS.js → task-runner-BwAkjjVE.js} +6 -6
  58. package/dist/{thread-state-BF8VwIxd.js → thread-state-BXjgk1pW.js} +4 -4
  59. package/dist/{turn-failure-response-Di7TbgsF.js → turn-failure-response-CVI57qKL.js} +7 -7
  60. package/dist/{turn-lifecycle-DzXwXmLg.js → turn-lifecycle-CF6ibonp.js} +6 -1
  61. package/dist/{turn-session-routing-CIWhXKeT.js → turn-session-routing-DddybdNu.js} +17 -16
  62. package/dist/{validation-BRmwRaXc.js → validation-BxF1nQbC.js} +1 -1
  63. package/dist/{version-DBVMsgvA.js → version-CTzSbCmR.js} +1 -1
  64. package/dist/version.js +1 -1
  65. package/dist/{viewer-BFADRGP8.js → viewer-CQwBszc7.js} +10 -7
  66. package/dist/{work-DDaoxZAw.js → work-BHlShEQ6.js} +30 -12
  67. package/dist/{worker-Bub0fDtW.js → worker-DhY9MnsH.js} +6 -6
  68. package/migrations/0073_conversation_quick_question.sql +1 -0
  69. package/migrations/meta/0073_snapshot.json +4070 -0
  70. package/migrations/meta/_journal.json +7 -0
  71. package/package.json +6 -5
@@ -1,4 +1,4 @@
1
- import { y as getConversationEventStore } from "./viewer-BFADRGP8.js";
1
+ import { y as getConversationEventStore } from "./viewer-CQwBszc7.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 {
@@ -19,6 +19,11 @@ var ConversationTurnLifecycleService = class {
19
19
  }
20
20
  }]);
21
21
  }
22
+ /** Return the input message ids that started a Turn, when it started. */
23
+ async loadInputMessageIds(conversationId, turnId) {
24
+ const event = await this.events.loadByIdempotencyKey(conversationId, `turn:${turnId}:started`);
25
+ return event?.data.type === "turn_started" ? event.data.inputMessageIds : void 0;
26
+ }
22
27
  /** Record a completion that is not a failure once. */
23
28
  async complete(input) {
24
29
  await this.events.append(input.conversationId, [{
@@ -1,16 +1,16 @@
1
- import { D as fallbackShortTitle, Rr as escapeSlackMrkdwnText, Xr as postSlackMessage, ca as getDashboardTaskLink, ia as JUNIOR_THREAD_STATE_TTL_MS, qr as openSlackDirectMessage, ua as ToolInputError, zr as formatSlackLink } from "./projection-CTvLSwcm.js";
2
- import { n as botConfig } from "./config-D0GKc9sC.js";
3
- import { _ as runBestEffort, h as logWarn } from "./logging-CFHIO4Vs.js";
4
- import { G as agentTurnCostUsd, K as agentTurnTotalTokens, S as getDb } from "./viewer-BFADRGP8.js";
5
- import { s as juniorConversations } from "./agent-invocations-C1RNOCs8.js";
6
- import { d as juniorAutomations, l as juniorAutomationRuns, u as juniorAutomationVersions } from "./executor-j8VMt-To.js";
7
- import { h as credentialSubjectSchema } from "./registry-OsyWR4GO.js";
8
- import { r as getStateAdapter } from "./adapter-dE2BiWP_.js";
9
- import { O as eventAutomationSchema, S as automationVersionSchema, j as scheduledAutomationSchema } from "./automation-BGrd03QO.js";
1
+ import { $r as postSlackMessage, D as fallbackShortTitle, Hr as formatSlackLink, Vr as escapeSlackMrkdwnText, Xr as openSlackDirectMessage, da as getDashboardTaskLink, pa as ToolInputError, sa as JUNIOR_THREAD_STATE_TTL_MS } from "./projection-6dXaN0n-.js";
2
+ import { n as botConfig } from "./config-Cb--cuv-.js";
3
+ import { _ as runBestEffort, h as logWarn } from "./logging-B04X_eCB.js";
4
+ import { G as agentTurnCostUsd, K as agentTurnTotalTokens, S as getDb } from "./viewer-CQwBszc7.js";
5
+ import { s as juniorConversations } from "./agent-invocations-CUWrrzkc.js";
6
+ import { d as juniorAutomations, l as juniorAutomationRuns, u as juniorAutomationVersions } from "./executor-BFKmqxYe.js";
7
+ import { h as credentialSubjectSchema } from "./registry-CEqKR_ld.js";
8
+ import { r as getStateAdapter } from "./adapter-DoPR2jS-.js";
9
+ import { O as eventAutomationSchema, S as automationVersionSchema, j as scheduledAutomationSchema } from "./automation-B8_mC68r.js";
10
10
  import { createHash } from "node:crypto";
11
11
  import { z } from "zod";
12
12
  import { and, asc, count, desc, eq, gte, inArray, isNotNull, isNull, lte, max, ne, or, sql } from "drizzle-orm";
13
- import { anyResourceMatchFields, describeEventTrigger, destinationSchema, destinationVisibilitySchema, eventMatchSchema, eventMatches, eventTriggerChoices, eventTriggerProblems, isSlackDestination, normalizeEventIdentifier, normalizeEventMatch, replyAttributionSchema, sourceSchema, taskOutcomeSchema } from "@sentry/junior-plugin-api";
13
+ import { agentEventMatchSchema, anyResourceMatchFields, describeEventTrigger, destinationSchema, destinationVisibilitySchema, eventMatches, eventTriggerChoices, eventTriggerProblems, isSlackDestination, normalizeEventIdentifier, normalizeEventMatch, replyAttributionSchema, sourceSchema, taskOutcomeSchema } from "@sentry/junior-plugin-api";
14
14
  // src/chat/events/catalog.ts
15
15
  /** A source with nothing enabled, for a namespace that the catalog lacks. */
16
16
  const NO_SOURCE = {
@@ -86,7 +86,7 @@ function eventGuidance(catalog, namespace, eventType) {
86
86
  }
87
87
  /** Build the match object the tools accept for one resource type. */
88
88
  function registeredEventMatchSchema() {
89
- return eventMatchSchema.optional().describe("Optional filters: exact values for the resource type matchFields. A single value must equal the event data. A list means the event value may be any one entry. For a field with list: true, the event value is a list, and it matches when it includes the value or any entry. A field with events is set only on those events, so every selected event must be in that list. Omit a key to ignore it. Unmatched events are dropped with no agent turn.");
89
+ return agentEventMatchSchema.optional().describe("Optional filters: exact values for the resource type match_fields, with snake_case keys. A single value must equal the event data. A list means the event value may be any one entry. For a field with list: true, the event value is a list, and it matches when it includes the value or any entry. A field with events is set only on those events, so every selected event must be in that list. Omit a key to ignore it. Unmatched events are dropped with no agent turn.");
90
90
  }
91
91
  /**
92
92
  * List why a selection cannot work with the enabled plugins. Use it for new
@@ -111,15 +111,16 @@ function uniqueMatchValues(match) {
111
111
  * Reject an event automation trigger or a Watch that cannot work, with every
112
112
  * problem in one message for the agent. Return its match as it is saved:
113
113
  * each text value in the case that its plugin declares, with no repeated
114
- * list values.
114
+ * list values. The dashboard clears `inputKeys` so messages name the filters
115
+ * as its plugin declares them.
115
116
  */
116
- function requireValidEventTrigger(catalog, selection, target) {
117
+ function requireValidEventTrigger(catalog, selection, target, options = { inputKeys: true }) {
117
118
  const fields = eventTriggerChoices(catalog[selection.namespace] ?? NO_SOURCE, selection)?.fields ?? {};
118
119
  const normalized = {
119
120
  ...selection,
120
121
  match: normalizeEventMatch(fields, selection.match)
121
122
  };
122
- const problems = registeredEventTriggerProblems(catalog, normalized, { inputKeys: true });
123
+ const problems = registeredEventTriggerProblems(catalog, normalized, options);
123
124
  if (problems.length > 0) {
124
125
  const source = catalog[selection.namespace]?.displayName ?? selection.namespace;
125
126
  const resource = selection.resourceType ? `${source} ${selection.resourceType.replaceAll("_", " ")}` : source;
@@ -141,7 +142,7 @@ function requireEventIdentifier(catalog, input) {
141
142
  const resourceType = resourceTypes.find((candidate) => candidate.type === input.resourceType);
142
143
  if (!resourceType?.identifier || fits(resourceType)) return identifier;
143
144
  const fitting = resourceTypes.filter(fits).map((candidate) => candidate.type);
144
- throw new ToolInputError([`Identifier "${identifier}" does not fit resourceType "${input.resourceType}" in namespace "${input.namespace}". Expected format: "${resourceType.identifier.format}".`, ...fitting.length > 0 ? [`If the identifier is correct, use one of these resourceType values: ${fitting.map((type) => `"${type}"`).join(", ")}.`] : []].join(" "));
145
+ throw new ToolInputError([`Identifier "${identifier}" does not fit resource_type "${input.resourceType}" in namespace "${input.namespace}". Expected format: "${resourceType.identifier.format}".`, ...fitting.length > 0 ? [`If the identifier is correct, use one of these resource_type values: ${fitting.map((type) => `"${type}"`).join(", ")}.`] : []].join(" "));
145
146
  }
146
147
  // src/chat/automations/revision.ts
147
148
  /** Storage revisions prevent stale edits from replacing newer values. */
@@ -1583,7 +1584,7 @@ function slackSourceForDestination(args) {
1583
1584
  * Reads parent Conversations when this Conversation has no Destination.
1584
1585
  */
1585
1586
  async function resolveConversationRouting(args) {
1586
- const conversationStore = args.conversationStore ?? (await import("./viewer-BFADRGP8.js").then((n) => n.v)).getConversationStore();
1587
+ const conversationStore = args.conversationStore ?? (await import("./viewer-CQwBszc7.js").then((n) => n.v)).getConversationStore();
1587
1588
  const chain = await loadConversationChain(args.conversationId, conversationStore);
1588
1589
  let destination;
1589
1590
  let source;
@@ -1,5 +1,5 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-nwUcYXjP.js";
2
- import { n as pluginCatalogRuntime } from "./catalog-runtime-DcJ5NHDW.js";
2
+ import { n as pluginCatalogRuntime } from "./catalog-runtime--sC2CYLQ.js";
3
3
  import { isDeepStrictEqual } from "node:util";
4
4
  // src/chat/plugins/validation.ts
5
5
  var validation_exports = /* @__PURE__ */ __exportAll({
@@ -1,5 +1,5 @@
1
1
  // package.json
2
- var version = "0.275.0";
2
+ var version = "0.276.0";
3
3
  // src/version.ts
4
4
  /** Installed Junior package version, or `unknown` when package metadata is unavailable. */
5
5
  const JUNIOR_VERSION = typeof version === "string" && version.trim() ? version : "unknown";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export { t as JUNIOR_VERSION } from "./version-DBVMsgvA.js";
1
+ export { t as JUNIOR_VERSION } from "./version-CTzSbCmR.js";
@@ -1,9 +1,9 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-nwUcYXjP.js";
2
- import { i as getChatConfig } from "./config-D0GKc9sC.js";
3
- import { V as normalizeIdentityEmail, h as logWarn, z as GOOGLE_IDENTITY_PROVIDER } from "./logging-CFHIO4Vs.js";
2
+ import { i as getChatConfig } from "./config-Cb--cuv-.js";
3
+ import { V as normalizeIdentityEmail, h as logWarn, z as GOOGLE_IDENTITY_PROVIDER } from "./logging-B04X_eCB.js";
4
4
  import { a as isSlackUserId, d as parseSlackChannelReferenceId, f as parseSlackTeamId, s as parseActorUserId } from "./actor-B4DYygOB.js";
5
- import { c as juniorIdentities, d as juniorDestinations, l as juniorUsers, o as conversationReadColumns, s as juniorConversations } from "./agent-invocations-C1RNOCs8.js";
6
- import { S as juniorConversationAnnotations, b as juniorConversationEvents, g as juniorConversationBindings, h as juniorConversationParticipants, t as createJuniorSqlExecutor, v as CONVERSATION_METRICS, y as juniorConversationMetrics } from "./executor-j8VMt-To.js";
5
+ import { c as juniorIdentities, d as juniorDestinations, l as juniorUsers, o as conversationReadColumns, s as juniorConversations } from "./agent-invocations-CUWrrzkc.js";
6
+ import { S as juniorConversationAnnotations, b as juniorConversationEvents, g as juniorConversationBindings, h as juniorConversationParticipants, t as createJuniorSqlExecutor, v as CONVERSATION_METRICS, y as juniorConversationMetrics } from "./executor-BFKmqxYe.js";
7
7
  import { d as newConversationEventSchema, f as encodeHistoryPayload, l as decodeStoredConversationEvent, n as detectImageMediaType, o as conversationEventDataSchema, u as historyReplacementSchema, v as usageSchema } from "./media-DstkkoNP.js";
8
8
  import { a as withLock } from "./locks-D-0h111u.js";
9
9
  import { createHash, randomUUID } from "node:crypto";
@@ -1225,9 +1225,12 @@ async function findJuniorIdentityIdByEmail(executor, email) {
1225
1225
  return (await executor.db().select({ id: juniorIdentities.id }).from(juniorIdentities).where(and(eq(juniorIdentities.provider, "junior"), eq(juniorIdentities.kind, "user"), or(eq(juniorIdentities.providerSubjectId, normalized), and(eq(juniorIdentities.emailNormalized, normalized), eq(juniorIdentities.emailVerified, true))))).limit(1))[0]?.id;
1226
1226
  }
1227
1227
  /**
1228
- * Resolve a dashboard:<hash> author against junior identities keyed by email.
1229
- * Web actors store userId as dashboard:${sha256(email).slice(0,24)} while the
1230
- * durable identity subject remains the verified email.
1228
+ * Resolve a legacy dashboard:<hash> author against junior identities keyed by
1229
+ * email. Web Actors stored dashboard:${sha256(email).slice(0,24)} before they
1230
+ * used the User id. This read-only fallback serves only those old events.
1231
+ *
1232
+ * TODO(dcramer): Delete with the guess in resolveEventActorIdentityId, after
1233
+ * every stored user Message event has its author Identity.
1231
1234
  */
1232
1235
  async function findJuniorIdentityIdByDashboardAuthorId(executor, dashboardAuthorId) {
1233
1236
  if (!dashboardAuthorId.startsWith("dashboard:")) return;
@@ -1,14 +1,14 @@
1
- import { G as AuthorizationFlowDisabledError, V as PluginCredentialFailureError, Va as loadForkHistory, Wt as isTurnExecutionLimitExceededError, Yt as getTerminalAssistantMessages, et as saveTurnCheckpoint, it as getTurnRecord, l as openConversationProjection, rt as failTurnRecord, tt as abandonTurnRecord } from "./projection-CTvLSwcm.js";
2
- import { n as botConfig } from "./config-D0GKc9sC.js";
3
- import { M as SYSTEM_IDENTITY_ID, x as getConversationStore, y as getConversationEventStore } from "./viewer-BFADRGP8.js";
1
+ import { G as AuthorizationFlowDisabledError, V as PluginCredentialFailureError, Wa as loadForkHistory, Wt as isTurnExecutionLimitExceededError, Yt as getTerminalAssistantMessages, et as saveTurnCheckpoint, it as getTurnRecord, l as openConversationProjection, rt as failTurnRecord, tt as abandonTurnRecord } from "./projection-6dXaN0n-.js";
2
+ import { n as botConfig } from "./config-Cb--cuv-.js";
3
+ import { M as SYSTEM_IDENTITY_ID, x as getConversationStore, y as getConversationEventStore } from "./viewer-CQwBszc7.js";
4
4
  import { _ as sameActorIdentity, p as agentInstructionProvenance } from "./media-DstkkoNP.js";
5
- import { Ft as readBlockedReport, Ot as buildSteeringPiMessage, bt as recordSubagentEnded, kt as withoutSavedSteeringMessages, vt as stopChildAgentsOf, xt as recordSubagentStarted } from "./agent-runner-bE7aH7ew.js";
6
- import { B as agentTypeStartsWithParentHistory, E as markAgentInvocationSteered, J as isTurnInputCommitLostError, K as getConversationTurnBoundaryError, O as reportReplacedAgentInvocation, S as markAgentInvocationMailboxAppended, T as markAgentInvocationRunning, W as TurnInputCommitLostError, d as getAgentInvocationMessageId, g as getLatestAgentInvocationForConversation, n as completeAgentInvocation, o as getActiveAgentInvocationForConversation, p as getAgentInvocationTurnId, r as createAgentInvocation, s as getAgentInvocation, v as isTerminalAgentInvocation, w as markAgentInvocationPaused, y as listActiveAgentInvocationsForConversation, z as agentTypeInstructions } from "./store-B7Z6zIc7.js";
7
- import { n as getAssistantReplyText } from "./assistant-reply-CjRU9Z59.js";
8
- import { A as recordFinishedTurnForAutomatedLimit, j as resetAutomatedTurnLimit, w as maybePostAutomatedTurnLimitNotice } from "./session-stop-DjIyORJw.js";
9
- import { r as appendAndEnqueueInboundMessage } from "./store-Dp3RMEQd.js";
10
- import { t as ConversationTurnLifecycleService } from "./turn-lifecycle-DzXwXmLg.js";
11
- import { a as persistThreadStateById, n as getPersistedSandboxState, r as getPersistedThreadState } from "./thread-state-BF8VwIxd.js";
5
+ import { At as withoutSavedSteeringMessages, It as readBlockedReport, St as recordSubagentStarted, kt as buildSteeringPiMessage, xt as recordSubagentEnded, yt as stopChildAgentsOf } from "./agent-runner-sMpA5qGM.js";
6
+ import { B as agentTypeInstructions, C as markAgentInvocationMailboxAppended, D as markAgentInvocationSteered, E as markAgentInvocationRunning, G as TurnInputCommitLostError, T as markAgentInvocationPaused, V as agentTypeStartsWithParentHistory, Y as isTurnInputCommitLostError, _ as getLatestAgentInvocationForConversation, b as listAgentInvocationsForConversation, c as getAgentInvocation, f as getAgentInvocationMessageId, i as createAgentInvocation, k as reportReplacedAgentInvocation, m as getAgentInvocationTurnId, n as NON_TERMINAL_AGENT_INVOCATION_STATUSES, q as getConversationTurnBoundaryError, r as completeAgentInvocation, s as getActiveAgentInvocationForConversation, t as ACTIVE_AGENT_INVOCATION_STATUSES, y as isTerminalAgentInvocation } from "./store-C5uVTx2G.js";
7
+ import { n as getAssistantReplyText } from "./assistant-reply-DbxKnBQF.js";
8
+ import { E as maybePostAutomatedTurnLimitNotice, M as recordFinishedTurnForAutomatedLimit, N as resetAutomatedTurnLimit } from "./session-stop-DK8LuPZW.js";
9
+ import { r as appendAndEnqueueInboundMessage } from "./store-BgH2P3X9.js";
10
+ import { t as ConversationTurnLifecycleService } from "./turn-lifecycle-CF6ibonp.js";
11
+ import { a as persistThreadStateById, n as getPersistedSandboxState, r as getPersistedThreadState } from "./thread-state-BXjgk1pW.js";
12
12
  import { isDeepStrictEqual } from "node:util";
13
13
  import { z } from "zod";
14
14
  // src/chat/runtime/turn-execution.ts
@@ -281,6 +281,24 @@ async function endOtherActiveAgentInvocation(invocation) {
281
281
  status: "failed"
282
282
  });
283
283
  }
284
+ /**
285
+ * End every agent invocation of a child whose last attempt lost its worker and
286
+ * whose input reached the child's mailbox. The worker ran no failure path, and
287
+ * the stop drops the mailbox, so none of them can run. The heartbeat sends
288
+ * each result.
289
+ */
290
+ async function endAgentInvocationsOfStoppedWork(conversationId, inboundMessageIds) {
291
+ for (const invocation of await listAgentInvocationsForConversation(conversationId, NON_TERMINAL_AGENT_INVOCATION_STATUSES)) {
292
+ if (!inboundMessageIds.includes(getAgentInvocationMessageId(invocation.invocationId))) continue;
293
+ const terminal = await projectTerminalTurn(invocation, { reportNow: true }) ?? await completeAgentInvocation({
294
+ invocationId: invocation.invocationId,
295
+ errorMessage: "This task stopped because its worker failed repeatedly.",
296
+ reportNow: true,
297
+ status: "failed"
298
+ });
299
+ if (terminal && isTerminalAgentInvocation(terminal)) await persistTerminalLifecycle(terminal);
300
+ }
301
+ }
284
302
  /** Classify authorization failures that terminally block background work. */
285
303
  function blockingInvocationError(error) {
286
304
  const cause = getConversationTurnBoundaryError(error)?.cause ?? error;
@@ -415,7 +433,7 @@ function createAgentInvocationWorker(agentRunner, options = {}) {
415
433
  await acknowledge();
416
434
  return { status: "completed" };
417
435
  }
418
- for (const active of await listActiveAgentInvocationsForConversation(invocation.childConversationId)) if (active.invocationId !== invocation.invocationId) await finish(await endOtherActiveAgentInvocation(active));
436
+ for (const active of await listAgentInvocationsForConversation(invocation.childConversationId, ACTIVE_AGENT_INVOCATION_STATUSES)) if (active.invocationId !== invocation.invocationId) await finish(await endOtherActiveAgentInvocation(active));
419
437
  invocation = await markAgentInvocationRunning(invocation.invocationId) ?? invocation;
420
438
  if (isTerminalAgentInvocation(invocation)) {
421
439
  await finish(invocation);
@@ -529,4 +547,4 @@ function createAgentInvocationWorker(agentRunner, options = {}) {
529
547
  return { status: "completed" };
530
548
  };
531
549
  }
532
- export { AgentRunError as a, resolveAgentInvocationId as i, createAndEnqueueAgentInvocation as n, executeTurn as o, enqueueAgentInvocation as r, createAgentInvocationWorker as t };
550
+ export { resolveAgentInvocationId as a, enqueueAgentInvocation as i, createAndEnqueueAgentInvocation as n, AgentRunError as o, endAgentInvocationsOfStoppedWork as r, executeTurn as s, createAgentInvocationWorker as t };
@@ -1,10 +1,10 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-nwUcYXjP.js";
2
- import { Ct as hasConversationStop, Et as isInvalidConversationRecordError, Tt as isFinalAttempt } from "./projection-CTvLSwcm.js";
3
- import { b as isProviderRetryError } from "./client-gnKpkpqP.js";
4
- import { i as getChatConfig } from "./config-D0GKc9sC.js";
5
- import { T as withLogContext, b as setSpanAttributes, h as logWarn, m as logInfo, p as logException } from "./logging-CFHIO4Vs.js";
6
- import { g as getTurnRequestDeadline, v as ConversationQueueMessageRejectedError } from "./background-compaction-queue-BYuOt3qK.js";
7
- import { C as requestAnotherSlice, T as startConversationWork, b as recordConversationRetry, d as countPendingConversationMessages, f as deadLetterAttempt, g as getConversationWorkState, i as beginConversationResume, l as completeConversationStop, m as ensureConversationWake, o as checkInConversationWork, p as drainConversationMailbox, s as clearConsumedConversationWake, t as ackMessages, u as completeConversationWork, x as releaseConversationWork, y as recordAttemptFailure } from "./store-Dp3RMEQd.js";
2
+ import { Ct as hasConversationStop, Et as isInvalidConversationRecordError, Tt as isFinalAttempt } from "./projection-6dXaN0n-.js";
3
+ import { b as isProviderRetryError } from "./client-7diKvInp.js";
4
+ import { i as getChatConfig } from "./config-Cb--cuv-.js";
5
+ import { T as withLogContext, b as setSpanAttributes, h as logWarn, m as logInfo, p as logException } from "./logging-B04X_eCB.js";
6
+ import { g as getTurnRequestDeadline, v as ConversationQueueMessageRejectedError } from "./background-compaction-queue-Bywqo1WJ.js";
7
+ import { C as requestAnotherSlice, T as startConversationWork, b as recordConversationRetry, d as countPendingConversationMessages, f as deadLetterAttempt, g as getConversationWorkState, i as beginConversationResume, l as completeConversationStop, m as ensureConversationWake, o as checkInConversationWork, p as drainConversationMailbox, s as clearConsumedConversationWake, t as ackMessages, u as completeConversationWork, x as releaseConversationWork, y as recordAttemptFailure } from "./store-BgH2P3X9.js";
8
8
  // src/chat/task-execution/attempt-selection.ts
9
9
  function selectContiguousTurnBatch(messages) {
10
10
  const first = messages[0];
@@ -0,0 +1 @@
1
+ ALTER TABLE "junior_conversations" ADD COLUMN "quick_question_at" timestamp with time zone;