@sentry/junior 0.147.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 (155) hide show
  1. package/dist/{agent-hooks-HS6VGUPM.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 -296
  6. package/dist/api/conversations/event-list.d.ts +2 -193
  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 +60 -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 +624 -562
  33. package/dist/app.js +183 -105
  34. package/dist/{catalog-runtime-M6ZTPYRV.js → catalog-runtime-WADOZVTB.js} +5 -5
  35. package/dist/chat/actor.d.ts +4 -1
  36. package/dist/chat/agent/request.d.ts +2 -0
  37. package/dist/chat/agent/resume.d.ts +1 -0
  38. package/dist/chat/agent-dispatch/context.d.ts +2 -2
  39. package/dist/chat/agent-invocations/types.d.ts +52 -0
  40. package/dist/chat/api-turns/work.d.ts +103 -0
  41. package/dist/chat/conversations/history.d.ts +60 -0
  42. package/dist/chat/conversations/provenance.d.ts +6 -0
  43. package/dist/chat/conversations/sql/actor-identity.d.ts +19 -0
  44. package/dist/chat/conversations/store.d.ts +1 -1
  45. package/dist/chat/resource-events/store.d.ts +1 -1
  46. package/dist/chat/runtime/reply-executor.d.ts +1 -1
  47. package/dist/chat/runtime/slack-runtime.d.ts +2 -1
  48. package/dist/chat/runtime/turn-preparation.d.ts +9 -0
  49. package/dist/chat/scheduled-tasks/tool-support.d.ts +5 -5
  50. package/dist/chat/scheduled-tasks/tools/create.d.ts +2 -2
  51. package/dist/chat/scheduled-tasks/tools/delete.d.ts +2 -2
  52. package/dist/chat/scheduled-tasks/tools/list.d.ts +2 -2
  53. package/dist/chat/scheduled-tasks/tools/run-now.d.ts +2 -2
  54. package/dist/chat/scheduled-tasks/tools/update.d.ts +2 -2
  55. package/dist/chat/slack/channel.d.ts +26 -0
  56. package/dist/chat/slack/dispatch-turn.d.ts +1 -0
  57. package/dist/chat/slack/timestamp-param.d.ts +0 -2
  58. package/dist/chat/slack/{tools → tool-support}/canvas/api.d.ts +1 -1
  59. package/dist/chat/slack/{tools → tool-support}/canvas/context.d.ts +3 -0
  60. package/dist/chat/slack/tool-support/channel-access.d.ts +42 -0
  61. package/dist/chat/slack/tool-support/channel-target.d.ts +27 -0
  62. package/dist/chat/slack/tool-support/list/params.d.ts +5 -0
  63. package/dist/chat/slack/tools/canvas/create.d.ts +1 -1
  64. package/dist/chat/slack/tools/channel-join.d.ts +28 -0
  65. package/dist/chat/slack/tools/channel-list-messages.d.ts +3 -2
  66. package/dist/chat/slack/tools/conversation-message-search.d.ts +2 -8
  67. package/dist/chat/slack/tools/message-add-reaction.d.ts +1 -1
  68. package/dist/chat/slack/tools/public-search.d.ts +63 -2
  69. package/dist/chat/slack/tools/send-files.d.ts +1 -1
  70. package/dist/chat/slack/tools/thread-read.d.ts +2 -5
  71. package/dist/chat/source.d.ts +2 -0
  72. package/dist/chat/task-execution/checkpoint.d.ts +1 -0
  73. package/dist/chat/task-execution/state.d.ts +9 -4
  74. package/dist/chat/task-execution/store.d.ts +3 -2
  75. package/dist/chat/task-execution/turn-cursor.d.ts +2 -0
  76. package/dist/chat/task-execution/worker.d.ts +2 -0
  77. package/dist/chat/tasks/read.d.ts +1 -1
  78. package/dist/chat/tools/search-conversation-events.d.ts +1 -1
  79. package/dist/chat/tools/types.d.ts +11 -4
  80. package/dist/chat/tools/watch-resource-events.d.ts +2 -2
  81. package/dist/{chunk-ORO3PWKQ.js → chunk-2B3PT3V2.js} +1 -1
  82. package/dist/{chunk-SVHUEHUL.js → chunk-45LOR4PU.js} +21 -4
  83. package/dist/{chunk-YBVXBNSV.js → chunk-4AQZYNHM.js} +2 -2
  84. package/dist/{chunk-Z4YU7Z4L.js → chunk-4EA2SFK2.js} +65 -4
  85. package/dist/{chunk-7NVJVJID.js → chunk-4GXJUYJV.js} +2 -2
  86. package/dist/{chunk-IIOOO4FQ.js → chunk-55F4QU2V.js} +2 -1
  87. package/dist/{chunk-745QJ3ZA.js → chunk-7OEIXFC3.js} +2 -2
  88. package/dist/{chunk-DU74WPIC.js → chunk-D3WPMGEX.js} +1 -1
  89. package/dist/{chunk-PVNG6UMU.js → chunk-D6YX4NNN.js} +22 -10
  90. package/dist/chunk-DUY5CDAM.js +36 -0
  91. package/dist/{chunk-4LJO56OJ.js → chunk-EAI67NTM.js} +1 -1
  92. package/dist/{chunk-X5UY34KT.js → chunk-EINWQFXI.js} +8 -8
  93. package/dist/chunk-GDFF3BQG.js +136 -0
  94. package/dist/{chunk-EFLJ2WJH.js → chunk-GXYDVZKM.js} +5 -5
  95. package/dist/{chunk-CWP5RHVX.js → chunk-HLPLT3NY.js} +8 -5
  96. package/dist/{chunk-JUUKWRBE.js → chunk-HWQGBIH7.js} +1 -1
  97. package/dist/{chunk-AZ7EAOBE.js → chunk-IL4EDBMV.js} +5 -5
  98. package/dist/{chunk-DLDRQHG5.js → chunk-LAZGHEYU.js} +1 -1
  99. package/dist/{chunk-RXBVB2JM.js → chunk-LE5H7LMT.js} +1 -1
  100. package/dist/chunk-LNVEIJ2L.js +48 -0
  101. package/dist/{chunk-YEO3VX72.js → chunk-OJCP3C3J.js} +8 -6
  102. package/dist/{chunk-GGB4WL5A.js → chunk-POSZWRGL.js} +1 -1
  103. package/dist/{chunk-YNTTROJT.js → chunk-QOWHHM3F.js} +1 -1
  104. package/dist/{chunk-6H5SZR24.js → chunk-RRJV5UR5.js} +302 -59
  105. package/dist/{chunk-AYU72WO7.js → chunk-ULAU5ZGU.js} +41 -64
  106. package/dist/{chunk-SGZO7UWH.js → chunk-V2FXMOEA.js} +2 -2
  107. package/dist/{chunk-AIOK6LAG.js → chunk-VCYSOXON.js} +272 -41
  108. package/dist/{chunk-7A4M7PCV.js → chunk-VMNRXKAH.js} +1166 -540
  109. package/dist/{chunk-YSB2N563.js → chunk-VRHTNBA6.js} +121 -87
  110. package/dist/{chunk-AVZDSUFB.js → chunk-VY6W3T43.js} +4 -4
  111. package/dist/{chunk-7UQIVT6G.js → chunk-WCN4YSH7.js} +6 -6
  112. package/dist/{chunk-CSZINQJ2.js → chunk-WOONT5ZP.js} +1 -1
  113. package/dist/{chunk-Q4R73I43.js → chunk-XJ42NBP5.js} +58 -28
  114. package/dist/{chunk-YHDERDRO.js → chunk-ZCHIC2GM.js} +91 -75
  115. package/dist/chunk-ZPL2RR7F.js +798 -0
  116. package/dist/cli/chat.js +33 -35
  117. package/dist/cli/check.js +6 -6
  118. package/dist/cli/plugins.js +13 -13
  119. package/dist/cli/snapshot-create.js +9 -9
  120. package/dist/cli/upgrade.js +7 -7
  121. package/dist/db/schema/agent-invocations.d.ts +20 -0
  122. package/dist/db/schema/conversation-annotations.d.ts +2 -2
  123. package/dist/db/schema.d.ts +22 -2
  124. package/dist/{db-CSEW4RII.js → db-XUKZRFFK.js} +7 -7
  125. package/dist/instrumentation.js +4 -4
  126. package/dist/nitro.js +2 -2
  127. package/dist/{oauth-callback-server-FUEV5HNG.js → oauth-callback-server-LPZMMGFI.js} +25 -26
  128. package/dist/{runner-U3XHSKSH.js → runner-DGKUTMPX.js} +17 -18
  129. package/dist/{skills-AKE6W3WI.js → skills-P7YUFSXM.js} +6 -6
  130. package/dist/spawn-DSK3ZEVD.js +38 -0
  131. package/dist/{validation-WDTAULUF.js → validation-S7U5M5NR.js} +6 -6
  132. package/dist/version.js +1 -1
  133. package/dist/{work-C3HAO2BG.js → work-GAA7TVAD.js} +18 -19
  134. package/dist/{worker-LNP4YKBM.js → worker-JXPJH3QB.js} +11 -10
  135. package/package.json +5 -4
  136. package/dist/api/health.d.ts +0 -7
  137. package/dist/api/personal-tokens/create.d.ts +0 -11
  138. package/dist/api/personal-tokens/list.d.ts +0 -12
  139. package/dist/api/personal-tokens/revoke.d.ts +0 -5
  140. package/dist/api/plugin-reports.d.ts +0 -63
  141. package/dist/api/plugins.d.ts +0 -8
  142. package/dist/api/runtime.d.ts +0 -24
  143. package/dist/api/skills.d.ts +0 -6
  144. package/dist/chat/slack/tools/channel-access.d.ts +0 -30
  145. package/dist/chunk-34GS7B6L.js +0 -115
  146. package/dist/chunk-AVOCH2Z5.js +0 -285
  147. package/dist/chunk-HLXXQI5Q.js +0 -238
  148. package/dist/chunk-K4SZAP3K.js +0 -67
  149. package/dist/chunk-R776HKPK.js +0 -81
  150. package/dist/spawn-B6GDTWJ4.js +0 -39
  151. /package/dist/chat/slack/{tools → tool-support}/canvas/markdown.d.ts +0 -0
  152. /package/dist/chat/slack/{tools → tool-support}/channel-capabilities.d.ts +0 -0
  153. /package/dist/chat/slack/{tools → tool-support}/context.d.ts +0 -0
  154. /package/dist/chat/slack/{tools → tool-support}/list/api.d.ts +0 -0
  155. /package/dist/chat/slack/{tools → tool-support}/slack-message-url.d.ts +0 -0
@@ -5,12 +5,12 @@ import {
5
5
  juniorConversations,
6
6
  juniorIdentities,
7
7
  juniorUsers
8
- } from "./chunk-DU74WPIC.js";
8
+ } from "./chunk-D3WPMGEX.js";
9
9
  import {
10
10
  TURN_REASONING_LEVELS,
11
11
  getChatConfig,
12
12
  modelProfileSchema
13
- } from "./chunk-7NVJVJID.js";
13
+ } from "./chunk-4GXJUYJV.js";
14
14
  import {
15
15
  juniorDestinations
16
16
  } from "./chunk-VFUK3X5B.js";
