@sentry/junior 0.266.0 → 0.268.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 (87) hide show
  1. package/dist/{actor-tlxzqaRe.js → actor-CP9K2Idu.js} +9 -1
  2. package/dist/{adapter-eRFA_naf.js → adapter-04AcD2SO.js} +5 -7
  3. package/dist/{admin-tILpP51p.js → admin-DIU1QyG3.js} +1 -1
  4. package/dist/{agent-invocations-CxKldAeB.js → agent-invocations-C1RNOCs8.js} +2 -0
  5. package/dist/{agent-runner-BtYK7bht.js → agent-runner-CAYfFmU7.js} +2636 -601
  6. package/dist/api/schema.d.ts +2 -5454
  7. package/dist/api/schema.js +6 -5
  8. package/dist/api.d.ts +6 -1
  9. package/dist/api.js +255 -1208
  10. package/dist/{app-Csbi9dW7.d.ts → app-z6Uuyq3j.d.ts} +23 -4
  11. package/dist/app.d.ts +2 -2
  12. package/dist/app.js +1869 -378
  13. package/dist/{automation-BKpY9LPa.js → automation-CmeFBSEh.js} +42 -14
  14. package/dist/{briefs-DgfWMU7e.js → briefs-DQbV2jNr.js} +4 -4
  15. package/dist/{catalog-runtime-DAJjAbSx.js → catalog-runtime-BD9GSpc6.js} +1 -1
  16. package/dist/cli/chat.js +15 -15
  17. package/dist/cli/check.js +3 -3
  18. package/dist/cli/init.js +0 -1
  19. package/dist/cli/main.js +3 -3
  20. package/dist/cli/plugins.js +4 -4
  21. package/dist/cli/snapshot-create.js +4 -4
  22. package/dist/cli/upgrade.d.ts +1 -1
  23. package/dist/cli/upgrade.js +3 -3
  24. package/dist/{client-B0YZfxNy.js → client-C1yDYjoS.js} +2 -2
  25. package/dist/{config-C0UwYqDK.js → config-DrTeF80T.js} +32 -10
  26. package/dist/{connections-Bwu3VORi.js → connections-D46f8vvi.js} +12 -12
  27. package/dist/{conversation-DF4rUcjb.js → conversation-DSo310Ps.js} +8 -1
  28. package/dist/{conversation-privacy-CY7JVjxn.js → conversation-privacy-CxlOCiUo.js} +1 -1
  29. package/dist/{credential-sync-VGAMUTGp.js → credential-sync-sm9fegLY.js} +29 -34
  30. package/dist/{credentialed-enF5Bf3y.js → credentialed-lukuD-cc.js} +2933 -1026
  31. package/dist/db-BU4LQD8s.d.ts +6 -0
  32. package/dist/{executor-TnWbvL09.js → executor-4vhvsMZJ.js} +83 -6
  33. package/dist/instrumentation.js +6 -2
  34. package/dist/{assistant-reply-UyzAfZQo.js → interruption-marker-CkncDT8d.js} +8 -2
  35. package/dist/{job-queue-DBpHmKnd.js → job-queue-In9QKz-I.js} +128 -3
  36. package/dist/{web-input-B-bMjD1V.js → list-BkgnXEEB.js} +1611 -817
  37. package/dist/{logging-Ce0mXZ8J.js → logging-DLSpkSSr.js} +11 -3
  38. package/dist/{message-VZ3DFpGb.js → message-BObyg59s.js} +4 -4
  39. package/dist/nitro.d.ts +1 -1
  40. package/dist/nitro.js +3 -3
  41. package/dist/{oauth-callback-server-CpqWLjVY.js → oauth-callback-server-B-WbSdoH.js} +2 -2
  42. package/dist/{prompt-BcCGlmg2.js → prompt-BW9jFsqZ.js} +1 -1
  43. package/dist/{registry-1BEIPdbT.js → registry-BgecKva0.js} +2 -2
  44. package/dist/{web-message-id-CJSUiksE.js → reporting-window-DVCD_10C.js} +1 -10
  45. package/dist/{resolve-BSHHkEGE.js → resolve-Cpa4Bu1O.js} +3 -3
  46. package/dist/{result-CwOpzqdh.js → result-D3TSmZZ8.js} +9 -9
  47. package/dist/{runner-CEaX04kz.js → runner-DS5OKhEp.js} +11 -11
  48. package/dist/{sandbox-egress-signals-BwtGHwqa.js → sandbox-egress-signals-CnDjY5rx.js} +1 -1
  49. package/dist/{schema-RsaBHxRH.js → schema-0050HFnB.js} +82 -5
  50. package/dist/schema-ZngqcOWM.d.ts +5813 -0
  51. package/dist/{service-account-6wC76eBZ.js → service-account-CKV2WTY7.js} +3 -3
  52. package/dist/{service-account-Dg4lIbHm.js → service-account-DGjnDw9y.js} +3 -3
  53. package/dist/{session-stop-tZOw9AJD.js → session-stop-Dam1EI7B.js} +527 -134
  54. package/dist/{skills-DzyGN7wd.js → skills-CfAnfImD.js} +2 -2
  55. package/dist/{spawn-6rokq7l_.js → spawn-cmq9p4Ly.js} +2 -2
  56. package/dist/{store-DcKkzrdt.js → store-C5PN02QO.js} +4 -4
  57. package/dist/{store-CG0VJyye.d.ts → store-xMuuXRE0.d.ts} +23 -9
  58. package/dist/store-zPEoJPBB.js +295 -0
  59. package/dist/{task-queue-Bg4RS2Gy.js → task-queue-_mf28dSu.js} +10 -5
  60. package/dist/{task-runner-8N5LIkSg.js → task-runner-DMI2prDO.js} +25 -14
  61. package/dist/{tasks-DDT-J3Rf.js → tasks-SB9z-VTU.js} +1551 -54
  62. package/dist/{thread-state-cprEaxgl.js → thread-state-BbbPh0Sn.js} +8 -18
  63. package/dist/{turn-failure-response-C8sMdsdX.js → turn-failure-response-BKKmnMB5.js} +11 -16
  64. package/dist/{turn-lifecycle-DaBVoz7h.js → turn-lifecycle-oP0kVeGz.js} +1 -1
  65. package/dist/{validation-C2lllinq.js → validation--JsAGLwc.js} +1 -1
  66. package/dist/{version-oaLfxxnf.js → version-jHwJp4hC.js} +1 -1
  67. package/dist/version.js +1 -1
  68. package/dist/{viewer-BpE6Z3qf.js → viewer-CpXTGlep.js} +329 -230
  69. package/dist/web-message-id-DlHNANtd.js +132 -0
  70. package/dist/{work-VX1SHWha.js → work-3N-GHY9m.js} +10 -10
  71. package/dist/{worker-hook-y_Y.js → worker-CCdbcItd.js} +30 -19
  72. package/migrations/0064_any_resource_event_triggers.sql +2 -0
  73. package/migrations/0065_user_customization.sql +1 -0
  74. package/migrations/0066_review_items.sql +53 -0
  75. package/migrations/0067_review_item_dedupe_tenant.sql +2 -0
  76. package/migrations/0068_review_item_slack_cards.sql +10 -0
  77. package/migrations/meta/0064_snapshot.json +3505 -0
  78. package/migrations/meta/0065_snapshot.json +3511 -0
  79. package/migrations/meta/0066_snapshot.json +4099 -0
  80. package/migrations/meta/0067_snapshot.json +3921 -0
  81. package/migrations/meta/0068_snapshot.json +4176 -0
  82. package/migrations/meta/_journal.json +36 -1
  83. package/package.json +19 -4
  84. package/dist/db-BnRqQ7G5.d.ts +0 -5
  85. package/dist/images-BKQqSi5W.js +0 -64
  86. package/dist/store-FALy-JQb.js +0 -1424
  87. package/dist/turn-session-routing-a9CHX-w6.js +0 -76
