@sentry/junior 0.101.0 → 0.102.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/dist/{agent-hooks-V6KU7PQN.js → agent-hooks-I4I2DHSW.js} +7 -7
- package/dist/api/people/schema.d.ts +13 -0
- package/dist/api/schema.d.ts +1 -1
- package/dist/api/schema.js +1 -1
- package/dist/api.js +14 -14
- package/dist/app.js +64 -53
- package/dist/{catalog-runtime-PFHVMHDR.js → catalog-runtime-5CVM2DOF.js} +2 -2
- package/dist/chat/agent/prompt.d.ts +1 -1
- package/dist/chat/agent-dispatch/validation.d.ts +1 -1
- package/dist/chat/conversation-privacy.d.ts +2 -6
- package/dist/chat/credentials/context.d.ts +33 -6
- package/dist/chat/credentials/subject.d.ts +15 -1
- package/dist/chat/logging.d.ts +4 -2
- package/dist/chat/mcp/tool-manager.d.ts +1 -1
- package/dist/chat/sandbox/egress/schemas.d.ts +13 -2
- package/dist/chat/services/context-compaction-marker.d.ts +8 -0
- package/dist/{chunk-XJA7BPHS.js → chunk-3OABPOHR.js} +3 -3
- package/dist/{chunk-EBFJOOUE.js → chunk-3UK5DFKW.js} +2 -2
- package/dist/{chunk-DBPLXSBK.js → chunk-4YN2ZXKB.js} +9 -1
- package/dist/{chunk-XVR4O24H.js → chunk-5K4N73TP.js} +4 -4
- package/dist/{chunk-LMJPRYHP.js → chunk-77LHNQK4.js} +32 -8
- package/dist/{chunk-I35CTGPO.js → chunk-AEWZ7F65.js} +41 -17
- package/dist/{chunk-IQIBZXGB.js → chunk-B5QS4AVO.js} +2 -2
- package/dist/{chunk-L2JIOAA2.js → chunk-DTUSCR2Y.js} +8 -11
- package/dist/{chunk-GEUUJRQF.js → chunk-E4EMFKGB.js} +1 -1
- package/dist/{chunk-VVIXK2BX.js → chunk-EMUZSROX.js} +2 -2
- package/dist/{chunk-IVXL57YF.js → chunk-EOB77KME.js} +4 -4
- package/dist/{chunk-PGGEOCQY.js → chunk-F4CQEUTP.js} +1 -1
- package/dist/{chunk-FP5N5OWZ.js → chunk-IQ36I3DF.js} +2 -2
- package/dist/{chunk-JSAANELJ.js → chunk-LJB2TLVT.js} +3 -3
- package/dist/{chunk-D5KZYS4T.js → chunk-MJSJAHBW.js} +1 -1
- package/dist/{chunk-VFBFK6EY.js → chunk-MR6H67P2.js} +2 -2
- package/dist/{chunk-5VGJJSSV.js → chunk-NSP6OGL2.js} +5 -5
- package/dist/{chunk-VHRM6GNH.js → chunk-QZGVPPIJ.js} +27 -3
- package/dist/{chunk-LVA4I4H7.js → chunk-RT5BUHR5.js} +15 -44
- package/dist/{chunk-A7X2FDUO.js → chunk-SHBPSE7A.js} +88 -66
- package/dist/{chunk-CM5EZD5F.js → chunk-UIE3R5XU.js} +1 -1
- package/dist/{chunk-JPQISMMJ.js → chunk-VSAFV2GI.js} +7 -6
- package/dist/{chunk-3ECW2K2O.js → chunk-WR7H7VLJ.js} +2 -2
- package/dist/{chunk-TPTJEHUE.js → chunk-X2IPNCB5.js} +61 -25
- package/dist/{chunk-UWGTSF5O.js → chunk-ZIX4PNBI.js} +129 -91
- package/dist/{chunk-PWC24W5F.js → chunk-ZSHL44IQ.js} +2 -2
- package/dist/cli/chat.js +21 -21
- package/dist/cli/check.js +3 -3
- package/dist/cli/plugins.js +9 -9
- package/dist/cli/snapshot-warmup.js +5 -5
- package/dist/cli/upgrade.js +85 -13
- package/dist/db/postgres-json.d.ts +5 -0
- package/dist/{db-RCZB7KNM.js → db-6QP6HY7U.js} +4 -4
- package/dist/{detail-4EPUMSDU.js → detail-OEIVZYXS.js} +11 -11
- package/dist/{detail-CD4SPJ4K.js → detail-U6IP2Z4N.js} +6 -6
- package/dist/instrumentation.js +2 -2
- package/dist/{legacy-import-VCYLWT2V.js → legacy-import-R3BMM2GH.js} +5 -5
- package/dist/{list-J6ROVH56.js → list-AJ6RWBOG.js} +7 -7
- package/dist/list-UMZKA5AI.js +121 -0
- package/dist/{list-7L5LY2WU.js → list-Z3CC52CZ.js} +6 -6
- package/dist/{plugin-conversations-JANXC4GA.js → plugin-conversations-F3IBVNFX.js} +7 -7
- package/dist/{profile-6NRWEKMZ.js → profile-CQMPFKED.js} +7 -7
- package/dist/{runner-CZIKSWGC.js → runner-C2ZTIOUD.js} +12 -12
- package/dist/{skills-MAZXZ2KE.js → skills-722AXRV5.js} +3 -3
- package/dist/{stats-Q5FRUXLY.js → stats-ZYFQFCTL.js} +5 -5
- package/dist/{subagent-YIINCFAS.js → subagent-X3ZWJHR4.js} +10 -10
- package/dist/{validation-FMEAEKCY.js → validation-EUI2UFRM.js} +3 -3
- package/package.json +5 -5
- package/dist/list-DA2ATOM4.js +0 -80
package/dist/chat/logging.d.ts
CHANGED
|
@@ -53,6 +53,8 @@ export declare function createChatSdkLogger(): ChatSdkLogger;
|
|
|
53
53
|
export declare function withLogContext<T>(context: LogContext, callback: () => Promise<T>): Promise<T>;
|
|
54
54
|
export declare function setLogContext(context: LogContext): void;
|
|
55
55
|
export declare function getLogContextAttributes(): LogAttributes;
|
|
56
|
+
/** Return inherited log context filtered to attributes valid for the span operation. */
|
|
57
|
+
export declare function getLogContextAttributesForSpan(op: string): LogAttributes;
|
|
56
58
|
export declare function registerLogRecordSink(sink: (record: EmittedLogRecord) => void): () => void;
|
|
57
59
|
export declare function createLogContextFromRequest(request: Request, context?: Partial<LogContext>): LogContext;
|
|
58
60
|
export declare function toSpanAttributes(context: LogContext): Record<string, string>;
|
|
@@ -93,7 +95,7 @@ export declare function captureExceptionInScope(error: unknown, context?: LogCon
|
|
|
93
95
|
export declare function getActiveTraceId(): string | undefined;
|
|
94
96
|
/** Build the static user-facing response for a failed turn. */
|
|
95
97
|
export declare function buildTurnFailureResponse(eventId: string): string;
|
|
96
|
-
/** Serialize
|
|
98
|
+
/** Serialize a bounded AI value, omitting it when valid JSON cannot fit. */
|
|
97
99
|
export declare function serializeGenAiAttribute(value: unknown, maxChars?: number): string | undefined;
|
|
98
100
|
/**
|
|
99
101
|
* Sum pi-ai `Usage` counters across every source into an `AgentTurnUsage`.
|
|
@@ -104,5 +106,5 @@ export declare function serializeGenAiAttribute(value: unknown, maxChars?: numbe
|
|
|
104
106
|
*/
|
|
105
107
|
export declare function extractGenAiUsageSummary(...sources: unknown[]): AgentTurnUsage;
|
|
106
108
|
/** Extract GenAI token and estimated USD cost attributes for tracing. */
|
|
107
|
-
export declare function extractGenAiUsageAttributes(...sources: unknown[]): Partial<Record<"gen_ai.usage.input_tokens" | "gen_ai.usage.output_tokens" | "gen_ai.usage.input_tokens
|
|
109
|
+
export declare function extractGenAiUsageAttributes(...sources: unknown[]): Partial<Record<"gen_ai.usage.input_tokens" | "gen_ai.usage.output_tokens" | "gen_ai.usage.cache_read.input_tokens" | "gen_ai.usage.cache_creation.input_tokens" | "gen_ai.usage.reasoning.output_tokens", number> & Partial<Record<"app.cost.input_usd" | "app.cost.output_usd" | "app.cost.cache_read_usd" | "app.cost.cache_write_usd" | "app.cost.total_usd", number>>>;
|
|
108
110
|
export {};
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import type { ImageContent, TextContent } from "@earendil-works/pi-ai";
|
|
10
10
|
import type { OAuthClientProvider } from "@modelcontextprotocol/sdk/client/auth.js";
|
|
11
|
-
import {
|
|
11
|
+
import type { ConversationPrivacy } from "@/chat/conversation-privacy";
|
|
12
12
|
import type { SkillMetadata } from "@/chat/skills";
|
|
13
13
|
import type { PluginDefinition } from "@/chat/plugins/types";
|
|
14
14
|
import { McpAuthorizationRequiredError } from "./client";
|
|
@@ -17,7 +17,7 @@ export declare const sandboxEgressCredentialContextSchema: z.ZodObject<{
|
|
|
17
17
|
platform: z.ZodLiteral<"system">;
|
|
18
18
|
name: z.ZodString;
|
|
19
19
|
}, z.core.$strict>;
|
|
20
|
-
subject: z.ZodOptional<z.ZodObject<{
|
|
20
|
+
subject: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
21
21
|
type: z.ZodLiteral<"user">;
|
|
22
22
|
userId: z.ZodString;
|
|
23
23
|
allowedWhen: z.ZodLiteral<"private-direct-conversation">;
|
|
@@ -27,7 +27,18 @@ export declare const sandboxEgressCredentialContextSchema: z.ZodObject<{
|
|
|
27
27
|
channelId: z.ZodString;
|
|
28
28
|
signature: z.ZodString;
|
|
29
29
|
}, z.core.$strict>;
|
|
30
|
-
}, z.core.$strict
|
|
30
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
31
|
+
type: z.ZodLiteral<"user">;
|
|
32
|
+
userId: z.ZodString;
|
|
33
|
+
allowedWhen: z.ZodLiteral<"scheduled-task">;
|
|
34
|
+
taskId: z.ZodString;
|
|
35
|
+
binding: z.ZodObject<{
|
|
36
|
+
type: z.ZodLiteral<"scheduled-task">;
|
|
37
|
+
plugin: z.ZodString;
|
|
38
|
+
taskId: z.ZodString;
|
|
39
|
+
signature: z.ZodString;
|
|
40
|
+
}, z.core.$strict>;
|
|
41
|
+
}, z.core.$strict>], "allowedWhen">>;
|
|
31
42
|
}, z.core.$strict>]>;
|
|
32
43
|
egressId: z.ZodString;
|
|
33
44
|
expiresAtMs: z.ZodNumber;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { PiMessage } from "@/chat/pi/messages";
|
|
2
|
+
export declare const COMPACTION_SUMMARY_PREFIX = "Context compaction summary for future Junior turns:";
|
|
3
|
+
export declare const LEGACY_COMPACTION_SUMMARY_PREFIX = "Context handoff summary for future Junior turns:";
|
|
4
|
+
export declare const MODEL_HANDOFF_SUMMARY_PREFIX = "Model handoff checkpoint. Continue the outstanding request now using this summary as the complete prior context:";
|
|
5
|
+
/** Return whether text is one of Junior's durable compacted-context markers. */
|
|
6
|
+
export declare function isCompactionSummaryText(text: string): boolean;
|
|
7
|
+
/** Return whether model-visible history contains a durable compacted context marker. */
|
|
8
|
+
export declare function hasCompactedConversationContext(messages: PiMessage[]): boolean;
|
|
@@ -7,13 +7,13 @@ import {
|
|
|
7
7
|
import {
|
|
8
8
|
getStateAdapter,
|
|
9
9
|
toOptionalTrimmed
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-SHBPSE7A.js";
|
|
11
11
|
import {
|
|
12
12
|
pluginCatalogRuntime
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-77LHNQK4.js";
|
|
14
14
|
import {
|
|
15
15
|
withSpan
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-AEWZ7F65.js";
|
|
17
17
|
|
|
18
18
|
// src/chat/sandbox/runtime-dependency-snapshots.ts
|
|
19
19
|
import { createHash } from "crypto";
|
|
@@ -5,14 +5,14 @@ import {
|
|
|
5
5
|
getChatConfig,
|
|
6
6
|
getDefaultRedisStateAdapterFor,
|
|
7
7
|
getStateAdapter
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-SHBPSE7A.js";
|
|
9
9
|
import {
|
|
10
10
|
parseDestination,
|
|
11
11
|
sameDestination
|
|
12
12
|
} from "./chunk-B7PUBQQM.js";
|
|
13
13
|
import {
|
|
14
14
|
parseStoredSlackActor
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-AEWZ7F65.js";
|
|
16
16
|
import {
|
|
17
17
|
isRecord,
|
|
18
18
|
toOptionalNumber,
|
|
@@ -20,6 +20,11 @@ var actorActivityDayReportSchema = z.object({
|
|
|
20
20
|
failed: z.number(),
|
|
21
21
|
tokens: z.number().optional()
|
|
22
22
|
}).strict();
|
|
23
|
+
var peopleActivityDayReportSchema = z.object({
|
|
24
|
+
activePeople: z.number(),
|
|
25
|
+
conversations: z.number(),
|
|
26
|
+
date: z.string()
|
|
27
|
+
}).strict();
|
|
23
28
|
var actorTotalsReportSchema = z.object({
|
|
24
29
|
active: z.number(),
|
|
25
30
|
activeDays: z.number(),
|
|
@@ -35,9 +40,12 @@ var actorSummaryReportSchema = actorTotalsReportSchema.extend({
|
|
|
35
40
|
actor: identifiedActorSchema
|
|
36
41
|
}).strict();
|
|
37
42
|
var actorDirectoryReportSchema = z.object({
|
|
43
|
+
activityDays: z.array(peopleActivityDayReportSchema),
|
|
38
44
|
generatedAt: z.string(),
|
|
39
45
|
people: z.array(actorSummaryReportSchema),
|
|
40
|
-
source: z.literal("conversation_index")
|
|
46
|
+
source: z.literal("conversation_index"),
|
|
47
|
+
windowEnd: z.string(),
|
|
48
|
+
windowStart: z.string()
|
|
41
49
|
}).strict();
|
|
42
50
|
var actorProfileReportSchema = z.object({
|
|
43
51
|
activityDays: z.array(actorActivityDayReportSchema),
|
|
@@ -7,10 +7,10 @@ import {
|
|
|
7
7
|
addAgentTurnUsage,
|
|
8
8
|
getAgentTurnSessionRecord,
|
|
9
9
|
upsertAgentTurnSessionRecord
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-EOB77KME.js";
|
|
11
11
|
import {
|
|
12
12
|
persistConversationMessages
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-VSAFV2GI.js";
|
|
14
14
|
import {
|
|
15
15
|
sleep
|
|
16
16
|
} from "./chunk-4ZNGQH7C.js";
|
|
@@ -18,11 +18,11 @@ import {
|
|
|
18
18
|
getPiMessageRole,
|
|
19
19
|
getStateAdapter,
|
|
20
20
|
trimTrailingAssistantMessages
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-SHBPSE7A.js";
|
|
22
22
|
import {
|
|
23
23
|
getActiveTraceId,
|
|
24
24
|
logException
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-AEWZ7F65.js";
|
|
26
26
|
import {
|
|
27
27
|
isRecord,
|
|
28
28
|
toOptionalString
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
logWarn,
|
|
4
4
|
parseActorUserId,
|
|
5
5
|
setSpanAttributes
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-AEWZ7F65.js";
|
|
7
7
|
import {
|
|
8
8
|
discoverInstalledPluginPackageContent,
|
|
9
9
|
normalizePluginPackageNames
|
|
@@ -1084,12 +1084,23 @@ var CredentialUnavailableError = class extends Error {
|
|
|
1084
1084
|
// src/chat/credentials/context.ts
|
|
1085
1085
|
import { z as z2 } from "zod";
|
|
1086
1086
|
var exactActorIdSchema = z2.string().refine((value) => parseActorUserId(value) === value);
|
|
1087
|
-
var
|
|
1087
|
+
var exactNonBlankStringSchema = z2.string().min(1).refine((value) => value === value.trim());
|
|
1088
|
+
var slackDirectCredentialSubjectBindingSchema = z2.object({
|
|
1088
1089
|
type: z2.literal("slack-direct-conversation"),
|
|
1089
1090
|
teamId: z2.string().min(1),
|
|
1090
1091
|
channelId: z2.string().min(1),
|
|
1091
1092
|
signature: z2.string().min(1)
|
|
1092
1093
|
}).strict();
|
|
1094
|
+
var scheduledTaskCredentialSubjectBindingSchema = z2.object({
|
|
1095
|
+
type: z2.literal("scheduled-task"),
|
|
1096
|
+
plugin: z2.string().min(1),
|
|
1097
|
+
taskId: exactNonBlankStringSchema,
|
|
1098
|
+
signature: z2.string().min(1)
|
|
1099
|
+
}).strict();
|
|
1100
|
+
var credentialSubjectBindingSchema = z2.discriminatedUnion("type", [
|
|
1101
|
+
slackDirectCredentialSubjectBindingSchema,
|
|
1102
|
+
scheduledTaskCredentialSubjectBindingSchema
|
|
1103
|
+
]);
|
|
1093
1104
|
var credentialUserActorSchema = z2.object({
|
|
1094
1105
|
type: z2.literal("user"),
|
|
1095
1106
|
userId: exactActorIdSchema
|
|
@@ -1098,12 +1109,24 @@ var credentialSystemActorSchema = z2.object({
|
|
|
1098
1109
|
platform: z2.literal("system"),
|
|
1099
1110
|
name: exactActorIdSchema
|
|
1100
1111
|
}).strict();
|
|
1101
|
-
var credentialSubjectSchema = z2.
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1112
|
+
var credentialSubjectSchema = z2.discriminatedUnion("allowedWhen", [
|
|
1113
|
+
z2.object({
|
|
1114
|
+
type: z2.literal("user"),
|
|
1115
|
+
userId: exactActorIdSchema,
|
|
1116
|
+
allowedWhen: z2.literal("private-direct-conversation"),
|
|
1117
|
+
binding: slackDirectCredentialSubjectBindingSchema
|
|
1118
|
+
}).strict(),
|
|
1119
|
+
z2.object({
|
|
1120
|
+
type: z2.literal("user"),
|
|
1121
|
+
userId: exactActorIdSchema,
|
|
1122
|
+
allowedWhen: z2.literal("scheduled-task"),
|
|
1123
|
+
taskId: exactNonBlankStringSchema,
|
|
1124
|
+
binding: scheduledTaskCredentialSubjectBindingSchema
|
|
1125
|
+
}).strict().refine((subject) => subject.binding.taskId === subject.taskId, {
|
|
1126
|
+
message: "Scheduled task credential subject requires task binding",
|
|
1127
|
+
path: ["binding"]
|
|
1128
|
+
})
|
|
1129
|
+
]);
|
|
1107
1130
|
var credentialContextSchema = z2.union([
|
|
1108
1131
|
z2.object({
|
|
1109
1132
|
actor: credentialUserActorSchema
|
|
@@ -2048,6 +2071,7 @@ export {
|
|
|
2048
2071
|
parsePluginManifest,
|
|
2049
2072
|
parseInlinePluginManifest,
|
|
2050
2073
|
CredentialUnavailableError,
|
|
2074
|
+
credentialSubjectSchema,
|
|
2051
2075
|
credentialContextSchema,
|
|
2052
2076
|
hasRequiredOAuthScope,
|
|
2053
2077
|
resolvePluginCommandEnv,
|
|
@@ -70,7 +70,7 @@ var LEGACY_KEY_MAP = {
|
|
|
70
70
|
inferredScore: "app.skill.score"
|
|
71
71
|
};
|
|
72
72
|
function normalizeGenAiFinishReason(reason) {
|
|
73
|
-
return reason === "toolUse" ? "
|
|
73
|
+
return reason === "toolUse" ? "tool_call" : reason;
|
|
74
74
|
}
|
|
75
75
|
function summarizeMessageText(text) {
|
|
76
76
|
const normalized = text.trim().replace(/\s+/g, " ");
|
|
@@ -1021,6 +1021,21 @@ function setLogContext(context) {
|
|
|
1021
1021
|
function getLogContextAttributes() {
|
|
1022
1022
|
return contextStorage.getStore() ?? {};
|
|
1023
1023
|
}
|
|
1024
|
+
function getLogContextAttributesForSpan(op) {
|
|
1025
|
+
const attributes = { ...getLogContextAttributes() };
|
|
1026
|
+
if (op === "gen_ai.invoke_agent" || op === "gen_ai.execute_tool") {
|
|
1027
|
+
delete attributes["gen_ai.request.model"];
|
|
1028
|
+
return attributes;
|
|
1029
|
+
}
|
|
1030
|
+
if (op === "gen_ai.chat" || op === "gen_ai.embeddings") {
|
|
1031
|
+
delete attributes["gen_ai.agent.name"];
|
|
1032
|
+
delete attributes["gen_ai.request.model"];
|
|
1033
|
+
return attributes;
|
|
1034
|
+
}
|
|
1035
|
+
delete attributes["gen_ai.agent.name"];
|
|
1036
|
+
delete attributes["gen_ai.request.model"];
|
|
1037
|
+
return attributes;
|
|
1038
|
+
}
|
|
1024
1039
|
function createLogContextFromRequest(request, context = {}) {
|
|
1025
1040
|
const url = new URL(request.url);
|
|
1026
1041
|
return {
|
|
@@ -1155,7 +1170,7 @@ async function withContext(context, callback) {
|
|
|
1155
1170
|
async function withSpan(name, op, context, callback, attributes = {}) {
|
|
1156
1171
|
const normalizedAttributes = normalizeSpanAttributes(attributes);
|
|
1157
1172
|
return withLogContext(context, () => {
|
|
1158
|
-
const inheritedAttributes =
|
|
1173
|
+
const inheritedAttributes = getLogContextAttributesForSpan(op);
|
|
1159
1174
|
return startSpan(
|
|
1160
1175
|
{
|
|
1161
1176
|
name,
|
|
@@ -1165,7 +1180,18 @@ async function withSpan(name, op, context, callback, attributes = {}) {
|
|
|
1165
1180
|
...normalizedAttributes
|
|
1166
1181
|
}
|
|
1167
1182
|
},
|
|
1168
|
-
(span) =>
|
|
1183
|
+
async (span) => {
|
|
1184
|
+
try {
|
|
1185
|
+
return await callback(
|
|
1186
|
+
(attributes2) => setAttributesOnSpan(span, attributes2)
|
|
1187
|
+
);
|
|
1188
|
+
} catch (error) {
|
|
1189
|
+
setAttributesOnSpan(span, {
|
|
1190
|
+
"error.type": error instanceof Error ? error.name : typeof error
|
|
1191
|
+
});
|
|
1192
|
+
throw error;
|
|
1193
|
+
}
|
|
1194
|
+
}
|
|
1169
1195
|
);
|
|
1170
1196
|
});
|
|
1171
1197
|
}
|
|
@@ -1223,7 +1249,7 @@ var GEN_AI_DEFAULT_MAX_ATTRIBUTE_CHARS = 1e5;
|
|
|
1223
1249
|
var GEN_AI_MAX_ARRAY_ITEMS = 50;
|
|
1224
1250
|
var GEN_AI_MAX_OBJECT_KEYS = 50;
|
|
1225
1251
|
function truncateGenAiString(value, maxChars) {
|
|
1226
|
-
return value.length > maxChars ?
|
|
1252
|
+
return value.length > maxChars ? "" : value;
|
|
1227
1253
|
}
|
|
1228
1254
|
function sanitizeGenAiValue(value, seen, depth, keyName) {
|
|
1229
1255
|
if (value === null || value === void 0) {
|
|
@@ -1277,7 +1303,7 @@ function serializeGenAiAttribute(value, maxChars = GEN_AI_DEFAULT_MAX_ATTRIBUTE_
|
|
|
1277
1303
|
if (!serialized) {
|
|
1278
1304
|
return void 0;
|
|
1279
1305
|
}
|
|
1280
|
-
return truncateGenAiString(redactSecrets(serialized), maxChars);
|
|
1306
|
+
return truncateGenAiString(redactSecrets(serialized), maxChars) || void 0;
|
|
1281
1307
|
}
|
|
1282
1308
|
function asRecord(value) {
|
|
1283
1309
|
return value && typeof value === "object" ? value : void 0;
|
|
@@ -1385,7 +1411,6 @@ function extractGenAiUsageAttributes(...sources) {
|
|
|
1385
1411
|
cachedInputTokens,
|
|
1386
1412
|
cacheCreationTokens,
|
|
1387
1413
|
reasoningTokens,
|
|
1388
|
-
totalTokens,
|
|
1389
1414
|
cost
|
|
1390
1415
|
} = extractGenAiUsageSummary(...sources);
|
|
1391
1416
|
const semanticInputTokens = sumTokenCounts(
|
|
@@ -1393,19 +1418,18 @@ function extractGenAiUsageAttributes(...sources) {
|
|
|
1393
1418
|
cachedInputTokens,
|
|
1394
1419
|
cacheCreationTokens
|
|
1395
1420
|
);
|
|
1396
|
-
const semanticTotalTokens = totalTokens ?? sumTokenCounts(semanticInputTokens, outputTokens);
|
|
1397
1421
|
return {
|
|
1398
1422
|
...semanticInputTokens !== void 0 ? { "gen_ai.usage.input_tokens": semanticInputTokens } : {},
|
|
1399
1423
|
...outputTokens !== void 0 ? { "gen_ai.usage.output_tokens": outputTokens } : {},
|
|
1400
|
-
|
|
1401
|
-
...cachedInputTokens !== void 0 ? { "gen_ai.usage.input_tokens
|
|
1402
|
-
...cacheCreationTokens !== void 0 ? { "gen_ai.usage.input_tokens
|
|
1403
|
-
...reasoningTokens !== void 0 ? { "
|
|
1404
|
-
...cost?.input !== void 0 ? { "app.
|
|
1405
|
-
...cost?.output !== void 0 ? { "app.
|
|
1406
|
-
...cost?.cacheRead !== void 0 ? { "app.
|
|
1407
|
-
...cost?.cacheWrite !== void 0 ? { "app.
|
|
1408
|
-
...cost?.total !== void 0 ? { "app.
|
|
1424
|
+
// OTel has no monetary cost attributes, so report accounting generically.
|
|
1425
|
+
...cachedInputTokens !== void 0 ? { "gen_ai.usage.cache_read.input_tokens": cachedInputTokens } : {},
|
|
1426
|
+
...cacheCreationTokens !== void 0 ? { "gen_ai.usage.cache_creation.input_tokens": cacheCreationTokens } : {},
|
|
1427
|
+
...reasoningTokens !== void 0 ? { "gen_ai.usage.reasoning.output_tokens": reasoningTokens } : {},
|
|
1428
|
+
...cost?.input !== void 0 ? { "app.cost.input_usd": cost.input } : {},
|
|
1429
|
+
...cost?.output !== void 0 ? { "app.cost.output_usd": cost.output } : {},
|
|
1430
|
+
...cost?.cacheRead !== void 0 ? { "app.cost.cache_read_usd": cost.cacheRead } : {},
|
|
1431
|
+
...cost?.cacheWrite !== void 0 ? { "app.cost.cache_write_usd": cost.cacheWrite } : {},
|
|
1432
|
+
...cost?.total !== void 0 ? { "app.cost.total_usd": cost.total } : {}
|
|
1409
1433
|
};
|
|
1410
1434
|
}
|
|
1411
1435
|
|
|
@@ -1581,7 +1605,7 @@ export {
|
|
|
1581
1605
|
normalizeGenAiFinishReason,
|
|
1582
1606
|
summarizeMessageText,
|
|
1583
1607
|
createChatSdkLogger,
|
|
1584
|
-
|
|
1608
|
+
getLogContextAttributesForSpan,
|
|
1585
1609
|
setSentryUser,
|
|
1586
1610
|
logInfo,
|
|
1587
1611
|
logWarn,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ensureLegacyConversationImport
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-VSAFV2GI.js";
|
|
4
4
|
import {
|
|
5
5
|
contextProvenance,
|
|
6
6
|
getAgentStepStore
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-QZGVPPIJ.js";
|
|
8
8
|
|
|
9
9
|
// src/chat/conversations/projection.ts
|
|
10
10
|
import { isDeepStrictEqual } from "util";
|
|
@@ -9,13 +9,13 @@ import {
|
|
|
9
9
|
getPersistedThreadState,
|
|
10
10
|
markTurnCompleted,
|
|
11
11
|
mergeArtifactsState
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-5K4N73TP.js";
|
|
13
13
|
import {
|
|
14
14
|
coerceThreadConversationState
|
|
15
15
|
} from "./chunk-XIMUQ4IU.js";
|
|
16
16
|
import {
|
|
17
17
|
getAgentTurnSessionRecord
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-EOB77KME.js";
|
|
19
19
|
import {
|
|
20
20
|
generateConversationId,
|
|
21
21
|
hydrateConversationMessages,
|
|
@@ -23,21 +23,20 @@ import {
|
|
|
23
23
|
normalizeConversationText,
|
|
24
24
|
updateConversationStats,
|
|
25
25
|
upsertConversationMessage
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-VSAFV2GI.js";
|
|
27
27
|
import {
|
|
28
28
|
createPluginEmbedder,
|
|
29
29
|
createPluginModel,
|
|
30
30
|
getPlugins
|
|
31
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-X2IPNCB5.js";
|
|
32
32
|
import {
|
|
33
33
|
createPluginLogger,
|
|
34
34
|
createPluginState
|
|
35
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-ZSHL44IQ.js";
|
|
36
36
|
import {
|
|
37
37
|
getDb
|
|
38
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-QZGVPPIJ.js";
|
|
39
39
|
import {
|
|
40
|
-
GEN_AI_PROVIDER_NAME,
|
|
41
40
|
botConfig,
|
|
42
41
|
getPiMessageRole,
|
|
43
42
|
getStateAdapter,
|
|
@@ -46,10 +45,10 @@ import {
|
|
|
46
45
|
isToolResultMessage,
|
|
47
46
|
normalizeToolNameFromResult,
|
|
48
47
|
stripRuntimeTurnContext
|
|
49
|
-
} from "./chunk-
|
|
48
|
+
} from "./chunk-SHBPSE7A.js";
|
|
50
49
|
import {
|
|
51
50
|
buildTurnFailureResponse
|
|
52
|
-
} from "./chunk-
|
|
51
|
+
} from "./chunk-AEWZ7F65.js";
|
|
53
52
|
import {
|
|
54
53
|
parseSlackMessageTs
|
|
55
54
|
} from "./chunk-7FBGKXPE.js";
|
|
@@ -97,8 +96,6 @@ function getFailureCapture(reply) {
|
|
|
97
96
|
}
|
|
98
97
|
function getAgentTurnDiagnosticsAttributes(reply) {
|
|
99
98
|
return {
|
|
100
|
-
"gen_ai.provider.name": GEN_AI_PROVIDER_NAME,
|
|
101
|
-
"gen_ai.operation.name": "invoke_agent",
|
|
102
99
|
"app.ai.outcome": reply.diagnostics.outcome,
|
|
103
100
|
"app.ai.assistant_messages": reply.diagnostics.assistantMessageCount,
|
|
104
101
|
"app.ai.tool_results": reply.diagnostics.toolResultCount,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
normalizeSlackConversationId
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-IQ36I3DF.js";
|
|
4
4
|
import {
|
|
5
5
|
parseSlackThreadId
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-RT5BUHR5.js";
|
|
7
7
|
|
|
8
8
|
// src/chat/slack/conversation-context.ts
|
|
9
9
|
function normalizeConversationName(type, channelName) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
commitMessages,
|
|
3
3
|
loadTurnProjection
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-B5QS4AVO.js";
|
|
5
5
|
import {
|
|
6
6
|
usageSchema
|
|
7
7
|
} from "./chunk-PDO5BLNM.js";
|
|
@@ -9,13 +9,13 @@ import {
|
|
|
9
9
|
getConversationStore,
|
|
10
10
|
instructionActors,
|
|
11
11
|
instructionProvenanceFor
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-QZGVPPIJ.js";
|
|
13
13
|
import {
|
|
14
14
|
getStateAdapter
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-SHBPSE7A.js";
|
|
16
16
|
import {
|
|
17
17
|
toStoredSlackActor
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-AEWZ7F65.js";
|
|
19
19
|
|
|
20
20
|
// src/chat/usage.ts
|
|
21
21
|
var agentTurnUsageSchema = usageSchema;
|
|
@@ -3,13 +3,13 @@ import {
|
|
|
3
3
|
} from "./chunk-4ZNGQH7C.js";
|
|
4
4
|
import {
|
|
5
5
|
getSlackBotToken
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-SHBPSE7A.js";
|
|
7
7
|
import {
|
|
8
8
|
logWarn,
|
|
9
9
|
setSpanAttributes,
|
|
10
10
|
setSpanStatus,
|
|
11
11
|
withSpan
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-AEWZ7F65.js";
|
|
13
13
|
import {
|
|
14
14
|
parseSlackChannelReferenceId
|
|
15
15
|
} from "./chunk-7FBGKXPE.js";
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import {
|
|
2
2
|
formatSlackConversationRedactedLabel,
|
|
3
3
|
resolveSlackConversationContextFromThreadId
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-EMUZSROX.js";
|
|
5
5
|
import {
|
|
6
6
|
getDb,
|
|
7
7
|
juniorConversations,
|
|
8
8
|
juniorIdentities
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-QZGVPPIJ.js";
|
|
10
10
|
import {
|
|
11
11
|
juniorDestinations
|
|
12
12
|
} from "./chunk-FXFQNHRU.js";
|
|
13
13
|
import {
|
|
14
14
|
parseSlackThreadId,
|
|
15
15
|
resolveConversationPrivacy
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-RT5BUHR5.js";
|
|
17
17
|
|
|
18
18
|
// src/api/conversations/list.query.ts
|
|
19
19
|
import { and, asc, desc, eq, isNull } from "drizzle-orm";
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
conversationAggregateColumns,
|
|
6
6
|
conversationRangeColumns
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-F4CQEUTP.js";
|
|
8
8
|
import {
|
|
9
9
|
activityDays
|
|
10
10
|
} from "./chunk-HNIT4HXU.js";
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
juniorConversations,
|
|
14
14
|
juniorIdentities,
|
|
15
15
|
juniorUsers
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-QZGVPPIJ.js";
|
|
17
17
|
import {
|
|
18
18
|
juniorDestinations
|
|
19
19
|
} from "./chunk-FXFQNHRU.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
conversationSummaryFromStoredConversation
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-LJB2TLVT.js";
|
|
4
4
|
import {
|
|
5
5
|
buildSentryConversationUrl,
|
|
6
6
|
buildSentryTraceUrl
|
|
@@ -8,19 +8,19 @@ import {
|
|
|
8
8
|
import {
|
|
9
9
|
loadProjection,
|
|
10
10
|
projectSteps
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-B5QS4AVO.js";
|
|
12
12
|
import {
|
|
13
13
|
getAgentStepStore,
|
|
14
14
|
getConversationMessageStore
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-QZGVPPIJ.js";
|
|
16
16
|
import {
|
|
17
17
|
stripRuntimeTurnContext,
|
|
18
18
|
unescapeXml,
|
|
19
19
|
unwrapCurrentInstruction
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-SHBPSE7A.js";
|
|
21
21
|
import {
|
|
22
22
|
canExposeConversationPayload
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-RT5BUHR5.js";
|
|
24
24
|
import {
|
|
25
25
|
isRecord
|
|
26
26
|
} from "./chunk-OB42YVAE.js";
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
getConnectedStateContext,
|
|
4
4
|
getStateAdapter,
|
|
5
5
|
modelProfileSchema
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-SHBPSE7A.js";
|
|
7
7
|
import {
|
|
8
8
|
juniorDestinations,
|
|
9
9
|
timestamptz
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
import {
|
|
16
16
|
normalizeIdentityEmail,
|
|
17
17
|
storedSlackActorSchema
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-AEWZ7F65.js";
|
|
19
19
|
|
|
20
20
|
// src/chat/conversations/sql/store.ts
|
|
21
21
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
@@ -1452,6 +1452,29 @@ async function ensureConversationRow(executor, conversationId, atMs) {
|
|
|
1452
1452
|
});
|
|
1453
1453
|
}
|
|
1454
1454
|
|
|
1455
|
+
// src/db/postgres-json.ts
|
|
1456
|
+
function sanitizePostgresJson(value) {
|
|
1457
|
+
if (typeof value === "string") {
|
|
1458
|
+
return value.replaceAll("\0", " ");
|
|
1459
|
+
}
|
|
1460
|
+
if (Array.isArray(value)) {
|
|
1461
|
+
return value.map((item) => sanitizePostgresJson(item));
|
|
1462
|
+
}
|
|
1463
|
+
if (value === null || typeof value !== "object") {
|
|
1464
|
+
return value;
|
|
1465
|
+
}
|
|
1466
|
+
const prototype = Object.getPrototypeOf(value);
|
|
1467
|
+
if (prototype !== Object.prototype && prototype !== null) {
|
|
1468
|
+
return value;
|
|
1469
|
+
}
|
|
1470
|
+
return Object.fromEntries(
|
|
1471
|
+
Object.entries(value).map(([key2, item]) => [
|
|
1472
|
+
key2,
|
|
1473
|
+
sanitizePostgresJson(item)
|
|
1474
|
+
])
|
|
1475
|
+
);
|
|
1476
|
+
}
|
|
1477
|
+
|
|
1455
1478
|
// src/chat/conversations/sql/history.ts
|
|
1456
1479
|
function messageRole(entry) {
|
|
1457
1480
|
if (entry.type !== "pi_message") {
|
|
@@ -1468,7 +1491,7 @@ function insertFromStep(conversationId, seq, contextEpoch, step) {
|
|
|
1468
1491
|
contextEpoch,
|
|
1469
1492
|
type,
|
|
1470
1493
|
role: messageRole(step.entry),
|
|
1471
|
-
payload,
|
|
1494
|
+
payload: sanitizePostgresJson(payload),
|
|
1472
1495
|
createdAt: new Date(step.createdAtMs)
|
|
1473
1496
|
};
|
|
1474
1497
|
}
|
|
@@ -2033,6 +2056,7 @@ export {
|
|
|
2033
2056
|
instructionProvenanceFor,
|
|
2034
2057
|
contextProvenance,
|
|
2035
2058
|
agentStepEntrySchema,
|
|
2059
|
+
sanitizePostgresJson,
|
|
2036
2060
|
createSqlAgentStepStore,
|
|
2037
2061
|
createSqlConversationMessageStore,
|
|
2038
2062
|
createJuniorSqlExecutor,
|