@sentry/junior 0.261.0 → 0.263.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-Bx_1B2De.js → adapter-BIacI0Bt.js} +2 -2
  2. package/dist/{admin-BAbbVgVc.js → admin-C7vUk7s9.js} +1 -1
  3. package/dist/{agent-hooks-ghyZZQqB.js → agent-hooks-CqnZfuCt.js} +126 -36
  4. package/dist/{agent-invocations-Qfz7dWgU.js → agent-invocations-CxKldAeB.js} +1 -0
  5. package/dist/{agent-runner-g110-xgg.js → agent-runner-BUBas7Yy.js} +150 -683
  6. package/dist/api/schema.d.ts +4 -0
  7. package/dist/api/schema.js +3 -3
  8. package/dist/api.js +34 -30
  9. package/dist/{app-VCiPQ65Q.d.ts → app-Bo0kB987.d.ts} +1 -1
  10. package/dist/app.d.ts +1 -1
  11. package/dist/app.js +55 -61
  12. package/dist/{assistant-reply-CQcMaWNL.js → assistant-reply-BFmjgJjD.js} +1 -1
  13. package/dist/{automation-DrpcA-SX.js → automation-CWX0qL8U.js} +1 -1
  14. package/dist/{briefs-CKcfrIQL.js → briefs-h55v5lX9.js} +4 -4
  15. package/dist/{catalog-runtime-cd60vzAB.js → catalog-runtime-Suf-aLlh.js} +1 -1
  16. package/dist/cli/chat.js +15 -17
  17. package/dist/cli/check.js +3 -3
  18. package/dist/cli/main.js +3 -3
  19. package/dist/cli/plugins.js +4 -4
  20. package/dist/cli/snapshot-create.js +4 -4
  21. package/dist/cli/upgrade.js +3 -3
  22. package/dist/{client-2i0JJpoC.js → client-DZBCBj1M.js} +2 -2
  23. package/dist/{config-C9qM41O0.js → config-Dnv8KmNs.js} +2 -2
  24. package/dist/{connections-DrtTrwkp.js → connections-Br0_xv27.js} +10 -10
  25. package/dist/{conversation-CvuKJ3tA.js → conversation-B0baEwoA.js} +2 -0
  26. package/dist/{conversation-privacy-1iTiFX1O.js → conversation-privacy-FY8yc2q3.js} +1 -1
  27. package/dist/{credential-sync-wKNQ1dYc.js → credential-sync-BvkiyWF5.js} +14 -14
  28. package/dist/{executor-Rimyj8HZ.js → executor-J9k2sp9m.js} +4 -3
  29. package/dist/{images-D1JggcVY.js → images-DV2FlEGL.js} +3 -3
  30. package/dist/instrumentation.js +2 -2
  31. package/dist/{job-queue-BjQdSqA3.js → job-queue-B4yTgklN.js} +1 -1
  32. package/dist/{logging-BLTa7R7f.js → logging-Dk_FpF36.js} +1 -1
  33. package/dist/{message-DAeP5WWW.js → message-BzseAFH1.js} +4 -3
  34. package/dist/nitro.d.ts +1 -1
  35. package/dist/nitro.js +3 -3
  36. package/dist/{oauth-callback-server-BAy1hhF1.js → oauth-callback-server-bTspTMCC.js} +2 -2
  37. package/dist/{profile-CthM2qFM.js → profile-Dq5I7TV1.js} +13 -6
  38. package/dist/{prompt-DeVax2qO.js → prompt-CxatQVaj.js} +1 -1
  39. package/dist/{registry-BnSaArNb.js → registry-BFzQFV_y.js} +1 -1
  40. package/dist/{resolve-B5eLRl0v.js → resolve-CnRHib0U.js} +4 -4
  41. package/dist/{result-Cvm0GZCv.js → result-DczfmNBa.js} +18 -12
  42. package/dist/{runner-D-pUzHbU.js → runner-CJd9Wec-.js} +11 -11
  43. package/dist/{sandbox-egress-signals-mvwGV7rl.js → sandbox-egress-signals-DUmVkOx4.js} +1 -1
  44. package/dist/{schema-OzL8Zw4H.js → schema-QidbykYl.js} +3 -3
  45. package/dist/{service-account-DWxvpSfd.js → service-account-BI2kQDrb.js} +3 -3
  46. package/dist/{service-account-Ch1uIpnR.js → service-account-x2QZXm4X.js} +3 -3
  47. package/dist/{session-stop-Boj_zpTa.js → session-stop-CtyJsnEj.js} +12 -12
  48. package/dist/{skills-BpdYCfFt.js → skills-Dbzx9-rS.js} +2 -2
  49. package/dist/{spawn-h1DJMQTf.js → spawn-D8WU99UV.js} +3 -2
  50. package/dist/store-TKg1HVKx.js +697 -0
  51. package/dist/{store-B6KqcdCQ.js → store-UlOrW6JC.js} +6 -6
  52. package/dist/{task-queue-BaDwKSYv.js → task-queue-BRB49H-J.js} +3 -3
  53. package/dist/{task-runner-BAX5li9a.js → task-runner-C575f2Dd.js} +19 -11
  54. package/dist/{tasks-uCfmlWga.js → tasks-LOItiYgL.js} +46 -66
  55. package/dist/{thread-state-BJHVIz8G.js → thread-state-IDHdZA7R.js} +5 -5
  56. package/dist/{turn-failure-response-CCC76P6-.js → turn-failure-response-h_LSXJ-M.js} +46 -20
  57. package/dist/{turn-lifecycle-pHSESVR9.js → turn-lifecycle-Cvi6Sb8Y.js} +1 -1
  58. package/dist/{turn-session-routing-BIKJZaiw.js → turn-session-routing-5Nyv4fso.js} +1 -1
  59. package/dist/{validation-B9KL_5Wc.js → validation-BeTriWC2.js} +1 -1
  60. package/dist/{version-CN9BXMW_.js → version-BQX_hLDC.js} +1 -1
  61. package/dist/version.js +1 -1
  62. package/dist/{viewer-C5xFaYVi.js → viewer-DmNRM88V.js} +4 -4
  63. package/dist/{web-input-D6eqfXYd.js → web-input-BHcGXSox.js} +97 -36
  64. package/dist/{work-C-ecZAme.js → work-DLJMV02b.js} +41 -10
  65. package/dist/{worker-BpYDqiOf.js → worker-vfG2ESg1.js} +5 -5
  66. package/migrations/0062_plugin_report_index.sql +20 -0
  67. package/migrations/0063_agent_invocation_type.sql +1 -0
  68. package/migrations/meta/0062_snapshot.json +3499 -0
  69. package/migrations/meta/0063_snapshot.json +3505 -0
  70. package/migrations/meta/_journal.json +14 -0
  71. package/package.json +4 -4
