@sentry/junior 0.255.0 → 0.257.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 (68) hide show
  1. package/dist/{admin-CeJh4SuR.js → admin-DgIkm6Vy.js} +1 -1
  2. package/dist/{agent-hooks-CDVx26Uu.js → agent-hooks-BjtTzvru.js} +13 -13
  3. package/dist/{agent-invocations-BY60iNw-.js → agent-invocations-Bdu3ROfo.js} +2 -1
  4. package/dist/{agent-runner-Caiof09f.js → agent-runner-D7OboVb3.js} +41 -33
  5. package/dist/api/schema.d.ts +41 -1
  6. package/dist/api/schema.js +2 -2
  7. package/dist/api.js +121 -33
  8. package/dist/{app-B0gT1Slp.d.ts → app-BsU5QNBd.d.ts} +7 -1
  9. package/dist/app.d.ts +1 -1
  10. package/dist/app.js +587 -210
  11. package/dist/{assistant-reply-BddmM66R.js → assistant-reply-CbTPebzL.js} +1 -1
  12. package/dist/{briefs-iVq_8-ft.js → briefs-oLOldnDM.js} +4 -4
  13. package/dist/{catalog-runtime-hKmI-iZa.js → catalog-runtime-CZzhGQ7F.js} +1 -1
  14. package/dist/cli/chat.js +16 -16
  15. package/dist/cli/check.js +3 -3
  16. package/dist/cli/main.js +2 -2
  17. package/dist/cli/plugins.js +4 -4
  18. package/dist/cli/snapshot-create.js +3 -3
  19. package/dist/cli/upgrade.js +3 -3
  20. package/dist/{client-Clj7onnT.js → client-D8HnkOQX.js} +2 -2
  21. package/dist/{config-BDAfLTI9.js → config-CJRnWK9H.js} +2 -2
  22. package/dist/{connections-BC0RTejT.js → connections-ClYrKzpX.js} +16 -11
  23. package/dist/{conversation-T18Xlkx9.js → conversation-CKNLYBJt.js} +3 -2
  24. package/dist/{conversation-privacy-1ERtieuM.js → conversation-privacy-C8b1nphZ.js} +1 -1
  25. package/dist/{credential-sync-BZuqqIHk.js → credential-sync-BXfohNmJ.js} +82 -40
  26. package/dist/{executor-Dh4Ofsnx.js → executor-Do0THDRR.js} +33 -23
  27. package/dist/{experimental-Qn9rKLgx.js → experimental-CQIvMUO7.js} +1 -0
  28. package/dist/{images-C-WOnTc_.js → images-BN_BiBXF.js} +3 -3
  29. package/dist/instrumentation.js +2 -2
  30. package/dist/{job-queue-BaCL36FY.js → job-queue-B6SV9uVa.js} +1 -1
  31. package/dist/{logging-D3aYP0aG.js → logging-CWxiIuCF.js} +50 -15
  32. package/dist/{message-B9xqD2BP.js → message-TUOdbSBW.js} +3 -3
  33. package/dist/nitro.d.ts +1 -1
  34. package/dist/nitro.js +3 -3
  35. package/dist/{oauth-callback-server-i5qdAou6.js → oauth-callback-server-Dj5UJODo.js} +2 -2
  36. package/dist/{pending-auth-D2t1Moxf.js → pending-auth-s_QFribU.js} +3 -3
  37. package/dist/{profile-DnkX3e2S.js → profile-h-72wM78.js} +4 -4
  38. package/dist/{prompt-C04mP1hu.js → prompt-DyoEj9c2.js} +1 -1
  39. package/dist/{registry-CmKmKHpp.js → registry-sLTr-sV9.js} +43 -3
  40. package/dist/{resolve-jfNHtEBx.js → resolve-ncQPZROQ.js} +2 -2
  41. package/dist/{result-Df5nEDX2.js → result-C883vngT.js} +7 -7
  42. package/dist/{runner-CmzoXEI4.js → runner-CzYImdOF.js} +10 -10
  43. package/dist/{sandbox-egress-signals-DjMNKLZz.js → sandbox-egress-signals-CZbMINHI.js} +1 -1
  44. package/dist/{schema-BBgv0MNf.js → schema-Dy69D4Ge.js} +4 -3
  45. package/dist/{session-stop-BEBfE97J.js → session-stop-CQjKd4a2.js} +46 -20
  46. package/dist/{skills-Dc-AMYi4.js → skills-C22SLruK.js} +2 -2
  47. package/dist/{spawn-OgTwBUj0.js → spawn-DY9CLXDL.js} +2 -2
  48. package/dist/{store-BashBewg.js → store-DXFIQy-G.js} +6 -6
  49. package/dist/{task-queue-VvIKqlQ4.js → task-queue-B17vV0La.js} +3 -3
  50. package/dist/{task-runner-D2CpD6GN.js → task-runner-DUjvzYXj.js} +11 -11
  51. package/dist/{tasks-dJooqiip.js → tasks-D_WIJtvO.js} +25 -10
  52. package/dist/{thread-state-CsMC-ob0.js → thread-state-Ch4yuCqG.js} +7 -7
  53. package/dist/{turn-failure-response-zB364t7_.js → turn-failure-response-C5nBKC4S.js} +8 -8
  54. package/dist/{turn-lifecycle-BfodfmiY.js → turn-lifecycle-CO-ylUmV.js} +1 -1
  55. package/dist/{turn-session-routing-BAh_qsBJ.js → turn-session-routing-B3LWooK5.js} +1 -1
  56. package/dist/{validation-LzIilOb6.js → validation-CXYxaNYx.js} +1 -1
  57. package/dist/{version-CDM8Rq6E.js → version-BcdZy2zg.js} +1 -1
  58. package/dist/version.js +1 -1
  59. package/dist/{viewer-Rnim7alE.js → viewer-DSZXygMU.js} +53 -5
  60. package/dist/{web-input-Dc1VwcT4.js → web-input-B9Bv0_lR.js} +73 -75
  61. package/dist/{work-BAn43SsN.js → work-nAfDSUFP.js} +9 -9
  62. package/dist/{worker-mBXq4_zg.js → worker-vGXZ6XFT.js} +5 -5
  63. package/migrations/0059_automation_run_version.sql +2 -0
  64. package/migrations/0060_identity_signed_in_at.sql +1 -0
  65. package/migrations/meta/0059_snapshot.json +3619 -0
  66. package/migrations/meta/0060_snapshot.json +3465 -0
  67. package/migrations/meta/_journal.json +15 -1
  68. package/package.json +6 -5
