@sentry/junior 0.286.0 → 0.288.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 (78) hide show
  1. package/dist/{adapter-JQZaJ-B_.js → adapter-Cikcqdty.js} +1 -1
  2. package/dist/{admin-Dm2bimJ-.js → admin-BcSxHuTB.js} +2 -1
  3. package/dist/{agent-runner-DGCwOEyL.js → agent-runner-9MXyWUL8.js} +784 -368
  4. package/dist/api/schema.d.ts +2 -2
  5. package/dist/api/schema.js +9 -8
  6. package/dist/api.d.ts +1 -1
  7. package/dist/api.js +411 -65
  8. package/dist/{app-BKq0JzWx.d.ts → app-BUklJVBe.d.ts} +4 -2
  9. package/dist/app.d.ts +1 -1
  10. package/dist/app.js +555 -71
  11. package/dist/{assistant-reply-CAPafcUY.js → assistant-reply-mj47jMRV.js} +1 -1
  12. package/dist/{automation-B-jJN_gM.js → automation-DDXwHQs5.js} +4 -7
  13. package/dist/{background-compaction-queue-Btu2oab_.js → background-compaction-queue-CjllSPir.js} +161 -90
  14. package/dist/{briefs-UMeYehUe.js → briefs-DW9iuolG.js} +7 -5
  15. package/dist/{catalog-runtime-Bym8GVdh.js → catalog-runtime-B3gfH58M.js} +1 -1
  16. package/dist/cli/chat.js +14 -14
  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.d.ts +1 -1
  22. package/dist/cli/upgrade.js +3 -3
  23. package/dist/config-CLJcyYEF.js +1762 -0
  24. package/dist/{connections-CQ7p0aNJ.js → connections-BtdJftow.js} +9 -9
  25. package/dist/{conversation-BusI2uzj.js → conversation-DhoqHtQ7.js} +30 -6
  26. package/dist/{conversation-pending-messages-DwehU0Fd.js → conversation-pending-messages-DHV0S4uF.js} +2 -5
  27. package/dist/{conversation-privacy-Cd_nZZBM.js → conversation-privacy-BPirIVlX.js} +1 -1
  28. package/dist/core-model-BTt5E5b0.js +182 -0
  29. package/dist/{credential-sync-DmiJi_At.js → credential-sync-Co8Q2xRW.js} +28 -20
  30. package/dist/{viewer-CH-ASQzh.js → db-Co7DTYYh.js} +62 -358
  31. package/dist/{db-C5zi4ecs.d.ts → db-zIs8-Ba3.d.ts} +6 -2
  32. package/dist/{executor-Dipi2Ixl.js → executor-m0kIN71Q.js} +102 -14
  33. package/dist/{media-B-BpXo41.js → history-IjdmO_r6.js} +8 -88
  34. package/dist/instrumentation.js +2 -2
  35. package/dist/{logging-CMFhLLj4.js → logging-DbD-dErY.js} +3 -2
  36. package/dist/media-BAHvgkok.js +85 -0
  37. package/dist/{message-D1xLljUF.js → message-DKTdTYm-.js} +10 -10
  38. package/dist/nitro.d.ts +1 -1
  39. package/dist/nitro.js +19 -41
  40. package/dist/{oauth-callback-server-DCAFIUQr.js → oauth-callback-server-CpbepSbp.js} +2 -2
  41. package/dist/{projection-CoeMNxJ4.js → projection-BViECfYu.js} +361 -746
  42. package/dist/{prompt-C9OQEfan.js → prompt-KT6MaDHN.js} +1 -1
  43. package/dist/{registry-u-sFYtx_.js → registry-D-Acyjhh.js} +1 -1
  44. package/dist/{reporting-window-B4TwyuJo.js → reporting-window-B3Ze-Qnt.js} +4 -1
  45. package/dist/{resolve-DYqgL3Eo.js → resolve-gkT2R66z.js} +3 -3
  46. package/dist/{result-CescSwAw.js → result-DHmCFEt8.js} +8 -8
  47. package/dist/{runner-Cr67a8TB.js → runner-DBKjGjH-.js} +8 -8
  48. package/dist/{sandbox-egress-signals-DLOazy5W.js → sandbox-egress-signals-9n8hqx29.js} +1 -1
  49. package/dist/{schedule-BTp__wrw.js → schedule-cP0AACm1.js} +11 -2
  50. package/dist/{schema-Ih60j59-.d.ts → schema-B_6aOcx5.d.ts} +159 -3
  51. package/dist/{schema-BUSi3sgv.js → schema-DxicIQbc.js} +79 -14
  52. package/dist/{service-account-CsKxktLk.js → service-account-Bi0HsY6w.js} +3 -3
  53. package/dist/{service-account-CGEqz9wG.js → service-account-CDlC9ssy.js} +3 -3
  54. package/dist/{session-stop-CGz5DByb.js → session-stop-BWOsuo8p.js} +62 -20
  55. package/dist/{skills-COCqf61f.js → skills-DO5K68Rq.js} +2 -2
  56. package/dist/spawn-BBqZDcPa.js +79 -0
  57. package/dist/{stop-GyFZkHuQ.js → stop-WC97cmHz.js} +832 -552
  58. package/dist/{store-D0-8plWp.js → store-ByR1Lr7e.js} +4 -16
  59. package/dist/{task-runner-xPuQmEot.js → task-runner-B-Ewf8TX.js} +30 -21
  60. package/dist/{turn-failure-response-BOviBdT-.js → turn-failure-response-CpdPoZSl.js} +25 -11
  61. package/dist/{validation-DZDKorGz.js → validation-B4sbIoES.js} +1 -1
  62. package/dist/{version-BTIz7fGi.js → version-D6lpuAgL.js} +1 -1
  63. package/dist/version.js +1 -1
  64. package/dist/viewer-CeP27tC3.js +337 -0
  65. package/dist/warmup-P_GJCL1c.js +767 -0
  66. package/dist/{work-C75_IM5e.js → work-DI7x1Slm.js} +32 -20
  67. package/dist/{worker-Dl47I729.js → worker-CYPTOT4j.js} +6 -7
  68. package/migrations/0088_conversation_unsubscribe.sql +1 -0
  69. package/migrations/0089_conversation_paused_status.sql +3 -0
  70. package/migrations/0090_guardian_review_time_index.sql +20 -0
  71. package/migrations/meta/0088_snapshot.json +4372 -0
  72. package/migrations/meta/0089_snapshot.json +4372 -0
  73. package/migrations/meta/0090_snapshot.json +4388 -0
  74. package/migrations/meta/_journal.json +21 -0
  75. package/package.json +5 -4
  76. package/dist/client-B0aAs7wC.js +0 -793
  77. package/dist/config-B9f9Lqo5.js +0 -579
  78. package/dist/spawn-C8F_iXWO.js +0 -42