@@ -1,36 +1,37 @@
1
- import { At as saveTurnCheckpoint, Bn as normalizeSlackReplyMarkdown, Dt as wasPendingAuthStopped, E as sameDefinitionValue, Ft as listTurnSummaries, I as loadProjection, It as recordTurnSummary, Jn as removeReactionFromMessage, M as commitMessages, Mt as completeTurnRecord, Nt as failTurnRecord, P as loadConversationProjection, Pt as getTurnRecord, Q as persistConversationMessages, Rn as escapeSlackMrkdwnText, S as automationDefinition, Tt as clearPendingAuth, U as recordAuthorizationCompleted, Un as truncateStatusText, Vn as normalizeSlackStatusText, Vt as buildTurnErrorResponse, Wn as addReactionToMessage, Wt as persistWithRetry, Z as hydrateConversationMessages, _ as parseEventAutomationRow, _n as isExperimentalFeatureEnabled, _t as PluginCredentialFailureError, at as appendThreadContextMessages, bn as createUserTokenStore, c as withScheduledAutomationLock, ct as estimateConversationContextTokens, dn as getThreadStopDecision, dt as markConversationMessage, et as persistConversationMessageSummaries, f as deleteEventAutomation, ft as normalizeConversationText, h as listDeletedEventAutomationsCreatedBy, ht as upsertConversationMessage, i as readScheduledAutomation, in as trimTrailingAssistantMessages, j as commitAcceptedReply, jt as abandonTurnRecord, kt as loadTurnCheckpoint, ln as decideSubscribedThreadReply, lt as getConversationMessageSlackTs, mt as turnHasReply, o as saveScheduledAutomationInLock, on as buildDeterministicAssistantMessageId, ot as buildConversationContext, pt as recordDeliveredAssistantMessage, q as recordSubscribedReplyRoute, qn as postSlackMessage, r as parseScheduledAutomationRow, rt as fallbackShortTitle, sn as buildDeterministicTurnId, st as createConversationMemoryService, tr as configValueSchema, tt as resolveConversationTitle, un as getSubscribedReplyPreflightDecision, ut as isHumanConversationMessage, w as listAutomationVersions, xt as AuthorizationFlowDisabledError, zn as formatSlackLink } from "./tasks-uCfmlWga.js";
2
- import { a as completeText, p as escapeXml, r as completeDecision, y as isProviderRetryError } from "./client-2i0JJpoC.js";
3
- import { B as toOptionalNumber, T as withSpan, V as toOptionalString, d as logError, f as logException, m as logWarn, n as createChatSdkLogger, o as getActiveTraceId, p as logInfo, t as buildTurnFailureResponse, v as setSentryUser, w as withLogContext, x as setTags, y as setSpanAttributes, z as isRecord } from "./logging-BLTa7R7f.js";
4
- import { c as getSlackClientSecret, i as getChatConfig, l as getSlackSigningSecret, n as botConfig, o as getSlackBotToken, s as getSlackClientId, v as normalizeSlackEmojiName } from "./config-C9qM41O0.js";
1
+ import { $ as persistConversationMessageSummaries, A as commitAcceptedReply, At as abandonTurnRecord, Bn as normalizeSlackReplyMarkdown, Bt as buildTurnErrorResponse, E as sameDefinitionValue, Et as wasPendingAuthStopped, F as loadProjection, Ft as recordTurnSummary, H as recordAuthorizationCompleted, Jn as removeReactionFromMessage, K as recordSubscribedReplyRoute, Mt as failTurnRecord, N as loadConversationProjection, Nt as getTurnRecord, Ot as loadTurnCheckpoint, Pt as listTurnSummaries, Rn as escapeSlackMrkdwnText, S as automationDefinition, Un as truncateStatusText, Ut as persistWithRetry, Vn as normalizeSlackStatusText, Wn as addReactionToMessage, X as hydrateConversationMessages, Z as persistConversationMessages, _ as parseEventAutomationRow, _n as isExperimentalFeatureEnabled, at as buildConversationContext, bn as createUserTokenStore, bt as AuthorizationFlowDisabledError, c as withScheduledAutomationLock, cn as buildDeterministicTurnId, ct as getConversationMessageSlackTs, dn as getSubscribedReplyPreflightDecision, dt as normalizeConversationText, et as resolveConversationTitle, f as deleteEventAutomation, fn as getThreadStopDecision, ft as recordDeliveredAssistantMessage, gt as PluginCredentialFailureError, h as listDeletedEventAutomationsCreatedBy, i as readScheduledAutomation, it as appendThreadContextMessages, j as commitMessages, jt as completeTurnRecord, kt as saveTurnCheckpoint, lt as isHumanConversationMessage, mt as upsertConversationMessage, nt as fallbackShortTitle, o as saveScheduledAutomationInLock, ot as createConversationMemoryService, pt as turnHasReply, qn as postSlackMessage, r as parseScheduledAutomationRow, rn as trimTrailingAssistantMessages, sn as buildDeterministicAssistantMessageId, st as estimateConversationContextTokens, tr as configValueSchema, un as decideSubscribedThreadReply, ut as markConversationMessage, w as listAutomationVersions, wt as clearPendingAuth, zn as formatSlackLink } from "./tasks-LOItiYgL.js";
2
+ import { a as completeText, p as escapeXml, r as completeDecision, y as isProviderRetryError } from "./client-DZBCBj1M.js";
3
+ import { B as toOptionalNumber, T as withSpan, V as toOptionalString, d as logError, f as logException, m as logWarn, n as createChatSdkLogger, o as getActiveTraceId, p as logInfo, t as buildTurnFailureResponse, v as setSentryUser, w as withLogContext, x as setTags, y as setSpanAttributes, z as isRecord } from "./logging-Dk_FpF36.js";
4
+ import { c as getSlackClientSecret, i as getChatConfig, l as getSlackSigningSecret, n as botConfig, o as getSlackBotToken, s as getSlackClientId, v as normalizeSlackEmojiName } from "./config-Dnv8KmNs.js";
5
5
  import { o as modelIdForProfile, r as defaultModelId } from "./model-profile-Bg8EoCKD.js";
