@sentry/junior 0.310.0 → 0.312.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 (157) hide show
  1. package/dist/{adapter-context-BhKpjpGD.js → adapter-context-BRjEWRy1.js} +2 -2
  2. package/dist/adapter-iIq7ihf7.js +259 -0
  3. package/dist/{admin-tgZEZAk2.js → admin-DhInw5K9.js} +1 -2
  4. package/dist/{agent-runner-D9cvNlQl.js → agent-runner-C9iDurwX.js} +6507 -7721
  5. package/dist/api/schema.d.ts +2 -2
  6. package/dist/api/schema.js +7 -6
  7. package/dist/api.d.ts +21 -3
  8. package/dist/api.js +1625 -535
  9. package/dist/{app-B_7Wn0en.d.ts → app-DRFrC8Mw.d.ts} +14 -10
  10. package/dist/app.d.ts +2 -2
  11. package/dist/app.js +454 -994
  12. package/dist/{background-compaction-queue-BGHqkhkY.js → background-compaction-queue-DrKi7w3d.js} +10 -85
  13. package/dist/callback-mFlTUWWx.js +75 -0
  14. package/dist/{catalog-runtime-BxwzbLKY.js → catalog-runtime-D7xapBAX.js} +1 -1
  15. package/dist/channel-access-CJGfNTdn.js +221 -0
  16. package/dist/child-message-DcsritGf.js +179 -0
  17. package/dist/cli/chat.js +18 -19
  18. package/dist/cli/check.js +23 -29
  19. package/dist/cli/init.js +1 -7
  20. package/dist/cli/main.js +3 -7
  21. package/dist/cli/plugins.js +8 -7
  22. package/dist/cli/run.d.ts +1 -2
  23. package/dist/cli/run.js +1 -2
  24. package/dist/cli/snapshot-create.js +5 -5
  25. package/dist/cli/upgrade.d.ts +1 -1
  26. package/dist/cli/upgrade.js +3 -3
  27. package/dist/{config-Dkt2Le2b.js → config-kXB2Y5tl.js} +294 -28
  28. package/dist/{continue-in-slack-BWVwePKD.js → continue-in-slack-O6pV5004.js} +7 -7
  29. package/dist/{conversation-feed-Ci6YD1N-.js → conversation-feed-uNOv_x68.js} +87 -24
  30. package/dist/{conversation-privacy-C39g8BY4.js → conversation-privacy-L4ja1_W6.js} +1 -1
  31. package/dist/{conversation-turn-CBlZIH02.js → conversation-turn-CeLbHqdw.js} +56 -49
  32. package/dist/{credential-sync-vGnrB0BY.js → credential-sync-I8VBGk05.js} +16 -16
  33. package/dist/{projection-jZSlEAXG.js → credentialed-Cb6E2phL.js} +16268 -16821
  34. package/dist/{db-B4Hjxr-u.d.ts → db-BbC5stfa.d.ts} +13 -6
  35. package/dist/{db-CFZggNoy.js → db-LAyyX8tk.js} +1698 -1046
  36. package/dist/{executor-BPkZDx5-.js → executor-SCub-fAq.js} +552 -181
  37. package/dist/{html-2r2KmLwi.js → html-BCZ3Xtb_.js} +6 -6
  38. package/dist/{session-stop-BfY4rhJs.js → ingest-BDf3D50j.js} +2134 -2553
  39. package/dist/{install-C-oE6C_u.js → install-DCFJFkC0.js} +2 -2
  40. package/dist/instrumentation.js +4 -4
  41. package/dist/{lineage-CsvrEFQe.js → lineage-B_m-4TJw.js} +2 -2
  42. package/dist/{stop-DYzjRf2U.js → list-CN2QA2R9.js} +1656 -685
  43. package/dist/{logging-D5gkyvnK.js → logging-dQ9ZRGQ8.js} +47 -9
  44. package/dist/media-CYm1QD8T.js +2356 -0
  45. package/dist/{message-DwvJ-I3w.js → message-DSXGj1hM.js} +19 -29
  46. package/dist/{model-input-MAq2881y.js → model-input--TrP9hYV.js} +3 -3
  47. package/dist/nitro.d.ts +1 -1
  48. package/dist/nitro.js +4 -3
  49. package/dist/{oauth-callback-server-DIF6Li06.js → oauth-callback-server-DHCZC6B4.js} +2 -2
  50. package/dist/{oauth-relay-DPE-wrwO.js → oauth-relay-pPMGnDZt.js} +1 -1
  51. package/dist/{registry-BBkWFCl8.js → registry-CZOzddwu.js} +5 -8
  52. package/dist/{resolve-B38MkHXE.js → resolve-cKOQ14Dh.js} +3 -3
  53. package/dist/{result-BaqSZcJb.js → result-DcvEOe1r.js} +119 -93
  54. package/dist/result-event-type-BdIJuZxg.js +48 -0
  55. package/dist/rule-DAxQY-1h.js +20 -0
  56. package/dist/{runner-11h8PrHh.js → runner-DBfUW44l.js} +14 -16
  57. package/dist/{sandbox-egress-signals-CTcACAtJ.js → sandbox-egress-signals-BVF_xAm1.js} +1 -1
  58. package/dist/{schema-DriSvB40.d.ts → schema-BEHKxr4I.d.ts} +861 -298
  59. package/dist/{schema-obw5jvR4.js → schema-Bk9Nm2E8.js} +344 -153
  60. package/dist/{service-account-Bx93N1n1.js → service-account-CVYsFjty.js} +3 -3
  61. package/dist/{service-account-Zc5bUcIJ.js → service-account-Ts4ulcrV.js} +68 -68
  62. package/dist/{skills-C8Npu5zO.js → skills-VTnhAJWm.js} +2 -2
  63. package/dist/{slack-conversation-unfurl-DlRVA02H.js → slack-conversation-unfurl-fuLnF1jE.js} +9 -11
  64. package/dist/{spawn-CXr58R0x.js → spawn-vxAarlX5.js} +6 -6
  65. package/dist/start-conversation-CEn2KH1A.js +941 -0
  66. package/dist/{state-CGrGVeQC.js → state-C1P3_Ywk.js} +4 -4
  67. package/dist/statuses-_cRJHXK7.js +150 -0
  68. package/dist/store-DFZaN-Ix.js +492 -0
  69. package/dist/task-queue-Cx4Lmjyk.js +90 -0
  70. package/dist/task-runner-CbTwFA6k.js +1432 -0
  71. package/dist/{thread-context-Dyj1KWaY.js → thread-context-BkAZDTX2.js} +13 -11
  72. package/dist/thread-state-DhPndWi1.js +5625 -0
  73. package/dist/{validation-DxVNIxA0.js → validation-nIzMtAVJ.js} +1 -1
  74. package/dist/{task-queue-CaZffYaH.js → vercel-queue-hW90XzbG.js} +93 -172
  75. package/dist/{version-Cr7Z71yG.js → version-Brbtz4Qf.js} +1 -1
  76. package/dist/version.js +1 -1
  77. package/dist/{warmup-C6LOZ2d2.js → warmup-BDA5myRK.js} +5832 -4567
  78. package/dist/web-message-id-C6P83ans.js +10 -0
  79. package/dist/{worker-CUBtu1Li.js → worker-D63RcaVD.js} +20 -8
  80. package/migrations/0126_artifact_drop_public.sql +8 -0
  81. package/migrations/0127_artifact_path.sql +4 -0
  82. package/migrations/0128_artifact_path_index.sql +1 -0
  83. package/migrations/0129_review_item_answered_index.sql +1 -0
  84. package/migrations/0130_review_item_status_index.sql +1 -0
  85. package/migrations/0131_brief_outcome_status.sql +1 -0
  86. package/migrations/0132_brief_outcome_status_backfill.sql +7 -0
  87. package/migrations/0133_brief_created_at_index.sql +1 -0
  88. package/migrations/0134_slack_person_search_index.sql +1 -0
  89. package/migrations/0135_code_change_size.sql +3 -0
  90. package/migrations/0136_merge_conflict_notice_dismiss.sql +16 -0
  91. package/migrations/0137_inbox_snoozes.sql +27 -0
  92. package/migrations/0138_code_change_search_index.sql +2 -0
  93. package/migrations/0139_review_item_owner.sql +22 -0
  94. package/migrations/0140_review_item_owner_index.sql +1 -0
  95. package/migrations/0141_memory_core_adoption.sql +89 -0
  96. package/migrations/0142_memory_core_indexes.sql +17 -0
  97. package/migrations/0143_todos.sql +14 -0
  98. package/migrations/0144_inbox_items.sql +32 -0
  99. package/migrations/0145_todo_changed_by_agent.sql +1 -0
  100. package/migrations/0146_inbox_item_subject_title_parts.sql +1 -0
  101. package/migrations/0147_inbox_snooze_wake_reason.sql +1 -0
  102. package/migrations/0148_authorization_request_index.sql +1 -0
  103. package/migrations/0149_conversation_metadata.sql +10 -0
  104. package/migrations/0150_conversation_metadata_fill.sql +39 -0
  105. package/migrations/0151_conversation_search_index.sql +1 -0
  106. package/migrations/0152_inbox_item_legacy_automation_keys.sql +21 -0
  107. package/migrations/0153_artifact_expiry.sql +1 -0
  108. package/migrations/0154_artifact_permanent_sha_index.sql +1 -0
  109. package/migrations/0155_artifact_drop_public_sha_index.sql +3 -0
  110. package/migrations/0156_conversation_kind_lead.sql +6 -0
  111. package/migrations/0157_conversation_lead_actor_index.sql +1 -0
  112. package/migrations/meta/0126_snapshot.json +5488 -0
  113. package/migrations/meta/0127_snapshot.json +5519 -0
  114. package/migrations/meta/0128_snapshot.json +5519 -0
  115. package/migrations/meta/0129_snapshot.json +5547 -0
  116. package/migrations/meta/0130_snapshot.json +5563 -0
  117. package/migrations/meta/0131_snapshot.json +5569 -0
  118. package/migrations/meta/0132_snapshot.json +5569 -0
  119. package/migrations/meta/0133_snapshot.json +5590 -0
  120. package/migrations/meta/0134_snapshot.json +5606 -0
  121. package/migrations/meta/0135_snapshot.json +5624 -0
  122. package/migrations/meta/0136_snapshot.json +5624 -0
  123. package/migrations/meta/0137_snapshot.json +5864 -0
  124. package/migrations/meta/0138_snapshot.json +5894 -0
  125. package/migrations/meta/0139_snapshot.json +5898 -0
  126. package/migrations/meta/0140_snapshot.json +5919 -0
  127. package/migrations/meta/0141_snapshot.json +6429 -0
  128. package/migrations/meta/0142_snapshot.json +6457 -0
  129. package/migrations/meta/0143_snapshot.json +6434 -0
  130. package/migrations/meta/0144_snapshot.json +6434 -0
  131. package/migrations/meta/0145_snapshot.json +6440 -0
  132. package/migrations/meta/0146_snapshot.json +6446 -0
  133. package/migrations/meta/0147_snapshot.json +6452 -0
  134. package/migrations/meta/0148_snapshot.json +6474 -0
  135. package/migrations/meta/0149_snapshot.json +6490 -0
  136. package/migrations/meta/0150_snapshot.json +6490 -0
  137. package/migrations/meta/0151_snapshot.json +6505 -0
  138. package/migrations/meta/0152_snapshot.json +6505 -0
  139. package/migrations/meta/0153_snapshot.json +6511 -0
  140. package/migrations/meta/0154_snapshot.json +6533 -0
  141. package/migrations/meta/0155_snapshot.json +6511 -0
  142. package/migrations/meta/0156_snapshot.json +6511 -0
  143. package/migrations/meta/0157_snapshot.json +6527 -0
  144. package/migrations/meta/_journal.json +224 -0
  145. package/package.json +7 -8
  146. package/skills/design-automation-skill/SKILL.md +108 -0
  147. package/dist/briefs-DKxkoruh.js +0 -395
  148. package/dist/conversation-M9KZ5JxF.js +0 -1024
  149. package/dist/prompt-CaMyeCpA.js +0 -910
  150. package/dist/schedule-DWxZ3kja.js +0 -1146
  151. package/dist/store-D4FQ1Nml.js +0 -335
  152. package/dist/task-runner-Dm7BHbGp.js +0 -287
  153. package/dist/turn-session-routing-CD0BRCex.js +0 -263
  154. package/dist/turn-user-message-9IxeEv5v.js +0 -364
  155. package/dist/users-CaUAYMb3.js +0 -181
  156. package/dist/viewer-AHldghAD.js +0 -212
  157. package/dist/web-message-id-BT8Mg8LL.js +0 -418