@@ -1,7 +1,7 @@
1
- import { W as isRecord, b as setSpanAttributes, h as logWarn } from "./logging-CMFhLLj4.js";
2
- import { c as fetchWithBoundedOAuthErrorBodies, i as resolvePluginHeaderEnvRefs } from "./registry-u-sFYtx_.js";
1
+ import { K as isRecord, b as setSpanAttributes, h as logWarn } from "./logging-DbD-dErY.js";
2
+ import { c as fetchWithBoundedOAuthErrorBodies, i as resolvePluginHeaderEnvRefs } from "./registry-D-Acyjhh.js";
3
3
  import { a as withLock, i as fenceLock, n as MUTATION_LOCK_TTL_MS } from "./locks-D-0h111u.js";
4
- import { r as getStateAdapter } from "./adapter-JQZaJ-B_.js";
4
+ import { r as getStateAdapter } from "./adapter-Cikcqdty.js";
5
5
  import { AsyncLocalStorage } from "node:async_hooks";
6
6
  import { randomUUID } from "node:crypto";
7
7
  import { UnauthorizedError, auth } from "@modelcontextprotocol/sdk/client/auth.js";
@@ -1,20 +1,20 @@
1
1
  import { v as __exportAll } from "./sentry-BRTJqumy.js";
2
- import { Ba as SANDBOX_DATA_ROOT, Bi as formatSlackLink, Ga as sandboxSkillFile, Gn as getPluginSlackConversationLink, Hr as cancelSubscriptions, Jn as getPluginUserPromptContributions, Ka as sandboxSkillPathResolution, Kn as getPluginSystemPromptContributions, N as normalizeConversationText, Pn as isExperimentalFeatureEnabled, Ro as JUNIOR_NATIVE_EVENT_NAMESPACE, Ua as SANDBOX_WORKSPACE_ROOT, Vi as normalizeSlackReplyMarkdown, Wa as sandboxSkillDir, Yn as getPlugins, Zi as postSlackMessage, _n as renderChildTag, ai as JUNIOR_THREAD_STATE_TTL_MS, at as listTurnSummaries, bn as tagJson, cn as normalizeToolNameFromResult, en as hasRuntimeTurnContext, fi as ToolInputError, fn as REQUEST_CONTEXT_SECTION_TAG, gn as escapeTagText, hn as escapeClosingTags, ho as buildSentryConversationUrl, ii as verifyTimerWatchCredentialSubject, it as getTurnRecord, ln as retainRuntimeTurnContext, mn as TURN_CONTEXT_TAG, mr as getReviewItem, oi as getDashboardConversationLink, on as isToolResultError, pn as SESSION_CONTEXT_SECTION_TAG, rn as isAssistantMessage, si as getDashboardObjectIconLink, sn as isToolResultMessage, un as stripRuntimeTurnContext, vn as renderTag$1, x as toStoredConversationMessage, yi as listWorkspaces, yn as renderUntrustedTag, zi as escapeSlackMrkdwnText, zo as conversationNoteEvent } from "./projection-CoeMNxJ4.js";
3
- import { f as renderCurrentInstruction, h as escapeXmlText, m as escapeXml } from "./client-B0aAs7wC.js";
4
- import { n as botConfig } from "./config-B9f9Lqo5.js";
5
- import { h as logWarn, m as logInfo, p as logException, v as serializeGenAiAttribute } from "./logging-CMFhLLj4.js";
2
+ import { $r as getDashboardConversationLink, Ba as sandboxSkillFile, Bn as getPlugins, Cn as renderTag$1, Fa as SANDBOX_DATA_ROOT, Fi as normalizeSlackReplyMarkdown, Fr as cancelSubscriptions, Gi as postSlackMessage, In as getPluginSlackConversationLink, Ln as getPluginSystemPromptContributions, N as normalizeConversationText, Ni as escapeSlackMrkdwnText, Pi as formatSlackLink, Qr as JUNIOR_THREAD_STATE_TTL_MS, Ra as SANDBOX_WORKSPACE_ROOT, Sn as renderChildTag, Tn as tagJson, Va as sandboxSkillPathResolution, Zr as verifyTimerWatchCredentialSubject, _n as SESSION_CONTEXT_SECTION_TAG, bn as escapeTagText, ct as listTurnSummaries, dn as isToolResultMessage, do as buildSentryConversationUrl, ei as getDashboardObjectIconLink, fn as normalizeToolNameFromResult, gn as REQUEST_CONTEXT_SECTION_TAG, in as hasRuntimeTurnContext, mn as stripRuntimeTurnContext, oi as ToolInputError, or as getReviewItem, pi as listWorkspaces, pn as retainRuntimeTurnContext, sn as isAssistantMessage, st as getTurnRecord, un as isToolResultError, vn as TURN_CONTEXT_TAG, wn as renderUntrustedTag, x as toStoredConversationMessage, yn as escapeClosingTags, za as sandboxSkillDir, zn as getPluginUserPromptContributions } from "./projection-BViECfYu.js";
3
+ import { I as renderCurrentInstruction, R as escapeXml, n as botConfig, z as escapeXmlText } from "./config-CLJcyYEF.js";
4
+ import { h as logWarn, m as logInfo, p as logException, v as serializeGenAiAttribute } from "./logging-DbD-dErY.js";
6
5
  import { o as isUserActor, t as createActor } from "./actor-6jsm_v96.js";
