@sentry/junior 0.102.3 → 0.104.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 (86) hide show
  1. package/dist/{agent-hooks-I4I2DHSW.js → agent-hooks-EOFSY2PD.js} +5 -5
  2. package/dist/api/conversations/archive.d.ts +7 -0
  3. package/dist/api/conversations/detail.d.ts +7 -0
  4. package/dist/api/conversations/list.d.ts +109 -0
  5. package/dist/api/conversations/routes.d.ts +3 -0
  6. package/dist/api/conversations/schema.d.ts +88 -69
  7. package/dist/api/conversations/stats.d.ts +7 -0
  8. package/dist/api/conversations/subagent.d.ts +7 -0
  9. package/dist/api/http.d.ts +5 -0
  10. package/dist/api/locations/detail.d.ts +10 -2
  11. package/dist/api/locations/list.d.ts +7 -0
  12. package/dist/api/locations/routes.d.ts +3 -0
  13. package/dist/api/locations/schema.d.ts +4 -3
  14. package/dist/api/people/list.d.ts +7 -0
  15. package/dist/api/people/profile.d.ts +7 -0
  16. package/dist/api/people/routes.d.ts +3 -0
  17. package/dist/api/people/schema.d.ts +35 -33
  18. package/dist/api/people/shared.d.ts +4 -4
  19. package/dist/api/route.d.ts +7 -0
  20. package/dist/api/schema.js +11 -17
  21. package/dist/api.js +2184 -88
  22. package/dist/app.js +120 -162
  23. package/dist/chat/conversations/history.d.ts +6 -6
  24. package/dist/chat/conversations/store.d.ts +1 -0
  25. package/dist/chat/pi/messages.d.ts +2 -2
  26. package/dist/chat/plugins/agent-hooks.d.ts +2 -2
  27. package/dist/chat/resource-events/store.d.ts +2 -2
  28. package/dist/chat/sandbox/runtime-dependencies.d.ts +2 -0
  29. package/dist/chat/sandbox/sandbox.d.ts +1 -0
  30. package/dist/chat/services/provider-retry.d.ts +1 -2
  31. package/dist/chat/slack/tools/conversation-search.d.ts +2 -2
  32. package/dist/chat/state/session-log.d.ts +2 -2
  33. package/dist/chat/task-execution/store.d.ts +2 -2
  34. package/dist/chat/tools/search-tools.d.ts +2 -2
  35. package/dist/{chunk-ZSHL44IQ.js → chunk-4PDVOHXP.js} +1 -1
  36. package/dist/{chunk-3OABPOHR.js → chunk-7G4J3CR7.js} +11 -2
  37. package/dist/chunk-AIRE7Q2W.js +362 -0
  38. package/dist/{chunk-QZGVPPIJ.js → chunk-BCULHGZK.js} +24 -4
  39. package/dist/{chunk-IQ36I3DF.js → chunk-CCTCIISK.js} +1 -1
  40. package/dist/{chunk-SHBPSE7A.js → chunk-M3UAVLEN.js} +2 -3
  41. package/dist/{chunk-EMUZSROX.js → chunk-O7ILGCMJ.js} +78 -1
  42. package/dist/{chunk-EOB77KME.js → chunk-QDKRE3LS.js} +340 -9
  43. package/dist/{chunk-DTUSCR2Y.js → chunk-QVTVCJR4.js} +7 -7
  44. package/dist/{chunk-5K4N73TP.js → chunk-RMZ65YAA.js} +3 -3
  45. package/dist/{chunk-VSAFV2GI.js → chunk-RYDF4GOX.js} +3 -3
  46. package/dist/{chunk-ZIX4PNBI.js → chunk-TMWUGGSA.js} +37 -35
  47. package/dist/{chunk-3UK5DFKW.js → chunk-U26ZWZCN.js} +1 -1
  48. package/dist/{chunk-X2IPNCB5.js → chunk-VDHMFCDY.js} +65 -12
  49. package/dist/cli/chat.js +13 -14
  50. package/dist/cli/plugins.js +6 -6
  51. package/dist/cli/snapshot-warmup.js +7 -3
  52. package/dist/cli/upgrade.js +6 -7
  53. package/dist/db/schema/conversations.d.ts +17 -0
  54. package/dist/db/schema.d.ts +17 -0
  55. package/dist/{db-6QP6HY7U.js → db-PDMC67T3.js} +2 -2
  56. package/dist/{legacy-import-R3BMM2GH.js → legacy-import-G333RHJZ.js} +3 -3
  57. package/dist/reporting-schema.d.ts +4 -4
  58. package/dist/{runner-C2ZTIOUD.js → runner-6A7MQRUE.js} +9 -10
  59. package/migrations/0004_useful_magus.sql +1 -0
  60. package/migrations/meta/0004_snapshot.json +1041 -0
  61. package/migrations/meta/_journal.json +7 -0
  62. package/package.json +6 -6
  63. package/dist/api/conversations/list.query.d.ts +0 -103
  64. package/dist/chunk-2RNOB32R.js +0 -17
  65. package/dist/chunk-4XNQSJAX.js +0 -331
  66. package/dist/chunk-4YN2ZXKB.js +0 -66
  67. package/dist/chunk-B5QS4AVO.js +0 -319
  68. package/dist/chunk-F4CQEUTP.js +0 -77
  69. package/dist/chunk-HYDQULR2.js +0 -214
  70. package/dist/chunk-KFP3TZOS.js +0 -102
  71. package/dist/chunk-LJB2TLVT.js +0 -273
  72. package/dist/chunk-LVUKF5CE.js +0 -63
  73. package/dist/chunk-NSP6OGL2.js +0 -671
  74. package/dist/chunk-QNVHH5PU.js +0 -20
  75. package/dist/chunk-QOZOJNSE.js +0 -96
  76. package/dist/chunk-WPHCUGN7.js +0 -84
  77. package/dist/detail-OEIVZYXS.js +0 -68
  78. package/dist/detail-V37NTVBN.js +0 -29
  79. package/dist/list-AJ6RWBOG.js +0 -30
  80. package/dist/list-FWLIZHSW.js +0 -30
  81. package/dist/list-NTUT6A5M.js +0 -121
  82. package/dist/plugin-conversations-F3IBVNFX.js +0 -37
  83. package/dist/profile-3FRQP4HP.js +0 -212
  84. package/dist/reporting/plugin-conversations.d.ts +0 -3
  85. package/dist/stats-7UFY6FPE.js +0 -174
  86. package/dist/subagent-X3ZWJHR4.js +0 -49
