@sentry/junior 0.87.0 → 0.88.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 (59) hide show
  1. package/dist/{agent-hooks-NWOUB3UR.js → agent-hooks-RIJ5TSWP.js} +8 -8
  2. package/dist/api/people/list.d.ts +4 -0
  3. package/dist/api/people/list.js +83 -0
  4. package/dist/api/people/list.query.d.ts +4 -0
  5. package/dist/api/people/profile.d.ts +4 -0
  6. package/dist/api/people/profile.js +131 -0
  7. package/dist/api/people/profile.query.d.ts +4 -0
  8. package/dist/api/people/shared.d.ts +76 -0
  9. package/dist/api/people/types.d.ts +85 -0
  10. package/dist/app.js +43 -40
  11. package/dist/{catalog-runtime-XOD7YPRS.js → catalog-runtime-MW7XERSU.js} +3 -3
  12. package/dist/chat/conversations/sql/migrations.d.ts +1 -1
  13. package/dist/chat/conversations/sql/schema/identities.d.ts +54 -3
  14. package/dist/chat/conversations/sql/schema/users.d.ts +109 -0
  15. package/dist/chat/conversations/sql/schema.d.ts +164 -3
  16. package/dist/chat/conversations/sql/store.d.ts +0 -1
  17. package/dist/chat/identities/identity.d.ts +18 -0
  18. package/dist/chat/identities/sql.d.ts +4 -0
  19. package/dist/chat/runtime/processing-reaction.d.ts +2 -1
  20. package/dist/chat/runtime/slack-resume.d.ts +3 -2
  21. package/dist/chat/runtime/thread-context.d.ts +3 -1
  22. package/dist/chat/runtime/turn-user-message.d.ts +2 -1
  23. package/dist/chat/services/conversation-memory.d.ts +3 -1
  24. package/dist/chat/slack/message.d.ts +2 -1
  25. package/dist/chat/slack/outbound.d.ts +5 -4
  26. package/dist/chat/slack/timestamp.d.ts +6 -0
  27. package/dist/chat/sql/schema.d.ts +163 -3
  28. package/dist/chat/tools/slack/context.d.ts +2 -1
  29. package/dist/{chunk-ENPSU7L7.js → chunk-2DPZRS3B.js} +4 -4
  30. package/dist/{chunk-6I6HBOQM.js → chunk-4IXHIV37.js} +413 -157
  31. package/dist/{chunk-JRXCSSSU.js → chunk-6UPQ5GTJ.js} +3 -3
  32. package/dist/{chunk-64ACM6AP.js → chunk-7ES37H6U.js} +2 -2
  33. package/dist/{chunk-GGD6WK6V.js → chunk-AHLSXMOU.js} +2 -2
  34. package/dist/{chunk-2TAIGJPQ.js → chunk-C5NCV3OB.js} +1 -1
  35. package/dist/{chunk-6O5UI3RG.js → chunk-F22AM3OW.js} +1 -1
  36. package/dist/{chunk-BRSQQRG6.js → chunk-IATAYWFU.js} +2 -2
  37. package/dist/{chunk-BQ3ITJA6.js → chunk-KBFQXJL4.js} +2 -2
  38. package/dist/{chunk-ACJJJEGG.js → chunk-KBSLCOGE.js} +8 -8
  39. package/dist/{chunk-IXTBFABZ.js → chunk-KQKIA4CU.js} +1 -1
  40. package/dist/{chunk-B6FQPS7A.js → chunk-NYJLQI42.js} +22 -20
  41. package/dist/chunk-PBV4ZIVM.js +261 -0
  42. package/dist/{chunk-ZU2ALUVQ.js → chunk-S35CPNPT.js} +1 -1
  43. package/dist/{chunk-RIB3M6YA.js → chunk-V6XDCS3X.js} +4 -4
  44. package/dist/{chunk-KF7522P3.js → chunk-VMBZFPZM.js} +11 -1
  45. package/dist/{chunk-2NFV5FMB.js → chunk-XS6NLQPA.js} +21 -12
  46. package/dist/{chunk-GB5DFM4D.js → chunk-YPAE5RH3.js} +1 -1
  47. package/dist/cli/chat.js +6 -6
  48. package/dist/cli/check.js +4 -4
  49. package/dist/cli/plugins.js +11 -11
  50. package/dist/cli/snapshot-warmup.js +6 -6
  51. package/dist/cli/upgrade.js +12 -12
  52. package/dist/{db-SZVUU7RB.js → db-37HOGLI7.js} +5 -5
  53. package/dist/nitro.js +4 -4
  54. package/dist/reporting/conversations.d.ts +0 -56
  55. package/dist/reporting.d.ts +2 -8
  56. package/dist/reporting.js +14 -290
  57. package/dist/{runner-DMP3IQNM.js → runner-BCRF2FCI.js} +13 -13
  58. package/dist/{validation-MBNJKWPQ.js → validation-FMJO3L5P.js} +4 -4
  59. package/package.json +14 -6