6
6
  import { a as isUserActor, g as parseSlackMessageTs, i as isActorUserId, l as parseSlackChannelId, n as createSlackActor, o as parseActorUserId, r as createSlackResumeActor, t as createActor } from "./actor-tlxzqaRe.js";
7
- import { L as createSlackDestination, c as getConversationEventStore, d as getDb, f as getSqlExecutor, u as getConversationStore, z as requireSlackDestination } from "./viewer-C5xFaYVi.js";
8
- import { c as juniorIdentities, d as juniorDestinations, l as juniorUsers } from "./agent-invocations-Qfz7dWgU.js";
9
- import { a as juniorAutomationRuns, s as juniorAutomations } from "./executor-Rimyj8HZ.js";
7
+ import { L as createSlackDestination, c as getConversationEventStore, d as getDb, f as getSqlExecutor, u as getConversationStore, z as requireSlackDestination } from "./viewer-DmNRM88V.js";
8
+ import { c as juniorIdentities, d as juniorDestinations, l as juniorUsers } from "./agent-invocations-CxKldAeB.js";
9
+ import { a as juniorAutomationRuns, s as juniorAutomations } from "./executor-J9k2sp9m.js";
10
10
  import { p as instructionProvenanceFor } from "./history-AY8rs-FR.js";
