@sentry/junior 0.100.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/README.md +0 -1
- package/dist/{agent-hooks-V6KU7PQN.js → agent-hooks-I4I2DHSW.js} +7 -7
- package/dist/api/conversations/schema.d.ts +2 -2
- package/dist/api/people/schema.d.ts +13 -0
- package/dist/api/schema.d.ts +1 -1
- package/dist/api/schema.js +3 -3
- package/dist/api.js +16 -16
- package/dist/app.js +165 -104
- 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/request.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/conversations/store.d.ts +1 -1
- 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/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 +3 -1
- package/dist/chat/sandbox/egress/schemas.d.ts +13 -2
- package/dist/chat/services/context-compaction-marker.d.ts +8 -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/state/conversation.d.ts +7 -3
- package/dist/{chunk-XJA7BPHS.js → chunk-3OABPOHR.js} +3 -3
- package/dist/{chunk-2T7DCRAW.js → chunk-3UK5DFKW.js} +3 -3
- package/dist/{chunk-IDZBM3NW.js → chunk-4YN2ZXKB.js} +10 -2
- package/dist/{chunk-NSOCZGOH.js → chunk-5K4N73TP.js} +9 -11
- 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-XSBIISXS.js → chunk-DTUSCR2Y.js} +9 -12
- 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-4AQUWWEM.js → chunk-HNIT4HXU.js} +1 -1
- package/dist/{chunk-MM5UFDAC.js → chunk-HYDQULR2.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-QSBQJ3PA.js → chunk-MR6H67P2.js} +3 -3
- package/dist/{chunk-VY7BT4SM.js → chunk-NSP6OGL2.js} +9 -8
- 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-6DTVCPLO.js → chunk-XIMUQ4IU.js} +4 -3
- package/dist/{chunk-45DMFMY2.js → chunk-ZIX4PNBI.js} +348 -200
- package/dist/{chunk-PWC24W5F.js → chunk-ZSHL44IQ.js} +2 -2
- package/dist/cli/chat.js +22 -22
- 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 +203 -14
- package/dist/db/postgres-json.d.ts +5 -0
- package/dist/{db-RCZB7KNM.js → db-6QP6HY7U.js} +4 -4
- package/dist/{detail-LU6COZO6.js → detail-OEIVZYXS.js} +12 -12
- package/dist/{detail-5SLCGT6J.js → detail-U6IP2Z4N.js} +8 -8
- package/dist/instrumentation.js +2 -2
- package/dist/{legacy-import-VCYLWT2V.js → legacy-import-R3BMM2GH.js} +5 -5
- package/dist/{list-KHRAWZWU.js → list-AJ6RWBOG.js} +8 -8
- package/dist/list-UMZKA5AI.js +121 -0
- package/dist/{list-4ALSU6ZW.js → list-Z3CC52CZ.js} +8 -8
- package/dist/{plugin-conversations-JANXC4GA.js → plugin-conversations-F3IBVNFX.js} +7 -7
- package/dist/{profile-3O3OVENT.js → profile-CQMPFKED.js} +8 -8
- package/dist/{runner-BM7D35YW.js → runner-C2ZTIOUD.js} +13 -13
- package/dist/{skills-MAZXZ2KE.js → skills-722AXRV5.js} +3 -3
- package/dist/{stats-J3YGCYDF.js → stats-ZYFQFCTL.js} +6 -6
- package/dist/{subagent-P7HOSMVC.js → subagent-X3ZWJHR4.js} +11 -11
- package/dist/{validation-FMEAEKCY.js → validation-EUI2UFRM.js} +3 -3
- package/package.json +6 -6
- package/dist/api-reference.d.ts +0 -14
- package/dist/list-2FI5SFV7.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 {};
|
|
@@ -3,6 +3,7 @@ import type { OAuthDiscoveryState } from "@modelcontextprotocol/sdk/client/auth.
|
|
|
3
3
|
import { type Destination, type Source } from "@sentry/junior-plugin-api";
|
|
4
4
|
import type { ThreadArtifactsState } from "@/chat/state/artifacts";
|
|
5
5
|
export interface McpAuthSessionState {
|
|
6
|
+
schemaVersion: 2;
|
|
6
7
|
authSessionId: string;
|
|
7
8
|
provider: string;
|
|
8
9
|
userId: string;
|
|
@@ -15,6 +15,7 @@ export declare class PluginMcpClient {
|
|
|
15
15
|
private readonly plugin;
|
|
16
16
|
private readonly options;
|
|
17
17
|
private client?;
|
|
18
|
+
private clientPromise?;
|
|
18
19
|
private lastAttemptedTransportSessionId?;
|
|
19
20
|
private transport?;
|
|
20
21
|
private listedTools?;
|
|
@@ -24,6 +25,7 @@ export declare class PluginMcpClient {
|
|
|
24
25
|
close(): Promise<void>;
|
|
25
26
|
private withSessionRecovery;
|
|
26
27
|
private getClient;
|
|
28
|
+
private connectClient;
|
|
27
29
|
private wrapAuth;
|
|
28
30
|
private shouldResetMissingSession;
|
|
29
31
|
private disposeClient;
|
|
@@ -5,8 +5,9 @@ export declare class StateBackedMcpOAuthClientProvider implements OAuthClientPro
|
|
|
5
5
|
readonly authSessionId: string;
|
|
6
6
|
private readonly callbackUrl;
|
|
7
7
|
private readonly sessionContext?;
|
|
8
|
+
private readonly runCredentialMutation?;
|
|
8
9
|
readonly clientMetadata: OAuthClientMetadata;
|
|
9
|
-
constructor(authSessionId: string, callbackUrl: string, sessionContext?: Omit<McpAuthSessionState, "authSessionId" | "authorizationUrl" | "codeVerifier" | "createdAtMs" | "updatedAtMs"> | undefined);
|
|
10
|
+
constructor(authSessionId: string, callbackUrl: string, sessionContext?: Omit<McpAuthSessionState, "schemaVersion" | "authSessionId" | "authorizationUrl" | "codeVerifier" | "createdAtMs" | "updatedAtMs"> | undefined, runCredentialMutation?: (<T>(mutation: () => Promise<T>) => Promise<T>) | undefined);
|
|
10
11
|
get redirectUrl(): string;
|
|
11
12
|
state(): Promise<string>;
|
|
12
13
|
clientInformation(): Promise<OAuthClientInformationMixed | undefined>;
|
|
@@ -21,6 +22,8 @@ export declare class StateBackedMcpOAuthClientProvider implements OAuthClientPro
|
|
|
21
22
|
invalidateCredentials(scope: "all" | "client" | "tokens" | "verifier" | "discovery"): Promise<void>;
|
|
22
23
|
getMcpServerSessionId(): Promise<string | undefined>;
|
|
23
24
|
saveMcpServerSessionId(sessionId: string | undefined): Promise<void>;
|
|
25
|
+
/** Route shared credential writes through callback-owned freshness control. */
|
|
26
|
+
private mutateCredentials;
|
|
24
27
|
private getCredentialContext;
|
|
25
28
|
private ensureSession;
|
|
26
29
|
private requireSession;
|
package/dist/chat/mcp/oauth.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type { ThreadArtifactsState } from "@/chat/state/artifacts";
|
|
|
3
3
|
import { type McpAuthSessionState } from "./auth-store";
|
|
4
4
|
import { StateBackedMcpOAuthClientProvider } from "./oauth-provider";
|
|
5
5
|
export declare function getMcpOAuthCallbackPath(provider: string): string;
|
|
6
|
+
/** Create one immutable provider authorization attempt for the active turn. */
|
|
6
7
|
export declare function createMcpOAuthClientProvider(input: {
|
|
7
8
|
provider: string;
|
|
8
9
|
conversationId: string;
|
|
@@ -17,4 +18,5 @@ export declare function createMcpOAuthClientProvider(input: {
|
|
|
17
18
|
configuration?: Record<string, unknown>;
|
|
18
19
|
artifactState?: ThreadArtifactsState;
|
|
19
20
|
}): Promise<StateBackedMcpOAuthClientProvider>;
|
|
20
|
-
|
|
21
|
+
/** Exchange a callback code while guarding every shared credential mutation. */
|
|
22
|
+
export declare function finalizeMcpAuthorization(provider: string, authSessionId: string, authorizationCode: string, runCredentialMutation?: <T>(mutation: () => Promise<T>) => Promise<T>): Promise<McpAuthSessionState>;
|
|
@@ -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";
|
|
@@ -43,6 +43,7 @@ export declare class McpToolManager {
|
|
|
43
43
|
private readonly activeProviders;
|
|
44
44
|
private readonly authorizationPendingProviders;
|
|
45
45
|
private readonly clientsByProvider;
|
|
46
|
+
private readonly clientPromisesByProvider;
|
|
46
47
|
private readonly toolsByProvider;
|
|
47
48
|
constructor(plugins: PluginDefinition[], options?: McpToolManagerOptions);
|
|
48
49
|
getActiveProviders(): string[];
|
|
@@ -61,6 +62,7 @@ export declare class McpToolManager {
|
|
|
61
62
|
}): ManagedMcpToolDescriptor[];
|
|
62
63
|
private filterListedTools;
|
|
63
64
|
private getClient;
|
|
65
|
+
private createClient;
|
|
64
66
|
private toManagedTool;
|
|
65
67
|
private handleAuthorizationRequired;
|
|
66
68
|
/** Return all active ManagedMcpTool objects, optionally filtered by provider. */
|
|
@@ -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;
|
|
@@ -30,7 +30,7 @@ export interface McpAuthOrchestrationInput {
|
|
|
30
30
|
getConfiguration: () => Record<string, unknown>;
|
|
31
31
|
getArtifactState: () => ThreadArtifactsState | undefined;
|
|
32
32
|
getMergedArtifactState: () => ThreadArtifactsState;
|
|
33
|
-
recordPendingAuth?: (pendingAuth: ConversationPendingAuthState) => void | Promise<void>;
|
|
33
|
+
recordPendingAuth?: (pendingAuth: ConversationPendingAuthState | undefined) => void | Promise<void>;
|
|
34
34
|
authorizationFlowMode?: AuthorizationFlowMode;
|
|
35
35
|
}
|
|
36
36
|
export interface McpAuthOrchestration {
|
|
@@ -10,22 +10,30 @@ export declare function canReusePendingAuthLink(args: {
|
|
|
10
10
|
scope?: string;
|
|
11
11
|
sessionId: string;
|
|
12
12
|
}): boolean;
|
|
13
|
+
/** Return the exact pending authorization target for one actor and provider. */
|
|
13
14
|
export declare function getConversationPendingAuth(args: {
|
|
14
15
|
conversation: ThreadConversationState;
|
|
15
|
-
kind:
|
|
16
|
+
kind: "mcp";
|
|
16
17
|
provider: string;
|
|
17
18
|
actorId: string;
|
|
18
19
|
scope?: string;
|
|
19
|
-
}): ConversationPendingAuthState
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
* different session's pending-auth, mark the prior session record as abandoned.
|
|
24
|
-
* Callers are responsible for persisting the mutated conversation afterwards.
|
|
25
|
-
*/
|
|
26
|
-
export declare function applyPendingAuthUpdate(args: {
|
|
20
|
+
}): Extract<ConversationPendingAuthState, {
|
|
21
|
+
kind: "mcp";
|
|
22
|
+
}> | undefined;
|
|
23
|
+
export declare function getConversationPendingAuth(args: {
|
|
27
24
|
conversation: ThreadConversationState;
|
|
25
|
+
kind: "plugin";
|
|
26
|
+
provider: string;
|
|
27
|
+
actorId: string;
|
|
28
|
+
scope?: string;
|
|
29
|
+
}): Extract<ConversationPendingAuthState, {
|
|
30
|
+
kind: "plugin";
|
|
31
|
+
}> | undefined;
|
|
32
|
+
export declare function clearPendingAuth(conversation: ThreadConversationState, sessionId?: string): void;
|
|
33
|
+
/** Mark the prior blocked turn abandoned after a new auth attempt replaces it. */
|
|
34
|
+
export declare function abandonReplacedPendingAuth(args: {
|
|
28
35
|
conversationId: string | undefined;
|
|
36
|
+
previousPendingAuth: ConversationPendingAuthState | undefined;
|
|
29
37
|
nextPendingAuth: ConversationPendingAuthState;
|
|
30
38
|
}): Promise<void>;
|
|
31
39
|
/**
|
|
@@ -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;
|
|
@@ -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";
|
|
@@ -1,18 +1,18 @@
|
|
|
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-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,
|
|
@@ -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";
|
|
@@ -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),
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
JUNIOR_THREAD_STATE_TTL_MS,
|
|
3
3
|
buildConversationStatePatch
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-XIMUQ4IU.js";
|
|
5
5
|
import {
|
|
6
6
|
abandonAgentTurnSessionRecord,
|
|
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
|
|
@@ -899,13 +899,11 @@ function clearPendingAuth(conversation, sessionId) {
|
|
|
899
899
|
}
|
|
900
900
|
conversation.processing.pendingAuth = void 0;
|
|
901
901
|
}
|
|
902
|
-
async function
|
|
903
|
-
|
|
904
|
-
args.conversation.processing.pendingAuth = args.nextPendingAuth;
|
|
905
|
-
if (previousPendingAuth && previousPendingAuth.sessionId !== args.nextPendingAuth.sessionId && args.conversationId) {
|
|
902
|
+
async function abandonReplacedPendingAuth(args) {
|
|
903
|
+
if (args.previousPendingAuth && args.previousPendingAuth.sessionId !== args.nextPendingAuth.sessionId && args.conversationId) {
|
|
906
904
|
await abandonAgentTurnSessionRecord({
|
|
907
905
|
conversationId: args.conversationId,
|
|
908
|
-
sessionId: previousPendingAuth.sessionId,
|
|
906
|
+
sessionId: args.previousPendingAuth.sessionId,
|
|
909
907
|
errorMessage: "Abandoned by a newer auth-blocked request in the same conversation."
|
|
910
908
|
});
|
|
911
909
|
}
|
|
@@ -951,7 +949,7 @@ export {
|
|
|
951
949
|
canReusePendingAuthLink,
|
|
952
950
|
getConversationPendingAuth,
|
|
953
951
|
clearPendingAuth,
|
|
954
|
-
|
|
952
|
+
abandonReplacedPendingAuth,
|
|
955
953
|
isPendingAuthLatestRequest,
|
|
956
954
|
coerceThreadArtifactsState,
|
|
957
955
|
mergeArtifactsState,
|
|
@@ -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,
|