@@ -1,12 +1,11 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-BKpuH2hG.js";
2
- import { F as actorFromRun, I as toolInvocationDestination } from "./agent-runner-D9cvNlQl.js";
3
- import { Cn as AgentMessageTargetError, En as PARENT_AGENT_TARGET, Sn as AgentMessagePausedError, Vt as getActiveAgentInvocationForConversation, Wt as getLatestAgentInvocationForConversation, dn as enqueueAgentInvocation, en as readChildConversationSender, wn as findChildAgentConversationId, yn as createAgentInvocationForMessage } from "./warmup-C6LOZ2d2.js";
4
- import { a as enqueueAgentMessageToParent } from "./result-BaqSZcJb.js";
5
- import { Xa as readConversationAccessFromSql, qa as canAccessConversation } from "./projection-jZSlEAXG.js";
6
- import { J as renderUntrustedTag, n as botConfig } from "./config-Dkt2Le2b.js";
7
- import { F as SYSTEM_IDENTITY_ID, a as getConversationStore, o as getDb } from "./db-CFZggNoy.js";
8
- import { F as EVENT_WAIT_MS, et as postAutomatedTurnLimitNoticeForConversation, st as admitAutomatedTurn } from "./session-stop-BfY4rhJs.js";
9
- import { r as appendAndEnqueueInboundMessage } from "./store-D4FQ1Nml.js";
2
+ import { A as actorFromRun, j as toolInvocationDestination } from "./agent-runner-C9iDurwX.js";
3
+ import { $t as createAgentInvocationForMessage, Et as getActiveAgentInvocationForConversation, Zt as enqueueAgentInvocation, an as PARENT_AGENT_TARGET, kt as getLatestAgentInvocationForConversation, nn as AgentMessageTargetError, rn as findChildAgentConversationId, zt as readChildConversationSender } from "./warmup-BDA5myRK.js";
4
+ import { a as enqueueAgentMessageToParent } from "./result-DcvEOe1r.js";
5
+ import { Qt as SYSTEM_IDENTITY_ID, a as getConversationStore, mn as canAccessConversation, o as getDb, yn as readConversationAccessFromSql } from "./db-LAyyX8tk.js";
6
+ import { E as enqueueAutomatedInput, p as EVENT_WAIT_MS } from "./ingest-BDf3D50j.js";
7
+ import { it as renderUntrustedTag } from "./config-kXB2Y5tl.js";
8
+ import { i as leadPersonParticipates } from "./start-conversation-CEn2KH1A.js";
10
9
  // src/chat/agent-invocations/top-level-message.ts
