@sentry/junior 0.101.0 → 0.102.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-V6KU7PQN.js → agent-hooks-I4I2DHSW.js} +7 -7
- package/dist/api/conversations/stats.query.d.ts +1 -1
- package/dist/api/locations/list.d.ts +7 -0
- package/dist/api/locations/schema.d.ts +13 -0
- package/dist/api/people/schema.d.ts +13 -0
- package/dist/api/people/shared.d.ts +1 -1
- package/dist/api/schema.d.ts +3 -3
- package/dist/api/schema.js +4 -2
- package/dist/api.js +15 -15
- package/dist/app.js +65 -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-VFBFK6EY.js → chunk-4XNQSJAX.js} +62 -6
- 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-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-GEUUJRQF.js → chunk-KFP3TZOS.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-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-HNIT4HXU.js → chunk-WPHCUGN7.js} +10 -1
- 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-V37NTVBN.js} +7 -7
- 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-7L5LY2WU.js → list-FWLIZHSW.js} +7 -7
- package/dist/list-NTUT6A5M.js +121 -0
- package/dist/{plugin-conversations-JANXC4GA.js → plugin-conversations-F3IBVNFX.js} +7 -7
- package/dist/{profile-6NRWEKMZ.js → profile-3FRQP4HP.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-7UFY6FPE.js} +6 -6
- package/dist/{subagent-YIINCFAS.js → subagent-X3ZWJHR4.js} +10 -10
- package/dist/{validation-FMEAEKCY.js → validation-EUI2UFRM.js} +3 -3
- package/package.json +6 -6
- package/dist/list-DA2ATOM4.js +0 -80
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
declare const credentialSubjectBindingSchema: z.ZodObject<{
|
|
2
|
+
declare const credentialSubjectBindingSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
3
3
|
type: z.ZodLiteral<"slack-direct-conversation">;
|
|
4
4
|
teamId: z.ZodString;
|
|
5
5
|
channelId: z.ZodString;
|
|
6
6
|
signature: z.ZodString;
|
|
7
|
-
}, z.core.$strict
|
|
7
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
8
|
+
type: z.ZodLiteral<"scheduled-task">;
|
|
9
|
+
plugin: z.ZodString;
|
|
10
|
+
taskId: z.ZodString;
|
|
11
|
+
signature: z.ZodString;
|
|
12
|
+
}, z.core.$strict>], "type">;
|
|
8
13
|
declare const credentialSystemActorSchema: z.ZodObject<{
|
|
9
14
|
platform: z.ZodLiteral<"system">;
|
|
10
15
|
name: z.ZodString;
|
|
11
16
|
}, z.core.$strict>;
|
|
12
|
-
export declare const credentialSubjectSchema: z.ZodObject<{
|
|
17
|
+
export declare const credentialSubjectSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
13
18
|
type: z.ZodLiteral<"user">;
|
|
14
19
|
userId: z.ZodString;
|
|
15
20
|
allowedWhen: z.ZodLiteral<"private-direct-conversation">;
|
|
@@ -19,7 +24,18 @@ export declare const credentialSubjectSchema: z.ZodObject<{
|
|
|
19
24
|
channelId: z.ZodString;
|
|
20
25
|
signature: z.ZodString;
|
|
21
26
|
}, z.core.$strict>;
|
|
22
|
-
}, z.core.$strict
|
|
27
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
28
|
+
type: z.ZodLiteral<"user">;
|
|
29
|
+
userId: z.ZodString;
|
|
30
|
+
allowedWhen: z.ZodLiteral<"scheduled-task">;
|
|
31
|
+
taskId: z.ZodString;
|
|
32
|
+
binding: z.ZodObject<{
|
|
33
|
+
type: z.ZodLiteral<"scheduled-task">;
|
|
34
|
+
plugin: z.ZodString;
|
|
35
|
+
taskId: z.ZodString;
|
|
36
|
+
signature: z.ZodString;
|
|
37
|
+
}, z.core.$strict>;
|
|
38
|
+
}, z.core.$strict>], "allowedWhen">;
|
|
23
39
|
export declare const credentialContextSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
24
40
|
actor: z.ZodObject<{
|
|
25
41
|
type: z.ZodLiteral<"user">;
|
|
@@ -30,7 +46,7 @@ export declare const credentialContextSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
30
46
|
platform: z.ZodLiteral<"system">;
|
|
31
47
|
name: z.ZodString;
|
|
32
48
|
}, z.core.$strict>;
|
|
33
|
-
subject: z.ZodOptional<z.ZodObject<{
|
|
49
|
+
subject: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
34
50
|
type: z.ZodLiteral<"user">;
|
|
35
51
|
userId: z.ZodString;
|
|
36
52
|
allowedWhen: z.ZodLiteral<"private-direct-conversation">;
|
|
@@ -40,7 +56,18 @@ export declare const credentialContextSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
40
56
|
channelId: z.ZodString;
|
|
41
57
|
signature: z.ZodString;
|
|
42
58
|
}, z.core.$strict>;
|
|
43
|
-
}, z.core.$strict
|
|
59
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
60
|
+
type: z.ZodLiteral<"user">;
|
|
61
|
+
userId: z.ZodString;
|
|
62
|
+
allowedWhen: z.ZodLiteral<"scheduled-task">;
|
|
63
|
+
taskId: z.ZodString;
|
|
64
|
+
binding: z.ZodObject<{
|
|
65
|
+
type: z.ZodLiteral<"scheduled-task">;
|
|
66
|
+
plugin: z.ZodString;
|
|
67
|
+
taskId: z.ZodString;
|
|
68
|
+
signature: z.ZodString;
|
|
69
|
+
}, z.core.$strict>;
|
|
70
|
+
}, z.core.$strict>], "allowedWhen">>;
|
|
44
71
|
}, z.core.$strict>]>;
|
|
45
72
|
export type CredentialSubjectBinding = z.output<typeof credentialSubjectBindingSchema>;
|
|
46
73
|
export type CredentialSystemActor = z.output<typeof credentialSystemActorSchema>;
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import type { PluginCredentialSubject } from "@sentry/junior-plugin-api";
|
|
2
2
|
import type { CredentialSubject } from "@/chat/credentials/context";
|
|
3
|
+
type SlackDirectPluginCredentialSubject = Extract<PluginCredentialSubject, {
|
|
4
|
+
allowedWhen: "private-direct-conversation";
|
|
5
|
+
}>;
|
|
3
6
|
/** Create a delegated user credential subject for a verified Slack DM turn. */
|
|
4
7
|
export declare function createSlackDirectCredentialSubject(input: {
|
|
5
8
|
channelId: string | undefined;
|
|
6
9
|
teamId: string | undefined;
|
|
7
10
|
userId: string | undefined;
|
|
8
|
-
}):
|
|
11
|
+
}): SlackDirectPluginCredentialSubject | undefined;
|
|
9
12
|
/** Bind a delegated user subject to the Slack DM destination being dispatched. */
|
|
10
13
|
export declare function bindSlackDirectCredentialSubject(input: {
|
|
11
14
|
channelId: string;
|
|
@@ -18,3 +21,14 @@ export declare function verifySlackDirectCredentialSubject(input: {
|
|
|
18
21
|
subject: CredentialSubject;
|
|
19
22
|
teamId: string;
|
|
20
23
|
}): boolean;
|
|
24
|
+
/** Bind a delegated user subject to one scheduler task dispatch. */
|
|
25
|
+
export declare function bindScheduledTaskCredentialSubject(input: {
|
|
26
|
+
plugin: string;
|
|
27
|
+
subject: PluginCredentialSubject;
|
|
28
|
+
}): CredentialSubject | undefined;
|
|
29
|
+
/** Verify that a delegated subject was signed for one scheduler task. */
|
|
30
|
+
export declare function verifyScheduledTaskCredentialSubject(input: {
|
|
31
|
+
plugin: string;
|
|
32
|
+
subject: CredentialSubject;
|
|
33
|
+
}): boolean;
|
|
34
|
+
export {};
|
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,
|
|
@@ -4,16 +4,16 @@ 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
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-WPHCUGN7.js";
|
|
11
11
|
import {
|
|
12
12
|
getDb,
|
|
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";
|
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
// src/api/locations/query.ts
|
|
22
22
|
import { and, asc, desc, eq, gte, isNull, sql } from "drizzle-orm";
|
|
23
23
|
var RECENT_LIMIT = 25;
|
|
24
|
-
var ACTIVITY_DAYS =
|
|
24
|
+
var ACTIVITY_DAYS = 90;
|
|
25
25
|
function emptyMetrics() {
|
|
26
26
|
return {
|
|
27
27
|
active: 0,
|
|
@@ -117,9 +117,62 @@ async function directoryRows(db) {
|
|
|
117
117
|
eq(juniorDestinations.id, juniorConversations.destinationId)
|
|
118
118
|
).where(topLevelWhere()).groupBy(...locationGroupBy());
|
|
119
119
|
}
|
|
120
|
+
async function directoryActivityRows(db, start) {
|
|
121
|
+
const date = sql`TO_CHAR(
|
|
122
|
+
${juniorConversations.lastActivityAt} AT TIME ZONE 'UTC',
|
|
123
|
+
'YYYY-MM-DD'
|
|
124
|
+
)`;
|
|
125
|
+
return db.select({
|
|
126
|
+
conversations: sql`COUNT(*)::integer`,
|
|
127
|
+
date,
|
|
128
|
+
visibility: juniorDestinations.visibility
|
|
129
|
+
}).from(juniorConversations).leftJoin(
|
|
130
|
+
juniorDestinations,
|
|
131
|
+
eq(juniorDestinations.id, juniorConversations.destinationId)
|
|
132
|
+
).where(and(topLevelWhere(), gte(juniorConversations.lastActivityAt, start))).groupBy(date, juniorDestinations.visibility);
|
|
133
|
+
}
|
|
134
|
+
function directoryActivityDays(rows, nowMs) {
|
|
135
|
+
const days = /* @__PURE__ */ new Map();
|
|
136
|
+
for (const row of rows) {
|
|
137
|
+
const day = days.get(row.date) ?? {
|
|
138
|
+
date: row.date,
|
|
139
|
+
privateConversations: 0,
|
|
140
|
+
publicConversations: 0
|
|
141
|
+
};
|
|
142
|
+
if (row.visibility === "public") {
|
|
143
|
+
day.publicConversations += row.conversations;
|
|
144
|
+
} else {
|
|
145
|
+
day.privateConversations += row.conversations;
|
|
146
|
+
}
|
|
147
|
+
days.set(row.date, day);
|
|
148
|
+
}
|
|
149
|
+
const end = new Date(nowMs);
|
|
150
|
+
end.setUTCHours(0, 0, 0, 0);
|
|
151
|
+
const start = new Date(end);
|
|
152
|
+
start.setUTCDate(start.getUTCDate() - (ACTIVITY_DAYS - 1));
|
|
153
|
+
const activity = [];
|
|
154
|
+
for (const cursor = new Date(start); cursor.getTime() <= end.getTime(); cursor.setUTCDate(cursor.getUTCDate() + 1)) {
|
|
155
|
+
const date = cursor.toISOString().slice(0, 10);
|
|
156
|
+
activity.push(
|
|
157
|
+
days.get(date) ?? {
|
|
158
|
+
date,
|
|
159
|
+
privateConversations: 0,
|
|
160
|
+
publicConversations: 0
|
|
161
|
+
}
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
return activity;
|
|
165
|
+
}
|
|
120
166
|
async function readLocationDirectoryFromSql() {
|
|
121
167
|
const nowMs = Date.now();
|
|
122
|
-
const
|
|
168
|
+
const end = new Date(nowMs);
|
|
169
|
+
end.setUTCHours(0, 0, 0, 0);
|
|
170
|
+
const start = new Date(end);
|
|
171
|
+
start.setUTCDate(start.getUTCDate() - (ACTIVITY_DAYS - 1));
|
|
172
|
+
const [rows, activityRows] = await Promise.all([
|
|
173
|
+
directoryRows(getDb()),
|
|
174
|
+
directoryActivityRows(getDb(), start)
|
|
175
|
+
]);
|
|
123
176
|
const locations = [];
|
|
124
177
|
const privateActivity = {
|
|
125
178
|
...emptyMetrics(),
|
|
@@ -131,12 +184,15 @@ async function readLocationDirectoryFromSql() {
|
|
|
131
184
|
else addMetrics(privateActivity, row);
|
|
132
185
|
}
|
|
133
186
|
return {
|
|
187
|
+
activityDays: directoryActivityDays(activityRows, nowMs),
|
|
134
188
|
generatedAt: new Date(nowMs).toISOString(),
|
|
135
189
|
locations: locations.sort(
|
|
136
190
|
(left, right) => Date.parse(right.lastSeenAt) - Date.parse(left.lastSeenAt) || right.conversations - left.conversations || left.label.localeCompare(right.label)
|
|
137
191
|
),
|
|
138
192
|
privateActivity,
|
|
139
|
-
source: "conversation_index"
|
|
193
|
+
source: "conversation_index",
|
|
194
|
+
windowEnd: end.toISOString(),
|
|
195
|
+
windowStart: start.toISOString()
|
|
140
196
|
};
|
|
141
197
|
}
|
|
142
198
|
async function recentLocationRows(db, locationId) {
|
|
@@ -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) {
|