@@ -1,15 +1,15 @@
1
1
  import {
2
2
  getStateAdapter
3
- } from "./chunk-GB5DFM4D.js";
3
+ } from "./chunk-YPAE5RH3.js";
4
4
  import {
5
5
  normalizeSlackConversationId
6
- } from "./chunk-GGD6WK6V.js";
6
+ } from "./chunk-AHLSXMOU.js";
7
7
  import {
8
8
  parseSlackThreadId
9
9
  } from "./chunk-L7OHKDOX.js";
10
10
  import {
11
11
  parseStoredSlackRequester
12
- } from "./chunk-IXTBFABZ.js";
12
+ } from "./chunk-KQKIA4CU.js";
13
13
  import {
14
14
  isRecord,
15
15
  toOptionalNumber
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  pluginCatalogRuntime
3
- } from "./chunk-BQ3ITJA6.js";
3
+ } from "./chunk-KBFQXJL4.js";
4
4
  import {
5
5
  skillRoots
6
6
  } from "./chunk-6APU57E6.js";
7
7
  import {
8
8
  logWarn
9
- } from "./chunk-KF7522P3.js";
9
+ } from "./chunk-VMBZFPZM.js";
10
10
 
11
11
  // src/chat/skills.ts
12
12
  import fs from "fs/promises";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getSlackBotToken
3
- } from "./chunk-ZU2ALUVQ.js";
3
+ } from "./chunk-S35CPNPT.js";
4
4
  import {
5
5
  isSlackConversationId,
6
6
  isSlackTeamId,
@@ -8,7 +8,7 @@ import {
8
8
  setSpanAttributes,
9
9
  setSpanStatus,
10
10
  withSpan
11
- } from "./chunk-KF7522P3.js";
11
+ } from "./chunk-VMBZFPZM.js";
12
12
 
13
13
  // src/chat/slack/client.ts
14
14
  import { AsyncLocalStorage as AsyncLocalStorage2 } from "async_hooks";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  pluginCatalogRuntime
3
- } from "./chunk-BQ3ITJA6.js";
3
+ } from "./chunk-KBFQXJL4.js";
4
4
 
5
5
  // src/chat/plugins/validation.ts
6
6
  import { isDeepStrictEqual } from "util";
@@ -4,7 +4,7 @@ import {
4
4
  import {
5
5
  destinationKey,
6
6
  parseDestination
7
- } from "./chunk-GGD6WK6V.js";
7
+ } from "./chunk-AHLSXMOU.js";
8
8
 
9
9
  // src/chat/task-execution/queue-signing.ts
