@sentry/junior 0.303.0 → 0.304.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 (82) hide show
  1. package/dist/{adapter-context-BdVnSuY5.js → adapter-context-B1IpoELr.js} +2 -2
  2. package/dist/{admin-AfeAdS3J.js → admin-BnVFGo_z.js} +5 -5
  3. package/dist/{agent-runner-BP8_DLUv.js → agent-runner-CoEeZSRh.js} +546 -372
  4. package/dist/api/schema.d.ts +1 -1
  5. package/dist/api/schema.js +5 -5
  6. package/dist/api.d.ts +1 -1
  7. package/dist/api.js +59 -61
  8. package/dist/{app-Dd9v1mNx.d.ts → app-Cs157Zc5.d.ts} +5 -3
  9. package/dist/app.d.ts +1 -1
  10. package/dist/app.js +77 -64
  11. package/dist/{automation-D9MvhOWY.js → automation-CuA3yEcD.js} +1 -1
  12. package/dist/{background-compaction-queue-xaE05jxH.js → background-compaction-queue-WLPNSF_b.js} +2 -2
  13. package/dist/{briefs-D8i-dKTp.js → briefs-CagVVefw.js} +11 -8
  14. package/dist/{catalog-runtime-d1EM6Z0V.js → catalog-runtime-B8ZXvXWm.js} +1 -1
  15. package/dist/cli/chat.js +15 -15
  16. package/dist/cli/check.js +5 -5
  17. package/dist/cli/init.js +1 -1
  18. package/dist/cli/main.js +3 -3
  19. package/dist/cli/plugins.js +4 -4
  20. package/dist/cli/snapshot-create.js +5 -5
  21. package/dist/cli/upgrade.d.ts +1 -1
  22. package/dist/cli/upgrade.js +4 -4
  23. package/dist/{config-oGM7KA9M.js → config-DdO1BNcw.js} +101 -7
  24. package/dist/{connections-BlikzEJv.js → connections-D20kp0j5.js} +6 -6
  25. package/dist/{continue-in-slack-BZnYifiG.js → continue-in-slack-BKEVMBj1.js} +8 -8
  26. package/dist/{conversation-CY1jnBiC.js → conversation-BOqdRtUx.js} +4 -12
  27. package/dist/{conversation-feed-BZJRk6UV.js → conversation-feed-CgpgP7yi.js} +35 -2
  28. package/dist/{conversation-privacy-Cx515ddM.js → conversation-privacy-L1SK_v0V.js} +10 -2
  29. package/dist/{conversation-turn-DAhRdX4m.js → conversation-turn-BptVJylj.js} +17 -17
  30. package/dist/{credential-sync-DfhmWFeo.js → credential-sync-D1J1CGzL.js} +14 -14
  31. package/dist/{db-C-2tFxk3.js → db-EKJnkrIb.js} +169 -6
  32. package/dist/{db-DPqcEM9_.d.ts → db-zbN5ZV_o.d.ts} +2 -2
  33. package/dist/{executor-NVfS8aQ2.js → executor-CoIZmFK8.js} +43 -9
  34. package/dist/{history-UZ3M2M9r.js → history-m2-ceTTX.js} +8 -2
  35. package/dist/{install-CHLrpRZc.js → install-BT2Pf6HP.js} +2 -2
  36. package/dist/instrumentation.js +7 -3
  37. package/dist/{lineage-HGLhd_-N.js → lineage-C5DGQCS_.js} +2 -2
  38. package/dist/{logging-DiyqRLBx.js → logging-QSZuMcvo.js} +1 -1
  39. package/dist/{message-CkCOcbFH.js → message-TtxftRHj.js} +8 -8
  40. package/dist/{model-input-DmoPPtPE.js → model-input-BHXfA29g.js} +2 -2
  41. package/dist/nitro.d.ts +1 -1
  42. package/dist/nitro.js +5 -5
  43. package/dist/{oauth-callback-server-CIf_6YmA.js → oauth-callback-server-B0enqHtZ.js} +2 -2
  44. package/dist/{projection-DBq8tsA5.js → projection-CNKK7doO.js} +547 -61
  45. package/dist/{prompt-D2KlJopL.js → prompt-DSjhoKu5.js} +185 -12
  46. package/dist/{queue-DFaOscp5.js → queue-CDxkit82.js} +4 -4
  47. package/dist/{registry-Bu0Z9BEO.js → registry-DBDNUUmz.js} +1 -1
  48. package/dist/{resolve-DXuA3G0g.js → resolve-CQLhMWSu.js} +3 -3
  49. package/dist/{result-DpiNseDA.js → result-B-pauj42.js} +8 -8
  50. package/dist/{runner-iu1heRFv.js → runner-B3KxKks5.js} +9 -9
  51. package/dist/{sandbox-egress-signals-2HFYDcQf.js → sandbox-egress-signals-DJJX9ClG.js} +1 -1
  52. package/dist/{schema-DvfX3Gq_.js → schema-Bx0Mlo32.js} +3 -3
  53. package/dist/{schema-DHMOaRzC.d.ts → schema-CKcu-IK6.d.ts} +43 -11
  54. package/dist/{service-account-BcT5LR7V.js → service-account-2HmlNPvy.js} +6 -5
  55. package/dist/{service-account-xYkaQTrw.js → service-account-DQLqkSVv.js} +5 -5
  56. package/dist/{session-stop-BLLp1IP_.js → session-stop-DEeZKqbX.js} +114 -49
  57. package/dist/{skills-CNAGH4ju.js → skills-2UrD7JkN.js} +2 -2
  58. package/dist/{slack-conversation-unfurl-DYnqe5ci.js → slack-conversation-unfurl-Dd129Uov.js} +12 -11
  59. package/dist/{spawn-cGasWW33.js → spawn-eMho9HDJ.js} +6 -6
  60. package/dist/{state-CDS6h_Wv.js → state-Bveuc4Zh.js} +4 -4
  61. package/dist/{stop-DMMA67yT.js → stop-D_ltJLDS.js} +170 -64
  62. package/dist/{store-Dgs7Oe44.js → store-COeYnPL_.js} +5 -5
  63. package/dist/{task-queue-DcF0nhhz.js → task-queue-CBIDXZpV.js} +3 -3
  64. package/dist/{task-runner-BGXF7Fo7.js → task-runner-CJF7zIJL.js} +7 -7
  65. package/dist/{thread-context-BPky1KBe.js → thread-context-Cg0jt0aE.js} +8 -8
  66. package/dist/{turn-session-routing-DGvn9MSl.js → turn-session-routing-CaY3Tp8m.js} +8 -8
  67. package/dist/{turn-user-message-19CkuUvM.js → turn-user-message-tcom1RYd.js} +3 -3
  68. package/dist/{validation-lu1DgjNQ.js → validation-EU91JwIT.js} +1 -1
  69. package/dist/{version-Uo3c94Dx.js → version-BYRPhY5G.js} +1 -1
  70. package/dist/version.js +1 -1
  71. package/dist/{viewer-BPQHMx3-.js → viewer-Cf8ISkAc.js} +3 -3
  72. package/dist/{warmup-H8uLvW9e.js → warmup-TgY4S1vx.js} +75 -469
  73. package/dist/{worker-B-pM_-3K.js → worker-C6Uq4OKD.js} +7 -7
  74. package/migrations/0111_attachment_kinds.sql +14 -0
  75. package/migrations/0112_attachment_url_fill.sql +51 -0
  76. package/migrations/0113_attachment_url_index.sql +1 -0
  77. package/migrations/meta/0099_snapshot.json +102 -326
  78. package/migrations/meta/0111_snapshot.json +5011 -0
  79. package/migrations/meta/0112_snapshot.json +5011 -0
  80. package/migrations/meta/0113_snapshot.json +5033 -0
  81. package/migrations/meta/_journal.json +21 -0
  82. package/package.json +7 -7