@@ -1,4 +1,4 @@
1
- import { st as extractAssistantText } from "./tasks-dJooqiip.js";
1
+ import { ct as extractAssistantText } from "./tasks-D_WIJtvO.js";
2
2
  //#region src/chat/no-reply.ts
3
3
  const NO_REPLY_MARKER = "[[NO_REPLY]]";
4
4
  /**
@@ -1,7 +1,7 @@
1
- import { r as completeObject } from "./client-Clj7onnT.js";
1
+ import { r as completeObject } from "./client-D8HnkOQX.js";
2
2
  import { r as defaultModelId } from "./model-profile-BwU8mqwD.js";
3
- import { U as parseBriefInput, d as conversationDetailReportSchema, p as conversationEventPageSchema, z as briefCodeChangeSchema } from "./conversation-T18Xlkx9.js";
4
- import { n as briefEntriesFromReportEvents, s as generateBrief, t as BRIEF_PROMPT } from "./prompt-C04mP1hu.js";
3
+ import { U as parseBriefInput, d as conversationDetailReportSchema, p as conversationEventPageSchema, z as briefCodeChangeSchema } from "./conversation-CKNLYBJt.js";
4
+ import { n as briefEntriesFromReportEvents, s as generateBrief, t as BRIEF_PROMPT } from "./prompt-DyoEj9c2.js";
5
5
  import { CLI_USAGE } from "./cli/run.js";
6
6
  import path from "node:path";
7
7
  import { z } from "zod";
@@ -269,7 +269,7 @@ async function parseRunOptions(argv) {
269
269
  * `DATABASE_URL` at import, and `briefs pull` must work with only a token.
270
270
  */
271
271
  async function configuredDefaultModelId() {
272
- const { botConfig } = await import("./config-BDAfLTI9.js").then((n) => n.r);
272
+ const { botConfig } = await import("./config-CJRnWK9H.js").then((n) => n.r);
273
273
  return defaultModelId(botConfig);
274
274
  }