@@ -20,7 +20,7 @@ import {
20
20
  } from "./chunk-F3B2YJ76.js";
21
21
  import {
22
22
  normalizeIdentityEmail
23
- } from "./chunk-4LJO56OJ.js";
23
+ } from "./chunk-EAI67NTM.js";
24
24
 
25
25
  // src/chat/conversations/sql/store.ts
26
26
  import { randomUUID as randomUUID2 } from "crypto";
@@ -215,7 +215,14 @@ function normalizeSessionSource(value) {
215
215
  if (value.platform === "local") {
216
216
  return {
217
217
  platform: "local",
218
- visibility: "private",
218
+ visibility: value.visibility,
219
+ conversationId: value.conversationId
220
+ };
221
+ }
222
+ if (value.platform === "web") {
223
+ return {
224
+ platform: "web",
225
+ visibility: value.visibility,
219
226
  conversationId: value.conversationId
220
227
  };
221
228
  }
@@ -262,6 +269,109 @@ async function bindProviderConversation(executor, args) {
262
269
  }
263
270
  }
264
271
 
272
+ // src/chat/conversations/sql/actor-identity.ts
273
+ function identityFromActor(actor) {
274
+ if (actor?.slackUserId) {
275
+ return {
276
+ kind: "user",
277
+ provider: "slack",
278
+ providerTenantId: actor.teamId,
279
+ providerSubjectId: actor.slackUserId,
280
+ ...actor.fullName ? { displayName: actor.fullName } : {},
281
+ ...actor.slackUserName ? { handle: actor.slackUserName } : {},
282
+ ...actor.email ? { email: actor.email, emailVerified: true } : {},
283
+ metadata: { platform: "slack" }
284
+ };
285
+ }
286
+ const email = actor?.email?.trim().toLowerCase();
287
+ if (!email) {
288
+ return void 0;
289
+ }
290
+ return {
291
+ kind: "user",
292
+ provider: "junior",
293
+ providerSubjectId: email,
294
+ email,
295
+ emailVerified: true,
296
+ ...actor?.fullName ? { displayName: actor.fullName } : {},
297
+ metadata: { platform: "web" }
298
+ };
299
+ }
300
+ function systemIdentityFromSource(source) {
301
+ if (source === "scheduler") {
302
+ return {
303
+ kind: "system",
304
+ provider: "junior",
305
+ providerSubjectId: "scheduler",
306
+ displayName: "Junior Scheduler"
307
+ };
308
+ }
309
+ if (source === "local") {
310
+ return {
311
+ kind: "system",
312
+ provider: "junior",
313
+ providerSubjectId: "local-cli",
314
+ displayName: "Local CLI"
315
+ };
316
+ }
317
+ if (source === "resource_event") {
318
+ return {
319
+ kind: "system",
320
+ provider: "junior",
321
+ providerSubjectId: "resource-event",
322
+ displayName: "Resource Event"
323
+ };
324
+ }
325
+ return void 0;
326
+ }
327
+ function actorIdentityForConversation(conversation) {
328
+ return identityFromActor(conversation.actor) ?? systemIdentityFromSource(conversation.source);
329
+ }
330
+ function actorFromIdentityRow(identity, userDisplayName) {
331
+ if (!identity) {
332
+ return void 0;
333
+ }
334
+ const fullName = userDisplayName?.trim() ? userDisplayName : identity.displayName;
335
+ const email = identity.emailNormalized ?? identity.email ?? void 0;
336
+ if (identity.provider === "slack") {
337
+ return {
338
+ ...email ? { email } : {},
339
+ ...fullName ? { fullName } : {},
340
+ platform: "slack",
341
+ slackUserId: identity.providerSubjectId,
342
+ ...identity.handle ? { slackUserName: identity.handle } : {},
343
+ ...identity.providerTenantId ? { teamId: identity.providerTenantId } : {}
344
+ };
345
+ }
346
+ if (identity.provider === "junior" && email) {
347
+ return {
348
+ email,
349
+ ...fullName ? { fullName } : {}
350
+ };
351
+ }
352
+ return void 0;
353
+ }
354
+ function mergeActor(current2, next) {
355
+ if (!current2) {
356
+ return next;
357
+ }
358
+ if (!next) {
359
+ return current2;
360
+ }
361
+ if (current2.slackUserId && next.slackUserId && current2.slackUserId !== next.slackUserId) {
362
+ return current2;
363
+ }
364
+ return {
365
+ ...current2,
366
+ ...current2.email ?? next.email ? { email: current2.email ?? next.email } : {},
367
+ ...current2.fullName ?? next.fullName ? { fullName: current2.fullName ?? next.fullName } : {},
368
+ ...current2.platform ?? next.platform ? { platform: current2.platform ?? next.platform } : {},
369
+ ...current2.slackUserId ?? next.slackUserId ? { slackUserId: current2.slackUserId ?? next.slackUserId } : {},
370
+ ...current2.slackUserName ?? next.slackUserName ? { slackUserName: current2.slackUserName ?? next.slackUserName } : {},
371
+ ...current2.teamId ?? next.teamId ? { teamId: current2.teamId ?? next.teamId } : {}
372
+ };
373
+ }
374
+
265
375
  // src/chat/conversations/location.ts
