@sentry/junior 0.312.0 → 0.314.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 (115) hide show
  1. package/dist/{adapter-iIq7ihf7.js → adapter-JARQvoLw.js} +1 -2
  2. package/dist/{adapter-context-BRjEWRy1.js → adapter-context-B4BrJZuS.js} +2 -2
  3. package/dist/{admin-DhInw5K9.js → admin-BXGAySz0.js} +1 -1
  4. package/dist/{agent-runner-C9iDurwX.js → agent-runner-qZU5TR8i.js} +865 -138
  5. package/dist/agent-update-cS7Z9mnG.js +26 -0
  6. package/dist/agent-update-delivery-CZ5M8RDa.js +85 -0
  7. package/dist/api/schema.d.ts +2 -2
  8. package/dist/api/schema.js +6 -6
  9. package/dist/api.d.ts +1 -1
  10. package/dist/api.js +340 -106
  11. package/dist/{app-DRFrC8Mw.d.ts → app-D7tKnw9a.d.ts} +4 -21
  12. package/dist/app.d.ts +2 -2
  13. package/dist/app.js +80 -171
  14. package/dist/{background-compaction-queue-DrKi7w3d.js → background-compaction-queue-C_uIBUvS.js} +6 -17
  15. package/dist/{callback-mFlTUWWx.js → callback-C8SdXCwr.js} +4 -11
  16. package/dist/{catalog-runtime-D7xapBAX.js → catalog-runtime-BLKtnUL3.js} +1 -1
  17. package/dist/{channel-access-CJGfNTdn.js → channel-access-BOL29BG3.js} +6 -6
  18. package/dist/child-message--2G3Ft26.js +19 -0
  19. package/dist/cli/chat.js +18 -21
  20. package/dist/cli/check.js +4 -4
  21. package/dist/cli/main.js +2 -2
  22. package/dist/cli/plugins.js +5 -5
  23. package/dist/cli/snapshot-create.js +5 -5
  24. package/dist/cli/upgrade.d.ts +1 -1
  25. package/dist/cli/upgrade.js +23 -4
  26. package/dist/{config-kXB2Y5tl.js → config-BIfHKNXN.js} +40 -35
  27. package/dist/{continue-in-slack-O6pV5004.js → continue-in-slack-fnmD2Ifb.js} +5 -7
  28. package/dist/{conversation-feed-uNOv_x68.js → conversation-feed-DdFQuQDR.js} +13 -2
  29. package/dist/{logging-dQ9ZRGQ8.js → conversation-privacy-DtZhI91r.js} +188 -2
  30. package/dist/{conversation-turn-CeLbHqdw.js → conversation-turn-DScuDYmN.js} +465 -62
  31. package/dist/create-CrNt4Ewu.js +212 -0
  32. package/dist/{credential-sync-I8VBGk05.js → credential-sync-CtqsGjj1.js} +14 -18
  33. package/dist/{credentialed-Cb6E2phL.js → credentialed-dWRA3-oJ.js} +911 -429
  34. package/dist/{db-LAyyX8tk.js → db-BTmLKZrp.js} +2245 -50
  35. package/dist/{db-BbC5stfa.d.ts → db-DcmzbA55.d.ts} +2 -2
  36. package/dist/{history-CYstOMKX.js → history-CneKY7_V.js} +19 -1
  37. package/dist/{html-BCZ3Xtb_.js → html-B8rBt7F4.js} +5 -7
  38. package/dist/{install-DCFJFkC0.js → install-OtFboxOM.js} +2 -2
  39. package/dist/instrumentation.js +2 -2
  40. package/dist/{lineage-B_m-4TJw.js → lineage-EULJkGO1.js} +1 -2
  41. package/dist/{list-CN2QA2R9.js → list-C5400AlJ.js} +284 -113
  42. package/dist/{thread-state-DhPndWi1.js → mailbox-turn-DL3Lvsm0.js} +4830 -485
  43. package/dist/markers-DUP8aBOp.js +323 -0
  44. package/dist/{media-CYm1QD8T.js → media-FYM-Bl3H.js} +42 -14
  45. package/dist/{message-DSXGj1hM.js → message-DuDelZFr.js} +16 -15
  46. package/dist/{model-input--TrP9hYV.js → model-input-0osF3pBS.js} +3 -3
  47. package/dist/nitro.d.ts +2 -4
  48. package/dist/nitro.js +340 -13
  49. package/dist/{oauth-callback-server-DHCZC6B4.js → oauth-callback-server-DX2fQ7Nq.js} +2 -2
  50. package/dist/{oauth-relay-pPMGnDZt.js → oauth-relay-PwPMdZJv.js} +1 -1
  51. package/dist/{plugins-Bkk0XRo2.js → plugins-BXMdNdyA.js} +1 -1
  52. package/dist/{registry-CZOzddwu.js → registry-D6kS6xYH.js} +1402 -64
  53. package/dist/{statuses-_cRJHXK7.js → reporting-window-C4dbzDiR.js} +1 -27
  54. package/dist/{resolve-cKOQ14Dh.js → resolve-D8CPJcNK.js} +3 -3
  55. package/dist/result-D090hxr5.js +402 -0
  56. package/dist/{runner-DBfUW44l.js → runner-BU7fgrm-.js} +7 -8
  57. package/dist/{sandbox-egress-signals-BVF_xAm1.js → sandbox-egress-signals-BUmVrsoG.js} +1 -1
  58. package/dist/{schema-Bk9Nm2E8.js → schema-7gW9vBpJ.js} +91 -10
  59. package/dist/{schema-BEHKxr4I.d.ts → schema-BB6E0wyV.d.ts} +2105 -2753
  60. package/dist/{service-account-CVYsFjty.js → service-account-plA-uzIB.js} +6 -5
  61. package/dist/{skills-VTnhAJWm.js → skills-CIosT6bS.js} +3 -3
  62. package/dist/{slack-conversation-unfurl-fuLnF1jE.js → slack-conversation-unfurl-CBgZqth6.js} +8 -10
  63. package/dist/spawn-DRjdzh3R.js +46 -0
  64. package/dist/{start-conversation-CEn2KH1A.js → start-conversation-a4NXH4X9.js} +13 -202
  65. package/dist/{store-DFZaN-Ix.js → store-BuhF1QDm.js} +2 -4
  66. package/dist/{task-queue-Cx4Lmjyk.js → task-queue-CrRjFzOh.js} +5 -16
  67. package/dist/{task-runner-CbTwFA6k.js → task-runner-C-pXsgHM.js} +105 -51
  68. package/dist/{thread-context-BkAZDTX2.js → thread-context-CDX4dSZd.js} +8 -10
  69. package/dist/turn-session-routing-CZTRU8IY.js +116 -0
  70. package/dist/turn-wake-Bzq1Efrm.js +154 -0
  71. package/dist/user-customization-B27StpVQ.js +9 -0
  72. package/dist/{validation-nIzMtAVJ.js → validation-bTq88sya.js} +1 -1
  73. package/dist/{vercel-queue-hW90XzbG.js → vercel-queue-nL0Hq3hr.js} +32 -147
  74. package/dist/{version-Brbtz4Qf.js → version-DGUa1dZK.js} +1 -1
  75. package/dist/version.js +1 -1
  76. package/dist/{warmup-BDA5myRK.js → warmup-CCOuIwAS.js} +831 -3254
  77. package/dist/{worker-D63RcaVD.js → worker-AkZg7Dg1.js} +5 -6
  78. package/migrations/0158_keep_legacy_archive_columns.sql +5 -0
  79. package/migrations/0159_conversation_embeddings_fk_validate.sql +5 -0
  80. package/migrations/0160_money_micro_usd_repair.sql +99 -0
  81. package/migrations/0161_agent_config_backfill.sql +34 -0
  82. package/migrations/0162_inbox_item_deliveries.sql +15 -0
  83. package/migrations/0163_pg_trgm.sql +2 -0
  84. package/migrations/0164_search_indexes.sql +4 -0
  85. package/migrations/0165_drop_legacy_archive_columns.sql +4 -0
  86. package/migrations/0166_memory_prefix_index.sql +1 -0
  87. package/migrations/0167_todo_search_indexes.sql +2 -0
  88. package/migrations/0168_todo_inbox_items.sql +4 -0
  89. package/migrations/0169_drop_code_urls.sql +2 -0
  90. package/migrations/meta/0158_snapshot.json +6515 -0
  91. package/migrations/meta/0159_snapshot.json +6515 -0
  92. package/migrations/meta/0160_snapshot.json +6515 -0
  93. package/migrations/meta/0161_snapshot.json +6278 -0
  94. package/migrations/meta/0162_snapshot.json +6404 -0
  95. package/migrations/meta/0163_snapshot.json +6404 -0
  96. package/migrations/meta/0164_snapshot.json +6466 -0
  97. package/migrations/meta/0165_snapshot.json +6466 -0
  98. package/migrations/meta/0166_snapshot.json +6494 -0
  99. package/migrations/meta/0167_snapshot.json +6525 -0
  100. package/migrations/meta/0168_snapshot.json +6525 -0
  101. package/migrations/meta/0169_snapshot.json +6513 -0
  102. package/migrations/meta/_journal.json +84 -0
  103. package/package.json +9 -18
  104. package/skills/design-automation-skill/SKILL.md +2 -3
  105. package/dist/actor-BsBdxDXQ.js +0 -208
  106. package/dist/child-message-DcsritGf.js +0 -179
  107. package/dist/conversation-privacy-L4ja1_W6.js +0 -189
  108. package/dist/executor-SCub-fAq.js +0 -1860
  109. package/dist/fan-out-Cod-yEHG.js +0 -10
  110. package/dist/ingest-BDf3D50j.js +0 -3836
  111. package/dist/result-DcvEOe1r.js +0 -574
  112. package/dist/result-event-type-BdIJuZxg.js +0 -48
  113. package/dist/service-account-Ts4ulcrV.js +0 -931
  114. package/dist/spawn-vxAarlX5.js +0 -73
  115. package/dist/state-C1P3_Ywk.js +0 -161