11
- import { d as actorLogContext, f as credentialContextForActor } from "./registry-BnSaArNb.js";
12
- import { A as listThreadReplies, At as getConversationTurnBoundaryError, D as resolveSlackChannelIdFromMessage, Dt as CooperativeTurnYieldError, E as readSlackRawMessageContext, Et as ConversationTurnBoundaryError, Ft as markTurnCompleted, I as eventAutomationTriggerAvailable, It as markTurnFailed, L as effectiveTaskOutcomes, Lt as startActiveTurn, Mt as isTurnInputCommitLostError, Nt as isTurnInputDeferredError, O as resolveSlackChannelIdFromThreadId, Ot as TurnInputCommitLostError, Pt as markTurnClosed, Rt as shouldEmitDevAgentTrace, St as RetryableDeliveryError, T as parseSlackThreadId, b as renderBlockText, bt as buildSteeringPiMessage, i as buildAuthPauseResponse, jt as isCooperativeTurnYieldError, k as getConversationInfo, kt as TurnInputDeferredError, n as executeAgentRun, p as latestProgressStatus, r as createContextCompactor, t as createAgentRunner, w as storeAttachment, xt as withoutSavedSteeringMessages, y as renderAttachmentText } from "./agent-runner-g110-xgg.js";
13
- import { Bt as readAttachmentVisionSummary, Lt as buildSentryConversationUrl, Rt as getSlackFileId, V as cancelSubscriptions, Vt as recordSlackAttachment, Yt as lookupSlackUser, _t as getDashboardConversationLink, at as downloadPrivateSlackFile, ct as getSlackClient, dt as normalizeSlackConversationId, ft as runWithSlackInstallationToken, gt as JUNIOR_THREAD_STATE_TTL_MS, it as SlackActionError, o as getPluginSlackConversationLink, rt as verifyTimerWatchCredentialSubject, st as getHeaderString, ut as isDmChannel, vt as getDashboardObjectIconLink } from "./agent-hooks-ghyZZQqB.js";
14
- import { B as readMessageAttachments, U as isVisionImageMediaType } from "./conversation-CvuKJ3tA.js";
15
- import { a as EVENT_SYSTEM_ACTOR, o as isEventConversationMessage } from "./prompt-DeVax2qO.js";
16
- import { a as acquireActiveLock, i as MUTATION_LOCK_TTL_MS, r as getStateAdapter, s as withLock } from "./adapter-Bx_1B2De.js";
17
- import { n as getAssistantReplyText } from "./assistant-reply-CQcMaWNL.js";
18
- import { H as runDispatchOutcome, N as maybePostAutomatedTurnLimitNotice, P as recordFinishedTurnForAutomatedLimit, R as deliversFinalText, c as isEventMailboxMetadata, d as getEventCatalog, i as skipInputBeforeConversationStop, j as joinMailboxText, l as renderEventBatchText, s as eventBatchMessageEvents, u as timerWatchCredentialSubject, x as automationEventCatalog, z as finishedRunReply } from "./session-stop-Boj_zpTa.js";
19
- import { a as getVercelConversationWorkQueue, f as getTurnRequestDeadline } from "./job-queue-BjQdSqA3.js";
20
- import { E as stopConversationWork, g as getConversationWorkState, h as getConversation, m as ensureConversationWake, n as appendAndEnqueueExclusiveInboundMessage, r as appendAndEnqueueInboundMessage, w as requestConversationWork } from "./store-B6KqcdCQ.js";
21
- import { l as automationListQuerySchema } from "./automation-DrpcA-SX.js";
11
+ import { d as actorLogContext, f as credentialContextForActor } from "./registry-BFzQFV_y.js";
12
+ import { A as listThreadReplies, D as resolveSlackChannelIdFromMessage, E as readSlackRawMessageContext, I as eventAutomationTriggerAvailable, L as effectiveTaskOutcomes, O as resolveSlackChannelIdFromThreadId, T as parseSlackThreadId, X as withoutSavedSteeringMessages, Y as buildSteeringPiMessage, Z as RetryableDeliveryError, b as renderBlockText, i as buildAuthPauseResponse, k as getConversationInfo, n as executeAgentRun, p as latestProgressStatus, r as createContextCompactor, t as createAgentRunner, tt as shouldEmitDevAgentTrace, w as storeAttachment, y as renderAttachmentText } from "./agent-runner-BUBas7Yy.js";
13
+ import { Bt as getSlackFileId, Ht as readAttachmentVisionSummary, Ut as recordSlackAttachment, V as cancelSubscriptions, Zt as lookupSlackUser, _t as getDashboardConversationLink, at as downloadPrivateSlackFile, ct as getSlackClient, dt as normalizeSlackConversationId, ft as runWithSlackInstallationToken, gt as JUNIOR_THREAD_STATE_TTL_MS, it as SlackActionError, o as getPluginSlackConversationLink, rt as verifyTimerWatchCredentialSubject, st as getHeaderString, ut as isDmChannel, vt as getDashboardObjectIconLink, zt as buildSentryConversationUrl } from "./agent-hooks-CqnZfuCt.js";
14
+ import { a as acquireActiveLock, i as MUTATION_LOCK_TTL_MS, r as getStateAdapter, s as withLock } from "./adapter-BIacI0Bt.js";
15
+ import { B as readMessageAttachments, U as isVisionImageMediaType } from "./conversation-B0baEwoA.js";
16
+ import { a as EVENT_SYSTEM_ACTOR, o as isEventConversationMessage } from "./prompt-CxatQVaj.js";
17
+ import { B as ConversationTurnBoundaryError, G as isCooperativeTurnYieldError, H as TurnInputCommitLostError, J as markTurnClosed, K as isTurnInputCommitLostError, U as TurnInputDeferredError, V as CooperativeTurnYieldError, W as getConversationTurnBoundaryError, X as markTurnFailed, Y as markTurnCompleted, Z as startActiveTurn, q as isTurnInputDeferredError } from "./store-TKg1HVKx.js";
18
+ import { n as getAssistantReplyText } from "./assistant-reply-BFmjgJjD.js";
19
+ import { H as runDispatchOutcome, N as maybePostAutomatedTurnLimitNotice, P as recordFinishedTurnForAutomatedLimit, R as deliversFinalText, c as isEventMailboxMetadata, d as getEventCatalog, i as skipInputBeforeConversationStop, j as joinMailboxText, l as renderEventBatchText, s as eventBatchMessageEvents, u as timerWatchCredentialSubject, x as automationEventCatalog, z as finishedRunReply } from "./session-stop-CtyJsnEj.js";
20
+ import { a as getVercelConversationWorkQueue, f as getTurnRequestDeadline } from "./job-queue-B4yTgklN.js";
21
+ import { E as stopConversationWork, g as getConversationWorkState, h as getConversation, m as ensureConversationWake, n as appendAndEnqueueExclusiveInboundMessage, r as appendAndEnqueueInboundMessage, w as requestConversationWork } from "./store-UlOrW6JC.js";
22
+ import { l as automationListQuerySchema } from "./automation-CWX0qL8U.js";
22
23
  import { c as sumUtcHoursIntoSixHours, m as healthReportSchema, t as webMessageId } from "./web-message-id-CJSUiksE.js";