275
275
  function apiUrl(baseUrl, pathname) {
@@ -1,5 +1,5 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-B4FMCO8f.js";
2
- import { t as createPluginCatalogRuntime } from "./registry-CmKmKHpp.js";
2
+ import { t as createPluginCatalogRuntime } from "./registry-sLTr-sV9.js";
3
3
  //#region src/chat/plugins/catalog-runtime.ts
4
4
  var catalog_runtime_exports = /* @__PURE__ */ __exportAll({ pluginCatalogRuntime: () => pluginCatalogRuntime });
5
5
  const pluginCatalogRuntime = createPluginCatalogRuntime();
package/dist/cli/chat.js CHANGED
@@ -1,4 +1,4 @@
1
- import { n as executeAgentRun, t as createAgentRunner } from "../agent-runner-Caiof09f.js";
1
+ import { n as executeAgentRun, t as createAgentRunner } from "../agent-runner-D7OboVb3.js";
2
2
  import { t as loadAppPluginSet } from "../plugin-module-CVvEUSMH.js";
3
3
  import path from "node:path";
4
4
  import { createHash, randomUUID } from "node:crypto";
@@ -100,10 +100,10 @@ async function loadLocalPluginSet() {
100
100
  async function configureLocalChatPlugins(pluginSet) {
101
101
  const [pluginsModule, agentHooksModule, catalogRuntimeModule, validationModule, databaseModule] = await Promise.all([
102
102
  import("../plugins-egKWjgue.js").then((n) => n.o),
103
- import("../agent-hooks-CDVx26Uu.js").then((n) => n.t),
104
- import("../catalog-runtime-hKmI-iZa.js").then((n) => n.t),
105
- import("../validation-LzIilOb6.js").then((n) => n.r),
106
- import("../viewer-Rnim7alE.js").then((n) => n.s)
103
+ import("../agent-hooks-BjtTzvru.js").then((n) => n.t),
104
+ import("../catalog-runtime-CZzhGQ7F.js").then((n) => n.t),
105
+ import("../validation-CXYxaNYx.js").then((n) => n.r),
106
+ import("../viewer-DSZXygMU.js").then((n) => n.c)
107
107
  ]);
108
108
  const resolvedPluginSet = pluginSet === void 0 ? await loadLocalPluginSet() : pluginSet ?? void 0;
109
109
  const plugins = pluginsModule.pluginRuntimeRegistrationsFromPluginSet(resolvedPluginSet);
@@ -153,21 +153,21 @@ function localDevServerUrl() {
153
153
  async function prepareLocalChatRun(io, pluginSet) {
154
154
  defaultStateAdapterForLocalChat();
155
155
  await configureLocalChatPlugins(pluginSet);
156
- const { setExperimentalFeatures } = await import("../experimental-Qn9rKLgx.js").then((n) => n.t);
156
+ const { setExperimentalFeatures } = await import("../experimental-CQIvMUO7.js").then((n) => n.t);
157
157
  setExperimentalFeatures({ subagents: true });
158
- const { setBriefsConfig } = await import("../agent-hooks-CDVx26Uu.js").then((n) => n.m);
158
+ const { setBriefsConfig } = await import("../agent-hooks-BjtTzvru.js").then((n) => n.m);
159
159
  setBriefsConfig({ enabled: true });
160
- const { runLocalAgentTurn } = await import("../runner-CmzoXEI4.js");
161
- const { startLocalOAuthCallbackServer } = await import("../oauth-callback-server-i5qdAou6.js");
160
+ const { runLocalAgentTurn } = await import("../runner-CzYImdOF.js");
161
+ const { startLocalOAuthCallbackServer } = await import("../oauth-callback-server-Dj5UJODo.js");
162
162
  const { createLocalOAuthState } = await import("../oauth-relay-CdCnu80W.js").then((n) => n.t);
163
- const { createLocalSandboxEgressSignalTransport } = await import("../sandbox-egress-signals-DjMNKLZz.js");
164
- const { bindSpawnAgent } = await import("../spawn-OgTwBUj0.js").then((n) => n.n);
165
- const { bindMessageAgent } = await import("../message-B9xqD2BP.js").then((n) => n.n);
166
- const { createAgentInvocationWorker, routeAgentInvocationWork } = await import("../work-BAn43SsN.js").then((n) => n.a);
167
- const { startAgentInvocationsForChildInput } = await import("../result-Df5nEDX2.js").then((n) => n.r);
168
- const { skipInputBeforeConversationStop } = await import("../session-stop-BEBfE97J.js").then((n) => n.r);
163
+ const { createLocalSandboxEgressSignalTransport } = await import("../sandbox-egress-signals-CZbMINHI.js");
164
+ const { bindSpawnAgent } = await import("../spawn-DY9CLXDL.js").then((n) => n.n);
165
+ const { bindMessageAgent } = await import("../message-TUOdbSBW.js").then((n) => n.n);
166
+ const { createAgentInvocationWorker, routeAgentInvocationWork } = await import("../work-nAfDSUFP.js").then((n) => n.a);
167
+ const { startAgentInvocationsForChildInput } = await import("../result-C883vngT.js").then((n) => n.r);
168
+ const { skipInputBeforeConversationStop } = await import("../session-stop-CQjKd4a2.js").then((n) => n.r);
169
169
  const { createLocalConversationWork } = await import("../conversation-work-C6y3T5Hx.js");
170
- const { processConversationWork } = await import("../worker-mBXq4_zg.js").then((n) => n.n);
170
+ const { processConversationWork } = await import("../worker-vGXZ6XFT.js").then((n) => n.n);
171
171
  let agentRunner;
172
172
  const localConversationWork = createLocalConversationWork(async (message) => {
173
173
  if (!agentRunner) throw new Error("Local agent runner is not ready");
package/dist/cli/check.js CHANGED
@@ -1,6 +1,6 @@
1
- import { D as JUNIOR_HEARTBEAT_ROUTE, M as LEGACY_JUNIOR_CONVERSATION_WORK_FUNCTION, T as JUNIOR_CONVERSATION_WORK_CALLBACK_ROUTE } from "../logging-D3aYP0aG.js";
2
- import { _ as parsePluginManifest, g as parseInlinePluginManifest } from "../registry-CmKmKHpp.js";
3
- import { i as parseSkillFile } from "../skills-Dc-AMYi4.js";
1
+ import { E as JUNIOR_CONVERSATION_WORK_CALLBACK_ROUTE, N as LEGACY_JUNIOR_CONVERSATION_WORK_FUNCTION, O as JUNIOR_HEARTBEAT_ROUTE } from "../logging-CWxiIuCF.js";
2
+ import { v as parseInlinePluginManifest, y as parsePluginManifest } from "../registry-sLTr-sV9.js";
3
+ import { i as parseSkillFile } from "../skills-C22SLruK.js";
4
4
  import path from "node:path";
5
5
  import fs from "node:fs/promises";
6
6
  import { pathToFileURL } from "node:url";
package/dist/cli/main.js CHANGED
@@ -25,10 +25,10 @@ async function runChat(argv, pluginSet) {
25
25
  return await (await import("./chat.js")).runChat(argv, void 0, { pluginSet });
26
26
  }
27
27
  async function runAdmin(argv) {
28
- return await (await import("../admin-CeJh4SuR.js")).runAdmin(argv);
28
+ return await (await import("../admin-DgIkm6Vy.js")).runAdmin(argv);
29
29
  }
30
30
  async function runBriefs(argv) {
31
- return await (await import("../briefs-iVq_8-ft.js")).runBriefs(argv);
31
+ return await (await import("../briefs-oLOldnDM.js")).runBriefs(argv);
32
32
  }
33
33
  function topLevelCommand(argv) {
34
34
  return (argv[0] === "--" ? argv.slice(1) : argv)[0];
@@ -1,7 +1,7 @@
1
- import { d as getDb } from "../viewer-Rnim7alE.js";
2
- import { n as pluginCatalogRuntime } from "../catalog-runtime-hKmI-iZa.js";
3
- import { d as setPlugins, f as validatePlugins, ft as createPluginLogger } from "../agent-hooks-CDVx26Uu.js";
4
- import { n as validatePluginRegistrations, t as validatePluginEgressCredentialHooks } from "../validation-LzIilOb6.js";
1
+ import { f as getDb } from "../viewer-DSZXygMU.js";
2
+ import { n as pluginCatalogRuntime } from "../catalog-runtime-CZzhGQ7F.js";
3
+ import { d as setPlugins, f as validatePlugins, ft as createPluginLogger } from "../agent-hooks-BjtTzvru.js";
4
+ import { n as validatePluginRegistrations, t as validatePluginEgressCredentialHooks } from "../validation-CXYxaNYx.js";
5
5
  import { a as pluginRuntimeRegistrationsFromPluginSet, i as pluginCliRegistrationsFromPluginSet, r as pluginCatalogConfigFromPluginSet } from "../plugins-egKWjgue.js";
6
6
  import { t as loadAppPluginSet } from "../plugin-module-CVvEUSMH.js";
7
7
  import { stderr, stdout } from "node:process";
@@ -1,6 +1,6 @@
1
- import { n as pluginCatalogRuntime } from "../catalog-runtime-hKmI-iZa.js";
2
- import { S as disconnectStateAdapter, t as create } from "../profile-DnkX3e2S.js";
3
- import { r as resolve } from "../resolve-jfNHtEBx.js";
1
+ import { n as pluginCatalogRuntime } from "../catalog-runtime-CZzhGQ7F.js";
2
+ import { S as disconnectStateAdapter, t as create } from "../profile-h-72wM78.js";
3
+ import { r as resolve } from "../resolve-ncQPZROQ.js";
4
4
  //#region src/cli/snapshot-create.ts
5
5
  const DEFAULT_RUNTIME = "node22";
6
6
  const DEFAULT_TIMEOUT_MS = 6e5;
@@ -1,6 +1,6 @@
1
- import { i as getChatConfig } from "../config-BDAfLTI9.js";
2
- import { t as createJuniorSqlExecutor } from "../executor-Dh4Ofsnx.js";
3
- import { t as createPluginCatalogRuntime } from "../registry-CmKmKHpp.js";
1
+ import { i as getChatConfig } from "../config-CJRnWK9H.js";
2
+ import { t as createJuniorSqlExecutor } from "../executor-Do0THDRR.js";
3
+ import { t as createPluginCatalogRuntime } from "../registry-sLTr-sV9.js";
4
4
  import { n as pluginCatalogConfigFromEnv, r as pluginCatalogConfigFromPluginSet, t as defineJuniorPlugins } from "../plugins-egKWjgue.js";
5
5
  import { t as loadAppPluginSet } from "../plugin-module-CVvEUSMH.js";
6
6
  import { basename, dirname, join, resolve } from "node:path";
@@ -1,5 +1,5 @@
1
- import { d as logException, g as serializeGenAiAttribute, i as extractGenAiUsageAttributes, m as normalizeGenAiFinishReason, p as logWarn, w as withSpan } from "./logging-D3aYP0aG.js";
2
- import { a as toCanonicalInputMessage, n as getCurrentConversationPrivacy, o as toCanonicalOutputMessage, s as toGenAiMessagesTraceAttributes } from "./conversation-privacy-1ERtieuM.js";
1
+ import { T as withSpan, _ as serializeGenAiAttribute, f as logException, h as normalizeGenAiFinishReason, i as extractGenAiUsageAttributes, m as logWarn } from "./logging-CWxiIuCF.js";
2
+ import { a as toCanonicalInputMessage, n as getCurrentConversationPrivacy, o as toCanonicalOutputMessage, s as toGenAiMessagesTraceAttributes } from "./conversation-privacy-C8b1nphZ.js";
3
3
  import { calculateCost, completeSimple, getEnvApiKey, getModels, registerApiProvider } from "@earendil-works/pi-ai/compat";
4
4
  import { stream as streamAnthropic, streamSimple as streamSimpleAnthropic } from "@earendil-works/pi-ai/api/anthropic-messages";
5
5
  import { createGatewayProvider } from "@ai-sdk/gateway";
@@ -1,6 +1,6 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-B4FMCO8f.js";
2
- import { S as toOptionalTrimmed, o as resolveGatewayModel } from "./client-Clj7onnT.js";
3
- import { p as logWarn } from "./logging-D3aYP0aG.js";
2
+ import { S as toOptionalTrimmed, o as resolveGatewayModel } from "./client-D8HnkOQX.js";
3
+ import { m as logWarn } from "./logging-CWxiIuCF.js";
4
4
  import { l as TURN_REASONING_LEVELS, s as modelProfileSchema, t as DEFAULT_MODEL_PROFILES, u as parseTurnReasoningLevel } from "./model-profile-BwU8mqwD.js";
5
5
  //#region src/chat/slack/emoji.ts
6
6
  const SLACK_EMOJI_NAME_RE = /^(?:[a-z0-9_+-]+)(?:::(?:skin-tone-[2-6]))?$/;
@@ -1,12 +1,12 @@
1
- import { It as startOAuthFlow, c as deleteMcpAuthSessionsForUserProvider, l as deleteMcpServerSessionId, u as deleteMcpStoredOAuthCredentials } from "./agent-runner-Caiof09f.js";
2
- import { D as deleteProviderIdentityForSlackUser, c as getConversationEventStore, f as getSqlExecutor } from "./viewer-Rnim7alE.js";
3
- import { u as hasRequiredOAuthScope } from "./registry-CmKmKHpp.js";
4
- import { n as pluginCatalogRuntime } from "./catalog-runtime-hKmI-iZa.js";
5
- import { G as loadTurnCheckpoint, X as getTurnRecord, Y as failTurnRecord } from "./tasks-dJooqiip.js";
6
- import { w as getStateAdapter } from "./profile-DnkX3e2S.js";
7
- import { a as getVercelConversationWorkQueue } from "./job-queue-BaCL36FY.js";
8
- import { m as ensureConversationWake, w as requestConversationWork } from "./store-BashBewg.js";
9
- import { n as resolveTurnSessionRouting } from "./turn-session-routing-BAh_qsBJ.js";
1
+ import { Lt as startOAuthFlow, c as deleteMcpAuthSessionsForUserProvider, l as deleteMcpServerSessionId, u as deleteMcpStoredOAuthCredentials } from "./agent-runner-D7OboVb3.js";
2
+ import { A as deleteProviderIdentityForSlackUser, j as deleteProviderIdentityForUser, l as getConversationEventStore, p as getSqlExecutor } from "./viewer-DSZXygMU.js";
3
+ import { u as hasRequiredOAuthScope } from "./registry-sLTr-sV9.js";
4
+ import { n as pluginCatalogRuntime } from "./catalog-runtime-CZzhGQ7F.js";
5
+ import { K as loadTurnCheckpoint, X as failTurnRecord, Z as getTurnRecord } from "./tasks-D_WIJtvO.js";
6
+ import { w as getStateAdapter } from "./profile-h-72wM78.js";
7
+ import { a as getVercelConversationWorkQueue } from "./job-queue-B6SV9uVa.js";
8
+ import { m as ensureConversationWake, w as requestConversationWork } from "./store-DXFIQy-G.js";
9
+ import { n as resolveTurnSessionRouting } from "./turn-session-routing-B3LWooK5.js";
10
10
  import { z } from "zod";
11
11
  import { randomBytes, randomUUID } from "node:crypto";
12
12
  //#region src/chat/task-execution/authorized-turn.ts
@@ -231,8 +231,13 @@ async function startConnection(provider, actor) {
231
231
  authorizationUrl: request.authorizationUrl
232
232
  };
233
233
  }
234
- /** Remove the user's stored connection for one provider. */
235
- async function disconnectConnection(userId, provider, userTokenStore) {
234
+ /**
235
+ * Remove the user's stored connection for one provider and the provider
236
+ * identity that the connection linked to the viewer's user.
237
+ */
238
+ async function disconnectConnection(userId, provider, userTokenStore, viewerUserId) {
239
+ const tokens = await userTokenStore.get(userId, provider);
240
+ if (tokens?.account) await deleteProviderIdentityForUser(getSqlExecutor(), viewerUserId, provider, tokens.account.id);
236
241
  await unlinkProvider(userId, provider, userTokenStore);
237
242
  }
238
243
  //#endregion
@@ -528,6 +528,7 @@ const conversationReportMessageEventDataSchema = z.object({
528
528
  ]),
529
529
  source: z.enum(["slack", "web"]).optional(),
530
530
  actorIdentity: actorIdentitySchema.optional(),
531
+ mentions: z.array(actorIdentitySchema).optional(),
531
532
  eventType: z.string().min(1).optional(),
532
533
  eventObjectType: objectTypeSchema.optional(),
533
534
  explicitMention: z.boolean().optional(),
@@ -541,9 +542,9 @@ const conversationReportMessageEventDataSchema = z.object({
541
542
  code: "custom",
542
543
  message: "message content must be text or explicitly redacted"
543
544
  });
544
- if (data.redacted && (data.actorIdentity || data.cards || data.attachments)) context.addIssue({
545
+ if (data.redacted && (data.actorIdentity || data.mentions || data.cards || data.attachments)) context.addIssue({
545
546
  code: "custom",
546
- message: "redacted messages must not expose actor identity, cards, or attachments"
547
+ message: "redacted messages must not expose actor identity, mentions, cards, or attachments"
547
548
  });
548
549
  });
549
550
  const conversationReportMessageHandledEventDataSchema = z.object({
@@ -1,4 +1,4 @@
1
- import { p as logWarn } from "./logging-D3aYP0aG.js";
1
+ import { m as logWarn } from "./logging-CWxiIuCF.js";
2
2
  import { AsyncLocalStorage } from "node:async_hooks";
3
3
  //#region src/chat/conversation-privacy.ts
4
4
  const SAFE_METADATA_KEY_LIMIT = 20;
@@ -1,19 +1,19 @@
1
- import { Ft as resolveBaseUrl, Lt as createUserTokenStore, Nt as formatProviderLabel, Pt as parseOAuthStatePayload, _ as resolvePluginOAuthAccount, d as getMcpAuthSession, f as getMcpStoredOAuthCredentials, o as finalizeMcpAuthorization, p as putMcpStoredOAuthCredentials, s as deleteMcpAuthSession, x as lookupSlackUserProfile, xt as getMcpProviderErrorAttributes } from "./agent-runner-Caiof09f.js";
2
- import { f as escapeXml } from "./client-Clj7onnT.js";
3
- import { d as logException, h as runBestEffort, p as logWarn } from "./logging-D3aYP0aG.js";
4
- import { a as getRuntimeMetadata, n as botConfig } from "./config-BDAfLTI9.js";
1
+ import { Ft as parseOAuthStatePayload, It as resolveBaseUrl, Pt as formatProviderLabel, Rt as createUserTokenStore, _ as resolvePluginOAuthAccount, d as getMcpAuthSession, f as getMcpStoredOAuthCredentials, o as finalizeMcpAuthorization, p as putMcpStoredOAuthCredentials, s as deleteMcpAuthSession, x as lookupSlackUserProfile, xt as getMcpProviderErrorAttributes } from "./agent-runner-D7OboVb3.js";
2
+ import { f as escapeXml } from "./client-D8HnkOQX.js";
3
+ import { L as isNativeIdentityProvider, f as logException, g as runBestEffort, m as logWarn } from "./logging-CWxiIuCF.js";
4
+ import { a as getRuntimeMetadata, n as botConfig } from "./config-CJRnWK9H.js";
5
5
  import { f as parseSlackUserId } from "./actor-BTtLaeWy.js";
6
- import { A as upsertIdentity, f as getSqlExecutor, j as upsertLinkedIdentity } from "./viewer-Rnim7alE.js";
6
+ import { N as findUserByVerifiedEmails, R as upsertIdentity, p as getSqlExecutor, x as identityFromActor, z as upsertLinkedIdentity } from "./viewer-DSZXygMU.js";
7
7
  import { i as homeDir } from "./package-discovery-BVvSnQBB.js";
8
- import { n as buildOAuthTokenRequest, r as parseOAuthTokenResponse, u as hasRequiredOAuthScope } from "./registry-CmKmKHpp.js";
9
- import { n as pluginCatalogRuntime } from "./catalog-runtime-hKmI-iZa.js";
10
- import { t as discoverSkills } from "./skills-Dc-AMYi4.js";
11
- import { Ft as recordAuthorizationCompleted, Pt as recordAuthenticationLinked, X as getTurnRecord, z as postSlackMessage } from "./tasks-dJooqiip.js";
12
- import { Ht as getSlackClient } from "./agent-hooks-CDVx26Uu.js";
13
- import { E as acquireActiveLock, w as getStateAdapter } from "./profile-DnkX3e2S.js";
14
- import { i as getConversationPendingAuth } from "./pending-auth-D2t1Moxf.js";
15
- import { r as getPersistedThreadState, s as coerceThreadConversationState } from "./thread-state-CsMC-ob0.js";
16
- import { c as deleteWebAuthorization, f as wakeAuthorizedTurn, i as readConnectedOAuthTokens, p as wakePausedTurn } from "./connections-BC0RTejT.js";
8
+ import { n as buildOAuthTokenRequest, r as parseOAuthTokenResponse, u as hasRequiredOAuthScope } from "./registry-sLTr-sV9.js";
9
+ import { n as pluginCatalogRuntime } from "./catalog-runtime-CZzhGQ7F.js";
10
+ import { t as discoverSkills } from "./skills-C22SLruK.js";
11
+ import { B as postSlackMessage, Ft as recordAuthenticationLinked, It as recordAuthorizationCompleted, Z as getTurnRecord } from "./tasks-D_WIJtvO.js";
12
+ import { Ht as getSlackClient } from "./agent-hooks-BjtTzvru.js";
13
+ import { E as acquireActiveLock, w as getStateAdapter } from "./profile-h-72wM78.js";
14
+ import { i as getConversationPendingAuth } from "./pending-auth-s_QFribU.js";
15
+ import { r as getPersistedThreadState, s as coerceThreadConversationState } from "./thread-state-Ch4yuCqG.js";
16
+ import { c as deleteWebAuthorization, f as wakeAuthorizedTurn, i as readConnectedOAuthTokens, p as wakePausedTurn } from "./connections-ClYrKzpX.js";
17
17
  import { n as relayLocalOAuthCallback } from "./oauth-relay-CdCnu80W.js";
18
18
  import path from "node:path";
19
19
  import { z } from "zod";
@@ -558,6 +558,57 @@ function oauthTokenErrorAttributes(provider, endpoint, status) {
558
558
  function pluginAuthorizationId(args) {
559
559
  return `${args.sessionId}:plugin:${args.provider}`;
560
560
  }
561
+ /** Return the Junior user of the person who started the OAuth connection. */
562
+ async function resolveOAuthActorUserId(actor) {
563
+ if (actor.platform === "web") {
564
+ const observation = identityFromActor(actor.email ? {
565
+ email: actor.email,
566
+ ...actor.fullName ? { fullName: actor.fullName } : void 0
567
+ } : void 0);
568
+ return observation ? (await upsertIdentity(getSqlExecutor(), observation)).userId : void 0;
569
+ }
570
+ const slackUserId = parseSlackUserId(actor.userId);
571
+ if (!slackUserId) throw new Error("OAuth Slack actor user id is invalid");
572
+ const profile = await lookupSlackUserProfile(slackUserId);
573
+ return (await upsertIdentity(getSqlExecutor(), {
574
+ kind: "user",
575
+ provider: "slack",
576
+ providerTenantId: actor.teamId,
577
+ providerSubjectId: profile.id,
578
+ displayName: profile.real_name || profile.display_name,
579
+ handle: profile.name,
580
+ ...profile.email ? {
581
+ email: profile.email,
582
+ emailVerified: true
583
+ } : void 0
584
+ })).userId;
585
+ }
586
+ /**
587
+ * Link a connected provider account to the person who connected it.
588
+ *
589
+ * The actor's user wins. A provider-verified email that matches exactly one
590
+ * user links the account when the actor has no user, and is saved on the
591
+ * identity when it matches the actor's user.
592
+ */
593
+ async function linkOAuthAccountIdentity(args) {
594
+ const executor = getSqlExecutor();
595
+ const actorUserId = await resolveOAuthActorUserId(args.actor);
596
+ const emailMatch = await findUserByVerifiedEmails(executor, args.verifiedEmails);
597
+ const userId = actorUserId ?? emailMatch?.userId;
598
+ if (!userId) throw new Error("OAuth account has no Junior user to link");
599
+ const email = emailMatch?.userId === userId ? emailMatch.email : void 0;
600
+ await upsertLinkedIdentity(executor, userId, {
601
+ kind: "user",
602
+ provider: args.provider,
603
+ providerSubjectId: args.account.id,
604
+ displayName: args.account.displayName,
605
+ handle: args.account.handle ?? args.account.label,
606
+ ...email ? {
607
+ email,
608
+ emailVerified: true
609
+ } : void 0
610
+ });
611
+ }
561
612
  /** Queue the pending Turn, including a newer Turn that reused this auth link. */
562
613
  async function wakeAuthorizedPluginTurn(stored, options) {
563
614
  if (!stored.resumeConversationId || !stored.resumeSessionId || !stored.destination) return;
@@ -640,8 +691,9 @@ async function GET(request, provider, waitUntil, options) {
640
691
  return htmlErrorResponse("Connection failed", "The token exchange with the provider failed. Please try again.", 500);
641
692
  }
642
693
  let parsedTokenResponse;
694
+ let tokenData;
643
695
  try {
644
- const tokenData = await tokenResponse.json();
696
+ tokenData = await tokenResponse.json();
645
697
  parsedTokenResponse = parseOAuthTokenResponse(tokenData, requestedScope, { treatEmptyScopeAsUnreported: providerConfig.treatEmptyScopeAsUnreported });
646
698
  } catch {
647
699
  logWarn("oauth.token_exchange.failed", oauthTokenErrorAttributes(provider, providerConfig.tokenEndpoint, tokenResponse.status));
@@ -650,11 +702,18 @@ async function GET(request, provider, waitUntil, options) {
650
702
  if (!hasRequiredOAuthScope(parsedTokenResponse.scope, requestedScope)) return htmlErrorResponse("Connection failed", `The ${providerLabel} authorization did not grant the access Junior requires. Return to Junior and connect your ${providerLabel} account again.`, 400);
651
703
  const userTokenStore = createUserTokenStore();
652
704
  let account;
705
+ let verifiedEmails = [];
653
706
  try {
654
- account = await resolvePluginOAuthAccount({
707
+ const resolved = await resolvePluginOAuthAccount({
655
708
  provider,
709
+ tokenResponse: tokenData,
656
710
  tokens: parsedTokenResponse
657
711
  });
712
+ if (resolved) {
713
+ const { verifiedEmails: emails, ...rest } = resolved;
714
+ account = rest;
715
+ verifiedEmails = emails ?? [];
716
+ }
658
717
  } catch {
659
718
  return htmlErrorResponse("Connection failed", `Junior could not verify the connected ${providerLabel} account. Please try again.`, 500);
660
719
  }
@@ -662,30 +721,13 @@ async function GET(request, provider, waitUntil, options) {
662
721
  ...parsedTokenResponse,
663
722
  ...account ? { account } : void 0
664
723
  });
665
- const slackActor = stored.actor?.platform === "slack" ? stored.actor : void 0;
666
- if (account && slackActor) await runBestEffort(async () => {
667
- const slackUserId = parseSlackUserId(slackActor.userId);
668
- if (!slackUserId) throw new Error("OAuth Slack actor user id is invalid");
669
- const profile = await lookupSlackUserProfile(slackUserId);
670
- const slackIdentity = await upsertIdentity(getSqlExecutor(), {
671
- kind: "user",
672
- provider: "slack",
673
- providerTenantId: slackActor.teamId,
674
- providerSubjectId: profile.id,
675
- displayName: profile.real_name || profile.display_name,
676
- handle: profile.name,
677
- ...profile.email ? {
678
- email: profile.email,
679
- emailVerified: true
680
- } : void 0
681
- });
682
- if (!slackIdentity.userId) throw new Error("OAuth Slack identity is not linked to a user");
683
- await upsertLinkedIdentity(getSqlExecutor(), slackIdentity.userId, {
684
- kind: "user",
724
+ const linkActor = stored.actor;
725
+ if (account && !isNativeIdentityProvider(provider) && (linkActor?.platform === "slack" || linkActor?.platform === "web")) await runBestEffort(async () => {
726
+ await linkOAuthAccountIdentity({
727
+ account,
728
+ actor: linkActor,
685
729
  provider,
686
- providerSubjectId: account.id,
687
- displayName: account.displayName,
688
- handle: account.handle ?? account.label
730
+ verifiedEmails
689
731
  });
690
732
  }, "oauth.callback.identity_link.failed", { "app.credential.provider": provider });
691
733
  const resumeConversationId = stored.resumeConversationId;
@@ -813,4 +855,4 @@ async function receiveLocalOAuthCredential(request) {
813
855
  return new Response(null, { status: 204 });
814
856
  }
815
857
  //#endregion
816
- export { GET$1 as a, publishAppHomeView as i, syncLocalOAuthCredential as n, GET as r, receiveLocalOAuthCredential as t };
858
+ export { GET$1 as a, publishAppHomeView as i, syncLocalOAuthCredential as n, htmlCallbackResponse as o, GET as r, receiveLocalOAuthCredential as t };
@@ -1,7 +1,7 @@
1
- import { d as logException } from "./logging-D3aYP0aG.js";
1
+ import { f as logException } from "./logging-CWxiIuCF.js";
2
2
  import { g as startSpanManual } from "./sentry-CgWZM_kV.js";
3
- import "./config-BDAfLTI9.js";
4
- import { a as juniorAgentInvocations, c as juniorIdentities, d as juniorDestinations, f as timestamptz, i as juniorAgentBindings, l as juniorUsers, s as juniorConversations } from "./agent-invocations-BY60iNw-.js";
3
+ import "./config-CJRnWK9H.js";
4
+ import { a as juniorAgentInvocations, c as juniorIdentities, d as juniorDestinations, f as timestamptz, i as juniorAgentBindings, l as juniorUsers, s as juniorConversations } from "./agent-invocations-Bdu3ROfo.js";
5
5
  import { AsyncLocalStorage } from "node:async_hooks";
6
6
  import { sql } from "drizzle-orm";
7
7
  import { bigint, boolean, check, date, doublePrecision, foreignKey, index, integer, jsonb, pgTable, primaryKey, text, uniqueIndex, uuid } from "drizzle-orm/pg-core";
@@ -338,6 +338,25 @@ const juniorAutomations = pgTable("junior_automations", {
338
338
  index("junior_automations_match_idx").on(table.namespace, table.identifier, table.createdAtMs, table.id).where(sql`${table.status} <> 'deleted'`)
339
339
  ]);
340
340
  //#endregion
341
+ //#region src/db/schema/automation-versions.ts
342
+ /** One saved Automation definition. Lifecycle and scheduler state are not versioned. */
343
+ const juniorAutomationVersions = pgTable("junior_automation_versions", {
344
+ automationId: text("automation_id").notNull(),
345
+ /** Starts at 1 and increases by 1 for each saved definition change. */
346
+ version: integer("version").notNull(),
347
+ createdAtMs: bigint("created_at_ms", { mode: "number" }).notNull(),
348
+ /** Slack principal that saved this definition. Null when unknown. */
349
+ editedBy: jsonb("edited_by"),
350
+ definition: jsonb("definition").notNull()
351
+ }, (table) => [primaryKey({
352
+ name: "junior_automation_versions_pk",
353
+ columns: [table.automationId, table.version]
354
+ }), foreignKey({
355
+ name: "junior_automation_versions_automation_id_fk",
356
+ columns: [table.automationId],
357
+ foreignColumns: [juniorAutomations.id]
358
+ }).onDelete("cascade")]);
359
+ //#endregion
341
360
  //#region src/db/schema/automation-runs.ts
342
361
  /**
343
362
  * One dispatch of an Automation, from claim or dispatch to its outcome. A
@@ -345,12 +364,17 @@ const juniorAutomations = pgTable("junior_automations", {
345
364
  * automation run id is its dispatch id. Automation code sets
346
365
  * `conversation_id` when it dispatches the run. A run that was skipped, or
347
366
  * that failed before dispatch, has no Conversation.
367
+ *
368
+ * `automation_version` is the Automation version that the run dispatched. It
369
+ * shows which instruction ran and who saved it after the definition changes.
370
+ * It is null before dispatch, and when no saved version matched.
348
371
  */
349
372
  const juniorAutomationRuns = pgTable("junior_automation_runs", {
350
373
  id: text("id").primaryKey(),
351
374
  automationId: text("automation_id").notNull().references(() => juniorAutomations.id, { onDelete: "cascade" }),
352
375
  conversationId: text("conversation_id").unique().references(() => juniorConversations.conversationId),
353
376
  status: text("status").$type().notNull(),
377
+ automationVersion: integer("automation_version"),
354
378
  scheduledForMs: bigint("scheduled_for_ms", { mode: "number" }),
355
379
  attempt: integer("attempt"),
356
380
  claimedAtMs: bigint("claimed_at_ms", { mode: "number" }),
@@ -360,31 +384,17 @@ const juniorAutomationRuns = pgTable("junior_automation_runs", {
360
384
  errorMessage: text("error_message"),
361
385
  resultMessageTs: text("result_message_ts")
362
386
  }, (table) => [
387
+ foreignKey({
388
+ name: "junior_automation_runs_automation_version_fk",
389
+ columns: [table.automationId, table.automationVersion],
390
+ foreignColumns: [juniorAutomationVersions.automationId, juniorAutomationVersions.version]
391
+ }),
363
392
  check("junior_automation_runs_status_check", sql`${table.status} in ('pending', 'running', 'completed', 'failed', 'blocked', 'skipped')`),
364
393
  index("junior_automation_runs_automation_idx").on(table.automationId, table.completedAtMs),
365
394
  index("junior_automation_runs_completed_idx").on(table.completedAtMs),
366
395
  index("junior_automation_runs_incomplete_idx").on(table.automationId, table.scheduledForMs).where(sql`${table.status} in ('pending', 'running')`)
367
396
  ]);
368
397
  //#endregion
369
- //#region src/db/schema/automation-versions.ts
370
- /** One saved Automation definition. Lifecycle and scheduler state are not versioned. */
371
- const juniorAutomationVersions = pgTable("junior_automation_versions", {
372
- automationId: text("automation_id").notNull(),
373
- /** Starts at 1 and increases by 1 for each saved definition change. */
374
- version: integer("version").notNull(),
375
- createdAtMs: bigint("created_at_ms", { mode: "number" }).notNull(),
376
- /** Slack principal that saved this definition. Null when unknown. */
377
- editedBy: jsonb("edited_by"),
378
- definition: jsonb("definition").notNull()
379
- }, (table) => [primaryKey({
380
- name: "junior_automation_versions_pk",
381
- columns: [table.automationId, table.version]
382
- }), foreignKey({
383
- name: "junior_automation_versions_automation_id_fk",
384
- columns: [table.automationId],
385
- foreignColumns: [juniorAutomations.id]
386
- }).onDelete("cascade")]);
387
- //#endregion
388
398
  //#region src/db/schema/workspaces.ts
389
399
  /** Named recipe used to prepare a reusable Sandbox. */
390
400
  const juniorWorkspaces = pgTable("junior_workspaces", {
@@ -1006,4 +1016,4 @@ function createJuniorSqlExecutor(args) {
1006
1016
  });
1007
1017
  }
1008
1018
  //#endregion
1009
- export { juniorConversationAnnotations as _, juniorAutomationVersions as a, juniorAttachments as b, juniorStats as c, juniorConversationBindings as d, juniorConversationBriefs as f, juniorApiTokens as g, juniorConversationEvents as h, juniorWorkspaces as i, juniorLocationConfigurations as l, juniorConversationMetrics as m, juniorSnapshots as n, juniorAutomationRuns as o, CONVERSATION_METRICS as p, juniorWorkspaceRepos as r, juniorAutomations as s, createJuniorSqlExecutor as t, juniorConversationParticipants as u, juniorCodeChanges as v, juniorArtifacts as x, juniorCodeRepositories as y };
1019
+ export { juniorConversationAnnotations as _, juniorAutomationRuns as a, juniorAttachments as b, juniorStats as c, juniorConversationBindings as d, juniorConversationBriefs as f, juniorApiTokens as g, juniorConversationEvents as h, juniorWorkspaces as i, juniorLocationConfigurations as l, juniorConversationMetrics as m, juniorSnapshots as n, juniorAutomationVersions as o, CONVERSATION_METRICS as p, juniorWorkspaceRepos as r, juniorAutomations as s, createJuniorSqlExecutor as t, juniorConversationParticipants as u, juniorCodeChanges as v, juniorArtifacts as x, juniorCodeRepositories as y };
@@ -14,6 +14,7 @@ var experimental_exports = /* @__PURE__ */ __exportAll({
14
14
  const EXPERIMENTAL_FEATURES = [
15
15
  "operator-tools",
16
16
  "passive-routing",
17
+ "slack-sign-in",
17
18
  "subagents"
18
19
  ];
19
20
  const EXPERIMENTAL_FEATURE_SET = new Set(EXPERIMENTAL_FEATURES);
@@ -1,7 +1,7 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-B4FMCO8f.js";
2
- import { D as storeAttachment, T as readLiveAttachment } from "./agent-runner-Caiof09f.js";
3
- import { f as getSqlExecutor } from "./viewer-Rnim7alE.js";
4
- import { L as detectImageMediaType } from "./conversation-T18Xlkx9.js";
2
+ import { D as storeAttachment, T as readLiveAttachment } from "./agent-runner-D7OboVb3.js";
3
+ import { p as getSqlExecutor } from "./viewer-DSZXygMU.js";
4
+ import { L as detectImageMediaType } from "./conversation-CKNLYBJt.js";
5
5
  //#region src/chat/attachments/images.ts
6
6
  var images_exports = /* @__PURE__ */ __exportAll({
7
7
  decodeInputImages: () => decodeInputImages,
@@ -1,6 +1,6 @@
1
- import { N as getDeploymentServiceVersion, P as getDeploymentTelemetryAttributes } from "./logging-D3aYP0aG.js";
1
+ import { F as getDeploymentTelemetryAttributes, P as getDeploymentServiceVersion } from "./logging-CWxiIuCF.js";
2
2
  import { _ as vercelAIIntegration, a as getClient, b as withStreamedSpan, c as init, o as getGlobalScope } from "./sentry-CgWZM_kV.js";
3
- import { n as getCurrentConversationPrivacy } from "./conversation-privacy-1ERtieuM.js";
3
+ import { n as getCurrentConversationPrivacy } from "./conversation-privacy-C8b1nphZ.js";
4
4
  import { t as consumePrivateTraceResultMarker } from "./private-trace-result-BLvBjy_e.js";
5
5
  //#region src/chat/sentry-payload-filter.ts
6
6
  const PAYLOAD_ATTRIBUTE_KEYS = /* @__PURE__ */ new Set([
@@ -1,4 +1,4 @@
1
- import { i as getChatConfig } from "./config-BDAfLTI9.js";
1
+ import { i as getChatConfig } from "./config-CJRnWK9H.js";
2
2
  import { AsyncLocalStorage } from "node:async_hooks";
3
3
  import { z } from "zod";
4
4
  import { createHash, createHmac, timingSafeEqual } from "node:crypto";