@sentry/junior 0.274.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-4qThDhgF.js → adapter-DoPR2jS-.js} +1 -1
  2. package/dist/{admin-c7ASvs6x.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-CLHM48dh.js → agent-runner-sMpA5qGM.js} +1118 -394
  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-BlmPpPoR.d.ts → app-DTj-yAQt.d.ts} +26 -2
  10. package/dist/app.d.ts +1 -1
  11. package/dist/app.js +237 -87
  12. package/dist/{assistant-reply-2IwdFWuQ.js → assistant-reply-DbxKnBQF.js} +1 -1
  13. package/dist/{automation-BGrd03QO.js → automation-B8_mC68r.js} +42 -13
  14. package/dist/{job-queue-Bh9sFO9t.js → background-compaction-queue-Bywqo1WJ.js} +42 -3
  15. package/dist/{briefs-C1-NOh8m.js → briefs-IL7QnCCR.js} +4 -4
  16. package/dist/{catalog-runtime-BnIJimKZ.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-C0ZIxoDr.js → client-7diKvInp.js} +2 -2
  25. package/dist/{config-DS-QLVSL.js → config-Cb--cuv-.js} +2 -2
  26. package/dist/{connections-Djb6ANAh.js → connections-C4-4fxaE.js} +14 -14
  27. package/dist/{conversation-BjTo9ZFL.js → conversation-DppJ83Hw.js} +32 -7
  28. package/dist/{conversation-privacy-3IMUZSHC.js → conversation-privacy-DTwdT3Pi.js} +1 -1
  29. package/dist/{credential-sync-ig88EB_v.js → credential-sync-Sl5RQCkS.js} +13 -13
  30. package/dist/{db-BMZhoYKj.d.ts → db-Ck6TXQIx.d.ts} +1 -1
  31. package/dist/{executor-C2moGIHS.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-DYRS7E8s.js → logging-B04X_eCB.js} +3 -2
  35. package/dist/{message-CicNrhCv.js → message-DQMFyyE-.js} +9 -9
  36. package/dist/nitro.d.ts +1 -1
  37. package/dist/nitro.js +13 -3
  38. package/dist/{oauth-callback-server-BXyrepfY.js → oauth-callback-server-BGq0_vQI.js} +2 -2
  39. package/dist/{projection-CMRrv9Pt.js → projection-6dXaN0n-.js} +109 -17
  40. package/dist/{prompt-JEWUUpLW.js → prompt-B4fQKGZR.js} +1 -1
  41. package/dist/{registry-D92WLl5I.js → registry-CEqKR_ld.js} +1 -1
  42. package/dist/{resolve-C-Dh14ps.js → resolve-8I5DkrfI.js} +3 -3
  43. package/dist/{result-DZ8TCQkd.js → result-BgAW90IM.js} +9 -9
  44. package/dist/{runner-BBmhrQTM.js → runner-CSKDr_19.js} +12 -12
  45. package/dist/{sandbox-egress-signals-Cehpq6hC.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-Bapo6l0R.js → service-account-CUuVJCKT.js} +3 -3
  49. package/dist/{service-account-Ce1465Fn.js → service-account-CtOab1Xz.js} +3 -3
  50. package/dist/{session-stop-CI5qJU7a.js → session-stop-DK8LuPZW.js} +155 -54
  51. package/dist/{skills-D-d79XQ6.js → skills-Bc0D7BGy.js} +2 -2
  52. package/dist/{spawn-C_FETz5x.js → spawn-DF_GUcd8.js} +2 -2
  53. package/dist/{stop-CmwFHwiN.js → stop-DthSy-z8.js} +159 -121
  54. package/dist/{store-BvI3yBGS.js → store-BgH2P3X9.js} +3 -3
  55. package/dist/{store-BIQYXvoV.js → store-C5uVTx2G.js} +11 -9
  56. package/dist/{task-queue-BdB0pab8.js → task-queue-C6ROM_XJ.js} +3 -3
  57. package/dist/{task-runner-DQr2QfvJ.js → task-runner-BwAkjjVE.js} +6 -6
  58. package/dist/{thread-state-ngCvtWNa.js → thread-state-BXjgk1pW.js} +4 -4
  59. package/dist/{turn-failure-response-BDT3sT2v.js → turn-failure-response-CVI57qKL.js} +7 -7
  60. package/dist/{turn-lifecycle-B7O6rZEX.js → turn-lifecycle-CF6ibonp.js} +6 -1
  61. package/dist/{turn-session-routing-DIeqG2pO.js → turn-session-routing-DddybdNu.js} +17 -16
  62. package/dist/{validation-D3Xik64v.js → validation-BxF1nQbC.js} +1 -1
  63. package/dist/{version-BoWLhNzj.js → version-CTzSbCmR.js} +1 -1
  64. package/dist/version.js +1 -1
  65. package/dist/{viewer-D25XOUHc.js → viewer-CQwBszc7.js} +10 -7
  66. package/dist/{work-D12-wcf4.js → work-BHlShEQ6.js} +30 -12
  67. package/dist/{worker-DGxfDtES.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,8 +1,8 @@
1
1
  import { c as modelProfileSchema, u as TURN_REASONING_LEVELS } from "./model-profile-B998sjVd.js";
2
- import { C as getSqlExecutor, x as getConversationStore } from "./viewer-D25XOUHc.js";
3
- import { a as juniorAgentInvocations, i as juniorAgentBindings, n as AGENT_INVOCATION_PARENT_MAILBOX_STATUSES, t as AGENT_INVOCATION_MAILBOX_STATUSES } from "./agent-invocations-C1RNOCs8.js";
4
- import "./executor-C2moGIHS.js";
5
- import { p as credentialContextSchema } from "./registry-D92WLl5I.js";
2
+ import { C as getSqlExecutor, x as getConversationStore } from "./viewer-CQwBszc7.js";
3
+ import { a as juniorAgentInvocations, i as juniorAgentBindings, n as AGENT_INVOCATION_PARENT_MAILBOX_STATUSES, t as AGENT_INVOCATION_MAILBOX_STATUSES } from "./agent-invocations-CUWrrzkc.js";
4
+ import "./executor-BFKmqxYe.js";
5
+ import { p as credentialContextSchema } from "./registry-CEqKR_ld.js";
6
6
  import { createHash } from "node:crypto";
7
7
  import { z } from "zod";
8
8
  import { and, asc, count, countDistinct, desc, eq, inArray, lt, ne, or, sql } from "drizzle-orm";
@@ -304,6 +304,8 @@ const TERMINAL_AGENT_INVOCATION_STATUSES = [
304
304
  "failed",
305
305
  "stopped"
306
306
  ];
307
+ /** Statuses of an agent invocation that owns its child's Turn. */
308
+ const ACTIVE_AGENT_INVOCATION_STATUSES = ["running", "paused"];
307
309
  /** Statuses of an agent invocation that has not finished. */
308
310
  const NON_TERMINAL_AGENT_INVOCATION_STATUSES = [
309
311
  "pending",
@@ -406,13 +408,13 @@ async function getAgentInvocation(invocationId) {
406
408
  const rows = await getSqlExecutor().db().select().from(juniorAgentInvocations).where(eq(juniorAgentInvocations.invocationId, invocationId));
407
409
  return rows[0] ? invocationFromRow(rows[0]) : void 0;
408
410
  }
409
- /** List the running and paused agent invocations of one child Conversation. */
410
- async function listActiveAgentInvocationsForConversation(childConversationId) {
411
- return (await getSqlExecutor().db().select().from(juniorAgentInvocations).where(and(eq(juniorAgentInvocations.childConversationId, childConversationId), inArray(juniorAgentInvocations.status, ["running", "paused"]))).orderBy(asc(juniorAgentInvocations.createdAt))).map(invocationFromRow);
411
+ /** List the agent invocations of one child Conversation in the given statuses. */
412
+ async function listAgentInvocationsForConversation(childConversationId, statuses) {
413
+ return (await getSqlExecutor().db().select().from(juniorAgentInvocations).where(and(eq(juniorAgentInvocations.childConversationId, childConversationId), inArray(juniorAgentInvocations.status, [...statuses]))).orderBy(asc(juniorAgentInvocations.createdAt))).map(invocationFromRow);
412
414
  }
413
415
  /** Resolve the single invocation that may resume for one child conversation. */
414
416
  async function getActiveAgentInvocationForConversation(childConversationId) {
415
- const active = await listActiveAgentInvocationsForConversation(childConversationId);
417
+ const active = await listAgentInvocationsForConversation(childConversationId, ACTIVE_AGENT_INVOCATION_STATUSES);
416
418
  if (active.length > 1) throw new Error(`Child conversation ${childConversationId} has multiple active agent invocations`);
417
419
  return active[0];
418
420
  }
@@ -711,4 +713,4 @@ async function markAgentInvocationSteered(invocationId, nowMs = Date.now()) {
711
713
  function isTerminalAgentInvocation(invocation) {
712
714
  return TERMINAL_AGENT_INVOCATION_STATUSES.includes(invocation.status);
713
715
  }
714
- export { startActiveTurn as $, AgentMessagePausedError as A, agentTypeStartsWithParentHistory as B, markAgentInvocationParentMailboxAppended as C, parseAgentInvocationResultMessageId as D, markAgentInvocationSteered as E, CHILD_AGENT_RESULTS as F, TurnInputDeferredError as G, ConversationTurnBoundaryError as H, PARENT_AGENT_TARGET as I, isTurnInputCommitLostError as J, getConversationTurnBoundaryError as K, agentNameSchema as L, AgentMessageTargetError as M, AgentNameInUseError as N, reportReplacedAgentInvocation as O, findChildAgentConversationId as P, markTurnFailed as Q, AGENT_TYPES as R, markAgentInvocationMailboxAppended as S, markAgentInvocationRunning as T, CooperativeTurnYieldError as U, formatAgentTypes as V, TurnInputCommitLostError as W, markTurnClosed as X, isTurnInputDeferredError as Y, markTurnCompleted as Z, invocationFromRow as _, createAgentInvocationFromLatest as a, listPendingAgentInvocationMailboxAppends as b, getAgentInvocationIdForEvents as c, getAgentInvocationMessageId as d, getAgentInvocationResultMessageId as f, getLatestAgentInvocationForConversation as g, getChildAgentLockName as h, createAgentInvocationForMessage as i, AgentMessageQueueFullError as j, AgentInvocationLimitError as k, getAgentInvocationIdForMessage as l, getChildAgentLabel as m, completeAgentInvocation as n, getActiveAgentInvocationForConversation as o, getAgentInvocationTurnId as p, isCooperativeTurnYieldError as q, createAgentInvocation as r, getAgentInvocation as s, NON_TERMINAL_AGENT_INVOCATION_STATUSES as t, getAgentInvocationIdForResult as u, isTerminalAgentInvocation as v, markAgentInvocationPaused as w, listPendingAgentInvocationResults as x, listActiveAgentInvocationsForConversation as y, agentTypeInstructions as z };
716
+ 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 };
@@ -1,5 +1,5 @@
1
- import { h as logWarn } from "./logging-DYRS7E8s.js";
2
- import { c as QUEUE_SIGNATURE_MAX_AGE_MS, d as getQueueProvider, l as signQueueMessage, p as runWithTurnRequestDeadline, u as verifyQueueMessage } from "./job-queue-Bh9sFO9t.js";
1
+ import { h as logWarn } from "./logging-B04X_eCB.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-Bywqo1WJ.js";
3
3
  import { createHash } from "node:crypto";
4
4
  import { 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-DQr2QfvJ.js").then((n) => n.r);
113
+ const { processPluginTask } = await import("./task-runner-BwAkjjVE.js").then((n) => n.r);
114
114
  await processPluginTask(message);
115
115
  },
116
116
  topic: PLUGIN_TASK_QUEUE_TOPIC,
@@ -1,12 +1,12 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-nwUcYXjP.js";
2
- import { Ca as createPluginLogger, In as coreTaskRegistrations, Jt as getPiMessageRole, Na as createPluginConversationEvents, Nn as getPlugins, Qt as instructionTextForProjection, Sa as createPluginModel, Za as createPluginCache, an as stripRuntimeTurnContext, ba as createPluginState, it as getTurnRecord, nn as isToolResultMessage, rn as normalizeToolNameFromResult, tn as isToolResultError, x as hydrateConversationMessages, xa as createPluginEmbedder } from "./projection-CMRrv9Pt.js";
2
+ import { $t as instructionTextForProjection, Aa as createPluginLogger, Ba as createPluginConversationEvents, Bn as getPlugins, Da as createPluginState, Jt as getPiMessageRole, Oa as createPluginEmbedder, Un as coreTaskRegistrations, an as normalizeToolNameFromResult, in as isToolResultMessage, io as createPluginCache, it as getTurnRecord, ka as createPluginModel, rn as isToolResultError, sn as stripRuntimeTurnContext, x as hydrateConversationMessages } from "./projection-6dXaN0n-.js";
3
3
  import { h as parseSlackMessageTs } from "./actor-B4DYygOB.js";
4
- import { S as getDb, i as readActorIdentity, x as getConversationStore } from "./viewer-D25XOUHc.js";
4
+ import { S as getDb, i as readActorIdentity, x as getConversationStore } from "./viewer-CQwBszc7.js";
5
5
  import { _ as sameActorIdentity } from "./media-DstkkoNP.js";
6
- import { r as getStateAdapter } from "./adapter-4qThDhgF.js";
7
- import { t as resolveConversationRouting, u as getDispatchRecord } from "./turn-session-routing-DIeqG2pO.js";
8
- import { o as coerceThreadConversationState, r as getPersistedThreadState } from "./thread-state-ngCvtWNa.js";
9
- import { i as pluginTaskParamsSchema, r as pluginTaskId, s as sendVercelPluginTask } from "./task-queue-BdB0pab8.js";
6
+ import { r as getStateAdapter } from "./adapter-DoPR2jS-.js";
7
+ import { t as resolveConversationRouting, u as getDispatchRecord } from "./turn-session-routing-DddybdNu.js";
8
+ import { o as coerceThreadConversationState, r as getPersistedThreadState } from "./thread-state-BXjgk1pW.js";
9
+ import { i as pluginTaskParamsSchema, r as pluginTaskId, s as sendVercelPluginTask } from "./task-queue-C6ROM_XJ.js";
10
10
  import { pluginRunContextSchema } from "@sentry/junior-plugin-api";
11
11
  // src/chat/plugins/task-runner.ts
12
12
  /**
@@ -1,7 +1,7 @@
1
- import { Qa as createDurableLocationConfigurationService, S as persistConversationMessages, ea as JUNIOR_THREAD_STATE_TTL_MS } from "./projection-CMRrv9Pt.js";
2
- import { H as toOptionalNumber, U as toOptionalString, V as isRecord } from "./logging-DYRS7E8s.js";
3
- import { S as getDb } from "./viewer-D25XOUHc.js";
4
- import { r as getStateAdapter } from "./adapter-4qThDhgF.js";
1
+ import { S as persistConversationMessages, ao as createDurableLocationConfigurationService, sa as JUNIOR_THREAD_STATE_TTL_MS } from "./projection-6dXaN0n-.js";
2
+ import { H as isRecord, U as toOptionalNumber, W as toOptionalString } from "./logging-B04X_eCB.js";
3
+ import { S as getDb } from "./viewer-CQwBszc7.js";
4
+ import { r as getStateAdapter } from "./adapter-DoPR2jS-.js";
5
5
  // src/chat/state/conversation.ts
6
6
  function defaultConversationState() {
7
7
  return {
@@ -1,11 +1,11 @@
1
- import { F as markConversationMessage, Ka as listConversationAnnotations, Y as clearPendingAuth, dn as buildDeterministicTurnId, x as hydrateConversationMessages } from "./projection-CMRrv9Pt.js";
2
- import { _ as findProviderError, h as ProviderError, v as getProviderErrorAttributes, y as getProviderErrorUserMessage } from "./client-C0ZIxoDr.js";
3
- import { V as isRecord, t as buildTurnFailureResponse } from "./logging-DYRS7E8s.js";
1
+ import { $a as listConversationAnnotations, F as markConversationMessage, Y as clearPendingAuth, pn as buildDeterministicTurnId, x as hydrateConversationMessages } from "./projection-6dXaN0n-.js";
2
+ import { _ as findProviderError, h as ProviderError, v as getProviderErrorAttributes, y as getProviderErrorUserMessage } from "./client-7diKvInp.js";
3
+ import { H as isRecord, t as buildTurnFailureResponse } from "./logging-B04X_eCB.js";
4
4
  import { h as parseSlackMessageTs } from "./actor-B4DYygOB.js";
5
- import { S as getDb, y as getConversationEventStore } from "./viewer-D25XOUHc.js";
6
- import { B as readMessageCardRefs, H as resolveMessageCards, V as removedCardSchema } from "./conversation-BjTo9ZFL.js";
7
- import { D as parseAgentInvocationResultMessageId, X as markTurnClosed, Z as markTurnCompleted, p as getAgentInvocationTurnId, s as getAgentInvocation } from "./store-BIQYXvoV.js";
8
- import { a as persistThreadStateById, o as coerceThreadConversationState, r as getPersistedThreadState } from "./thread-state-ngCvtWNa.js";
5
+ import { S as getDb, y as getConversationEventStore } from "./viewer-CQwBszc7.js";
6
+ import { H as removedCardSchema, U as resolveMessageCards, V as readMessageCardRefs } from "./conversation-DppJ83Hw.js";
7
+ import { O as parseAgentInvocationResultMessageId, Q as markTurnCompleted, Z as markTurnClosed, c as getAgentInvocation, m as getAgentInvocationTurnId } from "./store-C5uVTx2G.js";
8
+ import { a as persistThreadStateById, o as coerceThreadConversationState, r as getPersistedThreadState } from "./thread-state-BXjgk1pW.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-D25XOUHc.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, Fr as formatSlackLink, Kr as postSlackMessage, Pr as escapeSlackMrkdwnText, Ur as openSlackDirectMessage, ea as JUNIOR_THREAD_STATE_TTL_MS, ia as getDashboardTaskLink, oa as ToolInputError } from "./projection-CMRrv9Pt.js";
2
- import { n as botConfig } from "./config-DS-QLVSL.js";
3
- import { _ as runBestEffort, h as logWarn } from "./logging-DYRS7E8s.js";
4
- import { G as agentTurnCostUsd, K as agentTurnTotalTokens, S as getDb } from "./viewer-D25XOUHc.js";
5
- import { s as juniorConversations } from "./agent-invocations-C1RNOCs8.js";
6
- import { d as juniorAutomations, l as juniorAutomationRuns, u as juniorAutomationVersions } from "./executor-C2moGIHS.js";
7
- import { h as credentialSubjectSchema } from "./registry-D92WLl5I.js";
8
- import { r as getStateAdapter } from "./adapter-4qThDhgF.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-D25XOUHc.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-BnIJimKZ.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.274.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-BoWLhNzj.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-DS-QLVSL.js";
3
- import { B as normalizeIdentityEmail, R as GOOGLE_IDENTITY_PROVIDER, h as logWarn } from "./logging-DYRS7E8s.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-C2moGIHS.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, La as loadForkHistory, V as PluginCredentialFailureError, Wt as isTurnExecutionLimitExceededError, Yt as getTerminalAssistantMessages, et as saveTurnCheckpoint, it as getTurnRecord, l as openConversationProjection, rt as failTurnRecord, tt as abandonTurnRecord } from "./projection-CMRrv9Pt.js";
2
- import { n as botConfig } from "./config-DS-QLVSL.js";
3
- import { M as SYSTEM_IDENTITY_ID, x as getConversationStore, y as getConversationEventStore } from "./viewer-D25XOUHc.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-CLHM48dh.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-BIQYXvoV.js";
7
- import { n as getAssistantReplyText } from "./assistant-reply-2IwdFWuQ.js";
8
- import { A as recordFinishedTurnForAutomatedLimit, j as resetAutomatedTurnLimit, w as maybePostAutomatedTurnLimitNotice } from "./session-stop-CI5qJU7a.js";
9
- import { r as appendAndEnqueueInboundMessage } from "./store-BvI3yBGS.js";
10
- import { t as ConversationTurnLifecycleService } from "./turn-lifecycle-B7O6rZEX.js";
11
- import { a as persistThreadStateById, n as getPersistedSandboxState, r as getPersistedThreadState } from "./thread-state-ngCvtWNa.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-CMRrv9Pt.js";
3
- import { b as isProviderRetryError } from "./client-C0ZIxoDr.js";
4
- import { i as getChatConfig } from "./config-DS-QLVSL.js";
5
- import { T as withLogContext, b as setSpanAttributes, h as logWarn, m as logInfo, p as logException } from "./logging-DYRS7E8s.js";
6
- import { f as getTurnRequestDeadline, m as ConversationQueueMessageRejectedError } from "./job-queue-Bh9sFO9t.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-BvI3yBGS.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;