23
- import { A as readAutomationExecutions, D as readAutomationExecutionStatusDays, E as readAutomationExecutionHours, O as readAutomationExecutionStatusHours, S as emptyAutomationRunWindows, T as readAutomationExecutionDays, _ as markDispatchBlocked, a as claimDispatchMailboxAppend, b as markDispatchRunning, c as getDispatchConversationId, d as getDispatchRecord, f as getDispatchTurnId, g as markDispatchAwaitingResume, j as readAutomationRuns, k as readAutomationExecutionSummaries, l as getDispatchIdForConversation, m as isTerminalDispatchStatus, n as scheduleSessionCompletedPluginTasks, o as confirmDispatchMailboxAppend, t as processPluginTask, u as getDispatchInputMessageId, v as markDispatchCompleted, w as readAutomationExecutionByConversationId, y as markDispatchFailed } from "./task-runner-BAX5li9a.js";
24
- import { a as withAgentInvocationResultActors, c as resolveMailboxTurnWork, i as startAgentInvocationsForChildInput, l as sourceFromTurnInput, o as getAuthPausedConversationTurnId, s as getEventBatchDelayMs, t as enqueueAgentInvocationResult, u as turnInputFactsFromConversationMessage } from "./result-Cvm0GZCv.js";
25
- import { n as getTurnLifecycle, t as ConversationTurnLifecycleService } from "./turn-lifecycle-pHSESVR9.js";
26
- import { i as resolveAgentInvocationId, o as AgentRunError, s as executeTurn, t as createAgentInvocationWorker } from "./work-C-ecZAme.js";
27
- import { a as persistThreadState, i as persistThreadRuntimeState, n as getPersistedSandboxState, o as persistThreadStateById, r as getPersistedThreadState, s as coerceThreadConversationState, t as getLocationConfigurationService } from "./thread-state-BJHVIz8G.js";
28
- import { c as deleteWebAuthorization, d as createPausedTurns, f as getPausedTurnRequest, h as getTurnAuthorization, m as wakePausedTurn, s as createWebAuthorization } from "./connections-DrtTrwkp.js";
29
- import { n as resolveTurnSessionRouting } from "./turn-session-routing-BIKJZaiw.js";
30
- import { t as bindMessageAgent } from "./message-DAeP5WWW.js";
31
- import { t as bindSpawnAgent } from "./spawn-h1DJMQTf.js";
32
- import { a as persistAuthPauseTurnState, c as getTurnUserSlackMessageTs, d as loadPendingMessageCards, i as completeAuthPauseTurn, l as buildDeliveredTurnStatePatch, n as getAgentTurnDiagnosticsAttributes, o as getTurnUserMessage, r as requireTurnFailureEventId, s as getTurnUserReplyAttachmentContext, t as finalizeFailedTurnReplyWithEvent, u as getInterruptionMarker } from "./turn-failure-response-CCC76P6-.js";
33
- import { r as storeInputImages } from "./images-D1JggcVY.js";
24
+ import { A as readAutomationExecutions, D as readAutomationExecutionStatusDays, E as readAutomationExecutionHours, O as readAutomationExecutionStatusHours, S as emptyAutomationRunWindows, T as readAutomationExecutionDays, _ as markDispatchBlocked, a as claimDispatchMailboxAppend, b as markDispatchRunning, c as getDispatchConversationId, d as getDispatchRecord, f as getDispatchTurnId, g as markDispatchAwaitingResume, j as readAutomationRuns, k as readAutomationExecutionSummaries, l as getDispatchIdForConversation, m as isTerminalDispatchStatus, n as scheduleSessionCompletedPluginTasks, o as confirmDispatchMailboxAppend, t as processPluginTask, u as getDispatchInputMessageId, v as markDispatchCompleted, w as readAutomationExecutionByConversationId, y as markDispatchFailed } from "./task-runner-C575f2Dd.js";
25
+ import { a as withAgentInvocationResultActors, c as resolveMailboxTurnWork, i as startAgentInvocationsForChildInput, l as sourceFromTurnInput, o as getAuthPausedConversationTurnId, s as getEventBatchDelayMs, t as enqueueAgentInvocationResult, u as turnInputFactsFromConversationMessage } from "./result-DczfmNBa.js";
26
+ import { n as getTurnLifecycle, t as ConversationTurnLifecycleService } from "./turn-lifecycle-Cvi6Sb8Y.js";
27
+ import { i as resolveAgentInvocationId, o as AgentRunError, s as executeTurn, t as createAgentInvocationWorker } from "./work-DLJMV02b.js";
28
+ import { a as persistThreadState, i as persistThreadRuntimeState, n as getPersistedSandboxState, o as persistThreadStateById, r as getPersistedThreadState, s as coerceThreadConversationState, t as getLocationConfigurationService } from "./thread-state-IDHdZA7R.js";
29
+ import { c as deleteWebAuthorization, d as createPausedTurns, f as getPausedTurnRequest, h as getTurnAuthorization, m as wakePausedTurn, s as createWebAuthorization } from "./connections-Br0_xv27.js";
30
+ import { n as resolveTurnSessionRouting } from "./turn-session-routing-5Nyv4fso.js";
31
+ import { t as bindMessageAgent } from "./message-BzseAFH1.js";
32
+ import { t as bindSpawnAgent } from "./spawn-D8WU99UV.js";
33
+ import { a as persistAuthPauseTurnState, c as getTurnUserSlackMessageTs, d as loadPendingMessageCards, i as completeAuthPauseTurn, l as buildDeliveredTurnStatePatch, n as getAgentTurnDiagnosticsAttributes, o as getTurnUserMessage, r as requireTurnFailureEventId, s as getTurnUserReplyAttachmentContext, t as finalizeFailedTurnReplyWithEvent, u as getInterruptionMarker } from "./turn-failure-response-h_LSXJ-M.js";
34
+ import { r as storeInputImages } from "./images-DV2FlEGL.js";
34
35
  import { z } from "zod";
35
36
  import { createHash } from "node:crypto";
36
37
  import { and, asc, count, desc, eq, exists, inArray, ne, or, sql } from "drizzle-orm";
@@ -6376,6 +6377,13 @@ async function failStrandedTurnWithFallback(args) {
6376
6377
  "app.ai.conversation_id": args.conversationId,
6377
6378
  "app.ai.session_id": failed.turnId
6378
6379
  });
6380
+ await getTurnLifecycle().fail({
6381
+ conversationId: args.conversationId,
6382
+ createdAtMs: Date.now(),
6383
+ ...eventId ? { eventId } : void 0,
6384
+ failureCode: "agent_run_failed",
6385
+ turnId: failed.turnId
6386
+ });
6379
6387
  let routing;