10
10
  import { createHmac, timingSafeEqual } from "crypto";
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  getStateAdapter
3
- } from "./chunk-GB5DFM4D.js";
3
+ } from "./chunk-YPAE5RH3.js";
4
4
  import {
5
5
  logException,
6
6
  logInfo,
7
7
  logWarn
8
- } from "./chunk-KF7522P3.js";
8
+ } from "./chunk-VMBZFPZM.js";
9
9
 
10
10
  // src/chat/plugins/logging.ts
11
11
  function createPluginLogger(plugin) {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  parseActorUserId
3
- } from "./chunk-IXTBFABZ.js";
3
+ } from "./chunk-KQKIA4CU.js";
4
4
  import {
5
5
  discoverInstalledPluginPackageContent,
6
6
  normalizePluginPackageNames,
@@ -10,7 +10,7 @@ import {
10
10
  logInfo,
11
11
  logWarn,
12
12
  setSpanAttributes
13
- } from "./chunk-KF7522P3.js";
13
+ } from "./chunk-VMBZFPZM.js";
14
14
 
15
15
  // src/chat/plugins/registry.ts
16
16
  import { readFileSync, readdirSync, statSync } from "fs";
@@ -1,6 +1,3 @@
1
- import {
2
- getConversationStore
3
- } from "./chunk-6I6HBOQM.js";
4
1
  import {
5
2
  SANDBOX_DATA_ROOT,
6
3
  SANDBOX_WORKSPACE_ROOT,
@@ -9,21 +6,24 @@ import {
9
6
  import {
10
7
  getConnectedStateContext,
11
8
  getStateAdapter
12
- } from "./chunk-GB5DFM4D.js";
9
+ } from "./chunk-YPAE5RH3.js";
10
+ import {
11
+ getConversationStore
12
+ } from "./chunk-4IXHIV37.js";
13
13
  import {
14
14
  parseDestination
15
- } from "./chunk-GGD6WK6V.js";
15
+ } from "./chunk-AHLSXMOU.js";
16
16
  import {
17
17
  TURN_CONTEXT_TAG,
18
18
  botConfig,
19
19
  escapeXml,
20
20
  getChatConfig
21
- } from "./chunk-ZU2ALUVQ.js";
21
+ } from "./chunk-S35CPNPT.js";
22
22
  import {
23
23
  parseRequester,
24
24
  storedSlackRequesterSchema,
25
25
  toStoredSlackRequester
26
- } from "./chunk-IXTBFABZ.js";
26
+ } from "./chunk-KQKIA4CU.js";
27
27
  import {
28
28
  listReferenceFiles,
29
29
  soulPathCandidates,
@@ -32,7 +32,7 @@ import {
32
32
  import {
33
33
  logInfo,
34
34
  logWarn
35
- } from "./chunk-KF7522P3.js";
35
+ } from "./chunk-VMBZFPZM.js";
36
36
  import {
37
37
  isRecord
38
38
  } from "./chunk-FTMXFBDC.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  isSlackTeamId
3
- } from "./chunk-KF7522P3.js";
3
+ } from "./chunk-VMBZFPZM.js";
4
4
 
5
5
  // src/chat/requester.ts
6
6
  import { z } from "zod";