266
376
  import { nonBlankStringSchema } from "@sentry/junior-plugin-api";
267
377
  import { z } from "zod";
@@ -327,56 +437,11 @@ function tenantId2(value) {
327
437
  return value ?? "";
328
438
  }
329
439
  function sourceFromValue(value) {
330
- if (value === "api" || value === "internal" || value === "local" || value === "plugin" || value === "resource_event" || value === "scheduler" || value === "slack") {
440
+ if (value === "api" || value === "internal" || value === "local" || value === "plugin" || value === "resource_event" || value === "scheduler" || value === "slack" || value === "web") {
331
441
  return value;
332
442
  }
333
443
  return void 0;
334
444
  }
335
- function identityFromActor(actor) {
336
- if (!actor?.slackUserId) {
337
- return void 0;
338
- }
339
- return {
340
- kind: "user",
341
- provider: "slack",
342
- providerTenantId: actor.teamId,
343
- providerSubjectId: actor.slackUserId,
344
- ...actor.fullName ? { displayName: actor.fullName } : {},
345
- ...actor.slackUserName ? { handle: actor.slackUserName } : {},
346
- ...actor.email ? { email: actor.email, emailVerified: true } : {},
347
- metadata: { platform: "slack" }
348
- };
349
- }
350
- function systemIdentityFromSource(source) {
351
- if (source === "scheduler") {
352
- return {
353
- kind: "system",
354
- provider: "junior",
355
- providerSubjectId: "scheduler",
356
- displayName: "Junior Scheduler"
357
- };
358
- }
359
- if (source === "local") {
360
- return {
361
- kind: "system",
362
- provider: "junior",
363
- providerSubjectId: "local-cli",
364
- displayName: "Local CLI"
365
- };
366
- }
367
- if (source === "resource_event") {
368
- return {
369
- kind: "system",
370
- provider: "junior",
371
- providerSubjectId: "resource-event",
372
- displayName: "Resource Event"
373
- };
374
- }
375
- return void 0;
376
- }
377
- function actorIdentityForConversation(conversation) {
378
- return identityFromActor(conversation.actor) ?? systemIdentityFromSource(conversation.source);
379
- }
380
445
  function originTypeFromSource(source) {
381
446
  return source;
382
447
  }
@@ -408,8 +473,10 @@ function destinationUpsertFromDestination(args) {
408
473
  provider: "local",
409
474
  providerTenantId: localWorkspaceFromConversationId(destination.conversationId) ?? localWorkspaceFromConversationId(args.conversationId ?? ""),
410
475
  providerDestinationId: destination.conversationId,
411
- refreshVisibility: true,
412
- visibility: "direct",
476
+ // Match Slack: only refresh when a live visibility signal is present so
477
+ // execution-metadata writes cannot clobber public dashboard roots.
478
+ refreshVisibility: args.visibility !== void 0,
479
+ visibility: args.visibility ?? "direct",
413
480
  metadata: { platform: "local" }
414
481
  };
415
482
  }