@@ -1,7 +1,7 @@
1
1
  import { a as resolveLocalScheduleAtMs, i as isValidTimeZone, r as getZonedDateTimeParts, t as getFirstRunAtMs } from "./cadence-R7Em4RjE.js";
2
- import { n as actorIdentitySchema } from "./conversation-DF4rUcjb.js";
2
+ import { n as actorIdentitySchema } from "./conversation-DSo310Ps.js";
3
3
  import { z } from "zod";
4
- import { actorUserIdSchema, destinationVisibilitySchema, eventMatchSchema, eventTypeSchema, pluginEventTypeSchema, slackDestinationSchema, taskOutcomeSchema } from "@sentry/junior-plugin-api";
4
+ import { actorUserIdSchema, destinationVisibilitySchema, eventMatchFieldsSchema, eventMatchSchema, eventReachSchema, eventTypeSchema, pluginEventTypeSchema, slackDestinationSchema, taskOutcomeSchema } from "@sentry/junior-plugin-api";
5
5
  // src/chat/task-outcomes-schema.ts
6
6
  const taskMessageDestinationInputSchema = z.enum(["current_conversation", "task_creator"]).describe("Where to send the message. Use current_conversation for posts, digests, summaries, and channel reminders. Use task_creator only when the user asks for a direct reminder or notification.");
7
7
  /** Input accepted by task authoring tools before a user becomes a DM Destination. */
@@ -217,15 +217,23 @@ const eventAutomationPrincipalSchema = z.object({
217
217
  fullName: z.string().optional(),
218
218
  userName: z.string().optional()
219
219
  }).strict();
220
- /** Validate one persisted event-automation selector and its presentation metadata. */
220
+ /**
221
+ * Validate one persisted event-automation selector and its presentation
222
+ * metadata. A trigger names one resource with a resource type and an
223
+ * identifier, or it names neither. With neither, it runs for every resource
224
+ * of the namespace that its filters match.
225
+ */
221
226
  const eventAutomationTriggerSchema = z.object({
222
227
  events: z.array(eventTypeSchema).min(1),
223
228
  label: z.string().min(1),
224
229
  match: eventMatchSchema.optional(),
225
230
  namespace: z.string().min(1),
226
- identifier: z.string().min(1).max(300),
227
- resourceType: z.string().min(1)
228
- }).strict();
231
+ identifier: z.string().min(1).max(300).optional(),
232
+ resourceType: z.string().min(1).optional()
233
+ }).strict().refine((trigger) => trigger.identifier === void 0 === (trigger.resourceType === void 0), {
234
+ message: "Set both a resource type and an identifier, or leave out both to run for every resource.",
235
+ path: ["identifier"]
236
+ });
229
237
  /** Event automations target a Slack channel or DM, never a message thread. */
230
238
  const eventAutomationDestinationSchema = slackDestinationSchema.omit({ threadTs: true });
231
239
  const eventAutomationOutcomeSchema = taskOutcomeSchema.extend({ destination: eventAutomationDestinationSchema });
