@sentry/junior 0.119.0 → 0.120.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-NZSV4QQR.js → agent-hooks-5DDPWRYO.js} +7 -7
- package/dist/api.js +58 -79
- package/dist/app.js +21 -21
- package/dist/build/copy-build-content.d.ts +2 -2
- package/dist/{catalog-runtime-TAOYIZIZ.js → catalog-runtime-5KR5XBMJ.js} +7 -7
- package/dist/chat/discovery.d.ts +2 -0
- package/dist/chat/mcp/tool-manager.d.ts +14 -1
- package/dist/chat/plugins/types.d.ts +3 -9
- package/dist/chat/plugins/user-pages.d.ts +2 -1
- package/dist/{chunk-BLQZACHV.js → chunk-24B5R6OU.js} +92 -6
- package/dist/{chunk-JXRAOOXQ.js → chunk-6WX5SPI3.js} +1 -1
- package/dist/{chunk-VJTWKJWQ.js → chunk-ALAKN7LR.js} +1 -1
- package/dist/{chunk-ZJ6IVZVO.js → chunk-ALYQOZG7.js} +1 -1
- package/dist/{chunk-ZFX4M743.js → chunk-BHXW734F.js} +6 -6
- package/dist/{chunk-GKFDU3ZI.js → chunk-DJDGDJDF.js} +4 -4
- package/dist/{chunk-JLJLZS2N.js → chunk-DMKHRBI6.js} +4 -3
- package/dist/{chunk-NUENIPQL.js → chunk-DWOH57FW.js} +1 -1
- package/dist/{chunk-QZ7XRJDB.js → chunk-EIVE6GL4.js} +3 -3
- package/dist/{chunk-TGIQN7QW.js → chunk-ERYVNWNE.js} +93 -18
- package/dist/{chunk-JSTGI7TX.js → chunk-GNNV3UTY.js} +1 -1
- package/dist/chunk-H4HBKISO.js +417 -0
- package/dist/{chunk-BNJEPYTC.js → chunk-JQWP6V22.js} +4 -4
- package/dist/{chunk-D3N4BPSL.js → chunk-M243JMZH.js} +2 -2
- package/dist/{chunk-B3IT5END.js → chunk-OOUNJNMR.js} +16 -152
- package/dist/{chunk-6ZR455DC.js → chunk-Q3RL6A4E.js} +1 -1
- package/dist/{chunk-YLYJIQRX.js → chunk-QOQPPRFS.js} +12 -12
- package/dist/{chunk-4UIUDOOV.js → chunk-TKUCRFNX.js} +7 -7
- package/dist/{chunk-VLTWQQKH.js → chunk-VURFJVFH.js} +1 -1
- package/dist/{chunk-R53UT2OI.js → chunk-XAI2HNAY.js} +9 -5
- package/dist/{chunk-TAGV4Z3J.js → chunk-YEAOUT5W.js} +1 -1
- package/dist/cli/chat.js +23 -23
- package/dist/cli/check.js +8 -8
- package/dist/cli/plugins.js +12 -12
- package/dist/cli/snapshot-create.js +10 -10
- package/dist/cli/upgrade.js +7 -7
- package/dist/{db-FWGP5CKY.js → db-T4ZY64PB.js} +5 -5
- package/dist/{discovery-RMHYSRL7.js → discovery-GUFTFBTL.js} +3 -1
- package/dist/instrumentation.js +2 -2
- package/dist/nitro.js +24 -7
- package/dist/{oauth-callback-server-PM3QNXJQ.js → oauth-callback-server-LQ6DFI26.js} +16 -16
- package/dist/{runner-DV55N6ZB.js → runner-D3ZU6TJH.js} +9 -9
- package/dist/{skills-MANV5ZK6.js → skills-JMXY7LIY.js} +8 -8
- package/dist/{validation-QGB4INTI.js → validation-OEPJS7JX.js} +8 -8
- package/dist/version.js +1 -1
- package/package.json +8 -7
- package/skills/jr-rpc/SKILL.md +40 -0
- package/dist/chunk-3V7OFJZC.js +0 -264
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getDb
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-M243JMZH.js";
|
|
4
4
|
import {
|
|
5
|
-
juniorConversationAnnotations
|
|
5
|
+
juniorConversationAnnotations,
|
|
6
|
+
juniorIdentities,
|
|
7
|
+
juniorUsers
|
|
6
8
|
} from "./chunk-GCGJGSQL.js";
|
|
7
9
|
import {
|
|
8
10
|
SANDBOX_WORKSPACE_ROOT,
|
|
9
11
|
getStateAdapter,
|
|
10
12
|
sleep
|
|
11
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-ALAKN7LR.js";
|
|
12
14
|
import {
|
|
13
15
|
botConfig,
|
|
14
16
|
completeObject,
|
|
15
17
|
embedTexts,
|
|
16
18
|
getSlackBotToken,
|
|
17
19
|
standardModelId
|
|
18
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-VURFJVFH.js";
|
|
19
21
|
import {
|
|
20
22
|
isActorUserId,
|
|
21
23
|
parseActorUserId
|
|
@@ -24,10 +26,11 @@ import {
|
|
|
24
26
|
logException,
|
|
25
27
|
logInfo,
|
|
26
28
|
logWarn,
|
|
29
|
+
normalizeIdentityEmail,
|
|
27
30
|
setSpanAttributes,
|
|
28
31
|
setSpanStatus,
|
|
29
32
|
withSpan
|
|
30
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-ALYQOZG7.js";
|
|
31
34
|
import {
|
|
32
35
|
parseSlackChannelReferenceId,
|
|
33
36
|
parseSlackMessageTs,
|
|
@@ -321,6 +324,55 @@ function getSlackToolContext(context) {
|
|
|
321
324
|
};
|
|
322
325
|
}
|
|
323
326
|
|
|
327
|
+
// src/chat/plugins/viewer-actors.ts
|
|
328
|
+
import { and as and2, eq as eq2 } from "drizzle-orm";
|
|
329
|
+
import {
|
|
330
|
+
actorSchema
|
|
331
|
+
} from "@sentry/junior-plugin-api";
|
|
332
|
+
async function readViewerActorsFromSql(db, email) {
|
|
333
|
+
const normalizedEmail = normalizeIdentityEmail(email);
|
|
334
|
+
if (!normalizedEmail) return [];
|
|
335
|
+
const rows = await db.select({
|
|
336
|
+
displayName: juniorIdentities.displayName,
|
|
337
|
+
email: juniorUsers.primaryEmail,
|
|
338
|
+
handle: juniorIdentities.handle,
|
|
339
|
+
provider: juniorIdentities.provider,
|
|
340
|
+
providerSubjectId: juniorIdentities.providerSubjectId,
|
|
341
|
+
providerTenantId: juniorIdentities.providerTenantId
|
|
342
|
+
}).from(juniorIdentities).innerJoin(juniorUsers, eq2(juniorUsers.id, juniorIdentities.userId)).where(
|
|
343
|
+
and2(
|
|
344
|
+
eq2(juniorUsers.primaryEmailNormalized, normalizedEmail),
|
|
345
|
+
eq2(juniorIdentities.kind, "user")
|
|
346
|
+
)
|
|
347
|
+
);
|
|
348
|
+
const actors = [];
|
|
349
|
+
for (const row of rows) {
|
|
350
|
+
const candidate = row.provider === "slack" ? {
|
|
351
|
+
platform: "slack",
|
|
352
|
+
teamId: row.providerTenantId,
|
|
353
|
+
userId: row.providerSubjectId,
|
|
354
|
+
email: row.email,
|
|
355
|
+
...row.displayName ? { fullName: row.displayName } : {},
|
|
356
|
+
...row.handle ? { userName: row.handle } : {}
|
|
357
|
+
} : row.provider === "local" ? {
|
|
358
|
+
platform: "local",
|
|
359
|
+
userId: row.providerSubjectId,
|
|
360
|
+
email: row.email,
|
|
361
|
+
...row.displayName ? { fullName: row.displayName } : {},
|
|
362
|
+
...row.handle ? { userName: row.handle } : {}
|
|
363
|
+
} : void 0;
|
|
364
|
+
if (!candidate) continue;
|
|
365
|
+
const parsed = actorSchema.safeParse(candidate);
|
|
366
|
+
if (parsed.success && parsed.data.platform !== "system") {
|
|
367
|
+
actors.push(parsed.data);
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
return actors;
|
|
371
|
+
}
|
|
372
|
+
async function readViewerActors(email) {
|
|
373
|
+
return await readViewerActorsFromSql(getDb(), email);
|
|
374
|
+
}
|
|
375
|
+
|
|
324
376
|
// src/chat/credentials/subject.ts
|
|
325
377
|
import { createHmac, timingSafeEqual } from "crypto";
|
|
326
378
|
|
|
@@ -941,6 +993,7 @@ function invocationPluginContext(plugin, context) {
|
|
|
941
993
|
...base,
|
|
942
994
|
conversationId: context.conversationId,
|
|
943
995
|
embedder: createPluginEmbedder(plugin.manifest.name),
|
|
996
|
+
model: createPluginModel(plugin.manifest.name, plugin.model),
|
|
944
997
|
source: context.source,
|
|
945
998
|
text: context.userText ?? "",
|
|
946
999
|
state: createPluginState(plugin.manifest.name)
|
|
@@ -968,6 +1021,32 @@ function invocationPluginContext(plugin, context) {
|
|
|
968
1021
|
actor: context.actor?.platform === "local" ? context.actor : void 0
|
|
969
1022
|
};
|
|
970
1023
|
}
|
|
1024
|
+
function pluginMcpContext(plugin, context) {
|
|
1025
|
+
const manager = context.mcpToolManager;
|
|
1026
|
+
const wrappedTools = new Set(plugin.manifest.mcp?.wrappedTools ?? []);
|
|
1027
|
+
if (!manager || wrappedTools.size === 0) {
|
|
1028
|
+
return void 0;
|
|
1029
|
+
}
|
|
1030
|
+
const provider = plugin.manifest.name;
|
|
1031
|
+
const prepare = async () => {
|
|
1032
|
+
await manager.activateProvider(provider);
|
|
1033
|
+
return manager.getActiveProviders().includes(provider) ? "ready" : "authorization_pending";
|
|
1034
|
+
};
|
|
1035
|
+
return {
|
|
1036
|
+
prepare,
|
|
1037
|
+
async callTool(input) {
|
|
1038
|
+
if (await prepare() === "authorization_pending") {
|
|
1039
|
+
return { status: "authorization_pending" };
|
|
1040
|
+
}
|
|
1041
|
+
return await manager.callWrappedTool(
|
|
1042
|
+
provider,
|
|
1043
|
+
input.name,
|
|
1044
|
+
input.arguments ?? {},
|
|
1045
|
+
input.toolCallId ? { toolCallId: input.toolCallId } : void 0
|
|
1046
|
+
);
|
|
1047
|
+
}
|
|
1048
|
+
};
|
|
1049
|
+
}
|
|
971
1050
|
function safeErrorMessage(error) {
|
|
972
1051
|
return error instanceof Error ? error.message : String(error);
|
|
973
1052
|
}
|
|
@@ -1239,6 +1318,7 @@ function getPluginTools(context) {
|
|
|
1239
1318
|
db: getDb(),
|
|
1240
1319
|
plugin: pluginName
|
|
1241
1320
|
}) : void 0;
|
|
1321
|
+
const mcp = pluginMcpContext(plugin, context);
|
|
1242
1322
|
let pluginContext;
|
|
1243
1323
|
if (context.source.platform === "slack") {
|
|
1244
1324
|
if (context.destination.platform !== "slack") {
|
|
@@ -1257,6 +1337,7 @@ function getPluginTools(context) {
|
|
|
1257
1337
|
userText: context.userText,
|
|
1258
1338
|
embedder: createPluginEmbedder(pluginName),
|
|
1259
1339
|
egress: context.egress,
|
|
1340
|
+
...mcp ? { mcp } : {},
|
|
1260
1341
|
model: createPluginModel(pluginName, plugin.model),
|
|
1261
1342
|
state: createPluginState(pluginName)
|
|
1262
1343
|
};
|
|
@@ -1276,6 +1357,7 @@ function getPluginTools(context) {
|
|
|
1276
1357
|
userText: context.userText,
|
|
1277
1358
|
embedder: createPluginEmbedder(pluginName),
|
|
1278
1359
|
egress: context.egress,
|
|
1360
|
+
...mcp ? { mcp } : {},
|
|
1279
1361
|
model: createPluginModel(pluginName, plugin.model),
|
|
1280
1362
|
state: createPluginState(pluginName)
|
|
1281
1363
|
};
|
|
@@ -1416,7 +1498,10 @@ function getPluginApiRoutes() {
|
|
|
1416
1498
|
continue;
|
|
1417
1499
|
}
|
|
1418
1500
|
const app = hook({
|
|
1419
|
-
...basePluginContext(plugin)
|
|
1501
|
+
...basePluginContext(plugin),
|
|
1502
|
+
viewer: {
|
|
1503
|
+
actors: readViewerActors
|
|
1504
|
+
}
|
|
1420
1505
|
});
|
|
1421
1506
|
if (app === void 0) {
|
|
1422
1507
|
continue;
|
|
@@ -1853,6 +1938,7 @@ export {
|
|
|
1853
1938
|
setDashboardConversationLinkOptions,
|
|
1854
1939
|
getDashboardConversationLink,
|
|
1855
1940
|
getSlackToolContext,
|
|
1941
|
+
readViewerActors,
|
|
1856
1942
|
runWithWorkspaceTeamId,
|
|
1857
1943
|
getWorkspaceTeamId,
|
|
1858
1944
|
SlackActionError,
|
|
@@ -22,28 +22,28 @@ import {
|
|
|
22
22
|
persistThreadStateById,
|
|
23
23
|
stripRuntimeTurnContext,
|
|
24
24
|
updateConversationStats
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-JQWP6V22.js";
|
|
26
26
|
import {
|
|
27
27
|
createPluginEmbedder,
|
|
28
28
|
createPluginLogger,
|
|
29
29
|
createPluginModel,
|
|
30
30
|
createPluginState,
|
|
31
31
|
getPlugins
|
|
32
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-24B5R6OU.js";
|
|
33
33
|
import {
|
|
34
34
|
getDb
|
|
35
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-M243JMZH.js";
|
|
36
36
|
import {
|
|
37
37
|
getStateAdapter
|
|
38
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-ALAKN7LR.js";
|
|
39
39
|
import {
|
|
40
40
|
ProviderError,
|
|
41
41
|
getProviderErrorAttributes,
|
|
42
42
|
getProviderErrorUserMessage
|
|
43
|
-
} from "./chunk-
|
|
43
|
+
} from "./chunk-VURFJVFH.js";
|
|
44
44
|
import {
|
|
45
45
|
buildTurnFailureResponse
|
|
46
|
-
} from "./chunk-
|
|
46
|
+
} from "./chunk-ALYQOZG7.js";
|
|
47
47
|
import {
|
|
48
48
|
parseSlackMessageTs
|
|
49
49
|
} from "./chunk-F3B2YJ76.js";
|
|
@@ -2,18 +2,18 @@ import {
|
|
|
2
2
|
SANDBOX_WORKSPACE_ROOT,
|
|
3
3
|
getStateAdapter,
|
|
4
4
|
sleep
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-ALAKN7LR.js";
|
|
6
6
|
import {
|
|
7
7
|
toOptionalTrimmed
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-VURFJVFH.js";
|
|
9
9
|
import {
|
|
10
10
|
pluginCatalogRuntime
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-GNNV3UTY.js";
|
|
12
12
|
import {
|
|
13
13
|
setSpanAttributes,
|
|
14
14
|
setSpanStatus,
|
|
15
15
|
withSpan
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-ALYQOZG7.js";
|
|
17
17
|
|
|
18
18
|
// src/chat/sandbox/snapshot/profile.ts
|
|
19
19
|
import { createHash } from "crypto";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// package.json
|
|
2
2
|
var package_default = {
|
|
3
3
|
name: "@sentry/junior",
|
|
4
|
-
version: "0.
|
|
4
|
+
version: "0.120.0",
|
|
5
5
|
private: false,
|
|
6
6
|
publishConfig: {
|
|
7
7
|
access: "public"
|
|
@@ -49,7 +49,8 @@ var package_default = {
|
|
|
49
49
|
files: [
|
|
50
50
|
"dist",
|
|
51
51
|
"bin",
|
|
52
|
-
"migrations"
|
|
52
|
+
"migrations",
|
|
53
|
+
"skills"
|
|
53
54
|
],
|
|
54
55
|
scripts: {
|
|
55
56
|
prepare: "pnpm run build",
|
|
@@ -61,7 +62,7 @@ var package_default = {
|
|
|
61
62
|
test: "vitest run --maxWorkers=4",
|
|
62
63
|
"test:watch": "vitest",
|
|
63
64
|
typecheck: "tsc --noEmit",
|
|
64
|
-
"skills:check": "node scripts/check-skills.mjs",
|
|
65
|
+
"skills:check": "node --test scripts/check-skills.test.mjs && node scripts/check-skills.mjs",
|
|
65
66
|
"test:coverage": "vitest run --maxWorkers=4 --coverage --reporter=default --reporter=junit --outputFile.junit=coverage/results.junit.xml"
|
|
66
67
|
},
|
|
67
68
|
dependencies: {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
pluginCatalogRuntime
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-GNNV3UTY.js";
|
|
4
4
|
import {
|
|
5
5
|
logWarn
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-ALYQOZG7.js";
|
|
7
7
|
import {
|
|
8
8
|
skillRoots
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-H4HBKISO.js";
|
|
10
10
|
|
|
11
11
|
// src/chat/skills.ts
|
|
12
12
|
import fs from "fs/promises";
|
|
@@ -30,7 +30,7 @@ import {
|
|
|
30
30
|
toMcpProviderError,
|
|
31
31
|
toolInvocationDestination,
|
|
32
32
|
uploadFilesToConversation
|
|
33
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-TKUCRFNX.js";
|
|
34
34
|
import {
|
|
35
35
|
CooperativeTurnYieldError,
|
|
36
36
|
JUNIOR_THREAD_STATE_TTL_MS,
|
|
@@ -72,7 +72,7 @@ import {
|
|
|
72
72
|
stripRuntimeTurnContext,
|
|
73
73
|
trimTrailingAssistantMessages,
|
|
74
74
|
updateConversationStats
|
|
75
|
-
} from "./chunk-
|
|
75
|
+
} from "./chunk-JQWP6V22.js";
|
|
76
76
|
import {
|
|
77
77
|
parseSandboxEgressAuthRequiredSignal,
|
|
78
78
|
parseSandboxEgressPermissionDeniedSignal,
|
|
@@ -96,10 +96,10 @@ import {
|
|
|
96
96
|
runNonInteractiveCommand,
|
|
97
97
|
throwSandboxOperationError,
|
|
98
98
|
wrapSandboxSetupError
|
|
99
|
-
} from "./chunk-
|
|
99
|
+
} from "./chunk-DJDGDJDF.js";
|
|
100
100
|
import {
|
|
101
101
|
incrementStat
|
|
102
|
-
} from "./chunk-
|
|
102
|
+
} from "./chunk-6WX5SPI3.js";
|
|
103
103
|
import {
|
|
104
104
|
addAgentTurnUsage,
|
|
105
105
|
hasAgentTurnUsage
|
|
@@ -121,7 +121,7 @@ import {
|
|
|
121
121
|
normalizeSlackConversationId,
|
|
122
122
|
resolveChannelCapabilities,
|
|
123
123
|
withSlackRetries
|
|
124
|
-
} from "./chunk-
|
|
124
|
+
} from "./chunk-24B5R6OU.js";
|
|
125
125
|
import {
|
|
126
126
|
KNOWN_CONVERSATION_EVENT_TYPES,
|
|
127
127
|
contextProvenance,
|
|
@@ -130,7 +130,7 @@ import {
|
|
|
130
130
|
getConversationStore,
|
|
131
131
|
instructionActors,
|
|
132
132
|
instructionProvenanceFor
|
|
133
|
-
} from "./chunk-
|
|
133
|
+
} from "./chunk-M243JMZH.js";
|
|
134
134
|
import {
|
|
135
135
|
SANDBOX_DATA_ROOT,
|
|
136
136
|
SANDBOX_SKILLS_ROOT,
|
|
@@ -140,7 +140,7 @@ import {
|
|
|
140
140
|
sandboxSkillFile,
|
|
141
141
|
sandboxSkillPathResolution,
|
|
142
142
|
sleep
|
|
143
|
-
} from "./chunk-
|
|
143
|
+
} from "./chunk-ALAKN7LR.js";
|
|
144
144
|
import {
|
|
145
145
|
ACTIVE_TURN_COMPACTION_SUMMARY_PREFIX,
|
|
146
146
|
COMPACTION_SUMMARY_PREFIX,
|
|
@@ -171,7 +171,7 @@ import {
|
|
|
171
171
|
renderCurrentInstruction,
|
|
172
172
|
resolveGatewayModel,
|
|
173
173
|
unwrapCurrentInstruction
|
|
174
|
-
} from "./chunk-
|
|
174
|
+
} from "./chunk-VURFJVFH.js";
|
|
175
175
|
import {
|
|
176
176
|
canExposeConversationPayload,
|
|
177
177
|
parseSlackThreadId,
|
|
@@ -188,10 +188,10 @@ import {
|
|
|
188
188
|
findSkillByName,
|
|
189
189
|
loadSkillsByName,
|
|
190
190
|
parseSkillInvocation
|
|
191
|
-
} from "./chunk-
|
|
191
|
+
} from "./chunk-EIVE6GL4.js";
|
|
192
192
|
import {
|
|
193
193
|
pluginCatalogRuntime
|
|
194
|
-
} from "./chunk-
|
|
194
|
+
} from "./chunk-GNNV3UTY.js";
|
|
195
195
|
import {
|
|
196
196
|
CredentialUnavailableError,
|
|
197
197
|
OAuthProviderError,
|
|
@@ -199,7 +199,7 @@ import {
|
|
|
199
199
|
getOAuthProviderErrorAttributes,
|
|
200
200
|
resolveAuthTokenPlaceholder,
|
|
201
201
|
resolvePluginCommandEnv
|
|
202
|
-
} from "./chunk-
|
|
202
|
+
} from "./chunk-XAI2HNAY.js";
|
|
203
203
|
import {
|
|
204
204
|
credentialUserSubjectId
|
|
205
205
|
} from "./chunk-W3U3YQYI.js";
|
|
@@ -223,7 +223,7 @@ import {
|
|
|
223
223
|
summarizeMessageText,
|
|
224
224
|
withLogContext,
|
|
225
225
|
withSpan
|
|
226
|
-
} from "./chunk-
|
|
226
|
+
} from "./chunk-ALYQOZG7.js";
|
|
227
227
|
import {
|
|
228
228
|
parseSlackChannelId,
|
|
229
229
|
parseSlackMessageTs,
|
|
@@ -237,7 +237,7 @@ import {
|
|
|
237
237
|
listReferenceFiles,
|
|
238
238
|
soulPathCandidates,
|
|
239
239
|
worldPathCandidates
|
|
240
|
-
} from "./chunk-
|
|
240
|
+
} from "./chunk-H4HBKISO.js";
|
|
241
241
|
|
|
242
242
|
// src/chat/configuration/defaults.ts
|
|
243
243
|
var installDefaults = {};
|
|
@@ -6490,6 +6490,7 @@ var McpToolManager = class {
|
|
|
6490
6490
|
try {
|
|
6491
6491
|
const client = await this.getClient(plugin);
|
|
6492
6492
|
const tools = this.filterListedTools(plugin, await client.listTools());
|
|
6493
|
+
this.assertWrappedToolsAvailable(plugin, tools);
|
|
6493
6494
|
this.toolsByProvider.set(
|
|
6494
6495
|
provider,
|
|
6495
6496
|
tools.map((tool) => this.toManagedTool(plugin, client, tool))
|
|
@@ -6540,8 +6541,26 @@ var McpToolManager = class {
|
|
|
6540
6541
|
`Plugin ${plugin.manifest.name} MCP discovery missing allowlisted tools: ${missingTools.join(", ")}`
|
|
6541
6542
|
);
|
|
6542
6543
|
}
|
|
6543
|
-
const
|
|
6544
|
-
|
|
6544
|
+
const loadedToolSet = /* @__PURE__ */ new Set([
|
|
6545
|
+
...allowedTools,
|
|
6546
|
+
...plugin.manifest.mcp?.wrappedTools ?? []
|
|
6547
|
+
]);
|
|
6548
|
+
return tools.filter((tool) => loadedToolSet.has(tool.name));
|
|
6549
|
+
}
|
|
6550
|
+
assertWrappedToolsAvailable(plugin, tools) {
|
|
6551
|
+
const wrappedTools = plugin.manifest.mcp?.wrappedTools ?? [];
|
|
6552
|
+
if (wrappedTools.length === 0) {
|
|
6553
|
+
return;
|
|
6554
|
+
}
|
|
6555
|
+
const availableToolNames = new Set(tools.map((tool) => tool.name));
|
|
6556
|
+
const missingTools = wrappedTools.filter(
|
|
6557
|
+
(toolName) => !availableToolNames.has(toolName)
|
|
6558
|
+
);
|
|
6559
|
+
if (missingTools.length > 0) {
|
|
6560
|
+
throw new Error(
|
|
6561
|
+
`Plugin ${plugin.manifest.name} MCP discovery missing wrapped tools: ${missingTools.join(", ")}`
|
|
6562
|
+
);
|
|
6563
|
+
}
|
|
6545
6564
|
}
|
|
6546
6565
|
async getClient(plugin) {
|
|
6547
6566
|
const existing = this.clientsByProvider.get(plugin.manifest.name);
|
|
@@ -6627,8 +6646,13 @@ var McpToolManager = class {
|
|
|
6627
6646
|
"gen_ai.tool.call.result": resultAttribute
|
|
6628
6647
|
});
|
|
6629
6648
|
}
|
|
6649
|
+
const providerContent = boundMcpContent(
|
|
6650
|
+
toAgentToolContent(result)
|
|
6651
|
+
);
|
|
6630
6652
|
return {
|
|
6631
|
-
content: toModelVisibleMcpContent(result)
|
|
6653
|
+
content: toModelVisibleMcpContent(result),
|
|
6654
|
+
providerContent,
|
|
6655
|
+
...result.structuredContent !== void 0 ? { structuredContent: result.structuredContent } : {}
|
|
6632
6656
|
};
|
|
6633
6657
|
} catch (error) {
|
|
6634
6658
|
if (error instanceof McpAuthorizationRequiredError && await this.handleAuthorizationRequired(
|
|
@@ -6639,7 +6663,9 @@ var McpToolManager = class {
|
|
|
6639
6663
|
{ type: "text", text: "Authorization pending." }
|
|
6640
6664
|
];
|
|
6641
6665
|
return {
|
|
6642
|
-
|
|
6666
|
+
authorizationPending: true,
|
|
6667
|
+
content: parkedContent,
|
|
6668
|
+
providerContent: parkedContent
|
|
6643
6669
|
};
|
|
6644
6670
|
}
|
|
6645
6671
|
const errorAttributes = {
|
|
@@ -6692,10 +6718,59 @@ var McpToolManager = class {
|
|
|
6692
6718
|
if (options.provider && provider !== options.provider) {
|
|
6693
6719
|
continue;
|
|
6694
6720
|
}
|
|
6695
|
-
|
|
6721
|
+
const wrappedTools = new Set(
|
|
6722
|
+
this.pluginsByProvider.get(provider)?.manifest.mcp?.wrappedTools ?? []
|
|
6723
|
+
);
|
|
6724
|
+
resolved.push(
|
|
6725
|
+
...(this.toolsByProvider.get(provider) ?? []).filter(
|
|
6726
|
+
(tool) => !wrappedTools.has(tool.rawName)
|
|
6727
|
+
)
|
|
6728
|
+
);
|
|
6696
6729
|
}
|
|
6697
6730
|
return resolved;
|
|
6698
6731
|
}
|
|
6732
|
+
/** Call one active provider tool declared for plugin-owned wrapping. */
|
|
6733
|
+
async callWrappedTool(provider, rawName, args, options) {
|
|
6734
|
+
if (!this.activeProviders.has(provider)) {
|
|
6735
|
+
throw new McpToolError(`MCP provider is not active: ${provider}`);
|
|
6736
|
+
}
|
|
6737
|
+
const wrappedTools = new Set(
|
|
6738
|
+
this.pluginsByProvider.get(provider)?.manifest.mcp?.wrappedTools ?? []
|
|
6739
|
+
);
|
|
6740
|
+
if (!wrappedTools.has(rawName)) {
|
|
6741
|
+
throw new McpToolError(
|
|
6742
|
+
`Plugin ${provider} cannot call unwrapped MCP tool ${rawName}`
|
|
6743
|
+
);
|
|
6744
|
+
}
|
|
6745
|
+
const tool = (this.toolsByProvider.get(provider) ?? []).find(
|
|
6746
|
+
(candidate) => candidate.rawName === rawName
|
|
6747
|
+
);
|
|
6748
|
+
if (!tool) {
|
|
6749
|
+
throw new McpToolError(
|
|
6750
|
+
`MCP provider ${provider} does not expose tool ${rawName}`
|
|
6751
|
+
);
|
|
6752
|
+
}
|
|
6753
|
+
let result;
|
|
6754
|
+
try {
|
|
6755
|
+
result = await tool.execute(args, {
|
|
6756
|
+
conversationPrivacy: "private",
|
|
6757
|
+
...options?.toolCallId ? { toolCallId: options.toolCallId } : {}
|
|
6758
|
+
});
|
|
6759
|
+
} catch (error) {
|
|
6760
|
+
if (error instanceof McpToolError) {
|
|
6761
|
+
return { status: "error", message: error.message };
|
|
6762
|
+
}
|
|
6763
|
+
throw error;
|
|
6764
|
+
}
|
|
6765
|
+
if (result.authorizationPending) {
|
|
6766
|
+
return { status: "authorization_pending" };
|
|
6767
|
+
}
|
|
6768
|
+
return {
|
|
6769
|
+
status: "success",
|
|
6770
|
+
content: result.providerContent ?? result.content,
|
|
6771
|
+
...result.structuredContent !== void 0 ? { structuredContent: result.structuredContent } : {}
|
|
6772
|
+
};
|
|
6773
|
+
}
|
|
6699
6774
|
toToolDescriptor(tool) {
|
|
6700
6775
|
return {
|
|
6701
6776
|
name: tool.name,
|