@@ -423,20 +490,6 @@ function executionStatusFromValue(value) {
423
490
  function executionStatusToSql(status) {
424
491
  return status === "paused" ? "awaiting_resume" : status;
425
492
  }
426
- function actorFromIdentityRow(identity, userDisplayName) {
427
- if (!identity || identity.provider !== "slack") {
428
- return void 0;
429
- }
430
- const fullName = userDisplayName?.trim() ? userDisplayName : identity.displayName;
431
- return {
432
- ...identity.emailNormalized ? { email: identity.emailNormalized } : identity.email ? { email: identity.email } : {},
433
- ...fullName ? { fullName } : {},
434
- platform: "slack",
435
- slackUserId: identity.providerSubjectId,
436
- ...identity.handle ? { slackUserName: identity.handle } : {},
437
- ...identity.providerTenantId ? { teamId: identity.providerTenantId } : {}
438
- };
439
- }
440
493
  function destinationFromRow(destination) {
441
494
  const value = destination?.provider === "slack" ? {
442
495
  platform: "slack",
@@ -537,26 +590,6 @@ function assertSameConversationDestination(args) {
537
590
  `Conversation destination changed for ${args.conversationId}`
538
591
  );
539
592
  }
540
- function mergeActor(current2, next) {
541
- if (!current2) {
542
- return next;
543
- }
544
- if (!next) {
545
- return current2;
546
- }
547
- if (current2.slackUserId && next.slackUserId && current2.slackUserId !== next.slackUserId) {
548
- return current2;
549
- }
550
- return {
551
- ...current2,
552
- ...current2.email ?? next.email ? { email: current2.email ?? next.email } : {},
553
- ...current2.fullName ?? next.fullName ? { fullName: current2.fullName ?? next.fullName } : {},
554
- ...current2.platform ?? next.platform ? { platform: current2.platform ?? next.platform } : {},
555
- ...current2.slackUserId ?? next.slackUserId ? { slackUserId: current2.slackUserId ?? next.slackUserId } : {},
556
- ...current2.slackUserName ?? next.slackUserName ? { slackUserName: current2.slackUserName ?? next.slackUserName } : {},
557
- ...current2.teamId ?? next.teamId ? { teamId: current2.teamId ?? next.teamId } : {}
558
- };
559
- }
560
593
  function tokenTotal(usage) {
561
594
  if (!usage) return 0;
562
595
  if (usage.totalTokens !== void 0) return usage.totalTokens;
@@ -864,7 +897,8 @@ var SqlStore = class {
864
897
  }).onConflictDoUpdate({
865
898
  target: juniorConversations.conversationId,
866
899
  set: {
867
- source: sql2`coalesce(excluded.source, ${juniorConversations.source})`,
900
+ // Origin source is set-once so dashboard continues cannot rewrite a Slack root.
901
+ source: sql2`coalesce(${juniorConversations.source}, excluded.source)`,
868
902
  sessionSource: sql2`coalesce(${juniorConversations.sessionSource}, excluded.source_json)`,
869
903
  originType: sql2`coalesce(excluded.origin_type, ${juniorConversations.originType})`,
870
904
  originId: sql2`coalesce(excluded.origin_id, ${juniorConversations.originId})`,
@@ -4,18 +4,18 @@ import {
4
4
  } from "./chunk-EM225ITJ.js";
5
5
  import {
6
6
  getStateAdapter
7
- } from "./chunk-ORO3PWKQ.js";
7
+ } from "./chunk-2B3PT3V2.js";
8
8
  import {
9
9
  toOptionalTrimmed
10
- } from "./chunk-7NVJVJID.js";
10
+ } from "./chunk-4GXJUYJV.js";
11
11
  import {
12
12
  pluginCatalogRuntime
13
- } from "./chunk-JUUKWRBE.js";
13
+ } from "./chunk-HWQGBIH7.js";
14
14
  import {
15
15
  setSpanAttributes,
16
16
  setSpanStatus,
17
17
  withSpan
18
- } from "./chunk-4LJO56OJ.js";
18
+ } from "./chunk-EAI67NTM.js";
19
19
 
20
20
  // src/chat/sandbox/resources.ts
21
21
  var configuredResources;
@@ -4,19 +4,19 @@ import {
4
4
  isDmChannel,
5
5
  normalizeSlackConversationId,
6
6
  withSlackRetries
7
- } from "./chunk-SGZO7UWH.js";
7
+ } from "./chunk-V2FXMOEA.js";
8
8
  import {
9
9
  parseDestination
10
- } from "./chunk-YSB2N563.js";
10
+ } from "./chunk-VRHTNBA6.js";
11
11
  import {
12
12
  getStateAdapter
13
- } from "./chunk-ORO3PWKQ.js";
13
+ } from "./chunk-2B3PT3V2.js";
14
14
  import {
15
15
  normalizeSlackEmojiName
16
- } from "./chunk-7NVJVJID.js";
16
+ } from "./chunk-4GXJUYJV.js";
17
17
  import {
18
18
  pluginCatalogRuntime
19
- } from "./chunk-JUUKWRBE.js";
19
+ } from "./chunk-HWQGBIH7.js";
20
20
  import {
21
21
  parseSlackMessageTs,
22
22
  parseSlackUserId
@@ -25,7 +25,7 @@ import {
25
25
  isRecord,
26
26
  logInfo,
27
27
  logWarn
28
- } from "./chunk-4LJO56OJ.js";
28
+ } from "./chunk-EAI67NTM.js";
29
29
 
