@sentry/junior 0.116.1 → 0.118.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-GUAAS3XH.js → agent-hooks-J2FB7XD6.js} +8 -10
- package/dist/api/conversations/detail.d.ts +7 -0
- package/dist/api/conversations/event-list.d.ts +7 -0
- package/dist/api/conversations/events.d.ts +1 -1
- package/dist/api/schema/conversation.d.ts +28 -0
- package/dist/api/schema/stats.d.ts +22 -0
- package/dist/api/schema.d.ts +2 -0
- package/dist/api/schema.js +7 -3
- package/dist/api/stats.d.ts +16 -0
- package/dist/api/user-pages/routes.d.ts +4 -0
- package/dist/api.js +192 -18
- package/dist/app.js +53 -46
- package/dist/{catalog-runtime-WMPC4J4U.js → catalog-runtime-UHHLU53I.js} +5 -5
- package/dist/chat/agent/prompt.d.ts +6 -2
- package/dist/chat/agent/request.d.ts +2 -1
- package/dist/chat/agent/resume.d.ts +2 -0
- package/dist/chat/agent/tools.d.ts +1 -0
- package/dist/chat/conversations/history.d.ts +22 -1
- package/dist/chat/conversations/projection.d.ts +6 -0
- package/dist/chat/mcp/client.d.ts +4 -0
- package/dist/chat/mcp/errors.d.ts +22 -1
- package/dist/chat/oauth-response.d.ts +21 -0
- package/dist/chat/plugins/prompt.d.ts +9 -0
- package/dist/chat/plugins/types.d.ts +2 -21
- package/dist/chat/plugins/user-pages.d.ts +15 -0
- package/dist/chat/plugins/viewer-actors.d.ts +6 -0
- package/dist/chat/prompt.d.ts +1 -2
- package/dist/chat/sandbox/paths.d.ts +2 -0
- package/dist/chat/sandbox/sandbox.d.ts +3 -1
- package/dist/chat/sandbox/snapshot/install.d.ts +6 -0
- package/dist/chat/sandbox/snapshot/profile.d.ts +14 -0
- package/dist/chat/sandbox/snapshot/resolve.d.ts +22 -0
- package/dist/chat/sandbox/snapshot/span.d.ts +2 -0
- package/dist/chat/sandbox/workspace.d.ts +1 -0
- package/dist/chat/services/context-compaction-marker.d.ts +1 -0
- package/dist/chat/services/turn-session-record.d.ts +2 -0
- package/dist/chat/skills.d.ts +1 -2
- package/dist/chat/state/turn-session.d.ts +2 -0
- package/dist/chat/tools/index.d.ts +4 -1
- package/dist/chat/tools/query-conversation-events.d.ts +1 -1
- package/dist/chat/tools/sandbox/file-utils.d.ts +11 -0
- package/dist/chat/tools/sandbox/find-files.d.ts +2 -1
- package/dist/chat/tools/sandbox/grep.d.ts +2 -1
- package/dist/chat/tools/sandbox/view-image.d.ts +11 -0
- package/dist/chat/tools/types.d.ts +7 -0
- package/dist/{chunk-XA3VLFPK.js → chunk-3LGCVRBQ.js} +154 -20
- package/dist/{chunk-JPKGW6L6.js → chunk-3MUSSFMP.js} +78 -39
- package/dist/{chunk-7CSVG54J.js → chunk-3N3FMCKN.js} +30 -2
- package/dist/{chunk-VBMMMVVQ.js → chunk-4LPPH7Y6.js} +405 -446
- package/dist/{chunk-2YYPXQNQ.js → chunk-4SOQPUF4.js} +1 -1
- package/dist/{chunk-H35BDAUS.js → chunk-6BGUAOYP.js} +8 -8
- package/dist/{chunk-GDAXWEIJ.js → chunk-6K2QE2UI.js} +731 -424
- package/dist/{chunk-DLLW5ITL.js → chunk-7GADTCNS.js} +30 -9
- package/dist/{chunk-TC4ZEM2D.js → chunk-7SM3P4XR.js} +28 -1
- package/dist/{chunk-WKU7TY22.js → chunk-FIANEE7Z.js} +3 -1
- package/dist/{chunk-RXRQJF7Y.js → chunk-GCGJGSQL.js} +21 -0
- package/dist/{chunk-ZYHLNTC2.js → chunk-GT2ZUALJ.js} +584 -25
- package/dist/{chunk-KNCELO2M.js → chunk-HN6LFYG3.js} +1 -1
- package/dist/{chunk-N3C4XCRE.js → chunk-HWUBBHLK.js} +1 -1
- package/dist/{chunk-BFYVIOTS.js → chunk-KC5EE27Y.js} +13 -3
- package/dist/chunk-L72GDKSN.js +37 -0
- package/dist/{chunk-F3SWGSPG.js → chunk-MLZFK4KP.js} +1 -1
- package/dist/{chunk-RYFAVWP3.js → chunk-PJPKHGLG.js} +34 -15
- package/dist/{chunk-CY7NXM32.js → chunk-PWRFTDTY.js} +4 -2
- package/dist/{chunk-WLT72MRP.js → chunk-QWCF4RAC.js} +1 -1
- package/dist/{chunk-CGXLCMWI.js → chunk-S6R23MFB.js} +117 -17
- package/dist/{chunk-OY2PQQ4P.js → chunk-UXLYAVYL.js} +1 -1
- package/dist/cli/chat.js +23 -24
- package/dist/cli/check.js +6 -6
- package/dist/cli/main.js +1 -1
- package/dist/cli/plugins.js +12 -14
- package/dist/cli/{snapshot-warmup.js → snapshot-create.js} +17 -20
- package/dist/cli/upgrade.js +7 -7
- package/dist/db/schema/stats.d.ts +93 -0
- package/dist/db/schema.d.ts +94 -1
- package/dist/{db-FH4R5ZQ4.js → db-PMRHFSYL.js} +6 -6
- package/dist/handlers/oauth-html.d.ts +4 -2
- package/dist/instrumentation.js +2 -2
- package/dist/nitro.js +3 -3
- package/dist/{oauth-callback-server-C2SSJ3FQ.js → oauth-callback-server-QJUC7S4X.js} +15 -17
- package/dist/{plugins-IUJA4VBU.js → plugins-HW4VWW6G.js} +1 -1
- package/dist/{runner-NAALFIXM.js → runner-PZMV6JQW.js} +10 -12
- package/dist/{skills-UN2JXYYF.js → skills-W4JETYSV.js} +6 -6
- package/dist/stats.d.ts +18 -0
- package/dist/{validation-EEF4ROHR.js → validation-IJLNHZSU.js} +6 -6
- package/dist/version.js +1 -1
- package/migrations/0011_sour_golden_guardian.sql +8 -0
- package/migrations/meta/0011_snapshot.json +1195 -0
- package/migrations/meta/_journal.json +8 -1
- package/package.json +5 -5
- package/dist/chat/sandbox/runtime-dependency-snapshots.d.ts +0 -20
- package/dist/chunk-4ZNGQH7C.js +0 -25
- package/dist/chunk-FAEALXEH.js +0 -517
|
@@ -4,18 +4,18 @@ import {
|
|
|
4
4
|
juniorConversations,
|
|
5
5
|
juniorIdentities,
|
|
6
6
|
juniorUsers
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-GCGJGSQL.js";
|
|
8
8
|
import {
|
|
9
9
|
TURN_REASONING_LEVELS,
|
|
10
10
|
getChatConfig,
|
|
11
11
|
modelProfileSchema
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-PWRFTDTY.js";
|
|
13
13
|
import {
|
|
14
14
|
juniorDestinations
|
|
15
15
|
} from "./chunk-VFUK3X5B.js";
|
|
16
16
|
import {
|
|
17
17
|
normalizeIdentityEmail
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-MLZFK4KP.js";
|
|
19
19
|
import {
|
|
20
20
|
parseSlackChannelReferenceId,
|
|
21
21
|
parseSlackTeamId
|
|
@@ -943,6 +943,14 @@ var turnRoutedEventDataSchema = z2.object({
|
|
|
943
943
|
confidence: z2.number().min(0).max(1).optional(),
|
|
944
944
|
source: z2.enum(["configured", "inherited", "router"])
|
|
945
945
|
}).strict();
|
|
946
|
+
var turnContextEventDataSchema = z2.object({
|
|
947
|
+
type: z2.literal("turn_context"),
|
|
948
|
+
turnId: z2.string().min(1),
|
|
949
|
+
pluginName: z2.string().min(1),
|
|
950
|
+
kind: z2.string().min(1).max(64),
|
|
951
|
+
version: z2.number().int().positive(),
|
|
952
|
+
content: z2.record(z2.string(), z2.unknown())
|
|
953
|
+
}).strict();
|
|
946
954
|
var turnCompletedEventDataSchema = z2.object({
|
|
947
955
|
type: z2.literal("turn_completed"),
|
|
948
956
|
turnId: z2.string().min(1),
|
|
@@ -984,6 +992,7 @@ var appendableConversationEventDataSchema = z2.union([
|
|
|
984
992
|
messageHandledEventDataSchema,
|
|
985
993
|
messagesSummarizedEventDataSchema,
|
|
986
994
|
turnStartedEventDataSchema,
|
|
995
|
+
turnContextEventDataSchema,
|
|
987
996
|
turnRoutedEventDataSchema,
|
|
988
997
|
turnCompletedEventDataSchema,
|
|
989
998
|
turnFailedEventDataSchema,
|
|
@@ -1007,6 +1016,7 @@ var KNOWN_CONVERSATION_EVENT_TYPES = [
|
|
|
1007
1016
|
"message_handled",
|
|
1008
1017
|
"messages_summarized",
|
|
1009
1018
|
"turn_started",
|
|
1019
|
+
"turn_context",
|
|
1010
1020
|
"turn_routed",
|
|
1011
1021
|
"turn_completed",
|
|
1012
1022
|
"turn_failed",
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getDb
|
|
3
|
+
} from "./chunk-KC5EE27Y.js";
|
|
4
|
+
import {
|
|
5
|
+
juniorStats
|
|
6
|
+
} from "./chunk-GCGJGSQL.js";
|
|
7
|
+
|
|
8
|
+
// src/stats.ts
|
|
9
|
+
import { and, asc, gte, lte, sql } from "drizzle-orm";
|
|
10
|
+
function utcDate(nowMs) {
|
|
11
|
+
return new Date(nowMs).toISOString().slice(0, 10);
|
|
12
|
+
}
|
|
13
|
+
async function incrementStat(key, options = {}) {
|
|
14
|
+
const date = utcDate(options.nowMs ?? Date.now());
|
|
15
|
+
await getDb().insert(juniorStats).values({ ...key, date, count: 1 }).onConflictDoUpdate({
|
|
16
|
+
target: [
|
|
17
|
+
juniorStats.date,
|
|
18
|
+
juniorStats.namespace,
|
|
19
|
+
juniorStats.metric,
|
|
20
|
+
juniorStats.name
|
|
21
|
+
],
|
|
22
|
+
set: { count: sql`${juniorStats.count} + 1` }
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
async function readStats(start, end) {
|
|
26
|
+
return await getDb().select().from(juniorStats).where(and(gte(juniorStats.date, start), lte(juniorStats.date, end))).orderBy(
|
|
27
|
+
asc(juniorStats.date),
|
|
28
|
+
asc(juniorStats.namespace),
|
|
29
|
+
asc(juniorStats.metric),
|
|
30
|
+
asc(juniorStats.name)
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export {
|
|
35
|
+
incrementStat,
|
|
36
|
+
readStats
|
|
37
|
+
};
|
|
@@ -2,9 +2,6 @@ import {
|
|
|
2
2
|
addAgentTurnUsage,
|
|
3
3
|
agentTurnUsageSchema
|
|
4
4
|
} from "./chunk-MU6HHZEN.js";
|
|
5
|
-
import {
|
|
6
|
-
getStateAdapter
|
|
7
|
-
} from "./chunk-7CSVG54J.js";
|
|
8
5
|
import {
|
|
9
6
|
agentHistoryItemSchema,
|
|
10
7
|
contextProvenance,
|
|
@@ -16,16 +13,17 @@ import {
|
|
|
16
13
|
instructionProvenanceFor,
|
|
17
14
|
sanitizePostgresJson,
|
|
18
15
|
withConversationEventLock
|
|
19
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-KC5EE27Y.js";
|
|
20
17
|
import {
|
|
18
|
+
getStateAdapter,
|
|
21
19
|
sleep
|
|
22
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-3N3FMCKN.js";
|
|
23
21
|
import {
|
|
24
22
|
botConfig,
|
|
25
23
|
escapeXml,
|
|
26
24
|
resolveGatewayModel,
|
|
27
25
|
unwrapCurrentInstruction
|
|
28
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-PWRFTDTY.js";
|
|
29
27
|
import {
|
|
30
28
|
toStoredSlackActor
|
|
31
29
|
} from "./chunk-HZF5P5UN.js";
|
|
@@ -34,7 +32,7 @@ import {
|
|
|
34
32
|
logException,
|
|
35
33
|
logWarn,
|
|
36
34
|
setSpanAttributes
|
|
37
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-MLZFK4KP.js";
|
|
38
36
|
import {
|
|
39
37
|
isRecord,
|
|
40
38
|
toOptionalNumber,
|
|
@@ -412,16 +410,29 @@ async function commitMessagesLocked(args, executor) {
|
|
|
412
410
|
});
|
|
413
411
|
if (matchingPrefix === current.messages.length) {
|
|
414
412
|
const newMessages = nextLocalMessages.slice(matchingPrefix);
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
413
|
+
const turnContext = args.turnContext;
|
|
414
|
+
const turnContextEvents = turnContext?.contexts.map((context, index) => ({
|
|
415
|
+
idempotencyKey: `turn:${turnContext.turnId}:context:${context.pluginName}:${index}`,
|
|
416
|
+
createdAtMs: context.loadedAtMs,
|
|
417
|
+
data: {
|
|
418
|
+
type: "turn_context",
|
|
419
|
+
turnId: turnContext.turnId,
|
|
420
|
+
pluginName: context.pluginName,
|
|
421
|
+
kind: context.kind,
|
|
422
|
+
version: context.version,
|
|
423
|
+
content: context.content
|
|
424
|
+
}
|
|
425
|
+
})) ?? [];
|
|
426
|
+
await eventStore.append(args.conversationId, [
|
|
427
|
+
...newMessages.map((message, index) => ({
|
|
418
428
|
data: historyItemFromPiMessage(
|
|
419
429
|
message,
|
|
420
430
|
nextLocalProvenance[matchingPrefix + index]
|
|
421
431
|
),
|
|
422
432
|
createdAtMs: messageTimestamp(message)
|
|
423
|
-
}))
|
|
424
|
-
|
|
433
|
+
})),
|
|
434
|
+
...turnContextEvents
|
|
435
|
+
]);
|
|
425
436
|
} else {
|
|
426
437
|
throw new Error(
|
|
427
438
|
`Agent history for ${args.conversationId} changed before its committed boundary`
|
|
@@ -818,6 +829,7 @@ function materializeAgentTurnSessionRecord(stored, piProjection, turnStartMessag
|
|
|
818
829
|
function restoreRuntimeContext(messages, runtimeContext) {
|
|
819
830
|
if (!runtimeContext || runtimeContext.length === 0) return messages;
|
|
820
831
|
const restored = [...messages];
|
|
832
|
+
const unmatchedRuntimeContext = [];
|
|
821
833
|
for (const runtimeMessage of runtimeContext) {
|
|
822
834
|
const runtime = runtimeMessage;
|
|
823
835
|
const targetIndex = restored.findIndex((message) => {
|
|
@@ -825,7 +837,7 @@ function restoreRuntimeContext(messages, runtimeContext) {
|
|
|
825
837
|
return candidate.role === "user" && candidate.timestamp === runtime.timestamp;
|
|
826
838
|
});
|
|
827
839
|
if (targetIndex < 0) {
|
|
828
|
-
|
|
840
|
+
unmatchedRuntimeContext.push(runtimeMessage);
|
|
829
841
|
continue;
|
|
830
842
|
}
|
|
831
843
|
const target = restored[targetIndex];
|
|
@@ -837,7 +849,7 @@ function restoreRuntimeContext(messages, runtimeContext) {
|
|
|
837
849
|
]
|
|
838
850
|
};
|
|
839
851
|
}
|
|
840
|
-
return restored;
|
|
852
|
+
return [...unmatchedRuntimeContext, ...restored];
|
|
841
853
|
}
|
|
842
854
|
async function getStoredAgentTurnSessionRecord(conversationId, sessionId) {
|
|
843
855
|
const stateAdapter = getStateAdapter();
|
|
@@ -1022,7 +1034,13 @@ async function upsertAgentTurnSessionRecord(args) {
|
|
|
1022
1034
|
conversationId: args.conversationId,
|
|
1023
1035
|
messages: args.piMessages,
|
|
1024
1036
|
...instructionActor ? { newMessageProvenance: instructionProvenanceFor(instructionActor) } : {},
|
|
1025
|
-
...args.trailingMessageProvenance ? { trailingMessageProvenance: args.trailingMessageProvenance } : {}
|
|
1037
|
+
...args.trailingMessageProvenance ? { trailingMessageProvenance: args.trailingMessageProvenance } : {},
|
|
1038
|
+
...args.turnContexts && args.turnContexts.length > 0 ? {
|
|
1039
|
+
turnContext: {
|
|
1040
|
+
contexts: args.turnContexts,
|
|
1041
|
+
turnId: args.sessionId
|
|
1042
|
+
}
|
|
1043
|
+
} : {}
|
|
1026
1044
|
});
|
|
1027
1045
|
const durableTurnStartMessageIndex = args.turnStartMessageIndex === void 0 ? void 0 : stripRuntimeTurnContext(
|
|
1028
1046
|
args.piMessages.slice(0, args.turnStartMessageIndex)
|
|
@@ -1294,6 +1312,7 @@ async function persistRunningSessionRecord(args) {
|
|
|
1294
1312
|
...args.loadedSkillNames ? { loadedSkillNames: args.loadedSkillNames } : {},
|
|
1295
1313
|
modelId: args.modelId,
|
|
1296
1314
|
...args.reasoningLevel ? { reasoningLevel: args.reasoningLevel } : {},
|
|
1315
|
+
...args.turnContexts ? { turnContexts: args.turnContexts } : {},
|
|
1297
1316
|
...args.actor ?? latestSessionRecord?.actor ? { actor: args.actor ?? latestSessionRecord?.actor } : {},
|
|
1298
1317
|
...getActiveTraceId() ?? latestSessionRecord?.traceId ? { traceId: getActiveTraceId() ?? latestSessionRecord?.traceId } : {},
|
|
1299
1318
|
...(args.turnStartMessageIndex ?? latestSessionRecord?.turnStartMessageIndex) !== void 0 ? {
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
normalizeGenAiFinishReason,
|
|
13
13
|
serializeGenAiAttribute,
|
|
14
14
|
withSpan
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-MLZFK4KP.js";
|
|
16
16
|
|
|
17
17
|
// src/chat/config.ts
|
|
18
18
|
import { getModel as getModel2 } from "@earendil-works/pi-ai/compat";
|
|
@@ -272,10 +272,11 @@ function unwrapCurrentInstruction(text) {
|
|
|
272
272
|
|
|
273
273
|
// src/chat/services/context-compaction-marker.ts
|
|
274
274
|
var COMPACTION_SUMMARY_PREFIX = "Context compaction summary for future Junior turns:";
|
|
275
|
+
var ACTIVE_TURN_COMPACTION_SUMMARY_PREFIX = "Active-turn context checkpoint. If no newer user instruction follows this checkpoint, continue the same unfinished task now using the authoritative instructions above and this summary as internal continuation state. If a newer user instruction follows, treat this checkpoint as prior context and follow that newer instruction. Do not reply with a plan or summary solely because this checkpoint appeared:";
|
|
275
276
|
var MODEL_HANDOFF_SUMMARY_PREFIX = "Model handoff checkpoint. Continue the outstanding request now using this summary as the complete prior context:";
|
|
276
277
|
function isCompactionSummaryText(text) {
|
|
277
278
|
const normalized = (unwrapCurrentInstruction(text) ?? text).trimStart();
|
|
278
|
-
return normalized.startsWith(COMPACTION_SUMMARY_PREFIX) || normalized.startsWith(MODEL_HANDOFF_SUMMARY_PREFIX);
|
|
279
|
+
return normalized.startsWith(COMPACTION_SUMMARY_PREFIX) || normalized.startsWith(ACTIVE_TURN_COMPACTION_SUMMARY_PREFIX) || normalized.startsWith(MODEL_HANDOFF_SUMMARY_PREFIX);
|
|
279
280
|
}
|
|
280
281
|
function hasCompactedConversationContext(messages) {
|
|
281
282
|
return messages.some((message) => {
|
|
@@ -934,6 +935,7 @@ export {
|
|
|
934
935
|
renderCurrentInstruction,
|
|
935
936
|
unwrapCurrentInstruction,
|
|
936
937
|
COMPACTION_SUMMARY_PREFIX,
|
|
938
|
+
ACTIVE_TURN_COMPACTION_SUMMARY_PREFIX,
|
|
937
939
|
MODEL_HANDOFF_SUMMARY_PREFIX,
|
|
938
940
|
isCompactionSummaryText,
|
|
939
941
|
hasCompactedConversationContext,
|
|
@@ -1,38 +1,37 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getInterruptionMarker
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import {
|
|
5
|
-
createPluginLogger,
|
|
6
|
-
getPlugins
|
|
7
|
-
} from "./chunk-ZYHLNTC2.js";
|
|
8
|
-
import {
|
|
9
|
-
acquireActiveLock,
|
|
10
|
-
getStateAdapter
|
|
11
|
-
} from "./chunk-7CSVG54J.js";
|
|
3
|
+
} from "./chunk-PJPKHGLG.js";
|
|
12
4
|
import {
|
|
13
5
|
SlackActionError,
|
|
6
|
+
createPluginLogger,
|
|
7
|
+
getPlugins,
|
|
14
8
|
getSlackClient,
|
|
15
9
|
isDmChannel,
|
|
16
10
|
normalizeSlackConversationId,
|
|
17
11
|
withSlackRetries
|
|
18
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-GT2ZUALJ.js";
|
|
19
13
|
import {
|
|
20
14
|
getDb,
|
|
21
15
|
parseDestination
|
|
22
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-KC5EE27Y.js";
|
|
23
17
|
import {
|
|
18
|
+
acquireActiveLock,
|
|
19
|
+
getStateAdapter,
|
|
24
20
|
sleep
|
|
25
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-3N3FMCKN.js";
|
|
26
22
|
import {
|
|
27
23
|
normalizeSlackEmojiName
|
|
28
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-PWRFTDTY.js";
|
|
29
25
|
import {
|
|
30
26
|
pluginCatalogRuntime
|
|
31
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-UXLYAVYL.js";
|
|
28
|
+
import {
|
|
29
|
+
fetchWithBoundedOAuthErrorBodies
|
|
30
|
+
} from "./chunk-3LGCVRBQ.js";
|
|
32
31
|
import {
|
|
33
32
|
logInfo,
|
|
34
33
|
logWarn
|
|
35
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-MLZFK4KP.js";
|
|
36
35
|
import {
|
|
37
36
|
isRecord
|
|
38
37
|
} from "./chunk-OB42YVAE.js";
|
|
@@ -903,6 +902,79 @@ async function startOAuthFlow(provider, input) {
|
|
|
903
902
|
};
|
|
904
903
|
}
|
|
905
904
|
|
|
905
|
+
// src/chat/mcp/errors.ts
|
|
906
|
+
var McpProviderError = class extends Error {
|
|
907
|
+
phase;
|
|
908
|
+
provider;
|
|
909
|
+
missingSession;
|
|
910
|
+
resourceHost;
|
|
911
|
+
status;
|
|
912
|
+
constructor(details) {
|
|
913
|
+
super(`MCP provider ${details.phase.replace("_", " ")} failed`);
|
|
914
|
+
this.name = "McpProviderError";
|
|
915
|
+
this.phase = details.phase;
|
|
916
|
+
this.provider = details.provider;
|
|
917
|
+
this.missingSession = details.missingSession;
|
|
918
|
+
this.resourceHost = details.resourceHost;
|
|
919
|
+
this.status = details.status;
|
|
920
|
+
}
|
|
921
|
+
};
|
|
922
|
+
function providerStatus(error) {
|
|
923
|
+
if (!error || typeof error !== "object") {
|
|
924
|
+
return void 0;
|
|
925
|
+
}
|
|
926
|
+
const value = error;
|
|
927
|
+
const status = typeof value.status === "number" ? value.status : typeof value.code === "number" ? value.code : void 0;
|
|
928
|
+
return status !== void 0 && status >= 100 && status <= 599 ? status : void 0;
|
|
929
|
+
}
|
|
930
|
+
function toMcpProviderError(error, details) {
|
|
931
|
+
if (error instanceof McpProviderError) {
|
|
932
|
+
return error;
|
|
933
|
+
}
|
|
934
|
+
return new McpProviderError({
|
|
935
|
+
...details,
|
|
936
|
+
status: details.status ?? providerStatus(error)
|
|
937
|
+
});
|
|
938
|
+
}
|
|
939
|
+
function getMcpProviderErrorAttributes(error) {
|
|
940
|
+
if (!(error instanceof McpProviderError)) {
|
|
941
|
+
return {};
|
|
942
|
+
}
|
|
943
|
+
return {
|
|
944
|
+
"app.credential.provider": error.provider,
|
|
945
|
+
"app.mcp.error.phase": error.phase,
|
|
946
|
+
...error.status !== void 0 ? { "http.response.status_code": error.status } : {},
|
|
947
|
+
...error.resourceHost ? { "server.address": error.resourceHost } : {}
|
|
948
|
+
};
|
|
949
|
+
}
|
|
950
|
+
var McpToolError = class extends Error {
|
|
951
|
+
constructor(message) {
|
|
952
|
+
super(message);
|
|
953
|
+
this.name = "McpToolError";
|
|
954
|
+
}
|
|
955
|
+
};
|
|
956
|
+
function getMcpAwareErrorType(error, fallback) {
|
|
957
|
+
if (error instanceof McpToolError) {
|
|
958
|
+
return "tool_error";
|
|
959
|
+
}
|
|
960
|
+
if (error instanceof McpProviderError) {
|
|
961
|
+
return "mcp_provider_error";
|
|
962
|
+
}
|
|
963
|
+
return error instanceof Error ? error.name : fallback;
|
|
964
|
+
}
|
|
965
|
+
function getMcpAwareErrorMessage(error) {
|
|
966
|
+
return error instanceof Error ? error.message : String(error);
|
|
967
|
+
}
|
|
968
|
+
function getMcpAwareTelemetryMessage(error, _privacy) {
|
|
969
|
+
if (error instanceof McpToolError) {
|
|
970
|
+
return "MCP tool call failed";
|
|
971
|
+
}
|
|
972
|
+
if (error instanceof McpProviderError) {
|
|
973
|
+
return error.message;
|
|
974
|
+
}
|
|
975
|
+
return getMcpAwareErrorMessage(error);
|
|
976
|
+
}
|
|
977
|
+
|
|
906
978
|
// src/chat/mcp/auth-store.ts
|
|
907
979
|
import {
|
|
908
980
|
sourceSchema as sourceSchema2
|
|
@@ -1414,14 +1486,36 @@ async function finalizeMcpAuthorization(provider, authSessionId, authorizationCo
|
|
|
1414
1486
|
if (mcp.headers && Object.keys(mcp.headers).length > 0) {
|
|
1415
1487
|
requestInit.headers = new Headers(mcp.headers);
|
|
1416
1488
|
}
|
|
1489
|
+
let providerStatus2;
|
|
1417
1490
|
const transport = new StreamableHTTPClientTransport(new URL(mcp.url), {
|
|
1418
1491
|
...Object.keys(requestInit).length > 0 ? { requestInit } : {},
|
|
1419
|
-
authProvider
|
|
1492
|
+
authProvider,
|
|
1493
|
+
fetch: fetchWithBoundedOAuthErrorBodies(void 0, (status) => {
|
|
1494
|
+
providerStatus2 = status;
|
|
1495
|
+
})
|
|
1420
1496
|
});
|
|
1497
|
+
let failure;
|
|
1421
1498
|
try {
|
|
1422
1499
|
await transport.finishAuth(authorizationCode);
|
|
1423
|
-
}
|
|
1500
|
+
} catch (error) {
|
|
1501
|
+
failure = toMcpProviderError(error, {
|
|
1502
|
+
phase: "oauth_callback",
|
|
1503
|
+
provider,
|
|
1504
|
+
resourceHost: new URL(mcp.url).hostname,
|
|
1505
|
+
status: providerStatus2
|
|
1506
|
+
});
|
|
1507
|
+
}
|
|
1508
|
+
try {
|
|
1424
1509
|
await transport.close();
|
|
1510
|
+
} catch (error) {
|
|
1511
|
+
failure ??= toMcpProviderError(error, {
|
|
1512
|
+
phase: "oauth_callback",
|
|
1513
|
+
provider,
|
|
1514
|
+
resourceHost: new URL(mcp.url).hostname
|
|
1515
|
+
});
|
|
1516
|
+
}
|
|
1517
|
+
if (failure) {
|
|
1518
|
+
throw failure;
|
|
1425
1519
|
}
|
|
1426
1520
|
const nextSession = await getMcpAuthSession(authSessionId);
|
|
1427
1521
|
if (!nextSession) {
|
|
@@ -1853,6 +1947,12 @@ export {
|
|
|
1853
1947
|
resolveBaseUrl,
|
|
1854
1948
|
deliverOAuthAuthorization,
|
|
1855
1949
|
startOAuthFlow,
|
|
1950
|
+
McpProviderError,
|
|
1951
|
+
toMcpProviderError,
|
|
1952
|
+
getMcpProviderErrorAttributes,
|
|
1953
|
+
McpToolError,
|
|
1954
|
+
getMcpAwareErrorType,
|
|
1955
|
+
getMcpAwareTelemetryMessage,
|
|
1856
1956
|
getMcpAuthSession,
|
|
1857
1957
|
patchMcpAuthSession,
|
|
1858
1958
|
deleteMcpAuthSession,
|
package/dist/cli/chat.js
CHANGED
|
@@ -1,40 +1,39 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createAgentRunner,
|
|
3
3
|
executeAgentRun
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-6K2QE2UI.js";
|
|
5
5
|
import "../chunk-DIB4GX3G.js";
|
|
6
|
-
import "../chunk-
|
|
7
|
-
import "../chunk-
|
|
6
|
+
import "../chunk-S6R23MFB.js";
|
|
7
|
+
import "../chunk-PJPKHGLG.js";
|
|
8
8
|
import "../chunk-HDSDCEPK.js";
|
|
9
|
-
import "../chunk-
|
|
9
|
+
import "../chunk-4LPPH7Y6.js";
|
|
10
|
+
import "../chunk-L72GDKSN.js";
|
|
10
11
|
import "../chunk-MU6HHZEN.js";
|
|
11
12
|
import "../chunk-PDO5BLNM.js";
|
|
12
13
|
import "../chunk-UIE3R5XU.js";
|
|
13
14
|
import {
|
|
14
15
|
loadAppPluginSet
|
|
15
16
|
} from "../chunk-Y2CM7HXH.js";
|
|
16
|
-
import "../chunk-
|
|
17
|
-
import "../chunk-
|
|
18
|
-
import "../chunk-
|
|
19
|
-
import "../chunk-
|
|
20
|
-
import "../chunk-
|
|
21
|
-
import "../chunk-4ZNGQH7C.js";
|
|
22
|
-
import "../chunk-CY7NXM32.js";
|
|
17
|
+
import "../chunk-GT2ZUALJ.js";
|
|
18
|
+
import "../chunk-KC5EE27Y.js";
|
|
19
|
+
import "../chunk-GCGJGSQL.js";
|
|
20
|
+
import "../chunk-3N3FMCKN.js";
|
|
21
|
+
import "../chunk-PWRFTDTY.js";
|
|
23
22
|
import "../chunk-VFUK3X5B.js";
|
|
24
23
|
import "../chunk-FXOYURO4.js";
|
|
25
|
-
import "../chunk-
|
|
26
|
-
import "../chunk-
|
|
27
|
-
import "../chunk-
|
|
24
|
+
import "../chunk-7GADTCNS.js";
|
|
25
|
+
import "../chunk-UXLYAVYL.js";
|
|
26
|
+
import "../chunk-3LGCVRBQ.js";
|
|
28
27
|
import "../chunk-W3U3YQYI.js";
|
|
29
28
|
import "../chunk-HZF5P5UN.js";
|
|
30
|
-
import "../chunk-
|
|
29
|
+
import "../chunk-MLZFK4KP.js";
|
|
31
30
|
import "../chunk-OB42YVAE.js";
|
|
32
31
|
import "../chunk-F3B2YJ76.js";
|
|
33
32
|
import "../chunk-6GWA276C.js";
|
|
34
33
|
import "../chunk-B3IT5END.js";
|
|
35
34
|
import "../chunk-3V7OFJZC.js";
|
|
36
|
-
import "../chunk-
|
|
37
|
-
import "../chunk-
|
|
35
|
+
import "../chunk-QWCF4RAC.js";
|
|
36
|
+
import "../chunk-HWUBBHLK.js";
|
|
38
37
|
import "../chunk-MLKGABMK.js";
|
|
39
38
|
|
|
40
39
|
// src/cli/chat.ts
|
|
@@ -156,11 +155,11 @@ async function configureLocalChatPlugins(pluginSet) {
|
|
|
156
155
|
validationModule,
|
|
157
156
|
databaseModule
|
|
158
157
|
] = await Promise.all([
|
|
159
|
-
import("../plugins-
|
|
160
|
-
import("../agent-hooks-
|
|
161
|
-
import("../catalog-runtime-
|
|
162
|
-
import("../validation-
|
|
163
|
-
import("../db-
|
|
158
|
+
import("../plugins-HW4VWW6G.js"),
|
|
159
|
+
import("../agent-hooks-J2FB7XD6.js"),
|
|
160
|
+
import("../catalog-runtime-UHHLU53I.js"),
|
|
161
|
+
import("../validation-IJLNHZSU.js"),
|
|
162
|
+
import("../db-PMRHFSYL.js")
|
|
164
163
|
]);
|
|
165
164
|
const resolvedPluginSet = pluginSet === void 0 ? await loadLocalPluginSet() : pluginSet ?? void 0;
|
|
166
165
|
const plugins = pluginsModule.pluginRuntimeRegistrationsFromPluginSet(resolvedPluginSet);
|
|
@@ -224,8 +223,8 @@ function localDevServerUrl() {
|
|
|
224
223
|
async function prepareLocalChatRun(io, pluginSet) {
|
|
225
224
|
defaultStateAdapterForLocalChat();
|
|
226
225
|
await configureLocalChatPlugins(pluginSet);
|
|
227
|
-
const { runLocalAgentTurn } = await import("../runner-
|
|
228
|
-
const { startLocalOAuthCallbackServer } = await import("../oauth-callback-server-
|
|
226
|
+
const { runLocalAgentTurn } = await import("../runner-PZMV6JQW.js");
|
|
227
|
+
const { startLocalOAuthCallbackServer } = await import("../oauth-callback-server-QJUC7S4X.js");
|
|
229
228
|
const { createLocalOAuthState } = await import("../oauth-relay-3ZU72UGL.js");
|
|
230
229
|
const { createLocalSandboxEgressSignalTransport } = await import("../sandbox-egress-signals-CDFAP67O.js");
|
|
231
230
|
const agentRunner = createAgentRunner(executeAgentRun);
|
package/dist/cli/check.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
parseSkillFile
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-
|
|
3
|
+
} from "../chunk-7GADTCNS.js";
|
|
4
|
+
import "../chunk-UXLYAVYL.js";
|
|
5
5
|
import {
|
|
6
6
|
parseInlinePluginManifest,
|
|
7
7
|
parsePluginManifest
|
|
8
|
-
} from "../chunk-
|
|
8
|
+
} from "../chunk-3LGCVRBQ.js";
|
|
9
9
|
import "../chunk-W3U3YQYI.js";
|
|
10
10
|
import "../chunk-HZF5P5UN.js";
|
|
11
|
-
import "../chunk-
|
|
11
|
+
import "../chunk-MLZFK4KP.js";
|
|
12
12
|
import "../chunk-OB42YVAE.js";
|
|
13
13
|
import "../chunk-F3B2YJ76.js";
|
|
14
14
|
import "../chunk-6GWA276C.js";
|
|
@@ -18,8 +18,8 @@ import {
|
|
|
18
18
|
JUNIOR_CONVERSATION_WORK_CALLBACK_ROUTE,
|
|
19
19
|
JUNIOR_HEARTBEAT_ROUTE,
|
|
20
20
|
LEGACY_JUNIOR_CONVERSATION_WORK_FUNCTION
|
|
21
|
-
} from "../chunk-
|
|
22
|
-
import "../chunk-
|
|
21
|
+
} from "../chunk-QWCF4RAC.js";
|
|
22
|
+
import "../chunk-HWUBBHLK.js";
|
|
23
23
|
import "../chunk-MLKGABMK.js";
|
|
24
24
|
|
|
25
25
|
// src/cli/check.ts
|
package/dist/cli/main.js
CHANGED
|
@@ -22,7 +22,7 @@ async function runInit(dir) {
|
|
|
22
22
|
await mod.runInit(dir);
|
|
23
23
|
}
|
|
24
24
|
async function runSnapshotCreate() {
|
|
25
|
-
const mod = await import("./snapshot-
|
|
25
|
+
const mod = await import("./snapshot-create.js");
|
|
26
26
|
await mod.runSnapshotCreate();
|
|
27
27
|
}
|
|
28
28
|
async function runCheck(dir) {
|
package/dist/cli/plugins.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
validatePluginEgressCredentialHooks,
|
|
3
3
|
validatePluginRegistrations
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-4SOQPUF4.js";
|
|
5
5
|
import {
|
|
6
6
|
pluginCatalogConfigFromPluginSet,
|
|
7
7
|
pluginCliRegistrationsFromPluginSet,
|
|
8
8
|
pluginRuntimeRegistrationsFromPluginSet
|
|
9
|
-
} from "../chunk-
|
|
9
|
+
} from "../chunk-FIANEE7Z.js";
|
|
10
10
|
import {
|
|
11
11
|
loadAppPluginSet
|
|
12
12
|
} from "../chunk-Y2CM7HXH.js";
|
|
@@ -14,31 +14,29 @@ import {
|
|
|
14
14
|
createPluginLogger,
|
|
15
15
|
setPlugins,
|
|
16
16
|
validatePlugins
|
|
17
|
-
} from "../chunk-
|
|
18
|
-
import "../chunk-7CSVG54J.js";
|
|
19
|
-
import "../chunk-FAEALXEH.js";
|
|
17
|
+
} from "../chunk-GT2ZUALJ.js";
|
|
20
18
|
import {
|
|
21
19
|
getDb
|
|
22
|
-
} from "../chunk-
|
|
23
|
-
import "../chunk-
|
|
24
|
-
import "../chunk-
|
|
25
|
-
import "../chunk-
|
|
20
|
+
} from "../chunk-KC5EE27Y.js";
|
|
21
|
+
import "../chunk-GCGJGSQL.js";
|
|
22
|
+
import "../chunk-3N3FMCKN.js";
|
|
23
|
+
import "../chunk-PWRFTDTY.js";
|
|
26
24
|
import "../chunk-VFUK3X5B.js";
|
|
27
25
|
import "../chunk-FXOYURO4.js";
|
|
28
26
|
import {
|
|
29
27
|
pluginCatalogRuntime
|
|
30
|
-
} from "../chunk-
|
|
31
|
-
import "../chunk-
|
|
28
|
+
} from "../chunk-UXLYAVYL.js";
|
|
29
|
+
import "../chunk-3LGCVRBQ.js";
|
|
32
30
|
import "../chunk-W3U3YQYI.js";
|
|
33
31
|
import "../chunk-HZF5P5UN.js";
|
|
34
|
-
import "../chunk-
|
|
32
|
+
import "../chunk-MLZFK4KP.js";
|
|
35
33
|
import "../chunk-OB42YVAE.js";
|
|
36
34
|
import "../chunk-F3B2YJ76.js";
|
|
37
35
|
import "../chunk-6GWA276C.js";
|
|
38
36
|
import "../chunk-B3IT5END.js";
|
|
39
37
|
import "../chunk-3V7OFJZC.js";
|
|
40
|
-
import "../chunk-
|
|
41
|
-
import "../chunk-
|
|
38
|
+
import "../chunk-QWCF4RAC.js";
|
|
39
|
+
import "../chunk-HWUBBHLK.js";
|
|
42
40
|
import "../chunk-MLKGABMK.js";
|
|
43
41
|
|
|
44
42
|
// src/cli/plugins.ts
|