@sentry/junior 0.261.0 → 0.262.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 (66) hide show
  1. package/dist/{adapter-Bx_1B2De.js → adapter-t-Y9RHML.js} +2 -2
  2. package/dist/{admin-BAbbVgVc.js → admin-BCqeFndQ.js} +1 -1
  3. package/dist/{agent-hooks-ghyZZQqB.js → agent-hooks-9q2zdKHL.js} +63 -14
  4. package/dist/{agent-invocations-Qfz7dWgU.js → agent-invocations-CxKldAeB.js} +1 -0
  5. package/dist/{agent-runner-g110-xgg.js → agent-runner-Cx6NO5LE.js} +112 -35
  6. package/dist/api/schema.js +1 -1
  7. package/dist/api.js +31 -28
  8. package/dist/{app-VCiPQ65Q.d.ts → app-Bo0kB987.d.ts} +1 -1
  9. package/dist/app.d.ts +1 -1
  10. package/dist/app.js +52 -59
  11. package/dist/{assistant-reply-CQcMaWNL.js → assistant-reply-B2qUBAwL.js} +1 -1
  12. package/dist/{briefs-CKcfrIQL.js → briefs-DsGH2Vym.js} +2 -2
  13. package/dist/{catalog-runtime-cd60vzAB.js → catalog-runtime-CfwKT0sn.js} +1 -1
  14. package/dist/cli/chat.js +15 -17
  15. package/dist/cli/check.js +3 -3
  16. package/dist/cli/main.js +3 -3
  17. package/dist/cli/plugins.js +4 -4
  18. package/dist/cli/snapshot-create.js +4 -4
  19. package/dist/cli/upgrade.js +3 -3
  20. package/dist/{client-2i0JJpoC.js → client-DpfjZgNk.js} +2 -2
  21. package/dist/{config-C9qM41O0.js → config-BiCtNiu5.js} +2 -2
  22. package/dist/{connections-DrtTrwkp.js → connections-D9IKbfk-.js} +10 -10
  23. package/dist/{conversation-privacy-1iTiFX1O.js → conversation-privacy-CBUI0frD.js} +1 -1
  24. package/dist/{credential-sync-wKNQ1dYc.js → credential-sync-Bu6ZOuOk.js} +14 -14
  25. package/dist/{executor-Rimyj8HZ.js → executor-O8xqLDN6.js} +4 -3
  26. package/dist/{images-D1JggcVY.js → images-AM1exvU0.js} +2 -2
  27. package/dist/instrumentation.js +2 -2
  28. package/dist/{job-queue-BjQdSqA3.js → job-queue-DmarAQGI.js} +1 -1
  29. package/dist/{logging-BLTa7R7f.js → logging-dZN1Bvtu.js} +1 -1
  30. package/dist/{message-DAeP5WWW.js → message-C_g2S8kv.js} +3 -3
  31. package/dist/nitro.d.ts +1 -1
  32. package/dist/nitro.js +3 -3
  33. package/dist/{oauth-callback-server-BAy1hhF1.js → oauth-callback-server-DvvOvr4q.js} +2 -2
  34. package/dist/{profile-CthM2qFM.js → profile-BP2N5uDY.js} +13 -6
  35. package/dist/{registry-BnSaArNb.js → registry-BUje_knT.js} +1 -1
  36. package/dist/{resolve-B5eLRl0v.js → resolve-DftZiYNU.js} +4 -4
  37. package/dist/{result-Cvm0GZCv.js → result-CRMRT9CE.js} +16 -11
  38. package/dist/{runner-D-pUzHbU.js → runner-4mmL2Pt1.js} +10 -10
  39. package/dist/{sandbox-egress-signals-mvwGV7rl.js → sandbox-egress-signals-1ysv0z5A.js} +1 -1
  40. package/dist/{schema-OzL8Zw4H.js → schema-XuTZukI9.js} +1 -1
  41. package/dist/{service-account-DWxvpSfd.js → service-account-B1sH3P7d.js} +3 -3
  42. package/dist/{service-account-Ch1uIpnR.js → service-account-Del2I_x3.js} +3 -3
  43. package/dist/{session-stop-Boj_zpTa.js → session-stop-ZuyOHxdK.js} +11 -11
  44. package/dist/{skills-BpdYCfFt.js → skills-lPeepA2b.js} +2 -2
  45. package/dist/{spawn-h1DJMQTf.js → spawn-DovpdlrW.js} +3 -2
  46. package/dist/{store-B6KqcdCQ.js → store-dZynGGFW.js} +6 -6
  47. package/dist/{task-queue-BaDwKSYv.js → task-queue-CmMCtzHO.js} +3 -3
  48. package/dist/{task-runner-BAX5li9a.js → task-runner-BRgJ5e0s.js} +19 -11
  49. package/dist/{tasks-uCfmlWga.js → tasks-Bh2qYaed.js} +15 -24
  50. package/dist/{thread-state-BJHVIz8G.js → thread-state-DA37FsAT.js} +5 -5
  51. package/dist/{turn-failure-response-CCC76P6-.js → turn-failure-response-BLcscQ-f.js} +7 -7
  52. package/dist/{turn-lifecycle-pHSESVR9.js → turn-lifecycle-D0e887FM.js} +1 -1
  53. package/dist/{turn-session-routing-BIKJZaiw.js → turn-session-routing-DdbSbJS6.js} +1 -1
  54. package/dist/{validation-B9KL_5Wc.js → validation-DtcovXqq.js} +1 -1
  55. package/dist/{version-CN9BXMW_.js → version-JcDaJ75p.js} +1 -1
  56. package/dist/version.js +1 -1
  57. package/dist/{viewer-C5xFaYVi.js → viewer-oMTUVAcR.js} +4 -4
  58. package/dist/{web-input-D6eqfXYd.js → web-input-FQ5wgqYn.js} +26 -26
  59. package/dist/{work-C-ecZAme.js → work-BiIKfayl.js} +40 -10
  60. package/dist/{worker-BpYDqiOf.js → worker-BZ7l75NM.js} +5 -5
  61. package/migrations/0062_plugin_report_index.sql +20 -0
  62. package/migrations/0063_agent_invocation_type.sql +1 -0
  63. package/migrations/meta/0062_snapshot.json +3499 -0
  64. package/migrations/meta/0063_snapshot.json +3505 -0
  65. package/migrations/meta/_journal.json +14 -0
  66. package/package.json +5 -5
