@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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentry/junior",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.104.1",
|
|
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.
|
|
78
|
+
"@sentry/junior-plugin-api": "0.104.1"
|
|
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.
|
|
96
|
-
"@sentry/junior-
|
|
97
|
-
"@sentry/junior-
|
|
98
|
-
"@sentry/junior-
|
|
95
|
+
"@sentry/junior-github": "0.104.1",
|
|
96
|
+
"@sentry/junior-memory": "0.104.1",
|
|
97
|
+
"@sentry/junior-scheduler": "0.104.1",
|
|
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 {};
|
package/dist/chunk-2RNOB32R.js
DELETED
|
@@ -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
|
-
};
|
package/dist/chunk-6FPTHPXF.js
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
juniorConversations
|
|
3
|
-
} from "./chunk-HOBDQQJY.js";
|
|
4
|
-
|
|
5
|
-
// src/api/conversations/aggregate.ts
|
|
6
|
-
import { sql } from "drizzle-orm";
|
|
7
|
-
function tokenValue() {
|
|
8
|
-
return sql`
|
|
9
|
-
CASE
|
|
10
|
-
WHEN ${juniorConversations.usage}->>'totalTokens' IS NOT NULL
|
|
11
|
-
THEN (${juniorConversations.usage}->>'totalTokens')::double precision
|
|
12
|
-
WHEN COALESCE(
|
|
13
|
-
${juniorConversations.usage}->>'inputTokens',
|
|
14
|
-
${juniorConversations.usage}->>'outputTokens',
|
|
15
|
-
${juniorConversations.usage}->>'cachedInputTokens',
|
|
16
|
-
${juniorConversations.usage}->>'cacheCreationTokens'
|
|
17
|
-
) IS NOT NULL
|
|
18
|
-
THEN COALESCE((${juniorConversations.usage}->>'inputTokens')::double precision, 0)
|
|
19
|
-
+ COALESCE((${juniorConversations.usage}->>'outputTokens')::double precision, 0)
|
|
20
|
-
+ COALESCE((${juniorConversations.usage}->>'cachedInputTokens')::double precision, 0)
|
|
21
|
-
+ COALESCE((${juniorConversations.usage}->>'cacheCreationTokens')::double precision, 0)
|
|
22
|
-
ELSE NULL
|
|
23
|
-
END
|
|
24
|
-
`;
|
|
25
|
-
}
|
|
26
|
-
function costValue() {
|
|
27
|
-
return sql`
|
|
28
|
-
CASE
|
|
29
|
-
WHEN ${juniorConversations.usage}->'cost'->>'total' IS NOT NULL
|
|
30
|
-
THEN (${juniorConversations.usage}->'cost'->>'total')::double precision
|
|
31
|
-
WHEN COALESCE(
|
|
32
|
-
${juniorConversations.usage}->'cost'->>'input',
|
|
33
|
-
${juniorConversations.usage}->'cost'->>'output',
|
|
34
|
-
${juniorConversations.usage}->'cost'->>'cacheRead',
|
|
35
|
-
${juniorConversations.usage}->'cost'->>'cacheWrite'
|
|
36
|
-
) IS NOT NULL
|
|
37
|
-
THEN COALESCE((${juniorConversations.usage}->'cost'->>'input')::double precision, 0)
|
|
38
|
-
+ COALESCE((${juniorConversations.usage}->'cost'->>'output')::double precision, 0)
|
|
39
|
-
+ COALESCE((${juniorConversations.usage}->'cost'->>'cacheRead')::double precision, 0)
|
|
40
|
-
+ COALESCE((${juniorConversations.usage}->'cost'->>'cacheWrite')::double precision, 0)
|
|
41
|
-
ELSE NULL
|
|
42
|
-
END
|
|
43
|
-
`;
|
|
44
|
-
}
|
|
45
|
-
function conversationAggregateColumns() {
|
|
46
|
-
return {
|
|
47
|
-
active: sql`COUNT(*) FILTER (
|
|
48
|
-
WHERE ${juniorConversations.executionStatus} NOT IN ('idle', 'failed')
|
|
49
|
-
)::integer`,
|
|
50
|
-
conversations: sql`COUNT(*)::integer`,
|
|
51
|
-
costUsd: sql`SUM(${costValue()})::double precision`,
|
|
52
|
-
durationMs: sql`COALESCE(SUM(${juniorConversations.durationMs}), 0)::double precision`,
|
|
53
|
-
failed: sql`COUNT(*) FILTER (
|
|
54
|
-
WHERE ${juniorConversations.executionStatus} = 'failed'
|
|
55
|
-
)::integer`,
|
|
56
|
-
tokens: sql`SUM(${tokenValue()})::double precision`
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
function conversationRangeColumns() {
|
|
60
|
-
return {
|
|
61
|
-
firstSeenAt: sql`MIN(${juniorConversations.createdAt})`.mapWith(
|
|
62
|
-
juniorConversations.createdAt
|
|
63
|
-
),
|
|
64
|
-
lastSeenAt: sql`MAX(${juniorConversations.lastActivityAt})`.mapWith(
|
|
65
|
-
juniorConversations.lastActivityAt
|
|
66
|
-
)
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
function conversationActiveDaysColumn() {
|
|
70
|
-
return sql`COUNT(DISTINCT (${juniorConversations.lastActivityAt} AT TIME ZONE 'UTC')::date)::integer`;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export {
|
|
74
|
-
conversationAggregateColumns,
|
|
75
|
-
conversationRangeColumns,
|
|
76
|
-
conversationActiveDaysColumn
|
|
77
|
-
};
|
package/dist/chunk-6LBNXC4F.js
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
actorIdentitySchema,
|
|
3
|
-
conversationStatsItemSchema,
|
|
4
|
-
conversationSummaryReportSchema
|
|
5
|
-
} from "./chunk-7LLRS2OK.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
|
-
};
|
package/dist/chunk-7LLRS2OK.js
DELETED
|
@@ -1,215 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
usageSchema
|
|
3
|
-
} from "./chunk-PDO5BLNM.js";
|
|
4
|
-
|
|
5
|
-
// src/api/conversations/schema.ts
|
|
6
|
-
import { z } from "zod";
|
|
7
|
-
var conversationReportStatusSchema = z.enum([
|
|
8
|
-
"active",
|
|
9
|
-
"completed",
|
|
10
|
-
"failed"
|
|
11
|
-
]);
|
|
12
|
-
var conversationSurfaceSchema = z.enum([
|
|
13
|
-
"api",
|
|
14
|
-
"internal",
|
|
15
|
-
"scheduler",
|
|
16
|
-
"slack"
|
|
17
|
-
]);
|
|
18
|
-
var conversationUsageSchema = usageSchema;
|
|
19
|
-
var actorIdentitySchema = z.object({
|
|
20
|
-
email: z.string().optional(),
|
|
21
|
-
fullName: z.string().optional(),
|
|
22
|
-
slackUserId: z.string().optional(),
|
|
23
|
-
slackUserName: z.string().optional()
|
|
24
|
-
}).strict();
|
|
25
|
-
var conversationSummaryReportSchema = z.object({
|
|
26
|
-
displayTitle: z.string(),
|
|
27
|
-
cumulativeDurationMs: z.number(),
|
|
28
|
-
cumulativeUsage: conversationUsageSchema.optional(),
|
|
29
|
-
conversationId: z.string(),
|
|
30
|
-
status: conversationReportStatusSchema,
|
|
31
|
-
startedAt: z.string(),
|
|
32
|
-
lastSeenAt: z.string(),
|
|
33
|
-
lastProgressAt: z.string(),
|
|
34
|
-
surface: conversationSurfaceSchema,
|
|
35
|
-
actorIdentity: actorIdentitySchema.optional(),
|
|
36
|
-
channel: z.string().optional(),
|
|
37
|
-
channelName: z.string().optional(),
|
|
38
|
-
channelNameRedacted: z.boolean().optional(),
|
|
39
|
-
locationId: z.string().optional(),
|
|
40
|
-
sentryTraceUrl: z.string().optional(),
|
|
41
|
-
traceId: z.string().optional()
|
|
42
|
-
}).strict();
|
|
43
|
-
var transcriptPartTypeSchema = z.enum([
|
|
44
|
-
"text",
|
|
45
|
-
"thinking",
|
|
46
|
-
"tool_call",
|
|
47
|
-
"tool_result",
|
|
48
|
-
"unknown"
|
|
49
|
-
]);
|
|
50
|
-
var transcriptPartSchema = z.object({
|
|
51
|
-
bytes: z.number().optional(),
|
|
52
|
-
chars: z.number().optional(),
|
|
53
|
-
id: z.string().optional(),
|
|
54
|
-
input: z.unknown().optional(),
|
|
55
|
-
inputKeys: z.array(z.string()).optional(),
|
|
56
|
-
inputSizeBytes: z.number().optional(),
|
|
57
|
-
inputSizeChars: z.number().optional(),
|
|
58
|
-
inputType: z.string().optional(),
|
|
59
|
-
name: z.string().optional(),
|
|
60
|
-
output: z.unknown().optional(),
|
|
61
|
-
outputKeys: z.array(z.string()).optional(),
|
|
62
|
-
outputSizeBytes: z.number().optional(),
|
|
63
|
-
outputSizeChars: z.number().optional(),
|
|
64
|
-
outputType: z.string().optional(),
|
|
65
|
-
redacted: z.boolean().optional(),
|
|
66
|
-
sourceType: z.string().optional(),
|
|
67
|
-
text: z.string().optional(),
|
|
68
|
-
type: transcriptPartTypeSchema
|
|
69
|
-
}).strict();
|
|
70
|
-
var transcriptRoleSchema = z.enum([
|
|
71
|
-
"assistant",
|
|
72
|
-
"system",
|
|
73
|
-
"tool",
|
|
74
|
-
"toolResult",
|
|
75
|
-
"unknown",
|
|
76
|
-
"user"
|
|
77
|
-
]);
|
|
78
|
-
var transcriptMessageSchema = z.object({
|
|
79
|
-
outcome: z.enum(["error", "aborted"]).optional(),
|
|
80
|
-
parts: z.array(transcriptPartSchema),
|
|
81
|
-
role: transcriptRoleSchema,
|
|
82
|
-
timestamp: z.number().optional()
|
|
83
|
-
}).strict();
|
|
84
|
-
var conversationActivityStatusSchema = z.enum([
|
|
85
|
-
"aborted",
|
|
86
|
-
"completed",
|
|
87
|
-
"error",
|
|
88
|
-
"running",
|
|
89
|
-
"success"
|
|
90
|
-
]);
|
|
91
|
-
var conversationSubagentActivityReportSchema = z.object({
|
|
92
|
-
type: z.literal("subagent"),
|
|
93
|
-
createdAt: z.string(),
|
|
94
|
-
endedAt: z.string().optional(),
|
|
95
|
-
id: z.string(),
|
|
96
|
-
modelId: z.string().optional(),
|
|
97
|
-
outcome: z.enum(["success", "error", "aborted"]).optional(),
|
|
98
|
-
parentToolCallId: z.string().optional(),
|
|
99
|
-
reasoningLevel: z.string().optional(),
|
|
100
|
-
status: conversationActivityStatusSchema,
|
|
101
|
-
subagentKind: z.string(),
|
|
102
|
-
transcriptAvailable: z.boolean().optional()
|
|
103
|
-
}).strict();
|
|
104
|
-
var conversationToolActivityReportSchema = z.object({
|
|
105
|
-
type: z.literal("tool_execution"),
|
|
106
|
-
args: z.unknown().optional(),
|
|
107
|
-
createdAt: z.string(),
|
|
108
|
-
id: z.string(),
|
|
109
|
-
inputKeys: z.array(z.string()).optional(),
|
|
110
|
-
inputSizeBytes: z.number().optional(),
|
|
111
|
-
inputSizeChars: z.number().optional(),
|
|
112
|
-
inputType: z.string().optional(),
|
|
113
|
-
redacted: z.boolean().optional(),
|
|
114
|
-
status: conversationActivityStatusSchema,
|
|
115
|
-
subagents: z.array(conversationSubagentActivityReportSchema),
|
|
116
|
-
toolCallId: z.string(),
|
|
117
|
-
toolName: z.string()
|
|
118
|
-
}).strict();
|
|
119
|
-
var conversationActivityReportSchema = z.discriminatedUnion("type", [
|
|
120
|
-
conversationToolActivityReportSchema,
|
|
121
|
-
conversationSubagentActivityReportSchema
|
|
122
|
-
]);
|
|
123
|
-
var conversationContextEventSchema = z.discriminatedUnion("type", [
|
|
124
|
-
z.object({
|
|
125
|
-
type: z.literal("context_compacted"),
|
|
126
|
-
createdAt: z.string(),
|
|
127
|
-
modelId: z.string().optional(),
|
|
128
|
-
summary: z.string().optional(),
|
|
129
|
-
transcriptIndex: z.number().int().nonnegative()
|
|
130
|
-
}).strict(),
|
|
131
|
-
z.object({
|
|
132
|
-
type: z.literal("model_handoff"),
|
|
133
|
-
createdAt: z.string(),
|
|
134
|
-
fromModelId: z.string().optional(),
|
|
135
|
-
message: z.string().optional(),
|
|
136
|
-
toModelId: z.string(),
|
|
137
|
-
transcriptIndex: z.number().int().nonnegative()
|
|
138
|
-
}).strict()
|
|
139
|
-
]);
|
|
140
|
-
var conversationDetailReportSchema = conversationSummaryReportSchema.extend({
|
|
141
|
-
activity: z.array(conversationActivityReportSchema).optional(),
|
|
142
|
-
modelId: z.string().optional(),
|
|
143
|
-
reasoningLevel: z.string().optional(),
|
|
144
|
-
contextEvents: z.array(conversationContextEventSchema).optional(),
|
|
145
|
-
transcriptAvailable: z.boolean(),
|
|
146
|
-
transcriptMetadata: z.array(transcriptMessageSchema).optional(),
|
|
147
|
-
transcriptMessageCount: z.number().optional(),
|
|
148
|
-
transcriptRedacted: z.boolean().optional(),
|
|
149
|
-
transcriptRedactionReason: z.literal("non_public_conversation").optional(),
|
|
150
|
-
transcriptExpired: z.boolean().optional(),
|
|
151
|
-
transcriptExpiredAt: z.string().optional(),
|
|
152
|
-
transcript: z.array(transcriptMessageSchema),
|
|
153
|
-
generatedAt: z.string(),
|
|
154
|
-
sentryConversationUrl: z.string().optional()
|
|
155
|
-
}).strict();
|
|
156
|
-
var conversationSubagentTranscriptReportSchema = z.object({
|
|
157
|
-
type: z.literal("subagent"),
|
|
158
|
-
createdAt: z.string(),
|
|
159
|
-
endedAt: z.string().optional(),
|
|
160
|
-
id: z.string(),
|
|
161
|
-
modelId: z.string().optional(),
|
|
162
|
-
outcome: z.enum(["success", "error", "aborted"]).optional(),
|
|
163
|
-
parentToolCallId: z.string().optional(),
|
|
164
|
-
reasoningLevel: z.string().optional(),
|
|
165
|
-
status: conversationActivityStatusSchema,
|
|
166
|
-
subagentConversationId: z.string().optional(),
|
|
167
|
-
subagentKind: z.string(),
|
|
168
|
-
subagentSentryConversationUrl: z.string().optional(),
|
|
169
|
-
transcript: z.array(transcriptMessageSchema),
|
|
170
|
-
transcriptAvailable: z.boolean(),
|
|
171
|
-
transcriptMessageCount: z.number().optional(),
|
|
172
|
-
transcriptRedacted: z.boolean().optional(),
|
|
173
|
-
transcriptRedactionReason: z.literal("non_public_conversation").optional(),
|
|
174
|
-
transcriptExpired: z.boolean().optional(),
|
|
175
|
-
transcriptExpiredAt: z.string().optional(),
|
|
176
|
-
unavailableReason: z.enum(["missing_transcript_range", "missing_transcript_ref", "not_found"]).optional()
|
|
177
|
-
}).strict();
|
|
178
|
-
var conversationFeedSchema = z.object({
|
|
179
|
-
conversations: z.array(conversationSummaryReportSchema),
|
|
180
|
-
source: z.literal("conversation_index"),
|
|
181
|
-
generatedAt: z.string()
|
|
182
|
-
}).strict();
|
|
183
|
-
var conversationStatsItemSchema = z.object({
|
|
184
|
-
active: z.number(),
|
|
185
|
-
conversations: z.number(),
|
|
186
|
-
durationMs: z.number(),
|
|
187
|
-
failed: z.number(),
|
|
188
|
-
label: z.string(),
|
|
189
|
-
costUsd: z.number().optional(),
|
|
190
|
-
tokens: z.number().optional()
|
|
191
|
-
}).strict();
|
|
192
|
-
var conversationStatsReportSchema = z.object({
|
|
193
|
-
active: z.number(),
|
|
194
|
-
conversations: z.number(),
|
|
195
|
-
durationMs: z.number(),
|
|
196
|
-
failed: z.number(),
|
|
197
|
-
generatedAt: z.string(),
|
|
198
|
-
locations: z.array(conversationStatsItemSchema),
|
|
199
|
-
actors: z.array(conversationStatsItemSchema),
|
|
200
|
-
source: z.literal("conversation_index"),
|
|
201
|
-
costUsd: z.number().optional(),
|
|
202
|
-
tokens: z.number().optional(),
|
|
203
|
-
windowEnd: z.string(),
|
|
204
|
-
windowStart: z.string()
|
|
205
|
-
}).strict();
|
|
206
|
-
|
|
207
|
-
export {
|
|
208
|
-
actorIdentitySchema,
|
|
209
|
-
conversationSummaryReportSchema,
|
|
210
|
-
conversationDetailReportSchema,
|
|
211
|
-
conversationSubagentTranscriptReportSchema,
|
|
212
|
-
conversationFeedSchema,
|
|
213
|
-
conversationStatsItemSchema,
|
|
214
|
-
conversationStatsReportSchema
|
|
215
|
-
};
|
package/dist/chunk-B43K4C5K.js
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getDb,
|
|
3
|
-
juniorConversations,
|
|
4
|
-
juniorIdentities,
|
|
5
|
-
juniorUsers
|
|
6
|
-
} from "./chunk-HOBDQQJY.js";
|
|
7
|
-
import {
|
|
8
|
-
juniorDestinations
|
|
9
|
-
} from "./chunk-FXFQNHRU.js";
|
|
10
|
-
|
|
11
|
-
// src/api/people/shared.ts
|
|
12
|
-
import { and, asc, desc, eq, sql } from "drizzle-orm";
|
|
13
|
-
var RECENT_LIMIT = 25;
|
|
14
|
-
var ACTIVITY_DAYS = 365;
|
|
15
|
-
function normalizeEmail(email) {
|
|
16
|
-
const normalized = email?.trim().toLowerCase();
|
|
17
|
-
return normalized || void 0;
|
|
18
|
-
}
|
|
19
|
-
function emptyTotals() {
|
|
20
|
-
return {
|
|
21
|
-
active: 0,
|
|
22
|
-
activeDays: 0,
|
|
23
|
-
conversations: 0,
|
|
24
|
-
durationMs: 0,
|
|
25
|
-
failed: 0
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
function emptyActivityDay(date) {
|
|
29
|
-
return {
|
|
30
|
-
active: 0,
|
|
31
|
-
conversations: 0,
|
|
32
|
-
date,
|
|
33
|
-
durationMs: 0,
|
|
34
|
-
failed: 0
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
function activityDays(days, nowMs) {
|
|
38
|
-
const items = [];
|
|
39
|
-
const end = new Date(nowMs);
|
|
40
|
-
end.setUTCHours(0, 0, 0, 0);
|
|
41
|
-
const start = new Date(end);
|
|
42
|
-
start.setUTCDate(start.getUTCDate() - (ACTIVITY_DAYS - 1));
|
|
43
|
-
for (const cursor = new Date(start); cursor.getTime() <= end.getTime(); cursor.setUTCDate(cursor.getUTCDate() + 1)) {
|
|
44
|
-
const date = cursor.toISOString().slice(0, 10);
|
|
45
|
-
items.push(days.get(date) ?? emptyActivityDay(date));
|
|
46
|
-
}
|
|
47
|
-
return items;
|
|
48
|
-
}
|
|
49
|
-
function statsItems(map) {
|
|
50
|
-
return [...map.values()].sort(
|
|
51
|
-
(left, right) => right.conversations - left.conversations || right.durationMs - left.durationMs || left.label.localeCompare(right.label)
|
|
52
|
-
);
|
|
53
|
-
}
|
|
54
|
-
function verifiedActorWhere(email) {
|
|
55
|
-
const normalizedEmail = normalizeEmail(email);
|
|
56
|
-
return and(
|
|
57
|
-
eq(juniorIdentities.provider, "slack"),
|
|
58
|
-
eq(juniorIdentities.emailVerified, true),
|
|
59
|
-
sql`${juniorUsers.primaryEmailNormalized} IS NOT NULL`,
|
|
60
|
-
normalizedEmail ? eq(juniorUsers.primaryEmailNormalized, normalizedEmail) : void 0
|
|
61
|
-
);
|
|
62
|
-
}
|
|
63
|
-
async function recentActorRows(email) {
|
|
64
|
-
return getDb().select({
|
|
65
|
-
channelName: juniorConversations.channelName,
|
|
66
|
-
conversationId: juniorConversations.conversationId,
|
|
67
|
-
createdAt: juniorConversations.createdAt,
|
|
68
|
-
destinationId: juniorDestinations.id,
|
|
69
|
-
destinationVisibility: juniorDestinations.visibility,
|
|
70
|
-
durationMs: juniorConversations.durationMs,
|
|
71
|
-
email: juniorUsers.primaryEmailNormalized,
|
|
72
|
-
executionStatus: juniorConversations.executionStatus,
|
|
73
|
-
executionUpdatedAt: juniorConversations.executionUpdatedAt,
|
|
74
|
-
fullName: juniorUsers.displayName,
|
|
75
|
-
handle: juniorIdentities.handle,
|
|
76
|
-
lastActivityAt: juniorConversations.lastActivityAt,
|
|
77
|
-
providerSubjectId: juniorIdentities.providerSubjectId,
|
|
78
|
-
source: juniorConversations.source,
|
|
79
|
-
title: juniorConversations.title,
|
|
80
|
-
updatedAt: juniorConversations.updatedAt,
|
|
81
|
-
usage: juniorConversations.usage
|
|
82
|
-
}).from(juniorConversations).innerJoin(
|
|
83
|
-
juniorIdentities,
|
|
84
|
-
eq(juniorIdentities.id, juniorConversations.actorIdentityId)
|
|
85
|
-
).innerJoin(juniorUsers, eq(juniorUsers.id, juniorIdentities.userId)).leftJoin(
|
|
86
|
-
juniorDestinations,
|
|
87
|
-
eq(juniorDestinations.id, juniorConversations.destinationId)
|
|
88
|
-
).where(verifiedActorWhere(email)).orderBy(
|
|
89
|
-
desc(juniorConversations.lastActivityAt),
|
|
90
|
-
asc(juniorConversations.conversationId)
|
|
91
|
-
).limit(RECENT_LIMIT);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
export {
|
|
95
|
-
ACTIVITY_DAYS,
|
|
96
|
-
normalizeEmail,
|
|
97
|
-
emptyTotals,
|
|
98
|
-
activityDays,
|
|
99
|
-
statsItems,
|
|
100
|
-
verifiedActorWhere,
|
|
101
|
-
recentActorRows
|
|
102
|
-
};
|