@google/gemini-cli-a2a-server 0.12.0-nightly.20251023.a7faa208 → 0.12.0-nightly.20251027.cb0947c5
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 +1632 -1211
- package/dist/src/agent/task.d.ts +1 -0
- package/dist/src/agent/task.js +21 -9
- package/dist/src/agent/task.js.map +1 -1
- package/dist/src/agent/task.test.js +110 -1
- package/dist/src/agent/task.test.js.map +1 -1
- package/dist/src/commands/command-registry.d.ts +18 -0
- package/dist/src/commands/command-registry.js +22 -0
- package/dist/src/commands/command-registry.js.map +1 -0
- package/dist/src/commands/command-registry.test.d.ts +6 -0
- package/dist/src/commands/command-registry.test.js +41 -0
- package/dist/src/commands/command-registry.test.js.map +1 -0
- package/dist/src/commands/list-extensions.d.ts +11 -0
- package/dist/src/commands/list-extensions.js +13 -0
- package/dist/src/commands/list-extensions.js.map +1 -0
- package/dist/src/commands/list-extensions.test.d.ts +6 -0
- package/dist/src/commands/list-extensions.test.js +31 -0
- package/dist/src/commands/list-extensions.test.js.map +1 -0
- package/dist/src/config/config.js +1 -0
- package/dist/src/config/config.js.map +1 -1
- package/dist/src/config/settings.js +4 -4
- package/dist/src/config/settings.js.map +1 -1
- package/dist/src/http/app.js +36 -0
- package/dist/src/http/app.js.map +1 -1
- package/dist/src/http/app.test.js +215 -17
- package/dist/src/http/app.test.js.map +1 -1
- package/dist/src/persistence/gcs.test.js +48 -10
- package/dist/src/persistence/gcs.test.js.map +1 -1
- package/dist/src/types.d.ts +9 -2
- package/dist/src/types.js +4 -0
- package/dist/src/types.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
package/dist/a2a-server.mjs
CHANGED
|
@@ -6344,7 +6344,7 @@ var require_diagnostics = __commonJS({
|
|
|
6344
6344
|
function write2() {
|
|
6345
6345
|
logger6.apply(logger6, arguments);
|
|
6346
6346
|
}
|
|
6347
|
-
function
|
|
6347
|
+
function process25(message) {
|
|
6348
6348
|
for (var i3 = 0; i3 < modifiers.length; i3++) {
|
|
6349
6349
|
message = modifiers[i3].apply(modifiers[i3], arguments);
|
|
6350
6350
|
}
|
|
@@ -6371,7 +6371,7 @@ var require_diagnostics = __commonJS({
|
|
|
6371
6371
|
function yep(options2) {
|
|
6372
6372
|
function diagnostics() {
|
|
6373
6373
|
var args2 = Array.prototype.slice.call(arguments, 0);
|
|
6374
|
-
write2.call(write2, options2,
|
|
6374
|
+
write2.call(write2, options2, process25(args2, options2));
|
|
6375
6375
|
return true;
|
|
6376
6376
|
}
|
|
6377
6377
|
options2.enabled = true;
|
|
@@ -6383,7 +6383,7 @@ var require_diagnostics = __commonJS({
|
|
|
6383
6383
|
module2.exports = function create3(diagnostics) {
|
|
6384
6384
|
diagnostics.introduce = introduce;
|
|
6385
6385
|
diagnostics.enabled = enabled;
|
|
6386
|
-
diagnostics.process =
|
|
6386
|
+
diagnostics.process = process25;
|
|
6387
6387
|
diagnostics.modify = modify;
|
|
6388
6388
|
diagnostics.write = write2;
|
|
6389
6389
|
diagnostics.nope = nope;
|
|
@@ -34138,7 +34138,7 @@ var require_express = __commonJS({
|
|
|
34138
34138
|
"packages/a2a-server/node_modules/express/lib/express.js"(exports2, module2) {
|
|
34139
34139
|
"use strict";
|
|
34140
34140
|
var bodyParser = require_body_parser();
|
|
34141
|
-
var
|
|
34141
|
+
var EventEmitter11 = __require("node:events").EventEmitter;
|
|
34142
34142
|
var mixin = require_merge_descriptors();
|
|
34143
34143
|
var proto = require_application();
|
|
34144
34144
|
var Router = require_router();
|
|
@@ -34149,7 +34149,7 @@ var require_express = __commonJS({
|
|
|
34149
34149
|
var app = function(req2, res2, next) {
|
|
34150
34150
|
app.handle(req2, res2, next);
|
|
34151
34151
|
};
|
|
34152
|
-
mixin(app,
|
|
34152
|
+
mixin(app, EventEmitter11.prototype, false);
|
|
34153
34153
|
mixin(app, proto, false);
|
|
34154
34154
|
app.request = Object.create(req, {
|
|
34155
34155
|
app: { configurable: true, enumerable: true, writable: true, value: app }
|
|
@@ -34609,7 +34609,7 @@ var require_src2 = __commonJS({
|
|
|
34609
34609
|
var require_destroy2 = __commonJS({
|
|
34610
34610
|
"node_modules/destroy/index.js"(exports2, module2) {
|
|
34611
34611
|
"use strict";
|
|
34612
|
-
var
|
|
34612
|
+
var EventEmitter11 = __require("events").EventEmitter;
|
|
34613
34613
|
var ReadStream2 = __require("fs").ReadStream;
|
|
34614
34614
|
var Stream2 = __require("stream");
|
|
34615
34615
|
var Zlib2 = __require("zlib");
|
|
@@ -34671,7 +34671,7 @@ var require_destroy2 = __commonJS({
|
|
|
34671
34671
|
return stream3 instanceof Stream2 && typeof stream3.destroy === "function";
|
|
34672
34672
|
}
|
|
34673
34673
|
function isEventEmitter(val) {
|
|
34674
|
-
return val instanceof
|
|
34674
|
+
return val instanceof EventEmitter11;
|
|
34675
34675
|
}
|
|
34676
34676
|
function isFsReadStream(stream3) {
|
|
34677
34677
|
return stream3 instanceof ReadStream2;
|
|
@@ -45580,7 +45580,7 @@ var require_express3 = __commonJS({
|
|
|
45580
45580
|
"node_modules/express/lib/express.js"(exports2, module2) {
|
|
45581
45581
|
"use strict";
|
|
45582
45582
|
var bodyParser = require_body_parser2();
|
|
45583
|
-
var
|
|
45583
|
+
var EventEmitter11 = __require("events").EventEmitter;
|
|
45584
45584
|
var mixin = require_merge_descriptors2();
|
|
45585
45585
|
var proto = require_application2();
|
|
45586
45586
|
var Route = require_route3();
|
|
@@ -45592,7 +45592,7 @@ var require_express3 = __commonJS({
|
|
|
45592
45592
|
var app = function(req2, res2, next) {
|
|
45593
45593
|
app.handle(req2, res2, next);
|
|
45594
45594
|
};
|
|
45595
|
-
mixin(app,
|
|
45595
|
+
mixin(app, EventEmitter11.prototype, false);
|
|
45596
45596
|
mixin(app, proto, false);
|
|
45597
45597
|
app.request = Object.create(req, {
|
|
45598
45598
|
app: { configurable: true, enumerable: true, writable: true, value: app }
|
|
@@ -52323,7 +52323,7 @@ var require_logging_utils = __commonJS({
|
|
|
52323
52323
|
exports2.setBackend = setBackend;
|
|
52324
52324
|
exports2.log = log;
|
|
52325
52325
|
var node_events_1 = __require("node:events");
|
|
52326
|
-
var
|
|
52326
|
+
var process25 = __importStar(__require("node:process"));
|
|
52327
52327
|
var util4 = __importStar(__require("node:util"));
|
|
52328
52328
|
var colours_1 = require_colours();
|
|
52329
52329
|
var LogSeverity;
|
|
@@ -52374,7 +52374,7 @@ var require_logging_utils = __commonJS({
|
|
|
52374
52374
|
this.cached = /* @__PURE__ */ new Map();
|
|
52375
52375
|
this.filters = [];
|
|
52376
52376
|
this.filtersSet = false;
|
|
52377
|
-
let nodeFlag = (_a3 =
|
|
52377
|
+
let nodeFlag = (_a3 = process25.env[exports2.env.nodeEnables]) !== null && _a3 !== void 0 ? _a3 : "*";
|
|
52378
52378
|
if (nodeFlag === "all") {
|
|
52379
52379
|
nodeFlag = "*";
|
|
52380
52380
|
}
|
|
@@ -52414,7 +52414,7 @@ var require_logging_utils = __commonJS({
|
|
|
52414
52414
|
return (fields, ...args2) => {
|
|
52415
52415
|
var _a3;
|
|
52416
52416
|
const nscolour = `${colours_1.Colours.green}${namespace}${colours_1.Colours.reset}`;
|
|
52417
|
-
const pid = `${colours_1.Colours.yellow}${
|
|
52417
|
+
const pid = `${colours_1.Colours.yellow}${process25.pid}${colours_1.Colours.reset}`;
|
|
52418
52418
|
let level;
|
|
52419
52419
|
switch (fields.severity) {
|
|
52420
52420
|
case LogSeverity.ERROR:
|
|
@@ -52462,8 +52462,8 @@ var require_logging_utils = __commonJS({
|
|
|
52462
52462
|
}
|
|
52463
52463
|
setFilters() {
|
|
52464
52464
|
var _a3;
|
|
52465
|
-
const existingFilters = (_a3 =
|
|
52466
|
-
|
|
52465
|
+
const existingFilters = (_a3 = process25.env["NODE_DEBUG"]) !== null && _a3 !== void 0 ? _a3 : "";
|
|
52466
|
+
process25.env["NODE_DEBUG"] = `${existingFilters}${existingFilters ? "," : ""}${this.filters.join(",")}`;
|
|
52467
52467
|
}
|
|
52468
52468
|
};
|
|
52469
52469
|
function getDebugBackend(debugPkg) {
|
|
@@ -52509,7 +52509,7 @@ var require_logging_utils = __commonJS({
|
|
|
52509
52509
|
loggerCache.clear();
|
|
52510
52510
|
}
|
|
52511
52511
|
function log(namespace, parent) {
|
|
52512
|
-
const enablesFlag =
|
|
52512
|
+
const enablesFlag = process25.env[exports2.env.nodeEnables];
|
|
52513
52513
|
if (!enablesFlag) {
|
|
52514
52514
|
return exports2.placeholder;
|
|
52515
52515
|
}
|
|
@@ -57931,7 +57931,7 @@ var require_googleauth = __commonJS({
|
|
|
57931
57931
|
NO_ADC_FOUND: "Could not load the default credentials. Browse to https://cloud.google.com/docs/authentication/getting-started for more information.",
|
|
57932
57932
|
NO_UNIVERSE_DOMAIN_FOUND: "Unable to detect a Universe Domain in the current environment.\nTo learn more about Universe Domain retrieval, visit: \nhttps://cloud.google.com/compute/docs/metadata/predefined-metadata-keys"
|
|
57933
57933
|
};
|
|
57934
|
-
var
|
|
57934
|
+
var GoogleAuth8 = class {
|
|
57935
57935
|
// Note: this properly is only public to satisfy unit tests.
|
|
57936
57936
|
// https://github.com/Microsoft/TypeScript/issues/5228
|
|
57937
57937
|
get isGCE() {
|
|
@@ -58580,7 +58580,7 @@ var require_googleauth = __commonJS({
|
|
|
58580
58580
|
return res.data.signedBlob;
|
|
58581
58581
|
}
|
|
58582
58582
|
};
|
|
58583
|
-
exports2.GoogleAuth =
|
|
58583
|
+
exports2.GoogleAuth = GoogleAuth8;
|
|
58584
58584
|
_GoogleAuth_pendingAuthClient = /* @__PURE__ */ new WeakMap(), _GoogleAuth_instances = /* @__PURE__ */ new WeakSet(), _GoogleAuth_prepareAndCacheClient = async function _GoogleAuth_prepareAndCacheClient2(credential, quotaProjectIdOverride = process.env["GOOGLE_CLOUD_QUOTA_PROJECT"] || null) {
|
|
58585
58585
|
const projectId = await this.getProjectIdOptional();
|
|
58586
58586
|
if (quotaProjectIdOverride) {
|
|
@@ -58605,7 +58605,7 @@ var require_googleauth = __commonJS({
|
|
|
58605
58605
|
return credential;
|
|
58606
58606
|
}
|
|
58607
58607
|
};
|
|
58608
|
-
|
|
58608
|
+
GoogleAuth8.DefaultTransporter = transporters_1.DefaultTransporter;
|
|
58609
58609
|
}
|
|
58610
58610
|
});
|
|
58611
58611
|
|
|
@@ -65173,11 +65173,11 @@ var require_copy = __commonJS({
|
|
|
65173
65173
|
if (!destStat) {
|
|
65174
65174
|
await fs60.mkdir(dest);
|
|
65175
65175
|
}
|
|
65176
|
-
const
|
|
65176
|
+
const promises3 = [];
|
|
65177
65177
|
for await (const item of await fs60.opendir(src)) {
|
|
65178
65178
|
const srcItem = path64.join(src, item.name);
|
|
65179
65179
|
const destItem = path64.join(dest, item.name);
|
|
65180
|
-
|
|
65180
|
+
promises3.push(
|
|
65181
65181
|
runFilter(srcItem, destItem, opts).then((include) => {
|
|
65182
65182
|
if (include) {
|
|
65183
65183
|
return stat2.checkPaths(srcItem, destItem, "copy", opts).then(({ destStat: destStat2 }) => {
|
|
@@ -65187,7 +65187,7 @@ var require_copy = __commonJS({
|
|
|
65187
65187
|
})
|
|
65188
65188
|
);
|
|
65189
65189
|
}
|
|
65190
|
-
await Promise.all(
|
|
65190
|
+
await Promise.all(promises3);
|
|
65191
65191
|
if (!destStat) {
|
|
65192
65192
|
await fs60.chmod(dest, srcStat.mode);
|
|
65193
65193
|
}
|
|
@@ -68639,7 +68639,7 @@ var require_extension = __commonJS({
|
|
|
68639
68639
|
var require_websocket = __commonJS({
|
|
68640
68640
|
"node_modules/ws/lib/websocket.js"(exports2, module2) {
|
|
68641
68641
|
"use strict";
|
|
68642
|
-
var
|
|
68642
|
+
var EventEmitter11 = __require("events");
|
|
68643
68643
|
var https3 = __require("https");
|
|
68644
68644
|
var http6 = __require("http");
|
|
68645
68645
|
var net3 = __require("net");
|
|
@@ -68671,7 +68671,7 @@ var require_websocket = __commonJS({
|
|
|
68671
68671
|
var protocolVersions = [8, 13];
|
|
68672
68672
|
var readyStates = ["CONNECTING", "OPEN", "CLOSING", "CLOSED"];
|
|
68673
68673
|
var subprotocolRegex = /^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/;
|
|
68674
|
-
var WebSocket2 = class _WebSocket extends
|
|
68674
|
+
var WebSocket2 = class _WebSocket extends EventEmitter11 {
|
|
68675
68675
|
/**
|
|
68676
68676
|
* Create a new `WebSocket`.
|
|
68677
68677
|
*
|
|
@@ -69665,7 +69665,7 @@ var require_subprotocol = __commonJS({
|
|
|
69665
69665
|
var require_websocket_server = __commonJS({
|
|
69666
69666
|
"node_modules/ws/lib/websocket-server.js"(exports2, module2) {
|
|
69667
69667
|
"use strict";
|
|
69668
|
-
var
|
|
69668
|
+
var EventEmitter11 = __require("events");
|
|
69669
69669
|
var http6 = __require("http");
|
|
69670
69670
|
var { Duplex: Duplex5 } = __require("stream");
|
|
69671
69671
|
var { createHash: createHash11 } = __require("crypto");
|
|
@@ -69678,7 +69678,7 @@ var require_websocket_server = __commonJS({
|
|
|
69678
69678
|
var RUNNING = 0;
|
|
69679
69679
|
var CLOSING = 1;
|
|
69680
69680
|
var CLOSED2 = 2;
|
|
69681
|
-
var WebSocketServer2 = class extends
|
|
69681
|
+
var WebSocketServer2 = class extends EventEmitter11 {
|
|
69682
69682
|
/**
|
|
69683
69683
|
* Create a `WebSocketServer` instance.
|
|
69684
69684
|
*
|
|
@@ -70088,6 +70088,62 @@ var init_base_token_storage = __esm({
|
|
|
70088
70088
|
}
|
|
70089
70089
|
});
|
|
70090
70090
|
|
|
70091
|
+
// packages/core/dist/src/utils/events.js
|
|
70092
|
+
import { EventEmitter as EventEmitter4 } from "node:events";
|
|
70093
|
+
var CoreEvent, CoreEventEmitter, coreEvents;
|
|
70094
|
+
var init_events = __esm({
|
|
70095
|
+
"packages/core/dist/src/utils/events.js"() {
|
|
70096
|
+
"use strict";
|
|
70097
|
+
(function(CoreEvent2) {
|
|
70098
|
+
CoreEvent2["UserFeedback"] = "user-feedback";
|
|
70099
|
+
})(CoreEvent || (CoreEvent = {}));
|
|
70100
|
+
CoreEventEmitter = class _CoreEventEmitter extends EventEmitter4 {
|
|
70101
|
+
_feedbackBacklog = [];
|
|
70102
|
+
static MAX_BACKLOG_SIZE = 1e4;
|
|
70103
|
+
constructor() {
|
|
70104
|
+
super();
|
|
70105
|
+
}
|
|
70106
|
+
/**
|
|
70107
|
+
* Sends actionable feedback to the user.
|
|
70108
|
+
* Buffers automatically if the UI hasn't subscribed yet.
|
|
70109
|
+
*/
|
|
70110
|
+
emitFeedback(severity, message, error) {
|
|
70111
|
+
const payload = { severity, message, error };
|
|
70112
|
+
if (this.listenerCount(CoreEvent.UserFeedback) === 0) {
|
|
70113
|
+
if (this._feedbackBacklog.length >= _CoreEventEmitter.MAX_BACKLOG_SIZE) {
|
|
70114
|
+
this._feedbackBacklog.shift();
|
|
70115
|
+
}
|
|
70116
|
+
this._feedbackBacklog.push(payload);
|
|
70117
|
+
} else {
|
|
70118
|
+
this.emit(CoreEvent.UserFeedback, payload);
|
|
70119
|
+
}
|
|
70120
|
+
}
|
|
70121
|
+
/**
|
|
70122
|
+
* Flushes buffered messages. Call this immediately after primary UI listener
|
|
70123
|
+
* subscribes.
|
|
70124
|
+
*/
|
|
70125
|
+
drainFeedbackBacklog() {
|
|
70126
|
+
const backlog = [...this._feedbackBacklog];
|
|
70127
|
+
this._feedbackBacklog.length = 0;
|
|
70128
|
+
for (const payload of backlog) {
|
|
70129
|
+
this.emit(CoreEvent.UserFeedback, payload);
|
|
70130
|
+
}
|
|
70131
|
+
}
|
|
70132
|
+
on(event, listener) {
|
|
70133
|
+
return super.on(event, listener);
|
|
70134
|
+
}
|
|
70135
|
+
off(event, listener) {
|
|
70136
|
+
return super.off(event, listener);
|
|
70137
|
+
}
|
|
70138
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
70139
|
+
emit(event, ...args2) {
|
|
70140
|
+
return super.emit(event, ...args2);
|
|
70141
|
+
}
|
|
70142
|
+
};
|
|
70143
|
+
coreEvents = new CoreEventEmitter();
|
|
70144
|
+
}
|
|
70145
|
+
});
|
|
70146
|
+
|
|
70091
70147
|
// packages/core/dist/src/mcp/token-storage/keychain-token-storage.js
|
|
70092
70148
|
var keychain_token_storage_exports = {};
|
|
70093
70149
|
__export(keychain_token_storage_exports, {
|
|
@@ -70099,6 +70155,7 @@ var init_keychain_token_storage = __esm({
|
|
|
70099
70155
|
"packages/core/dist/src/mcp/token-storage/keychain-token-storage.js"() {
|
|
70100
70156
|
"use strict";
|
|
70101
70157
|
init_base_token_storage();
|
|
70158
|
+
init_events();
|
|
70102
70159
|
KEYCHAIN_TEST_PREFIX = "__keychain_test__";
|
|
70103
70160
|
KeychainTokenStorage = class extends BaseTokenStorage {
|
|
70104
70161
|
keychainAvailable = null;
|
|
@@ -70114,7 +70171,7 @@ var init_keychain_token_storage = __esm({
|
|
|
70114
70171
|
const module2 = await import(moduleName2);
|
|
70115
70172
|
this.keytarModule = module2.default || module2;
|
|
70116
70173
|
} catch (error) {
|
|
70117
|
-
|
|
70174
|
+
coreEvents.emitFeedback("error", "Failed to load 'keytar' module", error);
|
|
70118
70175
|
}
|
|
70119
70176
|
return this.keytarModule;
|
|
70120
70177
|
}
|
|
@@ -70187,7 +70244,7 @@ var init_keychain_token_storage = __esm({
|
|
|
70187
70244
|
const credentials = await keytar.findCredentials(this.serviceName);
|
|
70188
70245
|
return credentials.filter((cred) => !cred.account.startsWith(KEYCHAIN_TEST_PREFIX)).map((cred) => cred.account);
|
|
70189
70246
|
} catch (error) {
|
|
70190
|
-
|
|
70247
|
+
coreEvents.emitFeedback("error", "Failed to list servers from keychain", error);
|
|
70191
70248
|
return [];
|
|
70192
70249
|
}
|
|
70193
70250
|
}
|
|
@@ -70209,11 +70266,11 @@ var init_keychain_token_storage = __esm({
|
|
|
70209
70266
|
result.set(cred.account, data);
|
|
70210
70267
|
}
|
|
70211
70268
|
} catch (error) {
|
|
70212
|
-
|
|
70269
|
+
coreEvents.emitFeedback("error", `Failed to parse credentials for ${cred.account}`, error);
|
|
70213
70270
|
}
|
|
70214
70271
|
}
|
|
70215
70272
|
} catch (error) {
|
|
70216
|
-
|
|
70273
|
+
coreEvents.emitFeedback("error", "Failed to get all credentials from keychain", error);
|
|
70217
70274
|
}
|
|
70218
70275
|
return result;
|
|
70219
70276
|
}
|
|
@@ -93130,18 +93187,18 @@ var require_base64 = __commonJS({
|
|
|
93130
93187
|
var require_eventemitter = __commonJS({
|
|
93131
93188
|
"node_modules/@protobufjs/eventemitter/index.js"(exports2, module2) {
|
|
93132
93189
|
"use strict";
|
|
93133
|
-
module2.exports =
|
|
93134
|
-
function
|
|
93190
|
+
module2.exports = EventEmitter11;
|
|
93191
|
+
function EventEmitter11() {
|
|
93135
93192
|
this._listeners = {};
|
|
93136
93193
|
}
|
|
93137
|
-
|
|
93194
|
+
EventEmitter11.prototype.on = function on6(evt, fn, ctx) {
|
|
93138
93195
|
(this._listeners[evt] || (this._listeners[evt] = [])).push({
|
|
93139
93196
|
fn,
|
|
93140
93197
|
ctx: ctx || this
|
|
93141
93198
|
});
|
|
93142
93199
|
return this;
|
|
93143
93200
|
};
|
|
93144
|
-
|
|
93201
|
+
EventEmitter11.prototype.off = function off(evt, fn) {
|
|
93145
93202
|
if (evt === void 0)
|
|
93146
93203
|
this._listeners = {};
|
|
93147
93204
|
else {
|
|
@@ -93158,7 +93215,7 @@ var require_eventemitter = __commonJS({
|
|
|
93158
93215
|
}
|
|
93159
93216
|
return this;
|
|
93160
93217
|
};
|
|
93161
|
-
|
|
93218
|
+
EventEmitter11.prototype.emit = function emit(evt) {
|
|
93162
93219
|
var listeners = this._listeners[evt];
|
|
93163
93220
|
if (listeners) {
|
|
93164
93221
|
var args2 = [], i3 = 1;
|
|
@@ -95890,7 +95947,7 @@ var require_root = __commonJS({
|
|
|
95890
95947
|
}
|
|
95891
95948
|
return null;
|
|
95892
95949
|
}
|
|
95893
|
-
function
|
|
95950
|
+
function process25(filename2, source) {
|
|
95894
95951
|
try {
|
|
95895
95952
|
if (util4.isString(source) && source.charAt(0) === "{")
|
|
95896
95953
|
source = JSON.parse(source);
|
|
@@ -95925,12 +95982,12 @@ var require_root = __commonJS({
|
|
|
95925
95982
|
self2.files.push(filename2);
|
|
95926
95983
|
if (filename2 in common2) {
|
|
95927
95984
|
if (sync2) {
|
|
95928
|
-
|
|
95985
|
+
process25(filename2, common2[filename2]);
|
|
95929
95986
|
} else {
|
|
95930
95987
|
++queued;
|
|
95931
95988
|
setTimeout(function() {
|
|
95932
95989
|
--queued;
|
|
95933
|
-
|
|
95990
|
+
process25(filename2, common2[filename2]);
|
|
95934
95991
|
});
|
|
95935
95992
|
}
|
|
95936
95993
|
return;
|
|
@@ -95944,7 +96001,7 @@ var require_root = __commonJS({
|
|
|
95944
96001
|
finish(err2);
|
|
95945
96002
|
return;
|
|
95946
96003
|
}
|
|
95947
|
-
|
|
96004
|
+
process25(filename2, source);
|
|
95948
96005
|
} else {
|
|
95949
96006
|
++queued;
|
|
95950
96007
|
self2.fetch(filename2, function(err2, source2) {
|
|
@@ -95959,7 +96016,7 @@ var require_root = __commonJS({
|
|
|
95959
96016
|
finish(null, self2);
|
|
95960
96017
|
return;
|
|
95961
96018
|
}
|
|
95962
|
-
|
|
96019
|
+
process25(filename2, source2);
|
|
95963
96020
|
});
|
|
95964
96021
|
}
|
|
95965
96022
|
}
|
|
@@ -120331,8 +120388,8 @@ var require_utils12 = __commonJS({
|
|
|
120331
120388
|
});
|
|
120332
120389
|
}
|
|
120333
120390
|
exports2.callWithTimeout = callWithTimeout;
|
|
120334
|
-
async function PromiseAllSettled(
|
|
120335
|
-
return Promise.all(
|
|
120391
|
+
async function PromiseAllSettled(promises3) {
|
|
120392
|
+
return Promise.all(promises3.map(async (p) => {
|
|
120336
120393
|
try {
|
|
120337
120394
|
const ret = await p;
|
|
120338
120395
|
return {
|
|
@@ -122684,13 +122741,13 @@ var require_getMachineId_win = __commonJS({
|
|
|
122684
122741
|
"use strict";
|
|
122685
122742
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
122686
122743
|
exports2.getMachineId = void 0;
|
|
122687
|
-
var
|
|
122744
|
+
var process25 = __require("process");
|
|
122688
122745
|
var execAsync_1 = require_execAsync();
|
|
122689
122746
|
var api_1 = (init_esm2(), __toCommonJS(esm_exports5));
|
|
122690
122747
|
async function getMachineId() {
|
|
122691
122748
|
const args2 = "QUERY HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Cryptography /v MachineGuid";
|
|
122692
122749
|
let command = "%windir%\\System32\\REG.exe";
|
|
122693
|
-
if (
|
|
122750
|
+
if (process25.arch === "ia32" && "PROCESSOR_ARCHITEW6432" in process25.env) {
|
|
122694
122751
|
command = "%windir%\\sysnative\\cmd.exe /c " + command;
|
|
122695
122752
|
}
|
|
122696
122753
|
try {
|
|
@@ -122729,11 +122786,11 @@ var require_getMachineId = __commonJS({
|
|
|
122729
122786
|
"use strict";
|
|
122730
122787
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
122731
122788
|
exports2.getMachineId = void 0;
|
|
122732
|
-
var
|
|
122789
|
+
var process25 = __require("process");
|
|
122733
122790
|
var getMachineIdImpl;
|
|
122734
122791
|
async function getMachineId() {
|
|
122735
122792
|
if (!getMachineIdImpl) {
|
|
122736
|
-
switch (
|
|
122793
|
+
switch (process25.platform) {
|
|
122737
122794
|
case "darwin":
|
|
122738
122795
|
getMachineIdImpl = (await Promise.resolve().then(() => __toESM(require_getMachineId_darwin()))).getMachineId;
|
|
122739
122796
|
break;
|
|
@@ -126224,12 +126281,12 @@ var require_BatchLogRecordProcessorBase = __commonJS({
|
|
|
126224
126281
|
* */
|
|
126225
126282
|
_flushAll() {
|
|
126226
126283
|
return new Promise((resolve13, reject) => {
|
|
126227
|
-
const
|
|
126284
|
+
const promises3 = [];
|
|
126228
126285
|
const batchCount = Math.ceil(this._finishedLogRecords.length / this._maxExportBatchSize);
|
|
126229
126286
|
for (let i3 = 0; i3 < batchCount; i3++) {
|
|
126230
|
-
|
|
126287
|
+
promises3.push(this._flushOneBatch());
|
|
126231
126288
|
}
|
|
126232
|
-
Promise.all(
|
|
126289
|
+
Promise.all(promises3).then(() => {
|
|
126233
126290
|
resolve13();
|
|
126234
126291
|
}).catch(reject);
|
|
126235
126292
|
});
|
|
@@ -127291,12 +127348,12 @@ var require_BatchSpanProcessorBase = __commonJS({
|
|
|
127291
127348
|
* */
|
|
127292
127349
|
_flushAll() {
|
|
127293
127350
|
return new Promise((resolve13, reject) => {
|
|
127294
|
-
const
|
|
127351
|
+
const promises3 = [];
|
|
127295
127352
|
const count2 = Math.ceil(this._finishedSpans.length / this._maxExportBatchSize);
|
|
127296
127353
|
for (let i3 = 0, j = count2; i3 < j; i3++) {
|
|
127297
|
-
|
|
127354
|
+
promises3.push(this._flushOneBatch());
|
|
127298
127355
|
}
|
|
127299
|
-
Promise.all(
|
|
127356
|
+
Promise.all(promises3).then(() => {
|
|
127300
127357
|
resolve13();
|
|
127301
127358
|
}).catch(reject);
|
|
127302
127359
|
});
|
|
@@ -127607,12 +127664,12 @@ var require_MultiSpanProcessor = __commonJS({
|
|
|
127607
127664
|
this._spanProcessors = _spanProcessors;
|
|
127608
127665
|
}
|
|
127609
127666
|
forceFlush() {
|
|
127610
|
-
const
|
|
127667
|
+
const promises3 = [];
|
|
127611
127668
|
for (const spanProcessor of this._spanProcessors) {
|
|
127612
|
-
|
|
127669
|
+
promises3.push(spanProcessor.forceFlush());
|
|
127613
127670
|
}
|
|
127614
127671
|
return new Promise((resolve13) => {
|
|
127615
|
-
Promise.all(
|
|
127672
|
+
Promise.all(promises3).then(() => {
|
|
127616
127673
|
resolve13();
|
|
127617
127674
|
}).catch((error) => {
|
|
127618
127675
|
(0, core_1.globalErrorHandler)(error || new Error("MultiSpanProcessor: forceFlush failed"));
|
|
@@ -127631,12 +127688,12 @@ var require_MultiSpanProcessor = __commonJS({
|
|
|
127631
127688
|
}
|
|
127632
127689
|
}
|
|
127633
127690
|
shutdown() {
|
|
127634
|
-
const
|
|
127691
|
+
const promises3 = [];
|
|
127635
127692
|
for (const spanProcessor of this._spanProcessors) {
|
|
127636
|
-
|
|
127693
|
+
promises3.push(spanProcessor.shutdown());
|
|
127637
127694
|
}
|
|
127638
127695
|
return new Promise((resolve13, reject) => {
|
|
127639
|
-
Promise.all(
|
|
127696
|
+
Promise.all(promises3).then(() => {
|
|
127640
127697
|
resolve13();
|
|
127641
127698
|
}, reject);
|
|
127642
127699
|
});
|
|
@@ -127691,7 +127748,7 @@ var require_BasicTracerProvider = __commonJS({
|
|
|
127691
127748
|
}
|
|
127692
127749
|
forceFlush() {
|
|
127693
127750
|
const timeout = this._config.forceFlushTimeoutMillis;
|
|
127694
|
-
const
|
|
127751
|
+
const promises3 = this._activeSpanProcessor["_spanProcessors"].map((spanProcessor) => {
|
|
127695
127752
|
return new Promise((resolve13) => {
|
|
127696
127753
|
let state;
|
|
127697
127754
|
const timeoutInterval = setTimeout(() => {
|
|
@@ -127712,7 +127769,7 @@ var require_BasicTracerProvider = __commonJS({
|
|
|
127712
127769
|
});
|
|
127713
127770
|
});
|
|
127714
127771
|
return new Promise((resolve13, reject) => {
|
|
127715
|
-
Promise.all(
|
|
127772
|
+
Promise.all(promises3).then((results) => {
|
|
127716
127773
|
const errors = results.filter((result) => result !== ForceFlushState.resolved);
|
|
127717
127774
|
if (errors.length > 0) {
|
|
127718
127775
|
reject(errors);
|
|
@@ -132658,17 +132715,17 @@ var require_sdk = __commonJS({
|
|
|
132658
132715
|
}
|
|
132659
132716
|
}
|
|
132660
132717
|
shutdown() {
|
|
132661
|
-
const
|
|
132718
|
+
const promises3 = [];
|
|
132662
132719
|
if (this._tracerProvider) {
|
|
132663
|
-
|
|
132720
|
+
promises3.push(this._tracerProvider.shutdown());
|
|
132664
132721
|
}
|
|
132665
132722
|
if (this._loggerProvider) {
|
|
132666
|
-
|
|
132723
|
+
promises3.push(this._loggerProvider.shutdown());
|
|
132667
132724
|
}
|
|
132668
132725
|
if (this._meterProvider) {
|
|
132669
|
-
|
|
132726
|
+
promises3.push(this._meterProvider.shutdown());
|
|
132670
132727
|
}
|
|
132671
|
-
return Promise.all(
|
|
132728
|
+
return Promise.all(promises3).then(() => {
|
|
132672
132729
|
});
|
|
132673
132730
|
}
|
|
132674
132731
|
configureLoggerProviderFromEnv() {
|
|
@@ -139548,10 +139605,10 @@ var require_http22 = __commonJS({
|
|
|
139548
139605
|
var extend = require_extend();
|
|
139549
139606
|
var stream_1 = __require("stream");
|
|
139550
139607
|
var util4 = __require("util");
|
|
139551
|
-
var
|
|
139608
|
+
var process25 = __require("process");
|
|
139552
139609
|
var common_1 = require_common3();
|
|
139553
139610
|
var { HTTP2_HEADER_CONTENT_ENCODING, HTTP2_HEADER_CONTENT_TYPE, HTTP2_HEADER_METHOD, HTTP2_HEADER_PATH, HTTP2_HEADER_STATUS } = http22.constants;
|
|
139554
|
-
var DEBUG = !!
|
|
139611
|
+
var DEBUG = !!process25.env.HTTP2_DEBUG;
|
|
139555
139612
|
exports2.sessions = {};
|
|
139556
139613
|
async function request3(config2) {
|
|
139557
139614
|
const opts = extend(true, {}, config2);
|
|
@@ -210806,15 +210863,15 @@ var require_fd_slicer = __commonJS({
|
|
|
210806
210863
|
var Writable6 = stream3.Writable;
|
|
210807
210864
|
var PassThrough4 = stream3.PassThrough;
|
|
210808
210865
|
var Pend = require_pend();
|
|
210809
|
-
var
|
|
210866
|
+
var EventEmitter11 = __require("events").EventEmitter;
|
|
210810
210867
|
exports2.createFromBuffer = createFromBuffer;
|
|
210811
210868
|
exports2.createFromFd = createFromFd;
|
|
210812
210869
|
exports2.BufferSlicer = BufferSlicer;
|
|
210813
210870
|
exports2.FdSlicer = FdSlicer;
|
|
210814
|
-
util4.inherits(FdSlicer,
|
|
210871
|
+
util4.inherits(FdSlicer, EventEmitter11);
|
|
210815
210872
|
function FdSlicer(fd, options2) {
|
|
210816
210873
|
options2 = options2 || {};
|
|
210817
|
-
|
|
210874
|
+
EventEmitter11.call(this);
|
|
210818
210875
|
this.fd = fd;
|
|
210819
210876
|
this.pend = new Pend();
|
|
210820
210877
|
this.pend.max = 1;
|
|
@@ -210958,9 +211015,9 @@ var require_fd_slicer = __commonJS({
|
|
|
210958
211015
|
this.destroyed = true;
|
|
210959
211016
|
this.context.unref();
|
|
210960
211017
|
};
|
|
210961
|
-
util4.inherits(BufferSlicer,
|
|
211018
|
+
util4.inherits(BufferSlicer, EventEmitter11);
|
|
210962
211019
|
function BufferSlicer(buffer, options2) {
|
|
210963
|
-
|
|
211020
|
+
EventEmitter11.call(this);
|
|
210964
211021
|
options2 = options2 || {};
|
|
210965
211022
|
this.refCount = 0;
|
|
210966
211023
|
this.buffer = buffer;
|
|
@@ -211370,7 +211427,7 @@ var require_yauzl = __commonJS({
|
|
|
211370
211427
|
var fd_slicer = require_fd_slicer();
|
|
211371
211428
|
var crc32 = require_buffer_crc32();
|
|
211372
211429
|
var util4 = __require("util");
|
|
211373
|
-
var
|
|
211430
|
+
var EventEmitter11 = __require("events").EventEmitter;
|
|
211374
211431
|
var Transform4 = __require("stream").Transform;
|
|
211375
211432
|
var PassThrough4 = __require("stream").PassThrough;
|
|
211376
211433
|
var Writable6 = __require("stream").Writable;
|
|
@@ -211502,10 +211559,10 @@ var require_yauzl = __commonJS({
|
|
|
211502
211559
|
callback(new Error("end of central directory record signature not found"));
|
|
211503
211560
|
});
|
|
211504
211561
|
}
|
|
211505
|
-
util4.inherits(ZipFile,
|
|
211562
|
+
util4.inherits(ZipFile, EventEmitter11);
|
|
211506
211563
|
function ZipFile(reader, centralDirectoryOffset, fileSize, entryCount, comment, autoClose, lazyEntries, decodeStrings, validateEntrySizes, strictFileNames) {
|
|
211507
211564
|
var self2 = this;
|
|
211508
|
-
|
|
211565
|
+
EventEmitter11.call(self2);
|
|
211509
211566
|
self2.reader = reader;
|
|
211510
211567
|
self2.reader.on("error", function(err2) {
|
|
211511
211568
|
emitError(self2, err2);
|
|
@@ -211866,9 +211923,9 @@ var require_yauzl = __commonJS({
|
|
|
211866
211923
|
}
|
|
211867
211924
|
cb();
|
|
211868
211925
|
};
|
|
211869
|
-
util4.inherits(RandomAccessReader,
|
|
211926
|
+
util4.inherits(RandomAccessReader, EventEmitter11);
|
|
211870
211927
|
function RandomAccessReader() {
|
|
211871
|
-
|
|
211928
|
+
EventEmitter11.call(this);
|
|
211872
211929
|
this.refCount = 0;
|
|
211873
211930
|
}
|
|
211874
211931
|
RandomAccessReader.prototype.ref = function() {
|
|
@@ -212874,7 +212931,7 @@ var require_json_buffer = __commonJS({
|
|
|
212874
212931
|
var require_src56 = __commonJS({
|
|
212875
212932
|
"node_modules/keyv/src/index.js"(exports2, module2) {
|
|
212876
212933
|
"use strict";
|
|
212877
|
-
var
|
|
212934
|
+
var EventEmitter11 = __require("events");
|
|
212878
212935
|
var JSONB = require_json_buffer();
|
|
212879
212936
|
var loadStore = (options2) => {
|
|
212880
212937
|
const adapters = {
|
|
@@ -212904,7 +212961,7 @@ var require_src56 = __commonJS({
|
|
|
212904
212961
|
"redis",
|
|
212905
212962
|
"tiered"
|
|
212906
212963
|
];
|
|
212907
|
-
var Keyv2 = class extends
|
|
212964
|
+
var Keyv2 = class extends EventEmitter11 {
|
|
212908
212965
|
constructor(uri, { emitErrors = true, ...options2 } = {}) {
|
|
212909
212966
|
super();
|
|
212910
212967
|
this.opts = {
|
|
@@ -212963,9 +213020,9 @@ var require_src56 = __commonJS({
|
|
|
212963
213020
|
const isArray2 = Array.isArray(key);
|
|
212964
213021
|
const keyPrefixed = isArray2 ? this._getKeyPrefixArray(key) : this._getKeyPrefix(key);
|
|
212965
213022
|
if (isArray2 && store.getMany === void 0) {
|
|
212966
|
-
const
|
|
213023
|
+
const promises3 = [];
|
|
212967
213024
|
for (const key2 of keyPrefixed) {
|
|
212968
|
-
|
|
213025
|
+
promises3.push(
|
|
212969
213026
|
Promise.resolve().then(() => store.get(key2)).then((data) => typeof data === "string" ? this.opts.deserialize(data) : this.opts.compression ? this.opts.deserialize(data) : data).then((data) => {
|
|
212970
213027
|
if (data === void 0 || data === null) {
|
|
212971
213028
|
return void 0;
|
|
@@ -212977,7 +213034,7 @@ var require_src56 = __commonJS({
|
|
|
212977
213034
|
})
|
|
212978
213035
|
);
|
|
212979
213036
|
}
|
|
212980
|
-
return Promise.allSettled(
|
|
213037
|
+
return Promise.allSettled(promises3).then((values) => {
|
|
212981
213038
|
const data = [];
|
|
212982
213039
|
for (const value of values) {
|
|
212983
213040
|
data.push(value.value);
|
|
@@ -213033,11 +213090,11 @@ var require_src56 = __commonJS({
|
|
|
213033
213090
|
if (Array.isArray(key)) {
|
|
213034
213091
|
const keyPrefixed2 = this._getKeyPrefixArray(key);
|
|
213035
213092
|
if (store.deleteMany === void 0) {
|
|
213036
|
-
const
|
|
213093
|
+
const promises3 = [];
|
|
213037
213094
|
for (const key2 of keyPrefixed2) {
|
|
213038
|
-
|
|
213095
|
+
promises3.push(store.delete(key2));
|
|
213039
213096
|
}
|
|
213040
|
-
return Promise.allSettled(
|
|
213097
|
+
return Promise.allSettled(promises3).then((values) => values.every((x) => x.value === true));
|
|
213041
213098
|
}
|
|
213042
213099
|
return Promise.resolve().then(() => store.deleteMany(keyPrefixed2));
|
|
213043
213100
|
}
|
|
@@ -213327,7 +213384,7 @@ var require_agent3 = __commonJS({
|
|
|
213327
213384
|
"node_modules/http2-wrapper/source/agent.js"(exports2, module2) {
|
|
213328
213385
|
"use strict";
|
|
213329
213386
|
var { URL: URL9 } = __require("url");
|
|
213330
|
-
var
|
|
213387
|
+
var EventEmitter11 = __require("events");
|
|
213331
213388
|
var tls = __require("tls");
|
|
213332
213389
|
var http22 = __require("http2");
|
|
213333
213390
|
var QuickLRU = require_quick_lru();
|
|
@@ -213425,7 +213482,7 @@ var require_agent3 = __commonJS({
|
|
|
213425
213482
|
session.close();
|
|
213426
213483
|
}
|
|
213427
213484
|
};
|
|
213428
|
-
var Agent3 = class _Agent extends
|
|
213485
|
+
var Agent3 = class _Agent extends EventEmitter11 {
|
|
213429
213486
|
constructor({ timeout = 0, maxSessions = Number.POSITIVE_INFINITY, maxEmptySessions = 10, maxCachedTlsSessions = 100 } = {}) {
|
|
213430
213487
|
super();
|
|
213431
213488
|
this.sessions = {};
|
|
@@ -217122,10 +217179,10 @@ var require_wrap_handler = __commonJS({
|
|
|
217122
217179
|
var require_dispatcher = __commonJS({
|
|
217123
217180
|
"node_modules/undici/lib/dispatcher/dispatcher.js"(exports2, module2) {
|
|
217124
217181
|
"use strict";
|
|
217125
|
-
var
|
|
217182
|
+
var EventEmitter11 = __require("node:events");
|
|
217126
217183
|
var WrapHandler = require_wrap_handler();
|
|
217127
217184
|
var wrapInterceptor = (dispatch) => (opts, handler) => dispatch(opts, WrapHandler.wrap(handler));
|
|
217128
|
-
var Dispatcher = class extends
|
|
217185
|
+
var Dispatcher = class extends EventEmitter11 {
|
|
217129
217186
|
dispatch() {
|
|
217130
217187
|
throw new Error("not implemented");
|
|
217131
217188
|
}
|
|
@@ -228968,9 +229025,9 @@ var require_memory_cache_store = __commonJS({
|
|
|
228968
229025
|
"node_modules/undici/lib/cache/memory-cache-store.js"(exports2, module2) {
|
|
228969
229026
|
"use strict";
|
|
228970
229027
|
var { Writable: Writable6 } = __require("node:stream");
|
|
228971
|
-
var { EventEmitter:
|
|
229028
|
+
var { EventEmitter: EventEmitter11 } = __require("node:events");
|
|
228972
229029
|
var { assertCacheKey, assertCacheValue } = require_cache2();
|
|
228973
|
-
var MemoryCacheStore = class extends
|
|
229030
|
+
var MemoryCacheStore = class extends EventEmitter11 {
|
|
228974
229031
|
#maxCount = 1024;
|
|
228975
229032
|
#maxSize = 104857600;
|
|
228976
229033
|
// 100MB
|
|
@@ -236837,20 +236894,6 @@ var require_undici = __commonJS({
|
|
|
236837
236894
|
}
|
|
236838
236895
|
});
|
|
236839
236896
|
|
|
236840
|
-
// node_modules/strip-ansi/node_modules/ansi-regex/index.js
|
|
236841
|
-
var require_ansi_regex = __commonJS({
|
|
236842
|
-
"node_modules/strip-ansi/node_modules/ansi-regex/index.js"(exports2, module2) {
|
|
236843
|
-
"use strict";
|
|
236844
|
-
module2.exports = ({ onlyFirst = false } = {}) => {
|
|
236845
|
-
const pattern = [
|
|
236846
|
-
"[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)",
|
|
236847
|
-
"(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"
|
|
236848
|
-
].join("|");
|
|
236849
|
-
return new RegExp(pattern, onlyFirst ? void 0 : "g");
|
|
236850
|
-
};
|
|
236851
|
-
}
|
|
236852
|
-
});
|
|
236853
|
-
|
|
236854
236897
|
// node_modules/chardet/lib/fs/node.js
|
|
236855
236898
|
var require_node22 = __commonJS({
|
|
236856
236899
|
"node_modules/chardet/lib/fs/node.js"(exports2, module2) {
|
|
@@ -258218,20 +258261,20 @@ var Bucket = class _Bucket extends ServiceObject {
|
|
|
258218
258261
|
};
|
|
258219
258262
|
(async () => {
|
|
258220
258263
|
try {
|
|
258221
|
-
let
|
|
258264
|
+
let promises3 = [];
|
|
258222
258265
|
const limit = (0, import_p_limit.default)(MAX_PARALLEL_LIMIT);
|
|
258223
258266
|
const filesStream = this.getFilesStream(query);
|
|
258224
258267
|
for await (const curFile of filesStream) {
|
|
258225
|
-
if (
|
|
258226
|
-
await Promise.all(
|
|
258227
|
-
|
|
258268
|
+
if (promises3.length >= MAX_QUEUE_SIZE) {
|
|
258269
|
+
await Promise.all(promises3);
|
|
258270
|
+
promises3 = [];
|
|
258228
258271
|
}
|
|
258229
|
-
|
|
258272
|
+
promises3.push(limit(() => deleteFile(curFile)).catch((e2) => {
|
|
258230
258273
|
filesStream.destroy();
|
|
258231
258274
|
throw e2;
|
|
258232
258275
|
}));
|
|
258233
258276
|
}
|
|
258234
|
-
await Promise.all(
|
|
258277
|
+
await Promise.all(promises3);
|
|
258235
258278
|
callback(errors.length > 0 ? errors : null);
|
|
258236
258279
|
} catch (e2) {
|
|
258237
258280
|
callback(e2);
|
|
@@ -260143,10 +260186,10 @@ var Bucket = class _Bucket extends ServiceObject {
|
|
|
260143
260186
|
};
|
|
260144
260187
|
this.getFiles(options2).then(([files]) => {
|
|
260145
260188
|
const limit = (0, import_p_limit.default)(MAX_PARALLEL_LIMIT);
|
|
260146
|
-
const
|
|
260189
|
+
const promises3 = files.map((file) => {
|
|
260147
260190
|
return limit(() => processFile(file));
|
|
260148
260191
|
});
|
|
260149
|
-
return Promise.all(
|
|
260192
|
+
return Promise.all(promises3);
|
|
260150
260193
|
}).then(() => callback(errors.length > 0 ? errors : null, updatedFiles), (err2) => callback(err2, updatedFiles));
|
|
260151
260194
|
}
|
|
260152
260195
|
getId() {
|
|
@@ -267244,7 +267287,7 @@ var mtimeFilter = (opt) => {
|
|
|
267244
267287
|
// packages/a2a-server/src/persistence/gcs.ts
|
|
267245
267288
|
var fse = __toESM(require_lib8(), 1);
|
|
267246
267289
|
import { promises as fsPromises4, createReadStream as createReadStream4 } from "node:fs";
|
|
267247
|
-
import { tmpdir as
|
|
267290
|
+
import { tmpdir as tmpdir4 } from "node:os";
|
|
267248
267291
|
import { join as join22 } from "node:path";
|
|
267249
267292
|
|
|
267250
267293
|
// packages/a2a-server/src/config/config.ts
|
|
@@ -267255,7 +267298,7 @@ import { homedir as homedir5 } from "node:os";
|
|
|
267255
267298
|
|
|
267256
267299
|
// packages/core/dist/src/config/config.js
|
|
267257
267300
|
import * as path56 from "node:path";
|
|
267258
|
-
import
|
|
267301
|
+
import process24 from "node:process";
|
|
267259
267302
|
|
|
267260
267303
|
// node_modules/@google/genai/dist/node/index.mjs
|
|
267261
267304
|
var import_google_auth_library6 = __toESM(require_src10(), 1);
|
|
@@ -284918,12 +284961,7 @@ function shortenPath(filePath, maxLen = 35) {
|
|
|
284918
284961
|
if (filePath.length <= maxLen) {
|
|
284919
284962
|
return filePath;
|
|
284920
284963
|
}
|
|
284921
|
-
const
|
|
284922
|
-
const root = parsedPath.root;
|
|
284923
|
-
const separator = path10.sep;
|
|
284924
|
-
const relativePath = filePath.substring(root.length);
|
|
284925
|
-
const segments = relativePath.split(separator).filter((s2) => s2 !== "");
|
|
284926
|
-
if (segments.length <= 1) {
|
|
284964
|
+
const simpleTruncate = () => {
|
|
284927
284965
|
const keepLen = Math.floor((maxLen - 3) / 2);
|
|
284928
284966
|
if (keepLen <= 0) {
|
|
284929
284967
|
return filePath.substring(0, maxLen - 3) + "...";
|
|
@@ -284931,29 +284969,134 @@ function shortenPath(filePath, maxLen = 35) {
|
|
|
284931
284969
|
const start2 = filePath.substring(0, keepLen);
|
|
284932
284970
|
const end = filePath.substring(filePath.length - keepLen);
|
|
284933
284971
|
return `${start2}...${end}`;
|
|
284972
|
+
};
|
|
284973
|
+
const truncateComponent = (component, targetLength, mode) => {
|
|
284974
|
+
if (component.length <= targetLength) {
|
|
284975
|
+
return component;
|
|
284976
|
+
}
|
|
284977
|
+
if (targetLength <= 0) {
|
|
284978
|
+
return "";
|
|
284979
|
+
}
|
|
284980
|
+
if (targetLength <= 3) {
|
|
284981
|
+
if (mode === "end") {
|
|
284982
|
+
return component.slice(-targetLength);
|
|
284983
|
+
}
|
|
284984
|
+
return component.slice(0, targetLength);
|
|
284985
|
+
}
|
|
284986
|
+
if (mode === "start") {
|
|
284987
|
+
return `${component.slice(0, targetLength - 3)}...`;
|
|
284988
|
+
}
|
|
284989
|
+
if (mode === "end") {
|
|
284990
|
+
return `...${component.slice(component.length - (targetLength - 3))}`;
|
|
284991
|
+
}
|
|
284992
|
+
const front = Math.ceil((targetLength - 3) / 2);
|
|
284993
|
+
const back = targetLength - 3 - front;
|
|
284994
|
+
return `${component.slice(0, front)}...${component.slice(component.length - back)}`;
|
|
284995
|
+
};
|
|
284996
|
+
const parsedPath = path10.parse(filePath);
|
|
284997
|
+
const root = parsedPath.root;
|
|
284998
|
+
const separator = path10.sep;
|
|
284999
|
+
const relativePath = filePath.substring(root.length);
|
|
285000
|
+
const segments = relativePath.split(separator).filter((s2) => s2 !== "");
|
|
285001
|
+
if (segments.length <= 1) {
|
|
285002
|
+
return simpleTruncate();
|
|
284934
285003
|
}
|
|
284935
285004
|
const firstDir = segments[0];
|
|
284936
285005
|
const lastSegment = segments[segments.length - 1];
|
|
284937
285006
|
const startComponent = root + firstDir;
|
|
284938
|
-
const endPartSegments = [];
|
|
284939
|
-
let
|
|
284940
|
-
for (let i3 = segments.length - 2; i3
|
|
285007
|
+
const endPartSegments = [lastSegment];
|
|
285008
|
+
let endPartLength = lastSegment.length;
|
|
285009
|
+
for (let i3 = segments.length - 2; i3 > 0; i3--) {
|
|
284941
285010
|
const segment = segments[i3];
|
|
284942
|
-
const
|
|
284943
|
-
|
|
285011
|
+
const newLength = startComponent.length + separator.length + 3 + // for "..."
|
|
285012
|
+
separator.length + endPartLength + separator.length + segment.length;
|
|
285013
|
+
if (newLength <= maxLen) {
|
|
284944
285014
|
endPartSegments.unshift(segment);
|
|
284945
|
-
|
|
285015
|
+
endPartLength += separator.length + segment.length;
|
|
284946
285016
|
} else {
|
|
284947
285017
|
break;
|
|
284948
285018
|
}
|
|
284949
285019
|
}
|
|
284950
|
-
|
|
284951
|
-
|
|
284952
|
-
|
|
285020
|
+
const components = [firstDir, ...endPartSegments];
|
|
285021
|
+
const componentModes = components.map((_, index) => {
|
|
285022
|
+
if (index === 0) {
|
|
285023
|
+
return "start";
|
|
285024
|
+
}
|
|
285025
|
+
if (index === components.length - 1) {
|
|
285026
|
+
return "end";
|
|
285027
|
+
}
|
|
285028
|
+
return "center";
|
|
285029
|
+
});
|
|
285030
|
+
const separatorsCount = endPartSegments.length + 1;
|
|
285031
|
+
const fixedLen = root.length + separatorsCount * separator.length + 3;
|
|
285032
|
+
const availableForComponents = maxLen - fixedLen;
|
|
285033
|
+
const trailingFallback = () => {
|
|
285034
|
+
const ellipsisTail = `...${separator}${lastSegment}`;
|
|
285035
|
+
if (ellipsisTail.length <= maxLen) {
|
|
285036
|
+
return ellipsisTail;
|
|
285037
|
+
}
|
|
285038
|
+
if (root) {
|
|
285039
|
+
const rootEllipsisTail = `${root}...${separator}${lastSegment}`;
|
|
285040
|
+
if (rootEllipsisTail.length <= maxLen) {
|
|
285041
|
+
return rootEllipsisTail;
|
|
285042
|
+
}
|
|
285043
|
+
}
|
|
285044
|
+
if (root && `${root}${lastSegment}`.length <= maxLen) {
|
|
285045
|
+
return `${root}${lastSegment}`;
|
|
285046
|
+
}
|
|
285047
|
+
if (lastSegment.length <= maxLen) {
|
|
285048
|
+
return lastSegment;
|
|
285049
|
+
}
|
|
285050
|
+
return simpleTruncate();
|
|
285051
|
+
};
|
|
285052
|
+
if (availableForComponents <= 0) {
|
|
285053
|
+
return trailingFallback();
|
|
284953
285054
|
}
|
|
284954
|
-
|
|
285055
|
+
const minLengths = components.map((component, index) => {
|
|
285056
|
+
if (index === 0) {
|
|
285057
|
+
return Math.min(component.length, 1);
|
|
285058
|
+
}
|
|
285059
|
+
if (index === components.length - 1) {
|
|
285060
|
+
return component.length;
|
|
285061
|
+
}
|
|
285062
|
+
return Math.min(component.length, 1);
|
|
285063
|
+
});
|
|
285064
|
+
const minTotal = minLengths.reduce((sum, len) => sum + len, 0);
|
|
285065
|
+
if (availableForComponents < minTotal) {
|
|
285066
|
+
return trailingFallback();
|
|
285067
|
+
}
|
|
285068
|
+
const budgets = components.map((component) => component.length);
|
|
285069
|
+
let currentTotal = budgets.reduce((sum, len) => sum + len, 0);
|
|
285070
|
+
const pickIndexToReduce = () => {
|
|
285071
|
+
let bestIndex = -1;
|
|
285072
|
+
let bestScore = -Infinity;
|
|
285073
|
+
for (let i3 = 0; i3 < budgets.length; i3++) {
|
|
285074
|
+
if (budgets[i3] <= minLengths[i3]) {
|
|
285075
|
+
continue;
|
|
285076
|
+
}
|
|
285077
|
+
const isLast = i3 === budgets.length - 1;
|
|
285078
|
+
const score = (isLast ? 0 : 1e6) + budgets[i3];
|
|
285079
|
+
if (score > bestScore) {
|
|
285080
|
+
bestScore = score;
|
|
285081
|
+
bestIndex = i3;
|
|
285082
|
+
}
|
|
285083
|
+
}
|
|
285084
|
+
return bestIndex;
|
|
285085
|
+
};
|
|
285086
|
+
while (currentTotal > availableForComponents) {
|
|
285087
|
+
const index = pickIndexToReduce();
|
|
285088
|
+
if (index === -1) {
|
|
285089
|
+
return trailingFallback();
|
|
285090
|
+
}
|
|
285091
|
+
budgets[index]--;
|
|
285092
|
+
currentTotal--;
|
|
285093
|
+
}
|
|
285094
|
+
const truncatedComponents = components.map((component, index) => truncateComponent(component, budgets[index], componentModes[index]));
|
|
285095
|
+
const truncatedFirst = truncatedComponents[0];
|
|
285096
|
+
const truncatedEnd = truncatedComponents.slice(1).join(separator);
|
|
285097
|
+
const result = `${root}${truncatedFirst}${separator}...${separator}${truncatedEnd}`;
|
|
284955
285098
|
if (result.length > maxLen) {
|
|
284956
|
-
return
|
|
285099
|
+
return trailingFallback();
|
|
284957
285100
|
}
|
|
284958
285101
|
return result;
|
|
284959
285102
|
}
|
|
@@ -285502,6 +285645,21 @@ function getUseEncryptedStorageFlag() {
|
|
|
285502
285645
|
return process.env[FORCE_ENCRYPTED_FILE_ENV_VAR] === "true";
|
|
285503
285646
|
}
|
|
285504
285647
|
async function initOauthClient(authType, config2) {
|
|
285648
|
+
const credentials = await fetchCachedCredentials();
|
|
285649
|
+
if (credentials && credentials.type === "external_account_authorized_user") {
|
|
285650
|
+
const auth2 = new import_google_auth_library8.GoogleAuth({
|
|
285651
|
+
scopes: OAUTH_SCOPE
|
|
285652
|
+
});
|
|
285653
|
+
const byoidClient = await auth2.fromJSON({
|
|
285654
|
+
...credentials,
|
|
285655
|
+
refresh_token: credentials.refresh_token ?? void 0
|
|
285656
|
+
});
|
|
285657
|
+
const token2 = await byoidClient.getAccessToken();
|
|
285658
|
+
if (token2) {
|
|
285659
|
+
debugLogger.debug("Created BYOID auth client.");
|
|
285660
|
+
return byoidClient;
|
|
285661
|
+
}
|
|
285662
|
+
}
|
|
285505
285663
|
const client = new import_google_auth_library8.OAuth2Client({
|
|
285506
285664
|
clientId: OAUTH_CLIENT_ID,
|
|
285507
285665
|
clientSecret: OAUTH_CLIENT_SECRET,
|
|
@@ -285524,16 +285682,25 @@ async function initOauthClient(authType, config2) {
|
|
|
285524
285682
|
await cacheCredentials(tokens);
|
|
285525
285683
|
}
|
|
285526
285684
|
});
|
|
285527
|
-
if (
|
|
285528
|
-
|
|
285529
|
-
|
|
285530
|
-
|
|
285531
|
-
|
|
285532
|
-
|
|
285685
|
+
if (credentials) {
|
|
285686
|
+
client.setCredentials(credentials);
|
|
285687
|
+
try {
|
|
285688
|
+
const { token: token2 } = await client.getAccessToken();
|
|
285689
|
+
if (token2) {
|
|
285690
|
+
await client.getTokenInfo(token2);
|
|
285691
|
+
if (!userAccountManager.getCachedGoogleAccount()) {
|
|
285692
|
+
try {
|
|
285693
|
+
await fetchAndCacheUserInfo(client);
|
|
285694
|
+
} catch (error) {
|
|
285695
|
+
debugLogger.warn("Failed to fetch user info:", getErrorMessage(error));
|
|
285696
|
+
}
|
|
285697
|
+
}
|
|
285698
|
+
debugLogger.log("Loaded cached credentials.");
|
|
285699
|
+
return client;
|
|
285533
285700
|
}
|
|
285701
|
+
} catch (error) {
|
|
285702
|
+
debugLogger.debug(`Cached credentials are not valid:`, getErrorMessage(error));
|
|
285534
285703
|
}
|
|
285535
|
-
debugLogger.log("Loaded cached credentials.");
|
|
285536
|
-
return client;
|
|
285537
285704
|
}
|
|
285538
285705
|
if (authType === AuthType2.CLOUD_SHELL) {
|
|
285539
285706
|
try {
|
|
@@ -285743,15 +285910,10 @@ function getAvailablePort() {
|
|
|
285743
285910
|
}
|
|
285744
285911
|
});
|
|
285745
285912
|
}
|
|
285746
|
-
async function
|
|
285913
|
+
async function fetchCachedCredentials() {
|
|
285747
285914
|
const useEncryptedStorage = getUseEncryptedStorageFlag();
|
|
285748
285915
|
if (useEncryptedStorage) {
|
|
285749
|
-
|
|
285750
|
-
if (credentials) {
|
|
285751
|
-
client.setCredentials(credentials);
|
|
285752
|
-
return true;
|
|
285753
|
-
}
|
|
285754
|
-
return false;
|
|
285916
|
+
return await OAuthCredentialStorage.loadCredentials();
|
|
285755
285917
|
}
|
|
285756
285918
|
const pathsToTry = [
|
|
285757
285919
|
Storage2.getOAuthCredsPath(),
|
|
@@ -285759,19 +285921,13 @@ async function loadCachedCredentials(client) {
|
|
|
285759
285921
|
].filter((p) => !!p);
|
|
285760
285922
|
for (const keyFile of pathsToTry) {
|
|
285761
285923
|
try {
|
|
285762
|
-
const
|
|
285763
|
-
|
|
285764
|
-
const { token: token2 } = await client.getAccessToken();
|
|
285765
|
-
if (!token2) {
|
|
285766
|
-
continue;
|
|
285767
|
-
}
|
|
285768
|
-
await client.getTokenInfo(token2);
|
|
285769
|
-
return true;
|
|
285924
|
+
const keyFileString = await fs22.readFile(keyFile, "utf-8");
|
|
285925
|
+
return JSON.parse(keyFileString);
|
|
285770
285926
|
} catch (error) {
|
|
285771
285927
|
debugLogger.debug(`Failed to load credentials from ${keyFile}:`, getErrorMessage(error));
|
|
285772
285928
|
}
|
|
285773
285929
|
}
|
|
285774
|
-
return
|
|
285930
|
+
return null;
|
|
285775
285931
|
}
|
|
285776
285932
|
async function cacheCredentials(credentials) {
|
|
285777
285933
|
const filePath = Storage2.getOAuthCredsPath();
|
|
@@ -286349,24 +286505,18 @@ var BaseToolInvocation = class {
|
|
|
286349
286505
|
throw new Error(`Tool execution for "${this._toolDisplayName || this._toolName}" denied by policy.`);
|
|
286350
286506
|
}
|
|
286351
286507
|
if (decision === "ASK_USER") {
|
|
286352
|
-
|
|
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;
|
|
286508
|
+
return this.getConfirmationDetails(abortSignal);
|
|
286368
286509
|
}
|
|
286369
286510
|
}
|
|
286511
|
+
return this.getConfirmationDetails(abortSignal);
|
|
286512
|
+
}
|
|
286513
|
+
/**
|
|
286514
|
+
* Subclasses should override this method to provide custom confirmation UI
|
|
286515
|
+
* when the policy engine's decision is 'ASK_USER'.
|
|
286516
|
+
* The base implementation returns false (no confirmation needed).
|
|
286517
|
+
* Only tools that need confirmation (e.g., write, execute tools) should override this.
|
|
286518
|
+
*/
|
|
286519
|
+
async getConfirmationDetails(_abortSignal) {
|
|
286370
286520
|
return false;
|
|
286371
286521
|
}
|
|
286372
286522
|
getMessageBusDecision(abortSignal) {
|
|
@@ -286784,7 +286934,7 @@ var DiscoveredMCPTool = class _DiscoveredMCPTool extends BaseDeclarativeTool {
|
|
|
286784
286934
|
asFullyQualifiedTool() {
|
|
286785
286935
|
return new _DiscoveredMCPTool(this.mcpTool, this.serverName, this.serverToolName, this.description, this.parameterSchema, this.trust, `${this.serverName}__${this.serverToolName}`, this.cliConfig, this.extensionId);
|
|
286786
286936
|
}
|
|
286787
|
-
createInvocation(params) {
|
|
286937
|
+
createInvocation(params, _messageBus, _toolName, _displayName) {
|
|
286788
286938
|
return new DiscoveredMCPToolInvocation(this.mcpTool, this.serverName, this.serverToolName, this.displayName, this.trust, params, this.cliConfig);
|
|
286789
286939
|
}
|
|
286790
286940
|
};
|
|
@@ -286968,90 +287118,6 @@ function getCommonAttributes(config2) {
|
|
|
286968
287118
|
|
|
286969
287119
|
// packages/core/dist/src/telemetry/types.js
|
|
286970
287120
|
init_esm();
|
|
286971
|
-
var EVENT_CLI_CONFIG = "gemini_cli.config";
|
|
286972
|
-
var StartSessionEvent = class {
|
|
286973
|
-
"event.name";
|
|
286974
|
-
"event.timestamp";
|
|
286975
|
-
model;
|
|
286976
|
-
embedding_model;
|
|
286977
|
-
sandbox_enabled;
|
|
286978
|
-
core_tools_enabled;
|
|
286979
|
-
approval_mode;
|
|
286980
|
-
api_key_enabled;
|
|
286981
|
-
vertex_ai_enabled;
|
|
286982
|
-
debug_enabled;
|
|
286983
|
-
mcp_servers;
|
|
286984
|
-
telemetry_enabled;
|
|
286985
|
-
telemetry_log_user_prompts_enabled;
|
|
286986
|
-
file_filtering_respect_git_ignore;
|
|
286987
|
-
mcp_servers_count;
|
|
286988
|
-
mcp_tools_count;
|
|
286989
|
-
mcp_tools;
|
|
286990
|
-
output_format;
|
|
286991
|
-
extensions_count;
|
|
286992
|
-
extension_ids;
|
|
286993
|
-
constructor(config2, toolRegistry) {
|
|
286994
|
-
const generatorConfig = config2.getContentGeneratorConfig();
|
|
286995
|
-
const mcpServers = config2.getMcpServers();
|
|
286996
|
-
let useGemini = false;
|
|
286997
|
-
let useVertex = false;
|
|
286998
|
-
if (generatorConfig && generatorConfig.authType) {
|
|
286999
|
-
useGemini = generatorConfig.authType === AuthType2.USE_GEMINI;
|
|
287000
|
-
useVertex = generatorConfig.authType === AuthType2.USE_VERTEX_AI;
|
|
287001
|
-
}
|
|
287002
|
-
this["event.name"] = "cli_config";
|
|
287003
|
-
this["event.timestamp"] = (/* @__PURE__ */ new Date()).toISOString();
|
|
287004
|
-
this.model = config2.getModel();
|
|
287005
|
-
this.embedding_model = config2.getEmbeddingModel();
|
|
287006
|
-
this.sandbox_enabled = typeof config2.getSandbox() === "string" || !!config2.getSandbox();
|
|
287007
|
-
this.core_tools_enabled = (config2.getCoreTools() ?? []).join(",");
|
|
287008
|
-
this.approval_mode = config2.getApprovalMode();
|
|
287009
|
-
this.api_key_enabled = useGemini || useVertex;
|
|
287010
|
-
this.vertex_ai_enabled = useVertex;
|
|
287011
|
-
this.debug_enabled = config2.getDebugMode();
|
|
287012
|
-
this.mcp_servers = mcpServers ? Object.keys(mcpServers).join(",") : "";
|
|
287013
|
-
this.telemetry_enabled = config2.getTelemetryEnabled();
|
|
287014
|
-
this.telemetry_log_user_prompts_enabled = config2.getTelemetryLogPromptsEnabled();
|
|
287015
|
-
this.file_filtering_respect_git_ignore = config2.getFileFilteringRespectGitIgnore();
|
|
287016
|
-
this.mcp_servers_count = mcpServers ? Object.keys(mcpServers).length : 0;
|
|
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(",");
|
|
287021
|
-
if (toolRegistry) {
|
|
287022
|
-
const mcpTools = toolRegistry.getAllTools().filter((tool) => tool instanceof DiscoveredMCPTool);
|
|
287023
|
-
this.mcp_tools_count = mcpTools.length;
|
|
287024
|
-
this.mcp_tools = mcpTools.map((tool) => tool.name).join(",");
|
|
287025
|
-
}
|
|
287026
|
-
}
|
|
287027
|
-
toOpenTelemetryAttributes(config2) {
|
|
287028
|
-
return {
|
|
287029
|
-
...getCommonAttributes(config2),
|
|
287030
|
-
"event.name": EVENT_CLI_CONFIG,
|
|
287031
|
-
"event.timestamp": this["event.timestamp"],
|
|
287032
|
-
model: this.model,
|
|
287033
|
-
embedding_model: this.embedding_model,
|
|
287034
|
-
sandbox_enabled: this.sandbox_enabled,
|
|
287035
|
-
core_tools_enabled: this.core_tools_enabled,
|
|
287036
|
-
approval_mode: this.approval_mode,
|
|
287037
|
-
api_key_enabled: this.api_key_enabled,
|
|
287038
|
-
vertex_ai_enabled: this.vertex_ai_enabled,
|
|
287039
|
-
log_user_prompts_enabled: this.telemetry_log_user_prompts_enabled,
|
|
287040
|
-
file_filtering_respect_git_ignore: this.file_filtering_respect_git_ignore,
|
|
287041
|
-
debug_mode: this.debug_enabled,
|
|
287042
|
-
mcp_servers: this.mcp_servers,
|
|
287043
|
-
mcp_servers_count: this.mcp_servers_count,
|
|
287044
|
-
mcp_tools: this.mcp_tools,
|
|
287045
|
-
mcp_tools_count: this.mcp_tools_count,
|
|
287046
|
-
output_format: this.output_format,
|
|
287047
|
-
extensions_count: this.extensions_count,
|
|
287048
|
-
extension_ids: this.extension_ids
|
|
287049
|
-
};
|
|
287050
|
-
}
|
|
287051
|
-
toLogBody() {
|
|
287052
|
-
return "CLI configuration loaded.";
|
|
287053
|
-
}
|
|
287054
|
-
};
|
|
287055
287121
|
var EVENT_TOOL_CALL = "gemini_cli.tool_call";
|
|
287056
287122
|
var ToolCallEvent = class {
|
|
287057
287123
|
"event.name";
|
|
@@ -287811,6 +287877,7 @@ var REGRESSION_DETECTION = "gemini_cli.performance.regression";
|
|
|
287811
287877
|
var REGRESSION_PERCENTAGE_CHANGE = "gemini_cli.performance.regression.percentage_change";
|
|
287812
287878
|
var BASELINE_COMPARISON = "gemini_cli.performance.baseline.comparison";
|
|
287813
287879
|
var FLICKER_FRAME_COUNT = "gemini_cli.ui.flicker.count";
|
|
287880
|
+
var EXIT_FAIL_COUNT = "gemini_cli.exit.fail.count";
|
|
287814
287881
|
var baseMetricDefinition = {
|
|
287815
287882
|
getCommonAttributes
|
|
287816
287883
|
};
|
|
@@ -287892,6 +287959,12 @@ var COUNTER_DEFINITIONS = {
|
|
|
287892
287959
|
valueType: ValueType.INT,
|
|
287893
287960
|
assign: (c4) => flickerFrameCounter = c4,
|
|
287894
287961
|
attributes: {}
|
|
287962
|
+
},
|
|
287963
|
+
[EXIT_FAIL_COUNT]: {
|
|
287964
|
+
description: "Counts CLI exit failures.",
|
|
287965
|
+
valueType: ValueType.INT,
|
|
287966
|
+
assign: (c4) => exitFailCounter = c4,
|
|
287967
|
+
attributes: {}
|
|
287895
287968
|
}
|
|
287896
287969
|
};
|
|
287897
287970
|
var HISTOGRAM_DEFINITIONS = {
|
|
@@ -288094,6 +288167,7 @@ var agentRunCounter;
|
|
|
288094
288167
|
var agentDurationHistogram;
|
|
288095
288168
|
var agentTurnsHistogram;
|
|
288096
288169
|
var flickerFrameCounter;
|
|
288170
|
+
var exitFailCounter;
|
|
288097
288171
|
var genAiClientTokenUsageHistogram;
|
|
288098
288172
|
var genAiClientOperationDurationHistogram;
|
|
288099
288173
|
var startupTimeHistogram;
|
|
@@ -288503,8 +288577,8 @@ var Float64Vector = import_vector.default.Float64Vector;
|
|
|
288503
288577
|
var PointerVector = import_vector.default.PointerVector;
|
|
288504
288578
|
|
|
288505
288579
|
// packages/core/dist/src/generated/git-commit.js
|
|
288506
|
-
var GIT_COMMIT_INFO = "
|
|
288507
|
-
var CLI_VERSION = "0.12.0-nightly.
|
|
288580
|
+
var GIT_COMMIT_INFO = "cb0947c5";
|
|
288581
|
+
var CLI_VERSION = "0.12.0-nightly.20251027.cb0947c5";
|
|
288508
288582
|
|
|
288509
288583
|
// packages/core/dist/src/ide/detect-ide.js
|
|
288510
288584
|
var IDE_DEFINITIONS = {
|
|
@@ -288689,6 +288763,36 @@ var ClearcutLogger = class _ClearcutLogger {
|
|
|
288689
288763
|
}
|
|
288690
288764
|
}
|
|
288691
288765
|
}
|
|
288766
|
+
createBasicLogEvent(eventName, data = []) {
|
|
288767
|
+
const surface = determineSurface();
|
|
288768
|
+
return {
|
|
288769
|
+
console_type: "GEMINI_CLI",
|
|
288770
|
+
application: 102,
|
|
288771
|
+
// GEMINI_CLI
|
|
288772
|
+
event_name: eventName,
|
|
288773
|
+
event_metadata: [
|
|
288774
|
+
[
|
|
288775
|
+
...data,
|
|
288776
|
+
{
|
|
288777
|
+
gemini_cli_key: EventMetadataKey.GEMINI_CLI_SURFACE,
|
|
288778
|
+
value: surface
|
|
288779
|
+
},
|
|
288780
|
+
{
|
|
288781
|
+
gemini_cli_key: EventMetadataKey.GEMINI_CLI_VERSION,
|
|
288782
|
+
value: CLI_VERSION
|
|
288783
|
+
},
|
|
288784
|
+
{
|
|
288785
|
+
gemini_cli_key: EventMetadataKey.GEMINI_CLI_GIT_COMMIT_HASH,
|
|
288786
|
+
value: GIT_COMMIT_INFO
|
|
288787
|
+
},
|
|
288788
|
+
{
|
|
288789
|
+
gemini_cli_key: EventMetadataKey.GEMINI_CLI_OS,
|
|
288790
|
+
value: process.platform
|
|
288791
|
+
}
|
|
288792
|
+
]
|
|
288793
|
+
]
|
|
288794
|
+
};
|
|
288795
|
+
}
|
|
288692
288796
|
createLogEvent(eventName, data = []) {
|
|
288693
288797
|
const email = this.userAccountManager.getCachedGoogleAccount();
|
|
288694
288798
|
if (eventName !== EventNames.START_SESSION) {
|
|
@@ -288696,13 +288800,7 @@ var ClearcutLogger = class _ClearcutLogger {
|
|
|
288696
288800
|
}
|
|
288697
288801
|
const totalAccounts = this.userAccountManager.getLifetimeGoogleAccounts();
|
|
288698
288802
|
data = this.addDefaultFields(data, totalAccounts);
|
|
288699
|
-
const logEvent =
|
|
288700
|
-
console_type: "GEMINI_CLI",
|
|
288701
|
-
application: 102,
|
|
288702
|
-
// GEMINI_CLI
|
|
288703
|
-
event_name: eventName,
|
|
288704
|
-
event_metadata: [data]
|
|
288705
|
-
};
|
|
288803
|
+
const logEvent = this.createBasicLogEvent(eventName, data);
|
|
288706
288804
|
if (email) {
|
|
288707
288805
|
logEvent.client_email = email;
|
|
288708
288806
|
} else {
|
|
@@ -289243,7 +289341,7 @@ var ClearcutLogger = class _ClearcutLogger {
|
|
|
289243
289341
|
value: event.status
|
|
289244
289342
|
}
|
|
289245
289343
|
];
|
|
289246
|
-
this.enqueueLogEvent(this.
|
|
289344
|
+
this.enqueueLogEvent(this.createBasicLogEvent(EventNames.EXTENSION_INSTALL, data));
|
|
289247
289345
|
this.flushToClearcut().catch((error) => {
|
|
289248
289346
|
debugLogger.debug("Error flushing to Clearcut:", error);
|
|
289249
289347
|
});
|
|
@@ -289263,7 +289361,7 @@ var ClearcutLogger = class _ClearcutLogger {
|
|
|
289263
289361
|
value: event.status
|
|
289264
289362
|
}
|
|
289265
289363
|
];
|
|
289266
|
-
this.enqueueLogEvent(this.
|
|
289364
|
+
this.enqueueLogEvent(this.createBasicLogEvent(EventNames.EXTENSION_UNINSTALL, data));
|
|
289267
289365
|
this.flushToClearcut().catch((error) => {
|
|
289268
289366
|
debugLogger.debug("Error flushing to Clearcut:", error);
|
|
289269
289367
|
});
|
|
@@ -289295,7 +289393,7 @@ var ClearcutLogger = class _ClearcutLogger {
|
|
|
289295
289393
|
value: event.status
|
|
289296
289394
|
}
|
|
289297
289395
|
];
|
|
289298
|
-
this.enqueueLogEvent(this.
|
|
289396
|
+
this.enqueueLogEvent(this.createBasicLogEvent(EventNames.EXTENSION_UPDATE, data));
|
|
289299
289397
|
this.flushToClearcut().catch((error) => {
|
|
289300
289398
|
debugLogger.debug("Error flushing to Clearcut:", error);
|
|
289301
289399
|
});
|
|
@@ -289369,7 +289467,7 @@ var ClearcutLogger = class _ClearcutLogger {
|
|
|
289369
289467
|
value: event.setting_scope
|
|
289370
289468
|
}
|
|
289371
289469
|
];
|
|
289372
|
-
this.enqueueLogEvent(this.
|
|
289470
|
+
this.enqueueLogEvent(this.createBasicLogEvent(EventNames.EXTENSION_ENABLE, data));
|
|
289373
289471
|
this.flushToClearcut().catch((error) => {
|
|
289374
289472
|
debugLogger.debug("Error flushing to Clearcut:", error);
|
|
289375
289473
|
});
|
|
@@ -289399,7 +289497,7 @@ var ClearcutLogger = class _ClearcutLogger {
|
|
|
289399
289497
|
value: event.setting_scope
|
|
289400
289498
|
}
|
|
289401
289499
|
];
|
|
289402
|
-
this.enqueueLogEvent(this.
|
|
289500
|
+
this.enqueueLogEvent(this.createBasicLogEvent(EventNames.EXTENSION_DISABLE, data));
|
|
289403
289501
|
this.flushToClearcut().catch((error) => {
|
|
289404
289502
|
debugLogger.debug("Error flushing to Clearcut:", error);
|
|
289405
289503
|
});
|
|
@@ -289479,7 +289577,6 @@ var ClearcutLogger = class _ClearcutLogger {
|
|
|
289479
289577
|
* should exist on all log events.
|
|
289480
289578
|
*/
|
|
289481
289579
|
addDefaultFields(data, totalAccounts) {
|
|
289482
|
-
const surface = determineSurface();
|
|
289483
289580
|
const defaultLogMetadata = [
|
|
289484
289581
|
{
|
|
289485
289582
|
gemini_cli_key: EventMetadataKey.GEMINI_CLI_SESSION_ID,
|
|
@@ -289493,26 +289590,10 @@ var ClearcutLogger = class _ClearcutLogger {
|
|
|
289493
289590
|
gemini_cli_key: EventMetadataKey.GEMINI_CLI_GOOGLE_ACCOUNTS_COUNT,
|
|
289494
289591
|
value: `${totalAccounts}`
|
|
289495
289592
|
},
|
|
289496
|
-
{
|
|
289497
|
-
gemini_cli_key: EventMetadataKey.GEMINI_CLI_SURFACE,
|
|
289498
|
-
value: surface
|
|
289499
|
-
},
|
|
289500
|
-
{
|
|
289501
|
-
gemini_cli_key: EventMetadataKey.GEMINI_CLI_VERSION,
|
|
289502
|
-
value: CLI_VERSION
|
|
289503
|
-
},
|
|
289504
|
-
{
|
|
289505
|
-
gemini_cli_key: EventMetadataKey.GEMINI_CLI_GIT_COMMIT_HASH,
|
|
289506
|
-
value: GIT_COMMIT_INFO
|
|
289507
|
-
},
|
|
289508
289593
|
{
|
|
289509
289594
|
gemini_cli_key: EventMetadataKey.GEMINI_CLI_PROMPT_ID,
|
|
289510
289595
|
value: this.promptId
|
|
289511
289596
|
},
|
|
289512
|
-
{
|
|
289513
|
-
gemini_cli_key: EventMetadataKey.GEMINI_CLI_OS,
|
|
289514
|
-
value: process.platform
|
|
289515
|
-
},
|
|
289516
289597
|
{
|
|
289517
289598
|
gemini_cli_key: EventMetadataKey.GEMINI_CLI_NODE_VERSION,
|
|
289518
289599
|
value: process.versions.node
|
|
@@ -289722,7 +289803,7 @@ var GcpLogExporter = class {
|
|
|
289722
289803
|
};
|
|
289723
289804
|
|
|
289724
289805
|
// packages/core/dist/src/telemetry/uiTelemetry.js
|
|
289725
|
-
import { EventEmitter as
|
|
289806
|
+
import { EventEmitter as EventEmitter5 } from "node:events";
|
|
289726
289807
|
var createInitialModelMetrics = () => ({
|
|
289727
289808
|
api: {
|
|
289728
289809
|
totalRequests: 0,
|
|
@@ -289758,7 +289839,7 @@ var createInitialMetrics = () => ({
|
|
|
289758
289839
|
totalLinesRemoved: 0
|
|
289759
289840
|
}
|
|
289760
289841
|
});
|
|
289761
|
-
var UiTelemetryService = class extends
|
|
289842
|
+
var UiTelemetryService = class extends EventEmitter5 {
|
|
289762
289843
|
#metrics = createInitialMetrics();
|
|
289763
289844
|
#lastPromptTokenCount = 0;
|
|
289764
289845
|
addEvent(event) {
|
|
@@ -290522,17 +290603,6 @@ async function shutdownTelemetry(config2) {
|
|
|
290522
290603
|
}
|
|
290523
290604
|
|
|
290524
290605
|
// packages/core/dist/src/telemetry/loggers.js
|
|
290525
|
-
function logCliConfiguration(config2, event) {
|
|
290526
|
-
ClearcutLogger.getInstance(config2)?.logStartSessionEvent(event);
|
|
290527
|
-
if (!isTelemetrySdkInitialized())
|
|
290528
|
-
return;
|
|
290529
|
-
const logger6 = import_api_logs.logs.getLogger(SERVICE_NAME);
|
|
290530
|
-
const logRecord = {
|
|
290531
|
-
body: event.toLogBody(),
|
|
290532
|
-
attributes: event.toOpenTelemetryAttributes(config2)
|
|
290533
|
-
};
|
|
290534
|
-
logger6.emit(logRecord);
|
|
290535
|
-
}
|
|
290536
290606
|
function logToolCall(config2, event) {
|
|
290537
290607
|
const uiEvent = {
|
|
290538
290608
|
...event,
|
|
@@ -290849,43 +290919,6 @@ function isApiError(error) {
|
|
|
290849
290919
|
function isStructuredError(error) {
|
|
290850
290920
|
return typeof error === "object" && error !== null && "message" in error && typeof error.message === "string";
|
|
290851
290921
|
}
|
|
290852
|
-
function isProQuotaExceededError(error) {
|
|
290853
|
-
const checkMessage = (message) => message.includes("Quota exceeded for quota metric 'Gemini") && message.includes("Pro Requests'");
|
|
290854
|
-
if (typeof error === "string") {
|
|
290855
|
-
return checkMessage(error);
|
|
290856
|
-
}
|
|
290857
|
-
if (isStructuredError(error)) {
|
|
290858
|
-
return checkMessage(error.message);
|
|
290859
|
-
}
|
|
290860
|
-
if (isApiError(error)) {
|
|
290861
|
-
return checkMessage(error.error.message);
|
|
290862
|
-
}
|
|
290863
|
-
if (error && typeof error === "object" && "response" in error) {
|
|
290864
|
-
const gaxiosError = error;
|
|
290865
|
-
if (gaxiosError.response && gaxiosError.response.data) {
|
|
290866
|
-
if (typeof gaxiosError.response.data === "string") {
|
|
290867
|
-
return checkMessage(gaxiosError.response.data);
|
|
290868
|
-
}
|
|
290869
|
-
if (typeof gaxiosError.response.data === "object" && gaxiosError.response.data !== null && "error" in gaxiosError.response.data) {
|
|
290870
|
-
const errorData = gaxiosError.response.data;
|
|
290871
|
-
return checkMessage(errorData.error?.message || "");
|
|
290872
|
-
}
|
|
290873
|
-
}
|
|
290874
|
-
}
|
|
290875
|
-
return false;
|
|
290876
|
-
}
|
|
290877
|
-
function isGenericQuotaExceededError(error) {
|
|
290878
|
-
if (typeof error === "string") {
|
|
290879
|
-
return error.includes("Quota exceeded for quota metric");
|
|
290880
|
-
}
|
|
290881
|
-
if (isStructuredError(error)) {
|
|
290882
|
-
return error.message.includes("Quota exceeded for quota metric");
|
|
290883
|
-
}
|
|
290884
|
-
if (isApiError(error)) {
|
|
290885
|
-
return error.error.message.includes("Quota exceeded for quota metric");
|
|
290886
|
-
}
|
|
290887
|
-
return false;
|
|
290888
|
-
}
|
|
290889
290922
|
|
|
290890
290923
|
// packages/core/dist/src/core/loggingContentGenerator.js
|
|
290891
290924
|
var LoggingContentGenerator = class {
|
|
@@ -290974,6 +291007,58 @@ async function createCodeAssistContentGenerator(httpOptions, authType, config2,
|
|
|
290974
291007
|
throw new Error(`Unsupported authType: ${authType}`);
|
|
290975
291008
|
}
|
|
290976
291009
|
|
|
291010
|
+
// packages/core/dist/src/core/fakeContentGenerator.js
|
|
291011
|
+
import { promises } from "node:fs";
|
|
291012
|
+
var FakeContentGenerator = class _FakeContentGenerator {
|
|
291013
|
+
responses;
|
|
291014
|
+
callCounters = {
|
|
291015
|
+
generateContent: 0,
|
|
291016
|
+
generateContentStream: 0,
|
|
291017
|
+
countTokens: 0,
|
|
291018
|
+
embedContent: 0
|
|
291019
|
+
};
|
|
291020
|
+
userTier;
|
|
291021
|
+
constructor(responses) {
|
|
291022
|
+
this.responses = {
|
|
291023
|
+
generateContent: responses.generateContent ?? [],
|
|
291024
|
+
generateContentStream: responses.generateContentStream ?? [],
|
|
291025
|
+
countTokens: responses.countTokens ?? [],
|
|
291026
|
+
embedContent: responses.embedContent ?? []
|
|
291027
|
+
};
|
|
291028
|
+
}
|
|
291029
|
+
static async fromFile(filePath) {
|
|
291030
|
+
const fileContent = await promises.readFile(filePath, "utf-8");
|
|
291031
|
+
const responses = JSON.parse(fileContent);
|
|
291032
|
+
return new _FakeContentGenerator(responses);
|
|
291033
|
+
}
|
|
291034
|
+
getNextResponse(method, request3) {
|
|
291035
|
+
const response = this.responses[method][this.callCounters[method]++];
|
|
291036
|
+
if (!response) {
|
|
291037
|
+
throw new Error(`No more mock responses for ${method}, got request:
|
|
291038
|
+
` + safeJsonStringify(request3));
|
|
291039
|
+
}
|
|
291040
|
+
return response;
|
|
291041
|
+
}
|
|
291042
|
+
async generateContent(_request, _userPromptId) {
|
|
291043
|
+
return this.getNextResponse("generateContent", _request);
|
|
291044
|
+
}
|
|
291045
|
+
async generateContentStream(_request, _userPromptId) {
|
|
291046
|
+
const responses = this.getNextResponse("generateContentStream", _request);
|
|
291047
|
+
async function* stream3() {
|
|
291048
|
+
for (const response of responses) {
|
|
291049
|
+
yield response;
|
|
291050
|
+
}
|
|
291051
|
+
}
|
|
291052
|
+
return stream3();
|
|
291053
|
+
}
|
|
291054
|
+
async countTokens(_request) {
|
|
291055
|
+
return this.getNextResponse("countTokens", _request);
|
|
291056
|
+
}
|
|
291057
|
+
async embedContent(_request) {
|
|
291058
|
+
return this.getNextResponse("embedContent", _request);
|
|
291059
|
+
}
|
|
291060
|
+
};
|
|
291061
|
+
|
|
290977
291062
|
// packages/core/dist/src/core/contentGenerator.js
|
|
290978
291063
|
var AuthType2;
|
|
290979
291064
|
(function(AuthType3) {
|
|
@@ -291007,7 +291092,10 @@ function createContentGeneratorConfig(config2, authType) {
|
|
|
291007
291092
|
return contentGeneratorConfig;
|
|
291008
291093
|
}
|
|
291009
291094
|
async function createContentGenerator(config2, gcConfig, sessionId2) {
|
|
291010
|
-
|
|
291095
|
+
if (gcConfig.fakeResponses) {
|
|
291096
|
+
return FakeContentGenerator.fromFile(gcConfig.fakeResponses);
|
|
291097
|
+
}
|
|
291098
|
+
const version3 = "0.12.0-nightly.20251027.cb0947c5";
|
|
291011
291099
|
const userAgent = `GeminiCLI/${version3} (${process.platform}; ${process.arch})`;
|
|
291012
291100
|
const baseHeaders = {
|
|
291013
291101
|
"User-Agent": userAgent
|
|
@@ -298309,10 +298397,242 @@ var import_shell_quote = __toESM(require_shell_quote(), 1);
|
|
|
298309
298397
|
|
|
298310
298398
|
// packages/core/dist/src/mcp/google-auth-provider.js
|
|
298311
298399
|
var import_google_auth_library9 = __toESM(require_src10(), 1);
|
|
298400
|
+
|
|
298401
|
+
// packages/core/dist/src/mcp/oauth-utils.js
|
|
298402
|
+
var FIVE_MIN_BUFFER_MS = 5 * 60 * 1e3;
|
|
298403
|
+
var OAuthUtils = class {
|
|
298404
|
+
/**
|
|
298405
|
+
* Construct well-known OAuth endpoint URLs.
|
|
298406
|
+
* By default, uses standard root-based well-known URLs.
|
|
298407
|
+
* If includePathSuffix is true, appends any path from the base URL to the well-known endpoints.
|
|
298408
|
+
*/
|
|
298409
|
+
static buildWellKnownUrls(baseUrl, includePathSuffix = false) {
|
|
298410
|
+
const serverUrl = new URL(baseUrl);
|
|
298411
|
+
const base = `${serverUrl.protocol}//${serverUrl.host}`;
|
|
298412
|
+
if (!includePathSuffix) {
|
|
298413
|
+
return {
|
|
298414
|
+
protectedResource: new URL("/.well-known/oauth-protected-resource", base).toString(),
|
|
298415
|
+
authorizationServer: new URL("/.well-known/oauth-authorization-server", base).toString()
|
|
298416
|
+
};
|
|
298417
|
+
}
|
|
298418
|
+
const pathSuffix = serverUrl.pathname.replace(/\/$/, "");
|
|
298419
|
+
return {
|
|
298420
|
+
protectedResource: new URL(`/.well-known/oauth-protected-resource${pathSuffix}`, base).toString(),
|
|
298421
|
+
authorizationServer: new URL(`/.well-known/oauth-authorization-server${pathSuffix}`, base).toString()
|
|
298422
|
+
};
|
|
298423
|
+
}
|
|
298424
|
+
/**
|
|
298425
|
+
* Fetch OAuth protected resource metadata.
|
|
298426
|
+
*
|
|
298427
|
+
* @param resourceMetadataUrl The protected resource metadata URL
|
|
298428
|
+
* @returns The protected resource metadata or null if not available
|
|
298429
|
+
*/
|
|
298430
|
+
static async fetchProtectedResourceMetadata(resourceMetadataUrl) {
|
|
298431
|
+
try {
|
|
298432
|
+
const response = await fetch(resourceMetadataUrl);
|
|
298433
|
+
if (!response.ok) {
|
|
298434
|
+
return null;
|
|
298435
|
+
}
|
|
298436
|
+
return await response.json();
|
|
298437
|
+
} catch (error) {
|
|
298438
|
+
debugLogger.debug(`Failed to fetch protected resource metadata from ${resourceMetadataUrl}: ${getErrorMessage(error)}`);
|
|
298439
|
+
return null;
|
|
298440
|
+
}
|
|
298441
|
+
}
|
|
298442
|
+
/**
|
|
298443
|
+
* Fetch OAuth authorization server metadata.
|
|
298444
|
+
*
|
|
298445
|
+
* @param authServerMetadataUrl The authorization server metadata URL
|
|
298446
|
+
* @returns The authorization server metadata or null if not available
|
|
298447
|
+
*/
|
|
298448
|
+
static async fetchAuthorizationServerMetadata(authServerMetadataUrl) {
|
|
298449
|
+
try {
|
|
298450
|
+
const response = await fetch(authServerMetadataUrl);
|
|
298451
|
+
if (!response.ok) {
|
|
298452
|
+
return null;
|
|
298453
|
+
}
|
|
298454
|
+
return await response.json();
|
|
298455
|
+
} catch (error) {
|
|
298456
|
+
debugLogger.debug(`Failed to fetch authorization server metadata from ${authServerMetadataUrl}: ${getErrorMessage(error)}`);
|
|
298457
|
+
return null;
|
|
298458
|
+
}
|
|
298459
|
+
}
|
|
298460
|
+
/**
|
|
298461
|
+
* Convert authorization server metadata to OAuth configuration.
|
|
298462
|
+
*
|
|
298463
|
+
* @param metadata The authorization server metadata
|
|
298464
|
+
* @returns The OAuth configuration
|
|
298465
|
+
*/
|
|
298466
|
+
static metadataToOAuthConfig(metadata2) {
|
|
298467
|
+
return {
|
|
298468
|
+
authorizationUrl: metadata2.authorization_endpoint,
|
|
298469
|
+
tokenUrl: metadata2.token_endpoint,
|
|
298470
|
+
scopes: metadata2.scopes_supported || [],
|
|
298471
|
+
registrationUrl: metadata2.registration_endpoint
|
|
298472
|
+
};
|
|
298473
|
+
}
|
|
298474
|
+
/**
|
|
298475
|
+
* Discover Oauth Authorization server metadata given an Auth server URL, by
|
|
298476
|
+
* trying the standard well-known endpoints.
|
|
298477
|
+
*
|
|
298478
|
+
* @param authServerUrl The authorization server URL
|
|
298479
|
+
* @returns The authorization server metadata or null if not found
|
|
298480
|
+
*/
|
|
298481
|
+
static async discoverAuthorizationServerMetadata(authServerUrl) {
|
|
298482
|
+
const authServerUrlObj = new URL(authServerUrl);
|
|
298483
|
+
const base = `${authServerUrlObj.protocol}//${authServerUrlObj.host}`;
|
|
298484
|
+
const endpointsToTry = [];
|
|
298485
|
+
if (authServerUrlObj.pathname !== "/") {
|
|
298486
|
+
endpointsToTry.push(new URL(`/.well-known/oauth-authorization-server${authServerUrlObj.pathname}`, base).toString());
|
|
298487
|
+
endpointsToTry.push(new URL(`/.well-known/openid-configuration${authServerUrlObj.pathname}`, base).toString());
|
|
298488
|
+
endpointsToTry.push(new URL(`${authServerUrlObj.pathname}/.well-known/openid-configuration`, base).toString());
|
|
298489
|
+
}
|
|
298490
|
+
endpointsToTry.push(new URL("/.well-known/oauth-authorization-server", base).toString());
|
|
298491
|
+
endpointsToTry.push(new URL("/.well-known/openid-configuration", base).toString());
|
|
298492
|
+
for (const endpoint of endpointsToTry) {
|
|
298493
|
+
const authServerMetadata = await this.fetchAuthorizationServerMetadata(endpoint);
|
|
298494
|
+
if (authServerMetadata) {
|
|
298495
|
+
return authServerMetadata;
|
|
298496
|
+
}
|
|
298497
|
+
}
|
|
298498
|
+
debugLogger.debug(`Metadata discovery failed for authorization server ${authServerUrl}`);
|
|
298499
|
+
return null;
|
|
298500
|
+
}
|
|
298501
|
+
/**
|
|
298502
|
+
* Discover OAuth configuration using the standard well-known endpoints.
|
|
298503
|
+
*
|
|
298504
|
+
* @param serverUrl The base URL of the server
|
|
298505
|
+
* @returns The discovered OAuth configuration or null if not available
|
|
298506
|
+
*/
|
|
298507
|
+
static async discoverOAuthConfig(serverUrl) {
|
|
298508
|
+
try {
|
|
298509
|
+
const wellKnownUrls = this.buildWellKnownUrls(serverUrl, false);
|
|
298510
|
+
let resourceMetadata = await this.fetchProtectedResourceMetadata(wellKnownUrls.protectedResource);
|
|
298511
|
+
if (!resourceMetadata) {
|
|
298512
|
+
const url4 = new URL(serverUrl);
|
|
298513
|
+
if (url4.pathname && url4.pathname !== "/") {
|
|
298514
|
+
const pathBasedUrls = this.buildWellKnownUrls(serverUrl, true);
|
|
298515
|
+
resourceMetadata = await this.fetchProtectedResourceMetadata(pathBasedUrls.protectedResource);
|
|
298516
|
+
}
|
|
298517
|
+
}
|
|
298518
|
+
if (resourceMetadata?.authorization_servers?.length) {
|
|
298519
|
+
const authServerUrl = resourceMetadata.authorization_servers[0];
|
|
298520
|
+
const authServerMetadata2 = await this.discoverAuthorizationServerMetadata(authServerUrl);
|
|
298521
|
+
if (authServerMetadata2) {
|
|
298522
|
+
const config2 = this.metadataToOAuthConfig(authServerMetadata2);
|
|
298523
|
+
if (authServerMetadata2.registration_endpoint) {
|
|
298524
|
+
debugLogger.log("Dynamic client registration is supported at:", authServerMetadata2.registration_endpoint);
|
|
298525
|
+
}
|
|
298526
|
+
return config2;
|
|
298527
|
+
}
|
|
298528
|
+
}
|
|
298529
|
+
debugLogger.debug(`Trying OAuth discovery fallback at ${serverUrl}`);
|
|
298530
|
+
const authServerMetadata = await this.discoverAuthorizationServerMetadata(serverUrl);
|
|
298531
|
+
if (authServerMetadata) {
|
|
298532
|
+
const config2 = this.metadataToOAuthConfig(authServerMetadata);
|
|
298533
|
+
if (authServerMetadata.registration_endpoint) {
|
|
298534
|
+
debugLogger.log("Dynamic client registration is supported at:", authServerMetadata.registration_endpoint);
|
|
298535
|
+
}
|
|
298536
|
+
return config2;
|
|
298537
|
+
}
|
|
298538
|
+
return null;
|
|
298539
|
+
} catch (error) {
|
|
298540
|
+
debugLogger.debug(`Failed to discover OAuth configuration: ${getErrorMessage(error)}`);
|
|
298541
|
+
return null;
|
|
298542
|
+
}
|
|
298543
|
+
}
|
|
298544
|
+
/**
|
|
298545
|
+
* Parse WWW-Authenticate header to extract OAuth information.
|
|
298546
|
+
*
|
|
298547
|
+
* @param header The WWW-Authenticate header value
|
|
298548
|
+
* @returns The resource metadata URI if found
|
|
298549
|
+
*/
|
|
298550
|
+
static parseWWWAuthenticateHeader(header) {
|
|
298551
|
+
const match2 = header.match(/resource_metadata="([^"]+)"/);
|
|
298552
|
+
if (match2) {
|
|
298553
|
+
return match2[1];
|
|
298554
|
+
}
|
|
298555
|
+
return null;
|
|
298556
|
+
}
|
|
298557
|
+
/**
|
|
298558
|
+
* Discover OAuth configuration from WWW-Authenticate header.
|
|
298559
|
+
*
|
|
298560
|
+
* @param wwwAuthenticate The WWW-Authenticate header value
|
|
298561
|
+
* @returns The discovered OAuth configuration or null if not available
|
|
298562
|
+
*/
|
|
298563
|
+
static async discoverOAuthFromWWWAuthenticate(wwwAuthenticate) {
|
|
298564
|
+
const resourceMetadataUri = this.parseWWWAuthenticateHeader(wwwAuthenticate);
|
|
298565
|
+
if (!resourceMetadataUri) {
|
|
298566
|
+
return null;
|
|
298567
|
+
}
|
|
298568
|
+
const resourceMetadata = await this.fetchProtectedResourceMetadata(resourceMetadataUri);
|
|
298569
|
+
if (!resourceMetadata?.authorization_servers?.length) {
|
|
298570
|
+
return null;
|
|
298571
|
+
}
|
|
298572
|
+
const authServerUrl = resourceMetadata.authorization_servers[0];
|
|
298573
|
+
const authServerMetadata = await this.discoverAuthorizationServerMetadata(authServerUrl);
|
|
298574
|
+
if (authServerMetadata) {
|
|
298575
|
+
return this.metadataToOAuthConfig(authServerMetadata);
|
|
298576
|
+
}
|
|
298577
|
+
return null;
|
|
298578
|
+
}
|
|
298579
|
+
/**
|
|
298580
|
+
* Extract base URL from an MCP server URL.
|
|
298581
|
+
*
|
|
298582
|
+
* @param mcpServerUrl The MCP server URL
|
|
298583
|
+
* @returns The base URL
|
|
298584
|
+
*/
|
|
298585
|
+
static extractBaseUrl(mcpServerUrl) {
|
|
298586
|
+
const serverUrl = new URL(mcpServerUrl);
|
|
298587
|
+
return `${serverUrl.protocol}//${serverUrl.host}`;
|
|
298588
|
+
}
|
|
298589
|
+
/**
|
|
298590
|
+
* Check if a URL is an SSE endpoint.
|
|
298591
|
+
*
|
|
298592
|
+
* @param url The URL to check
|
|
298593
|
+
* @returns True if the URL appears to be an SSE endpoint
|
|
298594
|
+
*/
|
|
298595
|
+
static isSSEEndpoint(url4) {
|
|
298596
|
+
return url4.includes("/sse") || !url4.includes("/mcp");
|
|
298597
|
+
}
|
|
298598
|
+
/**
|
|
298599
|
+
* Build a resource parameter for OAuth requests.
|
|
298600
|
+
*
|
|
298601
|
+
* @param endpointUrl The endpoint URL
|
|
298602
|
+
* @returns The resource parameter value
|
|
298603
|
+
*/
|
|
298604
|
+
static buildResourceParameter(endpointUrl) {
|
|
298605
|
+
const url4 = new URL(endpointUrl);
|
|
298606
|
+
return `${url4.protocol}//${url4.host}${url4.pathname}`;
|
|
298607
|
+
}
|
|
298608
|
+
/**
|
|
298609
|
+
* Parses a JWT string to extract its expiry time.
|
|
298610
|
+
* @param idToken The JWT ID token.
|
|
298611
|
+
* @returns The expiry time in **milliseconds**, or undefined if parsing fails.
|
|
298612
|
+
*/
|
|
298613
|
+
static parseTokenExpiry(idToken) {
|
|
298614
|
+
try {
|
|
298615
|
+
const payload = JSON.parse(Buffer.from(idToken.split(".")[1], "base64").toString());
|
|
298616
|
+
if (payload && typeof payload.exp === "number") {
|
|
298617
|
+
return payload.exp * 1e3;
|
|
298618
|
+
}
|
|
298619
|
+
} catch (e2) {
|
|
298620
|
+
console.error("Failed to parse ID token for expiry time with error:", e2);
|
|
298621
|
+
}
|
|
298622
|
+
return void 0;
|
|
298623
|
+
}
|
|
298624
|
+
};
|
|
298625
|
+
|
|
298626
|
+
// packages/core/dist/src/mcp/google-auth-provider.js
|
|
298627
|
+
var CLOUD_RUN_HOST_REGEX = /^(.*\.)?run\.app$/;
|
|
298312
298628
|
var ALLOWED_HOSTS = [/^.+\.googleapis\.com$/, /^(.*\.)?luci\.app$/];
|
|
298313
298629
|
var GoogleCredentialProvider = class {
|
|
298314
298630
|
config;
|
|
298315
298631
|
auth;
|
|
298632
|
+
useIdToken = false;
|
|
298633
|
+
audience;
|
|
298634
|
+
cachedToken;
|
|
298635
|
+
tokenExpiryTime;
|
|
298316
298636
|
// Properties required by OAuthClientProvider, with no-op values
|
|
298317
298637
|
redirectUrl = "";
|
|
298318
298638
|
clientMetadata = {
|
|
@@ -298330,15 +298650,22 @@ var GoogleCredentialProvider = class {
|
|
|
298330
298650
|
throw new Error("URL must be provided in the config for Google Credentials provider");
|
|
298331
298651
|
}
|
|
298332
298652
|
const hostname2 = new URL(url4).hostname;
|
|
298333
|
-
|
|
298653
|
+
const isRunAppHost = CLOUD_RUN_HOST_REGEX.test(hostname2);
|
|
298654
|
+
if (!this.config?.allow_unscoped_id_tokens_cloud_run && isRunAppHost) {
|
|
298655
|
+
throw new Error(`To enable the Cloud Run MCP Server at ${url4} please set allow_unscoped_id_tokens_cloud_run:true in the MCP Server config.`);
|
|
298656
|
+
}
|
|
298657
|
+
if (this.config?.allow_unscoped_id_tokens_cloud_run && isRunAppHost) {
|
|
298658
|
+
this.useIdToken = true;
|
|
298659
|
+
}
|
|
298660
|
+
this.audience = hostname2;
|
|
298661
|
+
if (!this.useIdToken && !ALLOWED_HOSTS.some((pattern) => pattern.test(hostname2))) {
|
|
298334
298662
|
throw new Error(`Host "${hostname2}" is not an allowed host for Google Credential provider.`);
|
|
298335
298663
|
}
|
|
298336
|
-
|
|
298337
|
-
|
|
298338
|
-
throw new Error("Scopes must be provided in the oauth config for Google Credentials provider");
|
|
298664
|
+
if (!this.useIdToken && !this.config?.oauth?.scopes) {
|
|
298665
|
+
throw new Error("Scopes must be provided in the oauth config for Google Credentials provider (or enable allow_unscoped_id_tokens_for_cloud_run to use ID tokens for Cloud Run endpoints)");
|
|
298339
298666
|
}
|
|
298340
298667
|
this.auth = new import_google_auth_library9.GoogleAuth({
|
|
298341
|
-
scopes
|
|
298668
|
+
scopes: this.config?.oauth?.scopes
|
|
298342
298669
|
});
|
|
298343
298670
|
}
|
|
298344
298671
|
clientInformation() {
|
|
@@ -298348,17 +298675,46 @@ var GoogleCredentialProvider = class {
|
|
|
298348
298675
|
this._clientInformation = clientInformation;
|
|
298349
298676
|
}
|
|
298350
298677
|
async tokens() {
|
|
298678
|
+
if (this.cachedToken && this.tokenExpiryTime && Date.now() < this.tokenExpiryTime - FIVE_MIN_BUFFER_MS) {
|
|
298679
|
+
return this.cachedToken;
|
|
298680
|
+
}
|
|
298681
|
+
this.cachedToken = void 0;
|
|
298682
|
+
this.tokenExpiryTime = void 0;
|
|
298683
|
+
if (this.useIdToken) {
|
|
298684
|
+
try {
|
|
298685
|
+
const idClient = await this.auth.getIdTokenClient(this.audience);
|
|
298686
|
+
const idToken = await idClient.idTokenProvider.fetchIdToken(this.audience);
|
|
298687
|
+
const newToken2 = {
|
|
298688
|
+
access_token: idToken,
|
|
298689
|
+
token_type: "Bearer"
|
|
298690
|
+
};
|
|
298691
|
+
const expiryTime2 = OAuthUtils.parseTokenExpiry(idToken);
|
|
298692
|
+
if (expiryTime2) {
|
|
298693
|
+
this.tokenExpiryTime = expiryTime2;
|
|
298694
|
+
this.cachedToken = newToken2;
|
|
298695
|
+
}
|
|
298696
|
+
return newToken2;
|
|
298697
|
+
} catch (e2) {
|
|
298698
|
+
console.error("Failed to get ID token from Google ADC", e2);
|
|
298699
|
+
return void 0;
|
|
298700
|
+
}
|
|
298701
|
+
}
|
|
298351
298702
|
const client = await this.auth.getClient();
|
|
298352
298703
|
const accessTokenResponse = await client.getAccessToken();
|
|
298353
298704
|
if (!accessTokenResponse.token) {
|
|
298354
298705
|
console.error("Failed to get access token from Google ADC");
|
|
298355
298706
|
return void 0;
|
|
298356
298707
|
}
|
|
298357
|
-
const
|
|
298708
|
+
const newToken = {
|
|
298358
298709
|
access_token: accessTokenResponse.token,
|
|
298359
298710
|
token_type: "Bearer"
|
|
298360
298711
|
};
|
|
298361
|
-
|
|
298712
|
+
const expiryTime = client.credentials?.expiry_date;
|
|
298713
|
+
if (expiryTime) {
|
|
298714
|
+
this.tokenExpiryTime = expiryTime;
|
|
298715
|
+
this.cachedToken = newToken;
|
|
298716
|
+
}
|
|
298717
|
+
return newToken;
|
|
298362
298718
|
}
|
|
298363
298719
|
saveTokens(_tokens) {
|
|
298364
298720
|
}
|
|
@@ -298373,7 +298729,6 @@ var GoogleCredentialProvider = class {
|
|
|
298373
298729
|
|
|
298374
298730
|
// packages/core/dist/src/mcp/sa-impersonation-provider.js
|
|
298375
298731
|
var import_google_auth_library10 = __toESM(require_src10(), 1);
|
|
298376
|
-
var fiveMinBufferMs = 5 * 60 * 1e3;
|
|
298377
298732
|
function createIamApiUrl(targetSA) {
|
|
298378
298733
|
return `https://iamcredentials.googleapis.com/v1/projects/-/serviceAccounts/${encodeURIComponent(targetSA)}:generateIdToken`;
|
|
298379
298734
|
}
|
|
@@ -298417,7 +298772,7 @@ var ServiceAccountImpersonationProvider = class {
|
|
|
298417
298772
|
this._clientInformation = clientInformation;
|
|
298418
298773
|
}
|
|
298419
298774
|
async tokens() {
|
|
298420
|
-
if (this.cachedToken && this.tokenExpiryTime && Date.now() < this.tokenExpiryTime -
|
|
298775
|
+
if (this.cachedToken && this.tokenExpiryTime && Date.now() < this.tokenExpiryTime - FIVE_MIN_BUFFER_MS) {
|
|
298421
298776
|
return this.cachedToken;
|
|
298422
298777
|
}
|
|
298423
298778
|
this.cachedToken = void 0;
|
|
@@ -298443,7 +298798,7 @@ var ServiceAccountImpersonationProvider = class {
|
|
|
298443
298798
|
console.error("Failed to fetch ID token from Google:", e2);
|
|
298444
298799
|
return void 0;
|
|
298445
298800
|
}
|
|
298446
|
-
const expiryTime =
|
|
298801
|
+
const expiryTime = OAuthUtils.parseTokenExpiry(idToken);
|
|
298447
298802
|
const newTokens = {
|
|
298448
298803
|
access_token: idToken,
|
|
298449
298804
|
token_type: "Bearer"
|
|
@@ -298463,22 +298818,6 @@ var ServiceAccountImpersonationProvider = class {
|
|
|
298463
298818
|
codeVerifier() {
|
|
298464
298819
|
return "";
|
|
298465
298820
|
}
|
|
298466
|
-
/**
|
|
298467
|
-
* Parses a JWT string to extract its expiry time.
|
|
298468
|
-
* @param idToken The JWT ID token.
|
|
298469
|
-
* @returns The expiry time in **milliseconds**, or undefined if parsing fails.
|
|
298470
|
-
*/
|
|
298471
|
-
parseTokenExpiry(idToken) {
|
|
298472
|
-
try {
|
|
298473
|
-
const payload = JSON.parse(Buffer.from(idToken.split(".")[1], "base64").toString());
|
|
298474
|
-
if (payload && typeof payload.exp === "number") {
|
|
298475
|
-
return payload.exp * 1e3;
|
|
298476
|
-
}
|
|
298477
|
-
} catch (e2) {
|
|
298478
|
-
console.error("Failed to parse ID token for expiry time with error:", e2);
|
|
298479
|
-
}
|
|
298480
|
-
return void 0;
|
|
298481
|
-
}
|
|
298482
298821
|
};
|
|
298483
298822
|
|
|
298484
298823
|
// packages/core/dist/src/tools/mcp-client.js
|
|
@@ -298615,7 +298954,7 @@ var MCPOAuthTokenStorage = class {
|
|
|
298615
298954
|
}
|
|
298616
298955
|
} catch (error) {
|
|
298617
298956
|
if (error.code !== "ENOENT") {
|
|
298618
|
-
|
|
298957
|
+
coreEvents.emitFeedback("error", `Failed to load MCP OAuth tokens: ${getErrorMessage(error)}`, error);
|
|
298619
298958
|
}
|
|
298620
298959
|
}
|
|
298621
298960
|
return tokenMap;
|
|
@@ -298638,7 +298977,7 @@ var MCPOAuthTokenStorage = class {
|
|
|
298638
298977
|
try {
|
|
298639
298978
|
await fs25.writeFile(tokenFile, JSON.stringify(tokenArray, null, 2), { mode: 384 });
|
|
298640
298979
|
} catch (error) {
|
|
298641
|
-
|
|
298980
|
+
coreEvents.emitFeedback("error", `Failed to save MCP OAuth token: ${getErrorMessage(error)}`, error);
|
|
298642
298981
|
throw error;
|
|
298643
298982
|
}
|
|
298644
298983
|
}
|
|
@@ -298701,7 +299040,7 @@ var MCPOAuthTokenStorage = class {
|
|
|
298701
299040
|
});
|
|
298702
299041
|
}
|
|
298703
299042
|
} catch (error) {
|
|
298704
|
-
|
|
299043
|
+
coreEvents.emitFeedback("error", `Failed to remove MCP OAuth token: ${getErrorMessage(error)}`, error);
|
|
298705
299044
|
}
|
|
298706
299045
|
}
|
|
298707
299046
|
}
|
|
@@ -298730,220 +299069,12 @@ var MCPOAuthTokenStorage = class {
|
|
|
298730
299069
|
await fs25.unlink(tokenFile);
|
|
298731
299070
|
} catch (error) {
|
|
298732
299071
|
if (error.code !== "ENOENT") {
|
|
298733
|
-
|
|
299072
|
+
coreEvents.emitFeedback("error", `Failed to clear MCP OAuth tokens: ${getErrorMessage(error)}`, error);
|
|
298734
299073
|
}
|
|
298735
299074
|
}
|
|
298736
299075
|
}
|
|
298737
299076
|
};
|
|
298738
299077
|
|
|
298739
|
-
// packages/core/dist/src/mcp/oauth-utils.js
|
|
298740
|
-
var OAuthUtils = class {
|
|
298741
|
-
/**
|
|
298742
|
-
* Construct well-known OAuth endpoint URLs.
|
|
298743
|
-
* By default, uses standard root-based well-known URLs.
|
|
298744
|
-
* If includePathSuffix is true, appends any path from the base URL to the well-known endpoints.
|
|
298745
|
-
*/
|
|
298746
|
-
static buildWellKnownUrls(baseUrl, includePathSuffix = false) {
|
|
298747
|
-
const serverUrl = new URL(baseUrl);
|
|
298748
|
-
const base = `${serverUrl.protocol}//${serverUrl.host}`;
|
|
298749
|
-
if (!includePathSuffix) {
|
|
298750
|
-
return {
|
|
298751
|
-
protectedResource: new URL("/.well-known/oauth-protected-resource", base).toString(),
|
|
298752
|
-
authorizationServer: new URL("/.well-known/oauth-authorization-server", base).toString()
|
|
298753
|
-
};
|
|
298754
|
-
}
|
|
298755
|
-
const pathSuffix = serverUrl.pathname.replace(/\/$/, "");
|
|
298756
|
-
return {
|
|
298757
|
-
protectedResource: new URL(`/.well-known/oauth-protected-resource${pathSuffix}`, base).toString(),
|
|
298758
|
-
authorizationServer: new URL(`/.well-known/oauth-authorization-server${pathSuffix}`, base).toString()
|
|
298759
|
-
};
|
|
298760
|
-
}
|
|
298761
|
-
/**
|
|
298762
|
-
* Fetch OAuth protected resource metadata.
|
|
298763
|
-
*
|
|
298764
|
-
* @param resourceMetadataUrl The protected resource metadata URL
|
|
298765
|
-
* @returns The protected resource metadata or null if not available
|
|
298766
|
-
*/
|
|
298767
|
-
static async fetchProtectedResourceMetadata(resourceMetadataUrl) {
|
|
298768
|
-
try {
|
|
298769
|
-
const response = await fetch(resourceMetadataUrl);
|
|
298770
|
-
if (!response.ok) {
|
|
298771
|
-
return null;
|
|
298772
|
-
}
|
|
298773
|
-
return await response.json();
|
|
298774
|
-
} catch (error) {
|
|
298775
|
-
debugLogger.debug(`Failed to fetch protected resource metadata from ${resourceMetadataUrl}: ${getErrorMessage(error)}`);
|
|
298776
|
-
return null;
|
|
298777
|
-
}
|
|
298778
|
-
}
|
|
298779
|
-
/**
|
|
298780
|
-
* Fetch OAuth authorization server metadata.
|
|
298781
|
-
*
|
|
298782
|
-
* @param authServerMetadataUrl The authorization server metadata URL
|
|
298783
|
-
* @returns The authorization server metadata or null if not available
|
|
298784
|
-
*/
|
|
298785
|
-
static async fetchAuthorizationServerMetadata(authServerMetadataUrl) {
|
|
298786
|
-
try {
|
|
298787
|
-
const response = await fetch(authServerMetadataUrl);
|
|
298788
|
-
if (!response.ok) {
|
|
298789
|
-
return null;
|
|
298790
|
-
}
|
|
298791
|
-
return await response.json();
|
|
298792
|
-
} catch (error) {
|
|
298793
|
-
debugLogger.debug(`Failed to fetch authorization server metadata from ${authServerMetadataUrl}: ${getErrorMessage(error)}`);
|
|
298794
|
-
return null;
|
|
298795
|
-
}
|
|
298796
|
-
}
|
|
298797
|
-
/**
|
|
298798
|
-
* Convert authorization server metadata to OAuth configuration.
|
|
298799
|
-
*
|
|
298800
|
-
* @param metadata The authorization server metadata
|
|
298801
|
-
* @returns The OAuth configuration
|
|
298802
|
-
*/
|
|
298803
|
-
static metadataToOAuthConfig(metadata2) {
|
|
298804
|
-
return {
|
|
298805
|
-
authorizationUrl: metadata2.authorization_endpoint,
|
|
298806
|
-
tokenUrl: metadata2.token_endpoint,
|
|
298807
|
-
scopes: metadata2.scopes_supported || [],
|
|
298808
|
-
registrationUrl: metadata2.registration_endpoint
|
|
298809
|
-
};
|
|
298810
|
-
}
|
|
298811
|
-
/**
|
|
298812
|
-
* Discover Oauth Authorization server metadata given an Auth server URL, by
|
|
298813
|
-
* trying the standard well-known endpoints.
|
|
298814
|
-
*
|
|
298815
|
-
* @param authServerUrl The authorization server URL
|
|
298816
|
-
* @returns The authorization server metadata or null if not found
|
|
298817
|
-
*/
|
|
298818
|
-
static async discoverAuthorizationServerMetadata(authServerUrl) {
|
|
298819
|
-
const authServerUrlObj = new URL(authServerUrl);
|
|
298820
|
-
const base = `${authServerUrlObj.protocol}//${authServerUrlObj.host}`;
|
|
298821
|
-
const endpointsToTry = [];
|
|
298822
|
-
if (authServerUrlObj.pathname !== "/") {
|
|
298823
|
-
endpointsToTry.push(new URL(`/.well-known/oauth-authorization-server${authServerUrlObj.pathname}`, base).toString());
|
|
298824
|
-
endpointsToTry.push(new URL(`/.well-known/openid-configuration${authServerUrlObj.pathname}`, base).toString());
|
|
298825
|
-
endpointsToTry.push(new URL(`${authServerUrlObj.pathname}/.well-known/openid-configuration`, base).toString());
|
|
298826
|
-
}
|
|
298827
|
-
endpointsToTry.push(new URL("/.well-known/oauth-authorization-server", base).toString());
|
|
298828
|
-
endpointsToTry.push(new URL("/.well-known/openid-configuration", base).toString());
|
|
298829
|
-
for (const endpoint of endpointsToTry) {
|
|
298830
|
-
const authServerMetadata = await this.fetchAuthorizationServerMetadata(endpoint);
|
|
298831
|
-
if (authServerMetadata) {
|
|
298832
|
-
return authServerMetadata;
|
|
298833
|
-
}
|
|
298834
|
-
}
|
|
298835
|
-
debugLogger.debug(`Metadata discovery failed for authorization server ${authServerUrl}`);
|
|
298836
|
-
return null;
|
|
298837
|
-
}
|
|
298838
|
-
/**
|
|
298839
|
-
* Discover OAuth configuration using the standard well-known endpoints.
|
|
298840
|
-
*
|
|
298841
|
-
* @param serverUrl The base URL of the server
|
|
298842
|
-
* @returns The discovered OAuth configuration or null if not available
|
|
298843
|
-
*/
|
|
298844
|
-
static async discoverOAuthConfig(serverUrl) {
|
|
298845
|
-
try {
|
|
298846
|
-
const wellKnownUrls = this.buildWellKnownUrls(serverUrl, false);
|
|
298847
|
-
let resourceMetadata = await this.fetchProtectedResourceMetadata(wellKnownUrls.protectedResource);
|
|
298848
|
-
if (!resourceMetadata) {
|
|
298849
|
-
const url4 = new URL(serverUrl);
|
|
298850
|
-
if (url4.pathname && url4.pathname !== "/") {
|
|
298851
|
-
const pathBasedUrls = this.buildWellKnownUrls(serverUrl, true);
|
|
298852
|
-
resourceMetadata = await this.fetchProtectedResourceMetadata(pathBasedUrls.protectedResource);
|
|
298853
|
-
}
|
|
298854
|
-
}
|
|
298855
|
-
if (resourceMetadata?.authorization_servers?.length) {
|
|
298856
|
-
const authServerUrl = resourceMetadata.authorization_servers[0];
|
|
298857
|
-
const authServerMetadata2 = await this.discoverAuthorizationServerMetadata(authServerUrl);
|
|
298858
|
-
if (authServerMetadata2) {
|
|
298859
|
-
const config2 = this.metadataToOAuthConfig(authServerMetadata2);
|
|
298860
|
-
if (authServerMetadata2.registration_endpoint) {
|
|
298861
|
-
debugLogger.log("Dynamic client registration is supported at:", authServerMetadata2.registration_endpoint);
|
|
298862
|
-
}
|
|
298863
|
-
return config2;
|
|
298864
|
-
}
|
|
298865
|
-
}
|
|
298866
|
-
debugLogger.debug(`Trying OAuth discovery fallback at ${serverUrl}`);
|
|
298867
|
-
const authServerMetadata = await this.discoverAuthorizationServerMetadata(serverUrl);
|
|
298868
|
-
if (authServerMetadata) {
|
|
298869
|
-
const config2 = this.metadataToOAuthConfig(authServerMetadata);
|
|
298870
|
-
if (authServerMetadata.registration_endpoint) {
|
|
298871
|
-
debugLogger.log("Dynamic client registration is supported at:", authServerMetadata.registration_endpoint);
|
|
298872
|
-
}
|
|
298873
|
-
return config2;
|
|
298874
|
-
}
|
|
298875
|
-
return null;
|
|
298876
|
-
} catch (error) {
|
|
298877
|
-
debugLogger.debug(`Failed to discover OAuth configuration: ${getErrorMessage(error)}`);
|
|
298878
|
-
return null;
|
|
298879
|
-
}
|
|
298880
|
-
}
|
|
298881
|
-
/**
|
|
298882
|
-
* Parse WWW-Authenticate header to extract OAuth information.
|
|
298883
|
-
*
|
|
298884
|
-
* @param header The WWW-Authenticate header value
|
|
298885
|
-
* @returns The resource metadata URI if found
|
|
298886
|
-
*/
|
|
298887
|
-
static parseWWWAuthenticateHeader(header) {
|
|
298888
|
-
const match2 = header.match(/resource_metadata="([^"]+)"/);
|
|
298889
|
-
if (match2) {
|
|
298890
|
-
return match2[1];
|
|
298891
|
-
}
|
|
298892
|
-
return null;
|
|
298893
|
-
}
|
|
298894
|
-
/**
|
|
298895
|
-
* Discover OAuth configuration from WWW-Authenticate header.
|
|
298896
|
-
*
|
|
298897
|
-
* @param wwwAuthenticate The WWW-Authenticate header value
|
|
298898
|
-
* @returns The discovered OAuth configuration or null if not available
|
|
298899
|
-
*/
|
|
298900
|
-
static async discoverOAuthFromWWWAuthenticate(wwwAuthenticate) {
|
|
298901
|
-
const resourceMetadataUri = this.parseWWWAuthenticateHeader(wwwAuthenticate);
|
|
298902
|
-
if (!resourceMetadataUri) {
|
|
298903
|
-
return null;
|
|
298904
|
-
}
|
|
298905
|
-
const resourceMetadata = await this.fetchProtectedResourceMetadata(resourceMetadataUri);
|
|
298906
|
-
if (!resourceMetadata?.authorization_servers?.length) {
|
|
298907
|
-
return null;
|
|
298908
|
-
}
|
|
298909
|
-
const authServerUrl = resourceMetadata.authorization_servers[0];
|
|
298910
|
-
const authServerMetadata = await this.discoverAuthorizationServerMetadata(authServerUrl);
|
|
298911
|
-
if (authServerMetadata) {
|
|
298912
|
-
return this.metadataToOAuthConfig(authServerMetadata);
|
|
298913
|
-
}
|
|
298914
|
-
return null;
|
|
298915
|
-
}
|
|
298916
|
-
/**
|
|
298917
|
-
* Extract base URL from an MCP server URL.
|
|
298918
|
-
*
|
|
298919
|
-
* @param mcpServerUrl The MCP server URL
|
|
298920
|
-
* @returns The base URL
|
|
298921
|
-
*/
|
|
298922
|
-
static extractBaseUrl(mcpServerUrl) {
|
|
298923
|
-
const serverUrl = new URL(mcpServerUrl);
|
|
298924
|
-
return `${serverUrl.protocol}//${serverUrl.host}`;
|
|
298925
|
-
}
|
|
298926
|
-
/**
|
|
298927
|
-
* Check if a URL is an SSE endpoint.
|
|
298928
|
-
*
|
|
298929
|
-
* @param url The URL to check
|
|
298930
|
-
* @returns True if the URL appears to be an SSE endpoint
|
|
298931
|
-
*/
|
|
298932
|
-
static isSSEEndpoint(url4) {
|
|
298933
|
-
return url4.includes("/sse") || !url4.includes("/mcp");
|
|
298934
|
-
}
|
|
298935
|
-
/**
|
|
298936
|
-
* Build a resource parameter for OAuth requests.
|
|
298937
|
-
*
|
|
298938
|
-
* @param endpointUrl The endpoint URL
|
|
298939
|
-
* @returns The resource parameter value
|
|
298940
|
-
*/
|
|
298941
|
-
static buildResourceParameter(endpointUrl) {
|
|
298942
|
-
const url4 = new URL(endpointUrl);
|
|
298943
|
-
return `${url4.protocol}//${url4.host}${url4.pathname}`;
|
|
298944
|
-
}
|
|
298945
|
-
};
|
|
298946
|
-
|
|
298947
299078
|
// packages/core/dist/src/mcp/oauth-provider.js
|
|
298948
299079
|
var OAUTH_DISPLAY_MESSAGE_EVENT = "oauth-display-message";
|
|
298949
299080
|
var REDIRECT_PORT = 7777;
|
|
@@ -299313,7 +299444,7 @@ var MCPOAuthProvider = class {
|
|
|
299313
299444
|
...config2,
|
|
299314
299445
|
authorizationUrl: discoveredConfig.authorizationUrl,
|
|
299315
299446
|
tokenUrl: discoveredConfig.tokenUrl,
|
|
299316
|
-
scopes:
|
|
299447
|
+
scopes: config2.scopes || discoveredConfig.scopes || [],
|
|
299317
299448
|
// Preserve existing client credentials
|
|
299318
299449
|
clientId: config2.clientId,
|
|
299319
299450
|
clientSecret: config2.clientSecret
|
|
@@ -299331,7 +299462,7 @@ var MCPOAuthProvider = class {
|
|
|
299331
299462
|
...config2,
|
|
299332
299463
|
authorizationUrl: discoveredConfig.authorizationUrl,
|
|
299333
299464
|
tokenUrl: discoveredConfig.tokenUrl,
|
|
299334
|
-
scopes:
|
|
299465
|
+
scopes: config2.scopes || discoveredConfig.scopes || [],
|
|
299335
299466
|
registrationUrl: discoveredConfig.registrationUrl,
|
|
299336
299467
|
// Preserve existing client credentials
|
|
299337
299468
|
clientId: config2.clientId,
|
|
@@ -300294,7 +300425,7 @@ Signal: Signal number or \`(none)\` if no signal was received.
|
|
|
300294
300425
|
this.description = description;
|
|
300295
300426
|
this.parameterSchema = parameterSchema;
|
|
300296
300427
|
}
|
|
300297
|
-
createInvocation(params) {
|
|
300428
|
+
createInvocation(params, _messageBus, _toolName, _displayName) {
|
|
300298
300429
|
return new DiscoveredToolInvocation(this.config, this.name, params);
|
|
300299
300430
|
}
|
|
300300
300431
|
};
|
|
@@ -300626,7 +300757,7 @@ var LSToolInvocation = class extends BaseToolInvocation {
|
|
|
300626
300757
|
}
|
|
300627
300758
|
const relativePaths = files.map((file) => path18.relative(this.config.getTargetDir(), path18.join(this.params.path, file)));
|
|
300628
300759
|
const fileDiscovery = this.config.getFileService();
|
|
300629
|
-
const { filteredPaths,
|
|
300760
|
+
const { filteredPaths, ignoredCount } = fileDiscovery.filterFilesWithReport(relativePaths, {
|
|
300630
300761
|
respectGitIgnore: this.params.file_filtering_options?.respect_git_ignore ?? this.config.getFileFilteringOptions().respectGitIgnore ?? DEFAULT_FILE_FILTERING_OPTIONS.respectGitIgnore,
|
|
300631
300762
|
respectGeminiIgnore: this.params.file_filtering_options?.respect_gemini_ignore ?? this.config.getFileFilteringOptions().respectGeminiIgnore ?? DEFAULT_FILE_FILTERING_OPTIONS.respectGeminiIgnore
|
|
300632
300763
|
});
|
|
@@ -300647,7 +300778,7 @@ var LSToolInvocation = class extends BaseToolInvocation {
|
|
|
300647
300778
|
modifiedTime: stats2.mtime
|
|
300648
300779
|
});
|
|
300649
300780
|
} catch (error) {
|
|
300650
|
-
|
|
300781
|
+
debugLogger.debug(`Error accessing ${fullPath}: ${error}`);
|
|
300651
300782
|
}
|
|
300652
300783
|
}
|
|
300653
300784
|
entries2.sort((a2, b) => {
|
|
@@ -300660,21 +300791,14 @@ var LSToolInvocation = class extends BaseToolInvocation {
|
|
|
300660
300791
|
const directoryContent = entries2.map((entry) => `${entry.isDirectory ? "[DIR] " : ""}${entry.name}`).join("\n");
|
|
300661
300792
|
let resultMessage = `Directory listing for ${this.params.path}:
|
|
300662
300793
|
${directoryContent}`;
|
|
300663
|
-
|
|
300664
|
-
if (gitIgnoredCount > 0) {
|
|
300665
|
-
ignoredMessages.push(`${gitIgnoredCount} git-ignored`);
|
|
300666
|
-
}
|
|
300667
|
-
if (geminiIgnoredCount > 0) {
|
|
300668
|
-
ignoredMessages.push(`${geminiIgnoredCount} gemini-ignored`);
|
|
300669
|
-
}
|
|
300670
|
-
if (ignoredMessages.length > 0) {
|
|
300794
|
+
if (ignoredCount > 0) {
|
|
300671
300795
|
resultMessage += `
|
|
300672
300796
|
|
|
300673
|
-
(${
|
|
300797
|
+
(${ignoredCount} ignored)`;
|
|
300674
300798
|
}
|
|
300675
300799
|
let displayMessage = `Listed ${entries2.length} item(s).`;
|
|
300676
|
-
if (
|
|
300677
|
-
displayMessage += ` (${
|
|
300800
|
+
if (ignoredCount > 0) {
|
|
300801
|
+
displayMessage += ` (${ignoredCount} ignored)`;
|
|
300678
300802
|
}
|
|
300679
300803
|
return {
|
|
300680
300804
|
llmContent: resultMessage,
|
|
@@ -300746,6 +300870,7 @@ var LSTool = class _LSTool extends BaseDeclarativeTool {
|
|
|
300746
300870
|
|
|
300747
300871
|
// packages/core/dist/src/tools/read-file.js
|
|
300748
300872
|
import path23 from "node:path";
|
|
300873
|
+
import process9 from "node:process";
|
|
300749
300874
|
|
|
300750
300875
|
// packages/core/dist/src/utils/fileUtils.js
|
|
300751
300876
|
import fs28 from "node:fs";
|
|
@@ -302094,8 +302219,7 @@ Do NOT use this tool:
|
|
|
302094
302219
|
|
|
302095
302220
|
## Parameters
|
|
302096
302221
|
|
|
302097
|
-
- \`fact\` (string, required): The specific fact or piece of information to remember. This should be a clear, self-contained statement. For example, if the user says "My favorite color is blue", the fact would be "My favorite color is blue"
|
|
302098
|
-
`;
|
|
302222
|
+
- \`fact\` (string, required): The specific fact or piece of information to remember. This should be a clear, self-contained statement. For example, if the user says "My favorite color is blue", the fact would be "My favorite color is blue".`;
|
|
302099
302223
|
var DEFAULT_CONTEXT_FILENAME = "GEMINI.md";
|
|
302100
302224
|
var MEMORY_SECTION_HEADER = "## Gemini Added Memories";
|
|
302101
302225
|
var currentGeminiMdFilename = DEFAULT_CONTEXT_FILENAME;
|
|
@@ -302170,11 +302294,14 @@ ${afterSectionMarker}`.trimEnd() + "\n";
|
|
|
302170
302294
|
}
|
|
302171
302295
|
var MemoryToolInvocation = class _MemoryToolInvocation extends BaseToolInvocation {
|
|
302172
302296
|
static allowlist = /* @__PURE__ */ new Set();
|
|
302297
|
+
constructor(params, messageBus, toolName, displayName) {
|
|
302298
|
+
super(params, messageBus, toolName, displayName);
|
|
302299
|
+
}
|
|
302173
302300
|
getDescription() {
|
|
302174
302301
|
const memoryFilePath = getGlobalMemoryFilePath();
|
|
302175
302302
|
return `in ${tildeifyPath(memoryFilePath)}`;
|
|
302176
302303
|
}
|
|
302177
|
-
async
|
|
302304
|
+
async getConfirmationDetails(_abortSignal) {
|
|
302178
302305
|
const memoryFilePath = getGlobalMemoryFilePath();
|
|
302179
302306
|
const allowlistKey = memoryFilePath;
|
|
302180
302307
|
if (_MemoryToolInvocation.allowlist.has(allowlistKey)) {
|
|
@@ -302233,7 +302360,7 @@ var MemoryToolInvocation = class _MemoryToolInvocation extends BaseToolInvocatio
|
|
|
302233
302360
|
}
|
|
302234
302361
|
} catch (error) {
|
|
302235
302362
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
302236
|
-
console.
|
|
302363
|
+
console.warn(`[MemoryTool] Error executing save_memory for fact "${fact}": ${errorMessage}`);
|
|
302237
302364
|
return {
|
|
302238
302365
|
llmContent: JSON.stringify({
|
|
302239
302366
|
success: false,
|
|
@@ -302250,8 +302377,8 @@ var MemoryToolInvocation = class _MemoryToolInvocation extends BaseToolInvocatio
|
|
|
302250
302377
|
};
|
|
302251
302378
|
var MemoryTool = class _MemoryTool extends BaseDeclarativeTool {
|
|
302252
302379
|
static Name = MEMORY_TOOL_NAME;
|
|
302253
|
-
constructor() {
|
|
302254
|
-
super(_MemoryTool.Name, "Save Memory", memoryToolDescription, Kind.Think, memoryToolSchemaData.parametersJsonSchema);
|
|
302380
|
+
constructor(messageBus) {
|
|
302381
|
+
super(_MemoryTool.Name, "Save Memory", memoryToolDescription, Kind.Think, memoryToolSchemaData.parametersJsonSchema, true, false, messageBus);
|
|
302255
302382
|
}
|
|
302256
302383
|
validateToolParamValues(params) {
|
|
302257
302384
|
if (params.fact.trim() === "") {
|
|
@@ -302259,8 +302386,8 @@ var MemoryTool = class _MemoryTool extends BaseDeclarativeTool {
|
|
|
302259
302386
|
}
|
|
302260
302387
|
return null;
|
|
302261
302388
|
}
|
|
302262
|
-
createInvocation(params) {
|
|
302263
|
-
return new MemoryToolInvocation(params);
|
|
302389
|
+
createInvocation(params, messageBus, toolName, displayName) {
|
|
302390
|
+
return new MemoryToolInvocation(params, messageBus ?? this.messageBus, toolName ?? this.name, displayName ?? this.displayName);
|
|
302264
302391
|
}
|
|
302265
302392
|
static async performAddMemoryEntry(text, memoryFilePath, fsAdapter) {
|
|
302266
302393
|
try {
|
|
@@ -302920,7 +303047,7 @@ var ReadFileTool = class _ReadFileTool extends BaseDeclarativeTool {
|
|
|
302920
303047
|
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, {
|
|
302921
303048
|
properties: {
|
|
302922
303049
|
absolute_path: {
|
|
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.",
|
|
303050
|
+
description: process9.platform === "win32" ? "The absolute path to the file to read (e.g., 'C:\\Users\\project\\file.txt'). Relative paths are not supported. You must provide an absolute path." : "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.",
|
|
302924
303051
|
type: "string"
|
|
302925
303052
|
},
|
|
302926
303053
|
offset: {
|
|
@@ -302961,8 +303088,9 @@ var ReadFileTool = class _ReadFileTool extends BaseDeclarativeTool {
|
|
|
302961
303088
|
return "Limit must be a positive number";
|
|
302962
303089
|
}
|
|
302963
303090
|
const fileService = this.config.getFileService();
|
|
302964
|
-
|
|
302965
|
-
|
|
303091
|
+
const fileFilteringOptions = this.config.getFileFilteringOptions();
|
|
303092
|
+
if (fileService.shouldIgnoreFile(params.absolute_path, fileFilteringOptions)) {
|
|
303093
|
+
return `File path '${filePath}' is ignored by configured ignore patterns.`;
|
|
302966
303094
|
}
|
|
302967
303095
|
return null;
|
|
302968
303096
|
}
|
|
@@ -307225,7 +307353,7 @@ var PathScurryBase = class {
|
|
|
307225
307353
|
const dirs = /* @__PURE__ */ new Set();
|
|
307226
307354
|
const queue = [entry];
|
|
307227
307355
|
let processing = 0;
|
|
307228
|
-
const
|
|
307356
|
+
const process25 = () => {
|
|
307229
307357
|
let paused = false;
|
|
307230
307358
|
while (!paused) {
|
|
307231
307359
|
const dir = queue.shift();
|
|
@@ -307240,14 +307368,14 @@ var PathScurryBase = class {
|
|
|
307240
307368
|
if (er)
|
|
307241
307369
|
return results.emit("error", er);
|
|
307242
307370
|
if (follow && !didRealpaths) {
|
|
307243
|
-
const
|
|
307371
|
+
const promises3 = [];
|
|
307244
307372
|
for (const e2 of entries2) {
|
|
307245
307373
|
if (e2.isSymbolicLink()) {
|
|
307246
|
-
|
|
307374
|
+
promises3.push(e2.realpath().then((r2) => r2?.isUnknown() ? r2.lstat() : r2));
|
|
307247
307375
|
}
|
|
307248
307376
|
}
|
|
307249
|
-
if (
|
|
307250
|
-
Promise.all(
|
|
307377
|
+
if (promises3.length) {
|
|
307378
|
+
Promise.all(promises3).then(() => onReaddir(null, entries2, true));
|
|
307251
307379
|
return;
|
|
307252
307380
|
}
|
|
307253
307381
|
}
|
|
@@ -307266,9 +307394,9 @@ var PathScurryBase = class {
|
|
|
307266
307394
|
}
|
|
307267
307395
|
}
|
|
307268
307396
|
if (paused && !results.flowing) {
|
|
307269
|
-
results.once("drain",
|
|
307397
|
+
results.once("drain", process25);
|
|
307270
307398
|
} else if (!sync2) {
|
|
307271
|
-
|
|
307399
|
+
process25();
|
|
307272
307400
|
}
|
|
307273
307401
|
};
|
|
307274
307402
|
let sync2 = true;
|
|
@@ -307276,7 +307404,7 @@ var PathScurryBase = class {
|
|
|
307276
307404
|
sync2 = false;
|
|
307277
307405
|
}
|
|
307278
307406
|
};
|
|
307279
|
-
|
|
307407
|
+
process25();
|
|
307280
307408
|
return results;
|
|
307281
307409
|
}
|
|
307282
307410
|
streamSync(entry = this.cwd, opts = {}) {
|
|
@@ -307294,7 +307422,7 @@ var PathScurryBase = class {
|
|
|
307294
307422
|
}
|
|
307295
307423
|
const queue = [entry];
|
|
307296
307424
|
let processing = 0;
|
|
307297
|
-
const
|
|
307425
|
+
const process25 = () => {
|
|
307298
307426
|
let paused = false;
|
|
307299
307427
|
while (!paused) {
|
|
307300
307428
|
const dir = queue.shift();
|
|
@@ -307328,9 +307456,9 @@ var PathScurryBase = class {
|
|
|
307328
307456
|
}
|
|
307329
307457
|
}
|
|
307330
307458
|
if (paused && !results.flowing)
|
|
307331
|
-
results.once("drain",
|
|
307459
|
+
results.once("drain", process25);
|
|
307332
307460
|
};
|
|
307333
|
-
|
|
307461
|
+
process25();
|
|
307334
307462
|
return results;
|
|
307335
307463
|
}
|
|
307336
307464
|
chdir(path64 = this.cwd) {
|
|
@@ -308597,7 +308725,7 @@ var GrepToolInvocation = class extends BaseToolInvocation {
|
|
|
308597
308725
|
returnDisplay: `Found ${matchCount} ${matchTerm}`
|
|
308598
308726
|
};
|
|
308599
308727
|
} catch (error) {
|
|
308600
|
-
|
|
308728
|
+
debugLogger.warn(`Error during GrepLogic execution: ${error}`);
|
|
308601
308729
|
const errorMessage = getErrorMessage(error);
|
|
308602
308730
|
return {
|
|
308603
308731
|
llmContent: `Error during grep search operation: ${errorMessage}`,
|
|
@@ -308864,7 +308992,7 @@ var GrepToolInvocation = class extends BaseToolInvocation {
|
|
|
308864
308992
|
}
|
|
308865
308993
|
return allMatches;
|
|
308866
308994
|
} catch (error) {
|
|
308867
|
-
|
|
308995
|
+
debugLogger.warn(`GrepLogic: Error in performGrepSearch (Strategy: ${strategyUsed}): ${getErrorMessage(error)}`);
|
|
308868
308996
|
throw error;
|
|
308869
308997
|
}
|
|
308870
308998
|
}
|
|
@@ -309212,9 +309340,9 @@ import { spawnSync } from "node:child_process";
|
|
|
309212
309340
|
import { debuglog } from "node:util";
|
|
309213
309341
|
|
|
309214
309342
|
// node_modules/execa/lib/utils/standard-stream.js
|
|
309215
|
-
import
|
|
309343
|
+
import process10 from "node:process";
|
|
309216
309344
|
var isStandardStream = (stream3) => STANDARD_STREAMS.includes(stream3);
|
|
309217
|
-
var STANDARD_STREAMS = [
|
|
309345
|
+
var STANDARD_STREAMS = [process10.stdin, process10.stdout, process10.stderr];
|
|
309218
309346
|
var STANDARD_STREAMS_ALIASES = ["stdin", "stdout", "stderr"];
|
|
309219
309347
|
var getStreamName = (fdNumber) => STANDARD_STREAMS_ALIASES[fdNumber] ?? `stdio[${fdNumber}]`;
|
|
309220
309348
|
|
|
@@ -309349,11 +309477,11 @@ var quoteString = (escapedArgument) => {
|
|
|
309349
309477
|
var NO_ESCAPE_REGEXP = /^[\w./-]+$/;
|
|
309350
309478
|
|
|
309351
309479
|
// node_modules/is-unicode-supported/index.js
|
|
309352
|
-
import
|
|
309480
|
+
import process11 from "node:process";
|
|
309353
309481
|
function isUnicodeSupported() {
|
|
309354
|
-
const { env: env2 } =
|
|
309482
|
+
const { env: env2 } = process11;
|
|
309355
309483
|
const { TERM, TERM_PROGRAM } = env2;
|
|
309356
|
-
if (
|
|
309484
|
+
if (process11.platform !== "win32") {
|
|
309357
309485
|
return TERM !== "linux";
|
|
309358
309486
|
}
|
|
309359
309487
|
return Boolean(env2.WT_SESSION) || Boolean(env2.TERMINUS_SUBLIME) || env2.ConEmuTask === "{cmd::Cmder}" || TERM_PROGRAM === "Terminus-Sublime" || TERM_PROGRAM === "vscode" || TERM === "xterm-256color" || TERM === "alacritty" || TERM === "rxvt-unicode" || TERM === "rxvt-unicode-256color" || env2.TERMINAL_EMULATOR === "JetBrains-JediTerm";
|
|
@@ -309856,10 +309984,10 @@ var handleCommand = (filePath, rawArguments, rawOptions) => {
|
|
|
309856
309984
|
// node_modules/execa/lib/arguments/options.js
|
|
309857
309985
|
var import_cross_spawn2 = __toESM(require_cross_spawn(), 1);
|
|
309858
309986
|
import path31 from "node:path";
|
|
309859
|
-
import
|
|
309987
|
+
import process14 from "node:process";
|
|
309860
309988
|
|
|
309861
309989
|
// node_modules/npm-run-path/index.js
|
|
309862
|
-
import
|
|
309990
|
+
import process12 from "node:process";
|
|
309863
309991
|
import path28 from "node:path";
|
|
309864
309992
|
|
|
309865
309993
|
// node_modules/npm-run-path/node_modules/path-key/index.js
|
|
@@ -309900,10 +310028,10 @@ var TEN_MEGABYTES_IN_BYTES = 10 * 1024 * 1024;
|
|
|
309900
310028
|
|
|
309901
310029
|
// node_modules/npm-run-path/index.js
|
|
309902
310030
|
var npmRunPath = ({
|
|
309903
|
-
cwd: cwd2 =
|
|
309904
|
-
path: pathOption =
|
|
310031
|
+
cwd: cwd2 = process12.cwd(),
|
|
310032
|
+
path: pathOption = process12.env[pathKey()],
|
|
309905
310033
|
preferLocal = true,
|
|
309906
|
-
execPath: execPath2 =
|
|
310034
|
+
execPath: execPath2 = process12.execPath,
|
|
309907
310035
|
addExecPath = true
|
|
309908
310036
|
} = {}) => {
|
|
309909
310037
|
const cwdPath = path28.resolve(toPath(cwd2));
|
|
@@ -309931,7 +310059,7 @@ var applyExecPath = (result, pathParts, execPath2, cwdPath) => {
|
|
|
309931
310059
|
result.push(pathPart);
|
|
309932
310060
|
}
|
|
309933
310061
|
};
|
|
309934
|
-
var npmRunPathEnv = ({ env: env2 =
|
|
310062
|
+
var npmRunPathEnv = ({ env: env2 = process12.env, ...options2 } = {}) => {
|
|
309935
310063
|
env2 = { ...env2 };
|
|
309936
310064
|
const pathName = pathKey({ env: env2 });
|
|
309937
310065
|
options2.path = env2[pathName];
|
|
@@ -310661,7 +310789,7 @@ var incrementMaxListeners = (eventEmitter, maxListenersIncrement, signal) => {
|
|
|
310661
310789
|
};
|
|
310662
310790
|
|
|
310663
310791
|
// node_modules/execa/lib/ipc/forward.js
|
|
310664
|
-
import { EventEmitter as
|
|
310792
|
+
import { EventEmitter as EventEmitter6 } from "node:events";
|
|
310665
310793
|
|
|
310666
310794
|
// node_modules/execa/lib/ipc/incoming.js
|
|
310667
310795
|
import { once as once2 } from "node:events";
|
|
@@ -310743,7 +310871,7 @@ var getIpcEmitter = (anyProcess, channel, isSubprocess) => {
|
|
|
310743
310871
|
if (IPC_EMITTERS.has(anyProcess)) {
|
|
310744
310872
|
return IPC_EMITTERS.get(anyProcess);
|
|
310745
310873
|
}
|
|
310746
|
-
const ipcEmitter = new
|
|
310874
|
+
const ipcEmitter = new EventEmitter6();
|
|
310747
310875
|
ipcEmitter.connected = true;
|
|
310748
310876
|
IPC_EMITTERS.set(anyProcess, ipcEmitter);
|
|
310749
310877
|
forwardEvents({
|
|
@@ -311201,14 +311329,14 @@ var serializeEncoding = (encoding) => typeof encoding === "string" ? `"${encodin
|
|
|
311201
311329
|
// node_modules/execa/lib/arguments/cwd.js
|
|
311202
311330
|
import { statSync } from "node:fs";
|
|
311203
311331
|
import path30 from "node:path";
|
|
311204
|
-
import
|
|
311332
|
+
import process13 from "node:process";
|
|
311205
311333
|
var normalizeCwd = (cwd2 = getDefaultCwd()) => {
|
|
311206
311334
|
const cwdString = safeNormalizeFileUrl(cwd2, 'The "cwd" option');
|
|
311207
311335
|
return path30.resolve(cwdString);
|
|
311208
311336
|
};
|
|
311209
311337
|
var getDefaultCwd = () => {
|
|
311210
311338
|
try {
|
|
311211
|
-
return
|
|
311339
|
+
return process13.cwd();
|
|
311212
311340
|
} catch (error) {
|
|
311213
311341
|
error.message = `The current directory does not exist.
|
|
311214
311342
|
${error.message}`;
|
|
@@ -311251,7 +311379,7 @@ var normalizeOptions = (filePath, rawArguments, rawOptions) => {
|
|
|
311251
311379
|
options2.killSignal = normalizeKillSignal(options2.killSignal);
|
|
311252
311380
|
options2.forceKillAfterDelay = normalizeForceKillAfterDelay(options2.forceKillAfterDelay);
|
|
311253
311381
|
options2.lines = options2.lines.map((lines, fdNumber) => lines && !BINARY_ENCODINGS.has(options2.encoding) && options2.buffer[fdNumber]);
|
|
311254
|
-
if (
|
|
311382
|
+
if (process14.platform === "win32" && path31.basename(file, ".exe") === "cmd") {
|
|
311255
311383
|
commandArguments.unshift("/q");
|
|
311256
311384
|
}
|
|
311257
311385
|
return { file, commandArguments, options: options2 };
|
|
@@ -311292,7 +311420,7 @@ var addDefaultOptions = ({
|
|
|
311292
311420
|
serialization
|
|
311293
311421
|
});
|
|
311294
311422
|
var getEnv2 = ({ env: envOption, extendEnv, preferLocal, node, localDirectory, nodePath: nodePath2 }) => {
|
|
311295
|
-
const env2 = extendEnv ? { ...
|
|
311423
|
+
const env2 = extendEnv ? { ...process14.env, ...envOption } : envOption;
|
|
311296
311424
|
if (preferLocal || node) {
|
|
311297
311425
|
return npmRunPathEnv({
|
|
311298
311426
|
env: env2,
|
|
@@ -312493,7 +312621,7 @@ var normalizeGenerator = ({ stdioItem, stdioItem: { value }, index, newTransform
|
|
|
312493
312621
|
var sortTransforms = (newTransforms, direction) => direction === "input" ? newTransforms.reverse() : newTransforms;
|
|
312494
312622
|
|
|
312495
312623
|
// node_modules/execa/lib/stdio/direction.js
|
|
312496
|
-
import
|
|
312624
|
+
import process15 from "node:process";
|
|
312497
312625
|
var getStreamDirection = (stdioItems, fdNumber, optionName) => {
|
|
312498
312626
|
const directions = stdioItems.map((stdioItem) => getStdioItemDirection(stdioItem, fdNumber));
|
|
312499
312627
|
if (directions.includes("input") && directions.includes("output")) {
|
|
@@ -312533,10 +312661,10 @@ var guessStreamDirection = {
|
|
|
312533
312661
|
}
|
|
312534
312662
|
};
|
|
312535
312663
|
var getStandardStreamDirection = (value) => {
|
|
312536
|
-
if ([0,
|
|
312664
|
+
if ([0, process15.stdin].includes(value)) {
|
|
312537
312665
|
return "input";
|
|
312538
312666
|
}
|
|
312539
|
-
if ([1, 2,
|
|
312667
|
+
if ([1, 2, process15.stdout, process15.stderr].includes(value)) {
|
|
312540
312668
|
return "output";
|
|
312541
312669
|
}
|
|
312542
312670
|
};
|
|
@@ -313640,7 +313768,7 @@ import { setMaxListeners } from "node:events";
|
|
|
313640
313768
|
import { spawn as spawn4 } from "node:child_process";
|
|
313641
313769
|
|
|
313642
313770
|
// node_modules/execa/lib/ipc/methods.js
|
|
313643
|
-
import
|
|
313771
|
+
import process16 from "node:process";
|
|
313644
313772
|
|
|
313645
313773
|
// node_modules/execa/lib/ipc/get-one.js
|
|
313646
313774
|
import { once as once5, on as on2 } from "node:events";
|
|
@@ -313781,9 +313909,9 @@ var addIpcMethods = (subprocess, { ipc }) => {
|
|
|
313781
313909
|
Object.assign(subprocess, getIpcMethods(subprocess, false, ipc));
|
|
313782
313910
|
};
|
|
313783
313911
|
var getIpcExport = () => {
|
|
313784
|
-
const anyProcess =
|
|
313912
|
+
const anyProcess = process16;
|
|
313785
313913
|
const isSubprocess = true;
|
|
313786
|
-
const ipc =
|
|
313914
|
+
const ipc = process16.channel !== void 0;
|
|
313787
313915
|
return {
|
|
313788
313916
|
...getIpcMethods(anyProcess, isSubprocess, ipc),
|
|
313789
313917
|
getCancelSignal: getCancelSignal.bind(void 0, {
|
|
@@ -314249,7 +314377,7 @@ if (process.platform === "linux") {
|
|
|
314249
314377
|
}
|
|
314250
314378
|
|
|
314251
314379
|
// node_modules/signal-exit/dist/mjs/index.js
|
|
314252
|
-
var processOk = (
|
|
314380
|
+
var processOk = (process25) => !!process25 && typeof process25 === "object" && typeof process25.removeListener === "function" && typeof process25.emit === "function" && typeof process25.reallyExit === "function" && typeof process25.listeners === "function" && typeof process25.kill === "function" && typeof process25.pid === "number" && typeof process25.on === "function";
|
|
314253
314381
|
var kExitEmitter = Symbol.for("signal-exit emitter");
|
|
314254
314382
|
var global2 = globalThis;
|
|
314255
314383
|
var ObjectDefineProperty = Object.defineProperty.bind(Object);
|
|
@@ -314334,7 +314462,7 @@ var SignalExit = class extends SignalExitBase {
|
|
|
314334
314462
|
// "SIGHUP" throws an `ENOSYS` error on Windows,
|
|
314335
314463
|
// so use a supported signal instead
|
|
314336
314464
|
/* c8 ignore start */
|
|
314337
|
-
#hupSig =
|
|
314465
|
+
#hupSig = process17.platform === "win32" ? "SIGINT" : "SIGHUP";
|
|
314338
314466
|
/* c8 ignore stop */
|
|
314339
314467
|
#emitter = new Emitter();
|
|
314340
314468
|
#process;
|
|
@@ -314342,15 +314470,15 @@ var SignalExit = class extends SignalExitBase {
|
|
|
314342
314470
|
#originalProcessReallyExit;
|
|
314343
314471
|
#sigListeners = {};
|
|
314344
314472
|
#loaded = false;
|
|
314345
|
-
constructor(
|
|
314473
|
+
constructor(process25) {
|
|
314346
314474
|
super();
|
|
314347
|
-
this.#process =
|
|
314475
|
+
this.#process = process25;
|
|
314348
314476
|
this.#sigListeners = {};
|
|
314349
314477
|
for (const sig of signals) {
|
|
314350
314478
|
this.#sigListeners[sig] = () => {
|
|
314351
314479
|
const listeners = this.#process.listeners(sig);
|
|
314352
314480
|
let { count: count2 } = this.#emitter;
|
|
314353
|
-
const p =
|
|
314481
|
+
const p = process25;
|
|
314354
314482
|
if (typeof p.__signal_exit_emitter__ === "object" && typeof p.__signal_exit_emitter__.count === "number") {
|
|
314355
314483
|
count2 += p.__signal_exit_emitter__.count;
|
|
314356
314484
|
}
|
|
@@ -314359,12 +314487,12 @@ var SignalExit = class extends SignalExitBase {
|
|
|
314359
314487
|
const ret = this.#emitter.emit("exit", null, sig);
|
|
314360
314488
|
const s2 = sig === "SIGHUP" ? this.#hupSig : sig;
|
|
314361
314489
|
if (!ret)
|
|
314362
|
-
|
|
314490
|
+
process25.kill(process25.pid, s2);
|
|
314363
314491
|
}
|
|
314364
314492
|
};
|
|
314365
314493
|
}
|
|
314366
|
-
this.#originalProcessReallyExit =
|
|
314367
|
-
this.#originalProcessEmit =
|
|
314494
|
+
this.#originalProcessReallyExit = process25.reallyExit;
|
|
314495
|
+
this.#originalProcessEmit = process25.emit;
|
|
314368
314496
|
}
|
|
314369
314497
|
onExit(cb, opts) {
|
|
314370
314498
|
if (!processOk(this.#process)) {
|
|
@@ -314445,7 +314573,7 @@ var SignalExit = class extends SignalExitBase {
|
|
|
314445
314573
|
}
|
|
314446
314574
|
}
|
|
314447
314575
|
};
|
|
314448
|
-
var
|
|
314576
|
+
var process17 = globalThis.process;
|
|
314449
314577
|
var {
|
|
314450
314578
|
/**
|
|
314451
314579
|
* Called when the process is exiting, whether via signal, explicit
|
|
@@ -314473,7 +314601,7 @@ var {
|
|
|
314473
314601
|
* @internal
|
|
314474
314602
|
*/
|
|
314475
314603
|
unload
|
|
314476
|
-
} = signalExitWrap(processOk(
|
|
314604
|
+
} = signalExitWrap(processOk(process17) ? new SignalExit(process17) : new SignalExitFallback());
|
|
314477
314605
|
|
|
314478
314606
|
// node_modules/execa/lib/terminate/cleanup.js
|
|
314479
314607
|
var cleanupOnExit = (subprocess, { cleanup, detached }, { signal }) => {
|
|
@@ -315222,17 +315350,17 @@ var addConcurrentStream = (concurrentStreams, stream3, waitName) => {
|
|
|
315222
315350
|
if (!weakMap.has(stream3)) {
|
|
315223
315351
|
weakMap.set(stream3, []);
|
|
315224
315352
|
}
|
|
315225
|
-
const
|
|
315353
|
+
const promises3 = weakMap.get(stream3);
|
|
315226
315354
|
const promise = createDeferred();
|
|
315227
|
-
|
|
315355
|
+
promises3.push(promise);
|
|
315228
315356
|
const resolve13 = promise.resolve.bind(promise);
|
|
315229
|
-
return { resolve: resolve13, promises:
|
|
315357
|
+
return { resolve: resolve13, promises: promises3 };
|
|
315230
315358
|
};
|
|
315231
|
-
var waitForConcurrentStreams = async ({ resolve: resolve13, promises:
|
|
315359
|
+
var waitForConcurrentStreams = async ({ resolve: resolve13, promises: promises3 }, subprocess) => {
|
|
315232
315360
|
resolve13();
|
|
315233
315361
|
const [isSubprocessExit] = await Promise.race([
|
|
315234
315362
|
Promise.allSettled([true, subprocess]),
|
|
315235
|
-
Promise.all([false, ...
|
|
315363
|
+
Promise.all([false, ...promises3])
|
|
315236
315364
|
]);
|
|
315237
315365
|
return !isSubprocessExit;
|
|
315238
315366
|
};
|
|
@@ -317075,7 +317203,7 @@ function assertWhitespaceString(value, message) {
|
|
|
317075
317203
|
var distribution_default = is;
|
|
317076
317204
|
|
|
317077
317205
|
// node_modules/got/dist/source/as-promise/index.js
|
|
317078
|
-
import { EventEmitter as
|
|
317206
|
+
import { EventEmitter as EventEmitter8 } from "node:events";
|
|
317079
317207
|
|
|
317080
317208
|
// node_modules/p-cancelable/index.js
|
|
317081
317209
|
var CancelError = class extends Error {
|
|
@@ -317280,7 +317408,7 @@ var AbortError = class extends RequestError2 {
|
|
|
317280
317408
|
};
|
|
317281
317409
|
|
|
317282
317410
|
// node_modules/got/dist/source/core/index.js
|
|
317283
|
-
import
|
|
317411
|
+
import process19 from "node:process";
|
|
317284
317412
|
import { Buffer as Buffer8 } from "node:buffer";
|
|
317285
317413
|
import { Duplex as Duplex4 } from "node:stream";
|
|
317286
317414
|
import http5, { ServerResponse } from "node:http";
|
|
@@ -317391,7 +317519,7 @@ var timer = (request3) => {
|
|
|
317391
317519
|
var source_default = timer;
|
|
317392
317520
|
|
|
317393
317521
|
// node_modules/cacheable-request/dist/index.js
|
|
317394
|
-
import
|
|
317522
|
+
import EventEmitter7 from "node:events";
|
|
317395
317523
|
import urlLib from "node:url";
|
|
317396
317524
|
import crypto19 from "node:crypto";
|
|
317397
317525
|
import stream2, { PassThrough as PassThroughStream2 } from "node:stream";
|
|
@@ -317739,7 +317867,7 @@ var CacheableRequest = class {
|
|
|
317739
317867
|
...urlObjectToRequestOptions(url4)
|
|
317740
317868
|
};
|
|
317741
317869
|
options2.headers = Object.fromEntries(entries(options2.headers).map(([key2, value]) => [key2.toLowerCase(), value]));
|
|
317742
|
-
const ee = new
|
|
317870
|
+
const ee = new EventEmitter7();
|
|
317743
317871
|
const normalizedUrlString = normalizeUrl(urlLib.format(url4), {
|
|
317744
317872
|
stripWWW: false,
|
|
317745
317873
|
// eslint-disable-line @typescript-eslint/naming-convention
|
|
@@ -318558,7 +318686,7 @@ var calculateRetryDelay = ({ attemptCount, retryOptions, error, retryAfter, comp
|
|
|
318558
318686
|
var calculate_retry_delay_default = calculateRetryDelay;
|
|
318559
318687
|
|
|
318560
318688
|
// node_modules/got/dist/source/core/options.js
|
|
318561
|
-
import
|
|
318689
|
+
import process18 from "node:process";
|
|
318562
318690
|
import { promisify as promisify11, inspect as inspect3 } from "node:util";
|
|
318563
318691
|
import { checkServerIdentity } from "node:tls";
|
|
318564
318692
|
import https2 from "node:https";
|
|
@@ -318956,7 +319084,7 @@ function parseLinkHeader(link2) {
|
|
|
318956
319084
|
}
|
|
318957
319085
|
|
|
318958
319086
|
// node_modules/got/dist/source/core/options.js
|
|
318959
|
-
var [major2, minor] =
|
|
319087
|
+
var [major2, minor] = process18.versions.node.split(".").map(Number);
|
|
318960
319088
|
function validateSearchParameters(searchParameters) {
|
|
318961
319089
|
for (const key in searchParameters) {
|
|
318962
319090
|
const value = searchParameters[key];
|
|
@@ -320568,7 +320696,7 @@ function isUnixSocketURL(url4) {
|
|
|
320568
320696
|
}
|
|
320569
320697
|
|
|
320570
320698
|
// node_modules/got/dist/source/core/index.js
|
|
320571
|
-
var supportsBrotli = distribution_default.string(
|
|
320699
|
+
var supportsBrotli = distribution_default.string(process19.versions.brotli);
|
|
320572
320700
|
var methodsWithoutBody = /* @__PURE__ */ new Set(["GET", "HEAD"]);
|
|
320573
320701
|
var cacheableStore = new WeakableMap();
|
|
320574
320702
|
var redirectCodes = /* @__PURE__ */ new Set([300, 301, 302, 303, 304, 307, 308]);
|
|
@@ -320798,7 +320926,7 @@ var Request = class _Request extends Duplex4 {
|
|
|
320798
320926
|
this.emit("retry", this.retryCount + 1, error, (updatedOptions) => {
|
|
320799
320927
|
const request3 = new _Request(options2.url, updatedOptions, options2);
|
|
320800
320928
|
request3.retryCount = this.retryCount + 1;
|
|
320801
|
-
|
|
320929
|
+
process19.nextTick(() => {
|
|
320802
320930
|
void request3.flush();
|
|
320803
320931
|
});
|
|
320804
320932
|
return request3;
|
|
@@ -320991,9 +321119,9 @@ var Request = class _Request extends Duplex4 {
|
|
|
320991
321119
|
this.emit("downloadProgress", this.downloadProgress);
|
|
320992
321120
|
const rawCookies = response.headers["set-cookie"];
|
|
320993
321121
|
if (distribution_default.object(options2.cookieJar) && rawCookies) {
|
|
320994
|
-
let
|
|
321122
|
+
let promises3 = rawCookies.map(async (rawCookie) => options2.cookieJar.setCookie(rawCookie, url4.toString()));
|
|
320995
321123
|
if (options2.ignoreInvalidCookies) {
|
|
320996
|
-
|
|
321124
|
+
promises3 = promises3.map(async (promise) => {
|
|
320997
321125
|
try {
|
|
320998
321126
|
await promise;
|
|
320999
321127
|
} catch {
|
|
@@ -321001,7 +321129,7 @@ var Request = class _Request extends Duplex4 {
|
|
|
321001
321129
|
});
|
|
321002
321130
|
}
|
|
321003
321131
|
try {
|
|
321004
|
-
await Promise.all(
|
|
321132
|
+
await Promise.all(promises3);
|
|
321005
321133
|
} catch (error) {
|
|
321006
321134
|
this._beforeError(error);
|
|
321007
321135
|
return;
|
|
@@ -321470,7 +321598,7 @@ function asPromise(firstRequest) {
|
|
|
321470
321598
|
let globalRequest;
|
|
321471
321599
|
let globalResponse;
|
|
321472
321600
|
let normalizedOptions;
|
|
321473
|
-
const emitter = new
|
|
321601
|
+
const emitter = new EventEmitter8();
|
|
321474
321602
|
const promise = new PCancelable((resolve13, reject, onCancel) => {
|
|
321475
321603
|
onCancel(() => {
|
|
321476
321604
|
globalRequest.destroy();
|
|
@@ -321861,7 +321989,7 @@ var getTarget = () => {
|
|
|
321861
321989
|
var downloadFile2 = async (url4, outFile) => {
|
|
321862
321990
|
let tmpDir = void 0;
|
|
321863
321991
|
try {
|
|
321864
|
-
tmpDir = await import_fs_extra.default.mkdtemp("download-ripgrep");
|
|
321992
|
+
tmpDir = await import_fs_extra.default.mkdtemp(path33.join(os8.tmpdir(), "download-ripgrep"));
|
|
321865
321993
|
const tmpFile = path33.join(tmpDir, "tmp-file");
|
|
321866
321994
|
await pipeline2(source_default2.stream(url4), createWriteStream5(tmpFile));
|
|
321867
321995
|
await mkdir3(dirname7(outFile), { recursive: true });
|
|
@@ -322377,7 +322505,7 @@ var GlobToolInvocation = class extends BaseToolInvocation {
|
|
|
322377
322505
|
allEntries.push(...entries2);
|
|
322378
322506
|
}
|
|
322379
322507
|
const relativePaths = allEntries.map((p) => path35.relative(this.config.getTargetDir(), p.fullpath()));
|
|
322380
|
-
const { filteredPaths,
|
|
322508
|
+
const { filteredPaths, ignoredCount } = fileDiscovery.filterFilesWithReport(relativePaths, {
|
|
322381
322509
|
respectGitIgnore: this.params?.respect_git_ignore ?? this.config.getFileFilteringOptions().respectGitIgnore ?? DEFAULT_FILE_FILTERING_OPTIONS.respectGitIgnore,
|
|
322382
322510
|
respectGeminiIgnore: this.params?.respect_gemini_ignore ?? this.config.getFileFilteringOptions().respectGeminiIgnore ?? DEFAULT_FILE_FILTERING_OPTIONS.respectGeminiIgnore
|
|
322383
322511
|
});
|
|
@@ -322390,11 +322518,8 @@ var GlobToolInvocation = class extends BaseToolInvocation {
|
|
|
322390
322518
|
} else {
|
|
322391
322519
|
message += ` within ${searchDirectories.length} workspace directories`;
|
|
322392
322520
|
}
|
|
322393
|
-
if (
|
|
322394
|
-
message += ` (${
|
|
322395
|
-
}
|
|
322396
|
-
if (geminiIgnoredCount > 0) {
|
|
322397
|
-
message += ` (${geminiIgnoredCount} files were gemini-ignored)`;
|
|
322521
|
+
if (ignoredCount > 0) {
|
|
322522
|
+
message += ` (${ignoredCount} files were ignored)`;
|
|
322398
322523
|
}
|
|
322399
322524
|
return {
|
|
322400
322525
|
llmContent: message,
|
|
@@ -322413,11 +322538,8 @@ var GlobToolInvocation = class extends BaseToolInvocation {
|
|
|
322413
322538
|
} else {
|
|
322414
322539
|
resultMessage += ` across ${searchDirectories.length} workspace directories`;
|
|
322415
322540
|
}
|
|
322416
|
-
if (
|
|
322417
|
-
resultMessage += ` (${
|
|
322418
|
-
}
|
|
322419
|
-
if (geminiIgnoredCount > 0) {
|
|
322420
|
-
resultMessage += ` (${geminiIgnoredCount} additional files were gemini-ignored)`;
|
|
322541
|
+
if (ignoredCount > 0) {
|
|
322542
|
+
resultMessage += ` (${ignoredCount} additional files were ignored)`;
|
|
322421
322543
|
}
|
|
322422
322544
|
resultMessage += `, sorted by modification time (newest first):
|
|
322423
322545
|
${fileListDescription}`;
|
|
@@ -322426,8 +322548,8 @@ ${fileListDescription}`;
|
|
|
322426
322548
|
returnDisplay: `Found ${fileCount} matching file(s)`
|
|
322427
322549
|
};
|
|
322428
322550
|
} catch (error) {
|
|
322429
|
-
|
|
322430
|
-
|
|
322551
|
+
debugLogger.warn(`GlobLogic execute Error`, error);
|
|
322552
|
+
const errorMessage = getErrorMessage(error);
|
|
322431
322553
|
const rawError = `Error during glob search operation: ${errorMessage}`;
|
|
322432
322554
|
return {
|
|
322433
322555
|
llmContent: rawError,
|
|
@@ -322506,6 +322628,7 @@ var GlobTool = class _GlobTool extends BaseDeclarativeTool {
|
|
|
322506
322628
|
// packages/core/dist/src/tools/edit.js
|
|
322507
322629
|
import * as fs36 from "node:fs";
|
|
322508
322630
|
import * as path38 from "node:path";
|
|
322631
|
+
import process20 from "node:process";
|
|
322509
322632
|
|
|
322510
322633
|
// packages/core/dist/src/utils/LruCache.js
|
|
322511
322634
|
var LruCache = class {
|
|
@@ -324005,12 +324128,11 @@ function applyReplacement(currentContent, oldString, newString, isNewFile) {
|
|
|
324005
324128
|
}
|
|
324006
324129
|
return safeLiteralReplace(currentContent, oldString, newString);
|
|
324007
324130
|
}
|
|
324008
|
-
var EditToolInvocation = class {
|
|
324131
|
+
var EditToolInvocation = class extends BaseToolInvocation {
|
|
324009
324132
|
config;
|
|
324010
|
-
params
|
|
324011
|
-
|
|
324133
|
+
constructor(config2, params, messageBus, toolName, displayName) {
|
|
324134
|
+
super(params, messageBus, toolName, displayName);
|
|
324012
324135
|
this.config = config2;
|
|
324013
|
-
this.params = params;
|
|
324014
324136
|
}
|
|
324015
324137
|
toolLocations() {
|
|
324016
324138
|
return [{ path: this.params.file_path }];
|
|
@@ -324106,7 +324228,7 @@ var EditToolInvocation = class {
|
|
|
324106
324228
|
* Handles the confirmation prompt for the Edit tool in the CLI.
|
|
324107
324229
|
* It needs to calculate the diff to show the user.
|
|
324108
324230
|
*/
|
|
324109
|
-
async
|
|
324231
|
+
async getConfirmationDetails(abortSignal) {
|
|
324110
324232
|
if (this.config.getApprovalMode() === ApprovalMode.AUTO_EDIT) {
|
|
324111
324233
|
return false;
|
|
324112
324234
|
}
|
|
@@ -324260,8 +324382,11 @@ var EditToolInvocation = class {
|
|
|
324260
324382
|
var EditTool = class _EditTool extends BaseDeclarativeTool {
|
|
324261
324383
|
config;
|
|
324262
324384
|
static Name = EDIT_TOOL_NAME;
|
|
324263
|
-
constructor(config2) {
|
|
324264
|
-
super(
|
|
324385
|
+
constructor(config2, messageBus) {
|
|
324386
|
+
super(
|
|
324387
|
+
_EditTool.Name,
|
|
324388
|
+
"Edit",
|
|
324389
|
+
`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.
|
|
324265
324390
|
|
|
324266
324391
|
The user has the ability to modify the \`new_string\` content. If modified, this will be stated in the response.
|
|
324267
324392
|
|
|
@@ -324271,29 +324396,37 @@ Expectation for required parameters:
|
|
|
324271
324396
|
3. \`new_string\` MUST be the exact literal text to replace \`old_string\` with (also including all whitespace, indentation, newlines, and surrounding code etc.). Ensure the resulting code is correct and idiomatic.
|
|
324272
324397
|
4. NEVER escape \`old_string\` or \`new_string\`, that would break the exact literal text requirement.
|
|
324273
324398
|
**Important:** If ANY of the above are not satisfied, the tool will fail. CRITICAL for \`old_string\`: Must uniquely identify the single instance to change. Include at least 3 lines of context BEFORE and AFTER the target text, matching whitespace and indentation precisely. If this string matches multiple locations, or does not match exactly, the tool will fail.
|
|
324274
|
-
**Multiple replacements:** Set \`expected_replacements\` to the number of occurrences you want to replace. The tool will replace ALL occurrences that match \`old_string\` exactly. Ensure the number of replacements matches your expectation.`,
|
|
324275
|
-
|
|
324276
|
-
|
|
324277
|
-
|
|
324278
|
-
|
|
324279
|
-
|
|
324280
|
-
|
|
324281
|
-
|
|
324282
|
-
|
|
324283
|
-
|
|
324284
|
-
|
|
324285
|
-
|
|
324286
|
-
|
|
324399
|
+
**Multiple replacements:** Set \`expected_replacements\` to the number of occurrences you want to replace. The tool will replace ALL occurrences that match \`old_string\` exactly. Ensure the number of replacements matches your expectation.`,
|
|
324400
|
+
Kind.Edit,
|
|
324401
|
+
{
|
|
324402
|
+
properties: {
|
|
324403
|
+
file_path: {
|
|
324404
|
+
description: process20.platform === "win32" ? "The absolute path to the file to modify (e.g., 'C:\\Users\\project\\file.txt'). Must be an absolute path." : "The absolute path to the file to modify (e.g., '/home/user/project/file.txt'). Must start with '/'.",
|
|
324405
|
+
type: "string"
|
|
324406
|
+
},
|
|
324407
|
+
old_string: {
|
|
324408
|
+
description: "The exact literal text to replace, preferably unescaped. For single replacements (default), include at least 3 lines of context BEFORE and AFTER the target text, matching whitespace and indentation precisely. For multiple replacements, specify expected_replacements parameter. If this string is not the exact literal text (i.e. you escaped it) or does not match exactly, the tool will fail.",
|
|
324409
|
+
type: "string"
|
|
324410
|
+
},
|
|
324411
|
+
new_string: {
|
|
324412
|
+
description: "The exact literal text to replace `old_string` with, preferably unescaped. Provide the EXACT text. Ensure the resulting code is correct and idiomatic.",
|
|
324413
|
+
type: "string"
|
|
324414
|
+
},
|
|
324415
|
+
expected_replacements: {
|
|
324416
|
+
type: "number",
|
|
324417
|
+
description: "Number of replacements expected. Defaults to 1 if not specified. Use when you want to replace multiple occurrences.",
|
|
324418
|
+
minimum: 1
|
|
324419
|
+
}
|
|
324287
324420
|
},
|
|
324288
|
-
|
|
324289
|
-
|
|
324290
|
-
description: "Number of replacements expected. Defaults to 1 if not specified. Use when you want to replace multiple occurrences.",
|
|
324291
|
-
minimum: 1
|
|
324292
|
-
}
|
|
324421
|
+
required: ["file_path", "old_string", "new_string"],
|
|
324422
|
+
type: "object"
|
|
324293
324423
|
},
|
|
324294
|
-
|
|
324295
|
-
|
|
324296
|
-
|
|
324424
|
+
true,
|
|
324425
|
+
// isOutputMarkdown
|
|
324426
|
+
false,
|
|
324427
|
+
// canUpdateOutput
|
|
324428
|
+
messageBus
|
|
324429
|
+
);
|
|
324297
324430
|
this.config = config2;
|
|
324298
324431
|
}
|
|
324299
324432
|
/**
|
|
@@ -324315,8 +324448,8 @@ Expectation for required parameters:
|
|
|
324315
324448
|
}
|
|
324316
324449
|
return null;
|
|
324317
324450
|
}
|
|
324318
|
-
createInvocation(params) {
|
|
324319
|
-
return new EditToolInvocation(this.config, params);
|
|
324451
|
+
createInvocation(params, messageBus, toolName, displayName) {
|
|
324452
|
+
return new EditToolInvocation(this.config, params, messageBus ?? this.messageBus, toolName ?? this.name, displayName ?? this.displayName);
|
|
324320
324453
|
}
|
|
324321
324454
|
getModifyContext(_) {
|
|
324322
324455
|
return {
|
|
@@ -324663,6 +324796,226 @@ async function reportError(error, baseMessage, context2, type = "general", repor
|
|
|
324663
324796
|
}
|
|
324664
324797
|
}
|
|
324665
324798
|
|
|
324799
|
+
// packages/core/dist/src/utils/googleErrors.js
|
|
324800
|
+
function parseGoogleApiError(error) {
|
|
324801
|
+
if (!error) {
|
|
324802
|
+
return null;
|
|
324803
|
+
}
|
|
324804
|
+
let errorObj = error;
|
|
324805
|
+
if (typeof errorObj === "string") {
|
|
324806
|
+
try {
|
|
324807
|
+
errorObj = JSON.parse(errorObj);
|
|
324808
|
+
} catch (_) {
|
|
324809
|
+
return null;
|
|
324810
|
+
}
|
|
324811
|
+
}
|
|
324812
|
+
if (Array.isArray(errorObj) && errorObj.length > 0) {
|
|
324813
|
+
errorObj = errorObj[0];
|
|
324814
|
+
}
|
|
324815
|
+
if (typeof errorObj !== "object" || errorObj === null) {
|
|
324816
|
+
return null;
|
|
324817
|
+
}
|
|
324818
|
+
let currentError = fromGaxiosError(errorObj) ?? fromApiError(errorObj);
|
|
324819
|
+
let depth = 0;
|
|
324820
|
+
const maxDepth = 10;
|
|
324821
|
+
while (currentError && typeof currentError.message === "string" && depth < maxDepth) {
|
|
324822
|
+
try {
|
|
324823
|
+
const parsedMessage = JSON.parse(currentError.message.replace(/\u00A0/g, "").replace(/\n/g, " "));
|
|
324824
|
+
if (parsedMessage.error) {
|
|
324825
|
+
currentError = parsedMessage.error;
|
|
324826
|
+
depth++;
|
|
324827
|
+
} else {
|
|
324828
|
+
break;
|
|
324829
|
+
}
|
|
324830
|
+
} catch (_error) {
|
|
324831
|
+
break;
|
|
324832
|
+
}
|
|
324833
|
+
}
|
|
324834
|
+
if (!currentError) {
|
|
324835
|
+
return null;
|
|
324836
|
+
}
|
|
324837
|
+
const code2 = currentError.code;
|
|
324838
|
+
const message = currentError.message;
|
|
324839
|
+
const errorDetails = currentError.details;
|
|
324840
|
+
if (Array.isArray(errorDetails) && code2 && message) {
|
|
324841
|
+
const details = [];
|
|
324842
|
+
for (const detail of errorDetails) {
|
|
324843
|
+
if (detail && typeof detail === "object") {
|
|
324844
|
+
const detailObj = detail;
|
|
324845
|
+
const typeKey = Object.keys(detailObj).find((key) => key.trim() === "@type");
|
|
324846
|
+
if (typeKey) {
|
|
324847
|
+
if (typeKey !== "@type") {
|
|
324848
|
+
detailObj["@type"] = detailObj[typeKey];
|
|
324849
|
+
delete detailObj[typeKey];
|
|
324850
|
+
}
|
|
324851
|
+
details.push(detailObj);
|
|
324852
|
+
}
|
|
324853
|
+
}
|
|
324854
|
+
}
|
|
324855
|
+
if (details.length > 0) {
|
|
324856
|
+
return {
|
|
324857
|
+
code: code2,
|
|
324858
|
+
message,
|
|
324859
|
+
details
|
|
324860
|
+
};
|
|
324861
|
+
}
|
|
324862
|
+
}
|
|
324863
|
+
return null;
|
|
324864
|
+
}
|
|
324865
|
+
function fromGaxiosError(errorObj) {
|
|
324866
|
+
const gaxiosError = errorObj;
|
|
324867
|
+
let outerError;
|
|
324868
|
+
if (gaxiosError.response?.data) {
|
|
324869
|
+
let data = gaxiosError.response.data;
|
|
324870
|
+
if (typeof data === "string") {
|
|
324871
|
+
try {
|
|
324872
|
+
data = JSON.parse(data);
|
|
324873
|
+
} catch (_) {
|
|
324874
|
+
}
|
|
324875
|
+
}
|
|
324876
|
+
if (Array.isArray(data) && data.length > 0) {
|
|
324877
|
+
data = data[0];
|
|
324878
|
+
}
|
|
324879
|
+
if (typeof data === "object" && data !== null) {
|
|
324880
|
+
if ("error" in data) {
|
|
324881
|
+
outerError = data.error;
|
|
324882
|
+
}
|
|
324883
|
+
}
|
|
324884
|
+
}
|
|
324885
|
+
if (!outerError) {
|
|
324886
|
+
if (gaxiosError.error) {
|
|
324887
|
+
outerError = gaxiosError.error;
|
|
324888
|
+
} else {
|
|
324889
|
+
return void 0;
|
|
324890
|
+
}
|
|
324891
|
+
}
|
|
324892
|
+
return outerError;
|
|
324893
|
+
}
|
|
324894
|
+
function fromApiError(errorObj) {
|
|
324895
|
+
const apiError = errorObj;
|
|
324896
|
+
let outerError;
|
|
324897
|
+
if (apiError.message) {
|
|
324898
|
+
let data = apiError.message;
|
|
324899
|
+
if (typeof data === "string") {
|
|
324900
|
+
try {
|
|
324901
|
+
data = JSON.parse(data);
|
|
324902
|
+
} catch (_) {
|
|
324903
|
+
}
|
|
324904
|
+
}
|
|
324905
|
+
if (Array.isArray(data) && data.length > 0) {
|
|
324906
|
+
data = data[0];
|
|
324907
|
+
}
|
|
324908
|
+
if (typeof data === "object" && data !== null) {
|
|
324909
|
+
if ("error" in data) {
|
|
324910
|
+
outerError = data.error;
|
|
324911
|
+
}
|
|
324912
|
+
}
|
|
324913
|
+
}
|
|
324914
|
+
return outerError;
|
|
324915
|
+
}
|
|
324916
|
+
|
|
324917
|
+
// packages/core/dist/src/utils/googleQuotaErrors.js
|
|
324918
|
+
var TerminalQuotaError = class extends Error {
|
|
324919
|
+
cause;
|
|
324920
|
+
constructor(message, cause) {
|
|
324921
|
+
super(message);
|
|
324922
|
+
this.cause = cause;
|
|
324923
|
+
this.name = "TerminalQuotaError";
|
|
324924
|
+
}
|
|
324925
|
+
};
|
|
324926
|
+
var RetryableQuotaError = class extends Error {
|
|
324927
|
+
cause;
|
|
324928
|
+
retryDelayMs;
|
|
324929
|
+
constructor(message, cause, retryDelaySeconds) {
|
|
324930
|
+
super(message);
|
|
324931
|
+
this.cause = cause;
|
|
324932
|
+
this.name = "RetryableQuotaError";
|
|
324933
|
+
this.retryDelayMs = retryDelaySeconds * 1e3;
|
|
324934
|
+
}
|
|
324935
|
+
};
|
|
324936
|
+
function parseDurationInSeconds(duration) {
|
|
324937
|
+
if (!duration.endsWith("s")) {
|
|
324938
|
+
return null;
|
|
324939
|
+
}
|
|
324940
|
+
const seconds = parseFloat(duration.slice(0, -1));
|
|
324941
|
+
return isNaN(seconds) ? null : seconds;
|
|
324942
|
+
}
|
|
324943
|
+
function classifyGoogleError(error) {
|
|
324944
|
+
const googleApiError = parseGoogleApiError(error);
|
|
324945
|
+
if (!googleApiError || googleApiError.code !== 429) {
|
|
324946
|
+
return error;
|
|
324947
|
+
}
|
|
324948
|
+
const quotaFailure = googleApiError.details.find((d) => d["@type"] === "type.googleapis.com/google.rpc.QuotaFailure");
|
|
324949
|
+
const errorInfo = googleApiError.details.find((d) => d["@type"] === "type.googleapis.com/google.rpc.ErrorInfo");
|
|
324950
|
+
const retryInfo = googleApiError.details.find((d) => d["@type"] === "type.googleapis.com/google.rpc.RetryInfo");
|
|
324951
|
+
if (quotaFailure) {
|
|
324952
|
+
for (const violation of quotaFailure.violations) {
|
|
324953
|
+
const quotaId = violation.quotaId ?? "";
|
|
324954
|
+
if (quotaId.includes("PerDay") || quotaId.includes("Daily")) {
|
|
324955
|
+
return new TerminalQuotaError(`${googleApiError.message}
|
|
324956
|
+
Expected quota reset within 24h.`, googleApiError);
|
|
324957
|
+
}
|
|
324958
|
+
}
|
|
324959
|
+
}
|
|
324960
|
+
if (errorInfo) {
|
|
324961
|
+
if (errorInfo.domain) {
|
|
324962
|
+
const validDomains = [
|
|
324963
|
+
"cloudcode-pa.googleapis.com",
|
|
324964
|
+
"staging-cloudcode-pa.googleapis.com",
|
|
324965
|
+
"autopush-cloudcode-pa.googleapis.com"
|
|
324966
|
+
];
|
|
324967
|
+
if (validDomains.includes(errorInfo.domain)) {
|
|
324968
|
+
if (errorInfo.reason === "RATE_LIMIT_EXCEEDED") {
|
|
324969
|
+
let delaySeconds = 10;
|
|
324970
|
+
if (retryInfo?.retryDelay) {
|
|
324971
|
+
const parsedDelay = parseDurationInSeconds(retryInfo.retryDelay);
|
|
324972
|
+
if (parsedDelay) {
|
|
324973
|
+
delaySeconds = parsedDelay;
|
|
324974
|
+
}
|
|
324975
|
+
}
|
|
324976
|
+
return new RetryableQuotaError(`${googleApiError.message}`, googleApiError, delaySeconds);
|
|
324977
|
+
}
|
|
324978
|
+
if (errorInfo.reason === "QUOTA_EXHAUSTED") {
|
|
324979
|
+
return new TerminalQuotaError(`${googleApiError.message}`, googleApiError);
|
|
324980
|
+
}
|
|
324981
|
+
}
|
|
324982
|
+
}
|
|
324983
|
+
const quotaLimit = errorInfo.metadata?.["quota_limit"] ?? "";
|
|
324984
|
+
if (quotaLimit.includes("PerDay") || quotaLimit.includes("Daily")) {
|
|
324985
|
+
return new TerminalQuotaError(`${googleApiError.message}
|
|
324986
|
+
Expected quota reset within 24h.`, googleApiError);
|
|
324987
|
+
}
|
|
324988
|
+
}
|
|
324989
|
+
if (retryInfo?.retryDelay) {
|
|
324990
|
+
const delaySeconds = parseDurationInSeconds(retryInfo.retryDelay);
|
|
324991
|
+
if (delaySeconds) {
|
|
324992
|
+
if (delaySeconds > 120) {
|
|
324993
|
+
return new TerminalQuotaError(`${googleApiError.message}
|
|
324994
|
+
Suggested retry after ${retryInfo.retryDelay}.`, googleApiError);
|
|
324995
|
+
}
|
|
324996
|
+
return new RetryableQuotaError(`${googleApiError.message}
|
|
324997
|
+
Suggested retry after ${retryInfo.retryDelay}.`, googleApiError, delaySeconds);
|
|
324998
|
+
}
|
|
324999
|
+
}
|
|
325000
|
+
if (quotaFailure) {
|
|
325001
|
+
for (const violation of quotaFailure.violations) {
|
|
325002
|
+
const quotaId = violation.quotaId ?? "";
|
|
325003
|
+
if (quotaId.includes("PerMinute")) {
|
|
325004
|
+
return new RetryableQuotaError(`${googleApiError.message}
|
|
325005
|
+
Suggested retry after 60s.`, googleApiError, 60);
|
|
325006
|
+
}
|
|
325007
|
+
}
|
|
325008
|
+
}
|
|
325009
|
+
if (errorInfo) {
|
|
325010
|
+
const quotaLimit = errorInfo.metadata?.["quota_limit"] ?? "";
|
|
325011
|
+
if (quotaLimit.includes("PerMinute")) {
|
|
325012
|
+
return new RetryableQuotaError(`${errorInfo.reason}
|
|
325013
|
+
Suggested retry after 60s.`, googleApiError, 60);
|
|
325014
|
+
}
|
|
325015
|
+
}
|
|
325016
|
+
return error;
|
|
325017
|
+
}
|
|
325018
|
+
|
|
324666
325019
|
// packages/core/dist/src/utils/delay.js
|
|
324667
325020
|
function createAbortError() {
|
|
324668
325021
|
const abortError = new Error("Aborted");
|
|
@@ -324693,7 +325046,7 @@ function delay2(ms, signal) {
|
|
|
324693
325046
|
// packages/core/dist/src/utils/retry.js
|
|
324694
325047
|
var FETCH_FAILED_MESSAGE = "exception TypeError: fetch failed sending request";
|
|
324695
325048
|
var DEFAULT_RETRY_OPTIONS = {
|
|
324696
|
-
maxAttempts:
|
|
325049
|
+
maxAttempts: 3,
|
|
324697
325050
|
initialDelayMs: 5e3,
|
|
324698
325051
|
maxDelayMs: 3e4,
|
|
324699
325052
|
// 30 seconds
|
|
@@ -324728,7 +325081,6 @@ async function retryWithBackoff(fn, options2) {
|
|
|
324728
325081
|
};
|
|
324729
325082
|
let attempt = 0;
|
|
324730
325083
|
let currentDelay = initialDelayMs;
|
|
324731
|
-
let consecutive429Count = 0;
|
|
324732
325084
|
while (attempt < maxAttempts) {
|
|
324733
325085
|
if (signal?.aborted) {
|
|
324734
325086
|
throw createAbortError();
|
|
@@ -324748,72 +325100,51 @@ async function retryWithBackoff(fn, options2) {
|
|
|
324748
325100
|
if (error instanceof Error && error.name === "AbortError") {
|
|
324749
325101
|
throw error;
|
|
324750
325102
|
}
|
|
324751
|
-
const
|
|
324752
|
-
if (
|
|
324753
|
-
|
|
324754
|
-
|
|
324755
|
-
|
|
324756
|
-
|
|
324757
|
-
|
|
324758
|
-
|
|
324759
|
-
|
|
324760
|
-
|
|
324761
|
-
|
|
324762
|
-
|
|
324763
|
-
} catch (fallbackError) {
|
|
324764
|
-
debugLogger.warn("Fallback to Flash model failed:", fallbackError);
|
|
324765
|
-
}
|
|
324766
|
-
}
|
|
324767
|
-
if (errorStatus === 429 && authType === AuthType2.LOGIN_WITH_GOOGLE && !isProQuotaExceededError(error) && isGenericQuotaExceededError(error) && onPersistent429) {
|
|
324768
|
-
try {
|
|
324769
|
-
const fallbackModel = await onPersistent429(authType, error);
|
|
324770
|
-
if (fallbackModel !== false && fallbackModel !== null) {
|
|
324771
|
-
attempt = 0;
|
|
324772
|
-
consecutive429Count = 0;
|
|
324773
|
-
currentDelay = initialDelayMs;
|
|
324774
|
-
continue;
|
|
324775
|
-
} else {
|
|
324776
|
-
throw error;
|
|
325103
|
+
const classifiedError = classifyGoogleError(error);
|
|
325104
|
+
if (classifiedError instanceof TerminalQuotaError) {
|
|
325105
|
+
if (onPersistent429 && authType === AuthType2.LOGIN_WITH_GOOGLE) {
|
|
325106
|
+
try {
|
|
325107
|
+
const fallbackModel = await onPersistent429(authType, classifiedError);
|
|
325108
|
+
if (fallbackModel) {
|
|
325109
|
+
attempt = 0;
|
|
325110
|
+
currentDelay = initialDelayMs;
|
|
325111
|
+
continue;
|
|
325112
|
+
}
|
|
325113
|
+
} catch (fallbackError) {
|
|
325114
|
+
debugLogger.warn("Fallback to Flash model failed:", fallbackError);
|
|
324777
325115
|
}
|
|
324778
|
-
} catch (fallbackError) {
|
|
324779
|
-
debugLogger.warn("Fallback to Flash model failed:", fallbackError);
|
|
324780
325116
|
}
|
|
325117
|
+
throw classifiedError;
|
|
324781
325118
|
}
|
|
324782
|
-
if (
|
|
324783
|
-
|
|
324784
|
-
|
|
324785
|
-
|
|
324786
|
-
|
|
324787
|
-
|
|
324788
|
-
|
|
324789
|
-
|
|
324790
|
-
|
|
324791
|
-
|
|
324792
|
-
|
|
324793
|
-
|
|
324794
|
-
|
|
324795
|
-
} else {
|
|
324796
|
-
throw error;
|
|
325119
|
+
if (classifiedError instanceof RetryableQuotaError) {
|
|
325120
|
+
if (attempt >= maxAttempts) {
|
|
325121
|
+
if (onPersistent429 && authType === AuthType2.LOGIN_WITH_GOOGLE) {
|
|
325122
|
+
try {
|
|
325123
|
+
const fallbackModel = await onPersistent429(authType, classifiedError);
|
|
325124
|
+
if (fallbackModel) {
|
|
325125
|
+
attempt = 0;
|
|
325126
|
+
currentDelay = initialDelayMs;
|
|
325127
|
+
continue;
|
|
325128
|
+
}
|
|
325129
|
+
} catch (fallbackError) {
|
|
325130
|
+
console.warn("Model fallback failed:", fallbackError);
|
|
325131
|
+
}
|
|
324797
325132
|
}
|
|
324798
|
-
|
|
324799
|
-
debugLogger.warn("Fallback to Flash model failed:", fallbackError);
|
|
325133
|
+
throw classifiedError;
|
|
324800
325134
|
}
|
|
325135
|
+
console.warn(`Attempt ${attempt} failed: ${classifiedError.message}. Retrying after ${classifiedError.retryDelayMs}ms...`);
|
|
325136
|
+
await delay2(classifiedError.retryDelayMs, signal);
|
|
325137
|
+
continue;
|
|
324801
325138
|
}
|
|
324802
325139
|
if (attempt >= maxAttempts || !shouldRetryOnError(error, retryFetchErrors)) {
|
|
324803
325140
|
throw error;
|
|
324804
325141
|
}
|
|
324805
|
-
const
|
|
324806
|
-
|
|
324807
|
-
|
|
324808
|
-
|
|
324809
|
-
|
|
324810
|
-
|
|
324811
|
-
logRetryAttempt(attempt, error, errorStatus);
|
|
324812
|
-
const jitter = currentDelay * 0.3 * (Math.random() * 2 - 1);
|
|
324813
|
-
const delayWithJitter = Math.max(0, currentDelay + jitter);
|
|
324814
|
-
await delay2(delayWithJitter, signal);
|
|
324815
|
-
currentDelay = Math.min(maxDelayMs, currentDelay * 2);
|
|
324816
|
-
}
|
|
325142
|
+
const errorStatus = getErrorStatus(error);
|
|
325143
|
+
logRetryAttempt(attempt, error, errorStatus);
|
|
325144
|
+
const jitter = currentDelay * 0.3 * (Math.random() * 2 - 1);
|
|
325145
|
+
const delayWithJitter = Math.max(0, currentDelay + jitter);
|
|
325146
|
+
await delay2(delayWithJitter, signal);
|
|
325147
|
+
currentDelay = Math.min(maxDelayMs, currentDelay * 2);
|
|
324817
325148
|
}
|
|
324818
325149
|
}
|
|
324819
325150
|
throw new Error("Retry attempts exhausted");
|
|
@@ -324832,36 +325163,6 @@ function getErrorStatus(error) {
|
|
|
324832
325163
|
}
|
|
324833
325164
|
return void 0;
|
|
324834
325165
|
}
|
|
324835
|
-
function getRetryAfterDelayMs(error) {
|
|
324836
|
-
if (typeof error === "object" && error !== null) {
|
|
324837
|
-
if ("response" in error && typeof error.response === "object" && error.response !== null) {
|
|
324838
|
-
const response = error.response;
|
|
324839
|
-
if ("headers" in response && typeof response.headers === "object" && response.headers !== null) {
|
|
324840
|
-
const headers = response.headers;
|
|
324841
|
-
const retryAfterHeader = headers["retry-after"];
|
|
324842
|
-
if (typeof retryAfterHeader === "string") {
|
|
324843
|
-
const retryAfterSeconds = parseInt(retryAfterHeader, 10);
|
|
324844
|
-
if (!isNaN(retryAfterSeconds)) {
|
|
324845
|
-
return retryAfterSeconds * 1e3;
|
|
324846
|
-
}
|
|
324847
|
-
const retryAfterDate = new Date(retryAfterHeader);
|
|
324848
|
-
if (!isNaN(retryAfterDate.getTime())) {
|
|
324849
|
-
return Math.max(0, retryAfterDate.getTime() - Date.now());
|
|
324850
|
-
}
|
|
324851
|
-
}
|
|
324852
|
-
}
|
|
324853
|
-
}
|
|
324854
|
-
}
|
|
324855
|
-
return 0;
|
|
324856
|
-
}
|
|
324857
|
-
function getDelayDurationAndStatus(error) {
|
|
324858
|
-
const errorStatus = getErrorStatus(error);
|
|
324859
|
-
let delayDurationMs = 0;
|
|
324860
|
-
if (errorStatus === 429) {
|
|
324861
|
-
delayDurationMs = getRetryAfterDelayMs(error);
|
|
324862
|
-
}
|
|
324863
|
-
return { delayDurationMs, errorStatus };
|
|
324864
|
-
}
|
|
324865
325166
|
function logRetryAttempt(attempt, error, errorStatus) {
|
|
324866
325167
|
let message = `Attempt ${attempt} failed. Retrying with backoff...`;
|
|
324867
325168
|
if (errorStatus) {
|
|
@@ -325277,12 +325578,11 @@ function getErrorReplaceResult(params, occurrences, expectedReplacements, finalO
|
|
|
325277
325578
|
}
|
|
325278
325579
|
return error;
|
|
325279
325580
|
}
|
|
325280
|
-
var EditToolInvocation2 = class {
|
|
325581
|
+
var EditToolInvocation2 = class extends BaseToolInvocation {
|
|
325281
325582
|
config;
|
|
325282
|
-
params
|
|
325283
|
-
|
|
325583
|
+
constructor(config2, params, messageBus, toolName, displayName) {
|
|
325584
|
+
super(params, messageBus, toolName, displayName);
|
|
325284
325585
|
this.config = config2;
|
|
325285
|
-
this.params = params;
|
|
325286
325586
|
}
|
|
325287
325587
|
toolLocations() {
|
|
325288
325588
|
return [{ path: this.params.file_path }];
|
|
@@ -325449,7 +325749,7 @@ var EditToolInvocation2 = class {
|
|
|
325449
325749
|
* Handles the confirmation prompt for the Edit tool in the CLI.
|
|
325450
325750
|
* It needs to calculate the diff to show the user.
|
|
325451
325751
|
*/
|
|
325452
|
-
async
|
|
325752
|
+
async getConfirmationDetails(abortSignal) {
|
|
325453
325753
|
if (this.config.getApprovalMode() === ApprovalMode.AUTO_EDIT) {
|
|
325454
325754
|
return false;
|
|
325455
325755
|
}
|
|
@@ -325607,8 +325907,11 @@ var EditToolInvocation2 = class {
|
|
|
325607
325907
|
var SmartEditTool = class _SmartEditTool extends BaseDeclarativeTool {
|
|
325608
325908
|
config;
|
|
325609
325909
|
static Name = EDIT_TOOL_NAME;
|
|
325610
|
-
constructor(config2) {
|
|
325611
|
-
super(
|
|
325910
|
+
constructor(config2, messageBus) {
|
|
325911
|
+
super(
|
|
325912
|
+
_SmartEditTool.Name,
|
|
325913
|
+
"Edit",
|
|
325914
|
+
`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.
|
|
325612
325915
|
|
|
325613
325916
|
The user has the ability to modify the \`new_string\` content. If modified, this will be stated in the response.
|
|
325614
325917
|
|
|
@@ -325620,14 +325923,16 @@ var SmartEditTool = class _SmartEditTool extends BaseDeclarativeTool {
|
|
|
325620
325923
|
5. NEVER escape \`old_string\` or \`new_string\`, that would break the exact literal text requirement.
|
|
325621
325924
|
**Important:** If ANY of the above are not satisfied, the tool will fail. CRITICAL for \`old_string\`: Must uniquely identify the single instance to change. Include at least 3 lines of context BEFORE and AFTER the target text, matching whitespace and indentation precisely. If this string matches multiple locations, or does not match exactly, the tool will fail.
|
|
325622
325925
|
6. Prefer to break down complex and long changes into multiple smaller atomic calls to this tool. Always check the content of the file after changes or not finding a string to match.
|
|
325623
|
-
**Multiple replacements:** If there are multiple and ambiguous occurences of the \`old_string\` in the file, the tool will also fail.`,
|
|
325624
|
-
|
|
325625
|
-
|
|
325626
|
-
|
|
325627
|
-
|
|
325628
|
-
|
|
325629
|
-
|
|
325630
|
-
|
|
325926
|
+
**Multiple replacements:** If there are multiple and ambiguous occurences of the \`old_string\` in the file, the tool will also fail.`,
|
|
325927
|
+
Kind.Edit,
|
|
325928
|
+
{
|
|
325929
|
+
properties: {
|
|
325930
|
+
file_path: {
|
|
325931
|
+
description: "The absolute path to the file to modify. Must start with '/'.",
|
|
325932
|
+
type: "string"
|
|
325933
|
+
},
|
|
325934
|
+
instruction: {
|
|
325935
|
+
description: `A clear, semantic instruction for the code change, acting as a high-quality prompt for an expert LLM assistant. It must be self-contained and explain the goal of the change.
|
|
325631
325936
|
|
|
325632
325937
|
A good instruction should concisely answer:
|
|
325633
325938
|
1. WHY is the change needed? (e.g., "To fix a bug where users can be null...")
|
|
@@ -325642,20 +325947,26 @@ A good instruction should concisely answer:
|
|
|
325642
325947
|
- "Fix the bug." (Doesn't explain the bug or the fix)
|
|
325643
325948
|
- "Replace the line with this new line." (Brittle, just repeats the other parameters)
|
|
325644
325949
|
`,
|
|
325645
|
-
|
|
325646
|
-
|
|
325647
|
-
|
|
325648
|
-
|
|
325649
|
-
|
|
325950
|
+
type: "string"
|
|
325951
|
+
},
|
|
325952
|
+
old_string: {
|
|
325953
|
+
description: "The exact literal text to replace, preferably unescaped. Include at least 3 lines of context BEFORE and AFTER the target text, matching whitespace and indentation precisely. If this string is not the exact literal text (i.e. you escaped it) or does not match exactly, the tool will fail.",
|
|
325954
|
+
type: "string"
|
|
325955
|
+
},
|
|
325956
|
+
new_string: {
|
|
325957
|
+
description: "The exact literal text to replace `old_string` with, preferably unescaped. Provide the EXACT text. Ensure the resulting code is correct and idiomatic.",
|
|
325958
|
+
type: "string"
|
|
325959
|
+
}
|
|
325650
325960
|
},
|
|
325651
|
-
|
|
325652
|
-
|
|
325653
|
-
type: "string"
|
|
325654
|
-
}
|
|
325961
|
+
required: ["file_path", "instruction", "old_string", "new_string"],
|
|
325962
|
+
type: "object"
|
|
325655
325963
|
},
|
|
325656
|
-
|
|
325657
|
-
|
|
325658
|
-
|
|
325964
|
+
true,
|
|
325965
|
+
// isOutputMarkdown
|
|
325966
|
+
false,
|
|
325967
|
+
// canUpdateOutput
|
|
325968
|
+
messageBus
|
|
325969
|
+
);
|
|
325659
325970
|
this.config = config2;
|
|
325660
325971
|
}
|
|
325661
325972
|
/**
|
|
@@ -325685,7 +325996,7 @@ A good instruction should concisely answer:
|
|
|
325685
325996
|
return null;
|
|
325686
325997
|
}
|
|
325687
325998
|
createInvocation(params) {
|
|
325688
|
-
return new EditToolInvocation2(this.config, params);
|
|
325999
|
+
return new EditToolInvocation2(this.config, params, this.messageBus, this.name, this.displayName);
|
|
325689
326000
|
}
|
|
325690
326001
|
getModifyContext(_) {
|
|
325691
326002
|
return {
|
|
@@ -325756,14 +326067,22 @@ async function summarizeToolOutput(textToSummarize, geminiClient, abortSignal, m
|
|
|
325756
326067
|
const parsedResponse = await geminiClient.generateContent(contents, toolOutputSummarizerConfig, abortSignal, DEFAULT_GEMINI_FLASH_LITE_MODEL);
|
|
325757
326068
|
return getResponseText(parsedResponse) || textToSummarize;
|
|
325758
326069
|
} catch (error) {
|
|
325759
|
-
|
|
326070
|
+
debugLogger.warn("Failed to summarize tool output.", error);
|
|
325760
326071
|
return textToSummarize;
|
|
325761
326072
|
}
|
|
325762
326073
|
}
|
|
325763
326074
|
|
|
326075
|
+
// node_modules/ansi-regex/index.js
|
|
326076
|
+
function ansiRegex({ onlyFirst = false } = {}) {
|
|
326077
|
+
const ST = "(?:\\u0007|\\u001B\\u005C|\\u009C)";
|
|
326078
|
+
const osc = `(?:\\u001B\\][\\s\\S]*?${ST})`;
|
|
326079
|
+
const csi = "[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]";
|
|
326080
|
+
const pattern = `${osc}|${csi}`;
|
|
326081
|
+
return new RegExp(pattern, onlyFirst ? void 0 : "g");
|
|
326082
|
+
}
|
|
326083
|
+
|
|
325764
326084
|
// node_modules/strip-ansi/index.js
|
|
325765
|
-
var
|
|
325766
|
-
var regex = (0, import_ansi_regex.default)();
|
|
326085
|
+
var regex = ansiRegex();
|
|
325767
326086
|
function stripAnsi(string) {
|
|
325768
326087
|
if (typeof string !== "string") {
|
|
325769
326088
|
throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
|
|
@@ -331301,8 +331620,8 @@ var OUTPUT_UPDATE_INTERVAL_MS = 1e3;
|
|
|
331301
331620
|
var ShellToolInvocation = class extends BaseToolInvocation {
|
|
331302
331621
|
config;
|
|
331303
331622
|
allowlist;
|
|
331304
|
-
constructor(config2, params, allowlist) {
|
|
331305
|
-
super(params);
|
|
331623
|
+
constructor(config2, params, allowlist, messageBus) {
|
|
331624
|
+
super(params, messageBus);
|
|
331306
331625
|
this.config = config2;
|
|
331307
331626
|
this.allowlist = allowlist;
|
|
331308
331627
|
}
|
|
@@ -331316,13 +331635,11 @@ var ShellToolInvocation = class extends BaseToolInvocation {
|
|
|
331316
331635
|
}
|
|
331317
331636
|
return description;
|
|
331318
331637
|
}
|
|
331319
|
-
async
|
|
331638
|
+
async getConfirmationDetails(_abortSignal) {
|
|
331320
331639
|
const command = stripShellWrapper(this.params.command);
|
|
331321
331640
|
const rootCommands = [...new Set(getCommandRoots(command))];
|
|
331322
331641
|
if (!this.config.isInteractive() && this.config.getApprovalMode() !== ApprovalMode.YOLO) {
|
|
331323
|
-
|
|
331324
|
-
const [SHELL_TOOL_NAME2] = SHELL_TOOL_NAMES;
|
|
331325
|
-
if (doesToolInvocationMatch(SHELL_TOOL_NAME2, command, allowedTools)) {
|
|
331642
|
+
if (this.isInvocationAllowlisted(command)) {
|
|
331326
331643
|
return false;
|
|
331327
331644
|
}
|
|
331328
331645
|
throw new Error(`Command "${command}" is not in the list of allowed tools for non-interactive mode.`);
|
|
@@ -331489,6 +331806,14 @@ ${result.output}`;
|
|
|
331489
331806
|
}
|
|
331490
331807
|
}
|
|
331491
331808
|
}
|
|
331809
|
+
isInvocationAllowlisted(command) {
|
|
331810
|
+
const allowedTools = this.config.getAllowedTools() || [];
|
|
331811
|
+
if (allowedTools.length === 0) {
|
|
331812
|
+
return false;
|
|
331813
|
+
}
|
|
331814
|
+
const invocation = { params: { command } };
|
|
331815
|
+
return isShellInvocationAllowlisted(invocation, allowedTools);
|
|
331816
|
+
}
|
|
331492
331817
|
};
|
|
331493
331818
|
function getShellToolDescription() {
|
|
331494
331819
|
const returnedInfo = `
|
|
@@ -331521,7 +331846,7 @@ var ShellTool = class _ShellTool extends BaseDeclarativeTool {
|
|
|
331521
331846
|
config;
|
|
331522
331847
|
static Name = SHELL_TOOL_NAME;
|
|
331523
331848
|
allowlist = /* @__PURE__ */ new Set();
|
|
331524
|
-
constructor(config2) {
|
|
331849
|
+
constructor(config2, messageBus) {
|
|
331525
331850
|
void initializeShellParsers().catch(() => {
|
|
331526
331851
|
});
|
|
331527
331852
|
super(
|
|
@@ -331549,7 +331874,9 @@ var ShellTool = class _ShellTool extends BaseDeclarativeTool {
|
|
|
331549
331874
|
},
|
|
331550
331875
|
false,
|
|
331551
331876
|
// output is not markdown
|
|
331552
|
-
true
|
|
331877
|
+
true,
|
|
331878
|
+
// output can be updated
|
|
331879
|
+
messageBus
|
|
331553
331880
|
);
|
|
331554
331881
|
this.config = config2;
|
|
331555
331882
|
}
|
|
@@ -331580,8 +331907,8 @@ var ShellTool = class _ShellTool extends BaseDeclarativeTool {
|
|
|
331580
331907
|
}
|
|
331581
331908
|
return null;
|
|
331582
331909
|
}
|
|
331583
|
-
createInvocation(params) {
|
|
331584
|
-
return new ShellToolInvocation(this.config, params, this.allowlist);
|
|
331910
|
+
createInvocation(params, messageBus) {
|
|
331911
|
+
return new ShellToolInvocation(this.config, params, this.allowlist, messageBus);
|
|
331585
331912
|
}
|
|
331586
331913
|
};
|
|
331587
331914
|
|
|
@@ -331624,8 +331951,8 @@ async function getCorrectedFileContent(config2, filePath, proposedContent, abort
|
|
|
331624
331951
|
}
|
|
331625
331952
|
var WriteFileToolInvocation = class extends BaseToolInvocation {
|
|
331626
331953
|
config;
|
|
331627
|
-
constructor(config2, params) {
|
|
331628
|
-
super(params);
|
|
331954
|
+
constructor(config2, params, messageBus, toolName, displayName) {
|
|
331955
|
+
super(params, messageBus, toolName, displayName);
|
|
331629
331956
|
this.config = config2;
|
|
331630
331957
|
}
|
|
331631
331958
|
toolLocations() {
|
|
@@ -331635,7 +331962,7 @@ var WriteFileToolInvocation = class extends BaseToolInvocation {
|
|
|
331635
331962
|
const relativePath = makeRelative(this.params.file_path, this.config.getTargetDir());
|
|
331636
331963
|
return `Writing to ${shortenPath(relativePath)}`;
|
|
331637
331964
|
}
|
|
331638
|
-
async
|
|
331965
|
+
async getConfirmationDetails(abortSignal) {
|
|
331639
331966
|
if (this.config.getApprovalMode() === ApprovalMode.AUTO_EDIT) {
|
|
331640
331967
|
return false;
|
|
331641
331968
|
}
|
|
@@ -331768,7 +332095,7 @@ var WriteFileToolInvocation = class extends BaseToolInvocation {
|
|
|
331768
332095
|
var WriteFileTool = class _WriteFileTool extends BaseDeclarativeTool {
|
|
331769
332096
|
config;
|
|
331770
332097
|
static Name = WRITE_FILE_TOOL_NAME;
|
|
331771
|
-
constructor(config2) {
|
|
332098
|
+
constructor(config2, messageBus) {
|
|
331772
332099
|
super(_WriteFileTool.Name, "WriteFile", `Writes content to a specified file in the local filesystem.
|
|
331773
332100
|
|
|
331774
332101
|
The user has the ability to modify \`content\`. If modified, this will be stated in the response.`, Kind.Edit, {
|
|
@@ -331784,7 +332111,7 @@ var WriteFileTool = class _WriteFileTool extends BaseDeclarativeTool {
|
|
|
331784
332111
|
},
|
|
331785
332112
|
required: ["file_path", "content"],
|
|
331786
332113
|
type: "object"
|
|
331787
|
-
});
|
|
332114
|
+
}, true, false, messageBus);
|
|
331788
332115
|
this.config = config2;
|
|
331789
332116
|
}
|
|
331790
332117
|
validateToolParamValues(params) {
|
|
@@ -331813,7 +332140,7 @@ var WriteFileTool = class _WriteFileTool extends BaseDeclarativeTool {
|
|
|
331813
332140
|
return null;
|
|
331814
332141
|
}
|
|
331815
332142
|
createInvocation(params) {
|
|
331816
|
-
return new WriteFileToolInvocation(this.config, params);
|
|
332143
|
+
return new WriteFileToolInvocation(this.config, params, this.messageBus, this.name, this.displayName);
|
|
331817
332144
|
}
|
|
331818
332145
|
getModifyContext(abortSignal) {
|
|
331819
332146
|
return {
|
|
@@ -336149,10 +336476,10 @@ function compile$1(options2 = {}) {
|
|
|
336149
336476
|
}
|
|
336150
336477
|
);
|
|
336151
336478
|
return function(html2, metadata2 = void 0) {
|
|
336152
|
-
return
|
|
336479
|
+
return process21(html2, metadata2, options2, picker, findBaseElements, limitedWalk);
|
|
336153
336480
|
};
|
|
336154
336481
|
}
|
|
336155
|
-
function
|
|
336482
|
+
function process21(html2, metadata2, options2, picker, findBaseElements, walk) {
|
|
336156
336483
|
const maxInputLength = options2.limits.maxInputLength;
|
|
336157
336484
|
if (maxInputLength && html2 && html2.length > maxInputLength) {
|
|
336158
336485
|
console.warn(
|
|
@@ -336917,16 +337244,7 @@ ${textContent2}
|
|
|
336917
337244
|
const displayPrompt = this.params.prompt.length > 100 ? this.params.prompt.substring(0, 97) + "..." : this.params.prompt;
|
|
336918
337245
|
return `Processing URLs and instructions from prompt: "${displayPrompt}"`;
|
|
336919
337246
|
}
|
|
336920
|
-
async
|
|
336921
|
-
if (this.messageBus) {
|
|
336922
|
-
const decision = await this.getMessageBusDecision(abortSignal);
|
|
336923
|
-
if (decision === "ALLOW") {
|
|
336924
|
-
return false;
|
|
336925
|
-
}
|
|
336926
|
-
if (decision === "DENY") {
|
|
336927
|
-
throw new Error("Tool execution denied by policy.");
|
|
336928
|
-
}
|
|
336929
|
-
}
|
|
337247
|
+
async getConfirmationDetails(_abortSignal) {
|
|
336930
337248
|
if (this.config.getApprovalMode() === ApprovalMode.AUTO_EDIT) {
|
|
336931
337249
|
return false;
|
|
336932
337250
|
}
|
|
@@ -337116,20 +337434,9 @@ ${this.config.getTargetDir()}
|
|
|
337116
337434
|
) `;
|
|
337117
337435
|
const paramExcludes = this.params.exclude || [];
|
|
337118
337436
|
const paramUseDefaultExcludes = this.params.useDefaultExcludes !== false;
|
|
337119
|
-
const
|
|
337120
|
-
const
|
|
337121
|
-
...getDefaultExcludes(this.config),
|
|
337122
|
-
...paramExcludes,
|
|
337123
|
-
...geminiIgnorePatterns
|
|
337124
|
-
] : [...paramExcludes, ...geminiIgnorePatterns];
|
|
337125
|
-
let excludeDesc = `Excluding: ${finalExclusionPatternsForDescription.length > 0 ? `patterns like
|
|
337437
|
+
const finalExclusionPatternsForDescription = paramUseDefaultExcludes ? [...getDefaultExcludes(this.config), ...paramExcludes] : [...paramExcludes];
|
|
337438
|
+
const excludeDesc = `Excluding: ${finalExclusionPatternsForDescription.length > 0 ? `patterns like
|
|
337126
337439
|
${finalExclusionPatternsForDescription.slice(0, 2).join("`, `")}${finalExclusionPatternsForDescription.length > 2 ? "...`" : "`"}` : "none specified"}`;
|
|
337127
|
-
if (geminiIgnorePatterns.length > 0) {
|
|
337128
|
-
const geminiPatternsInEffect = geminiIgnorePatterns.filter((p) => finalExclusionPatternsForDescription.includes(p)).length;
|
|
337129
|
-
if (geminiPatternsInEffect > 0) {
|
|
337130
|
-
excludeDesc += ` (includes ${geminiPatternsInEffect} from .geminiignore)`;
|
|
337131
|
-
}
|
|
337132
|
-
}
|
|
337133
337440
|
return `Will attempt to read and concatenate files ${pathDesc}. ${excludeDesc}. File encoding: ${DEFAULT_ENCODING}. Separator: "${DEFAULT_OUTPUT_SEPARATOR_FORMAT.replace("{filePath}", "path/to/file.ext")}".`;
|
|
337134
337441
|
}
|
|
337135
337442
|
async execute(signal) {
|
|
@@ -337169,7 +337476,7 @@ ${finalExclusionPatternsForDescription.slice(0, 2).join("`, `")}${finalExclusion
|
|
|
337169
337476
|
}
|
|
337170
337477
|
const relativeEntries = Array.from(allEntries).map((p) => path45.relative(this.config.getTargetDir(), p));
|
|
337171
337478
|
const fileDiscovery = this.config.getFileService();
|
|
337172
|
-
const { filteredPaths,
|
|
337479
|
+
const { filteredPaths, ignoredCount } = fileDiscovery.filterFilesWithReport(relativeEntries, {
|
|
337173
337480
|
respectGitIgnore: this.params.file_filtering_options?.respect_git_ignore ?? this.config.getFileFilteringOptions().respectGitIgnore ?? DEFAULT_FILE_FILTERING_OPTIONS.respectGitIgnore,
|
|
337174
337481
|
respectGeminiIgnore: this.params.file_filtering_options?.respect_gemini_ignore ?? this.config.getFileFilteringOptions().respectGeminiIgnore ?? DEFAULT_FILE_FILTERING_OPTIONS.respectGeminiIgnore
|
|
337175
337482
|
});
|
|
@@ -337184,16 +337491,10 @@ ${finalExclusionPatternsForDescription.slice(0, 2).join("`, `")}${finalExclusion
|
|
|
337184
337491
|
}
|
|
337185
337492
|
filesToConsider.add(fullPath);
|
|
337186
337493
|
}
|
|
337187
|
-
if (
|
|
337494
|
+
if (ignoredCount > 0) {
|
|
337188
337495
|
skippedFiles.push({
|
|
337189
|
-
path: `${
|
|
337190
|
-
reason: "
|
|
337191
|
-
});
|
|
337192
|
-
}
|
|
337193
|
-
if (geminiIgnoredCount > 0) {
|
|
337194
|
-
skippedFiles.push({
|
|
337195
|
-
path: `${geminiIgnoredCount} file(s)`,
|
|
337196
|
-
reason: "gemini ignored"
|
|
337496
|
+
path: `${ignoredCount} file(s)`,
|
|
337497
|
+
reason: "ignored by project ignore files"
|
|
337197
337498
|
});
|
|
337198
337499
|
}
|
|
337199
337500
|
} catch (error) {
|
|
@@ -337622,6 +337923,10 @@ async function readFullStructure(rootPath, options2) {
|
|
|
337622
337923
|
}
|
|
337623
337924
|
const filesInCurrentDir = [];
|
|
337624
337925
|
const subFoldersInCurrentDir = [];
|
|
337926
|
+
const filterFileOptions = {
|
|
337927
|
+
respectGitIgnore: options2.fileFilteringOptions?.respectGitIgnore,
|
|
337928
|
+
respectGeminiIgnore: options2.fileFilteringOptions?.respectGeminiIgnore
|
|
337929
|
+
};
|
|
337625
337930
|
for (const entry of entries2) {
|
|
337626
337931
|
if (entry.isFile()) {
|
|
337627
337932
|
if (currentItemCount >= options2.maxItems) {
|
|
@@ -337630,11 +337935,8 @@ async function readFullStructure(rootPath, options2) {
|
|
|
337630
337935
|
}
|
|
337631
337936
|
const fileName = entry.name;
|
|
337632
337937
|
const filePath = path46.join(currentPath, fileName);
|
|
337633
|
-
if (options2.fileService) {
|
|
337634
|
-
|
|
337635
|
-
if (shouldIgnore) {
|
|
337636
|
-
continue;
|
|
337637
|
-
}
|
|
337938
|
+
if (options2.fileService?.shouldIgnoreFile(filePath, filterFileOptions)) {
|
|
337939
|
+
continue;
|
|
337638
337940
|
}
|
|
337639
337941
|
if (!options2.fileIncludePattern || options2.fileIncludePattern.test(fileName)) {
|
|
337640
337942
|
filesInCurrentDir.push(fileName);
|
|
@@ -337653,10 +337955,7 @@ async function readFullStructure(rootPath, options2) {
|
|
|
337653
337955
|
}
|
|
337654
337956
|
const subFolderName = entry.name;
|
|
337655
337957
|
const subFolderPath = path46.join(currentPath, subFolderName);
|
|
337656
|
-
|
|
337657
|
-
if (options2.fileService) {
|
|
337658
|
-
isIgnored = options2.fileFilteringOptions.respectGitIgnore && options2.fileService.shouldGitIgnoreFile(subFolderPath) || options2.fileFilteringOptions.respectGeminiIgnore && options2.fileService.shouldGeminiIgnoreFile(subFolderPath);
|
|
337659
|
-
}
|
|
337958
|
+
const isIgnored = options2.fileService?.shouldIgnoreFile(subFolderPath, filterFileOptions) ?? false;
|
|
337660
337959
|
if (options2.ignoredFolders.has(subFolderName) || isIgnored) {
|
|
337661
337960
|
const ignoredSubFolder = {
|
|
337662
337961
|
name: subFolderName,
|
|
@@ -337797,6 +338096,24 @@ ${directoryContext}
|
|
|
337797
338096
|
const initialParts = [{ text: context2 }];
|
|
337798
338097
|
return initialParts;
|
|
337799
338098
|
}
|
|
338099
|
+
async function getInitialChatHistory(config2, extraHistory) {
|
|
338100
|
+
const envParts = await getEnvironmentContext(config2);
|
|
338101
|
+
const envContextString = envParts.map((part) => part.text || "").join("\n\n");
|
|
338102
|
+
const allSetupText = `
|
|
338103
|
+
${envContextString}
|
|
338104
|
+
|
|
338105
|
+
Reminder: Do not return an empty response when a tool call is required.
|
|
338106
|
+
|
|
338107
|
+
My setup is complete. I will provide my first command in the next turn.
|
|
338108
|
+
`.trim();
|
|
338109
|
+
return [
|
|
338110
|
+
{
|
|
338111
|
+
role: "user",
|
|
338112
|
+
parts: [{ text: allSetupText }]
|
|
338113
|
+
},
|
|
338114
|
+
...extraHistory ?? []
|
|
338115
|
+
];
|
|
338116
|
+
}
|
|
337800
338117
|
|
|
337801
338118
|
// packages/core/dist/src/utils/generateContentResponseUtilities.js
|
|
337802
338119
|
function getResponseTextFromParts(parts2) {
|
|
@@ -337929,8 +338246,10 @@ ${truncatedContent}`,
|
|
|
337929
338246
|
};
|
|
337930
338247
|
}
|
|
337931
338248
|
}
|
|
337932
|
-
var CoreToolScheduler = class {
|
|
337933
|
-
|
|
338249
|
+
var CoreToolScheduler = class _CoreToolScheduler {
|
|
338250
|
+
// Static WeakMap to track which MessageBus instances already have a handler subscribed
|
|
338251
|
+
// This prevents duplicate subscriptions when multiple CoreToolScheduler instances are created
|
|
338252
|
+
static subscribedMessageBuses = /* @__PURE__ */ new WeakMap();
|
|
337934
338253
|
toolCalls = [];
|
|
337935
338254
|
outputUpdateHandler;
|
|
337936
338255
|
onAllToolCallsComplete;
|
|
@@ -337940,10 +338259,12 @@ var CoreToolScheduler = class {
|
|
|
337940
338259
|
onEditorClose;
|
|
337941
338260
|
isFinalizingToolCalls = false;
|
|
337942
338261
|
isScheduling = false;
|
|
338262
|
+
isCancelling = false;
|
|
337943
338263
|
requestQueue = [];
|
|
338264
|
+
toolCallQueue = [];
|
|
338265
|
+
completedToolCallsForBatch = [];
|
|
337944
338266
|
constructor(options2) {
|
|
337945
338267
|
this.config = options2.config;
|
|
337946
|
-
this.toolRegistry = options2.config.getToolRegistry();
|
|
337947
338268
|
this.outputUpdateHandler = options2.outputUpdateHandler;
|
|
337948
338269
|
this.onAllToolCallsComplete = options2.onAllToolCallsComplete;
|
|
337949
338270
|
this.onToolCallsUpdate = options2.onToolCallsUpdate;
|
|
@@ -337951,10 +338272,21 @@ var CoreToolScheduler = class {
|
|
|
337951
338272
|
this.onEditorClose = options2.onEditorClose;
|
|
337952
338273
|
if (this.config.getEnableMessageBusIntegration()) {
|
|
337953
338274
|
const messageBus = this.config.getMessageBus();
|
|
337954
|
-
|
|
338275
|
+
if (!_CoreToolScheduler.subscribedMessageBuses.has(messageBus)) {
|
|
338276
|
+
const sharedHandler = (request3) => {
|
|
338277
|
+
messageBus.publish({
|
|
338278
|
+
type: MessageBusType.TOOL_CONFIRMATION_RESPONSE,
|
|
338279
|
+
correlationId: request3.correlationId,
|
|
338280
|
+
confirmed: false,
|
|
338281
|
+
requiresUserConfirmation: true
|
|
338282
|
+
});
|
|
338283
|
+
};
|
|
338284
|
+
messageBus.subscribe(MessageBusType.TOOL_CONFIRMATION_REQUEST, sharedHandler);
|
|
338285
|
+
_CoreToolScheduler.subscribedMessageBuses.set(messageBus, sharedHandler);
|
|
338286
|
+
}
|
|
337955
338287
|
}
|
|
337956
338288
|
}
|
|
337957
|
-
setStatusInternal(targetCallId, newStatus, auxiliaryData) {
|
|
338289
|
+
setStatusInternal(targetCallId, newStatus, signal, auxiliaryData) {
|
|
337958
338290
|
this.toolCalls = this.toolCalls.map((currentCall) => {
|
|
337959
338291
|
if (currentCall.request.callId !== targetCallId || currentCall.status === "success" || currentCall.status === "error" || currentCall.status === "cancelled") {
|
|
337960
338292
|
return currentCall;
|
|
@@ -338073,7 +338405,6 @@ var CoreToolScheduler = class {
|
|
|
338073
338405
|
}
|
|
338074
338406
|
});
|
|
338075
338407
|
this.notifyToolCallsUpdate();
|
|
338076
|
-
this.checkAndNotifyCompletion();
|
|
338077
338408
|
}
|
|
338078
338409
|
setArgsInternal(targetCallId, args2) {
|
|
338079
338410
|
this.toolCalls = this.toolCalls.map((call) => {
|
|
@@ -338118,7 +338449,7 @@ var CoreToolScheduler = class {
|
|
|
338118
338449
|
* @returns A suggestion string like " Did you mean 'tool'?" or " Did you mean one of: 'tool1', 'tool2'?", or an empty string if no suggestions are found.
|
|
338119
338450
|
*/
|
|
338120
338451
|
getToolSuggestion(unknownToolName, topN = 3) {
|
|
338121
|
-
const allToolNames = this.
|
|
338452
|
+
const allToolNames = this.config.getToolRegistry().getAllToolNames();
|
|
338122
338453
|
const matches = allToolNames.map((toolName) => ({
|
|
338123
338454
|
name: toolName,
|
|
338124
338455
|
distance: import_fast_levenshtein.default.get(unknownToolName, toolName)
|
|
@@ -338162,15 +338493,31 @@ var CoreToolScheduler = class {
|
|
|
338162
338493
|
}
|
|
338163
338494
|
return this._schedule(request3, signal);
|
|
338164
338495
|
}
|
|
338496
|
+
cancelAll(signal) {
|
|
338497
|
+
if (this.isCancelling) {
|
|
338498
|
+
return;
|
|
338499
|
+
}
|
|
338500
|
+
this.isCancelling = true;
|
|
338501
|
+
if (this.toolCalls.length > 0) {
|
|
338502
|
+
const activeCall = this.toolCalls[0];
|
|
338503
|
+
if (activeCall.status === "awaiting_approval" || activeCall.status === "executing" || activeCall.status === "scheduled" || activeCall.status === "validating") {
|
|
338504
|
+
this.setStatusInternal(activeCall.request.callId, "cancelled", signal, "User cancelled the operation.");
|
|
338505
|
+
}
|
|
338506
|
+
}
|
|
338507
|
+
this._cancelAllQueuedCalls();
|
|
338508
|
+
void this.checkAndNotifyCompletion(signal);
|
|
338509
|
+
}
|
|
338165
338510
|
async _schedule(request3, signal) {
|
|
338166
338511
|
this.isScheduling = true;
|
|
338512
|
+
this.isCancelling = false;
|
|
338167
338513
|
try {
|
|
338168
338514
|
if (this.isRunning()) {
|
|
338169
338515
|
throw new Error("Cannot schedule new tool calls while other tool calls are actively running (executing or awaiting approval).");
|
|
338170
338516
|
}
|
|
338171
338517
|
const requestsToProcess = Array.isArray(request3) ? request3 : [request3];
|
|
338518
|
+
this.completedToolCallsForBatch = [];
|
|
338172
338519
|
const newToolCalls = requestsToProcess.map((reqInfo) => {
|
|
338173
|
-
const toolInstance = this.
|
|
338520
|
+
const toolInstance = this.config.getToolRegistry().getTool(reqInfo.name);
|
|
338174
338521
|
if (!toolInstance) {
|
|
338175
338522
|
const suggestion = this.getToolSuggestion(reqInfo.name);
|
|
338176
338523
|
const errorMessage = `Tool "${reqInfo.name}" not found in registry. Tools must use the exact names that are registered.${suggestion}`;
|
|
@@ -338199,28 +338546,44 @@ var CoreToolScheduler = class {
|
|
|
338199
338546
|
startTime: Date.now()
|
|
338200
338547
|
};
|
|
338201
338548
|
});
|
|
338202
|
-
this.
|
|
338203
|
-
this.
|
|
338204
|
-
|
|
338205
|
-
|
|
338206
|
-
|
|
338549
|
+
this.toolCallQueue.push(...newToolCalls);
|
|
338550
|
+
await this._processNextInQueue(signal);
|
|
338551
|
+
} finally {
|
|
338552
|
+
this.isScheduling = false;
|
|
338553
|
+
}
|
|
338554
|
+
}
|
|
338555
|
+
async _processNextInQueue(signal) {
|
|
338556
|
+
if (this.toolCalls.length > 0 || this.toolCallQueue.length === 0) {
|
|
338557
|
+
return;
|
|
338558
|
+
}
|
|
338559
|
+
if (signal.aborted) {
|
|
338560
|
+
this._cancelAllQueuedCalls();
|
|
338561
|
+
await this.checkAndNotifyCompletion(signal);
|
|
338562
|
+
return;
|
|
338563
|
+
}
|
|
338564
|
+
const toolCall = this.toolCallQueue.shift();
|
|
338565
|
+
this.toolCalls = [toolCall];
|
|
338566
|
+
this.notifyToolCallsUpdate();
|
|
338567
|
+
if (toolCall.status === "error") {
|
|
338568
|
+
await this.checkAndNotifyCompletion(signal);
|
|
338569
|
+
return;
|
|
338570
|
+
}
|
|
338571
|
+
if (toolCall.status === "validating") {
|
|
338572
|
+
const { request: reqInfo, invocation } = toolCall;
|
|
338573
|
+
try {
|
|
338574
|
+
if (signal.aborted) {
|
|
338575
|
+
this.setStatusInternal(reqInfo.callId, "cancelled", signal, "Tool call cancelled by user.");
|
|
338576
|
+
await this.checkAndNotifyCompletion(signal);
|
|
338577
|
+
return;
|
|
338207
338578
|
}
|
|
338208
|
-
const
|
|
338209
|
-
|
|
338210
|
-
|
|
338211
|
-
|
|
338212
|
-
|
|
338213
|
-
|
|
338214
|
-
}
|
|
338215
|
-
const confirmationDetails = await invocation.shouldConfirmExecute(signal);
|
|
338216
|
-
if (!confirmationDetails) {
|
|
338217
|
-
this.setToolCallOutcome(reqInfo.callId, ToolConfirmationOutcome.ProceedAlways);
|
|
338218
|
-
this.setStatusInternal(reqInfo.callId, "scheduled");
|
|
338219
|
-
continue;
|
|
338220
|
-
}
|
|
338221
|
-
if (this.isAutoApproved(validatingCall)) {
|
|
338579
|
+
const confirmationDetails = await invocation.shouldConfirmExecute(signal);
|
|
338580
|
+
if (!confirmationDetails) {
|
|
338581
|
+
this.setToolCallOutcome(reqInfo.callId, ToolConfirmationOutcome.ProceedAlways);
|
|
338582
|
+
this.setStatusInternal(reqInfo.callId, "scheduled", signal);
|
|
338583
|
+
} else {
|
|
338584
|
+
if (this.isAutoApproved(toolCall)) {
|
|
338222
338585
|
this.setToolCallOutcome(reqInfo.callId, ToolConfirmationOutcome.ProceedAlways);
|
|
338223
|
-
this.setStatusInternal(reqInfo.callId, "scheduled");
|
|
338586
|
+
this.setStatusInternal(reqInfo.callId, "scheduled", signal);
|
|
338224
338587
|
} else {
|
|
338225
338588
|
if (confirmationDetails.type === "edit" && confirmationDetails.ideConfirmation) {
|
|
338226
338589
|
confirmationDetails.ideConfirmation.then((resolution) => {
|
|
@@ -338236,33 +338599,30 @@ var CoreToolScheduler = class {
|
|
|
338236
338599
|
...confirmationDetails,
|
|
338237
338600
|
onConfirm: (outcome, payload) => this.handleConfirmationResponse(reqInfo.callId, originalOnConfirm, outcome, signal, payload)
|
|
338238
338601
|
};
|
|
338239
|
-
this.setStatusInternal(reqInfo.callId, "awaiting_approval", wrappedConfirmationDetails);
|
|
338240
|
-
}
|
|
338241
|
-
} catch (error) {
|
|
338242
|
-
if (signal.aborted) {
|
|
338243
|
-
this.setStatusInternal(reqInfo.callId, "cancelled", "Tool call cancelled by user.");
|
|
338244
|
-
continue;
|
|
338602
|
+
this.setStatusInternal(reqInfo.callId, "awaiting_approval", signal, wrappedConfirmationDetails);
|
|
338245
338603
|
}
|
|
338246
|
-
|
|
338604
|
+
}
|
|
338605
|
+
} catch (error) {
|
|
338606
|
+
if (signal.aborted) {
|
|
338607
|
+
this.setStatusInternal(reqInfo.callId, "cancelled", signal, "Tool call cancelled by user.");
|
|
338608
|
+
await this.checkAndNotifyCompletion(signal);
|
|
338609
|
+
} else {
|
|
338610
|
+
this.setStatusInternal(reqInfo.callId, "error", signal, createErrorResponse(reqInfo, error instanceof Error ? error : new Error(String(error)), ToolErrorType.UNHANDLED_EXCEPTION));
|
|
338611
|
+
await this.checkAndNotifyCompletion(signal);
|
|
338247
338612
|
}
|
|
338248
338613
|
}
|
|
338249
|
-
await this.attemptExecutionOfScheduledCalls(signal);
|
|
338250
|
-
void this.checkAndNotifyCompletion();
|
|
338251
|
-
} finally {
|
|
338252
|
-
this.isScheduling = false;
|
|
338253
338614
|
}
|
|
338615
|
+
await this.attemptExecutionOfScheduledCalls(signal);
|
|
338254
338616
|
}
|
|
338255
338617
|
async handleConfirmationResponse(callId, originalOnConfirm, outcome, signal, payload) {
|
|
338256
338618
|
const toolCall = this.toolCalls.find((c4) => c4.request.callId === callId && c4.status === "awaiting_approval");
|
|
338257
338619
|
if (toolCall && toolCall.status === "awaiting_approval") {
|
|
338258
338620
|
await originalOnConfirm(outcome);
|
|
338259
338621
|
}
|
|
338260
|
-
if (outcome === ToolConfirmationOutcome.ProceedAlways) {
|
|
338261
|
-
await this.autoApproveCompatiblePendingTools(signal, callId);
|
|
338262
|
-
}
|
|
338263
338622
|
this.setToolCallOutcome(callId, outcome);
|
|
338264
338623
|
if (outcome === ToolConfirmationOutcome.Cancel || signal.aborted) {
|
|
338265
|
-
this.
|
|
338624
|
+
this.cancelAll(signal);
|
|
338625
|
+
return;
|
|
338266
338626
|
} else if (outcome === ToolConfirmationOutcome.ModifyWithEditor) {
|
|
338267
338627
|
const waitingToolCall = toolCall;
|
|
338268
338628
|
if (isModifiableDeclarativeTool(waitingToolCall.tool)) {
|
|
@@ -338271,13 +338631,13 @@ var CoreToolScheduler = class {
|
|
|
338271
338631
|
if (!editorType) {
|
|
338272
338632
|
return;
|
|
338273
338633
|
}
|
|
338274
|
-
this.setStatusInternal(callId, "awaiting_approval", {
|
|
338634
|
+
this.setStatusInternal(callId, "awaiting_approval", signal, {
|
|
338275
338635
|
...waitingToolCall.confirmationDetails,
|
|
338276
338636
|
isModifying: true
|
|
338277
338637
|
});
|
|
338278
338638
|
const { updatedParams, updatedDiff } = await modifyWithEditor(waitingToolCall.request.args, modifyContext, editorType, signal, this.onEditorClose);
|
|
338279
338639
|
this.setArgsInternal(callId, updatedParams);
|
|
338280
|
-
this.setStatusInternal(callId, "awaiting_approval", {
|
|
338640
|
+
this.setStatusInternal(callId, "awaiting_approval", signal, {
|
|
338281
338641
|
...waitingToolCall.confirmationDetails,
|
|
338282
338642
|
fileDiff: updatedDiff,
|
|
338283
338643
|
isModifying: false
|
|
@@ -338287,7 +338647,7 @@ var CoreToolScheduler = class {
|
|
|
338287
338647
|
if (payload?.newContent && toolCall) {
|
|
338288
338648
|
await this._applyInlineModify(toolCall, payload, signal);
|
|
338289
338649
|
}
|
|
338290
|
-
this.setStatusInternal(callId, "scheduled");
|
|
338650
|
+
this.setStatusInternal(callId, "scheduled", signal);
|
|
338291
338651
|
}
|
|
338292
338652
|
await this.attemptExecutionOfScheduledCalls(signal);
|
|
338293
338653
|
}
|
|
@@ -338306,7 +338666,7 @@ var CoreToolScheduler = class {
|
|
|
338306
338666
|
const updatedParams = modifyContext.createUpdatedParams(currentContent, payload.newContent, toolCall.request.args);
|
|
338307
338667
|
const updatedDiff = createPatch(modifyContext.getFilePath(toolCall.request.args), currentContent, payload.newContent, "Current", "Proposed");
|
|
338308
338668
|
this.setArgsInternal(toolCall.request.callId, updatedParams);
|
|
338309
|
-
this.setStatusInternal(toolCall.request.callId, "awaiting_approval", {
|
|
338669
|
+
this.setStatusInternal(toolCall.request.callId, "awaiting_approval", signal, {
|
|
338310
338670
|
...toolCall.confirmationDetails,
|
|
338311
338671
|
fileDiff: updatedDiff
|
|
338312
338672
|
});
|
|
@@ -338321,7 +338681,7 @@ var CoreToolScheduler = class {
|
|
|
338321
338681
|
const scheduledCall = toolCall;
|
|
338322
338682
|
const { callId, name: toolName } = scheduledCall.request;
|
|
338323
338683
|
const invocation = scheduledCall.invocation;
|
|
338324
|
-
this.setStatusInternal(callId, "executing");
|
|
338684
|
+
this.setStatusInternal(callId, "executing", signal);
|
|
338325
338685
|
const liveOutputCallback = scheduledCall.tool.canUpdateOutput && this.outputUpdateHandler ? (outputChunk) => {
|
|
338326
338686
|
if (this.outputUpdateHandler) {
|
|
338327
338687
|
this.outputUpdateHandler(callId, outputChunk);
|
|
@@ -338343,10 +338703,8 @@ var CoreToolScheduler = class {
|
|
|
338343
338703
|
try {
|
|
338344
338704
|
const toolResult = await promise;
|
|
338345
338705
|
if (signal.aborted) {
|
|
338346
|
-
this.setStatusInternal(callId, "cancelled", "User cancelled tool execution.");
|
|
338347
|
-
|
|
338348
|
-
}
|
|
338349
|
-
if (toolResult.error === void 0) {
|
|
338706
|
+
this.setStatusInternal(callId, "cancelled", signal, "User cancelled tool execution.");
|
|
338707
|
+
} else if (toolResult.error === void 0) {
|
|
338350
338708
|
let content = toolResult.llmContent;
|
|
338351
338709
|
let outputFile = void 0;
|
|
338352
338710
|
const contentLength = typeof content === "string" ? content.length : void 0;
|
|
@@ -338377,45 +338735,106 @@ var CoreToolScheduler = class {
|
|
|
338377
338735
|
outputFile,
|
|
338378
338736
|
contentLength
|
|
338379
338737
|
};
|
|
338380
|
-
this.setStatusInternal(callId, "success", successResponse);
|
|
338738
|
+
this.setStatusInternal(callId, "success", signal, successResponse);
|
|
338381
338739
|
} else {
|
|
338382
338740
|
const error = new Error(toolResult.error.message);
|
|
338383
338741
|
const errorResponse = createErrorResponse(scheduledCall.request, error, toolResult.error.type);
|
|
338384
|
-
this.setStatusInternal(callId, "error", errorResponse);
|
|
338742
|
+
this.setStatusInternal(callId, "error", signal, errorResponse);
|
|
338385
338743
|
}
|
|
338386
338744
|
} catch (executionError) {
|
|
338387
338745
|
if (signal.aborted) {
|
|
338388
|
-
this.setStatusInternal(callId, "cancelled", "User cancelled tool execution.");
|
|
338746
|
+
this.setStatusInternal(callId, "cancelled", signal, "User cancelled tool execution.");
|
|
338389
338747
|
} else {
|
|
338390
|
-
this.setStatusInternal(callId, "error", createErrorResponse(scheduledCall.request, executionError instanceof Error ? executionError : new Error(String(executionError)), ToolErrorType.UNHANDLED_EXCEPTION));
|
|
338748
|
+
this.setStatusInternal(callId, "error", signal, createErrorResponse(scheduledCall.request, executionError instanceof Error ? executionError : new Error(String(executionError)), ToolErrorType.UNHANDLED_EXCEPTION));
|
|
338391
338749
|
}
|
|
338392
338750
|
}
|
|
338751
|
+
await this.checkAndNotifyCompletion(signal);
|
|
338393
338752
|
}
|
|
338394
338753
|
}
|
|
338395
338754
|
}
|
|
338396
|
-
async checkAndNotifyCompletion() {
|
|
338397
|
-
|
|
338398
|
-
|
|
338399
|
-
|
|
338755
|
+
async checkAndNotifyCompletion(signal) {
|
|
338756
|
+
if (this.toolCalls.length === 0) {
|
|
338757
|
+
if (signal.aborted && this.toolCallQueue.length > 0) {
|
|
338758
|
+
this._cancelAllQueuedCalls();
|
|
338759
|
+
}
|
|
338760
|
+
} else {
|
|
338761
|
+
const activeCall = this.toolCalls[0];
|
|
338762
|
+
const isTerminal = activeCall.status === "success" || activeCall.status === "error" || activeCall.status === "cancelled";
|
|
338763
|
+
if (!isTerminal) {
|
|
338764
|
+
return;
|
|
338765
|
+
}
|
|
338766
|
+
const completedCall = activeCall;
|
|
338767
|
+
this.completedToolCallsForBatch.push(completedCall);
|
|
338768
|
+
logToolCall(this.config, new ToolCallEvent(completedCall));
|
|
338400
338769
|
this.toolCalls = [];
|
|
338401
|
-
|
|
338402
|
-
|
|
338770
|
+
}
|
|
338771
|
+
if (this.toolCallQueue.length === 0 || signal.aborted) {
|
|
338772
|
+
if (signal.aborted) {
|
|
338773
|
+
this._cancelAllQueuedCalls();
|
|
338774
|
+
}
|
|
338775
|
+
if (this.completedToolCallsForBatch.length === 0 && !signal.aborted) {
|
|
338776
|
+
return;
|
|
338403
338777
|
}
|
|
338404
338778
|
if (this.onAllToolCallsComplete) {
|
|
338405
338779
|
this.isFinalizingToolCalls = true;
|
|
338406
|
-
await this.onAllToolCallsComplete(
|
|
338780
|
+
await this.onAllToolCallsComplete(this.completedToolCallsForBatch);
|
|
338781
|
+
this.completedToolCallsForBatch = [];
|
|
338407
338782
|
this.isFinalizingToolCalls = false;
|
|
338408
338783
|
}
|
|
338784
|
+
this.isCancelling = false;
|
|
338409
338785
|
this.notifyToolCallsUpdate();
|
|
338410
338786
|
if (this.requestQueue.length > 0) {
|
|
338411
338787
|
const next = this.requestQueue.shift();
|
|
338412
338788
|
this._schedule(next.request, next.signal).then(next.resolve).catch(next.reject);
|
|
338413
338789
|
}
|
|
338790
|
+
} else {
|
|
338791
|
+
await this._processNextInQueue(signal);
|
|
338792
|
+
}
|
|
338793
|
+
}
|
|
338794
|
+
_cancelAllQueuedCalls() {
|
|
338795
|
+
while (this.toolCallQueue.length > 0) {
|
|
338796
|
+
const queuedCall = this.toolCallQueue.shift();
|
|
338797
|
+
if (queuedCall.status === "error") {
|
|
338798
|
+
this.completedToolCallsForBatch.push(queuedCall);
|
|
338799
|
+
continue;
|
|
338800
|
+
}
|
|
338801
|
+
const durationMs = "startTime" in queuedCall && queuedCall.startTime ? Date.now() - queuedCall.startTime : void 0;
|
|
338802
|
+
const errorMessage = "[Operation Cancelled] User cancelled the operation.";
|
|
338803
|
+
this.completedToolCallsForBatch.push({
|
|
338804
|
+
request: queuedCall.request,
|
|
338805
|
+
tool: queuedCall.tool,
|
|
338806
|
+
invocation: queuedCall.invocation,
|
|
338807
|
+
status: "cancelled",
|
|
338808
|
+
response: {
|
|
338809
|
+
callId: queuedCall.request.callId,
|
|
338810
|
+
responseParts: [
|
|
338811
|
+
{
|
|
338812
|
+
functionResponse: {
|
|
338813
|
+
id: queuedCall.request.callId,
|
|
338814
|
+
name: queuedCall.request.name,
|
|
338815
|
+
response: {
|
|
338816
|
+
error: errorMessage
|
|
338817
|
+
}
|
|
338818
|
+
}
|
|
338819
|
+
}
|
|
338820
|
+
],
|
|
338821
|
+
resultDisplay: void 0,
|
|
338822
|
+
error: void 0,
|
|
338823
|
+
errorType: void 0,
|
|
338824
|
+
contentLength: errorMessage.length
|
|
338825
|
+
},
|
|
338826
|
+
durationMs,
|
|
338827
|
+
outcome: ToolConfirmationOutcome.Cancel
|
|
338828
|
+
});
|
|
338414
338829
|
}
|
|
338415
338830
|
}
|
|
338416
338831
|
notifyToolCallsUpdate() {
|
|
338417
338832
|
if (this.onToolCallsUpdate) {
|
|
338418
|
-
this.onToolCallsUpdate([
|
|
338833
|
+
this.onToolCallsUpdate([
|
|
338834
|
+
...this.completedToolCallsForBatch,
|
|
338835
|
+
...this.toolCalls,
|
|
338836
|
+
...this.toolCallQueue
|
|
338837
|
+
]);
|
|
338419
338838
|
}
|
|
338420
338839
|
}
|
|
338421
338840
|
setToolCallOutcome(callId, outcome) {
|
|
@@ -338428,22 +338847,6 @@ var CoreToolScheduler = class {
|
|
|
338428
338847
|
};
|
|
338429
338848
|
});
|
|
338430
338849
|
}
|
|
338431
|
-
/**
|
|
338432
|
-
* Handle tool confirmation requests from the message bus when policy decision is ASK_USER.
|
|
338433
|
-
* This publishes a response with requiresUserConfirmation=true to signal the tool
|
|
338434
|
-
* that it should fall back to its legacy confirmation UI.
|
|
338435
|
-
*/
|
|
338436
|
-
handleToolConfirmationRequest(request3) {
|
|
338437
|
-
const messageBus = this.config.getMessageBus();
|
|
338438
|
-
messageBus.publish({
|
|
338439
|
-
type: MessageBusType.TOOL_CONFIRMATION_RESPONSE,
|
|
338440
|
-
correlationId: request3.correlationId,
|
|
338441
|
-
confirmed: false,
|
|
338442
|
-
// Not auto-approved
|
|
338443
|
-
requiresUserConfirmation: true
|
|
338444
|
-
// Use legacy UI confirmation
|
|
338445
|
-
});
|
|
338446
|
-
}
|
|
338447
338850
|
isAutoApproved(toolCall) {
|
|
338448
338851
|
if (this.config.getApprovalMode() === ApprovalMode.YOLO) {
|
|
338449
338852
|
return true;
|
|
@@ -338456,20 +338859,6 @@ var CoreToolScheduler = class {
|
|
|
338456
338859
|
}
|
|
338457
338860
|
return doesToolInvocationMatch(tool, invocation, allowedTools);
|
|
338458
338861
|
}
|
|
338459
|
-
async autoApproveCompatiblePendingTools(signal, triggeringCallId) {
|
|
338460
|
-
const pendingTools = this.toolCalls.filter((call) => call.status === "awaiting_approval" && call.request.callId !== triggeringCallId);
|
|
338461
|
-
for (const pendingTool of pendingTools) {
|
|
338462
|
-
try {
|
|
338463
|
-
const stillNeedsConfirmation = await pendingTool.invocation.shouldConfirmExecute(signal);
|
|
338464
|
-
if (!stillNeedsConfirmation) {
|
|
338465
|
-
this.setToolCallOutcome(pendingTool.request.callId, ToolConfirmationOutcome.ProceedAlways);
|
|
338466
|
-
this.setStatusInternal(pendingTool.request.callId, "scheduled");
|
|
338467
|
-
}
|
|
338468
|
-
} catch (error) {
|
|
338469
|
-
console.error(`Error checking confirmation for tool ${pendingTool.request.callId}:`, error);
|
|
338470
|
-
}
|
|
338471
|
-
}
|
|
338472
|
-
}
|
|
338473
338862
|
};
|
|
338474
338863
|
|
|
338475
338864
|
// packages/core/dist/src/utils/thoughtUtils.js
|
|
@@ -339362,7 +339751,7 @@ function getCitations(resp) {
|
|
|
339362
339751
|
import path49 from "node:path";
|
|
339363
339752
|
import fs47 from "node:fs";
|
|
339364
339753
|
import os17 from "node:os";
|
|
339365
|
-
import
|
|
339754
|
+
import process22 from "node:process";
|
|
339366
339755
|
|
|
339367
339756
|
// packages/core/dist/src/agents/codebase-investigator.js
|
|
339368
339757
|
var CodebaseInvestigationReportSchema = external_exports.object({
|
|
@@ -339512,7 +339901,7 @@ function resolvePathFromEnv(envVar) {
|
|
|
339512
339901
|
function getCoreSystemPrompt(config2, userMemory) {
|
|
339513
339902
|
let systemMdEnabled = false;
|
|
339514
339903
|
let systemMdPath = path49.resolve(path49.join(GEMINI_DIR, "system.md"));
|
|
339515
|
-
const systemMdResolution = resolvePathFromEnv(
|
|
339904
|
+
const systemMdResolution = resolvePathFromEnv(process22.env["GEMINI_SYSTEM_MD"]);
|
|
339516
339905
|
if (systemMdResolution.value && !systemMdResolution.isDisabled) {
|
|
339517
339906
|
systemMdEnabled = true;
|
|
339518
339907
|
if (!systemMdResolution.isSwitch) {
|
|
@@ -339630,8 +340019,8 @@ ${function() {
|
|
|
339630
340019
|
- **Feedback:** To report a bug or provide feedback, please use the /bug command.
|
|
339631
340020
|
|
|
339632
340021
|
${function() {
|
|
339633
|
-
const isSandboxExec =
|
|
339634
|
-
const isGenericSandbox = !!
|
|
340022
|
+
const isSandboxExec = process22.env["SANDBOX"] === "sandbox-exec";
|
|
340023
|
+
const isGenericSandbox = !!process22.env["SANDBOX"];
|
|
339635
340024
|
if (isSandboxExec) {
|
|
339636
340025
|
return `
|
|
339637
340026
|
# macOS Seatbelt
|
|
@@ -339651,7 +340040,7 @@ You are running outside of a sandbox container, directly on the user's system. F
|
|
|
339651
340040
|
}()}
|
|
339652
340041
|
|
|
339653
340042
|
${function() {
|
|
339654
|
-
if (isGitRepository(
|
|
340043
|
+
if (isGitRepository(process22.cwd())) {
|
|
339655
340044
|
return `
|
|
339656
340045
|
# Git Repository
|
|
339657
340046
|
- The current working (project) directory is being managed by a git repository.
|
|
@@ -339675,7 +340064,7 @@ ${function() {
|
|
|
339675
340064
|
# Final Reminder
|
|
339676
340065
|
Your core function is efficient and safe assistance. Balance extreme conciseness with the crucial need for clarity, especially regarding safety and potential system modifications. Always prioritize user control and project conventions. Never make assumptions about the contents of files; instead use '${READ_FILE_TOOL_NAME}' or '${READ_MANY_FILES_TOOL_NAME}' to ensure you aren't making broad assumptions. Finally, you are an agent - please keep going until the user's query is completely resolved.
|
|
339677
340066
|
`.trim();
|
|
339678
|
-
const writeSystemMdResolution = resolvePathFromEnv(
|
|
340067
|
+
const writeSystemMdResolution = resolvePathFromEnv(process22.env["GEMINI_WRITE_SYSTEM_MD"]);
|
|
339679
340068
|
if (writeSystemMdResolution.value && !writeSystemMdResolution.isDisabled) {
|
|
339680
340069
|
const writePath = writeSystemMdResolution.isSwitch ? systemMdPath : writeSystemMdResolution.value;
|
|
339681
340070
|
fs47.mkdirSync(path49.dirname(writePath), { recursive: true });
|
|
@@ -340082,19 +340471,28 @@ var LoopDetectionService = class {
|
|
|
340082
340471
|
...trimmedHistory,
|
|
340083
340472
|
{ role: "user", parts: [{ text: taskPrompt }] }
|
|
340084
340473
|
];
|
|
340474
|
+
if (contents.length > 0 && isFunctionCall(contents[0])) {
|
|
340475
|
+
contents.unshift({
|
|
340476
|
+
role: "user",
|
|
340477
|
+
parts: [{ text: "Recent conversation history:" }]
|
|
340478
|
+
});
|
|
340479
|
+
}
|
|
340085
340480
|
const schema = {
|
|
340086
340481
|
type: "object",
|
|
340087
340482
|
properties: {
|
|
340088
|
-
|
|
340483
|
+
unproductive_state_analysis: {
|
|
340089
340484
|
type: "string",
|
|
340090
340485
|
description: "Your reasoning on if the conversation is looping without forward progress."
|
|
340091
340486
|
},
|
|
340092
|
-
|
|
340487
|
+
unproductive_state_confidence: {
|
|
340093
340488
|
type: "number",
|
|
340094
340489
|
description: "A number between 0.0 and 1.0 representing your confidence that the conversation is in an unproductive state."
|
|
340095
340490
|
}
|
|
340096
340491
|
},
|
|
340097
|
-
required: [
|
|
340492
|
+
required: [
|
|
340493
|
+
"unproductive_state_analysis",
|
|
340494
|
+
"unproductive_state_confidence"
|
|
340495
|
+
]
|
|
340098
340496
|
};
|
|
340099
340497
|
let result;
|
|
340100
340498
|
try {
|
|
@@ -340107,18 +340505,18 @@ var LoopDetectionService = class {
|
|
|
340107
340505
|
promptId: this.promptId
|
|
340108
340506
|
});
|
|
340109
340507
|
} catch (e2) {
|
|
340110
|
-
this.config.getDebugMode() ?
|
|
340508
|
+
this.config.getDebugMode() ? debugLogger.warn(e2) : debugLogger.debug(e2);
|
|
340111
340509
|
return false;
|
|
340112
340510
|
}
|
|
340113
|
-
if (typeof result["
|
|
340114
|
-
if (result["
|
|
340115
|
-
if (typeof result["
|
|
340116
|
-
debugLogger.warn(result["
|
|
340511
|
+
if (typeof result["unproductive_state_confidence"] === "number") {
|
|
340512
|
+
if (result["unproductive_state_confidence"] > 0.9) {
|
|
340513
|
+
if (typeof result["unproductive_state_analysis"] === "string" && result["unproductive_state_analysis"]) {
|
|
340514
|
+
debugLogger.warn(result["unproductive_state_analysis"]);
|
|
340117
340515
|
}
|
|
340118
340516
|
logLoopDetected(this.config, new LoopDetectedEvent(LoopType.LLM_DETECTED_LOOP, this.promptId));
|
|
340119
340517
|
return true;
|
|
340120
340518
|
} else {
|
|
340121
|
-
this.llmCheckInterval = Math.round(MIN_LLM_CHECK_INTERVAL + (MAX_LLM_CHECK_INTERVAL - MIN_LLM_CHECK_INTERVAL) * (1 - result["
|
|
340519
|
+
this.llmCheckInterval = Math.round(MIN_LLM_CHECK_INTERVAL + (MAX_LLM_CHECK_INTERVAL - MIN_LLM_CHECK_INTERVAL) * (1 - result["unproductive_state_confidence"]));
|
|
340122
340520
|
}
|
|
340123
340521
|
}
|
|
340124
340522
|
return false;
|
|
@@ -340151,10 +340549,9 @@ var LoopDetectionService = class {
|
|
|
340151
340549
|
}
|
|
340152
340550
|
};
|
|
340153
340551
|
|
|
340154
|
-
// packages/core/dist/src/
|
|
340155
|
-
|
|
340156
|
-
|
|
340157
|
-
}
|
|
340552
|
+
// packages/core/dist/src/services/chatCompressionService.js
|
|
340553
|
+
var COMPRESSION_TOKEN_THRESHOLD = 0.7;
|
|
340554
|
+
var COMPRESSION_PRESERVE_THRESHOLD = 0.3;
|
|
340158
340555
|
function findCompressSplitPoint(contents, fraction) {
|
|
340159
340556
|
if (fraction <= 0 || fraction >= 1) {
|
|
340160
340557
|
throw new Error("Fraction must be between 0 and 1");
|
|
@@ -340180,9 +340577,110 @@ function findCompressSplitPoint(contents, fraction) {
|
|
|
340180
340577
|
}
|
|
340181
340578
|
return lastSplitPoint;
|
|
340182
340579
|
}
|
|
340580
|
+
var ChatCompressionService = class {
|
|
340581
|
+
async compress(chat, promptId, force, model, config2, hasFailedCompressionAttempt) {
|
|
340582
|
+
const curatedHistory = chat.getHistory(true);
|
|
340583
|
+
if (curatedHistory.length === 0 || hasFailedCompressionAttempt && !force) {
|
|
340584
|
+
return {
|
|
340585
|
+
newHistory: null,
|
|
340586
|
+
info: {
|
|
340587
|
+
originalTokenCount: 0,
|
|
340588
|
+
newTokenCount: 0,
|
|
340589
|
+
compressionStatus: CompressionStatus.NOOP
|
|
340590
|
+
}
|
|
340591
|
+
};
|
|
340592
|
+
}
|
|
340593
|
+
const originalTokenCount = uiTelemetryService.getLastPromptTokenCount();
|
|
340594
|
+
const contextPercentageThreshold = config2.getChatCompression()?.contextPercentageThreshold;
|
|
340595
|
+
if (!force) {
|
|
340596
|
+
const threshold = contextPercentageThreshold ?? COMPRESSION_TOKEN_THRESHOLD;
|
|
340597
|
+
if (originalTokenCount < threshold * tokenLimit(model)) {
|
|
340598
|
+
return {
|
|
340599
|
+
newHistory: null,
|
|
340600
|
+
info: {
|
|
340601
|
+
originalTokenCount,
|
|
340602
|
+
newTokenCount: originalTokenCount,
|
|
340603
|
+
compressionStatus: CompressionStatus.NOOP
|
|
340604
|
+
}
|
|
340605
|
+
};
|
|
340606
|
+
}
|
|
340607
|
+
}
|
|
340608
|
+
const splitPoint = findCompressSplitPoint(curatedHistory, 1 - COMPRESSION_PRESERVE_THRESHOLD);
|
|
340609
|
+
const historyToCompress = curatedHistory.slice(0, splitPoint);
|
|
340610
|
+
const historyToKeep = curatedHistory.slice(splitPoint);
|
|
340611
|
+
if (historyToCompress.length === 0) {
|
|
340612
|
+
return {
|
|
340613
|
+
newHistory: null,
|
|
340614
|
+
info: {
|
|
340615
|
+
originalTokenCount,
|
|
340616
|
+
newTokenCount: originalTokenCount,
|
|
340617
|
+
compressionStatus: CompressionStatus.NOOP
|
|
340618
|
+
}
|
|
340619
|
+
};
|
|
340620
|
+
}
|
|
340621
|
+
const summaryResponse = await config2.getContentGenerator().generateContent({
|
|
340622
|
+
model,
|
|
340623
|
+
contents: [
|
|
340624
|
+
...historyToCompress,
|
|
340625
|
+
{
|
|
340626
|
+
role: "user",
|
|
340627
|
+
parts: [
|
|
340628
|
+
{
|
|
340629
|
+
text: "First, reason in your scratchpad. Then, generate the <state_snapshot>."
|
|
340630
|
+
}
|
|
340631
|
+
]
|
|
340632
|
+
}
|
|
340633
|
+
],
|
|
340634
|
+
config: {
|
|
340635
|
+
systemInstruction: { text: getCompressionPrompt() }
|
|
340636
|
+
}
|
|
340637
|
+
}, promptId);
|
|
340638
|
+
const summary = getResponseText(summaryResponse) ?? "";
|
|
340639
|
+
const extraHistory = [
|
|
340640
|
+
{
|
|
340641
|
+
role: "user",
|
|
340642
|
+
parts: [{ text: summary }]
|
|
340643
|
+
},
|
|
340644
|
+
{
|
|
340645
|
+
role: "model",
|
|
340646
|
+
parts: [{ text: "Got it. Thanks for the additional context!" }]
|
|
340647
|
+
},
|
|
340648
|
+
...historyToKeep
|
|
340649
|
+
];
|
|
340650
|
+
const fullNewHistory = await getInitialChatHistory(config2, extraHistory);
|
|
340651
|
+
const newTokenCount = Math.floor(fullNewHistory.reduce((total, content) => total + JSON.stringify(content).length, 0) / 4);
|
|
340652
|
+
logChatCompression(config2, makeChatCompressionEvent({
|
|
340653
|
+
tokens_before: originalTokenCount,
|
|
340654
|
+
tokens_after: newTokenCount
|
|
340655
|
+
}));
|
|
340656
|
+
if (newTokenCount > originalTokenCount) {
|
|
340657
|
+
return {
|
|
340658
|
+
newHistory: null,
|
|
340659
|
+
info: {
|
|
340660
|
+
originalTokenCount,
|
|
340661
|
+
newTokenCount,
|
|
340662
|
+
compressionStatus: CompressionStatus.COMPRESSION_FAILED_INFLATED_TOKEN_COUNT
|
|
340663
|
+
}
|
|
340664
|
+
};
|
|
340665
|
+
} else {
|
|
340666
|
+
uiTelemetryService.setLastPromptTokenCount(newTokenCount);
|
|
340667
|
+
return {
|
|
340668
|
+
newHistory: extraHistory,
|
|
340669
|
+
info: {
|
|
340670
|
+
originalTokenCount,
|
|
340671
|
+
newTokenCount,
|
|
340672
|
+
compressionStatus: CompressionStatus.COMPRESSED
|
|
340673
|
+
}
|
|
340674
|
+
};
|
|
340675
|
+
}
|
|
340676
|
+
}
|
|
340677
|
+
};
|
|
340678
|
+
|
|
340679
|
+
// packages/core/dist/src/core/client.js
|
|
340680
|
+
function isThinkingSupported(model) {
|
|
340681
|
+
return model.startsWith("gemini-2.5") || model === DEFAULT_GEMINI_MODEL_AUTO;
|
|
340682
|
+
}
|
|
340183
340683
|
var MAX_TURNS = 100;
|
|
340184
|
-
var COMPRESSION_TOKEN_THRESHOLD = 0.7;
|
|
340185
|
-
var COMPRESSION_PRESERVE_THRESHOLD = 0.3;
|
|
340186
340684
|
var GeminiClient = class {
|
|
340187
340685
|
config;
|
|
340188
340686
|
chat;
|
|
@@ -340192,6 +340690,7 @@ var GeminiClient = class {
|
|
|
340192
340690
|
};
|
|
340193
340691
|
sessionTurnCount = 0;
|
|
340194
340692
|
loopDetector;
|
|
340693
|
+
compressionService;
|
|
340195
340694
|
lastPromptId;
|
|
340196
340695
|
currentSequenceModel = null;
|
|
340197
340696
|
lastSentIdeContext;
|
|
@@ -340204,6 +340703,7 @@ var GeminiClient = class {
|
|
|
340204
340703
|
constructor(config2) {
|
|
340205
340704
|
this.config = config2;
|
|
340206
340705
|
this.loopDetector = new LoopDetectionService(config2);
|
|
340706
|
+
this.compressionService = new ChatCompressionService();
|
|
340207
340707
|
this.lastPromptId = this.config.getSessionId();
|
|
340208
340708
|
}
|
|
340209
340709
|
async initialize() {
|
|
@@ -340270,22 +340770,7 @@ var GeminiClient = class {
|
|
|
340270
340770
|
const toolRegistry = this.config.getToolRegistry();
|
|
340271
340771
|
const toolDeclarations = toolRegistry.getFunctionDeclarations();
|
|
340272
340772
|
const tools = [{ functionDeclarations: toolDeclarations }];
|
|
340273
|
-
const
|
|
340274
|
-
const envContextString = envParts.map((part) => part.text || "").join("\n\n");
|
|
340275
|
-
const allSetupText = `
|
|
340276
|
-
${envContextString}
|
|
340277
|
-
|
|
340278
|
-
Reminder: Do not return an empty response when a tool call is required.
|
|
340279
|
-
|
|
340280
|
-
My setup is complete. I will provide my first command in the next turn.
|
|
340281
|
-
`.trim();
|
|
340282
|
-
const history = [
|
|
340283
|
-
{
|
|
340284
|
-
role: "user",
|
|
340285
|
-
parts: [{ text: allSetupText }]
|
|
340286
|
-
},
|
|
340287
|
-
...extraHistory ?? []
|
|
340288
|
-
];
|
|
340773
|
+
const history = await getInitialChatHistory(this.config, extraHistory);
|
|
340289
340774
|
try {
|
|
340290
340775
|
const userMemory = this.config.getUserMemory();
|
|
340291
340776
|
const systemInstruction = getCoreSystemPrompt(this.config, userMemory);
|
|
@@ -340597,87 +341082,16 @@ My setup is complete. I will provide my first command in the next turn.
|
|
|
340597
341082
|
}
|
|
340598
341083
|
async tryCompressChat(prompt_id, force = false) {
|
|
340599
341084
|
const model = this._getEffectiveModelForCurrentTurn();
|
|
340600
|
-
const
|
|
340601
|
-
if (
|
|
340602
|
-
return {
|
|
340603
|
-
originalTokenCount: 0,
|
|
340604
|
-
newTokenCount: 0,
|
|
340605
|
-
compressionStatus: CompressionStatus.NOOP
|
|
340606
|
-
};
|
|
340607
|
-
}
|
|
340608
|
-
const originalTokenCount = uiTelemetryService.getLastPromptTokenCount();
|
|
340609
|
-
const contextPercentageThreshold = this.config.getChatCompression()?.contextPercentageThreshold;
|
|
340610
|
-
if (!force) {
|
|
340611
|
-
const threshold = contextPercentageThreshold ?? COMPRESSION_TOKEN_THRESHOLD;
|
|
340612
|
-
if (originalTokenCount < threshold * tokenLimit(model)) {
|
|
340613
|
-
return {
|
|
340614
|
-
originalTokenCount,
|
|
340615
|
-
newTokenCount: originalTokenCount,
|
|
340616
|
-
compressionStatus: CompressionStatus.NOOP
|
|
340617
|
-
};
|
|
340618
|
-
}
|
|
340619
|
-
}
|
|
340620
|
-
const splitPoint = findCompressSplitPoint(curatedHistory, 1 - COMPRESSION_PRESERVE_THRESHOLD);
|
|
340621
|
-
const historyToCompress = curatedHistory.slice(0, splitPoint);
|
|
340622
|
-
const historyToKeep = curatedHistory.slice(splitPoint);
|
|
340623
|
-
if (historyToCompress.length === 0) {
|
|
340624
|
-
return {
|
|
340625
|
-
originalTokenCount,
|
|
340626
|
-
newTokenCount: originalTokenCount,
|
|
340627
|
-
compressionStatus: CompressionStatus.NOOP
|
|
340628
|
-
};
|
|
340629
|
-
}
|
|
340630
|
-
const summaryResponse = await this.config.getContentGenerator().generateContent({
|
|
340631
|
-
model,
|
|
340632
|
-
contents: [
|
|
340633
|
-
...historyToCompress,
|
|
340634
|
-
{
|
|
340635
|
-
role: "user",
|
|
340636
|
-
parts: [
|
|
340637
|
-
{
|
|
340638
|
-
text: "First, reason in your scratchpad. Then, generate the <state_snapshot>."
|
|
340639
|
-
}
|
|
340640
|
-
]
|
|
340641
|
-
}
|
|
340642
|
-
],
|
|
340643
|
-
config: {
|
|
340644
|
-
systemInstruction: { text: getCompressionPrompt() }
|
|
340645
|
-
}
|
|
340646
|
-
}, prompt_id);
|
|
340647
|
-
const summary = getResponseText(summaryResponse) ?? "";
|
|
340648
|
-
const chat = await this.startChat([
|
|
340649
|
-
{
|
|
340650
|
-
role: "user",
|
|
340651
|
-
parts: [{ text: summary }]
|
|
340652
|
-
},
|
|
340653
|
-
{
|
|
340654
|
-
role: "model",
|
|
340655
|
-
parts: [{ text: "Got it. Thanks for the additional context!" }]
|
|
340656
|
-
},
|
|
340657
|
-
...historyToKeep
|
|
340658
|
-
]);
|
|
340659
|
-
this.forceFullIdeContext = true;
|
|
340660
|
-
const newTokenCount = Math.floor(chat.getHistory().reduce((total, content) => total + JSON.stringify(content).length, 0) / 4);
|
|
340661
|
-
logChatCompression(this.config, makeChatCompressionEvent({
|
|
340662
|
-
tokens_before: originalTokenCount,
|
|
340663
|
-
tokens_after: newTokenCount
|
|
340664
|
-
}));
|
|
340665
|
-
if (newTokenCount > originalTokenCount) {
|
|
341085
|
+
const { newHistory, info: info2 } = await this.compressionService.compress(this.getChat(), prompt_id, force, model, this.config, this.hasFailedCompressionAttempt);
|
|
341086
|
+
if (info2.compressionStatus === CompressionStatus.COMPRESSION_FAILED_INFLATED_TOKEN_COUNT) {
|
|
340666
341087
|
this.hasFailedCompressionAttempt = !force && true;
|
|
340667
|
-
|
|
340668
|
-
|
|
340669
|
-
|
|
340670
|
-
|
|
340671
|
-
}
|
|
340672
|
-
} else {
|
|
340673
|
-
this.chat = chat;
|
|
340674
|
-
uiTelemetryService.setLastPromptTokenCount(newTokenCount);
|
|
341088
|
+
} else if (info2.compressionStatus === CompressionStatus.COMPRESSED) {
|
|
341089
|
+
if (newHistory) {
|
|
341090
|
+
this.chat = await this.startChat(newHistory);
|
|
341091
|
+
this.forceFullIdeContext = true;
|
|
341092
|
+
}
|
|
340675
341093
|
}
|
|
340676
|
-
return
|
|
340677
|
-
originalTokenCount,
|
|
340678
|
-
newTokenCount,
|
|
340679
|
-
compressionStatus: CompressionStatus.COMPRESSED
|
|
340680
|
-
};
|
|
341094
|
+
return info2;
|
|
340681
341095
|
}
|
|
340682
341096
|
};
|
|
340683
341097
|
|
|
@@ -340860,15 +341274,13 @@ var FileDiscoveryService = class {
|
|
|
340860
341274
|
/**
|
|
340861
341275
|
* Filters a list of file paths based on git ignore rules
|
|
340862
341276
|
*/
|
|
340863
|
-
filterFiles(filePaths, options2 = {
|
|
340864
|
-
respectGitIgnore
|
|
340865
|
-
respectGeminiIgnore: true
|
|
340866
|
-
}) {
|
|
341277
|
+
filterFiles(filePaths, options2 = {}) {
|
|
341278
|
+
const { respectGitIgnore = true, respectGeminiIgnore = true } = options2;
|
|
340867
341279
|
return filePaths.filter((filePath) => {
|
|
340868
|
-
if (
|
|
341280
|
+
if (respectGitIgnore && this.gitIgnoreFilter?.isIgnored(filePath)) {
|
|
340869
341281
|
return false;
|
|
340870
341282
|
}
|
|
340871
|
-
if (
|
|
341283
|
+
if (respectGeminiIgnore && this.geminiIgnoreFilter?.isIgnored(filePath)) {
|
|
340872
341284
|
return false;
|
|
340873
341285
|
}
|
|
340874
341286
|
return true;
|
|
@@ -340882,62 +341294,18 @@ var FileDiscoveryService = class {
|
|
|
340882
341294
|
respectGitIgnore: true,
|
|
340883
341295
|
respectGeminiIgnore: true
|
|
340884
341296
|
}) {
|
|
340885
|
-
const filteredPaths =
|
|
340886
|
-
|
|
340887
|
-
let geminiIgnoredCount = 0;
|
|
340888
|
-
for (const filePath of filePaths) {
|
|
340889
|
-
if (opts.respectGitIgnore && this.shouldGitIgnoreFile(filePath)) {
|
|
340890
|
-
gitIgnoredCount++;
|
|
340891
|
-
continue;
|
|
340892
|
-
}
|
|
340893
|
-
if (opts.respectGeminiIgnore && this.shouldGeminiIgnoreFile(filePath)) {
|
|
340894
|
-
geminiIgnoredCount++;
|
|
340895
|
-
continue;
|
|
340896
|
-
}
|
|
340897
|
-
filteredPaths.push(filePath);
|
|
340898
|
-
}
|
|
341297
|
+
const filteredPaths = this.filterFiles(filePaths, opts);
|
|
341298
|
+
const ignoredCount = filePaths.length - filteredPaths.length;
|
|
340899
341299
|
return {
|
|
340900
341300
|
filteredPaths,
|
|
340901
|
-
|
|
340902
|
-
geminiIgnoredCount
|
|
341301
|
+
ignoredCount
|
|
340903
341302
|
};
|
|
340904
341303
|
}
|
|
340905
|
-
/**
|
|
340906
|
-
* Checks if a single file should be git-ignored
|
|
340907
|
-
*/
|
|
340908
|
-
shouldGitIgnoreFile(filePath) {
|
|
340909
|
-
if (this.gitIgnoreFilter) {
|
|
340910
|
-
return this.gitIgnoreFilter.isIgnored(filePath);
|
|
340911
|
-
}
|
|
340912
|
-
return false;
|
|
340913
|
-
}
|
|
340914
|
-
/**
|
|
340915
|
-
* Checks if a single file should be gemini-ignored
|
|
340916
|
-
*/
|
|
340917
|
-
shouldGeminiIgnoreFile(filePath) {
|
|
340918
|
-
if (this.geminiIgnoreFilter) {
|
|
340919
|
-
return this.geminiIgnoreFilter.isIgnored(filePath);
|
|
340920
|
-
}
|
|
340921
|
-
return false;
|
|
340922
|
-
}
|
|
340923
341304
|
/**
|
|
340924
341305
|
* Unified method to check if a file should be ignored based on filtering options
|
|
340925
341306
|
*/
|
|
340926
341307
|
shouldIgnoreFile(filePath, options2 = {}) {
|
|
340927
|
-
|
|
340928
|
-
if (respectGitIgnore && this.shouldGitIgnoreFile(filePath)) {
|
|
340929
|
-
return true;
|
|
340930
|
-
}
|
|
340931
|
-
if (respectGeminiIgnore && this.shouldGeminiIgnoreFile(filePath)) {
|
|
340932
|
-
return true;
|
|
340933
|
-
}
|
|
340934
|
-
return false;
|
|
340935
|
-
}
|
|
340936
|
-
/**
|
|
340937
|
-
* Returns loaded patterns from .geminiignore
|
|
340938
|
-
*/
|
|
340939
|
-
getGeminiIgnorePatterns() {
|
|
340940
|
-
return this.geminiIgnoreFilter?.getPatterns() ?? [];
|
|
341308
|
+
return this.filterFiles([filePath], options2).length === 0;
|
|
340941
341309
|
}
|
|
340942
341310
|
};
|
|
340943
341311
|
|
|
@@ -340952,7 +341320,7 @@ var import_promise_deferred = __toESM(require_dist9(), 1);
|
|
|
340952
341320
|
var import_promise_deferred2 = __toESM(require_dist9(), 1);
|
|
340953
341321
|
import { Buffer as Buffer22 } from "node:buffer";
|
|
340954
341322
|
import { spawn as spawn8 } from "child_process";
|
|
340955
|
-
import { EventEmitter as
|
|
341323
|
+
import { EventEmitter as EventEmitter9 } from "node:events";
|
|
340956
341324
|
var __defProp3 = Object.defineProperty;
|
|
340957
341325
|
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
340958
341326
|
var __getOwnPropNames2 = Object.getOwnPropertyNames;
|
|
@@ -345293,7 +345661,7 @@ init_utils4();
|
|
|
345293
345661
|
var PluginStore = class {
|
|
345294
345662
|
constructor() {
|
|
345295
345663
|
this.plugins = /* @__PURE__ */ new Set();
|
|
345296
|
-
this.events = new
|
|
345664
|
+
this.events = new EventEmitter9();
|
|
345297
345665
|
}
|
|
345298
345666
|
on(type, listener) {
|
|
345299
345667
|
this.events.on(type, listener);
|
|
@@ -345723,7 +346091,7 @@ var WriteTodosTool = class _WriteTodosTool extends BaseDeclarativeTool {
|
|
|
345723
346091
|
}
|
|
345724
346092
|
return null;
|
|
345725
346093
|
}
|
|
345726
|
-
createInvocation(params) {
|
|
346094
|
+
createInvocation(params, _messageBus, _toolName, _displayName) {
|
|
345727
346095
|
return new WriteTodosToolInvocation(params);
|
|
345728
346096
|
}
|
|
345729
346097
|
};
|
|
@@ -346088,7 +346456,7 @@ var JsonStreamEventType;
|
|
|
346088
346456
|
// packages/core/dist/src/utils/workspaceContext.js
|
|
346089
346457
|
import * as fs52 from "node:fs";
|
|
346090
346458
|
import * as path55 from "node:path";
|
|
346091
|
-
import * as
|
|
346459
|
+
import * as process23 from "node:process";
|
|
346092
346460
|
var WorkspaceContext = class {
|
|
346093
346461
|
directories = /* @__PURE__ */ new Set();
|
|
346094
346462
|
initialDirectories;
|
|
@@ -346130,7 +346498,7 @@ var WorkspaceContext = class {
|
|
|
346130
346498
|
* @param directory The directory path to add (can be relative or absolute)
|
|
346131
346499
|
* @param basePath Optional base path for resolving relative paths (defaults to cwd)
|
|
346132
346500
|
*/
|
|
346133
|
-
addDirectory(directory, basePath =
|
|
346501
|
+
addDirectory(directory, basePath = process23.cwd()) {
|
|
346134
346502
|
try {
|
|
346135
346503
|
const resolved = this.resolveAndValidateDir(directory, basePath);
|
|
346136
346504
|
if (this.directories.has(resolved)) {
|
|
@@ -346142,7 +346510,7 @@ var WorkspaceContext = class {
|
|
|
346142
346510
|
debugLogger.warn(`[WARN] Skipping unreadable directory: ${directory} (${err2 instanceof Error ? err2.message : String(err2)})`);
|
|
346143
346511
|
}
|
|
346144
346512
|
}
|
|
346145
|
-
resolveAndValidateDir(directory, basePath =
|
|
346513
|
+
resolveAndValidateDir(directory, basePath = process23.cwd()) {
|
|
346146
346514
|
const absolutePath = path55.isAbsolute(directory) ? directory : path55.resolve(basePath, directory);
|
|
346147
346515
|
if (!fs52.existsSync(absolutePath)) {
|
|
346148
346516
|
throw new Error(`Directory does not exist: ${absolutePath}`);
|
|
@@ -346231,7 +346599,7 @@ var WorkspaceContext = class {
|
|
|
346231
346599
|
};
|
|
346232
346600
|
|
|
346233
346601
|
// packages/core/dist/src/confirmation-bus/message-bus.js
|
|
346234
|
-
import { EventEmitter as
|
|
346602
|
+
import { EventEmitter as EventEmitter10 } from "node:events";
|
|
346235
346603
|
|
|
346236
346604
|
// packages/core/dist/src/policy/types.js
|
|
346237
346605
|
var PolicyDecision;
|
|
@@ -346242,7 +346610,7 @@ var PolicyDecision;
|
|
|
346242
346610
|
})(PolicyDecision || (PolicyDecision = {}));
|
|
346243
346611
|
|
|
346244
346612
|
// packages/core/dist/src/confirmation-bus/message-bus.js
|
|
346245
|
-
var MessageBus = class extends
|
|
346613
|
+
var MessageBus = class extends EventEmitter10 {
|
|
346246
346614
|
policyEngine;
|
|
346247
346615
|
debug;
|
|
346248
346616
|
constructor(policyEngine, debug2 = false) {
|
|
@@ -346550,7 +346918,7 @@ function convertInputConfigToJsonSchema(inputConfig) {
|
|
|
346550
346918
|
// packages/core/dist/src/core/nonInteractiveToolExecutor.js
|
|
346551
346919
|
async function executeToolCall(config2, toolCallRequest, abortSignal) {
|
|
346552
346920
|
return new Promise((resolve13, reject) => {
|
|
346553
|
-
new CoreToolScheduler({
|
|
346921
|
+
const scheduler3 = new CoreToolScheduler({
|
|
346554
346922
|
config: config2,
|
|
346555
346923
|
getPreferredEditor: () => void 0,
|
|
346556
346924
|
onEditorClose: () => {
|
|
@@ -346558,7 +346926,10 @@ async function executeToolCall(config2, toolCallRequest, abortSignal) {
|
|
|
346558
346926
|
onAllToolCallsComplete: async (completedToolCalls) => {
|
|
346559
346927
|
resolve13(completedToolCalls[0]);
|
|
346560
346928
|
}
|
|
346561
|
-
})
|
|
346929
|
+
});
|
|
346930
|
+
scheduler3.schedule(toolCallRequest, abortSignal).catch((error) => {
|
|
346931
|
+
reject(error);
|
|
346932
|
+
});
|
|
346562
346933
|
});
|
|
346563
346934
|
}
|
|
346564
346935
|
|
|
@@ -348573,6 +348944,7 @@ var Config = class {
|
|
|
348573
348944
|
continueOnFailedApiCall;
|
|
348574
348945
|
retryFetchErrors;
|
|
348575
348946
|
enableShellOutputEfficiency;
|
|
348947
|
+
fakeResponses;
|
|
348576
348948
|
disableYoloMode;
|
|
348577
348949
|
constructor(params) {
|
|
348578
348950
|
this.sessionId = params.sessionId;
|
|
@@ -348614,7 +348986,7 @@ var Config = class {
|
|
|
348614
348986
|
};
|
|
348615
348987
|
this.checkpointing = params.checkpointing ?? false;
|
|
348616
348988
|
this.proxy = params.proxy;
|
|
348617
|
-
this.cwd = params.cwd ??
|
|
348989
|
+
this.cwd = params.cwd ?? process24.cwd();
|
|
348618
348990
|
this.fileDiscoveryService = params.fileDiscoveryService ?? null;
|
|
348619
348991
|
this.bugCommand = params.bugCommand;
|
|
348620
348992
|
this.model = params.model;
|
|
@@ -348660,6 +349032,7 @@ var Config = class {
|
|
|
348660
349032
|
this.enableShellOutputEfficiency = params.enableShellOutputEfficiency ?? true;
|
|
348661
349033
|
this.extensionManagement = params.extensionManagement ?? true;
|
|
348662
349034
|
this.storage = new Storage2(this.targetDir);
|
|
349035
|
+
this.fakeResponses = params.fakeResponses;
|
|
348663
349036
|
this.enablePromptCompletion = params.enablePromptCompletion ?? false;
|
|
348664
349037
|
this.fileExclusions = new FileExclusions(this);
|
|
348665
349038
|
this.eventEmitter = params.eventEmitter;
|
|
@@ -348712,7 +349085,6 @@ var Config = class {
|
|
|
348712
349085
|
this.contentGeneratorConfig = newContentGeneratorConfig;
|
|
348713
349086
|
this.baseLlmClient = new BaseLlmClient(this.contentGenerator, this);
|
|
348714
349087
|
this.inFallbackMode = false;
|
|
348715
|
-
logCliConfiguration(this, new StartSessionEvent(this, this.toolRegistry));
|
|
348716
349088
|
}
|
|
348717
349089
|
getUserTier() {
|
|
348718
349090
|
return this.contentGenerator?.userTier;
|
|
@@ -348774,7 +349146,7 @@ var Config = class {
|
|
|
348774
349146
|
}
|
|
348775
349147
|
isRestrictiveSandbox() {
|
|
348776
349148
|
const sandboxConfig = this.getSandbox();
|
|
348777
|
-
const seatbeltProfile =
|
|
349149
|
+
const seatbeltProfile = process24.env["SEATBELT_PROFILE"];
|
|
348778
349150
|
return !!sandboxConfig && sandboxConfig.command === "sandbox-exec" && !!seatbeltProfile && seatbeltProfile.startsWith("restrictive-");
|
|
348779
349151
|
}
|
|
348780
349152
|
getTargetDir() {
|
|
@@ -349157,15 +349529,9 @@ var Config = class {
|
|
|
349157
349529
|
const isExcluded = excludeTools.includes(definition.name);
|
|
349158
349530
|
const isAllowed = !allowedTools || allowedTools.includes(definition.name);
|
|
349159
349531
|
if (isAllowed && !isExcluded) {
|
|
349160
|
-
|
|
349161
|
-
|
|
349162
|
-
|
|
349163
|
-
registry.registerTool(wrapper);
|
|
349164
|
-
} catch (error) {
|
|
349165
|
-
console.error(`Failed to wrap agent '${definition.name}' as a tool:`, error);
|
|
349166
|
-
}
|
|
349167
|
-
} else if (this.getDebugMode()) {
|
|
349168
|
-
debugLogger.log(`[Config] Skipping registration of agent '${definition.name}' due to allow/exclude configuration.`);
|
|
349532
|
+
const messageBusEnabled = this.getEnableMessageBusIntegration();
|
|
349533
|
+
const wrapper = new SubagentToolWrapper(definition, this, messageBusEnabled ? this.getMessageBus() : void 0);
|
|
349534
|
+
registry.registerTool(wrapper);
|
|
349169
349535
|
}
|
|
349170
349536
|
}
|
|
349171
349537
|
}
|
|
@@ -349174,6 +349540,11 @@ var Config = class {
|
|
|
349174
349540
|
}
|
|
349175
349541
|
};
|
|
349176
349542
|
|
|
349543
|
+
// packages/core/dist/src/commands/extensions.js
|
|
349544
|
+
function listExtensions(config2) {
|
|
349545
|
+
return config2.getExtensions();
|
|
349546
|
+
}
|
|
349547
|
+
|
|
349177
349548
|
// packages/core/dist/src/core/logger.js
|
|
349178
349549
|
var MessageSenderType;
|
|
349179
349550
|
(function(MessageSenderType2) {
|
|
@@ -351827,34 +352198,12 @@ var hasFileExtension = (0, import_picomatch.default)("**/*[*.]*");
|
|
|
351827
352198
|
var import_fdir = __toESM(require_dist10(), 1);
|
|
351828
352199
|
|
|
351829
352200
|
// packages/core/dist/src/utils/errorParsing.js
|
|
351830
|
-
var getRateLimitErrorMessageGoogleFree = (fallbackModel = DEFAULT_GEMINI_FLASH_MODEL) => `
|
|
351831
|
-
Possible quota limitations in place or slow response times detected. Switching to the ${fallbackModel} model for the rest of this session.`;
|
|
351832
|
-
var getRateLimitErrorMessageGoogleProQuotaFree = (currentModel = DEFAULT_GEMINI_MODEL, fallbackModel = DEFAULT_GEMINI_FLASH_MODEL) => `
|
|
351833
|
-
You have reached your daily ${currentModel} quota limit. You will be switched to the ${fallbackModel} model for the rest of this session. To increase your limits, upgrade to get higher limits at https://goo.gle/set-up-gemini-code-assist, or use /auth to switch to using a paid API key from AI Studio at https://aistudio.google.com/apikey`;
|
|
351834
|
-
var getRateLimitErrorMessageGoogleGenericQuotaFree = () => `
|
|
351835
|
-
You have reached your daily quota limit. To increase your limits, upgrade to get higher limits at https://goo.gle/set-up-gemini-code-assist, or use /auth to switch to using a paid API key from AI Studio at https://aistudio.google.com/apikey`;
|
|
351836
|
-
var getRateLimitErrorMessageGooglePaid = (fallbackModel = DEFAULT_GEMINI_FLASH_MODEL) => `
|
|
351837
|
-
Possible quota limitations in place or slow response times detected. Switching to the ${fallbackModel} model for the rest of this session. We appreciate you for choosing Gemini Code Assist and the Gemini CLI.`;
|
|
351838
|
-
var getRateLimitErrorMessageGoogleProQuotaPaid = (currentModel = DEFAULT_GEMINI_MODEL, fallbackModel = DEFAULT_GEMINI_FLASH_MODEL) => `
|
|
351839
|
-
You have reached your daily ${currentModel} quota limit. You will be switched to the ${fallbackModel} model for the rest of this session. We appreciate you for choosing Gemini Code Assist and the Gemini CLI. To continue accessing the ${currentModel} model today, consider using /auth to switch to using a paid API key from AI Studio at https://aistudio.google.com/apikey`;
|
|
351840
|
-
var getRateLimitErrorMessageGoogleGenericQuotaPaid = (currentModel = DEFAULT_GEMINI_MODEL) => `
|
|
351841
|
-
You have reached your daily quota limit. We appreciate you for choosing Gemini Code Assist and the Gemini CLI. To continue accessing the ${currentModel} model today, consider using /auth to switch to using a paid API key from AI Studio at https://aistudio.google.com/apikey`;
|
|
351842
352201
|
var RATE_LIMIT_ERROR_MESSAGE_USE_GEMINI = "\nPlease wait and try again later. To increase your limits, request a quota increase through AI Studio, or switch to another /auth method";
|
|
351843
352202
|
var RATE_LIMIT_ERROR_MESSAGE_VERTEX = "\nPlease wait and try again later. To increase your limits, request a quota increase through Vertex, or switch to another /auth method";
|
|
351844
352203
|
var getRateLimitErrorMessageDefault = (fallbackModel = DEFAULT_GEMINI_FLASH_MODEL) => `
|
|
351845
352204
|
Possible quota limitations in place or slow response times detected. Switching to the ${fallbackModel} model for the rest of this session.`;
|
|
351846
|
-
function getRateLimitMessage(authType,
|
|
352205
|
+
function getRateLimitMessage(authType, fallbackModel) {
|
|
351847
352206
|
switch (authType) {
|
|
351848
|
-
case AuthType2.LOGIN_WITH_GOOGLE: {
|
|
351849
|
-
const isPaidTier = userTier === UserTierId.LEGACY || userTier === UserTierId.STANDARD;
|
|
351850
|
-
if (isProQuotaExceededError(error)) {
|
|
351851
|
-
return isPaidTier ? getRateLimitErrorMessageGoogleProQuotaPaid(currentModel || DEFAULT_GEMINI_MODEL, fallbackModel) : getRateLimitErrorMessageGoogleProQuotaFree(currentModel || DEFAULT_GEMINI_MODEL, fallbackModel);
|
|
351852
|
-
} else if (isGenericQuotaExceededError(error)) {
|
|
351853
|
-
return isPaidTier ? getRateLimitErrorMessageGoogleGenericQuotaPaid(currentModel || DEFAULT_GEMINI_MODEL) : getRateLimitErrorMessageGoogleGenericQuotaFree();
|
|
351854
|
-
} else {
|
|
351855
|
-
return isPaidTier ? getRateLimitErrorMessageGooglePaid(fallbackModel) : getRateLimitErrorMessageGoogleFree(fallbackModel);
|
|
351856
|
-
}
|
|
351857
|
-
}
|
|
351858
352207
|
case AuthType2.USE_GEMINI:
|
|
351859
352208
|
return RATE_LIMIT_ERROR_MESSAGE_USE_GEMINI;
|
|
351860
352209
|
case AuthType2.USE_VERTEX_AI:
|
|
@@ -351867,7 +352216,7 @@ function parseAndFormatApiError(error, authType, userTier, currentModel, fallbac
|
|
|
351867
352216
|
if (isStructuredError(error)) {
|
|
351868
352217
|
let text = `[API Error: ${error.message}]`;
|
|
351869
352218
|
if (error.status === 429) {
|
|
351870
|
-
text += getRateLimitMessage(authType,
|
|
352219
|
+
text += getRateLimitMessage(authType, fallbackModel);
|
|
351871
352220
|
}
|
|
351872
352221
|
return text;
|
|
351873
352222
|
}
|
|
@@ -351890,7 +352239,7 @@ function parseAndFormatApiError(error, authType, userTier, currentModel, fallbac
|
|
|
351890
352239
|
}
|
|
351891
352240
|
let text = `[API Error: ${finalMessage} (Status: ${parsedError.error.status})]`;
|
|
351892
352241
|
if (parsedError.error.code === 429) {
|
|
351893
|
-
text += getRateLimitMessage(authType,
|
|
352242
|
+
text += getRateLimitMessage(authType, fallbackModel);
|
|
351894
352243
|
}
|
|
351895
352244
|
return text;
|
|
351896
352245
|
}
|
|
@@ -351901,6 +352250,9 @@ function parseAndFormatApiError(error, authType, userTier, currentModel, fallbac
|
|
|
351901
352250
|
return "[API Error: An unknown error occurred.]";
|
|
351902
352251
|
}
|
|
351903
352252
|
|
|
352253
|
+
// packages/core/dist/src/index.js
|
|
352254
|
+
init_events();
|
|
352255
|
+
|
|
351904
352256
|
// packages/core/dist/src/utils/session.js
|
|
351905
352257
|
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
351906
352258
|
var sessionId = randomUUID6();
|
|
@@ -351951,7 +352303,8 @@ async function loadConfig(settings, extensions, taskId) {
|
|
|
351951
352303
|
enableRecursiveFileSearch: settings.fileFiltering?.enableRecursiveFileSearch
|
|
351952
352304
|
},
|
|
351953
352305
|
ideMode: false,
|
|
351954
|
-
folderTrust: settings.folderTrust === true
|
|
352306
|
+
folderTrust: settings.folderTrust === true,
|
|
352307
|
+
extensions
|
|
351955
352308
|
};
|
|
351956
352309
|
const fileService = new FileDiscoveryService(workspaceDir);
|
|
351957
352310
|
const { memoryContent, fileCount } = await loadServerHierarchicalMemory(
|
|
@@ -352146,7 +352499,7 @@ var GCSTaskStore = class {
|
|
|
352146
352499
|
if (await fse.pathExists(workDir)) {
|
|
352147
352500
|
const entries2 = await fsPromises4.readdir(workDir);
|
|
352148
352501
|
if (entries2.length > 0) {
|
|
352149
|
-
const tmpArchiveFile = join22(
|
|
352502
|
+
const tmpArchiveFile = join22(tmpdir4(), getTmpArchiveFilename(taskId));
|
|
352150
352503
|
try {
|
|
352151
352504
|
await create(
|
|
352152
352505
|
{
|
|
@@ -352268,7 +352621,7 @@ var GCSTaskStore = class {
|
|
|
352268
352621
|
const workspaceFile = this.storage.bucket(this.bucketName).file(workspaceObjectPath);
|
|
352269
352622
|
const [workspaceExists] = await workspaceFile.exists();
|
|
352270
352623
|
if (workspaceExists) {
|
|
352271
|
-
const tmpArchiveFile = join22(
|
|
352624
|
+
const tmpArchiveFile = join22(tmpdir4(), getTmpArchiveFilename(taskId));
|
|
352272
352625
|
try {
|
|
352273
352626
|
await workspaceFile.download({ destination: tmpArchiveFile });
|
|
352274
352627
|
await extract({ file: tmpArchiveFile, cwd: workDir });
|
|
@@ -352362,10 +352715,10 @@ function loadSettings(workspaceDir) {
|
|
|
352362
352715
|
});
|
|
352363
352716
|
}
|
|
352364
352717
|
if (settingsErrors.length > 0) {
|
|
352365
|
-
|
|
352718
|
+
debugLogger.error("Errors loading settings:");
|
|
352366
352719
|
for (const error of settingsErrors) {
|
|
352367
|
-
|
|
352368
|
-
|
|
352720
|
+
debugLogger.error(` Path: ${error.path}`);
|
|
352721
|
+
debugLogger.error(` Message: ${error.message}`);
|
|
352369
352722
|
}
|
|
352370
352723
|
}
|
|
352371
352724
|
return {
|
|
@@ -352751,8 +353104,8 @@ var Task = class _Task {
|
|
|
352751
353104
|
);
|
|
352752
353105
|
}
|
|
352753
353106
|
if (hasChanged) {
|
|
352754
|
-
const message = this.toolStatusMessage(tc, this.id, this.contextId);
|
|
352755
353107
|
const coderAgentMessage = tc.status === "awaiting_approval" ? { kind: "tool-call-confirmation" /* ToolCallConfirmationEvent */ } : { kind: "tool-call-update" /* ToolCallUpdateEvent */ };
|
|
353108
|
+
const message = this.toolStatusMessage(tc, this.id, this.contextId);
|
|
352756
353109
|
const event = this._createStatusUpdateEvent(
|
|
352757
353110
|
this.taskState,
|
|
352758
353111
|
coderAgentMessage,
|
|
@@ -352777,10 +353130,10 @@ var Task = class _Task {
|
|
|
352777
353130
|
const isAwaitingApproval = allPendingStatuses.some(
|
|
352778
353131
|
(status) => status === "awaiting_approval"
|
|
352779
353132
|
);
|
|
352780
|
-
const
|
|
352781
|
-
(status) => status === "
|
|
353133
|
+
const isExecuting = allPendingStatuses.some(
|
|
353134
|
+
(status) => status === "executing"
|
|
352782
353135
|
);
|
|
352783
|
-
if (isAwaitingApproval &&
|
|
353136
|
+
if (isAwaitingApproval && !isExecuting && !this.skipFinalTrueAfterInlineEdit) {
|
|
352784
353137
|
this.skipFinalTrueAfterInlineEdit = false;
|
|
352785
353138
|
this.setTaskStateAndPublishUpdate(
|
|
352786
353139
|
"input-required",
|
|
@@ -352949,6 +353302,10 @@ var Task = class _Task {
|
|
|
352949
353302
|
logger.info("[Task] Sending agent thought...");
|
|
352950
353303
|
this._sendThought(event.value, traceId);
|
|
352951
353304
|
break;
|
|
353305
|
+
case GeminiEventType.Citation:
|
|
353306
|
+
logger.info("[Task] Received citation from LLM stream.");
|
|
353307
|
+
this._sendCitation(event.value);
|
|
353308
|
+
break;
|
|
352952
353309
|
case GeminiEventType.ChatCompressed:
|
|
352953
353310
|
break;
|
|
352954
353311
|
case GeminiEventType.Finished:
|
|
@@ -353225,6 +353582,19 @@ var Task = class _Task {
|
|
|
353225
353582
|
)
|
|
353226
353583
|
);
|
|
353227
353584
|
}
|
|
353585
|
+
_sendCitation(citation) {
|
|
353586
|
+
if (!citation || citation.trim() === "") {
|
|
353587
|
+
return;
|
|
353588
|
+
}
|
|
353589
|
+
logger.info("[Task] Sending citation to event bus.");
|
|
353590
|
+
const message = this._createTextMessage(citation);
|
|
353591
|
+
const citationEvent = {
|
|
353592
|
+
kind: "citation" /* CitationEvent */
|
|
353593
|
+
};
|
|
353594
|
+
this.eventBus?.publish(
|
|
353595
|
+
this._createStatusUpdateEvent(this.taskState, citationEvent, message)
|
|
353596
|
+
);
|
|
353597
|
+
}
|
|
353228
353598
|
};
|
|
353229
353599
|
|
|
353230
353600
|
// packages/a2a-server/src/http/requestStorage.ts
|
|
@@ -353751,6 +354121,31 @@ var CoderAgentExecutor = class {
|
|
|
353751
354121
|
}
|
|
353752
354122
|
};
|
|
353753
354123
|
|
|
354124
|
+
// packages/a2a-server/src/commands/list-extensions.ts
|
|
354125
|
+
var ListExtensionsCommand = class {
|
|
354126
|
+
names = ["extensions", "extensions list"];
|
|
354127
|
+
async execute(config2, _) {
|
|
354128
|
+
return listExtensions(config2);
|
|
354129
|
+
}
|
|
354130
|
+
};
|
|
354131
|
+
|
|
354132
|
+
// packages/a2a-server/src/commands/command-registry.ts
|
|
354133
|
+
var CommandRegistry = class {
|
|
354134
|
+
commands = /* @__PURE__ */ new Map();
|
|
354135
|
+
constructor() {
|
|
354136
|
+
this.register(new ListExtensionsCommand());
|
|
354137
|
+
}
|
|
354138
|
+
register(command) {
|
|
354139
|
+
for (const name4 of command.names) {
|
|
354140
|
+
this.commands.set(name4, command);
|
|
354141
|
+
}
|
|
354142
|
+
}
|
|
354143
|
+
get(commandName) {
|
|
354144
|
+
return this.commands.get(commandName);
|
|
354145
|
+
}
|
|
354146
|
+
};
|
|
354147
|
+
var commandRegistry = new CommandRegistry();
|
|
354148
|
+
|
|
353754
354149
|
// packages/a2a-server/src/http/app.ts
|
|
353755
354150
|
var coderAgentCard = {
|
|
353756
354151
|
name: "Gemini SDLC Agent",
|
|
@@ -353793,6 +354188,11 @@ function updateCoderAgentCardUrl(port) {
|
|
|
353793
354188
|
}
|
|
353794
354189
|
async function createApp() {
|
|
353795
354190
|
try {
|
|
354191
|
+
const workspaceRoot = setTargetDir(void 0);
|
|
354192
|
+
loadEnvironment();
|
|
354193
|
+
const settings = loadSettings(workspaceRoot);
|
|
354194
|
+
const extensions = loadExtensions(workspaceRoot);
|
|
354195
|
+
const config2 = await loadConfig(settings, extensions, "a2a-server");
|
|
353796
354196
|
const bucketName = process.env["GCS_BUCKET_NAME"];
|
|
353797
354197
|
let taskStoreForExecutor;
|
|
353798
354198
|
let taskStoreForHandler;
|
|
@@ -353838,6 +354238,27 @@ async function createApp() {
|
|
|
353838
354238
|
res.status(500).send({ error: errorMessage });
|
|
353839
354239
|
}
|
|
353840
354240
|
});
|
|
354241
|
+
expressApp.post("/executeCommand", async (req, res) => {
|
|
354242
|
+
try {
|
|
354243
|
+
const { command, args: args2 } = req.body;
|
|
354244
|
+
if (typeof command !== "string") {
|
|
354245
|
+
return res.status(400).json({ error: 'Invalid "command" field.' });
|
|
354246
|
+
}
|
|
354247
|
+
if (args2 && !Array.isArray(args2)) {
|
|
354248
|
+
return res.status(400).json({ error: '"args" field must be an array.' });
|
|
354249
|
+
}
|
|
354250
|
+
const commandToExecute = commandRegistry.get(command);
|
|
354251
|
+
if (!commandToExecute) {
|
|
354252
|
+
return res.status(404).json({ error: `Command not found: ${command}` });
|
|
354253
|
+
}
|
|
354254
|
+
const result = await commandToExecute.execute(config2, args2 ?? []);
|
|
354255
|
+
return res.status(200).json(result);
|
|
354256
|
+
} catch (e2) {
|
|
354257
|
+
logger.error("Error executing /executeCommand:", e2);
|
|
354258
|
+
const errorMessage = e2 instanceof Error ? e2.message : "Unknown error executing command";
|
|
354259
|
+
return res.status(500).json({ error: errorMessage });
|
|
354260
|
+
}
|
|
354261
|
+
});
|
|
353841
354262
|
expressApp.get("/tasks/metadata", async (req, res) => {
|
|
353842
354263
|
if (!(taskStoreForExecutor instanceof InMemoryTaskStore)) {
|
|
353843
354264
|
res.status(501).send({
|