@@ -1,6 +1,6 @@
1
- import { n as finishServiceAccountSignIn, o as serviceAccountPlugins, r as getServiceAccountStatus, s as startServiceAccountSignIn, t as disconnectServiceAccount } from "./service-account-Ts4ulcrV.js";
2
- import { n as pluginCatalogRuntime } from "./catalog-runtime-D7xapBAX.js";
3
- import { n as disconnectStateAdapter } from "./adapter-iIq7ihf7.js";
1
+ import { a as finishServiceAccountSignIn, i as disconnectServiceAccount, l as serviceAccountPlugins, o as getServiceAccountStatus, u as startServiceAccountSignIn } from "./registry-D6kS6xYH.js";
2
+ import { n as pluginCatalogRuntime } from "./catalog-runtime-BLKtnUL3.js";
3
+ import { n as disconnectStateAdapter } from "./adapter-JARQvoLw.js";
4
4
  import { CLI_USAGE } from "./cli/run.js";
5
5
  import { createServer } from "node:http";
6
6
  // src/cli/service-account.ts
@@ -86,8 +86,9 @@ async function runConnect(plugin) {
86
86
  } finally {
87
87
  loopback.close();
88
88
  }
89
- const tools = (plugin.manifest.accounts?.serviceAccount?.tools ?? []).join(", ");
90
- console.log(plugin.manifest.accounts?.userOAuth === false ? `Connected the ${provider} service account. Everyone now uses it for: ${tools}.` : `Connected the ${provider} service account. Actors who have not connected ${provider} now use it for: ${tools}.`);
89
+ const serviceAccount = plugin.manifest.accounts?.serviceAccount;
90
+ const allowed = (serviceAccount?.tools ?? serviceAccount?.operations ?? []).join(", ");
91
+ console.log(plugin.manifest.accounts?.userOAuth === false ? `Connected the ${provider} service account. Everyone now uses it for: ${allowed}.` : `Connected the ${provider} service account. Actors who have not connected ${provider} now use it for: ${allowed}.`);
91
92
  return 0;