@@ -29,6 +29,13 @@
29
29
  "when": 1783915376595,
30
30
  "tag": "0003_peaceful_scalphunter",
31
31
  "breakpoints": true
32
+ },
33
+ {
34
+ "idx": 4,
35
+ "version": "7",
36
+ "when": 1784137322420,
37
+ "tag": "0004_useful_magus",
38
+ "breakpoints": true
32
39
  }
33
40
  ]
34
41
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/junior",
3
- "version": "0.102.3",
3
+ "version": "0.104.0",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -75,7 +75,7 @@
75
75
  "pg": "^8.16.3",
76
76
  "yaml": "^2.9.0",
77
77
  "zod": "^4.4.3",
78
- "@sentry/junior-plugin-api": "0.102.3"
78
+ "@sentry/junior-plugin-api": "0.104.0"
79
79
  },
80
80
  "devDependencies": {
81
81
  "@emnapi/core": "^1.10.0",
@@ -92,10 +92,10 @@
92
92
  "typescript": "^6.0.3",
93
93
  "vercel": "^54.4.0",
94
94
  "vitest": "^4.1.7",
95
- "@sentry/junior-github": "0.102.3",
96
- "@sentry/junior-memory": "0.102.3",
97
- "@sentry/junior-testing": "0.0.0",
98
- "@sentry/junior-scheduler": "0.102.3"
95
+ "@sentry/junior-github": "0.104.0",
96
+ "@sentry/junior-scheduler": "0.104.0",
97
+ "@sentry/junior-memory": "0.104.0",
98
+ "@sentry/junior-testing": "0.0.0"
99
99
  },