7
- import { C as getSqlExecutor, S as getDb, V as SYSTEM_IDENTITY_ID, et as nextDetailVersion, x as getConversationStore, y as getConversationEventStore } from "./viewer-CH-ASQzh.js";
8
- import { A as juniorConversations, M as juniorUsers } from "./executor-Dipi2Ixl.js";
9
- import { i as isVisionImageMediaType } from "./media-B-BpXo41.js";
6
+ import { T as SYSTEM_IDENTITY_ID, V as nextDetailVersion, a as getConversationStore, o as getDb, r as getConversationEventStore, s as getSqlExecutor } from "./db-Co7DTYYh.js";
7
+ import { A as juniorConversations, M as juniorUsers } from "./executor-m0kIN71Q.js";
10
8
  import { a as listReferenceFiles, c as soulPathCandidates, l as worldPathCandidates } from "./package-discovery-DJhGdS4c.js";
11
- import { h as credentialSubjectSchema } from "./registry-u-sFYtx_.js";
12
- import { r as getStateAdapter } from "./adapter-JQZaJ-B_.js";
13
- import { a as EVENT_SYSTEM_ACTOR, i as EVENT_MESSAGE_AUTHOR, o as isEventConversationMessage, r as EVENT_AUTHOR_ID } from "./prompt-C9OQEfan.js";
14
- import { a as QUIET_MARKER, i as NO_REPLY_MARKER, r as sanitizeAssistantText } from "./assistant-reply-CAPafcUY.js";
15
- import { E as userCustomizationTextSchema, _ as formatUserInputAnswer } from "./reporting-window-B4TwyuJo.js";
16
- import { r as appendAndEnqueueInboundMessage } from "./store-D0-8plWp.js";
17
- import { Tt as eventGuidance, wt as eventCatalogEntry, xt as CORE_EVENT_NAMESPACE } from "./task-runner-xPuQmEot.js";
9
+ import { h as credentialSubjectSchema } from "./registry-D-Acyjhh.js";
10
+ import { c as conversationNoteEvent, i as JUNIOR_NATIVE_EVENT_NAMESPACE } from "./core-model-BTt5E5b0.js";
11
+ import { r as getStateAdapter } from "./adapter-Cikcqdty.js";
12
+ import { i as isVisionImageMediaType } from "./media-BAHvgkok.js";
13
+ import { a as EVENT_SYSTEM_ACTOR, i as EVENT_MESSAGE_AUTHOR, o as isEventConversationMessage, r as EVENT_AUTHOR_ID } from "./prompt-KT6MaDHN.js";
14
+ import { a as QUIET_MARKER, i as NO_REPLY_MARKER, r as sanitizeAssistantText } from "./assistant-reply-mj47jMRV.js";
15
+ import { D as userCustomizationTextSchema, v as formatUserInputAnswer } from "./reporting-window-B3Ze-Qnt.js";
16
+ import { r as appendAndEnqueueInboundMessage } from "./store-ByR1Lr7e.js";
17
+ import { Tt as eventGuidance, wt as eventCatalogEntry, xt as CORE_EVENT_NAMESPACE } from "./task-runner-B-Ewf8TX.js";
18
18
  import path from "node:path";
