@google/gemini-cli 0.33.0-preview.4 → 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/bundle/gemini.js
CHANGED
|
@@ -105392,10 +105392,36 @@ var init_tools = __esm({
|
|
|
105392
105392
|
|
|
105393
105393
|
// packages/core/dist/src/tools/mcp-tool.js
|
|
105394
105394
|
function isMcpToolName(name4) {
|
|
105395
|
-
|
|
105396
|
-
|
|
105397
|
-
|
|
105398
|
-
|
|
105395
|
+
return name4.startsWith(MCP_TOOL_PREFIX);
|
|
105396
|
+
}
|
|
105397
|
+
function parseMcpToolName(name4) {
|
|
105398
|
+
if (!isMcpToolName(name4)) {
|
|
105399
|
+
return {};
|
|
105400
|
+
}
|
|
105401
|
+
const withoutPrefix = name4.slice(MCP_TOOL_PREFIX.length);
|
|
105402
|
+
const match2 = withoutPrefix.match(/^([^_]+)_(.+)$/);
|
|
105403
|
+
if (match2) {
|
|
105404
|
+
return {
|
|
105405
|
+
serverName: match2[1],
|
|
105406
|
+
toolName: match2[2]
|
|
105407
|
+
};
|
|
105408
|
+
}
|
|
105409
|
+
return {};
|
|
105410
|
+
}
|
|
105411
|
+
function formatMcpToolName(serverName, toolName) {
|
|
105412
|
+
if (serverName === "*" && !toolName) {
|
|
105413
|
+
return `${MCP_TOOL_PREFIX}*`;
|
|
105414
|
+
} else if (serverName === "*") {
|
|
105415
|
+
return `${MCP_TOOL_PREFIX}*_${toolName}`;
|
|
105416
|
+
} else if (!toolName) {
|
|
105417
|
+
return `${MCP_TOOL_PREFIX}${serverName}_*`;
|
|
105418
|
+
} else {
|
|
105419
|
+
return `${MCP_TOOL_PREFIX}${serverName}_${toolName}`;
|
|
105420
|
+
}
|
|
105421
|
+
}
|
|
105422
|
+
function isMcpToolAnnotation(annotation) {
|
|
105423
|
+
return typeof annotation === "object" && annotation !== null && // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
105424
|
+
typeof annotation["_serverName"] === "string";
|
|
105399
105425
|
}
|
|
105400
105426
|
function transformTextBlock(block) {
|
|
105401
105427
|
return { text: block.text };
|
|
@@ -105490,24 +105516,28 @@ function getStringifiedResultForDisplay(rawResponse) {
|
|
|
105490
105516
|
return displayParts.join("\n");
|
|
105491
105517
|
}
|
|
105492
105518
|
function generateValidName(name4) {
|
|
105493
|
-
let validToolname = name4.
|
|
105519
|
+
let validToolname = name4.startsWith("mcp_") ? name4 : `mcp_${name4}`;
|
|
105520
|
+
validToolname = validToolname.replace(/[^a-zA-Z0-9_\-.:]/g, "_");
|
|
105494
105521
|
if (/^[^a-zA-Z_]/.test(validToolname)) {
|
|
105495
105522
|
validToolname = `_${validToolname}`;
|
|
105496
105523
|
}
|
|
105497
105524
|
const safeLimit = MAX_FUNCTION_NAME_LENGTH - 1;
|
|
105498
105525
|
if (validToolname.length > safeLimit) {
|
|
105526
|
+
debugLogger.warn(`Truncating MCP tool name "${validToolname}" to fit within the 64 character limit. This tool may require user approval.`);
|
|
105499
105527
|
validToolname = validToolname.slice(0, 30) + "..." + validToolname.slice(-30);
|
|
105500
105528
|
}
|
|
105501
105529
|
return validToolname;
|
|
105502
105530
|
}
|
|
105503
|
-
var MCP_QUALIFIED_NAME_SEPARATOR, DiscoveredMCPToolInvocation, DiscoveredMCPTool, MAX_FUNCTION_NAME_LENGTH;
|
|
105531
|
+
var MCP_QUALIFIED_NAME_SEPARATOR, MCP_TOOL_PREFIX, DiscoveredMCPToolInvocation, DiscoveredMCPTool, MAX_FUNCTION_NAME_LENGTH;
|
|
105504
105532
|
var init_mcp_tool = __esm({
|
|
105505
105533
|
"packages/core/dist/src/tools/mcp-tool.js"() {
|
|
105506
105534
|
"use strict";
|
|
105507
105535
|
init_safeJsonStringify();
|
|
105536
|
+
init_debugLogger();
|
|
105508
105537
|
init_tools();
|
|
105509
105538
|
init_tool_error();
|
|
105510
|
-
MCP_QUALIFIED_NAME_SEPARATOR = "
|
|
105539
|
+
MCP_QUALIFIED_NAME_SEPARATOR = "_";
|
|
105540
|
+
MCP_TOOL_PREFIX = "mcp_";
|
|
105511
105541
|
DiscoveredMCPToolInvocation = class _DiscoveredMCPToolInvocation extends BaseToolInvocation {
|
|
105512
105542
|
mcpTool;
|
|
105513
105543
|
serverName;
|
|
@@ -105649,7 +105679,7 @@ var init_mcp_tool = __esm({
|
|
|
105649
105679
|
_toolAnnotations;
|
|
105650
105680
|
constructor(mcpTool, serverName, serverToolName, description, parameterSchema, messageBus, trust, isReadOnly, nameOverride, cliConfig, extensionName, extensionId, _toolAnnotations) {
|
|
105651
105681
|
super(
|
|
105652
|
-
|
|
105682
|
+
nameOverride ?? generateValidName(`${serverName}${MCP_QUALIFIED_NAME_SEPARATOR}${serverToolName}`),
|
|
105653
105683
|
`${serverToolName} (${serverName} MCP Server)`,
|
|
105654
105684
|
description,
|
|
105655
105685
|
Kind.Other,
|
|
@@ -105684,7 +105714,7 @@ var init_mcp_tool = __esm({
|
|
|
105684
105714
|
return this._toolAnnotations;
|
|
105685
105715
|
}
|
|
105686
105716
|
getFullyQualifiedPrefix() {
|
|
105687
|
-
return `${this.serverName}${MCP_QUALIFIED_NAME_SEPARATOR}
|
|
105717
|
+
return generateValidName(`${this.serverName}${MCP_QUALIFIED_NAME_SEPARATOR}`);
|
|
105688
105718
|
}
|
|
105689
105719
|
getFullyQualifiedName() {
|
|
105690
105720
|
return generateValidName(`${this.serverName}${MCP_QUALIFIED_NAME_SEPARATOR}${this.serverToolName}`);
|
|
@@ -196293,8 +196323,8 @@ var GIT_COMMIT_INFO, CLI_VERSION;
|
|
|
196293
196323
|
var init_git_commit = __esm({
|
|
196294
196324
|
"packages/core/dist/src/generated/git-commit.js"() {
|
|
196295
196325
|
"use strict";
|
|
196296
|
-
GIT_COMMIT_INFO = "
|
|
196297
|
-
CLI_VERSION = "0.33.0-preview.
|
|
196326
|
+
GIT_COMMIT_INFO = "a6256cdab";
|
|
196327
|
+
CLI_VERSION = "0.33.0-preview.5";
|
|
196298
196328
|
}
|
|
196299
196329
|
});
|
|
196300
196330
|
|
|
@@ -292762,7 +292792,7 @@ function getVersion() {
|
|
|
292762
292792
|
}
|
|
292763
292793
|
versionPromise = (async () => {
|
|
292764
292794
|
const pkgJson = await getPackageJson(__dirname3);
|
|
292765
|
-
return "0.33.0-preview.
|
|
292795
|
+
return "0.33.0-preview.5";
|
|
292766
292796
|
})();
|
|
292767
292797
|
return versionPromise;
|
|
292768
292798
|
}
|
|
@@ -294985,11 +295015,11 @@ Signal: Signal number or \`(none)\` if no signal was received.
|
|
|
294985
295015
|
buildToolMetadata() {
|
|
294986
295016
|
const toolMetadata = /* @__PURE__ */ new Map();
|
|
294987
295017
|
for (const [name4, tool] of this.allKnownTools) {
|
|
294988
|
-
|
|
294989
|
-
|
|
294990
|
-
|
|
294991
|
-
|
|
294992
|
-
|
|
295018
|
+
const metadata2 = tool.toolAnnotations ? { ...tool.toolAnnotations } : {};
|
|
295019
|
+
if (tool instanceof DiscoveredMCPTool) {
|
|
295020
|
+
metadata2["_serverName"] = tool.serverName;
|
|
295021
|
+
}
|
|
295022
|
+
if (Object.keys(metadata2).length > 0) {
|
|
294993
295023
|
toolMetadata.set(name4, metadata2);
|
|
294994
295024
|
}
|
|
294995
295025
|
}
|
|
@@ -411952,34 +411982,17 @@ function matchesWildcard(pattern, toolName, serverName) {
|
|
|
411952
411982
|
if (pattern === "*") {
|
|
411953
411983
|
return true;
|
|
411954
411984
|
}
|
|
411955
|
-
if (pattern
|
|
411956
|
-
return
|
|
411957
|
-
}
|
|
411958
|
-
return toolName === pattern;
|
|
411959
|
-
}
|
|
411960
|
-
function matchesCompositePattern(pattern, toolName, serverName) {
|
|
411961
|
-
const parts2 = pattern.split("__");
|
|
411962
|
-
if (parts2.length !== 2)
|
|
411963
|
-
return false;
|
|
411964
|
-
const [patternServer, patternTool] = parts2;
|
|
411965
|
-
const { actualServer, actualTool } = getToolMetadata(toolName, serverName);
|
|
411966
|
-
if (actualServer === void 0) {
|
|
411967
|
-
return false;
|
|
411985
|
+
if (pattern === `${MCP_TOOL_PREFIX}*`) {
|
|
411986
|
+
return serverName !== void 0;
|
|
411968
411987
|
}
|
|
411969
|
-
if (
|
|
411970
|
-
|
|
411988
|
+
if (pattern.startsWith(MCP_TOOL_PREFIX) && pattern.endsWith("_*")) {
|
|
411989
|
+
const expectedServerName = pattern.slice(MCP_TOOL_PREFIX.length, -2);
|
|
411990
|
+
if (serverName === void 0 || serverName !== expectedServerName) {
|
|
411991
|
+
return false;
|
|
411992
|
+
}
|
|
411993
|
+
return toolName.startsWith(`${MCP_TOOL_PREFIX}${expectedServerName}_`);
|
|
411971
411994
|
}
|
|
411972
|
-
|
|
411973
|
-
const toolMatch = patternTool === "*" || patternTool === actualTool;
|
|
411974
|
-
return serverMatch && toolMatch;
|
|
411975
|
-
}
|
|
411976
|
-
function getToolMetadata(toolName, serverName) {
|
|
411977
|
-
const sepIndex = toolName.indexOf("__");
|
|
411978
|
-
const isQualified = sepIndex !== -1;
|
|
411979
|
-
return {
|
|
411980
|
-
actualServer: serverName ?? (isQualified ? toolName.substring(0, sepIndex) : void 0),
|
|
411981
|
-
actualTool: isQualified ? toolName.substring(sepIndex + 2) : toolName
|
|
411982
|
-
};
|
|
411995
|
+
return toolName === pattern;
|
|
411983
411996
|
}
|
|
411984
411997
|
function ruleMatches(rule, toolCall, stringifiedArgs, serverName, currentApprovalMode, toolAnnotations) {
|
|
411985
411998
|
if (rule.modes && rule.modes.length > 0) {
|
|
@@ -411987,6 +412000,15 @@ function ruleMatches(rule, toolCall, stringifiedArgs, serverName, currentApprova
|
|
|
411987
412000
|
return false;
|
|
411988
412001
|
}
|
|
411989
412002
|
}
|
|
412003
|
+
if (rule.mcpName) {
|
|
412004
|
+
if (rule.mcpName === "*") {
|
|
412005
|
+
if (serverName === void 0)
|
|
412006
|
+
return false;
|
|
412007
|
+
} else {
|
|
412008
|
+
if (serverName !== rule.mcpName)
|
|
412009
|
+
return false;
|
|
412010
|
+
}
|
|
412011
|
+
}
|
|
411990
412012
|
if (rule.toolName) {
|
|
411991
412013
|
if (rule.toolName === "*") {
|
|
411992
412014
|
} else if (isWildcardPattern(rule.toolName)) {
|
|
@@ -412028,6 +412050,7 @@ var init_policy_engine = __esm({
|
|
|
412028
412050
|
init_protocol2();
|
|
412029
412051
|
init_shell_utils();
|
|
412030
412052
|
init_tool_names();
|
|
412053
|
+
init_mcp_tool();
|
|
412031
412054
|
PolicyEngine = class {
|
|
412032
412055
|
rules;
|
|
412033
412056
|
checkers;
|
|
@@ -412156,6 +412179,15 @@ var init_policy_engine = __esm({
|
|
|
412156
412179
|
* Returns the decision and the matching rule (if any).
|
|
412157
412180
|
*/
|
|
412158
412181
|
async check(toolCall, serverName, toolAnnotations) {
|
|
412182
|
+
if (!serverName && isMcpToolAnnotation(toolAnnotations)) {
|
|
412183
|
+
serverName = toolAnnotations._serverName;
|
|
412184
|
+
}
|
|
412185
|
+
if (!serverName && toolCall.name) {
|
|
412186
|
+
const parsed = parseMcpToolName(toolCall.name);
|
|
412187
|
+
if (parsed.serverName) {
|
|
412188
|
+
serverName = parsed.serverName;
|
|
412189
|
+
}
|
|
412190
|
+
}
|
|
412159
412191
|
let stringifiedArgs;
|
|
412160
412192
|
if (toolCall.args && (this.rules.some((rule) => rule.argsPattern) || this.checkers.some((checker) => checker.argsPattern))) {
|
|
412161
412193
|
stringifiedArgs = stableStringify(toolCall.args);
|
|
@@ -412177,12 +412209,6 @@ var init_policy_engine = __esm({
|
|
|
412177
412209
|
const toolCallsToTry = [];
|
|
412178
412210
|
for (const name4 of toolNamesToTry) {
|
|
412179
412211
|
toolCallsToTry.push({ ...toolCall, name: name4 });
|
|
412180
|
-
if (serverName && !name4.includes("__")) {
|
|
412181
|
-
toolCallsToTry.push({
|
|
412182
|
-
...toolCall,
|
|
412183
|
-
name: `${serverName}__${name4}`
|
|
412184
|
-
});
|
|
412185
|
-
}
|
|
412186
412212
|
}
|
|
412187
412213
|
for (const rule of this.rules) {
|
|
412188
412214
|
const match2 = toolCallsToTry.some((tc) => ruleMatches(rule, tc, stringifiedArgs, serverName, this.approvalMode, toolAnnotations));
|
|
@@ -412328,107 +412354,52 @@ var init_policy_engine = __esm({
|
|
|
412328
412354
|
*/
|
|
412329
412355
|
getExcludedTools(toolMetadata, allToolNames) {
|
|
412330
412356
|
const excludedTools = /* @__PURE__ */ new Set();
|
|
412331
|
-
|
|
412332
|
-
|
|
412333
|
-
|
|
412334
|
-
|
|
412335
|
-
|
|
412336
|
-
|
|
412337
|
-
|
|
412338
|
-
|
|
412339
|
-
|
|
412340
|
-
|
|
412341
|
-
|
|
412342
|
-
|
|
412343
|
-
|
|
412344
|
-
|
|
412345
|
-
|
|
412346
|
-
|
|
412347
|
-
|
|
412348
|
-
|
|
412349
|
-
|
|
412350
|
-
|
|
412351
|
-
|
|
412352
|
-
|
|
412353
|
-
|
|
412354
|
-
|
|
412355
|
-
|
|
412356
|
-
annotationsMatch = false;
|
|
412357
|
+
if (!allToolNames) {
|
|
412358
|
+
return excludedTools;
|
|
412359
|
+
}
|
|
412360
|
+
for (const toolName of allToolNames) {
|
|
412361
|
+
const annotations = toolMetadata?.get(toolName);
|
|
412362
|
+
const serverName = isMcpToolAnnotation(annotations) ? annotations._serverName : void 0;
|
|
412363
|
+
let staticallyExcluded = false;
|
|
412364
|
+
let matchFound = false;
|
|
412365
|
+
for (const rule of this.rules) {
|
|
412366
|
+
const ruleWithoutArgs = { ...rule, argsPattern: void 0 };
|
|
412367
|
+
const toolCall = { name: toolName, args: {} };
|
|
412368
|
+
const appliesToTool = ruleMatches(
|
|
412369
|
+
ruleWithoutArgs,
|
|
412370
|
+
toolCall,
|
|
412371
|
+
void 0,
|
|
412372
|
+
// stringifiedArgs
|
|
412373
|
+
serverName,
|
|
412374
|
+
this.approvalMode,
|
|
412375
|
+
annotations
|
|
412376
|
+
);
|
|
412377
|
+
if (appliesToTool) {
|
|
412378
|
+
if (rule.argsPattern) {
|
|
412379
|
+
if (rule.decision !== PolicyDecision.DENY) {
|
|
412380
|
+
staticallyExcluded = false;
|
|
412381
|
+
matchFound = true;
|
|
412357
412382
|
break;
|
|
412358
412383
|
}
|
|
412359
|
-
}
|
|
412360
|
-
if (!annotationsMatch) {
|
|
412361
412384
|
continue;
|
|
412362
|
-
}
|
|
412363
|
-
if (rule.toolName) {
|
|
412364
|
-
if (isWildcardPattern(rule.toolName)) {
|
|
412365
|
-
const rawServerName = annotations["_serverName"];
|
|
412366
|
-
const serverName = typeof rawServerName === "string" ? rawServerName : void 0;
|
|
412367
|
-
const qualifiedName = serverName && !toolName2.includes("__") ? `${serverName}__${toolName2}` : toolName2;
|
|
412368
|
-
if (!matchesWildcard(rule.toolName, qualifiedName, void 0)) {
|
|
412369
|
-
continue;
|
|
412370
|
-
}
|
|
412371
|
-
} else if (toolName2 !== rule.toolName) {
|
|
412372
|
-
continue;
|
|
412373
|
-
}
|
|
412374
|
-
}
|
|
412375
|
-
let decision2;
|
|
412376
|
-
if (globalVerdict !== void 0) {
|
|
412377
|
-
decision2 = globalVerdict;
|
|
412378
412385
|
} else {
|
|
412379
|
-
|
|
412380
|
-
|
|
412381
|
-
|
|
412382
|
-
excludedTools.add(toolName2);
|
|
412383
|
-
}
|
|
412384
|
-
processedTools.add(toolName2);
|
|
412385
|
-
}
|
|
412386
|
-
continue;
|
|
412387
|
-
}
|
|
412388
|
-
if (!rule.toolName) {
|
|
412389
|
-
if (globalVerdict === void 0) {
|
|
412390
|
-
globalVerdict = rule.decision;
|
|
412391
|
-
if (globalVerdict !== PolicyDecision.DENY) {
|
|
412386
|
+
const decision = this.applyNonInteractiveMode(rule.decision);
|
|
412387
|
+
staticallyExcluded = decision === PolicyDecision.DENY;
|
|
412388
|
+
matchFound = true;
|
|
412392
412389
|
break;
|
|
412393
412390
|
}
|
|
412394
412391
|
}
|
|
412395
|
-
continue;
|
|
412396
|
-
}
|
|
412397
|
-
const toolName = rule.toolName;
|
|
412398
|
-
if (processedTools.has(toolName)) {
|
|
412399
|
-
continue;
|
|
412400
412392
|
}
|
|
412401
|
-
|
|
412402
|
-
|
|
412403
|
-
if (
|
|
412404
|
-
|
|
412405
|
-
excludedTools.add(toolName);
|
|
412406
|
-
}
|
|
412407
|
-
coveredByWildcard = true;
|
|
412408
|
-
break;
|
|
412393
|
+
if (!matchFound) {
|
|
412394
|
+
const defaultDec = this.applyNonInteractiveMode(this.defaultDecision);
|
|
412395
|
+
if (defaultDec === PolicyDecision.DENY) {
|
|
412396
|
+
staticallyExcluded = true;
|
|
412409
412397
|
}
|
|
412410
412398
|
}
|
|
412411
|
-
if (
|
|
412412
|
-
continue;
|
|
412413
|
-
}
|
|
412414
|
-
processedTools.add(toolName);
|
|
412415
|
-
let decision;
|
|
412416
|
-
if (globalVerdict !== void 0) {
|
|
412417
|
-
decision = globalVerdict;
|
|
412418
|
-
} else {
|
|
412419
|
-
decision = rule.decision;
|
|
412420
|
-
}
|
|
412421
|
-
if (decision === PolicyDecision.DENY) {
|
|
412399
|
+
if (staticallyExcluded) {
|
|
412422
412400
|
excludedTools.add(toolName);
|
|
412423
412401
|
}
|
|
412424
412402
|
}
|
|
412425
|
-
if (globalVerdict === PolicyDecision.DENY && allToolNames) {
|
|
412426
|
-
for (const name4 of allToolNames) {
|
|
412427
|
-
if (!processedTools.has(name4)) {
|
|
412428
|
-
excludedTools.add(name4);
|
|
412429
|
-
}
|
|
412430
|
-
}
|
|
412431
|
-
}
|
|
412432
412403
|
return excludedTools;
|
|
412433
412404
|
}
|
|
412434
412405
|
applyNonInteractiveMode(decision) {
|
|
@@ -427981,7 +427952,10 @@ function validateShellCommandSyntax(rule, ruleIndex) {
|
|
|
427981
427952
|
return null;
|
|
427982
427953
|
}
|
|
427983
427954
|
function validateToolName(name4, ruleIndex) {
|
|
427984
|
-
if (
|
|
427955
|
+
if (name4.includes("__")) {
|
|
427956
|
+
return `Rule #${ruleIndex + 1}: The "__" syntax for MCP tools is strictly deprecated. Please use the 'mcpName = "..."' property or the 'mcp_server_tool' format instead.`;
|
|
427957
|
+
}
|
|
427958
|
+
if (isValidToolName(name4, { allowWildcards: true })) {
|
|
427985
427959
|
return null;
|
|
427986
427960
|
}
|
|
427987
427961
|
const allNames = [...ALL_BUILTIN_TOOL_NAMES];
|
|
@@ -428066,8 +428040,6 @@ async function loadPoliciesFromToml(policyPaths, getPolicyTier2) {
|
|
|
428066
428040
|
}
|
|
428067
428041
|
for (let i4 = 0; i4 < tomlRules.length; i4++) {
|
|
428068
428042
|
const rule = tomlRules[i4];
|
|
428069
|
-
if (rule.mcpName)
|
|
428070
|
-
continue;
|
|
428071
428043
|
const toolNames = rule.toolName ? Array.isArray(rule.toolName) ? rule.toolName : [rule.toolName] : [];
|
|
428072
428044
|
for (const name4 of toolNames) {
|
|
428073
428045
|
const warning = validateToolName(name4, i4);
|
|
@@ -428090,16 +428062,14 @@ async function loadPoliciesFromToml(policyPaths, getPolicyTier2) {
|
|
|
428090
428062
|
return argsPatterns.flatMap((argsPattern) => {
|
|
428091
428063
|
const toolNames = rule.toolName ? Array.isArray(rule.toolName) ? rule.toolName : [rule.toolName] : [void 0];
|
|
428092
428064
|
return toolNames.map((toolName) => {
|
|
428093
|
-
let effectiveToolName;
|
|
428094
|
-
|
|
428095
|
-
|
|
428096
|
-
|
|
428097
|
-
effectiveToolName = `${rule.mcpName}__*`;
|
|
428098
|
-
} else {
|
|
428099
|
-
effectiveToolName = toolName;
|
|
428065
|
+
let effectiveToolName = toolName;
|
|
428066
|
+
const mcpName = rule.mcpName;
|
|
428067
|
+
if (mcpName) {
|
|
428068
|
+
effectiveToolName = formatMcpToolName(mcpName, effectiveToolName);
|
|
428100
428069
|
}
|
|
428101
428070
|
const policyRule = {
|
|
428102
428071
|
toolName: effectiveToolName,
|
|
428072
|
+
mcpName: rule.mcpName,
|
|
428103
428073
|
decision: rule.decision,
|
|
428104
428074
|
priority: transformPriority(rule.priority, tier),
|
|
428105
428075
|
modes: rule.modes,
|
|
@@ -428173,14 +428143,15 @@ Error: ${error40.message}`,
|
|
|
428173
428143
|
return toolNames.map((toolName) => {
|
|
428174
428144
|
let effectiveToolName;
|
|
428175
428145
|
if (checker.mcpName && toolName) {
|
|
428176
|
-
effectiveToolName = `${checker.mcpName}
|
|
428146
|
+
effectiveToolName = `${MCP_TOOL_PREFIX}${checker.mcpName}_${toolName}`;
|
|
428177
428147
|
} else if (checker.mcpName) {
|
|
428178
|
-
effectiveToolName = `${checker.mcpName}
|
|
428148
|
+
effectiveToolName = `${MCP_TOOL_PREFIX}${checker.mcpName}_*`;
|
|
428179
428149
|
} else {
|
|
428180
428150
|
effectiveToolName = toolName;
|
|
428181
428151
|
}
|
|
428182
428152
|
const safetyCheckerRule = {
|
|
428183
428153
|
toolName: effectiveToolName,
|
|
428154
|
+
mcpName: checker.mcpName,
|
|
428184
428155
|
priority: transformPriority(checker.priority, tier),
|
|
428185
428156
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
428186
428157
|
checker: checker.checker,
|
|
@@ -428239,14 +428210,19 @@ Error: ${error40.message}`
|
|
|
428239
428210
|
return { rules, checkers, errors };
|
|
428240
428211
|
}
|
|
428241
428212
|
function validateMcpPolicyToolNames(serverName, discoveredToolNames, policyRules) {
|
|
428242
|
-
const prefix = `${serverName}
|
|
428213
|
+
const prefix = `${MCP_TOOL_PREFIX}${serverName}_`;
|
|
428243
428214
|
const warnings = [];
|
|
428244
428215
|
for (const rule of policyRules) {
|
|
428245
428216
|
if (!rule.toolName)
|
|
428246
428217
|
continue;
|
|
428247
|
-
|
|
428218
|
+
let toolPart;
|
|
428219
|
+
if (rule.mcpName === serverName && rule.toolName.startsWith(prefix)) {
|
|
428220
|
+
toolPart = rule.toolName.slice(prefix.length);
|
|
428221
|
+
} else if (rule.toolName.startsWith(prefix)) {
|
|
428222
|
+
toolPart = rule.toolName.slice(prefix.length);
|
|
428223
|
+
} else {
|
|
428248
428224
|
continue;
|
|
428249
|
-
|
|
428225
|
+
}
|
|
428250
428226
|
if (toolPart === "*")
|
|
428251
428227
|
continue;
|
|
428252
428228
|
if (discoveredToolNames.includes(toolPart))
|
|
@@ -428274,6 +428250,7 @@ var init_toml_loader = __esm({
|
|
|
428274
428250
|
import_toml = __toESM(require_toml(), 1);
|
|
428275
428251
|
init_zod();
|
|
428276
428252
|
init_errors();
|
|
428253
|
+
init_mcp_tool();
|
|
428277
428254
|
MAX_TYPO_DISTANCE = 3;
|
|
428278
428255
|
PolicyRuleSchema = external_exports.object({
|
|
428279
428256
|
toolName: external_exports.union([external_exports.string(), external_exports.array(external_exports.string())]).optional(),
|
|
@@ -428529,7 +428506,8 @@ async function createPolicyEngineConfig(settings, approvalMode, defaultPoliciesD
|
|
|
428529
428506
|
if (settings.mcp?.excluded) {
|
|
428530
428507
|
for (const serverName of settings.mcp.excluded) {
|
|
428531
428508
|
rules.push({
|
|
428532
|
-
toolName: `${serverName}
|
|
428509
|
+
toolName: serverName === "*" ? `${MCP_TOOL_PREFIX}*` : `${MCP_TOOL_PREFIX}${serverName}_*`,
|
|
428510
|
+
mcpName: serverName,
|
|
428533
428511
|
decision: PolicyDecision.DENY,
|
|
428534
428512
|
priority: MCP_EXCLUDED_PRIORITY,
|
|
428535
428513
|
source: "Settings (MCP Excluded)"
|
|
@@ -428588,7 +428566,8 @@ async function createPolicyEngineConfig(settings, approvalMode, defaultPoliciesD
|
|
|
428588
428566
|
for (const [serverName, serverConfig] of Object.entries(settings.mcpServers)) {
|
|
428589
428567
|
if (serverConfig.trust) {
|
|
428590
428568
|
rules.push({
|
|
428591
|
-
toolName: `${serverName}
|
|
428569
|
+
toolName: `${MCP_TOOL_PREFIX}${serverName}_*`,
|
|
428570
|
+
mcpName: serverName,
|
|
428592
428571
|
decision: PolicyDecision.ALLOW,
|
|
428593
428572
|
priority: TRUSTED_MCP_SERVER_PRIORITY,
|
|
428594
428573
|
source: "Settings (MCP Trusted)"
|
|
@@ -428599,7 +428578,8 @@ async function createPolicyEngineConfig(settings, approvalMode, defaultPoliciesD
|
|
|
428599
428578
|
if (settings.mcp?.allowed) {
|
|
428600
428579
|
for (const serverName of settings.mcp.allowed) {
|
|
428601
428580
|
rules.push({
|
|
428602
|
-
toolName: `${serverName}
|
|
428581
|
+
toolName: serverName === "*" ? `${MCP_TOOL_PREFIX}*` : `${MCP_TOOL_PREFIX}${serverName}_*`,
|
|
428582
|
+
mcpName: serverName,
|
|
428603
428583
|
decision: PolicyDecision.ALLOW,
|
|
428604
428584
|
priority: ALLOWED_MCP_SERVER_PRIORITY,
|
|
428605
428585
|
source: "Settings (MCP Allowed)"
|
|
@@ -428716,6 +428696,7 @@ var init_config3 = __esm({
|
|
|
428716
428696
|
init_shell_utils();
|
|
428717
428697
|
init_tool_names();
|
|
428718
428698
|
init_errors();
|
|
428699
|
+
init_mcp_tool();
|
|
428719
428700
|
init_security();
|
|
428720
428701
|
__filename3 = fileURLToPath15(import.meta.url);
|
|
428721
428702
|
__dirname7 = path69.dirname(__filename3);
|
|
@@ -441114,6 +441095,7 @@ __export(dist_exports, {
|
|
|
441114
441095
|
MCP_DEFAULT_TIMEOUT_MSEC: () => MCP_DEFAULT_TIMEOUT_MSEC,
|
|
441115
441096
|
MCP_EXCLUDED_PRIORITY: () => MCP_EXCLUDED_PRIORITY,
|
|
441116
441097
|
MCP_QUALIFIED_NAME_SEPARATOR: () => MCP_QUALIFIED_NAME_SEPARATOR,
|
|
441098
|
+
MCP_TOOL_PREFIX: () => MCP_TOOL_PREFIX,
|
|
441117
441099
|
MEDIA_FILE_PATTERNS: () => MEDIA_FILE_PATTERNS,
|
|
441118
441100
|
MEMORY_PARAM_FACT: () => MEMORY_PARAM_FACT,
|
|
441119
441101
|
MEMORY_SECTION_HEADER: () => MEMORY_SECTION_HEADER,
|
|
@@ -441343,6 +441325,7 @@ __export(dist_exports, {
|
|
|
441343
441325
|
flushTelemetry: () => flushTelemetry,
|
|
441344
441326
|
formatBytes: () => formatBytes,
|
|
441345
441327
|
formatCheckpointDisplayList: () => formatCheckpointDisplayList,
|
|
441328
|
+
formatMcpToolName: () => formatMcpToolName,
|
|
441346
441329
|
formatPolicyError: () => formatPolicyError,
|
|
441347
441330
|
formatProtoJsonDuration: () => formatProtoJsonDuration,
|
|
441348
441331
|
formatTruncatedToolOutput: () => formatTruncatedToolOutput,
|
|
@@ -441462,6 +441445,7 @@ __export(dist_exports, {
|
|
|
441462
441445
|
isHeadlessMode: () => isHeadlessMode,
|
|
441463
441446
|
isInvalidArgumentError: () => isInvalidArgumentError,
|
|
441464
441447
|
isJetBrainsTerminal: () => isJetBrainsTerminal,
|
|
441448
|
+
isMcpToolAnnotation: () => isMcpToolAnnotation,
|
|
441465
441449
|
isMcpToolName: () => isMcpToolName,
|
|
441466
441450
|
isNightly: () => isNightly,
|
|
441467
441451
|
isNodeError: () => isNodeError,
|
|
@@ -441536,6 +441520,7 @@ __export(dist_exports, {
|
|
|
441536
441520
|
parseBooleanEnvFlag: () => parseBooleanEnvFlag,
|
|
441537
441521
|
parseCommandDetails: () => parseCommandDetails,
|
|
441538
441522
|
parseGoogleApiError: () => parseGoogleApiError,
|
|
441523
|
+
parseMcpToolName: () => parseMcpToolName,
|
|
441539
441524
|
parsePrompt: () => parsePrompt,
|
|
441540
441525
|
parseTelemetryTargetValue: () => parseTelemetryTargetValue,
|
|
441541
441526
|
parseThought: () => parseThought,
|
|
@@ -515092,7 +515077,7 @@ var WarningMessage = ({ text }) => {
|
|
|
515092
515077
|
};
|
|
515093
515078
|
|
|
515094
515079
|
// packages/cli/src/generated/git-commit.ts
|
|
515095
|
-
var GIT_COMMIT_INFO2 = "
|
|
515080
|
+
var GIT_COMMIT_INFO2 = "508aaeda8";
|
|
515096
515081
|
|
|
515097
515082
|
// packages/cli/src/ui/components/AboutBox.tsx
|
|
515098
515083
|
init_dist8();
|
|
@@ -563509,7 +563494,7 @@ async function loadSandboxConfig(settings, argv) {
|
|
|
563509
563494
|
const sandboxOption = argv.sandbox ?? settings.tools?.sandbox;
|
|
563510
563495
|
const command2 = getSandboxCommand(sandboxOption);
|
|
563511
563496
|
const packageJson2 = await getPackageJson(__dirname13);
|
|
563512
|
-
const image2 = process.env["GEMINI_SANDBOX_IMAGE"] ?? "us-docker.pkg.dev/gemini-code-dev/gemini-cli/sandbox:0.33.0-preview.
|
|
563497
|
+
const image2 = process.env["GEMINI_SANDBOX_IMAGE"] ?? "us-docker.pkg.dev/gemini-code-dev/gemini-cli/sandbox:0.33.0-preview.5" ?? packageJson2?.config?.sandboxImageUri;
|
|
563513
563498
|
return command2 && image2 ? { command: command2, image: image2 } : void 0;
|
|
563514
563499
|
}
|
|
563515
563500
|
|