11
10
  const AGENT_MESSAGE_EVENT_NAMESPACE = "junior";
12
11
  /** Event type of a message from another top-level agent. */
@@ -15,7 +14,9 @@ const TOP_LEVEL_AGENT_MESSAGE_EVENT_TYPE = "agent.top_level_message";
15
14
  * Check that a top-level agent can message another top-level agent under
16
15
  * `policies/conversation-access.md`. Public agents can message each other.
17
16
  * A private agent can message only agents at its own Destination, such as
18
- * another thread in the same private Slack channel.
17
+ * another thread in the same private Slack channel. A Lead can also message
18
+ * a public root where its person is a Participant, so it can steer the
19
+ * person's work.
19
20
  * Every target that the sender cannot reach gets the same error, so the
20
21
  * error does not show that a private Conversation exists.
21
22
  */
@@ -33,7 +34,10 @@ async function requireTopLevelAgentAccess(args) {
33
34
  requester: sender,
34
35
  target: receiver
35
36
  })) throw notReachable;
36
- if (receiver.visibility === "public" && sender.visibility !== "public") throw new AgentMessageTargetError(`"${args.to}" is a public conversation and this conversation is private. A private conversation can message only conversations in its own channel or DM`);
37
+ if (receiver.visibility === "public" && sender.visibility !== "public" && !await leadPersonParticipates({
38
+ leadConversationId: args.senderConversationId,
39
+ rootConversationId: args.to
40
+ })) throw new AgentMessageTargetError(`"${args.to}" is a public conversation and this conversation is private. A private conversation can message only conversations in its own channel or DM`);
37
41
  }