@@ -10,7 +10,7 @@ import {
10
10
  isSnapshotMissingError,
11
11
  resolveRuntimeDependencySnapshot,
12
12
  runNonInteractiveCommand
13
- } from "./chunk-RIB3M6YA.js";
13
+ } from "./chunk-V6XDCS3X.js";
14
14
  import {
15
15
  pluginTaskId,
16
16
  pluginTaskParamsSchema,
@@ -34,7 +34,7 @@ import {
34
34
  recordToolExecutionStarted,
35
35
  stripNoReplyMarker,
36
36
  upsertAgentTurnSessionRecord
37
- } from "./chunk-ACJJJEGG.js";
37
+ } from "./chunk-KBSLCOGE.js";
38
38
  import {
39
39
  createPluginEmbedder,
40
40
  createPluginHookRunner,
@@ -44,16 +44,13 @@ import {
44
44
  getPluginUserPromptContributions,
45
45
  getPlugins,
46
46
  getSlackToolContext,
47
+ parseSlackMessageTs,
47
48
  resolveChannelCapabilities
48
- } from "./chunk-2NFV5FMB.js";
49
+ } from "./chunk-XS6NLQPA.js";
49
50
  import {
50
51
  createPluginLogger,
51
52
  createPluginState
52
- } from "./chunk-BRSQQRG6.js";
53
- import {
54
- getConversationStore,
55
- getDb
56
- } from "./chunk-6I6HBOQM.js";
53
+ } from "./chunk-IATAYWFU.js";
57
54
  import {
58
55
  SANDBOX_DATA_ROOT,
59
56
  SANDBOX_SKILLS_ROOT,
@@ -64,7 +61,11 @@ import {
64
61
  import {
65
62
  acquireActiveLock,
66
63
  getStateAdapter
67
- } from "./chunk-GB5DFM4D.js";
64
+ } from "./chunk-YPAE5RH3.js";
65
+ import {
66
+ getConversationStore,
67
+ getDb
68
+ } from "./chunk-4IXHIV37.js";
68
69
  import {
69
70
  SlackActionError,
70
71
  downloadPrivateSlackFile,
@@ -75,7 +76,7 @@ import {
75
76
  normalizeSlackConversationId,
76
77
  parseDestination,
77
78
  withSlackRetries
78
- } from "./chunk-GGD6WK6V.js";
79
+ } from "./chunk-AHLSXMOU.js";
79
80
  import {
80
81
  GEN_AI_PROVIDER_NAME,
81
82
  GEN_AI_SERVER_ADDRESS,
@@ -111,7 +112,7 @@ import {
111
112
  toObservablePromptPart,
112
113
  trimTrailingAssistantMessages,
113
114
  upsertActiveSkill
114
- } from "./chunk-ZU2ALUVQ.js";
115
+ } from "./chunk-S35CPNPT.js";
115
116
  import {
116
117
  parseSlackThreadId,
117
118
  resolveConversationPrivacy,
@@ -127,18 +128,18 @@ import {
127
128
  findSkillByName,
128
129
  loadSkillsByName,
129
130
  parseSkillInvocation
130
- } from "./chunk-64ACM6AP.js";
131
+ } from "./chunk-7ES37H6U.js";
131
132
  import {
132
133
  CredentialUnavailableError,
133
134
  credentialContextSchema,
134
135
  pluginCatalogRuntime,
135
136
  resolveAuthTokenPlaceholder,
136
137
  resolvePluginCommandEnv
137
- } from "./chunk-BQ3ITJA6.js";
138
+ } from "./chunk-KBFQXJL4.js";
138
139
  import {
139
140
  createRequester,
140
141
  parseActorUserId
141
- } from "./chunk-IXTBFABZ.js";
142
+ } from "./chunk-KQKIA4CU.js";
142
143
  import {
143
144
  listReferenceFiles
144
145
  } from "./chunk-6APU57E6.js";
@@ -159,7 +160,7 @@ import {
159
160
  setSpanStatus,
160
161
  setTags,
161
162
  withSpan
162
- } from "./chunk-KF7522P3.js";
163
+ } from "./chunk-VMBZFPZM.js";
163
164
  import {
164
165
  isRecord,
165
166
  toOptionalString
@@ -4866,7 +4867,7 @@ function requireSlackThreadTimestamp(threadTs, action) {
4866
4867
  return normalized;
4867
4868
  }
4868
4869
  function requireSlackMessageTimestamp(timestamp, action) {
4869
- const normalized = timestamp.trim();
4870
+ const normalized = parseSlackMessageTs(timestamp);
4870
4871
  if (!normalized) {
4871
4872
  throw new Error(`${action} requires a target message timestamp`);
4872
4873
  }
@@ -4933,15 +4934,16 @@ async function postSlackMessage(input) {
4933
4934
  }
4934
4935
  }
4935
4936
  );