100
100
  "scripts": {
101
101
  "build": "tsup && tsc -p tsconfig.build.json --emitDeclarationOnly",
@@ -1,103 +0,0 @@
1
- import type { Conversation } from "@/chat/conversations/store";
2
- import type { JuniorDatabase } from "@/db/db";
3
- import type { ConversationFeed } from "./schema";
4
- declare function conversationRows(db: JuniorDatabase, limit: number, actorEmail?: string): Promise<{
5
- conversation: {
6
- conversationId: string;
7
- schemaVersion: number;
8
- source: import("@/chat/conversations/store").ConversationSource | null;
9
- originType: string | null;
10
- originId: string | null;
11
- originRunId: string | null;
12
- destinationId: string | null;
13
- destination: {
14
- platform: "slack";
15
- teamId: string;
16
- channelId: string;
17
- } | {
18
- platform: "local";
19
- conversationId: string;
20
- } | null;
21
- actorIdentityId: string | null;
22
- creatorIdentityId: string | null;
23
- credentialSubjectIdentityId: string | null;
24
- actor: {
25
- email?: string | undefined;
26
- fullName?: string | undefined;
27
- platform?: "slack" | undefined;
28
- slackUserId?: string | undefined;
29
- slackUserName?: string | undefined;
30
- teamId?: string | undefined;
31
- } | null;
32
- channelName: string | null;
33
- title: string | null;
34
- createdAt: Date;
35
- lastActivityAt: Date;
36
- updatedAt: Date;
37
- executionUpdatedAt: Date | null;
38
- executionStatus: import("@/chat/conversations/store").ConversationStatus;
39
- runId: string | null;
40
- lastCheckpointAt: Date | null;
41
- lastEnqueuedAt: Date | null;
42
- parentConversationId: string | null;
43
- transcriptPurgedAt: Date | null;
44
- durationMs: number;
45
- usage: {
46
- inputTokens?: number | undefined;
47
- outputTokens?: number | undefined;
48
- cachedInputTokens?: number | undefined;
49
- cacheCreationTokens?: number | undefined;
50
- reasoningTokens?: number | undefined;
51
- totalTokens?: number | undefined;
52
- cost?: {
53
- input?: number | undefined;
54
- output?: number | undefined;
55
- cacheRead?: number | undefined;
56
- cacheWrite?: number | undefined;
57
- total?: number | undefined;
58
- } | undefined;
59
- } | null;
60
- executionDurationMs: number;
61
- executionUsage: {
62
- inputTokens?: number | undefined;
63
- outputTokens?: number | undefined;
64
- cachedInputTokens?: number | undefined;
65
- cacheCreationTokens?: number | undefined;
66
- reasoningTokens?: number | undefined;
67
- totalTokens?: number | undefined;
68
- cost?: {
69
- input?: number | undefined;
70
- output?: number | undefined;
71
- cacheRead?: number | undefined;
72
- cacheWrite?: number | undefined;
73
- total?: number | undefined;
74
- } | undefined;
75
- } | null;
76
- metricRunId: string | null;
77
- };
78
- destinationId: string | null;
79
- destinationVisibility: import("../../db/schema/destinations").JuniorDestinationVisibility | null;
80
- identityDisplayName: string | null;
81
- identityEmail: string | null;
82
- identityHandle: string | null;
83
- identityProvider: string | null;
84
- identitySubjectId: string | null;
85
- identityTenantId: string | null;
86
- }[]>;
87
- type ConversationRow = Awaited<ReturnType<typeof conversationRows>>[number];
88
- /** Read one normalized conversation record directly from its SQL row. */
89
- export declare function readConversationRecordFromSql(conversationId: string): Promise<{
90
- conversation: Conversation;
91
- durationMs: number;
92
- locationId?: string;
93
- usage: ConversationRow["conversation"]["usage"];
94
- } | undefined>;
95
- /**
96
- * Build a bounded dashboard feed, applying a normalized actor-email filter
97
- * before the limit when one is provided.
98
- */
99
- export declare function readConversationFeedFromSql(options?: {
100
- actorEmail?: string;
101
- limit?: number;
102
- }): Promise<ConversationFeed>;
103
- export {};
@@ -1,17 +0,0 @@
1
- // src/api/schema.ts
2
- import { z } from "zod";
3
- var conversationParamsSchema = z.object({ conversationId: z.string().min(1) }).strict();
4
- var conversationFeedQuerySchema = z.object({
5
- actorEmail: z.string().trim().email().transform((value) => value.toLowerCase()).optional()
6
- }).strict();
7
- var subagentParamsSchema = conversationParamsSchema.extend({ subagentId: z.string().min(1) }).strict();
8
- var personParamsSchema = z.object({ email: z.string().trim().min(1) }).strict();
9
- var locationParamsSchema = z.object({ locationId: z.string().min(1) }).strict();
10
-
11
- export {
12
- conversationParamsSchema,
13
- conversationFeedQuerySchema,
14
- subagentParamsSchema,
15
- personParamsSchema,
16
- locationParamsSchema
17
- };
@@ -1,331 +0,0 @@
1
- import {
2
- summaryFromRow
3
- } from "./chunk-QOZOJNSE.js";
4
- import {
5
- conversationAggregateColumns,
6
- conversationRangeColumns
7
- } from "./chunk-F4CQEUTP.js";
8
- import {
9
- activityDays
10
- } from "./chunk-WPHCUGN7.js";
11
- import {
12
- getDb,
13
- juniorConversations,
14
- juniorIdentities,
15
- juniorUsers
16
- } from "./chunk-QZGVPPIJ.js";
17
- import {
18
- juniorDestinations
19
- } from "./chunk-FXFQNHRU.js";
20
-
21
- // src/api/locations/query.ts
22
- import { and, asc, desc, eq, gte, isNull, sql } from "drizzle-orm";
23
- var RECENT_LIMIT = 25;
24
- var ACTIVITY_DAYS = 90;
25
- function emptyMetrics() {
26
- return {
27
- active: 0,
28
- conversations: 0,
29
- durationMs: 0,
30
- failed: 0
31
- };
32
- }
33
- function addMetrics(target, row) {
34
- target.active += row.active;
35
- target.conversations += row.conversations;
36
- target.durationMs += row.durationMs;
37
- target.failed += row.failed;
38
- if (row.tokens !== null) {
39
- target.tokens = (target.tokens ?? 0) + row.tokens;
40
- }
41
- if (row.costUsd !== null) {
42
- target.costUsd = Math.round(((target.costUsd ?? 0) + row.costUsd) * 1e12) / 1e12;
43
- }
44
- }
45
- function publicLabel(input) {
46
- const name = input.displayName?.trim().replace(/^#/, "");
47
- return name ? `#${name}` : `Public channel ${input.providerDestinationId}`;
48
- }
49
- function actorLabel(actor) {
50
- return actor.email?.trim() || actor.fullName?.trim() || actor.slackUserName?.trim() || actor.slackUserId?.trim() || "Unknown";
51
- }
52
- function emptyActor(actor) {
53
- return {
54
- ...emptyMetrics(),
55
- actor,
56
- label: actorLabel(actor)
57
- };
58
- }
59
- function topLevelWhere() {
60
- return isNull(juniorConversations.parentConversationId);
61
- }
62
- function publicLocationWhere(destinationId) {
63
- return and(
64
- topLevelWhere(),
65
- eq(juniorDestinations.id, destinationId),
66
- eq(juniorDestinations.visibility, "public")
67
- );
68
- }
69
- function locationColumns() {
70
- return {
71
- destinationDisplayName: juniorDestinations.displayName,
72
- destinationId: juniorDestinations.id,
73
- destinationKind: juniorDestinations.kind,
74
- destinationProvider: juniorDestinations.provider,
75
- destinationProviderId: juniorDestinations.providerDestinationId,
76
- destinationVisibility: juniorDestinations.visibility
77
- };
78
- }
79
- function locationGroupBy() {
80
- return [
81
- juniorDestinations.displayName,
82
- juniorDestinations.id,
83
- juniorDestinations.kind,
84
- juniorDestinations.provider,
85
- juniorDestinations.providerDestinationId,
86
- juniorDestinations.visibility
87
- ];
88
- }
89
- function locationFromAggregate(row) {
90
- if (row.destinationVisibility !== "public" || !row.destinationId || !row.destinationProvider || !row.destinationProviderId || !row.destinationKind) {
91
- return void 0;
92
- }
93
- const location = {
94
- ...emptyMetrics(),
95
- firstSeenAt: row.firstSeenAt.toISOString(),
96
- id: row.destinationId,
97
- kind: row.destinationKind,
98
- label: publicLabel({
99
- displayName: row.destinationDisplayName,
100
- providerDestinationId: row.destinationProviderId
101
- }),
102
- lastSeenAt: row.lastSeenAt.toISOString(),
103
- provider: row.destinationProvider,
104
- providerDestinationId: row.destinationProviderId,
105
- visibility: "public"
106
- };
107
- addMetrics(location, row);
108
- return location;
109
- }
110
- async function directoryRows(db) {
111
- return db.select({
112
- ...locationColumns(),
113
- ...conversationAggregateColumns(),
114
- ...conversationRangeColumns()
115
- }).from(juniorConversations).leftJoin(
116
- juniorDestinations,
117
- eq(juniorDestinations.id, juniorConversations.destinationId)
118
- ).where(topLevelWhere()).groupBy(...locationGroupBy());
119
- }
120
- async function directoryActivityRows(db, start) {
121
- const date = sql`TO_CHAR(
122
- ${juniorConversations.lastActivityAt} AT TIME ZONE 'UTC',
123
- 'YYYY-MM-DD'
124
- )`;
125
- return db.select({
126
- conversations: sql`COUNT(*)::integer`,
127
- date,
128
- visibility: juniorDestinations.visibility
129
- }).from(juniorConversations).leftJoin(
130
- juniorDestinations,
131
- eq(juniorDestinations.id, juniorConversations.destinationId)
132
- ).where(and(topLevelWhere(), gte(juniorConversations.lastActivityAt, start))).groupBy(date, juniorDestinations.visibility);
133
- }
134
- function directoryActivityDays(rows, nowMs) {
135
- const days = /* @__PURE__ */ new Map();
136
- for (const row of rows) {
137
- const day = days.get(row.date) ?? {
138
- date: row.date,
139
- privateConversations: 0,
140
- publicConversations: 0
141
- };
142
- if (row.visibility === "public") {
143
- day.publicConversations += row.conversations;
144
- } else {
145
- day.privateConversations += row.conversations;
146
- }
147
- days.set(row.date, day);
148
- }
149
- const end = new Date(nowMs);
150
- end.setUTCHours(0, 0, 0, 0);
151
- const start = new Date(end);
152
- start.setUTCDate(start.getUTCDate() - (ACTIVITY_DAYS - 1));
153
- const activity = [];
154
- for (const cursor = new Date(start); cursor.getTime() <= end.getTime(); cursor.setUTCDate(cursor.getUTCDate() + 1)) {
155
- const date = cursor.toISOString().slice(0, 10);
156
- activity.push(
157
- days.get(date) ?? {
158
- date,
159
- privateConversations: 0,
160
- publicConversations: 0
161
- }
162
- );
163
- }
164
- return activity;
165
- }
166
- async function readLocationDirectoryFromSql() {
167
- const nowMs = Date.now();
168
- const end = new Date(nowMs);
169
- end.setUTCHours(0, 0, 0, 0);
170
- const start = new Date(end);
171
- start.setUTCDate(start.getUTCDate() - (ACTIVITY_DAYS - 1));
172
- const [rows, activityRows] = await Promise.all([
173
- directoryRows(getDb()),
174
- directoryActivityRows(getDb(), start)
175
- ]);
176
- const locations = [];
177
- const privateActivity = {
178
- ...emptyMetrics(),
179
- label: "Private activity"
180
- };
181
- for (const row of rows) {
182
- const location = locationFromAggregate(row);
183
- if (location) locations.push(location);
184
- else addMetrics(privateActivity, row);
185
- }
186
- return {
187
- activityDays: directoryActivityDays(activityRows, nowMs),
188
- generatedAt: new Date(nowMs).toISOString(),
189
- locations: locations.sort(
190
- (left, right) => Date.parse(right.lastSeenAt) - Date.parse(left.lastSeenAt) || right.conversations - left.conversations || left.label.localeCompare(right.label)
191
- ),
192
- privateActivity,
193
- source: "conversation_index",
194
- windowEnd: end.toISOString(),
195
- windowStart: start.toISOString()
196
- };
197
- }
198
- async function recentLocationRows(db, locationId) {
199
- return db.select({
200
- channelName: juniorConversations.channelName,
201
- conversationId: juniorConversations.conversationId,
202
- createdAt: juniorConversations.createdAt,
203
- destinationId: juniorDestinations.id,
204
- destinationVisibility: juniorDestinations.visibility,
205
- durationMs: juniorConversations.durationMs,
206
- email: sql`COALESCE(
207
- ${juniorUsers.primaryEmailNormalized},
208
- ${juniorIdentities.email}
209
- )`,
210
- executionStatus: juniorConversations.executionStatus,
211
- executionUpdatedAt: juniorConversations.executionUpdatedAt,
212
- fullName: juniorUsers.displayName,
213
- handle: juniorIdentities.handle,
214
- lastActivityAt: juniorConversations.lastActivityAt,
215
- providerSubjectId: sql`CASE
216
- WHEN ${juniorIdentities.provider} = 'slack'
217
- THEN ${juniorIdentities.providerSubjectId}
218
- ELSE NULL
219
- END`,
220
- source: juniorConversations.source,
221
- title: juniorConversations.title,
222
- updatedAt: juniorConversations.updatedAt,
223
- usage: juniorConversations.usage
224
- }).from(juniorConversations).innerJoin(
225
- juniorDestinations,
226
- eq(juniorDestinations.id, juniorConversations.destinationId)
227
- ).leftJoin(
228
- juniorIdentities,
229
- eq(juniorIdentities.id, juniorConversations.actorIdentityId)
230
- ).leftJoin(juniorUsers, eq(juniorUsers.id, juniorIdentities.userId)).where(publicLocationWhere(locationId)).orderBy(
231
- desc(juniorConversations.lastActivityAt),
232
- asc(juniorConversations.conversationId)
233
- ).limit(RECENT_LIMIT);
234
- }
235
- async function readLocationDetailFromSql(locationId) {
236
- const nowMs = Date.now();
237
- const end = new Date(nowMs);
238
- end.setUTCHours(0, 0, 0, 0);
239
- const start = new Date(end);
240
- start.setUTCDate(start.getUTCDate() - (ACTIVITY_DAYS - 1));
241
- const where = publicLocationWhere(locationId);
242
- const activityDate = sql`TO_CHAR(
243
- ${juniorConversations.lastActivityAt} AT TIME ZONE 'UTC',
244
- 'YYYY-MM-DD'
245
- )`;
246
- const [locationRows, dayRows, actorRows, recentRows] = await Promise.all([
247
- getDb().select({
248
- ...locationColumns(),
249
- ...conversationAggregateColumns(),
250
- ...conversationRangeColumns()
251
- }).from(juniorConversations).innerJoin(
252
- juniorDestinations,
253
- eq(juniorDestinations.id, juniorConversations.destinationId)
254
- ).where(where).groupBy(...locationGroupBy()),
255
- getDb().select({ date: activityDate, ...conversationAggregateColumns() }).from(juniorConversations).innerJoin(
256
- juniorDestinations,
257
- eq(juniorDestinations.id, juniorConversations.destinationId)
258
- ).where(and(where, gte(juniorConversations.lastActivityAt, start))).groupBy(activityDate),
259
- getDb().select({
260
- actorIdentityId: juniorConversations.actorIdentityId,
261
- email: juniorUsers.primaryEmailNormalized,
262
- fullName: juniorUsers.displayName,
263
- handle: juniorIdentities.handle,
264
- identityEmail: juniorIdentities.email,
265
- identityProvider: juniorIdentities.provider,
266
- providerSubjectId: juniorIdentities.providerSubjectId,
267
- ...conversationAggregateColumns()
268
- }).from(juniorConversations).innerJoin(
269
- juniorDestinations,
270
- eq(juniorDestinations.id, juniorConversations.destinationId)
271
- ).leftJoin(
272
- juniorIdentities,
273
- eq(juniorIdentities.id, juniorConversations.actorIdentityId)
274
- ).leftJoin(juniorUsers, eq(juniorUsers.id, juniorIdentities.userId)).where(where).groupBy(
275
- juniorConversations.actorIdentityId,
276
- juniorUsers.primaryEmailNormalized,
277
- juniorUsers.displayName,
278
- juniorIdentities.handle,
279
- juniorIdentities.email,
280
- juniorIdentities.provider,
281
- juniorIdentities.providerSubjectId
282
- ),
283
- recentLocationRows(getDb(), locationId)
284
- ]);
285
- const locationRow = locationRows[0];
286
- const location = locationRow ? locationFromAggregate(locationRow) : void 0;
287
- if (!location) return void 0;
288
- const days = /* @__PURE__ */ new Map();
289
- for (const row of dayRows) {
290
- days.set(row.date, {
291
- active: row.active,
292
- conversations: row.conversations,
293
- date: row.date,
294
- durationMs: row.durationMs,
295
- failed: row.failed,
296
- ...row.tokens !== null ? { tokens: row.tokens } : {}
297
- });
298
- }
299
- const actors = [];
300
- for (const row of actorRows) {
301
- if (!row.actorIdentityId) continue;
302
- const actor = {
303
- ...row.email ?? row.identityEmail ? { email: row.email ?? row.identityEmail ?? void 0 } : {},
304
- ...row.fullName ? { fullName: row.fullName } : {},
305
- ...row.identityProvider === "slack" && row.providerSubjectId ? { slackUserId: row.providerSubjectId } : {},
306
- ...row.handle ? { slackUserName: row.handle } : {}
307
- };
308
- if (!actor.email && !actor.slackUserId) continue;
309
- const item = emptyActor(actor);
310
- addMetrics(item, row);
311
- actors.push(item);
312
- }
313
- const activity = activityDays(days, nowMs, ACTIVITY_DAYS);
314
- return {
315
- ...location,
316
- activityDays: activity,
317
- actors: actors.sort(
318
- (left, right) => right.conversations - left.conversations || left.label.localeCompare(right.label)
319
- ),
320
- generatedAt: new Date(nowMs).toISOString(),
321
- recentConversations: recentRows.map(summaryFromRow),
322
- source: "conversation_index",
323
- windowEnd: end.toISOString(),
324
- windowStart: activity[0] ? `${activity[0].date}T00:00:00.000Z` : end.toISOString()
325
- };
326
- }
327
-
328
- export {
329
- readLocationDirectoryFromSql,
330
- readLocationDetailFromSql
331
- };
@@ -1,66 +0,0 @@
1
- import {
2
- actorIdentitySchema,
3
- conversationStatsItemSchema,
4
- conversationSummaryReportSchema
5
- } from "./chunk-HYDQULR2.js";
6
-
7
- // src/api/people/schema.ts
8
- import { z } from "zod";
9
- var peopleConversationSummaryReportSchema = conversationSummaryReportSchema.omit({
10
- cumulativeUsage: true,
11
- sentryTraceUrl: true,
12
- traceId: true
13
- });
14
- var peopleConversationStatsItemSchema = conversationStatsItemSchema.omit({ costUsd: true });
15
- var actorActivityDayReportSchema = z.object({
16
- active: z.number(),
17
- conversations: z.number(),
18
- date: z.string(),
19
- durationMs: z.number(),
20
- failed: z.number(),
21
- tokens: z.number().optional()
22
- }).strict();
23
- var peopleActivityDayReportSchema = z.object({
24
- activePeople: z.number(),
25
- conversations: z.number(),
26
- date: z.string()
27
- }).strict();
28
- var actorTotalsReportSchema = z.object({
29
- active: z.number(),
30
- activeDays: z.number(),
31
- conversations: z.number(),
32
- durationMs: z.number(),
33
- failed: z.number(),
34
- tokens: z.number().optional()
35
- }).strict();
36
- var identifiedActorSchema = actorIdentitySchema.extend({ email: z.string().min(1) }).strict();
37
- var actorSummaryReportSchema = actorTotalsReportSchema.extend({
38
- firstSeenAt: z.string(),
39
- lastSeenAt: z.string(),
40
- actor: identifiedActorSchema
41
- }).strict();
42
- var actorDirectoryReportSchema = z.object({
43
- activityDays: z.array(peopleActivityDayReportSchema),
44
- generatedAt: z.string(),
45
- people: z.array(actorSummaryReportSchema),
46
- source: z.literal("conversation_index"),
47
- windowEnd: z.string(),
48
- windowStart: z.string()
49
- }).strict();
50
- var actorProfileReportSchema = z.object({
51
- activityDays: z.array(actorActivityDayReportSchema),
52
- generatedAt: z.string(),
53
- locations: z.array(peopleConversationStatsItemSchema),
54
- recentConversations: z.array(peopleConversationSummaryReportSchema),
55
- actor: identifiedActorSchema,
56
- source: z.literal("conversation_index"),
57
- surfaces: z.array(peopleConversationStatsItemSchema),
58
- totals: actorTotalsReportSchema,
59
- windowEnd: z.string(),
60
- windowStart: z.string()
61
- }).strict();
62
-
63
- export {
64
- actorDirectoryReportSchema,
65
- actorProfileReportSchema
66
- };