19
19
  import { isDeepStrictEqual } from "node:util";
20
20
  import * as z from "zod";
@@ -160,7 +160,7 @@ const TASK_EXECUTION_RULES = [
160
160
  * input itself holds only facts.
161
161
  */
162
162
  const AGENT_INPUT_RULES = [
163
- "- An `<agent-result>` reports a child agent that you started. Act on its `status`. `completed`: use the result to continue the work in this conversation, and do not repeat work that the child agent already did. `failed`: if you still need this work, use messageAgent to ask the same child agent to try again, or tell the user what is blocked. `stopped`: the child agent was stopped on purpose; do not start this work again unless the user asks. `blocked`: the child agent did not finish because something is missing. If you can give it, send it to the child agent with messageAgent. If only a person can give it, such as user approval, your own text cannot give it. Do not ask in plain text: add one action item with `addReviewItem` that names the exact action. Make its `dedupe_key` from the child conversation and the blocked action, so a repeat block updates the same item. After the user answers in this conversation, tell the child agent with messageAgent to try again. The runtime shows the user's own messages to the child's action review. Otherwise tell the user what is missing.",
163
+ "- An `<agent-result>` reports a child agent that you started. Act on its `status`. `completed`: use the result to continue the work in this conversation, and do not repeat work that the child agent already did. `failed`: if you still need this work, use messageAgent to ask the same child agent to try again, or tell the user what is blocked. `stopped`: the child agent was stopped on purpose; do not start this work again unless the user asks. `blocked`: the child agent did not finish because something is missing. If you can give it, send it to the child agent with messageAgent. If only a person can give it, such as user approval, do not ask in plain text: add one action item with `addReviewItem` that names the exact action. Make its `dedupe_key` from the child conversation and the blocked action, so a repeat block updates the same item. After the user answers in this conversation, use messageAgent to pass the approval on to the child agent, name the exact action, and tell it to try again. Otherwise tell the user what is missing.",
164
164
  "- `waiting_on` on an `<agent-result>` names child agents that you started that have not reported yet. Their results arrive later. Unless this result is useful to the user alone, wait for them before you report.",
165
165
  "- An `<agent-message source=\"child_agent\">` comes from a child agent that can still be working; its result arrives later. If it needs an answer, use messageAgent.",
166
166
  "- A child agent calls people by their Slack mention. When your reply is to a person that a child agent names, write to them as \"you\", and do not also name them in the third person.",
@@ -803,8 +803,9 @@ function buildTurnContextPrompt(params) {
803
803
  * before it calls the model, so without this note the model cannot see it.
804
804
  * The note has the error reference, never the raw error.
805
805
  */
806
- function failedTurnNote(eventId) {
807
- return `Your previous turn failed before it finished. The person may have seen an error reply or no reply.${eventId ? ` Error reference: event_id=${eventId}.` : ""} Do not assume that request was completed.`;
806
+ function failedTurnNote(failureCode, eventId) {
807
+ const reference = eventId ? ` Error reference: event_id=${eventId}.` : "";
808
+ return `Your previous turn failed before it finished. ${failureCode === "delivery_failed" ? "Your reply was not delivered, so the person did not see it. They may have seen an error reply." : "The person may have seen an error reply or no reply."}${reference} Do not assume that request was completed.`;
808
809
  }
809
810
  /** Most notes that one Turn shows. Older notes in the window are dropped. */
810
811
  const MAX_CONVERSATION_NOTES_PER_TURN = 20;
@@ -854,7 +855,7 @@ async function loadTurnConversationNotes(input) {
854
855
  if (data.turnId !== input.turnId) return [];
855
856
  foundTurn = true;
856
857
  } else if (foundTurn && data.type === "turn_failed") {
857
- newestFirst.push(failedTurnNote(data.eventId));
858
+ newestFirst.push(failedTurnNote(data.failureCode, data.eventId));
858
859
  if (newestFirst.length === MAX_CONVERSATION_NOTES_PER_TURN) break scan;
859
860
  } else if (foundTurn && data.type === "structured_event" && data.namespace === "junior" && data.name === conversationNoteEvent.eventName && data.version === conversationNoteEvent.version) {
860
861
  newestFirst.push(conversationNoteEvent.parse(data.content).text);
@@ -865,6 +866,47 @@ async function loadTurnConversationNotes(input) {
865
866
  }
866
867
  return newestFirst.reverse();
867
868
  }
869
+ // src/chat/experimental.ts
870
+ /**
871
+ * Known unstable product features that must be opted into explicitly.
872
+ * Add new keys here as features graduate from private experiments; remove them
873
+ * once they become stable defaults.
874
+ */
875
+ const EXPERIMENTAL_FEATURES = [
876
+ "operator-tools",
877
+ "passive-routing",
878
+ "user-customization"
879
+ ];
880
+ const EXPERIMENTAL_FEATURE_SET = new Set(EXPERIMENTAL_FEATURES);
881
+ let configuredExperimental = {};
882
+ function isExperimentalFeature(value) {
883
+ return EXPERIMENTAL_FEATURE_SET.has(value);
884
+ }
885
+ /** Replace app-level experimental opt-ins and return the previous setting. */
886
+ function setExperimentalFeatures(config) {
887
+ const previous = { ...configuredExperimental };
888
+ if (config === void 0) {
889
+ configuredExperimental = {};
890
+ return previous;
891
+ }
892
+ const next = {};
893
+ for (const [rawName, enabled] of Object.entries(config)) {
894
+ if (enabled === void 0) continue;
895
+ if (typeof enabled !== "boolean") throw new Error(`experimental.${rawName} must be a boolean when provided`);
896
+ if (!isExperimentalFeature(rawName)) throw new Error(`experimental.${rawName} is not a known experimental feature. Known features: ${EXPERIMENTAL_FEATURES.join(", ")}`);
897
+ next[rawName] = enabled;
898
+ }
899
+ configuredExperimental = next;
900
+ return previous;
901
+ }
902
+ /** Return a copy of the app-level experimental opt-ins configured by createApp(). */
903
+ function getExperimentalFeatures() {
904
+ return { ...configuredExperimental };
905
+ }
906
+ /** Return whether one experimental feature is enabled via createApp({ experimental }). */
907
+ function isExperimentalFeatureEnabled(feature) {
908
+ return configuredExperimental[feature] === true;
909
+ }
868
910
  // src/chat/identities/customization.ts
869
911
  /** Read the saved customization for one user. */
870
912
  async function readUserCustomization(userId) {
@@ -2568,7 +2610,7 @@ function conversationSubtree(conversationIds) {
2568
2610
  from junior_conversations child
2569
2611
  join tree
2570
2612
  on child.parent_conversation_id = tree.conversation_id
2571
- and child.root_conversation_id = tree.root_conversation_id
2613
+ and (child.root_conversation_id || '') = tree.root_conversation_id
2572
2614
  )
2573
2615
  select scope_conversation_id, conversation_id from tree
2574
2616
  ) conversation_subtree`;
@@ -2923,4 +2965,4 @@ async function saveStoppedConversationEvents(conversationId, messages) {
2923
2965
  }
2924
2966
  }]);
2925
2967
  }
2926
- export { withoutSavedSteeringMessages as $, requireSlackChannelMessageScope as A, maybePostAutomatedTurnLimitNotice as B, enqueueEventNotification as C, timerWatchCredentialSubject as D, renderEventBatchInputs as E, WORKSPACE_SNAPSHOT_FAILED_EVENT as F, admitAutomatedTurn as G, resolveSlackReplyTarget as H, WORKSPACE_SNAPSHOT_READY_EVENT as I, assemblePrompt as J, recordFinishedTurnForAutomatedLimit as K, workspaceSnapshotFinishedEvent as L, slackChannelMessageReplyThreadTs as M, slackChannelMessageRunsAutomation as N, getEventCatalog as O, slackChannelMessageTrigger as P, loadPromptTurnContext as Q, workspaceSnapshotWatch as R, EVENT_WAIT_MS as S, isEventMailboxMetadata as T, sendSlackReply as U, postAutomatedTurnLimitNoticeForConversation as V, renderSlackObjectCard as W, buildSteeringPiMessage as X, buildPromptInput as Y, instructionForInputs as Z, sourceFromTurnInput as _, session_stop_exports as a, readBlockedReport as at, conversationSubtree as b, loadReviewItemInput as c, deliversFinalText as ct, getAuthPausedConversationTurnId as d, readAutomationResult as dt, readUserCustomization as et, getEventBatchDelayMs as f, remindMissingAutomationResult as ft, resolveMailboxTurnWork as g, parseWebMessages as h, resumeStoppedConversationTree as i, REPORT_BLOCKED_TOOL_NAME as it, slackChannelMessageEvent as j, SLACK_EVENT_NAMESPACE as k, savedInputInstruction as l, finishedRunReply as lt, parseEventMessages as m, isWatchEvent as n, addConversationNote as nt, skipInputAfterConversationStop as o, FINISH_AUTOMATION_RUN_TOOL_NAME as ot, listActiveMailboxTurns as p, runDispatchOutcome as pt, resetAutomatedTurnLimit as q, markConversationsStopped as r, JUNIOR_PERSONALITY as rt, eventReviewItemInputs as s, automationResultSchema as st, getConversationStoppedAtMs as t, saveUserCustomization as tt, getActiveConversationTurnId as u, postsRunNotices as ut, turnInputFactsFromConversationMessage as v, eventBatchMessageMeta as w, conversationSubtreeColumns as x, legacyWebMailboxMetadataSchema as y, renderTaskInput as z };
2968
+ export { withoutSavedSteeringMessages as $, requireSlackChannelMessageScope as A, maybePostAutomatedTurnLimitNotice as B, enqueueEventNotification as C, timerWatchCredentialSubject as D, renderEventBatchInputs as E, WORKSPACE_SNAPSHOT_FAILED_EVENT as F, admitAutomatedTurn as G, resolveSlackReplyTarget as H, WORKSPACE_SNAPSHOT_READY_EVENT as I, assemblePrompt as J, recordFinishedTurnForAutomatedLimit as K, workspaceSnapshotFinishedEvent as L, slackChannelMessageReplyThreadTs as M, slackChannelMessageRunsAutomation as N, getEventCatalog as O, slackChannelMessageTrigger as P, loadPromptTurnContext as Q, workspaceSnapshotWatch as R, EVENT_WAIT_MS as S, isEventMailboxMetadata as T, sendSlackReply as U, postAutomatedTurnLimitNoticeForConversation as V, renderSlackObjectCard as W, buildSteeringPiMessage as X, buildPromptInput as Y, instructionForInputs as Z, sourceFromTurnInput as _, session_stop_exports as a, addConversationNote as at, conversationSubtree as b, loadReviewItemInput as c, readBlockedReport as ct, getAuthPausedConversationTurnId as d, deliversFinalText as dt, readUserCustomization as et, getEventBatchDelayMs as f, finishedRunReply as ft, resolveMailboxTurnWork as g, runDispatchOutcome as gt, parseWebMessages as h, remindMissingAutomationResult as ht, resumeStoppedConversationTree as i, setExperimentalFeatures as it, slackChannelMessageEvent as j, SLACK_EVENT_NAMESPACE as k, savedInputInstruction as l, FINISH_AUTOMATION_RUN_TOOL_NAME as lt, parseEventMessages as m, readAutomationResult as mt, isWatchEvent as n, getExperimentalFeatures as nt, skipInputAfterConversationStop as o, JUNIOR_PERSONALITY as ot, listActiveMailboxTurns as p, postsRunNotices as pt, resetAutomatedTurnLimit as q, markConversationsStopped as r, isExperimentalFeatureEnabled as rt, eventReviewItemInputs as s, REPORT_BLOCKED_TOOL_NAME as st, getConversationStoppedAtMs as t, saveUserCustomization as tt, getActiveConversationTurnId as u, automationResultSchema as ut, turnInputFactsFromConversationMessage as v, eventBatchMessageMeta as w, conversationSubtreeColumns as x, legacyWebMailboxMetadataSchema as y, renderTaskInput as z };
@@ -1,7 +1,7 @@
1
1
  import { v as __exportAll } from "./sentry-BRTJqumy.js";
2
- import { h as logWarn } from "./logging-CMFhLLj4.js";
2
+ import { h as logWarn } from "./logging-DbD-dErY.js";
3
3
  import { s as skillRoots } from "./package-discovery-DJhGdS4c.js";
4
- import { n as pluginCatalogRuntime } from "./catalog-runtime-Bym8GVdh.js";
4
+ import { n as pluginCatalogRuntime } from "./catalog-runtime-B3gfH58M.js";
5
5
  import path from "node:path";
6
6
  import * as z from "zod";
7
7
  import fs from "node:fs/promises";
@@ -0,0 +1,79 @@
1
+ import { v as __exportAll } from "./sentry-BRTJqumy.js";
2
+ import { n as botConfig } from "./config-CLJcyYEF.js";
3
+ import { o as getDb, x as conversationKindFromRow } from "./db-Co7DTYYh.js";
4
+ import { A as juniorConversations } from "./executor-m0kIN71Q.js";
5
+ import { $t as actorFromRun, Ht as AgentDepthLimitError, en as toolInvocationDestination } from "./agent-runner-9MXyWUL8.js";
6
+ import { n as createAndEnqueueAgentInvocation } from "./work-DI7x1Slm.js";
7
+ import { desc, eq, sql } from "drizzle-orm";
8
+ // src/chat/conversations/lineage.ts
9
+ /**
10
+ * Read the parent chain of a Conversation in one query, root first, with the
11
+ * Conversation last. Returns an empty list when the Conversation is missing.
12
+ *
13
+ * The chain stops at a parent that is missing or that is already in the
14
+ * chain. Then the first entry still has a `parentConversationId`, so callers
15
+ * can tell a broken chain from one that ends at a root.
16
+ */
17
+ async function readConversationLineage(conversationId) {
18
+ const lineage = sql`(
19
+ with recursive lineage(conversation_id, parent_conversation_id, depth, path) as (
20
+ select selected.conversation_id, selected.parent_conversation_id, 0, array[selected.conversation_id]
21
+ from junior_conversations selected
22
+ where selected.conversation_id = ${conversationId}
23
+ union all
24
+ select parent.conversation_id, parent.parent_conversation_id, lineage.depth + 1, lineage.path || parent.conversation_id
25
+ from junior_conversations parent
26
+ join lineage on parent.conversation_id = lineage.parent_conversation_id
27
+ where parent.conversation_id <> all(lineage.path)
28
+ )
29
+ select conversation_id, depth from lineage
30
+ ) conversation_lineage`;
31
+ return (await getDb().select({
32
+ conversationId: juniorConversations.conversationId,
33
+ kind: juniorConversations.kind,
34
+ parentConversationId: juniorConversations.parentConversationId
35
+ }).from(juniorConversations).innerJoin(lineage, eq(sql`conversation_lineage.conversation_id`, juniorConversations.conversationId)).orderBy(desc(sql`conversation_lineage.depth`))).map((row) => ({
36
+ conversationId: row.conversationId,
37
+ kind: conversationKindFromRow(row),
38
+ ...row.parentConversationId ? { parentConversationId: row.parentConversationId } : void 0
39
+ }));
40
+ }
41
+ // src/chat/agent-invocations/spawn.ts
42
+ var spawn_exports = /* @__PURE__ */ __exportAll({ bindSpawnAgent: () => bindSpawnAgent });
43
+ /**
44
+ * Count the parents of the Conversation that starts a child agent. A chain
45
+ * that does not end at a root, such as a cycle, cannot start one.
46
+ */
47
+ async function assertCanStartChildAgent(conversationId, maxAgentDepth) {
48
+ const lineage = await readConversationLineage(conversationId);
49
+ const root = lineage[0];
50
+ if (!root || root.parentConversationId || lineage.length - 1 > maxAgentDepth) throw new AgentDepthLimitError(maxAgentDepth);
51
+ }
52
+ /** Bind a Run's Actor and credentials to new Agent invocations. */
53
+ function bindSpawnAgent(run, options) {
54
+ const actor = actorFromRun(run);
55
+ if (!actor) return;
56
+ return async (input, call) => {
57
+ call.signal?.throwIfAborted();
58
+ await assertCanStartChildAgent(run.conversationId, options.maxAgentDepth ?? botConfig.maxAgentDepth);
59
+ const queue = typeof options.queue === "function" ? options.queue() : options.queue;
60
+ return { childConversationId: (await createAndEnqueueAgentInvocation({
61
+ actor,
62
+ ...input.name ? { agentName: input.name } : void 0,
63
+ ...input.agentType ? { agentType: input.agentType } : void 0,
64
+ ...run.credentialContext ? { credentialContext: run.credentialContext } : void 0,
65
+ destination: toolInvocationDestination(run),
66
+ idempotencyKey: `${run.turnId}:${call.toolCallId}`,
67
+ input: input.task,
68
+ ...input.kind ? { kind: input.kind } : void 0,
69
+ parentConversationId: run.conversationId,
70
+ parentToolCallId: call.toolCallId,
71
+ ...input.reasoningLevel ? { reasoningLevel: input.reasoningLevel } : void 0,
72
+ ...input.title ? { title: input.title } : void 0
73
+ }, {
74
+ ...options,
75
+ queue
76
+ })).childConversationId };
77
+ };
78
+ }
79
+ export { spawn_exports as n, readConversationLineage as r, bindSpawnAgent as t };