@sentry/junior 0.146.0 → 0.148.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 (227) hide show
  1. package/dist/{agent-hooks-SLJADYE5.js → agent-hooks-VAUYT6PD.js} +10 -10
  2. package/dist/api/conversations/access.d.ts +2 -1
  3. package/dist/api/conversations/archive.d.ts +3 -5
  4. package/dist/api/conversations/create.d.ts +6 -0
  5. package/dist/api/conversations/detail.d.ts +2 -295
  6. package/dist/api/conversations/event-list.d.ts +2 -192
  7. package/dist/api/conversations/list.d.ts +4 -66
  8. package/dist/api/conversations/routes.d.ts +1 -1
  9. package/dist/api/conversations/stats.d.ts +0 -54
  10. package/dist/api/http.d.ts +2 -6
  11. package/dist/api/locations/detail.d.ts +3 -111
  12. package/dist/api/locations/list.d.ts +0 -45
  13. package/dist/api/locations/query.d.ts +2 -1
  14. package/dist/api/locations/routes.d.ts +1 -1
  15. package/dist/api/people/list.d.ts +0 -29
  16. package/dist/api/people/profile.d.ts +2 -106
  17. package/dist/api/people/profile.query.d.ts +2 -1
  18. package/dist/api/people/routes.d.ts +1 -1
  19. package/dist/api/people/shared.d.ts +1 -1
  20. package/dist/api/people/spend.d.ts +3 -4
  21. package/dist/api/personal-tokens/routes.d.ts +2 -2
  22. package/dist/api/route.d.ts +8 -14
  23. package/dist/api/schema/conversation.d.ts +64 -29
  24. package/dist/api/schema/location.d.ts +4 -0
  25. package/dist/api/schema/person.d.ts +7 -3
  26. package/dist/api/schema.d.ts +2 -2
  27. package/dist/api/schema.js +7 -1
  28. package/dist/api/stats.d.ts +0 -13
  29. package/dist/api/validation.d.ts +7 -0
  30. package/dist/api/viewer.d.ts +3 -0
  31. package/dist/api.d.ts +2 -1
  32. package/dist/api.js +630 -564
  33. package/dist/app.js +369 -309
  34. package/dist/{catalog-runtime-RQIMSDPR.js → catalog-runtime-WADOZVTB.js} +5 -5
  35. package/dist/chat/actor.d.ts +4 -1
  36. package/dist/chat/agent/prompt.d.ts +0 -2
  37. package/dist/chat/agent/request.d.ts +4 -5
  38. package/dist/chat/agent/resume.d.ts +1 -0
  39. package/dist/chat/agent/sandbox.d.ts +2 -2
  40. package/dist/chat/agent/tools.d.ts +0 -2
  41. package/dist/chat/agent-dispatch/context.d.ts +2 -2
  42. package/dist/chat/agent-dispatch/types.d.ts +2 -2
  43. package/dist/chat/agent-invocations/types.d.ts +52 -0
  44. package/dist/chat/api-turns/work.d.ts +103 -0
  45. package/dist/chat/capabilities/jr-rpc-command.d.ts +2 -2
  46. package/dist/chat/configuration/service.d.ts +5 -2
  47. package/dist/chat/configuration/sql.d.ts +9 -0
  48. package/dist/chat/configuration/types.d.ts +17 -13
  49. package/dist/chat/conversations/history.d.ts +63 -0
  50. package/dist/chat/conversations/projection.d.ts +10 -0
  51. package/dist/chat/conversations/provenance.d.ts +6 -0
  52. package/dist/chat/conversations/sql/actor-identity.d.ts +19 -0
  53. package/dist/chat/conversations/store.d.ts +1 -1
  54. package/dist/chat/credentials/unlink-provider.d.ts +2 -1
  55. package/dist/chat/credentials/user-token-store.d.ts +2 -0
  56. package/dist/chat/event-tasks/tool-support.d.ts +2 -0
  57. package/dist/chat/identities/sql.d.ts +8 -0
  58. package/dist/chat/logging.d.ts +2 -0
  59. package/dist/chat/mcp/auth-store.d.ts +0 -2
  60. package/dist/chat/mcp/oauth.d.ts +0 -2
  61. package/dist/chat/oauth-flow.d.ts +3 -1
  62. package/dist/chat/pi/client.d.ts +2 -0
  63. package/dist/chat/plugins/credential-hooks.d.ts +2 -0
  64. package/dist/chat/prompt.d.ts +0 -2
  65. package/dist/chat/resource-events/notification.d.ts +2 -1
  66. package/dist/chat/resource-events/store.d.ts +1 -1
  67. package/dist/chat/runtime/delivered-turn-state.d.ts +1 -4
  68. package/dist/chat/runtime/reply-executor.d.ts +1 -1
  69. package/dist/chat/runtime/slack-runtime.d.ts +2 -1
  70. package/dist/chat/runtime/thread-state.d.ts +8 -11
  71. package/dist/chat/runtime/turn-input.d.ts +4 -2
  72. package/dist/chat/runtime/turn-preparation.d.ts +11 -4
  73. package/dist/chat/sandbox/command-result.d.ts +2 -0
  74. package/dist/chat/sandbox/egress/schemas.d.ts +6 -0
  75. package/dist/chat/scheduled-tasks/tool-support.d.ts +7 -5
  76. package/dist/chat/scheduled-tasks/tools/create.d.ts +4 -2
  77. package/dist/chat/scheduled-tasks/tools/delete.d.ts +4 -2
  78. package/dist/chat/scheduled-tasks/tools/list.d.ts +4 -2
  79. package/dist/chat/scheduled-tasks/tools/run-now.d.ts +4 -2
  80. package/dist/chat/scheduled-tasks/tools/update.d.ts +4 -2
  81. package/dist/chat/services/mcp-auth-orchestration.d.ts +0 -3
  82. package/dist/chat/services/plugin-auth-orchestration.d.ts +2 -1
  83. package/dist/chat/services/provider-default-config.d.ts +2 -2
  84. package/dist/chat/services/subscribed-decision.d.ts +3 -0
  85. package/dist/chat/services/subscribed-reply-policy.d.ts +1 -0
  86. package/dist/chat/services/turn-result.d.ts +0 -3
  87. package/dist/chat/services/turn-router.d.ts +3 -0
  88. package/dist/chat/slack/assistant-thread/lifecycle.d.ts +0 -1
  89. package/dist/chat/slack/assistant-thread/title.d.ts +0 -3
  90. package/dist/chat/slack/channel.d.ts +26 -0
  91. package/dist/chat/slack/dispatch-turn.d.ts +2 -1
  92. package/dist/chat/slack/timestamp-param.d.ts +0 -2
  93. package/dist/chat/slack/{tools → tool-support}/canvas/api.d.ts +1 -1
  94. package/dist/chat/slack/tool-support/canvas/context.d.ts +11 -0
  95. package/dist/chat/slack/tool-support/channel-access.d.ts +42 -0
  96. package/dist/chat/slack/tool-support/channel-target.d.ts +27 -0
  97. package/dist/chat/slack/{tools → tool-support}/list/api.d.ts +8 -1
  98. package/dist/chat/slack/tool-support/list/params.d.ts +5 -0
  99. package/dist/chat/slack/tools/canvas/create.d.ts +3 -1
  100. package/dist/chat/slack/tools/canvas/edit.d.ts +2 -0
  101. package/dist/chat/slack/tools/canvas/read.d.ts +2 -0
  102. package/dist/chat/slack/tools/canvas/write.d.ts +2 -0
  103. package/dist/chat/slack/tools/{user-lookup.d.ts → channel-join.d.ts} +6 -5
  104. package/dist/chat/slack/tools/channel-list-messages.d.ts +5 -2
  105. package/dist/chat/slack/tools/conversation-message-search.d.ts +4 -8
  106. package/dist/chat/slack/tools/list/add-items.d.ts +4 -1
  107. package/dist/chat/slack/tools/list/create.d.ts +2 -0
  108. package/dist/chat/slack/tools/list/get-items.d.ts +5 -3
  109. package/dist/chat/slack/tools/list/update-item.d.ts +5 -1
  110. package/dist/chat/slack/tools/message-add-reaction.d.ts +3 -1
  111. package/dist/chat/slack/tools/public-search.d.ts +65 -2
  112. package/dist/chat/slack/tools/send-files.d.ts +3 -1
  113. package/dist/chat/slack/tools/thread-read.d.ts +4 -5
  114. package/dist/chat/slack/vision-cache.d.ts +5 -0
  115. package/dist/chat/source.d.ts +2 -0
  116. package/dist/chat/state/conversation.d.ts +4 -5
  117. package/dist/chat/task-execution/checkpoint.d.ts +1 -0
  118. package/dist/chat/task-execution/state.d.ts +9 -4
  119. package/dist/chat/task-execution/store.d.ts +3 -2
  120. package/dist/chat/task-execution/turn-cursor.d.ts +2 -0
  121. package/dist/chat/task-execution/worker.d.ts +2 -0
  122. package/dist/chat/tasks/read.d.ts +1 -1
  123. package/dist/chat/tool-support/structured-result.d.ts +1 -0
  124. package/dist/chat/tool-support/timed-out-tool-result.d.ts +11 -0
  125. package/dist/chat/tools/create-event-task.d.ts +2 -0
  126. package/dist/chat/tools/delete-event-task.d.ts +2 -0
  127. package/dist/chat/tools/handoff/tool.d.ts +2 -0
  128. package/dist/chat/tools/list-event-tasks.d.ts +2 -0
  129. package/dist/chat/tools/list-resource-event-subscriptions.d.ts +2 -0
  130. package/dist/chat/tools/runtime/report-progress.d.ts +2 -0
  131. package/dist/chat/tools/runtime/spawn-agent.d.ts +2 -0
  132. package/dist/chat/tools/search-conversation-events.d.ts +3 -1
  133. package/dist/chat/tools/search-resource-event-types.d.ts +2 -0
  134. package/dist/chat/tools/search-tools.d.ts +2 -0
  135. package/dist/chat/tools/skill/load-skill.d.ts +2 -0
  136. package/dist/chat/tools/skill/search-mcp-tools.d.ts +2 -0
  137. package/dist/chat/tools/stop-watching-resources.d.ts +2 -0
  138. package/dist/chat/tools/system-time.d.ts +2 -0
  139. package/dist/chat/tools/types.d.ts +11 -10
  140. package/dist/chat/tools/update-event-task.d.ts +2 -0
  141. package/dist/chat/tools/user-lookup.d.ts +29 -0
  142. package/dist/chat/tools/watch-resource-events.d.ts +4 -2
  143. package/dist/chat/tools/web/fetch-tool.d.ts +2 -0
  144. package/dist/chat/tools/web/image-generate.d.ts +2 -0
  145. package/dist/chat/tools/web/search.d.ts +2 -0
  146. package/dist/{chunk-GYEKOX7N.js → chunk-2B3PT3V2.js} +1 -1
  147. package/dist/{chunk-JLMVCNXL.js → chunk-45LOR4PU.js} +22 -4
  148. package/dist/{chunk-FGHADGIC.js → chunk-4AQZYNHM.js} +2 -2
  149. package/dist/{chunk-W65V465O.js → chunk-4EA2SFK2.js} +66 -4
  150. package/dist/{chunk-MKRIZ4VG.js → chunk-4GXJUYJV.js} +4 -2
  151. package/dist/{chunk-F7REGDKO.js → chunk-55F4QU2V.js} +2 -1
  152. package/dist/{chunk-M6ZWP4RI.js → chunk-7OEIXFC3.js} +2 -2
  153. package/dist/{chunk-MCFIXAV5.js → chunk-D3WPMGEX.js} +55 -37
  154. package/dist/{chunk-AISNSNDV.js → chunk-D6YX4NNN.js} +22 -10
  155. package/dist/chunk-DUY5CDAM.js +36 -0
  156. package/dist/{chunk-B63BF443.js → chunk-EAI67NTM.js} +9 -1
  157. package/dist/{chunk-FEKQHPVA.js → chunk-EINWQFXI.js} +9 -8
  158. package/dist/chunk-GDFF3BQG.js +136 -0
  159. package/dist/{chunk-X22KCSCO.js → chunk-GXYDVZKM.js} +7 -5
  160. package/dist/{chunk-X2WMBTS3.js → chunk-HLPLT3NY.js} +8 -5
  161. package/dist/{chunk-PB222GIA.js → chunk-HWQGBIH7.js} +1 -1
  162. package/dist/chunk-IL4EDBMV.js +566 -0
  163. package/dist/{chunk-HQE6EJS5.js → chunk-LAZGHEYU.js} +1 -1
  164. package/dist/{chunk-QG7OOKIN.js → chunk-LE5H7LMT.js} +1 -1
  165. package/dist/chunk-LNVEIJ2L.js +48 -0
  166. package/dist/{chunk-JUA6VU2Z.js → chunk-OJCP3C3J.js} +12 -23
  167. package/dist/{chunk-37JJDS4H.js → chunk-POSZWRGL.js} +1 -1
  168. package/dist/{chunk-TCEJ7XXM.js → chunk-QOWHHM3F.js} +1 -1
  169. package/dist/{chunk-H6U2U3EP.js → chunk-RRJV5UR5.js} +304 -65
  170. package/dist/{chunk-OFPYOC3M.js → chunk-ULAU5ZGU.js} +127 -120
  171. package/dist/{chunk-V6SRLKUB.js → chunk-V2FXMOEA.js} +2 -2
  172. package/dist/{chunk-GDQEU4I7.js → chunk-VCYSOXON.js} +296 -526
  173. package/dist/{chunk-BLETMLRX.js → chunk-VMNRXKAH.js} +1374 -989
  174. package/dist/{chunk-37EVZP66.js → chunk-VRHTNBA6.js} +167 -92
  175. package/dist/{chunk-FXDDDSPL.js → chunk-VY6W3T43.js} +4 -4
  176. package/dist/{chunk-ZDGHGY74.js → chunk-WCN4YSH7.js} +13 -6
  177. package/dist/{chunk-PH4Q3A6W.js → chunk-WOONT5ZP.js} +1 -1
  178. package/dist/{chunk-47OSH2ZO.js → chunk-XJ42NBP5.js} +395 -206
  179. package/dist/{chunk-SCGVWUZX.js → chunk-ZCHIC2GM.js} +92 -75
  180. package/dist/chunk-ZPL2RR7F.js +798 -0
  181. package/dist/cli/chat.js +33 -35
  182. package/dist/cli/check.js +6 -6
  183. package/dist/cli/plugins.js +13 -13
  184. package/dist/cli/snapshot-create.js +9 -9
  185. package/dist/cli/upgrade.js +7 -7
  186. package/dist/db/schema/agent-invocations.d.ts +20 -0
  187. package/dist/db/schema/conversation-annotations.d.ts +2 -2
  188. package/dist/db/schema/location-configurations.d.ts +127 -0
  189. package/dist/db/schema.d.ts +150 -3
  190. package/dist/{db-WWOMXWTT.js → db-XUKZRFFK.js} +7 -7
  191. package/dist/instrumentation.js +4 -4
  192. package/dist/nitro.js +2 -2
  193. package/dist/{oauth-callback-server-A6ZZX74U.js → oauth-callback-server-LPZMMGFI.js} +25 -26
  194. package/dist/{runner-KSGB2UAV.js → runner-DGKUTMPX.js} +22 -41
  195. package/dist/{skills-26QPWKVS.js → skills-P7YUFSXM.js} +6 -6
  196. package/dist/spawn-DSK3ZEVD.js +38 -0
  197. package/dist/{validation-OPSRGFGH.js → validation-S7U5M5NR.js} +6 -6
  198. package/dist/version.js +1 -1
  199. package/dist/{work-VMSW7STJ.js → work-GAA7TVAD.js} +18 -19
  200. package/dist/{worker-2JNFB7C7.js → worker-JXPJH3QB.js} +11 -10
  201. package/migrations/0024_misty_typhoid_mary.sql +12 -0
  202. package/migrations/meta/0024_snapshot.json +2275 -0
  203. package/migrations/meta/_journal.json +7 -0
  204. package/package.json +6 -5
  205. package/dist/api/health.d.ts +0 -7
  206. package/dist/api/personal-tokens/create.d.ts +0 -11
  207. package/dist/api/personal-tokens/list.d.ts +0 -12
  208. package/dist/api/personal-tokens/revoke.d.ts +0 -5
  209. package/dist/api/plugin-reports.d.ts +0 -63
  210. package/dist/api/plugins.d.ts +0 -8
  211. package/dist/api/runtime.d.ts +0 -24
  212. package/dist/api/skills.d.ts +0 -6
  213. package/dist/chat/slack/tools/canvas/context.d.ts +0 -18
  214. package/dist/chat/slack/tools/channel-access.d.ts +0 -30
  215. package/dist/chat/state/artifacts.d.ts +0 -30
  216. package/dist/chat/tool-support/turn-deadline-result.d.ts +0 -3
  217. package/dist/chunk-HLXXQI5Q.js +0 -238
  218. package/dist/chunk-LVW7BLLT.js +0 -115
  219. package/dist/chunk-Q6QZTTLS.js +0 -55
  220. package/dist/chunk-QSXZ42KX.js +0 -285
  221. package/dist/chunk-R776HKPK.js +0 -81
  222. package/dist/chunk-T5GXFFLA.js +0 -67
  223. package/dist/spawn-5LAJXZ2P.js +0 -39
  224. /package/dist/chat/slack/{tools → tool-support}/canvas/markdown.d.ts +0 -0
  225. /package/dist/chat/slack/{tools → tool-support}/channel-capabilities.d.ts +0 -0
  226. /package/dist/chat/slack/{tools → tool-support}/context.d.ts +0 -0
  227. /package/dist/chat/slack/{tools → tool-support}/slack-message-url.d.ts +0 -0