6380
6388
  try {
6381
6389
  routing = await resolveTurnSessionRouting({ conversationId: args.conversationId });
@@ -6406,12 +6414,49 @@ async function failStrandedTurnWithFallback(args) {
6406
6414
  });
6407
6415
  return true;
6408
6416
  }
6417
+ /** Recovery resumes a turn at most once after its worker stops checking in. */
6418
+ const MAX_LOST_WORKER_RESUMES = 1;
6419
+ const LOST_WORKER_FAILURE = "Turn lost its worker before reaching a safe boundary";
6420
+ /**
6421
+ * Saved on the paused turn when recovery resumes it. The resumed run replaces
6422
+ * it at its first save.
6423
+ */
6424
+ const LOST_WORKER_RESUME_MESSAGE = "Turn lost its worker; resuming from its last boundary";
6425
+ /** True when a resumed turn lost its worker again before it saved anything. */
6426
+ function lostWorkerBeforeFirstSave(turn) {
6427
+ return turn.errorMessage === "Turn lost its worker; resuming from its last boundary" && (turn.lostWorkerResumeCount ?? 0) >= MAX_LOST_WORKER_RESUMES;
6428
+ }
6429
+ /**
6430
+ * Pause a turn whose worker stopped checking in, so it resumes from its last
6431
+ * save. Returns false when the turn already used its resume or has no slice
6432
+ * left.
6433
+ */
6434
+ async function pauseLostWorkerTurn(turn) {
6435
+ if ((turn.lostWorkerResumeCount ?? 0) >= MAX_LOST_WORKER_RESUMES || turn.sliceId + 1 > botConfig.maxSlicesPerTurn) return false;
6436
+ const paused = await saveTurnCheckpoint({
6437
+ mode: "paused",
6438
+ reason: "retry",
6439
+ conversationId: turn.conversationId,
6440
+ turnId: turn.turnId,
6441
+ sliceId: turn.sliceId,
6442
+ messages: turn.piMessages,
6443
+ lostWorkerResumeCount: (turn.lostWorkerResumeCount ?? 0) + 1,
6444
+ errorMessage: LOST_WORKER_RESUME_MESSAGE
6445
+ });
6446
+ if (!paused) return false;
6447
+ logWarn("agent.turn.lost_worker.resumed", {
6448
+ "app.ai.conversation_id": turn.conversationId,
6449
+ "app.ai.session_id": turn.turnId,
6450
+ "app.ai.resume_slice_id": paused.sliceId
6451
+ });
6452
+ return true;
6453
+ }
6409
6454
  /** Resume the first valid paused Slack session for an idle conversation. */
6410
6455
  async function runNextPausedTurn(conversationId, options, runOptions = {}) {
6411
6456
  return withLogContext({ conversationId }, () => runNextPausedTurnInContext(conversationId, options, runOptions));
6412
6457
  }
