@sentry/junior 0.104.2 → 0.106.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-EOFSY2PD.js → agent-hooks-KR5BCWOK.js} +5 -5
- package/dist/api/conversations/schema.d.ts +13 -0
- package/dist/api/schema.d.ts +1 -1
- package/dist/api/schema.js +1 -1
- package/dist/api.js +76 -39
- package/dist/app.js +68 -17
- package/dist/chat/agent/request.d.ts +9 -0
- package/dist/chat/agent-dispatch/types.d.ts +2 -1
- package/dist/chat/config.d.ts +1 -0
- package/dist/chat/no-reply.d.ts +0 -2
- package/dist/chat/services/turn-limit.d.ts +6 -0
- package/dist/chat/services/turn-session-record.d.ts +0 -1
- package/dist/chat/slack/action-token.d.ts +6 -0
- package/dist/chat/slack/tools/public-search.d.ts +74 -0
- package/dist/chat/tools/definition.d.ts +2 -0
- package/dist/chat/tools/index.d.ts +2 -2
- package/dist/chat/tools/types.d.ts +3 -0
- package/dist/{chunk-CCTCIISK.js → chunk-3MPPVPGZ.js} +1 -1
- package/dist/{chunk-7G4J3CR7.js → chunk-3NYUCBLE.js} +1 -1
- package/dist/{chunk-U26ZWZCN.js → chunk-3OUSJPR7.js} +1 -1
- package/dist/{chunk-M3UAVLEN.js → chunk-4UYIRWDW.js} +2 -0
- package/dist/{chunk-QVTVCJR4.js → chunk-4W4O4DCV.js} +7 -7
- package/dist/{chunk-4PDVOHXP.js → chunk-AZ5OMSN5.js} +1 -1
- package/dist/{chunk-RMZ65YAA.js → chunk-BKM4UXUD.js} +21 -6
- package/dist/{chunk-AIRE7Q2W.js → chunk-CCFROYAV.js} +7 -0
- package/dist/{chunk-QDKRE3LS.js → chunk-DDRQ4U7I.js} +3 -3
- package/dist/{chunk-TMWUGGSA.js → chunk-GPPUTY5M.js} +327 -187
- package/dist/{chunk-RYDF4GOX.js → chunk-P4P7O5WG.js} +3 -3
- package/dist/{chunk-O7ILGCMJ.js → chunk-R5BFYK2O.js} +1 -1
- package/dist/{chunk-BCULHGZK.js → chunk-XTKJPSMF.js} +1 -1
- package/dist/{chunk-VDHMFCDY.js → chunk-ZMRLBBD5.js} +4 -4
- package/dist/cli/chat.js +13 -13
- package/dist/cli/plugins.js +5 -5
- package/dist/cli/snapshot-warmup.js +2 -2
- package/dist/cli/upgrade.js +6 -6
- package/dist/{db-PDMC67T3.js → db-S33LFWG2.js} +2 -2
- package/dist/{legacy-import-G333RHJZ.js → legacy-import-TMJISRKO.js} +3 -3
- package/dist/{runner-6A7MQRUE.js → runner-HA5XAL6K.js} +9 -9
- package/package.json +6 -6
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DispatchOptions, Source, SlackDestination } from "@sentry/junior-plugin-api";
|
|
1
|
+
import type { DispatchOptions, DestinationVisibility, Source, SlackDestination } from "@sentry/junior-plugin-api";
|
|
2
2
|
import type { CredentialSubject, CredentialSystemActor } from "@/chat/credentials/context";
|
|
3
3
|
export type DispatchStatus = "pending" | "running" | "awaiting_resume" | "completed" | "failed" | "blocked";
|
|
4
4
|
export type SlackDispatchOptions = Omit<DispatchOptions, "destination"> & {
|
|
@@ -13,6 +13,7 @@ export interface DispatchRecord {
|
|
|
13
13
|
createdAtMs: number;
|
|
14
14
|
credentialSubject?: CredentialSubject;
|
|
15
15
|
destination: SlackDestination;
|
|
16
|
+
destinationVisibility: DestinationVisibility;
|
|
16
17
|
errorMessage?: string;
|
|
17
18
|
id: string;
|
|
18
19
|
idempotencyKey: string;
|
package/dist/chat/config.d.ts
CHANGED
package/dist/chat/no-reply.d.ts
CHANGED
|
@@ -3,5 +3,3 @@ export declare const NO_REPLY_MARKER = "[[NO_REPLY]]";
|
|
|
3
3
|
export declare function isNoReplyMarker(text: string): boolean;
|
|
4
4
|
/** Detect marker leaks before publication strips or rejects them. */
|
|
5
5
|
export declare function containsNoReplyMarker(text: string): boolean;
|
|
6
|
-
/** Remove the reserved marker from mixed assistant text so it is never shown to users. */
|
|
7
|
-
export declare function stripNoReplyMarker(text: string): string;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Terminal failure raised when one agent turn exhausts its slice budget. */
|
|
2
|
+
export declare class TurnSliceLimitExceededError extends Error {
|
|
3
|
+
constructor(maxSlices: number);
|
|
4
|
+
}
|
|
5
|
+
/** Explain a terminal turn execution limit with actionable recovery guidance. */
|
|
6
|
+
export declare function buildTurnLimitResponse(eventId: string): string;
|
|
@@ -4,7 +4,6 @@ import type { Destination, Actor, Source } from "@sentry/junior-plugin-api";
|
|
|
4
4
|
import type { PiMessage } from "@/chat/pi/messages";
|
|
5
5
|
import type { PiMessageProvenance } from "@/chat/state/session-log";
|
|
6
6
|
import { type AgentTurnUsage } from "@/chat/usage";
|
|
7
|
-
export declare const AGENT_CONTINUE_MAX_SLICES = 48;
|
|
8
7
|
export interface TurnSessionContext {
|
|
9
8
|
conversationId?: string;
|
|
10
9
|
sessionId?: string;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
declare const slackActionTokenSchema: z.core.$ZodBranded<z.ZodString, "SlackActionToken", "out">;
|
|
3
|
+
export type SlackActionToken = z.output<typeof slackActionTokenSchema>;
|
|
4
|
+
/** Parse the ephemeral search token from an untrusted Slack message envelope. */
|
|
5
|
+
export declare function readSlackActionToken(message: unknown): SlackActionToken | undefined;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { SlackActionToken } from "@/chat/slack/action-token";
|
|
2
|
+
/** Create an interactive, public-channel-only Slack search tool. */
|
|
3
|
+
export declare function createSlackPublicSearchTool(actionToken: SlackActionToken): Omit<import("../../tools/definition").AnyToolDefinition, "inputSchema" | "outputSchema" | "prepareArguments" | "execute"> & {
|
|
4
|
+
inputSchema: import("../../tools/definition").JsonSchemaObject;
|
|
5
|
+
outputSchema: import("../../tools/definition").JsonSchemaObject;
|
|
6
|
+
prepareArguments(args: unknown): {
|
|
7
|
+
query: string;
|
|
8
|
+
after?: number | undefined;
|
|
9
|
+
before?: number | undefined;
|
|
10
|
+
cursor?: string | undefined;
|
|
11
|
+
limit?: number | undefined;
|
|
12
|
+
sort?: "timestamp" | "score" | undefined;
|
|
13
|
+
sort_dir?: "asc" | "desc" | undefined;
|
|
14
|
+
};
|
|
15
|
+
execute?: ((input: unknown, options: import("../../tools/definition").ToolExecuteOptions) => {
|
|
16
|
+
[x: string]: unknown;
|
|
17
|
+
ok: boolean;
|
|
18
|
+
status: "error" | "success";
|
|
19
|
+
query: string;
|
|
20
|
+
count: number;
|
|
21
|
+
messages: {
|
|
22
|
+
channel_id: string;
|
|
23
|
+
message_ts: string;
|
|
24
|
+
content: string;
|
|
25
|
+
permalink: string;
|
|
26
|
+
author_name?: string | undefined;
|
|
27
|
+
author_user_id?: string | undefined;
|
|
28
|
+
channel_name?: string | undefined;
|
|
29
|
+
is_author_bot?: boolean | undefined;
|
|
30
|
+
}[];
|
|
31
|
+
target?: string | undefined;
|
|
32
|
+
data?: unknown;
|
|
33
|
+
truncated?: boolean | undefined;
|
|
34
|
+
continuation?: {
|
|
35
|
+
arguments: Record<string, unknown>;
|
|
36
|
+
reason?: string | undefined;
|
|
37
|
+
} | undefined;
|
|
38
|
+
error?: string | {
|
|
39
|
+
kind: string;
|
|
40
|
+
message: string;
|
|
41
|
+
retryable?: boolean | undefined;
|
|
42
|
+
} | undefined;
|
|
43
|
+
next_cursor?: string | undefined;
|
|
44
|
+
} | Promise<{
|
|
45
|
+
[x: string]: unknown;
|
|
46
|
+
ok: boolean;
|
|
47
|
+
status: "error" | "success";
|
|
48
|
+
query: string;
|
|
49
|
+
count: number;
|
|
50
|
+
messages: {
|
|
51
|
+
channel_id: string;
|
|
52
|
+
message_ts: string;
|
|
53
|
+
content: string;
|
|
54
|
+
permalink: string;
|
|
55
|
+
author_name?: string | undefined;
|
|
56
|
+
author_user_id?: string | undefined;
|
|
57
|
+
channel_name?: string | undefined;
|
|
58
|
+
is_author_bot?: boolean | undefined;
|
|
59
|
+
}[];
|
|
60
|
+
target?: string | undefined;
|
|
61
|
+
data?: unknown;
|
|
62
|
+
truncated?: boolean | undefined;
|
|
63
|
+
continuation?: {
|
|
64
|
+
arguments: Record<string, unknown>;
|
|
65
|
+
reason?: string | undefined;
|
|
66
|
+
} | undefined;
|
|
67
|
+
error?: string | {
|
|
68
|
+
kind: string;
|
|
69
|
+
message: string;
|
|
70
|
+
retryable?: boolean | undefined;
|
|
71
|
+
} | undefined;
|
|
72
|
+
next_cursor?: string | undefined;
|
|
73
|
+
}>) | undefined;
|
|
74
|
+
};
|
|
@@ -89,6 +89,8 @@ export interface AnyToolDefinition {
|
|
|
89
89
|
execute?(input: unknown, options: ToolExecuteOptions): Promise<unknown> | unknown;
|
|
90
90
|
prepareArguments?(args: unknown): unknown;
|
|
91
91
|
}
|
|
92
|
+
/** Name-indexed heterogeneous tool definitions accepted by the agent runtime. */
|
|
93
|
+
export type ToolRegistry = Record<string, AnyToolDefinition>;
|
|
92
94
|
/** Distinguish legacy TypeBox schemas from JSON Schema projected from Zod. */
|
|
93
95
|
export declare function isTypeBoxInputSchema(schema: ToolInputSchema): schema is TSchema;
|
|
94
96
|
/** Infer execute parameter types from the inputSchema via generic binding. */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { SkillMetadata } from "@/chat/skills";
|
|
2
|
-
import type {
|
|
2
|
+
import type { ToolRegistry } from "@/chat/tools/definition";
|
|
3
3
|
import type { ToolHooks, ToolRuntimeContext } from "@/chat/tools/types";
|
|
4
4
|
export type { ToolHooks, ToolRuntimeContext };
|
|
5
5
|
/** Build the model-facing tool registry from runtime-owned context and capabilities. */
|
|
6
|
-
export declare function createTools(availableSkills: SkillMetadata[], hooks: ToolHooks | undefined, context: ToolRuntimeContext):
|
|
6
|
+
export declare function createTools(availableSkills: SkillMetadata[], hooks: ToolHooks | undefined, context: ToolRuntimeContext): ToolRegistry;
|
|
@@ -8,6 +8,7 @@ import type { Skill } from "@/chat/skills";
|
|
|
8
8
|
import type { LoadSkillMetadata } from "@/chat/tools/skill/load-skill";
|
|
9
9
|
import type { JuniorToolResult } from "@/chat/tool-support/structured-result";
|
|
10
10
|
import type { LocalActor, Actor, SlackActor } from "@/chat/actor";
|
|
11
|
+
import type { SlackActionToken } from "@/chat/slack/action-token";
|
|
11
12
|
import type { ModelProfile } from "@/chat/model-profile";
|
|
12
13
|
interface HandoffControl {
|
|
13
14
|
/** Non-empty catalog with the default target first. */
|
|
@@ -77,12 +78,14 @@ interface SlackToolRuntimeContext extends BaseToolRuntimeContext {
|
|
|
77
78
|
destination: SlackDestination;
|
|
78
79
|
actor?: SlackActor;
|
|
79
80
|
source: SlackSource;
|
|
81
|
+
slackActionToken?: SlackActionToken;
|
|
80
82
|
}
|
|
81
83
|
interface LocalToolRuntimeContext extends BaseToolRuntimeContext {
|
|
82
84
|
destination: LocalDestination;
|
|
83
85
|
actor?: LocalActor;
|
|
84
86
|
source: LocalSource;
|
|
85
87
|
slack?: never;
|
|
88
|
+
slackActionToken?: never;
|
|
86
89
|
}
|
|
87
90
|
export type ToolRuntimeContext = LocalToolRuntimeContext | SlackToolRuntimeContext;
|
|
88
91
|
export interface ToolState {
|
|
@@ -596,6 +596,7 @@ function modelIdForProfile(config, profile) {
|
|
|
596
596
|
// src/chat/config.ts
|
|
597
597
|
var MIN_AGENT_TURN_TIMEOUT_MS = 10 * 1e3;
|
|
598
598
|
var DEFAULT_AGENT_TURN_TIMEOUT_MS = 12 * 60 * 1e3;
|
|
599
|
+
var MAX_SLICES_PER_TURN = 100;
|
|
599
600
|
var DEFAULT_FUNCTION_MAX_DURATION_SECONDS = 300;
|
|
600
601
|
var DEFAULT_SLACK_SLASH_COMMAND = "/jr";
|
|
601
602
|
var DEFAULT_PROCESSING_REACTION_EMOJI = "eyes";
|
|
@@ -767,6 +768,7 @@ function readBotConfig(env) {
|
|
|
767
768
|
embeddingModelId: validateEmbeddingModelId(env.AI_EMBEDDING_MODEL) ?? DEFAULT_EMBEDDING_MODEL_ID,
|
|
768
769
|
loadingMessages: parseLoadingMessages(env.JUNIOR_LOADING_MESSAGES),
|
|
769
770
|
visionModelId: validateGatewayModelId(env.AI_VISION_MODEL),
|
|
771
|
+
maxSlicesPerTurn: MAX_SLICES_PER_TURN,
|
|
770
772
|
turnTimeoutMs: parseAgentTurnTimeoutMs(
|
|
771
773
|
env.AGENT_TURN_TIMEOUT_MS,
|
|
772
774
|
maxTurnTimeoutMs
|
|
@@ -9,13 +9,13 @@ import {
|
|
|
9
9
|
getPersistedThreadState,
|
|
10
10
|
markTurnCompleted,
|
|
11
11
|
mergeArtifactsState
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-BKM4UXUD.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-DDRQ4U7I.js";
|
|
19
19
|
import {
|
|
20
20
|
generateConversationId,
|
|
21
21
|
hydrateConversationMessages,
|
|
@@ -23,19 +23,19 @@ import {
|
|
|
23
23
|
normalizeConversationText,
|
|
24
24
|
updateConversationStats,
|
|
25
25
|
upsertConversationMessage
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-P4P7O5WG.js";
|
|
27
27
|
import {
|
|
28
28
|
createPluginEmbedder,
|
|
29
29
|
createPluginModel,
|
|
30
30
|
getPlugins
|
|
31
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-ZMRLBBD5.js";
|
|
32
32
|
import {
|
|
33
33
|
createPluginLogger,
|
|
34
34
|
createPluginState
|
|
35
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-AZ5OMSN5.js";
|
|
36
36
|
import {
|
|
37
37
|
getDb
|
|
38
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-XTKJPSMF.js";
|
|
39
39
|
import {
|
|
40
40
|
botConfig,
|
|
41
41
|
getPiMessageRole,
|
|
@@ -45,7 +45,7 @@ import {
|
|
|
45
45
|
isToolResultMessage,
|
|
46
46
|
normalizeToolNameFromResult,
|
|
47
47
|
stripRuntimeTurnContext
|
|
48
|
-
} from "./chunk-
|
|
48
|
+
} from "./chunk-4UYIRWDW.js";
|
|
49
49
|
import {
|
|
50
50
|
buildTurnFailureResponse
|
|
51
51
|
} from "./chunk-AEWZ7F65.js";
|
|
@@ -7,18 +7,19 @@ import {
|
|
|
7
7
|
addAgentTurnUsage,
|
|
8
8
|
getAgentTurnSessionRecord,
|
|
9
9
|
upsertAgentTurnSessionRecord
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-DDRQ4U7I.js";
|
|
11
11
|
import {
|
|
12
12
|
persistConversationMessages
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-P4P7O5WG.js";
|
|
14
14
|
import {
|
|
15
15
|
sleep
|
|
16
16
|
} from "./chunk-4ZNGQH7C.js";
|
|
17
17
|
import {
|
|
18
|
+
botConfig,
|
|
18
19
|
getPiMessageRole,
|
|
19
20
|
getStateAdapter,
|
|
20
21
|
trimTrailingAssistantMessages
|
|
21
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-4UYIRWDW.js";
|
|
22
23
|
import {
|
|
23
24
|
getActiveTraceId,
|
|
24
25
|
logException
|
|
@@ -112,8 +113,18 @@ async function persistWithRetry(persist) {
|
|
|
112
113
|
throw lastError;
|
|
113
114
|
}
|
|
114
115
|
|
|
116
|
+
// src/chat/services/turn-limit.ts
|
|
117
|
+
var TurnSliceLimitExceededError = class extends Error {
|
|
118
|
+
constructor(maxSlices) {
|
|
119
|
+
super(`Agent turn exceeded execution limit (${maxSlices} slices)`);
|
|
120
|
+
this.name = "TurnSliceLimitExceededError";
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
function buildTurnLimitResponse(eventId) {
|
|
124
|
+
return `I couldn't finish this request because this turn reached its execution limit. Please try again with a smaller or more specific request. Reference: \`event_id=${eventId}\`.`;
|
|
125
|
+
}
|
|
126
|
+
|
|
115
127
|
// src/chat/services/turn-session-record.ts
|
|
116
|
-
var AGENT_CONTINUE_MAX_SLICES = 48;
|
|
117
128
|
function logSessionRecordError(error, eventName, args, attributes, message) {
|
|
118
129
|
logException(
|
|
119
130
|
error,
|
|
@@ -362,7 +373,7 @@ async function persistTimeoutSessionRecord(args) {
|
|
|
362
373
|
latestSessionRecord?.cumulativeUsage,
|
|
363
374
|
args.currentUsage
|
|
364
375
|
);
|
|
365
|
-
if (nextSliceId >
|
|
376
|
+
if (nextSliceId > botConfig.maxSlicesPerTurn) {
|
|
366
377
|
return await upsertAgentTurnSessionRecord({
|
|
367
378
|
...args.channelName ?? latestSessionRecord?.channelName ? {
|
|
368
379
|
channelName: args.channelName ?? latestSessionRecord?.channelName
|
|
@@ -386,7 +397,9 @@ async function persistTimeoutSessionRecord(args) {
|
|
|
386
397
|
} : {},
|
|
387
398
|
resumeReason: "timeout",
|
|
388
399
|
resumedFromSliceId: latestSessionRecord?.resumedFromSliceId,
|
|
389
|
-
errorMessage:
|
|
400
|
+
errorMessage: new TurnSliceLimitExceededError(
|
|
401
|
+
botConfig.maxSlicesPerTurn
|
|
402
|
+
).message,
|
|
390
403
|
...args.actor ?? latestSessionRecord?.actor ? { actor: args.actor ?? latestSessionRecord?.actor } : {},
|
|
391
404
|
...getActiveTraceId() ?? latestSessionRecord?.traceId ? { traceId: getActiveTraceId() ?? latestSessionRecord?.traceId } : {}
|
|
392
405
|
});
|
|
@@ -938,6 +951,8 @@ export {
|
|
|
938
951
|
markTurnCompleted,
|
|
939
952
|
markTurnFailed,
|
|
940
953
|
persistWithRetry,
|
|
954
|
+
TurnSliceLimitExceededError,
|
|
955
|
+
buildTurnLimitResponse,
|
|
941
956
|
loadTurnSessionRecord,
|
|
942
957
|
persistRunningSessionRecord,
|
|
943
958
|
persistCompletedSessionRecord,
|
|
@@ -225,12 +225,19 @@ var conversationStatsItemSchema = z2.object({
|
|
|
225
225
|
costUsd: z2.number().optional(),
|
|
226
226
|
tokens: z2.number().optional()
|
|
227
227
|
}).strict();
|
|
228
|
+
var conversationMetricDaySchema = z2.object({
|
|
229
|
+
costUsd: z2.number().optional(),
|
|
230
|
+
date: z2.string(),
|
|
231
|
+
durationMs: z2.number(),
|
|
232
|
+
tokens: z2.number().optional()
|
|
233
|
+
}).strict();
|
|
228
234
|
var conversationStatsReportSchema = z2.object({
|
|
229
235
|
active: z2.number(),
|
|
230
236
|
conversations: z2.number(),
|
|
231
237
|
durationMs: z2.number(),
|
|
232
238
|
failed: z2.number(),
|
|
233
239
|
generatedAt: z2.string(),
|
|
240
|
+
metricDays: z2.array(conversationMetricDaySchema),
|
|
234
241
|
locations: z2.array(conversationStatsItemSchema),
|
|
235
242
|
actors: z2.array(conversationStatsItemSchema),
|
|
236
243
|
source: z2.literal("conversation_index"),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ensureLegacyConversationImport
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-P4P7O5WG.js";
|
|
4
4
|
import {
|
|
5
5
|
usageSchema
|
|
6
6
|
} from "./chunk-PDO5BLNM.js";
|
|
@@ -10,10 +10,10 @@ import {
|
|
|
10
10
|
getConversationStore,
|
|
11
11
|
instructionActors,
|
|
12
12
|
instructionProvenanceFor
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-XTKJPSMF.js";
|
|
14
14
|
import {
|
|
15
15
|
getStateAdapter
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-4UYIRWDW.js";
|
|
17
17
|
import {
|
|
18
18
|
logWarn,
|
|
19
19
|
toStoredSlackActor
|