@@ -1,30 +1,34 @@
1
1
  import {
2
2
  resolveBaseUrl
3
- } from "./chunk-ZDGHGY74.js";
3
+ } from "./chunk-WCN4YSH7.js";
4
4
  import {
5
5
  createPluginLogger,
6
6
  getPlugins
7
- } from "./chunk-SCGVWUZX.js";
7
+ } from "./chunk-ZCHIC2GM.js";
8
+ import {
9
+ getSlackClient,
10
+ withSlackRetries
11
+ } from "./chunk-V2FXMOEA.js";
8
12
  import {
9
13
  getDb,
10
14
  parseDestination
11
- } from "./chunk-37EVZP66.js";
15
+ } from "./chunk-VRHTNBA6.js";
12
16
  import {
13
17
  sleep
14
18
  } from "./chunk-EM225ITJ.js";
15
19
  import {
16
20
  acquireActiveLock,
17
21
  getStateAdapter
18
- } from "./chunk-GYEKOX7N.js";
22
+ } from "./chunk-2B3PT3V2.js";
19
23
  import {
20
24
  pluginCatalogRuntime
21
- } from "./chunk-PB222GIA.js";
25
+ } from "./chunk-HWQGBIH7.js";
22
26
  import {
23
27
  fetchWithBoundedOAuthErrorBodies
24
- } from "./chunk-37JJDS4H.js";
28
+ } from "./chunk-POSZWRGL.js";
25
29
  import {
26
30
  isRecord
27
- } from "./chunk-B63BF443.js";
31
+ } from "./chunk-EAI67NTM.js";
28
32
 
