@sentry/junior 0.103.0 → 0.104.1
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.
- package/dist/{agent-hooks-NHIXBJW3.js → agent-hooks-EOFSY2PD.js} +3 -3
- package/dist/api/conversations/archive.d.ts +7 -0
- package/dist/api/conversations/detail.d.ts +7 -0
- package/dist/api/conversations/list.d.ts +109 -0
- package/dist/api/conversations/routes.d.ts +3 -0
- package/dist/api/conversations/schema.d.ts +72 -69
- package/dist/api/conversations/stats.d.ts +7 -0
- package/dist/api/conversations/subagent.d.ts +7 -0
- package/dist/api/http.d.ts +5 -0
- package/dist/api/locations/detail.d.ts +10 -2
- package/dist/api/locations/list.d.ts +7 -0
- package/dist/api/locations/routes.d.ts +3 -0
- package/dist/api/locations/schema.d.ts +4 -3
- package/dist/api/people/list.d.ts +7 -0
- package/dist/api/people/profile.d.ts +7 -0
- package/dist/api/people/routes.d.ts +3 -0
- package/dist/api/people/schema.d.ts +35 -33
- package/dist/api/people/shared.d.ts +3 -3
- package/dist/api/route.d.ts +7 -0
- package/dist/api/schema.js +11 -17
- package/dist/api.js +2184 -88
- package/dist/app.js +107 -101
- package/dist/chat/conversations/history.d.ts +6 -6
- package/dist/chat/conversations/store.d.ts +1 -0
- package/dist/chat/pi/messages.d.ts +2 -2
- package/dist/chat/plugins/agent-hooks.d.ts +2 -2
- package/dist/chat/resource-events/store.d.ts +2 -2
- package/dist/chat/slack/tools/conversation-search.d.ts +2 -2
- package/dist/chat/state/session-log.d.ts +2 -2
- package/dist/chat/task-execution/store.d.ts +2 -2
- package/dist/chat/tools/search-tools.d.ts +2 -2
- package/dist/chunk-AIRE7Q2W.js +362 -0
- package/dist/{chunk-HOBDQQJY.js → chunk-BCULHGZK.js} +23 -3
- package/dist/{chunk-DEQZ23O3.js → chunk-O7ILGCMJ.js} +77 -0
- package/dist/{chunk-C4BT2P2K.js → chunk-QDKRE3LS.js} +339 -8
- package/dist/{chunk-GY5ZRYPH.js → chunk-QVTVCJR4.js} +5 -5
- package/dist/{chunk-JXQWOCBE.js → chunk-RMZ65YAA.js} +2 -2
- package/dist/{chunk-E2VS47AZ.js → chunk-RYDF4GOX.js} +2 -2
- package/dist/{chunk-OE453VRG.js → chunk-TMWUGGSA.js} +26 -28
- package/dist/{chunk-JPXLAJUU.js → chunk-VDHMFCDY.js} +9 -10
- package/dist/cli/chat.js +10 -11
- package/dist/cli/plugins.js +4 -4
- package/dist/cli/upgrade.js +3 -4
- package/dist/db/schema/conversations.d.ts +17 -0
- package/dist/db/schema.d.ts +17 -0
- package/dist/{db-I343BSOM.js → db-PDMC67T3.js} +1 -1
- package/dist/{legacy-import-M7VBOQTK.js → legacy-import-G333RHJZ.js} +2 -2
- package/dist/reporting-schema.d.ts +4 -4
- package/dist/{runner-IEE5G4NV.js → runner-6A7MQRUE.js} +7 -8
- package/migrations/0004_useful_magus.sql +1 -0
- package/migrations/meta/0004_snapshot.json +1041 -0
- package/migrations/meta/_journal.json +7 -0
- package/package.json +6 -6
- package/dist/api/conversations/list.query.d.ts +0 -103
- package/dist/chunk-2RNOB32R.js +0 -17
- package/dist/chunk-6FPTHPXF.js +0 -77
- package/dist/chunk-6LBNXC4F.js +0 -66
- package/dist/chunk-7LLRS2OK.js +0 -215
- package/dist/chunk-B43K4C5K.js +0 -102
- package/dist/chunk-BQCPAIAB.js +0 -319
- package/dist/chunk-FW7DVHTL.js +0 -673
- package/dist/chunk-GCGRQJR5.js +0 -84
- package/dist/chunk-HRDWLE7Q.js +0 -273
- package/dist/chunk-LVUKF5CE.js +0 -63
- package/dist/chunk-QNVHH5PU.js +0 -20
- package/dist/chunk-QOZOJNSE.js +0 -96
- package/dist/chunk-VKFOVMZL.js +0 -331
- package/dist/detail-ENVV4HIY.js +0 -68
- package/dist/detail-UIOKVIET.js +0 -29
- package/dist/list-WR5U6JVM.js +0 -30
- package/dist/list-XZ4HKQ4R.js +0 -121
- package/dist/list-ZOUSMSEH.js +0 -30
- package/dist/plugin-conversations-DTUP4RH6.js +0 -37
- package/dist/profile-UO2N3XXG.js +0 -212
- package/dist/reporting/plugin-conversations.d.ts +0 -3
- package/dist/stats-NZIET4LT.js +0 -174
- package/dist/subagent-DY6XKTJ5.js +0 -49
package/dist/profile-UO2N3XXG.js
DELETED
|
@@ -1,212 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
slackLocationLabel,
|
|
3
|
-
summaryFromRow,
|
|
4
|
-
surfaceLabel
|
|
5
|
-
} from "./chunk-QOZOJNSE.js";
|
|
6
|
-
import {
|
|
7
|
-
ACTIVITY_DAYS,
|
|
8
|
-
activityDays,
|
|
9
|
-
emptyTotals,
|
|
10
|
-
normalizeEmail,
|
|
11
|
-
recentActorRows,
|
|
12
|
-
statsItems,
|
|
13
|
-
verifiedActorWhere
|
|
14
|
-
} from "./chunk-B43K4C5K.js";
|
|
15
|
-
import {
|
|
16
|
-
conversationActiveDaysColumn,
|
|
17
|
-
conversationAggregateColumns
|
|
18
|
-
} from "./chunk-6FPTHPXF.js";
|
|
19
|
-
import {
|
|
20
|
-
actorProfileReportSchema
|
|
21
|
-
} from "./chunk-6LBNXC4F.js";
|
|
22
|
-
import "./chunk-7LLRS2OK.js";
|
|
23
|
-
import "./chunk-PDO5BLNM.js";
|
|
24
|
-
import {
|
|
25
|
-
getDb,
|
|
26
|
-
juniorConversations,
|
|
27
|
-
juniorIdentities,
|
|
28
|
-
juniorUsers
|
|
29
|
-
} from "./chunk-HOBDQQJY.js";
|
|
30
|
-
import "./chunk-M3UAVLEN.js";
|
|
31
|
-
import {
|
|
32
|
-
juniorDestinations
|
|
33
|
-
} from "./chunk-FXFQNHRU.js";
|
|
34
|
-
import "./chunk-RT5BUHR5.js";
|
|
35
|
-
import "./chunk-B7PUBQQM.js";
|
|
36
|
-
import "./chunk-AEWZ7F65.js";
|
|
37
|
-
import "./chunk-OB42YVAE.js";
|
|
38
|
-
import "./chunk-6GWA276C.js";
|
|
39
|
-
import "./chunk-7FBGKXPE.js";
|
|
40
|
-
import "./chunk-MLKGABMK.js";
|
|
41
|
-
|
|
42
|
-
// src/api/people/profile.query.ts
|
|
43
|
-
import { and, eq, gte, sql } from "drizzle-orm";
|
|
44
|
-
function emptyProfile(email, nowMs) {
|
|
45
|
-
const end = new Date(nowMs);
|
|
46
|
-
end.setUTCHours(0, 0, 0, 0);
|
|
47
|
-
const start = new Date(end);
|
|
48
|
-
start.setUTCDate(start.getUTCDate() - (ACTIVITY_DAYS - 1));
|
|
49
|
-
return {
|
|
50
|
-
activityDays: activityDays(/* @__PURE__ */ new Map(), nowMs),
|
|
51
|
-
generatedAt: new Date(nowMs).toISOString(),
|
|
52
|
-
locations: [],
|
|
53
|
-
recentConversations: [],
|
|
54
|
-
actor: { email },
|
|
55
|
-
source: "conversation_index",
|
|
56
|
-
surfaces: [],
|
|
57
|
-
totals: emptyTotals(),
|
|
58
|
-
windowEnd: end.toISOString(),
|
|
59
|
-
windowStart: start.toISOString()
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
function addAggregate(map, label, row) {
|
|
63
|
-
const item = map.get(label) ?? {
|
|
64
|
-
active: 0,
|
|
65
|
-
conversations: 0,
|
|
66
|
-
durationMs: 0,
|
|
67
|
-
failed: 0,
|
|
68
|
-
label
|
|
69
|
-
};
|
|
70
|
-
item.active += row.active;
|
|
71
|
-
item.conversations += row.conversations;
|
|
72
|
-
item.durationMs += row.durationMs;
|
|
73
|
-
item.failed += row.failed;
|
|
74
|
-
if (row.tokens !== null) item.tokens = (item.tokens ?? 0) + row.tokens;
|
|
75
|
-
map.set(label, item);
|
|
76
|
-
}
|
|
77
|
-
function surfaceExpression() {
|
|
78
|
-
return sql`CASE
|
|
79
|
-
WHEN ${juniorConversations.source} IN ('api', 'scheduler', 'slack')
|
|
80
|
-
THEN ${juniorConversations.source}
|
|
81
|
-
WHEN ${juniorConversations.conversationId} LIKE 'slack:%' THEN 'slack'
|
|
82
|
-
WHEN ${juniorConversations.conversationId} LIKE 'scheduler:%' THEN 'scheduler'
|
|
83
|
-
WHEN ${juniorConversations.conversationId} LIKE 'api:%' THEN 'api'
|
|
84
|
-
ELSE 'internal'
|
|
85
|
-
END`;
|
|
86
|
-
}
|
|
87
|
-
function locationLabel(row) {
|
|
88
|
-
if (row.surface !== "slack")
|
|
89
|
-
return surfaceLabel(row.surface);
|
|
90
|
-
if (row.destinationVisibility !== "public") return "Private Conversation";
|
|
91
|
-
return slackLocationLabel({
|
|
92
|
-
channel: row.channel || void 0,
|
|
93
|
-
channelName: row.channelName ?? void 0
|
|
94
|
-
}) ?? "Conversation";
|
|
95
|
-
}
|
|
96
|
-
async function readPeopleProfileFromSql(email) {
|
|
97
|
-
const nowMs = Date.now();
|
|
98
|
-
const normalizedEmail = normalizeEmail(email);
|
|
99
|
-
if (!normalizedEmail) return emptyProfile("", nowMs);
|
|
100
|
-
const end = new Date(nowMs);
|
|
101
|
-
end.setUTCHours(0, 0, 0, 0);
|
|
102
|
-
const start = new Date(end);
|
|
103
|
-
start.setUTCDate(start.getUTCDate() - (ACTIVITY_DAYS - 1));
|
|
104
|
-
const where = verifiedActorWhere(normalizedEmail);
|
|
105
|
-
const surface = surfaceExpression();
|
|
106
|
-
const activityDate = sql`TO_CHAR(
|
|
107
|
-
${juniorConversations.lastActivityAt} AT TIME ZONE 'UTC',
|
|
108
|
-
'YYYY-MM-DD'
|
|
109
|
-
)`;
|
|
110
|
-
const channel = sql`SPLIT_PART(${juniorConversations.conversationId}, ':', 2)`;
|
|
111
|
-
const [totalsRows, dayRows, locationRows, surfaceRows, recentRows] = await Promise.all([
|
|
112
|
-
getDb().select({
|
|
113
|
-
email: juniorUsers.primaryEmailNormalized,
|
|
114
|
-
fullName: juniorUsers.displayName,
|
|
115
|
-
slackUserId: sql`MAX(${juniorIdentities.providerSubjectId})`,
|
|
116
|
-
slackUserName: sql`MAX(${juniorIdentities.handle})`,
|
|
117
|
-
activeDays: conversationActiveDaysColumn(),
|
|
118
|
-
...conversationAggregateColumns()
|
|
119
|
-
}).from(juniorConversations).innerJoin(
|
|
120
|
-
juniorIdentities,
|
|
121
|
-
eq(juniorIdentities.id, juniorConversations.actorIdentityId)
|
|
122
|
-
).innerJoin(juniorUsers, eq(juniorUsers.id, juniorIdentities.userId)).where(where).groupBy(juniorUsers.primaryEmailNormalized, juniorUsers.displayName),
|
|
123
|
-
getDb().select({
|
|
124
|
-
date: activityDate,
|
|
125
|
-
...conversationAggregateColumns()
|
|
126
|
-
}).from(juniorConversations).innerJoin(
|
|
127
|
-
juniorIdentities,
|
|
128
|
-
eq(juniorIdentities.id, juniorConversations.actorIdentityId)
|
|
129
|
-
).innerJoin(juniorUsers, eq(juniorUsers.id, juniorIdentities.userId)).where(and(where, gte(juniorConversations.lastActivityAt, start))).groupBy(activityDate),
|
|
130
|
-
getDb().select({
|
|
131
|
-
channel,
|
|
132
|
-
channelName: juniorConversations.channelName,
|
|
133
|
-
destinationVisibility: juniorDestinations.visibility,
|
|
134
|
-
surface,
|
|
135
|
-
...conversationAggregateColumns()
|
|
136
|
-
}).from(juniorConversations).innerJoin(
|
|
137
|
-
juniorIdentities,
|
|
138
|
-
eq(juniorIdentities.id, juniorConversations.actorIdentityId)
|
|
139
|
-
).innerJoin(juniorUsers, eq(juniorUsers.id, juniorIdentities.userId)).leftJoin(
|
|
140
|
-
juniorDestinations,
|
|
141
|
-
eq(juniorDestinations.id, juniorConversations.destinationId)
|
|
142
|
-
).where(where).groupBy(
|
|
143
|
-
channel,
|
|
144
|
-
juniorConversations.channelName,
|
|
145
|
-
juniorDestinations.visibility,
|
|
146
|
-
surface
|
|
147
|
-
),
|
|
148
|
-
getDb().select({ surface, ...conversationAggregateColumns() }).from(juniorConversations).innerJoin(
|
|
149
|
-
juniorIdentities,
|
|
150
|
-
eq(juniorIdentities.id, juniorConversations.actorIdentityId)
|
|
151
|
-
).innerJoin(juniorUsers, eq(juniorUsers.id, juniorIdentities.userId)).where(where).groupBy(surface),
|
|
152
|
-
recentActorRows(normalizedEmail)
|
|
153
|
-
]);
|
|
154
|
-
const totalsRow = totalsRows[0];
|
|
155
|
-
if (!totalsRow) return emptyProfile(normalizedEmail, nowMs);
|
|
156
|
-
const actor = {
|
|
157
|
-
email: totalsRow.email,
|
|
158
|
-
...totalsRow.fullName ? { fullName: totalsRow.fullName } : {},
|
|
159
|
-
...totalsRow.slackUserId ? { slackUserId: totalsRow.slackUserId } : {},
|
|
160
|
-
...totalsRow.slackUserName ? { slackUserName: totalsRow.slackUserName } : {}
|
|
161
|
-
};
|
|
162
|
-
const days = /* @__PURE__ */ new Map();
|
|
163
|
-
for (const row of dayRows) {
|
|
164
|
-
days.set(row.date, {
|
|
165
|
-
active: row.active,
|
|
166
|
-
conversations: row.conversations,
|
|
167
|
-
date: row.date,
|
|
168
|
-
durationMs: row.durationMs,
|
|
169
|
-
failed: row.failed,
|
|
170
|
-
...row.tokens !== null ? { tokens: row.tokens } : {}
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
const locations = /* @__PURE__ */ new Map();
|
|
174
|
-
for (const row of locationRows) {
|
|
175
|
-
addAggregate(locations, locationLabel(row), row);
|
|
176
|
-
}
|
|
177
|
-
const surfaces = /* @__PURE__ */ new Map();
|
|
178
|
-
for (const row of surfaceRows) {
|
|
179
|
-
addAggregate(
|
|
180
|
-
surfaces,
|
|
181
|
-
surfaceLabel(row.surface),
|
|
182
|
-
row
|
|
183
|
-
);
|
|
184
|
-
}
|
|
185
|
-
return {
|
|
186
|
-
activityDays: activityDays(days, nowMs),
|
|
187
|
-
generatedAt: new Date(nowMs).toISOString(),
|
|
188
|
-
locations: statsItems(locations),
|
|
189
|
-
recentConversations: recentRows.map(summaryFromRow),
|
|
190
|
-
actor,
|
|
191
|
-
source: "conversation_index",
|
|
192
|
-
surfaces: statsItems(surfaces),
|
|
193
|
-
totals: {
|
|
194
|
-
active: totalsRow.active,
|
|
195
|
-
activeDays: totalsRow.activeDays,
|
|
196
|
-
conversations: totalsRow.conversations,
|
|
197
|
-
durationMs: totalsRow.durationMs,
|
|
198
|
-
failed: totalsRow.failed,
|
|
199
|
-
...totalsRow.tokens !== null ? { tokens: totalsRow.tokens } : {}
|
|
200
|
-
},
|
|
201
|
-
windowEnd: end.toISOString(),
|
|
202
|
-
windowStart: start.toISOString()
|
|
203
|
-
};
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
// src/api/people/profile.ts
|
|
207
|
-
async function readPeopleProfile(email) {
|
|
208
|
-
return actorProfileReportSchema.parse(await readPeopleProfileFromSql(email));
|
|
209
|
-
}
|
|
210
|
-
export {
|
|
211
|
-
readPeopleProfile
|
|
212
|
-
};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import type { PluginConversationSummary } from "@sentry/junior-plugin-api";
|
|
2
|
-
/** Supply bounded SQL conversation metadata to plugin operational reports. */
|
|
3
|
-
export declare function listRecentConversationSummaries(requestedLimit?: number): Promise<PluginConversationSummary[]>;
|
package/dist/stats-NZIET4LT.js
DELETED
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
conversationAggregateColumns
|
|
3
|
-
} from "./chunk-6FPTHPXF.js";
|
|
4
|
-
import {
|
|
5
|
-
conversationStatsReportSchema
|
|
6
|
-
} from "./chunk-7LLRS2OK.js";
|
|
7
|
-
import "./chunk-PDO5BLNM.js";
|
|
8
|
-
import {
|
|
9
|
-
getDb,
|
|
10
|
-
juniorConversations,
|
|
11
|
-
juniorIdentities,
|
|
12
|
-
juniorUsers
|
|
13
|
-
} from "./chunk-HOBDQQJY.js";
|
|
14
|
-
import "./chunk-M3UAVLEN.js";
|
|
15
|
-
import {
|
|
16
|
-
juniorDestinations
|
|
17
|
-
} from "./chunk-FXFQNHRU.js";
|
|
18
|
-
import "./chunk-RT5BUHR5.js";
|
|
19
|
-
import "./chunk-B7PUBQQM.js";
|
|
20
|
-
import "./chunk-AEWZ7F65.js";
|
|
21
|
-
import "./chunk-OB42YVAE.js";
|
|
22
|
-
import "./chunk-6GWA276C.js";
|
|
23
|
-
import "./chunk-7FBGKXPE.js";
|
|
24
|
-
import "./chunk-MLKGABMK.js";
|
|
25
|
-
|
|
26
|
-
// src/api/conversations/stats.query.ts
|
|
27
|
-
import { and, eq, gte, isNull, lte } from "drizzle-orm";
|
|
28
|
-
var WINDOW_MS = 90 * 24 * 60 * 60 * 1e3;
|
|
29
|
-
function emptyStatsItem(label) {
|
|
30
|
-
return {
|
|
31
|
-
active: 0,
|
|
32
|
-
conversations: 0,
|
|
33
|
-
durationMs: 0,
|
|
34
|
-
failed: 0,
|
|
35
|
-
label
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
function addUsd(current, next) {
|
|
39
|
-
return Math.round(((current ?? 0) + next) * 1e12) / 1e12;
|
|
40
|
-
}
|
|
41
|
-
function actorLabel(row) {
|
|
42
|
-
return row.userEmail?.trim() || row.identityEmail?.trim() || row.userDisplayName?.trim() || row.identityDisplayName?.trim() || row.identityHandle?.trim() || row.identitySubjectId?.trim() || "Unknown";
|
|
43
|
-
}
|
|
44
|
-
function surfaceLabel(source) {
|
|
45
|
-
if (source === "scheduler") return "Scheduler";
|
|
46
|
-
if (source === "api") return "API";
|
|
47
|
-
if (source === "internal" || source === "local") return "Internal";
|
|
48
|
-
return "Conversation";
|
|
49
|
-
}
|
|
50
|
-
function locationLabel(row) {
|
|
51
|
-
if (row.destinationProvider !== "slack") {
|
|
52
|
-
return surfaceLabel(row.source);
|
|
53
|
-
}
|
|
54
|
-
if (row.destinationKind === "dm") {
|
|
55
|
-
return "Direct Message";
|
|
56
|
-
}
|
|
57
|
-
if (row.destinationVisibility !== "public") {
|
|
58
|
-
return "Private Conversation";
|
|
59
|
-
}
|
|
60
|
-
const name = (row.channelName ?? row.destinationDisplayName)?.trim().replace(/^#/, "");
|
|
61
|
-
return name ? `#${name}` : "Public Channel";
|
|
62
|
-
}
|
|
63
|
-
function addAggregate(map, label, row) {
|
|
64
|
-
const item = map.get(label) ?? emptyStatsItem(label);
|
|
65
|
-
item.active += row.active;
|
|
66
|
-
item.conversations += row.conversations;
|
|
67
|
-
item.durationMs += row.durationMs;
|
|
68
|
-
item.failed += row.failed;
|
|
69
|
-
if (row.tokens !== null) {
|
|
70
|
-
item.tokens = (item.tokens ?? 0) + row.tokens;
|
|
71
|
-
}
|
|
72
|
-
if (row.costUsd !== null) {
|
|
73
|
-
item.costUsd = addUsd(item.costUsd, row.costUsd);
|
|
74
|
-
}
|
|
75
|
-
map.set(label, item);
|
|
76
|
-
}
|
|
77
|
-
function statsItems(map) {
|
|
78
|
-
return [...map.values()].sort(
|
|
79
|
-
(left, right) => right.conversations - left.conversations || left.label.localeCompare(right.label)
|
|
80
|
-
);
|
|
81
|
-
}
|
|
82
|
-
function statsWhere(start, end) {
|
|
83
|
-
return and(
|
|
84
|
-
isNull(juniorConversations.parentConversationId),
|
|
85
|
-
gte(juniorConversations.lastActivityAt, start),
|
|
86
|
-
lte(juniorConversations.lastActivityAt, end)
|
|
87
|
-
);
|
|
88
|
-
}
|
|
89
|
-
async function aggregateStats(db, start, end) {
|
|
90
|
-
const where = statsWhere(start, end);
|
|
91
|
-
const [totalsRows, actorRows, locationRows] = await Promise.all([
|
|
92
|
-
db.select(conversationAggregateColumns()).from(juniorConversations).where(where),
|
|
93
|
-
db.select({
|
|
94
|
-
identityDisplayName: juniorIdentities.displayName,
|
|
95
|
-
identityEmail: juniorIdentities.emailNormalized,
|
|
96
|
-
identityHandle: juniorIdentities.handle,
|
|
97
|
-
identitySubjectId: juniorIdentities.providerSubjectId,
|
|
98
|
-
userDisplayName: juniorUsers.displayName,
|
|
99
|
-
userEmail: juniorUsers.primaryEmailNormalized,
|
|
100
|
-
...conversationAggregateColumns()
|
|
101
|
-
}).from(juniorConversations).leftJoin(
|
|
102
|
-
juniorIdentities,
|
|
103
|
-
eq(juniorIdentities.id, juniorConversations.actorIdentityId)
|
|
104
|
-
).leftJoin(juniorUsers, eq(juniorUsers.id, juniorIdentities.userId)).where(where).groupBy(
|
|
105
|
-
juniorIdentities.displayName,
|
|
106
|
-
juniorIdentities.emailNormalized,
|
|
107
|
-
juniorIdentities.handle,
|
|
108
|
-
juniorIdentities.providerSubjectId,
|
|
109
|
-
juniorUsers.displayName,
|
|
110
|
-
juniorUsers.primaryEmailNormalized
|
|
111
|
-
),
|
|
112
|
-
db.select({
|
|
113
|
-
channelName: juniorConversations.channelName,
|
|
114
|
-
destinationDisplayName: juniorDestinations.displayName,
|
|
115
|
-
destinationKind: juniorDestinations.kind,
|
|
116
|
-
destinationProvider: juniorDestinations.provider,
|
|
117
|
-
destinationVisibility: juniorDestinations.visibility,
|
|
118
|
-
source: juniorConversations.source,
|
|
119
|
-
...conversationAggregateColumns()
|
|
120
|
-
}).from(juniorConversations).leftJoin(
|
|
121
|
-
juniorDestinations,
|
|
122
|
-
eq(juniorDestinations.id, juniorConversations.destinationId)
|
|
123
|
-
).where(where).groupBy(
|
|
124
|
-
juniorConversations.channelName,
|
|
125
|
-
juniorConversations.source,
|
|
126
|
-
juniorDestinations.displayName,
|
|
127
|
-
juniorDestinations.kind,
|
|
128
|
-
juniorDestinations.provider,
|
|
129
|
-
juniorDestinations.visibility
|
|
130
|
-
)
|
|
131
|
-
]);
|
|
132
|
-
return { actorRows, locationRows, totals: totalsRows[0] };
|
|
133
|
-
}
|
|
134
|
-
async function readConversationStatsFromSql() {
|
|
135
|
-
const nowMs = Date.now();
|
|
136
|
-
const windowStartMs = nowMs - WINDOW_MS;
|
|
137
|
-
const { actorRows, locationRows, totals } = await aggregateStats(
|
|
138
|
-
getDb(),
|
|
139
|
-
new Date(windowStartMs),
|
|
140
|
-
new Date(nowMs)
|
|
141
|
-
);
|
|
142
|
-
const actors = /* @__PURE__ */ new Map();
|
|
143
|
-
const locations = /* @__PURE__ */ new Map();
|
|
144
|
-
for (const row of actorRows) {
|
|
145
|
-
addAggregate(actors, actorLabel(row), row);
|
|
146
|
-
}
|
|
147
|
-
for (const row of locationRows) {
|
|
148
|
-
addAggregate(locations, locationLabel(row), row);
|
|
149
|
-
}
|
|
150
|
-
return {
|
|
151
|
-
active: totals?.active ?? 0,
|
|
152
|
-
conversations: totals?.conversations ?? 0,
|
|
153
|
-
durationMs: totals?.durationMs ?? 0,
|
|
154
|
-
failed: totals?.failed ?? 0,
|
|
155
|
-
generatedAt: new Date(nowMs).toISOString(),
|
|
156
|
-
locations: statsItems(locations),
|
|
157
|
-
actors: statsItems(actors),
|
|
158
|
-
source: "conversation_index",
|
|
159
|
-
...totals?.costUsd !== null && totals?.costUsd !== void 0 ? { costUsd: addUsd(void 0, totals.costUsd) } : {},
|
|
160
|
-
...totals?.tokens !== null && totals?.tokens !== void 0 ? { tokens: totals.tokens } : {},
|
|
161
|
-
windowEnd: new Date(nowMs).toISOString(),
|
|
162
|
-
windowStart: new Date(windowStartMs).toISOString()
|
|
163
|
-
};
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
// src/api/conversations/stats.ts
|
|
167
|
-
async function readConversationStats() {
|
|
168
|
-
return conversationStatsReportSchema.parse(
|
|
169
|
-
await readConversationStatsFromSql()
|
|
170
|
-
);
|
|
171
|
-
}
|
|
172
|
-
export {
|
|
173
|
-
readConversationStats
|
|
174
|
-
};
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
buildConversationSubagent
|
|
3
|
-
} from "./chunk-FW7DVHTL.js";
|
|
4
|
-
import {
|
|
5
|
-
readConversationRecordFromSql
|
|
6
|
-
} from "./chunk-HRDWLE7Q.js";
|
|
7
|
-
import {
|
|
8
|
-
conversationSubagentTranscriptReportSchema
|
|
9
|
-
} from "./chunk-7LLRS2OK.js";
|
|
10
|
-
import "./chunk-LVUKF5CE.js";
|
|
11
|
-
import "./chunk-DEQZ23O3.js";
|
|
12
|
-
import "./chunk-BQCPAIAB.js";
|
|
13
|
-
import "./chunk-E2VS47AZ.js";
|
|
14
|
-
import "./chunk-PDO5BLNM.js";
|
|
15
|
-
import "./chunk-CCTCIISK.js";
|
|
16
|
-
import "./chunk-HOBDQQJY.js";
|
|
17
|
-
import "./chunk-4ZNGQH7C.js";
|
|
18
|
-
import "./chunk-M3UAVLEN.js";
|
|
19
|
-
import "./chunk-FXFQNHRU.js";
|
|
20
|
-
import "./chunk-RT5BUHR5.js";
|
|
21
|
-
import "./chunk-B7PUBQQM.js";
|
|
22
|
-
import "./chunk-AEWZ7F65.js";
|
|
23
|
-
import "./chunk-OB42YVAE.js";
|
|
24
|
-
import "./chunk-6GWA276C.js";
|
|
25
|
-
import "./chunk-7FBGKXPE.js";
|
|
26
|
-
import "./chunk-MLKGABMK.js";
|
|
27
|
-
|
|
28
|
-
// src/api/conversations/subagent.ts
|
|
29
|
-
async function readConversationSubagent(conversationId, subagentId) {
|
|
30
|
-
const record = await readConversationRecordFromSql(conversationId);
|
|
31
|
-
if (!record) {
|
|
32
|
-
return conversationSubagentTranscriptReportSchema.parse({
|
|
33
|
-
type: "subagent",
|
|
34
|
-
createdAt: (/* @__PURE__ */ new Date(0)).toISOString(),
|
|
35
|
-
id: subagentId,
|
|
36
|
-
status: "error",
|
|
37
|
-
subagentKind: "unknown",
|
|
38
|
-
transcript: [],
|
|
39
|
-
transcriptAvailable: false,
|
|
40
|
-
unavailableReason: "not_found"
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
return conversationSubagentTranscriptReportSchema.parse(
|
|
44
|
-
await buildConversationSubagent(record.conversation, subagentId)
|
|
45
|
-
);
|
|
46
|
-
}
|
|
47
|
-
export {
|
|
48
|
-
readConversationSubagent
|
|
49
|
-
};
|