92
93
  }
93
94
  async function runStatus(plugin) {
@@ -1,8 +1,8 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-BKpuH2hG.js";
2
2
  import { s as skillRoots } from "./package-discovery-DD9vencX.js";
3
- import { h as logWarn } from "./logging-dQ9ZRGQ8.js";
4
- import { n as pluginCatalogRuntime } from "./catalog-runtime-D7xapBAX.js";
5
- import { t as mapBounded } from "./fan-out-Cod-yEHG.js";
3
+ import { w as logWarn } from "./conversation-privacy-DtZhI91r.js";
4
+ import { n as pluginCatalogRuntime } from "./catalog-runtime-BLKtnUL3.js";
5
+ import { gt as mapBounded } from "./config-BIfHKNXN.js";
6
6
  import * as z from "zod";
7
7
  import path from "node:path";
8
8
  import fs from "node:fs/promises";
@@ -1,14 +1,12 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-BKpuH2hG.js";
2
- import { Lt as readActorIdentity, V as getConversationIdByProviderConversation, a as getConversationStore, o as getDb, s as getSqlExecutor, yn as readConversationAccessFromSql } from "./db-LAyyX8tk.js";
3
- import { _ as slackUserIdSchema, b as slackMessageTsSchema, f as parseSlackTeamId, g as slackTeamIdSchema, h as slackChannelIdSchema, m as slackBotIdSchema, n as createSlackActor, p as parseSlackUserId, s as parseActorUserId, u as parseSlackChannelId } from "./actor-BsBdxDXQ.js";
4
- import { Bo as getWorkspaceTeamId, Ni as parseDashboardConversationLink, Qr as unfurlSlackLinks, Yr as postSlackEphemeralMessage, ai as escapeSlackMrkdwnText, oi as formatSlackLink, or as lookupSlackBot, sr as lookupSlackUserProfile } from "./credentialed-Cb6E2phL.js";
5
- import { P as createCache, n as botConfig } from "./config-kXB2Y5tl.js";
6
- import { E as withSpan } from "./logging-dQ9ZRGQ8.js";
7
- import { t as runWithSlackInstallation } from "./adapter-context-BRjEWRy1.js";
8
- import { a as isMovableToSlack, i as continueConversationInSlack, n as alreadyContinuesInSlackMessage, t as BUSY } from "./continue-in-slack-O6pV5004.js";
9
- import { t as checkSlackChannelReadAccess } from "./channel-access-CJGfNTdn.js";
10
- import { tn as deferConversationMove } from "./thread-state-DhPndWi1.js";
11
- import { t as mapBounded } from "./fan-out-Cod-yEHG.js";
2
+ import { C as createSlackActor, D as parseActorUserId, Mn as readConversationAccessFromSql, Si as slackMessageTsSchema, X as getConversationIdByProviderConversation, Xt as readActorIdentity, _i as slackChannelIdSchema, a as getDb, fi as parseSlackChannelId, gi as slackBotIdSchema, hi as parseSlackUserId, i as getConversationStore, mi as parseSlackTeamId, o as getSqlExecutor, vi as slackTeamIdSchema, yi as slackUserIdSchema } from "./db-BTmLKZrp.js";
3
+ import { as as getWorkspaceTeamId, bi as formatSlackLink, br as lookupSlackBot, fi as unfurlSlackLinks, li as postSlackEphemeralMessage, qi as parseDashboardConversationLink, xr as lookupSlackUserProfile, yi as escapeSlackMrkdwnText } from "./credentialed-dWRA3-oJ.js";
4
+ import { P as createCache, gt as mapBounded, n as botConfig } from "./config-BIfHKNXN.js";
5
+ import { F as withSpan } from "./conversation-privacy-DtZhI91r.js";
6
+ import { t as runWithSlackInstallation } from "./adapter-context-B4BrJZuS.js";
7
+ import { a as isMovableToSlack, i as continueConversationInSlack, n as alreadyContinuesInSlackMessage, t as BUSY } from "./continue-in-slack-fnmD2Ifb.js";
8
+ import { t as checkSlackChannelReadAccess } from "./channel-access-BOL29BG3.js";
9
+ import { oi as deferConversationMove } from "./mailbox-turn-DL3Lvsm0.js";
12
10
  import * as z from "zod";
13
11
  // src/chat/ingress/workspace-membership.ts
14
12
  const MEMBER_TTL_MS = 3e5;
@@ -0,0 +1,46 @@
1
+ import { t as __exportAll } from "./rolldown-runtime-BKpuH2hG.js";
2
+ import { R as actorFromRun } from "./agent-runner-qZU5TR8i.js";
3
+ import { n as botConfig } from "./config-BIfHKNXN.js";
4
+ import { t as readConversationLineage } from "./lineage-EULJkGO1.js";
5
+ import { n as spawnChildAgent } from "./create-CrNt4Ewu.js";
6
+ import { ht as AgentDepthLimitError } from "./warmup-CCOuIwAS.js";
7
+ // src/chat/agent-invocations/spawn.ts
8
+ var spawn_exports = /* @__PURE__ */ __exportAll({ bindSpawnAgent: () => bindSpawnAgent });
9
+ /**
10
+ * Count the parents of the Conversation that starts a child agent. A chain
11
+ * that does not end at a root, such as a cycle, cannot start one.
12
+ */
13
+ async function assertCanStartChildAgent(conversationId, maxAgentDepth) {
14
+ const lineage = await readConversationLineage(conversationId);
15
+ const root = lineage[0];
16
+ if (!root || root.parentConversationId || lineage.length - 1 > maxAgentDepth) throw new AgentDepthLimitError(maxAgentDepth);
17
+ }
18
+ /** Bind a Run's Actor and credentials to new child agents. */
19
+ function bindSpawnAgent(run, options) {
20
+ const actor = actorFromRun(run);
21
+ if (!actor) return;
22
+ return async (input, call) => {
23
+ call.signal?.throwIfAborted();
24
+ await assertCanStartChildAgent(run.conversationId, options.maxAgentDepth ?? botConfig.maxAgentDepth);
25
+ const queue = typeof options.queue === "function" ? options.queue() : options.queue;
26
+ return await spawnChildAgent({
27
+ actor,
28
+ ...input.name ? { agentName: input.name } : void 0,
29
+ ...input.agentType ? { agentType: input.agentType } : void 0,
30
+ ...input.fork ? { fork: true } : void 0,
31
+ ...run.credentialContext ? { credentialContext: run.credentialContext } : void 0,
32
+ idempotencyKey: `${run.turnId}:${call.toolCallId}`,
33
+ input: input.task,
34
+ ...input.kind ? { kind: input.kind } : void 0,
35
+ parentConversationId: run.conversationId,
36
+ parentToolCallId: call.toolCallId,
37
+ parentTurnId: run.turnId,
38
+ ...input.reasoningLevel ? { reasoningLevel: input.reasoningLevel } : void 0,
39
+ ...input.title ? { title: input.title } : void 0
40
+ }, {
41
+ ...options,
42
+ queue
43
+ });
44
+ };
45
+ }
46
+ export { spawn_exports as n, bindSpawnAgent as t };
@@ -1,15 +1,11 @@
1
- import { Ar as getDispatchConversationId, Eo as SlackActionError, Fo as readPrivateSlackFile, Lo as streamPrivateSlackFile, Nr as getDispatchRecord, io as conversationWatch, wi as getDashboardConversationLink } from "./credentialed-Cb6E2phL.js";
2
- import { ht as bufferBody } from "./config-kXB2Y5tl.js";
3
- import { t as mapBounded } from "./fan-out-Cod-yEHG.js";
4
- import { o as getActiveTraceContext } from "./logging-dQ9ZRGQ8.js";
5
- import "./actor-BsBdxDXQ.js";
6
- import { $t as resolveActorIdentityId, A as isTopLevelKind, Fn as conversationDetailTouch, Vn as sameDestination, a as getConversationStore, fn as ToolInputError, nt as conversationKindSql, o as getDb, s as getSqlExecutor } from "./db-LAyyX8tk.js";
7
- import { B as juniorAttachments, C as juniorConversationParticipants, H as juniorConversations, K as juniorUsers, M as juniorConversationEvents, U as juniorIdentities, n as isPostgresErrorCode, z as juniorAttachmentUploads } from "./executor-SCub-fAq.js";
8
- import { d as contextProvenance } from "./history-CYstOMKX.js";
9
- import { L as buildDeterministicTurnId, W as openConversationProjection, c as appendAndEnqueueExclusiveInboundMessage, l as appendAndEnqueueInboundMessage, z as commitMessages } from "./thread-state-DhPndWi1.js";
10
- import { i as isVisionImageMediaType, r as detectImageMediaType } from "./media-CYm1QD8T.js";
11
- import { t as getVercelConversationWorkQueue } from "./vercel-queue-hW90XzbG.js";
12
- import { a as recordUploadedAttachment, i as readLiveAttachment, n as fileFields, u as AttachmentSourceUnavailableError } from "./store-DFZaN-Ix.js";
1
+ import { Co as conversationWatch, Go as SlackActionError, Ri as getDashboardConversationLink, es as readPrivateSlackFile, ns as streamPrivateSlackFile } from "./credentialed-dWRA3-oJ.js";
2
+ import { _t as bufferBody, gt as mapBounded } from "./config-BIfHKNXN.js";
3
+ import { h as getActiveTraceContext } from "./conversation-privacy-DtZhI91r.js";
4
+ import { Br as juniorConversations, Lr as juniorAttachmentUploads, Rr as juniorAttachments, Tn as ToolInputError, Vr as juniorIdentities, Wr as juniorUsers, Yn as conversationDetailTouch, a as getDb, c as isPostgresErrorCode, di as sameDestination, fn as resolveActorIdentityId, ft as conversationKindSql, i as getConversationStore, o as getSqlExecutor, wr as juniorConversationParticipants, z as isTopLevelKind } from "./db-BTmLKZrp.js";
5
+ import { On as buildDeterministicTurnId, Tt as appendAndEnqueueInboundMessage, wt as appendAndEnqueueExclusiveInboundMessage } from "./mailbox-turn-DL3Lvsm0.js";
6
+ import { i as isVisionImageMediaType, r as detectImageMediaType } from "./media-FYM-Bl3H.js";
7
+ import { t as getVercelConversationWorkQueue } from "./vercel-queue-nL0Hq3hr.js";
8
+ import { a as recordUploadedAttachment, i as readLiveAttachment, n as fileFields, u as AttachmentSourceUnavailableError } from "./store-BuhF1QDm.js";
13
9
  import { t as webMessageId } from "./web-message-id-C6P83ans.js";
14
10
  import * as z from "zod";
15
11
  import { createHash, randomUUID } from "node:crypto";
@@ -194,191 +190,6 @@ const readSlackAttachmentSource = async (source) => {
194
190
  }
195
191
  };