@@ -1,12 +1,12 @@
1
- import { Tt as clearPendingAuth, Z as hydrateConversationMessages, dt as markConversationMessage, sn as buildDeterministicTurnId } from "./tasks-uCfmlWga.js";
2
- import { _ as getProviderErrorAttributes, g as findProviderError, m as ProviderError, v as getProviderErrorUserMessage } from "./client-2i0JJpoC.js";
3
- import { t as buildTurnFailureResponse, z as isRecord } from "./logging-BLTa7R7f.js";
1
+ import { Tt as clearPendingAuth, Z as hydrateConversationMessages, dt as markConversationMessage, sn as buildDeterministicTurnId } from "./tasks-Bh2qYaed.js";
2
+ import { _ as getProviderErrorAttributes, g as findProviderError, m as ProviderError, v as getProviderErrorUserMessage } from "./client-DpfjZgNk.js";
3
+ import { t as buildTurnFailureResponse, z as isRecord } from "./logging-dZN1Bvtu.js";
4
4
  import { g as parseSlackMessageTs } from "./actor-tlxzqaRe.js";
5
- import { c as getConversationEventStore, d as getDb } from "./viewer-C5xFaYVi.js";
6
- import { Ft as markTurnCompleted, Pt as markTurnClosed } from "./agent-runner-g110-xgg.js";
7
- import { Gt as listConversationAnnotations } from "./agent-hooks-ghyZZQqB.js";
5
+ import { c as getConversationEventStore, d as getDb } from "./viewer-oMTUVAcR.js";
6
+ import { Lt as markTurnClosed, Rt as markTurnCompleted } from "./agent-runner-Cx6NO5LE.js";
7
+ import { Gt as listConversationAnnotations } from "./agent-hooks-9q2zdKHL.js";
8
8
  import { F as readMessageCardRefs, I as removedCardSchema, L as resolveMessageCards } from "./conversation-CvuKJ3tA.js";
9
- import { o as persistThreadStateById, r as getPersistedThreadState, s as coerceThreadConversationState } from "./thread-state-BJHVIz8G.js";
9
+ import { o as persistThreadStateById, r as getPersistedThreadState, s as coerceThreadConversationState } from "./thread-state-DA37FsAT.js";
10
10
  // src/chat/conversations/pending-cards.ts
11
11
  /** Select undelivered cards and load their latest saved facts. */
