@google/gemini-cli 0.42.0 → 0.44.0-nightly.20260513.g5ee05c775
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundle/{chunk-COQP2M4D.js → chunk-27SPXGT2.js} +562 -437
- package/bundle/{chunk-EDKX67D6.js → chunk-2VH3SA6M.js} +43 -23
- package/bundle/{chunk-PUDLNWHE.js → chunk-3KOQHVJU.js} +3 -3
- package/bundle/{chunk-COKAF5GM.js → chunk-4QQ5AHZP.js} +2 -2
- package/bundle/{chunk-KVEAHIIV.js → chunk-5EEEHNEE.js} +3 -3
- package/bundle/{chunk-G2VTSEZ6.js → chunk-5SMSFUPB.js} +1 -1
- package/bundle/{chunk-7VVHSNDQ.js → chunk-AC2EWTF7.js} +1970 -731
- package/bundle/{chunk-GA527JB7.js → chunk-ATSNFRDF.js} +1 -1
- package/bundle/{chunk-3IS7GD6D.js → chunk-BA752AEU.js} +3 -3
- package/bundle/{chunk-CYEIWMZJ.js → chunk-FGYOOMPI.js} +1 -1
- package/bundle/{chunk-QOZSZYL7.js → chunk-FK45PHSI.js} +3 -3
- package/bundle/{chunk-I7AME6VC.js → chunk-FTY6BJEY.js} +9 -8
- package/bundle/{chunk-NTOPH4WG.js → chunk-GCWBZXBS.js} +2 -2
- package/bundle/chunk-I2JHD4D3.js +512 -0
- package/bundle/{chunk-7C6GGDK6.js → chunk-IZJOLGNO.js} +3 -3
- package/bundle/{chunk-4SLGT6YD.js → chunk-J4YAW3P3.js} +1 -1
- package/bundle/chunk-KADNKBXT.js +118 -0
- package/bundle/{chunk-DN4XSYRG.js → chunk-LF33N5QM.js} +8696 -13355
- package/bundle/{chunk-CHERUG6W.js → chunk-LO22NRY4.js} +502 -390
- package/bundle/{chunk-JEW7ZIWE.js → chunk-M7OUJJZ2.js} +5270 -5234
- package/bundle/{chunk-WIXUKOZA.js → chunk-MFNKZZOB.js} +1 -1
- package/bundle/chunk-MLPM54XD.js +357247 -0
- package/bundle/{chunk-ECNYAST2.js → chunk-N22WUHJE.js} +5419 -5378
- package/bundle/chunk-OC7XGTLV.js +81656 -0
- package/bundle/{chunk-ZNMQA242.js → chunk-QDEK3TQ6.js} +3 -3
- package/bundle/{chunk-BCYBA52D.js → chunk-QMXQUBC4.js} +43 -23
- package/bundle/chunk-TBHMNRI3.js +1571 -0
- package/bundle/{chunk-LATVEETM.js → chunk-TOOOS4HD.js} +2 -2
- package/bundle/{chunk-XUMRUXOT.js → chunk-UHSQLPNG.js} +50 -27
- package/bundle/chunk-USS2A6NQ.js +156 -0
- package/bundle/chunk-WMTLLWRC.js +391 -0
- package/bundle/chunk-XDWZDV7C.js +17250 -0
- package/bundle/{chunk-DMWX7UP6.js → chunk-YBYQH75I.js} +2252 -829
- package/bundle/{chunk-FCAODPNO.js → chunk-ZZN56QZ3.js} +502 -390
- package/bundle/{cleanup-3RILFNVM.js → cleanup-2H3SANYB.js} +3 -3
- package/bundle/{cleanup-SVRKYBR6.js → cleanup-7GY7BVC6.js} +3 -3
- package/bundle/{cleanup-XFVHHDVO.js → cleanup-FERREFU6.js} +3 -3
- package/bundle/cleanup-VIITMMDH.js +33 -0
- package/bundle/{core-FRVSDP2C.js → core-GS6NXK7Y.js} +30 -2
- package/bundle/{devtoolsService-VM2WTHBX.js → devtoolsService-FKC6Y4OE.js} +3 -3
- package/bundle/{devtoolsService-TRDGMQLJ.js → devtoolsService-K2DRCZEY.js} +5 -4
- package/bundle/{devtoolsService-RUEO5PGP.js → devtoolsService-PS6RYICL.js} +3 -3
- package/bundle/devtoolsService-ZDXC2NPD.js +857 -0
- package/bundle/{dist-6BN2CJPN.js → dist-S3YUNQKP.js} +30 -2
- package/bundle/{core-B5S6HZJT.js → dist-TBGNMYU2.js} +30 -2
- package/bundle/dist-ZEW43MLQ.js +2124 -0
- package/bundle/docs/changelogs/index.md +30 -0
- package/bundle/docs/changelogs/latest.md +261 -166
- package/bundle/docs/changelogs/preview.md +178 -103
- package/bundle/docs/cli/auto-memory.md +60 -38
- package/bundle/docs/cli/settings.md +1 -1
- package/bundle/docs/cli/tutorials/memory-management.md +1 -1
- package/bundle/docs/extensions/releasing.md +58 -24
- package/bundle/docs/reference/configuration.md +14 -1
- package/bundle/docs/reference/keyboard-shortcuts.md +23 -0
- package/bundle/{gemini-QSTQ2DBG.js → gemini-6YGVETF3.js} +165 -61
- package/bundle/{gemini-GHUELHBF.js → gemini-7FCGNXOV.js} +350 -232
- package/bundle/gemini-IXZUGRVP.js +16360 -0
- package/bundle/{gemini-NQPVX5JC.js → gemini-WYTY4CD5.js} +165 -61
- package/bundle/gemini.js +8 -8
- package/bundle/{interactiveCli-AG2YWL2O.js → interactiveCli-A2FV6NYD.js} +1721 -1472
- package/bundle/{interactiveCli-MZFG35NB.js → interactiveCli-DWNRHVIB.js} +2003 -1736
- package/bundle/{interactiveCli-453M2IVE.js → interactiveCli-H7N4UXVQ.js} +1720 -1472
- package/bundle/interactiveCli-XRZEELCX.js +34754 -0
- package/bundle/{liteRtServerManager-G4Q7OVBX.js → liteRtServerManager-5C5EONBK.js} +5 -5
- package/bundle/{liteRtServerManager-S7WL25VD.js → liteRtServerManager-NQKPNCLR.js} +5 -5
- package/bundle/{liteRtServerManager-BXQ6VVWP.js → liteRtServerManager-UJBPII3P.js} +5 -5
- package/bundle/liteRtServerManager-UZCAJJCS.js +66 -0
- package/bundle/{memoryDiscovery-KSYZVCWF.js → memoryDiscovery-ALKMYAPP.js} +1 -1
- package/bundle/{memoryDiscovery-FB7MMKTA.js → memoryDiscovery-XFCKEF3F.js} +1 -1
- package/bundle/node_modules/@google/gemini-cli-devtools/package.json +1 -1
- package/bundle/{oauth2-provider-VR4DL6AL.js → oauth2-provider-JNOY6NUI.js} +2 -2
- package/bundle/{oauth2-provider-H7G6RSFW.js → oauth2-provider-O6OA5EMU.js} +2 -2
- package/bundle/{oauth2-provider-5UF5WEE2.js → oauth2-provider-QYCLASEA.js} +39 -73
- package/bundle/oauth2-provider-VWLTUFO7.js +237 -0
- package/bundle/{start-CQBSKFYB.js → start-6FV3VPPH.js} +7 -7
- package/bundle/{start-NIMXQJYB.js → start-IWAUTCYF.js} +7 -7
- package/bundle/{start-2SKRN43X.js → start-L4DAQUQM.js} +7 -7
- package/bundle/start-XTXUKP77.js +19 -0
- package/package.json +1 -1
|
@@ -41,18 +41,18 @@ import {
|
|
|
41
41
|
updateAllUpdatableExtensions,
|
|
42
42
|
updateExtension,
|
|
43
43
|
validateAuthMethod
|
|
44
|
-
} from "./chunk-
|
|
44
|
+
} from "./chunk-ZZN56QZ3.js";
|
|
45
45
|
import {
|
|
46
46
|
appEvents
|
|
47
47
|
} from "./chunk-5PS3AYFU.js";
|
|
48
48
|
import {
|
|
49
49
|
startCommand,
|
|
50
50
|
startServer
|
|
51
|
-
} from "./chunk-
|
|
51
|
+
} from "./chunk-3KOQHVJU.js";
|
|
52
52
|
import {
|
|
53
53
|
exitCli,
|
|
54
54
|
require_source
|
|
55
|
-
} from "./chunk-
|
|
55
|
+
} from "./chunk-MFNKZZOB.js";
|
|
56
56
|
import {
|
|
57
57
|
DEFAULT_PORT,
|
|
58
58
|
GEMMA_MODEL_NAME,
|
|
@@ -86,11 +86,11 @@ import {
|
|
|
86
86
|
readServerProcessInfo,
|
|
87
87
|
resolveGemmaConfig,
|
|
88
88
|
saveModelChange
|
|
89
|
-
} from "./chunk-
|
|
89
|
+
} from "./chunk-2VH3SA6M.js";
|
|
90
90
|
import {
|
|
91
91
|
RELAUNCH_EXIT_CODE
|
|
92
|
-
} from "./chunk-
|
|
93
|
-
import "./chunk-
|
|
92
|
+
} from "./chunk-FK45PHSI.js";
|
|
93
|
+
import "./chunk-5SMSFUPB.js";
|
|
94
94
|
import {
|
|
95
95
|
cleanupCheckpoints,
|
|
96
96
|
registerCleanup,
|
|
@@ -99,33 +99,43 @@ import {
|
|
|
99
99
|
runExitCleanup,
|
|
100
100
|
runSyncCleanup,
|
|
101
101
|
setupSignalHandlers
|
|
102
|
-
} from "./chunk-
|
|
102
|
+
} from "./chunk-USS2A6NQ.js";
|
|
103
103
|
import {
|
|
104
104
|
AuthType,
|
|
105
105
|
ChatRecordingService,
|
|
106
106
|
Client,
|
|
107
107
|
Config,
|
|
108
|
+
CoreToolCallStatus,
|
|
108
109
|
ExitCodes,
|
|
109
110
|
FileDiscoveryService,
|
|
110
111
|
FolderTrustDiscoveryService,
|
|
112
|
+
GeminiEventType,
|
|
111
113
|
IdeClient,
|
|
114
|
+
IntegrityStatus,
|
|
112
115
|
InvalidStreamError,
|
|
113
116
|
JsonFormatter,
|
|
117
|
+
JsonStreamEventType,
|
|
114
118
|
LegacyAgentSession,
|
|
115
119
|
Logger,
|
|
116
120
|
MCPServerConfig,
|
|
121
|
+
MCPServerStatus,
|
|
122
|
+
OutputFormat,
|
|
117
123
|
PolicyIntegrityManager,
|
|
118
124
|
ROOT_SCHEDULER_ID,
|
|
119
125
|
ReadManyFilesTool,
|
|
120
126
|
Scheduler,
|
|
127
|
+
SessionEndReason,
|
|
128
|
+
SessionStartSource,
|
|
121
129
|
ShellExecutionService,
|
|
122
130
|
SimpleExtensionLoader,
|
|
123
131
|
StreamJsonFormatter,
|
|
124
132
|
ToolCallEvent,
|
|
133
|
+
TrustLevel,
|
|
125
134
|
UserAccountManager,
|
|
126
135
|
UserPromptEvent,
|
|
127
136
|
ValidationCancelledError,
|
|
128
137
|
ValidationRequiredError,
|
|
138
|
+
WarningPriority,
|
|
129
139
|
addMemory,
|
|
130
140
|
applyAdminAllowlist,
|
|
131
141
|
applyRequiredServers,
|
|
@@ -166,6 +176,7 @@ import {
|
|
|
166
176
|
listInboxPatches,
|
|
167
177
|
listInboxSkills,
|
|
168
178
|
listMemoryFiles,
|
|
179
|
+
loadConversationRecord,
|
|
169
180
|
logToolCall,
|
|
170
181
|
logUserPrompt,
|
|
171
182
|
parseAndFormatApiError,
|
|
@@ -189,9 +200,11 @@ import {
|
|
|
189
200
|
updatePolicy,
|
|
190
201
|
writeToStderr,
|
|
191
202
|
writeToStdout
|
|
192
|
-
} from "./chunk-
|
|
203
|
+
} from "./chunk-LF33N5QM.js";
|
|
193
204
|
import {
|
|
194
205
|
ASK_USER_TOOL_NAME,
|
|
206
|
+
ApprovalMode,
|
|
207
|
+
CoreEvent,
|
|
195
208
|
DEFAULT_FILE_FILTERING_OPTIONS,
|
|
196
209
|
DEFAULT_GEMINI_EMBEDDING_MODEL,
|
|
197
210
|
DEFAULT_GEMINI_FLASH_LITE_MODEL,
|
|
@@ -211,6 +224,7 @@ import {
|
|
|
211
224
|
FatalUntrustedWorkspaceError,
|
|
212
225
|
GEMINI_DIR,
|
|
213
226
|
GEMINI_MODEL_ALIAS_AUTO,
|
|
227
|
+
Kind,
|
|
214
228
|
PREVIEW_GEMINI_3_1_CUSTOM_TOOLS_MODEL,
|
|
215
229
|
PREVIEW_GEMINI_3_1_FLASH_LITE_MODEL,
|
|
216
230
|
PREVIEW_GEMINI_3_1_MODEL,
|
|
@@ -220,6 +234,7 @@ import {
|
|
|
220
234
|
REFERENCE_CONTENT_START,
|
|
221
235
|
Storage,
|
|
222
236
|
ToolConfirmationOutcome,
|
|
237
|
+
ToolErrorType,
|
|
223
238
|
coreEvents,
|
|
224
239
|
debugLogger,
|
|
225
240
|
external_exports,
|
|
@@ -227,13 +242,14 @@ import {
|
|
|
227
242
|
getDisplayString,
|
|
228
243
|
getErrorMessage,
|
|
229
244
|
getErrorType,
|
|
245
|
+
getProjectHash,
|
|
230
246
|
homedir,
|
|
231
247
|
isFatalToolError,
|
|
232
248
|
isNodeError,
|
|
233
249
|
loadServerHierarchicalMemory,
|
|
234
250
|
resolveToRealPath,
|
|
235
251
|
setGeminiMdFilename
|
|
236
|
-
} from "./chunk-
|
|
252
|
+
} from "./chunk-M7OUJJZ2.js";
|
|
237
253
|
import "./chunk-664ZODQF.js";
|
|
238
254
|
import "./chunk-RJTRUG2J.js";
|
|
239
255
|
import "./chunk-IUUIT4SU.js";
|
|
@@ -1518,11 +1534,11 @@ var parser = new YargsParser({
|
|
|
1518
1534
|
resolve: resolve2,
|
|
1519
1535
|
// TODO: figure out a way to combine ESM and CJS coverage, such that
|
|
1520
1536
|
// we can exercise all the lines below:
|
|
1521
|
-
require: (
|
|
1537
|
+
require: (path16) => {
|
|
1522
1538
|
if (typeof __require !== "undefined") {
|
|
1523
|
-
return __require(
|
|
1524
|
-
} else if (
|
|
1525
|
-
return JSON.parse(readFileSync(
|
|
1539
|
+
return __require(path16);
|
|
1540
|
+
} else if (path16.match(/\.json$/)) {
|
|
1541
|
+
return JSON.parse(readFileSync(path16, "utf8"));
|
|
1526
1542
|
} else {
|
|
1527
1543
|
throw Error("only .json config files are supported in ESM");
|
|
1528
1544
|
}
|
|
@@ -5363,7 +5379,7 @@ var MCP_LIST_DEFAULT_TIMEOUT_MSEC = 5e3;
|
|
|
5363
5379
|
async function testMCPConnection(serverName, config, isTrusted, activeSettings) {
|
|
5364
5380
|
const isStdio = !!config.command;
|
|
5365
5381
|
if (isStdio && !isTrusted) {
|
|
5366
|
-
return
|
|
5382
|
+
return MCPServerStatus.DISCONNECTED;
|
|
5367
5383
|
}
|
|
5368
5384
|
const client = new Client({
|
|
5369
5385
|
name: "mcp-test-client",
|
|
@@ -5399,7 +5415,7 @@ async function testMCPConnection(serverName, config, isTrusted, activeSettings)
|
|
|
5399
5415
|
transport = await createTransport(serverName, config, false, mcpContext);
|
|
5400
5416
|
} catch {
|
|
5401
5417
|
await client.close();
|
|
5402
|
-
return
|
|
5418
|
+
return MCPServerStatus.DISCONNECTED;
|
|
5403
5419
|
}
|
|
5404
5420
|
try {
|
|
5405
5421
|
const timeout = config.timeout ?? MCP_LIST_DEFAULT_TIMEOUT_MSEC;
|
|
@@ -5413,10 +5429,10 @@ async function testMCPConnection(serverName, config, isTrusted, activeSettings)
|
|
|
5413
5429
|
);
|
|
5414
5430
|
}
|
|
5415
5431
|
await client.close();
|
|
5416
|
-
return
|
|
5432
|
+
return MCPServerStatus.CONNECTED;
|
|
5417
5433
|
} catch {
|
|
5418
5434
|
await transport.close();
|
|
5419
|
-
return
|
|
5435
|
+
return MCPServerStatus.DISCONNECTED;
|
|
5420
5436
|
}
|
|
5421
5437
|
}
|
|
5422
5438
|
async function getServerStatus(serverName, server, isTrusted, activeSettings) {
|
|
@@ -5429,16 +5445,20 @@ async function getServerStatus(serverName, server, isTrusted, activeSettings) {
|
|
|
5429
5445
|
});
|
|
5430
5446
|
if (!loadResult.allowed) {
|
|
5431
5447
|
if (loadResult.blockType === "admin" || loadResult.blockType === "allowlist" || loadResult.blockType === "excludelist") {
|
|
5432
|
-
return
|
|
5448
|
+
return MCPServerStatus.BLOCKED;
|
|
5433
5449
|
}
|
|
5434
|
-
return
|
|
5450
|
+
return MCPServerStatus.DISABLED;
|
|
5451
|
+
}
|
|
5452
|
+
if (!isTrusted) {
|
|
5453
|
+
return MCPServerStatus.DISABLED;
|
|
5435
5454
|
}
|
|
5436
5455
|
return testMCPConnection(serverName, server, isTrusted, activeSettings);
|
|
5437
5456
|
}
|
|
5438
5457
|
async function listMcpServers(loadedSettingsArg) {
|
|
5439
5458
|
const loadedSettings = loadedSettingsArg ?? loadSettings();
|
|
5440
5459
|
const activeSettings = loadedSettings.merged;
|
|
5441
|
-
const
|
|
5460
|
+
const allSettings = !loadedSettings.isTrusted ? loadedSettings.getMergedSettingsAsIfTrusted() : activeSettings;
|
|
5461
|
+
const { mcpServers, blockedServerNames } = await getMcpServersFromConfig(allSettings);
|
|
5442
5462
|
const serverNames = Object.keys(mcpServers);
|
|
5443
5463
|
if (blockedServerNames.length > 0) {
|
|
5444
5464
|
const message = getAdminBlockedMcpServersMessage(
|
|
@@ -5453,6 +5473,13 @@ async function listMcpServers(loadedSettingsArg) {
|
|
|
5453
5473
|
}
|
|
5454
5474
|
return;
|
|
5455
5475
|
}
|
|
5476
|
+
if (!loadedSettings.isTrusted) {
|
|
5477
|
+
debugLogger.log(
|
|
5478
|
+
import_chalk.default.yellow(
|
|
5479
|
+
"Warning: MCP servers are configured but disabled because this folder is untrusted.\nUser-level servers are also suppressed in untrusted folders to prevent accidental side-effects.\n"
|
|
5480
|
+
)
|
|
5481
|
+
);
|
|
5482
|
+
}
|
|
5456
5483
|
debugLogger.log("Configured MCP servers:\n");
|
|
5457
5484
|
for (const serverName of serverNames) {
|
|
5458
5485
|
const server = mcpServers[serverName];
|
|
@@ -5465,23 +5492,23 @@ async function listMcpServers(loadedSettingsArg) {
|
|
|
5465
5492
|
let statusIndicator = "";
|
|
5466
5493
|
let statusText = "";
|
|
5467
5494
|
switch (status) {
|
|
5468
|
-
case
|
|
5495
|
+
case MCPServerStatus.CONNECTED:
|
|
5469
5496
|
statusIndicator = import_chalk.default.green("\u2713");
|
|
5470
5497
|
statusText = "Connected";
|
|
5471
5498
|
break;
|
|
5472
|
-
case
|
|
5499
|
+
case MCPServerStatus.CONNECTING:
|
|
5473
5500
|
statusIndicator = import_chalk.default.yellow("\u2026");
|
|
5474
5501
|
statusText = "Connecting";
|
|
5475
5502
|
break;
|
|
5476
|
-
case
|
|
5503
|
+
case MCPServerStatus.BLOCKED:
|
|
5477
5504
|
statusIndicator = import_chalk.default.red("\u26D4");
|
|
5478
5505
|
statusText = "Blocked";
|
|
5479
5506
|
break;
|
|
5480
|
-
case
|
|
5507
|
+
case MCPServerStatus.DISABLED:
|
|
5481
5508
|
statusIndicator = import_chalk.default.gray("\u25CB");
|
|
5482
5509
|
statusText = "Disabled";
|
|
5483
5510
|
break;
|
|
5484
|
-
case
|
|
5511
|
+
case MCPServerStatus.DISCONNECTED:
|
|
5485
5512
|
default:
|
|
5486
5513
|
statusIndicator = import_chalk.default.red("\u2717");
|
|
5487
5514
|
statusText = "Disconnected";
|
|
@@ -5767,7 +5794,7 @@ async function handleInstall(args) {
|
|
|
5767
5794
|
);
|
|
5768
5795
|
if (confirmed) {
|
|
5769
5796
|
const trustedFolders = loadTrustedFolders();
|
|
5770
|
-
await trustedFolders.setValue(realPath,
|
|
5797
|
+
await trustedFolders.setValue(realPath, TrustLevel.TRUST_FOLDER);
|
|
5771
5798
|
} else {
|
|
5772
5799
|
throw new Error(
|
|
5773
5800
|
`Installation aborted: Folder "${absolutePath}" is not trusted.`
|
|
@@ -6292,27 +6319,27 @@ import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
|
6292
6319
|
var __filename = fileURLToPath2(import.meta.url);
|
|
6293
6320
|
var __dirname2 = dirname3(__filename);
|
|
6294
6321
|
var EXAMPLES_PATH = join(__dirname2, "examples");
|
|
6295
|
-
async function pathExists(
|
|
6322
|
+
async function pathExists(path16) {
|
|
6296
6323
|
try {
|
|
6297
|
-
await access(
|
|
6324
|
+
await access(path16);
|
|
6298
6325
|
return true;
|
|
6299
6326
|
} catch {
|
|
6300
6327
|
return false;
|
|
6301
6328
|
}
|
|
6302
6329
|
}
|
|
6303
|
-
async function createDirectory(
|
|
6304
|
-
if (await pathExists(
|
|
6305
|
-
throw new Error(`Path already exists: ${
|
|
6330
|
+
async function createDirectory(path16) {
|
|
6331
|
+
if (await pathExists(path16)) {
|
|
6332
|
+
throw new Error(`Path already exists: ${path16}`);
|
|
6306
6333
|
}
|
|
6307
|
-
await mkdir(
|
|
6334
|
+
await mkdir(path16, { recursive: true });
|
|
6308
6335
|
}
|
|
6309
|
-
async function copyDirectory(template,
|
|
6310
|
-
await createDirectory(
|
|
6336
|
+
async function copyDirectory(template, path16) {
|
|
6337
|
+
await createDirectory(path16);
|
|
6311
6338
|
const examplePath = join(EXAMPLES_PATH, template);
|
|
6312
6339
|
const entries = await readdir(examplePath, { withFileTypes: true });
|
|
6313
6340
|
for (const entry of entries) {
|
|
6314
6341
|
const srcPath = join(examplePath, entry.name);
|
|
6315
|
-
const destPath = join(
|
|
6342
|
+
const destPath = join(path16, entry.name);
|
|
6316
6343
|
await cp(srcPath, destPath, { recursive: true });
|
|
6317
6344
|
}
|
|
6318
6345
|
}
|
|
@@ -6587,7 +6614,7 @@ async function handleEnable3(args) {
|
|
|
6587
6614
|
const result = enableSkill(settings, name);
|
|
6588
6615
|
const feedback = renderSkillActionFeedback(
|
|
6589
6616
|
result,
|
|
6590
|
-
(label,
|
|
6617
|
+
(label, path16) => `${import_chalk5.default.bold(label)} (${import_chalk5.default.dim(path16)})`
|
|
6591
6618
|
);
|
|
6592
6619
|
debugLogger.log(feedback);
|
|
6593
6620
|
}
|
|
@@ -6617,7 +6644,7 @@ async function handleDisable3(args) {
|
|
|
6617
6644
|
const result = disableSkill(settings, name, scope);
|
|
6618
6645
|
const feedback = renderSkillActionFeedback(
|
|
6619
6646
|
result,
|
|
6620
|
-
(label,
|
|
6647
|
+
(label, path16) => `${import_chalk6.default.bold(label)} (${import_chalk6.default.dim(path16)})`
|
|
6621
6648
|
);
|
|
6622
6649
|
debugLogger.log(feedback);
|
|
6623
6650
|
}
|
|
@@ -7812,7 +7839,7 @@ async function loadSandboxConfig(settings, argv) {
|
|
|
7812
7839
|
}
|
|
7813
7840
|
const command2 = getSandboxCommand(sandboxValue);
|
|
7814
7841
|
const packageJson = await getPackageJson(__dirname3);
|
|
7815
|
-
const image = process.env["GEMINI_SANDBOX_IMAGE"] ?? "us-docker.pkg.dev/gemini-code-dev/gemini-cli/sandbox:0.
|
|
7842
|
+
const image = process.env["GEMINI_SANDBOX_IMAGE"] ?? "us-docker.pkg.dev/gemini-code-dev/gemini-cli/sandbox:0.44.0-nightly.20260513.g5ee05c775" ?? customImage ?? packageJson?.config?.sandboxImageUri;
|
|
7816
7843
|
const isNative = command2 === "windows-native" || command2 === "sandbox-exec" || command2 === "lxc";
|
|
7817
7844
|
return command2 && (image || isNative) ? { enabled: true, allowedPaths, networkAccess, command: command2, image } : void 0;
|
|
7818
7845
|
}
|
|
@@ -7871,9 +7898,9 @@ async function resolveWorkspacePolicyState(options) {
|
|
|
7871
7898
|
cwd,
|
|
7872
7899
|
potentialWorkspacePoliciesDir
|
|
7873
7900
|
);
|
|
7874
|
-
if (integrityResult.status ===
|
|
7901
|
+
if (integrityResult.status === IntegrityStatus.MATCH) {
|
|
7875
7902
|
workspacePoliciesDir = potentialWorkspacePoliciesDir;
|
|
7876
|
-
} else if (integrityResult.status ===
|
|
7903
|
+
} else if (integrityResult.status === IntegrityStatus.NEW && integrityResult.fileCount === 0) {
|
|
7877
7904
|
workspacePoliciesDir = void 0;
|
|
7878
7905
|
} else if (interactive && !autoAcceptWorkspacePolicies) {
|
|
7879
7906
|
policyUpdateConfirmationRequest = {
|
|
@@ -7980,8 +8007,13 @@ async function parseArguments(settings) {
|
|
|
7980
8007
|
const queryArg2 = argv["query"];
|
|
7981
8008
|
const query = typeof queryArg2 === "string" || Array.isArray(queryArg2) ? queryArg2 : void 0;
|
|
7982
8009
|
const hasPositionalQuery = Array.isArray(query) ? query.length > 0 : !!query;
|
|
7983
|
-
|
|
7984
|
-
|
|
8010
|
+
const sessionFlags = [
|
|
8011
|
+
argv["resume"] !== void 0,
|
|
8012
|
+
argv["session-id"] !== void 0,
|
|
8013
|
+
argv["session-file"] !== void 0
|
|
8014
|
+
].filter(Boolean).length;
|
|
8015
|
+
if (sessionFlags > 1) {
|
|
8016
|
+
return "The flags --resume, --session-id, and --session-file are mutually exclusive. Please provide only one.";
|
|
7985
8017
|
}
|
|
7986
8018
|
if (argv["prompt"] && hasPositionalQuery) {
|
|
7987
8019
|
return "Cannot use both a positional prompt and the --prompt (-p) flag together";
|
|
@@ -8112,6 +8144,10 @@ async function parseArguments(settings) {
|
|
|
8112
8144
|
}
|
|
8113
8145
|
return trimmed;
|
|
8114
8146
|
}
|
|
8147
|
+
}).option("session-file", {
|
|
8148
|
+
type: "string",
|
|
8149
|
+
nargs: 1,
|
|
8150
|
+
description: "Load a session from a JSON file"
|
|
8115
8151
|
}).option("session-id", {
|
|
8116
8152
|
type: "string",
|
|
8117
8153
|
nargs: 1,
|
|
@@ -8313,23 +8349,23 @@ async function loadCliConfig(settings, sessionId, argv, options = {}) {
|
|
|
8313
8349
|
if (rawApprovalMode) {
|
|
8314
8350
|
switch (rawApprovalMode) {
|
|
8315
8351
|
case "yolo":
|
|
8316
|
-
approvalMode =
|
|
8352
|
+
approvalMode = ApprovalMode.YOLO;
|
|
8317
8353
|
break;
|
|
8318
8354
|
case "auto_edit":
|
|
8319
|
-
approvalMode =
|
|
8355
|
+
approvalMode = ApprovalMode.AUTO_EDIT;
|
|
8320
8356
|
break;
|
|
8321
8357
|
case "plan":
|
|
8322
8358
|
if (!(settings.general?.plan?.enabled ?? true)) {
|
|
8323
8359
|
debugLogger.warn(
|
|
8324
8360
|
'Approval mode "plan" is disabled in your settings. Falling back to "default".'
|
|
8325
8361
|
);
|
|
8326
|
-
approvalMode =
|
|
8362
|
+
approvalMode = ApprovalMode.DEFAULT;
|
|
8327
8363
|
} else {
|
|
8328
|
-
approvalMode =
|
|
8364
|
+
approvalMode = ApprovalMode.PLAN;
|
|
8329
8365
|
}
|
|
8330
8366
|
break;
|
|
8331
8367
|
case "default":
|
|
8332
|
-
approvalMode =
|
|
8368
|
+
approvalMode = ApprovalMode.DEFAULT;
|
|
8333
8369
|
break;
|
|
8334
8370
|
default:
|
|
8335
8371
|
throw new Error(
|
|
@@ -8337,10 +8373,10 @@ async function loadCliConfig(settings, sessionId, argv, options = {}) {
|
|
|
8337
8373
|
);
|
|
8338
8374
|
}
|
|
8339
8375
|
} else {
|
|
8340
|
-
approvalMode =
|
|
8376
|
+
approvalMode = ApprovalMode.DEFAULT;
|
|
8341
8377
|
}
|
|
8342
8378
|
if (settings.security?.disableYoloMode || settings.admin?.secureModeEnabled) {
|
|
8343
|
-
if (approvalMode ===
|
|
8379
|
+
if (approvalMode === ApprovalMode.YOLO) {
|
|
8344
8380
|
if (settings.admin?.secureModeEnabled) {
|
|
8345
8381
|
debugLogger.error(
|
|
8346
8382
|
'YOLO mode is disabled by "secureModeEnabled" setting.'
|
|
@@ -8358,16 +8394,16 @@ async function loadCliConfig(settings, sessionId, argv, options = {}) {
|
|
|
8358
8394
|
)
|
|
8359
8395
|
);
|
|
8360
8396
|
}
|
|
8361
|
-
} else if (approvalMode ===
|
|
8397
|
+
} else if (approvalMode === ApprovalMode.YOLO) {
|
|
8362
8398
|
debugLogger.warn(
|
|
8363
8399
|
"YOLO mode is enabled. All tool calls will be automatically approved."
|
|
8364
8400
|
);
|
|
8365
8401
|
}
|
|
8366
|
-
if (!trustedFolder && approvalMode !==
|
|
8402
|
+
if (!trustedFolder && approvalMode !== ApprovalMode.DEFAULT) {
|
|
8367
8403
|
debugLogger.warn(
|
|
8368
8404
|
`Approval mode overridden to "default" because the current folder is not trusted.`
|
|
8369
8405
|
);
|
|
8370
|
-
approvalMode =
|
|
8406
|
+
approvalMode = ApprovalMode.DEFAULT;
|
|
8371
8407
|
}
|
|
8372
8408
|
let telemetrySettings;
|
|
8373
8409
|
try {
|
|
@@ -8596,7 +8632,11 @@ async function loadCliConfig(settings, sessionId, argv, options = {}) {
|
|
|
8596
8632
|
shellBackgroundCompletionBehavior: settings.tools?.shell?.backgroundCompletionBehavior,
|
|
8597
8633
|
shellToolInactivityTimeout: settings.tools?.shell?.inactivityTimeout,
|
|
8598
8634
|
enableShellOutputEfficiency: settings.tools?.shell?.enableShellOutputEfficiency ?? true,
|
|
8599
|
-
|
|
8635
|
+
// In ACP mode, always skip the next-speaker check. This check triggers
|
|
8636
|
+
// recursive continuation turns inside GeminiClient.processTurn() that
|
|
8637
|
+
// conflict with ACP's explicit turn management via session/prompt,
|
|
8638
|
+
// causing infinite agent_thought_chunk loops.
|
|
8639
|
+
skipNextSpeakerCheck: isAcpMode || settings.model?.skipNextSpeakerCheck,
|
|
8600
8640
|
truncateToolOutputThreshold: settings.tools?.truncateToolOutputThreshold,
|
|
8601
8641
|
eventEmitter: coreEvents,
|
|
8602
8642
|
useWriteTodos: argv.useWriteTodos ?? settings.useWriteTodos,
|
|
@@ -8755,6 +8795,8 @@ import { createHash as createHash2 } from "node:crypto";
|
|
|
8755
8795
|
import v8 from "node:v8";
|
|
8756
8796
|
import os6 from "node:os";
|
|
8757
8797
|
import dns from "node:dns";
|
|
8798
|
+
import * as path15 from "node:path";
|
|
8799
|
+
import * as fsPromises from "node:fs/promises";
|
|
8758
8800
|
|
|
8759
8801
|
// packages/cli/src/utils/sandbox.ts
|
|
8760
8802
|
var import_shell_quote2 = __toESM(require_shell_quote(), 1);
|
|
@@ -9215,21 +9257,11 @@ async function start_sandbox(config, nodeArgs = [], cliConfig, cliArgs = []) {
|
|
|
9215
9257
|
}
|
|
9216
9258
|
const imageName = parseImageName(image);
|
|
9217
9259
|
const isIntegrationTest = process.env["GEMINI_CLI_INTEGRATION_TEST"] === "true";
|
|
9218
|
-
|
|
9219
|
-
|
|
9220
|
-
|
|
9221
|
-
|
|
9222
|
-
|
|
9223
|
-
debugLogger.log(`ContainerName: ${containerName}`);
|
|
9224
|
-
} else {
|
|
9225
|
-
let index = 0;
|
|
9226
|
-
const containerNameCheck = (await execAsync(`${command2} ps -a --format "{{.Names}}"`)).stdout.trim();
|
|
9227
|
-
while (containerNameCheck.includes(`${imageName}-${index}`)) {
|
|
9228
|
-
index++;
|
|
9229
|
-
}
|
|
9230
|
-
containerName = `${imageName}-${index}`;
|
|
9231
|
-
debugLogger.log(`ContainerName (regular): ${containerName}`);
|
|
9232
|
-
}
|
|
9260
|
+
const containerNamePrefix = isIntegrationTest ? "gemini-cli-integration-test" : imageName;
|
|
9261
|
+
const containerName = `${containerNamePrefix}-${randomBytes(6).toString(
|
|
9262
|
+
"hex"
|
|
9263
|
+
)}`;
|
|
9264
|
+
debugLogger.log(`ContainerName: ${containerName}`);
|
|
9233
9265
|
args.push("--name", containerName, "--hostname", containerName);
|
|
9234
9266
|
if (process.env["GEMINI_CLI_TEST_VAR"]) {
|
|
9235
9267
|
args.push(
|
|
@@ -9788,7 +9820,7 @@ import path9 from "node:path";
|
|
|
9788
9820
|
import process4 from "node:process";
|
|
9789
9821
|
var homeDirectoryCheck = {
|
|
9790
9822
|
id: "home-directory",
|
|
9791
|
-
priority:
|
|
9823
|
+
priority: WarningPriority.Low,
|
|
9792
9824
|
check: async (workspaceRoot, settings) => {
|
|
9793
9825
|
if (settings.ui?.showHomeDirectoryWarning === false) {
|
|
9794
9826
|
return null;
|
|
@@ -9812,7 +9844,7 @@ var homeDirectoryCheck = {
|
|
|
9812
9844
|
};
|
|
9813
9845
|
var rootDirectoryCheck = {
|
|
9814
9846
|
id: "root-directory",
|
|
9815
|
-
priority:
|
|
9847
|
+
priority: WarningPriority.High,
|
|
9816
9848
|
check: async (workspaceRoot, _settings) => {
|
|
9817
9849
|
try {
|
|
9818
9850
|
const workspaceRealPath = await fs9.realpath(workspaceRoot);
|
|
@@ -9828,7 +9860,7 @@ var rootDirectoryCheck = {
|
|
|
9828
9860
|
};
|
|
9829
9861
|
var folderTrustCheck = {
|
|
9830
9862
|
id: "folder-trust",
|
|
9831
|
-
priority:
|
|
9863
|
+
priority: WarningPriority.High,
|
|
9832
9864
|
check: async (workspaceRoot, settings) => {
|
|
9833
9865
|
if (!isFolderTrustEnabled(settings)) {
|
|
9834
9866
|
return null;
|
|
@@ -10018,12 +10050,12 @@ function handleError(error, config, customErrorCode) {
|
|
|
10018
10050
|
error,
|
|
10019
10051
|
config.getContentGeneratorConfig()?.authType
|
|
10020
10052
|
);
|
|
10021
|
-
if (config.getOutputFormat() ===
|
|
10053
|
+
if (config.getOutputFormat() === OutputFormat.STREAM_JSON) {
|
|
10022
10054
|
const streamFormatter = new StreamJsonFormatter();
|
|
10023
10055
|
const errorCode = customErrorCode ?? extractErrorCode(error);
|
|
10024
10056
|
const metrics = uiTelemetryService.getMetrics();
|
|
10025
10057
|
streamFormatter.emitEvent({
|
|
10026
|
-
type:
|
|
10058
|
+
type: JsonStreamEventType.RESULT,
|
|
10027
10059
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10028
10060
|
status: "error",
|
|
10029
10061
|
error: {
|
|
@@ -10034,7 +10066,7 @@ function handleError(error, config, customErrorCode) {
|
|
|
10034
10066
|
});
|
|
10035
10067
|
runSyncCleanup();
|
|
10036
10068
|
process.exit(getNumericExitCode(errorCode));
|
|
10037
|
-
} else if (config.getOutputFormat() ===
|
|
10069
|
+
} else if (config.getOutputFormat() === OutputFormat.JSON) {
|
|
10038
10070
|
const formatter = new JsonFormatter();
|
|
10039
10071
|
const errorCode = customErrorCode ?? extractErrorCode(error);
|
|
10040
10072
|
const formattedError = formatter.formatError(
|
|
@@ -10054,11 +10086,11 @@ function handleToolError(toolName, toolError, config, errorType, resultDisplay)
|
|
|
10054
10086
|
const isFatal = isFatalToolError(errorType);
|
|
10055
10087
|
if (isFatal) {
|
|
10056
10088
|
const toolExecutionError = new FatalToolExecutionError(errorMessage);
|
|
10057
|
-
if (config.getOutputFormat() ===
|
|
10089
|
+
if (config.getOutputFormat() === OutputFormat.STREAM_JSON) {
|
|
10058
10090
|
const streamFormatter = new StreamJsonFormatter();
|
|
10059
10091
|
const metrics = uiTelemetryService.getMetrics();
|
|
10060
10092
|
streamFormatter.emitEvent({
|
|
10061
|
-
type:
|
|
10093
|
+
type: JsonStreamEventType.RESULT,
|
|
10062
10094
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10063
10095
|
status: "error",
|
|
10064
10096
|
error: {
|
|
@@ -10067,7 +10099,7 @@ function handleToolError(toolName, toolError, config, errorType, resultDisplay)
|
|
|
10067
10099
|
},
|
|
10068
10100
|
stats: streamFormatter.convertToStreamStats(metrics, 0)
|
|
10069
10101
|
});
|
|
10070
|
-
} else if (config.getOutputFormat() ===
|
|
10102
|
+
} else if (config.getOutputFormat() === OutputFormat.JSON) {
|
|
10071
10103
|
const formatter = new JsonFormatter();
|
|
10072
10104
|
const formattedError = formatter.formatError(
|
|
10073
10105
|
toolExecutionError,
|
|
@@ -10085,11 +10117,11 @@ function handleToolError(toolName, toolError, config, errorType, resultDisplay)
|
|
|
10085
10117
|
}
|
|
10086
10118
|
function handleCancellationError(config) {
|
|
10087
10119
|
const cancellationError = new FatalCancellationError("Operation cancelled.");
|
|
10088
|
-
if (config.getOutputFormat() ===
|
|
10120
|
+
if (config.getOutputFormat() === OutputFormat.STREAM_JSON) {
|
|
10089
10121
|
const streamFormatter = new StreamJsonFormatter();
|
|
10090
10122
|
const metrics = uiTelemetryService.getMetrics();
|
|
10091
10123
|
streamFormatter.emitEvent({
|
|
10092
|
-
type:
|
|
10124
|
+
type: JsonStreamEventType.RESULT,
|
|
10093
10125
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10094
10126
|
status: "error",
|
|
10095
10127
|
error: {
|
|
@@ -10100,7 +10132,7 @@ function handleCancellationError(config) {
|
|
|
10100
10132
|
});
|
|
10101
10133
|
runSyncCleanup();
|
|
10102
10134
|
process.exit(cancellationError.exitCode);
|
|
10103
|
-
} else if (config.getOutputFormat() ===
|
|
10135
|
+
} else if (config.getOutputFormat() === OutputFormat.JSON) {
|
|
10104
10136
|
const formatter = new JsonFormatter();
|
|
10105
10137
|
const formattedError = formatter.formatError(
|
|
10106
10138
|
cancellationError,
|
|
@@ -10120,11 +10152,11 @@ function handleMaxTurnsExceededError(config) {
|
|
|
10120
10152
|
const maxTurnsError = new FatalTurnLimitedError(
|
|
10121
10153
|
"Reached max session turns for this session. Increase the number of turns by specifying maxSessionTurns in settings.json."
|
|
10122
10154
|
);
|
|
10123
|
-
if (config.getOutputFormat() ===
|
|
10155
|
+
if (config.getOutputFormat() === OutputFormat.STREAM_JSON) {
|
|
10124
10156
|
const streamFormatter = new StreamJsonFormatter();
|
|
10125
10157
|
const metrics = uiTelemetryService.getMetrics();
|
|
10126
10158
|
streamFormatter.emitEvent({
|
|
10127
|
-
type:
|
|
10159
|
+
type: JsonStreamEventType.RESULT,
|
|
10128
10160
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10129
10161
|
status: "error",
|
|
10130
10162
|
error: {
|
|
@@ -10135,7 +10167,7 @@ function handleMaxTurnsExceededError(config) {
|
|
|
10135
10167
|
});
|
|
10136
10168
|
runSyncCleanup();
|
|
10137
10169
|
process.exit(maxTurnsError.exitCode);
|
|
10138
|
-
} else if (config.getOutputFormat() ===
|
|
10170
|
+
} else if (config.getOutputFormat() === OutputFormat.JSON) {
|
|
10139
10171
|
const formatter = new JsonFormatter();
|
|
10140
10172
|
const formattedError = formatter.formatError(
|
|
10141
10173
|
maxTurnsError,
|
|
@@ -10215,7 +10247,7 @@ async function runNonInteractive({
|
|
|
10215
10247
|
}
|
|
10216
10248
|
});
|
|
10217
10249
|
if (process.env["GEMINI_CLI_ACTIVITY_LOG_TARGET"]) {
|
|
10218
|
-
const { setupInitialActivityLogger } = await import("./devtoolsService-
|
|
10250
|
+
const { setupInitialActivityLogger } = await import("./devtoolsService-ZDXC2NPD.js");
|
|
10219
10251
|
setupInitialActivityLogger(config);
|
|
10220
10252
|
}
|
|
10221
10253
|
const { stdout: workingStdout } = createWorkingStdio();
|
|
@@ -10231,7 +10263,7 @@ async function runNonInteractive({
|
|
|
10231
10263
|
}
|
|
10232
10264
|
};
|
|
10233
10265
|
const startTime = Date.now();
|
|
10234
|
-
const streamFormatter = config.getOutputFormat() ===
|
|
10266
|
+
const streamFormatter = config.getOutputFormat() === OutputFormat.STREAM_JSON ? new StreamJsonFormatter() : null;
|
|
10235
10267
|
const abortController = new AbortController();
|
|
10236
10268
|
let isAborting = false;
|
|
10237
10269
|
let cancelMessageTimer = null;
|
|
@@ -10284,13 +10316,13 @@ async function runNonInteractive({
|
|
|
10284
10316
|
};
|
|
10285
10317
|
try {
|
|
10286
10318
|
consolePatcher.patch();
|
|
10287
|
-
if (config.getRawOutput() && !config.getAcceptRawOutputRisk() && config.getOutputFormat() ===
|
|
10319
|
+
if (config.getRawOutput() && !config.getAcceptRawOutputRisk() && config.getOutputFormat() === OutputFormat.TEXT) {
|
|
10288
10320
|
process.stderr.write(
|
|
10289
10321
|
"[WARNING] --raw-output is enabled. Model output is not sanitized and may contain harmful ANSI sequences (e.g. for phishing or command injection). Use --accept-raw-output-risk to suppress this warning.\n"
|
|
10290
10322
|
);
|
|
10291
10323
|
}
|
|
10292
10324
|
setupStdinCancellation();
|
|
10293
|
-
coreEvents.on(
|
|
10325
|
+
coreEvents.on(CoreEvent.UserFeedback, handleUserFeedback);
|
|
10294
10326
|
coreEvents.drainBacklogs();
|
|
10295
10327
|
process.stdout.on("error", (err) => {
|
|
10296
10328
|
if (err.code === "EPIPE") {
|
|
@@ -10316,7 +10348,7 @@ async function runNonInteractive({
|
|
|
10316
10348
|
}
|
|
10317
10349
|
if (streamFormatter) {
|
|
10318
10350
|
streamFormatter.emitEvent({
|
|
10319
|
-
type:
|
|
10351
|
+
type: JsonStreamEventType.INIT,
|
|
10320
10352
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10321
10353
|
session_id: config.getSessionId(),
|
|
10322
10354
|
model: config.getModel()
|
|
@@ -10354,7 +10386,7 @@ async function runNonInteractive({
|
|
|
10354
10386
|
}
|
|
10355
10387
|
if (streamFormatter) {
|
|
10356
10388
|
streamFormatter.emitEvent({
|
|
10357
|
-
type:
|
|
10389
|
+
type: JsonStreamEventType.MESSAGE,
|
|
10358
10390
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10359
10391
|
role: "user",
|
|
10360
10392
|
content: input
|
|
@@ -10393,12 +10425,12 @@ async function runNonInteractive({
|
|
|
10393
10425
|
const metrics = uiTelemetryService.getMetrics();
|
|
10394
10426
|
const durationMs = Date.now() - startTime;
|
|
10395
10427
|
streamFormatter.emitEvent({
|
|
10396
|
-
type:
|
|
10428
|
+
type: JsonStreamEventType.RESULT,
|
|
10397
10429
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10398
10430
|
status: "success",
|
|
10399
10431
|
stats: streamFormatter.convertToStreamStats(metrics, durationMs)
|
|
10400
10432
|
});
|
|
10401
|
-
} else if (config.getOutputFormat() ===
|
|
10433
|
+
} else if (config.getOutputFormat() === OutputFormat.JSON) {
|
|
10402
10434
|
const formatter = new JsonFormatter();
|
|
10403
10435
|
const stats = uiTelemetryService.getMetrics();
|
|
10404
10436
|
textOutput.write(
|
|
@@ -10491,13 +10523,13 @@ async function runNonInteractive({
|
|
|
10491
10523
|
const output = isRaw ? part.text : stripAnsi(part.text);
|
|
10492
10524
|
if (streamFormatter) {
|
|
10493
10525
|
streamFormatter.emitEvent({
|
|
10494
|
-
type:
|
|
10526
|
+
type: JsonStreamEventType.MESSAGE,
|
|
10495
10527
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10496
10528
|
role: "assistant",
|
|
10497
10529
|
content: output,
|
|
10498
10530
|
delta: true
|
|
10499
10531
|
});
|
|
10500
|
-
} else if (config.getOutputFormat() ===
|
|
10532
|
+
} else if (config.getOutputFormat() === OutputFormat.JSON) {
|
|
10501
10533
|
responseText += output;
|
|
10502
10534
|
} else {
|
|
10503
10535
|
if (part.text) {
|
|
@@ -10510,13 +10542,13 @@ async function runNonInteractive({
|
|
|
10510
10542
|
break;
|
|
10511
10543
|
}
|
|
10512
10544
|
case "tool_request": {
|
|
10513
|
-
if (config.getOutputFormat() ===
|
|
10545
|
+
if (config.getOutputFormat() === OutputFormat.JSON) {
|
|
10514
10546
|
preToolResponseText = responseText || preToolResponseText;
|
|
10515
10547
|
responseText = "";
|
|
10516
10548
|
}
|
|
10517
10549
|
if (streamFormatter) {
|
|
10518
10550
|
streamFormatter.emitEvent({
|
|
10519
|
-
type:
|
|
10551
|
+
type: JsonStreamEventType.TOOL_USE,
|
|
10520
10552
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10521
10553
|
tool_name: event.name,
|
|
10522
10554
|
tool_id: event.requestId,
|
|
@@ -10532,7 +10564,7 @@ async function runNonInteractive({
|
|
|
10532
10564
|
const displayText = displayContentToString(display);
|
|
10533
10565
|
const errorMsg = getTextContent(event.content) ?? "Tool error";
|
|
10534
10566
|
streamFormatter.emitEvent({
|
|
10535
|
-
type:
|
|
10567
|
+
type: JsonStreamEventType.TOOL_RESULT,
|
|
10536
10568
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10537
10569
|
tool_id: event.requestId,
|
|
10538
10570
|
status: event.isError ? "error" : "success",
|
|
@@ -10547,17 +10579,17 @@ async function runNonInteractive({
|
|
|
10547
10579
|
const display = event.display?.result;
|
|
10548
10580
|
const displayText = displayContentToString(display);
|
|
10549
10581
|
const errorMsg = getTextContent(event.content) ?? "Tool error";
|
|
10550
|
-
if (event.data?.["errorType"] ===
|
|
10551
|
-
if (config.getOutputFormat() ===
|
|
10582
|
+
if (event.data?.["errorType"] === ToolErrorType.STOP_EXECUTION) {
|
|
10583
|
+
if (config.getOutputFormat() === OutputFormat.JSON && !responseText && preToolResponseText) {
|
|
10552
10584
|
responseText = preToolResponseText;
|
|
10553
10585
|
}
|
|
10554
10586
|
const stopMessage = `Agent execution stopped: ${errorMsg}`;
|
|
10555
|
-
if (config.getOutputFormat() ===
|
|
10587
|
+
if (config.getOutputFormat() === OutputFormat.TEXT) {
|
|
10556
10588
|
process.stderr.write(`${stopMessage}
|
|
10557
10589
|
`);
|
|
10558
10590
|
}
|
|
10559
10591
|
}
|
|
10560
|
-
if (event.data?.["errorType"] ===
|
|
10592
|
+
if (event.data?.["errorType"] === ToolErrorType.NO_SPACE_LEFT) {
|
|
10561
10593
|
throw new FatalToolExecutionError(
|
|
10562
10594
|
"Error executing tool " + event.name + ": " + (displayText || errorMsg)
|
|
10563
10595
|
);
|
|
@@ -10579,12 +10611,12 @@ async function runNonInteractive({
|
|
|
10579
10611
|
const errorCode = event._meta?.["code"];
|
|
10580
10612
|
if (errorCode === "AGENT_EXECUTION_BLOCKED") {
|
|
10581
10613
|
const blockMessage = `Agent execution blocked: ${event.message.trim()}`;
|
|
10582
|
-
if (config.getOutputFormat() ===
|
|
10614
|
+
if (config.getOutputFormat() === OutputFormat.TEXT) {
|
|
10583
10615
|
process.stderr.write(`[WARNING] ${blockMessage}
|
|
10584
10616
|
`);
|
|
10585
10617
|
} else if (streamFormatter) {
|
|
10586
10618
|
streamFormatter.emitEvent({
|
|
10587
|
-
type:
|
|
10619
|
+
type: JsonStreamEventType.ERROR,
|
|
10588
10620
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10589
10621
|
severity: "warning",
|
|
10590
10622
|
message: stripAnsi(blockMessage)
|
|
@@ -10594,13 +10626,13 @@ async function runNonInteractive({
|
|
|
10594
10626
|
break;
|
|
10595
10627
|
}
|
|
10596
10628
|
const severity = event.status === "RESOURCE_EXHAUSTED" ? "error" : "warning";
|
|
10597
|
-
if (config.getOutputFormat() ===
|
|
10629
|
+
if (config.getOutputFormat() === OutputFormat.TEXT) {
|
|
10598
10630
|
process.stderr.write(`[WARNING] ${event.message}
|
|
10599
10631
|
`);
|
|
10600
10632
|
}
|
|
10601
10633
|
if (streamFormatter) {
|
|
10602
10634
|
streamFormatter.emitEvent({
|
|
10603
|
-
type:
|
|
10635
|
+
type: JsonStreamEventType.ERROR,
|
|
10604
10636
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10605
10637
|
severity,
|
|
10606
10638
|
message: stripAnsi(event.message)
|
|
@@ -10620,7 +10652,7 @@ async function runNonInteractive({
|
|
|
10620
10652
|
);
|
|
10621
10653
|
} else if (streamFormatter) {
|
|
10622
10654
|
streamFormatter.emitEvent({
|
|
10623
|
-
type:
|
|
10655
|
+
type: JsonStreamEventType.ERROR,
|
|
10624
10656
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10625
10657
|
severity: "error",
|
|
10626
10658
|
message: "Maximum session turns exceeded"
|
|
@@ -10628,7 +10660,7 @@ async function runNonInteractive({
|
|
|
10628
10660
|
}
|
|
10629
10661
|
}
|
|
10630
10662
|
const stopMessage = typeof event.data?.["message"] === "string" ? event.data["message"] : "";
|
|
10631
|
-
if (stopMessage && config.getOutputFormat() ===
|
|
10663
|
+
if (stopMessage && config.getOutputFormat() === OutputFormat.TEXT) {
|
|
10632
10664
|
process.stderr.write(`Agent execution stopped: ${stopMessage}
|
|
10633
10665
|
`);
|
|
10634
10666
|
}
|
|
@@ -10658,7 +10690,7 @@ async function runNonInteractive({
|
|
|
10658
10690
|
abortController.signal.removeEventListener("abort", abortSession);
|
|
10659
10691
|
scheduler?.dispose();
|
|
10660
10692
|
consolePatcher.cleanup();
|
|
10661
|
-
coreEvents.off(
|
|
10693
|
+
coreEvents.off(CoreEvent.UserFeedback, handleUserFeedback);
|
|
10662
10694
|
}
|
|
10663
10695
|
if (errorToHandle) {
|
|
10664
10696
|
handleError(errorToHandle, config);
|
|
@@ -10670,6 +10702,9 @@ async function runNonInteractive({
|
|
|
10670
10702
|
async function runNonInteractive2(params) {
|
|
10671
10703
|
const useAgentSession = params.config.getAgentSessionNoninteractiveEnabled();
|
|
10672
10704
|
if (useAgentSession) {
|
|
10705
|
+
debugLogger.debug(
|
|
10706
|
+
"[ADK] Running non-interactive mode with ADK agent session"
|
|
10707
|
+
);
|
|
10673
10708
|
return runNonInteractive(params);
|
|
10674
10709
|
}
|
|
10675
10710
|
const { config, settings, input, prompt_id, resumedSessionData } = params;
|
|
@@ -10683,7 +10718,7 @@ async function runNonInteractive2(params) {
|
|
|
10683
10718
|
}
|
|
10684
10719
|
});
|
|
10685
10720
|
if (process.env["GEMINI_CLI_ACTIVITY_LOG_TARGET"]) {
|
|
10686
|
-
const { setupInitialActivityLogger } = await import("./devtoolsService-
|
|
10721
|
+
const { setupInitialActivityLogger } = await import("./devtoolsService-ZDXC2NPD.js");
|
|
10687
10722
|
setupInitialActivityLogger(config);
|
|
10688
10723
|
}
|
|
10689
10724
|
const { stdout: workingStdout } = createWorkingStdio();
|
|
@@ -10699,7 +10734,7 @@ async function runNonInteractive2(params) {
|
|
|
10699
10734
|
}
|
|
10700
10735
|
};
|
|
10701
10736
|
const startTime = Date.now();
|
|
10702
|
-
const streamFormatter = config.getOutputFormat() ===
|
|
10737
|
+
const streamFormatter = config.getOutputFormat() === OutputFormat.STREAM_JSON ? new StreamJsonFormatter() : null;
|
|
10703
10738
|
const abortController = new AbortController();
|
|
10704
10739
|
let isAborting = false;
|
|
10705
10740
|
let cancelMessageTimer = null;
|
|
@@ -10750,13 +10785,13 @@ async function runNonInteractive2(params) {
|
|
|
10750
10785
|
let scheduler;
|
|
10751
10786
|
try {
|
|
10752
10787
|
consolePatcher.patch();
|
|
10753
|
-
if (config.getRawOutput() && !config.getAcceptRawOutputRisk() && config.getOutputFormat() ===
|
|
10788
|
+
if (config.getRawOutput() && !config.getAcceptRawOutputRisk() && config.getOutputFormat() === OutputFormat.TEXT) {
|
|
10754
10789
|
process.stderr.write(
|
|
10755
10790
|
"[WARNING] --raw-output is enabled. Model output is not sanitized and may contain harmful ANSI sequences (e.g. for phishing or command injection). Use --accept-raw-output-risk to suppress this warning.\n"
|
|
10756
10791
|
);
|
|
10757
10792
|
}
|
|
10758
10793
|
setupStdinCancellation();
|
|
10759
|
-
coreEvents.on(
|
|
10794
|
+
coreEvents.on(CoreEvent.UserFeedback, handleUserFeedback);
|
|
10760
10795
|
coreEvents.drainBacklogs();
|
|
10761
10796
|
process.stdout.on("error", (err) => {
|
|
10762
10797
|
if (err.code === "EPIPE") {
|
|
@@ -10780,7 +10815,7 @@ async function runNonInteractive2(params) {
|
|
|
10780
10815
|
}
|
|
10781
10816
|
if (streamFormatter) {
|
|
10782
10817
|
streamFormatter.emitEvent({
|
|
10783
|
-
type:
|
|
10818
|
+
type: JsonStreamEventType.INIT,
|
|
10784
10819
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10785
10820
|
session_id: config.getSessionId(),
|
|
10786
10821
|
model: config.getModel()
|
|
@@ -10818,7 +10853,7 @@ async function runNonInteractive2(params) {
|
|
|
10818
10853
|
}
|
|
10819
10854
|
if (streamFormatter) {
|
|
10820
10855
|
streamFormatter.emitEvent({
|
|
10821
|
-
type:
|
|
10856
|
+
type: JsonStreamEventType.MESSAGE,
|
|
10822
10857
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10823
10858
|
role: "user",
|
|
10824
10859
|
content: input
|
|
@@ -10846,28 +10881,28 @@ async function runNonInteractive2(params) {
|
|
|
10846
10881
|
if (abortController.signal.aborted) {
|
|
10847
10882
|
handleCancellationError(config);
|
|
10848
10883
|
}
|
|
10849
|
-
if (event.type ===
|
|
10884
|
+
if (event.type === GeminiEventType.Content) {
|
|
10850
10885
|
const isRaw = config.getRawOutput() || config.getAcceptRawOutputRisk();
|
|
10851
10886
|
const output = isRaw ? event.value : stripAnsi(event.value);
|
|
10852
10887
|
if (streamFormatter) {
|
|
10853
10888
|
streamFormatter.emitEvent({
|
|
10854
|
-
type:
|
|
10889
|
+
type: JsonStreamEventType.MESSAGE,
|
|
10855
10890
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10856
10891
|
role: "assistant",
|
|
10857
10892
|
content: output,
|
|
10858
10893
|
delta: true
|
|
10859
10894
|
});
|
|
10860
|
-
} else if (config.getOutputFormat() ===
|
|
10895
|
+
} else if (config.getOutputFormat() === OutputFormat.JSON) {
|
|
10861
10896
|
responseText += output;
|
|
10862
10897
|
} else {
|
|
10863
10898
|
if (event.value) {
|
|
10864
10899
|
textOutput.write(output);
|
|
10865
10900
|
}
|
|
10866
10901
|
}
|
|
10867
|
-
} else if (event.type ===
|
|
10902
|
+
} else if (event.type === GeminiEventType.ToolCallRequest) {
|
|
10868
10903
|
if (streamFormatter) {
|
|
10869
10904
|
streamFormatter.emitEvent({
|
|
10870
|
-
type:
|
|
10905
|
+
type: JsonStreamEventType.TOOL_USE,
|
|
10871
10906
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10872
10907
|
tool_name: event.value.name,
|
|
10873
10908
|
tool_id: event.value.callId,
|
|
@@ -10875,33 +10910,33 @@ async function runNonInteractive2(params) {
|
|
|
10875
10910
|
});
|
|
10876
10911
|
}
|
|
10877
10912
|
toolCallRequests.push(event.value);
|
|
10878
|
-
} else if (event.type ===
|
|
10913
|
+
} else if (event.type === GeminiEventType.LoopDetected) {
|
|
10879
10914
|
const message = "Loop detected, stopping execution";
|
|
10880
10915
|
if (streamFormatter) {
|
|
10881
10916
|
streamFormatter.emitEvent({
|
|
10882
|
-
type:
|
|
10917
|
+
type: JsonStreamEventType.ERROR,
|
|
10883
10918
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10884
10919
|
severity: "warning",
|
|
10885
10920
|
message
|
|
10886
10921
|
});
|
|
10887
10922
|
}
|
|
10888
10923
|
warnings.push(message);
|
|
10889
|
-
} else if (event.type ===
|
|
10924
|
+
} else if (event.type === GeminiEventType.MaxSessionTurns) {
|
|
10890
10925
|
const message = "Maximum session turns exceeded";
|
|
10891
10926
|
if (streamFormatter) {
|
|
10892
10927
|
streamFormatter.emitEvent({
|
|
10893
|
-
type:
|
|
10928
|
+
type: JsonStreamEventType.ERROR,
|
|
10894
10929
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10895
10930
|
severity: "error",
|
|
10896
10931
|
message
|
|
10897
10932
|
});
|
|
10898
10933
|
}
|
|
10899
10934
|
warnings.push(message);
|
|
10900
|
-
} else if (event.type ===
|
|
10935
|
+
} else if (event.type === GeminiEventType.Error) {
|
|
10901
10936
|
throw event.value.error;
|
|
10902
|
-
} else if (event.type ===
|
|
10937
|
+
} else if (event.type === GeminiEventType.AgentExecutionStopped) {
|
|
10903
10938
|
const stopMessage = `Agent execution stopped: ${event.value.systemMessage?.trim() || event.value.reason}`;
|
|
10904
|
-
if (config.getOutputFormat() ===
|
|
10939
|
+
if (config.getOutputFormat() === OutputFormat.TEXT) {
|
|
10905
10940
|
process.stderr.write(`${stopMessage}
|
|
10906
10941
|
`);
|
|
10907
10942
|
}
|
|
@@ -10909,7 +10944,7 @@ async function runNonInteractive2(params) {
|
|
|
10909
10944
|
const metrics = uiTelemetryService.getMetrics();
|
|
10910
10945
|
const durationMs = Date.now() - startTime;
|
|
10911
10946
|
streamFormatter.emitEvent({
|
|
10912
|
-
type:
|
|
10947
|
+
type: JsonStreamEventType.RESULT,
|
|
10913
10948
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10914
10949
|
status: "success",
|
|
10915
10950
|
stats: streamFormatter.convertToStreamStats(
|
|
@@ -10917,32 +10952,46 @@ async function runNonInteractive2(params) {
|
|
|
10917
10952
|
durationMs
|
|
10918
10953
|
)
|
|
10919
10954
|
});
|
|
10955
|
+
} else if (config.getOutputFormat() === OutputFormat.JSON) {
|
|
10956
|
+
const formatter = new JsonFormatter();
|
|
10957
|
+
const stats = uiTelemetryService.getMetrics();
|
|
10958
|
+
textOutput.write(
|
|
10959
|
+
formatter.format(
|
|
10960
|
+
config.getSessionId(),
|
|
10961
|
+
responseText,
|
|
10962
|
+
stats,
|
|
10963
|
+
void 0,
|
|
10964
|
+
[...warnings, stopMessage]
|
|
10965
|
+
)
|
|
10966
|
+
);
|
|
10967
|
+
} else {
|
|
10968
|
+
textOutput.ensureTrailingNewline();
|
|
10920
10969
|
}
|
|
10921
10970
|
return;
|
|
10922
|
-
} else if (event.type ===
|
|
10971
|
+
} else if (event.type === GeminiEventType.AgentExecutionBlocked) {
|
|
10923
10972
|
const blockMessage = `Agent execution blocked: ${event.value.systemMessage?.trim() || event.value.reason}`;
|
|
10924
|
-
if (config.getOutputFormat() ===
|
|
10973
|
+
if (config.getOutputFormat() === OutputFormat.TEXT) {
|
|
10925
10974
|
process.stderr.write(`[WARNING] ${blockMessage}
|
|
10926
10975
|
`);
|
|
10927
10976
|
} else if (streamFormatter) {
|
|
10928
10977
|
streamFormatter.emitEvent({
|
|
10929
|
-
type:
|
|
10978
|
+
type: JsonStreamEventType.ERROR,
|
|
10930
10979
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10931
10980
|
severity: "warning",
|
|
10932
10981
|
message: stripAnsi(blockMessage)
|
|
10933
10982
|
});
|
|
10934
10983
|
}
|
|
10935
10984
|
warnings.push(blockMessage);
|
|
10936
|
-
} else if (event.type ===
|
|
10985
|
+
} else if (event.type === GeminiEventType.InvalidStream) {
|
|
10937
10986
|
invalidStreamError = "Invalid stream: The model returned an empty response or malformed tool call.";
|
|
10938
10987
|
if (streamFormatter) {
|
|
10939
10988
|
streamFormatter.emitEvent({
|
|
10940
|
-
type:
|
|
10989
|
+
type: JsonStreamEventType.ERROR,
|
|
10941
10990
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10942
10991
|
severity: "error",
|
|
10943
10992
|
message: invalidStreamError
|
|
10944
10993
|
});
|
|
10945
|
-
} else if (config.getOutputFormat() ===
|
|
10994
|
+
} else if (config.getOutputFormat() === OutputFormat.TEXT) {
|
|
10946
10995
|
process.stderr.write(`[ERROR] ${invalidStreamError}
|
|
10947
10996
|
`);
|
|
10948
10997
|
}
|
|
@@ -10962,7 +11011,7 @@ async function runNonInteractive2(params) {
|
|
|
10962
11011
|
const requestInfo = completedToolCall.request;
|
|
10963
11012
|
if (streamFormatter) {
|
|
10964
11013
|
streamFormatter.emitEvent({
|
|
10965
|
-
type:
|
|
11014
|
+
type: JsonStreamEventType.TOOL_RESULT,
|
|
10966
11015
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10967
11016
|
tool_id: requestInfo.callId,
|
|
10968
11017
|
status: completedToolCall.status === "error" ? "error" : "success",
|
|
@@ -10996,11 +11045,11 @@ async function runNonInteractive2(params) {
|
|
|
10996
11045
|
);
|
|
10997
11046
|
}
|
|
10998
11047
|
const stopExecutionTool = completedToolCalls.find(
|
|
10999
|
-
(tc) => tc.response.errorType ===
|
|
11048
|
+
(tc) => tc.response.errorType === ToolErrorType.STOP_EXECUTION
|
|
11000
11049
|
);
|
|
11001
11050
|
if (stopExecutionTool && stopExecutionTool.response.error) {
|
|
11002
11051
|
const stopMessage = `Agent execution stopped: ${stopExecutionTool.response.error.message}`;
|
|
11003
|
-
if (config.getOutputFormat() ===
|
|
11052
|
+
if (config.getOutputFormat() === OutputFormat.TEXT) {
|
|
11004
11053
|
process.stderr.write(`${stopMessage}
|
|
11005
11054
|
`);
|
|
11006
11055
|
}
|
|
@@ -11008,7 +11057,7 @@ async function runNonInteractive2(params) {
|
|
|
11008
11057
|
const metrics = uiTelemetryService.getMetrics();
|
|
11009
11058
|
const durationMs = Date.now() - startTime;
|
|
11010
11059
|
streamFormatter.emitEvent({
|
|
11011
|
-
type:
|
|
11060
|
+
type: JsonStreamEventType.RESULT,
|
|
11012
11061
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
11013
11062
|
status: "success",
|
|
11014
11063
|
stats: streamFormatter.convertToStreamStats(
|
|
@@ -11016,7 +11065,7 @@ async function runNonInteractive2(params) {
|
|
|
11016
11065
|
durationMs
|
|
11017
11066
|
)
|
|
11018
11067
|
});
|
|
11019
|
-
} else if (config.getOutputFormat() ===
|
|
11068
|
+
} else if (config.getOutputFormat() === OutputFormat.JSON) {
|
|
11020
11069
|
const formatter = new JsonFormatter();
|
|
11021
11070
|
const stats = uiTelemetryService.getMetrics();
|
|
11022
11071
|
textOutput.write(
|
|
@@ -11039,12 +11088,12 @@ async function runNonInteractive2(params) {
|
|
|
11039
11088
|
const metrics = uiTelemetryService.getMetrics();
|
|
11040
11089
|
const durationMs = Date.now() - startTime;
|
|
11041
11090
|
streamFormatter.emitEvent({
|
|
11042
|
-
type:
|
|
11091
|
+
type: JsonStreamEventType.RESULT,
|
|
11043
11092
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
11044
11093
|
status: invalidStreamError ? "error" : "success",
|
|
11045
11094
|
stats: streamFormatter.convertToStreamStats(metrics, durationMs)
|
|
11046
11095
|
});
|
|
11047
|
-
} else if (config.getOutputFormat() ===
|
|
11096
|
+
} else if (config.getOutputFormat() === OutputFormat.JSON) {
|
|
11048
11097
|
const formatter = new JsonFormatter();
|
|
11049
11098
|
const stats = uiTelemetryService.getMetrics();
|
|
11050
11099
|
textOutput.write(
|
|
@@ -11068,7 +11117,7 @@ async function runNonInteractive2(params) {
|
|
|
11068
11117
|
cleanupStdinCancellation();
|
|
11069
11118
|
scheduler?.dispose();
|
|
11070
11119
|
consolePatcher.cleanup();
|
|
11071
|
-
coreEvents.off(
|
|
11120
|
+
coreEvents.off(CoreEvent.UserFeedback, handleUserFeedback);
|
|
11072
11121
|
}
|
|
11073
11122
|
if (errorToHandle) {
|
|
11074
11123
|
handleError(errorToHandle, config);
|
|
@@ -13499,12 +13548,12 @@ function toToolCallContent(toolResult) {
|
|
|
13499
13548
|
}
|
|
13500
13549
|
var basicPermissionOptions = [
|
|
13501
13550
|
{
|
|
13502
|
-
optionId:
|
|
13551
|
+
optionId: ToolConfirmationOutcome.ProceedOnce,
|
|
13503
13552
|
name: "Allow",
|
|
13504
13553
|
kind: "allow_once"
|
|
13505
13554
|
},
|
|
13506
13555
|
{
|
|
13507
|
-
optionId:
|
|
13556
|
+
optionId: ToolConfirmationOutcome.Cancel,
|
|
13508
13557
|
name: "Reject",
|
|
13509
13558
|
kind: "reject_once"
|
|
13510
13559
|
}
|
|
@@ -13516,13 +13565,13 @@ function toPermissionOptions(confirmation, config, enablePermanentToolApproval =
|
|
|
13516
13565
|
switch (confirmation.type) {
|
|
13517
13566
|
case "edit":
|
|
13518
13567
|
options.push({
|
|
13519
|
-
optionId:
|
|
13568
|
+
optionId: ToolConfirmationOutcome.ProceedAlways,
|
|
13520
13569
|
name: "Allow for this session",
|
|
13521
13570
|
kind: "allow_always"
|
|
13522
13571
|
});
|
|
13523
13572
|
if (enablePermanentToolApproval) {
|
|
13524
13573
|
options.push({
|
|
13525
|
-
optionId:
|
|
13574
|
+
optionId: ToolConfirmationOutcome.ProceedAlwaysAndSave,
|
|
13526
13575
|
name: "Allow for this file in all future sessions",
|
|
13527
13576
|
kind: "allow_always"
|
|
13528
13577
|
});
|
|
@@ -13530,13 +13579,13 @@ function toPermissionOptions(confirmation, config, enablePermanentToolApproval =
|
|
|
13530
13579
|
break;
|
|
13531
13580
|
case "exec":
|
|
13532
13581
|
options.push({
|
|
13533
|
-
optionId:
|
|
13582
|
+
optionId: ToolConfirmationOutcome.ProceedAlways,
|
|
13534
13583
|
name: "Allow for this session",
|
|
13535
13584
|
kind: "allow_always"
|
|
13536
13585
|
});
|
|
13537
13586
|
if (enablePermanentToolApproval) {
|
|
13538
13587
|
options.push({
|
|
13539
|
-
optionId:
|
|
13588
|
+
optionId: ToolConfirmationOutcome.ProceedAlwaysAndSave,
|
|
13540
13589
|
name: "Allow this command for all future sessions",
|
|
13541
13590
|
kind: "allow_always"
|
|
13542
13591
|
});
|
|
@@ -13545,19 +13594,19 @@ function toPermissionOptions(confirmation, config, enablePermanentToolApproval =
|
|
|
13545
13594
|
case "mcp":
|
|
13546
13595
|
options.push(
|
|
13547
13596
|
{
|
|
13548
|
-
optionId:
|
|
13597
|
+
optionId: ToolConfirmationOutcome.ProceedAlwaysServer,
|
|
13549
13598
|
name: "Allow all server tools for this session",
|
|
13550
13599
|
kind: "allow_always"
|
|
13551
13600
|
},
|
|
13552
13601
|
{
|
|
13553
|
-
optionId:
|
|
13602
|
+
optionId: ToolConfirmationOutcome.ProceedAlwaysTool,
|
|
13554
13603
|
name: "Allow tool for this session",
|
|
13555
13604
|
kind: "allow_always"
|
|
13556
13605
|
}
|
|
13557
13606
|
);
|
|
13558
13607
|
if (enablePermanentToolApproval) {
|
|
13559
13608
|
options.push({
|
|
13560
|
-
optionId:
|
|
13609
|
+
optionId: ToolConfirmationOutcome.ProceedAlwaysAndSave,
|
|
13561
13610
|
name: "Allow tool for all future sessions",
|
|
13562
13611
|
kind: "allow_always"
|
|
13563
13612
|
});
|
|
@@ -13565,13 +13614,13 @@ function toPermissionOptions(confirmation, config, enablePermanentToolApproval =
|
|
|
13565
13614
|
break;
|
|
13566
13615
|
case "info":
|
|
13567
13616
|
options.push({
|
|
13568
|
-
optionId:
|
|
13617
|
+
optionId: ToolConfirmationOutcome.ProceedAlways,
|
|
13569
13618
|
name: "Allow for this session",
|
|
13570
13619
|
kind: "allow_always"
|
|
13571
13620
|
});
|
|
13572
13621
|
if (enablePermanentToolApproval) {
|
|
13573
13622
|
options.push({
|
|
13574
|
-
optionId:
|
|
13623
|
+
optionId: ToolConfirmationOutcome.ProceedAlwaysAndSave,
|
|
13575
13624
|
name: "Allow for all future sessions",
|
|
13576
13625
|
kind: "allow_always"
|
|
13577
13626
|
});
|
|
@@ -13603,21 +13652,21 @@ function toPermissionOptions(confirmation, config, enablePermanentToolApproval =
|
|
|
13603
13652
|
}
|
|
13604
13653
|
function toAcpToolKind(kind) {
|
|
13605
13654
|
switch (kind) {
|
|
13606
|
-
case
|
|
13607
|
-
case
|
|
13608
|
-
case
|
|
13609
|
-
case
|
|
13610
|
-
case
|
|
13611
|
-
case
|
|
13612
|
-
case
|
|
13613
|
-
case
|
|
13614
|
-
case
|
|
13615
|
-
case
|
|
13655
|
+
case Kind.Read:
|
|
13656
|
+
case Kind.Edit:
|
|
13657
|
+
case Kind.Execute:
|
|
13658
|
+
case Kind.Search:
|
|
13659
|
+
case Kind.Delete:
|
|
13660
|
+
case Kind.Move:
|
|
13661
|
+
case Kind.Think:
|
|
13662
|
+
case Kind.Fetch:
|
|
13663
|
+
case Kind.SwitchMode:
|
|
13664
|
+
case Kind.Other:
|
|
13616
13665
|
return kind;
|
|
13617
|
-
case
|
|
13666
|
+
case Kind.Agent:
|
|
13618
13667
|
return "think";
|
|
13619
|
-
case
|
|
13620
|
-
case
|
|
13668
|
+
case Kind.Plan:
|
|
13669
|
+
case Kind.Communicate:
|
|
13621
13670
|
default:
|
|
13622
13671
|
return "other";
|
|
13623
13672
|
}
|
|
@@ -13625,24 +13674,24 @@ function toAcpToolKind(kind) {
|
|
|
13625
13674
|
function buildAvailableModes(isPlanEnabled) {
|
|
13626
13675
|
const modes = [
|
|
13627
13676
|
{
|
|
13628
|
-
id:
|
|
13677
|
+
id: ApprovalMode.DEFAULT,
|
|
13629
13678
|
name: "Default",
|
|
13630
13679
|
description: "Prompts for approval"
|
|
13631
13680
|
},
|
|
13632
13681
|
{
|
|
13633
|
-
id:
|
|
13682
|
+
id: ApprovalMode.AUTO_EDIT,
|
|
13634
13683
|
name: "Auto Edit",
|
|
13635
13684
|
description: "Auto-approves edit tools"
|
|
13636
13685
|
},
|
|
13637
13686
|
{
|
|
13638
|
-
id:
|
|
13687
|
+
id: ApprovalMode.YOLO,
|
|
13639
13688
|
name: "YOLO",
|
|
13640
13689
|
description: "Auto-approves all tools"
|
|
13641
13690
|
}
|
|
13642
13691
|
];
|
|
13643
13692
|
if (isPlanEnabled) {
|
|
13644
13693
|
modes.push({
|
|
13645
|
-
id:
|
|
13694
|
+
id: ApprovalMode.PLAN,
|
|
13646
13695
|
name: "Plan",
|
|
13647
13696
|
description: "Read-only mode"
|
|
13648
13697
|
});
|
|
@@ -13655,7 +13704,7 @@ function buildAvailableModels(config, settings) {
|
|
|
13655
13704
|
const useGemini31 = config.getGemini31LaunchedSync?.() ?? false;
|
|
13656
13705
|
const useGemini31FlashLite = config.getGemini31FlashLiteLaunchedSync?.() ?? false;
|
|
13657
13706
|
const selectedAuthType = settings.merged.security.auth.selectedType;
|
|
13658
|
-
const useCustomToolModel = useGemini31 && selectedAuthType ===
|
|
13707
|
+
const useCustomToolModel = useGemini31 && selectedAuthType === AuthType.USE_GEMINI;
|
|
13659
13708
|
if (config.getExperimentalDynamicModelConfiguration?.() === true && config.getModelConfigService) {
|
|
13660
13709
|
const options = config.getModelConfigService().getAvailableModelOptions({
|
|
13661
13710
|
useGemini3_1: useGemini31,
|
|
@@ -13744,7 +13793,7 @@ var Session = class {
|
|
|
13744
13793
|
this.connection = connection;
|
|
13745
13794
|
this.settings = settings;
|
|
13746
13795
|
coreEvents.on(
|
|
13747
|
-
|
|
13796
|
+
CoreEvent.ApprovalModeChanged,
|
|
13748
13797
|
this.handleApprovalModeChanged
|
|
13749
13798
|
);
|
|
13750
13799
|
}
|
|
@@ -13767,7 +13816,7 @@ var Session = class {
|
|
|
13767
13816
|
};
|
|
13768
13817
|
dispose() {
|
|
13769
13818
|
coreEvents.off(
|
|
13770
|
-
|
|
13819
|
+
CoreEvent.ApprovalModeChanged,
|
|
13771
13820
|
this.handleApprovalModeChanged
|
|
13772
13821
|
);
|
|
13773
13822
|
}
|
|
@@ -13855,7 +13904,7 @@ ${thought.description}`;
|
|
|
13855
13904
|
await this.sendUpdate({
|
|
13856
13905
|
sessionUpdate: "tool_call",
|
|
13857
13906
|
toolCallId: toolCall.id,
|
|
13858
|
-
status: toolCall.status ===
|
|
13907
|
+
status: toolCall.status === CoreToolCallStatus.Success ? "completed" : "failed",
|
|
13859
13908
|
title: toolCall.displayName || toolCall.name,
|
|
13860
13909
|
content: toolCallContent,
|
|
13861
13910
|
kind: tool ? toAcpToolKind(tool.kind) : "other"
|
|
@@ -13947,7 +13996,7 @@ ${thought.description}`;
|
|
|
13947
13996
|
return { stopReason: "cancelled" };
|
|
13948
13997
|
}
|
|
13949
13998
|
switch (event.type) {
|
|
13950
|
-
case
|
|
13999
|
+
case GeminiEventType.Content: {
|
|
13951
14000
|
const content = {
|
|
13952
14001
|
type: "text",
|
|
13953
14002
|
text: event.value
|
|
@@ -13958,7 +14007,7 @@ ${thought.description}`;
|
|
|
13958
14007
|
});
|
|
13959
14008
|
break;
|
|
13960
14009
|
}
|
|
13961
|
-
case
|
|
14010
|
+
case GeminiEventType.Thought: {
|
|
13962
14011
|
const thoughtText = `**${event.value.subject}**
|
|
13963
14012
|
${event.value.description}`;
|
|
13964
14013
|
await this.sendUpdate({
|
|
@@ -13967,10 +14016,10 @@ ${event.value.description}`;
|
|
|
13967
14016
|
});
|
|
13968
14017
|
break;
|
|
13969
14018
|
}
|
|
13970
|
-
case
|
|
14019
|
+
case GeminiEventType.ToolCallRequest:
|
|
13971
14020
|
toolCallRequests.push(event.value);
|
|
13972
14021
|
break;
|
|
13973
|
-
case
|
|
14022
|
+
case GeminiEventType.Finished: {
|
|
13974
14023
|
const usage2 = event.value.usageMetadata;
|
|
13975
14024
|
if (usage2) {
|
|
13976
14025
|
turnInputTokens = usage2.promptTokenCount ?? turnInputTokens;
|
|
@@ -13978,19 +14027,19 @@ ${event.value.description}`;
|
|
|
13978
14027
|
}
|
|
13979
14028
|
break;
|
|
13980
14029
|
}
|
|
13981
|
-
case
|
|
14030
|
+
case GeminiEventType.ModelInfo:
|
|
13982
14031
|
turnModelId = event.value;
|
|
13983
14032
|
break;
|
|
13984
|
-
case
|
|
14033
|
+
case GeminiEventType.MaxSessionTurns:
|
|
13985
14034
|
stopReason = "max_turn_requests";
|
|
13986
14035
|
break;
|
|
13987
|
-
case
|
|
14036
|
+
case GeminiEventType.LoopDetected:
|
|
13988
14037
|
stopReason = "max_turn_requests";
|
|
13989
14038
|
break;
|
|
13990
|
-
case
|
|
14039
|
+
case GeminiEventType.ContextWindowWillOverflow:
|
|
13991
14040
|
stopReason = "max_tokens";
|
|
13992
14041
|
break;
|
|
13993
|
-
case
|
|
14042
|
+
case GeminiEventType.Error: {
|
|
13994
14043
|
const parseResult = StructuredErrorSchema.safeParse(
|
|
13995
14044
|
event.value.error
|
|
13996
14045
|
);
|
|
@@ -14179,12 +14228,6 @@ ${event.value.description}`;
|
|
|
14179
14228
|
const invocation = tool.build(args);
|
|
14180
14229
|
const displayTitle = typeof invocation.getDisplayTitle === "function" ? invocation.getDisplayTitle() : invocation.getDescription();
|
|
14181
14230
|
const explanation = typeof invocation.getExplanation === "function" ? invocation.getExplanation() : "";
|
|
14182
|
-
if (explanation) {
|
|
14183
|
-
await this.sendUpdate({
|
|
14184
|
-
sessionUpdate: "agent_thought_chunk",
|
|
14185
|
-
content: { type: "text", text: explanation }
|
|
14186
|
-
});
|
|
14187
|
-
}
|
|
14188
14231
|
const confirmationDetails = await invocation.shouldConfirmExecute(abortSignal);
|
|
14189
14232
|
if (confirmationDetails) {
|
|
14190
14233
|
const content2 = [];
|
|
@@ -14199,6 +14242,12 @@ ${event.value.description}`;
|
|
|
14199
14242
|
}
|
|
14200
14243
|
});
|
|
14201
14244
|
}
|
|
14245
|
+
if (content2.length === 0 && explanation) {
|
|
14246
|
+
content2.push({
|
|
14247
|
+
type: "content",
|
|
14248
|
+
content: { type: "text", text: explanation }
|
|
14249
|
+
});
|
|
14250
|
+
}
|
|
14202
14251
|
const params = {
|
|
14203
14252
|
sessionId: this.id,
|
|
14204
14253
|
options: toPermissionOptions(
|
|
@@ -14218,7 +14267,7 @@ ${event.value.description}`;
|
|
|
14218
14267
|
const output = RequestPermissionResponseSchema.parse(
|
|
14219
14268
|
await this.connection.requestPermission(params)
|
|
14220
14269
|
);
|
|
14221
|
-
const outcome = output.outcome.outcome === "cancelled" ?
|
|
14270
|
+
const outcome = output.outcome.outcome === "cancelled" ? ToolConfirmationOutcome.Cancel : external_exports.nativeEnum(ToolConfirmationOutcome).parse(output.outcome.optionId);
|
|
14222
14271
|
await confirmationDetails.onConfirm(outcome);
|
|
14223
14272
|
await updatePolicy(
|
|
14224
14273
|
tool,
|
|
@@ -14229,16 +14278,16 @@ ${event.value.description}`;
|
|
|
14229
14278
|
invocation
|
|
14230
14279
|
);
|
|
14231
14280
|
switch (outcome) {
|
|
14232
|
-
case
|
|
14281
|
+
case ToolConfirmationOutcome.Cancel:
|
|
14233
14282
|
return errorResponse(
|
|
14234
14283
|
new Error(`Tool "${fc.name}" was canceled by the user.`)
|
|
14235
14284
|
);
|
|
14236
|
-
case
|
|
14237
|
-
case
|
|
14238
|
-
case
|
|
14239
|
-
case
|
|
14240
|
-
case
|
|
14241
|
-
case
|
|
14285
|
+
case ToolConfirmationOutcome.ProceedOnce:
|
|
14286
|
+
case ToolConfirmationOutcome.ProceedAlways:
|
|
14287
|
+
case ToolConfirmationOutcome.ProceedAlwaysAndSave:
|
|
14288
|
+
case ToolConfirmationOutcome.ProceedAlwaysServer:
|
|
14289
|
+
case ToolConfirmationOutcome.ProceedAlwaysTool:
|
|
14290
|
+
case ToolConfirmationOutcome.ModifyWithEditor:
|
|
14242
14291
|
break;
|
|
14243
14292
|
default: {
|
|
14244
14293
|
const resultOutcome = outcome;
|
|
@@ -14247,6 +14296,12 @@ ${event.value.description}`;
|
|
|
14247
14296
|
}
|
|
14248
14297
|
} else {
|
|
14249
14298
|
const content2 = [];
|
|
14299
|
+
if (explanation) {
|
|
14300
|
+
content2.push({
|
|
14301
|
+
type: "content",
|
|
14302
|
+
content: { type: "text", text: explanation }
|
|
14303
|
+
});
|
|
14304
|
+
}
|
|
14250
14305
|
await this.sendUpdate({
|
|
14251
14306
|
sessionUpdate: "tool_call",
|
|
14252
14307
|
toolCallId: callId,
|
|
@@ -14286,7 +14341,7 @@ ${event.value.description}`;
|
|
|
14286
14341
|
);
|
|
14287
14342
|
this.chat.recordCompletedToolCalls(this.context.config.getActiveModel(), [
|
|
14288
14343
|
{
|
|
14289
|
-
status:
|
|
14344
|
+
status: CoreToolCallStatus.Success,
|
|
14290
14345
|
request: {
|
|
14291
14346
|
callId,
|
|
14292
14347
|
name: fc.name,
|
|
@@ -14331,7 +14386,7 @@ ${event.value.description}`;
|
|
|
14331
14386
|
});
|
|
14332
14387
|
this.chat.recordCompletedToolCalls(this.context.config.getActiveModel(), [
|
|
14333
14388
|
{
|
|
14334
|
-
status:
|
|
14389
|
+
status: CoreToolCallStatus.Error,
|
|
14335
14390
|
request: {
|
|
14336
14391
|
callId,
|
|
14337
14392
|
name: fc.name,
|
|
@@ -14446,12 +14501,12 @@ ${event.value.description}`;
|
|
|
14446
14501
|
sessionId: this.id,
|
|
14447
14502
|
options: [
|
|
14448
14503
|
{
|
|
14449
|
-
optionId:
|
|
14504
|
+
optionId: ToolConfirmationOutcome.ProceedOnce,
|
|
14450
14505
|
name: "Allow once",
|
|
14451
14506
|
kind: "allow_once"
|
|
14452
14507
|
},
|
|
14453
14508
|
{
|
|
14454
|
-
optionId:
|
|
14509
|
+
optionId: ToolConfirmationOutcome.Cancel,
|
|
14455
14510
|
name: "Deny",
|
|
14456
14511
|
kind: "reject_once"
|
|
14457
14512
|
}
|
|
@@ -14476,8 +14531,8 @@ ${event.value.description}`;
|
|
|
14476
14531
|
const output = RequestPermissionResponseSchema.parse(
|
|
14477
14532
|
await this.connection.requestPermission(params)
|
|
14478
14533
|
);
|
|
14479
|
-
const outcome = output.outcome.outcome === "cancelled" ?
|
|
14480
|
-
if (outcome ===
|
|
14534
|
+
const outcome = output.outcome.outcome === "cancelled" ? ToolConfirmationOutcome.Cancel : external_exports.nativeEnum(ToolConfirmationOutcome).parse(output.outcome.optionId);
|
|
14535
|
+
if (outcome === ToolConfirmationOutcome.ProceedOnce) {
|
|
14481
14536
|
this.context.config.getWorkspaceContext().addReadOnlyPath(absolutePath);
|
|
14482
14537
|
validationError = null;
|
|
14483
14538
|
} else {
|
|
@@ -14858,7 +14913,11 @@ var AcpFileSystemService = class {
|
|
|
14858
14913
|
path: filePath,
|
|
14859
14914
|
sessionId: this.sessionId
|
|
14860
14915
|
});
|
|
14861
|
-
|
|
14916
|
+
const content = response.content;
|
|
14917
|
+
if (typeof content !== "string") {
|
|
14918
|
+
throw new Error("content must be a string");
|
|
14919
|
+
}
|
|
14920
|
+
return content;
|
|
14862
14921
|
} catch (err) {
|
|
14863
14922
|
this.normalizeFileSystemError(err);
|
|
14864
14923
|
}
|
|
@@ -14909,7 +14968,7 @@ var AcpSessionManager = class {
|
|
|
14909
14968
|
mcpServers,
|
|
14910
14969
|
loadedSettings
|
|
14911
14970
|
);
|
|
14912
|
-
const authType = loadedSettings.merged.security.auth.selectedType ||
|
|
14971
|
+
const authType = loadedSettings.merged.security.auth.selectedType || AuthType.USE_GEMINI;
|
|
14913
14972
|
let isAuthenticated = false;
|
|
14914
14973
|
let authErrorMessage = "";
|
|
14915
14974
|
try {
|
|
@@ -14921,7 +14980,7 @@ var AcpSessionManager = class {
|
|
|
14921
14980
|
);
|
|
14922
14981
|
isAuthenticated = true;
|
|
14923
14982
|
const contentGeneratorConfig = config.getContentGeneratorConfig();
|
|
14924
|
-
if (authType ===
|
|
14983
|
+
if (authType === AuthType.USE_GEMINI && (!contentGeneratorConfig || !contentGeneratorConfig.apiKey)) {
|
|
14925
14984
|
isAuthenticated = false;
|
|
14926
14985
|
authErrorMessage = "Gemini API key is missing or not configured.";
|
|
14927
14986
|
}
|
|
@@ -15131,12 +15190,12 @@ var GeminiAgent = class {
|
|
|
15131
15190
|
}
|
|
15132
15191
|
const authMethods = [
|
|
15133
15192
|
{
|
|
15134
|
-
id:
|
|
15193
|
+
id: AuthType.LOGIN_WITH_GOOGLE,
|
|
15135
15194
|
name: "Log in with Google",
|
|
15136
15195
|
description: "Log in with your Google account"
|
|
15137
15196
|
},
|
|
15138
15197
|
{
|
|
15139
|
-
id:
|
|
15198
|
+
id: AuthType.USE_GEMINI,
|
|
15140
15199
|
name: "Gemini API key",
|
|
15141
15200
|
description: "Use an API key with Gemini Developer API",
|
|
15142
15201
|
_meta: {
|
|
@@ -15146,12 +15205,12 @@ var GeminiAgent = class {
|
|
|
15146
15205
|
}
|
|
15147
15206
|
},
|
|
15148
15207
|
{
|
|
15149
|
-
id:
|
|
15208
|
+
id: AuthType.USE_VERTEX_AI,
|
|
15150
15209
|
name: "Vertex AI",
|
|
15151
15210
|
description: "Use an API key with Vertex AI GenAI API"
|
|
15152
15211
|
},
|
|
15153
15212
|
{
|
|
15154
|
-
id:
|
|
15213
|
+
id: AuthType.GATEWAY,
|
|
15155
15214
|
name: "AI API Gateway",
|
|
15156
15215
|
description: "Use a custom AI API Gateway",
|
|
15157
15216
|
_meta: {
|
|
@@ -15324,7 +15383,7 @@ async function validateNonInteractiveAuth(configuredAuthType, useExternalAuth, n
|
|
|
15324
15383
|
}
|
|
15325
15384
|
return authType;
|
|
15326
15385
|
} catch (error) {
|
|
15327
|
-
if (nonInteractiveConfig.getOutputFormat() ===
|
|
15386
|
+
if (nonInteractiveConfig.getOutputFormat() === OutputFormat.JSON) {
|
|
15328
15387
|
handleError(
|
|
15329
15388
|
error instanceof Error ? error : new Error(String(error)),
|
|
15330
15389
|
nonInteractiveConfig,
|
|
@@ -15520,10 +15579,10 @@ var SlashCommandConflictHandler = class {
|
|
|
15520
15579
|
this.handleConflicts = this.handleConflicts.bind(this);
|
|
15521
15580
|
}
|
|
15522
15581
|
start() {
|
|
15523
|
-
coreEvents.on(
|
|
15582
|
+
coreEvents.on(CoreEvent.SlashCommandConflicts, this.handleConflicts);
|
|
15524
15583
|
}
|
|
15525
15584
|
stop() {
|
|
15526
|
-
coreEvents.off(
|
|
15585
|
+
coreEvents.off(CoreEvent.SlashCommandConflicts, this.handleConflicts);
|
|
15527
15586
|
if (this.flushTimeout) {
|
|
15528
15587
|
clearTimeout(this.flushTimeout);
|
|
15529
15588
|
this.flushTimeout = null;
|
|
@@ -15706,13 +15765,69 @@ ${reason.stack}` : ""}`;
|
|
|
15706
15765
|
}
|
|
15707
15766
|
});
|
|
15708
15767
|
}
|
|
15709
|
-
async function resolveSessionId(resumeArg, sessionIdArg) {
|
|
15710
|
-
if (!resumeArg && !sessionIdArg) {
|
|
15768
|
+
async function resolveSessionId(resumeArg, sessionIdArg, sessionFileArg) {
|
|
15769
|
+
if (!resumeArg && !sessionIdArg && !sessionFileArg) {
|
|
15711
15770
|
return { sessionId: createSessionId() };
|
|
15712
15771
|
}
|
|
15713
15772
|
const storage = new Storage(process.cwd());
|
|
15714
15773
|
await storage.initialize();
|
|
15715
15774
|
const sessionSelector = new SessionSelector(storage);
|
|
15775
|
+
if (sessionFileArg) {
|
|
15776
|
+
try {
|
|
15777
|
+
const sessionData = await loadConversationRecord(sessionFileArg);
|
|
15778
|
+
if (!sessionData) {
|
|
15779
|
+
throw new Error(`File not found or invalid format: ${sessionFileArg}`);
|
|
15780
|
+
}
|
|
15781
|
+
const now = Date.now();
|
|
15782
|
+
const isoNow = new Date(now).toISOString();
|
|
15783
|
+
sessionData.messages = (sessionData.messages || []).filter(
|
|
15784
|
+
(m) => typeof m === "object" && m !== null && (m.type === "user" || m.type === "gemini") && m.content !== void 0
|
|
15785
|
+
);
|
|
15786
|
+
sessionData.messages.unshift({
|
|
15787
|
+
id: `import-${now}`,
|
|
15788
|
+
type: "info",
|
|
15789
|
+
content: `Imported session from ${sessionFileArg}`,
|
|
15790
|
+
timestamp: isoNow
|
|
15791
|
+
});
|
|
15792
|
+
const newSessionId = createSessionId();
|
|
15793
|
+
sessionData.sessionId = newSessionId;
|
|
15794
|
+
sessionData.projectHash = getProjectHash(storage.getProjectRoot());
|
|
15795
|
+
sessionData.startTime = isoNow;
|
|
15796
|
+
sessionData.lastUpdated = isoNow;
|
|
15797
|
+
const chatsDir = path15.join(storage.getProjectTempDir(), "chats");
|
|
15798
|
+
const newSessionPath = path15.join(
|
|
15799
|
+
chatsDir,
|
|
15800
|
+
`session-${now}-${newSessionId.slice(0, 8)}.jsonl`
|
|
15801
|
+
);
|
|
15802
|
+
const { messages: _messages, ...initialMetadata } = sessionData;
|
|
15803
|
+
const lines = [JSON.stringify(initialMetadata)];
|
|
15804
|
+
if (sessionData.messages) {
|
|
15805
|
+
for (const msg of sessionData.messages) {
|
|
15806
|
+
lines.push(JSON.stringify(msg));
|
|
15807
|
+
}
|
|
15808
|
+
}
|
|
15809
|
+
await fsPromises.mkdir(chatsDir, { recursive: true });
|
|
15810
|
+
await fsPromises.writeFile(
|
|
15811
|
+
newSessionPath,
|
|
15812
|
+
lines.join("\n") + "\n",
|
|
15813
|
+
"utf-8"
|
|
15814
|
+
);
|
|
15815
|
+
return {
|
|
15816
|
+
sessionId: newSessionId,
|
|
15817
|
+
resumedSessionData: {
|
|
15818
|
+
conversation: sessionData,
|
|
15819
|
+
filePath: newSessionPath
|
|
15820
|
+
}
|
|
15821
|
+
};
|
|
15822
|
+
} catch (error) {
|
|
15823
|
+
coreEvents.emitFeedback(
|
|
15824
|
+
"error",
|
|
15825
|
+
`Error importing session from file: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
15826
|
+
);
|
|
15827
|
+
await runExitCleanup();
|
|
15828
|
+
process.exit(ExitCodes.FATAL_INPUT_ERROR);
|
|
15829
|
+
}
|
|
15830
|
+
}
|
|
15716
15831
|
if (sessionIdArg) {
|
|
15717
15832
|
if (await sessionSelector.sessionExists(sessionIdArg)) {
|
|
15718
15833
|
coreEvents.emitFeedback(
|
|
@@ -15734,8 +15849,10 @@ async function resolveSessionId(resumeArg, sessionIdArg) {
|
|
|
15734
15849
|
};
|
|
15735
15850
|
} catch (error) {
|
|
15736
15851
|
if (error instanceof SessionError && error.code === "NO_SESSIONS_FOUND") {
|
|
15737
|
-
|
|
15738
|
-
|
|
15852
|
+
if (resumeArg === RESUME_LATEST) {
|
|
15853
|
+
coreEvents.emitFeedback("warning", error.message);
|
|
15854
|
+
return { sessionId: createSessionId() };
|
|
15855
|
+
}
|
|
15739
15856
|
}
|
|
15740
15857
|
coreEvents.emitFeedback(
|
|
15741
15858
|
"error",
|
|
@@ -15746,7 +15863,7 @@ async function resolveSessionId(resumeArg, sessionIdArg) {
|
|
|
15746
15863
|
}
|
|
15747
15864
|
}
|
|
15748
15865
|
async function startInteractiveUI(config, settings, startupWarnings, workspaceRoot = process.cwd(), resumedSessionData, initializationResult) {
|
|
15749
|
-
const { startInteractiveUI: doStartUI } = await import("./interactiveCli-
|
|
15866
|
+
const { startInteractiveUI: doStartUI } = await import("./interactiveCli-A2FV6NYD.js");
|
|
15750
15867
|
await doStartUI(
|
|
15751
15868
|
config,
|
|
15752
15869
|
settings,
|
|
@@ -15809,7 +15926,8 @@ async function main() {
|
|
|
15809
15926
|
const argv = await argvPromise;
|
|
15810
15927
|
const { sessionId, resumedSessionData } = await resolveSessionId(
|
|
15811
15928
|
argv.resume,
|
|
15812
|
-
argv.sessionId
|
|
15929
|
+
argv.sessionId,
|
|
15930
|
+
argv.sessionFile
|
|
15813
15931
|
);
|
|
15814
15932
|
if (argv.allowedTools && argv.allowedTools.length > 0 || settings.merged.tools?.allowed && settings.merged.tools.allowed.length > 0) {
|
|
15815
15933
|
coreEvents.emitFeedback(
|
|
@@ -15848,12 +15966,12 @@ async function main() {
|
|
|
15848
15966
|
dns.setDefaultResultOrder(
|
|
15849
15967
|
validateDnsResolutionOrder(settings.merged.advanced.dnsResolutionOrder)
|
|
15850
15968
|
);
|
|
15851
|
-
if (!settings.merged.security.auth.selectedType || settings.merged.security.auth.selectedType ===
|
|
15969
|
+
if (!settings.merged.security.auth.selectedType || settings.merged.security.auth.selectedType === AuthType.LEGACY_CLOUD_SHELL) {
|
|
15852
15970
|
if (process.env["CLOUD_SHELL"] === "true" || process.env["GEMINI_CLI_USE_COMPUTE_ADC"] === "true") {
|
|
15853
15971
|
settings.setValue(
|
|
15854
15972
|
"User" /* User */,
|
|
15855
15973
|
"security.auth.selectedType",
|
|
15856
|
-
|
|
15974
|
+
AuthType.COMPUTE_ADC
|
|
15857
15975
|
);
|
|
15858
15976
|
}
|
|
15859
15977
|
}
|
|
@@ -15953,7 +16071,7 @@ ${finalArgs[promptIndex + 1]}`;
|
|
|
15953
16071
|
await config.storage.initialize();
|
|
15954
16072
|
adminControlsListner.setConfig(config);
|
|
15955
16073
|
if (config.isInteractive() && settings.merged.general.devtools) {
|
|
15956
|
-
const { setupInitialActivityLogger } = await import("./devtoolsService-
|
|
16074
|
+
const { setupInitialActivityLogger } = await import("./devtoolsService-ZDXC2NPD.js");
|
|
15957
16075
|
setupInitialActivityLogger(config);
|
|
15958
16076
|
}
|
|
15959
16077
|
registerTelemetryConfig(config);
|
|
@@ -15961,7 +16079,7 @@ ${finalArgs[promptIndex + 1]}`;
|
|
|
15961
16079
|
const messageBus = config.getMessageBus();
|
|
15962
16080
|
createPolicyUpdater2(policyEngine, messageBus, config.storage);
|
|
15963
16081
|
registerCleanup(async () => {
|
|
15964
|
-
await config.getHookSystem()?.fireSessionEndEvent(
|
|
16082
|
+
await config.getHookSystem()?.fireSessionEndEvent(SessionEndReason.Exit);
|
|
15965
16083
|
});
|
|
15966
16084
|
if (!config.getAcpMode()) {
|
|
15967
16085
|
registerCleanup(consolePatcher.cleanup);
|
|
@@ -16012,7 +16130,7 @@ ${finalArgs[promptIndex + 1]}`;
|
|
|
16012
16130
|
const initAppHandle = startupProfiler.start("initialize_app");
|
|
16013
16131
|
const initializationResult = await initializeApp(config, settings);
|
|
16014
16132
|
initAppHandle?.end();
|
|
16015
|
-
import("./liteRtServerManager-
|
|
16133
|
+
import("./liteRtServerManager-UZCAJJCS.js").then(({ LiteRtServerManager }) => {
|
|
16016
16134
|
const mergedGemma = settings.merged.experimental?.gemmaModelRouter;
|
|
16017
16135
|
if (!mergedGemma) return;
|
|
16018
16136
|
const userGemma = settings.forScope("User" /* User */).settings.experimental?.gemmaModelRouter;
|
|
@@ -16022,7 +16140,7 @@ ${finalArgs[promptIndex + 1]}`;
|
|
|
16022
16140
|
autoStartServer: userGemma?.autoStartServer
|
|
16023
16141
|
});
|
|
16024
16142
|
}).catch((e) => debugLogger.warn("LiteRT auto-start import failed:", e));
|
|
16025
|
-
if (settings.merged.security.auth.selectedType ===
|
|
16143
|
+
if (settings.merged.security.auth.selectedType === AuthType.LOGIN_WITH_GOOGLE && config.isBrowserLaunchSuppressed()) {
|
|
16026
16144
|
await getOauthClient(settings.merged.security.auth.selectedType, config);
|
|
16027
16145
|
}
|
|
16028
16146
|
if (config.getAcpMode()) {
|
|
@@ -16038,7 +16156,7 @@ ${finalArgs[promptIndex + 1]}`;
|
|
|
16038
16156
|
...rawStartupWarnings.map((message) => ({
|
|
16039
16157
|
id: `startup-${createHash2("sha256").update(message).digest("hex").substring(0, 16)}`,
|
|
16040
16158
|
message,
|
|
16041
|
-
priority:
|
|
16159
|
+
priority: WarningPriority.High
|
|
16042
16160
|
})),
|
|
16043
16161
|
...await getUserStartupWarnings(settings.merged, void 0, {
|
|
16044
16162
|
isAlternateBuffer: useAlternateBuffer
|
|
@@ -16075,7 +16193,7 @@ ${finalArgs[promptIndex + 1]}`;
|
|
|
16075
16193
|
${input}` : stdinData;
|
|
16076
16194
|
}
|
|
16077
16195
|
}
|
|
16078
|
-
const sessionStartSource = resumedSessionData ?
|
|
16196
|
+
const sessionStartSource = resumedSessionData ? SessionStartSource.Resume : SessionStartSource.Startup;
|
|
16079
16197
|
const hookSystem = config?.getHookSystem();
|
|
16080
16198
|
if (hookSystem) {
|
|
16081
16199
|
const result = await hookSystem.fireSessionStartEvent(sessionStartSource);
|
|
@@ -16132,8 +16250,8 @@ ${input}` : wrappedContext;
|
|
|
16132
16250
|
}
|
|
16133
16251
|
}
|
|
16134
16252
|
function initializeOutputListenersAndFlush(config) {
|
|
16135
|
-
if (coreEvents.listenerCount(
|
|
16136
|
-
coreEvents.on(
|
|
16253
|
+
if (coreEvents.listenerCount(CoreEvent.Output) === 0) {
|
|
16254
|
+
coreEvents.on(CoreEvent.Output, (payload) => {
|
|
16137
16255
|
if (payload.isStderr) {
|
|
16138
16256
|
writeToStderr(payload.chunk, payload.encoding);
|
|
16139
16257
|
} else {
|
|
@@ -16141,8 +16259,8 @@ function initializeOutputListenersAndFlush(config) {
|
|
|
16141
16259
|
}
|
|
16142
16260
|
});
|
|
16143
16261
|
}
|
|
16144
|
-
if (coreEvents.listenerCount(
|
|
16145
|
-
coreEvents.on(
|
|
16262
|
+
if (coreEvents.listenerCount(CoreEvent.ConsoleLog) === 0) {
|
|
16263
|
+
coreEvents.on(CoreEvent.ConsoleLog, (payload) => {
|
|
16146
16264
|
if (payload.type === "error" || payload.type === "warn") {
|
|
16147
16265
|
writeToStderr(payload.content + "\n");
|
|
16148
16266
|
} else {
|
|
@@ -16150,8 +16268,8 @@ function initializeOutputListenersAndFlush(config) {
|
|
|
16150
16268
|
}
|
|
16151
16269
|
});
|
|
16152
16270
|
}
|
|
16153
|
-
if (coreEvents.listenerCount(
|
|
16154
|
-
coreEvents.on(
|
|
16271
|
+
if (coreEvents.listenerCount(CoreEvent.UserFeedback) === 0) {
|
|
16272
|
+
coreEvents.on(CoreEvent.UserFeedback, (payload) => {
|
|
16155
16273
|
writeToStderr(payload.message + "\n");
|
|
16156
16274
|
});
|
|
16157
16275
|
}
|
|
@@ -16159,7 +16277,7 @@ function initializeOutputListenersAndFlush(config) {
|
|
|
16159
16277
|
const forceToStderr = outputFormat === "json";
|
|
16160
16278
|
coreEvents.drainBacklogs(
|
|
16161
16279
|
(event, args) => {
|
|
16162
|
-
if (forceToStderr && event ===
|
|
16280
|
+
if (forceToStderr && event === CoreEvent.Output) {
|
|
16163
16281
|
const payload = args[0];
|
|
16164
16282
|
if (!payload.isStderr) {
|
|
16165
16283
|
return {
|