196
192
  };
197
- // src/chat/agent-invocations/fork-history.ts
198
- /** Instructions that a fork child reads with its first task. */
199
- const FORK_INSTRUCTIONS = "You are a fork of your parent agent. The messages before your first parent task are copied from the parent's conversation so you have its context. They are not your job: your job is the parent task below. Sandbox files, approvals, and credentials of the parent were not copied, and your sandbox is separate. Verify files in your own sandbox before you use them.";
200
- /**
201
- * Cut parent history for a fork: everything before the parent's message that
202
- * started the fork, through the last point where every tool call has its
203
- * result. A model request with an unanswered tool call fails, and the parent
204
- * can commit its history in the middle of a tool round.
205
- */
206
- function forkHistoryFrom(messages, parentToolCallId) {
207
- const spawnIndex = parentToolCallId ? messages.findIndex((message) => message.role === "assistant" && message.content.some((part) => part.type === "toolCall" && part.id === parentToolCallId)) : -1;
208
- const before = spawnIndex >= 0 ? messages.slice(0, spawnIndex) : messages;
209
- const pending = /* @__PURE__ */ new Set();
210
- let end = 0;
211
- for (const [index, message] of before.entries()) {
212
- if (message.role === "assistant") {
213
- for (const part of message.content) if (part.type === "toolCall") pending.add(part.id);
214
- } else if (message.role === "toolResult") pending.delete(message.toolCallId);
215
- if (pending.size === 0) end = index + 1;
216
- }
217
- return before.slice(0, end);
218
- }
219
- /**
220
- * Load the start history of a fork child from its parent Conversation.
221
- */
222
- async function loadForkHistory(invocation) {
223
- return forkHistoryFrom((await openConversationProjection({ conversationId: invocation.parentConversationId })).messages, invocation.parentToolCallId);
224
- }
225
- async function hasTurnStarted(conversationId) {
226
- const [row] = await getSqlExecutor().db().select({ seq: juniorConversationEvents.seq }).from(juniorConversationEvents).where(and(eq(juniorConversationEvents.conversationId, conversationId), eq(juniorConversationEvents.type, "turn_started"))).limit(1);
227
- return row !== void 0;
228
- }
229
- /**
230
- * Commit the start history of a fork child before its first Turn starts, so
231
- * the history is below the Turn start. A child that already has agent
232
- * history, such as on a retry, commits nothing. A child whose Turn already
233
- * started commits nothing too: the history would be Turn messages, and a
234
- * parent `reply` in it would read as the Turn's answer. Only a worker that
235
- * committed fork history after the Turn start leaves such a child.
236
- */
237
- async function commitForkHistory(args) {
238
- if ((await openConversationProjection({ conversationId: args.childConversationId })).messages.length > 0 || await hasTurnStarted(args.childConversationId)) return;
239
- const messages = await loadForkHistory(args);
240
- if (messages.length === 0) return;
241
- await commitMessages({
242
- conversationId: args.childConversationId,
243
- messages,
244
- provenance: messages.map(() => contextProvenance)
245
- });
246
- }
247
- /** True for agent history that a fork child inherited from its parent. */
248
- function isInheritedForkHistory(event, firstEvent) {
249
- return firstEvent !== void 0 && event.seq > firstEvent.seq && event.createdAtMs < firstEvent.createdAtMs && (event.data.type === "assistant_message" || event.data.type === "tool_result");
250
- }
251
- const firstRow = alias(juniorConversationEvents, "first_event");
252
- /**
253
- * SQL filter for event rows that a fork child did not inherit from its
254
- * parent. Usage reports use it, so inherited model calls count only in the
255
- * parent. It reads only a lower seq, the Conversation's first event, so a
256
- * counted row never changes whether it counts.
257
- */
258
- function notInheritedByForkChild() {
259
- return sql`not coalesce(${juniorConversationEvents.createdAt} < (
260
- select ${firstRow.createdAt}
261
- from ${juniorConversationEvents} as ${sql.identifier("first_event")}
262
- where ${firstRow.conversationId} = ${juniorConversationEvents.conversationId}
263
- and ${firstRow.seq} < ${juniorConversationEvents.seq}
264
- order by ${firstRow.seq}
265
- limit 1
266
- ), false)`;
267
- }
268
- // src/chat/services/turn-session-routing.ts
269
- async function loadConversationChain(conversationId, conversationStore) {
270
- const chain = [];
271
- const seen = /* @__PURE__ */ new Set();
272
- let cursor = conversationId;
273
- while (cursor && !seen.has(cursor)) {
274
- seen.add(cursor);
275
- const conversation = await conversationStore.get({ conversationId: cursor });
276
- if (!conversation) break;
277
- chain.push(conversation);
278
- cursor = conversation.parentConversationId;
279
- }
280
- return chain;
281
- }
282
- /**
283
- * Normalize a stored Slack session source against the conversation destination.
284
- *
285
- * Does not create channel or thread values from the conversation id.
286
- */
287
- function slackSourceForDestination(args) {
288
- if (args.source?.kind !== "slack" || args.source.channelId !== args.destination.channelId) return;
289
- const threadTs = args.source.threadTs?.trim();
290
- return {
291
- kind: "slack",
292
- visibility: args.source.visibility ?? "public",
293
- teamId: args.source.teamId?.trim() || args.destination.teamId,
294
- channelId: args.source.channelId,
295
- ...threadTs ? { threadTs } : void 0
296
- };
297
- }
298
- /**
299
- * Resolve the Conversation Location, Destination, and session Source.
300
- *
301
- * Reads parent Conversations when this Conversation has no Destination.
302
- */
303
- async function resolveConversationRouting(args) {
304
- const conversationStore = args.conversationStore ?? (await import("./db-LAyyX8tk.js").then((n) => n.n)).getConversationStore();
305
- const chain = await loadConversationChain(args.conversationId, conversationStore);
306
- let destination;
307
- let source;
308
- let location;
309
- for (const conversation of chain) {
310
- destination ??= conversation.destination;
311
- source ??= conversation.sessionSource;
312
- location ??= conversation.location;
313
- if (destination && source) break;
314
- }
315
- if (!destination) return;
316
- if (destination.platform === "slack") {
317
- const slackSource = slackSourceForDestination({
318
- destination,
319
- source
320
- });
321
- return {
322
- destination,
323
- ...location ? { location } : void 0,
324
- ...slackSource ? { source: slackSource } : void 0
325
- };
326
- }
327
- return {
328
- destination,
329
- ...location ? { location } : void 0,
330
- ...source ? { source } : void 0
331
- };
332
- }
333
- /** Require the Conversation Destination and Source from SQL. */
334
- async function resolveTurnSessionRouting(args) {
335
- const routing = await resolveConversationRouting(args);
336
- if (!routing?.destination || !routing.source) throw new Error(`Conversation ${args.conversationId} is missing durable routing metadata`);
337
- return {
338
- destination: routing.destination,
339
- ...routing.location ? { location: routing.location } : void 0,
340
- source: routing.source
341
- };
342
- }
343
- /**
344
- * Require the Destination and Source to resume a Turn.
345
- *
346
- * A dispatch Conversation stores the dispatch Source, which has no session
347
- * Source. Its dispatch record owns the Destination and Source.
348
- */
349
- async function resolveTurnResumeRouting(args) {
350
- if (!args.dispatchId) return await resolveTurnSessionRouting(args);
351
- const dispatch = await getDispatchRecord(args.dispatchId);
352
- if (!dispatch) throw new Error(`Dispatch record is missing for ${args.dispatchId}`);
353
- const dispatchConversationId = getDispatchConversationId(dispatch);
354
- if (dispatchConversationId !== args.conversationId) throw new Error(`Dispatch ${dispatch.id} belongs to ${dispatchConversationId}, not ${args.conversationId}`);
355
- const location = (await resolveConversationRouting(args))?.location;
356
- return {
357
- destination: dispatch.destination,
358
- ...location ? { location } : void 0,
359
- source: dispatch.source
360
- };
361
- }
362
- // src/chat/task-execution/turn-membership.ts
363
- /** True when the committed message at `seq` belongs to the Turn. */
364
- function isTurnMessage(start, seq, message) {
365
- return seq > start.seq && message.role !== "system";
366
- }
367
- /**
368
- * The messages of a saved Turn with their provenance. Without a
369
- * `turn_started` event, nothing tells this Turn from earlier history, so it
370
- * has no messages.
371
- */
372
- function savedTurnMessages(record, start) {
373
- if (!start) return [];
374
- return record.piMessages.flatMap((message, index) => {
375
- const seq = record.piMessageSeqs[index];
376
- return seq !== void 0 && isTurnMessage(start, seq, message) ? [{
377
- message,
378
- provenance: record.piMessageProvenance[index] ?? { authority: "context" }
379
- }] : [];
380
- });
381
- }
382
193
  // src/chat/attachments/uploads.ts