4936
- if (!response.ts) {
4937
+ const messageTs = parseSlackMessageTs(response.ts);
4938
+ if (!messageTs) {
4937
4939
  throw new Error("Slack message posted without ts");
4938
4940
  }
4939
4941
  return {
4940
- ts: response.ts,
4942
+ ts: messageTs,
4941
4943
  ...input.includePermalink ? {
4942
4944
  permalink: await getPermalinkBestEffort({
4943
4945
  channelId,
4944
- messageTs: response.ts
4946
+ messageTs
4945
4947
  })
4946
4948
  } : {}
4947
4949
  };
@@ -14628,7 +14630,7 @@ function isHumanConversationMessage(message) {
14628
14630
  return message.role === "user" && message.author?.isBot !== true;
14629
14631
  }
14630
14632
  function getConversationMessageSlackTs(message) {
14631
- return message.meta?.slackTs ?? toOptionalString(message.id);
14633
+ return parseSlackMessageTs(message.meta?.slackTs);
14632
14634
  }
14633
14635
 
14634
14636
  // src/chat/services/turn-failure-response.ts
@@ -0,0 +1,261 @@
1
+ import {
2
+ getDb,
3
+ juniorConversations,
4
+ juniorDestinations,
5
+ juniorIdentities,
6
+ juniorUsers
7
+ } from "./chunk-4IXHIV37.js";
8
+
9
+ // src/api/people/shared.ts
10
+ import { and, asc, desc, eq, sql } from "drizzle-orm";
11
+ var PRIVATE_CONVERSATION_LABEL = "Private Conversation";
12
+ var SAMPLE_LIMIT = 5e3;
13
+ var RECENT_LIMIT = 25;
14
+ var ACTIVITY_DAYS = 366;
15
+ var HUNG_PROGRESS_MS = 5 * 60 * 1e3;
16
+ function normalizeEmail(email) {
17
+ const normalized = email?.trim().toLowerCase();
18
+ return normalized || void 0;
19
+ }
20
+ function reportTime(value) {
21
+ const time = Date.parse(value);
22
+ return Number.isFinite(time) ? time : void 0;
23
+ }
24
+ function reportDate(value) {
25
+ const time = reportTime(value);
26
+ return time === void 0 ? void 0 : new Date(time).toISOString().slice(0, 10);
27
+ }
28
+ function channelFromConversationId(conversationId) {
29
+ const [provider, channel] = conversationId.split(":");
30
+ return provider === "slack" && channel ? channel : void 0;
31
+ }
32
+ function surfaceFromRow(row) {
33
+ const source = row.source;
34
+ if (source === "api" || source === "scheduler" || source === "slack") {
35
+ return source;
36
+ }
37
+ if (row.conversationId.startsWith("slack:")) return "slack";
38
+ if (row.conversationId.startsWith("scheduler:")) return "scheduler";
39
+ if (row.conversationId.startsWith("api:")) return "api";
40
+ return "internal";
41
+ }
42
+ function statusFromRow(row, nowMs) {
43
+ if (row.executionStatus === "failed") {
44
+ return "failed";
45
+ }
46
+ if (row.executionStatus === "idle") {
47
+ return "completed";
48
+ }
49
+ const updatedAtMs = (row.executionUpdatedAt ?? row.updatedAt).getTime();
50
+ if (row.executionStatus === "running" && nowMs - updatedAtMs > HUNG_PROGRESS_MS) {
51
+ return "hung";
52
+ }
53
+ return "active";
54
+ }
55
+ function surfaceLabel(surface) {
56
+ if (surface === "scheduler") return "Scheduler";
57
+ if (surface === "api") return "API";
58
+ if (surface === "internal") return "Internal";
59
+ return "Conversation";
60
+ }
61
+ function slackLocationLabel(args) {
62
+ const channelId = args.channel;
63
+ if (!channelId) return void 0;
64
+ if (args.channelNameRedacted && args.channelName) {
65
+ return args.channelName;
66
+ }
67
+ const name = args.channelName?.replace(/^#/, "");
68
+ if (channelId.startsWith("D")) return "Direct Message";
69
+ if (channelId.startsWith("C")) return name ? `#${name}` : "Public Channel";
70
+ if (channelId.startsWith("G")) {
71
+ if (name?.startsWith("mpdm-")) return "Group DM";
72
+ return "Private Channel";
73
+ }
74
+ return name || channelId;
75
+ }
76
+ function channelNameFromRow(row) {
77
+ if (row.destinationVisibility && row.destinationVisibility !== "public") {
78
+ return PRIVATE_CONVERSATION_LABEL;
79
+ }
80
+ return row.channelName ?? void 0;
81
+ }
82
+ function titleFromRow(row, surface) {
83
+ if (row.destinationVisibility && row.destinationVisibility !== "public") {
84
+ return PRIVATE_CONVERSATION_LABEL;
85
+ }
86
+ const channel = channelFromConversationId(row.conversationId);
87
+ return row.title ?? slackLocationLabel({
88
+ channel,
89
+ channelName: row.channelName ?? void 0
90
+ }) ?? surfaceLabel(surface);
91
+ }
92
+ function summaryFromRow(row, nowMs) {
93
+ const surface = surfaceFromRow(row);
94
+ const channel = channelFromConversationId(row.conversationId);
95
+ const channelName = channelNameFromRow(row);
96
+ const channelNameRedacted = Boolean(row.destinationVisibility) && row.destinationVisibility !== "public";
97
+ return {
98
+ conversationId: row.conversationId,
99
+ cumulativeDurationMs: 0,
100
+ displayTitle: titleFromRow(row, surface),
101
+ id: row.runId ?? row.conversationId,
102
+ lastProgressAt: new Date(
103
+ row.executionUpdatedAt ?? row.updatedAt
104
+ ).toISOString(),
105
+ lastSeenAt: row.lastActivityAt.toISOString(),
106
+ startedAt: row.createdAt.toISOString(),
107
+ status: statusFromRow(row, nowMs),
108
+ surface,
109
+ requesterIdentity: {
110
+ email: row.email,
111
+ ...row.fullName ? { fullName: row.fullName } : {},
112
+ slackUserId: row.providerSubjectId,
113
+ ...row.handle ? { slackUserName: row.handle } : {}
114
+ },
115
+ ...channel ? { channel } : {},
116
+ ...channelName ? { channelName } : {},
117
+ ...channelNameRedacted ? { channelNameRedacted: true } : {}
118
+ };
119
+ }
120
+ function emptyTotals() {
121
+ return {
122
+ active: 0,
123
+ activeDays: 0,
124
+ conversations: 0,
125
+ durationMs: 0,
126
+ failed: 0,
127
+ hung: 0,
128
+ runs: 0
129
+ };
130
+ }
131
+ function emptyStatsItem(label) {
132
+ return {
133
+ active: 0,
134
+ conversations: 0,
135
+ durationMs: 0,
136
+ failed: 0,
137
+ hung: 0,
138
+ label,
139
+ runs: 0
140
+ };
141
+ }
142
+ function emptyActivityDay(date) {
143
+ return {
144
+ active: 0,
145
+ conversations: 0,
146
+ date,
147
+ durationMs: 0,
148
+ failed: 0,
149
+ hung: 0,
150
+ runs: 0
151
+ };
152
+ }
153
+ function signals(summary) {
154
+ return {
155
+ active: summary.status === "active",
156
+ failed: summary.status === "failed",
157
+ hung: summary.status === "hung"
158
+ };
159
+ }
160
+ function addSignals(target, value) {
161
+ target.active += value.active ? 1 : 0;
162
+ target.failed += value.failed ? 1 : 0;
163
+ target.hung += value.hung ? 1 : 0;
164
+ }
165
+ function identityWithEmail(requester) {
166
+ const email = normalizeEmail(requester?.email);
167
+ if (!email) return void 0;
168
+ return {
169
+ email,
170
+ ...requester?.fullName ? { fullName: requester.fullName } : {},
171
+ ...requester?.slackUserId ? { slackUserId: requester.slackUserId } : {},
172
+ ...requester?.slackUserName ? { slackUserName: requester.slackUserName } : {}
173
+ };
174
+ }
175
+ function mergeIdentity(current, next) {
176
+ return {
177
+ email: current.email,
178
+ ...current.fullName ?? next.fullName ? { fullName: current.fullName ?? next.fullName } : {},
179
+ ...current.slackUserId ?? next.slackUserId ? { slackUserId: current.slackUserId ?? next.slackUserId } : {},
180
+ ...current.slackUserName ?? next.slackUserName ? { slackUserName: current.slackUserName ?? next.slackUserName } : {}
181
+ };
182
+ }
183
+ function activityDays(days, nowMs) {
184
+ const items = [];
185
+ const end = new Date(nowMs);
186
+ end.setUTCHours(0, 0, 0, 0);
187
+ const start = new Date(end);
188
+ start.setUTCDate(start.getUTCDate() - (ACTIVITY_DAYS - 1));
189
+ for (const cursor = new Date(start); cursor.getTime() <= end.getTime(); cursor.setUTCDate(cursor.getUTCDate() + 1)) {
190
+ const date = cursor.toISOString().slice(0, 10);
191
+ items.push(days.get(date) ?? emptyActivityDay(date));
192
+ }
193
+ return items;
194
+ }
195
+ function statsItems(map) {
196
+ return [...map.values()].sort(
197
+ (left, right) => right.conversations - left.conversations || right.runs - left.runs || right.durationMs - left.durationMs || left.label.localeCompare(right.label)
198
+ );
199
+ }
200
+ async function requesterRows(options = {}, email) {
201
+ const normalizedEmail = normalizeEmail(email);
202
+ const rows = await (options.db ?? getDb()).select({
203
+ channelName: juniorConversations.channelName,
204
+ conversationId: juniorConversations.conversationId,
205
+ createdAt: juniorConversations.createdAt,
206
+ destinationVisibility: juniorDestinations.visibility,
207
+ email: juniorUsers.primaryEmailNormalized,
208
+ executionStatus: juniorConversations.executionStatus,
209
+ executionUpdatedAt: juniorConversations.executionUpdatedAt,
210
+ fullName: juniorUsers.displayName,
211
+ handle: juniorIdentities.handle,
212
+ lastActivityAt: juniorConversations.lastActivityAt,
213
+ providerSubjectId: juniorIdentities.providerSubjectId,
214
+ runId: juniorConversations.runId,
215
+ source: juniorConversations.source,
216
+ title: juniorConversations.title,
217
+ updatedAt: juniorConversations.updatedAt
218
+ }).from(juniorConversations).innerJoin(
219
+ juniorIdentities,
220
+ eq(juniorIdentities.id, juniorConversations.requesterIdentityId)
221
+ ).innerJoin(juniorUsers, eq(juniorUsers.id, juniorIdentities.userId)).leftJoin(
222
+ juniorDestinations,
223
+ eq(juniorDestinations.id, juniorConversations.destinationId)
224
+ ).where(
225
+ and(
226
+ eq(juniorIdentities.provider, "slack"),
227
+ eq(juniorIdentities.emailVerified, true),
228
+ sql`${juniorUsers.primaryEmailNormalized} IS NOT NULL`,
229
+ normalizedEmail ? eq(juniorUsers.primaryEmailNormalized, normalizedEmail) : void 0
230
+ )
231
+ ).orderBy(
232
+ desc(juniorConversations.lastActivityAt),
233
+ asc(juniorConversations.conversationId)
234
+ ).limit(SAMPLE_LIMIT + 1);
235
+ return {
236
+ rows: rows.slice(0, SAMPLE_LIMIT),
237
+ truncated: rows.length > SAMPLE_LIMIT
238
+ };
239
+ }
240
+
241
+ export {
242
+ SAMPLE_LIMIT,
243
+ RECENT_LIMIT,
244
+ ACTIVITY_DAYS,
245
+ normalizeEmail,
246
+ reportTime,
247
+ reportDate,
248
+ surfaceLabel,
249
+ slackLocationLabel,
250
+ summaryFromRow,
251
+ emptyTotals,
252
+ emptyStatsItem,
253
+ emptyActivityDay,
254
+ signals,
255
+ addSignals,
256
+ identityWithEmail,
257
+ mergeIdentity,
258
+ activityDays,
259
+ statsItems,
260
+ requesterRows
261
+ };
@@ -12,7 +12,7 @@ import {
12
12
  serializeGenAiAttribute,
13
13
  setSpanAttributes,
14
14
  withSpan
15
- } from "./chunk-KF7522P3.js";
15
+ } from "./chunk-VMBZFPZM.js";
16
16
 
17
17
  // src/chat/xml.ts
18
18
  function escapeXml(value) {
@@ -3,16 +3,16 @@ import {
3
3
  } from "./chunk-G3E7SCME.js";
4
4
  import {
5
5
  getStateAdapter
6
- } from "./chunk-GB5DFM4D.js";
6
+ } from "./chunk-YPAE5RH3.js";
7
7
  import {
8
8
  toOptionalTrimmed
9
- } from "./chunk-ZU2ALUVQ.js";
9
+ } from "./chunk-S35CPNPT.js";
10
10
  import {
11
11
  pluginCatalogRuntime
12
- } from "./chunk-BQ3ITJA6.js";
12
+ } from "./chunk-KBFQXJL4.js";
13
13
  import {
14
14
  withSpan
15
- } from "./chunk-KF7522P3.js";
15
+ } from "./chunk-VMBZFPZM.js";
16
16
 