29
33
  // src/chat/capabilities/router.ts
30
34
  var ProviderCredentialRouter = class {
@@ -209,6 +213,379 @@ function getMcpAwareTelemetryMessage(error, _privacy) {
209
213
  return getMcpAwareErrorMessage(error);
210
214
  }
211
215
 
216
+ // src/chat/slack/users.ts
217
+ function normalizeUser(raw) {
218
+ const rawFields = raw.profile?.fields;
219
+ const profileFields = [];
220
+ if (rawFields && typeof rawFields === "object") {
221
+ for (const [id, field] of Object.entries(rawFields)) {
222
+ if (!field) continue;
223
+ profileFields.push({
224
+ id,
225
+ label: field.label || void 0,
226
+ value: field.value || void 0,
227
+ alt: field.alt || void 0
228
+ });
229
+ }
230
+ }
231
+ return {
232
+ id: raw.id ?? "",
233
+ team_id: raw.team_id || void 0,
234
+ name: raw.name || void 0,
235
+ real_name: raw.real_name || raw.profile?.real_name || void 0,
236
+ display_name: raw.profile?.display_name || void 0,
237
+ title: raw.profile?.title || void 0,
238
+ email: raw.profile?.email || void 0,
239
+ status_text: raw.profile?.status_text ?? void 0,
240
+ status_emoji: raw.profile?.status_emoji ?? void 0,
241
+ is_bot: raw.is_bot ?? false,
242
+ is_deleted: raw.deleted ?? false,
243
+ timezone: raw.tz || void 0,
244
+ ...profileFields.length > 0 ? { profile_fields: profileFields } : {}
245
+ };
246
+ }
247
+ function normalizeNameTokens(value) {
248
+ return value.toLowerCase().split(/[^\p{L}\p{N}]+/u).filter(Boolean);
249
+ }
250
+ function nameFields(user) {
251
+ return [
252
+ user.name ?? "",
253
+ user.profile?.display_name ?? "",
254
+ user.real_name ?? user.profile?.real_name ?? ""
255
+ ].map((value) => value.toLowerCase().trim()).filter(Boolean);
256
+ }
257
+ async function lookupSlackUserProfile(userId) {
258
+ const client = getSlackClient();
259
+ const result = await withSlackRetries(
260
+ () => client.users.info({ user: userId }),
261
+ 3,
262
+ { action: "users.info" }
263
+ );
264
+ const user = result.user;
265
+ if (!user) {
266
+ throw new Error(`Slack users.info returned no user for ${userId}`);
267
+ }
268
+ return normalizeUser(user);
269
+ }
270
+ async function lookupSlackUserByEmail(email) {
271
+ const client = getSlackClient();
272
+ let result;
273
+ try {
274
+ result = await withSlackRetries(
275
+ () => client.users.lookupByEmail({ email }),
276
+ 3,
277
+ { action: "users.lookupByEmail" }
278
+ );
279
+ } catch (error) {
280
+ const apiError = error.apiError;
281
+ if (apiError === "users_not_found") {
282
+ return null;
283
+ }
284
+ throw error;
285
+ }
286
+ const user = result.user;
287
+ if (!user) {
288
+ return null;
289
+ }
290
+ return normalizeUser(user);
291
+ }
292
+ function scoreNameMatch(user, query) {
293
+ const queryLower = query.toLowerCase().trim();
294
+ if (!queryLower) return 0;
295
+ const fields = nameFields(user);
296
+ if (fields.length === 0) return 0;
297
+ let best = 0;
298
+ const queryTokens = normalizeNameTokens(queryLower);
299
+ for (const field of fields) {
300
+ if (field === queryLower) {
301
+ best = Math.max(best, 100);
302
+ continue;
303
+ }
304
+ if (field.startsWith(queryLower)) {
305
+ best = Math.max(best, 70);
306
+ } else if (field.includes(queryLower)) {
307
+ best = Math.max(best, 25);
308
+ }
309
+ const tokens = normalizeNameTokens(field);
310
+ for (const token of tokens) {
311
+ if (token === queryLower) {
312
+ best = Math.max(best, 85);
313
+ } else if (token.startsWith(queryLower)) {
314
+ best = Math.max(best, 60);
315
+ }
316
+ }
317
+ if (queryTokens.length > 1 && queryTokens.every(
318
+ (queryToken) => tokens.some(
319
+ (token) => token === queryToken || token.startsWith(queryToken)
320
+ )
321
+ )) {
322
+ best = Math.max(best, 95);
323
+ }
324
+ }
325
+ return best;
326
+ }
327
+ function compareNameMatches(left, right) {
328
+ if (right.score !== left.score) return right.score - left.score;
329
+ return (left.user.name ?? "").localeCompare(right.user.name ?? "");
330
+ }
331
+ async function listWorkspaceUsers(options) {
332
+ const client = getSlackClient();
333
+ const matches = [];
334
+ let cursor;
335
+ let pages = 0;
336
+ let totalScanned = 0;
337
+ while (pages < options.maxPages) {
338
+ pages++;
339
+ const result = await withSlackRetries(
340
+ () => client.users.list({
341
+ limit: 200,
342
+ ...cursor ? { cursor } : {}
343
+ }),
344
+ 3,
345
+ { action: "users.list" }
346
+ );
347
+ const members = result.members ?? [];
348
+ totalScanned += members.length;
349
+ for (const member of members) {
350
+ if (!options.includeDeleted && member.deleted) continue;
351
+ if (!options.includeBots && member.is_bot) continue;
352
+ if (member.id === "USLACKBOT") continue;
353
+ const score = options.score(member);
354
+ if (score <= 0) continue;
355
+ matches.push({ user: member, score });
356
+ }
357
+ const nextCursor = result.response_metadata?.next_cursor;
358
+ if (!nextCursor) {
359
+ cursor = void 0;
360
+ break;
361
+ }
362
+ cursor = nextCursor;
363
+ }
364
+ return {
365
+ matches,
366
+ searched_pages: pages,
367
+ searched_user_count: totalScanned,
368
+ // True only when we hit the page cap with more data remaining.
369
+ truncated: pages >= options.maxPages && Boolean(cursor)
370
+ };
371
+ }
372
+ async function searchSlackUsers(options) {
373
+ const {
374
+ query,
375
+ limit = 10,
376
+ maxPages = 3,
377
+ includeDeleted = false,
378
+ includeBots = false
379
+ } = options;
380
+ const queryLower = query.toLowerCase().trim();
381
+ const listed = await listWorkspaceUsers({
382
+ maxPages,
383
+ includeDeleted,
384
+ includeBots,
385
+ score: (member) => scoreNameMatch(member, queryLower)
386
+ });
387
+ listed.matches.sort(compareNameMatches);
388
+ return {
389
+ users: listed.matches.slice(0, limit).map((m) => normalizeUser(m.user)),
390
+ searched_pages: listed.searched_pages,
391
+ searched_user_count: listed.searched_user_count,
392
+ truncated: listed.truncated
393
+ };
394
+ }
395
+
396
+ // src/chat/plugins/credential-hooks.ts
397
+ import {
398
+ pluginAuthorizationSchema,
399
+ pluginCredentialResultSchema,
400
+ pluginGrantSchema,
401
+ pluginProviderAccountSchema
402
+ } from "@sentry/junior-plugin-api";
403
+ function parseSchema(schema, value, message) {
404
+ const result = schema.safeParse(value);
405
+ if (!result.success) {
406
+ throw new Error(message);
407
+ }
408
+ return result.data;
409
+ }
410
+ function parseAuthorization(value, pluginName) {
411
+ if (value === void 0) {
412
+ return void 0;
413
+ }
414
+ const authorization = parseSchema(
415
+ pluginAuthorizationSchema,
416
+ value,
417
+ `Plugin "${pluginName}" grant authorization is invalid`
418
+ );
419
+ if (authorization.provider !== pluginName) {
420
+ throw new Error(
421
+ `Plugin "${pluginName}" grant authorization provider must match the issuing plugin`
422
+ );
423
+ }
424
+ return authorization;
425
+ }
426
+ function parseGrant(value, pluginName) {
427
+ return parseSchema(
428
+ pluginGrantSchema,
429
+ value,
430
+ `Plugin "${pluginName}" grantForEgress returned an invalid grant`
431
+ );
432
+ }
433
+ function pluginFor(provider) {
434
+ return getPlugins().find((candidate) => candidate.manifest.name === provider);
435
+ }
436
+ function basePluginContext(plugin) {
437
+ const pluginName = plugin.manifest.name;
438
+ return {
439
+ plugin: { name: pluginName },
440
+ log: createPluginLogger(pluginName),
441
+ db: getDb()
442
+ };
443
+ }
444
+ function parseCredentialResult(value, pluginName) {
445
+ const result = parseSchema(
446
+ pluginCredentialResultSchema,
447
+ value,
448
+ `Plugin "${pluginName}" issueCredential result is invalid`
449
+ );
450
+ if (result.type === "lease") {
451
+ parseAuthorization(result.lease.authorization, pluginName);
452
+ return result;
453
+ }
454
+ if (result.type === "unavailable") {
455
+ return result;
456
+ }
457
+ parseAuthorization(result.authorization, pluginName);
458
+ return result;
459
+ }
460
+ async function selectPluginGrant(input) {
461
+ const plugin = pluginFor(input.provider);
462
+ const hook = plugin?.hooks?.grantForEgress;
463
+ if (!plugin || !hook) {
464
+ return void 0;
465
+ }
466
+ const result = await hook({
467
+ ...basePluginContext(plugin),
468
+ request: {
469
+ ...input.bodyText !== void 0 ? { bodyText: input.bodyText } : {},
470
+ method: input.method,
471
+ ...input.operation ? { operation: input.operation } : {},
472
+ url: input.upstreamUrl.toString()
473
+ }
474
+ });
475
+ return result === void 0 ? void 0 : parseGrant(result, plugin.manifest.name);
476
+ }
477
+ async function onPluginEgressResponse(input) {
478
+ const plugin = pluginFor(input.provider);
479
+ const hook = plugin?.hooks?.onEgressResponse;
480
+ if (!plugin || !hook) {
481
+ return {};
482
+ }
483
+ let permissionDenied;
484
+ await hook({
485
+ ...basePluginContext(plugin),
486
+ grant: input.grant,
487
+ permissionDenied(message) {
488
+ const trimmed = message.trim();
489
+ if (!trimmed) {
490
+ throw new Error(
491
+ `Plugin "${plugin.manifest.name}" onEgressResponse permissionDenied message is empty`
492
+ );
493
+ }
494
+ permissionDenied = { message: trimmed };
495
+ },
496
+ request: {
497
+ method: input.method,
498
+ ...input.operation ? { operation: input.operation } : {},
499
+ url: input.upstreamUrl.toString()
500
+ },
501
+ response: input.response
502
+ });
503
+ return permissionDenied ? { permissionDenied } : {};
504
+ }
505
+ function hasEgressCredentialHooks(provider) {
506
+ const hooks = pluginFor(provider)?.hooks;
507
+ return Boolean(hooks?.grantForEgress || hooks?.issueCredential);
508
+ }
509
+ function getOAuthAccountProviders() {
510
+ return getPlugins().filter((plugin) => Boolean(plugin.hooks?.resolveOAuthAccount)).map((plugin) => plugin.manifest.name);
511
+ }
512
+ async function resolvePluginOAuthAccount(input) {
513
+ const plugin = pluginFor(input.provider);
514
+ const hook = plugin?.hooks?.resolveOAuthAccount;
515
+ if (!plugin || !hook) {
516
+ return void 0;
517
+ }
518
+ const account = await hook({
519
+ ...basePluginContext(plugin),
520
+ tokens: input.tokens
521
+ });
522
+ return account === void 0 ? void 0 : parseSchema(
523
+ pluginProviderAccountSchema,
524
+ account,
525
+ `Plugin "${plugin.manifest.name}" resolveOAuthAccount returned an invalid account`
526
+ );
527
+ }
528
+ async function issuePluginCredential(input) {
529
+ const plugin = pluginFor(input.provider);
530
+ const hook = plugin?.hooks?.issueCredential;
531
+ if (!plugin || !hook) {
532
+ throw new Error(`Plugin "${input.provider}" has no issueCredential hook`);
533
+ }
534
+ const currentUserId = "type" in input.actor ? input.actor.userId : void 0;
535
+ const credentialSubjectUserId = input.credentialSubject?.userId;
536
+ const result = await hook({
537
+ ...basePluginContext(plugin),
538
+ actor: input.actor,
539
+ grant: input.grant,
540
+ ...input.credentialSubject ? { credentialSubject: input.credentialSubject } : {},
541
+ tokens: {
542
+ ...currentUserId ? {
543
+ currentUser: {
544
+ userId: currentUserId,
545
+ get: async () => await input.userTokenStore.get(
546
+ currentUserId,
547
+ plugin.manifest.name
548
+ ),
549
+ set: async (tokens) => {
550
+ await input.userTokenStore.set(
551
+ currentUserId,
552
+ plugin.manifest.name,
553
+ tokens
554
+ );
555
+ },
556
+ withRefresh: async (callback) => await input.userTokenStore.withRefresh(
557
+ currentUserId,
558
+ plugin.manifest.name,
559
+ callback
560
+ )
561
+ }
562
+ } : {},
563
+ ...credentialSubjectUserId ? {
564
+ credentialSubject: {
565
+ userId: credentialSubjectUserId,
566
+ get: async () => await input.userTokenStore.get(
567
+ credentialSubjectUserId,
568
+ plugin.manifest.name
569
+ ),
570
+ set: async (tokens) => {
571
+ await input.userTokenStore.set(
572
+ credentialSubjectUserId,
573
+ plugin.manifest.name,
574
+ tokens
575
+ );
576
+ },
577
+ withRefresh: async (callback) => await input.userTokenStore.withRefresh(
578
+ credentialSubjectUserId,
579
+ plugin.manifest.name,
580
+ callback
581
+ )
582
+ }
583
+ } : {}
584
+ }
585
+ });
586
+ return parseCredentialResult(result, plugin.manifest.name);
587
+ }
588
+
212
589
  // src/chat/mcp/auth-store.ts
213
590
  import {
214
591
  sourceSchema
@@ -284,7 +661,6 @@ function parseMcpAuthSession(value) {
284
661
  ...typeof parsed.threadTs === "string" ? { threadTs: parsed.threadTs } : {},
285
662
  ...typeof parsed.toolChannelId === "string" ? { toolChannelId: parsed.toolChannelId } : {},
286
663
  ...isRecord(parsed.configuration) ? { configuration: parsed.configuration } : {},
287
- ...isRecord(parsed.artifactState) ? { artifactState: parsed.artifactState } : {},
288
664
  ...typeof parsed.authorizationUrl === "string" ? { authorizationUrl: parsed.authorizationUrl } : {},
289
665
  ...typeof parsed.codeVerifier === "string" ? { codeVerifier: parsed.codeVerifier } : {}
290
666
  };
@@ -683,8 +1059,7 @@ async function createMcpOAuthClientProvider(input) {
683
1059
  ...input.channelId ? { channelId: input.channelId } : {},
684
1060
  ...input.threadTs ? { threadTs: input.threadTs } : {},
685
1061
  ...input.toolChannelId ? { toolChannelId: input.toolChannelId } : {},
686
- ...input.configuration ? { configuration: input.configuration } : {},
687
- ...input.artifactState ? { artifactState: input.artifactState } : {}
1062
+ ...input.configuration ? { configuration: input.configuration } : {}
688
1063
  }
689
1064
  );
690
1065
  }