383
194
  const MINUTE_MS = 6e4;
384
195
  /** Time that a browser has to write the bytes after it asks to upload. */
@@ -909,7 +720,7 @@ const startConversationToolDefinition = zodToolDefinition({
909
720
  }).strict(),
910
721
  outputSchema: juniorToolOutputSchema.extend({
911
722
  conversation_id: z.string().min(1).describe("ID of the new conversation. Pass it to messageAgent to steer it."),
912
- dashboard_url: z.string().url().optional().describe("Dashboard link of the new conversation."),
723
+ url: z.string().url().optional().describe("Link to the new conversation."),
913
724
  subscribable: subscribableResourceSchema.describe("Watch it with watchEvents only when the person asks to hear back.")
914
725
  })
915
726
  });
@@ -918,7 +729,7 @@ function createStartConversationTool(context) {
918
729
  return zodTool({
919
730
  ...startConversationToolDefinition,
920
731
  execute: async (input, options) => {
921
- if (!options.toolCallId || !context.turnId) throw new ToolInputError("startConversation requires an active Turn and tool call ID");
732
+ if (!options.toolCallId || !context.turnId) throw new ToolInputError("startConversation requires an active Turn and tool call ID. No change to the call can fix this.");
922
733
  const { conversationId } = await startLeadConversation({
923
734
  leadConversationId: context.conversationId,
924
735
  messageKey: `${context.turnId}:${options.toolCallId}`,
@@ -926,10 +737,10 @@ function createStartConversationTool(context) {
926
737
  task: input.task,
927
738
  title: input.title
928
739
  });
929
- const dashboardUrl = getDashboardConversationLink(conversationId);
740
+ const url = getDashboardConversationLink(conversationId);
930
741
  return {
931
742
  conversation_id: conversationId,
932
- ...dashboardUrl ? { dashboard_url: dashboardUrl } : void 0,
743
+ ...url ? { url } : void 0,
933
744
  subscribable: conversationWatch({
934
745
  conversationId,
935
746
  title: input.title
@@ -938,4 +749,4 @@ function createStartConversationTool(context) {
938
749
  }
939
750
  });
940
751
  }
941
- export { readSlackAttachmentSource as A, FORK_INSTRUCTIONS as C, getSlackFileId as D, notInheritedByForkChild as E, zodToolDefinition as F, injectContinuationToolName as I, juniorToolOutputSchema as L, slackAttachmentsVersionQuery as M, parseToolInput as N, matchSlackAttachments as O, zodTool as P, makeStructuredToolOutput as R, resolveTurnResumeRouting as S, isInheritedForkHistory as T, verifyAttachmentUploads as _, readLeadUser as a, savedTurnMessages as b, conversationTurnIdForMessage as c, recordWebConversationActivity as d, webActorFromUser as f, createAttachmentUpload as g, collectAttachmentUploadGarbage as h, leadPersonParticipates as i, recordSlackAttachment as j, readAttachmentVisionSummary as k, createAndEnqueueConversation as l, AttachmentUploadError as m, startConversationToolDefinition as n, acceptsWebMessages as o, resolveConversationDestination as p, getLeadConversation as r, appendAndEnqueueWebMessage as s, createStartConversationTool as t, createConversationId as u, writeAttachmentUpload as v, commitForkHistory as w, resolveConversationRouting as x, isTurnMessage as y };
752
+ export { makeStructuredToolOutput as A, recordSlackAttachment as C, zodToolDefinition as D, zodTool as E, injectContinuationToolName as O, readSlackAttachmentSource as S, parseToolInput as T, verifyAttachmentUploads as _, readLeadUser as a, matchSlackAttachments as b, conversationTurnIdForMessage as c, recordWebConversationActivity as d, webActorFromUser as f, createAttachmentUpload as g, collectAttachmentUploadGarbage as h, leadPersonParticipates as i, juniorToolOutputSchema as k, createAndEnqueueConversation as l, AttachmentUploadError as m, startConversationToolDefinition as n, acceptsWebMessages as o, resolveConversationDestination as p, getLeadConversation as r, appendAndEnqueueWebMessage as s, createStartConversationTool as t, createConversationId as u, writeAttachmentUpload as v, slackAttachmentsVersionQuery as w, readAttachmentVisionSummary as x, getSlackFileId as y };
@@ -1,7 +1,5 @@
1
- import { B as juniorAttachments, H as juniorConversations, V as juniorMessageAttachments } from "./executor-SCub-fAq.js";
2
- import { Fn as conversationDetailTouch, Ln as touchConversationDetail } from "./db-LAyyX8tk.js";
3
- import { t as mapBounded } from "./fan-out-Cod-yEHG.js";
4
- import { ht as bufferBody } from "./config-kXB2Y5tl.js";
1
+ import { Br as juniorConversations, Rr as juniorAttachments, Yn as conversationDetailTouch, Zn as touchConversationDetail, zr as juniorMessageAttachments } from "./db-BTmLKZrp.js";
2
+ import { _t as bufferBody, gt as mapBounded } from "./config-BIfHKNXN.js";
5
3
  import { createHash, randomUUID } from "node:crypto";
6
4
  import { and, asc, eq, inArray, isNotNull, isNull, lte, notExists, or } from "drizzle-orm";
7
5
  // src/chat/attachments/source.ts
@@ -1,6 +1,6 @@
1
- import { h as logWarn } from "./logging-dQ9ZRGQ8.js";
2
- import { t as queueCallback } from "./callback-mFlTUWWx.js";
3
- import { c as QUEUE_SIGNATURE_MAX_AGE_MS, d as getQueueProvider, l as signQueueMessage, u as verifyQueueMessage } from "./vercel-queue-hW90XzbG.js";
1
+ import { w as logWarn } from "./conversation-privacy-DtZhI91r.js";
2
+ import { t as queueCallback } from "./callback-C8SdXCwr.js";
3
+ import { c as QUEUE_SIGNATURE_MAX_AGE_MS, d as getQueueProvider, l as signQueueMessage, u as verifyQueueMessage } from "./vercel-queue-nL0Hq3hr.js";
4
4
  import * as z from "zod";
5
5
  import { createHash } from "node:crypto";
6
6
  // src/chat/plugins/task-queue.ts
@@ -12,7 +12,6 @@ import { createHash } from "node:crypto";
12
12
  */
13
13
  /** Deploy topic name. Keep stable for Vercel queue wiring. */
14
14
  const PLUGIN_TASK_QUEUE_TOPIC = "junior_plugin_tasks";
15
- const PLUGIN_TASK_DEV_CONSUMER_GROUP = "junior_plugin_tasks_dev";
16
15
  const PLUGIN_TASK_MAX_DELIVERIES = 5;
17
16
  const PLUGIN_TASK_SIGN_CONTEXT = "junior.plugin_task_queue.v1";
18
17
  const PLUGIN_TASK_SIGN_VERSION = "v1";
@@ -57,14 +56,12 @@ function logPluginTaskQueueMessageRejected(reason, metadata) {
57
56
  }
58
57
  function pluginTaskCallback() {
59
58
  return queueCallback({
60
- consumerGroup: PLUGIN_TASK_DEV_CONSUMER_GROUP,
61
59
  maxDeliveries: PLUGIN_TASK_MAX_DELIVERIES,
62
60
  onRejected: logPluginTaskQueueMessageRejected,
63
61
  run: async (message) => {
64
- const { processPluginTask } = await import("./task-runner-CbTwFA6k.js").then((n) => n.r);
62
+ const { processPluginTask } = await import("./task-runner-C-pXsgHM.js").then((n) => n.r);
65
63
  await processPluginTask(message);
66
64
  },
67
- topic: PLUGIN_TASK_QUEUE_TOPIC,
68
65
  verify: verifyPluginTaskQueueMessage
69
66
  });
70
67
  }
@@ -79,12 +76,4 @@ async function sendVercelPluginTask(message) {
79
76
  function createVercelPluginTaskCallback() {
80
77
  return pluginTaskCallback().create();
81
78
  }
82
- /** Return the queue consumer for plugin tasks, for a pulling queue worker. */
83
- function pluginTaskQueueConsumer() {
84
- return pluginTaskCallback().consumer;
85
- }
86
- /** Register the local-dev consumer for plugin tasks. */
87
- function registerVercelPluginTaskDevConsumer() {
88
- return pluginTaskCallback().registerDev();
89
- }
90
- export { pluginTaskQueueConsumer as a, pluginTaskParamsSchema as i, createVercelPluginTaskCallback as n, registerVercelPluginTaskDevConsumer as o, pluginTaskId as r, sendVercelPluginTask as s, PLUGIN_TASK_QUEUE_TOPIC as t };
79
+ export { sendVercelPluginTask as a, pluginTaskParamsSchema as i, createVercelPluginTaskCallback as n, pluginTaskId as r, PLUGIN_TASK_QUEUE_TOPIC as t };