17
17
  // src/chat/sandbox/runtime-dependency-snapshots.ts
18
18
  import { createHash } from "crypto";
@@ -22,6 +22,14 @@ import {
22
22
  getConfig,
23
23
  getLogger
24
24
  } from "@logtape/logtape";
25
+
26
+ // src/chat/identities/identity.ts
27
+ function normalizeIdentityEmail(email) {
28
+ const normalized = email?.trim().toLowerCase();
29
+ return normalized || void 0;
30
+ }
31
+
32
+ // src/chat/logging.ts
25
33
  var MAX_STRING_VALUE = 1200;
26
34
  var SECRETS_RE = [
27
35
  /\b(sk-[A-Za-z0-9_-]{20,})\b/g,
@@ -1034,10 +1042,11 @@ function setSentryTagsFromContext(context) {
1034
1042
  }
1035
1043
  function sentryUserIdentityFromContext(context) {
1036
1044
  if (context.slackUserId) {
1045
+ const email = normalizeIdentityEmail(context.slackUserEmail);
1037
1046
  return {
1038
1047
  id: context.slackUserId,
1039
1048
  ...context.slackUserName ? { username: context.slackUserName } : {},
1040
- ...context.slackUserEmail ? { email: context.slackUserEmail } : {}
1049
+ ...email ? { email } : {}
1041
1050
  };
1042
1051
  }
1043
1052
  return void 0;
@@ -1344,6 +1353,7 @@ function isSlackConversationId(value) {
1344
1353
  }
1345
1354
 
1346
1355
  export {
1356
+ normalizeIdentityEmail,
1347
1357
  normalizeGenAiFinishReason,
1348
1358
  createChatSdkLogger,
1349
1359
  getLogContextAttributes,