@google/gemini-cli-a2a-server 0.11.0-nightly.20251020.a96f0659 → 0.11.0-preview.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/a2a-server.mjs +624 -396
- package/dist/src/agent/task.d.ts +3 -3
- package/dist/src/agent/task.js +15 -11
- package/dist/src/agent/task.js.map +1 -1
- package/dist/src/agent/task.test.js +26 -0
- package/dist/src/agent/task.test.js.map +1 -1
- package/dist/src/config/config.js +3 -4
- package/dist/src/config/config.js.map +1 -1
- package/dist/src/http/app.test.js +23 -0
- package/dist/src/http/app.test.js.map +1 -1
- package/dist/src/http/endpoints.test.js +2 -1
- package/dist/src/http/endpoints.test.js.map +1 -1
- package/dist/src/persistence/gcs.js +9 -0
- package/dist/src/persistence/gcs.js.map +1 -1
- package/dist/src/persistence/gcs.test.js +31 -0
- package/dist/src/persistence/gcs.test.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
package/dist/a2a-server.mjs
CHANGED
|
@@ -223680,7 +223680,7 @@ var require_proxy_agent = __commonJS({
|
|
|
223680
223680
|
return this.#client.destroy(err2);
|
|
223681
223681
|
}
|
|
223682
223682
|
};
|
|
223683
|
-
var
|
|
223683
|
+
var ProxyAgent2 = class extends DispatcherBase {
|
|
223684
223684
|
constructor(opts) {
|
|
223685
223685
|
if (!opts || typeof opts === "object" && !(opts instanceof URL) && !opts.uri) {
|
|
223686
223686
|
throw new InvalidArgumentError("Proxy uri is mandatory");
|
|
@@ -223821,7 +223821,7 @@ var require_proxy_agent = __commonJS({
|
|
|
223821
223821
|
throw new InvalidArgumentError("Proxy-Authorization should be sent in ProxyAgent constructor");
|
|
223822
223822
|
}
|
|
223823
223823
|
}
|
|
223824
|
-
module2.exports =
|
|
223824
|
+
module2.exports = ProxyAgent2;
|
|
223825
223825
|
}
|
|
223826
223826
|
});
|
|
223827
223827
|
|
|
@@ -223831,7 +223831,7 @@ var require_env_http_proxy_agent = __commonJS({
|
|
|
223831
223831
|
"use strict";
|
|
223832
223832
|
var DispatcherBase = require_dispatcher_base();
|
|
223833
223833
|
var { kClose, kDestroy, kClosed, kDestroyed, kDispatch, kNoProxyAgent, kHttpProxyAgent, kHttpsProxyAgent } = require_symbols();
|
|
223834
|
-
var
|
|
223834
|
+
var ProxyAgent2 = require_proxy_agent();
|
|
223835
223835
|
var Agent3 = require_agent4();
|
|
223836
223836
|
var DEFAULT_PORTS = {
|
|
223837
223837
|
"http:": 80,
|
|
@@ -223848,13 +223848,13 @@ var require_env_http_proxy_agent = __commonJS({
|
|
|
223848
223848
|
this[kNoProxyAgent] = new Agent3(agentOpts);
|
|
223849
223849
|
const HTTP_PROXY = httpProxy ?? process.env.http_proxy ?? process.env.HTTP_PROXY;
|
|
223850
223850
|
if (HTTP_PROXY) {
|
|
223851
|
-
this[kHttpProxyAgent] = new
|
|
223851
|
+
this[kHttpProxyAgent] = new ProxyAgent2({ ...agentOpts, uri: HTTP_PROXY });
|
|
223852
223852
|
} else {
|
|
223853
223853
|
this[kHttpProxyAgent] = this[kNoProxyAgent];
|
|
223854
223854
|
}
|
|
223855
223855
|
const HTTPS_PROXY = httpsProxy ?? process.env.https_proxy ?? process.env.HTTPS_PROXY;
|
|
223856
223856
|
if (HTTPS_PROXY) {
|
|
223857
|
-
this[kHttpsProxyAgent] = new
|
|
223857
|
+
this[kHttpsProxyAgent] = new ProxyAgent2({ ...agentOpts, uri: HTTPS_PROXY });
|
|
223858
223858
|
} else {
|
|
223859
223859
|
this[kHttpsProxyAgent] = this[kHttpProxyAgent];
|
|
223860
223860
|
}
|
|
@@ -227433,9 +227433,9 @@ var require_global2 = __commonJS({
|
|
|
227433
227433
|
var { InvalidArgumentError } = require_errors6();
|
|
227434
227434
|
var Agent3 = require_agent4();
|
|
227435
227435
|
if (getGlobalDispatcher() === void 0) {
|
|
227436
|
-
|
|
227436
|
+
setGlobalDispatcher2(new Agent3());
|
|
227437
227437
|
}
|
|
227438
|
-
function
|
|
227438
|
+
function setGlobalDispatcher2(agent) {
|
|
227439
227439
|
if (!agent || typeof agent.dispatch !== "function") {
|
|
227440
227440
|
throw new InvalidArgumentError("Argument agent must implement Agent");
|
|
227441
227441
|
}
|
|
@@ -227450,7 +227450,7 @@ var require_global2 = __commonJS({
|
|
|
227450
227450
|
return globalThis[globalDispatcher];
|
|
227451
227451
|
}
|
|
227452
227452
|
module2.exports = {
|
|
227453
|
-
setGlobalDispatcher:
|
|
227453
|
+
setGlobalDispatcher: setGlobalDispatcher2,
|
|
227454
227454
|
getGlobalDispatcher
|
|
227455
227455
|
};
|
|
227456
227456
|
}
|
|
@@ -236675,7 +236675,7 @@ var require_undici = __commonJS({
|
|
|
236675
236675
|
var Pool = require_pool2();
|
|
236676
236676
|
var BalancedPool = require_balanced_pool();
|
|
236677
236677
|
var Agent3 = require_agent4();
|
|
236678
|
-
var
|
|
236678
|
+
var ProxyAgent2 = require_proxy_agent();
|
|
236679
236679
|
var EnvHttpProxyAgent2 = require_env_http_proxy_agent();
|
|
236680
236680
|
var RetryAgent = require_retry_agent();
|
|
236681
236681
|
var H2CClient = require_h2c_client();
|
|
@@ -236691,7 +236691,7 @@ var require_undici = __commonJS({
|
|
|
236691
236691
|
var SnapshotAgent = require_snapshot_agent();
|
|
236692
236692
|
var mockErrors = require_mock_errors();
|
|
236693
236693
|
var RetryHandler = require_retry_handler();
|
|
236694
|
-
var { getGlobalDispatcher, setGlobalDispatcher:
|
|
236694
|
+
var { getGlobalDispatcher, setGlobalDispatcher: setGlobalDispatcher2 } = require_global2();
|
|
236695
236695
|
var DecoratorHandler = require_decorator_handler();
|
|
236696
236696
|
var RedirectHandler = require_redirect_handler();
|
|
236697
236697
|
Object.assign(Dispatcher.prototype, api);
|
|
@@ -236700,7 +236700,7 @@ var require_undici = __commonJS({
|
|
|
236700
236700
|
module2.exports.Pool = Pool;
|
|
236701
236701
|
module2.exports.BalancedPool = BalancedPool;
|
|
236702
236702
|
module2.exports.Agent = Agent3;
|
|
236703
|
-
module2.exports.ProxyAgent =
|
|
236703
|
+
module2.exports.ProxyAgent = ProxyAgent2;
|
|
236704
236704
|
module2.exports.EnvHttpProxyAgent = EnvHttpProxyAgent2;
|
|
236705
236705
|
module2.exports.RetryAgent = RetryAgent;
|
|
236706
236706
|
module2.exports.H2CClient = H2CClient;
|
|
@@ -236766,7 +236766,7 @@ var require_undici = __commonJS({
|
|
|
236766
236766
|
}, handler);
|
|
236767
236767
|
};
|
|
236768
236768
|
}
|
|
236769
|
-
module2.exports.setGlobalDispatcher =
|
|
236769
|
+
module2.exports.setGlobalDispatcher = setGlobalDispatcher2;
|
|
236770
236770
|
module2.exports.getGlobalDispatcher = getGlobalDispatcher;
|
|
236771
236771
|
var fetchImpl = require_fetch2().fetch;
|
|
236772
236772
|
module2.exports.fetch = async function fetch2(init3, options2 = void 0) {
|
|
@@ -285059,6 +285059,23 @@ var Storage2 = class _Storage {
|
|
|
285059
285059
|
}
|
|
285060
285060
|
};
|
|
285061
285061
|
|
|
285062
|
+
// packages/core/dist/src/utils/debugLogger.js
|
|
285063
|
+
var DebugLogger = class {
|
|
285064
|
+
log(...args2) {
|
|
285065
|
+
console.log(...args2);
|
|
285066
|
+
}
|
|
285067
|
+
warn(...args2) {
|
|
285068
|
+
console.warn(...args2);
|
|
285069
|
+
}
|
|
285070
|
+
error(...args2) {
|
|
285071
|
+
console.error(...args2);
|
|
285072
|
+
}
|
|
285073
|
+
debug(...args2) {
|
|
285074
|
+
console.debug(...args2);
|
|
285075
|
+
}
|
|
285076
|
+
};
|
|
285077
|
+
var debugLogger = new DebugLogger();
|
|
285078
|
+
|
|
285062
285079
|
// packages/core/dist/src/utils/userAccountManager.js
|
|
285063
285080
|
var UserAccountManager = class {
|
|
285064
285081
|
getGoogleAccountsCachePath() {
|
|
@@ -285076,13 +285093,13 @@ var UserAccountManager = class {
|
|
|
285076
285093
|
}
|
|
285077
285094
|
const parsed = JSON.parse(content);
|
|
285078
285095
|
if (typeof parsed !== "object" || parsed === null) {
|
|
285079
|
-
|
|
285096
|
+
debugLogger.log("Invalid accounts file schema, starting fresh.");
|
|
285080
285097
|
return defaultState;
|
|
285081
285098
|
}
|
|
285082
285099
|
const { active, old } = parsed;
|
|
285083
285100
|
const isValid2 = (active === void 0 || active === null || typeof active === "string") && (old === void 0 || Array.isArray(old) && old.every((i3) => typeof i3 === "string"));
|
|
285084
285101
|
if (!isValid2) {
|
|
285085
|
-
|
|
285102
|
+
debugLogger.log("Invalid accounts file schema, starting fresh.");
|
|
285086
285103
|
return defaultState;
|
|
285087
285104
|
}
|
|
285088
285105
|
return {
|
|
@@ -285099,7 +285116,7 @@ var UserAccountManager = class {
|
|
|
285099
285116
|
if (error instanceof Error && "code" in error && error.code === "ENOENT") {
|
|
285100
285117
|
return defaultState;
|
|
285101
285118
|
}
|
|
285102
|
-
|
|
285119
|
+
debugLogger.log("Error during sync read of accounts, starting fresh.", error);
|
|
285103
285120
|
return defaultState;
|
|
285104
285121
|
}
|
|
285105
285122
|
}
|
|
@@ -285112,7 +285129,7 @@ var UserAccountManager = class {
|
|
|
285112
285129
|
if (error instanceof Error && "code" in error && error.code === "ENOENT") {
|
|
285113
285130
|
return defaultState;
|
|
285114
285131
|
}
|
|
285115
|
-
|
|
285132
|
+
debugLogger.log("Could not parse accounts file, starting fresh.", error);
|
|
285116
285133
|
return defaultState;
|
|
285117
285134
|
}
|
|
285118
285135
|
}
|
|
@@ -285512,21 +285529,21 @@ async function initOauthClient(authType, config2) {
|
|
|
285512
285529
|
try {
|
|
285513
285530
|
await fetchAndCacheUserInfo(client);
|
|
285514
285531
|
} catch (error) {
|
|
285515
|
-
|
|
285532
|
+
debugLogger.warn("Failed to fetch user info:", getErrorMessage(error));
|
|
285516
285533
|
}
|
|
285517
285534
|
}
|
|
285518
|
-
|
|
285535
|
+
debugLogger.log("Loaded cached credentials.");
|
|
285519
285536
|
return client;
|
|
285520
285537
|
}
|
|
285521
285538
|
if (authType === AuthType2.CLOUD_SHELL) {
|
|
285522
285539
|
try {
|
|
285523
|
-
|
|
285540
|
+
debugLogger.log("Attempting to authenticate via Cloud Shell VM's ADC.");
|
|
285524
285541
|
const computeClient = new import_google_auth_library8.Compute({
|
|
285525
285542
|
// We can leave this empty, since the metadata server will provide
|
|
285526
285543
|
// the service account email.
|
|
285527
285544
|
});
|
|
285528
285545
|
await computeClient.getAccessToken();
|
|
285529
|
-
|
|
285546
|
+
debugLogger.log("Authentication successful.");
|
|
285530
285547
|
return computeClient;
|
|
285531
285548
|
} catch (e2) {
|
|
285532
285549
|
throw new Error(`Could not authenticate using Cloud Shell credentials. Please select a different authentication method or ensure you are in a properly configured environment. Error: ${getErrorMessage(e2)}`);
|
|
@@ -285546,7 +285563,7 @@ async function initOauthClient(authType, config2) {
|
|
|
285546
285563
|
}
|
|
285547
285564
|
} else {
|
|
285548
285565
|
const webLogin = await authWithWeb(client);
|
|
285549
|
-
|
|
285566
|
+
debugLogger.log(`
|
|
285550
285567
|
|
|
285551
285568
|
Code Assist login required.
|
|
285552
285569
|
Attempting to open authentication page in your browser.
|
|
@@ -285565,7 +285582,7 @@ ${webLogin.authUrl}
|
|
|
285565
285582
|
console.error("An unexpected error occurred while trying to open the browser:", getErrorMessage(err2), "\nThis might be due to browser compatibility issues or system configuration.", "\nPlease try running again with NO_BROWSER=true set for manual authentication.");
|
|
285566
285583
|
throw new FatalAuthenticationError(`Failed to open browser: ${getErrorMessage(err2)}`);
|
|
285567
285584
|
}
|
|
285568
|
-
|
|
285585
|
+
debugLogger.log("Waiting for authentication...");
|
|
285569
285586
|
const authTimeout = 5 * 60 * 1e3;
|
|
285570
285587
|
const timeoutPromise = new Promise((_, reject) => {
|
|
285571
285588
|
setTimeout(() => {
|
|
@@ -285594,10 +285611,10 @@ async function authWithUserCode(client) {
|
|
|
285594
285611
|
code_challenge: codeVerifier.codeChallenge,
|
|
285595
285612
|
state
|
|
285596
285613
|
});
|
|
285597
|
-
|
|
285598
|
-
|
|
285599
|
-
|
|
285600
|
-
|
|
285614
|
+
debugLogger.log("Please visit the following URL to authorize the application:");
|
|
285615
|
+
debugLogger.log("");
|
|
285616
|
+
debugLogger.log(authUrl);
|
|
285617
|
+
debugLogger.log("");
|
|
285601
285618
|
const code2 = await new Promise((resolve13) => {
|
|
285602
285619
|
const rl = readline.createInterface({
|
|
285603
285620
|
input: process.stdin,
|
|
@@ -285664,7 +285681,7 @@ async function authWithWeb(client) {
|
|
|
285664
285681
|
try {
|
|
285665
285682
|
await fetchAndCacheUserInfo(client);
|
|
285666
285683
|
} catch (error) {
|
|
285667
|
-
|
|
285684
|
+
debugLogger.warn("Failed to retrieve Google Account ID during authentication:", getErrorMessage(error));
|
|
285668
285685
|
}
|
|
285669
285686
|
res.writeHead(HTTP_REDIRECT, { Location: SIGN_IN_SUCCESS_URL });
|
|
285670
285687
|
res.end();
|
|
@@ -285751,7 +285768,7 @@ async function loadCachedCredentials(client) {
|
|
|
285751
285768
|
await client.getTokenInfo(token2);
|
|
285752
285769
|
return true;
|
|
285753
285770
|
} catch (error) {
|
|
285754
|
-
|
|
285771
|
+
debugLogger.debug(`Failed to load credentials from ${keyFile}:`, getErrorMessage(error));
|
|
285755
285772
|
}
|
|
285756
285773
|
}
|
|
285757
285774
|
return false;
|
|
@@ -285847,6 +285864,7 @@ function fromGenerateContentResponse(res) {
|
|
|
285847
285864
|
out2.promptFeedback = inres.promptFeedback;
|
|
285848
285865
|
out2.usageMetadata = inres.usageMetadata;
|
|
285849
285866
|
out2.modelVersion = inres.modelVersion;
|
|
285867
|
+
out2.responseId = res.traceId;
|
|
285850
285868
|
return out2;
|
|
285851
285869
|
}
|
|
285852
285870
|
function toVertexGenerateContentRequest(req, sessionId2) {
|
|
@@ -286303,24 +286321,53 @@ var MessageBusType;
|
|
|
286303
286321
|
MessageBusType2["TOOL_POLICY_REJECTION"] = "tool-policy-rejection";
|
|
286304
286322
|
MessageBusType2["TOOL_EXECUTION_SUCCESS"] = "tool-execution-success";
|
|
286305
286323
|
MessageBusType2["TOOL_EXECUTION_FAILURE"] = "tool-execution-failure";
|
|
286324
|
+
MessageBusType2["UPDATE_POLICY"] = "update-policy";
|
|
286306
286325
|
})(MessageBusType || (MessageBusType = {}));
|
|
286307
286326
|
|
|
286308
286327
|
// packages/core/dist/src/tools/tools.js
|
|
286309
286328
|
var BaseToolInvocation = class {
|
|
286310
286329
|
params;
|
|
286311
286330
|
messageBus;
|
|
286312
|
-
|
|
286331
|
+
_toolName;
|
|
286332
|
+
_toolDisplayName;
|
|
286333
|
+
constructor(params, messageBus, _toolName, _toolDisplayName) {
|
|
286313
286334
|
this.params = params;
|
|
286314
286335
|
this.messageBus = messageBus;
|
|
286315
|
-
|
|
286316
|
-
|
|
286317
|
-
}
|
|
286336
|
+
this._toolName = _toolName;
|
|
286337
|
+
this._toolDisplayName = _toolDisplayName;
|
|
286318
286338
|
}
|
|
286319
286339
|
toolLocations() {
|
|
286320
286340
|
return [];
|
|
286321
286341
|
}
|
|
286322
|
-
shouldConfirmExecute(
|
|
286323
|
-
|
|
286342
|
+
async shouldConfirmExecute(abortSignal) {
|
|
286343
|
+
if (this.messageBus) {
|
|
286344
|
+
const decision = await this.getMessageBusDecision(abortSignal);
|
|
286345
|
+
if (decision === "ALLOW") {
|
|
286346
|
+
return false;
|
|
286347
|
+
}
|
|
286348
|
+
if (decision === "DENY") {
|
|
286349
|
+
throw new Error(`Tool execution for "${this._toolDisplayName || this._toolName}" denied by policy.`);
|
|
286350
|
+
}
|
|
286351
|
+
if (decision === "ASK_USER") {
|
|
286352
|
+
const confirmationDetails = {
|
|
286353
|
+
type: "info",
|
|
286354
|
+
title: `Confirm: ${this._toolDisplayName || this._toolName}`,
|
|
286355
|
+
prompt: this.getDescription(),
|
|
286356
|
+
onConfirm: async (outcome) => {
|
|
286357
|
+
if (outcome === ToolConfirmationOutcome.ProceedAlways) {
|
|
286358
|
+
if (this.messageBus && this._toolName) {
|
|
286359
|
+
this.messageBus.publish({
|
|
286360
|
+
type: MessageBusType.UPDATE_POLICY,
|
|
286361
|
+
toolName: this._toolName
|
|
286362
|
+
});
|
|
286363
|
+
}
|
|
286364
|
+
}
|
|
286365
|
+
}
|
|
286366
|
+
};
|
|
286367
|
+
return confirmationDetails;
|
|
286368
|
+
}
|
|
286369
|
+
}
|
|
286370
|
+
return false;
|
|
286324
286371
|
}
|
|
286325
286372
|
getMessageBusDecision(abortSignal) {
|
|
286326
286373
|
if (!this.messageBus) {
|
|
@@ -286328,7 +286375,7 @@ var BaseToolInvocation = class {
|
|
|
286328
286375
|
}
|
|
286329
286376
|
const correlationId = randomUUID3();
|
|
286330
286377
|
const toolCall = {
|
|
286331
|
-
name: this.constructor.name,
|
|
286378
|
+
name: this._toolName || this.constructor.name,
|
|
286332
286379
|
args: this.params
|
|
286333
286380
|
};
|
|
286334
286381
|
return new Promise((resolve13) => {
|
|
@@ -286394,7 +286441,8 @@ var DeclarativeTool = class {
|
|
|
286394
286441
|
isOutputMarkdown;
|
|
286395
286442
|
canUpdateOutput;
|
|
286396
286443
|
messageBus;
|
|
286397
|
-
|
|
286444
|
+
extensionId;
|
|
286445
|
+
constructor(name4, displayName, description, kind, parameterSchema, isOutputMarkdown = true, canUpdateOutput = false, messageBus, extensionId) {
|
|
286398
286446
|
this.name = name4;
|
|
286399
286447
|
this.displayName = displayName;
|
|
286400
286448
|
this.description = description;
|
|
@@ -286403,6 +286451,7 @@ var DeclarativeTool = class {
|
|
|
286403
286451
|
this.isOutputMarkdown = isOutputMarkdown;
|
|
286404
286452
|
this.canUpdateOutput = canUpdateOutput;
|
|
286405
286453
|
this.messageBus = messageBus;
|
|
286454
|
+
this.extensionId = extensionId;
|
|
286406
286455
|
}
|
|
286407
286456
|
get schema() {
|
|
286408
286457
|
return {
|
|
@@ -286489,7 +286538,7 @@ var BaseDeclarativeTool = class extends DeclarativeTool {
|
|
|
286489
286538
|
if (validationError) {
|
|
286490
286539
|
throw new Error(validationError);
|
|
286491
286540
|
}
|
|
286492
|
-
return this.createInvocation(params, this.messageBus);
|
|
286541
|
+
return this.createInvocation(params, this.messageBus, this.name, this.displayName);
|
|
286493
286542
|
}
|
|
286494
286543
|
validateToolParams(params) {
|
|
286495
286544
|
const errors = SchemaValidator.validate(this.schema.parametersJsonSchema, params);
|
|
@@ -286708,7 +286757,8 @@ var DiscoveredMCPTool = class _DiscoveredMCPTool extends BaseDeclarativeTool {
|
|
|
286708
286757
|
parameterSchema;
|
|
286709
286758
|
trust;
|
|
286710
286759
|
cliConfig;
|
|
286711
|
-
|
|
286760
|
+
extensionId;
|
|
286761
|
+
constructor(mcpTool, serverName, serverToolName, description, parameterSchema, trust, nameOverride, cliConfig, extensionId) {
|
|
286712
286762
|
super(
|
|
286713
286763
|
nameOverride ?? generateValidName(serverToolName),
|
|
286714
286764
|
`${serverToolName} (${serverName} MCP Server)`,
|
|
@@ -286717,7 +286767,11 @@ var DiscoveredMCPTool = class _DiscoveredMCPTool extends BaseDeclarativeTool {
|
|
|
286717
286767
|
parameterSchema,
|
|
286718
286768
|
true,
|
|
286719
286769
|
// isOutputMarkdown
|
|
286720
|
-
false
|
|
286770
|
+
false,
|
|
286771
|
+
// canUpdateOutput
|
|
286772
|
+
void 0,
|
|
286773
|
+
// messageBus
|
|
286774
|
+
extensionId
|
|
286721
286775
|
);
|
|
286722
286776
|
this.mcpTool = mcpTool;
|
|
286723
286777
|
this.serverName = serverName;
|
|
@@ -286725,9 +286779,10 @@ var DiscoveredMCPTool = class _DiscoveredMCPTool extends BaseDeclarativeTool {
|
|
|
286725
286779
|
this.parameterSchema = parameterSchema;
|
|
286726
286780
|
this.trust = trust;
|
|
286727
286781
|
this.cliConfig = cliConfig;
|
|
286782
|
+
this.extensionId = extensionId;
|
|
286728
286783
|
}
|
|
286729
286784
|
asFullyQualifiedTool() {
|
|
286730
|
-
return new _DiscoveredMCPTool(this.mcpTool, this.serverName, this.serverToolName, this.description, this.parameterSchema, this.trust, `${this.serverName}__${this.serverToolName}`, this.cliConfig);
|
|
286785
|
+
return new _DiscoveredMCPTool(this.mcpTool, this.serverName, this.serverToolName, this.description, this.parameterSchema, this.trust, `${this.serverName}__${this.serverToolName}`, this.cliConfig, this.extensionId);
|
|
286731
286786
|
}
|
|
286732
286787
|
createInvocation(params) {
|
|
286733
286788
|
return new DiscoveredMCPToolInvocation(this.mcpTool, this.serverName, this.serverToolName, this.displayName, this.trust, params, this.cliConfig);
|
|
@@ -286933,6 +286988,8 @@ var StartSessionEvent = class {
|
|
|
286933
286988
|
mcp_tools_count;
|
|
286934
286989
|
mcp_tools;
|
|
286935
286990
|
output_format;
|
|
286991
|
+
extensions_count;
|
|
286992
|
+
extension_ids;
|
|
286936
286993
|
constructor(config2, toolRegistry) {
|
|
286937
286994
|
const generatorConfig = config2.getContentGeneratorConfig();
|
|
286938
286995
|
const mcpServers = config2.getMcpServers();
|
|
@@ -286958,6 +287015,9 @@ var StartSessionEvent = class {
|
|
|
286958
287015
|
this.file_filtering_respect_git_ignore = config2.getFileFilteringRespectGitIgnore();
|
|
286959
287016
|
this.mcp_servers_count = mcpServers ? Object.keys(mcpServers).length : 0;
|
|
286960
287017
|
this.output_format = config2.getOutputFormat();
|
|
287018
|
+
const extensions = config2.getExtensions();
|
|
287019
|
+
this.extensions_count = extensions.length;
|
|
287020
|
+
this.extension_ids = extensions.map((e2) => e2.id).join(",");
|
|
286961
287021
|
if (toolRegistry) {
|
|
286962
287022
|
const mcpTools = toolRegistry.getAllTools().filter((tool) => tool instanceof DiscoveredMCPTool);
|
|
286963
287023
|
this.mcp_tools_count = mcpTools.length;
|
|
@@ -286983,7 +287043,9 @@ var StartSessionEvent = class {
|
|
|
286983
287043
|
mcp_servers_count: this.mcp_servers_count,
|
|
286984
287044
|
mcp_tools: this.mcp_tools,
|
|
286985
287045
|
mcp_tools_count: this.mcp_tools_count,
|
|
286986
|
-
output_format: this.output_format
|
|
287046
|
+
output_format: this.output_format,
|
|
287047
|
+
extensions_count: this.extensions_count,
|
|
287048
|
+
extension_ids: this.extension_ids
|
|
286987
287049
|
};
|
|
286988
287050
|
}
|
|
286989
287051
|
toLogBody() {
|
|
@@ -287005,6 +287067,7 @@ var ToolCallEvent = class {
|
|
|
287005
287067
|
tool_type;
|
|
287006
287068
|
content_length;
|
|
287007
287069
|
mcp_server_name;
|
|
287070
|
+
extension_id;
|
|
287008
287071
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
287009
287072
|
metadata;
|
|
287010
287073
|
constructor(call, function_name, function_args, duration_ms, success, prompt_id, tool_type, error) {
|
|
@@ -287023,6 +287086,7 @@ var ToolCallEvent = class {
|
|
|
287023
287086
|
if (typeof call.tool !== "undefined" && call.tool instanceof DiscoveredMCPTool) {
|
|
287024
287087
|
this.tool_type = "mcp";
|
|
287025
287088
|
this.mcp_server_name = call.tool.serverName;
|
|
287089
|
+
this.extension_id = call.tool.extensionId;
|
|
287026
287090
|
} else {
|
|
287027
287091
|
this.tool_type = "native";
|
|
287028
287092
|
}
|
|
@@ -287065,6 +287129,7 @@ var ToolCallEvent = class {
|
|
|
287065
287129
|
tool_type: this.tool_type,
|
|
287066
287130
|
content_length: this.content_length,
|
|
287067
287131
|
mcp_server_name: this.mcp_server_name,
|
|
287132
|
+
extension_id: this.extension_id,
|
|
287068
287133
|
metadata: this.metadata
|
|
287069
287134
|
};
|
|
287070
287135
|
if (this.error) {
|
|
@@ -288387,12 +288452,15 @@ var EventMetadataKey;
|
|
|
288387
288452
|
EventMetadataKey2[EventMetadataKey2["GEMINI_CLI_CONTENT_RETRY_FAILURE_TOTAL_DURATION_MS"] = 81] = "GEMINI_CLI_CONTENT_RETRY_FAILURE_TOTAL_DURATION_MS";
|
|
288388
288453
|
EventMetadataKey2[EventMetadataKey2["GEMINI_CLI_NODE_VERSION"] = 83] = "GEMINI_CLI_NODE_VERSION";
|
|
288389
288454
|
EventMetadataKey2[EventMetadataKey2["GEMINI_CLI_EXTENSION_NAME"] = 85] = "GEMINI_CLI_EXTENSION_NAME";
|
|
288455
|
+
EventMetadataKey2[EventMetadataKey2["GEMINI_CLI_EXTENSION_ID"] = 121] = "GEMINI_CLI_EXTENSION_ID";
|
|
288390
288456
|
EventMetadataKey2[EventMetadataKey2["GEMINI_CLI_EXTENSION_VERSION"] = 86] = "GEMINI_CLI_EXTENSION_VERSION";
|
|
288391
288457
|
EventMetadataKey2[EventMetadataKey2["GEMINI_CLI_EXTENSION_PREVIOUS_VERSION"] = 117] = "GEMINI_CLI_EXTENSION_PREVIOUS_VERSION";
|
|
288392
288458
|
EventMetadataKey2[EventMetadataKey2["GEMINI_CLI_EXTENSION_SOURCE"] = 87] = "GEMINI_CLI_EXTENSION_SOURCE";
|
|
288393
288459
|
EventMetadataKey2[EventMetadataKey2["GEMINI_CLI_EXTENSION_INSTALL_STATUS"] = 88] = "GEMINI_CLI_EXTENSION_INSTALL_STATUS";
|
|
288394
288460
|
EventMetadataKey2[EventMetadataKey2["GEMINI_CLI_EXTENSION_UNINSTALL_STATUS"] = 96] = "GEMINI_CLI_EXTENSION_UNINSTALL_STATUS";
|
|
288395
288461
|
EventMetadataKey2[EventMetadataKey2["GEMINI_CLI_EXTENSION_UPDATE_STATUS"] = 118] = "GEMINI_CLI_EXTENSION_UPDATE_STATUS";
|
|
288462
|
+
EventMetadataKey2[EventMetadataKey2["GEMINI_CLI_START_SESSION_EXTENSIONS_COUNT"] = 119] = "GEMINI_CLI_START_SESSION_EXTENSIONS_COUNT";
|
|
288463
|
+
EventMetadataKey2[EventMetadataKey2["GEMINI_CLI_START_SESSION_EXTENSION_IDS"] = 120] = "GEMINI_CLI_START_SESSION_EXTENSION_IDS";
|
|
288396
288464
|
EventMetadataKey2[EventMetadataKey2["GEMINI_CLI_EXTENSION_ENABLE_SETTING_SCOPE"] = 102] = "GEMINI_CLI_EXTENSION_ENABLE_SETTING_SCOPE";
|
|
288397
288465
|
EventMetadataKey2[EventMetadataKey2["GEMINI_CLI_EXTENSION_DISABLE_SETTING_SCOPE"] = 107] = "GEMINI_CLI_EXTENSION_DISABLE_SETTING_SCOPE";
|
|
288398
288466
|
EventMetadataKey2[EventMetadataKey2["GEMINI_CLI_TOOL_OUTPUT_TRUNCATED_ORIGINAL_LENGTH"] = 89] = "GEMINI_CLI_TOOL_OUTPUT_TRUNCATED_ORIGINAL_LENGTH";
|
|
@@ -288435,8 +288503,8 @@ var Float64Vector = import_vector.default.Float64Vector;
|
|
|
288435
288503
|
var PointerVector = import_vector.default.PointerVector;
|
|
288436
288504
|
|
|
288437
288505
|
// packages/core/dist/src/generated/git-commit.js
|
|
288438
|
-
var GIT_COMMIT_INFO = "
|
|
288439
|
-
var CLI_VERSION = "0.11.0-
|
|
288506
|
+
var GIT_COMMIT_INFO = "0542de95";
|
|
288507
|
+
var CLI_VERSION = "0.11.0-preview.0";
|
|
288440
288508
|
|
|
288441
288509
|
// packages/core/dist/src/ide/detect-ide.js
|
|
288442
288510
|
var IDE_DEFINITIONS = {
|
|
@@ -288613,7 +288681,7 @@ var ClearcutLogger = class _ClearcutLogger {
|
|
|
288613
288681
|
}
|
|
288614
288682
|
]);
|
|
288615
288683
|
if (wasAtCapacity && this.config?.getDebugMode()) {
|
|
288616
|
-
|
|
288684
|
+
debugLogger.debug(`ClearcutLogger: Dropped old event to prevent memory leak (queue size: ${this.events.size})`);
|
|
288617
288685
|
}
|
|
288618
288686
|
} catch (error) {
|
|
288619
288687
|
if (this.config?.getDebugMode()) {
|
|
@@ -288647,20 +288715,20 @@ var ClearcutLogger = class _ClearcutLogger {
|
|
|
288647
288715
|
return;
|
|
288648
288716
|
}
|
|
288649
288717
|
this.flushToClearcut().catch((error) => {
|
|
288650
|
-
|
|
288718
|
+
debugLogger.debug("Error flushing to Clearcut:", error);
|
|
288651
288719
|
});
|
|
288652
288720
|
}
|
|
288653
288721
|
async flushToClearcut() {
|
|
288654
288722
|
if (this.flushing) {
|
|
288655
288723
|
if (this.config?.getDebugMode()) {
|
|
288656
|
-
|
|
288724
|
+
debugLogger.debug("ClearcutLogger: Flush already in progress, marking pending flush.");
|
|
288657
288725
|
}
|
|
288658
288726
|
this.pendingFlush = true;
|
|
288659
288727
|
return Promise.resolve({});
|
|
288660
288728
|
}
|
|
288661
288729
|
this.flushing = true;
|
|
288662
288730
|
if (this.config?.getDebugMode()) {
|
|
288663
|
-
|
|
288731
|
+
debugLogger.log("Flushing log events to Clearcut.");
|
|
288664
288732
|
}
|
|
288665
288733
|
const eventsToSend = this.events.toArray();
|
|
288666
288734
|
this.events.clear();
|
|
@@ -288705,7 +288773,7 @@ var ClearcutLogger = class _ClearcutLogger {
|
|
|
288705
288773
|
this.pendingFlush = false;
|
|
288706
288774
|
this.flushToClearcut().catch((error) => {
|
|
288707
288775
|
if (this.config?.getDebugMode()) {
|
|
288708
|
-
|
|
288776
|
+
debugLogger.debug("Error in pending flush to Clearcut:", error);
|
|
288709
288777
|
}
|
|
288710
288778
|
});
|
|
288711
288779
|
}
|
|
@@ -288776,12 +288844,20 @@ var ClearcutLogger = class _ClearcutLogger {
|
|
|
288776
288844
|
{
|
|
288777
288845
|
gemini_cli_key: EventMetadataKey.GEMINI_CLI_START_SESSION_MCP_TOOLS,
|
|
288778
288846
|
value: event.mcp_tools ? event.mcp_tools : ""
|
|
288847
|
+
},
|
|
288848
|
+
{
|
|
288849
|
+
gemini_cli_key: EventMetadataKey.GEMINI_CLI_START_SESSION_EXTENSIONS_COUNT,
|
|
288850
|
+
value: event.extensions_count.toString()
|
|
288851
|
+
},
|
|
288852
|
+
{
|
|
288853
|
+
gemini_cli_key: EventMetadataKey.GEMINI_CLI_START_SESSION_EXTENSION_IDS,
|
|
288854
|
+
value: event.extension_ids.toString()
|
|
288779
288855
|
}
|
|
288780
288856
|
];
|
|
288781
288857
|
this.sessionData = data;
|
|
288782
288858
|
this.enqueueLogEvent(this.createLogEvent(EventNames.START_SESSION, data));
|
|
288783
288859
|
this.flushToClearcut().catch((error) => {
|
|
288784
|
-
|
|
288860
|
+
debugLogger.debug("Error flushing to Clearcut:", error);
|
|
288785
288861
|
});
|
|
288786
288862
|
}
|
|
288787
288863
|
logNewPromptEvent(event) {
|
|
@@ -288973,13 +289049,13 @@ var ClearcutLogger = class _ClearcutLogger {
|
|
|
288973
289049
|
logFlashFallbackEvent() {
|
|
288974
289050
|
this.enqueueLogEvent(this.createLogEvent(EventNames.FLASH_FALLBACK, []));
|
|
288975
289051
|
this.flushToClearcut().catch((error) => {
|
|
288976
|
-
|
|
289052
|
+
debugLogger.debug("Error flushing to Clearcut:", error);
|
|
288977
289053
|
});
|
|
288978
289054
|
}
|
|
288979
289055
|
logRipgrepFallbackEvent() {
|
|
288980
289056
|
this.enqueueLogEvent(this.createLogEvent(EventNames.RIPGREP_FALLBACK, []));
|
|
288981
289057
|
this.flushToClearcut().catch((error) => {
|
|
288982
|
-
|
|
289058
|
+
debugLogger.debug("Error flushing to Clearcut:", error);
|
|
288983
289059
|
});
|
|
288984
289060
|
}
|
|
288985
289061
|
logLoopDetectedEvent(event) {
|
|
@@ -289084,7 +289160,7 @@ var ClearcutLogger = class _ClearcutLogger {
|
|
|
289084
289160
|
logEndSessionEvent() {
|
|
289085
289161
|
this.enqueueLogEvent(this.createLogEvent(EventNames.END_SESSION, []));
|
|
289086
289162
|
this.flushToClearcut().catch((error) => {
|
|
289087
|
-
|
|
289163
|
+
debugLogger.debug("Error flushing to Clearcut:", error);
|
|
289088
289164
|
});
|
|
289089
289165
|
}
|
|
289090
289166
|
logInvalidChunkEvent(event) {
|
|
@@ -289150,6 +289226,10 @@ var ClearcutLogger = class _ClearcutLogger {
|
|
|
289150
289226
|
gemini_cli_key: EventMetadataKey.GEMINI_CLI_EXTENSION_NAME,
|
|
289151
289227
|
value: event.extension_name
|
|
289152
289228
|
},
|
|
289229
|
+
{
|
|
289230
|
+
gemini_cli_key: EventMetadataKey.GEMINI_CLI_EXTENSION_ID,
|
|
289231
|
+
value: event.extension_id
|
|
289232
|
+
},
|
|
289153
289233
|
{
|
|
289154
289234
|
gemini_cli_key: EventMetadataKey.GEMINI_CLI_EXTENSION_VERSION,
|
|
289155
289235
|
value: event.extension_version
|
|
@@ -289165,7 +289245,7 @@ var ClearcutLogger = class _ClearcutLogger {
|
|
|
289165
289245
|
];
|
|
289166
289246
|
this.enqueueLogEvent(this.createLogEvent(EventNames.EXTENSION_INSTALL, data));
|
|
289167
289247
|
this.flushToClearcut().catch((error) => {
|
|
289168
|
-
|
|
289248
|
+
debugLogger.debug("Error flushing to Clearcut:", error);
|
|
289169
289249
|
});
|
|
289170
289250
|
}
|
|
289171
289251
|
logExtensionUninstallEvent(event) {
|
|
@@ -289174,6 +289254,10 @@ var ClearcutLogger = class _ClearcutLogger {
|
|
|
289174
289254
|
gemini_cli_key: EventMetadataKey.GEMINI_CLI_EXTENSION_NAME,
|
|
289175
289255
|
value: event.extension_name
|
|
289176
289256
|
},
|
|
289257
|
+
{
|
|
289258
|
+
gemini_cli_key: EventMetadataKey.GEMINI_CLI_EXTENSION_ID,
|
|
289259
|
+
value: event.extension_id
|
|
289260
|
+
},
|
|
289177
289261
|
{
|
|
289178
289262
|
gemini_cli_key: EventMetadataKey.GEMINI_CLI_EXTENSION_UNINSTALL_STATUS,
|
|
289179
289263
|
value: event.status
|
|
@@ -289181,7 +289265,7 @@ var ClearcutLogger = class _ClearcutLogger {
|
|
|
289181
289265
|
];
|
|
289182
289266
|
this.enqueueLogEvent(this.createLogEvent(EventNames.EXTENSION_UNINSTALL, data));
|
|
289183
289267
|
this.flushToClearcut().catch((error) => {
|
|
289184
|
-
|
|
289268
|
+
debugLogger.debug("Error flushing to Clearcut:", error);
|
|
289185
289269
|
});
|
|
289186
289270
|
}
|
|
289187
289271
|
logExtensionUpdateEvent(event) {
|
|
@@ -289190,6 +289274,10 @@ var ClearcutLogger = class _ClearcutLogger {
|
|
|
289190
289274
|
gemini_cli_key: EventMetadataKey.GEMINI_CLI_EXTENSION_NAME,
|
|
289191
289275
|
value: event.extension_name
|
|
289192
289276
|
},
|
|
289277
|
+
{
|
|
289278
|
+
gemini_cli_key: EventMetadataKey.GEMINI_CLI_EXTENSION_ID,
|
|
289279
|
+
value: event.extension_id
|
|
289280
|
+
},
|
|
289193
289281
|
{
|
|
289194
289282
|
gemini_cli_key: EventMetadataKey.GEMINI_CLI_EXTENSION_VERSION,
|
|
289195
289283
|
value: event.extension_version
|
|
@@ -289209,7 +289297,7 @@ var ClearcutLogger = class _ClearcutLogger {
|
|
|
289209
289297
|
];
|
|
289210
289298
|
this.enqueueLogEvent(this.createLogEvent(EventNames.EXTENSION_UPDATE, data));
|
|
289211
289299
|
this.flushToClearcut().catch((error) => {
|
|
289212
|
-
|
|
289300
|
+
debugLogger.debug("Error flushing to Clearcut:", error);
|
|
289213
289301
|
});
|
|
289214
289302
|
}
|
|
289215
289303
|
logToolOutputTruncatedEvent(event) {
|
|
@@ -289272,6 +289360,10 @@ var ClearcutLogger = class _ClearcutLogger {
|
|
|
289272
289360
|
gemini_cli_key: EventMetadataKey.GEMINI_CLI_EXTENSION_NAME,
|
|
289273
289361
|
value: event.extension_name
|
|
289274
289362
|
},
|
|
289363
|
+
{
|
|
289364
|
+
gemini_cli_key: EventMetadataKey.GEMINI_CLI_EXTENSION_ID,
|
|
289365
|
+
value: event.extension_id
|
|
289366
|
+
},
|
|
289275
289367
|
{
|
|
289276
289368
|
gemini_cli_key: EventMetadataKey.GEMINI_CLI_EXTENSION_ENABLE_SETTING_SCOPE,
|
|
289277
289369
|
value: event.setting_scope
|
|
@@ -289279,7 +289371,7 @@ var ClearcutLogger = class _ClearcutLogger {
|
|
|
289279
289371
|
];
|
|
289280
289372
|
this.enqueueLogEvent(this.createLogEvent(EventNames.EXTENSION_ENABLE, data));
|
|
289281
289373
|
this.flushToClearcut().catch((error) => {
|
|
289282
|
-
|
|
289374
|
+
debugLogger.debug("Error flushing to Clearcut:", error);
|
|
289283
289375
|
});
|
|
289284
289376
|
}
|
|
289285
289377
|
logModelSlashCommandEvent(event) {
|
|
@@ -289298,6 +289390,10 @@ var ClearcutLogger = class _ClearcutLogger {
|
|
|
289298
289390
|
gemini_cli_key: EventMetadataKey.GEMINI_CLI_EXTENSION_NAME,
|
|
289299
289391
|
value: event.extension_name
|
|
289300
289392
|
},
|
|
289393
|
+
{
|
|
289394
|
+
gemini_cli_key: EventMetadataKey.GEMINI_CLI_EXTENSION_ID,
|
|
289395
|
+
value: event.extension_id
|
|
289396
|
+
},
|
|
289301
289397
|
{
|
|
289302
289398
|
gemini_cli_key: EventMetadataKey.GEMINI_CLI_EXTENSION_DISABLE_SETTING_SCOPE,
|
|
289303
289399
|
value: event.setting_scope
|
|
@@ -289305,7 +289401,7 @@ var ClearcutLogger = class _ClearcutLogger {
|
|
|
289305
289401
|
];
|
|
289306
289402
|
this.enqueueLogEvent(this.createLogEvent(EventNames.EXTENSION_DISABLE, data));
|
|
289307
289403
|
this.flushToClearcut().catch((error) => {
|
|
289308
|
-
|
|
289404
|
+
debugLogger.debug("Error flushing to Clearcut:", error);
|
|
289309
289405
|
});
|
|
289310
289406
|
}
|
|
289311
289407
|
logSmartEditStrategyEvent(event) {
|
|
@@ -289439,8 +289535,6 @@ var ClearcutLogger = class _ClearcutLogger {
|
|
|
289439
289535
|
}
|
|
289440
289536
|
}
|
|
289441
289537
|
getConfigJson() {
|
|
289442
|
-
const configJson = safeJsonStringifyBooleanValuesOnly(this.config);
|
|
289443
|
-
console.debug(configJson);
|
|
289444
289538
|
return safeJsonStringifyBooleanValuesOnly(this.config);
|
|
289445
289539
|
}
|
|
289446
289540
|
shutdown() {
|
|
@@ -289449,13 +289543,13 @@ var ClearcutLogger = class _ClearcutLogger {
|
|
|
289449
289543
|
requeueFailedEvents(eventsToSend) {
|
|
289450
289544
|
const eventsToRetry = eventsToSend.slice(-MAX_RETRY_EVENTS);
|
|
289451
289545
|
if (eventsToSend.length > MAX_RETRY_EVENTS && this.config?.getDebugMode()) {
|
|
289452
|
-
|
|
289546
|
+
debugLogger.warn(`ClearcutLogger: Dropping ${eventsToSend.length - MAX_RETRY_EVENTS} events due to retry queue limit. Total events: ${eventsToSend.length}, keeping: ${MAX_RETRY_EVENTS}`);
|
|
289453
289547
|
}
|
|
289454
289548
|
const availableSpace = MAX_EVENTS - this.events.size;
|
|
289455
289549
|
const numEventsToRequeue = Math.min(eventsToRetry.length, availableSpace);
|
|
289456
289550
|
if (numEventsToRequeue === 0) {
|
|
289457
289551
|
if (this.config?.getDebugMode()) {
|
|
289458
|
-
|
|
289552
|
+
debugLogger.debug(`ClearcutLogger: No events re-queued (queue size: ${this.events.size})`);
|
|
289459
289553
|
}
|
|
289460
289554
|
return;
|
|
289461
289555
|
}
|
|
@@ -289467,7 +289561,7 @@ var ClearcutLogger = class _ClearcutLogger {
|
|
|
289467
289561
|
this.events.pop();
|
|
289468
289562
|
}
|
|
289469
289563
|
if (this.config?.getDebugMode()) {
|
|
289470
|
-
|
|
289564
|
+
debugLogger.debug(`ClearcutLogger: Re-queued ${numEventsToRequeue} events for retry (queue size: ${this.events.size})`);
|
|
289471
289565
|
}
|
|
289472
289566
|
}
|
|
289473
289567
|
};
|
|
@@ -290393,7 +290487,7 @@ function initializeTelemetry(config2) {
|
|
|
290393
290487
|
try {
|
|
290394
290488
|
sdk.start();
|
|
290395
290489
|
if (config2.getDebugMode()) {
|
|
290396
|
-
|
|
290490
|
+
debugLogger.log("OpenTelemetry SDK started successfully.");
|
|
290397
290491
|
}
|
|
290398
290492
|
telemetryInitialized = true;
|
|
290399
290493
|
initializeMetrics(config2);
|
|
@@ -290418,7 +290512,7 @@ async function shutdownTelemetry(config2) {
|
|
|
290418
290512
|
ClearcutLogger.getInstance()?.shutdown();
|
|
290419
290513
|
await sdk.shutdown();
|
|
290420
290514
|
if (config2.getDebugMode()) {
|
|
290421
|
-
|
|
290515
|
+
debugLogger.log("OpenTelemetry SDK shut down successfully.");
|
|
290422
290516
|
}
|
|
290423
290517
|
} catch (error) {
|
|
290424
290518
|
console.error("Error shutting down SDK:", error);
|
|
@@ -290913,7 +291007,7 @@ function createContentGeneratorConfig(config2, authType) {
|
|
|
290913
291007
|
return contentGeneratorConfig;
|
|
290914
291008
|
}
|
|
290915
291009
|
async function createContentGenerator(config2, gcConfig, sessionId2) {
|
|
290916
|
-
const version3 = "0.11.0-
|
|
291010
|
+
const version3 = "0.11.0-preview.0";
|
|
290917
291011
|
const userAgent = `GeminiCLI/${version3} (${process.platform}; ${process.arch})`;
|
|
290918
291012
|
const baseHeaders = {
|
|
290919
291013
|
"User-Agent": userAgent
|
|
@@ -290953,7 +291047,7 @@ var PromptRegistry = class {
|
|
|
290953
291047
|
registerPrompt(prompt) {
|
|
290954
291048
|
if (this.prompts.has(prompt.name)) {
|
|
290955
291049
|
const newName = `${prompt.serverName}_${prompt.name}`;
|
|
290956
|
-
|
|
291050
|
+
debugLogger.warn(`Prompt with name "${prompt.name}" is already registered. Renaming to "${newName}".`);
|
|
290957
291051
|
this.prompts.set(newName, { ...prompt, name: newName });
|
|
290958
291052
|
} else {
|
|
290959
291053
|
this.prompts.set(prompt.name, prompt);
|
|
@@ -298678,7 +298772,7 @@ var OAuthUtils = class {
|
|
|
298678
298772
|
}
|
|
298679
298773
|
return await response.json();
|
|
298680
298774
|
} catch (error) {
|
|
298681
|
-
|
|
298775
|
+
debugLogger.debug(`Failed to fetch protected resource metadata from ${resourceMetadataUrl}: ${getErrorMessage(error)}`);
|
|
298682
298776
|
return null;
|
|
298683
298777
|
}
|
|
298684
298778
|
}
|
|
@@ -298696,7 +298790,7 @@ var OAuthUtils = class {
|
|
|
298696
298790
|
}
|
|
298697
298791
|
return await response.json();
|
|
298698
298792
|
} catch (error) {
|
|
298699
|
-
|
|
298793
|
+
debugLogger.debug(`Failed to fetch authorization server metadata from ${authServerMetadataUrl}: ${getErrorMessage(error)}`);
|
|
298700
298794
|
return null;
|
|
298701
298795
|
}
|
|
298702
298796
|
}
|
|
@@ -298738,7 +298832,7 @@ var OAuthUtils = class {
|
|
|
298738
298832
|
return authServerMetadata;
|
|
298739
298833
|
}
|
|
298740
298834
|
}
|
|
298741
|
-
|
|
298835
|
+
debugLogger.debug(`Metadata discovery failed for authorization server ${authServerUrl}`);
|
|
298742
298836
|
return null;
|
|
298743
298837
|
}
|
|
298744
298838
|
/**
|
|
@@ -298764,23 +298858,23 @@ var OAuthUtils = class {
|
|
|
298764
298858
|
if (authServerMetadata2) {
|
|
298765
298859
|
const config2 = this.metadataToOAuthConfig(authServerMetadata2);
|
|
298766
298860
|
if (authServerMetadata2.registration_endpoint) {
|
|
298767
|
-
|
|
298861
|
+
debugLogger.log("Dynamic client registration is supported at:", authServerMetadata2.registration_endpoint);
|
|
298768
298862
|
}
|
|
298769
298863
|
return config2;
|
|
298770
298864
|
}
|
|
298771
298865
|
}
|
|
298772
|
-
|
|
298866
|
+
debugLogger.debug(`Trying OAuth discovery fallback at ${serverUrl}`);
|
|
298773
298867
|
const authServerMetadata = await this.discoverAuthorizationServerMetadata(serverUrl);
|
|
298774
298868
|
if (authServerMetadata) {
|
|
298775
298869
|
const config2 = this.metadataToOAuthConfig(authServerMetadata);
|
|
298776
298870
|
if (authServerMetadata.registration_endpoint) {
|
|
298777
|
-
|
|
298871
|
+
debugLogger.log("Dynamic client registration is supported at:", authServerMetadata.registration_endpoint);
|
|
298778
298872
|
}
|
|
298779
298873
|
return config2;
|
|
298780
298874
|
}
|
|
298781
298875
|
return null;
|
|
298782
298876
|
} catch (error) {
|
|
298783
|
-
|
|
298877
|
+
debugLogger.debug(`Failed to discover OAuth configuration: ${getErrorMessage(error)}`);
|
|
298784
298878
|
return null;
|
|
298785
298879
|
}
|
|
298786
298880
|
}
|
|
@@ -298846,7 +298940,7 @@ var OAuthUtils = class {
|
|
|
298846
298940
|
*/
|
|
298847
298941
|
static buildResourceParameter(endpointUrl) {
|
|
298848
298942
|
const url4 = new URL(endpointUrl);
|
|
298849
|
-
return `${url4.protocol}//${url4.host}`;
|
|
298943
|
+
return `${url4.protocol}//${url4.host}${url4.pathname}`;
|
|
298850
298944
|
}
|
|
298851
298945
|
};
|
|
298852
298946
|
|
|
@@ -298978,7 +299072,7 @@ var MCPOAuthProvider = class {
|
|
|
298978
299072
|
});
|
|
298979
299073
|
server.on("error", reject);
|
|
298980
299074
|
server.listen(REDIRECT_PORT, () => {
|
|
298981
|
-
|
|
299075
|
+
debugLogger.log(`OAuth callback server listening on port ${REDIRECT_PORT}`);
|
|
298982
299076
|
});
|
|
298983
299077
|
setTimeout(() => {
|
|
298984
299078
|
server.close();
|
|
@@ -299014,7 +299108,7 @@ var MCPOAuthProvider = class {
|
|
|
299014
299108
|
try {
|
|
299015
299109
|
params.append("resource", OAuthUtils.buildResourceParameter(mcpServerUrl));
|
|
299016
299110
|
} catch (error) {
|
|
299017
|
-
|
|
299111
|
+
debugLogger.warn(`Could not add resource parameter: ${getErrorMessage(error)}`);
|
|
299018
299112
|
}
|
|
299019
299113
|
}
|
|
299020
299114
|
const url4 = new URL7(config2.authorizationUrl);
|
|
@@ -299052,7 +299146,7 @@ var MCPOAuthProvider = class {
|
|
|
299052
299146
|
try {
|
|
299053
299147
|
params.append("resource", OAuthUtils.buildResourceParameter(resourceUrl));
|
|
299054
299148
|
} catch (error) {
|
|
299055
|
-
|
|
299149
|
+
debugLogger.warn(`Could not add resource parameter: ${getErrorMessage(error)}`);
|
|
299056
299150
|
}
|
|
299057
299151
|
}
|
|
299058
299152
|
const response = await fetch(config2.tokenUrl, {
|
|
@@ -299079,7 +299173,7 @@ var MCPOAuthProvider = class {
|
|
|
299079
299173
|
throw new Error(errorMessage || `Token exchange failed: ${response.status} - ${responseText}`);
|
|
299080
299174
|
}
|
|
299081
299175
|
if (!contentType.includes("application/json") && !contentType.includes("application/x-www-form-urlencoded")) {
|
|
299082
|
-
|
|
299176
|
+
debugLogger.warn(`Token endpoint returned unexpected content-type: ${contentType}. Expected application/json or application/x-www-form-urlencoded. Will attempt to parse response.`);
|
|
299083
299177
|
}
|
|
299084
299178
|
try {
|
|
299085
299179
|
return JSON.parse(responseText);
|
|
@@ -299132,7 +299226,7 @@ var MCPOAuthProvider = class {
|
|
|
299132
299226
|
try {
|
|
299133
299227
|
params.append("resource", OAuthUtils.buildResourceParameter(mcpServerUrl));
|
|
299134
299228
|
} catch (error) {
|
|
299135
|
-
|
|
299229
|
+
debugLogger.warn(`Could not add resource parameter: ${getErrorMessage(error)}`);
|
|
299136
299230
|
}
|
|
299137
299231
|
}
|
|
299138
299232
|
const response = await fetch(tokenUrl, {
|
|
@@ -299159,7 +299253,7 @@ var MCPOAuthProvider = class {
|
|
|
299159
299253
|
throw new Error(errorMessage || `Token refresh failed: ${response.status} - ${responseText}`);
|
|
299160
299254
|
}
|
|
299161
299255
|
if (!contentType.includes("application/json") && !contentType.includes("application/x-www-form-urlencoded")) {
|
|
299162
|
-
|
|
299256
|
+
debugLogger.warn(`Token refresh endpoint returned unexpected content-type: ${contentType}. Expected application/json or application/x-www-form-urlencoded. Will attempt to parse response.`);
|
|
299163
299257
|
}
|
|
299164
299258
|
try {
|
|
299165
299259
|
return JSON.parse(responseText);
|
|
@@ -299198,11 +299292,11 @@ var MCPOAuthProvider = class {
|
|
|
299198
299292
|
if (events) {
|
|
299199
299293
|
events.emit(OAUTH_DISPLAY_MESSAGE_EVENT, message);
|
|
299200
299294
|
} else {
|
|
299201
|
-
|
|
299295
|
+
debugLogger.log(message);
|
|
299202
299296
|
}
|
|
299203
299297
|
};
|
|
299204
299298
|
if (!config2.authorizationUrl && mcpServerUrl) {
|
|
299205
|
-
|
|
299299
|
+
debugLogger.debug(`Starting OAuth for MCP server "${serverName}"\u2026
|
|
299206
299300
|
\u2713 No authorization URL; using OAuth discovery`);
|
|
299207
299301
|
try {
|
|
299208
299302
|
const headers = OAuthUtils.isSSEEndpoint(mcpServerUrl) ? { Accept: "text/event-stream" } : { Accept: "application/json" };
|
|
@@ -299228,7 +299322,7 @@ var MCPOAuthProvider = class {
|
|
|
299228
299322
|
}
|
|
299229
299323
|
}
|
|
299230
299324
|
} catch (error) {
|
|
299231
|
-
|
|
299325
|
+
debugLogger.debug(`Failed to check endpoint for authentication requirements: ${getErrorMessage(error)}`);
|
|
299232
299326
|
}
|
|
299233
299327
|
if (!config2.authorizationUrl) {
|
|
299234
299328
|
const discoveredConfig = await this.discoverOAuthFromMCPServer(mcpServerUrl);
|
|
@@ -299256,7 +299350,7 @@ var MCPOAuthProvider = class {
|
|
|
299256
299350
|
}
|
|
299257
299351
|
const authUrl2 = new URL7(config2.authorizationUrl);
|
|
299258
299352
|
const serverUrl = `${authUrl2.protocol}//${authUrl2.host}`;
|
|
299259
|
-
|
|
299353
|
+
debugLogger.debug("\u2192 Attempting dynamic client registration...");
|
|
299260
299354
|
const authServerMetadata = await OAuthUtils.discoverAuthorizationServerMetadata(serverUrl);
|
|
299261
299355
|
if (!authServerMetadata) {
|
|
299262
299356
|
throw new Error("Failed to fetch authorization server metadata for client registration");
|
|
@@ -299269,7 +299363,7 @@ var MCPOAuthProvider = class {
|
|
|
299269
299363
|
if (clientRegistration.client_secret) {
|
|
299270
299364
|
config2.clientSecret = clientRegistration.client_secret;
|
|
299271
299365
|
}
|
|
299272
|
-
|
|
299366
|
+
debugLogger.debug("\u2713 Dynamic client registration successful");
|
|
299273
299367
|
} else {
|
|
299274
299368
|
throw new Error("No client ID provided and dynamic registration not supported");
|
|
299275
299369
|
}
|
|
@@ -299290,10 +299384,10 @@ ${authUrl}
|
|
|
299290
299384
|
try {
|
|
299291
299385
|
await openBrowserSecurely(authUrl);
|
|
299292
299386
|
} catch (error) {
|
|
299293
|
-
|
|
299387
|
+
debugLogger.warn("Failed to open browser automatically:", getErrorMessage(error));
|
|
299294
299388
|
}
|
|
299295
299389
|
const { code: code2 } = await callbackPromise;
|
|
299296
|
-
|
|
299390
|
+
debugLogger.debug("\u2713 Authorization code received, exchanging for tokens...");
|
|
299297
299391
|
const tokenResponse = await this.exchangeCodeForToken(config2, code2, pkceParams.codeVerifier, mcpServerUrl);
|
|
299298
299392
|
if (!tokenResponse.access_token) {
|
|
299299
299393
|
throw new Error("No access token received from token endpoint");
|
|
@@ -299309,11 +299403,11 @@ ${authUrl}
|
|
|
299309
299403
|
}
|
|
299310
299404
|
try {
|
|
299311
299405
|
await this.tokenStorage.saveToken(serverName, token2, config2.clientId, config2.tokenUrl, mcpServerUrl);
|
|
299312
|
-
|
|
299406
|
+
debugLogger.debug("\u2713 Authentication successful! Token saved.");
|
|
299313
299407
|
const savedToken = await this.tokenStorage.getCredentials(serverName);
|
|
299314
299408
|
if (savedToken && savedToken.token && savedToken.token.accessToken) {
|
|
299315
299409
|
const tokenFingerprint = crypto18.createHash("sha256").update(savedToken.token.accessToken).digest("hex").slice(0, 8);
|
|
299316
|
-
|
|
299410
|
+
debugLogger.debug(`\u2713 Token verification successful (fingerprint: ${tokenFingerprint})`);
|
|
299317
299411
|
} else {
|
|
299318
299412
|
console.error("Token verification failed: token not found or invalid after save");
|
|
299319
299413
|
}
|
|
@@ -299331,21 +299425,21 @@ ${authUrl}
|
|
|
299331
299425
|
* @returns A valid access token or null if not authenticated
|
|
299332
299426
|
*/
|
|
299333
299427
|
async getValidToken(serverName, config2) {
|
|
299334
|
-
|
|
299428
|
+
debugLogger.debug(`Getting valid token for server: ${serverName}`);
|
|
299335
299429
|
const credentials = await this.tokenStorage.getCredentials(serverName);
|
|
299336
299430
|
if (!credentials) {
|
|
299337
|
-
|
|
299431
|
+
debugLogger.debug(`No credentials found for server: ${serverName}`);
|
|
299338
299432
|
return null;
|
|
299339
299433
|
}
|
|
299340
299434
|
const { token: token2 } = credentials;
|
|
299341
|
-
|
|
299435
|
+
debugLogger.debug(`Found token for server: ${serverName}, expired: ${this.tokenStorage.isTokenExpired(token2)}`);
|
|
299342
299436
|
if (!this.tokenStorage.isTokenExpired(token2)) {
|
|
299343
|
-
|
|
299437
|
+
debugLogger.debug(`Returning valid token for server: ${serverName}`);
|
|
299344
299438
|
return token2.accessToken;
|
|
299345
299439
|
}
|
|
299346
299440
|
if (token2.refreshToken && config2.clientId && credentials.tokenUrl) {
|
|
299347
299441
|
try {
|
|
299348
|
-
|
|
299442
|
+
debugLogger.log(`Refreshing expired token for MCP server: ${serverName}`);
|
|
299349
299443
|
const newTokenResponse = await this.refreshAccessToken(config2, token2.refreshToken, credentials.tokenUrl, credentials.mcpServerUrl);
|
|
299350
299444
|
const newToken = {
|
|
299351
299445
|
accessToken: newTokenResponse.access_token,
|
|
@@ -299512,7 +299606,7 @@ function extractWWWAuthenticateHeader(errorString) {
|
|
|
299512
299606
|
}
|
|
299513
299607
|
async function handleAutomaticOAuth(mcpServerName, mcpServerConfig, wwwAuthenticate) {
|
|
299514
299608
|
try {
|
|
299515
|
-
|
|
299609
|
+
debugLogger.log(`\u{1F510} '${mcpServerName}' requires OAuth authentication`);
|
|
299516
299610
|
let oauthConfig;
|
|
299517
299611
|
const resourceMetadataUri = OAuthUtils.parseWWWAuthenticateHeader(wwwAuthenticate);
|
|
299518
299612
|
if (resourceMetadataUri) {
|
|
@@ -299533,10 +299627,10 @@ async function handleAutomaticOAuth(mcpServerName, mcpServerConfig, wwwAuthentic
|
|
|
299533
299627
|
scopes: oauthConfig.scopes || []
|
|
299534
299628
|
};
|
|
299535
299629
|
const serverUrl = mcpServerConfig.httpUrl || mcpServerConfig.url;
|
|
299536
|
-
|
|
299630
|
+
debugLogger.log(`Starting OAuth authentication for server '${mcpServerName}'...`);
|
|
299537
299631
|
const authProvider = new MCPOAuthProvider(new MCPOAuthTokenStorage());
|
|
299538
299632
|
await authProvider.authenticate(mcpServerName, oauthAuthConfig, serverUrl);
|
|
299539
|
-
|
|
299633
|
+
debugLogger.log(`OAuth authentication successful for server '${mcpServerName}'`);
|
|
299540
299634
|
return true;
|
|
299541
299635
|
} catch (error) {
|
|
299542
299636
|
console.error(`Failed to handle automatic OAuth for server '${mcpServerName}': ${getErrorMessage(error)}`);
|
|
@@ -299628,7 +299722,7 @@ async function discoverTools(mcpServerName, mcpServerConfig, mcpClient, cliConfi
|
|
|
299628
299722
|
if (!isEnabled(funcDecl, mcpServerName, mcpServerConfig)) {
|
|
299629
299723
|
continue;
|
|
299630
299724
|
}
|
|
299631
|
-
discoveredTools.push(new DiscoveredMCPTool(mcpCallableTool, mcpServerName, funcDecl.name, funcDecl.description ?? "", funcDecl.parametersJsonSchema ?? { type: "object", properties: {} }, mcpServerConfig.trust, void 0, cliConfig));
|
|
299725
|
+
discoveredTools.push(new DiscoveredMCPTool(mcpCallableTool, mcpServerName, funcDecl.name, funcDecl.description ?? "", funcDecl.parametersJsonSchema ?? { type: "object", properties: {} }, mcpServerConfig.trust, void 0, cliConfig, mcpServerConfig.extension?.id));
|
|
299632
299726
|
} catch (error) {
|
|
299633
299727
|
console.error(`Error discovering tool: '${funcDecl.name}' from MCP server '${mcpServerName}': ${error.message}`);
|
|
299634
299728
|
}
|
|
@@ -299745,16 +299839,16 @@ async function connectToMcpServer(mcpServerName, mcpServerConfig, debugMode, wor
|
|
|
299745
299839
|
clientId: credentials.clientId
|
|
299746
299840
|
});
|
|
299747
299841
|
if (hasStoredTokens) {
|
|
299748
|
-
|
|
299842
|
+
debugLogger.log(`Stored OAuth token for SSE server '${mcpServerName}' was rejected. Please re-authenticate using: /mcp auth ${mcpServerName}`);
|
|
299749
299843
|
} else {
|
|
299750
|
-
|
|
299844
|
+
debugLogger.log(`401 error received for SSE server '${mcpServerName}' without OAuth configuration. Please authenticate using: /mcp auth ${mcpServerName}`);
|
|
299751
299845
|
}
|
|
299752
299846
|
}
|
|
299753
299847
|
throw new Error(`401 error received for SSE server '${mcpServerName}' without OAuth configuration. Please authenticate using: /mcp auth ${mcpServerName}`);
|
|
299754
299848
|
}
|
|
299755
299849
|
let wwwAuthenticate = extractWWWAuthenticateHeader(errorString);
|
|
299756
299850
|
if (!wwwAuthenticate && hasNetworkTransport(mcpServerConfig)) {
|
|
299757
|
-
|
|
299851
|
+
debugLogger.log(`No www-authenticate header in error, trying to fetch it from server...`);
|
|
299758
299852
|
try {
|
|
299759
299853
|
const urlToFetch = mcpServerConfig.httpUrl || mcpServerConfig.url;
|
|
299760
299854
|
const response = await fetch(urlToFetch, {
|
|
@@ -299767,18 +299861,18 @@ async function connectToMcpServer(mcpServerName, mcpServerConfig, debugMode, wor
|
|
|
299767
299861
|
if (response.status === 401) {
|
|
299768
299862
|
wwwAuthenticate = response.headers.get("www-authenticate");
|
|
299769
299863
|
if (wwwAuthenticate) {
|
|
299770
|
-
|
|
299864
|
+
debugLogger.log(`Found www-authenticate header from server: ${wwwAuthenticate}`);
|
|
299771
299865
|
}
|
|
299772
299866
|
}
|
|
299773
299867
|
} catch (fetchError) {
|
|
299774
|
-
|
|
299868
|
+
debugLogger.debug(`Failed to fetch www-authenticate header: ${getErrorMessage(fetchError)}`);
|
|
299775
299869
|
}
|
|
299776
299870
|
}
|
|
299777
299871
|
if (wwwAuthenticate) {
|
|
299778
|
-
|
|
299872
|
+
debugLogger.log(`Received 401 with www-authenticate header: ${wwwAuthenticate}`);
|
|
299779
299873
|
const oauthSuccess = await handleAutomaticOAuth(mcpServerName, mcpServerConfig, wwwAuthenticate);
|
|
299780
299874
|
if (oauthSuccess) {
|
|
299781
|
-
|
|
299875
|
+
debugLogger.log(`Retrying connection to '${mcpServerName}' with OAuth token...`);
|
|
299782
299876
|
const tokenStorage = new MCPOAuthTokenStorage();
|
|
299783
299877
|
const credentials = await tokenStorage.getCredentials(mcpServerName);
|
|
299784
299878
|
if (credentials) {
|
|
@@ -299827,21 +299921,21 @@ async function connectToMcpServer(mcpServerName, mcpServerConfig, debugMode, wor
|
|
|
299827
299921
|
clientId: credentials.clientId
|
|
299828
299922
|
});
|
|
299829
299923
|
if (hasStoredTokens) {
|
|
299830
|
-
|
|
299924
|
+
debugLogger.log(`Stored OAuth token for SSE server '${mcpServerName}' was rejected. Please re-authenticate using: /mcp auth ${mcpServerName}`);
|
|
299831
299925
|
} else {
|
|
299832
|
-
|
|
299926
|
+
debugLogger.log(`401 error received for SSE server '${mcpServerName}' without OAuth configuration. Please authenticate using: /mcp auth ${mcpServerName}`);
|
|
299833
299927
|
}
|
|
299834
299928
|
}
|
|
299835
299929
|
throw new Error(`401 error received for SSE server '${mcpServerName}' without OAuth configuration. Please authenticate using: /mcp auth ${mcpServerName}`);
|
|
299836
299930
|
}
|
|
299837
|
-
|
|
299931
|
+
debugLogger.log(`\u{1F50D} Attempting OAuth discovery for '${mcpServerName}'...`);
|
|
299838
299932
|
if (hasNetworkTransport(mcpServerConfig)) {
|
|
299839
299933
|
const serverUrl = new URL(mcpServerConfig.httpUrl || mcpServerConfig.url);
|
|
299840
299934
|
const baseUrl = `${serverUrl.protocol}//${serverUrl.host}`;
|
|
299841
299935
|
try {
|
|
299842
299936
|
const oauthConfig = await OAuthUtils.discoverOAuthConfig(baseUrl);
|
|
299843
299937
|
if (oauthConfig) {
|
|
299844
|
-
|
|
299938
|
+
debugLogger.log(`Discovered OAuth configuration from base URL for server '${mcpServerName}'`);
|
|
299845
299939
|
const oauthAuthConfig = {
|
|
299846
299940
|
enabled: true,
|
|
299847
299941
|
authorizationUrl: oauthConfig.authorizationUrl,
|
|
@@ -299849,7 +299943,7 @@ async function connectToMcpServer(mcpServerName, mcpServerConfig, debugMode, wor
|
|
|
299849
299943
|
scopes: oauthConfig.scopes || []
|
|
299850
299944
|
};
|
|
299851
299945
|
const authServerUrl = mcpServerConfig.httpUrl || mcpServerConfig.url;
|
|
299852
|
-
|
|
299946
|
+
debugLogger.log(`Starting OAuth authentication for server '${mcpServerName}'...`);
|
|
299853
299947
|
const authProvider = new MCPOAuthProvider(new MCPOAuthTokenStorage());
|
|
299854
299948
|
await authProvider.authenticate(mcpServerName, oauthAuthConfig, authServerUrl);
|
|
299855
299949
|
const tokenStorage = new MCPOAuthTokenStorage();
|
|
@@ -299959,7 +300053,7 @@ async function createTransport(mcpServerName, mcpServerConfig, debugMode) {
|
|
|
299959
300053
|
});
|
|
299960
300054
|
if (accessToken) {
|
|
299961
300055
|
hasOAuthConfig = true;
|
|
299962
|
-
|
|
300056
|
+
debugLogger.log(`Found stored OAuth token for server '${mcpServerName}'`);
|
|
299963
300057
|
}
|
|
299964
300058
|
}
|
|
299965
300059
|
}
|
|
@@ -300009,7 +300103,7 @@ async function createTransport(mcpServerName, mcpServerConfig, debugMode) {
|
|
|
300009
300103
|
if (debugMode) {
|
|
300010
300104
|
transport.stderr.on("data", (data) => {
|
|
300011
300105
|
const stderrStr = data.toString().trim();
|
|
300012
|
-
|
|
300106
|
+
debugLogger.debug(`[DEBUG] [MCP STDERR (${mcpServerName})]: `, stderrStr);
|
|
300013
300107
|
});
|
|
300014
300108
|
}
|
|
300015
300109
|
return transport;
|
|
@@ -300018,7 +300112,7 @@ async function createTransport(mcpServerName, mcpServerConfig, debugMode) {
|
|
|
300018
300112
|
}
|
|
300019
300113
|
function isEnabled(funcDecl, mcpServerName, mcpServerConfig) {
|
|
300020
300114
|
if (!funcDecl.name) {
|
|
300021
|
-
|
|
300115
|
+
debugLogger.warn(`Discovered a function declaration without a name from MCP server '${mcpServerName}'. Skipping.`);
|
|
300022
300116
|
return false;
|
|
300023
300117
|
}
|
|
300024
300118
|
const { includeTools, excludeTools } = mcpServerConfig;
|
|
@@ -300031,21 +300125,11 @@ function isEnabled(funcDecl, mcpServerName, mcpServerConfig) {
|
|
|
300031
300125
|
// packages/core/dist/src/tools/mcp-client-manager.js
|
|
300032
300126
|
var McpClientManager = class {
|
|
300033
300127
|
clients = /* @__PURE__ */ new Map();
|
|
300034
|
-
mcpServers;
|
|
300035
|
-
mcpServerCommand;
|
|
300036
300128
|
toolRegistry;
|
|
300037
|
-
promptRegistry;
|
|
300038
|
-
debugMode;
|
|
300039
|
-
workspaceContext;
|
|
300040
300129
|
discoveryState = MCPDiscoveryState.NOT_STARTED;
|
|
300041
300130
|
eventEmitter;
|
|
300042
|
-
constructor(
|
|
300043
|
-
this.mcpServers = mcpServers;
|
|
300044
|
-
this.mcpServerCommand = mcpServerCommand;
|
|
300131
|
+
constructor(toolRegistry, eventEmitter) {
|
|
300045
300132
|
this.toolRegistry = toolRegistry;
|
|
300046
|
-
this.promptRegistry = promptRegistry;
|
|
300047
|
-
this.debugMode = debugMode;
|
|
300048
|
-
this.workspaceContext = workspaceContext;
|
|
300049
300133
|
this.eventEmitter = eventEmitter;
|
|
300050
300134
|
}
|
|
300051
300135
|
/**
|
|
@@ -300058,11 +300142,11 @@ var McpClientManager = class {
|
|
|
300058
300142
|
return;
|
|
300059
300143
|
}
|
|
300060
300144
|
await this.stop();
|
|
300061
|
-
const servers = populateMcpServerCommand(
|
|
300145
|
+
const servers = populateMcpServerCommand(cliConfig.getMcpServers() || {}, cliConfig.getMcpServerCommand());
|
|
300062
300146
|
this.discoveryState = MCPDiscoveryState.IN_PROGRESS;
|
|
300063
300147
|
this.eventEmitter?.emit("mcp-client-update", this.clients);
|
|
300064
|
-
const discoveryPromises = Object.entries(servers).map(async ([name4, config2]) => {
|
|
300065
|
-
const client = new McpClient(name4, config2, this.toolRegistry,
|
|
300148
|
+
const discoveryPromises = Object.entries(servers).filter(([_, config2]) => !config2.extension || config2.extension.isActive).map(async ([name4, config2]) => {
|
|
300149
|
+
const client = new McpClient(name4, config2, this.toolRegistry, cliConfig.getPromptRegistry(), cliConfig.getWorkspaceContext(), cliConfig.getDebugMode());
|
|
300066
300150
|
this.clients.set(name4, client);
|
|
300067
300151
|
this.eventEmitter?.emit("mcp-client-update", this.clients);
|
|
300068
300152
|
try {
|
|
@@ -300221,7 +300305,7 @@ var ToolRegistry = class {
|
|
|
300221
300305
|
mcpClientManager;
|
|
300222
300306
|
constructor(config2, eventEmitter) {
|
|
300223
300307
|
this.config = config2;
|
|
300224
|
-
this.mcpClientManager = new McpClientManager(this
|
|
300308
|
+
this.mcpClientManager = new McpClientManager(this, eventEmitter);
|
|
300225
300309
|
}
|
|
300226
300310
|
/**
|
|
300227
300311
|
* Registers a tool definition.
|
|
@@ -300232,7 +300316,7 @@ var ToolRegistry = class {
|
|
|
300232
300316
|
if (tool instanceof DiscoveredMCPTool) {
|
|
300233
300317
|
tool = tool.asFullyQualifiedTool();
|
|
300234
300318
|
} else {
|
|
300235
|
-
|
|
300319
|
+
debugLogger.warn(`Tool with name "${tool.name}" is already registered. Overwriting.`);
|
|
300236
300320
|
}
|
|
300237
300321
|
}
|
|
300238
300322
|
this.tools.set(tool.name, tool);
|
|
@@ -300375,7 +300459,7 @@ var ToolRegistry = class {
|
|
|
300375
300459
|
}
|
|
300376
300460
|
for (const func2 of functions) {
|
|
300377
300461
|
if (!func2.name) {
|
|
300378
|
-
|
|
300462
|
+
debugLogger.warn("Discovered a tool with no name. Skipping.");
|
|
300379
300463
|
continue;
|
|
300380
300464
|
}
|
|
300381
300465
|
const parameters = func2.parametersJsonSchema && typeof func2.parametersJsonSchema === "object" && !Array.isArray(func2.parametersJsonSchema) ? func2.parametersJsonSchema : {};
|
|
@@ -300477,8 +300561,8 @@ var MEMORY_TOOL_NAME = "save_memory";
|
|
|
300477
300561
|
// packages/core/dist/src/tools/ls.js
|
|
300478
300562
|
var LSToolInvocation = class extends BaseToolInvocation {
|
|
300479
300563
|
config;
|
|
300480
|
-
constructor(config2, params) {
|
|
300481
|
-
super(params);
|
|
300564
|
+
constructor(config2, params, messageBus, _toolName, _toolDisplayName) {
|
|
300565
|
+
super(params, messageBus, _toolName, _toolDisplayName);
|
|
300482
300566
|
this.config = config2;
|
|
300483
300567
|
}
|
|
300484
300568
|
/**
|
|
@@ -300602,10 +300686,11 @@ ${directoryContent}`;
|
|
|
300602
300686
|
}
|
|
300603
300687
|
}
|
|
300604
300688
|
};
|
|
300605
|
-
var LSTool = class extends BaseDeclarativeTool {
|
|
300689
|
+
var LSTool = class _LSTool extends BaseDeclarativeTool {
|
|
300606
300690
|
config;
|
|
300607
|
-
|
|
300608
|
-
|
|
300691
|
+
static Name = LS_TOOL_NAME;
|
|
300692
|
+
constructor(config2, messageBus) {
|
|
300693
|
+
super(_LSTool.Name, "ReadFolder", "Lists the names of files and subdirectories directly within a specified directory path. Can optionally ignore entries matching provided glob patterns.", Kind.Search, {
|
|
300609
300694
|
properties: {
|
|
300610
300695
|
path: {
|
|
300611
300696
|
description: "The absolute path to the directory to list (must be absolute, not relative)",
|
|
@@ -300635,7 +300720,7 @@ var LSTool = class extends BaseDeclarativeTool {
|
|
|
300635
300720
|
},
|
|
300636
300721
|
required: ["path"],
|
|
300637
300722
|
type: "object"
|
|
300638
|
-
});
|
|
300723
|
+
}, true, false, messageBus);
|
|
300639
300724
|
this.config = config2;
|
|
300640
300725
|
}
|
|
300641
300726
|
/**
|
|
@@ -300654,8 +300739,8 @@ var LSTool = class extends BaseDeclarativeTool {
|
|
|
300654
300739
|
}
|
|
300655
300740
|
return null;
|
|
300656
300741
|
}
|
|
300657
|
-
createInvocation(params) {
|
|
300658
|
-
return new LSToolInvocation(this.config, params);
|
|
300742
|
+
createInvocation(params, messageBus, _toolName, _toolDisplayName) {
|
|
300743
|
+
return new LSToolInvocation(this.config, params, messageBus, _toolName, _toolDisplayName);
|
|
300659
300744
|
}
|
|
300660
300745
|
};
|
|
300661
300746
|
|
|
@@ -302163,9 +302248,10 @@ var MemoryToolInvocation = class _MemoryToolInvocation extends BaseToolInvocatio
|
|
|
302163
302248
|
}
|
|
302164
302249
|
}
|
|
302165
302250
|
};
|
|
302166
|
-
var MemoryTool = class extends BaseDeclarativeTool {
|
|
302251
|
+
var MemoryTool = class _MemoryTool extends BaseDeclarativeTool {
|
|
302252
|
+
static Name = MEMORY_TOOL_NAME;
|
|
302167
302253
|
constructor() {
|
|
302168
|
-
super(
|
|
302254
|
+
super(_MemoryTool.Name, "Save Memory", memoryToolDescription, Kind.Think, memoryToolSchemaData.parametersJsonSchema);
|
|
302169
302255
|
}
|
|
302170
302256
|
validateToolParamValues(params) {
|
|
302171
302257
|
if (params.fact.trim() === "") {
|
|
@@ -302492,14 +302578,14 @@ async function isBinaryFile(filePath) {
|
|
|
302492
302578
|
}
|
|
302493
302579
|
return nonPrintableCount / bytesRead > 0.3;
|
|
302494
302580
|
} catch (error) {
|
|
302495
|
-
|
|
302581
|
+
debugLogger.warn(`Failed to check if file is binary: ${filePath}`, error instanceof Error ? error.message : String(error));
|
|
302496
302582
|
return false;
|
|
302497
302583
|
} finally {
|
|
302498
302584
|
if (fh) {
|
|
302499
302585
|
try {
|
|
302500
302586
|
await fh.close();
|
|
302501
302587
|
} catch (closeError) {
|
|
302502
|
-
|
|
302588
|
+
debugLogger.warn(`Failed to close file handle for: ${filePath}`, closeError instanceof Error ? closeError.message : String(closeError));
|
|
302503
302589
|
}
|
|
302504
302590
|
}
|
|
302505
302591
|
}
|
|
@@ -302777,8 +302863,8 @@ function getProgrammingLanguage(args2) {
|
|
|
302777
302863
|
// packages/core/dist/src/tools/read-file.js
|
|
302778
302864
|
var ReadFileToolInvocation = class extends BaseToolInvocation {
|
|
302779
302865
|
config;
|
|
302780
|
-
constructor(config2, params) {
|
|
302781
|
-
super(params);
|
|
302866
|
+
constructor(config2, params, messageBus, _toolName, _toolDisplayName) {
|
|
302867
|
+
super(params, messageBus, _toolName, _toolDisplayName);
|
|
302782
302868
|
this.config = config2;
|
|
302783
302869
|
}
|
|
302784
302870
|
getDescription() {
|
|
@@ -302827,10 +302913,11 @@ ${result.llmContent}`;
|
|
|
302827
302913
|
};
|
|
302828
302914
|
}
|
|
302829
302915
|
};
|
|
302830
|
-
var ReadFileTool = class extends BaseDeclarativeTool {
|
|
302916
|
+
var ReadFileTool = class _ReadFileTool extends BaseDeclarativeTool {
|
|
302831
302917
|
config;
|
|
302832
|
-
|
|
302833
|
-
|
|
302918
|
+
static Name = READ_FILE_TOOL_NAME;
|
|
302919
|
+
constructor(config2, messageBus) {
|
|
302920
|
+
super(_ReadFileTool.Name, "ReadFile", `Reads and returns the content of a specified file. If the file is large, the content will be truncated. The tool's response will clearly indicate if truncation has occurred and will provide details on how to read more of the file using the 'offset' and 'limit' parameters. Handles text, images (PNG, JPG, GIF, WEBP, SVG, BMP), and PDF files. For text files, it can read specific line ranges.`, Kind.Read, {
|
|
302834
302921
|
properties: {
|
|
302835
302922
|
absolute_path: {
|
|
302836
302923
|
description: "The absolute path to the file to read (e.g., '/home/user/project/file.txt'). Relative paths are not supported. You must provide an absolute path.",
|
|
@@ -302847,7 +302934,7 @@ var ReadFileTool = class extends BaseDeclarativeTool {
|
|
|
302847
302934
|
},
|
|
302848
302935
|
required: ["absolute_path"],
|
|
302849
302936
|
type: "object"
|
|
302850
|
-
});
|
|
302937
|
+
}, true, false, messageBus);
|
|
302851
302938
|
this.config = config2;
|
|
302852
302939
|
}
|
|
302853
302940
|
validateToolParamValues(params) {
|
|
@@ -302879,8 +302966,8 @@ var ReadFileTool = class extends BaseDeclarativeTool {
|
|
|
302879
302966
|
}
|
|
302880
302967
|
return null;
|
|
302881
302968
|
}
|
|
302882
|
-
createInvocation(params) {
|
|
302883
|
-
return new ReadFileToolInvocation(this.config, params);
|
|
302969
|
+
createInvocation(params, messageBus, _toolName, _toolDisplayName) {
|
|
302970
|
+
return new ReadFileToolInvocation(this.config, params, messageBus, _toolName, _toolDisplayName);
|
|
302884
302971
|
}
|
|
302885
302972
|
};
|
|
302886
302973
|
|
|
@@ -308405,29 +308492,12 @@ function isGitRepository(directory) {
|
|
|
308405
308492
|
}
|
|
308406
308493
|
}
|
|
308407
308494
|
|
|
308408
|
-
// packages/core/dist/src/utils/debugLogger.js
|
|
308409
|
-
var DebugLogger = class {
|
|
308410
|
-
log(...args2) {
|
|
308411
|
-
console.log(...args2);
|
|
308412
|
-
}
|
|
308413
|
-
warn(...args2) {
|
|
308414
|
-
console.warn(...args2);
|
|
308415
|
-
}
|
|
308416
|
-
error(...args2) {
|
|
308417
|
-
console.error(...args2);
|
|
308418
|
-
}
|
|
308419
|
-
debug(...args2) {
|
|
308420
|
-
console.debug(...args2);
|
|
308421
|
-
}
|
|
308422
|
-
};
|
|
308423
|
-
var debugLogger = new DebugLogger();
|
|
308424
|
-
|
|
308425
308495
|
// packages/core/dist/src/tools/grep.js
|
|
308426
308496
|
var GrepToolInvocation = class extends BaseToolInvocation {
|
|
308427
308497
|
config;
|
|
308428
308498
|
fileExclusions;
|
|
308429
|
-
constructor(config2, params) {
|
|
308430
|
-
super(params);
|
|
308499
|
+
constructor(config2, params, messageBus, _toolName, _toolDisplayName) {
|
|
308500
|
+
super(params, messageBus, _toolName, _toolDisplayName);
|
|
308431
308501
|
this.config = config2;
|
|
308432
308502
|
this.fileExclusions = config2.getFileExclusions();
|
|
308433
308503
|
}
|
|
@@ -308675,10 +308745,10 @@ var GrepToolInvocation = class extends BaseToolInvocation {
|
|
|
308675
308745
|
});
|
|
308676
308746
|
return this.parseGrepOutput(output, absolutePath);
|
|
308677
308747
|
} catch (gitError) {
|
|
308678
|
-
|
|
308748
|
+
debugLogger.debug(`GrepLogic: git grep failed: ${getErrorMessage(gitError)}. Falling back...`);
|
|
308679
308749
|
}
|
|
308680
308750
|
}
|
|
308681
|
-
|
|
308751
|
+
debugLogger.debug("GrepLogic: System grep is being considered as fallback strategy.");
|
|
308682
308752
|
const grepAvailable = await this.isCommandAvailable("grep");
|
|
308683
308753
|
if (grepAvailable) {
|
|
308684
308754
|
strategyUsed = "system grep";
|
|
@@ -308755,10 +308825,10 @@ var GrepToolInvocation = class extends BaseToolInvocation {
|
|
|
308755
308825
|
});
|
|
308756
308826
|
return this.parseGrepOutput(output, absolutePath);
|
|
308757
308827
|
} catch (grepError) {
|
|
308758
|
-
|
|
308828
|
+
debugLogger.debug(`GrepLogic: System grep failed: ${getErrorMessage(grepError)}. Falling back...`);
|
|
308759
308829
|
}
|
|
308760
308830
|
}
|
|
308761
|
-
|
|
308831
|
+
debugLogger.debug("GrepLogic: Falling back to JavaScript grep implementation.");
|
|
308762
308832
|
strategyUsed = "javascript fallback";
|
|
308763
308833
|
const globPattern = include ? include : "**/*";
|
|
308764
308834
|
const ignorePatterns = this.fileExclusions.getGlobExcludes();
|
|
@@ -308788,7 +308858,7 @@ var GrepToolInvocation = class extends BaseToolInvocation {
|
|
|
308788
308858
|
});
|
|
308789
308859
|
} catch (readError) {
|
|
308790
308860
|
if (!isNodeError(readError) || readError.code !== "ENOENT") {
|
|
308791
|
-
|
|
308861
|
+
debugLogger.debug(`GrepLogic: Could not read/process ${fileAbsolutePath}: ${getErrorMessage(readError)}`);
|
|
308792
308862
|
}
|
|
308793
308863
|
}
|
|
308794
308864
|
}
|
|
@@ -308799,10 +308869,11 @@ var GrepToolInvocation = class extends BaseToolInvocation {
|
|
|
308799
308869
|
}
|
|
308800
308870
|
}
|
|
308801
308871
|
};
|
|
308802
|
-
var GrepTool = class extends BaseDeclarativeTool {
|
|
308872
|
+
var GrepTool = class _GrepTool extends BaseDeclarativeTool {
|
|
308803
308873
|
config;
|
|
308804
|
-
|
|
308805
|
-
|
|
308874
|
+
static Name = GREP_TOOL_NAME;
|
|
308875
|
+
constructor(config2, messageBus) {
|
|
308876
|
+
super(_GrepTool.Name, "SearchText", "Searches for a regular expression pattern within the content of files in a specified directory (or current working directory). Can filter files by a glob pattern. Returns the lines containing matches, along with their file paths and line numbers.", Kind.Search, {
|
|
308806
308877
|
properties: {
|
|
308807
308878
|
pattern: {
|
|
308808
308879
|
description: "The regular expression (regex) pattern to search for within file contents (e.g., 'function\\s+myFunction', 'import\\s+\\{.*\\}\\s+from\\s+.*').",
|
|
@@ -308819,7 +308890,7 @@ var GrepTool = class extends BaseDeclarativeTool {
|
|
|
308819
308890
|
},
|
|
308820
308891
|
required: ["pattern"],
|
|
308821
308892
|
type: "object"
|
|
308822
|
-
});
|
|
308893
|
+
}, true, false, messageBus);
|
|
308823
308894
|
this.config = config2;
|
|
308824
308895
|
}
|
|
308825
308896
|
/**
|
|
@@ -308871,8 +308942,8 @@ var GrepTool = class extends BaseDeclarativeTool {
|
|
|
308871
308942
|
}
|
|
308872
308943
|
return null;
|
|
308873
308944
|
}
|
|
308874
|
-
createInvocation(params) {
|
|
308875
|
-
return new GrepToolInvocation(this.config, params);
|
|
308945
|
+
createInvocation(params, messageBus, _toolName, _toolDisplayName) {
|
|
308946
|
+
return new GrepToolInvocation(this.config, params, messageBus, _toolName, _toolDisplayName);
|
|
308876
308947
|
}
|
|
308877
308948
|
};
|
|
308878
308949
|
|
|
@@ -321844,26 +321915,51 @@ var rgPath = join9(__dirname4, "..", "bin", `rg${process.platform === "win32" ?
|
|
|
321844
321915
|
|
|
321845
321916
|
// packages/core/dist/src/tools/ripGrep.js
|
|
321846
321917
|
var DEFAULT_TOTAL_MAX_MATCHES = 2e4;
|
|
321847
|
-
function
|
|
321848
|
-
return
|
|
321918
|
+
function getRgCandidateFilenames() {
|
|
321919
|
+
return process.platform === "win32" ? ["rg.exe", "rg"] : ["rg"];
|
|
321849
321920
|
}
|
|
321850
|
-
async function
|
|
321851
|
-
|
|
321852
|
-
|
|
321921
|
+
async function resolveExistingRgPath() {
|
|
321922
|
+
const binDir = Storage2.getGlobalBinDir();
|
|
321923
|
+
for (const fileName of getRgCandidateFilenames()) {
|
|
321924
|
+
const candidatePath = path34.join(binDir, fileName);
|
|
321925
|
+
if (await fileExists(candidatePath)) {
|
|
321926
|
+
return candidatePath;
|
|
321927
|
+
}
|
|
321928
|
+
}
|
|
321929
|
+
return null;
|
|
321930
|
+
}
|
|
321931
|
+
var ripgrepAcquisitionPromise = null;
|
|
321932
|
+
async function ensureRipgrepAvailable() {
|
|
321933
|
+
const existingPath = await resolveExistingRgPath();
|
|
321934
|
+
if (existingPath) {
|
|
321935
|
+
return existingPath;
|
|
321936
|
+
}
|
|
321937
|
+
if (!ripgrepAcquisitionPromise) {
|
|
321938
|
+
ripgrepAcquisitionPromise = (async () => {
|
|
321939
|
+
try {
|
|
321940
|
+
await downloadRipGrep(Storage2.getGlobalBinDir());
|
|
321941
|
+
return await resolveExistingRgPath();
|
|
321942
|
+
} finally {
|
|
321943
|
+
ripgrepAcquisitionPromise = null;
|
|
321944
|
+
}
|
|
321945
|
+
})();
|
|
321853
321946
|
}
|
|
321854
|
-
|
|
321855
|
-
|
|
321947
|
+
return ripgrepAcquisitionPromise;
|
|
321948
|
+
}
|
|
321949
|
+
async function canUseRipgrep() {
|
|
321950
|
+
return await ensureRipgrepAvailable() !== null;
|
|
321856
321951
|
}
|
|
321857
321952
|
async function ensureRgPath() {
|
|
321858
|
-
|
|
321859
|
-
|
|
321953
|
+
const downloadedPath = await ensureRipgrepAvailable();
|
|
321954
|
+
if (downloadedPath) {
|
|
321955
|
+
return downloadedPath;
|
|
321860
321956
|
}
|
|
321861
321957
|
throw new Error("Cannot use ripgrep.");
|
|
321862
321958
|
}
|
|
321863
321959
|
var GrepToolInvocation2 = class extends BaseToolInvocation {
|
|
321864
321960
|
config;
|
|
321865
|
-
constructor(config2, params) {
|
|
321866
|
-
super(params);
|
|
321961
|
+
constructor(config2, params, messageBus, _toolName, _toolDisplayName) {
|
|
321962
|
+
super(params, messageBus, _toolName, _toolDisplayName);
|
|
321867
321963
|
this.config = config2;
|
|
321868
321964
|
}
|
|
321869
321965
|
/**
|
|
@@ -321909,7 +322005,7 @@ var GrepToolInvocation2 = class extends BaseToolInvocation {
|
|
|
321909
322005
|
let allMatches = [];
|
|
321910
322006
|
const totalMaxMatches = DEFAULT_TOTAL_MAX_MATCHES;
|
|
321911
322007
|
if (this.config.getDebugMode()) {
|
|
321912
|
-
|
|
322008
|
+
debugLogger.log(`[GrepTool] Total result limit: ${totalMaxMatches}`);
|
|
321913
322009
|
}
|
|
321914
322010
|
for (const searchDir of searchDirectories) {
|
|
321915
322011
|
const searchResult = await this.performRipgrepSearch({
|
|
@@ -322112,27 +322208,39 @@ var GrepToolInvocation2 = class extends BaseToolInvocation {
|
|
|
322112
322208
|
return description;
|
|
322113
322209
|
}
|
|
322114
322210
|
};
|
|
322115
|
-
var RipGrepTool = class extends BaseDeclarativeTool {
|
|
322211
|
+
var RipGrepTool = class _RipGrepTool extends BaseDeclarativeTool {
|
|
322116
322212
|
config;
|
|
322117
|
-
|
|
322118
|
-
|
|
322119
|
-
|
|
322120
|
-
|
|
322121
|
-
|
|
322122
|
-
|
|
322123
|
-
|
|
322124
|
-
|
|
322125
|
-
|
|
322126
|
-
|
|
322213
|
+
static Name = GREP_TOOL_NAME;
|
|
322214
|
+
constructor(config2, messageBus) {
|
|
322215
|
+
super(
|
|
322216
|
+
_RipGrepTool.Name,
|
|
322217
|
+
"SearchText",
|
|
322218
|
+
"Searches for a regular expression pattern within the content of files in a specified directory (or current working directory). Can filter files by a glob pattern. Returns the lines containing matches, along with their file paths and line numbers. Total results limited to 20,000 matches like VSCode.",
|
|
322219
|
+
Kind.Search,
|
|
322220
|
+
{
|
|
322221
|
+
properties: {
|
|
322222
|
+
pattern: {
|
|
322223
|
+
description: "The regular expression (regex) pattern to search for within file contents (e.g., 'function\\s+myFunction', 'import\\s+\\{.*\\}\\s+from\\s+.*').",
|
|
322224
|
+
type: "string"
|
|
322225
|
+
},
|
|
322226
|
+
path: {
|
|
322227
|
+
description: "Optional: The absolute path to the directory to search within. If omitted, searches the current working directory.",
|
|
322228
|
+
type: "string"
|
|
322229
|
+
},
|
|
322230
|
+
include: {
|
|
322231
|
+
description: "Optional: A glob pattern to filter which files are searched (e.g., '*.js', '*.{ts,tsx}', 'src/**'). If omitted, searches all files (respecting potential global ignores).",
|
|
322232
|
+
type: "string"
|
|
322233
|
+
}
|
|
322127
322234
|
},
|
|
322128
|
-
|
|
322129
|
-
|
|
322130
|
-
type: "string"
|
|
322131
|
-
}
|
|
322235
|
+
required: ["pattern"],
|
|
322236
|
+
type: "object"
|
|
322132
322237
|
},
|
|
322133
|
-
|
|
322134
|
-
|
|
322135
|
-
|
|
322238
|
+
true,
|
|
322239
|
+
// isOutputMarkdown
|
|
322240
|
+
false,
|
|
322241
|
+
// canUpdateOutput
|
|
322242
|
+
messageBus
|
|
322243
|
+
);
|
|
322136
322244
|
this.config = config2;
|
|
322137
322245
|
}
|
|
322138
322246
|
/**
|
|
@@ -322183,8 +322291,8 @@ var RipGrepTool = class extends BaseDeclarativeTool {
|
|
|
322183
322291
|
}
|
|
322184
322292
|
return null;
|
|
322185
322293
|
}
|
|
322186
|
-
createInvocation(params) {
|
|
322187
|
-
return new GrepToolInvocation2(this.config, params);
|
|
322294
|
+
createInvocation(params, messageBus, _toolName, _toolDisplayName) {
|
|
322295
|
+
return new GrepToolInvocation2(this.config, params, messageBus, _toolName, _toolDisplayName);
|
|
322188
322296
|
}
|
|
322189
322297
|
};
|
|
322190
322298
|
|
|
@@ -322212,8 +322320,8 @@ function sortFileEntries(entries2, nowTimestamp, recencyThresholdMs) {
|
|
|
322212
322320
|
}
|
|
322213
322321
|
var GlobToolInvocation = class extends BaseToolInvocation {
|
|
322214
322322
|
config;
|
|
322215
|
-
constructor(config2, params) {
|
|
322216
|
-
super(params);
|
|
322323
|
+
constructor(config2, params, messageBus, _toolName, _toolDisplayName) {
|
|
322324
|
+
super(params, messageBus, _toolName, _toolDisplayName);
|
|
322217
322325
|
this.config = config2;
|
|
322218
322326
|
}
|
|
322219
322327
|
getDescription() {
|
|
@@ -322332,10 +322440,11 @@ ${fileListDescription}`;
|
|
|
322332
322440
|
}
|
|
322333
322441
|
}
|
|
322334
322442
|
};
|
|
322335
|
-
var GlobTool = class extends BaseDeclarativeTool {
|
|
322443
|
+
var GlobTool = class _GlobTool extends BaseDeclarativeTool {
|
|
322336
322444
|
config;
|
|
322337
|
-
|
|
322338
|
-
|
|
322445
|
+
static Name = GLOB_TOOL_NAME;
|
|
322446
|
+
constructor(config2, messageBus) {
|
|
322447
|
+
super(_GlobTool.Name, "FindFiles", "Efficiently finds files matching specific glob patterns (e.g., `src/**/*.ts`, `**/*.md`), returning absolute paths sorted by modification time (newest first). Ideal for quickly locating files based on their name or path structure, especially in large codebases.", Kind.Search, {
|
|
322339
322448
|
properties: {
|
|
322340
322449
|
pattern: {
|
|
322341
322450
|
description: "The glob pattern to match against (e.g., '**/*.py', 'docs/*.md').",
|
|
@@ -322360,7 +322469,7 @@ var GlobTool = class extends BaseDeclarativeTool {
|
|
|
322360
322469
|
},
|
|
322361
322470
|
required: ["pattern"],
|
|
322362
322471
|
type: "object"
|
|
322363
|
-
});
|
|
322472
|
+
}, true, false, messageBus);
|
|
322364
322473
|
this.config = config2;
|
|
322365
322474
|
}
|
|
322366
322475
|
/**
|
|
@@ -322389,8 +322498,8 @@ var GlobTool = class extends BaseDeclarativeTool {
|
|
|
322389
322498
|
}
|
|
322390
322499
|
return null;
|
|
322391
322500
|
}
|
|
322392
|
-
createInvocation(params) {
|
|
322393
|
-
return new GlobToolInvocation(this.config, params);
|
|
322501
|
+
createInvocation(params, messageBus, _toolName, _toolDisplayName) {
|
|
322502
|
+
return new GlobToolInvocation(this.config, params, messageBus, _toolName, _toolDisplayName);
|
|
322394
322503
|
}
|
|
322395
322504
|
};
|
|
322396
322505
|
|
|
@@ -323290,7 +323399,7 @@ import * as os10 from "node:os";
|
|
|
323290
323399
|
import * as path37 from "node:path";
|
|
323291
323400
|
var logger2 = {
|
|
323292
323401
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
323293
|
-
debug: (...args2) =>
|
|
323402
|
+
debug: (...args2) => debugLogger.debug("[DEBUG] [IDEClient]", ...args2),
|
|
323294
323403
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
323295
323404
|
error: (...args2) => console.error("[ERROR] [IDEClient]", ...args2)
|
|
323296
323405
|
};
|
|
@@ -324009,11 +324118,11 @@ var EditToolInvocation = class {
|
|
|
324009
324118
|
throw error;
|
|
324010
324119
|
}
|
|
324011
324120
|
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
324012
|
-
|
|
324121
|
+
debugLogger.log(`Error preparing edit: ${errorMsg}`);
|
|
324013
324122
|
return false;
|
|
324014
324123
|
}
|
|
324015
324124
|
if (editData.error) {
|
|
324016
|
-
|
|
324125
|
+
debugLogger.log(`Error: ${editData.error.display}`);
|
|
324017
324126
|
return false;
|
|
324018
324127
|
}
|
|
324019
324128
|
const fileName = path38.basename(this.params.file_path);
|
|
@@ -324148,10 +324257,11 @@ var EditToolInvocation = class {
|
|
|
324148
324257
|
}
|
|
324149
324258
|
}
|
|
324150
324259
|
};
|
|
324151
|
-
var EditTool = class extends BaseDeclarativeTool {
|
|
324260
|
+
var EditTool = class _EditTool extends BaseDeclarativeTool {
|
|
324152
324261
|
config;
|
|
324262
|
+
static Name = EDIT_TOOL_NAME;
|
|
324153
324263
|
constructor(config2) {
|
|
324154
|
-
super(
|
|
324264
|
+
super(_EditTool.Name, "Edit", `Replaces text within a file. By default, replaces a single occurrence, but can replace multiple occurrences when \`expected_replacements\` is specified. This tool requires providing significant context around the change to ensure precise targeting. Always use the ${READ_FILE_TOOL_NAME} tool to examine the file's current content before attempting a text replacement.
|
|
324155
324265
|
|
|
324156
324266
|
The user has the ability to modify the \`new_string\` content. If modified, this will be stated in the response.
|
|
324157
324267
|
|
|
@@ -324333,47 +324443,42 @@ function getDiffCommand(oldPath, newPath, editor) {
|
|
|
324333
324443
|
async function openDiff(oldPath, newPath, editor, onEditorClose) {
|
|
324334
324444
|
const diffCommand = getDiffCommand(oldPath, newPath, editor);
|
|
324335
324445
|
if (!diffCommand) {
|
|
324336
|
-
|
|
324446
|
+
debugLogger.error("No diff tool available. Install a supported editor.");
|
|
324337
324447
|
return;
|
|
324338
324448
|
}
|
|
324339
|
-
|
|
324340
|
-
|
|
324341
|
-
|
|
324342
|
-
|
|
324343
|
-
|
|
324344
|
-
|
|
324345
|
-
|
|
324346
|
-
|
|
324347
|
-
throw result.error;
|
|
324348
|
-
}
|
|
324349
|
-
if (result.status !== 0) {
|
|
324350
|
-
throw new Error(`${editor} exited with code ${result.status}`);
|
|
324351
|
-
}
|
|
324352
|
-
} finally {
|
|
324353
|
-
onEditorClose();
|
|
324449
|
+
const isTerminalEditor = ["vim", "emacs", "neovim"].includes(editor);
|
|
324450
|
+
if (isTerminalEditor) {
|
|
324451
|
+
try {
|
|
324452
|
+
const result = spawnSync2(diffCommand.command, diffCommand.args, {
|
|
324453
|
+
stdio: "inherit"
|
|
324454
|
+
});
|
|
324455
|
+
if (result.error) {
|
|
324456
|
+
throw result.error;
|
|
324354
324457
|
}
|
|
324355
|
-
|
|
324458
|
+
if (result.status !== 0) {
|
|
324459
|
+
throw new Error(`${editor} exited with code ${result.status}`);
|
|
324460
|
+
}
|
|
324461
|
+
} finally {
|
|
324462
|
+
onEditorClose();
|
|
324356
324463
|
}
|
|
324357
|
-
return
|
|
324358
|
-
const childProcess2 = spawn6(diffCommand.command, diffCommand.args, {
|
|
324359
|
-
stdio: "inherit",
|
|
324360
|
-
shell: process.platform === "win32"
|
|
324361
|
-
});
|
|
324362
|
-
childProcess2.on("close", (code2) => {
|
|
324363
|
-
if (code2 === 0) {
|
|
324364
|
-
resolve13();
|
|
324365
|
-
} else {
|
|
324366
|
-
reject(new Error(`${editor} exited with code ${code2}`));
|
|
324367
|
-
}
|
|
324368
|
-
});
|
|
324369
|
-
childProcess2.on("error", (error) => {
|
|
324370
|
-
reject(error);
|
|
324371
|
-
});
|
|
324372
|
-
});
|
|
324373
|
-
} catch (error) {
|
|
324374
|
-
console.error(error);
|
|
324375
|
-
throw error;
|
|
324464
|
+
return;
|
|
324376
324465
|
}
|
|
324466
|
+
return new Promise((resolve13, reject) => {
|
|
324467
|
+
const childProcess2 = spawn6(diffCommand.command, diffCommand.args, {
|
|
324468
|
+
stdio: "inherit",
|
|
324469
|
+
shell: process.platform === "win32"
|
|
324470
|
+
});
|
|
324471
|
+
childProcess2.on("close", (code2) => {
|
|
324472
|
+
if (code2 === 0) {
|
|
324473
|
+
resolve13();
|
|
324474
|
+
} else {
|
|
324475
|
+
reject(new Error(`${editor} exited with code ${code2}`));
|
|
324476
|
+
}
|
|
324477
|
+
});
|
|
324478
|
+
childProcess2.on("error", (error) => {
|
|
324479
|
+
reject(error);
|
|
324480
|
+
});
|
|
324481
|
+
});
|
|
324377
324482
|
}
|
|
324378
324483
|
|
|
324379
324484
|
// packages/core/dist/src/tools/modifiable-tool.js
|
|
@@ -324656,7 +324761,7 @@ async function retryWithBackoff(fn, options2) {
|
|
|
324656
324761
|
throw error;
|
|
324657
324762
|
}
|
|
324658
324763
|
} catch (fallbackError) {
|
|
324659
|
-
|
|
324764
|
+
debugLogger.warn("Fallback to Flash model failed:", fallbackError);
|
|
324660
324765
|
}
|
|
324661
324766
|
}
|
|
324662
324767
|
if (errorStatus === 429 && authType === AuthType2.LOGIN_WITH_GOOGLE && !isProQuotaExceededError(error) && isGenericQuotaExceededError(error) && onPersistent429) {
|
|
@@ -324671,7 +324776,7 @@ async function retryWithBackoff(fn, options2) {
|
|
|
324671
324776
|
throw error;
|
|
324672
324777
|
}
|
|
324673
324778
|
} catch (fallbackError) {
|
|
324674
|
-
|
|
324779
|
+
debugLogger.warn("Fallback to Flash model failed:", fallbackError);
|
|
324675
324780
|
}
|
|
324676
324781
|
}
|
|
324677
324782
|
if (errorStatus === 429) {
|
|
@@ -324691,7 +324796,7 @@ async function retryWithBackoff(fn, options2) {
|
|
|
324691
324796
|
throw error;
|
|
324692
324797
|
}
|
|
324693
324798
|
} catch (fallbackError) {
|
|
324694
|
-
|
|
324799
|
+
debugLogger.warn("Fallback to Flash model failed:", fallbackError);
|
|
324695
324800
|
}
|
|
324696
324801
|
}
|
|
324697
324802
|
if (attempt >= maxAttempts || !shouldRetryOnError(error, retryFetchErrors)) {
|
|
@@ -324699,7 +324804,7 @@ async function retryWithBackoff(fn, options2) {
|
|
|
324699
324804
|
}
|
|
324700
324805
|
const { delayDurationMs, errorStatus: delayErrorStatus } = getDelayDurationAndStatus(error);
|
|
324701
324806
|
if (delayDurationMs > 0) {
|
|
324702
|
-
|
|
324807
|
+
debugLogger.warn(`Attempt ${attempt} failed with status ${delayErrorStatus ?? "unknown"}. Retrying after explicit delay of ${delayDurationMs}ms...`, error);
|
|
324703
324808
|
await delay2(delayDurationMs, signal);
|
|
324704
324809
|
currentDelay = initialDelayMs;
|
|
324705
324810
|
} else {
|
|
@@ -324763,19 +324868,19 @@ function logRetryAttempt(attempt, error, errorStatus) {
|
|
|
324763
324868
|
message = `Attempt ${attempt} failed with status ${errorStatus}. Retrying with backoff...`;
|
|
324764
324869
|
}
|
|
324765
324870
|
if (errorStatus === 429) {
|
|
324766
|
-
|
|
324871
|
+
debugLogger.warn(message, error);
|
|
324767
324872
|
} else if (errorStatus && errorStatus >= 500 && errorStatus < 600) {
|
|
324768
324873
|
console.error(message, error);
|
|
324769
324874
|
} else if (error instanceof Error) {
|
|
324770
324875
|
if (error.message.includes("429")) {
|
|
324771
|
-
|
|
324876
|
+
debugLogger.warn(`Attempt ${attempt} failed with 429 error (no Retry-After header). Retrying with backoff...`, error);
|
|
324772
324877
|
} else if (error.message.match(/5\d{2}/)) {
|
|
324773
324878
|
console.error(`Attempt ${attempt} failed with 5xx error. Retrying with backoff...`, error);
|
|
324774
324879
|
} else {
|
|
324775
|
-
|
|
324880
|
+
debugLogger.warn(message, error);
|
|
324776
324881
|
}
|
|
324777
324882
|
} else {
|
|
324778
|
-
|
|
324883
|
+
debugLogger.warn(message, error);
|
|
324779
324884
|
}
|
|
324780
324885
|
}
|
|
324781
324886
|
|
|
@@ -324939,7 +325044,7 @@ async function FixLLMEditWithInstruction(instruction, old_string, new_string, er
|
|
|
324939
325044
|
let promptId = promptIdContext.getStore();
|
|
324940
325045
|
if (!promptId) {
|
|
324941
325046
|
promptId = `llm-fixer-fallback-${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
324942
|
-
|
|
325047
|
+
debugLogger.warn(`Could not find promptId in context. This is unexpected. Using a fallback ID: ${promptId}`);
|
|
324943
325048
|
}
|
|
324944
325049
|
const cacheKey = createHash8("sha256").update(JSON.stringify([
|
|
324945
325050
|
current_content,
|
|
@@ -325356,11 +325461,11 @@ var EditToolInvocation2 = class {
|
|
|
325356
325461
|
throw error;
|
|
325357
325462
|
}
|
|
325358
325463
|
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
325359
|
-
|
|
325464
|
+
debugLogger.log(`Error preparing edit: ${errorMsg}`);
|
|
325360
325465
|
return false;
|
|
325361
325466
|
}
|
|
325362
325467
|
if (editData.error) {
|
|
325363
|
-
|
|
325468
|
+
debugLogger.log(`Error: ${editData.error.display}`);
|
|
325364
325469
|
return false;
|
|
325365
325470
|
}
|
|
325366
325471
|
const fileName = path42.basename(this.params.file_path);
|
|
@@ -325499,10 +325604,11 @@ var EditToolInvocation2 = class {
|
|
|
325499
325604
|
}
|
|
325500
325605
|
}
|
|
325501
325606
|
};
|
|
325502
|
-
var SmartEditTool = class extends BaseDeclarativeTool {
|
|
325607
|
+
var SmartEditTool = class _SmartEditTool extends BaseDeclarativeTool {
|
|
325503
325608
|
config;
|
|
325609
|
+
static Name = EDIT_TOOL_NAME;
|
|
325504
325610
|
constructor(config2) {
|
|
325505
|
-
super(
|
|
325611
|
+
super(_SmartEditTool.Name, "Edit", `Replaces text within a file. Replaces a single occurrence. This tool requires providing significant context around the change to ensure precise targeting. Always use the ${READ_FILE_TOOL_NAME} tool to examine the file's current content before attempting a text replacement.
|
|
325506
325612
|
|
|
325507
325613
|
The user has the ability to modify the \`new_string\` content. If modified, this will be stated in the response.
|
|
325508
325614
|
|
|
@@ -325714,7 +325820,7 @@ function getSystemEncoding() {
|
|
|
325714
325820
|
}
|
|
325715
325821
|
throw new Error(`Unable to parse Windows code page from 'chcp' output "${output.trim()}". `);
|
|
325716
325822
|
} catch (error) {
|
|
325717
|
-
|
|
325823
|
+
debugLogger.warn(`Failed to get Windows code page using 'chcp' command: ${error instanceof Error ? error.message : String(error)}. Will attempt to detect encoding from command output instead.`);
|
|
325718
325824
|
}
|
|
325719
325825
|
return null;
|
|
325720
325826
|
}
|
|
@@ -325724,7 +325830,7 @@ function getSystemEncoding() {
|
|
|
325724
325830
|
try {
|
|
325725
325831
|
locale = execSync2("locale charmap", { encoding: "utf8" }).toString().trim();
|
|
325726
325832
|
} catch (_e) {
|
|
325727
|
-
|
|
325833
|
+
debugLogger.warn("Failed to get locale charmap.");
|
|
325728
325834
|
return null;
|
|
325729
325835
|
}
|
|
325730
325836
|
}
|
|
@@ -325764,7 +325870,7 @@ function windowsCodePageToEncoding(cp) {
|
|
|
325764
325870
|
if (map2[cp]) {
|
|
325765
325871
|
return map2[cp];
|
|
325766
325872
|
}
|
|
325767
|
-
|
|
325873
|
+
debugLogger.warn(`Unable to determine encoding for windows code page ${cp}.`);
|
|
325768
325874
|
return null;
|
|
325769
325875
|
}
|
|
325770
325876
|
function detectEncodingFromBuffer(buffer) {
|
|
@@ -325774,7 +325880,7 @@ function detectEncodingFromBuffer(buffer) {
|
|
|
325774
325880
|
return detected.toLowerCase();
|
|
325775
325881
|
}
|
|
325776
325882
|
} catch (error) {
|
|
325777
|
-
|
|
325883
|
+
debugLogger.warn("Failed to detect encoding with chardet:", error);
|
|
325778
325884
|
}
|
|
325779
325885
|
return null;
|
|
325780
325886
|
}
|
|
@@ -330197,6 +330303,37 @@ function isCommandAllowed(command, config2) {
|
|
|
330197
330303
|
}
|
|
330198
330304
|
return { allowed: false, reason: blockReason };
|
|
330199
330305
|
}
|
|
330306
|
+
function isShellInvocationAllowlisted(invocation, allowedPatterns) {
|
|
330307
|
+
if (!allowedPatterns.length) {
|
|
330308
|
+
return false;
|
|
330309
|
+
}
|
|
330310
|
+
const hasShellWildcard = allowedPatterns.some((pattern) => SHELL_TOOL_NAMES.includes(pattern));
|
|
330311
|
+
const hasShellSpecificPattern = allowedPatterns.some((pattern) => SHELL_TOOL_NAMES.some((name4) => pattern.startsWith(`${name4}(`)));
|
|
330312
|
+
if (!hasShellWildcard && !hasShellSpecificPattern) {
|
|
330313
|
+
return false;
|
|
330314
|
+
}
|
|
330315
|
+
if (hasShellWildcard) {
|
|
330316
|
+
return true;
|
|
330317
|
+
}
|
|
330318
|
+
if (!("params" in invocation) || typeof invocation.params !== "object" || invocation.params === null || !("command" in invocation.params)) {
|
|
330319
|
+
return false;
|
|
330320
|
+
}
|
|
330321
|
+
const commandValue = invocation.params.command;
|
|
330322
|
+
if (typeof commandValue !== "string" || !commandValue.trim()) {
|
|
330323
|
+
return false;
|
|
330324
|
+
}
|
|
330325
|
+
const command = commandValue.trim();
|
|
330326
|
+
const parseResult = parseCommandDetails(command);
|
|
330327
|
+
if (!parseResult || parseResult.hasError) {
|
|
330328
|
+
return false;
|
|
330329
|
+
}
|
|
330330
|
+
const normalize5 = (cmd) => cmd.trim().replace(/\s+/g, " ");
|
|
330331
|
+
const commandsToValidate = parseResult.details.map((detail) => normalize5(detail.text)).filter(Boolean);
|
|
330332
|
+
if (commandsToValidate.length === 0) {
|
|
330333
|
+
return false;
|
|
330334
|
+
}
|
|
330335
|
+
return commandsToValidate.every((commandSegment) => doesToolInvocationMatch(SHELL_TOOL_NAMES[0], { params: { command: commandSegment } }, allowedPatterns));
|
|
330336
|
+
}
|
|
330200
330337
|
|
|
330201
330338
|
// packages/core/dist/src/services/shellExecutionService.js
|
|
330202
330339
|
var import_headless = __toESM(require_xterm_headless(), 1);
|
|
@@ -331063,19 +331200,27 @@ var ShellExecutionService = class {
|
|
|
331063
331200
|
return { pid: ptyProcess.pid, result };
|
|
331064
331201
|
} catch (e2) {
|
|
331065
331202
|
const error = e2;
|
|
331066
|
-
|
|
331067
|
-
|
|
331068
|
-
|
|
331069
|
-
|
|
331070
|
-
|
|
331071
|
-
|
|
331072
|
-
|
|
331073
|
-
|
|
331074
|
-
aborted: false,
|
|
331203
|
+
if (error.message.includes("posix_spawnp failed")) {
|
|
331204
|
+
onOutputEvent({
|
|
331205
|
+
type: "data",
|
|
331206
|
+
chunk: "[GEMINI_CLI_WARNING] PTY execution failed, falling back to child_process. This may be due to sandbox restrictions.\n"
|
|
331207
|
+
});
|
|
331208
|
+
throw e2;
|
|
331209
|
+
} else {
|
|
331210
|
+
return {
|
|
331075
331211
|
pid: void 0,
|
|
331076
|
-
|
|
331077
|
-
|
|
331078
|
-
|
|
331212
|
+
result: Promise.resolve({
|
|
331213
|
+
error,
|
|
331214
|
+
rawOutput: Buffer.from(""),
|
|
331215
|
+
output: "",
|
|
331216
|
+
exitCode: 1,
|
|
331217
|
+
signal: null,
|
|
331218
|
+
aborted: false,
|
|
331219
|
+
pid: void 0,
|
|
331220
|
+
executionMethod: "none"
|
|
331221
|
+
})
|
|
331222
|
+
};
|
|
331223
|
+
}
|
|
331079
331224
|
}
|
|
331080
331225
|
}
|
|
331081
331226
|
/**
|
|
@@ -331117,7 +331262,7 @@ var ShellExecutionService = class {
|
|
|
331117
331262
|
activePty.ptyProcess.resize(cols, rows);
|
|
331118
331263
|
activePty.headlessTerminal.resize(cols, rows);
|
|
331119
331264
|
} catch (e2) {
|
|
331120
|
-
if (e2 instanceof Error && "code" in e2 && e2.code === "ESRCH") {
|
|
331265
|
+
if (e2 instanceof Error && ("code" in e2 && e2.code === "ESRCH" || e2.message === "Cannot resize a pty that has already exited")) {
|
|
331121
331266
|
} else {
|
|
331122
331267
|
throw e2;
|
|
331123
331268
|
}
|
|
@@ -331372,14 +331517,15 @@ function getCommandDescription() {
|
|
|
331372
331517
|
return "Exact bash command to execute as `bash -c <command>`";
|
|
331373
331518
|
}
|
|
331374
331519
|
}
|
|
331375
|
-
var ShellTool = class extends BaseDeclarativeTool {
|
|
331520
|
+
var ShellTool = class _ShellTool extends BaseDeclarativeTool {
|
|
331376
331521
|
config;
|
|
331522
|
+
static Name = SHELL_TOOL_NAME;
|
|
331377
331523
|
allowlist = /* @__PURE__ */ new Set();
|
|
331378
331524
|
constructor(config2) {
|
|
331379
331525
|
void initializeShellParsers().catch(() => {
|
|
331380
331526
|
});
|
|
331381
331527
|
super(
|
|
331382
|
-
|
|
331528
|
+
_ShellTool.Name,
|
|
331383
331529
|
"Shell",
|
|
331384
331530
|
getShellToolDescription(),
|
|
331385
331531
|
Kind.Execute,
|
|
@@ -331619,10 +331765,11 @@ var WriteFileToolInvocation = class extends BaseToolInvocation {
|
|
|
331619
331765
|
}
|
|
331620
331766
|
}
|
|
331621
331767
|
};
|
|
331622
|
-
var WriteFileTool = class extends BaseDeclarativeTool {
|
|
331768
|
+
var WriteFileTool = class _WriteFileTool extends BaseDeclarativeTool {
|
|
331623
331769
|
config;
|
|
331770
|
+
static Name = WRITE_FILE_TOOL_NAME;
|
|
331624
331771
|
constructor(config2) {
|
|
331625
|
-
super(
|
|
331772
|
+
super(_WriteFileTool.Name, "WriteFile", `Writes content to a specified file in the local filesystem.
|
|
331626
331773
|
|
|
331627
331774
|
The user has the ability to modify \`content\`. If modified, this will be stated in the response.`, Kind.Edit, {
|
|
331628
331775
|
properties: {
|
|
@@ -331693,6 +331840,7 @@ var WriteFileTool = class extends BaseDeclarativeTool {
|
|
|
331693
331840
|
};
|
|
331694
331841
|
|
|
331695
331842
|
// packages/core/dist/src/utils/fetch.js
|
|
331843
|
+
var import_undici2 = __toESM(require_undici(), 1);
|
|
331696
331844
|
import { URL as URL8 } from "node:url";
|
|
331697
331845
|
var PRIVATE_IP_RANGES = [
|
|
331698
331846
|
/^10\./,
|
|
@@ -331734,6 +331882,13 @@ async function fetchWithTimeout(url4, timeout) {
|
|
|
331734
331882
|
clearTimeout(timeoutId);
|
|
331735
331883
|
}
|
|
331736
331884
|
}
|
|
331885
|
+
function setGlobalProxy(proxy2) {
|
|
331886
|
+
try {
|
|
331887
|
+
(0, import_undici2.setGlobalDispatcher)(new import_undici2.ProxyAgent(proxy2));
|
|
331888
|
+
} catch (e2) {
|
|
331889
|
+
console.error(`Failed to set proxy: ${getErrorMessage(e2)}`);
|
|
331890
|
+
}
|
|
331891
|
+
}
|
|
331737
331892
|
|
|
331738
331893
|
// node_modules/domelementtype/lib/esm/index.js
|
|
331739
331894
|
var ElementType;
|
|
@@ -336674,7 +336829,6 @@ function handleDeprecatedOptions(options2) {
|
|
|
336674
336829
|
}
|
|
336675
336830
|
|
|
336676
336831
|
// packages/core/dist/src/tools/web-fetch.js
|
|
336677
|
-
var import_undici2 = __toESM(require_undici(), 1);
|
|
336678
336832
|
var URL_FETCH_TIMEOUT_MS = 1e4;
|
|
336679
336833
|
var MAX_CONTENT_LENGTH = 1e5;
|
|
336680
336834
|
function parsePrompt(text) {
|
|
@@ -336701,8 +336855,8 @@ function parsePrompt(text) {
|
|
|
336701
336855
|
}
|
|
336702
336856
|
var WebFetchToolInvocation = class extends BaseToolInvocation {
|
|
336703
336857
|
config;
|
|
336704
|
-
constructor(config2, params, messageBus) {
|
|
336705
|
-
super(params, messageBus);
|
|
336858
|
+
constructor(config2, params, messageBus, _toolName, _toolDisplayName) {
|
|
336859
|
+
super(params, messageBus, _toolName, _toolDisplayName);
|
|
336706
336860
|
this.config = config2;
|
|
336707
336861
|
}
|
|
336708
336862
|
async executeFallback(signal) {
|
|
@@ -336814,7 +336968,7 @@ ${textContent2}
|
|
|
336814
336968
|
// Pass signal
|
|
336815
336969
|
DEFAULT_GEMINI_FLASH_MODEL
|
|
336816
336970
|
);
|
|
336817
|
-
|
|
336971
|
+
debugLogger.debug(`[WebFetchTool] Full response for prompt "${userPrompt.substring(0, 50)}...":`, JSON.stringify(response, null, 2));
|
|
336818
336972
|
let responseText = getResponseText(response) || "";
|
|
336819
336973
|
const urlContextMeta = response.candidates?.[0]?.urlContextMetadata;
|
|
336820
336974
|
const groundingMetadata = response.candidates?.[0]?.groundingMetadata;
|
|
@@ -336869,7 +337023,7 @@ ${sourceListFormatted.join("\n")}`;
|
|
|
336869
337023
|
}
|
|
336870
337024
|
}
|
|
336871
337025
|
const llmContent = responseText;
|
|
336872
|
-
|
|
337026
|
+
debugLogger.debug(`[WebFetchTool] Formatted tool response for prompt "${userPrompt}:
|
|
336873
337027
|
|
|
336874
337028
|
":`, llmContent);
|
|
336875
337029
|
return {
|
|
@@ -336889,11 +337043,12 @@ ${sourceListFormatted.join("\n")}`;
|
|
|
336889
337043
|
}
|
|
336890
337044
|
}
|
|
336891
337045
|
};
|
|
336892
|
-
var WebFetchTool = class extends BaseDeclarativeTool {
|
|
337046
|
+
var WebFetchTool = class _WebFetchTool extends BaseDeclarativeTool {
|
|
336893
337047
|
config;
|
|
337048
|
+
static Name = WEB_FETCH_TOOL_NAME;
|
|
336894
337049
|
constructor(config2, messageBus) {
|
|
336895
337050
|
super(
|
|
336896
|
-
|
|
337051
|
+
_WebFetchTool.Name,
|
|
336897
337052
|
"WebFetch",
|
|
336898
337053
|
"Processes content from URL(s), including local and private network addresses (e.g., localhost), embedded in a prompt. Include up to 20 URLs and instructions (e.g., summarize, extract specific data) directly in the 'prompt' parameter.",
|
|
336899
337054
|
Kind.Fetch,
|
|
@@ -336916,7 +337071,7 @@ var WebFetchTool = class extends BaseDeclarativeTool {
|
|
|
336916
337071
|
this.config = config2;
|
|
336917
337072
|
const proxy2 = config2.getProxy();
|
|
336918
337073
|
if (proxy2) {
|
|
336919
|
-
(
|
|
337074
|
+
setGlobalProxy(proxy2);
|
|
336920
337075
|
}
|
|
336921
337076
|
}
|
|
336922
337077
|
validateToolParamValues(params) {
|
|
@@ -336933,8 +337088,8 @@ var WebFetchTool = class extends BaseDeclarativeTool {
|
|
|
336933
337088
|
}
|
|
336934
337089
|
return null;
|
|
336935
337090
|
}
|
|
336936
|
-
createInvocation(params, messageBus) {
|
|
336937
|
-
return new WebFetchToolInvocation(this.config, params, messageBus);
|
|
337091
|
+
createInvocation(params, messageBus, _toolName, _toolDisplayName) {
|
|
337092
|
+
return new WebFetchToolInvocation(this.config, params, messageBus, _toolName, _toolDisplayName);
|
|
336938
337093
|
}
|
|
336939
337094
|
};
|
|
336940
337095
|
|
|
@@ -336948,8 +337103,8 @@ var DEFAULT_OUTPUT_SEPARATOR_FORMAT = "--- {filePath} ---";
|
|
|
336948
337103
|
var DEFAULT_OUTPUT_TERMINATOR = "\n--- End of content ---";
|
|
336949
337104
|
var ReadManyFilesToolInvocation = class extends BaseToolInvocation {
|
|
336950
337105
|
config;
|
|
336951
|
-
constructor(config2, params) {
|
|
336952
|
-
super(params);
|
|
337106
|
+
constructor(config2, params, messageBus, _toolName, _toolDisplayName) {
|
|
337107
|
+
super(params, messageBus, _toolName, _toolDisplayName);
|
|
336953
337108
|
this.config = config2;
|
|
336954
337109
|
}
|
|
336955
337110
|
getDescription() {
|
|
@@ -337200,9 +337355,10 @@ ${fileContentForLlm}
|
|
|
337200
337355
|
};
|
|
337201
337356
|
}
|
|
337202
337357
|
};
|
|
337203
|
-
var ReadManyFilesTool = class extends BaseDeclarativeTool {
|
|
337358
|
+
var ReadManyFilesTool = class _ReadManyFilesTool extends BaseDeclarativeTool {
|
|
337204
337359
|
config;
|
|
337205
|
-
|
|
337360
|
+
static Name = READ_MANY_FILES_TOOL_NAME;
|
|
337361
|
+
constructor(config2, messageBus) {
|
|
337206
337362
|
const parameterSchema = {
|
|
337207
337363
|
type: "object",
|
|
337208
337364
|
properties: {
|
|
@@ -337260,7 +337416,10 @@ var ReadManyFilesTool = class extends BaseDeclarativeTool {
|
|
|
337260
337416
|
},
|
|
337261
337417
|
required: ["paths"]
|
|
337262
337418
|
};
|
|
337263
|
-
super(
|
|
337419
|
+
super(
|
|
337420
|
+
_ReadManyFilesTool.Name,
|
|
337421
|
+
"ReadManyFiles",
|
|
337422
|
+
`Reads content from multiple files specified by paths or glob patterns within a configured target directory. For text files, it concatenates their content into a single string. It is primarily designed for text-based files. However, it can also process image (e.g., .png, .jpg) and PDF (.pdf) files if their file names or extensions are explicitly included in the 'paths' argument. For these explicitly requested non-text files, their data is read and included in a format suitable for model consumption (e.g., base64 encoded).
|
|
337264
337423
|
|
|
337265
337424
|
This tool is useful when you need to understand or analyze a collection of files, such as:
|
|
337266
337425
|
- Getting an overview of a codebase or parts of it (e.g., all TypeScript files in the 'src' directory).
|
|
@@ -337269,19 +337428,27 @@ This tool is useful when you need to understand or analyze a collection of files
|
|
|
337269
337428
|
- Gathering context from multiple configuration files.
|
|
337270
337429
|
- When the user asks to "read all files in X directory" or "show me the content of all Y files".
|
|
337271
337430
|
|
|
337272
|
-
Use this tool when the user's query implies needing the content of several files simultaneously for context, analysis, or summarization. For text files, it uses default UTF-8 encoding and a '--- {filePath} ---' separator between file contents. The tool inserts a '--- End of content ---' after the last file. Ensure paths are relative to the target directory. Glob patterns like 'src/**/*.js' are supported. Avoid using for single files if a more specific single-file reading tool is available, unless the user specifically requests to process a list containing just one file via this tool. Other binary files (not explicitly requested as image/PDF) are generally skipped. Default excludes apply to common non-text files (except for explicitly requested images/PDFs) and large dependency directories unless 'useDefaultExcludes' is false.`,
|
|
337431
|
+
Use this tool when the user's query implies needing the content of several files simultaneously for context, analysis, or summarization. For text files, it uses default UTF-8 encoding and a '--- {filePath} ---' separator between file contents. The tool inserts a '--- End of content ---' after the last file. Ensure paths are relative to the target directory. Glob patterns like 'src/**/*.js' are supported. Avoid using for single files if a more specific single-file reading tool is available, unless the user specifically requests to process a list containing just one file via this tool. Other binary files (not explicitly requested as image/PDF) are generally skipped. Default excludes apply to common non-text files (except for explicitly requested images/PDFs) and large dependency directories unless 'useDefaultExcludes' is false.`,
|
|
337432
|
+
Kind.Read,
|
|
337433
|
+
parameterSchema,
|
|
337434
|
+
true,
|
|
337435
|
+
// isOutputMarkdown
|
|
337436
|
+
false,
|
|
337437
|
+
// canUpdateOutput
|
|
337438
|
+
messageBus
|
|
337439
|
+
);
|
|
337273
337440
|
this.config = config2;
|
|
337274
337441
|
}
|
|
337275
|
-
createInvocation(params) {
|
|
337276
|
-
return new ReadManyFilesToolInvocation(this.config, params);
|
|
337442
|
+
createInvocation(params, messageBus, _toolName, _toolDisplayName) {
|
|
337443
|
+
return new ReadManyFilesToolInvocation(this.config, params, messageBus, _toolName, _toolDisplayName);
|
|
337277
337444
|
}
|
|
337278
337445
|
};
|
|
337279
337446
|
|
|
337280
337447
|
// packages/core/dist/src/tools/web-search.js
|
|
337281
337448
|
var WebSearchToolInvocation = class extends BaseToolInvocation {
|
|
337282
337449
|
config;
|
|
337283
|
-
constructor(config2, params) {
|
|
337284
|
-
super(params);
|
|
337450
|
+
constructor(config2, params, messageBus, _toolName, _toolDisplayName) {
|
|
337451
|
+
super(params, messageBus, _toolName, _toolDisplayName);
|
|
337285
337452
|
this.config = config2;
|
|
337286
337453
|
}
|
|
337287
337454
|
getDescription() {
|
|
@@ -337366,19 +337533,31 @@ ${modifiedResponseText}`,
|
|
|
337366
337533
|
}
|
|
337367
337534
|
}
|
|
337368
337535
|
};
|
|
337369
|
-
var WebSearchTool = class extends BaseDeclarativeTool {
|
|
337536
|
+
var WebSearchTool = class _WebSearchTool extends BaseDeclarativeTool {
|
|
337370
337537
|
config;
|
|
337371
|
-
|
|
337372
|
-
|
|
337373
|
-
|
|
337374
|
-
|
|
337375
|
-
|
|
337376
|
-
|
|
337377
|
-
|
|
337378
|
-
|
|
337538
|
+
static Name = WEB_SEARCH_TOOL_NAME;
|
|
337539
|
+
constructor(config2, messageBus) {
|
|
337540
|
+
super(
|
|
337541
|
+
_WebSearchTool.Name,
|
|
337542
|
+
"GoogleSearch",
|
|
337543
|
+
"Performs a web search using Google Search (via the Gemini API) and returns the results. This tool is useful for finding information on the internet based on a query.",
|
|
337544
|
+
Kind.Search,
|
|
337545
|
+
{
|
|
337546
|
+
type: "object",
|
|
337547
|
+
properties: {
|
|
337548
|
+
query: {
|
|
337549
|
+
type: "string",
|
|
337550
|
+
description: "The search query to find information on the web."
|
|
337551
|
+
}
|
|
337552
|
+
},
|
|
337553
|
+
required: ["query"]
|
|
337379
337554
|
},
|
|
337380
|
-
|
|
337381
|
-
|
|
337555
|
+
true,
|
|
337556
|
+
// isOutputMarkdown
|
|
337557
|
+
false,
|
|
337558
|
+
// canUpdateOutput
|
|
337559
|
+
messageBus
|
|
337560
|
+
);
|
|
337382
337561
|
this.config = config2;
|
|
337383
337562
|
}
|
|
337384
337563
|
/**
|
|
@@ -337392,8 +337571,8 @@ var WebSearchTool = class extends BaseDeclarativeTool {
|
|
|
337392
337571
|
}
|
|
337393
337572
|
return null;
|
|
337394
337573
|
}
|
|
337395
|
-
createInvocation(params) {
|
|
337396
|
-
return new WebSearchToolInvocation(this.config, params);
|
|
337574
|
+
createInvocation(params, messageBus, _toolName, _toolDisplayName) {
|
|
337575
|
+
return new WebSearchToolInvocation(this.config, params, messageBus, _toolName, _toolDisplayName);
|
|
337397
337576
|
}
|
|
337398
337577
|
};
|
|
337399
337578
|
|
|
@@ -337433,7 +337612,7 @@ async function readFullStructure(rootPath, options2) {
|
|
|
337433
337612
|
entries2 = rawEntries.sort((a2, b) => a2.name.localeCompare(b.name));
|
|
337434
337613
|
} catch (error) {
|
|
337435
337614
|
if (isNodeError(error) && (error.code === "EACCES" || error.code === "ENOENT")) {
|
|
337436
|
-
|
|
337615
|
+
debugLogger.warn(`Warning: Could not read directory ${currentPath}: ${error.message}`);
|
|
337437
337616
|
if (currentPath === rootPath && error.code === "ENOENT") {
|
|
337438
337617
|
return null;
|
|
337439
337618
|
}
|
|
@@ -338026,7 +338205,8 @@ var CoreToolScheduler = class {
|
|
|
338026
338205
|
if (toolCall.status !== "validating") {
|
|
338027
338206
|
continue;
|
|
338028
338207
|
}
|
|
338029
|
-
const
|
|
338208
|
+
const validatingCall = toolCall;
|
|
338209
|
+
const { request: reqInfo, invocation } = validatingCall;
|
|
338030
338210
|
try {
|
|
338031
338211
|
if (signal.aborted) {
|
|
338032
338212
|
this.setStatusInternal(reqInfo.callId, "cancelled", "Tool call cancelled by user.");
|
|
@@ -338038,8 +338218,7 @@ var CoreToolScheduler = class {
|
|
|
338038
338218
|
this.setStatusInternal(reqInfo.callId, "scheduled");
|
|
338039
338219
|
continue;
|
|
338040
338220
|
}
|
|
338041
|
-
|
|
338042
|
-
if (this.config.getApprovalMode() === ApprovalMode.YOLO || doesToolInvocationMatch(toolCall.tool, invocation, allowedTools)) {
|
|
338221
|
+
if (this.isAutoApproved(validatingCall)) {
|
|
338043
338222
|
this.setToolCallOutcome(reqInfo.callId, ToolConfirmationOutcome.ProceedAlways);
|
|
338044
338223
|
this.setStatusInternal(reqInfo.callId, "scheduled");
|
|
338045
338224
|
} else {
|
|
@@ -338265,6 +338444,18 @@ var CoreToolScheduler = class {
|
|
|
338265
338444
|
// Use legacy UI confirmation
|
|
338266
338445
|
});
|
|
338267
338446
|
}
|
|
338447
|
+
isAutoApproved(toolCall) {
|
|
338448
|
+
if (this.config.getApprovalMode() === ApprovalMode.YOLO) {
|
|
338449
|
+
return true;
|
|
338450
|
+
}
|
|
338451
|
+
const allowedTools = this.config.getAllowedTools() || [];
|
|
338452
|
+
const { tool, invocation } = toolCall;
|
|
338453
|
+
const toolName = typeof tool === "string" ? tool : tool.name;
|
|
338454
|
+
if (SHELL_TOOL_NAMES.includes(toolName)) {
|
|
338455
|
+
return isShellInvocationAllowlisted(invocation, allowedTools);
|
|
338456
|
+
}
|
|
338457
|
+
return doesToolInvocationMatch(tool, invocation, allowedTools);
|
|
338458
|
+
}
|
|
338268
338459
|
async autoApproveCompatiblePendingTools(signal, triggeringCallId) {
|
|
338269
338460
|
const pendingTools = this.toolCalls.filter((call) => call.status === "awaiting_approval" && call.request.callId !== triggeringCallId);
|
|
338270
338461
|
for (const pendingTool of pendingTools) {
|
|
@@ -339064,18 +339255,20 @@ var Turn = class {
|
|
|
339064
339255
|
if (!resp)
|
|
339065
339256
|
continue;
|
|
339066
339257
|
this.debugResponses.push(resp);
|
|
339258
|
+
const traceId = resp.responseId;
|
|
339067
339259
|
const thoughtPart = resp.candidates?.[0]?.content?.parts?.[0];
|
|
339068
339260
|
if (thoughtPart?.thought) {
|
|
339069
339261
|
const thought = parseThought(thoughtPart.text ?? "");
|
|
339070
339262
|
yield {
|
|
339071
339263
|
type: GeminiEventType.Thought,
|
|
339072
|
-
value: thought
|
|
339264
|
+
value: thought,
|
|
339265
|
+
traceId
|
|
339073
339266
|
};
|
|
339074
339267
|
continue;
|
|
339075
339268
|
}
|
|
339076
339269
|
const text = getResponseText(resp);
|
|
339077
339270
|
if (text) {
|
|
339078
|
-
yield { type: GeminiEventType.Content, value: text };
|
|
339271
|
+
yield { type: GeminiEventType.Content, value: text, traceId };
|
|
339079
339272
|
}
|
|
339080
339273
|
const functionCalls = resp.functionCalls ?? [];
|
|
339081
339274
|
for (const fnCall of functionCalls) {
|
|
@@ -339306,7 +339499,7 @@ function resolvePathFromEnv(envVar) {
|
|
|
339306
339499
|
customPath = path49.join(home, customPath.slice(2));
|
|
339307
339500
|
}
|
|
339308
339501
|
} catch (error) {
|
|
339309
|
-
|
|
339502
|
+
debugLogger.warn(`Could not resolve home directory for path: ${trimmedEnvVar}`, error);
|
|
339310
339503
|
return { isSwitch: false, value: null, isDisabled: false };
|
|
339311
339504
|
}
|
|
339312
339505
|
}
|
|
@@ -339623,7 +339816,7 @@ async function checkNextSpeaker(chat, baseLlmClient, abortSignal, promptId) {
|
|
|
339623
339816
|
}
|
|
339624
339817
|
return null;
|
|
339625
339818
|
} catch (error) {
|
|
339626
|
-
|
|
339819
|
+
debugLogger.warn("Failed to talk to Gemini endpoint when seeing if conversation should continue.", error);
|
|
339627
339820
|
return null;
|
|
339628
339821
|
}
|
|
339629
339822
|
}
|
|
@@ -339914,13 +340107,13 @@ var LoopDetectionService = class {
|
|
|
339914
340107
|
promptId: this.promptId
|
|
339915
340108
|
});
|
|
339916
340109
|
} catch (e2) {
|
|
339917
|
-
this.config.getDebugMode() ? console.error(e2) :
|
|
340110
|
+
this.config.getDebugMode() ? console.error(e2) : debugLogger.debug(e2);
|
|
339918
340111
|
return false;
|
|
339919
340112
|
}
|
|
339920
340113
|
if (typeof result["confidence"] === "number") {
|
|
339921
340114
|
if (result["confidence"] > 0.9) {
|
|
339922
340115
|
if (typeof result["reasoning"] === "string" && result["reasoning"]) {
|
|
339923
|
-
|
|
340116
|
+
debugLogger.warn(result["reasoning"]);
|
|
339924
340117
|
}
|
|
339925
340118
|
logLoopDetected(this.config, new LoopDetectedEvent(LoopType.LLM_DETECTED_LOOP, this.promptId));
|
|
339926
340119
|
return true;
|
|
@@ -340148,7 +340341,7 @@ My setup is complete. I will provide my first command in the next turn.
|
|
|
340148
340341
|
"```"
|
|
340149
340342
|
];
|
|
340150
340343
|
if (this.config.getDebugMode()) {
|
|
340151
|
-
|
|
340344
|
+
debugLogger.log(contextParts.join("\n"));
|
|
340152
340345
|
}
|
|
340153
340346
|
return {
|
|
340154
340347
|
contextParts,
|
|
@@ -340231,7 +340424,7 @@ My setup is complete. I will provide my first command in the next turn.
|
|
|
340231
340424
|
"```"
|
|
340232
340425
|
];
|
|
340233
340426
|
if (this.config.getDebugMode()) {
|
|
340234
|
-
|
|
340427
|
+
debugLogger.log(contextParts.join("\n"));
|
|
340235
340428
|
}
|
|
340236
340429
|
return {
|
|
340237
340430
|
contextParts,
|
|
@@ -340508,7 +340701,7 @@ var GitIgnoreParser = class {
|
|
|
340508
340701
|
}
|
|
340509
340702
|
const isExcludeFile = patternsFilePath.endsWith(path50.join(".git", "info", "exclude"));
|
|
340510
340703
|
const relativeBaseDir = isExcludeFile ? "." : path50.dirname(path50.relative(this.projectRoot, patternsFilePath)).split(path50.sep).join(path50.posix.sep);
|
|
340511
|
-
return content.split("\n").map((p) => p.
|
|
340704
|
+
return content.split("\n").map((p) => p.trimStart()).filter((p) => p !== "" && !p.startsWith("#")).map((p) => {
|
|
340512
340705
|
const isNegative = p.startsWith("!");
|
|
340513
340706
|
if (isNegative) {
|
|
340514
340707
|
p = p.substring(1);
|
|
@@ -345389,6 +345582,12 @@ function shouldAttemptBrowserLaunch() {
|
|
|
345389
345582
|
}
|
|
345390
345583
|
|
|
345391
345584
|
// packages/core/dist/src/tools/write-todos.js
|
|
345585
|
+
var TODO_STATUSES = [
|
|
345586
|
+
"pending",
|
|
345587
|
+
"in_progress",
|
|
345588
|
+
"completed",
|
|
345589
|
+
"cancelled"
|
|
345590
|
+
];
|
|
345392
345591
|
var WRITE_TODOS_DESCRIPTION = `This tool can help you list out the current subtasks that are required to be completed for a given user request. The list of subtasks helps you keep track of the current task, organize complex queries and help ensure that you don't miss any steps. With this list, the user can also see the current progress you are making in executing a given task.
|
|
345393
345592
|
|
|
345394
345593
|
Depending on the task complexity, you should first divide a given task into subtasks and then use this tool to list out the subtasks that are required to be completed for a given user request.
|
|
@@ -345472,9 +345671,10 @@ ${todoListString}` : "Successfully cleared the todo list.";
|
|
|
345472
345671
|
};
|
|
345473
345672
|
}
|
|
345474
345673
|
};
|
|
345475
|
-
var WriteTodosTool = class extends BaseDeclarativeTool {
|
|
345674
|
+
var WriteTodosTool = class _WriteTodosTool extends BaseDeclarativeTool {
|
|
345675
|
+
static Name = WRITE_TODOS_TOOL_NAME;
|
|
345476
345676
|
constructor() {
|
|
345477
|
-
super(
|
|
345677
|
+
super(_WriteTodosTool.Name, "Write Todos", WRITE_TODOS_DESCRIPTION, Kind.Other, {
|
|
345478
345678
|
type: "object",
|
|
345479
345679
|
properties: {
|
|
345480
345680
|
todos: {
|
|
@@ -345491,7 +345691,7 @@ var WriteTodosTool = class extends BaseDeclarativeTool {
|
|
|
345491
345691
|
status: {
|
|
345492
345692
|
type: "string",
|
|
345493
345693
|
description: "The current status of the task.",
|
|
345494
|
-
enum:
|
|
345694
|
+
enum: TODO_STATUSES
|
|
345495
345695
|
}
|
|
345496
345696
|
},
|
|
345497
345697
|
required: ["description", "status"]
|
|
@@ -345513,8 +345713,8 @@ var WriteTodosTool = class extends BaseDeclarativeTool {
|
|
|
345513
345713
|
if (typeof todo.description !== "string" || !todo.description.trim()) {
|
|
345514
345714
|
return "Each todo must have a non-empty description string";
|
|
345515
345715
|
}
|
|
345516
|
-
if (!
|
|
345517
|
-
return
|
|
345716
|
+
if (!TODO_STATUSES.includes(todo.status)) {
|
|
345717
|
+
return `Each todo must have a valid status (${TODO_STATUSES.join(", ")})`;
|
|
345518
345718
|
}
|
|
345519
345719
|
}
|
|
345520
345720
|
const inProgressCount = todos.filter((todo) => todo.status === "in_progress").length;
|
|
@@ -345676,7 +345876,7 @@ var ClassifierStrategy = class {
|
|
|
345676
345876
|
let promptId = promptIdContext.getStore();
|
|
345677
345877
|
if (!promptId) {
|
|
345678
345878
|
promptId = `classifier-router-fallback-${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
345679
|
-
|
|
345879
|
+
debugLogger.warn(`Could not find promptId in context. This is unexpected. Using a fallback ID: ${promptId}`);
|
|
345680
345880
|
}
|
|
345681
345881
|
const historySlice = context2.history.slice(-HISTORY_SEARCH_WINDOW);
|
|
345682
345882
|
const cleanHistory = historySlice.filter((content) => !isFunctionCall(content) && !isFunctionResponse(content));
|
|
@@ -345713,7 +345913,7 @@ var ClassifierStrategy = class {
|
|
|
345713
345913
|
};
|
|
345714
345914
|
}
|
|
345715
345915
|
} catch (error) {
|
|
345716
|
-
|
|
345916
|
+
debugLogger.warn(`[Routing] ClassifierStrategy failed:`, error);
|
|
345717
345917
|
return null;
|
|
345718
345918
|
}
|
|
345719
345919
|
}
|
|
@@ -345939,7 +346139,7 @@ var WorkspaceContext = class {
|
|
|
345939
346139
|
this.directories.add(resolved);
|
|
345940
346140
|
this.notifyDirectoriesChanged();
|
|
345941
346141
|
} catch (err2) {
|
|
345942
|
-
|
|
346142
|
+
debugLogger.warn(`[WARN] Skipping unreadable directory: ${directory} (${err2 instanceof Error ? err2.message : String(err2)})`);
|
|
345943
346143
|
}
|
|
345944
346144
|
}
|
|
345945
346145
|
resolveAndValidateDir(directory, basePath = process21.cwd()) {
|
|
@@ -346044,9 +346244,12 @@ var PolicyDecision;
|
|
|
346044
346244
|
// packages/core/dist/src/confirmation-bus/message-bus.js
|
|
346045
346245
|
var MessageBus = class extends EventEmitter9 {
|
|
346046
346246
|
policyEngine;
|
|
346047
|
-
|
|
346247
|
+
debug;
|
|
346248
|
+
constructor(policyEngine, debug2 = false) {
|
|
346048
346249
|
super();
|
|
346049
346250
|
this.policyEngine = policyEngine;
|
|
346251
|
+
this.debug = debug2;
|
|
346252
|
+
this.debug = debug2;
|
|
346050
346253
|
}
|
|
346051
346254
|
isValidMessage(message) {
|
|
346052
346255
|
if (!message || !message.type) {
|
|
@@ -346061,6 +346264,9 @@ var MessageBus = class extends EventEmitter9 {
|
|
|
346061
346264
|
this.emit(message.type, message);
|
|
346062
346265
|
}
|
|
346063
346266
|
publish(message) {
|
|
346267
|
+
if (this.debug) {
|
|
346268
|
+
console.debug(`[MESSAGE_BUS] publish: ${safeJsonStringify(message)}`);
|
|
346269
|
+
}
|
|
346064
346270
|
try {
|
|
346065
346271
|
if (!this.isValidMessage(message)) {
|
|
346066
346272
|
throw new Error(`Invalid message structure: ${safeJsonStringify(message)}`);
|
|
@@ -346236,9 +346442,6 @@ var PolicyEngine = class {
|
|
|
346236
346442
|
}
|
|
346237
346443
|
};
|
|
346238
346444
|
|
|
346239
|
-
// packages/core/dist/src/config/config.js
|
|
346240
|
-
var import_undici3 = __toESM(require_undici(), 1);
|
|
346241
|
-
|
|
346242
346445
|
// packages/core/dist/src/agents/registry.js
|
|
346243
346446
|
var AgentRegistry = class {
|
|
346244
346447
|
config;
|
|
@@ -346253,7 +346456,7 @@ var AgentRegistry = class {
|
|
|
346253
346456
|
async initialize() {
|
|
346254
346457
|
this.loadBuiltInAgents();
|
|
346255
346458
|
if (this.config.getDebugMode()) {
|
|
346256
|
-
|
|
346459
|
+
debugLogger.log(`[AgentRegistry] Initialized with ${this.agents.size} agents.`);
|
|
346257
346460
|
}
|
|
346258
346461
|
}
|
|
346259
346462
|
loadBuiltInAgents() {
|
|
@@ -346282,11 +346485,11 @@ var AgentRegistry = class {
|
|
|
346282
346485
|
*/
|
|
346283
346486
|
registerAgent(definition) {
|
|
346284
346487
|
if (!definition.name || !definition.description) {
|
|
346285
|
-
|
|
346488
|
+
debugLogger.warn(`[AgentRegistry] Skipping invalid agent definition. Missing name or description.`);
|
|
346286
346489
|
return;
|
|
346287
346490
|
}
|
|
346288
346491
|
if (this.agents.has(definition.name) && this.config.getDebugMode()) {
|
|
346289
|
-
|
|
346492
|
+
debugLogger.log(`[AgentRegistry] Overriding agent '${definition.name}'`);
|
|
346290
346493
|
}
|
|
346291
346494
|
this.agents.set(definition.name, definition);
|
|
346292
346495
|
}
|
|
@@ -347960,7 +348163,7 @@ var AgentExecutor = class _AgentExecutor {
|
|
|
347960
348163
|
}
|
|
347961
348164
|
if (!allowedToolNames.has(functionCall.name)) {
|
|
347962
348165
|
const error = `Unauthorized tool call: '${functionCall.name}' is not available to this agent.`;
|
|
347963
|
-
|
|
348166
|
+
debugLogger.warn(`[AgentExecutor] Blocked call: ${error}`);
|
|
347964
348167
|
syncResponseParts.push({
|
|
347965
348168
|
functionResponse: {
|
|
347966
348169
|
name: functionCall.name,
|
|
@@ -348328,7 +348531,6 @@ var Config = class {
|
|
|
348328
348531
|
cwd;
|
|
348329
348532
|
bugCommand;
|
|
348330
348533
|
model;
|
|
348331
|
-
extensionContextFilePaths;
|
|
348332
348534
|
noBrowser;
|
|
348333
348535
|
folderTrust;
|
|
348334
348536
|
ideMode;
|
|
@@ -348336,6 +348538,7 @@ var Config = class {
|
|
|
348336
348538
|
maxSessionTurns;
|
|
348337
348539
|
listExtensions;
|
|
348338
348540
|
_extensions;
|
|
348541
|
+
_enabledExtensions;
|
|
348339
348542
|
_blockedMcpServers;
|
|
348340
348543
|
fallbackModelHandler;
|
|
348341
348544
|
quotaErrorOccurred = false;
|
|
@@ -348414,11 +348617,11 @@ var Config = class {
|
|
|
348414
348617
|
this.fileDiscoveryService = params.fileDiscoveryService ?? null;
|
|
348415
348618
|
this.bugCommand = params.bugCommand;
|
|
348416
348619
|
this.model = params.model;
|
|
348417
|
-
this.extensionContextFilePaths = params.extensionContextFilePaths ?? [];
|
|
348418
348620
|
this.maxSessionTurns = params.maxSessionTurns ?? -1;
|
|
348419
348621
|
this.experimentalZedIntegration = params.experimentalZedIntegration ?? false;
|
|
348420
348622
|
this.listExtensions = params.listExtensions ?? false;
|
|
348421
348623
|
this._extensions = params.extensions ?? [];
|
|
348624
|
+
this._enabledExtensions = params.enabledExtensions ?? [];
|
|
348422
348625
|
this._blockedMcpServers = params.blockedMcpServers ?? [];
|
|
348423
348626
|
this.noBrowser = params.noBrowser ?? false;
|
|
348424
348627
|
this.summarizeToolOutput = params.summarizeToolOutput;
|
|
@@ -348446,7 +348649,7 @@ var Config = class {
|
|
|
348446
348649
|
this.useModelRouter = params.useModelRouter ?? false;
|
|
348447
348650
|
this.enableMessageBusIntegration = params.enableMessageBusIntegration ?? false;
|
|
348448
348651
|
this.codebaseInvestigatorSettings = {
|
|
348449
|
-
enabled: params.codebaseInvestigatorSettings?.enabled ??
|
|
348652
|
+
enabled: params.codebaseInvestigatorSettings?.enabled ?? false,
|
|
348450
348653
|
maxNumTurns: params.codebaseInvestigatorSettings?.maxNumTurns ?? 15,
|
|
348451
348654
|
maxTimeMinutes: params.codebaseInvestigatorSettings?.maxTimeMinutes ?? 5,
|
|
348452
348655
|
thinkingBudget: params.codebaseInvestigatorSettings?.thinkingBudget ?? DEFAULT_THINKING_MODE,
|
|
@@ -348460,7 +348663,7 @@ var Config = class {
|
|
|
348460
348663
|
this.fileExclusions = new FileExclusions(this);
|
|
348461
348664
|
this.eventEmitter = params.eventEmitter;
|
|
348462
348665
|
this.policyEngine = new PolicyEngine(params.policyEngineConfig);
|
|
348463
|
-
this.messageBus = new MessageBus(this.policyEngine);
|
|
348666
|
+
this.messageBus = new MessageBus(this.policyEngine, this.debugMode);
|
|
348464
348667
|
this.outputSettings = {
|
|
348465
348668
|
format: params.output?.format ?? OutputFormat.TEXT
|
|
348466
348669
|
};
|
|
@@ -348472,7 +348675,7 @@ var Config = class {
|
|
|
348472
348675
|
initializeTelemetry(this);
|
|
348473
348676
|
}
|
|
348474
348677
|
if (this.getProxy()) {
|
|
348475
|
-
(
|
|
348678
|
+
setGlobalProxy(this.getProxy());
|
|
348476
348679
|
}
|
|
348477
348680
|
this.geminiClient = new GeminiClient(this);
|
|
348478
348681
|
this.modelRouterService = new ModelRouterService(this);
|
|
@@ -348724,9 +348927,6 @@ var Config = class {
|
|
|
348724
348927
|
getUsageStatisticsEnabled() {
|
|
348725
348928
|
return this.usageStatisticsEnabled;
|
|
348726
348929
|
}
|
|
348727
|
-
getExtensionContextFilePaths() {
|
|
348728
|
-
return this.extensionContextFilePaths;
|
|
348729
|
-
}
|
|
348730
348930
|
getExperimentalZedIntegration() {
|
|
348731
348931
|
return this.experimentalZedIntegration;
|
|
348732
348932
|
}
|
|
@@ -348739,6 +348939,11 @@ var Config = class {
|
|
|
348739
348939
|
getExtensions() {
|
|
348740
348940
|
return this._extensions;
|
|
348741
348941
|
}
|
|
348942
|
+
// The list of explicitly enabled extensions, if any were given, may contain
|
|
348943
|
+
// the string "none".
|
|
348944
|
+
getEnabledExtensions() {
|
|
348945
|
+
return this._enabledExtensions;
|
|
348946
|
+
}
|
|
348742
348947
|
getBlockedMcpServers() {
|
|
348743
348948
|
return this._blockedMcpServers;
|
|
348744
348949
|
}
|
|
@@ -348896,11 +349101,11 @@ var Config = class {
|
|
|
348896
349101
|
if (isEnabled2) {
|
|
348897
349102
|
const messageBusEnabled = this.getEnableMessageBusIntegration();
|
|
348898
349103
|
if (this.debugMode && messageBusEnabled) {
|
|
348899
|
-
|
|
349104
|
+
debugLogger.log(`[DEBUG] enableMessageBusIntegration setting: ${messageBusEnabled}`);
|
|
348900
349105
|
}
|
|
348901
349106
|
const toolArgs = messageBusEnabled ? [...args2, this.getMessageBus()] : args2;
|
|
348902
349107
|
if (this.debugMode && messageBusEnabled) {
|
|
348903
|
-
|
|
349108
|
+
debugLogger.log(`[DEBUG] Registering ${className} with messageBus: ${messageBusEnabled ? "YES" : "NO"}`);
|
|
348904
349109
|
}
|
|
348905
349110
|
registry.registerTool(new ToolClass(...toolArgs));
|
|
348906
349111
|
}
|
|
@@ -348955,7 +349160,7 @@ var Config = class {
|
|
|
348955
349160
|
console.error(`Failed to wrap agent '${definition.name}' as a tool:`, error);
|
|
348956
349161
|
}
|
|
348957
349162
|
} else if (this.getDebugMode()) {
|
|
348958
|
-
|
|
349163
|
+
debugLogger.log(`[Config] Skipping registration of agent '${definition.name}' due to allow/exclude configuration.`);
|
|
348959
349164
|
}
|
|
348960
349165
|
}
|
|
348961
349166
|
}
|
|
@@ -348981,7 +349186,7 @@ import * as fs53 from "node:fs/promises";
|
|
|
348981
349186
|
import * as path57 from "node:path";
|
|
348982
349187
|
var logger3 = {
|
|
348983
349188
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
348984
|
-
debug: (...args2) =>
|
|
349189
|
+
debug: (...args2) => debugLogger.debug("[DEBUG] [BfsFileSearch]", ...args2)
|
|
348985
349190
|
};
|
|
348986
349191
|
async function bfsFileSearch(rootDir, options2) {
|
|
348987
349192
|
const { fileName, ignoreDirs = [], maxDirs = Infinity, debug: debug2 = false, fileService } = options2;
|
|
@@ -349015,7 +349220,7 @@ async function bfsFileSearch(rootDir, options2) {
|
|
|
349015
349220
|
return { currentDir, entries: entries2 };
|
|
349016
349221
|
} catch (error) {
|
|
349017
349222
|
const message = error?.message ?? "Unknown error";
|
|
349018
|
-
|
|
349223
|
+
debugLogger.warn(`[WARN] Skipping unreadable directory: ${currentDir} (${message})`);
|
|
349019
349224
|
if (debug2) {
|
|
349020
349225
|
logger3.debug(`Full error for ${currentDir}:`, error);
|
|
349021
349226
|
}
|
|
@@ -351194,9 +351399,9 @@ var lexer = _Lexer.lex;
|
|
|
351194
351399
|
// packages/core/dist/src/utils/memoryImportProcessor.js
|
|
351195
351400
|
var logger4 = {
|
|
351196
351401
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
351197
|
-
debug: (...args2) =>
|
|
351402
|
+
debug: (...args2) => debugLogger.debug("[DEBUG] [ImportProcessor]", ...args2),
|
|
351198
351403
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
351199
|
-
warn: (...args2) =>
|
|
351404
|
+
warn: (...args2) => debugLogger.warn("[WARN] [ImportProcessor]", ...args2),
|
|
351200
351405
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
351201
351406
|
error: (...args2) => console.error("[ERROR] [ImportProcessor]", ...args2)
|
|
351202
351407
|
};
|
|
@@ -351414,9 +351619,9 @@ function validateImportPath(importPath, basePath, allowedDirectories) {
|
|
|
351414
351619
|
// packages/core/dist/src/utils/memoryDiscovery.js
|
|
351415
351620
|
var logger5 = {
|
|
351416
351621
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
351417
|
-
debug: (...args2) =>
|
|
351622
|
+
debug: (...args2) => debugLogger.debug("[DEBUG] [MemoryDiscovery]", ...args2),
|
|
351418
351623
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
351419
|
-
warn: (...args2) =>
|
|
351624
|
+
warn: (...args2) => debugLogger.warn("[WARN] [MemoryDiscovery]", ...args2),
|
|
351420
351625
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
351421
351626
|
error: (...args2) => console.error("[ERROR] [MemoryDiscovery]", ...args2)
|
|
351422
351627
|
};
|
|
@@ -351448,7 +351653,7 @@ async function findProjectRoot2(startDir) {
|
|
|
351448
351653
|
currentDir = parentDir;
|
|
351449
351654
|
}
|
|
351450
351655
|
}
|
|
351451
|
-
async function getGeminiMdFilePathsInternal(currentWorkingDirectory, includeDirectoriesToReadGemini, userHomePath, debugMode, fileService,
|
|
351656
|
+
async function getGeminiMdFilePathsInternal(currentWorkingDirectory, includeDirectoriesToReadGemini, userHomePath, debugMode, fileService, folderTrust, fileFilteringOptions, maxDirs) {
|
|
351452
351657
|
const dirs = /* @__PURE__ */ new Set([
|
|
351453
351658
|
...includeDirectoriesToReadGemini,
|
|
351454
351659
|
currentWorkingDirectory
|
|
@@ -351458,7 +351663,7 @@ async function getGeminiMdFilePathsInternal(currentWorkingDirectory, includeDire
|
|
|
351458
351663
|
const pathsArrays = [];
|
|
351459
351664
|
for (let i3 = 0; i3 < dirsArray.length; i3 += CONCURRENT_LIMIT) {
|
|
351460
351665
|
const batch = dirsArray.slice(i3, i3 + CONCURRENT_LIMIT);
|
|
351461
|
-
const batchPromises = batch.map((dir) => getGeminiMdFilePathsInternalForEachDir(dir, userHomePath, debugMode, fileService,
|
|
351666
|
+
const batchPromises = batch.map((dir) => getGeminiMdFilePathsInternalForEachDir(dir, userHomePath, debugMode, fileService, folderTrust, fileFilteringOptions, maxDirs));
|
|
351462
351667
|
const batchResults = await Promise.allSettled(batchPromises);
|
|
351463
351668
|
for (const result of batchResults) {
|
|
351464
351669
|
if (result.status === "fulfilled") {
|
|
@@ -351473,7 +351678,7 @@ async function getGeminiMdFilePathsInternal(currentWorkingDirectory, includeDire
|
|
|
351473
351678
|
const paths = pathsArrays.flat();
|
|
351474
351679
|
return Array.from(new Set(paths));
|
|
351475
351680
|
}
|
|
351476
|
-
async function getGeminiMdFilePathsInternalForEachDir(dir, userHomePath, debugMode, fileService,
|
|
351681
|
+
async function getGeminiMdFilePathsInternalForEachDir(dir, userHomePath, debugMode, fileService, folderTrust, fileFilteringOptions, maxDirs) {
|
|
351477
351682
|
const allPaths = /* @__PURE__ */ new Set();
|
|
351478
351683
|
const geminiMdFilenames = getAllGeminiMdFilenames();
|
|
351479
351684
|
for (const geminiMdFilename of geminiMdFilenames) {
|
|
@@ -351531,9 +351736,6 @@ async function getGeminiMdFilePathsInternalForEachDir(dir, userHomePath, debugMo
|
|
|
351531
351736
|
}
|
|
351532
351737
|
}
|
|
351533
351738
|
}
|
|
351534
|
-
for (const extensionPath of extensionContextFilePaths) {
|
|
351535
|
-
allPaths.add(extensionPath);
|
|
351536
|
-
}
|
|
351537
351739
|
const finalPaths = Array.from(allPaths);
|
|
351538
351740
|
if (debugMode)
|
|
351539
351741
|
logger5.debug(`Final ordered ${getAllGeminiMdFilenames()} paths to read: ${JSON.stringify(finalPaths)}`);
|
|
@@ -351587,11 +351789,12 @@ ${trimmedContent}
|
|
|
351587
351789
|
--- End of Context from: ${displayPath} ---`;
|
|
351588
351790
|
}).filter((block2) => block2 !== null).join("\n\n");
|
|
351589
351791
|
}
|
|
351590
|
-
async function loadServerHierarchicalMemory(currentWorkingDirectory, includeDirectoriesToReadGemini, debugMode, fileService,
|
|
351792
|
+
async function loadServerHierarchicalMemory(currentWorkingDirectory, includeDirectoriesToReadGemini, debugMode, fileService, extensions, folderTrust, importFormat = "tree", fileFilteringOptions, maxDirs = 200) {
|
|
351591
351793
|
if (debugMode)
|
|
351592
351794
|
logger5.debug(`Loading server hierarchical memory for CWD: ${currentWorkingDirectory} (importFormat: ${importFormat})`);
|
|
351593
351795
|
const userHomePath = homedir4();
|
|
351594
|
-
const filePaths = await getGeminiMdFilePathsInternal(currentWorkingDirectory, includeDirectoriesToReadGemini, userHomePath, debugMode, fileService,
|
|
351796
|
+
const filePaths = await getGeminiMdFilePathsInternal(currentWorkingDirectory, includeDirectoriesToReadGemini, userHomePath, debugMode, fileService, folderTrust, fileFilteringOptions || DEFAULT_MEMORY_FILE_FILTERING_OPTIONS, maxDirs);
|
|
351797
|
+
filePaths.push(...extensions.filter((ext2) => ext2.isActive).flatMap((ext2) => ext2.contextFiles));
|
|
351595
351798
|
if (filePaths.length === 0) {
|
|
351596
351799
|
if (debugMode)
|
|
351597
351800
|
logger5.debug("No GEMINI.md files found in hierarchy of the workspace.");
|
|
@@ -351746,13 +351949,12 @@ async function loadConfig(settings, extensions, taskId) {
|
|
|
351746
351949
|
folderTrust: settings.folderTrust === true
|
|
351747
351950
|
};
|
|
351748
351951
|
const fileService = new FileDiscoveryService(workspaceDir);
|
|
351749
|
-
const extensionContextFilePaths = extensions.flatMap((e2) => e2.contextFiles);
|
|
351750
351952
|
const { memoryContent, fileCount } = await loadServerHierarchicalMemory(
|
|
351751
351953
|
workspaceDir,
|
|
351752
351954
|
[workspaceDir],
|
|
351753
351955
|
false,
|
|
351754
351956
|
fileService,
|
|
351755
|
-
|
|
351957
|
+
extensions,
|
|
351756
351958
|
settings.folderTrust === true
|
|
351757
351959
|
);
|
|
351758
351960
|
configParams.userMemory = memoryContent;
|
|
@@ -351791,7 +351993,7 @@ function mergeMcpServers(settings, extensions) {
|
|
|
351791
351993
|
for (const extension of extensions) {
|
|
351792
351994
|
Object.entries(extension.mcpServers || {}).forEach(([key, server]) => {
|
|
351793
351995
|
if (mcpServers[key]) {
|
|
351794
|
-
|
|
351996
|
+
debugLogger.warn(
|
|
351795
351997
|
`Skipping extension MCP config for server with key "${key}" as it already exists.`
|
|
351796
351998
|
);
|
|
351797
351999
|
return;
|
|
@@ -351856,6 +352058,10 @@ function findEnvFile(startDir) {
|
|
|
351856
352058
|
|
|
351857
352059
|
// packages/a2a-server/src/persistence/gcs.ts
|
|
351858
352060
|
var getTmpArchiveFilename = (taskId) => `task-${taskId}-workspace-${v4_default2()}.tar.gz`;
|
|
352061
|
+
var isTaskIdValid = (taskId) => {
|
|
352062
|
+
const validTaskIdRegex = /^[a-zA-Z0-9_-]+$/;
|
|
352063
|
+
return validTaskIdRegex.test(taskId);
|
|
352064
|
+
};
|
|
351859
352065
|
var GCSTaskStore = class {
|
|
351860
352066
|
storage;
|
|
351861
352067
|
bucketName;
|
|
@@ -351904,6 +352110,9 @@ var GCSTaskStore = class {
|
|
|
351904
352110
|
await this.bucketInitialized;
|
|
351905
352111
|
}
|
|
351906
352112
|
getObjectPath(taskId, type) {
|
|
352113
|
+
if (!isTaskIdValid(taskId)) {
|
|
352114
|
+
throw new Error(`Invalid taskId: ${taskId}`);
|
|
352115
|
+
}
|
|
351907
352116
|
return `tasks/${taskId}/${type}.tar.gz`;
|
|
351908
352117
|
}
|
|
351909
352118
|
async save(task) {
|
|
@@ -352426,7 +352635,7 @@ var Task = class _Task {
|
|
|
352426
352635
|
contextId: this.contextId
|
|
352427
352636
|
};
|
|
352428
352637
|
}
|
|
352429
|
-
_createStatusUpdateEvent(stateToReport, coderAgentMessage, message, final = false, timestamp, metadataError) {
|
|
352638
|
+
_createStatusUpdateEvent(stateToReport, coderAgentMessage, message, final = false, timestamp, metadataError, traceId) {
|
|
352430
352639
|
const metadata2 = {
|
|
352431
352640
|
coderAgent: coderAgentMessage,
|
|
352432
352641
|
model: this.config.getModel(),
|
|
@@ -352435,6 +352644,9 @@ var Task = class _Task {
|
|
|
352435
352644
|
if (metadataError) {
|
|
352436
352645
|
metadata2.error = metadataError;
|
|
352437
352646
|
}
|
|
352647
|
+
if (traceId) {
|
|
352648
|
+
metadata2.traceId = traceId;
|
|
352649
|
+
}
|
|
352438
352650
|
return {
|
|
352439
352651
|
kind: "status-update",
|
|
352440
352652
|
taskId: this.id,
|
|
@@ -352449,7 +352661,7 @@ var Task = class _Task {
|
|
|
352449
352661
|
metadata: metadata2
|
|
352450
352662
|
};
|
|
352451
352663
|
}
|
|
352452
|
-
setTaskStateAndPublishUpdate(newState, coderAgentMessage, messageText, messageParts, final = false, metadataError) {
|
|
352664
|
+
setTaskStateAndPublishUpdate(newState, coderAgentMessage, messageText, messageParts, final = false, metadataError, traceId) {
|
|
352453
352665
|
this.taskState = newState;
|
|
352454
352666
|
let message;
|
|
352455
352667
|
if (messageText) {
|
|
@@ -352470,7 +352682,8 @@ var Task = class _Task {
|
|
|
352470
352682
|
message,
|
|
352471
352683
|
final,
|
|
352472
352684
|
void 0,
|
|
352473
|
-
metadataError
|
|
352685
|
+
metadataError,
|
|
352686
|
+
traceId
|
|
352474
352687
|
);
|
|
352475
352688
|
this.eventBus?.publish(event);
|
|
352476
352689
|
}
|
|
@@ -352687,10 +352900,11 @@ var Task = class _Task {
|
|
|
352687
352900
|
const stateChange = {
|
|
352688
352901
|
kind: "state-change" /* StateChangeEvent */
|
|
352689
352902
|
};
|
|
352903
|
+
const traceId = "traceId" in event && event.traceId ? event.traceId : void 0;
|
|
352690
352904
|
switch (event.type) {
|
|
352691
352905
|
case GeminiEventType.Content:
|
|
352692
352906
|
logger.info("[Task] Sending agent message content...");
|
|
352693
|
-
this._sendTextContent(event.value);
|
|
352907
|
+
this._sendTextContent(event.value, traceId);
|
|
352694
352908
|
break;
|
|
352695
352909
|
case GeminiEventType.ToolCallRequest:
|
|
352696
352910
|
logger.warn(
|
|
@@ -352721,12 +352935,14 @@ var Task = class _Task {
|
|
|
352721
352935
|
stateChange,
|
|
352722
352936
|
"Task cancelled by user",
|
|
352723
352937
|
void 0,
|
|
352724
|
-
true
|
|
352938
|
+
true,
|
|
352939
|
+
void 0,
|
|
352940
|
+
traceId
|
|
352725
352941
|
);
|
|
352726
352942
|
break;
|
|
352727
352943
|
case GeminiEventType.Thought:
|
|
352728
352944
|
logger.info("[Task] Sending agent thought...");
|
|
352729
|
-
this._sendThought(event.value);
|
|
352945
|
+
this._sendThought(event.value, traceId);
|
|
352730
352946
|
break;
|
|
352731
352947
|
case GeminiEventType.ChatCompressed:
|
|
352732
352948
|
break;
|
|
@@ -352752,7 +352968,8 @@ var Task = class _Task {
|
|
|
352752
352968
|
`Agent Error, unknown agent message: ${errorMessage}`,
|
|
352753
352969
|
void 0,
|
|
352754
352970
|
false,
|
|
352755
|
-
errMessage
|
|
352971
|
+
errMessage,
|
|
352972
|
+
traceId
|
|
352756
352973
|
);
|
|
352757
352974
|
break;
|
|
352758
352975
|
}
|
|
@@ -352949,7 +353166,7 @@ var Task = class _Task {
|
|
|
352949
353166
|
}();
|
|
352950
353167
|
}
|
|
352951
353168
|
}
|
|
352952
|
-
_sendTextContent(content) {
|
|
353169
|
+
_sendTextContent(content, traceId) {
|
|
352953
353170
|
if (content === "") {
|
|
352954
353171
|
return;
|
|
352955
353172
|
}
|
|
@@ -352963,11 +353180,14 @@ var Task = class _Task {
|
|
|
352963
353180
|
this.taskState,
|
|
352964
353181
|
textContent2,
|
|
352965
353182
|
message,
|
|
352966
|
-
false
|
|
353183
|
+
false,
|
|
353184
|
+
void 0,
|
|
353185
|
+
void 0,
|
|
353186
|
+
traceId
|
|
352967
353187
|
)
|
|
352968
353188
|
);
|
|
352969
353189
|
}
|
|
352970
|
-
_sendThought(content) {
|
|
353190
|
+
_sendThought(content, traceId) {
|
|
352971
353191
|
if (!content.subject && !content.description) {
|
|
352972
353192
|
return;
|
|
352973
353193
|
}
|
|
@@ -352989,7 +353209,15 @@ var Task = class _Task {
|
|
|
352989
353209
|
kind: "thought" /* ThoughtEvent */
|
|
352990
353210
|
};
|
|
352991
353211
|
this.eventBus?.publish(
|
|
352992
|
-
this._createStatusUpdateEvent(
|
|
353212
|
+
this._createStatusUpdateEvent(
|
|
353213
|
+
this.taskState,
|
|
353214
|
+
thought,
|
|
353215
|
+
message,
|
|
353216
|
+
false,
|
|
353217
|
+
void 0,
|
|
353218
|
+
void 0,
|
|
353219
|
+
traceId
|
|
353220
|
+
)
|
|
352993
353221
|
);
|
|
352994
353222
|
}
|
|
352995
353223
|
};
|