30
30
  // src/chat/slack/outbound.ts
31
31
  var MAX_SLACK_MESSAGE_TEXT_CHARS = 4e4;
@@ -5,7 +5,7 @@ import {
5
5
  } from "./chunk-F3B2YJ76.js";
6
6
  import {
7
7
  toOptionalString
8
- } from "./chunk-4LJO56OJ.js";
8
+ } from "./chunk-EAI67NTM.js";
9
9
 
10
10
  // src/chat/slack/context.ts
11
11
  import { z } from "zod";
@@ -1,34 +1,34 @@
1
1
  import {
2
2
  resolveBaseUrl
3
- } from "./chunk-7UQIVT6G.js";
3
+ } from "./chunk-WCN4YSH7.js";
4
4
  import {
5
5
  createPluginLogger,
6
6
  getPlugins
7
- } from "./chunk-YHDERDRO.js";
7
+ } from "./chunk-ZCHIC2GM.js";
8
8
  import {
9
9
  getSlackClient,
10
10
  withSlackRetries
11
- } from "./chunk-SGZO7UWH.js";
11
+ } from "./chunk-V2FXMOEA.js";
12
12
  import {
13
13
  getDb,
14
14
  parseDestination
15
- } from "./chunk-YSB2N563.js";
15
+ } from "./chunk-VRHTNBA6.js";
16
16
  import {
17
17
  sleep
18
18
  } from "./chunk-EM225ITJ.js";
