@google/gemini-cli 0.42.0-preview.2 → 0.43.0-preview.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundle/{chunk-FIIOJPLW.js → chunk-43AGRA7S.js} +3 -3
- package/bundle/{chunk-M6ZQAQKH.js → chunk-46T44JOY.js} +1 -1
- package/bundle/{chunk-OFOKTVUH.js → chunk-4TLQKGTR.js} +1 -1
- package/bundle/{chunk-4NXNVHPO.js → chunk-6XOSIMPZ.js} +8 -9
- package/bundle/{chunk-AAU5XCLJ.js → chunk-HQXINMBL.js} +2 -2
- package/bundle/{chunk-QM234EIA.js → chunk-JENIU3E3.js} +1 -1
- package/bundle/{chunk-R7BHIYZD.js → chunk-LBQFRHYD.js} +1 -1
- package/bundle/{chunk-WLPWIJ3Y.js → chunk-LFGJVOVZ.js} +486 -381
- package/bundle/{chunk-DEKZKOVU.js → chunk-MRHFLHPJ.js} +2 -2
- package/bundle/{chunk-ODIOD5TJ.js → chunk-MXKXLNQD.js} +3 -3
- package/bundle/{chunk-ECNYAST2.js → chunk-N6QYTC2T.js} +5417 -5376
- package/bundle/{chunk-WOGMVEEF.js → chunk-NBRZ4A3S.js} +2170 -791
- package/bundle/{chunk-Q24MYLMP.js → chunk-P4UQCQUB.js} +3 -3
- package/bundle/{chunk-S3WIE72K.js → chunk-PGJUNQPO.js} +34 -16
- package/bundle/{chunk-THNM4JU6.js → chunk-PSWUV2OO.js} +3 -3
- package/bundle/{chunk-6QBZKEWW.js → chunk-PYLHDAUK.js} +3 -3
- package/bundle/{chunk-2KRAWFEQ.js → chunk-Q23X5R4A.js} +486 -381
- package/bundle/{chunk-SJ6AOVZF.js → chunk-QYUN3J2L.js} +533 -441
- package/bundle/{chunk-77HSANAH.js → chunk-SAISHGWW.js} +1907 -716
- package/bundle/{chunk-I6IY72IP.js → chunk-SYD5SJFT.js} +38 -23
- package/bundle/{chunk-JW36FWGZ.js → chunk-T3SUXLQQ.js} +2 -2
- package/bundle/{chunk-BLNG7CSO.js → chunk-UIG2IVPJ.js} +34 -16
- package/bundle/{chunk-JEW7ZIWE.js → chunk-UJ26GAE5.js} +5326 -5290
- package/bundle/{chunk-E54WEGH3.js → chunk-UNAVBUTP.js} +14729 -7452
- package/bundle/{chunk-LYMYMKWM.js → chunk-WQOLTO3C.js} +1 -1
- package/bundle/{chunk-WFKT4UTI.js → chunk-X26T73X6.js} +3 -3
- package/bundle/{cleanup-5FPOUEHR.js → cleanup-EIZJH2E3.js} +3 -3
- package/bundle/{cleanup-G7DNOS4V.js → cleanup-MI76P55B.js} +3 -3
- package/bundle/{cleanup-GZM5KIZA.js → cleanup-NZBQYB7U.js} +3 -3
- package/bundle/{core-IYSSLWMM.js → core-ERSGIOMQ.js} +30 -2
- package/bundle/{dist-D7FZVGG3.js → core-T2TBFAYG.js} +30 -2
- package/bundle/{devtoolsService-UADEEKOH.js → devtoolsService-7KZDSYEF.js} +3 -3
- package/bundle/{devtoolsService-3XOQOECV.js → devtoolsService-FYTOIC37.js} +3 -3
- package/bundle/{devtoolsService-7ZN7CSSO.js → devtoolsService-LV5NJ2BT.js} +4 -5
- package/bundle/{dist-GF2RNVWZ.js → dist-ETX67B7P.js} +30 -2
- package/bundle/docs/changelogs/index.md +14 -0
- package/bundle/docs/changelogs/latest.md +108 -166
- package/bundle/docs/changelogs/preview.md +227 -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-IRKIMLB4.js → gemini-IVKBXHDT.js} +160 -60
- package/bundle/{gemini-MWN2MSYV.js → gemini-JKWQQTKP.js} +160 -60
- package/bundle/{gemini-IMX43TZ4.js → gemini-Z77GAAR6.js} +331 -245
- package/bundle/gemini.js +8 -8
- package/bundle/{interactiveCli-SAMKYHUU.js → interactiveCli-36WZS6KT.js} +1704 -1457
- package/bundle/{interactiveCli-752P4PTI.js → interactiveCli-BQ36B66Z.js} +1703 -1457
- package/bundle/{interactiveCli-VX6GBWOV.js → interactiveCli-SME5QTEN.js} +1967 -1739
- package/bundle/{liteRtServerManager-CDLVKT7N.js → liteRtServerManager-2QD4R3A3.js} +5 -5
- package/bundle/{liteRtServerManager-FPYU5KEK.js → liteRtServerManager-ISYDOBNC.js} +5 -5
- package/bundle/{liteRtServerManager-OWPZ35U6.js → liteRtServerManager-N6OMT6W5.js} +5 -5
- package/bundle/{memoryDiscovery-FB7MMKTA.js → memoryDiscovery-LLSKN6HL.js} +1 -1
- package/bundle/{memoryDiscovery-KSYZVCWF.js → memoryDiscovery-SJ7P6RCN.js} +1 -1
- package/bundle/node_modules/@google/gemini-cli-devtools/package.json +1 -1
- package/bundle/{oauth2-provider-446FDCUW.js → oauth2-provider-DOSIH6VE.js} +2 -2
- package/bundle/{oauth2-provider-RQNNLGWV.js → oauth2-provider-TZF6EZRX.js} +2 -2
- package/bundle/{oauth2-provider-6W4IY3LC.js → oauth2-provider-VFOABWBW.js} +73 -39
- package/bundle/{start-6U3XBAVH.js → start-3GPIRK3E.js} +7 -7
- package/bundle/{start-KUNHDGRA.js → start-6NONW677.js} +7 -7
- package/bundle/{start-TTLMBKNX.js → start-M6MUPEJS.js} +7 -7
- package/package.json +1 -1
- package/bundle/chunk-76KOJPMV.js +0 -391
- package/bundle/chunk-LHVIO4J4.js +0 -81544
- package/bundle/chunk-OP6THN3K.js +0 -118
- package/bundle/chunk-RO2XVFEU.js +0 -512
- package/bundle/chunk-WRDVEMWE.js +0 -1571
- package/bundle/chunk-YDC4M26X.js +0 -156
- package/bundle/chunk-ZDP2ZWKG.js +0 -17230
- package/bundle/chunk-ZFOGBX2H.js +0 -356008
- package/bundle/cleanup-J6AUEKWI.js +0 -33
- package/bundle/devtoolsService-KTUMQHXG.js +0 -857
- package/bundle/dist-HBMVDPXB.js +0 -2096
- package/bundle/gemini-SYFUC6XO.js +0 -16256
- package/bundle/interactiveCli-37SKHAKX.js +0 -34505
- package/bundle/liteRtServerManager-OWTQEYE6.js +0 -66
- package/bundle/oauth2-provider-TITPL3DN.js +0 -237
- package/bundle/start-TZXEJLTH.js +0 -19
|
@@ -41,18 +41,18 @@ import {
|
|
|
41
41
|
updateAllUpdatableExtensions,
|
|
42
42
|
updateExtension,
|
|
43
43
|
validateAuthMethod
|
|
44
|
-
} from "./chunk-
|
|
44
|
+
} from "./chunk-QYUN3J2L.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-P4UQCQUB.js";
|
|
52
52
|
import {
|
|
53
53
|
exitCli,
|
|
54
54
|
require_source
|
|
55
|
-
} from "./chunk-
|
|
55
|
+
} from "./chunk-LBQFRHYD.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-SYD5SJFT.js";
|
|
90
90
|
import {
|
|
91
91
|
RELAUNCH_EXIT_CODE
|
|
92
|
-
} from "./chunk-
|
|
93
|
-
import "./chunk-
|
|
92
|
+
} from "./chunk-43AGRA7S.js";
|
|
93
|
+
import "./chunk-46T44JOY.js";
|
|
94
94
|
import {
|
|
95
95
|
cleanupCheckpoints,
|
|
96
96
|
registerCleanup,
|
|
@@ -99,43 +99,33 @@ import {
|
|
|
99
99
|
runExitCleanup,
|
|
100
100
|
runSyncCleanup,
|
|
101
101
|
setupSignalHandlers
|
|
102
|
-
} from "./chunk-
|
|
102
|
+
} from "./chunk-T3SUXLQQ.js";
|
|
103
103
|
import {
|
|
104
104
|
AuthType,
|
|
105
105
|
ChatRecordingService,
|
|
106
106
|
Client,
|
|
107
107
|
Config,
|
|
108
|
-
CoreToolCallStatus,
|
|
109
108
|
ExitCodes,
|
|
110
109
|
FileDiscoveryService,
|
|
111
110
|
FolderTrustDiscoveryService,
|
|
112
|
-
GeminiEventType,
|
|
113
111
|
IdeClient,
|
|
114
|
-
IntegrityStatus,
|
|
115
112
|
InvalidStreamError,
|
|
116
113
|
JsonFormatter,
|
|
117
|
-
JsonStreamEventType,
|
|
118
114
|
LegacyAgentSession,
|
|
119
115
|
Logger,
|
|
120
116
|
MCPServerConfig,
|
|
121
|
-
MCPServerStatus,
|
|
122
|
-
OutputFormat,
|
|
123
117
|
PolicyIntegrityManager,
|
|
124
118
|
ROOT_SCHEDULER_ID,
|
|
125
119
|
ReadManyFilesTool,
|
|
126
120
|
Scheduler,
|
|
127
|
-
SessionEndReason,
|
|
128
|
-
SessionStartSource,
|
|
129
121
|
ShellExecutionService,
|
|
130
122
|
SimpleExtensionLoader,
|
|
131
123
|
StreamJsonFormatter,
|
|
132
124
|
ToolCallEvent,
|
|
133
|
-
TrustLevel,
|
|
134
125
|
UserAccountManager,
|
|
135
126
|
UserPromptEvent,
|
|
136
127
|
ValidationCancelledError,
|
|
137
128
|
ValidationRequiredError,
|
|
138
|
-
WarningPriority,
|
|
139
129
|
addMemory,
|
|
140
130
|
applyAdminAllowlist,
|
|
141
131
|
applyRequiredServers,
|
|
@@ -176,6 +166,7 @@ import {
|
|
|
176
166
|
listInboxPatches,
|
|
177
167
|
listInboxSkills,
|
|
178
168
|
listMemoryFiles,
|
|
169
|
+
loadConversationRecord,
|
|
179
170
|
logToolCall,
|
|
180
171
|
logUserPrompt,
|
|
181
172
|
parseAndFormatApiError,
|
|
@@ -199,11 +190,9 @@ import {
|
|
|
199
190
|
updatePolicy,
|
|
200
191
|
writeToStderr,
|
|
201
192
|
writeToStdout
|
|
202
|
-
} from "./chunk-
|
|
193
|
+
} from "./chunk-UNAVBUTP.js";
|
|
203
194
|
import {
|
|
204
195
|
ASK_USER_TOOL_NAME,
|
|
205
|
-
ApprovalMode,
|
|
206
|
-
CoreEvent,
|
|
207
196
|
DEFAULT_FILE_FILTERING_OPTIONS,
|
|
208
197
|
DEFAULT_GEMINI_EMBEDDING_MODEL,
|
|
209
198
|
DEFAULT_GEMINI_FLASH_LITE_MODEL,
|
|
@@ -223,7 +212,6 @@ import {
|
|
|
223
212
|
FatalUntrustedWorkspaceError,
|
|
224
213
|
GEMINI_DIR,
|
|
225
214
|
GEMINI_MODEL_ALIAS_AUTO,
|
|
226
|
-
Kind,
|
|
227
215
|
PREVIEW_GEMINI_3_1_CUSTOM_TOOLS_MODEL,
|
|
228
216
|
PREVIEW_GEMINI_3_1_FLASH_LITE_MODEL,
|
|
229
217
|
PREVIEW_GEMINI_3_1_MODEL,
|
|
@@ -233,7 +221,6 @@ import {
|
|
|
233
221
|
REFERENCE_CONTENT_START,
|
|
234
222
|
Storage,
|
|
235
223
|
ToolConfirmationOutcome,
|
|
236
|
-
ToolErrorType,
|
|
237
224
|
coreEvents,
|
|
238
225
|
debugLogger,
|
|
239
226
|
external_exports,
|
|
@@ -241,13 +228,14 @@ import {
|
|
|
241
228
|
getDisplayString,
|
|
242
229
|
getErrorMessage,
|
|
243
230
|
getErrorType,
|
|
231
|
+
getProjectHash,
|
|
244
232
|
homedir,
|
|
245
233
|
isFatalToolError,
|
|
246
234
|
isNodeError,
|
|
247
235
|
loadServerHierarchicalMemory,
|
|
248
236
|
resolveToRealPath,
|
|
249
237
|
setGeminiMdFilename
|
|
250
|
-
} from "./chunk-
|
|
238
|
+
} from "./chunk-N6QYTC2T.js";
|
|
251
239
|
import "./chunk-664ZODQF.js";
|
|
252
240
|
import "./chunk-RJTRUG2J.js";
|
|
253
241
|
import "./chunk-IUUIT4SU.js";
|
|
@@ -1532,11 +1520,11 @@ var parser = new YargsParser({
|
|
|
1532
1520
|
resolve: resolve2,
|
|
1533
1521
|
// TODO: figure out a way to combine ESM and CJS coverage, such that
|
|
1534
1522
|
// we can exercise all the lines below:
|
|
1535
|
-
require: (
|
|
1523
|
+
require: (path16) => {
|
|
1536
1524
|
if (typeof __require !== "undefined") {
|
|
1537
|
-
return __require(
|
|
1538
|
-
} else if (
|
|
1539
|
-
return JSON.parse(readFileSync(
|
|
1525
|
+
return __require(path16);
|
|
1526
|
+
} else if (path16.match(/\.json$/)) {
|
|
1527
|
+
return JSON.parse(readFileSync(path16, "utf8"));
|
|
1540
1528
|
} else {
|
|
1541
1529
|
throw Error("only .json config files are supported in ESM");
|
|
1542
1530
|
}
|
|
@@ -5377,7 +5365,7 @@ var MCP_LIST_DEFAULT_TIMEOUT_MSEC = 5e3;
|
|
|
5377
5365
|
async function testMCPConnection(serverName, config, isTrusted, activeSettings) {
|
|
5378
5366
|
const isStdio = !!config.command;
|
|
5379
5367
|
if (isStdio && !isTrusted) {
|
|
5380
|
-
return
|
|
5368
|
+
return "disconnected" /* DISCONNECTED */;
|
|
5381
5369
|
}
|
|
5382
5370
|
const client = new Client({
|
|
5383
5371
|
name: "mcp-test-client",
|
|
@@ -5413,7 +5401,7 @@ async function testMCPConnection(serverName, config, isTrusted, activeSettings)
|
|
|
5413
5401
|
transport = await createTransport(serverName, config, false, mcpContext);
|
|
5414
5402
|
} catch {
|
|
5415
5403
|
await client.close();
|
|
5416
|
-
return
|
|
5404
|
+
return "disconnected" /* DISCONNECTED */;
|
|
5417
5405
|
}
|
|
5418
5406
|
try {
|
|
5419
5407
|
const timeout = config.timeout ?? MCP_LIST_DEFAULT_TIMEOUT_MSEC;
|
|
@@ -5427,10 +5415,10 @@ async function testMCPConnection(serverName, config, isTrusted, activeSettings)
|
|
|
5427
5415
|
);
|
|
5428
5416
|
}
|
|
5429
5417
|
await client.close();
|
|
5430
|
-
return
|
|
5418
|
+
return "connected" /* CONNECTED */;
|
|
5431
5419
|
} catch {
|
|
5432
5420
|
await transport.close();
|
|
5433
|
-
return
|
|
5421
|
+
return "disconnected" /* DISCONNECTED */;
|
|
5434
5422
|
}
|
|
5435
5423
|
}
|
|
5436
5424
|
async function getServerStatus(serverName, server, isTrusted, activeSettings) {
|
|
@@ -5443,16 +5431,20 @@ async function getServerStatus(serverName, server, isTrusted, activeSettings) {
|
|
|
5443
5431
|
});
|
|
5444
5432
|
if (!loadResult.allowed) {
|
|
5445
5433
|
if (loadResult.blockType === "admin" || loadResult.blockType === "allowlist" || loadResult.blockType === "excludelist") {
|
|
5446
|
-
return
|
|
5434
|
+
return "blocked" /* BLOCKED */;
|
|
5447
5435
|
}
|
|
5448
|
-
return
|
|
5436
|
+
return "disabled" /* DISABLED */;
|
|
5437
|
+
}
|
|
5438
|
+
if (!isTrusted) {
|
|
5439
|
+
return "disabled" /* DISABLED */;
|
|
5449
5440
|
}
|
|
5450
5441
|
return testMCPConnection(serverName, server, isTrusted, activeSettings);
|
|
5451
5442
|
}
|
|
5452
5443
|
async function listMcpServers(loadedSettingsArg) {
|
|
5453
5444
|
const loadedSettings = loadedSettingsArg ?? loadSettings();
|
|
5454
5445
|
const activeSettings = loadedSettings.merged;
|
|
5455
|
-
const
|
|
5446
|
+
const allSettings = !loadedSettings.isTrusted ? loadedSettings.getMergedSettingsAsIfTrusted() : activeSettings;
|
|
5447
|
+
const { mcpServers, blockedServerNames } = await getMcpServersFromConfig(allSettings);
|
|
5456
5448
|
const serverNames = Object.keys(mcpServers);
|
|
5457
5449
|
if (blockedServerNames.length > 0) {
|
|
5458
5450
|
const message = getAdminBlockedMcpServersMessage(
|
|
@@ -5467,6 +5459,13 @@ async function listMcpServers(loadedSettingsArg) {
|
|
|
5467
5459
|
}
|
|
5468
5460
|
return;
|
|
5469
5461
|
}
|
|
5462
|
+
if (!loadedSettings.isTrusted) {
|
|
5463
|
+
debugLogger.log(
|
|
5464
|
+
import_chalk.default.yellow(
|
|
5465
|
+
"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"
|
|
5466
|
+
)
|
|
5467
|
+
);
|
|
5468
|
+
}
|
|
5470
5469
|
debugLogger.log("Configured MCP servers:\n");
|
|
5471
5470
|
for (const serverName of serverNames) {
|
|
5472
5471
|
const server = mcpServers[serverName];
|
|
@@ -5479,23 +5478,23 @@ async function listMcpServers(loadedSettingsArg) {
|
|
|
5479
5478
|
let statusIndicator = "";
|
|
5480
5479
|
let statusText = "";
|
|
5481
5480
|
switch (status) {
|
|
5482
|
-
case
|
|
5481
|
+
case "connected" /* CONNECTED */:
|
|
5483
5482
|
statusIndicator = import_chalk.default.green("\u2713");
|
|
5484
5483
|
statusText = "Connected";
|
|
5485
5484
|
break;
|
|
5486
|
-
case
|
|
5485
|
+
case "connecting" /* CONNECTING */:
|
|
5487
5486
|
statusIndicator = import_chalk.default.yellow("\u2026");
|
|
5488
5487
|
statusText = "Connecting";
|
|
5489
5488
|
break;
|
|
5490
|
-
case
|
|
5489
|
+
case "blocked" /* BLOCKED */:
|
|
5491
5490
|
statusIndicator = import_chalk.default.red("\u26D4");
|
|
5492
5491
|
statusText = "Blocked";
|
|
5493
5492
|
break;
|
|
5494
|
-
case
|
|
5493
|
+
case "disabled" /* DISABLED */:
|
|
5495
5494
|
statusIndicator = import_chalk.default.gray("\u25CB");
|
|
5496
5495
|
statusText = "Disabled";
|
|
5497
5496
|
break;
|
|
5498
|
-
case
|
|
5497
|
+
case "disconnected" /* DISCONNECTED */:
|
|
5499
5498
|
default:
|
|
5500
5499
|
statusIndicator = import_chalk.default.red("\u2717");
|
|
5501
5500
|
statusText = "Disconnected";
|
|
@@ -5781,7 +5780,7 @@ async function handleInstall(args) {
|
|
|
5781
5780
|
);
|
|
5782
5781
|
if (confirmed) {
|
|
5783
5782
|
const trustedFolders = loadTrustedFolders();
|
|
5784
|
-
await trustedFolders.setValue(realPath,
|
|
5783
|
+
await trustedFolders.setValue(realPath, "TRUST_FOLDER" /* TRUST_FOLDER */);
|
|
5785
5784
|
} else {
|
|
5786
5785
|
throw new Error(
|
|
5787
5786
|
`Installation aborted: Folder "${absolutePath}" is not trusted.`
|
|
@@ -6306,27 +6305,27 @@ import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
|
6306
6305
|
var __filename = fileURLToPath2(import.meta.url);
|
|
6307
6306
|
var __dirname2 = dirname3(__filename);
|
|
6308
6307
|
var EXAMPLES_PATH = join(__dirname2, "examples");
|
|
6309
|
-
async function pathExists(
|
|
6308
|
+
async function pathExists(path16) {
|
|
6310
6309
|
try {
|
|
6311
|
-
await access(
|
|
6310
|
+
await access(path16);
|
|
6312
6311
|
return true;
|
|
6313
6312
|
} catch {
|
|
6314
6313
|
return false;
|
|
6315
6314
|
}
|
|
6316
6315
|
}
|
|
6317
|
-
async function createDirectory(
|
|
6318
|
-
if (await pathExists(
|
|
6319
|
-
throw new Error(`Path already exists: ${
|
|
6316
|
+
async function createDirectory(path16) {
|
|
6317
|
+
if (await pathExists(path16)) {
|
|
6318
|
+
throw new Error(`Path already exists: ${path16}`);
|
|
6320
6319
|
}
|
|
6321
|
-
await mkdir(
|
|
6320
|
+
await mkdir(path16, { recursive: true });
|
|
6322
6321
|
}
|
|
6323
|
-
async function copyDirectory(template,
|
|
6324
|
-
await createDirectory(
|
|
6322
|
+
async function copyDirectory(template, path16) {
|
|
6323
|
+
await createDirectory(path16);
|
|
6325
6324
|
const examplePath = join(EXAMPLES_PATH, template);
|
|
6326
6325
|
const entries = await readdir(examplePath, { withFileTypes: true });
|
|
6327
6326
|
for (const entry of entries) {
|
|
6328
6327
|
const srcPath = join(examplePath, entry.name);
|
|
6329
|
-
const destPath = join(
|
|
6328
|
+
const destPath = join(path16, entry.name);
|
|
6330
6329
|
await cp(srcPath, destPath, { recursive: true });
|
|
6331
6330
|
}
|
|
6332
6331
|
}
|
|
@@ -6601,7 +6600,7 @@ async function handleEnable3(args) {
|
|
|
6601
6600
|
const result = enableSkill(settings, name);
|
|
6602
6601
|
const feedback = renderSkillActionFeedback(
|
|
6603
6602
|
result,
|
|
6604
|
-
(label,
|
|
6603
|
+
(label, path16) => `${import_chalk5.default.bold(label)} (${import_chalk5.default.dim(path16)})`
|
|
6605
6604
|
);
|
|
6606
6605
|
debugLogger.log(feedback);
|
|
6607
6606
|
}
|
|
@@ -6631,7 +6630,7 @@ async function handleDisable3(args) {
|
|
|
6631
6630
|
const result = disableSkill(settings, name, scope);
|
|
6632
6631
|
const feedback = renderSkillActionFeedback(
|
|
6633
6632
|
result,
|
|
6634
|
-
(label,
|
|
6633
|
+
(label, path16) => `${import_chalk6.default.bold(label)} (${import_chalk6.default.dim(path16)})`
|
|
6635
6634
|
);
|
|
6636
6635
|
debugLogger.log(feedback);
|
|
6637
6636
|
}
|
|
@@ -7826,7 +7825,7 @@ async function loadSandboxConfig(settings, argv) {
|
|
|
7826
7825
|
}
|
|
7827
7826
|
const command2 = getSandboxCommand(sandboxValue);
|
|
7828
7827
|
const packageJson = await getPackageJson(__dirname3);
|
|
7829
|
-
const image = process.env["GEMINI_SANDBOX_IMAGE"] ?? "us-docker.pkg.dev/gemini-code-dev/gemini-cli/sandbox:0.42.0-
|
|
7828
|
+
const image = process.env["GEMINI_SANDBOX_IMAGE"] ?? "us-docker.pkg.dev/gemini-code-dev/gemini-cli/sandbox:0.42.0-nightly.20260428.g59b2dea0e" ?? customImage ?? packageJson?.config?.sandboxImageUri;
|
|
7830
7829
|
const isNative = command2 === "windows-native" || command2 === "sandbox-exec" || command2 === "lxc";
|
|
7831
7830
|
return command2 && (image || isNative) ? { enabled: true, allowedPaths, networkAccess, command: command2, image } : void 0;
|
|
7832
7831
|
}
|
|
@@ -7885,9 +7884,9 @@ async function resolveWorkspacePolicyState(options) {
|
|
|
7885
7884
|
cwd,
|
|
7886
7885
|
potentialWorkspacePoliciesDir
|
|
7887
7886
|
);
|
|
7888
|
-
if (integrityResult.status ===
|
|
7887
|
+
if (integrityResult.status === "MATCH" /* MATCH */) {
|
|
7889
7888
|
workspacePoliciesDir = potentialWorkspacePoliciesDir;
|
|
7890
|
-
} else if (integrityResult.status ===
|
|
7889
|
+
} else if (integrityResult.status === "NEW" /* NEW */ && integrityResult.fileCount === 0) {
|
|
7891
7890
|
workspacePoliciesDir = void 0;
|
|
7892
7891
|
} else if (interactive && !autoAcceptWorkspacePolicies) {
|
|
7893
7892
|
policyUpdateConfirmationRequest = {
|
|
@@ -7994,8 +7993,13 @@ async function parseArguments(settings) {
|
|
|
7994
7993
|
const queryArg2 = argv["query"];
|
|
7995
7994
|
const query = typeof queryArg2 === "string" || Array.isArray(queryArg2) ? queryArg2 : void 0;
|
|
7996
7995
|
const hasPositionalQuery = Array.isArray(query) ? query.length > 0 : !!query;
|
|
7997
|
-
|
|
7998
|
-
|
|
7996
|
+
const sessionFlags = [
|
|
7997
|
+
argv["resume"] !== void 0,
|
|
7998
|
+
argv["session-id"] !== void 0,
|
|
7999
|
+
argv["session-file"] !== void 0
|
|
8000
|
+
].filter(Boolean).length;
|
|
8001
|
+
if (sessionFlags > 1) {
|
|
8002
|
+
return "The flags --resume, --session-id, and --session-file are mutually exclusive. Please provide only one.";
|
|
7999
8003
|
}
|
|
8000
8004
|
if (argv["prompt"] && hasPositionalQuery) {
|
|
8001
8005
|
return "Cannot use both a positional prompt and the --prompt (-p) flag together";
|
|
@@ -8126,6 +8130,10 @@ async function parseArguments(settings) {
|
|
|
8126
8130
|
}
|
|
8127
8131
|
return trimmed;
|
|
8128
8132
|
}
|
|
8133
|
+
}).option("session-file", {
|
|
8134
|
+
type: "string",
|
|
8135
|
+
nargs: 1,
|
|
8136
|
+
description: "Load a session from a JSON file"
|
|
8129
8137
|
}).option("session-id", {
|
|
8130
8138
|
type: "string",
|
|
8131
8139
|
nargs: 1,
|
|
@@ -8327,23 +8335,23 @@ async function loadCliConfig(settings, sessionId, argv, options = {}) {
|
|
|
8327
8335
|
if (rawApprovalMode) {
|
|
8328
8336
|
switch (rawApprovalMode) {
|
|
8329
8337
|
case "yolo":
|
|
8330
|
-
approvalMode =
|
|
8338
|
+
approvalMode = "yolo" /* YOLO */;
|
|
8331
8339
|
break;
|
|
8332
8340
|
case "auto_edit":
|
|
8333
|
-
approvalMode =
|
|
8341
|
+
approvalMode = "autoEdit" /* AUTO_EDIT */;
|
|
8334
8342
|
break;
|
|
8335
8343
|
case "plan":
|
|
8336
8344
|
if (!(settings.general?.plan?.enabled ?? true)) {
|
|
8337
8345
|
debugLogger.warn(
|
|
8338
8346
|
'Approval mode "plan" is disabled in your settings. Falling back to "default".'
|
|
8339
8347
|
);
|
|
8340
|
-
approvalMode =
|
|
8348
|
+
approvalMode = "default" /* DEFAULT */;
|
|
8341
8349
|
} else {
|
|
8342
|
-
approvalMode =
|
|
8350
|
+
approvalMode = "plan" /* PLAN */;
|
|
8343
8351
|
}
|
|
8344
8352
|
break;
|
|
8345
8353
|
case "default":
|
|
8346
|
-
approvalMode =
|
|
8354
|
+
approvalMode = "default" /* DEFAULT */;
|
|
8347
8355
|
break;
|
|
8348
8356
|
default:
|
|
8349
8357
|
throw new Error(
|
|
@@ -8351,10 +8359,10 @@ async function loadCliConfig(settings, sessionId, argv, options = {}) {
|
|
|
8351
8359
|
);
|
|
8352
8360
|
}
|
|
8353
8361
|
} else {
|
|
8354
|
-
approvalMode =
|
|
8362
|
+
approvalMode = "default" /* DEFAULT */;
|
|
8355
8363
|
}
|
|
8356
8364
|
if (settings.security?.disableYoloMode || settings.admin?.secureModeEnabled) {
|
|
8357
|
-
if (approvalMode ===
|
|
8365
|
+
if (approvalMode === "yolo" /* YOLO */) {
|
|
8358
8366
|
if (settings.admin?.secureModeEnabled) {
|
|
8359
8367
|
debugLogger.error(
|
|
8360
8368
|
'YOLO mode is disabled by "secureModeEnabled" setting.'
|
|
@@ -8372,16 +8380,16 @@ async function loadCliConfig(settings, sessionId, argv, options = {}) {
|
|
|
8372
8380
|
)
|
|
8373
8381
|
);
|
|
8374
8382
|
}
|
|
8375
|
-
} else if (approvalMode ===
|
|
8383
|
+
} else if (approvalMode === "yolo" /* YOLO */) {
|
|
8376
8384
|
debugLogger.warn(
|
|
8377
8385
|
"YOLO mode is enabled. All tool calls will be automatically approved."
|
|
8378
8386
|
);
|
|
8379
8387
|
}
|
|
8380
|
-
if (!trustedFolder && approvalMode !==
|
|
8388
|
+
if (!trustedFolder && approvalMode !== "default" /* DEFAULT */) {
|
|
8381
8389
|
debugLogger.warn(
|
|
8382
8390
|
`Approval mode overridden to "default" because the current folder is not trusted.`
|
|
8383
8391
|
);
|
|
8384
|
-
approvalMode =
|
|
8392
|
+
approvalMode = "default" /* DEFAULT */;
|
|
8385
8393
|
}
|
|
8386
8394
|
let telemetrySettings;
|
|
8387
8395
|
try {
|
|
@@ -8610,7 +8618,11 @@ async function loadCliConfig(settings, sessionId, argv, options = {}) {
|
|
|
8610
8618
|
shellBackgroundCompletionBehavior: settings.tools?.shell?.backgroundCompletionBehavior,
|
|
8611
8619
|
shellToolInactivityTimeout: settings.tools?.shell?.inactivityTimeout,
|
|
8612
8620
|
enableShellOutputEfficiency: settings.tools?.shell?.enableShellOutputEfficiency ?? true,
|
|
8613
|
-
|
|
8621
|
+
// In ACP mode, always skip the next-speaker check. This check triggers
|
|
8622
|
+
// recursive continuation turns inside GeminiClient.processTurn() that
|
|
8623
|
+
// conflict with ACP's explicit turn management via session/prompt,
|
|
8624
|
+
// causing infinite agent_thought_chunk loops.
|
|
8625
|
+
skipNextSpeakerCheck: isAcpMode || settings.model?.skipNextSpeakerCheck,
|
|
8614
8626
|
truncateToolOutputThreshold: settings.tools?.truncateToolOutputThreshold,
|
|
8615
8627
|
eventEmitter: coreEvents,
|
|
8616
8628
|
useWriteTodos: argv.useWriteTodos ?? settings.useWriteTodos,
|
|
@@ -8769,6 +8781,8 @@ import { createHash as createHash2 } from "node:crypto";
|
|
|
8769
8781
|
import v8 from "node:v8";
|
|
8770
8782
|
import os6 from "node:os";
|
|
8771
8783
|
import dns from "node:dns";
|
|
8784
|
+
import * as path15 from "node:path";
|
|
8785
|
+
import * as fsPromises from "node:fs/promises";
|
|
8772
8786
|
|
|
8773
8787
|
// packages/cli/src/utils/sandbox.ts
|
|
8774
8788
|
var import_shell_quote2 = __toESM(require_shell_quote(), 1);
|
|
@@ -9229,21 +9243,11 @@ async function start_sandbox(config, nodeArgs = [], cliConfig, cliArgs = []) {
|
|
|
9229
9243
|
}
|
|
9230
9244
|
const imageName = parseImageName(image);
|
|
9231
9245
|
const isIntegrationTest = process.env["GEMINI_CLI_INTEGRATION_TEST"] === "true";
|
|
9232
|
-
|
|
9233
|
-
|
|
9234
|
-
|
|
9235
|
-
|
|
9236
|
-
|
|
9237
|
-
debugLogger.log(`ContainerName: ${containerName}`);
|
|
9238
|
-
} else {
|
|
9239
|
-
let index = 0;
|
|
9240
|
-
const containerNameCheck = (await execAsync(`${command2} ps -a --format "{{.Names}}"`)).stdout.trim();
|
|
9241
|
-
while (containerNameCheck.includes(`${imageName}-${index}`)) {
|
|
9242
|
-
index++;
|
|
9243
|
-
}
|
|
9244
|
-
containerName = `${imageName}-${index}`;
|
|
9245
|
-
debugLogger.log(`ContainerName (regular): ${containerName}`);
|
|
9246
|
-
}
|
|
9246
|
+
const containerNamePrefix = isIntegrationTest ? "gemini-cli-integration-test" : imageName;
|
|
9247
|
+
const containerName = `${containerNamePrefix}-${randomBytes(6).toString(
|
|
9248
|
+
"hex"
|
|
9249
|
+
)}`;
|
|
9250
|
+
debugLogger.log(`ContainerName: ${containerName}`);
|
|
9247
9251
|
args.push("--name", containerName, "--hostname", containerName);
|
|
9248
9252
|
if (process.env["GEMINI_CLI_TEST_VAR"]) {
|
|
9249
9253
|
args.push(
|
|
@@ -9802,7 +9806,7 @@ import path9 from "node:path";
|
|
|
9802
9806
|
import process4 from "node:process";
|
|
9803
9807
|
var homeDirectoryCheck = {
|
|
9804
9808
|
id: "home-directory",
|
|
9805
|
-
priority:
|
|
9809
|
+
priority: "low" /* Low */,
|
|
9806
9810
|
check: async (workspaceRoot, settings) => {
|
|
9807
9811
|
if (settings.ui?.showHomeDirectoryWarning === false) {
|
|
9808
9812
|
return null;
|
|
@@ -9826,7 +9830,7 @@ var homeDirectoryCheck = {
|
|
|
9826
9830
|
};
|
|
9827
9831
|
var rootDirectoryCheck = {
|
|
9828
9832
|
id: "root-directory",
|
|
9829
|
-
priority:
|
|
9833
|
+
priority: "high" /* High */,
|
|
9830
9834
|
check: async (workspaceRoot, _settings) => {
|
|
9831
9835
|
try {
|
|
9832
9836
|
const workspaceRealPath = await fs9.realpath(workspaceRoot);
|
|
@@ -9842,7 +9846,7 @@ var rootDirectoryCheck = {
|
|
|
9842
9846
|
};
|
|
9843
9847
|
var folderTrustCheck = {
|
|
9844
9848
|
id: "folder-trust",
|
|
9845
|
-
priority:
|
|
9849
|
+
priority: "high" /* High */,
|
|
9846
9850
|
check: async (workspaceRoot, settings) => {
|
|
9847
9851
|
if (!isFolderTrustEnabled(settings)) {
|
|
9848
9852
|
return null;
|
|
@@ -10032,12 +10036,12 @@ function handleError(error, config, customErrorCode) {
|
|
|
10032
10036
|
error,
|
|
10033
10037
|
config.getContentGeneratorConfig()?.authType
|
|
10034
10038
|
);
|
|
10035
|
-
if (config.getOutputFormat() ===
|
|
10039
|
+
if (config.getOutputFormat() === "stream-json" /* STREAM_JSON */) {
|
|
10036
10040
|
const streamFormatter = new StreamJsonFormatter();
|
|
10037
10041
|
const errorCode = customErrorCode ?? extractErrorCode(error);
|
|
10038
10042
|
const metrics = uiTelemetryService.getMetrics();
|
|
10039
10043
|
streamFormatter.emitEvent({
|
|
10040
|
-
type:
|
|
10044
|
+
type: "result" /* RESULT */,
|
|
10041
10045
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10042
10046
|
status: "error",
|
|
10043
10047
|
error: {
|
|
@@ -10048,7 +10052,7 @@ function handleError(error, config, customErrorCode) {
|
|
|
10048
10052
|
});
|
|
10049
10053
|
runSyncCleanup();
|
|
10050
10054
|
process.exit(getNumericExitCode(errorCode));
|
|
10051
|
-
} else if (config.getOutputFormat() ===
|
|
10055
|
+
} else if (config.getOutputFormat() === "json" /* JSON */) {
|
|
10052
10056
|
const formatter = new JsonFormatter();
|
|
10053
10057
|
const errorCode = customErrorCode ?? extractErrorCode(error);
|
|
10054
10058
|
const formattedError = formatter.formatError(
|
|
@@ -10068,11 +10072,11 @@ function handleToolError(toolName, toolError, config, errorType, resultDisplay)
|
|
|
10068
10072
|
const isFatal = isFatalToolError(errorType);
|
|
10069
10073
|
if (isFatal) {
|
|
10070
10074
|
const toolExecutionError = new FatalToolExecutionError(errorMessage);
|
|
10071
|
-
if (config.getOutputFormat() ===
|
|
10075
|
+
if (config.getOutputFormat() === "stream-json" /* STREAM_JSON */) {
|
|
10072
10076
|
const streamFormatter = new StreamJsonFormatter();
|
|
10073
10077
|
const metrics = uiTelemetryService.getMetrics();
|
|
10074
10078
|
streamFormatter.emitEvent({
|
|
10075
|
-
type:
|
|
10079
|
+
type: "result" /* RESULT */,
|
|
10076
10080
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10077
10081
|
status: "error",
|
|
10078
10082
|
error: {
|
|
@@ -10081,7 +10085,7 @@ function handleToolError(toolName, toolError, config, errorType, resultDisplay)
|
|
|
10081
10085
|
},
|
|
10082
10086
|
stats: streamFormatter.convertToStreamStats(metrics, 0)
|
|
10083
10087
|
});
|
|
10084
|
-
} else if (config.getOutputFormat() ===
|
|
10088
|
+
} else if (config.getOutputFormat() === "json" /* JSON */) {
|
|
10085
10089
|
const formatter = new JsonFormatter();
|
|
10086
10090
|
const formattedError = formatter.formatError(
|
|
10087
10091
|
toolExecutionError,
|
|
@@ -10099,11 +10103,11 @@ function handleToolError(toolName, toolError, config, errorType, resultDisplay)
|
|
|
10099
10103
|
}
|
|
10100
10104
|
function handleCancellationError(config) {
|
|
10101
10105
|
const cancellationError = new FatalCancellationError("Operation cancelled.");
|
|
10102
|
-
if (config.getOutputFormat() ===
|
|
10106
|
+
if (config.getOutputFormat() === "stream-json" /* STREAM_JSON */) {
|
|
10103
10107
|
const streamFormatter = new StreamJsonFormatter();
|
|
10104
10108
|
const metrics = uiTelemetryService.getMetrics();
|
|
10105
10109
|
streamFormatter.emitEvent({
|
|
10106
|
-
type:
|
|
10110
|
+
type: "result" /* RESULT */,
|
|
10107
10111
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10108
10112
|
status: "error",
|
|
10109
10113
|
error: {
|
|
@@ -10114,7 +10118,7 @@ function handleCancellationError(config) {
|
|
|
10114
10118
|
});
|
|
10115
10119
|
runSyncCleanup();
|
|
10116
10120
|
process.exit(cancellationError.exitCode);
|
|
10117
|
-
} else if (config.getOutputFormat() ===
|
|
10121
|
+
} else if (config.getOutputFormat() === "json" /* JSON */) {
|
|
10118
10122
|
const formatter = new JsonFormatter();
|
|
10119
10123
|
const formattedError = formatter.formatError(
|
|
10120
10124
|
cancellationError,
|
|
@@ -10134,11 +10138,11 @@ function handleMaxTurnsExceededError(config) {
|
|
|
10134
10138
|
const maxTurnsError = new FatalTurnLimitedError(
|
|
10135
10139
|
"Reached max session turns for this session. Increase the number of turns by specifying maxSessionTurns in settings.json."
|
|
10136
10140
|
);
|
|
10137
|
-
if (config.getOutputFormat() ===
|
|
10141
|
+
if (config.getOutputFormat() === "stream-json" /* STREAM_JSON */) {
|
|
10138
10142
|
const streamFormatter = new StreamJsonFormatter();
|
|
10139
10143
|
const metrics = uiTelemetryService.getMetrics();
|
|
10140
10144
|
streamFormatter.emitEvent({
|
|
10141
|
-
type:
|
|
10145
|
+
type: "result" /* RESULT */,
|
|
10142
10146
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10143
10147
|
status: "error",
|
|
10144
10148
|
error: {
|
|
@@ -10149,7 +10153,7 @@ function handleMaxTurnsExceededError(config) {
|
|
|
10149
10153
|
});
|
|
10150
10154
|
runSyncCleanup();
|
|
10151
10155
|
process.exit(maxTurnsError.exitCode);
|
|
10152
|
-
} else if (config.getOutputFormat() ===
|
|
10156
|
+
} else if (config.getOutputFormat() === "json" /* JSON */) {
|
|
10153
10157
|
const formatter = new JsonFormatter();
|
|
10154
10158
|
const formattedError = formatter.formatError(
|
|
10155
10159
|
maxTurnsError,
|
|
@@ -10229,7 +10233,7 @@ async function runNonInteractive({
|
|
|
10229
10233
|
}
|
|
10230
10234
|
});
|
|
10231
10235
|
if (process.env["GEMINI_CLI_ACTIVITY_LOG_TARGET"]) {
|
|
10232
|
-
const { setupInitialActivityLogger } = await import("./devtoolsService-
|
|
10236
|
+
const { setupInitialActivityLogger } = await import("./devtoolsService-7KZDSYEF.js");
|
|
10233
10237
|
setupInitialActivityLogger(config);
|
|
10234
10238
|
}
|
|
10235
10239
|
const { stdout: workingStdout } = createWorkingStdio();
|
|
@@ -10245,7 +10249,7 @@ async function runNonInteractive({
|
|
|
10245
10249
|
}
|
|
10246
10250
|
};
|
|
10247
10251
|
const startTime = Date.now();
|
|
10248
|
-
const streamFormatter = config.getOutputFormat() ===
|
|
10252
|
+
const streamFormatter = config.getOutputFormat() === "stream-json" /* STREAM_JSON */ ? new StreamJsonFormatter() : null;
|
|
10249
10253
|
const abortController = new AbortController();
|
|
10250
10254
|
let isAborting = false;
|
|
10251
10255
|
let cancelMessageTimer = null;
|
|
@@ -10298,13 +10302,13 @@ async function runNonInteractive({
|
|
|
10298
10302
|
};
|
|
10299
10303
|
try {
|
|
10300
10304
|
consolePatcher.patch();
|
|
10301
|
-
if (config.getRawOutput() && !config.getAcceptRawOutputRisk() && config.getOutputFormat() ===
|
|
10305
|
+
if (config.getRawOutput() && !config.getAcceptRawOutputRisk() && config.getOutputFormat() === "text" /* TEXT */) {
|
|
10302
10306
|
process.stderr.write(
|
|
10303
10307
|
"[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"
|
|
10304
10308
|
);
|
|
10305
10309
|
}
|
|
10306
10310
|
setupStdinCancellation();
|
|
10307
|
-
coreEvents.on(
|
|
10311
|
+
coreEvents.on("user-feedback" /* UserFeedback */, handleUserFeedback);
|
|
10308
10312
|
coreEvents.drainBacklogs();
|
|
10309
10313
|
process.stdout.on("error", (err) => {
|
|
10310
10314
|
if (err.code === "EPIPE") {
|
|
@@ -10330,7 +10334,7 @@ async function runNonInteractive({
|
|
|
10330
10334
|
}
|
|
10331
10335
|
if (streamFormatter) {
|
|
10332
10336
|
streamFormatter.emitEvent({
|
|
10333
|
-
type:
|
|
10337
|
+
type: "init" /* INIT */,
|
|
10334
10338
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10335
10339
|
session_id: config.getSessionId(),
|
|
10336
10340
|
model: config.getModel()
|
|
@@ -10368,7 +10372,7 @@ async function runNonInteractive({
|
|
|
10368
10372
|
}
|
|
10369
10373
|
if (streamFormatter) {
|
|
10370
10374
|
streamFormatter.emitEvent({
|
|
10371
|
-
type:
|
|
10375
|
+
type: "message" /* MESSAGE */,
|
|
10372
10376
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10373
10377
|
role: "user",
|
|
10374
10378
|
content: input
|
|
@@ -10407,12 +10411,12 @@ async function runNonInteractive({
|
|
|
10407
10411
|
const metrics = uiTelemetryService.getMetrics();
|
|
10408
10412
|
const durationMs = Date.now() - startTime;
|
|
10409
10413
|
streamFormatter.emitEvent({
|
|
10410
|
-
type:
|
|
10414
|
+
type: "result" /* RESULT */,
|
|
10411
10415
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10412
10416
|
status: "success",
|
|
10413
10417
|
stats: streamFormatter.convertToStreamStats(metrics, durationMs)
|
|
10414
10418
|
});
|
|
10415
|
-
} else if (config.getOutputFormat() ===
|
|
10419
|
+
} else if (config.getOutputFormat() === "json" /* JSON */) {
|
|
10416
10420
|
const formatter = new JsonFormatter();
|
|
10417
10421
|
const stats = uiTelemetryService.getMetrics();
|
|
10418
10422
|
textOutput.write(
|
|
@@ -10505,13 +10509,13 @@ async function runNonInteractive({
|
|
|
10505
10509
|
const output = isRaw ? part.text : stripAnsi(part.text);
|
|
10506
10510
|
if (streamFormatter) {
|
|
10507
10511
|
streamFormatter.emitEvent({
|
|
10508
|
-
type:
|
|
10512
|
+
type: "message" /* MESSAGE */,
|
|
10509
10513
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10510
10514
|
role: "assistant",
|
|
10511
10515
|
content: output,
|
|
10512
10516
|
delta: true
|
|
10513
10517
|
});
|
|
10514
|
-
} else if (config.getOutputFormat() ===
|
|
10518
|
+
} else if (config.getOutputFormat() === "json" /* JSON */) {
|
|
10515
10519
|
responseText += output;
|
|
10516
10520
|
} else {
|
|
10517
10521
|
if (part.text) {
|
|
@@ -10524,13 +10528,13 @@ async function runNonInteractive({
|
|
|
10524
10528
|
break;
|
|
10525
10529
|
}
|
|
10526
10530
|
case "tool_request": {
|
|
10527
|
-
if (config.getOutputFormat() ===
|
|
10531
|
+
if (config.getOutputFormat() === "json" /* JSON */) {
|
|
10528
10532
|
preToolResponseText = responseText || preToolResponseText;
|
|
10529
10533
|
responseText = "";
|
|
10530
10534
|
}
|
|
10531
10535
|
if (streamFormatter) {
|
|
10532
10536
|
streamFormatter.emitEvent({
|
|
10533
|
-
type:
|
|
10537
|
+
type: "tool_use" /* TOOL_USE */,
|
|
10534
10538
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10535
10539
|
tool_name: event.name,
|
|
10536
10540
|
tool_id: event.requestId,
|
|
@@ -10546,7 +10550,7 @@ async function runNonInteractive({
|
|
|
10546
10550
|
const displayText = displayContentToString(display);
|
|
10547
10551
|
const errorMsg = getTextContent(event.content) ?? "Tool error";
|
|
10548
10552
|
streamFormatter.emitEvent({
|
|
10549
|
-
type:
|
|
10553
|
+
type: "tool_result" /* TOOL_RESULT */,
|
|
10550
10554
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10551
10555
|
tool_id: event.requestId,
|
|
10552
10556
|
status: event.isError ? "error" : "success",
|
|
@@ -10561,17 +10565,17 @@ async function runNonInteractive({
|
|
|
10561
10565
|
const display = event.display?.result;
|
|
10562
10566
|
const displayText = displayContentToString(display);
|
|
10563
10567
|
const errorMsg = getTextContent(event.content) ?? "Tool error";
|
|
10564
|
-
if (event.data?.["errorType"] ===
|
|
10565
|
-
if (config.getOutputFormat() ===
|
|
10568
|
+
if (event.data?.["errorType"] === "stop_execution" /* STOP_EXECUTION */) {
|
|
10569
|
+
if (config.getOutputFormat() === "json" /* JSON */ && !responseText && preToolResponseText) {
|
|
10566
10570
|
responseText = preToolResponseText;
|
|
10567
10571
|
}
|
|
10568
10572
|
const stopMessage = `Agent execution stopped: ${errorMsg}`;
|
|
10569
|
-
if (config.getOutputFormat() ===
|
|
10573
|
+
if (config.getOutputFormat() === "text" /* TEXT */) {
|
|
10570
10574
|
process.stderr.write(`${stopMessage}
|
|
10571
10575
|
`);
|
|
10572
10576
|
}
|
|
10573
10577
|
}
|
|
10574
|
-
if (event.data?.["errorType"] ===
|
|
10578
|
+
if (event.data?.["errorType"] === "no_space_left" /* NO_SPACE_LEFT */) {
|
|
10575
10579
|
throw new FatalToolExecutionError(
|
|
10576
10580
|
"Error executing tool " + event.name + ": " + (displayText || errorMsg)
|
|
10577
10581
|
);
|
|
@@ -10593,12 +10597,12 @@ async function runNonInteractive({
|
|
|
10593
10597
|
const errorCode = event._meta?.["code"];
|
|
10594
10598
|
if (errorCode === "AGENT_EXECUTION_BLOCKED") {
|
|
10595
10599
|
const blockMessage = `Agent execution blocked: ${event.message.trim()}`;
|
|
10596
|
-
if (config.getOutputFormat() ===
|
|
10600
|
+
if (config.getOutputFormat() === "text" /* TEXT */) {
|
|
10597
10601
|
process.stderr.write(`[WARNING] ${blockMessage}
|
|
10598
10602
|
`);
|
|
10599
10603
|
} else if (streamFormatter) {
|
|
10600
10604
|
streamFormatter.emitEvent({
|
|
10601
|
-
type:
|
|
10605
|
+
type: "error" /* ERROR */,
|
|
10602
10606
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10603
10607
|
severity: "warning",
|
|
10604
10608
|
message: stripAnsi(blockMessage)
|
|
@@ -10608,13 +10612,13 @@ async function runNonInteractive({
|
|
|
10608
10612
|
break;
|
|
10609
10613
|
}
|
|
10610
10614
|
const severity = event.status === "RESOURCE_EXHAUSTED" ? "error" : "warning";
|
|
10611
|
-
if (config.getOutputFormat() ===
|
|
10615
|
+
if (config.getOutputFormat() === "text" /* TEXT */) {
|
|
10612
10616
|
process.stderr.write(`[WARNING] ${event.message}
|
|
10613
10617
|
`);
|
|
10614
10618
|
}
|
|
10615
10619
|
if (streamFormatter) {
|
|
10616
10620
|
streamFormatter.emitEvent({
|
|
10617
|
-
type:
|
|
10621
|
+
type: "error" /* ERROR */,
|
|
10618
10622
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10619
10623
|
severity,
|
|
10620
10624
|
message: stripAnsi(event.message)
|
|
@@ -10634,7 +10638,7 @@ async function runNonInteractive({
|
|
|
10634
10638
|
);
|
|
10635
10639
|
} else if (streamFormatter) {
|
|
10636
10640
|
streamFormatter.emitEvent({
|
|
10637
|
-
type:
|
|
10641
|
+
type: "error" /* ERROR */,
|
|
10638
10642
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10639
10643
|
severity: "error",
|
|
10640
10644
|
message: "Maximum session turns exceeded"
|
|
@@ -10642,7 +10646,7 @@ async function runNonInteractive({
|
|
|
10642
10646
|
}
|
|
10643
10647
|
}
|
|
10644
10648
|
const stopMessage = typeof event.data?.["message"] === "string" ? event.data["message"] : "";
|
|
10645
|
-
if (stopMessage && config.getOutputFormat() ===
|
|
10649
|
+
if (stopMessage && config.getOutputFormat() === "text" /* TEXT */) {
|
|
10646
10650
|
process.stderr.write(`Agent execution stopped: ${stopMessage}
|
|
10647
10651
|
`);
|
|
10648
10652
|
}
|
|
@@ -10672,7 +10676,7 @@ async function runNonInteractive({
|
|
|
10672
10676
|
abortController.signal.removeEventListener("abort", abortSession);
|
|
10673
10677
|
scheduler?.dispose();
|
|
10674
10678
|
consolePatcher.cleanup();
|
|
10675
|
-
coreEvents.off(
|
|
10679
|
+
coreEvents.off("user-feedback" /* UserFeedback */, handleUserFeedback);
|
|
10676
10680
|
}
|
|
10677
10681
|
if (errorToHandle) {
|
|
10678
10682
|
handleError(errorToHandle, config);
|
|
@@ -10684,6 +10688,9 @@ async function runNonInteractive({
|
|
|
10684
10688
|
async function runNonInteractive2(params) {
|
|
10685
10689
|
const useAgentSession = params.config.getAgentSessionNoninteractiveEnabled();
|
|
10686
10690
|
if (useAgentSession) {
|
|
10691
|
+
debugLogger.debug(
|
|
10692
|
+
"[ADK] Running non-interactive mode with ADK agent session"
|
|
10693
|
+
);
|
|
10687
10694
|
return runNonInteractive(params);
|
|
10688
10695
|
}
|
|
10689
10696
|
const { config, settings, input, prompt_id, resumedSessionData } = params;
|
|
@@ -10697,7 +10704,7 @@ async function runNonInteractive2(params) {
|
|
|
10697
10704
|
}
|
|
10698
10705
|
});
|
|
10699
10706
|
if (process.env["GEMINI_CLI_ACTIVITY_LOG_TARGET"]) {
|
|
10700
|
-
const { setupInitialActivityLogger } = await import("./devtoolsService-
|
|
10707
|
+
const { setupInitialActivityLogger } = await import("./devtoolsService-7KZDSYEF.js");
|
|
10701
10708
|
setupInitialActivityLogger(config);
|
|
10702
10709
|
}
|
|
10703
10710
|
const { stdout: workingStdout } = createWorkingStdio();
|
|
@@ -10713,7 +10720,7 @@ async function runNonInteractive2(params) {
|
|
|
10713
10720
|
}
|
|
10714
10721
|
};
|
|
10715
10722
|
const startTime = Date.now();
|
|
10716
|
-
const streamFormatter = config.getOutputFormat() ===
|
|
10723
|
+
const streamFormatter = config.getOutputFormat() === "stream-json" /* STREAM_JSON */ ? new StreamJsonFormatter() : null;
|
|
10717
10724
|
const abortController = new AbortController();
|
|
10718
10725
|
let isAborting = false;
|
|
10719
10726
|
let cancelMessageTimer = null;
|
|
@@ -10764,13 +10771,13 @@ async function runNonInteractive2(params) {
|
|
|
10764
10771
|
let scheduler;
|
|
10765
10772
|
try {
|
|
10766
10773
|
consolePatcher.patch();
|
|
10767
|
-
if (config.getRawOutput() && !config.getAcceptRawOutputRisk() && config.getOutputFormat() ===
|
|
10774
|
+
if (config.getRawOutput() && !config.getAcceptRawOutputRisk() && config.getOutputFormat() === "text" /* TEXT */) {
|
|
10768
10775
|
process.stderr.write(
|
|
10769
10776
|
"[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"
|
|
10770
10777
|
);
|
|
10771
10778
|
}
|
|
10772
10779
|
setupStdinCancellation();
|
|
10773
|
-
coreEvents.on(
|
|
10780
|
+
coreEvents.on("user-feedback" /* UserFeedback */, handleUserFeedback);
|
|
10774
10781
|
coreEvents.drainBacklogs();
|
|
10775
10782
|
process.stdout.on("error", (err) => {
|
|
10776
10783
|
if (err.code === "EPIPE") {
|
|
@@ -10794,7 +10801,7 @@ async function runNonInteractive2(params) {
|
|
|
10794
10801
|
}
|
|
10795
10802
|
if (streamFormatter) {
|
|
10796
10803
|
streamFormatter.emitEvent({
|
|
10797
|
-
type:
|
|
10804
|
+
type: "init" /* INIT */,
|
|
10798
10805
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10799
10806
|
session_id: config.getSessionId(),
|
|
10800
10807
|
model: config.getModel()
|
|
@@ -10832,7 +10839,7 @@ async function runNonInteractive2(params) {
|
|
|
10832
10839
|
}
|
|
10833
10840
|
if (streamFormatter) {
|
|
10834
10841
|
streamFormatter.emitEvent({
|
|
10835
|
-
type:
|
|
10842
|
+
type: "message" /* MESSAGE */,
|
|
10836
10843
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10837
10844
|
role: "user",
|
|
10838
10845
|
content: input
|
|
@@ -10860,28 +10867,28 @@ async function runNonInteractive2(params) {
|
|
|
10860
10867
|
if (abortController.signal.aborted) {
|
|
10861
10868
|
handleCancellationError(config);
|
|
10862
10869
|
}
|
|
10863
|
-
if (event.type ===
|
|
10870
|
+
if (event.type === "content" /* Content */) {
|
|
10864
10871
|
const isRaw = config.getRawOutput() || config.getAcceptRawOutputRisk();
|
|
10865
10872
|
const output = isRaw ? event.value : stripAnsi(event.value);
|
|
10866
10873
|
if (streamFormatter) {
|
|
10867
10874
|
streamFormatter.emitEvent({
|
|
10868
|
-
type:
|
|
10875
|
+
type: "message" /* MESSAGE */,
|
|
10869
10876
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10870
10877
|
role: "assistant",
|
|
10871
10878
|
content: output,
|
|
10872
10879
|
delta: true
|
|
10873
10880
|
});
|
|
10874
|
-
} else if (config.getOutputFormat() ===
|
|
10881
|
+
} else if (config.getOutputFormat() === "json" /* JSON */) {
|
|
10875
10882
|
responseText += output;
|
|
10876
10883
|
} else {
|
|
10877
10884
|
if (event.value) {
|
|
10878
10885
|
textOutput.write(output);
|
|
10879
10886
|
}
|
|
10880
10887
|
}
|
|
10881
|
-
} else if (event.type ===
|
|
10888
|
+
} else if (event.type === "tool_call_request" /* ToolCallRequest */) {
|
|
10882
10889
|
if (streamFormatter) {
|
|
10883
10890
|
streamFormatter.emitEvent({
|
|
10884
|
-
type:
|
|
10891
|
+
type: "tool_use" /* TOOL_USE */,
|
|
10885
10892
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10886
10893
|
tool_name: event.value.name,
|
|
10887
10894
|
tool_id: event.value.callId,
|
|
@@ -10889,33 +10896,33 @@ async function runNonInteractive2(params) {
|
|
|
10889
10896
|
});
|
|
10890
10897
|
}
|
|
10891
10898
|
toolCallRequests.push(event.value);
|
|
10892
|
-
} else if (event.type ===
|
|
10899
|
+
} else if (event.type === "loop_detected" /* LoopDetected */) {
|
|
10893
10900
|
const message = "Loop detected, stopping execution";
|
|
10894
10901
|
if (streamFormatter) {
|
|
10895
10902
|
streamFormatter.emitEvent({
|
|
10896
|
-
type:
|
|
10903
|
+
type: "error" /* ERROR */,
|
|
10897
10904
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10898
10905
|
severity: "warning",
|
|
10899
10906
|
message
|
|
10900
10907
|
});
|
|
10901
10908
|
}
|
|
10902
10909
|
warnings.push(message);
|
|
10903
|
-
} else if (event.type ===
|
|
10910
|
+
} else if (event.type === "max_session_turns" /* MaxSessionTurns */) {
|
|
10904
10911
|
const message = "Maximum session turns exceeded";
|
|
10905
10912
|
if (streamFormatter) {
|
|
10906
10913
|
streamFormatter.emitEvent({
|
|
10907
|
-
type:
|
|
10914
|
+
type: "error" /* ERROR */,
|
|
10908
10915
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10909
10916
|
severity: "error",
|
|
10910
10917
|
message
|
|
10911
10918
|
});
|
|
10912
10919
|
}
|
|
10913
10920
|
warnings.push(message);
|
|
10914
|
-
} else if (event.type ===
|
|
10921
|
+
} else if (event.type === "error" /* Error */) {
|
|
10915
10922
|
throw event.value.error;
|
|
10916
|
-
} else if (event.type ===
|
|
10923
|
+
} else if (event.type === "agent_execution_stopped" /* AgentExecutionStopped */) {
|
|
10917
10924
|
const stopMessage = `Agent execution stopped: ${event.value.systemMessage?.trim() || event.value.reason}`;
|
|
10918
|
-
if (config.getOutputFormat() ===
|
|
10925
|
+
if (config.getOutputFormat() === "text" /* TEXT */) {
|
|
10919
10926
|
process.stderr.write(`${stopMessage}
|
|
10920
10927
|
`);
|
|
10921
10928
|
}
|
|
@@ -10923,7 +10930,7 @@ async function runNonInteractive2(params) {
|
|
|
10923
10930
|
const metrics = uiTelemetryService.getMetrics();
|
|
10924
10931
|
const durationMs = Date.now() - startTime;
|
|
10925
10932
|
streamFormatter.emitEvent({
|
|
10926
|
-
type:
|
|
10933
|
+
type: "result" /* RESULT */,
|
|
10927
10934
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10928
10935
|
status: "success",
|
|
10929
10936
|
stats: streamFormatter.convertToStreamStats(
|
|
@@ -10931,32 +10938,46 @@ async function runNonInteractive2(params) {
|
|
|
10931
10938
|
durationMs
|
|
10932
10939
|
)
|
|
10933
10940
|
});
|
|
10941
|
+
} else if (config.getOutputFormat() === "json" /* JSON */) {
|
|
10942
|
+
const formatter = new JsonFormatter();
|
|
10943
|
+
const stats = uiTelemetryService.getMetrics();
|
|
10944
|
+
textOutput.write(
|
|
10945
|
+
formatter.format(
|
|
10946
|
+
config.getSessionId(),
|
|
10947
|
+
responseText,
|
|
10948
|
+
stats,
|
|
10949
|
+
void 0,
|
|
10950
|
+
[...warnings, stopMessage]
|
|
10951
|
+
)
|
|
10952
|
+
);
|
|
10953
|
+
} else {
|
|
10954
|
+
textOutput.ensureTrailingNewline();
|
|
10934
10955
|
}
|
|
10935
10956
|
return;
|
|
10936
|
-
} else if (event.type ===
|
|
10957
|
+
} else if (event.type === "agent_execution_blocked" /* AgentExecutionBlocked */) {
|
|
10937
10958
|
const blockMessage = `Agent execution blocked: ${event.value.systemMessage?.trim() || event.value.reason}`;
|
|
10938
|
-
if (config.getOutputFormat() ===
|
|
10959
|
+
if (config.getOutputFormat() === "text" /* TEXT */) {
|
|
10939
10960
|
process.stderr.write(`[WARNING] ${blockMessage}
|
|
10940
10961
|
`);
|
|
10941
10962
|
} else if (streamFormatter) {
|
|
10942
10963
|
streamFormatter.emitEvent({
|
|
10943
|
-
type:
|
|
10964
|
+
type: "error" /* ERROR */,
|
|
10944
10965
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10945
10966
|
severity: "warning",
|
|
10946
10967
|
message: stripAnsi(blockMessage)
|
|
10947
10968
|
});
|
|
10948
10969
|
}
|
|
10949
10970
|
warnings.push(blockMessage);
|
|
10950
|
-
} else if (event.type ===
|
|
10971
|
+
} else if (event.type === "invalid_stream" /* InvalidStream */) {
|
|
10951
10972
|
invalidStreamError = "Invalid stream: The model returned an empty response or malformed tool call.";
|
|
10952
10973
|
if (streamFormatter) {
|
|
10953
10974
|
streamFormatter.emitEvent({
|
|
10954
|
-
type:
|
|
10975
|
+
type: "error" /* ERROR */,
|
|
10955
10976
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10956
10977
|
severity: "error",
|
|
10957
10978
|
message: invalidStreamError
|
|
10958
10979
|
});
|
|
10959
|
-
} else if (config.getOutputFormat() ===
|
|
10980
|
+
} else if (config.getOutputFormat() === "text" /* TEXT */) {
|
|
10960
10981
|
process.stderr.write(`[ERROR] ${invalidStreamError}
|
|
10961
10982
|
`);
|
|
10962
10983
|
}
|
|
@@ -10976,7 +10997,7 @@ async function runNonInteractive2(params) {
|
|
|
10976
10997
|
const requestInfo = completedToolCall.request;
|
|
10977
10998
|
if (streamFormatter) {
|
|
10978
10999
|
streamFormatter.emitEvent({
|
|
10979
|
-
type:
|
|
11000
|
+
type: "tool_result" /* TOOL_RESULT */,
|
|
10980
11001
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10981
11002
|
tool_id: requestInfo.callId,
|
|
10982
11003
|
status: completedToolCall.status === "error" ? "error" : "success",
|
|
@@ -11010,11 +11031,11 @@ async function runNonInteractive2(params) {
|
|
|
11010
11031
|
);
|
|
11011
11032
|
}
|
|
11012
11033
|
const stopExecutionTool = completedToolCalls.find(
|
|
11013
|
-
(tc) => tc.response.errorType ===
|
|
11034
|
+
(tc) => tc.response.errorType === "stop_execution" /* STOP_EXECUTION */
|
|
11014
11035
|
);
|
|
11015
11036
|
if (stopExecutionTool && stopExecutionTool.response.error) {
|
|
11016
11037
|
const stopMessage = `Agent execution stopped: ${stopExecutionTool.response.error.message}`;
|
|
11017
|
-
if (config.getOutputFormat() ===
|
|
11038
|
+
if (config.getOutputFormat() === "text" /* TEXT */) {
|
|
11018
11039
|
process.stderr.write(`${stopMessage}
|
|
11019
11040
|
`);
|
|
11020
11041
|
}
|
|
@@ -11022,7 +11043,7 @@ async function runNonInteractive2(params) {
|
|
|
11022
11043
|
const metrics = uiTelemetryService.getMetrics();
|
|
11023
11044
|
const durationMs = Date.now() - startTime;
|
|
11024
11045
|
streamFormatter.emitEvent({
|
|
11025
|
-
type:
|
|
11046
|
+
type: "result" /* RESULT */,
|
|
11026
11047
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
11027
11048
|
status: "success",
|
|
11028
11049
|
stats: streamFormatter.convertToStreamStats(
|
|
@@ -11030,7 +11051,7 @@ async function runNonInteractive2(params) {
|
|
|
11030
11051
|
durationMs
|
|
11031
11052
|
)
|
|
11032
11053
|
});
|
|
11033
|
-
} else if (config.getOutputFormat() ===
|
|
11054
|
+
} else if (config.getOutputFormat() === "json" /* JSON */) {
|
|
11034
11055
|
const formatter = new JsonFormatter();
|
|
11035
11056
|
const stats = uiTelemetryService.getMetrics();
|
|
11036
11057
|
textOutput.write(
|
|
@@ -11053,12 +11074,12 @@ async function runNonInteractive2(params) {
|
|
|
11053
11074
|
const metrics = uiTelemetryService.getMetrics();
|
|
11054
11075
|
const durationMs = Date.now() - startTime;
|
|
11055
11076
|
streamFormatter.emitEvent({
|
|
11056
|
-
type:
|
|
11077
|
+
type: "result" /* RESULT */,
|
|
11057
11078
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
11058
11079
|
status: invalidStreamError ? "error" : "success",
|
|
11059
11080
|
stats: streamFormatter.convertToStreamStats(metrics, durationMs)
|
|
11060
11081
|
});
|
|
11061
|
-
} else if (config.getOutputFormat() ===
|
|
11082
|
+
} else if (config.getOutputFormat() === "json" /* JSON */) {
|
|
11062
11083
|
const formatter = new JsonFormatter();
|
|
11063
11084
|
const stats = uiTelemetryService.getMetrics();
|
|
11064
11085
|
textOutput.write(
|
|
@@ -11082,7 +11103,7 @@ async function runNonInteractive2(params) {
|
|
|
11082
11103
|
cleanupStdinCancellation();
|
|
11083
11104
|
scheduler?.dispose();
|
|
11084
11105
|
consolePatcher.cleanup();
|
|
11085
|
-
coreEvents.off(
|
|
11106
|
+
coreEvents.off("user-feedback" /* UserFeedback */, handleUserFeedback);
|
|
11086
11107
|
}
|
|
11087
11108
|
if (errorToHandle) {
|
|
11088
11109
|
handleError(errorToHandle, config);
|
|
@@ -13513,12 +13534,12 @@ function toToolCallContent(toolResult) {
|
|
|
13513
13534
|
}
|
|
13514
13535
|
var basicPermissionOptions = [
|
|
13515
13536
|
{
|
|
13516
|
-
optionId:
|
|
13537
|
+
optionId: "proceed_once" /* ProceedOnce */,
|
|
13517
13538
|
name: "Allow",
|
|
13518
13539
|
kind: "allow_once"
|
|
13519
13540
|
},
|
|
13520
13541
|
{
|
|
13521
|
-
optionId:
|
|
13542
|
+
optionId: "cancel" /* Cancel */,
|
|
13522
13543
|
name: "Reject",
|
|
13523
13544
|
kind: "reject_once"
|
|
13524
13545
|
}
|
|
@@ -13530,13 +13551,13 @@ function toPermissionOptions(confirmation, config, enablePermanentToolApproval =
|
|
|
13530
13551
|
switch (confirmation.type) {
|
|
13531
13552
|
case "edit":
|
|
13532
13553
|
options.push({
|
|
13533
|
-
optionId:
|
|
13554
|
+
optionId: "proceed_always" /* ProceedAlways */,
|
|
13534
13555
|
name: "Allow for this session",
|
|
13535
13556
|
kind: "allow_always"
|
|
13536
13557
|
});
|
|
13537
13558
|
if (enablePermanentToolApproval) {
|
|
13538
13559
|
options.push({
|
|
13539
|
-
optionId:
|
|
13560
|
+
optionId: "proceed_always_and_save" /* ProceedAlwaysAndSave */,
|
|
13540
13561
|
name: "Allow for this file in all future sessions",
|
|
13541
13562
|
kind: "allow_always"
|
|
13542
13563
|
});
|
|
@@ -13544,13 +13565,13 @@ function toPermissionOptions(confirmation, config, enablePermanentToolApproval =
|
|
|
13544
13565
|
break;
|
|
13545
13566
|
case "exec":
|
|
13546
13567
|
options.push({
|
|
13547
|
-
optionId:
|
|
13568
|
+
optionId: "proceed_always" /* ProceedAlways */,
|
|
13548
13569
|
name: "Allow for this session",
|
|
13549
13570
|
kind: "allow_always"
|
|
13550
13571
|
});
|
|
13551
13572
|
if (enablePermanentToolApproval) {
|
|
13552
13573
|
options.push({
|
|
13553
|
-
optionId:
|
|
13574
|
+
optionId: "proceed_always_and_save" /* ProceedAlwaysAndSave */,
|
|
13554
13575
|
name: "Allow this command for all future sessions",
|
|
13555
13576
|
kind: "allow_always"
|
|
13556
13577
|
});
|
|
@@ -13559,19 +13580,19 @@ function toPermissionOptions(confirmation, config, enablePermanentToolApproval =
|
|
|
13559
13580
|
case "mcp":
|
|
13560
13581
|
options.push(
|
|
13561
13582
|
{
|
|
13562
|
-
optionId:
|
|
13583
|
+
optionId: "proceed_always_server" /* ProceedAlwaysServer */,
|
|
13563
13584
|
name: "Allow all server tools for this session",
|
|
13564
13585
|
kind: "allow_always"
|
|
13565
13586
|
},
|
|
13566
13587
|
{
|
|
13567
|
-
optionId:
|
|
13588
|
+
optionId: "proceed_always_tool" /* ProceedAlwaysTool */,
|
|
13568
13589
|
name: "Allow tool for this session",
|
|
13569
13590
|
kind: "allow_always"
|
|
13570
13591
|
}
|
|
13571
13592
|
);
|
|
13572
13593
|
if (enablePermanentToolApproval) {
|
|
13573
13594
|
options.push({
|
|
13574
|
-
optionId:
|
|
13595
|
+
optionId: "proceed_always_and_save" /* ProceedAlwaysAndSave */,
|
|
13575
13596
|
name: "Allow tool for all future sessions",
|
|
13576
13597
|
kind: "allow_always"
|
|
13577
13598
|
});
|
|
@@ -13579,13 +13600,13 @@ function toPermissionOptions(confirmation, config, enablePermanentToolApproval =
|
|
|
13579
13600
|
break;
|
|
13580
13601
|
case "info":
|
|
13581
13602
|
options.push({
|
|
13582
|
-
optionId:
|
|
13603
|
+
optionId: "proceed_always" /* ProceedAlways */,
|
|
13583
13604
|
name: "Allow for this session",
|
|
13584
13605
|
kind: "allow_always"
|
|
13585
13606
|
});
|
|
13586
13607
|
if (enablePermanentToolApproval) {
|
|
13587
13608
|
options.push({
|
|
13588
|
-
optionId:
|
|
13609
|
+
optionId: "proceed_always_and_save" /* ProceedAlwaysAndSave */,
|
|
13589
13610
|
name: "Allow for all future sessions",
|
|
13590
13611
|
kind: "allow_always"
|
|
13591
13612
|
});
|
|
@@ -13617,21 +13638,21 @@ function toPermissionOptions(confirmation, config, enablePermanentToolApproval =
|
|
|
13617
13638
|
}
|
|
13618
13639
|
function toAcpToolKind(kind) {
|
|
13619
13640
|
switch (kind) {
|
|
13620
|
-
case
|
|
13621
|
-
case
|
|
13622
|
-
case
|
|
13623
|
-
case
|
|
13624
|
-
case
|
|
13625
|
-
case
|
|
13626
|
-
case
|
|
13627
|
-
case
|
|
13628
|
-
case
|
|
13629
|
-
case
|
|
13641
|
+
case "read" /* Read */:
|
|
13642
|
+
case "edit" /* Edit */:
|
|
13643
|
+
case "execute" /* Execute */:
|
|
13644
|
+
case "search" /* Search */:
|
|
13645
|
+
case "delete" /* Delete */:
|
|
13646
|
+
case "move" /* Move */:
|
|
13647
|
+
case "think" /* Think */:
|
|
13648
|
+
case "fetch" /* Fetch */:
|
|
13649
|
+
case "switch_mode" /* SwitchMode */:
|
|
13650
|
+
case "other" /* Other */:
|
|
13630
13651
|
return kind;
|
|
13631
|
-
case
|
|
13652
|
+
case "agent" /* Agent */:
|
|
13632
13653
|
return "think";
|
|
13633
|
-
case
|
|
13634
|
-
case
|
|
13654
|
+
case "plan" /* Plan */:
|
|
13655
|
+
case "communicate" /* Communicate */:
|
|
13635
13656
|
default:
|
|
13636
13657
|
return "other";
|
|
13637
13658
|
}
|
|
@@ -13639,24 +13660,24 @@ function toAcpToolKind(kind) {
|
|
|
13639
13660
|
function buildAvailableModes(isPlanEnabled) {
|
|
13640
13661
|
const modes = [
|
|
13641
13662
|
{
|
|
13642
|
-
id:
|
|
13663
|
+
id: "default" /* DEFAULT */,
|
|
13643
13664
|
name: "Default",
|
|
13644
13665
|
description: "Prompts for approval"
|
|
13645
13666
|
},
|
|
13646
13667
|
{
|
|
13647
|
-
id:
|
|
13668
|
+
id: "autoEdit" /* AUTO_EDIT */,
|
|
13648
13669
|
name: "Auto Edit",
|
|
13649
13670
|
description: "Auto-approves edit tools"
|
|
13650
13671
|
},
|
|
13651
13672
|
{
|
|
13652
|
-
id:
|
|
13673
|
+
id: "yolo" /* YOLO */,
|
|
13653
13674
|
name: "YOLO",
|
|
13654
13675
|
description: "Auto-approves all tools"
|
|
13655
13676
|
}
|
|
13656
13677
|
];
|
|
13657
13678
|
if (isPlanEnabled) {
|
|
13658
13679
|
modes.push({
|
|
13659
|
-
id:
|
|
13680
|
+
id: "plan" /* PLAN */,
|
|
13660
13681
|
name: "Plan",
|
|
13661
13682
|
description: "Read-only mode"
|
|
13662
13683
|
});
|
|
@@ -13669,7 +13690,7 @@ function buildAvailableModels(config, settings) {
|
|
|
13669
13690
|
const useGemini31 = config.getGemini31LaunchedSync?.() ?? false;
|
|
13670
13691
|
const useGemini31FlashLite = config.getGemini31FlashLiteLaunchedSync?.() ?? false;
|
|
13671
13692
|
const selectedAuthType = settings.merged.security.auth.selectedType;
|
|
13672
|
-
const useCustomToolModel = useGemini31 && selectedAuthType ===
|
|
13693
|
+
const useCustomToolModel = useGemini31 && selectedAuthType === "gemini-api-key" /* USE_GEMINI */;
|
|
13673
13694
|
if (config.getExperimentalDynamicModelConfiguration?.() === true && config.getModelConfigService) {
|
|
13674
13695
|
const options = config.getModelConfigService().getAvailableModelOptions({
|
|
13675
13696
|
useGemini3_1: useGemini31,
|
|
@@ -13758,7 +13779,7 @@ var Session = class {
|
|
|
13758
13779
|
this.connection = connection;
|
|
13759
13780
|
this.settings = settings;
|
|
13760
13781
|
coreEvents.on(
|
|
13761
|
-
|
|
13782
|
+
"approval-mode-changed" /* ApprovalModeChanged */,
|
|
13762
13783
|
this.handleApprovalModeChanged
|
|
13763
13784
|
);
|
|
13764
13785
|
}
|
|
@@ -13781,7 +13802,7 @@ var Session = class {
|
|
|
13781
13802
|
};
|
|
13782
13803
|
dispose() {
|
|
13783
13804
|
coreEvents.off(
|
|
13784
|
-
|
|
13805
|
+
"approval-mode-changed" /* ApprovalModeChanged */,
|
|
13785
13806
|
this.handleApprovalModeChanged
|
|
13786
13807
|
);
|
|
13787
13808
|
}
|
|
@@ -13869,7 +13890,7 @@ ${thought.description}`;
|
|
|
13869
13890
|
await this.sendUpdate({
|
|
13870
13891
|
sessionUpdate: "tool_call",
|
|
13871
13892
|
toolCallId: toolCall.id,
|
|
13872
|
-
status: toolCall.status ===
|
|
13893
|
+
status: toolCall.status === "success" /* Success */ ? "completed" : "failed",
|
|
13873
13894
|
title: toolCall.displayName || toolCall.name,
|
|
13874
13895
|
content: toolCallContent,
|
|
13875
13896
|
kind: tool ? toAcpToolKind(tool.kind) : "other"
|
|
@@ -13961,7 +13982,7 @@ ${thought.description}`;
|
|
|
13961
13982
|
return { stopReason: "cancelled" };
|
|
13962
13983
|
}
|
|
13963
13984
|
switch (event.type) {
|
|
13964
|
-
case
|
|
13985
|
+
case "content" /* Content */: {
|
|
13965
13986
|
const content = {
|
|
13966
13987
|
type: "text",
|
|
13967
13988
|
text: event.value
|
|
@@ -13972,7 +13993,7 @@ ${thought.description}`;
|
|
|
13972
13993
|
});
|
|
13973
13994
|
break;
|
|
13974
13995
|
}
|
|
13975
|
-
case
|
|
13996
|
+
case "thought" /* Thought */: {
|
|
13976
13997
|
const thoughtText = `**${event.value.subject}**
|
|
13977
13998
|
${event.value.description}`;
|
|
13978
13999
|
await this.sendUpdate({
|
|
@@ -13981,10 +14002,10 @@ ${event.value.description}`;
|
|
|
13981
14002
|
});
|
|
13982
14003
|
break;
|
|
13983
14004
|
}
|
|
13984
|
-
case
|
|
14005
|
+
case "tool_call_request" /* ToolCallRequest */:
|
|
13985
14006
|
toolCallRequests.push(event.value);
|
|
13986
14007
|
break;
|
|
13987
|
-
case
|
|
14008
|
+
case "finished" /* Finished */: {
|
|
13988
14009
|
const usage2 = event.value.usageMetadata;
|
|
13989
14010
|
if (usage2) {
|
|
13990
14011
|
turnInputTokens = usage2.promptTokenCount ?? turnInputTokens;
|
|
@@ -13992,19 +14013,19 @@ ${event.value.description}`;
|
|
|
13992
14013
|
}
|
|
13993
14014
|
break;
|
|
13994
14015
|
}
|
|
13995
|
-
case
|
|
14016
|
+
case "model_info" /* ModelInfo */:
|
|
13996
14017
|
turnModelId = event.value;
|
|
13997
14018
|
break;
|
|
13998
|
-
case
|
|
14019
|
+
case "max_session_turns" /* MaxSessionTurns */:
|
|
13999
14020
|
stopReason = "max_turn_requests";
|
|
14000
14021
|
break;
|
|
14001
|
-
case
|
|
14022
|
+
case "loop_detected" /* LoopDetected */:
|
|
14002
14023
|
stopReason = "max_turn_requests";
|
|
14003
14024
|
break;
|
|
14004
|
-
case
|
|
14025
|
+
case "context_window_will_overflow" /* ContextWindowWillOverflow */:
|
|
14005
14026
|
stopReason = "max_tokens";
|
|
14006
14027
|
break;
|
|
14007
|
-
case
|
|
14028
|
+
case "error" /* Error */: {
|
|
14008
14029
|
const parseResult = StructuredErrorSchema.safeParse(
|
|
14009
14030
|
event.value.error
|
|
14010
14031
|
);
|
|
@@ -14193,12 +14214,6 @@ ${event.value.description}`;
|
|
|
14193
14214
|
const invocation = tool.build(args);
|
|
14194
14215
|
const displayTitle = typeof invocation.getDisplayTitle === "function" ? invocation.getDisplayTitle() : invocation.getDescription();
|
|
14195
14216
|
const explanation = typeof invocation.getExplanation === "function" ? invocation.getExplanation() : "";
|
|
14196
|
-
if (explanation) {
|
|
14197
|
-
await this.sendUpdate({
|
|
14198
|
-
sessionUpdate: "agent_thought_chunk",
|
|
14199
|
-
content: { type: "text", text: explanation }
|
|
14200
|
-
});
|
|
14201
|
-
}
|
|
14202
14217
|
const confirmationDetails = await invocation.shouldConfirmExecute(abortSignal);
|
|
14203
14218
|
if (confirmationDetails) {
|
|
14204
14219
|
const content2 = [];
|
|
@@ -14213,6 +14228,12 @@ ${event.value.description}`;
|
|
|
14213
14228
|
}
|
|
14214
14229
|
});
|
|
14215
14230
|
}
|
|
14231
|
+
if (content2.length === 0 && explanation) {
|
|
14232
|
+
content2.push({
|
|
14233
|
+
type: "content",
|
|
14234
|
+
content: { type: "text", text: explanation }
|
|
14235
|
+
});
|
|
14236
|
+
}
|
|
14216
14237
|
const params = {
|
|
14217
14238
|
sessionId: this.id,
|
|
14218
14239
|
options: toPermissionOptions(
|
|
@@ -14232,7 +14253,7 @@ ${event.value.description}`;
|
|
|
14232
14253
|
const output = RequestPermissionResponseSchema.parse(
|
|
14233
14254
|
await this.connection.requestPermission(params)
|
|
14234
14255
|
);
|
|
14235
|
-
const outcome = output.outcome.outcome === "cancelled" ?
|
|
14256
|
+
const outcome = output.outcome.outcome === "cancelled" ? "cancel" /* Cancel */ : external_exports.nativeEnum(ToolConfirmationOutcome).parse(output.outcome.optionId);
|
|
14236
14257
|
await confirmationDetails.onConfirm(outcome);
|
|
14237
14258
|
await updatePolicy(
|
|
14238
14259
|
tool,
|
|
@@ -14243,16 +14264,16 @@ ${event.value.description}`;
|
|
|
14243
14264
|
invocation
|
|
14244
14265
|
);
|
|
14245
14266
|
switch (outcome) {
|
|
14246
|
-
case
|
|
14267
|
+
case "cancel" /* Cancel */:
|
|
14247
14268
|
return errorResponse(
|
|
14248
14269
|
new Error(`Tool "${fc.name}" was canceled by the user.`)
|
|
14249
14270
|
);
|
|
14250
|
-
case
|
|
14251
|
-
case
|
|
14252
|
-
case
|
|
14253
|
-
case
|
|
14254
|
-
case
|
|
14255
|
-
case
|
|
14271
|
+
case "proceed_once" /* ProceedOnce */:
|
|
14272
|
+
case "proceed_always" /* ProceedAlways */:
|
|
14273
|
+
case "proceed_always_and_save" /* ProceedAlwaysAndSave */:
|
|
14274
|
+
case "proceed_always_server" /* ProceedAlwaysServer */:
|
|
14275
|
+
case "proceed_always_tool" /* ProceedAlwaysTool */:
|
|
14276
|
+
case "modify_with_editor" /* ModifyWithEditor */:
|
|
14256
14277
|
break;
|
|
14257
14278
|
default: {
|
|
14258
14279
|
const resultOutcome = outcome;
|
|
@@ -14261,6 +14282,12 @@ ${event.value.description}`;
|
|
|
14261
14282
|
}
|
|
14262
14283
|
} else {
|
|
14263
14284
|
const content2 = [];
|
|
14285
|
+
if (explanation) {
|
|
14286
|
+
content2.push({
|
|
14287
|
+
type: "content",
|
|
14288
|
+
content: { type: "text", text: explanation }
|
|
14289
|
+
});
|
|
14290
|
+
}
|
|
14264
14291
|
await this.sendUpdate({
|
|
14265
14292
|
sessionUpdate: "tool_call",
|
|
14266
14293
|
toolCallId: callId,
|
|
@@ -14300,7 +14327,7 @@ ${event.value.description}`;
|
|
|
14300
14327
|
);
|
|
14301
14328
|
this.chat.recordCompletedToolCalls(this.context.config.getActiveModel(), [
|
|
14302
14329
|
{
|
|
14303
|
-
status:
|
|
14330
|
+
status: "success" /* Success */,
|
|
14304
14331
|
request: {
|
|
14305
14332
|
callId,
|
|
14306
14333
|
name: fc.name,
|
|
@@ -14345,7 +14372,7 @@ ${event.value.description}`;
|
|
|
14345
14372
|
});
|
|
14346
14373
|
this.chat.recordCompletedToolCalls(this.context.config.getActiveModel(), [
|
|
14347
14374
|
{
|
|
14348
|
-
status:
|
|
14375
|
+
status: "error" /* Error */,
|
|
14349
14376
|
request: {
|
|
14350
14377
|
callId,
|
|
14351
14378
|
name: fc.name,
|
|
@@ -14460,12 +14487,12 @@ ${event.value.description}`;
|
|
|
14460
14487
|
sessionId: this.id,
|
|
14461
14488
|
options: [
|
|
14462
14489
|
{
|
|
14463
|
-
optionId:
|
|
14490
|
+
optionId: "proceed_once" /* ProceedOnce */,
|
|
14464
14491
|
name: "Allow once",
|
|
14465
14492
|
kind: "allow_once"
|
|
14466
14493
|
},
|
|
14467
14494
|
{
|
|
14468
|
-
optionId:
|
|
14495
|
+
optionId: "cancel" /* Cancel */,
|
|
14469
14496
|
name: "Deny",
|
|
14470
14497
|
kind: "reject_once"
|
|
14471
14498
|
}
|
|
@@ -14490,8 +14517,8 @@ ${event.value.description}`;
|
|
|
14490
14517
|
const output = RequestPermissionResponseSchema.parse(
|
|
14491
14518
|
await this.connection.requestPermission(params)
|
|
14492
14519
|
);
|
|
14493
|
-
const outcome = output.outcome.outcome === "cancelled" ?
|
|
14494
|
-
if (outcome ===
|
|
14520
|
+
const outcome = output.outcome.outcome === "cancelled" ? "cancel" /* Cancel */ : external_exports.nativeEnum(ToolConfirmationOutcome).parse(output.outcome.optionId);
|
|
14521
|
+
if (outcome === "proceed_once" /* ProceedOnce */) {
|
|
14495
14522
|
this.context.config.getWorkspaceContext().addReadOnlyPath(absolutePath);
|
|
14496
14523
|
validationError = null;
|
|
14497
14524
|
} else {
|
|
@@ -14923,7 +14950,7 @@ var AcpSessionManager = class {
|
|
|
14923
14950
|
mcpServers,
|
|
14924
14951
|
loadedSettings
|
|
14925
14952
|
);
|
|
14926
|
-
const authType = loadedSettings.merged.security.auth.selectedType ||
|
|
14953
|
+
const authType = loadedSettings.merged.security.auth.selectedType || "gemini-api-key" /* USE_GEMINI */;
|
|
14927
14954
|
let isAuthenticated = false;
|
|
14928
14955
|
let authErrorMessage = "";
|
|
14929
14956
|
try {
|
|
@@ -14935,7 +14962,7 @@ var AcpSessionManager = class {
|
|
|
14935
14962
|
);
|
|
14936
14963
|
isAuthenticated = true;
|
|
14937
14964
|
const contentGeneratorConfig = config.getContentGeneratorConfig();
|
|
14938
|
-
if (authType ===
|
|
14965
|
+
if (authType === "gemini-api-key" /* USE_GEMINI */ && (!contentGeneratorConfig || !contentGeneratorConfig.apiKey)) {
|
|
14939
14966
|
isAuthenticated = false;
|
|
14940
14967
|
authErrorMessage = "Gemini API key is missing or not configured.";
|
|
14941
14968
|
}
|
|
@@ -15145,12 +15172,12 @@ var GeminiAgent = class {
|
|
|
15145
15172
|
}
|
|
15146
15173
|
const authMethods = [
|
|
15147
15174
|
{
|
|
15148
|
-
id:
|
|
15175
|
+
id: "oauth-personal" /* LOGIN_WITH_GOOGLE */,
|
|
15149
15176
|
name: "Log in with Google",
|
|
15150
15177
|
description: "Log in with your Google account"
|
|
15151
15178
|
},
|
|
15152
15179
|
{
|
|
15153
|
-
id:
|
|
15180
|
+
id: "gemini-api-key" /* USE_GEMINI */,
|
|
15154
15181
|
name: "Gemini API key",
|
|
15155
15182
|
description: "Use an API key with Gemini Developer API",
|
|
15156
15183
|
_meta: {
|
|
@@ -15160,12 +15187,12 @@ var GeminiAgent = class {
|
|
|
15160
15187
|
}
|
|
15161
15188
|
},
|
|
15162
15189
|
{
|
|
15163
|
-
id:
|
|
15190
|
+
id: "vertex-ai" /* USE_VERTEX_AI */,
|
|
15164
15191
|
name: "Vertex AI",
|
|
15165
15192
|
description: "Use an API key with Vertex AI GenAI API"
|
|
15166
15193
|
},
|
|
15167
15194
|
{
|
|
15168
|
-
id:
|
|
15195
|
+
id: "gateway" /* GATEWAY */,
|
|
15169
15196
|
name: "AI API Gateway",
|
|
15170
15197
|
description: "Use a custom AI API Gateway",
|
|
15171
15198
|
_meta: {
|
|
@@ -15338,7 +15365,7 @@ async function validateNonInteractiveAuth(configuredAuthType, useExternalAuth, n
|
|
|
15338
15365
|
}
|
|
15339
15366
|
return authType;
|
|
15340
15367
|
} catch (error) {
|
|
15341
|
-
if (nonInteractiveConfig.getOutputFormat() ===
|
|
15368
|
+
if (nonInteractiveConfig.getOutputFormat() === "json" /* JSON */) {
|
|
15342
15369
|
handleError(
|
|
15343
15370
|
error instanceof Error ? error : new Error(String(error)),
|
|
15344
15371
|
nonInteractiveConfig,
|
|
@@ -15534,10 +15561,10 @@ var SlashCommandConflictHandler = class {
|
|
|
15534
15561
|
this.handleConflicts = this.handleConflicts.bind(this);
|
|
15535
15562
|
}
|
|
15536
15563
|
start() {
|
|
15537
|
-
coreEvents.on(
|
|
15564
|
+
coreEvents.on("slash-command-conflicts" /* SlashCommandConflicts */, this.handleConflicts);
|
|
15538
15565
|
}
|
|
15539
15566
|
stop() {
|
|
15540
|
-
coreEvents.off(
|
|
15567
|
+
coreEvents.off("slash-command-conflicts" /* SlashCommandConflicts */, this.handleConflicts);
|
|
15541
15568
|
if (this.flushTimeout) {
|
|
15542
15569
|
clearTimeout(this.flushTimeout);
|
|
15543
15570
|
this.flushTimeout = null;
|
|
@@ -15720,13 +15747,69 @@ ${reason.stack}` : ""}`;
|
|
|
15720
15747
|
}
|
|
15721
15748
|
});
|
|
15722
15749
|
}
|
|
15723
|
-
async function resolveSessionId(resumeArg, sessionIdArg) {
|
|
15724
|
-
if (!resumeArg && !sessionIdArg) {
|
|
15750
|
+
async function resolveSessionId(resumeArg, sessionIdArg, sessionFileArg) {
|
|
15751
|
+
if (!resumeArg && !sessionIdArg && !sessionFileArg) {
|
|
15725
15752
|
return { sessionId: createSessionId() };
|
|
15726
15753
|
}
|
|
15727
15754
|
const storage = new Storage(process.cwd());
|
|
15728
15755
|
await storage.initialize();
|
|
15729
15756
|
const sessionSelector = new SessionSelector(storage);
|
|
15757
|
+
if (sessionFileArg) {
|
|
15758
|
+
try {
|
|
15759
|
+
const sessionData = await loadConversationRecord(sessionFileArg);
|
|
15760
|
+
if (!sessionData) {
|
|
15761
|
+
throw new Error(`File not found or invalid format: ${sessionFileArg}`);
|
|
15762
|
+
}
|
|
15763
|
+
const now = Date.now();
|
|
15764
|
+
const isoNow = new Date(now).toISOString();
|
|
15765
|
+
sessionData.messages = (sessionData.messages || []).filter(
|
|
15766
|
+
(m) => typeof m === "object" && m !== null && (m.type === "user" || m.type === "gemini") && m.content !== void 0
|
|
15767
|
+
);
|
|
15768
|
+
sessionData.messages.unshift({
|
|
15769
|
+
id: `import-${now}`,
|
|
15770
|
+
type: "info",
|
|
15771
|
+
content: `Imported session from ${sessionFileArg}`,
|
|
15772
|
+
timestamp: isoNow
|
|
15773
|
+
});
|
|
15774
|
+
const newSessionId = createSessionId();
|
|
15775
|
+
sessionData.sessionId = newSessionId;
|
|
15776
|
+
sessionData.projectHash = getProjectHash(storage.getProjectRoot());
|
|
15777
|
+
sessionData.startTime = isoNow;
|
|
15778
|
+
sessionData.lastUpdated = isoNow;
|
|
15779
|
+
const chatsDir = path15.join(storage.getProjectTempDir(), "chats");
|
|
15780
|
+
const newSessionPath = path15.join(
|
|
15781
|
+
chatsDir,
|
|
15782
|
+
`session-${now}-${newSessionId.slice(0, 8)}.jsonl`
|
|
15783
|
+
);
|
|
15784
|
+
const { messages: _messages, ...initialMetadata } = sessionData;
|
|
15785
|
+
const lines = [JSON.stringify(initialMetadata)];
|
|
15786
|
+
if (sessionData.messages) {
|
|
15787
|
+
for (const msg of sessionData.messages) {
|
|
15788
|
+
lines.push(JSON.stringify(msg));
|
|
15789
|
+
}
|
|
15790
|
+
}
|
|
15791
|
+
await fsPromises.mkdir(chatsDir, { recursive: true });
|
|
15792
|
+
await fsPromises.writeFile(
|
|
15793
|
+
newSessionPath,
|
|
15794
|
+
lines.join("\n") + "\n",
|
|
15795
|
+
"utf-8"
|
|
15796
|
+
);
|
|
15797
|
+
return {
|
|
15798
|
+
sessionId: newSessionId,
|
|
15799
|
+
resumedSessionData: {
|
|
15800
|
+
conversation: sessionData,
|
|
15801
|
+
filePath: newSessionPath
|
|
15802
|
+
}
|
|
15803
|
+
};
|
|
15804
|
+
} catch (error) {
|
|
15805
|
+
coreEvents.emitFeedback(
|
|
15806
|
+
"error",
|
|
15807
|
+
`Error importing session from file: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
15808
|
+
);
|
|
15809
|
+
await runExitCleanup();
|
|
15810
|
+
process.exit(ExitCodes.FATAL_INPUT_ERROR);
|
|
15811
|
+
}
|
|
15812
|
+
}
|
|
15730
15813
|
if (sessionIdArg) {
|
|
15731
15814
|
if (await sessionSelector.sessionExists(sessionIdArg)) {
|
|
15732
15815
|
coreEvents.emitFeedback(
|
|
@@ -15748,8 +15831,10 @@ async function resolveSessionId(resumeArg, sessionIdArg) {
|
|
|
15748
15831
|
};
|
|
15749
15832
|
} catch (error) {
|
|
15750
15833
|
if (error instanceof SessionError && error.code === "NO_SESSIONS_FOUND") {
|
|
15751
|
-
|
|
15752
|
-
|
|
15834
|
+
if (resumeArg === RESUME_LATEST) {
|
|
15835
|
+
coreEvents.emitFeedback("warning", error.message);
|
|
15836
|
+
return { sessionId: createSessionId() };
|
|
15837
|
+
}
|
|
15753
15838
|
}
|
|
15754
15839
|
coreEvents.emitFeedback(
|
|
15755
15840
|
"error",
|
|
@@ -15760,7 +15845,7 @@ async function resolveSessionId(resumeArg, sessionIdArg) {
|
|
|
15760
15845
|
}
|
|
15761
15846
|
}
|
|
15762
15847
|
async function startInteractiveUI(config, settings, startupWarnings, workspaceRoot = process.cwd(), resumedSessionData, initializationResult) {
|
|
15763
|
-
const { startInteractiveUI: doStartUI } = await import("./interactiveCli-
|
|
15848
|
+
const { startInteractiveUI: doStartUI } = await import("./interactiveCli-SME5QTEN.js");
|
|
15764
15849
|
await doStartUI(
|
|
15765
15850
|
config,
|
|
15766
15851
|
settings,
|
|
@@ -15823,7 +15908,8 @@ async function main() {
|
|
|
15823
15908
|
const argv = await argvPromise;
|
|
15824
15909
|
const { sessionId, resumedSessionData } = await resolveSessionId(
|
|
15825
15910
|
argv.resume,
|
|
15826
|
-
argv.sessionId
|
|
15911
|
+
argv.sessionId,
|
|
15912
|
+
argv.sessionFile
|
|
15827
15913
|
);
|
|
15828
15914
|
if (argv.allowedTools && argv.allowedTools.length > 0 || settings.merged.tools?.allowed && settings.merged.tools.allowed.length > 0) {
|
|
15829
15915
|
coreEvents.emitFeedback(
|
|
@@ -15862,12 +15948,12 @@ async function main() {
|
|
|
15862
15948
|
dns.setDefaultResultOrder(
|
|
15863
15949
|
validateDnsResolutionOrder(settings.merged.advanced.dnsResolutionOrder)
|
|
15864
15950
|
);
|
|
15865
|
-
if (!settings.merged.security.auth.selectedType || settings.merged.security.auth.selectedType ===
|
|
15951
|
+
if (!settings.merged.security.auth.selectedType || settings.merged.security.auth.selectedType === "cloud-shell" /* LEGACY_CLOUD_SHELL */) {
|
|
15866
15952
|
if (process.env["CLOUD_SHELL"] === "true" || process.env["GEMINI_CLI_USE_COMPUTE_ADC"] === "true") {
|
|
15867
15953
|
settings.setValue(
|
|
15868
15954
|
"User" /* User */,
|
|
15869
15955
|
"security.auth.selectedType",
|
|
15870
|
-
|
|
15956
|
+
"compute-default-credentials" /* COMPUTE_ADC */
|
|
15871
15957
|
);
|
|
15872
15958
|
}
|
|
15873
15959
|
}
|
|
@@ -15967,7 +16053,7 @@ ${finalArgs[promptIndex + 1]}`;
|
|
|
15967
16053
|
await config.storage.initialize();
|
|
15968
16054
|
adminControlsListner.setConfig(config);
|
|
15969
16055
|
if (config.isInteractive() && settings.merged.general.devtools) {
|
|
15970
|
-
const { setupInitialActivityLogger } = await import("./devtoolsService-
|
|
16056
|
+
const { setupInitialActivityLogger } = await import("./devtoolsService-7KZDSYEF.js");
|
|
15971
16057
|
setupInitialActivityLogger(config);
|
|
15972
16058
|
}
|
|
15973
16059
|
registerTelemetryConfig(config);
|
|
@@ -15975,7 +16061,7 @@ ${finalArgs[promptIndex + 1]}`;
|
|
|
15975
16061
|
const messageBus = config.getMessageBus();
|
|
15976
16062
|
createPolicyUpdater2(policyEngine, messageBus, config.storage);
|
|
15977
16063
|
registerCleanup(async () => {
|
|
15978
|
-
await config.getHookSystem()?.fireSessionEndEvent(
|
|
16064
|
+
await config.getHookSystem()?.fireSessionEndEvent("exit" /* Exit */);
|
|
15979
16065
|
});
|
|
15980
16066
|
if (!config.getAcpMode()) {
|
|
15981
16067
|
registerCleanup(consolePatcher.cleanup);
|
|
@@ -16026,7 +16112,7 @@ ${finalArgs[promptIndex + 1]}`;
|
|
|
16026
16112
|
const initAppHandle = startupProfiler.start("initialize_app");
|
|
16027
16113
|
const initializationResult = await initializeApp(config, settings);
|
|
16028
16114
|
initAppHandle?.end();
|
|
16029
|
-
import("./liteRtServerManager-
|
|
16115
|
+
import("./liteRtServerManager-2QD4R3A3.js").then(({ LiteRtServerManager }) => {
|
|
16030
16116
|
const mergedGemma = settings.merged.experimental?.gemmaModelRouter;
|
|
16031
16117
|
if (!mergedGemma) return;
|
|
16032
16118
|
const userGemma = settings.forScope("User" /* User */).settings.experimental?.gemmaModelRouter;
|
|
@@ -16036,7 +16122,7 @@ ${finalArgs[promptIndex + 1]}`;
|
|
|
16036
16122
|
autoStartServer: userGemma?.autoStartServer
|
|
16037
16123
|
});
|
|
16038
16124
|
}).catch((e) => debugLogger.warn("LiteRT auto-start import failed:", e));
|
|
16039
|
-
if (settings.merged.security.auth.selectedType ===
|
|
16125
|
+
if (settings.merged.security.auth.selectedType === "oauth-personal" /* LOGIN_WITH_GOOGLE */ && config.isBrowserLaunchSuppressed()) {
|
|
16040
16126
|
await getOauthClient(settings.merged.security.auth.selectedType, config);
|
|
16041
16127
|
}
|
|
16042
16128
|
if (config.getAcpMode()) {
|
|
@@ -16052,7 +16138,7 @@ ${finalArgs[promptIndex + 1]}`;
|
|
|
16052
16138
|
...rawStartupWarnings.map((message) => ({
|
|
16053
16139
|
id: `startup-${createHash2("sha256").update(message).digest("hex").substring(0, 16)}`,
|
|
16054
16140
|
message,
|
|
16055
|
-
priority:
|
|
16141
|
+
priority: "high" /* High */
|
|
16056
16142
|
})),
|
|
16057
16143
|
...await getUserStartupWarnings(settings.merged, void 0, {
|
|
16058
16144
|
isAlternateBuffer: useAlternateBuffer
|
|
@@ -16089,7 +16175,7 @@ ${finalArgs[promptIndex + 1]}`;
|
|
|
16089
16175
|
${input}` : stdinData;
|
|
16090
16176
|
}
|
|
16091
16177
|
}
|
|
16092
|
-
const sessionStartSource = resumedSessionData ?
|
|
16178
|
+
const sessionStartSource = resumedSessionData ? "resume" /* Resume */ : "startup" /* Startup */;
|
|
16093
16179
|
const hookSystem = config?.getHookSystem();
|
|
16094
16180
|
if (hookSystem) {
|
|
16095
16181
|
const result = await hookSystem.fireSessionStartEvent(sessionStartSource);
|
|
@@ -16146,8 +16232,8 @@ ${input}` : wrappedContext;
|
|
|
16146
16232
|
}
|
|
16147
16233
|
}
|
|
16148
16234
|
function initializeOutputListenersAndFlush(config) {
|
|
16149
|
-
if (coreEvents.listenerCount(
|
|
16150
|
-
coreEvents.on(
|
|
16235
|
+
if (coreEvents.listenerCount("output" /* Output */) === 0) {
|
|
16236
|
+
coreEvents.on("output" /* Output */, (payload) => {
|
|
16151
16237
|
if (payload.isStderr) {
|
|
16152
16238
|
writeToStderr(payload.chunk, payload.encoding);
|
|
16153
16239
|
} else {
|
|
@@ -16155,8 +16241,8 @@ function initializeOutputListenersAndFlush(config) {
|
|
|
16155
16241
|
}
|
|
16156
16242
|
});
|
|
16157
16243
|
}
|
|
16158
|
-
if (coreEvents.listenerCount(
|
|
16159
|
-
coreEvents.on(
|
|
16244
|
+
if (coreEvents.listenerCount("console-log" /* ConsoleLog */) === 0) {
|
|
16245
|
+
coreEvents.on("console-log" /* ConsoleLog */, (payload) => {
|
|
16160
16246
|
if (payload.type === "error" || payload.type === "warn") {
|
|
16161
16247
|
writeToStderr(payload.content + "\n");
|
|
16162
16248
|
} else {
|
|
@@ -16164,8 +16250,8 @@ function initializeOutputListenersAndFlush(config) {
|
|
|
16164
16250
|
}
|
|
16165
16251
|
});
|
|
16166
16252
|
}
|
|
16167
|
-
if (coreEvents.listenerCount(
|
|
16168
|
-
coreEvents.on(
|
|
16253
|
+
if (coreEvents.listenerCount("user-feedback" /* UserFeedback */) === 0) {
|
|
16254
|
+
coreEvents.on("user-feedback" /* UserFeedback */, (payload) => {
|
|
16169
16255
|
writeToStderr(payload.message + "\n");
|
|
16170
16256
|
});
|
|
16171
16257
|
}
|
|
@@ -16173,7 +16259,7 @@ function initializeOutputListenersAndFlush(config) {
|
|
|
16173
16259
|
const forceToStderr = outputFormat === "json";
|
|
16174
16260
|
coreEvents.drainBacklogs(
|
|
16175
16261
|
(event, args) => {
|
|
16176
|
-
if (forceToStderr && event ===
|
|
16262
|
+
if (forceToStderr && event === "output" /* Output */) {
|
|
16177
16263
|
const payload = args[0];
|
|
16178
16264
|
if (!payload.isStderr) {
|
|
16179
16265
|
return {
|