@@ -758,196 +1133,6 @@ async function finalizeMcpAuthorization(provider, authSessionId, authorizationCo
758
1133
  return nextSession;
759
1134
  }
760
1135
 
761
- // src/chat/plugins/credential-hooks.ts
762
- import {
763
- pluginAuthorizationSchema,
764
- pluginCredentialResultSchema,
765
- pluginGrantSchema,
766
- pluginProviderAccountSchema
767
- } from "@sentry/junior-plugin-api";
768
- function parseSchema(schema, value, message) {
769
- const result = schema.safeParse(value);
770
- if (!result.success) {
771
- throw new Error(message);
772
- }
773
- return result.data;
774
- }
775
- function parseAuthorization(value, pluginName) {
776
- if (value === void 0) {
777
- return void 0;
778
- }
779
- const authorization = parseSchema(
780
- pluginAuthorizationSchema,
781
- value,
782
- `Plugin "${pluginName}" grant authorization is invalid`
783
- );
784
- if (authorization.provider !== pluginName) {
785
- throw new Error(
786
- `Plugin "${pluginName}" grant authorization provider must match the issuing plugin`
787
- );
788
- }
789
- return authorization;
790
- }
791
- function parseGrant(value, pluginName) {
792
- return parseSchema(
793
- pluginGrantSchema,
794
- value,
795
- `Plugin "${pluginName}" grantForEgress returned an invalid grant`
796
- );
797
- }
798
- function pluginFor(provider) {
799
- return getPlugins().find((candidate) => candidate.manifest.name === provider);
800
- }
801
- function basePluginContext(plugin) {
802
- const pluginName = plugin.manifest.name;
803
- return {
804
- plugin: { name: pluginName },
805
- log: createPluginLogger(pluginName),
806
- db: getDb()
807
- };
808
- }
809
- function parseCredentialResult(value, pluginName) {
810
- const result = parseSchema(
811
- pluginCredentialResultSchema,
812
- value,
813
- `Plugin "${pluginName}" issueCredential result is invalid`
814
- );
815
- if (result.type === "lease") {
816
- parseAuthorization(result.lease.authorization, pluginName);
817
- return result;
818
- }
819
- if (result.type === "unavailable") {
820
- return result;
821
- }
822
- parseAuthorization(result.authorization, pluginName);
823
- return result;
824
- }
825
- async function selectPluginGrant(input) {
826
- const plugin = pluginFor(input.provider);
827
- const hook = plugin?.hooks?.grantForEgress;
828
- if (!plugin || !hook) {
829
- return void 0;
830
- }
831
- const result = await hook({
832
- ...basePluginContext(plugin),
833
- request: {
834
- ...input.bodyText !== void 0 ? { bodyText: input.bodyText } : {},
835
- method: input.method,
836
- ...input.operation ? { operation: input.operation } : {},
837
- url: input.upstreamUrl.toString()
838
- }
839
- });
840
- return result === void 0 ? void 0 : parseGrant(result, plugin.manifest.name);
841
- }
842
- async function onPluginEgressResponse(input) {
843
- const plugin = pluginFor(input.provider);
844
- const hook = plugin?.hooks?.onEgressResponse;
845
- if (!plugin || !hook) {
846
- return {};
847
- }
848
- let permissionDenied;
849
- await hook({
850
- ...basePluginContext(plugin),
851
- grant: input.grant,
852
- permissionDenied(message) {
853
- const trimmed = message.trim();
854
- if (!trimmed) {
855
- throw new Error(
856
- `Plugin "${plugin.manifest.name}" onEgressResponse permissionDenied message is empty`
857
- );
858
- }
859
- permissionDenied = { message: trimmed };
860
- },
861
- request: {
862
- method: input.method,
863
- ...input.operation ? { operation: input.operation } : {},
864
- url: input.upstreamUrl.toString()
865
- },
866
- response: input.response
867
- });
868
- return permissionDenied ? { permissionDenied } : {};
869
- }
870
- function hasEgressCredentialHooks(provider) {
871
- const hooks = pluginFor(provider)?.hooks;
872
- return Boolean(hooks?.grantForEgress || hooks?.issueCredential);
873
- }
874
- async function resolvePluginOAuthAccount(input) {
875
- const plugin = pluginFor(input.provider);
876
- const hook = plugin?.hooks?.resolveOAuthAccount;
877
- if (!plugin || !hook) {
878
- return void 0;
879
- }
880
- const account = await hook({
881
- ...basePluginContext(plugin),
882
- tokens: input.tokens
883
- });
884
- return account === void 0 ? void 0 : parseSchema(
885
- pluginProviderAccountSchema,
886
- account,
887
- `Plugin "${plugin.manifest.name}" resolveOAuthAccount returned an invalid account`
888
- );
889
- }
890
- async function issuePluginCredential(input) {
891
- const plugin = pluginFor(input.provider);
892
- const hook = plugin?.hooks?.issueCredential;
893
- if (!plugin || !hook) {
894
- throw new Error(`Plugin "${input.provider}" has no issueCredential hook`);
895
- }
896
- const currentUserId = "type" in input.actor ? input.actor.userId : void 0;
897
- const credentialSubjectUserId = input.credentialSubject?.userId;
898
- const result = await hook({
899
- ...basePluginContext(plugin),
900
- actor: input.actor,
901
- grant: input.grant,
902
- ...input.credentialSubject ? { credentialSubject: input.credentialSubject } : {},
903
- tokens: {
904
- ...currentUserId ? {
905
- currentUser: {
906
- userId: currentUserId,
907
- get: async () => await input.userTokenStore.get(
908
- currentUserId,
909
- plugin.manifest.name
910
- ),
911
- set: async (tokens) => {
912
- await input.userTokenStore.set(
913
- currentUserId,
914
- plugin.manifest.name,
915
- tokens
916
- );
917
- },
918
- withRefresh: async (callback) => await input.userTokenStore.withRefresh(
919
- currentUserId,
920
- plugin.manifest.name,
921
- callback
922
- )
923
- }
924
- } : {},
925
- ...credentialSubjectUserId ? {
926
- credentialSubject: {
927
- userId: credentialSubjectUserId,
928
- get: async () => await input.userTokenStore.get(
929
- credentialSubjectUserId,
930
- plugin.manifest.name
931
- ),
932
- set: async (tokens) => {
933
- await input.userTokenStore.set(
934
- credentialSubjectUserId,
935
- plugin.manifest.name,
936
- tokens
937
- );
938
- },
939
- withRefresh: async (callback) => await input.userTokenStore.withRefresh(
940
- credentialSubjectUserId,
941
- plugin.manifest.name,
942
- callback
943
- )
944
- }
945
- } : {}
946
- }
947
- });
948
- return parseCredentialResult(result, plugin.manifest.name);
949
- }
950
-
951
1136
  export {
952
1137
  createUserTokenStore,
953
1138
  issueProviderCredentialLease,
@@ -957,6 +1142,15 @@ export {
957
1142
  McpToolError,
958
1143
  getMcpAwareErrorType,
959
1144
  getMcpAwareTelemetryMessage,
1145
+ lookupSlackUserProfile,
1146
+ lookupSlackUserByEmail,
1147
+ searchSlackUsers,
1148
+ selectPluginGrant,
1149
+ onPluginEgressResponse,
1150
+ hasEgressCredentialHooks,
1151
+ getOAuthAccountProviders,
1152
+ resolvePluginOAuthAccount,
1153
+ issuePluginCredential,
960
1154
  getMcpAuthSession,
961
1155
  patchMcpAuthSession,
962
1156
  deleteMcpAuthSession,
@@ -965,10 +1159,5 @@ export {
965
1159
  deleteMcpStoredOAuthCredentials,
966
1160
  deleteMcpServerSessionId,
967
1161
  createMcpOAuthClientProvider,
968
- finalizeMcpAuthorization,
969
- selectPluginGrant,
970
- onPluginEgressResponse,
971
- hasEgressCredentialHooks,
972
- resolvePluginOAuthAccount,
973
- issuePluginCredential
1162
+ finalizeMcpAuthorization
974
1163
  };