@@ -248,10 +256,11 @@ const eventAutomationSchema = z.object({
248
256
  const automationTitleSchema = z.string().trim().min(1).max(60);
249
257
  const automationInstructionSchema = z.string().trim().min(1).max(4e3);
250
258
  /**
251
- * Instruction input for agent tools. An Automation runs later without the
252
- * request around it, so the instruction must name each person exactly.
259
+ * Instruction input for agent tools. The run does not see the request, so the
260
+ * instruction names exact targets. It calls the creator "the Automation
261
+ * creator". It names every other person with their mention.
253
262
  */
254
- const automationInstructionToolSchema = automationInstructionSchema.describe("Work to perform when the Automation runs. It runs later without this conversation, so write it to stand alone: name each person with their Slack mention, such as <@U123>, instead of me, my, or you. Preserve the user's scope, targets, and constraints. Do not add permissions or side effects the user did not request.");
263
+ const automationInstructionToolSchema = automationInstructionSchema.describe("Work to perform when the Automation runs. The run does not see this conversation, so words like \"this channel\" or \"here\" will mean nothing then. Write the exact target instead, such as a channel mention or a link. Call the person who created the Automation \"the Automation creator\", not \"me\"; each run knows who that is. Name every other person with their Slack mention, such as <@U123>, including a requester who did not create the Automation. Preserve the user's scope, targets, and constraints. Do not add permissions or side effects the user did not request.");
255
264
  const automationEditFieldsSchema = z.object({
256
265
  title: automationTitleSchema.optional(),
257
266
  instruction: automationInstructionSchema.optional(),
@@ -262,8 +271,8 @@ const scheduledAutomationEditSchema = automationEditFieldsSchema.extend({
262
271
  schedule: scheduleIntentSchema.optional(),
263
272
  status: z.enum(["active", "blocked"]).optional()
264
273
  }).strict();
265
- const eventAutomationEditSchema = automationEditFieldsSchema.extend({ trigger: eventAutomationTriggerSchema.extend({
266
- identifier: z.string().trim().min(1).max(300),
274
+ const eventAutomationEditSchema = automationEditFieldsSchema.extend({ trigger: eventAutomationTriggerSchema.safeExtend({
275
+ identifier: z.string().trim().min(1).max(300).optional(),
267
276
  label: z.string().trim().min(1).max(500)
268
277
  }).optional() }).strict();
269
278
  // src/chat/scheduled-automations/types.ts
@@ -387,7 +396,15 @@ const automationRunWindowsSchema = z.object({
387
396
  30: z.number().int().nonnegative(),
388
397
  90: z.number().int().nonnegative()
389
398
  }).strict();
399
+ /** Linked Conversation cost in USD for each dashboard range. */
400
+ const automationCostWindowsSchema = z.object({
401
+ 1: z.number().finite().nonnegative(),
402
+ 7: z.number().finite().nonnegative(),
403
+ 30: z.number().finite().nonnegative(),
404
+ 90: z.number().finite().nonnegative()
405
+ }).strict();
390
406
  const automationSummaryBaseSchema = z.object({
407
+ costUsd: automationCostWindowsSchema,
391
408
  credentialMode: z.enum(["creator", "system"]),
392
409
  createdAt: z.string().datetime(),
393
410
  createdBy: z.string().min(1),
@@ -662,8 +679,19 @@ const automationEditErrorSchema = z.object({
662
679
  ]),
663
680
  fields: z.record(z.string(), z.array(z.string())).optional()
664
681
  }).strict();
665
- /** Catalog metadata only; callbacks and provider connections stay on the server. */
666
- const automationEventCatalogSchema = z.array(pluginEventTypeSchema.safeExtend({ namespace: z.string() }));
682
+ /**
683
+ * Catalog metadata only, one entry for each namespace. Callbacks, guidance,
684
+ * and provider connections stay on the server. `events` gives the reach of
685
+ * each event once, and `anyResourceFields` gives the filters of every
686
+ * resource type, for a trigger with no identifier.
687
+ */
688
+ const automationEventCatalogSchema = z.array(z.object({
689
+ namespace: z.string(),
690
+ displayName: z.string(),
691
+ events: z.record(z.string(), z.object({ reach: eventReachSchema })),
692
+ anyResourceFields: eventMatchFieldsSchema,
693
+ resourceTypes: z.array(pluginEventTypeSchema)
694
+ }).strict());
667
695
  const automationScheduleIntentSchema = scheduleIntentSchema;
668
696
  const automationSchedulePreviewSchema = scheduledAutomationSchema.pick({ schedule: true }).extend({ nextRunAtMs: z.number() }).strict();
669
- export { eventAutomationSchema as A, eventAutomationSummarySchema as C, scheduledRunSchema as D, scheduledAutomationSchema as E, taskOutcomeInputSchema as F, compileScheduleIntent as M, scheduleIntentSchema as N, automationInstructionToolSchema as O, weekdaySchema as P, automationVersionSchema as S, SCHEDULED_AUTOMATION_SYSTEM_ACTOR as T, automationSummarySchema as _, automationExecutionSchema as a, automationVersionListSchema as b, automationLifecycleSchema as c, automationParamsSchema as d, automationRunListSchema as f, automationSchedulePreviewSchema as g, automationScheduleIntentSchema as h, automationExecutionListSchema as i, ScheduleIntentError as j, automationTitleSchema as k, automationListQuerySchema as l, automationRunWindowsSchema as m, automationEditSchema as n, automationExecutionStatusDaySchema as o, automationRunSchema as p, automationEventCatalogSchema as r, automationExecutionStatusSchema as s, automationEditErrorSchema as t, automationListSchema as u, automationUpdateSchema as v, scheduledAutomationSummarySchema as w, automationVersionParamsSchema as x, automationVersionActivateSchema as y };
697
+ export { eventAutomationSchema as A, eventAutomationSummarySchema as C, scheduledRunSchema as D, scheduledAutomationSchema as E, weekdaySchema as F, taskOutcomeInputSchema as I, ScheduleIntentError as M, compileScheduleIntent as N, automationInstructionToolSchema as O, scheduleIntentSchema as P, automationVersionSchema as S, SCHEDULED_AUTOMATION_SYSTEM_ACTOR as T, automationSummarySchema as _, automationExecutionSchema as a, automationVersionListSchema as b, automationLifecycleSchema as c, automationParamsSchema as d, automationRunListSchema as f, automationSchedulePreviewSchema as g, automationScheduleIntentSchema as h, automationExecutionListSchema as i, eventAutomationTriggerSchema as j, automationTitleSchema as k, automationListQuerySchema as l, automationRunWindowsSchema as m, automationEditSchema as n, automationExecutionStatusDaySchema as o, automationRunSchema as p, automationEventCatalogSchema as r, automationExecutionStatusSchema as s, automationEditErrorSchema as t, automationListSchema as u, automationUpdateSchema as v, scheduledAutomationSummarySchema as w, automationVersionParamsSchema as x, automationVersionActivateSchema as y };
@@ -1,7 +1,7 @@
1
- import { i as completeObject } from "./client-B0YZfxNy.js";
1
+ import { i as completeObject } from "./client-C1yDYjoS.js";
2
2
  import { r as defaultModelId } from "./model-profile-Bg8EoCKD.js";
3
- import { J as parseBriefInput, W as briefCodeChangeSchema, d as conversationDetailReportSchema, p as conversationEventPageSchema } from "./conversation-DF4rUcjb.js";
4
- import { n as briefEntriesFromReportEvents, s as generateBrief, t as BRIEF_PROMPT } from "./prompt-BcCGlmg2.js";
3
+ import { J as briefCodeChangeSchema, Q as parseBriefInput, d as conversationDetailReportSchema, p as conversationEventPageSchema } from "./conversation-DSo310Ps.js";
4
+ import { n as briefEntriesFromReportEvents, s as generateBrief, t as BRIEF_PROMPT } from "./prompt-BW9jFsqZ.js";
5
5
  import { CLI_USAGE } from "./cli/run.js";
6
6
  import path from "node:path";
7
7
  import { z } from "zod";
@@ -267,7 +267,7 @@ async function parseRunOptions(argv) {
267
267
  * `DATABASE_URL` at import, and `briefs pull` must work with only a token.
268
268
  */
269
269
  async function configuredDefaultModelId() {
270
- const { botConfig } = await import("./config-C0UwYqDK.js").then((n) => n.r);
270
+ const { botConfig } = await import("./config-DrTeF80T.js").then((n) => n.r);
271
271
  return defaultModelId(botConfig);
272
272
  }
273
273
  function apiUrl(baseUrl, pathname) {
@@ -1,5 +1,5 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-nwUcYXjP.js";
2
- import { t as createPluginCatalogRuntime } from "./registry-1BEIPdbT.js";
2
+ import { t as createPluginCatalogRuntime } from "./registry-BgecKva0.js";
3
3
  // 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-BtYK7bht.js";
1
+ import { n as executeAgentRun, t as createAgentRunner } from "../agent-runner-CAYfFmU7.js";
2
2
  import { t as loadAppPluginSet } from "../plugin-module-Cf5gVPWP.js";
3
3
  import path from "node:path";
4
4
  import { createHash, randomUUID } from "node:crypto";
@@ -99,10 +99,10 @@ async function loadLocalPluginSet() {
99
99
  async function configureLocalChatPlugins(pluginSet) {
100
100
  const [pluginsModule, agentHooksModule, catalogRuntimeModule, validationModule, databaseModule] = await Promise.all([
101
101
  import("../plugins-DOm9Y6qI.js").then((n) => n.o),
102
- import("../credentialed-enF5Bf3y.js").then((n) => n.a),
103
- import("../catalog-runtime-DAJjAbSx.js").then((n) => n.t),
104
- import("../validation-C2lllinq.js").then((n) => n.r),
105
- import("../viewer-BpE6Z3qf.js").then((n) => n.c)
102
+ import("../credentialed-lukuD-cc.js").then((n) => n.a),
103
+ import("../catalog-runtime-BD9GSpc6.js").then((n) => n.t),
104
+ import("../validation--JsAGLwc.js").then((n) => n.r),
105
+ import("../viewer-CpXTGlep.js").then((n) => n.u)
106
106
  ]);
107
107
  const resolvedPluginSet = pluginSet === void 0 ? await loadLocalPluginSet() : pluginSet ?? void 0;
108
108
  const plugins = pluginsModule.pluginRuntimeRegistrationsFromPluginSet(resolvedPluginSet);
@@ -152,19 +152,19 @@ function localDevServerUrl() {
152
152
  async function prepareLocalChatRun(io, pluginSet) {
153
153
  defaultStateAdapterForLocalChat();
154
154
  await configureLocalChatPlugins(pluginSet);
155
- const { setBriefsConfig } = await import("../credentialed-enF5Bf3y.js").then((n) => n._);
155
+ const { setBriefsConfig } = await import("../credentialed-lukuD-cc.js").then((n) => n._);
156
156
  setBriefsConfig({ enabled: true });
157
- const { runLocalAgentTurn } = await import("../runner-CEaX04kz.js");
158
- const { startLocalOAuthCallbackServer } = await import("../oauth-callback-server-CpqWLjVY.js");
157
+ const { runLocalAgentTurn } = await import("../runner-DS5OKhEp.js");
158
+ const { startLocalOAuthCallbackServer } = await import("../oauth-callback-server-B-WbSdoH.js");
159
159
  const { createLocalOAuthState } = await import("../oauth-relay-CTygMkNx.js").then((n) => n.t);
160
- const { createLocalSandboxEgressSignalTransport } = await import("../sandbox-egress-signals-BwtGHwqa.js");
161
- const { bindSpawnAgent } = await import("../spawn-6rokq7l_.js").then((n) => n.n);
162
- const { bindMessageAgent } = await import("../message-VZ3DFpGb.js").then((n) => n.n);
163
- const { createAgentInvocationWorker, routeAgentInvocationWork } = await import("../work-VX1SHWha.js").then((n) => n.a);
164
- const { startAgentInvocationsForChildInput } = await import("../result-CwOpzqdh.js").then((n) => n.r);
165
- const { skipInputBeforeConversationStop } = await import("../session-stop-tZOw9AJD.js").then((n) => n.r);
160
+ const { createLocalSandboxEgressSignalTransport } = await import("../sandbox-egress-signals-CnDjY5rx.js");
161
+ const { bindSpawnAgent } = await import("../spawn-cmq9p4Ly.js").then((n) => n.n);
162
+ const { bindMessageAgent } = await import("../message-BObyg59s.js").then((n) => n.n);
163
+ const { createAgentInvocationWorker, routeAgentInvocationWork } = await import("../work-3N-GHY9m.js").then((n) => n.a);
164
+ const { startAgentInvocationsForChildInput } = await import("../result-D3TSmZZ8.js").then((n) => n.r);
165
+ const { skipInputBeforeConversationStop } = await import("../session-stop-Dam1EI7B.js").then((n) => n.r);
166
166
  const { createLocalConversationWork } = await import("../conversation-work-BaT_T6EB.js");
167
- const { processConversationWork } = await import("../worker-hook-y_Y.js").then((n) => n.n);
167
+ const { processConversationWork } = await import("../worker-CCdbcItd.js").then((n) => n.n);
168
168
  let agentRunner;
169
169
  const localConversationWork = createLocalConversationWork(async (message) => {
170
170
  if (!agentRunner) throw new Error("Local agent runner is not ready");
package/dist/cli/check.js CHANGED
@@ -1,6 +1,6 @@
1
- import { E as JUNIOR_CONVERSATION_WORK_CALLBACK_ROUTE, N as LEGACY_JUNIOR_CONVERSATION_WORK_FUNCTION, O as JUNIOR_HEARTBEAT_ROUTE } from "../logging-Ce0mXZ8J.js";
2
- import { v as parseInlinePluginManifest, y as parsePluginManifest } from "../registry-1BEIPdbT.js";
3
- import { i as parseSkillFile } from "../skills-DzyGN7wd.js";
1
+ import { D as JUNIOR_CONVERSATION_WORK_CALLBACK_ROUTE, P as LEGACY_JUNIOR_CONVERSATION_WORK_FUNCTION, k as JUNIOR_HEARTBEAT_ROUTE } from "../logging-DLSpkSSr.js";
2
+ import { v as parseInlinePluginManifest, y as parsePluginManifest } from "../registry-BgecKva0.js";
3
+ import { i as parseSkillFile } from "../skills-CfAnfImD.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/init.js CHANGED
@@ -156,7 +156,6 @@ async function runInit(dir, log = console.log) {
156
156
  SLACK_SIGNING_SECRET=
157
157
  JUNIOR_SECRET=
158
158
  JUNIOR_BOT_NAME=
159
- JUNIOR_SLASH_COMMAND=
160
159
  JUNIOR_CROSS_ACTOR_MID_RUN_MODE=
161
160
  AI_MODEL=
162
161
  AI_FAST_MODEL=
package/dist/cli/main.js CHANGED
@@ -25,13 +25,13 @@ 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-tILpP51p.js")).runAdmin(argv);
28
+ return await (await import("../admin-DIU1QyG3.js")).runAdmin(argv);
29
29
  }
30
30
  async function runServiceAccount(argv) {
31
- return await (await import("../service-account-Dg4lIbHm.js")).runServiceAccount(argv);
31
+ return await (await import("../service-account-DGjnDw9y.js")).runServiceAccount(argv);
32
32
  }
33
33
  async function runBriefs(argv) {
34
- return await (await import("../briefs-DgfWMU7e.js")).runBriefs(argv);
34
+ return await (await import("../briefs-DQbV2jNr.js")).runBriefs(argv);
35
35
  }
36
36
  function topLevelCommand(argv) {
37
37
  return (argv[0] === "--" ? argv.slice(1) : argv)[0];
@@ -1,7 +1,7 @@
1
- import { f as getDb } from "../viewer-BpE6Z3qf.js";
2
- import { n as pluginCatalogRuntime } from "../catalog-runtime-DAJjAbSx.js";
3
- import { An as createPluginLogger, h as validatePlugins, m as setPlugins } from "../credentialed-enF5Bf3y.js";
4
- import { n as validatePluginRegistrations, t as validatePluginEgressCredentialHooks } from "../validation-C2lllinq.js";
1
+ import { m as getDb } from "../viewer-CpXTGlep.js";
2
+ import { n as pluginCatalogRuntime } from "../catalog-runtime-BD9GSpc6.js";
3
+ import { In as createPluginLogger, h as validatePlugins, m as setPlugins } from "../credentialed-lukuD-cc.js";
4
+ import { n as validatePluginRegistrations, t as validatePluginEgressCredentialHooks } from "../validation--JsAGLwc.js";
5
5
  import { a as pluginRuntimeRegistrationsFromPluginSet, i as pluginCliRegistrationsFromPluginSet, r as pluginCatalogConfigFromPluginSet } from "../plugins-DOm9Y6qI.js";
6
6
  import { t as loadAppPluginSet } from "../plugin-module-Cf5gVPWP.js";
7
7
  import { stderr, stdout } from "node:process";
@@ -1,7 +1,7 @@
1
- import { n as pluginCatalogRuntime } from "../catalog-runtime-DAJjAbSx.js";
2
- import { M as create } from "../credentialed-enF5Bf3y.js";
3
- import { t as disconnectStateAdapter } from "../adapter-eRFA_naf.js";
4
- import { n as resolve } from "../resolve-BSHHkEGE.js";
1
+ import { n as pluginCatalogRuntime } from "../catalog-runtime-BD9GSpc6.js";
2
+ import { j as create } from "../credentialed-lukuD-cc.js";
3
+ import { t as disconnectStateAdapter } from "../adapter-04AcD2SO.js";
4
+ import { n as resolve } from "../resolve-Cpa4Bu1O.js";
5
5
  // src/cli/snapshot-create.ts
6
6
  const DEFAULT_RUNTIME = "node22";
7
7
  const DEFAULT_TIMEOUT_MS = 6e5;
@@ -1,4 +1,4 @@
1
- import "../db-BnRqQ7G5.js";
1
+ import "../db-BU4LQD8s.js";
2
2
  import { n as JuniorPluginSet } from "../plugins-B_0Cr0MO.js";
3
3
  interface UpgradeIo {
4
4
  info: (line: string) => void;
@@ -1,6 +1,6 @@
1
- import { i as getChatConfig } from "../config-C0UwYqDK.js";
2
- import { t as createJuniorSqlExecutor } from "../executor-TnWbvL09.js";
3
- import { t as createPluginCatalogRuntime } from "../registry-1BEIPdbT.js";
1
+ import { i as getChatConfig } from "../config-DrTeF80T.js";
2
+ import { t as createJuniorSqlExecutor } from "../executor-4vhvsMZJ.js";
3
+ import { t as createPluginCatalogRuntime } from "../registry-BgecKva0.js";
4
4
  import { n as pluginCatalogConfigFromEnv, r as pluginCatalogConfigFromPluginSet, t as defineJuniorPlugins } from "../plugins-DOm9Y6qI.js";
5
5
  import { t as loadAppPluginSet } from "../plugin-module-Cf5gVPWP.js";
6
6
  import { basename, dirname, join, resolve } from "node:path";
@@ -1,5 +1,5 @@
1
- import { T as withSpan, _ as serializeGenAiAttribute, f as logException, h as normalizeGenAiFinishReason, i as extractGenAiUsageAttributes, m as logWarn } from "./logging-Ce0mXZ8J.js";
2
- import { a as toCanonicalInputMessage, n as getCurrentConversationPrivacy, o as toCanonicalOutputMessage, s as toGenAiMessagesTraceAttributes } from "./conversation-privacy-CY7JVjxn.js";
1
+ import { E as withSpan, g as normalizeGenAiFinishReason, h as logWarn, i as extractGenAiUsageAttributes, p as logException, v as serializeGenAiAttribute } from "./logging-DLSpkSSr.js";
2
+ import { a as toCanonicalInputMessage, n as getCurrentConversationPrivacy, o as toCanonicalOutputMessage, s as toGenAiMessagesTraceAttributes } from "./conversation-privacy-CxlOCiUo.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-nwUcYXjP.js";
2
- import { C as toOptionalTrimmed, s as resolveGatewayModel } from "./client-B0YZfxNy.js";
3
- import { m as logWarn } from "./logging-Ce0mXZ8J.js";
2
+ import { C as toOptionalTrimmed, s as resolveGatewayModel } from "./client-C1yDYjoS.js";
3
+ import { h as logWarn } from "./logging-DLSpkSSr.js";
4
4
  import { l as TURN_REASONING_LEVELS, s as modelProfileSchema, t as DEFAULT_MODEL_PROFILES, u as parseTurnReasoningLevel } from "./model-profile-Bg8EoCKD.js";
5
5
  import { AwsClient } from "aws4fetch";
6
6
  // src/chat/attachments/s3.ts
@@ -98,6 +98,33 @@ function readAttachmentStorageConfig(env) {
98
98
  default: throw new Error("JUNIOR_ATTACHMENT_STORAGE_PROVIDER must be vercel-blob, s3, or memory");
99
99
  }
100
100
  }
101
+ // src/chat/queue/config.ts
102
+ /** Jobs that one BullMQ worker runs at the same time, for each queue topic. */
103
+ const DEFAULT_BULLMQ_WORKER_CONCURRENCY = 4;
104
+ function readWorkerConcurrency(value) {
105
+ const raw = toOptionalTrimmed(value);
106
+ if (raw === void 0) return DEFAULT_BULLMQ_WORKER_CONCURRENCY;
107
+ const concurrency = Number(raw);
108
+ if (!/^\d+$/.test(raw) || !Number.isSafeInteger(concurrency) || concurrency < 1) throw new Error("JUNIOR_QUEUE_WORKER_CONCURRENCY must be a positive integer");
109
+ return concurrency;
110
+ }
111
+ /** Read queue settings from environment variables. */
112
+ function readQueueConfig(env) {
113
+ const provider = toOptionalTrimmed(env.JUNIOR_QUEUE_PROVIDER) ?? "vercel";
114
+ switch (provider) {
115
+ case "vercel": return { provider };
116
+ case "bullmq": {
117
+ const redisUrl = toOptionalTrimmed(env.JUNIOR_QUEUE_REDIS_URL);
118
+ if (!redisUrl) throw new Error("JUNIOR_QUEUE_REDIS_URL is required when JUNIOR_QUEUE_PROVIDER is bullmq");
119
+ return {
120
+ provider,
121
+ redisUrl,
122
+ workerConcurrency: readWorkerConcurrency(env.JUNIOR_QUEUE_WORKER_CONCURRENCY)
123
+ };
124
+ }
125
+ default: throw new Error("JUNIOR_QUEUE_PROVIDER must be vercel or bullmq");
126
+ }
127
+ }
101
128
  // src/chat/slack/emoji.ts
102
129
  const SLACK_EMOJI_NAME_RE = /^(?:[a-z0-9_+-]+)(?:::(?:skin-tone-[2-6]))?$/;
103
130
  function normalizeSlackEmojiName(value) {
@@ -164,7 +191,6 @@ const MAX_EVENT_AUTOMATION_RUNS = 10;
164
191
  /** Length of the rolling window for the Event automation run limit. */
165
192
  const EVENT_AUTOMATION_RUN_WINDOW_MS = 6e4;
166
193
  const DEFAULT_FUNCTION_MAX_DURATION_SECONDS = 300;
167
- const DEFAULT_SLACK_SLASH_COMMAND = "/jr";
168
194
  const DEFAULT_PROCESSING_REACTION_EMOJI = "eyes";
169
195
  const DEFAULT_COMPLETED_REACTION_EMOJI = "white_check_mark";
170
196
  const DEFAULT_MODEL_CONTEXT_WINDOW_TOKENS = 4e5;
@@ -220,11 +246,6 @@ function parseOptionalPositiveInteger(envName, rawValue) {
220
246
  if (!Number.isSafeInteger(value) || value <= 0 || String(value) !== trimmed) throw new Error(`${envName} must be a positive integer`);
221
247
  return value;
222
248
  }
223
- function parseSlashCommand(rawValue) {
224
- const command = toOptionalTrimmed(rawValue) ?? DEFAULT_SLACK_SLASH_COMMAND;
225
- if (!command.startsWith("/") || /\s/.test(command)) throw new Error("JUNIOR_SLASH_COMMAND must start with / and contain no whitespace");
226
- return command;
227
- }
228
249
  function parseConversationWorkEnabled(rawValue) {
229
250
  const value = toOptionalTrimmed(rawValue)?.toLowerCase();
230
251
  if (value === void 0 || value === "true") return true;
@@ -412,6 +433,7 @@ function readChatConfig(env = process.env, functionMaxDurationSeconds = DEFAULT_
412
433
  return {
413
434
  attachmentStorage: readAttachmentStorageConfig(env),
414
435
  bot: readBotConfig(env, resolvedFunctionMaxDurationSeconds),
436
+ queue: readQueueConfig(env),
415
437
  functionMaxDurationSeconds: resolvedFunctionMaxDurationSeconds,
416
438
  conversationWorkEnabled: parseConversationWorkEnabled(env.JUNIOR_CONVERSATION_WORK_ENABLED),
417
439
  conversationWorkSoftYieldAfterMs: resolveConversationWorkSoftYieldAfterMs(resolvedFunctionMaxDurationSeconds),
@@ -426,9 +448,9 @@ function readChatConfig(env = process.env, functionMaxDurationSeconds = DEFAULT_
426
448
  clientSecret: toOptionalTrimmed(env.SLACK_CLIENT_SECRET),
427
449
  completedReactionEmoji: DEFAULT_COMPLETED_REACTION_EMOJI,
428
450
  processingReactionEmoji: DEFAULT_PROCESSING_REACTION_EMOJI,
429
- signingSecret: toOptionalTrimmed(env.SLACK_SIGNING_SECRET),
430
- slashCommand: parseSlashCommand(env.JUNIOR_SLASH_COMMAND)
451
+ signingSecret: toOptionalTrimmed(env.SLACK_SIGNING_SECRET)
431
452
  },
453
+ sandbox: { provider: env.JUNIOR_SANDBOX_PROVIDER?.trim().toLowerCase() === "docker" ? "docker" : "vercel" },
432
454
  state: {
433
455
  adapter: env.JUNIOR_STATE_ADAPTER?.trim().toLowerCase() === "memory" ? "memory" : "redis",
434
456
  keyPrefix: toOptionalTrimmed(env.JUNIOR_STATE_KEY_PREFIX),
@@ -1,14 +1,13 @@
1
- import { Mt as failTurnRecord, Nt as getTurnRecord, Ot as loadTurnCheckpoint } from "./tasks-DDT-J3Rf.js";
2
- import { n as botConfig } from "./config-C0UwYqDK.js";
3
- import { A as deleteProviderIdentityForSlackUser, j as deleteProviderIdentityForUser, l as getConversationEventStore, p as getSqlExecutor } from "./viewer-BpE6Z3qf.js";
4
- import { u as hasRequiredOAuthScope } from "./registry-1BEIPdbT.js";
5
- import { n as pluginCatalogRuntime } from "./catalog-runtime-DAJjAbSx.js";
6
- import { c as deleteMcpServerSessionId, l as deleteMcpStoredOAuthCredentials, s as deleteMcpAuthSessionsForUserProvider } from "./agent-runner-BtYK7bht.js";
7
- import { ct as startOAuthFlow } from "./credentialed-enF5Bf3y.js";
8
- import { r as getStateAdapter } from "./adapter-eRFA_naf.js";
9
- import { a as getVercelConversationWorkQueue } from "./job-queue-DBpHmKnd.js";
10
- import { m as ensureConversationWake, w as requestConversationWork } from "./store-FALy-JQb.js";
11
- import { n as resolveTurnSessionRouting } from "./turn-session-routing-a9CHX-w6.js";
1
+ import { Jt as failTurnRecord, Wt as loadTurnCheckpoint, Yt as getTurnRecord, j as resolveTurnSessionRouting } from "./tasks-SB9z-VTU.js";
2
+ import { n as botConfig } from "./config-DrTeF80T.js";
3
+ import { T as deleteProviderIdentityForUser, d as getConversationEventStore, h as getSqlExecutor, w as deleteProviderIdentityForSlackUser } from "./viewer-CpXTGlep.js";
4
+ import { u as hasRequiredOAuthScope } from "./registry-BgecKva0.js";
5
+ import { n as pluginCatalogRuntime } from "./catalog-runtime-BD9GSpc6.js";
6
+ import { c as deleteMcpServerSessionId, l as deleteMcpStoredOAuthCredentials, s as deleteMcpAuthSessionsForUserProvider } from "./agent-runner-CAYfFmU7.js";
7
+ import { H as startOAuthFlow } from "./credentialed-lukuD-cc.js";
8
+ import { i as getStateAdapter } from "./adapter-04AcD2SO.js";
9
+ import { a as getVercelConversationWorkQueue } from "./job-queue-In9QKz-I.js";
10
+ import { m as ensureConversationWake, w as requestConversationWork } from "./store-zPEoJPBB.js";
12
11
  import { z } from "zod";
13
12
  import { randomBytes, randomUUID } from "node:crypto";
14
13
  // src/chat/task-execution/authorized-turn.ts
@@ -85,7 +84,8 @@ async function getPausedTurnRequest(args) {
85
84
  conversationId: args.conversationId,
86
85
  destination: routing.destination,
87
86
  turnId: args.turnId,
88
- expectedVersion: turn.version
87
+ expectedVersion: turn.version,
88
+ traceContext: turn.traceContext
89
89
  };
90
90
  }
91
91
  /** Wake the conversation worker for a paused turn. */
@@ -426,6 +426,13 @@ const cancelConversationPendingMessagesResponseSchema = z.object({
426
426
  cancelledInboundMessageIds: z.array(z.string().min(1)),
427
427
  conversationId: z.string().min(1)
428
428
  }).strict();
429
+ /** Queued web messages that the viewer wants Junior to read now. */
430
+ const steerConversationPendingMessagesBodySchema = z.object({ inboundMessageIds: z.array(z.string().min(1)).min(1) }).strict();
431
+ /** Result of steering queued web messages into the conversation. */
432
+ const steerConversationPendingMessagesResponseSchema = z.object({
433
+ conversationId: z.string().min(1),
434
+ steeredInboundMessageIds: z.array(z.string().min(1))
435
+ }).strict();
429
436
  const conversationAuxiliaryCostsSchema = z.object({
430
437
  costUsd: z.number().finite().nonnegative(),
431
438
  operations: z.array(z.object({
@@ -913,4 +920,4 @@ const conversationFeedSchema = z.object({
913
920
  source: z.literal("conversation_index"),
914
921
  generatedAt: z.string()
915
922
  }).strict();
916
- export { forkConversationResponseSchema as A, readMessageAttachments as B, conversationReportEventSchema as C, createConversationBodySchema as D, conversationUsageSchema as E, readMessageCardRefs as F, briefLinkSchema as G, detectImageMediaType as H, removedCardSchema as I, parseBriefInput as J, briefOutcomeStatusSchema as K, resolveMessageCards as L, annotationCard as M, messageCardRef as N, createConversationMessageBodySchema as O, messageCardText as P, MAX_INPUT_IMAGES as R, conversationReportEventDataSchema as S, conversationSummaryReportSchema as T, isVisionImageMediaType as U, INPUT_IMAGE_TYPES as V, briefCodeChangeSchema as W, conversationParamsSchema as _, cancelConversationPendingMessagesBodySchema as a, conversationPendingMessageSchema as b, conversationAttachmentParamsSchema as c, conversationDetailReportSchema as d, conversationEventHistorySchema as f, conversationFeedSchema as g, conversationFeedQuerySchema as h, archiveConversationResponseSchema as i, conversationChildAgentTotalsSchema as j, forkConversationBodySchema as k, conversationAuxiliaryCostsSchema as l, conversationEventsQuerySchema as m, actorIdentitySchema as n, cancelConversationPendingMessagesResponseSchema as o, conversationEventPageSchema as p, conversationBriefSchema as q, archiveConversationBodySchema as r, conversationActivityPreviewSchema as s, acceptedConversationMessageSchema as t, conversationDetailQuerySchema as u, conversationPendingAuthorizationSchema as v, conversationReportMessageEventSchema as w, conversationPendingMessagesReportSchema as x, conversationPendingMessageDeliverySchema as y, MAX_INPUT_IMAGE_BYTES as z };
923
+ export { createConversationMessageBodySchema as A, removedCardSchema as B, conversationReportEventSchema as C, conversationSurfaceSchema as D, conversationSummaryReportSchema as E, conversationChildAgentTotalsSchema as F, INPUT_IMAGE_TYPES as G, MAX_INPUT_IMAGES as H, annotationCard as I, briefCodeChangeSchema as J, detectImageMediaType as K, messageCardRef as L, forkConversationResponseSchema as M, steerConversationPendingMessagesBodySchema as N, conversationUsageSchema as O, steerConversationPendingMessagesResponseSchema as P, parseBriefInput as Q, messageCardText as R, conversationReportEventDataSchema as S, conversationReportStatusSchema as T, MAX_INPUT_IMAGE_BYTES as U, resolveMessageCards as V, readMessageAttachments as W, briefOutcomeStatusSchema as X, briefLinkSchema as Y, conversationBriefSchema as Z, conversationParamsSchema as _, cancelConversationPendingMessagesBodySchema as a, conversationPendingMessageSchema as b, conversationAttachmentParamsSchema as c, conversationDetailReportSchema as d, conversationEventHistorySchema as f, conversationFeedSchema as g, conversationFeedQuerySchema as h, archiveConversationResponseSchema as i, forkConversationBodySchema as j, createConversationBodySchema as k, conversationAuxiliaryCostsSchema as l, conversationEventsQuerySchema as m, actorIdentitySchema as n, cancelConversationPendingMessagesResponseSchema as o, conversationEventPageSchema as p, isVisionImageMediaType as q, archiveConversationBodySchema as r, conversationActivityPreviewSchema as s, acceptedConversationMessageSchema as t, conversationDetailQuerySchema as u, conversationPendingAuthorizationSchema as v, conversationReportMessageEventSchema as w, conversationPendingMessagesReportSchema as x, conversationPendingMessageDeliverySchema as y, readMessageCardRefs as z };
@@ -1,4 +1,4 @@
1
- import { m as logWarn } from "./logging-Ce0mXZ8J.js";
1
+ import { h as logWarn } from "./logging-DLSpkSSr.js";
2
2
  import { AsyncLocalStorage } from "node:async_hooks";
3
3
  // src/chat/conversation-privacy.ts
4
4
  const SAFE_METADATA_KEY_LIMIT = 20;
@@ -1,19 +1,19 @@
1
- import { H as recordAuthorizationCompleted, Nt as getTurnRecord, Tt as getConversationPendingAuth, V as recordAuthenticationLinked } from "./tasks-DDT-J3Rf.js";
2
- import { p as escapeXml } from "./client-B0YZfxNy.js";
3
- import { a as getRuntimeMetadata, n as botConfig } from "./config-C0UwYqDK.js";
4
- import { L as isNativeIdentityProvider, f as logException, g as runBestEffort, m as logWarn } from "./logging-Ce0mXZ8J.js";
5
- import { f as parseSlackUserId } from "./actor-tlxzqaRe.js";
6
- import { I as upsertIdentity, L as upsertLinkedIdentity, M as findUserByVerifiedEmails, p as getSqlExecutor, x as identityFromActor } from "./viewer-BpE6Z3qf.js";
1
+ import { Vt as getConversationPendingAuth, Yt as getTurnRecord, it as recordAuthorizationCompleted, rt as recordAuthenticationLinked } from "./tasks-SB9z-VTU.js";
2
+ import { p as escapeXml } from "./client-C1yDYjoS.js";
3
+ import { a as getRuntimeMetadata, n as botConfig } from "./config-DrTeF80T.js";
4
+ import { R as isNativeIdentityProvider, _ as runBestEffort, h as logWarn, p as logException } from "./logging-DLSpkSSr.js";
5
+ import { p as parseSlackUserId } from "./actor-CP9K2Idu.js";
6
+ import { A as upsertLinkedIdentity, C as resolveActorIdentityId, E as findUserByVerifiedEmails, a as readIdentityById, h as getSqlExecutor } from "./viewer-CpXTGlep.js";
7
7
  import { i as homeDir } from "./package-discovery-DJBompdd.js";
8
- import { n as buildOAuthTokenRequest, r as parseOAuthTokenResponse, u as hasRequiredOAuthScope } from "./registry-1BEIPdbT.js";
9
- import { n as pluginCatalogRuntime } from "./catalog-runtime-DAJjAbSx.js";
10
- import { t as discoverSkills } from "./skills-DzyGN7wd.js";
11
- import { a as finalizeMcpAuthorization, d as getMcpStoredOAuthCredentials, f as putMcpStoredOAuthCredentials, o as deleteMcpAuthSession, u as getMcpAuthSession, v as lookupSlackUserProfile } from "./agent-runner-BtYK7bht.js";
12
- import { at as formatProviderLabel, en as getSlackClient, i as resolvePluginOAuthAccount, n as createUserTokenStore, ot as parseOAuthStatePayload, st as resolveBaseUrl, vt as postSlackMessage } from "./credentialed-enF5Bf3y.js";
13
- import { a as acquireActiveLock, r as getStateAdapter } from "./adapter-eRFA_naf.js";
14
- import { _ as getMcpProviderErrorAttributes } from "./service-account-6wC76eBZ.js";
15
- import { r as getPersistedThreadState, s as coerceThreadConversationState } from "./thread-state-cprEaxgl.js";
16
- import { c as deleteWebAuthorization, i as readConnectedOAuthTokens, m as wakePausedTurn, p as wakeAuthorizedTurn, u as htmlCallbackResponse } from "./connections-Bwu3VORi.js";
8
+ import { n as buildOAuthTokenRequest, r as parseOAuthTokenResponse, u as hasRequiredOAuthScope } from "./registry-BgecKva0.js";
9
+ import { n as pluginCatalogRuntime } from "./catalog-runtime-BD9GSpc6.js";
10
+ import { t as discoverSkills } from "./skills-CfAnfImD.js";
11
+ import { a as finalizeMcpAuthorization, d as getMcpStoredOAuthCredentials, f as putMcpStoredOAuthCredentials, o as deleteMcpAuthSession, u as getMcpAuthSession, v as lookupSlackUserProfile } from "./agent-runner-CAYfFmU7.js";
12
+ import { B as parseOAuthStatePayload, V as resolveBaseUrl, i as resolvePluginOAuthAccount, in as getSlackClient, n as createUserTokenStore, tt as postSlackMessage, z as formatProviderLabel } from "./credentialed-lukuD-cc.js";
13
+ import { i as getStateAdapter, o as acquireActiveLock } from "./adapter-04AcD2SO.js";
14
+ import { _ as getMcpProviderErrorAttributes } from "./service-account-CKV2WTY7.js";
15
+ import { o as coerceThreadConversationState, r as getPersistedThreadState } from "./thread-state-BbbPh0Sn.js";
16
+ import { c as deleteWebAuthorization, i as readConnectedOAuthTokens, m as wakePausedTurn, p as wakeAuthorizedTurn, u as htmlCallbackResponse } from "./connections-D46f8vvi.js";
17
17
  import { n as relayLocalOAuthCallback } from "./oauth-relay-CTygMkNx.js";
18
18
  import path from "node:path";
19
19
  import { z } from "zod";
@@ -394,28 +394,23 @@ function pluginAuthorizationId(args) {
394
394
  }
395
395
  /** Return the Junior user of the person who started the OAuth connection. */
396
396
  async function resolveOAuthActorUserId(actor) {
397
- if (actor.platform === "web") {
398
- const observation = identityFromActor(actor.email ? {
399
- email: actor.email,
400
- ...actor.fullName ? { fullName: actor.fullName } : void 0
401
- } : void 0);
402
- return observation ? (await upsertIdentity(getSqlExecutor(), observation)).userId : void 0;
403
- }
397
+ const identityActor = actor.platform === "web" ? actor : await slackProfileActor(actor);
398
+ const identityId = await resolveActorIdentityId(getSqlExecutor(), identityActor);
399
+ return identityId ? (await readIdentityById(identityId))?.user?.id : void 0;
400
+ }
401
+ /** Refresh a Slack actor with the profile Slack returns for that user. */
402
+ async function slackProfileActor(actor) {
404
403
  const slackUserId = parseSlackUserId(actor.userId);
405
404
  if (!slackUserId) throw new Error("OAuth Slack actor user id is invalid");
406
405
  const profile = await lookupSlackUserProfile(slackUserId);
407
- return (await upsertIdentity(getSqlExecutor(), {
408
- kind: "user",
409
- provider: "slack",
410
- providerTenantId: actor.teamId,
411
- providerSubjectId: profile.id,
412
- displayName: profile.real_name || profile.display_name,
413
- handle: profile.name,
414
- ...profile.email ? {
415
- email: profile.email,
416
- emailVerified: true
417
- } : void 0
418
- })).userId;
406
+ return {
407
+ platform: "slack",
408
+ teamId: actor.teamId,
409
+ userId: profile.id,
410
+ ...profile.real_name || profile.display_name ? { fullName: profile.real_name || profile.display_name } : void 0,
411
+ ...profile.name ? { userName: profile.name } : void 0,
412
+ ...profile.email ? { email: profile.email } : void 0
413
+ };
419
414
  }
420
415
  /**
421
416
  * Link a connected provider account to the person who connected it.