19
19
  import {
20
20
  acquireActiveLock,
21
21
  getStateAdapter
22
- } from "./chunk-ORO3PWKQ.js";
22
+ } from "./chunk-2B3PT3V2.js";
23
23
  import {
24
24
  pluginCatalogRuntime
25
- } from "./chunk-JUUKWRBE.js";
25
+ } from "./chunk-HWQGBIH7.js";
26
26
  import {
27
27
  fetchWithBoundedOAuthErrorBodies
28
- } from "./chunk-GGB4WL5A.js";
28
+ } from "./chunk-POSZWRGL.js";
29
29
  import {
30
30
  isRecord
31
- } from "./chunk-4LJO56OJ.js";
31
+ } from "./chunk-EAI67NTM.js";
32
32
 
33
33
  // src/chat/capabilities/router.ts
34
34
  var ProviderCredentialRouter = class {
@@ -244,6 +244,16 @@ function normalizeUser(raw) {
244
244
  ...profileFields.length > 0 ? { profile_fields: profileFields } : {}
245
245
  };
246
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
+ }
247
257
  async function lookupSlackUserProfile(userId) {
248
258
  const client = getSlackClient();
249
259
  const result = await withSlackRetries(
@@ -279,21 +289,44 @@ async function lookupSlackUserByEmail(email) {
279
289
  }
280
290
  return normalizeUser(user);
281
291
  }
282
- function scoreMatch(user, queryLower) {
283
- const name = (user.name ?? "").toLowerCase();
284
- const realName = (user.real_name ?? user.profile?.real_name ?? "").toLowerCase();
285
- const displayName = (user.profile?.display_name ?? "").toLowerCase();
286
- if (name === queryLower || displayName === queryLower) return 100;
287
- if (realName === queryLower) return 90;
288
- if (name.startsWith(queryLower) || displayName.startsWith(queryLower))
289
- return 70;
290
- if (realName.startsWith(queryLower)) return 60;
291
- const realNameWords = realName.split(/\s+/);
292
- if (realNameWords.some((w) => w === queryLower)) return 55;
293
- if (realNameWords.some((w) => w.startsWith(queryLower))) return 50;
294
- if (name.includes(queryLower) || displayName.includes(queryLower)) return 30;
295
- if (realName.includes(queryLower)) return 20;
296
- return 0;
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 ?? "");
297
330
  }
298
331
  async function listWorkspaceUsers(options) {
299
332
  const client = getSlackClient();
@@ -349,12 +382,9 @@ async function searchSlackUsers(options) {
349
382
  maxPages,
350
383
  includeDeleted,
351
384
  includeBots,
352
- score: (member) => scoreMatch(member, queryLower)
353
- });
354
- listed.matches.sort((a, b) => {
355
- if (b.score !== a.score) return b.score - a.score;
356
- return (a.user.name ?? "").localeCompare(b.user.name ?? "");
385
+ score: (member) => scoreNameMatch(member, queryLower)
357
386
  });
387
+ listed.matches.sort(compareNameMatches);
358
388
  return {
359
389
  users: listed.matches.slice(0, limit).map((m) => normalizeUser(m.user)),
360
390
  searched_pages: listed.searched_pages,