38
42
  function renderTopLevelMessageInput(args) {
39
43
  return renderUntrustedTag("agent-message", {
@@ -43,28 +47,14 @@ function renderTopLevelMessageInput(args) {
43
47
  }
44
48
  /**
45
49
  * Send one message from a top-level agent to another top-level agent and
46
- * wake the target. The access check runs on each call. A paused target
47
- * (automated-turn limit) takes no message, so two agents cannot keep each
48
- * other running. Repeat calls with the same `messageKey` are safe.
50
+ * wake the target. The access check runs on each call. A stopped target
51
+ * holds the message, so once the automated-turn limit stops one of two
52
+ * agents, they cannot keep each other running. Repeat calls with the same
53
+ * `messageKey` are safe.
49
54
  */
50
55
  async function enqueueTopLevelAgentMessage(args) {
51
56
  await requireTopLevelAgentAccess(args);
52
57
  const nowMs = args.nowMs ?? Date.now();
53
- const maxTurns = botConfig.maxConsecutiveAutomatedTurns;
54
- const decision = await admitAutomatedTurn({
55
- conversationId: args.to,
56
- maxTurns,
57
- nowMs,
58
- state: args.state
59
- });
60
- if (decision.status === "paused") {
61
- if (decision.shouldPostNotice) await postAutomatedTurnLimitNoticeForConversation({
62
- conversationId: args.to,
63
- maxTurns,
64
- nowMs
65
- });
66
- throw new AgentMessagePausedError(args.to);
67
- }
68
58
  const inboundMessageId = `agent-message:${args.senderConversationId}:${args.messageKey}`;
69
59
  const summary = `Top-level agent ${args.senderConversationId} sent a message.`;
70
60
  const metadata = {
@@ -77,7 +67,7 @@ async function enqueueTopLevelAgentMessage(args) {
77
67
  trustedSummary: summary
78
68
  }
79
69
  };
80
- await appendAndEnqueueInboundMessage({
70
+ await enqueueAutomatedInput({
81
71
  message: {
82
72
  conversationId: args.to,
83
73
  createdAtMs: nowMs,
@@ -1,7 +1,7 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-BKpuH2hG.js";
2
- import { s as getSqlExecutor } from "./db-CFZggNoy.js";
3
- import { h as isVisionImageMediaType, m as detectImageMediaType } from "./web-message-id-BT8Mg8LL.js";
4
- import { Co as readLiveAttachment } from "./projection-jZSlEAXG.js";
2
+ import { s as getSqlExecutor } from "./db-LAyyX8tk.js";
3
+ import { i as isVisionImageMediaType, r as detectImageMediaType } from "./media-CYm1QD8T.js";
4
+ import { i as readLiveAttachment } from "./store-DFZaN-Ix.js";
5
5
  import { escapeTagText, renderTag } from "@sentry/junior-plugin-api";
6
6
  // src/chat/attachments/model-input.ts
7
7
  var model_input_exports = /* @__PURE__ */ __exportAll({ loadInputAttachments: () => loadInputAttachments });
package/dist/nitro.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { n as JuniorPluginSet } from "./plugins-fBrz8PCV.js";
2
- import { i as JuniorDashboardOptions } from "./app-B_7Wn0en.js";
2
+ import { i as JuniorDashboardOptions } from "./app-DRFrC8Mw.js";
3
3
  import { withSentryConfig as withSentryConfig$1 } from "@sentry/nitro";
4
4
  type SentryNitroConfig = Parameters<typeof withSentryConfig$1>[0];
5
5
  type SentryNitroOptions = NonNullable<Parameters<typeof withSentryConfig$1>[1]>;
package/dist/nitro.js CHANGED
@@ -1,8 +1,9 @@
1
1
  import { d as resolvePackageDir, t as discoverInstalledPluginPackageContent, u as isValidPackageName } from "./package-discovery-DD9vencX.js";
2
2
  import { a as pluginRuntimeRegistrationsFromPluginSet, r as pluginCatalogConfigFromPluginSet } from "./plugins-Bkk0XRo2.js";
3
- import { a as CACHE_WARMUP_QUEUE_TOPIC, h as resolveConversationWorkQueueTopic, t as BACKGROUND_COMPACTION_QUEUE_TOPIC, u as WORKSPACE_SNAPSHOT_JOB_QUEUE_TOPIC } from "./background-compaction-queue-BGHqkhkY.js";
4
- import { t as PLUGIN_TASK_QUEUE_TOPIC } from "./task-queue-CaZffYaH.js";
5
- import { A as JUNIOR_CONTEXT_COMPACTION_CALLBACK_ROUTE, B as getDeploymentServiceVersion, D as JUNIOR_AUTO_ARCHIVE_CRON_SCHEDULE, F as JUNIOR_RETENTION_CRON_SCHEDULE, I as JUNIOR_RETENTION_ROUTE, L as JUNIOR_WORKSPACE_SNAPSHOT_JOB_CALLBACK_ROUTE, M as JUNIOR_HEARTBEAT_CRON_SCHEDULE, N as JUNIOR_HEARTBEAT_ROUTE, O as JUNIOR_AUTO_ARCHIVE_ROUTE, P as JUNIOR_PLUGIN_TASK_CALLBACK_ROUTE, j as JUNIOR_CONVERSATION_WORK_CALLBACK_ROUTE, k as JUNIOR_CACHE_WARMUP_CALLBACK_ROUTE } from "./logging-D5gkyvnK.js";
3
+ import { a as CACHE_WARMUP_QUEUE_TOPIC, t as BACKGROUND_COMPACTION_QUEUE_TOPIC, u as WORKSPACE_SNAPSHOT_JOB_QUEUE_TOPIC } from "./background-compaction-queue-DrKi7w3d.js";
4
+ import { t as PLUGIN_TASK_QUEUE_TOPIC } from "./task-queue-Cx4Lmjyk.js";
5
+ import { n as resolveConversationWorkQueueTopic } from "./vercel-queue-hW90XzbG.js";
6
+ import { A as JUNIOR_CONTEXT_COMPACTION_CALLBACK_ROUTE, B as getDeploymentServiceVersion, D as JUNIOR_AUTO_ARCHIVE_CRON_SCHEDULE, F as JUNIOR_RETENTION_CRON_SCHEDULE, I as JUNIOR_RETENTION_ROUTE, L as JUNIOR_WORKSPACE_SNAPSHOT_JOB_CALLBACK_ROUTE, M as JUNIOR_HEARTBEAT_CRON_SCHEDULE, N as JUNIOR_HEARTBEAT_ROUTE, O as JUNIOR_AUTO_ARCHIVE_ROUTE, P as JUNIOR_PLUGIN_TASK_CALLBACK_ROUTE, j as JUNIOR_CONVERSATION_WORK_CALLBACK_ROUTE, k as JUNIOR_CACHE_WARMUP_CALLBACK_ROUTE } from "./logging-dQ9ZRGQ8.js";
6
7
  import { n as loadPluginSetFromModule, r as resolvePluginModule } from "./plugin-module-Cv2ETe8Y.js";
7
8
  import path from "node:path";
8
9
  import { cpSync, existsSync, mkdirSync, readdirSync, statSync } from "node:fs";
@@ -1,5 +1,5 @@
1
- import { a as GET, n as syncLocalOAuthCredential, r as GET$1 } from "./credential-sync-vGnrB0BY.js";
2
- import { Sn as createUserTokenStore } from "./projection-jZSlEAXG.js";
1
+ import { a as GET, n as syncLocalOAuthCredential, r as GET$1 } from "./credential-sync-I8VBGk05.js";
2
+ import { r as createUserTokenStore } from "./credentialed-Cb6E2phL.js";
3
3
  import { createServer } from "node:http";
4
4
  // src/chat/local/oauth-callback-server.ts
5
5
  const LOCAL_OAUTH_TIMEOUT_MS = 6e5;
@@ -1,5 +1,5 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-BKpuH2hG.js";
2
- import { d as readJuniorSecret } from "./task-queue-CaZffYaH.js";
2
+ import { f as readJuniorSecret } from "./vercel-queue-hW90XzbG.js";
3
3
  import * as z from "zod";
4
4
  import { randomBytes } from "node:crypto";
5
5
  import { SignJWT, jwtVerify } from "jose";
@@ -1,5 +1,5 @@
1
1
  import { n as normalizePluginPackageNames, o as pluginRoots, t as discoverInstalledPluginPackageContent } from "./package-discovery-DD9vencX.js";
2
- import { b as setSpanAttributes, h as logWarn, m as logInfo } from "./logging-D5gkyvnK.js";
2
+ import { b as setSpanAttributes, h as logWarn, m as logInfo } from "./logging-dQ9ZRGQ8.js";
3
3
  import { o as isUserActor, s as parseActorUserId } from "./actor-BsBdxDXQ.js";
4
4
  import * as z from "zod";
5
5
  import path from "node:path";
@@ -10,9 +10,6 @@ import { readFileSync, readdirSync, statSync } from "node:fs";
10
10
  function setDefined$1(target, key, value) {
11
11
  if (value !== void 0) target[key] = value;
12
12
  }
13
- function isRecord(value) {
14
- return Boolean(value && typeof value === "object" && !Array.isArray(value));
15
- }
16
13
  function unqualifyManifestToken(name, value) {
17
14
  if (typeof name === "string" && typeof value === "string" && value.startsWith(`${name}.`)) return value.slice(name.length + 1);
18
15
  return value;
@@ -22,7 +19,7 @@ function inlineTokenListSource(name, values) {
22
19
  return values.map((value) => unqualifyManifestToken(name, value));
23
20
  }
24
21
  function inlineCredentialsSource(credentials) {
25
- if (credentials === void 0 || !isRecord(credentials)) return credentials;
22
+ if (typeof credentials !== "object" || credentials === null || Array.isArray(credentials)) return credentials;
26
23
  const result = {};
27
24
  setDefined$1(result, "type", credentials.type);
28
25
  setDefined$1(result, "domains", credentials.domains);
@@ -57,7 +54,7 @@ function accountsSource(accounts) {
57
54
  return result;
58
55
  }
59
56
  function inlineMcpSource(mcp) {
60
- if (mcp === void 0 || !isRecord(mcp)) return mcp;
57
+ if (typeof mcp !== "object" || mcp === null || Array.isArray(mcp)) return mcp;
61
58
  const result = {};
62
59
  setDefined$1(result, "transport", mcp.transport);
63
60
  setDefined$1(result, "url", mcp.url);
@@ -69,7 +66,7 @@ function inlineMcpSource(mcp) {
69
66
  return result;
70
67
  }
71
68
  function inlineOauthSource(oauth) {
72
- if (oauth === void 0 || !isRecord(oauth)) return oauth;
69
+ if (typeof oauth !== "object" || oauth === null || Array.isArray(oauth)) return oauth;
73
70
  const result = {};
74
71
  setDefined$1(result, "client-id-env", oauth.clientIdEnv);
75
72
  setDefined$1(result, "client-secret-env", oauth.clientSecretEnv);
@@ -83,7 +80,7 @@ function inlineOauthSource(oauth) {
83
80
  return result;
84
81
  }
85
82
  function inlineTargetSource(name, target) {
86
- if (target === void 0 || !isRecord(target)) return target;
83
+ if (typeof target !== "object" || target === null || Array.isArray(target)) return target;
87
84
  const result = {};
88
85
  setDefined$1(result, "type", target.type);
89
86
  setDefined$1(result, "config-key", unqualifyManifestToken(name, target.configKey));
@@ -1,6 +1,6 @@
1
- import { i as trace, n as postinstall, o as getSandboxResources, t as dependencies } from "./install-C-oE6C_u.js";
2
- import { $i as getSandboxProvider, Fs as sleep, Yi as create, Zi as isStale } from "./projection-jZSlEAXG.js";
3
- import { tt as getStateAdapter } from "./db-CFZggNoy.js";
1
+ import { i as trace, n as postinstall, o as getSandboxResources, t as dependencies } from "./install-DCFJFkC0.js";
2
+ import { Jt as create, Qt as getSandboxProvider, Xt as isStale, zo as sleep } from "./credentialed-Cb6E2phL.js";
3
+ import { i as getStateAdapter } from "./adapter-iIq7ihf7.js";
4
4
  import * as z from "zod";
5
5
  // src/chat/sandbox/snapshot/resolve.ts
6
6
  const SNAPSHOT_CACHE_PREFIX = "junior:sandbox_snapshot_profile:v2";
@@ -1,21 +1,17 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-BKpuH2hG.js";
2
2
  import { t as mapBounded } from "./fan-out-Cod-yEHG.js";
3
- import { A as turnBehavior, F as SYSTEM_IDENTITY_ID, a as getConversationStore } from "./db-CFZggNoy.js";
4
- import { A as parseEventMessages, B as renderEventBatchInputs, D as getEventBatchDelayMs, F as EVENT_WAIT_MS, R as eventBatchMessageMeta, V as timerWatchCredentialSubject, j as resolveMailboxTurnWork, k as listActiveMailboxTurns, s as eventReviewItemInputs, t as getConversationStoppedAtMs } from "./session-stop-BfY4rhJs.js";
5
- import { a as EVENT_SYSTEM_ACTOR } from "./prompt-CaMyeCpA.js";
6
- import { p as credentialContextForActor } from "./registry-BBkWFCl8.js";
7
- import { C as ownAgentInvocation, D as getAgentInvocationIdForEvents, I as getTurnReplyKey, M as getAgentInvocationTurnId, N as getAgentReplyMessageId, O as getAgentInvocationIdForMessage, S as listChildMessages, b as hasAgentInvocationReply, j as getAgentInvocationResultMessageId, k as getAgentInvocationIdForResult, y as childMessageSenderMetadata, z as buildDeterministicTurnId } from "./turn-user-message-9IxeEv5v.js";
8
- import { _ as getConversationWorkState, r as appendAndEnqueueInboundMessage } from "./store-D4FQ1Nml.js";
9
- import { $t as getChildAgentInputSender, Bt as TERMINAL_AGENT_INVOCATION_STATUSES, Gt as isTerminalAgentInvocation, Kt as listAgentInvocationsForConversation, Qt as childAgentInput, Rt as listUnreportedSiblingAgents, Wt as getLatestAgentInvocationForConversation, Xt as reportReplacedWithoutOpenWork, Yt as markAgentInvocationParentMailboxAppended, Zt as sendsResultToParent, an as parentMessageText, bn as createAgentInvocationFromLatest, dn as enqueueAgentInvocation, en as readChildConversationSender, fn as resolveAgentInvocationId, in as logDroppedParentMessage, ln as endActiveAgentInvocations, on as readParentMessage, sn as createAgentInvocationWorker, tn as routeChildInput, un as endAgentInvocationsOfStoppedWork, zt as NON_TERMINAL_AGENT_INVOCATION_STATUSES } from "./warmup-C6LOZ2d2.js";
10
- import { J as renderUntrustedTag } from "./config-Dkt2Le2b.js";
11
- import { C as AGENT_MESSAGE_EVENT_TYPE, E as agentInvocationResultEventType, S as AGENT_INVOCATION_EVENT_NAMESPACE, T as AGENT_REPLY_EVENT_TYPE } from "./web-message-id-BT8Mg8LL.js";
3
+ import { F as turnBehavior, Qt as SYSTEM_IDENTITY_ID, a as getConversationStore, s as getSqlExecutor } from "./db-LAyyX8tk.js";
4
+ import { $ as eventInboxItemInputs, D as getConversationStoppedAtMs, E as enqueueAutomatedInput, _ as timerWatchCredentialSubject, a as getEventBatchDelayMs, c as parseEventMessages, g as renderEventBatchInputs, ht as closeOpenTodosOfChild, l as resolveMailboxTurnWork, m as eventBatchMessageMeta, p as EVENT_WAIT_MS, s as listActiveMailboxTurns } from "./ingest-BDf3D50j.js";
5
+ import { L as buildDeterministicTurnId, w as getConversationWorkState, xt as EVENT_SYSTEM_ACTOR } from "./thread-state-DhPndWi1.js";
6
+ import { p as credentialContextForActor } from "./registry-CZOzddwu.js";
7
+ import { At as isTerminalAgentInvocation, Bt as routeChildInput, Ct as NON_TERMINAL_AGENT_INVOCATION_STATUSES, Ft as reportReplacedWithoutOpenWork, Gt as parentMessageText, It as sendsResultToParent, Kt as readParentMessage, Lt as childAgentInput, Pt as markAgentInvocationParentMailboxAppended, Qt as resolveAgentInvocationId, Rt as getChildAgentInputSender, St as listUnreportedSiblingAgents, Tt as childAgentStillWorks, Wt as logDroppedParentMessage, Xt as endAgentInvocationsOfStoppedWork, Yt as endActiveAgentInvocations, Zt as enqueueAgentInvocation, en as createAgentInvocationFromLatest, jt as listAgentInvocationsForConversation, kt as getLatestAgentInvocationForConversation, qt as createAgentInvocationWorker, wt as TERMINAL_AGENT_INVOCATION_STATUSES, zt as readChildConversationSender } from "./warmup-BDA5myRK.js";
8
+ import { a as ownAgentInvocation, d as getAgentInvocationIdForResult, h as getAgentReplyMessageId, i as listChildMessages, l as getAgentInvocationIdForEvents, m as getAgentInvocationTurnId, n as hasAgentInvocationReply, p as getAgentInvocationResultMessageId, t as childMessageSenderMetadata, u as getAgentInvocationIdForMessage, v as getTurnReplyKey } from "./child-message-DcsritGf.js";
9
+ import { it as renderUntrustedTag } from "./config-kXB2Y5tl.js";
10
+ import { a as agentInvocationResultEventType, i as AGENT_REPLY_EVENT_TYPE, n as AGENT_MESSAGE_EVENT_TYPE, t as AGENT_INVOCATION_EVENT_NAMESPACE } from "./result-event-type-BdIJuZxg.js";
11
+ import * as z from "zod";
12
12
  import { actorSchema } from "@sentry/junior-plugin-api";
13
- // src/chat/agent-invocations/result.ts
14
- var result_exports = /* @__PURE__ */ __exportAll({
15
- createChildConversationWorker: () => createChildConversationWorker,
16
- createDeliverToParent: () => createDeliverToParent
17
- });
18
- const AGENT_INVOCATION_RESULT_MAX_LENGTH = 12e3;
13
+ // src/chat/agent-invocations/result-actors.ts
14
+ const senderActorMetadataSchema = z.object({ actor: actorSchema });
19
15
  /**
20
16
  * Return the Inbound message author id for results sent by one Actor.
21
17
  * `selectContiguousTurnBatch` in `task-execution/worker.ts` puts messages in
@@ -31,6 +27,77 @@ function resultAuthorId(actor) {
31
27
  default: return `agent-invocation:${actor.platform}:${actor.userId}`;
32
28
  }
33
29
  }
30
+ /** Read the Actor that a reply or message from a child without an Agent invocation carries. */
31
+ function senderActorFromMetadata(metadata) {
32
+ const parsed = senderActorMetadataSchema.safeParse(metadata);
33
+ return parsed.success ? parsed.data.actor : void 0;
34
+ }
35
+ /**
36
+ * Run each agent invocation result or message as the Actor that triggered the
37
+ * child, user or system, with its grants. This is on purpose: the result
38
+ * continues that Actor's work. The Actor comes from SQL when an agent
39
+ * invocation names the child, so the parent Turn has the same authority it
40
+ * had at spawn time. Otherwise the input carries it, and so does a parent
41
+ * task to a child.
42
+ * Input that a child's Turn with another Actor sent runs as the Event system
43
+ * Actor, so it never gets more authority than that Turn. A result that a stop
44
+ * skipped is dropped. Returns undefined when no input is left.
45
+ */
46
+ async function withAgentInvocationResultActors(work) {
47
+ if (work.kind !== "mailbox") return work;
48
+ const conversationId = work.batch[0]?.message.conversationId;
49
+ const latest = conversationId ? await getLatestAgentInvocationForConversation(conversationId) : void 0;
50
+ const kept = (await mapBounded(work.batch, async (entry) => {
51
+ const parentMessage = readParentMessage(entry.message);
52
+ if (parentMessage) {
53
+ if (await routeChildInput(entry.message, latest) === "dropped") {
54
+ logDroppedParentMessage(entry.message, parentMessage);
55
+ return;
56
+ }
57
+ const text = await parentMessageText(entry.message, parentMessage);
58
+ return {
59
+ ...entry,
60
+ actor: parentMessage.actor,
61
+ requestText: entry.message.input.text.trim(),
62
+ ...parentMessage.credentialContext ? { credentialContext: parentMessage.credentialContext } : void 0,
63
+ message: {
64
+ ...entry.message,
65
+ input: {
66
+ ...entry.message.input,
67
+ text
68
+ }
69
+ }
70
+ };
71
+ }
72
+ const input = childAgentInput(entry.message);
73
+ if (!input) return entry;
74
+ if (await routeChildInput(entry.message, latest) === "dropped") return;
75
+ const { invocation } = await getChildAgentInputSender(entry.message, input);
76
+ const actor = invocation?.actor ?? senderActorFromMetadata(entry.message.input.metadata);
77
+ if (!actor || entry.message.input.authorId !== resultAuthorId(actor)) return {
78
+ ...entry,
79
+ actor: EVENT_SYSTEM_ACTOR
80
+ };
81
+ return input.kind === "result" && invocation?.credentialContext ? {
82
+ ...entry,
83
+ actor,
84
+ credentialContext: invocation.credentialContext
85
+ } : {
86
+ ...entry,
87
+ actor
88
+ };
89
+ })).filter((entry) => entry !== void 0);
90
+ return kept.length > 0 ? {
91
+ kind: "mailbox",
92
+ batch: kept
93
+ } : void 0;
94
+ }
95
+ // src/chat/agent-invocations/result.ts
96
+ var result_exports = /* @__PURE__ */ __exportAll({
97
+ createChildConversationWorker: () => createChildConversationWorker,
98
+ createDeliverToParent: () => createDeliverToParent
99
+ });
100
+ const AGENT_INVOCATION_RESULT_MAX_LENGTH = 12e3;
34
101
  /**
35
102
  * Error messages can contain text from tools or providers, so the trusted
36
103
  * summary in the mailbox metadata has only the status.
@@ -117,8 +184,8 @@ function buildResultInboundMessage(invocation, nowMs) {
117
184
  * Append one terminal agent invocation result to the parent mailbox and wake
118
185
  * the parent. Repeat calls are safe.
119
186
  *
120
- * Results do not go through `admitAutomatedTurn`, so the automated-turn limit
121
- * never drops them. Result Turns still count toward that limit.
187
+ * A stopped parent holds the result. Result Turns count toward the
188
+ * automated-turn limit.
122
189
  * TODO(dcramer): Add a per-parent total invocation limit as the loop guard
123
190
  * for spawn -> result -> spawn chains (#881).
124
191
  */
@@ -132,7 +199,9 @@ async function enqueueAgentInvocationResult(invocation, options) {
132
199
  if (replaced && isTerminalAgentInvocation(replaced)) await enqueueAgentInvocationResult(replaced, options);
133
200
  return;
134
201
  }
135
- await appendAndEnqueueInboundMessage({
202
+ const resultMessageId = getAgentInvocationResultMessageId(invocation.invocationId);
203
+ if (!parentMessages.some((message) => message.inboundMessageId === resultMessageId)) await closeTodosForResult(invocation, invocation.status, nowMs);
204
+ await enqueueAutomatedInput({
136
205
  message: buildResultInboundMessage(invocation, nowMs),
137
206
  renderText: renderResultUnderLock(invocation, terminalResult(invocation)),
138
207
  queue: options.queue,
@@ -142,6 +211,20 @@ async function enqueueAgentInvocationResult(invocation, options) {
142
211
  await markAgentInvocationParentMailboxAppended(invocation.invocationId, nowMs);
143
212
  }
144
213
  /**
214
+ * Close the child's open To-dos of the parent before the parent reads the
215
+ * child's result: done when it completed, dropped when it stopped. A
216
+ * blocked or failed child did not finish that work.
217
+ */
218
+ async function closeTodosForResult(sender, status, nowMs) {
219
+ if (status !== "completed" && status !== "stopped") return;
220
+ await closeOpenTodosOfChild(getSqlExecutor(), {
221
+ childConversationId: sender.childConversationId,
222
+ nowMs,
223
+ parentConversationId: sender.parentConversationId,
224
+ status: status === "completed" ? "done" : "dropped"
225
+ });
226
+ }
227
+ /**
145
228
  * Read every child reply and result that reached the parent's mailbox. A
146
229
  * sibling whose `reply` is among them has answered.
147
230
  */
@@ -170,12 +253,6 @@ function senderEventMetadata(sender, actor, event) {
170
253
  actor
171
254
  };
172
255
  }
173
- /** Read the Actor that a reply or message from a child without an Agent invocation carries. */
174
- function senderActorFromMetadata(metadata) {
175
- const actor = metadata?.actor;
176
- const parsed = actorSchema.safeParse(actor);
177
- return parsed.success ? parsed.data : void 0;
178
- }
179
256
  function renderMessageInput(sender, text) {
180
257
  return renderUntrustedTag("agent-message", {
181
258
  conversation_id: sender.childConversationId,
@@ -202,7 +279,7 @@ async function enqueueAgentMessageToParent(args) {
202
279
  namespace: AGENT_INVOCATION_EVENT_NAMESPACE,
203
280
  trustedSummary: summary
204
281
  });
205
- await appendAndEnqueueInboundMessage({
282
+ await enqueueAutomatedInput({
206
283
  message: {
207
284
  conversationId: args.sender.parentConversationId,
208
285
  createdAtMs: nowMs,
@@ -230,7 +307,8 @@ const RESULT_SUMMARIES = {
230
307
  /**
231
308
  * Append the result of one child agent Turn to its parent mailbox and wake
232
309
  * the parent: a `reply`, which the parent reads as a completed
233
- * `<agent-result>`, or a blocked or failed result. `sender` names the child:
310
+ * `<agent-result>` or, while the child still works, as a message, or a
311
+ * blocked or failed result. `sender` names the child:
234
312
  * an agent invocation, open or not, or the child Conversation when none
235
313
  * names it. `actor` is the Actor of the child's Turn; the parent never runs
236
314
  * with more authority than it. The key of the result, the `reply` tool call
@@ -249,22 +327,30 @@ async function enqueueChildResultToParent(args) {
249
327
  output: args.result.text,
250
328
  status: args.result.kind
251
329
  };
252
- const sender = {
330
+ const replyTurn = {
253
331
  ...args.sender.invocationId ? { agentInvocationId: args.sender.invocationId } : void 0,
254
332
  conversationId: args.sender.childConversationId,
255
333
  turnId: args.turnId
256
334
  };
335
+ const stillWorks = args.result.kind === "reply" && await childAgentStillWorks(args.sender.childConversationId, ownAgentInvocation(replyTurn));
336
+ const sender = stillWorks ? {
337
+ conversationId: replyTurn.conversationId,
338
+ turnId: replyTurn.turnId
339
+ } : replyTurn;
340
+ const text = stillWorks ? renderMessageInput(args.sender, rendered.output) : renderResultInput(args.sender, rendered, []);
257
341
  const metadata = {
258
342
  ...senderEventMetadata(args.sender, actor, {
259
343
  eventKey: inboundMessageId,
260
344
  eventType: AGENT_REPLY_EVENT_TYPE,
261
345
  identifier: senderId,
262
346
  namespace: AGENT_INVOCATION_EVENT_NAMESPACE,
263
- trustedSummary: `${childAgentLabel(args.sender)} ${RESULT_SUMMARIES[args.result.kind]}`
347
+ trustedSummary: `${childAgentLabel(args.sender)} ${stillWorks ? "sent a message." : RESULT_SUMMARIES[args.result.kind]}`
264
348
  }),
265
349
  ...childMessageSenderMetadata(sender)
266
350
  };
267
- await appendAndEnqueueInboundMessage({
351
+ const replyingInvocationId = args.result.kind === "reply" ? ownAgentInvocation(sender) : void 0;
352
+ if (replyingInvocationId && !hasAgentInvocationReply(await readParentChildMessages(args.sender.parentConversationId, args.state), replyingInvocationId)) await closeTodosForResult(args.sender, "completed", nowMs);
353
+ await enqueueAutomatedInput({
268
354
  message: {
269
355
  conversationId: args.sender.parentConversationId,
270
356
  createdAtMs: nowMs,
@@ -274,12 +360,12 @@ async function enqueueChildResultToParent(args) {
274
360
  authorId: resultAuthorId(actor),
275
361
  authorIdentityId: SYSTEM_IDENTITY_ID,
276
362
  metadata,
277
- text: renderResultInput(args.sender, rendered, [])
363
+ text
278
364
  },
279
365
  receivedAtMs: nowMs,
280
366
  source: "event"
281
367
  },
282
- renderText: async (parentInboundMessageIds, messageSenders) => !ownAgentInvocation(sender) && await getConversationStoppedAtMs(args.sender.childConversationId) !== void 0 ? void 0 : await renderResultUnderLock(args.sender, rendered)(parentInboundMessageIds, messageSenders),
368
+ renderText: async (parentInboundMessageIds, messageSenders) => !ownAgentInvocation(sender) && await getConversationStoppedAtMs(args.sender.childConversationId) !== void 0 ? void 0 : stillWorks ? text : await renderResultUnderLock(args.sender, rendered)(parentInboundMessageIds, messageSenders),
283
369
  queue: args.queue,
284
370
  queueDelayMs: EVENT_WAIT_MS,
285
371
  state: args.state
@@ -355,8 +441,7 @@ async function startAgentInvocationsForChildInput(context, options) {
355
441
  const messages = context.attempt.messages;
356
442
  const latest = await getLatestAgentInvocationForConversation(context.conversationId);
357
443
  if (messages.length === 0 || !latest) return;
358
- const stoppedAtMs = await getConversationStoppedAtMs(context.conversationId);
359
- const routes = await mapBounded(messages, (message) => routeChildInput(message, latest, stoppedAtMs));
444
+ const routes = await mapBounded(messages, (message) => routeChildInput(message, latest));
360
445
  if (!routes.includes("agent invocation")) return;
361
446
  const inputs = messages.map(childAgentInput);
362
447
  const isAgentInput = messages.every((message, index) => inputs[index] !== void 0 || readParentMessage(message) !== void 0);
@@ -370,7 +455,7 @@ async function startAgentInvocationsForChildInput(context, options) {
370
455
  };
371
456
  const { actor, source } = events[0];
372
457
  const invocation = await createAgentInvocationFromLatest({
373
- input: renderEventBatchInputs(messages, await eventReviewItemInputs(messages)).join("\n\n"),
458
+ input: renderEventBatchInputs(messages, await eventInboxItemInputs(messages)).map((input) => input.text).join("\n\n"),
374
459
  invocationId: getAgentInvocationIdForEvents(messages[0].inboundMessageId),
375
460
  latest,
376
461
  runAs: {
@@ -486,63 +571,4 @@ async function reportParentWithoutOpenWork(conversationId, options) {
486
571
  const replaced = sender ? await reportReplacedWithoutOpenWork(sender.parentConversationId) : void 0;
487
572
  if (replaced && isTerminalAgentInvocation(replaced)) await enqueueAgentInvocationResult(replaced, options);
488
573
  }
489
- /**
490
- * Run each agent invocation result or message as the Actor that triggered the
491
- * child, user or system, with its grants. This is on purpose: the result
492
- * continues that Actor's work. The Actor comes from SQL when an agent
493
- * invocation names the child, so the parent Turn has the same authority it
494
- * had at spawn time. Otherwise the input carries it, and so does a parent
495
- * task to a child.
496
- * Input that a child's Turn with another Actor sent runs as the Event system
497
- * Actor, so it never gets more authority than that Turn. A result that a stop
498
- * skipped is dropped. Returns undefined when no input is left.
499
- */
500
- async function withAgentInvocationResultActors(work) {
501
- if (work.kind !== "mailbox") return work;
502
- const conversationId = work.batch[0]?.message.conversationId;
503
- const [latest, stoppedAtMs] = conversationId ? await Promise.all([getLatestAgentInvocationForConversation(conversationId), getConversationStoppedAtMs(conversationId)]) : [void 0, void 0];
504
- const kept = (await mapBounded(work.batch, async (entry) => {
505
- const parentMessage = readParentMessage(entry.message);
506
- if (parentMessage) {
507
- if (await routeChildInput(entry.message, latest, stoppedAtMs) === "dropped") {
508
- logDroppedParentMessage(entry.message, parentMessage);
509
- return;
510
- }
511
- const text = await parentMessageText(entry.message, parentMessage);
512
- return {
513
- ...entry,
514
- actor: parentMessage.actor,
515
- ...parentMessage.credentialContext ? { credentialContext: parentMessage.credentialContext } : void 0,
516
- message: {
517
- ...entry.message,
518
- input: {
519
- ...entry.message.input,
520
- text
521
- }
522
- }
523
- };
524
- }
525
- const input = childAgentInput(entry.message);
526
- if (!input) return entry;
527
- if (await routeChildInput(entry.message, latest, stoppedAtMs) === "dropped") return;
528
- const { invocation } = await getChildAgentInputSender(entry.message, input);
529
- const actor = invocation?.actor ?? senderActorFromMetadata(entry.message.input.metadata);
530
- if (!actor || entry.message.input.authorId !== resultAuthorId(actor)) return {
531
- ...entry,
532
- actor: EVENT_SYSTEM_ACTOR
533
- };
534
- return input.kind === "result" && invocation?.credentialContext ? {
535
- ...entry,
536
- actor,
537
- credentialContext: invocation.credentialContext
538
- } : {
539
- ...entry,
540
- actor
541
- };
542
- })).filter((entry) => entry !== void 0);
543
- return kept.length > 0 ? {
544
- kind: "mailbox",
545
- batch: kept
546
- } : void 0;
547
- }
548
574
  export { enqueueAgentMessageToParent as a, enqueueAgentInvocationResult as i, createDeliverToParent as n, result_exports as o, createEndStoppedChildWork as r, withAgentInvocationResultActors as s, createChildConversationWorker as t };
@@ -0,0 +1,48 @@
1
+ import * as z from "zod";
2
+ // src/chat/todos/types.ts
3
+ /** Statuses of a To-do. `done` and `dropped` close it. */
4
+ const TODO_STATUSES = [
5
+ "open",
6
+ "in_progress",
7
+ "done",
8
+ "dropped"
9
+ ];
10
+ /** Statuses of a To-do that is still work to do. */
11
+ const OPEN_TODO_STATUSES = ["open", "in_progress"];
12
+ /** Whether a To-do with this status is still work to do. */
13
+ function isOpenTodoStatus(status) {
14
+ return status === "open" || status === "in_progress";
15
+ }
16
+ /** Model-facing tool that changes the To-dos. */
17
+ const UPDATE_TODOS_TOOL_NAME = "updateTodos";
18
+ /** Assignee text for the list's own agent, in tool results and blocks. */
19
+ const SELF_TODO_ASSIGNEE = "self";
20
+ // src/api/schema/user-customization.ts
21
+ /** Longest customization text one user can save. */
22
+ const USER_CUSTOMIZATION_MAX_CHARS = 1e3;
23
+ /** Saved customization text. An empty string means none. */
24
+ const userCustomizationTextSchema = z.string().trim().max(USER_CUSTOMIZATION_MAX_CHARS);
25
+ /** Request and response body for the viewer's customization. */
26
+ const userCustomizationSchema = z.object({ customization: userCustomizationTextSchema }).strict();
27
+ // src/chat/agent-invocations/result-event-type.ts
28
+ /** Event namespace of the messages between a parent and its child agents. */
29
+ const AGENT_INVOCATION_EVENT_NAMESPACE = "junior";
30
+ const AGENT_INVOCATION_RESULT_EVENT_TYPE_PREFIX = "agent_invocation.";
31
+ /** Build the Event type of the parent message for one agent invocation result. */
32
+ function agentInvocationResultEventType(status) {
33
+ return `${AGENT_INVOCATION_RESULT_EVENT_TYPE_PREFIX}${status}`;
34
+ }
35
+ /** True when an Event type names an agent invocation result. */
36
+ function isAgentInvocationResultEventType(eventType) {
37
+ return eventType.startsWith(AGENT_INVOCATION_RESULT_EVENT_TYPE_PREFIX);
38
+ }
39
+ /** Event type of the `reply` that ends a child agent's Turn. */
40
+ const AGENT_REPLY_EVENT_TYPE = "agent.reply";
41
+ /** Event type of a message that a child agent sends to its parent. */
42
+ const AGENT_MESSAGE_EVENT_TYPE = "agent.message";
43
+ /**
44
+ * Event type of a parent agent task or message to a child that no agent
45
+ * invocation names.
46
+ */
47
+ const AGENT_PARENT_MESSAGE_EVENT_TYPE = "agent.parent_message";
48
+ export { agentInvocationResultEventType as a, userCustomizationSchema as c, SELF_TODO_ASSIGNEE as d, TODO_STATUSES as f, AGENT_REPLY_EVENT_TYPE as i, userCustomizationTextSchema as l, isOpenTodoStatus as m, AGENT_MESSAGE_EVENT_TYPE as n, isAgentInvocationResultEventType as o, UPDATE_TODOS_TOOL_NAME as p, AGENT_PARENT_MESSAGE_EVENT_TYPE as r, USER_CUSTOMIZATION_MAX_CHARS as s, AGENT_INVOCATION_EVENT_NAMESPACE as t, OPEN_TODO_STATUSES as u };
@@ -0,0 +1,20 @@
1
+ // src/chat/gateway-providers/rule.ts
2
+ /**
3
+ * The routing rule of the "Enabled providers" admin setting.
4
+ *
5
+ * This module imports nothing, so the dashboard client bundle can use it.
6
+ */
7
+ /**
8
+ * Return the AI Gateway `only` list for one model, or undefined to send none.
9
+ *
10
+ * `enabled` is null when every provider is enabled. `served` lists the
11
+ * providers that serve the model. A model that no enabled provider serves
12
+ * stays unfiltered, so unchecking its providers can never break it. A filter
13
+ * that keeps every provider of the model changes nothing, so it is not sent.
14
+ */
15
+ function gatewayOnlyProviders(enabled, served) {
16
+ if (enabled === null) return void 0;
17
+ const only = served.filter((provider) => enabled.includes(provider));
18
+ return only.length > 0 && only.length < served.length ? only : void 0;
19
+ }
20
+ export { gatewayOnlyProviders as t };