12
12
  async function loadPendingMessageCards(conversationId) {
@@ -1,4 +1,4 @@
1
- import { c as getConversationEventStore } from "./viewer-C5xFaYVi.js";
1
+ import { c as getConversationEventStore } from "./viewer-oMTUVAcR.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 {
@@ -34,7 +34,7 @@ function slackSourceForDestination(args) {
34
34
  * Reads parent Conversations when this Conversation has no Destination.
35
35
  */
36
36
  async function resolveConversationRouting(args) {
37
- const conversationStore = args.conversationStore ?? (await import("./viewer-C5xFaYVi.js").then((n) => n.s)).getConversationStore();
37
+ const conversationStore = args.conversationStore ?? (await import("./viewer-oMTUVAcR.js").then((n) => n.s)).getConversationStore();
38
38
  const chain = await loadConversationChain(args.conversationId, conversationStore);
39
39
  let destination;
40
40
  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-cd60vzAB.js";
2
+ import { n as pluginCatalogRuntime } from "./catalog-runtime-CfwKT0sn.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.261.0";
2
+ var version = "0.262.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-CN9BXMW_.js";
1
+ export { t as JUNIOR_VERSION } from "./version-JcDaJ75p.js";
@@ -1,9 +1,9 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-nwUcYXjP.js";
2
- import { I as GOOGLE_IDENTITY_PROVIDER, R as normalizeIdentityEmail } from "./logging-BLTa7R7f.js";
3
- import { i as getChatConfig } from "./config-C9qM41O0.js";
2
+ import { I as GOOGLE_IDENTITY_PROVIDER, R as normalizeIdentityEmail } from "./logging-dZN1Bvtu.js";
3
+ import { i as getChatConfig } from "./config-BiCtNiu5.js";
4
4
  import { d as parseSlackTeamId, o as parseActorUserId, u as parseSlackChannelReferenceId } from "./actor-tlxzqaRe.js";
5
- import { c as juniorIdentities, d as juniorDestinations, l as juniorUsers, o as conversationReadColumns, s as juniorConversations } from "./agent-invocations-Qfz7dWgU.js";
6
- import { _ as juniorConversationAnnotations, d as juniorConversationBindings, h as juniorConversationEvents, m as juniorConversationMetrics, p as CONVERSATION_METRICS, t as createJuniorSqlExecutor, u as juniorConversationParticipants } from "./executor-Rimyj8HZ.js";
5
+ import { c as juniorIdentities, d as juniorDestinations, l as juniorUsers, o as conversationReadColumns, s as juniorConversations } from "./agent-invocations-CxKldAeB.js";
6
+ import { _ as juniorConversationAnnotations, d as juniorConversationBindings, h as juniorConversationEvents, m as juniorConversationMetrics, p as CONVERSATION_METRICS, t as createJuniorSqlExecutor, u as juniorConversationParticipants } from "./executor-O8xqLDN6.js";
7
7
  import { c as newConversationEventSchema, h as usageSchema, l as encodeHistoryPayload, o as decodeStoredConversationEvent, r as conversationEventDataSchema, s as historyReplacementSchema } from "./history-AY8rs-FR.js";
8
8
  import { randomUUID } from "node:crypto";
9
9
  import { and, asc, desc, eq, gt, gte, inArray, isNull, lt, lte, ne, or, sql } from "drizzle-orm";
@@ -1,36 +1,36 @@
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 { At as saveTurnCheckpoint, Bn as normalizeSlackStatusText, Dt as wasPendingAuthStopped, E as sameDefinitionValue, Ft as listTurnSummaries, Hn as truncateStatusText, I as loadProjection, It as recordTurnSummary, Kn as postSlackMessage, Ln as escapeSlackMrkdwnText, M as commitMessages, Mt as completeTurnRecord, Nt as failTurnRecord, P as loadConversationProjection, Pt as getTurnRecord, Q as persistConversationMessages, Rn as formatSlackLink, S as automationDefinition, Tt as clearPendingAuth, U as recordAuthorizationCompleted, Un as addReactionToMessage, Vt as buildTurnErrorResponse, Wt as persistWithRetry, Z as hydrateConversationMessages, _ as parseEventAutomationRow, _t as PluginCredentialFailureError, at as appendThreadContextMessages, c as withScheduledAutomationLock, ct as estimateConversationContextTokens, dn as getThreadStopDecision, dt as markConversationMessage, er as configValueSchema, et as persistConversationMessageSummaries, f as deleteEventAutomation, ft as normalizeConversationText, gn as isExperimentalFeatureEnabled, 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 removeReactionFromMessage, r as parseScheduledAutomationRow, rt as fallbackShortTitle, sn as buildDeterministicTurnId, st as createConversationMemoryService, tt as resolveConversationTitle, un as getSubscribedReplyPreflightDecision, ut as isHumanConversationMessage, w as listAutomationVersions, xt as AuthorizationFlowDisabledError, yn as createUserTokenStore, zn as normalizeSlackReplyMarkdown } from "./tasks-Bh2qYaed.js";
2
+ import { a as completeText, p as escapeXml, r as completeDecision, y as isProviderRetryError } from "./client-DpfjZgNk.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-dZN1Bvtu.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-BiCtNiu5.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-oMTUVAcR.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-O8xqLDN6.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";
11
+ import { d as actorLogContext, f as credentialContextForActor } from "./registry-BUje_knT.js";
12
+ import { A as listThreadReplies, At as CooperativeTurnYieldError, Bt as startActiveTurn, Ct as buildSteeringPiMessage, D as resolveSlackChannelIdFromMessage, E as readSlackRawMessageContext, Ft as isTurnInputCommitLostError, I as eventAutomationTriggerAvailable, It as isTurnInputDeferredError, L as effectiveTaskOutcomes, Lt as markTurnClosed, Mt as TurnInputDeferredError, Nt as getConversationTurnBoundaryError, O as resolveSlackChannelIdFromThreadId, Pt as isCooperativeTurnYieldError, Rt as markTurnCompleted, T as parseSlackThreadId, Tt as RetryableDeliveryError, Vt as shouldEmitDevAgentTrace, b as renderBlockText, i as buildAuthPauseResponse, jt as TurnInputCommitLostError, k as getConversationInfo, kt as ConversationTurnBoundaryError, n as executeAgentRun, p as latestProgressStatus, r as createContextCompactor, t as createAgentRunner, w as storeAttachment, wt as withoutSavedSteeringMessages, y as renderAttachmentText, zt as markTurnFailed } from "./agent-runner-Cx6NO5LE.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-9q2zdKHL.js";
14
+ import { a as acquireActiveLock, i as MUTATION_LOCK_TTL_MS, r as getStateAdapter, s as withLock } from "./adapter-t-Y9RHML.js";
14
15
  import { B as readMessageAttachments, U as isVisionImageMediaType } from "./conversation-CvuKJ3tA.js";
15
16
  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";
17
+ import { n as getAssistantReplyText } from "./assistant-reply-B2qUBAwL.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-ZuyOHxdK.js";
19
+ import { a as getVercelConversationWorkQueue, f as getTurnRequestDeadline } from "./job-queue-DmarAQGI.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-dZynGGFW.js";
21
21
  import { l as automationListQuerySchema } from "./automation-DrpcA-SX.js";
22
22
  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";
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-BRgJ5e0s.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-CRMRT9CE.js";
25
+ import { n as getTurnLifecycle, t as ConversationTurnLifecycleService } from "./turn-lifecycle-D0e887FM.js";
26
+ import { i as resolveAgentInvocationId, o as AgentRunError, s as executeTurn, t as createAgentInvocationWorker } from "./work-BiIKfayl.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-DA37FsAT.js";
28
+ import { c as deleteWebAuthorization, d as createPausedTurns, f as getPausedTurnRequest, h as getTurnAuthorization, m as wakePausedTurn, s as createWebAuthorization } from "./connections-D9IKbfk-.js";
29
+ import { n as resolveTurnSessionRouting } from "./turn-session-routing-DdbSbJS6.js";
30
+ import { t as bindMessageAgent } from "./message-C_g2S8kv.js";
31
+ import { t as bindSpawnAgent } from "./spawn-DovpdlrW.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-BLcscQ-f.js";
33
+ import { r as storeInputImages } from "./images-AM1exvU0.js";
34
34
  import { z } from "zod";
35
35
  import { createHash } from "node:crypto";
36
36
  import { and, asc, count, desc, eq, exists, inArray, ne, or, sql } from "drizzle-orm";
@@ -1,14 +1,14 @@
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 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-Bh2qYaed.js";
3
+ import { n as botConfig } from "./config-BiCtNiu5.js";
4
+ import { c as getConversationEventStore, u as getConversationStore } from "./viewer-oMTUVAcR.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 { Ct as buildSteeringPiMessage, Ft as isTurnInputCommitLostError, G as completeAgentInvocation, H as recordSubagentStarted, K as createAgentInvocation, Nt as getConversationTurnBoundaryError, Ot as readBlockedReport, V as recordSubagentEnded, X as getActiveAgentInvocationForConversation, Z as getAgentInvocation, _t as agentTypeInstructions, at as getLatestAgentInvocationForConversation, dt as markAgentInvocationPaused, ft as markAgentInvocationRunning, jt as TurnInputCommitLostError, lt as markAgentInvocationMailboxAppended, mt as reportReplacedAgentInvocation, ot as isTerminalAgentInvocation, pt as markAgentInvocationSteered, rt as getAgentInvocationTurnId, tt as getAgentInvocationMessageId, vt as agentTypeStartsWithParentHistory, wt as withoutSavedSteeringMessages, z as stopChildAgentsOf } from "./agent-runner-Cx6NO5LE.js";
7
+ import { n as getAssistantReplyText } from "./assistant-reply-B2qUBAwL.js";
8
+ import { F as resetAutomatedTurnLimit, N as maybePostAutomatedTurnLimitNotice, P as recordFinishedTurnForAutomatedLimit } from "./session-stop-ZuyOHxdK.js";
9
+ import { r as appendAndEnqueueInboundMessage } from "./store-dZynGGFW.js";
10
+ import { t as ConversationTurnLifecycleService } from "./turn-lifecycle-D0e887FM.js";
11
+ import { n as getPersistedSandboxState, o as persistThreadStateById, r as getPersistedThreadState } from "./thread-state-DA37FsAT.js";
12
12
  import { isDeepStrictEqual } from "node:util";
13
13
  import { z } from "zod";
14
14
  // src/chat/runtime/turn-execution.ts
@@ -52,6 +52,34 @@ async function executeTurn(agentRunner, run, saveResult) {
52
52
  });
53
53
  return { status: "completed" };
54
54
  }
55
+ // src/chat/agent-invocations/fork-history.ts
56
+ /**
57
+ * Cut parent history for a fork: everything before the parent's message that
58
+ * started the fork, through the last point where every tool call has its
59
+ * result. A model request with an unanswered tool call fails, and the parent
60
+ * can commit its history in the middle of a tool round.
61
+ */
62
+ function forkHistoryFrom(messages, parentToolCallId) {
63
+ const spawnIndex = parentToolCallId ? messages.findIndex((message) => message.role === "assistant" && message.content.some((part) => part.type === "toolCall" && part.id === parentToolCallId)) : -1;
64
+ const before = spawnIndex >= 0 ? messages.slice(0, spawnIndex) : messages;
65
+ const pending = /* @__PURE__ */ new Set();
66
+ let end = 0;
67
+ for (const [index, message] of before.entries()) {
68
+ if (message.role === "assistant") {
69
+ for (const part of message.content) if (part.type === "toolCall") pending.add(part.id);
70
+ } else if (message.role === "toolResult") pending.delete(message.toolCallId);
71
+ if (pending.size === 0) end = index + 1;
72
+ }
73
+ return before.slice(0, end);
74
+ }
75
+ /**
76
+ * Load the start history of a fork child from its parent Conversation. The
77
+ * child commits it as its own history in its first checkpoint, so later
78
+ * agent invocations of the child read it from the child Conversation.
79
+ */
80
+ async function loadForkHistory(invocation) {
81
+ return forkHistoryFrom((await openConversationProjection({ conversationId: invocation.parentConversationId })).messages, invocation.parentToolCallId);
82
+ }
55
83
  // src/chat/agent-invocations/work.ts
56
84
  var work_exports = /* @__PURE__ */ __exportAll({
57
85
  agentInvocationInputText: () => agentInvocationInputText,
@@ -138,10 +166,12 @@ function invocationIdFromMessages(messages) {
138
166
  */
139
167
  function agentInvocationInputText(invocation) {
140
168
  if (!invocation.parentToolCallId) return invocation.input;
169
+ const typeInstructions = agentTypeInstructions(invocation.agentType);
141
170
  return [
142
171
  "[parent agent task]",
143
172
  "",
144
173
  "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.",
174
+ ...typeInstructions ? ["", typeInstructions] : [],
145
175
  "",
146
176
  invocation.input
147
177
  ].join("\n");
@@ -426,7 +456,7 @@ function createAgentInvocationWorker(agentRunner, options = {}) {
426
456
  readChildDepthAndRootLocation(invocation.childConversationId)
427
457
  ]);
428
458
  sandboxRef = getPersistedSandboxState(persisted);
429
- history = projection.messages;
459
+ history = agentTypeStartsWithParentHistory(invocation.agentType) && projection.messages.length === 0 ? await loadForkHistory(invocation) : projection.messages;
430
460
  location = tree.location;
431
461
  canSpawn = tree.depth <= maxAgentDepth;
432
462
  } 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-DpfjZgNk.js";
3
+ import { f as logException, m as logWarn, p as logInfo, w as withLogContext } from "./logging-dZN1Bvtu.js";
4
+ import { i as getChatConfig } from "./config-BiCtNiu5.js";
5
+ import { f as getTurnRequestDeadline, m as ConversationQueueMessageRejectedError } from "./job-queue-DmarAQGI.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-dZynGGFW.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;