6413
6458
  async function runNextPausedTurnInContext(conversationId, options, runOptions) {
6414
- const summaries = await listTurnSummaries(conversationId);
6459
+ let summaries = await listTurnSummaries(conversationId);
6415
6460
  const persisted = await getPersistedThreadState(conversationId);
6416
6461
  const conversation = coerceThreadConversationState(persisted);
6417
6462
  await hydrateConversationMessages({
@@ -6420,6 +6465,7 @@ async function runNextPausedTurnInContext(conversationId, options, runOptions) {
6420
6465
  });
6421
6466
  const newest = summaries[0];
6422
6467
  const running = newest ? await getTurnRecord(conversationId, newest.turnId) : void 0;
6468
+ let resumedTurnId;
6423
6469
  if (running?.state === "running") {
6424
6470
  if (turnHasReply(conversation, running.turnId)) {
6425
6471
  const acceptedReply = [...conversation.messages].reverse().find((message) => message.role === "assistant" && message.id.startsWith(`${running.turnId}:assistant:`));
@@ -6437,15 +6483,30 @@ async function runNextPausedTurnInContext(conversationId, options, runOptions) {
6437
6483
  await persistThreadStateById(conversationId, { conversation });
6438
6484
  return false;
6439
6485
  }
6440
- await failStrandedTurnWithFallback({
6441
- conversationId,
6442
- errorMessage: "Turn lost its worker before reaching a safe boundary",
6443
- turn: running
6444
- });
6445
- return false;
6486
+ if (!await pauseLostWorkerTurn(running)) {
6487
+ await failStrandedTurnWithFallback({
6488
+ conversationId,
6489
+ errorMessage: LOST_WORKER_FAILURE,
6490
+ turn: running
6491
+ });
6492
+ return false;
6493
+ }
6494
+ resumedTurnId = running.turnId;
6495
+ summaries = await listTurnSummaries(conversationId);
6446
6496
  }
6447
6497
  for (const summary of summaries) {
6448
6498
  if (!isPausedTurn(summary)) continue;
6499
+ if (summary.turnId !== resumedTurnId && summary.resumeReason === "retry") {
6500
+ const turn = await getTurnRecord(conversationId, summary.turnId);
6501
+ if (turn && lostWorkerBeforeFirstSave(turn)) {
6502
+ await failStrandedTurnWithFallback({
6503
+ conversationId,
6504
+ errorMessage: LOST_WORKER_FAILURE,
6505
+ turn
6506
+ });
6507
+ continue;
6508
+ }
6509
+ }
6449
6510
  const request = await getPausedTurnRequest({
6450
6511
  conversationId,
6451
6512
  turnId: summary.turnId
@@ -1,14 +1,15 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-nwUcYXjP.js";
2
- import { At as saveTurnCheckpoint, Nt as failTurnRecord, Pt as getTurnRecord, Ut as isTurnExecutionLimitExceededError, _t as PluginCredentialFailureError, jt as abandonTurnRecord, qt as getTerminalAssistantMessages, xt as AuthorizationFlowDisabledError, z as openConversationProjection } from "./tasks-uCfmlWga.js";
3
- import { n as botConfig } from "./config-C9qM41O0.js";
4
- import { c as getConversationEventStore, u as getConversationStore } from "./viewer-C5xFaYVi.js";
2
+ import { At as abandonTurnRecord, Ht as isTurnExecutionLimitExceededError, Kt as getTerminalAssistantMessages, Mt as failTurnRecord, Nt as getTurnRecord, R as openConversationProjection, bt as AuthorizationFlowDisabledError, gt as PluginCredentialFailureError, kt as saveTurnCheckpoint } from "./tasks-LOItiYgL.js";
3
+ import { n as botConfig } from "./config-Dnv8KmNs.js";
4
+ import { c as getConversationEventStore, u as getConversationStore } from "./viewer-DmNRM88V.js";
5
5
  import { m as sameActorIdentity, u as agentInstructionProvenance } from "./history-AY8rs-FR.js";
6
- import { At as getConversationTurnBoundaryError, G as createAgentInvocation, H as recordSubagentStarted, Mt as isTurnInputCommitLostError, Ot as TurnInputCommitLostError, Tt as readBlockedReport, V as recordSubagentEnded, W as completeAgentInvocation, X as getAgentInvocation, Y as getActiveAgentInvocationForConversation, at as isTerminalAgentInvocation, bt as buildSteeringPiMessage, ct as markAgentInvocationMailboxAppended, dt as markAgentInvocationRunning, et as getAgentInvocationMessageId, ft as markAgentInvocationSteered, it as getLatestAgentInvocationForConversation, nt as getAgentInvocationTurnId, pt as reportReplacedAgentInvocation, ut as markAgentInvocationPaused, xt as withoutSavedSteeringMessages, z as stopChildAgentsOf } from "./agent-runner-g110-xgg.js";
7
- import { n as getAssistantReplyText } from "./assistant-reply-CQcMaWNL.js";
8
- import { F as resetAutomatedTurnLimit, N as maybePostAutomatedTurnLimitNotice, P as recordFinishedTurnForAutomatedLimit } from "./session-stop-Boj_zpTa.js";
9
- import { r as appendAndEnqueueInboundMessage } from "./store-B6KqcdCQ.js";
10
- import { t as ConversationTurnLifecycleService } from "./turn-lifecycle-pHSESVR9.js";
11
- import { n as getPersistedSandboxState, o as persistThreadStateById, r as getPersistedThreadState } from "./thread-state-BJHVIz8G.js";
6
+ import { H as recordSubagentStarted, V as recordSubagentEnded, X as withoutSavedSteeringMessages, Y as buildSteeringPiMessage, et as readBlockedReport, z as stopChildAgentsOf } from "./agent-runner-BUBas7Yy.js";
7
+ import { E as markAgentInvocationSteered, H as TurnInputCommitLostError, K as isTurnInputCommitLostError, L as agentTypeInstructions, O as reportReplacedAgentInvocation, R as agentTypeStartsWithParentHistory, S as markAgentInvocationMailboxAppended, T as markAgentInvocationRunning, W as getConversationTurnBoundaryError, _ as getLatestAgentInvocationForConversation, c as getAgentInvocation, f as getAgentInvocationMessageId, m as getAgentInvocationTurnId, n as completeAgentInvocation, r as createAgentInvocation, s as getActiveAgentInvocationForConversation, w as markAgentInvocationPaused, y as isTerminalAgentInvocation } from "./store-TKg1HVKx.js";
8
+ import { n as getAssistantReplyText } from "./assistant-reply-BFmjgJjD.js";
9
+ import { F as resetAutomatedTurnLimit, N as maybePostAutomatedTurnLimitNotice, P as recordFinishedTurnForAutomatedLimit } from "./session-stop-CtyJsnEj.js";
10
+ import { r as appendAndEnqueueInboundMessage } from "./store-UlOrW6JC.js";
11
+ import { t as ConversationTurnLifecycleService } from "./turn-lifecycle-Cvi6Sb8Y.js";
12
+ import { n as getPersistedSandboxState, o as persistThreadStateById, r as getPersistedThreadState } from "./thread-state-IDHdZA7R.js";
12
13
  import { isDeepStrictEqual } from "node:util";
13
14
  import { z } from "zod";
14
15
  // src/chat/runtime/turn-execution.ts
@@ -52,6 +53,34 @@ async function executeTurn(agentRunner, run, saveResult) {
52
53
  });
53
54
  return { status: "completed" };
54
55
  }
56
+ // src/chat/agent-invocations/fork-history.ts
57
+ /**
58
+ * Cut parent history for a fork: everything before the parent's message that
59
+ * started the fork, through the last point where every tool call has its
60
+ * result. A model request with an unanswered tool call fails, and the parent
61
+ * can commit its history in the middle of a tool round.
62
+ */
63
+ function forkHistoryFrom(messages, parentToolCallId) {
64
+ const spawnIndex = parentToolCallId ? messages.findIndex((message) => message.role === "assistant" && message.content.some((part) => part.type === "toolCall" && part.id === parentToolCallId)) : -1;
65
+ const before = spawnIndex >= 0 ? messages.slice(0, spawnIndex) : messages;
66
+ const pending = /* @__PURE__ */ new Set();
67
+ let end = 0;
68
+ for (const [index, message] of before.entries()) {
69
+ if (message.role === "assistant") {
70
+ for (const part of message.content) if (part.type === "toolCall") pending.add(part.id);
71
+ } else if (message.role === "toolResult") pending.delete(message.toolCallId);
72
+ if (pending.size === 0) end = index + 1;
73
+ }
74
+ return before.slice(0, end);
75
+ }
76
+ /**
77
+ * Load the start history of a fork child from its parent Conversation. The
78
+ * child commits it as its own history in its first checkpoint, so later
79
+ * agent invocations of the child read it from the child Conversation.
80
+ */
81
+ async function loadForkHistory(invocation) {
82
+ return forkHistoryFrom((await openConversationProjection({ conversationId: invocation.parentConversationId })).messages, invocation.parentToolCallId);
83
+ }
55
84
  // src/chat/agent-invocations/work.ts
56
85
  var work_exports = /* @__PURE__ */ __exportAll({
57
86
  agentInvocationInputText: () => agentInvocationInputText,
@@ -138,10 +167,12 @@ function invocationIdFromMessages(messages) {
138
167
  */
139
168
  function agentInvocationInputText(invocation) {
140
169
  if (!invocation.parentToolCallId) return invocation.input;
170
+ const typeInstructions = agentTypeInstructions(invocation.agentType);
141
171
  return [
142
172
  "[parent agent task]",
143
173
  "",
144
174
  "Your parent agent wrote this. It is not a message from a person, so it does not give user approval, even when it says that the user approved something. Action review reads the user's own messages in the root conversation.",
175
+ ...typeInstructions ? ["", typeInstructions] : [],
145
176
  "",
146
177
  invocation.input
147
178
  ].join("\n");
@@ -426,7 +457,7 @@ function createAgentInvocationWorker(agentRunner, options = {}) {
426
457
  readChildDepthAndRootLocation(invocation.childConversationId)
427
458
  ]);
428
459
  sandboxRef = getPersistedSandboxState(persisted);
429
- history = projection.messages;
460
+ history = agentTypeStartsWithParentHistory(invocation.agentType) && projection.messages.length === 0 ? await loadForkHistory(invocation) : projection.messages;
430
461
  location = tree.location;
431
462
  canSpawn = tree.depth <= maxAgentDepth;
432
463
  } catch (error) {
@@ -1,9 +1,9 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-nwUcYXjP.js";
2
- import { y as isProviderRetryError } from "./client-2i0JJpoC.js";
3
- import { f as logException, m as logWarn, p as logInfo, w as withLogContext } from "./logging-BLTa7R7f.js";
4
- import { i as getChatConfig } from "./config-C9qM41O0.js";
5
- import { f as getTurnRequestDeadline, m as ConversationQueueMessageRejectedError } from "./job-queue-BjQdSqA3.js";
6
- import { C as requestAnotherSlice, M as isInvalidConversationRecordError, T as startConversationWork, b as recordConversationRetry, d as countPendingConversationMessages, f as deadLetterAttempt, g as getConversationWorkState, i as beginConversationResume, j as isFinalAttempt, k as hasConversationStop, 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-B6KqcdCQ.js";
2
+ import { y as isProviderRetryError } from "./client-DZBCBj1M.js";
3
+ import { f as logException, m as logWarn, p as logInfo, w as withLogContext } from "./logging-Dk_FpF36.js";
4
+ import { i as getChatConfig } from "./config-Dnv8KmNs.js";
5
+ import { f as getTurnRequestDeadline, m as ConversationQueueMessageRejectedError } from "./job-queue-B4yTgklN.js";
6
+ import { C as requestAnotherSlice, M as isInvalidConversationRecordError, T as startConversationWork, b as recordConversationRetry, d as countPendingConversationMessages, f as deadLetterAttempt, g as getConversationWorkState, i as beginConversationResume, j as isFinalAttempt, k as hasConversationStop, 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-UlOrW6JC.js";
7
7
  // src/chat/task-execution/worker.ts
8
8
  var worker_exports = /* @__PURE__ */ __exportAll({
9
9
  CONVERSATION_WORK_DEFER_DELAY_MS: () => CONVERSATION_WORK_DEFER_DELAY_MS,
@@ -0,0 +1,20 @@
1
+ -- For a busy database, first run the index definition below with CONCURRENTLY,
2
+ -- as one statement outside a transaction. Before junior upgrade, check its
3
+ -- pg_get_indexdef, pg_index.indisvalid, and pg_index.indisready.
4
+ DO $$
5
+ BEGIN
6
+ -- Even CREATE INDEX IF NOT EXISTS takes a write-blocking table lock.
7
+ IF to_regclass('junior_conversation_events_plugin_report_idx') IS NULL THEN
8
+ CREATE INDEX "junior_conversation_events_plugin_report_idx" ON "junior_conversation_events" USING btree (("payload"->>'namespace'),("payload"->>'name'),"created_at") WHERE "junior_conversation_events"."type" = 'structured_event';
9
+ END IF;
10
+
11
+ -- A failed concurrent build can leave an index that exists but cannot be used.
12
+ IF NOT EXISTS (
13
+ SELECT 1 FROM pg_index
14
+ WHERE indexrelid = 'junior_conversation_events_plugin_report_idx'::regclass
15
+ AND indrelid = 'junior_conversation_events'::regclass
16
+ AND indisvalid AND indisready
17
+ ) THEN
18
+ RAISE EXCEPTION 'The plugin report index is not valid and ready. Repair the concurrent build before running junior upgrade.';
19
+ END IF;
20
+ END $$;
@@ -0,0 +1 @@
1
+ ALTER TABLE "junior_agent_invocations" ADD COLUMN "agent_type" text;