@@ -1,7 +1,7 @@
1
- import { i as getChatConfig } from "../config-oGM7KA9M.js";
2
- import { t as createJuniorSqlExecutor } from "../executor-NVfS8aQ2.js";
1
+ import { i as getChatConfig } from "../config-DdO1BNcw.js";
2
+ import { t as createJuniorSqlExecutor } from "../executor-CoIZmFK8.js";
3
3
  import { t as loadAppPluginSet } from "../plugin-module-Cv2ETe8Y.js";
4
- import { t as createPluginCatalogRuntime } from "../registry-Bu0Z9BEO.js";
4
+ import { t as createPluginCatalogRuntime } from "../registry-DBDNUUmz.js";
5
5
  import { n as pluginCatalogConfigFromEnv, r as pluginCatalogConfigFromPluginSet, t as defineJuniorPlugins } from "../plugins-Bkk0XRo2.js";
6
6
  import { basename, dirname, join, resolve } from "node:path";
7
7
  import { createHash } from "node:crypto";
@@ -64,7 +64,7 @@ function migrationResult(migrations, state) {
64
64
  /** Reject legacy databases that must first run the bridge release upgrade. */
65
65
  function assertSupportedMigrationState(state) {
66
66
  if (!state.hasJuniorTables || state.appliedAt !== void 0) return;
67
- throw new Error(`Existing Junior SQL tables have no core Drizzle migration history. Stop old Junior workers, install @sentry/junior@${CORE_MIGRATION_BRIDGE_VERSION}, run \`junior upgrade\`, then restore this Junior version and rerun \`junior upgrade\` before restarting workers.`);
67
+ throw new Error(`Existing SQL tables have no core Drizzle migration history. Stop old workers, install @sentry/junior@${CORE_MIGRATION_BRIDGE_VERSION}, run \`junior upgrade\`, then restore this version and rerun \`junior upgrade\` before restarting workers.`);
68
68
  }
69
69
  /** Apply the packaged Drizzle migrations during `junior upgrade`. */
70
70
  async function migrateSchema(executor) {
@@ -1,6 +1,6 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-BKpuH2hG.js";
2
- import { E as withSpan, g as normalizeGenAiFinishReason, h as logWarn, i as extractGenAiUsageAttributes, p as logException, v as serializeGenAiAttribute } from "./logging-DiyqRLBx.js";
3
- import { a as toCanonicalInputMessage, n as getCurrentConversationPrivacy, o as toCanonicalOutputMessage, s as toGenAiMessagesTraceAttributes } from "./conversation-privacy-Cx515ddM.js";
2
+ import { E as withSpan, g as normalizeGenAiFinishReason, h as logWarn, i as extractGenAiUsageAttributes, p as logException, v as serializeGenAiAttribute } from "./logging-QSZuMcvo.js";
3
+ import { a as toCanonicalInputMessage, n as getCurrentConversationPrivacy, o as toCanonicalOutputMessage, s as toGenAiMessagesTraceAttributes } from "./conversation-privacy-L1SK_v0V.js";
4
4
  import { AwsClient } from "aws4fetch";
5
5
  import { del, get, issueSignedToken, presignUrl, put } from "@vercel/blob";
6
6
  import * as z from "zod";
@@ -8,8 +8,9 @@ import { calculateCost, completeSimple, getEnvApiKey, getModels, registerApiProv
8
8
  import { stream as streamAnthropic, streamSimple as streamSimpleAnthropic } from "@earendil-works/pi-ai/api/anthropic-messages";
9
9
  import { createGatewayProvider } from "@ai-sdk/gateway";
10
10
  import { getVercelOidcToken } from "@vercel/oidc";
11
- import { Experimental_DecisionRefusalError, NoObjectGeneratedError, embedMany, experimental_decide, generateObject, rerank } from "ai";
11
+ import { Experimental_DecisionRefusalError, NoImageGeneratedError, NoObjectGeneratedError, embedMany, experimental_decide, generateImage, generateObject, generateText, rerank } from "ai";
12
12
  import { createHash } from "node:crypto";
13
+ import { renderSystemMessageUpdate } from "@earendil-works/pi-ai";
13
14
  // src/chat/optional-string.ts
14
15
  /**
15
16
  * Normalize optional env-style strings so blank values do not masquerade as
@@ -102,6 +103,21 @@ function createVercelAttachmentStorage() {
102
103
  url: presignedUrl
103
104
  };
104
105
  },
106
+ async createDownloadUrl(input) {
107
+ const token = await issueSignedToken({
108
+ operations: ["get"],
109
+ pathname: input.key,
110
+ validUntil: input.expiresAtMs
111
+ });
112
+ const { presignedUrl } = await presignUrl(token, {
113
+ access: "private",
114
+ operation: "get",
115
+ pathname: input.key,
116
+ useCache: false,
117
+ validUntil: input.expiresAtMs
118
+ });
119
+ return presignedUrl;
120
+ },
105
121
  async get(key, range) {
106
122
  const result = await get(key, {
107
123
  access: "private",
@@ -198,6 +214,10 @@ async function expectOk(response, operation) {
198
214
  await drain(response);
199
215
  if (!response.ok) throw new Error(`S3 ${operation} failed with status ${response.status}`);
200
216
  }
217
+ /** Presigned URL lifetime in whole seconds, at least one. */
218
+ function expiresInSeconds(expiresAtMs) {
219
+ return String(Math.max(1, Math.ceil((expiresAtMs - Date.now()) / 1e3)));
220
+ }
201
221
  /** Store private conversation attachments in an S3-compatible bucket. */
202
222
  function createS3AttachmentStorage(config) {
203
223
  const client = new AwsClient({
@@ -228,7 +248,7 @@ function createS3AttachmentStorage(config) {
228
248
  },
229
249
  async createUploadTarget(input) {
230
250
  const url = new URL(objectUrl(config, input.key));
231
- url.searchParams.set("X-Amz-Expires", String(Math.max(1, Math.ceil((input.expiresAtMs - Date.now()) / 1e3))));
251
+ url.searchParams.set("X-Amz-Expires", expiresInSeconds(input.expiresAtMs));
232
252
  const browserHeaders = {
233
253
  "content-type": input.contentType,
234
254
  "if-none-match": "*"
@@ -249,6 +269,14 @@ function createS3AttachmentStorage(config) {
249
269
  })).url
250
270
  };
251
271
  },
272
+ async createDownloadUrl(input) {
273
+ const url = new URL(objectUrl(config, input.key));
274
+ url.searchParams.set("X-Amz-Expires", expiresInSeconds(input.expiresAtMs));
275
+ return (await client.sign(url.toString(), {
276
+ aws: { signQuery: true },
277
+ method: "GET"
278
+ })).url;
279
+ },
252
280
  async get(key, range) {
253
281
  const response = await client.fetch(objectUrl(config, key), range ? { headers: { range: rangeHeader(range) } } : void 0);
254
282
  if (response.status === 404) {
@@ -764,6 +792,7 @@ function tokensForChars(chars, profile) {
764
792
  }
765
793
  function messageChars(message) {
766
794
  switch (message.role) {
795
+ case "system": return renderSystemMessageUpdate(message).length;
767
796
  case "user":
768
797
  case "toolResult": return contentChars(message.content);
769
798
  case "assistant": {
@@ -1043,6 +1072,7 @@ const GATEWAY_MODEL_OVERRIDES = {
1043
1072
  },
1044
1073
  compat: {
1045
1074
  forceAdaptiveThinking: true,
1075
+ supportsMidConvoSystemMessages: true,
1046
1076
  supportsTemperature: false
1047
1077
  }
1048
1078
  },
@@ -1089,7 +1119,8 @@ const GATEWAY_MODEL_OVERRIDES = {
1089
1119
  thinkingLevelMap: {
1090
1120
  xhigh: "xhigh",
1091
1121
  max: "max"
1092
- }
1122
+ },
1123
+ compat: { supportsMidConvoSystemMessages: true }
1093
1124
  },
1094
1125
  "openai/gpt-6-astra": {
1095
1126
  id: "openai/gpt-6-astra",
@@ -1261,7 +1292,7 @@ async function completeText(params) {
1261
1292
  }, startAttributes);
1262
1293
  }
1263
1294
  function logContextFromMetadata(modelId, metadata) {
1264
- const conversationId = typeof metadata?.["conversationId"] === "string" ? metadata["conversationId"] : typeof metadata?.["threadId"] === "string" ? metadata["threadId"] : void 0;
1295
+ const conversationId = typeof metadata?.["conversationId"] === "string" && metadata["conversationId"] ? metadata["conversationId"] : void 0;
1265
1296
  const messageConversationId = typeof metadata?.["threadId"] === "string" ? metadata["threadId"] : void 0;
1266
1297
  const destinationName = typeof metadata?.["channelId"] === "string" ? metadata["channelId"] : void 0;
1267
1298
  const runId = typeof metadata?.["runId"] === "string" ? metadata["runId"] : void 0;
@@ -1523,6 +1554,66 @@ async function rerankTexts(params) {
1523
1554
  throw providerError;
1524
1555
  }
1525
1556
  }
1557
+ const WEB_SEARCH_TOOL_NAME = "parallelSearch";
1558
+ /** Run one AI Gateway parallel search inside a `gen_ai.chat` span. */
1559
+ async function searchWeb(params) {
1560
+ const credential = await resolveGatewayCredential();
1561
+ const provider = createGatewayProvider({ apiKey: credential.token });
1562
+ return await withSpan(`${GEN_AI_OPERATION_CHAT} ${params.modelId}`, "gen_ai.chat", {}, async (setSpanAttributes) => {
1563
+ const response = await generateText({
1564
+ model: provider.chat(params.modelId),
1565
+ prompt: params.query,
1566
+ tools: { [WEB_SEARCH_TOOL_NAME]: provider.tools.parallelSearch({
1567
+ mode: "agentic",
1568
+ maxResults: params.maxResults
1569
+ }) },
1570
+ toolChoice: {
1571
+ type: "tool",
1572
+ toolName: WEB_SEARCH_TOOL_NAME
1573
+ },
1574
+ abortSignal: params.signal
1575
+ });
1576
+ const costUsd = gatewayCostUsd(response.providerMetadata);
1577
+ setSpanAttributes({
1578
+ "gen_ai.response.finish_reasons": [response.finishReason],
1579
+ ...extractGenAiUsageAttributes(response.usage, costUsd !== void 0 ? { cost: { total: costUsd } } : void 0)
1580
+ });
1581
+ return {
1582
+ ...costUsd !== void 0 ? { costUsd } : void 0,
1583
+ outputs: response.toolResults.filter((result) => result.toolName === WEB_SEARCH_TOOL_NAME).map((result) => result.output)
1584
+ };
1585
+ }, {
1586
+ "gen_ai.provider.name": GEN_AI_PROVIDER_NAME,
1587
+ "gen_ai.operation.name": GEN_AI_OPERATION_CHAT,
1588
+ "gen_ai.request.model": params.modelId,
1589
+ ...params.promptName ? { "gen_ai.prompt.name": params.promptName } : void 0,
1590
+ "server.address": GEN_AI_SERVER_ADDRESS,
1591
+ "server.port": 443,
1592
+ "gen_ai.provider.auth_mode": credential.mode
1593
+ });
1594
+ }
1595
+ /** Generate or edit images with an AI Gateway image model. */
1596
+ async function generateImages(params) {
1597
+ const provider = createGatewayProvider({
1598
+ apiKey: await getGatewayApiKey(),
1599
+ ...params.fetch ? { fetch: params.fetch } : void 0
1600
+ });
1601
+ try {
1602
+ const result = await generateImage({
1603
+ model: provider.imageModel(params.modelId),
1604
+ prompt: params.prompt,
1605
+ n: 1
1606
+ });
1607
+ const costUsd = gatewayCostUsd(result.providerMetadata);
1608
+ return {
1609
+ ...costUsd !== void 0 ? { costUsd } : void 0,
1610
+ images: result.images
1611
+ };
1612
+ } catch (error) {
1613
+ if (NoImageGeneratedError.isInstance(error)) return { images: [] };
1614
+ throw error;
1615
+ }
1616
+ }
1526
1617
  // src/chat/slack/emoji.ts
1527
1618
  const SLACK_EMOJI_NAME_RE = /^(?:[a-z0-9_+-]+)(?:::(?:skin-tone-[2-6]))?$/;
1528
1619
  function normalizeSlackEmojiName(value) {
@@ -1655,6 +1746,7 @@ const DEFAULT_DECISION_MODEL_ID = "typesafe-ai/jev";
1655
1746
  const DEFAULT_EMBEDDING_MODEL_ID = "openai/text-embedding-3-small";
1656
1747
  const DEFAULT_RERANKING_MODEL_ID = "voyage/rerank-2.5-lite";
1657
1748
  const DEFAULT_IMAGE_GENERATION_MODEL_ID = "openai/gpt-image-2";
1749
+ const DEFAULT_TRANSCRIPTION_MODEL_ID = "elevenlabs/scribe-v2";
1658
1750
  const DEFAULT_VISION_MODEL_ID = resolveGatewayModel("openai/gpt-5.6-sol").id;
1659
1751
  function validateGatewayModelId(raw) {
1660
1752
  const trimmed = toOptionalTrimmed(raw);
@@ -1692,6 +1784,7 @@ function readBotConfig(env, functionMaxDurationSeconds) {
1692
1784
  fastModelId,
1693
1785
  guardianModelId,
1694
1786
  imageGenerationModelId: toOptionalTrimmed(env["AI_IMAGE_MODEL"]) ?? DEFAULT_IMAGE_GENERATION_MODEL_ID,
1787
+ transcriptionModelId: toOptionalTrimmed(env["AI_TRANSCRIPTION_MODEL"]) ?? DEFAULT_TRANSCRIPTION_MODEL_ID,
1695
1788
  embeddingModelId: validateEmbeddingModelId(env["AI_EMBEDDING_MODEL"]) ?? DEFAULT_EMBEDDING_MODEL_ID,
1696
1789
  rerankingModelId: toOptionalTrimmed(env["AI_RERANKING_MODEL"]) ?? DEFAULT_RERANKING_MODEL_ID,
1697
1790
  loadingMessages: parseLoadingMessages(env["JUNIOR_LOADING_MESSAGES"]),
@@ -1859,6 +1952,7 @@ function setBotModelConfig(config) {
1859
1952
  if (config.guardianModelId !== void 0) botConfig.guardianModelId = requireModelId("guardianModelId", config.guardianModelId, validateGatewayModelId);
1860
1953
  if (config.rerankingModelId !== void 0) botConfig.rerankingModelId = requireModelId("rerankingModelId", config.rerankingModelId, toOptionalTrimmed);
1861
1954
  if (config.imageGenerationModelId !== void 0) botConfig.imageGenerationModelId = requireModelId("imageGenerationModelId", config.imageGenerationModelId, validateEmbeddingModelId);
1955
+ if (config.transcriptionModelId !== void 0) botConfig.transcriptionModelId = requireModelId("transcriptionModelId", config.transcriptionModelId, toOptionalTrimmed);
1862
1956
  if (config.visionModelId !== void 0) botConfig.visionModelId = requireModelId("visionModelId", config.visionModelId, validateGatewayModelId);
1863
1957
  if (config.refusalFallbackModelId !== void 0) botConfig.refusalFallbackModelId = requireModelId("refusalFallbackModelId", config.refusalFallbackModelId, validateGatewayModelId);
1864
1958
  if (config.webSearchModelId !== void 0) botConfig.webSearchModelId = requireModelId("webSearchModelId", config.webSearchModelId, validateGatewayModelId);
@@ -1875,4 +1969,4 @@ function setSlackReactionConfig(overrides) {
1875
1969
  if (overrides.processingReactionEmoji !== void 0) chatConfig.slack.processingReactionEmoji = parseReactionEmoji("processingReactionEmoji", overrides.processingReactionEmoji, chatConfig.slack.processingReactionEmoji);
1876
1970
  if (overrides.completedReactionEmoji !== void 0) chatConfig.slack.completedReactionEmoji = parseReactionEmoji("completedReactionEmoji", overrides.completedReactionEmoji, chatConfig.slack.completedReactionEmoji);
1877
1971
  }
1878
- export { estimateRequestOverheadTokens as A, ProviderError as B, completeObject as C, resolveGatewayModel as D, rerankTexts as E, isCompactionSummaryText as F, getProviderErrorUserMessage as G, createProviderError as H, renderCurrentInstruction as I, getGatewayApiKey as J, isProviderRefusal as K, unwrapCurrentInstruction as L, textCharsForTokens as M, COMPACTION_SUMMARY_PREFIX as N, requestPrefixAttributes as O, hasCompactedConversationContext as P, toOptionalTrimmed as Q, escapeXml as R, completeDecision as S, embedTexts as T, findProviderError as U, createAssistantProviderError as V, getProviderErrorAttributes as W, bufferBody as X, resolveGatewayCredential as Y, getAttachmentStorage as Z, TURN_REASONING_LEVELS as _, getRuntimeMetadata as a, GEN_AI_PROVIDER_NAME as b, getSlackClientSecret as c, restoreRuntimeConfig as d, setBotModelConfig as f, snapshotRuntimeConfig as g, setSlackReactionConfig as h, getChatConfig as i, estimateTextTokens as j, estimateMessagesTokens as k, getSlackSigningSecret as l, setRuntimeLimits as m, botConfig as n, getSlackBotToken as o, setBotName as p, isProviderRetryError as q, config_exports as r, getSlackClientId as s, DEFAULT_SQL_STATEMENT_TIMEOUT_MS as t, resetRuntimeConfig as u, toPiReasoningLevel as v, completeText as w, GEN_AI_SERVER_ADDRESS as x, normalizeSlackEmojiName as y, escapeXmlText as z };
1972
+ export { bufferBody as $, searchWeb as A, unwrapCurrentInstruction as B, completeObject as C, generateImages as D, gatewayCostUsd as E, textCharsForTokens as F, createProviderError as G, escapeXmlText as H, COMPACTION_SUMMARY_PREFIX as I, getProviderErrorUserMessage as J, findProviderError as K, hasCompactedConversationContext as L, estimateMessagesTokens as M, estimateRequestOverheadTokens as N, rerankTexts as O, estimateTextTokens as P, resolveGatewayCredential as Q, isCompactionSummaryText as R, completeDecision as S, embedTexts as T, ProviderError as U, escapeXml as V, createAssistantProviderError as W, isProviderRetryError as X, isProviderRefusal as Y, getGatewayApiKey as Z, TURN_REASONING_LEVELS as _, getRuntimeMetadata as a, GEN_AI_PROVIDER_NAME as b, getSlackClientSecret as c, restoreRuntimeConfig as d, getAttachmentStorage as et, setBotModelConfig as f, snapshotRuntimeConfig as g, setSlackReactionConfig as h, getChatConfig as i, requestPrefixAttributes as j, resolveGatewayModel as k, getSlackSigningSecret as l, setRuntimeLimits as m, botConfig as n, getSlackBotToken as o, setBotName as p, getProviderErrorAttributes as q, config_exports as r, getSlackClientId as s, DEFAULT_SQL_STATEMENT_TIMEOUT_MS as t, toOptionalTrimmed as tt, resetRuntimeConfig as u, toPiReasoningLevel as v, completeText as w, GEN_AI_SERVER_ADDRESS as x, normalizeSlackEmojiName as y, renderCurrentInstruction as z };
@@ -1,9 +1,9 @@
1
- import { pa as startOAuthFlow } from "./projection-DBq8tsA5.js";
2
- import { n as botConfig } from "./config-oGM7KA9M.js";
3
- import { I as deleteProviderIdentityForSlackUser, L as deleteProviderIdentityForUser, s as getSqlExecutor } from "./db-C-2tFxk3.js";
4
- import { u as hasRequiredOAuthScope } from "./registry-Bu0Z9BEO.js";
5
- import { n as pluginCatalogRuntime } from "./catalog-runtime-d1EM6Z0V.js";
6
- import { h as deleteMcpStoredOAuthCredentials, m as deleteMcpServerSessionId, p as deleteMcpAuthSessionsForUserProvider } from "./service-account-BcT5LR7V.js";
1
+ import { da as startOAuthFlow } from "./projection-CNKK7doO.js";
2
+ import { n as botConfig } from "./config-DdO1BNcw.js";
3
+ import { R as deleteProviderIdentityForSlackUser, s as getSqlExecutor, z as deleteProviderIdentityForUser } from "./db-EKJnkrIb.js";
4
+ import { u as hasRequiredOAuthScope } from "./registry-DBDNUUmz.js";
5
+ import { n as pluginCatalogRuntime } from "./catalog-runtime-B8ZXvXWm.js";
6
+ import { h as deleteMcpStoredOAuthCredentials, m as deleteMcpServerSessionId, p as deleteMcpAuthSessionsForUserProvider } from "./service-account-2HmlNPvy.js";
7
7
  import { randomBytes } from "node:crypto";
8
8
  // src/handlers/oauth-html.ts
9
9
  /** Build pre-escaped callback HTML with the shared response security policy. */
@@ -1,14 +1,14 @@
1
- import { Lt as moveIdleConversationDestination, Mo as readLatestConversationBrief, Ta as getSlackMessagePermalink, ga as formatSlackLink, ha as escapeSlackMrkdwnText, ji as getDashboardConversationLink, ka as postSlackMessage, wa as deleteSlackMessage } from "./projection-DBq8tsA5.js";
2
- import { A as setFirstConversationLocation, J as getStateAdapter, a as getConversationStore, nt as getConversationIdByProviderConversation, o as getDb, s as getSqlExecutor, tt as claimProviderConversation, x as withConversationMutationLock } from "./db-C-2tFxk3.js";
1
+ import { Ao as readLatestConversationBrief, Ca as getSlackMessagePermalink, Da as postSlackMessage, Lt as moveIdleConversationDestination, Sa as deleteSlackMessage, ki as getDashboardConversationLink, ma as formatSlackLink, pa as escapeSlackMrkdwnText } from "./projection-CNKK7doO.js";
2
+ import { C as withConversationMutationLock, M as setFirstConversationLocation, X as getStateAdapter, a as getConversationStore, it as getConversationIdByProviderConversation, o as getDb, rt as claimProviderConversation, s as getSqlExecutor } from "./db-EKJnkrIb.js";
3
3
  import { u as parseSlackChannelId, v as parseSlackMessageTs } from "./actor-D2iXzvlN.js";
4
- import { _r as checkSlackChannelReadAccess, vr as joinPublicChannelForRead } from "./warmup-H8uLvW9e.js";
5
- import "./store-Dgs7Oe44.js";
6
- import { F as juniorDestinations } from "./executor-NVfS8aQ2.js";
4
+ import { mr as joinPublicChannelForRead, pr as checkSlackChannelReadAccess } from "./warmup-TgY4S1vx.js";
5
+ import "./store-COeYnPL_.js";
6
+ import { I as juniorDestinations } from "./executor-CoIZmFK8.js";
7
7
  import { and, eq } from "drizzle-orm";
8
8
  // src/chat/slack/continue-in-slack.ts
9
9
  /** Refusal for a move that cannot wait for the active Run. */
10
- const BUSY = "Wait for Junior to finish, then try again.";
11
- const THREAD_TAKEN = "This thread already has a Junior conversation.";
10
+ const BUSY = "Wait for the current reply to finish, then try again.";
11
+ const THREAD_TAKEN = "This Slack thread already has a conversation.";
12
12
  const MOVED_ELSEWHERE = /* @__PURE__ */ new Error("Conversation already has a Location");
13
13
  /**
14
14
  * Return whether a Conversation can still move to a Slack thread.
@@ -25,7 +25,7 @@ function canContinueInSlack(conversation, access) {
25
25
  }
26
26
  /** Text for the first message of the Conversation in Slack. */
27
27
  async function movedMessageText(conversation, actorName) {
28
- const title = conversation.title ?? "Junior conversation";
28
+ const title = conversation.title ?? "Untitled conversation";
29
29
  const url = getDashboardConversationLink(conversation.conversationId);
30
30
  const brief = await readLatestConversationBrief(getDb(), conversation.conversationId);
31
31
  return [
@@ -1,4 +1,4 @@
1
- import { a as conversationTurnFailureReasonSchema, h as usageSchema, i as conversationTurnFailureCodeSchema } from "./history-UZ3M2M9r.js";
1
+ import { a as conversationTurnFailureReasonSchema, h as usageSchema, i as conversationTurnFailureCodeSchema } from "./history-m2-ceTTX.js";
2
2
  import * as z from "zod";
3
3
  import { codeChangeStateSchema, conversationAnnotationInputSchema, conversationEventPresentationSchema, conversationSidebarAnnotationSchema, objectFactFields, objectTypeSchema } from "@sentry/junior-plugin-api";
4
4
  // src/chat/briefs/schema.ts
@@ -155,8 +155,8 @@ const messageAttachmentSchema = z.object({
155
155
  contentType: z.string().min(1),
156
156
  bytes: z.number().int().nonnegative(),
157
157
  /**
158
- * True for a large Slack file that Junior never stores. Each read
159
- * downloads it from Slack, so it has no preview.
158
+ * True for a large Slack file that Junior has not stored yet. A
159
+ * dashboard read downloads it from Slack, so it has no preview.
160
160
  */
161
161
  pending: z.literal(true).optional()
162
162
  }).strict();
@@ -424,14 +424,6 @@ const conversationEventsQuerySchema = z.union([
424
424
  limit: conversationEventsLimitSchema
425
425
  }).strict()
426
426
  ]);
427
- const conversationFeedQuerySchema = z.object({
428
- actorEmail: z.string().trim().email().transform((value) => value.toLowerCase()).optional(),
429
- codeRepositoryId: z.string().uuid().optional(),
430
- /** `nextCursor` from the previous page of the same feed. */
431
- cursor: z.string().min(1).max(500).optional(),
432
- q: z.string().trim().max(200).optional(),
433
- status: z.enum(["active", "archived"]).default("active")
434
- }).strict();
435
427
  /** Client key that makes a retried send the same Message. */
436
428
  const idempotencyKeySchema = z.string().trim().min(1).max(200);
437
429
  const createConversationMessageBodySchema = z.object({
@@ -1024,4 +1016,4 @@ const conversationDetailReportSchema = conversationSummaryReportSchema.extend({
1024
1016
  sentryConversationUrl: z.string().optional(),
1025
1017
  sourceTask: conversationSourceTaskSchema.optional()
1026
1018
  }).strict().superRefine(validateConversationEvents);
1027
- export { briefResourceLabel as $, agentTypeInstructions as A, messageCardRef as B, createConversationBodySchema as C, idempotencyKeySchema as D, forkConversationResponseSchema as E, renameConversationBodySchema as F, MAX_ATTACHMENT_BYTES as G, readMessageCardRefs as H, renameConversationResponseSchema as I, messageAttachmentSchema as J, MAX_INPUT_ATTACHMENTS as K, conversationReadPositionSchema as L, formatAgentTypes as M, CONVERSATION_TITLE_MAX_LENGTH as N, conversationChildAgentTotalsSchema as O, conversationTitleSchema as P, briefOutcomeStatusSchema as Q, reviewItemChangeRecordSchema as R, conversationUsageSchema as S, forkConversationBodySchema as T, removedCardSchema as U, messageCardText as V, resolveMessageCards as W, briefCodeChangeSchema as X, readMessageAttachments as Y, briefLinkSchema as Z, conversationReportEventSchema as _, conversationActivityPreviewSchema as a, conversationSummaryReportSchema as b, conversationAuxiliaryCostsSchema as c, conversationEventHistorySchema as d, conversationBriefSchema as et, conversationEventPageSchema as f, conversationReportEventDataSchema as g, conversationParamsSchema as h, actorIdentitySchema as i, agentTypeSchema as j, AGENT_TYPES as k, conversationDetailQuerySchema as l, conversationFeedQuerySchema as m, CONVERSATION_VERSION_HEADER as n, parseStoredBrief as nt, conversationAttachmentParamsSchema as o, conversationEventsQuerySchema as p, inputFileSchema as q, acceptedConversationMessageSchema as r, conversationAttachmentQuerySchema as s, CONVERSATION_DETAIL_VERSION_HEADER as t, parseBriefInput as tt, conversationDetailReportSchema as u, conversationReportMessageEventSchema as v, createConversationMessageBodySchema as w, conversationSurfaceSchema as x, conversationReportStatusSchema as y, annotationCard as z };
1019
+ export { conversationBriefSchema as $, agentTypeSchema as A, messageCardText as B, createConversationMessageBodySchema as C, conversationChildAgentTotalsSchema as D, idempotencyKeySchema as E, renameConversationResponseSchema as F, MAX_INPUT_ATTACHMENTS as G, removedCardSchema as H, conversationReadPositionSchema as I, readMessageAttachments as J, inputFileSchema as K, reviewItemChangeRecordSchema as L, CONVERSATION_TITLE_MAX_LENGTH as M, conversationTitleSchema as N, AGENT_TYPES as O, renameConversationBodySchema as P, briefResourceLabel as Q, annotationCard as R, createConversationBodySchema as S, forkConversationResponseSchema as T, resolveMessageCards as U, readMessageCardRefs as V, MAX_ATTACHMENT_BYTES as W, briefLinkSchema as X, briefCodeChangeSchema as Y, briefOutcomeStatusSchema as Z, conversationReportMessageEventSchema as _, conversationActivityPreviewSchema as a, conversationSurfaceSchema as b, conversationAuxiliaryCostsSchema as c, conversationEventHistorySchema as d, parseBriefInput as et, conversationEventPageSchema as f, conversationReportEventSchema as g, conversationReportEventDataSchema as h, actorIdentitySchema as i, formatAgentTypes as j, agentTypeInstructions as k, conversationDetailQuerySchema as l, conversationParamsSchema as m, CONVERSATION_VERSION_HEADER as n, conversationAttachmentParamsSchema as o, conversationEventsQuerySchema as p, messageAttachmentSchema as q, acceptedConversationMessageSchema as r, conversationAttachmentQuerySchema as s, CONVERSATION_DETAIL_VERSION_HEADER as t, parseStoredBrief as tt, conversationDetailReportSchema as u, conversationReportStatusSchema as v, forkConversationBodySchema as w, conversationUsageSchema as x, conversationSummaryReportSchema as y, messageCardRef as z };
@@ -1,4 +1,4 @@
1
- import { J as messageAttachmentSchema, Q as briefOutcomeStatusSchema, R as reviewItemChangeRecordSchema, b as conversationSummaryReportSchema, i as actorIdentitySchema, u as conversationDetailReportSchema } from "./conversation-CY1jnBiC.js";
1
+ import { L as reviewItemChangeRecordSchema, Z as briefOutcomeStatusSchema, i as actorIdentitySchema, q as messageAttachmentSchema, u as conversationDetailReportSchema, y as conversationSummaryReportSchema } from "./conversation-BOqdRtUx.js";
2
2
  import * as z from "zod";
3
3
  // src/api/objects/cards.ts
4
4
  const MAX_LABEL_CHARS = 256;
@@ -295,12 +295,45 @@ const conversationFeedBriefSchema = z.object({
295
295
  status: briefOutcomeStatusSchema,
296
296
  summary: z.string()
297
297
  }).strict();
298
+ const conversationFeedIncludeSchema = z.enum(["links", "media"]);
299
+ /** Query of `GET /api/conversations`. */
300
+ const conversationFeedQuerySchema = z.object({
301
+ actorEmail: z.string().trim().email().transform((value) => value.toLowerCase()).optional(),
302
+ codeRepositoryId: z.string().uuid().optional(),
303
+ /** `nextCursor` from the previous page of the same feed. */
304
+ cursor: z.string().min(1).max(500).optional(),
305
+ /**
306
+ * Extra row content that costs a query, comma separated: `media` for
307
+ * each row's newest files, `links` for web links from its recent
308
+ * messages. Rows show them only where the viewer sees private content.
309
+ */
310
+ include: z.string().default("").transform((value) => [...new Set(value.split(",").filter(Boolean))]).pipe(z.array(conversationFeedIncludeSchema)),
311
+ q: z.string().trim().max(200).optional(),
312
+ status: z.enum(["active", "archived"]).default("active")
313
+ }).strict();
314
+ /**
315
+ * One stored file of a Conversation that a feed row previews, newest first.
316
+ * Read it through the Conversation's attachment route.
317
+ */
318
+ const conversationFeedMediaSchema = z.object({
319
+ contentType: z.string(),
320
+ filename: z.string(),
321
+ id: z.string().min(1)
322
+ }).strict();
298
323
  /**
299
324
  * A root in the feed, or one of its visible Threads. A Thread nests under
300
325
  * its nearest visible Thread ancestor, or under the root. Tasks never show.
301
326
  */
302
327
  const conversationFeedItemSchema = conversationSummaryReportSchema.extend({
303
328
  brief: conversationFeedBriefSchema.optional(),
329
+ /**
330
+ * Web links from the Conversation's recent messages, newest first, for
331
+ * the row to resolve into cards. URLs only: never message text. Only
332
+ * with `include=links`.
333
+ */
334
+ links: z.array(z.url()).max(3).optional(),
335
+ /** Only with `include=media`. */
336
+ media: z.array(conversationFeedMediaSchema).max(3).optional(),
304
337
  threads: z.lazy(() => z.array(conversationFeedItemSchema)).optional()
305
338
  });
306
339
  const conversationFeedSchema = z.object({
@@ -310,4 +343,4 @@ const conversationFeedSchema = z.object({
310
343
  /** Present when older conversations follow this page. */
311
344
  nextCursor: z.string().optional()
312
345
  }).strict();
313
- export { skillReportsSchema as C, webPageObjectCard as D, personObjectCard as E, skillReportSchema as S, messageObjectCard as T, pluginPackageContentReportSchema as _, conversationDetailWithMailboxReportSchema as a, runtimeInfoReportSchema as b, conversationPendingMessageSchema as c, steerConversationPendingMessagesBodySchema as d, steerConversationPendingMessagesResponseSchema as f, pluginPackageContentItemReportSchema as g, pluginOperationalReportSchema as h, cancelConversationPendingMessagesResponseSchema as i, conversationPendingMessagesReportSchema as l, pluginOperationalReportFeedSchema as m, conversationFeedSchema as n, conversationPendingAuthorizationSchema as o, healthReportSchema as p, cancelConversationPendingMessagesBodySchema as r, conversationPendingMessageDeliverySchema as s, conversationFeedBriefSchema as t, conversationUnchangedDetailWithMailboxSchema as u, pluginSchema as v, conversationObjectCard as w, skillDetailReportSchema as x, pluginsSchema as y };
346
+ export { skillReportSchema as C, personObjectCard as D, messageObjectCard as E, webPageObjectCard as O, skillDetailReportSchema as S, conversationObjectCard as T, pluginPackageContentItemReportSchema as _, cancelConversationPendingMessagesResponseSchema as a, pluginsSchema as b, conversationPendingMessageDeliverySchema as c, conversationUnchangedDetailWithMailboxSchema as d, steerConversationPendingMessagesBodySchema as f, pluginOperationalReportSchema as g, pluginOperationalReportFeedSchema as h, cancelConversationPendingMessagesBodySchema as i, conversationPendingMessageSchema as l, healthReportSchema as m, conversationFeedQuerySchema as n, conversationDetailWithMailboxReportSchema as o, steerConversationPendingMessagesResponseSchema as p, conversationFeedSchema as r, conversationPendingAuthorizationSchema as s, conversationFeedBriefSchema as t, conversationPendingMessagesReportSchema as u, pluginPackageContentReportSchema as v, skillReportsSchema as w, runtimeInfoReportSchema as x, pluginSchema as y };
@@ -1,5 +1,6 @@
1
- import { h as logWarn } from "./logging-DiyqRLBx.js";
1
+ import { h as logWarn } from "./logging-QSZuMcvo.js";
2
2
  import { AsyncLocalStorage } from "node:async_hooks";
3
+ import { renderSystemMessageUpdate } from "@earendil-works/pi-ai";
3
4
  // src/chat/conversation-privacy.ts
4
5
  const SAFE_METADATA_KEY_LIMIT = 20;
5
6
  const conversationPrivacyStorage = new AsyncLocalStorage();
@@ -133,10 +134,17 @@ function toCanonicalOutputMessage(message) {
133
134
  };
134
135
  }
135
136
  /**
136
- * Map a pi-ai Message (user/assistant/toolResult) to the canonical
137
+ * Map a pi-ai Message (system/user/assistant/toolResult) to the canonical
137
138
  * gen_ai.input.messages shape: `{ role, parts: [...] }`.
138
139
  */
139
140
  function toCanonicalInputMessage(message) {
141
+ if (message.role === "system") return {
142
+ role: "system",
143
+ parts: [{
144
+ type: "text",
145
+ content: renderSystemMessageUpdate(message)
146
+ }]
147
+ };
140
148
  if (message.role === "user") return {
141
149
  role: "user",
142
150
  parts: typeof message.content === "string" ? [{
@@ -1,22 +1,22 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-BKpuH2hG.js";
2
- import { B as blockScheduledAutomation, E as notifyAutomationBlocked, X as blockEventAutomation, a as getPersistedThreadState, c as coerceThreadConversationState, g as getDispatchRecord, i as getPersistedSandboxState, k as readAutomationExecutionByConversationId, m as getDispatchIdForConversation, s as persistThreadStateById } from "./turn-session-routing-DGvn9MSl.js";
3
- import { C as isPersonInput, D as turnBehavior, a as getConversationStore, ft as nextDetailVersion, o as getDb, r as getConversationEventStore, s as getSqlExecutor, w as isTopLevelKind } from "./db-C-2tFxk3.js";
4
- import { E as withSpan, S as setTags, h as logWarn, p as logException } from "./logging-DiyqRLBx.js";
5
- import { Y as readMessageAttachments } from "./conversation-CY1jnBiC.js";
6
- import { M as juniorConversations } from "./executor-NVfS8aQ2.js";
7
- import { c as buildDeliveredTurnStatePatch, l as loadPendingMessageCards, o as completeAuthPauseTurn, r as finalizeFailedTurnReplyWithEvent, t as buildTurnThreadContext } from "./thread-context-BPky1KBe.js";
8
- import { Et as resolveConversationDestination, Gn as AgentRunError, Hn as createWebAuthorization, Kn as executeTurn, jn as supersedeOpenMailboxTurns, on as childAgentTurnOptions, sn as isParentMessageMeta, un as readParentMessage, xn as completeCancelledConversationTurn } from "./warmup-H8uLvW9e.js";
9
- import { A as latestConversationMessageSeq, I as upsertConversationMessage, M as normalizeConversationText, N as recordDeliveredAssistantMessage, a as loadProjection, at as failTurnRecord, b as persistConversationMessages, bn as persistWithRetry, j as markConversationMessage, ki as verifyTimerWatchCredentialSubject, nt as saveTurnCheckpoint, st as getTurnRecord, t as commitAcceptedReply, un as getAssistantReplyText, v as hydrateConversationMessages } from "./projection-DBq8tsA5.js";
10
- import { R as buildDeterministicTurnId, _ as ConversationTurnLifecycleService, d as isTurnInputCommitLostError, g as startActiveTurn, h as markTurnFailed, l as getConversationTurnBoundaryError, s as TurnInputCommitLostError, t as getTurnUserMessage } from "./turn-user-message-19CkuUvM.js";
11
- import { f as credentialContextForActor } from "./registry-Bu0Z9BEO.js";
2
+ import { B as blockScheduledAutomation, E as notifyAutomationBlocked, X as blockEventAutomation, a as getPersistedThreadState, c as coerceThreadConversationState, g as getDispatchRecord, i as getPersistedSandboxState, k as readAutomationExecutionByConversationId, m as getDispatchIdForConversation, s as persistThreadStateById } from "./turn-session-routing-CaY3Tp8m.js";
3
+ import { E as isTopLevelKind, T as isPersonInput, a as getConversationStore, k as turnBehavior, mt as nextDetailVersion, o as getDb, r as getConversationEventStore, s as getSqlExecutor } from "./db-EKJnkrIb.js";
4
+ import { E as withSpan, S as setTags, h as logWarn, p as logException } from "./logging-QSZuMcvo.js";
5
+ import { J as readMessageAttachments } from "./conversation-BOqdRtUx.js";
6
+ import { N as juniorConversations } from "./executor-CoIZmFK8.js";
7
+ import { c as buildDeliveredTurnStatePatch, l as loadPendingMessageCards, o as completeAuthPauseTurn, r as finalizeFailedTurnReplyWithEvent, t as buildTurnThreadContext } from "./thread-context-Cg0jt0aE.js";
8
+ import { Hn as AgentRunError, On as supersedeOpenMailboxTurns, Ot as resolveConversationDestination, Un as executeTurn, in as isParentMessageMeta, rn as childAgentTurnOptions, sn as readParentMessage, vn as completeCancelledConversationTurn, zn as createWebAuthorization } from "./warmup-TgY4S1vx.js";
9
+ import { A as latestConversationMessageSeq, Di as verifyTimerWatchCredentialSubject, I as upsertConversationMessage, M as normalizeConversationText, N as recordDeliveredAssistantMessage, a as loadProjection, at as failTurnRecord, b as persistConversationMessages, bn as persistWithRetry, j as markConversationMessage, nt as saveTurnCheckpoint, st as getTurnRecord, t as commitAcceptedReply, un as getAssistantReplyText, v as hydrateConversationMessages } from "./projection-CNKK7doO.js";
10
+ import { R as buildDeterministicTurnId, _ as ConversationTurnLifecycleService, d as isTurnInputCommitLostError, g as startActiveTurn, h as markTurnFailed, l as getConversationTurnBoundaryError, s as TurnInputCommitLostError, t as getTurnUserMessage } from "./turn-user-message-tcom1RYd.js";
11
+ import { f as credentialContextForActor } from "./registry-DBDNUUmz.js";
12
12
  import { i as getActiveSpan, r as continueTrace } from "./sentry-CPbZjomA.js";
13
- import { i as measureTurnCompactionWait } from "./agent-runner-BP8_DLUv.js";
14
- import { n as botConfig } from "./config-oGM7KA9M.js";
15
- import { D as turnInputFactsFromConversationMessage, E as sourceFromTurnInput, I as maybePostAutomatedTurnLimitNotice, M as isEventMailboxMetadata, N as renderEventBatchInputs, O as legacyWebMailboxMetadataSchema, P as timerWatchCredentialSubject, U as recordFinishedTurnForAutomatedLimit, c as loadReviewItemInput, f as buildSteeringPiMessage, g as withoutSavedSteeringMessages, j as eventBatchMessageMeta, m as instructionForInputs, p as instructionActorFor, s as eventReviewItemInputs, x as getEventBatchDelayMs } from "./session-stop-BLLp1IP_.js";
16
- import { n as scheduleSessionCompletedPluginTasks, t as processPluginTask } from "./task-runner-BGXF7Fo7.js";
17
- import { p as instructionProvenanceFor } from "./history-UZ3M2M9r.js";
18
- import { o as isEventConversationMessage } from "./prompt-D2KlJopL.js";
19
- import { t as readConversationLineage } from "./lineage-HGLhd_-N.js";
13
+ import { i as measureTurnCompactionWait } from "./agent-runner-CoEeZSRh.js";
14
+ import { n as botConfig } from "./config-DdO1BNcw.js";
15
+ import { D as turnInputFactsFromConversationMessage, E as sourceFromTurnInput, I as maybePostAutomatedTurnLimitNotice, M as isEventMailboxMetadata, N as renderEventBatchInputs, O as legacyWebMailboxMetadataSchema, P as timerWatchCredentialSubject, U as recordFinishedTurnForAutomatedLimit, c as loadReviewItemInput, f as buildSteeringPiMessage, g as withoutSavedSteeringMessages, j as eventBatchMessageMeta, m as instructionForInputs, p as instructionActorFor, s as eventReviewItemInputs, x as getEventBatchDelayMs } from "./session-stop-DEeZKqbX.js";
16
+ import { n as scheduleSessionCompletedPluginTasks, t as processPluginTask } from "./task-runner-CJF7zIJL.js";
17
+ import { p as instructionProvenanceFor } from "./history-m2-ceTTX.js";
18
+ import { o as isEventConversationMessage } from "./prompt-DSjhoKu5.js";
19
+ import { t as readConversationLineage } from "./lineage-C5DGQCS_.js";
20
20
  import { isDeepStrictEqual } from "node:util";
21
21
  import { createHash } from "node:crypto";
22
22
  import { and, eq, isNotNull, isNull } from "drizzle-orm";
@@ -1,19 +1,19 @@
1
- import { $n as resolvePluginOAuthAccount, Qo as getSlackClient, Z as getConversationPendingAuth, Zn as createUserTokenStore, d as recordAuthorizationCompleted, da as parseOAuthStatePayload, fa as resolveBaseUrl, ka as postSlackMessage, st as getTurnRecord, u as recordAuthenticationLinked, ua as formatProviderLabel } from "./projection-DBq8tsA5.js";
2
- import { R as escapeXml, a as getRuntimeMetadata, n as botConfig } from "./config-oGM7KA9M.js";
3
- import { W as isNativeIdentityProvider, _ as runBestEffort, h as logWarn, p as logException } from "./logging-DiyqRLBx.js";
1
+ import { Da as postSlackMessage, Yn as createUserTokenStore, Z as getConversationPendingAuth, Zn as resolvePluginOAuthAccount, ca as formatProviderLabel, d as recordAuthorizationCompleted, is as getSlackClient, la as parseOAuthStatePayload, st as getTurnRecord, u as recordAuthenticationLinked, ua as resolveBaseUrl } from "./projection-CNKK7doO.js";
2
+ import { V as escapeXml, a as getRuntimeMetadata, n as botConfig } from "./config-DdO1BNcw.js";
3
+ import { W as isNativeIdentityProvider, _ as runBestEffort, h as logWarn, p as logException } from "./logging-QSZuMcvo.js";
4
4
  import { p as parseSlackUserId } from "./actor-D2iXzvlN.js";
5
- import { H as upsertLinkedIdentity, J as getStateAdapter, P as resolveActorIdentityId, Q as acquireActiveLock, R as findUserByVerifiedEmails, s as getSqlExecutor } from "./db-C-2tFxk3.js";
5
+ import { B as findUserByVerifiedEmails, I as resolveActorIdentityId, W as upsertLinkedIdentity, X as getStateAdapter, et as acquireActiveLock, s as getSqlExecutor } from "./db-EKJnkrIb.js";
6
6
  import { i as homeDir } from "./package-discovery-x4AvVhMj.js";
7
- import { n as buildOAuthTokenRequest, r as parseOAuthTokenResponse, u as hasRequiredOAuthScope } from "./registry-Bu0Z9BEO.js";
8
- import { n as pluginCatalogRuntime } from "./catalog-runtime-d1EM6Z0V.js";
9
- import { t as discoverSkills } from "./skills-CNAGH4ju.js";
10
- import { o as finalizeMcpAuthorization } from "./agent-runner-BP8_DLUv.js";
11
- import { O as getMcpProviderErrorAttributes, S as putMcpStoredOAuthCredentials, f as deleteMcpAuthSession, g as getMcpAuthSession, v as getMcpStoredOAuthCredentials } from "./service-account-BcT5LR7V.js";
12
- import { o as readIdentityById } from "./viewer-BPQHMx3-.js";
7
+ import { n as buildOAuthTokenRequest, r as parseOAuthTokenResponse, u as hasRequiredOAuthScope } from "./registry-DBDNUUmz.js";
8
+ import { n as pluginCatalogRuntime } from "./catalog-runtime-B8ZXvXWm.js";
9
+ import { t as discoverSkills } from "./skills-2UrD7JkN.js";
10
+ import { o as finalizeMcpAuthorization } from "./agent-runner-CoEeZSRh.js";
11
+ import { O as getMcpProviderErrorAttributes, S as putMcpStoredOAuthCredentials, f as deleteMcpAuthSession, g as getMcpAuthSession, v as getMcpStoredOAuthCredentials } from "./service-account-2HmlNPvy.js";
12
+ import { o as readIdentityById } from "./viewer-Cf8ISkAc.js";
13
13
  import { t as readJuniorSecret } from "./secrets-DHaJ5TTn.js";
14
- import { Fn as wakeAuthorizedTurn, In as wakePausedTurn, L as lookupSlackUserProfile, Un as deleteWebAuthorization } from "./warmup-H8uLvW9e.js";
15
- import { a as getPersistedThreadState, c as coerceThreadConversationState } from "./turn-session-routing-DGvn9MSl.js";
16
- import { i as readConnectedOAuthTokens, s as htmlCallbackResponse } from "./connections-BlikzEJv.js";
14
+ import { Bn as deleteWebAuthorization, L as lookupSlackUserProfile, Mn as wakeAuthorizedTurn, Nn as wakePausedTurn } from "./warmup-TgY4S1vx.js";
15
+ import { a as getPersistedThreadState, c as coerceThreadConversationState } from "./turn-session-routing-CaY3Tp8m.js";
16
+ import { i as readConnectedOAuthTokens, s as htmlCallbackResponse } from "./connections-D20kp0j5.js";
17
17
  import { n as relayLocalOAuthCallback } from "./oauth-relay-DAmfVmJu.js";
18
18
  import * as z from "zod";
19
19
  import path from "node:path";
@@ -432,7 +432,7 @@ async function linkOAuthAccountIdentity(args) {
432
432
  const actorUserId = await resolveOAuthActorUserId(args.actor);
433
433
  const emailMatch = await findUserByVerifiedEmails(executor, args.verifiedEmails);
434
434
  const userId = actorUserId ?? emailMatch?.userId;
435
- if (!userId) throw new Error("OAuth account has no Junior user to link");
435
+ if (!userId) throw new Error("OAuth account has no User to link");
436
436
  const email = emailMatch?.userId === userId ? emailMatch.email : void 0;
437
437
  await upsertLinkedIdentity(executor, userId, {
438
438
  kind: "user",