@sentry/junior 0.99.0 → 0.101.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.
- package/README.md +0 -1
- package/dist/{agent-hooks-OSW6C3CJ.js → agent-hooks-V6KU7PQN.js} +6 -5
- package/dist/api/activity.d.ts +14 -0
- package/dist/api/conversations/aggregate.d.ts +16 -0
- package/dist/api/conversations/detail-projection.d.ts +1 -0
- package/dist/api/conversations/list.query.d.ts +3 -0
- package/dist/api/conversations/projection.d.ts +1 -0
- package/dist/api/conversations/reporting.d.ts +42 -0
- package/dist/api/conversations/schema.d.ts +9 -9
- package/dist/api/conversations/stats.query.d.ts +1 -1
- package/dist/api/locations/detail.d.ts +81 -0
- package/dist/api/locations/list.d.ts +30 -0
- package/dist/api/locations/query.d.ts +5 -0
- package/dist/api/locations/schema.d.ts +175 -0
- package/dist/api/people/list.query.d.ts +1 -1
- package/dist/api/people/profile.query.d.ts +1 -1
- package/dist/api/people/schema.d.ts +10 -14
- package/dist/api/people/shared.d.ts +38 -78
- package/dist/api/schema.d.ts +8 -0
- package/dist/api/schema.js +14 -3
- package/dist/api.js +24 -11
- package/dist/app.js +126 -70
- package/dist/chat/agent/request.d.ts +4 -1
- package/dist/chat/config.d.ts +2 -0
- package/dist/chat/conversations/store.d.ts +1 -1
- package/dist/chat/mcp/auth-store.d.ts +1 -0
- package/dist/chat/mcp/client.d.ts +2 -0
- package/dist/chat/mcp/oauth-provider.d.ts +4 -1
- package/dist/chat/mcp/oauth.d.ts +3 -1
- package/dist/chat/mcp/tool-manager.d.ts +2 -0
- package/dist/chat/reasoning-level.d.ts +4 -0
- package/dist/chat/services/mcp-auth-orchestration.d.ts +1 -1
- package/dist/chat/services/pending-auth.d.ts +17 -9
- package/dist/chat/services/{turn-thinking-level.d.ts → turn-reasoning-level.d.ts} +11 -10
- package/dist/chat/services/turn-result.d.ts +3 -3
- package/dist/chat/state/conversation.d.ts +7 -3
- package/dist/chat/tools/search-tools.d.ts +2 -2
- package/dist/{chunk-T55RBE4Z.js → chunk-2RNOB32R.js} +3 -1
- package/dist/{chunk-ZZUBLPXD.js → chunk-5VGJJSSV.js} +9 -7
- package/dist/{chunk-EEZCY5WX.js → chunk-A7X2FDUO.js} +18 -2
- package/dist/{chunk-CRQVIHDI.js → chunk-DBPLXSBK.js} +2 -8
- package/dist/{chunk-NJEDJFK4.js → chunk-EBFJOOUE.js} +2 -2
- package/dist/{chunk-WTYEKPXU.js → chunk-FP5N5OWZ.js} +1 -1
- package/dist/chunk-FXFQNHRU.js +48 -0
- package/dist/chunk-GEUUJRQF.js +102 -0
- package/dist/chunk-HNIT4HXU.js +75 -0
- package/dist/{chunk-EUZ44ROE.js → chunk-HYDQULR2.js} +2 -4
- package/dist/{chunk-DHHU2WSG.js → chunk-IQIBZXGB.js} +2 -2
- package/dist/{chunk-OL6XQ23W.js → chunk-IVXL57YF.js} +3 -3
- package/dist/{chunk-IO65E4ZD.js → chunk-JPQISMMJ.js} +3 -3
- package/dist/{chunk-KFUSLFLL.js → chunk-JSAANELJ.js} +11 -4
- package/dist/{chunk-ER45IV77.js → chunk-L2JIOAA2.js} +10 -10
- package/dist/chunk-PGGEOCQY.js +77 -0
- package/dist/{chunk-EOWXRY5E.js → chunk-PWC24W5F.js} +1 -1
- package/dist/chunk-QOZOJNSE.js +96 -0
- package/dist/{chunk-FTTFV6DC.js → chunk-TPTJEHUE.js} +4 -4
- package/dist/{chunk-PYK7R5A7.js → chunk-UWGTSF5O.js} +285 -174
- package/dist/chunk-VFBFK6EY.js +275 -0
- package/dist/{chunk-OGHXZ4KQ.js → chunk-VHRM6GNH.js} +88 -122
- package/dist/{chunk-NG2AV7IB.js → chunk-VVIXK2BX.js} +1 -1
- package/dist/{chunk-6DTVCPLO.js → chunk-XIMUQ4IU.js} +4 -3
- package/dist/{chunk-H66UCBPW.js → chunk-XJA7BPHS.js} +1 -1
- package/dist/{chunk-WJ7STXT6.js → chunk-XVR4O24H.js} +8 -10
- package/dist/cli/chat.js +16 -15
- package/dist/cli/plugins.js +6 -5
- package/dist/cli/snapshot-warmup.js +2 -2
- package/dist/cli/upgrade.js +126 -8
- package/dist/db/schema/conversations.d.ts +17 -0
- package/dist/db/schema/destinations.d.ts +12 -3
- package/dist/db/schema.d.ts +19 -2
- package/dist/{db-GFSCDAHS.js → db-RCZB7KNM.js} +3 -2
- package/dist/{detail-Q4IVDNGS.js → detail-4EPUMSDU.js} +11 -10
- package/dist/detail-CD4SPJ4K.js +29 -0
- package/dist/{legacy-import-6WWXMALY.js → legacy-import-VCYLWT2V.js} +4 -3
- package/dist/list-7L5LY2WU.js +30 -0
- package/dist/list-DA2ATOM4.js +80 -0
- package/dist/{list-A3F5JDYV.js → list-J6ROVH56.js} +7 -6
- package/dist/{plugin-conversations-PDCQWU3O.js → plugin-conversations-JANXC4GA.js} +6 -5
- package/dist/profile-6NRWEKMZ.js +212 -0
- package/dist/{runner-267ZRLZD.js → runner-CZIKSWGC.js} +13 -12
- package/dist/stats-Q5FRUXLY.js +174 -0
- package/dist/{subagent-UN3MP6LV.js → subagent-YIINCFAS.js} +10 -9
- package/migrations/0003_peaceful_scalphunter.sql +4 -0
- package/migrations/meta/0003_snapshot.json +1035 -0
- package/migrations/meta/_journal.json +8 -1
- package/package.json +6 -6
- package/dist/api-reference.d.ts +0 -14
- package/dist/chunk-CV22LUIV.js +0 -261
- package/dist/list-M5BRWW3D.js +0 -92
- package/dist/profile-UEIRSVT3.js +0 -146
- package/dist/stats-L62E4O4U.js +0 -207
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { AuthorizationPauseKind } from "@/chat/services/auth-pause";
|
|
2
1
|
type ConversationRole = "assistant" | "system" | "user";
|
|
3
2
|
export interface ConversationAuthor {
|
|
4
3
|
fullName?: string;
|
|
@@ -39,14 +38,19 @@ export interface ConversationProcessingState {
|
|
|
39
38
|
lastCompletedAtMs?: number;
|
|
40
39
|
pendingAuth?: ConversationPendingAuthState;
|
|
41
40
|
}
|
|
42
|
-
|
|
43
|
-
kind: AuthorizationPauseKind;
|
|
41
|
+
interface ConversationPendingAuthBase {
|
|
44
42
|
linkSentAtMs: number;
|
|
45
43
|
provider: string;
|
|
46
44
|
actorId: string;
|
|
47
45
|
scope?: string;
|
|
48
46
|
sessionId: string;
|
|
49
47
|
}
|
|
48
|
+
export type ConversationPendingAuthState = (ConversationPendingAuthBase & {
|
|
49
|
+
authSessionId: string;
|
|
50
|
+
kind: "mcp";
|
|
51
|
+
}) | (ConversationPendingAuthBase & {
|
|
52
|
+
kind: "plugin";
|
|
53
|
+
});
|
|
50
54
|
export interface ConversationStats {
|
|
51
55
|
compactedMessageCount: number;
|
|
52
56
|
estimatedContextTokens: number;
|
|
@@ -32,7 +32,7 @@ export declare function createSearchToolsTool(catalogTools: Record<string, AnyTo
|
|
|
32
32
|
tools: {
|
|
33
33
|
tool_name: string;
|
|
34
34
|
description: string;
|
|
35
|
-
exposure: "
|
|
35
|
+
exposure: "direct" | "hidden" | "deferred" | "modelOnly";
|
|
36
36
|
signature: string;
|
|
37
37
|
call: {
|
|
38
38
|
tool_name: string;
|
|
@@ -77,7 +77,7 @@ export declare function createSearchToolsTool(catalogTools: Record<string, AnyTo
|
|
|
77
77
|
tools: {
|
|
78
78
|
tool_name: string;
|
|
79
79
|
description: string;
|
|
80
|
-
exposure: "
|
|
80
|
+
exposure: "direct" | "hidden" | "deferred" | "modelOnly";
|
|
81
81
|
signature: string;
|
|
82
82
|
call: {
|
|
83
83
|
tool_name: string;
|
|
@@ -6,10 +6,12 @@ var conversationFeedQuerySchema = z.object({
|
|
|
6
6
|
}).strict();
|
|
7
7
|
var subagentParamsSchema = conversationParamsSchema.extend({ subagentId: z.string().min(1) }).strict();
|
|
8
8
|
var personParamsSchema = z.object({ email: z.string().trim().min(1) }).strict();
|
|
9
|
+
var locationParamsSchema = z.object({ locationId: z.string().min(1) }).strict();
|
|
9
10
|
|
|
10
11
|
export {
|
|
11
12
|
conversationParamsSchema,
|
|
12
13
|
conversationFeedQuerySchema,
|
|
13
14
|
subagentParamsSchema,
|
|
14
|
-
personParamsSchema
|
|
15
|
+
personParamsSchema,
|
|
16
|
+
locationParamsSchema
|
|
15
17
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
conversationSummaryFromStoredConversation
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-JSAANELJ.js";
|
|
4
4
|
import {
|
|
5
5
|
buildSentryConversationUrl,
|
|
6
6
|
buildSentryTraceUrl
|
|
@@ -8,16 +8,16 @@ import {
|
|
|
8
8
|
import {
|
|
9
9
|
loadProjection,
|
|
10
10
|
projectSteps
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-IQIBZXGB.js";
|
|
12
12
|
import {
|
|
13
13
|
getAgentStepStore,
|
|
14
14
|
getConversationMessageStore
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-VHRM6GNH.js";
|
|
16
16
|
import {
|
|
17
17
|
stripRuntimeTurnContext,
|
|
18
18
|
unescapeXml,
|
|
19
19
|
unwrapCurrentInstruction
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-A7X2FDUO.js";
|
|
21
21
|
import {
|
|
22
22
|
canExposeConversationPayload
|
|
23
23
|
} from "./chunk-LVA4I4H7.js";
|
|
@@ -465,10 +465,11 @@ function historyContent(args) {
|
|
|
465
465
|
) : marker?.entry.reason === "handoff" ? summaryIndex(projected, projectedProvenance, [
|
|
466
466
|
MODEL_HANDOFF_SUMMARY_PREFIX
|
|
467
467
|
]) : -1;
|
|
468
|
-
const summary = replacementSummaryIndex >= 0 ? summaryAfterPrefix(
|
|
468
|
+
const summary = marker?.entry.reason === "compaction" && replacementSummaryIndex >= 0 ? summaryAfterPrefix(
|
|
469
469
|
projected[replacementSummaryIndex],
|
|
470
|
-
|
|
470
|
+
COMPACTION_SUMMARY_PREFIXES
|
|
471
471
|
) : void 0;
|
|
472
|
+
const handoffMessage = marker?.entry.reason === "handoff" && replacementSummaryIndex >= 0 ? messageText(projected[replacementSummaryIndex]) || void 0 : void 0;
|
|
472
473
|
if (marker?.entry.reason === "compaction") {
|
|
473
474
|
contextEvents.push({
|
|
474
475
|
type: "context_compacted",
|
|
@@ -483,7 +484,7 @@ function historyContent(args) {
|
|
|
483
484
|
createdAt: new Date(marker.createdAtMs).toISOString(),
|
|
484
485
|
...previousModelId ? { fromModelId: previousModelId } : {},
|
|
485
486
|
toModelId: marker.entry.modelId,
|
|
486
|
-
...args.canExposePayload &&
|
|
487
|
+
...args.canExposePayload && handoffMessage ? { message: handoffMessage } : {},
|
|
487
488
|
transcriptIndex: messages.length
|
|
488
489
|
});
|
|
489
490
|
}
|
|
@@ -564,6 +565,7 @@ async function buildConversationDetail(args) {
|
|
|
564
565
|
...conversationSummaryFromStoredConversation({
|
|
565
566
|
conversation,
|
|
566
567
|
durationMs: args.durationMs,
|
|
568
|
+
...args.locationId ? { locationId: args.locationId } : {},
|
|
567
569
|
usage: args.usage
|
|
568
570
|
}),
|
|
569
571
|
...traceId ? { traceId } : {},
|
|
@@ -541,11 +541,24 @@ function normalizeSlackEmojiName(value) {
|
|
|
541
541
|
return SLACK_EMOJI_NAME_RE.test(normalized) ? normalized : null;
|
|
542
542
|
}
|
|
543
543
|
|
|
544
|
-
// src/chat/
|
|
544
|
+
// src/chat/reasoning-level.ts
|
|
545
545
|
import { z } from "zod";
|
|
546
|
+
var TURN_REASONING_LEVELS = [
|
|
547
|
+
"none",
|
|
548
|
+
"low",
|
|
549
|
+
"medium",
|
|
550
|
+
"high",
|
|
551
|
+
"xhigh"
|
|
552
|
+
];
|
|
553
|
+
function parseTurnReasoningLevel(value) {
|
|
554
|
+
return z.enum(TURN_REASONING_LEVELS).parse(value);
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
// src/chat/model-profile.ts
|
|
558
|
+
import { z as z2 } from "zod";
|
|
546
559
|
var STANDARD_MODEL_PROFILE = "standard";
|
|
547
560
|
var DEFAULT_HANDOFF_MODEL_PROFILE = "handoff";
|
|
548
|
-
var modelProfileSchema =
|
|
561
|
+
var modelProfileSchema = z2.string().regex(/^[a-z][a-z0-9_-]*$/);
|
|
549
562
|
var ModelProfileNotConfiguredError = class extends Error {
|
|
550
563
|
constructor(profile) {
|
|
551
564
|
super(`Model profile "${profile}" is not configured`);
|
|
@@ -721,6 +734,7 @@ function readBotConfig(env) {
|
|
|
721
734
|
const functionMaxDurationSeconds = resolveFunctionMaxDurationSeconds(env);
|
|
722
735
|
const maxTurnTimeoutMs = resolveMaxTurnTimeoutMs(functionMaxDurationSeconds);
|
|
723
736
|
const modelId = validateGatewayModelId(env.AI_MODEL) ?? DEFAULT_MODEL_ID;
|
|
737
|
+
const reasoningLevel = toOptionalTrimmed(env.AI_REASONING_LEVEL);
|
|
724
738
|
const fastModelId = validateGatewayModelId(env.AI_FAST_MODEL ?? env.AI_MODEL) ?? DEFAULT_FAST_MODEL_ID;
|
|
725
739
|
const handoffModelId = validateGatewayModelId(env.AI_HANDOFF_MODEL) ?? DEFAULT_HANDOFF_MODEL_ID;
|
|
726
740
|
return {
|
|
@@ -731,6 +745,7 @@ function readBotConfig(env) {
|
|
|
731
745
|
"AI_MODEL_CONTEXT_WINDOW_TOKENS",
|
|
732
746
|
env.AI_MODEL_CONTEXT_WINDOW_TOKENS
|
|
733
747
|
),
|
|
748
|
+
reasoningLevel: reasoningLevel === void 0 ? void 0 : parseTurnReasoningLevel(reasoningLevel),
|
|
734
749
|
fastModelId,
|
|
735
750
|
embeddingModelId: validateEmbeddingModelId(env.AI_EMBEDDING_MODEL) ?? DEFAULT_EMBEDDING_MODEL_ID,
|
|
736
751
|
loadingMessages: parseLoadingMessages(env.JUNIOR_LOADING_MESSAGES),
|
|
@@ -1110,6 +1125,7 @@ export {
|
|
|
1110
1125
|
completeObject,
|
|
1111
1126
|
embedTexts,
|
|
1112
1127
|
normalizeSlackEmojiName,
|
|
1128
|
+
TURN_REASONING_LEVELS,
|
|
1113
1129
|
STANDARD_MODEL_PROFILE,
|
|
1114
1130
|
DEFAULT_HANDOFF_MODEL_PROFILE,
|
|
1115
1131
|
modelProfileSchema,
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
actorIdentitySchema,
|
|
3
3
|
conversationStatsItemSchema,
|
|
4
4
|
conversationSummaryReportSchema
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-HYDQULR2.js";
|
|
6
6
|
|
|
7
7
|
// src/api/people/schema.ts
|
|
8
8
|
import { z } from "zod";
|
|
@@ -37,10 +37,7 @@ var actorSummaryReportSchema = actorTotalsReportSchema.extend({
|
|
|
37
37
|
var actorDirectoryReportSchema = z.object({
|
|
38
38
|
generatedAt: z.string(),
|
|
39
39
|
people: z.array(actorSummaryReportSchema),
|
|
40
|
-
|
|
41
|
-
sampleSize: z.number(),
|
|
42
|
-
source: z.literal("conversation_index"),
|
|
43
|
-
truncated: z.boolean()
|
|
40
|
+
source: z.literal("conversation_index")
|
|
44
41
|
}).strict();
|
|
45
42
|
var actorProfileReportSchema = z.object({
|
|
46
43
|
activityDays: z.array(actorActivityDayReportSchema),
|
|
@@ -48,12 +45,9 @@ var actorProfileReportSchema = z.object({
|
|
|
48
45
|
locations: z.array(peopleConversationStatsItemSchema),
|
|
49
46
|
recentConversations: z.array(peopleConversationSummaryReportSchema),
|
|
50
47
|
actor: identifiedActorSchema,
|
|
51
|
-
sampleLimit: z.number(),
|
|
52
|
-
sampleSize: z.number(),
|
|
53
48
|
source: z.literal("conversation_index"),
|
|
54
49
|
surfaces: z.array(peopleConversationStatsItemSchema),
|
|
55
50
|
totals: actorTotalsReportSchema,
|
|
56
|
-
truncated: z.boolean(),
|
|
57
51
|
windowEnd: z.string(),
|
|
58
52
|
windowStart: z.string()
|
|
59
53
|
}).strict();
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
JUNIOR_THREAD_STATE_TTL_MS
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-XIMUQ4IU.js";
|
|
4
4
|
import {
|
|
5
5
|
getChatConfig,
|
|
6
6
|
getDefaultRedisStateAdapterFor,
|
|
7
7
|
getStateAdapter
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-A7X2FDUO.js";
|
|
9
9
|
import {
|
|
10
10
|
parseDestination,
|
|
11
11
|
sameDestination
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// src/db/schema/timestamps.ts
|
|
2
|
+
import { timestamp } from "drizzle-orm/pg-core";
|
|
3
|
+
var timestamptz = (name) => timestamp(name, { withTimezone: true });
|
|
4
|
+
|
|
5
|
+
// src/db/schema/destinations.ts
|
|
6
|
+
import { index, jsonb, pgTable, text, uniqueIndex } from "drizzle-orm/pg-core";
|
|
7
|
+
import { z } from "zod";
|
|
8
|
+
var juniorDestinationKindSchema = z.enum([
|
|
9
|
+
"channel",
|
|
10
|
+
"dm",
|
|
11
|
+
"group",
|
|
12
|
+
"local_conversation",
|
|
13
|
+
"thread",
|
|
14
|
+
"web_session"
|
|
15
|
+
]);
|
|
16
|
+
var juniorDestinations = pgTable(
|
|
17
|
+
"junior_destinations",
|
|
18
|
+
{
|
|
19
|
+
id: text("id").primaryKey(),
|
|
20
|
+
provider: text("provider").notNull(),
|
|
21
|
+
providerTenantId: text("provider_tenant_id").notNull().default(""),
|
|
22
|
+
providerDestinationId: text("provider_destination_id").notNull(),
|
|
23
|
+
kind: text("kind").$type().notNull(),
|
|
24
|
+
parentDestinationId: text("parent_destination_id"),
|
|
25
|
+
displayName: text("display_name"),
|
|
26
|
+
visibility: text("visibility").$type().notNull().default("unknown"),
|
|
27
|
+
metadata: jsonb("metadata_json"),
|
|
28
|
+
createdAt: timestamptz("created_at").notNull(),
|
|
29
|
+
updatedAt: timestamptz("updated_at").notNull()
|
|
30
|
+
},
|
|
31
|
+
(table) => [
|
|
32
|
+
uniqueIndex("junior_destinations_provider_destination_uidx").on(
|
|
33
|
+
table.provider,
|
|
34
|
+
table.providerTenantId,
|
|
35
|
+
table.providerDestinationId
|
|
36
|
+
),
|
|
37
|
+
index("junior_destinations_provider_kind_idx").on(
|
|
38
|
+
table.provider,
|
|
39
|
+
table.kind
|
|
40
|
+
)
|
|
41
|
+
]
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
export {
|
|
45
|
+
timestamptz,
|
|
46
|
+
juniorDestinationKindSchema,
|
|
47
|
+
juniorDestinations
|
|
48
|
+
};
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getDb,
|
|
3
|
+
juniorConversations,
|
|
4
|
+
juniorIdentities,
|
|
5
|
+
juniorUsers
|
|
6
|
+
} from "./chunk-VHRM6GNH.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 = 366;
|
|
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
|
+
};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import {
|
|
2
|
+
actorIdentitySchema,
|
|
3
|
+
conversationStatsItemSchema,
|
|
4
|
+
conversationSummaryReportSchema
|
|
5
|
+
} from "./chunk-HYDQULR2.js";
|
|
6
|
+
import {
|
|
7
|
+
juniorDestinationKindSchema
|
|
8
|
+
} from "./chunk-FXFQNHRU.js";
|
|
9
|
+
|
|
10
|
+
// src/api/activity.ts
|
|
11
|
+
import { z } from "zod";
|
|
12
|
+
var dailyConversationActivitySchema = z.object({
|
|
13
|
+
active: z.number(),
|
|
14
|
+
conversations: z.number(),
|
|
15
|
+
date: z.string(),
|
|
16
|
+
durationMs: z.number(),
|
|
17
|
+
failed: z.number(),
|
|
18
|
+
tokens: z.number().optional()
|
|
19
|
+
}).strict();
|
|
20
|
+
function emptyActivityDay(date) {
|
|
21
|
+
return {
|
|
22
|
+
active: 0,
|
|
23
|
+
conversations: 0,
|
|
24
|
+
date,
|
|
25
|
+
durationMs: 0,
|
|
26
|
+
failed: 0
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
function activityDays(days, nowMs, count) {
|
|
30
|
+
const items = [];
|
|
31
|
+
const end = new Date(nowMs);
|
|
32
|
+
end.setUTCHours(0, 0, 0, 0);
|
|
33
|
+
const start = new Date(end);
|
|
34
|
+
start.setUTCDate(start.getUTCDate() - (count - 1));
|
|
35
|
+
for (const cursor = new Date(start); cursor.getTime() <= end.getTime(); cursor.setUTCDate(cursor.getUTCDate() + 1)) {
|
|
36
|
+
const date = cursor.toISOString().slice(0, 10);
|
|
37
|
+
items.push(days.get(date) ?? emptyActivityDay(date));
|
|
38
|
+
}
|
|
39
|
+
return items;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// src/api/locations/schema.ts
|
|
43
|
+
import { z as z2 } from "zod";
|
|
44
|
+
var locationSummaryReportSchema = conversationStatsItemSchema.extend({
|
|
45
|
+
id: z2.string(),
|
|
46
|
+
firstSeenAt: z2.string(),
|
|
47
|
+
kind: juniorDestinationKindSchema,
|
|
48
|
+
lastSeenAt: z2.string(),
|
|
49
|
+
provider: z2.string(),
|
|
50
|
+
providerDestinationId: z2.string(),
|
|
51
|
+
visibility: z2.literal("public")
|
|
52
|
+
}).strict();
|
|
53
|
+
var locationActorSummaryReportSchema = conversationStatsItemSchema.extend({ actor: actorIdentitySchema }).strict();
|
|
54
|
+
var locationDirectoryReportSchema = z2.object({
|
|
55
|
+
generatedAt: z2.string(),
|
|
56
|
+
locations: z2.array(locationSummaryReportSchema),
|
|
57
|
+
privateActivity: conversationStatsItemSchema,
|
|
58
|
+
source: z2.literal("conversation_index")
|
|
59
|
+
}).strict();
|
|
60
|
+
var locationDetailReportSchema = locationSummaryReportSchema.extend({
|
|
61
|
+
activityDays: z2.array(dailyConversationActivitySchema),
|
|
62
|
+
actors: z2.array(locationActorSummaryReportSchema),
|
|
63
|
+
generatedAt: z2.string(),
|
|
64
|
+
recentConversations: z2.array(conversationSummaryReportSchema),
|
|
65
|
+
source: z2.literal("conversation_index"),
|
|
66
|
+
windowEnd: z2.string(),
|
|
67
|
+
windowStart: z2.string()
|
|
68
|
+
}).strict();
|
|
69
|
+
|
|
70
|
+
export {
|
|
71
|
+
dailyConversationActivitySchema,
|
|
72
|
+
activityDays,
|
|
73
|
+
locationDirectoryReportSchema,
|
|
74
|
+
locationDetailReportSchema
|
|
75
|
+
};
|
|
@@ -36,6 +36,7 @@ var conversationSummaryReportSchema = z.object({
|
|
|
36
36
|
channel: z.string().optional(),
|
|
37
37
|
channelName: z.string().optional(),
|
|
38
38
|
channelNameRedacted: z.boolean().optional(),
|
|
39
|
+
locationId: z.string().optional(),
|
|
39
40
|
sentryTraceUrl: z.string().optional(),
|
|
40
41
|
traceId: z.string().optional()
|
|
41
42
|
}).strict();
|
|
@@ -130,7 +131,7 @@ var conversationContextEventSchema = z.discriminatedUnion("type", [
|
|
|
130
131
|
type: z.literal("model_handoff"),
|
|
131
132
|
createdAt: z.string(),
|
|
132
133
|
fromModelId: z.string().optional(),
|
|
133
|
-
|
|
134
|
+
message: z.string().optional(),
|
|
134
135
|
toModelId: z.string(),
|
|
135
136
|
transcriptIndex: z.number().int().nonnegative()
|
|
136
137
|
}).strict()
|
|
@@ -195,12 +196,9 @@ var conversationStatsReportSchema = z.object({
|
|
|
195
196
|
generatedAt: z.string(),
|
|
196
197
|
locations: z.array(conversationStatsItemSchema),
|
|
197
198
|
actors: z.array(conversationStatsItemSchema),
|
|
198
|
-
sampleLimit: z.number(),
|
|
199
|
-
sampleSize: z.number(),
|
|
200
199
|
source: z.literal("conversation_index"),
|
|
201
200
|
costUsd: z.number().optional(),
|
|
202
201
|
tokens: z.number().optional(),
|
|
203
|
-
truncated: z.boolean(),
|
|
204
202
|
windowEnd: z.string(),
|
|
205
203
|
windowStart: z.string()
|
|
206
204
|
}).strict();
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ensureLegacyConversationImport
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-JPQISMMJ.js";
|
|
4
4
|
import {
|
|
5
5
|
contextProvenance,
|
|
6
6
|
getAgentStepStore
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-VHRM6GNH.js";
|
|
8
8
|
|
|
9
9
|
// src/chat/conversations/projection.ts
|
|
10
10
|
import { isDeepStrictEqual } from "util";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
commitMessages,
|
|
3
3
|
loadTurnProjection
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-IQIBZXGB.js";
|
|
5
5
|
import {
|
|
6
6
|
usageSchema
|
|
7
7
|
} from "./chunk-PDO5BLNM.js";
|
|
@@ -9,10 +9,10 @@ import {
|
|
|
9
9
|
getConversationStore,
|
|
10
10
|
instructionActors,
|
|
11
11
|
instructionProvenanceFor
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-VHRM6GNH.js";
|
|
13
13
|
import {
|
|
14
14
|
getStateAdapter
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-A7X2FDUO.js";
|
|
16
16
|
import {
|
|
17
17
|
toStoredSlackActor
|
|
18
18
|
} from "./chunk-I35CTGPO.js";
|
|
@@ -11,14 +11,14 @@ import {
|
|
|
11
11
|
legacyActorProvenance,
|
|
12
12
|
piMessageSchema,
|
|
13
13
|
readSessionLogEntries
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-VHRM6GNH.js";
|
|
15
15
|
import {
|
|
16
16
|
botConfig,
|
|
17
17
|
escapeXml,
|
|
18
18
|
getStateAdapter,
|
|
19
19
|
resolveGatewayModel,
|
|
20
20
|
unescapeXml
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-A7X2FDUO.js";
|
|
22
22
|
import {
|
|
23
23
|
logWarn,
|
|
24
24
|
setSpanAttributes
|
|
@@ -464,7 +464,7 @@ async function hydrateConversationMessages(args) {
|
|
|
464
464
|
args.conversation.messages = [];
|
|
465
465
|
return;
|
|
466
466
|
}
|
|
467
|
-
const { ensureLegacyConversationImport: ensureLegacyConversationImport2 } = await import("./legacy-import-
|
|
467
|
+
const { ensureLegacyConversationImport: ensureLegacyConversationImport2 } = await import("./legacy-import-VCYLWT2V.js");
|
|
468
468
|
await ensureLegacyConversationImport2({ conversationId: args.conversationId });
|
|
469
469
|
await hydrateConversationCompactions({
|
|
470
470
|
conversation: args.conversation,
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
formatSlackConversationRedactedLabel,
|
|
3
3
|
resolveSlackConversationContextFromThreadId
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-VVIXK2BX.js";
|
|
5
5
|
import {
|
|
6
6
|
getDb,
|
|
7
7
|
juniorConversations,
|
|
8
|
-
juniorDestinations,
|
|
9
8
|
juniorIdentities
|
|
10
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-VHRM6GNH.js";
|
|
10
|
+
import {
|
|
11
|
+
juniorDestinations
|
|
12
|
+
} from "./chunk-FXFQNHRU.js";
|
|
11
13
|
import {
|
|
12
14
|
parseSlackThreadId,
|
|
13
15
|
resolveConversationPrivacy
|
|
@@ -148,7 +150,8 @@ function conversationSummaryFromStoredConversation(args) {
|
|
|
148
150
|
...actorIdentity ? { actorIdentity } : {},
|
|
149
151
|
...slackThread ? { channel: slackThread.channelId } : {},
|
|
150
152
|
...channelName ? { channelName } : {},
|
|
151
|
-
...channelNameRedacted ? { channelNameRedacted: true } : {}
|
|
153
|
+
...channelNameRedacted ? { channelNameRedacted: true } : {},
|
|
154
|
+
...args.locationId && !channelNameRedacted ? { locationId: args.locationId } : {}
|
|
152
155
|
};
|
|
153
156
|
}
|
|
154
157
|
|
|
@@ -157,6 +160,7 @@ var CONVERSATION_FEED_LIMIT = 50;
|
|
|
157
160
|
async function conversationRows(db, limit, actorEmail) {
|
|
158
161
|
return db.select({
|
|
159
162
|
conversation: juniorConversations,
|
|
163
|
+
destinationId: juniorDestinations.id,
|
|
160
164
|
destinationVisibility: juniorDestinations.visibility,
|
|
161
165
|
identityDisplayName: juniorIdentities.displayName,
|
|
162
166
|
identityEmail: juniorIdentities.email,
|
|
@@ -218,6 +222,7 @@ async function readConversationRecordFromSql(conversationId) {
|
|
|
218
222
|
const db = getDb();
|
|
219
223
|
const rows = await db.select({
|
|
220
224
|
conversation: juniorConversations,
|
|
225
|
+
destinationId: juniorDestinations.id,
|
|
221
226
|
destinationVisibility: juniorDestinations.visibility,
|
|
222
227
|
identityDisplayName: juniorIdentities.displayName,
|
|
223
228
|
identityEmail: juniorIdentities.email,
|
|
@@ -236,6 +241,7 @@ async function readConversationRecordFromSql(conversationId) {
|
|
|
236
241
|
return row ? {
|
|
237
242
|
conversation: conversationFromRow(row),
|
|
238
243
|
durationMs: row.conversation.durationMs,
|
|
244
|
+
...row.destinationVisibility === "public" && row.destinationId ? { locationId: row.destinationId } : {},
|
|
239
245
|
usage: row.conversation.usage
|
|
240
246
|
} : void 0;
|
|
241
247
|
}
|
|
@@ -251,6 +257,7 @@ async function readConversationFeedFromSql(options = {}) {
|
|
|
251
257
|
(row) => conversationSummaryFromStoredConversation({
|
|
252
258
|
conversation: conversationFromRow(row),
|
|
253
259
|
durationMs: row.conversation.durationMs,
|
|
260
|
+
...row.destinationVisibility === "public" && row.destinationId ? { locationId: row.destinationId } : {},
|
|
254
261
|
usage: row.conversation.usage ?? void 0
|
|
255
262
|
})
|
|
256
263
|
),
|
|
@@ -9,13 +9,13 @@ import {
|
|
|
9
9
|
getPersistedThreadState,
|
|
10
10
|
markTurnCompleted,
|
|
11
11
|
mergeArtifactsState
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-XVR4O24H.js";
|
|
13
13
|
import {
|
|
14
14
|
coerceThreadConversationState
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-XIMUQ4IU.js";
|
|
16
16
|
import {
|
|
17
17
|
getAgentTurnSessionRecord
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-IVXL57YF.js";
|
|
19
19
|
import {
|
|
20
20
|
generateConversationId,
|
|
21
21
|
hydrateConversationMessages,
|
|
@@ -23,19 +23,19 @@ import {
|
|
|
23
23
|
normalizeConversationText,
|
|
24
24
|
updateConversationStats,
|
|
25
25
|
upsertConversationMessage
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-JPQISMMJ.js";
|
|
27
27
|
import {
|
|
28
28
|
createPluginEmbedder,
|
|
29
29
|
createPluginModel,
|
|
30
30
|
getPlugins
|
|
31
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-TPTJEHUE.js";
|
|
32
32
|
import {
|
|
33
33
|
createPluginLogger,
|
|
34
34
|
createPluginState
|
|
35
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-PWC24W5F.js";
|
|
36
36
|
import {
|
|
37
37
|
getDb
|
|
38
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-VHRM6GNH.js";
|
|
39
39
|
import {
|
|
40
40
|
GEN_AI_PROVIDER_NAME,
|
|
41
41
|
botConfig,
|
|
@@ -46,7 +46,7 @@ import {
|
|
|
46
46
|
isToolResultMessage,
|
|
47
47
|
normalizeToolNameFromResult,
|
|
48
48
|
stripRuntimeTurnContext
|
|
49
|
-
} from "./chunk-
|
|
49
|
+
} from "./chunk-A7X2FDUO.js";
|
|
50
50
|
import {
|
|
51
51
|
buildTurnFailureResponse
|
|
52
52
|
} from "./chunk-I35CTGPO.js";
|
|
@@ -105,8 +105,8 @@ function getAgentTurnDiagnosticsAttributes(reply) {
|
|
|
105
105
|
"app.ai.tool_error_results": reply.diagnostics.toolErrorCount,
|
|
106
106
|
"app.ai.tool_call_count": reply.diagnostics.toolCalls.length,
|
|
107
107
|
"app.ai.used_primary_text": reply.diagnostics.usedPrimaryText,
|
|
108
|
-
...reply.diagnostics.
|
|
109
|
-
"gen_ai.request.reasoning.level": reply.diagnostics.
|
|
108
|
+
...reply.diagnostics.reasoningLevel ? {
|
|
109
|
+
"gen_ai.request.reasoning.level": reply.diagnostics.reasoningLevel
|
|
110
110
|
} : {},
|
|
111
111
|
...reply.diagnostics.stopReason ? {
|
|
112
112
|
"gen_ai.response.finish_reasons": [reply.diagnostics.stopReason]
|