@google/gemini-cli-a2a-server 0.33.0-preview.3 → 0.33.0-preview.5
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/a2a-server.mjs +144 -157
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
package/dist/a2a-server.mjs
CHANGED
|
@@ -122500,10 +122500,36 @@ var init_tools = __esm({
|
|
|
122500
122500
|
|
|
122501
122501
|
// packages/core/dist/src/tools/mcp-tool.js
|
|
122502
122502
|
function isMcpToolName(name4) {
|
|
122503
|
-
|
|
122504
|
-
|
|
122505
|
-
|
|
122506
|
-
|
|
122503
|
+
return name4.startsWith(MCP_TOOL_PREFIX);
|
|
122504
|
+
}
|
|
122505
|
+
function parseMcpToolName(name4) {
|
|
122506
|
+
if (!isMcpToolName(name4)) {
|
|
122507
|
+
return {};
|
|
122508
|
+
}
|
|
122509
|
+
const withoutPrefix = name4.slice(MCP_TOOL_PREFIX.length);
|
|
122510
|
+
const match2 = withoutPrefix.match(/^([^_]+)_(.+)$/);
|
|
122511
|
+
if (match2) {
|
|
122512
|
+
return {
|
|
122513
|
+
serverName: match2[1],
|
|
122514
|
+
toolName: match2[2]
|
|
122515
|
+
};
|
|
122516
|
+
}
|
|
122517
|
+
return {};
|
|
122518
|
+
}
|
|
122519
|
+
function formatMcpToolName(serverName, toolName) {
|
|
122520
|
+
if (serverName === "*" && !toolName) {
|
|
122521
|
+
return `${MCP_TOOL_PREFIX}*`;
|
|
122522
|
+
} else if (serverName === "*") {
|
|
122523
|
+
return `${MCP_TOOL_PREFIX}*_${toolName}`;
|
|
122524
|
+
} else if (!toolName) {
|
|
122525
|
+
return `${MCP_TOOL_PREFIX}${serverName}_*`;
|
|
122526
|
+
} else {
|
|
122527
|
+
return `${MCP_TOOL_PREFIX}${serverName}_${toolName}`;
|
|
122528
|
+
}
|
|
122529
|
+
}
|
|
122530
|
+
function isMcpToolAnnotation(annotation) {
|
|
122531
|
+
return typeof annotation === "object" && annotation !== null && // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
122532
|
+
typeof annotation["_serverName"] === "string";
|
|
122507
122533
|
}
|
|
122508
122534
|
function transformTextBlock(block) {
|
|
122509
122535
|
return { text: block.text };
|
|
@@ -122598,24 +122624,28 @@ function getStringifiedResultForDisplay(rawResponse) {
|
|
|
122598
122624
|
return displayParts.join("\n");
|
|
122599
122625
|
}
|
|
122600
122626
|
function generateValidName(name4) {
|
|
122601
|
-
let validToolname = name4.
|
|
122627
|
+
let validToolname = name4.startsWith("mcp_") ? name4 : `mcp_${name4}`;
|
|
122628
|
+
validToolname = validToolname.replace(/[^a-zA-Z0-9_\-.:]/g, "_");
|
|
122602
122629
|
if (/^[^a-zA-Z_]/.test(validToolname)) {
|
|
122603
122630
|
validToolname = `_${validToolname}`;
|
|
122604
122631
|
}
|
|
122605
122632
|
const safeLimit = MAX_FUNCTION_NAME_LENGTH - 1;
|
|
122606
122633
|
if (validToolname.length > safeLimit) {
|
|
122634
|
+
debugLogger.warn(`Truncating MCP tool name "${validToolname}" to fit within the 64 character limit. This tool may require user approval.`);
|
|
122607
122635
|
validToolname = validToolname.slice(0, 30) + "..." + validToolname.slice(-30);
|
|
122608
122636
|
}
|
|
122609
122637
|
return validToolname;
|
|
122610
122638
|
}
|
|
122611
|
-
var MCP_QUALIFIED_NAME_SEPARATOR, DiscoveredMCPToolInvocation, DiscoveredMCPTool, MAX_FUNCTION_NAME_LENGTH;
|
|
122639
|
+
var MCP_QUALIFIED_NAME_SEPARATOR, MCP_TOOL_PREFIX, DiscoveredMCPToolInvocation, DiscoveredMCPTool, MAX_FUNCTION_NAME_LENGTH;
|
|
122612
122640
|
var init_mcp_tool = __esm({
|
|
122613
122641
|
"packages/core/dist/src/tools/mcp-tool.js"() {
|
|
122614
122642
|
"use strict";
|
|
122615
122643
|
init_safeJsonStringify();
|
|
122644
|
+
init_debugLogger();
|
|
122616
122645
|
init_tools();
|
|
122617
122646
|
init_tool_error();
|
|
122618
|
-
MCP_QUALIFIED_NAME_SEPARATOR = "
|
|
122647
|
+
MCP_QUALIFIED_NAME_SEPARATOR = "_";
|
|
122648
|
+
MCP_TOOL_PREFIX = "mcp_";
|
|
122619
122649
|
DiscoveredMCPToolInvocation = class _DiscoveredMCPToolInvocation extends BaseToolInvocation {
|
|
122620
122650
|
mcpTool;
|
|
122621
122651
|
serverName;
|
|
@@ -122757,7 +122787,7 @@ var init_mcp_tool = __esm({
|
|
|
122757
122787
|
_toolAnnotations;
|
|
122758
122788
|
constructor(mcpTool, serverName, serverToolName, description, parameterSchema, messageBus, trust, isReadOnly, nameOverride, cliConfig, extensionName, extensionId, _toolAnnotations) {
|
|
122759
122789
|
super(
|
|
122760
|
-
|
|
122790
|
+
nameOverride ?? generateValidName(`${serverName}${MCP_QUALIFIED_NAME_SEPARATOR}${serverToolName}`),
|
|
122761
122791
|
`${serverToolName} (${serverName} MCP Server)`,
|
|
122762
122792
|
description,
|
|
122763
122793
|
Kind.Other,
|
|
@@ -122792,7 +122822,7 @@ var init_mcp_tool = __esm({
|
|
|
122792
122822
|
return this._toolAnnotations;
|
|
122793
122823
|
}
|
|
122794
122824
|
getFullyQualifiedPrefix() {
|
|
122795
|
-
return `${this.serverName}${MCP_QUALIFIED_NAME_SEPARATOR}
|
|
122825
|
+
return generateValidName(`${this.serverName}${MCP_QUALIFIED_NAME_SEPARATOR}`);
|
|
122796
122826
|
}
|
|
122797
122827
|
getFullyQualifiedName() {
|
|
122798
122828
|
return generateValidName(`${this.serverName}${MCP_QUALIFIED_NAME_SEPARATOR}${this.serverToolName}`);
|
|
@@ -214180,8 +214210,8 @@ var GIT_COMMIT_INFO, CLI_VERSION;
|
|
|
214180
214210
|
var init_git_commit = __esm({
|
|
214181
214211
|
"packages/core/dist/src/generated/git-commit.js"() {
|
|
214182
214212
|
"use strict";
|
|
214183
|
-
GIT_COMMIT_INFO = "
|
|
214184
|
-
CLI_VERSION = "0.33.0-preview.
|
|
214213
|
+
GIT_COMMIT_INFO = "a6256cdab";
|
|
214214
|
+
CLI_VERSION = "0.33.0-preview.5";
|
|
214185
214215
|
}
|
|
214186
214216
|
});
|
|
214187
214217
|
|
|
@@ -291439,7 +291469,7 @@ function getVersion() {
|
|
|
291439
291469
|
}
|
|
291440
291470
|
versionPromise = (async () => {
|
|
291441
291471
|
const pkgJson = await getPackageJson(__dirname3);
|
|
291442
|
-
return "0.33.0-preview.
|
|
291472
|
+
return "0.33.0-preview.5";
|
|
291443
291473
|
})();
|
|
291444
291474
|
return versionPromise;
|
|
291445
291475
|
}
|
|
@@ -292834,14 +292864,16 @@ var init_recordingContentGenerator = __esm({
|
|
|
292834
292864
|
});
|
|
292835
292865
|
|
|
292836
292866
|
// packages/core/dist/src/core/contentGenerator.js
|
|
292837
|
-
async function createContentGeneratorConfig(config3, authType, apiKey) {
|
|
292867
|
+
async function createContentGeneratorConfig(config3, authType, apiKey, baseUrl, customHeaders) {
|
|
292838
292868
|
const geminiApiKey = apiKey || process.env["GEMINI_API_KEY"] || await loadApiKey() || void 0;
|
|
292839
292869
|
const googleApiKey = process.env["GOOGLE_API_KEY"] || void 0;
|
|
292840
292870
|
const googleCloudProject = process.env["GOOGLE_CLOUD_PROJECT"] || process.env["GOOGLE_CLOUD_PROJECT_ID"] || void 0;
|
|
292841
292871
|
const googleCloudLocation = process.env["GOOGLE_CLOUD_LOCATION"] || void 0;
|
|
292842
292872
|
const contentGeneratorConfig = {
|
|
292843
292873
|
authType,
|
|
292844
|
-
proxy: config3?.getProxy()
|
|
292874
|
+
proxy: config3?.getProxy(),
|
|
292875
|
+
baseUrl,
|
|
292876
|
+
customHeaders
|
|
292845
292877
|
};
|
|
292846
292878
|
if (authType === AuthType2.LOGIN_WITH_GOOGLE || authType === AuthType2.COMPUTE_ADC) {
|
|
292847
292879
|
return contentGeneratorConfig;
|
|
@@ -292882,8 +292914,11 @@ async function createContentGenerator(config3, gcConfig, sessionId2) {
|
|
|
292882
292914
|
const httpOptions = { headers: baseHeaders };
|
|
292883
292915
|
return new LoggingContentGenerator(await createCodeAssistContentGenerator(httpOptions, config3.authType, gcConfig, sessionId2), gcConfig);
|
|
292884
292916
|
}
|
|
292885
|
-
if (config3.authType === AuthType2.USE_GEMINI || config3.authType === AuthType2.USE_VERTEX_AI) {
|
|
292917
|
+
if (config3.authType === AuthType2.USE_GEMINI || config3.authType === AuthType2.USE_VERTEX_AI || config3.authType === AuthType2.GATEWAY) {
|
|
292886
292918
|
let headers = { ...baseHeaders };
|
|
292919
|
+
if (config3.customHeaders) {
|
|
292920
|
+
headers = { ...headers, ...config3.customHeaders };
|
|
292921
|
+
}
|
|
292887
292922
|
if (gcConfig?.getUsageStatisticsEnabled()) {
|
|
292888
292923
|
const installationManager2 = new InstallationManager();
|
|
292889
292924
|
const installationId = installationManager2.getInstallationId();
|
|
@@ -292893,6 +292928,9 @@ async function createContentGenerator(config3, gcConfig, sessionId2) {
|
|
|
292893
292928
|
};
|
|
292894
292929
|
}
|
|
292895
292930
|
const httpOptions = { headers };
|
|
292931
|
+
if (config3.baseUrl) {
|
|
292932
|
+
httpOptions.baseUrl = config3.baseUrl;
|
|
292933
|
+
}
|
|
292896
292934
|
const googleGenAI = new GoogleGenAI({
|
|
292897
292935
|
apiKey: config3.apiKey === "" ? void 0 : config3.apiKey,
|
|
292898
292936
|
vertexai: config3.vertexai,
|
|
@@ -292927,6 +292965,7 @@ var init_contentGenerator = __esm({
|
|
|
292927
292965
|
AuthType3["USE_VERTEX_AI"] = "vertex-ai";
|
|
292928
292966
|
AuthType3["LEGACY_CLOUD_SHELL"] = "cloud-shell";
|
|
292929
292967
|
AuthType3["COMPUTE_ADC"] = "compute-default-credentials";
|
|
292968
|
+
AuthType3["GATEWAY"] = "gateway";
|
|
292930
292969
|
})(AuthType2 || (AuthType2 = {}));
|
|
292931
292970
|
}
|
|
292932
292971
|
});
|
|
@@ -293609,11 +293648,11 @@ Signal: Signal number or \`(none)\` if no signal was received.
|
|
|
293609
293648
|
buildToolMetadata() {
|
|
293610
293649
|
const toolMetadata = /* @__PURE__ */ new Map();
|
|
293611
293650
|
for (const [name4, tool] of this.allKnownTools) {
|
|
293612
|
-
|
|
293613
|
-
|
|
293614
|
-
|
|
293615
|
-
|
|
293616
|
-
|
|
293651
|
+
const metadata2 = tool.toolAnnotations ? { ...tool.toolAnnotations } : {};
|
|
293652
|
+
if (tool instanceof DiscoveredMCPTool) {
|
|
293653
|
+
metadata2["_serverName"] = tool.serverName;
|
|
293654
|
+
}
|
|
293655
|
+
if (Object.keys(metadata2).length > 0) {
|
|
293617
293656
|
toolMetadata.set(name4, metadata2);
|
|
293618
293657
|
}
|
|
293619
293658
|
}
|
|
@@ -400304,34 +400343,17 @@ function matchesWildcard(pattern, toolName, serverName) {
|
|
|
400304
400343
|
if (pattern === "*") {
|
|
400305
400344
|
return true;
|
|
400306
400345
|
}
|
|
400307
|
-
if (pattern
|
|
400308
|
-
return
|
|
400346
|
+
if (pattern === `${MCP_TOOL_PREFIX}*`) {
|
|
400347
|
+
return serverName !== void 0;
|
|
400309
400348
|
}
|
|
400310
|
-
|
|
400311
|
-
|
|
400312
|
-
|
|
400313
|
-
|
|
400314
|
-
|
|
400315
|
-
return
|
|
400316
|
-
const [patternServer, patternTool] = parts2;
|
|
400317
|
-
const { actualServer, actualTool } = getToolMetadata(toolName, serverName);
|
|
400318
|
-
if (actualServer === void 0) {
|
|
400319
|
-
return false;
|
|
400320
|
-
}
|
|
400321
|
-
if (serverName !== void 0 && !toolName.startsWith(serverName + "__")) {
|
|
400322
|
-
return false;
|
|
400349
|
+
if (pattern.startsWith(MCP_TOOL_PREFIX) && pattern.endsWith("_*")) {
|
|
400350
|
+
const expectedServerName = pattern.slice(MCP_TOOL_PREFIX.length, -2);
|
|
400351
|
+
if (serverName === void 0 || serverName !== expectedServerName) {
|
|
400352
|
+
return false;
|
|
400353
|
+
}
|
|
400354
|
+
return toolName.startsWith(`${MCP_TOOL_PREFIX}${expectedServerName}_`);
|
|
400323
400355
|
}
|
|
400324
|
-
|
|
400325
|
-
const toolMatch = patternTool === "*" || patternTool === actualTool;
|
|
400326
|
-
return serverMatch && toolMatch;
|
|
400327
|
-
}
|
|
400328
|
-
function getToolMetadata(toolName, serverName) {
|
|
400329
|
-
const sepIndex = toolName.indexOf("__");
|
|
400330
|
-
const isQualified = sepIndex !== -1;
|
|
400331
|
-
return {
|
|
400332
|
-
actualServer: serverName ?? (isQualified ? toolName.substring(0, sepIndex) : void 0),
|
|
400333
|
-
actualTool: isQualified ? toolName.substring(sepIndex + 2) : toolName
|
|
400334
|
-
};
|
|
400356
|
+
return toolName === pattern;
|
|
400335
400357
|
}
|
|
400336
400358
|
function ruleMatches(rule, toolCall, stringifiedArgs, serverName, currentApprovalMode, toolAnnotations) {
|
|
400337
400359
|
if (rule.modes && rule.modes.length > 0) {
|
|
@@ -400339,6 +400361,15 @@ function ruleMatches(rule, toolCall, stringifiedArgs, serverName, currentApprova
|
|
|
400339
400361
|
return false;
|
|
400340
400362
|
}
|
|
400341
400363
|
}
|
|
400364
|
+
if (rule.mcpName) {
|
|
400365
|
+
if (rule.mcpName === "*") {
|
|
400366
|
+
if (serverName === void 0)
|
|
400367
|
+
return false;
|
|
400368
|
+
} else {
|
|
400369
|
+
if (serverName !== rule.mcpName)
|
|
400370
|
+
return false;
|
|
400371
|
+
}
|
|
400372
|
+
}
|
|
400342
400373
|
if (rule.toolName) {
|
|
400343
400374
|
if (rule.toolName === "*") {
|
|
400344
400375
|
} else if (isWildcardPattern(rule.toolName)) {
|
|
@@ -400380,6 +400411,7 @@ var init_policy_engine = __esm({
|
|
|
400380
400411
|
init_protocol2();
|
|
400381
400412
|
init_shell_utils();
|
|
400382
400413
|
init_tool_names();
|
|
400414
|
+
init_mcp_tool();
|
|
400383
400415
|
PolicyEngine = class {
|
|
400384
400416
|
rules;
|
|
400385
400417
|
checkers;
|
|
@@ -400508,6 +400540,15 @@ var init_policy_engine = __esm({
|
|
|
400508
400540
|
* Returns the decision and the matching rule (if any).
|
|
400509
400541
|
*/
|
|
400510
400542
|
async check(toolCall, serverName, toolAnnotations) {
|
|
400543
|
+
if (!serverName && isMcpToolAnnotation(toolAnnotations)) {
|
|
400544
|
+
serverName = toolAnnotations._serverName;
|
|
400545
|
+
}
|
|
400546
|
+
if (!serverName && toolCall.name) {
|
|
400547
|
+
const parsed = parseMcpToolName(toolCall.name);
|
|
400548
|
+
if (parsed.serverName) {
|
|
400549
|
+
serverName = parsed.serverName;
|
|
400550
|
+
}
|
|
400551
|
+
}
|
|
400511
400552
|
let stringifiedArgs;
|
|
400512
400553
|
if (toolCall.args && (this.rules.some((rule) => rule.argsPattern) || this.checkers.some((checker) => checker.argsPattern))) {
|
|
400513
400554
|
stringifiedArgs = stableStringify(toolCall.args);
|
|
@@ -400529,12 +400570,6 @@ var init_policy_engine = __esm({
|
|
|
400529
400570
|
const toolCallsToTry = [];
|
|
400530
400571
|
for (const name4 of toolNamesToTry) {
|
|
400531
400572
|
toolCallsToTry.push({ ...toolCall, name: name4 });
|
|
400532
|
-
if (serverName && !name4.includes("__")) {
|
|
400533
|
-
toolCallsToTry.push({
|
|
400534
|
-
...toolCall,
|
|
400535
|
-
name: `${serverName}__${name4}`
|
|
400536
|
-
});
|
|
400537
|
-
}
|
|
400538
400573
|
}
|
|
400539
400574
|
for (const rule of this.rules) {
|
|
400540
400575
|
const match2 = toolCallsToTry.some((tc) => ruleMatches(rule, tc, stringifiedArgs, serverName, this.approvalMode, toolAnnotations));
|
|
@@ -400680,107 +400715,52 @@ var init_policy_engine = __esm({
|
|
|
400680
400715
|
*/
|
|
400681
400716
|
getExcludedTools(toolMetadata, allToolNames) {
|
|
400682
400717
|
const excludedTools = /* @__PURE__ */ new Set();
|
|
400683
|
-
|
|
400684
|
-
|
|
400685
|
-
|
|
400686
|
-
|
|
400687
|
-
|
|
400688
|
-
|
|
400689
|
-
|
|
400690
|
-
|
|
400691
|
-
|
|
400692
|
-
|
|
400693
|
-
|
|
400694
|
-
|
|
400695
|
-
|
|
400696
|
-
|
|
400697
|
-
|
|
400698
|
-
|
|
400699
|
-
|
|
400700
|
-
|
|
400701
|
-
|
|
400702
|
-
|
|
400703
|
-
|
|
400704
|
-
|
|
400705
|
-
|
|
400706
|
-
|
|
400707
|
-
|
|
400708
|
-
annotationsMatch = false;
|
|
400718
|
+
if (!allToolNames) {
|
|
400719
|
+
return excludedTools;
|
|
400720
|
+
}
|
|
400721
|
+
for (const toolName of allToolNames) {
|
|
400722
|
+
const annotations = toolMetadata?.get(toolName);
|
|
400723
|
+
const serverName = isMcpToolAnnotation(annotations) ? annotations._serverName : void 0;
|
|
400724
|
+
let staticallyExcluded = false;
|
|
400725
|
+
let matchFound = false;
|
|
400726
|
+
for (const rule of this.rules) {
|
|
400727
|
+
const ruleWithoutArgs = { ...rule, argsPattern: void 0 };
|
|
400728
|
+
const toolCall = { name: toolName, args: {} };
|
|
400729
|
+
const appliesToTool = ruleMatches(
|
|
400730
|
+
ruleWithoutArgs,
|
|
400731
|
+
toolCall,
|
|
400732
|
+
void 0,
|
|
400733
|
+
// stringifiedArgs
|
|
400734
|
+
serverName,
|
|
400735
|
+
this.approvalMode,
|
|
400736
|
+
annotations
|
|
400737
|
+
);
|
|
400738
|
+
if (appliesToTool) {
|
|
400739
|
+
if (rule.argsPattern) {
|
|
400740
|
+
if (rule.decision !== PolicyDecision.DENY) {
|
|
400741
|
+
staticallyExcluded = false;
|
|
400742
|
+
matchFound = true;
|
|
400709
400743
|
break;
|
|
400710
400744
|
}
|
|
400711
|
-
}
|
|
400712
|
-
if (!annotationsMatch) {
|
|
400713
400745
|
continue;
|
|
400714
|
-
}
|
|
400715
|
-
if (rule.toolName) {
|
|
400716
|
-
if (isWildcardPattern(rule.toolName)) {
|
|
400717
|
-
const rawServerName = annotations["_serverName"];
|
|
400718
|
-
const serverName = typeof rawServerName === "string" ? rawServerName : void 0;
|
|
400719
|
-
const qualifiedName = serverName && !toolName2.includes("__") ? `${serverName}__${toolName2}` : toolName2;
|
|
400720
|
-
if (!matchesWildcard(rule.toolName, qualifiedName, void 0)) {
|
|
400721
|
-
continue;
|
|
400722
|
-
}
|
|
400723
|
-
} else if (toolName2 !== rule.toolName) {
|
|
400724
|
-
continue;
|
|
400725
|
-
}
|
|
400726
|
-
}
|
|
400727
|
-
let decision2;
|
|
400728
|
-
if (globalVerdict !== void 0) {
|
|
400729
|
-
decision2 = globalVerdict;
|
|
400730
400746
|
} else {
|
|
400731
|
-
|
|
400732
|
-
|
|
400733
|
-
|
|
400734
|
-
excludedTools.add(toolName2);
|
|
400735
|
-
}
|
|
400736
|
-
processedTools.add(toolName2);
|
|
400737
|
-
}
|
|
400738
|
-
continue;
|
|
400739
|
-
}
|
|
400740
|
-
if (!rule.toolName) {
|
|
400741
|
-
if (globalVerdict === void 0) {
|
|
400742
|
-
globalVerdict = rule.decision;
|
|
400743
|
-
if (globalVerdict !== PolicyDecision.DENY) {
|
|
400747
|
+
const decision = this.applyNonInteractiveMode(rule.decision);
|
|
400748
|
+
staticallyExcluded = decision === PolicyDecision.DENY;
|
|
400749
|
+
matchFound = true;
|
|
400744
400750
|
break;
|
|
400745
400751
|
}
|
|
400746
400752
|
}
|
|
400747
|
-
continue;
|
|
400748
|
-
}
|
|
400749
|
-
const toolName = rule.toolName;
|
|
400750
|
-
if (processedTools.has(toolName)) {
|
|
400751
|
-
continue;
|
|
400752
400753
|
}
|
|
400753
|
-
|
|
400754
|
-
|
|
400755
|
-
if (
|
|
400756
|
-
|
|
400757
|
-
excludedTools.add(toolName);
|
|
400758
|
-
}
|
|
400759
|
-
coveredByWildcard = true;
|
|
400760
|
-
break;
|
|
400754
|
+
if (!matchFound) {
|
|
400755
|
+
const defaultDec = this.applyNonInteractiveMode(this.defaultDecision);
|
|
400756
|
+
if (defaultDec === PolicyDecision.DENY) {
|
|
400757
|
+
staticallyExcluded = true;
|
|
400761
400758
|
}
|
|
400762
400759
|
}
|
|
400763
|
-
if (
|
|
400764
|
-
continue;
|
|
400765
|
-
}
|
|
400766
|
-
processedTools.add(toolName);
|
|
400767
|
-
let decision;
|
|
400768
|
-
if (globalVerdict !== void 0) {
|
|
400769
|
-
decision = globalVerdict;
|
|
400770
|
-
} else {
|
|
400771
|
-
decision = rule.decision;
|
|
400772
|
-
}
|
|
400773
|
-
if (decision === PolicyDecision.DENY) {
|
|
400760
|
+
if (staticallyExcluded) {
|
|
400774
400761
|
excludedTools.add(toolName);
|
|
400775
400762
|
}
|
|
400776
400763
|
}
|
|
400777
|
-
if (globalVerdict === PolicyDecision.DENY && allToolNames) {
|
|
400778
|
-
for (const name4 of allToolNames) {
|
|
400779
|
-
if (!processedTools.has(name4)) {
|
|
400780
|
-
excludedTools.add(name4);
|
|
400781
|
-
}
|
|
400782
|
-
}
|
|
400783
|
-
}
|
|
400784
400764
|
return excludedTools;
|
|
400785
400765
|
}
|
|
400786
400766
|
applyNonInteractiveMode(decision) {
|
|
@@ -414045,7 +414025,10 @@ function validateShellCommandSyntax(rule, ruleIndex) {
|
|
|
414045
414025
|
return null;
|
|
414046
414026
|
}
|
|
414047
414027
|
function validateToolName(name4, ruleIndex) {
|
|
414048
|
-
if (
|
|
414028
|
+
if (name4.includes("__")) {
|
|
414029
|
+
return `Rule #${ruleIndex + 1}: The "__" syntax for MCP tools is strictly deprecated. Please use the 'mcpName = "..."' property or the 'mcp_server_tool' format instead.`;
|
|
414030
|
+
}
|
|
414031
|
+
if (isValidToolName(name4, { allowWildcards: true })) {
|
|
414049
414032
|
return null;
|
|
414050
414033
|
}
|
|
414051
414034
|
const allNames = [...ALL_BUILTIN_TOOL_NAMES];
|
|
@@ -414130,8 +414113,6 @@ async function loadPoliciesFromToml(policyPaths, getPolicyTier) {
|
|
|
414130
414113
|
}
|
|
414131
414114
|
for (let i4 = 0; i4 < tomlRules.length; i4++) {
|
|
414132
414115
|
const rule = tomlRules[i4];
|
|
414133
|
-
if (rule.mcpName)
|
|
414134
|
-
continue;
|
|
414135
414116
|
const toolNames = rule.toolName ? Array.isArray(rule.toolName) ? rule.toolName : [rule.toolName] : [];
|
|
414136
414117
|
for (const name4 of toolNames) {
|
|
414137
414118
|
const warning = validateToolName(name4, i4);
|
|
@@ -414154,16 +414135,14 @@ async function loadPoliciesFromToml(policyPaths, getPolicyTier) {
|
|
|
414154
414135
|
return argsPatterns.flatMap((argsPattern) => {
|
|
414155
414136
|
const toolNames = rule.toolName ? Array.isArray(rule.toolName) ? rule.toolName : [rule.toolName] : [void 0];
|
|
414156
414137
|
return toolNames.map((toolName) => {
|
|
414157
|
-
let effectiveToolName;
|
|
414158
|
-
|
|
414159
|
-
|
|
414160
|
-
|
|
414161
|
-
effectiveToolName = `${rule.mcpName}__*`;
|
|
414162
|
-
} else {
|
|
414163
|
-
effectiveToolName = toolName;
|
|
414138
|
+
let effectiveToolName = toolName;
|
|
414139
|
+
const mcpName = rule.mcpName;
|
|
414140
|
+
if (mcpName) {
|
|
414141
|
+
effectiveToolName = formatMcpToolName(mcpName, effectiveToolName);
|
|
414164
414142
|
}
|
|
414165
414143
|
const policyRule = {
|
|
414166
414144
|
toolName: effectiveToolName,
|
|
414145
|
+
mcpName: rule.mcpName,
|
|
414167
414146
|
decision: rule.decision,
|
|
414168
414147
|
priority: transformPriority(rule.priority, tier),
|
|
414169
414148
|
modes: rule.modes,
|
|
@@ -414237,14 +414216,15 @@ Error: ${error2.message}`,
|
|
|
414237
414216
|
return toolNames.map((toolName) => {
|
|
414238
414217
|
let effectiveToolName;
|
|
414239
414218
|
if (checker.mcpName && toolName) {
|
|
414240
|
-
effectiveToolName = `${checker.mcpName}
|
|
414219
|
+
effectiveToolName = `${MCP_TOOL_PREFIX}${checker.mcpName}_${toolName}`;
|
|
414241
414220
|
} else if (checker.mcpName) {
|
|
414242
|
-
effectiveToolName = `${checker.mcpName}
|
|
414221
|
+
effectiveToolName = `${MCP_TOOL_PREFIX}${checker.mcpName}_*`;
|
|
414243
414222
|
} else {
|
|
414244
414223
|
effectiveToolName = toolName;
|
|
414245
414224
|
}
|
|
414246
414225
|
const safetyCheckerRule = {
|
|
414247
414226
|
toolName: effectiveToolName,
|
|
414227
|
+
mcpName: checker.mcpName,
|
|
414248
414228
|
priority: transformPriority(checker.priority, tier),
|
|
414249
414229
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
414250
414230
|
checker: checker.checker,
|
|
@@ -414303,14 +414283,19 @@ Error: ${error2.message}`
|
|
|
414303
414283
|
return { rules, checkers, errors };
|
|
414304
414284
|
}
|
|
414305
414285
|
function validateMcpPolicyToolNames(serverName, discoveredToolNames, policyRules) {
|
|
414306
|
-
const prefix = `${serverName}
|
|
414286
|
+
const prefix = `${MCP_TOOL_PREFIX}${serverName}_`;
|
|
414307
414287
|
const warnings = [];
|
|
414308
414288
|
for (const rule of policyRules) {
|
|
414309
414289
|
if (!rule.toolName)
|
|
414310
414290
|
continue;
|
|
414311
|
-
|
|
414291
|
+
let toolPart;
|
|
414292
|
+
if (rule.mcpName === serverName && rule.toolName.startsWith(prefix)) {
|
|
414293
|
+
toolPart = rule.toolName.slice(prefix.length);
|
|
414294
|
+
} else if (rule.toolName.startsWith(prefix)) {
|
|
414295
|
+
toolPart = rule.toolName.slice(prefix.length);
|
|
414296
|
+
} else {
|
|
414312
414297
|
continue;
|
|
414313
|
-
|
|
414298
|
+
}
|
|
414314
414299
|
if (toolPart === "*")
|
|
414315
414300
|
continue;
|
|
414316
414301
|
if (discoveredToolNames.includes(toolPart))
|
|
@@ -414338,6 +414323,7 @@ var init_toml_loader = __esm({
|
|
|
414338
414323
|
import_toml = __toESM(require_toml(), 1);
|
|
414339
414324
|
init_zod();
|
|
414340
414325
|
init_errors();
|
|
414326
|
+
init_mcp_tool();
|
|
414341
414327
|
MAX_TYPO_DISTANCE = 3;
|
|
414342
414328
|
PolicyRuleSchema = external_exports.object({
|
|
414343
414329
|
toolName: external_exports.union([external_exports.string(), external_exports.array(external_exports.string())]).optional(),
|
|
@@ -414420,6 +414406,7 @@ var init_config3 = __esm({
|
|
|
414420
414406
|
init_shell_utils();
|
|
414421
414407
|
init_tool_names();
|
|
414422
414408
|
init_errors();
|
|
414409
|
+
init_mcp_tool();
|
|
414423
414410
|
init_security();
|
|
414424
414411
|
__filename3 = fileURLToPath15(import.meta.url);
|
|
414425
414412
|
__dirname7 = path77.dirname(__filename3);
|
|
@@ -419377,7 +419364,7 @@ var init_config4 = __esm({
|
|
|
419377
419364
|
getContentGenerator() {
|
|
419378
419365
|
return this.contentGenerator;
|
|
419379
419366
|
}
|
|
419380
|
-
async refreshAuth(authMethod, apiKey) {
|
|
419367
|
+
async refreshAuth(authMethod, apiKey, baseUrl, customHeaders) {
|
|
419381
419368
|
this.modelAvailabilityService.reset();
|
|
419382
419369
|
if (this.contentGeneratorConfig?.authType === AuthType2.USE_GEMINI && authMethod !== AuthType2.USE_GEMINI) {
|
|
419383
419370
|
this.geminiClient.stripThoughtsFromHistory();
|
|
@@ -419386,7 +419373,7 @@ var init_config4 = __esm({
|
|
|
419386
419373
|
if (this.contentGeneratorConfig) {
|
|
419387
419374
|
this.contentGeneratorConfig.authType = void 0;
|
|
419388
419375
|
}
|
|
419389
|
-
const newContentGeneratorConfig = await createContentGeneratorConfig(this, authMethod, apiKey);
|
|
419376
|
+
const newContentGeneratorConfig = await createContentGeneratorConfig(this, authMethod, apiKey, baseUrl, customHeaders);
|
|
419390
419377
|
this.contentGenerator = await createContentGenerator(newContentGeneratorConfig, this, this.getSessionId());
|
|
419391
419378
|
this.contentGeneratorConfig = newContentGeneratorConfig;
|
|
419392
419379
|
this.baseLlmClient = new BaseLlmClient(this.contentGenerator, this);
|