@google/gemini-cli 0.40.0-preview.2 → 0.40.0-preview.4
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-3GU3LF3I.js → chunk-4XVBQQNJ.js} +181 -16
- package/bundle/{chunk-PLUWJHZZ.js → chunk-547AWTTH.js} +238 -61
- package/bundle/{chunk-EFCQXWIF.js → chunk-63PTTRTA.js} +3 -3
- package/bundle/{chunk-IMEC72NS.js → chunk-ATGIEBEB.js} +1 -1
- package/bundle/{chunk-WL5MCPV2.js → chunk-BV2W6YE6.js} +2 -2
- package/bundle/{chunk-QK7UWGBN.js → chunk-CIO3GUGQ.js} +1382 -1083
- package/bundle/{chunk-HV36F4CL.js → chunk-CJQVVQSH.js} +134 -354
- package/bundle/{chunk-VCGILCZV.js → chunk-F73F75XM.js} +16 -0
- package/bundle/{chunk-TDW6FM3A.js → chunk-G356GKHH.js} +1 -1
- package/bundle/{chunk-4IJPDKI6.js → chunk-H4NQBTXN.js} +146 -364
- package/bundle/{chunk-GXRQOXQF.js → chunk-H7F2VOIJ.js} +178 -14
- package/bundle/chunk-HF7X35D3.js +80012 -0
- package/bundle/{chunk-WHIWQCI5.js → chunk-HGFADN5A.js} +1 -1
- package/bundle/{chunk-NO7STVVM.js → chunk-KG7ZFMJL.js} +1413 -1089
- package/bundle/{chunk-33ANPP4S.js → chunk-LMVZLINC.js} +3 -3
- package/bundle/chunk-LODNDE3S.js +17505 -0
- package/bundle/{chunk-IUVLJUOL.js → chunk-LVHUYMBU.js} +2 -2
- package/bundle/{chunk-NIVCRM5L.js → chunk-M76FWZ5L.js} +134 -354
- package/bundle/{chunk-RM43GNQQ.js → chunk-NV6UCR4K.js} +7711 -12909
- package/bundle/{chunk-MUGUV6RZ.js → chunk-PRZIW6SM.js} +2 -2
- package/bundle/chunk-RENFZ63F.js +351149 -0
- package/bundle/chunk-SYPUOR3U.js +156 -0
- package/bundle/{chunk-2RHFUIH4.js → chunk-UHHRGNIO.js} +16 -0
- package/bundle/chunk-VQ7N6NVX.js +1571 -0
- package/bundle/{chunk-UBXB5AEJ.js → chunk-WSTHO4WR.js} +3 -3
- package/bundle/chunk-ZQNX6OWU.js +118 -0
- package/bundle/{cleanup-A7WXWAMI.js → cleanup-4EFDM2N7.js} +3 -3
- package/bundle/{cleanup-EWPIME2M.js → cleanup-4RRVO4GO.js} +3 -3
- package/bundle/{cleanup-IPLJJT5S.js → cleanup-DNS7PXYC.js} +3 -3
- package/bundle/cleanup-DXHNV2J6.js +33 -0
- package/bundle/{core-VCDK23ZC.js → core-WQSFCPEO.js} +28 -2
- package/bundle/{devtoolsService-6Y6YER6T.js → devtoolsService-JWET4G6G.js} +3 -3
- package/bundle/{devtoolsService-B5VVZ752.js → devtoolsService-LPEBYJVD.js} +3 -3
- package/bundle/{devtoolsService-2JXSALRU.js → devtoolsService-S2LBUUZU.js} +5 -4
- package/bundle/devtoolsService-YCRNWWXE.js +852 -0
- package/bundle/{dist-UIXQETMC.js → dist-ANTOB3YW.js} +28 -2
- package/bundle/{core-BQT6T3CH.js → dist-RIVCP5ZD.js} +28 -2
- package/bundle/dist-UH565MTG.js +2046 -0
- package/bundle/docs/cli/cli-reference.md +1 -0
- package/bundle/docs/cli/trusted-folders.md +28 -0
- package/bundle/docs/reference/configuration.md +14 -0
- package/bundle/{gemini-ID44Z5SV.js → gemini-27FQ5BI4.js} +66 -22
- package/bundle/{gemini-54LH6RUH.js → gemini-57EC2ZF7.js} +241 -182
- package/bundle/{gemini-44W2QEZI.js → gemini-JAZVYRDD.js} +64 -21
- package/bundle/gemini-TQZRS37Q.js +16087 -0
- package/bundle/gemini.js +3 -3
- package/bundle/{interactiveCli-5MTJDFYC.js → interactiveCli-E35R6QQC.js} +17 -167
- package/bundle/{interactiveCli-JFBPGMNM.js → interactiveCli-FPHSBRV3.js} +30 -179
- package/bundle/{interactiveCli-5B3X6RNB.js → interactiveCli-L3EK4XEX.js} +300 -432
- package/bundle/interactiveCli-MVHR4VV7.js +34448 -0
- package/bundle/{liteRtServerManager-76V63PRJ.js → liteRtServerManager-LXEAYAUP.js} +4 -4
- package/bundle/{liteRtServerManager-WQMDPACQ.js → liteRtServerManager-ORSW3R4F.js} +4 -4
- package/bundle/{liteRtServerManager-6GJWEP5W.js → liteRtServerManager-PI4ZNFB5.js} +4 -4
- package/bundle/liteRtServerManager-YYXO5Q3I.js +65 -0
- package/bundle/{memoryDiscovery-RYHYLAPJ.js → memoryDiscovery-CZURD35O.js} +1 -1
- package/bundle/{memoryDiscovery-HWEYBJE7.js → memoryDiscovery-GZLXKRGB.js} +1 -1
- package/bundle/node_modules/@google/gemini-cli-devtools/package.json +1 -1
- package/bundle/{oauth2-provider-EX6SQEZP.js → oauth2-provider-B3NTBNAM.js} +2 -2
- package/bundle/{oauth2-provider-ZF52AWQY.js → oauth2-provider-ENF2D4Q7.js} +39 -73
- package/bundle/{oauth2-provider-JCKLNKRV.js → oauth2-provider-I3G773GE.js} +2 -2
- package/bundle/oauth2-provider-WTF7AHQ2.js +237 -0
- package/bundle/{start-CYDJTOAP.js → start-CRIFZ3SW.js} +6 -6
- package/bundle/{start-SHOUHW3Y.js → start-KVFKS3IT.js} +6 -6
- package/bundle/{start-B6EMQCH5.js → start-OTLGMCNH.js} +6 -6
- package/bundle/start-S3REI3X2.js +18 -0
- package/package.json +1 -1
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
initializeApp,
|
|
25
25
|
installSkill,
|
|
26
26
|
isAlternateBufferEnabled,
|
|
27
|
+
isRecord,
|
|
27
28
|
isSlashCommand,
|
|
28
29
|
linkSkill,
|
|
29
30
|
normalizeServerId,
|
|
@@ -42,18 +43,18 @@ import {
|
|
|
42
43
|
updateAllUpdatableExtensions,
|
|
43
44
|
updateExtension,
|
|
44
45
|
validateAuthMethod
|
|
45
|
-
} from "./chunk-
|
|
46
|
+
} from "./chunk-547AWTTH.js";
|
|
46
47
|
import {
|
|
47
48
|
appEvents
|
|
48
49
|
} from "./chunk-5PS3AYFU.js";
|
|
49
50
|
import {
|
|
50
51
|
startCommand,
|
|
51
52
|
startServer
|
|
52
|
-
} from "./chunk-
|
|
53
|
+
} from "./chunk-ZQNX6OWU.js";
|
|
53
54
|
import {
|
|
54
55
|
exitCli,
|
|
55
56
|
require_source
|
|
56
|
-
} from "./chunk-
|
|
57
|
+
} from "./chunk-HGFADN5A.js";
|
|
57
58
|
import {
|
|
58
59
|
DEFAULT_PORT,
|
|
59
60
|
GEMMA_MODEL_NAME,
|
|
@@ -87,7 +88,7 @@ import {
|
|
|
87
88
|
readServerProcessInfo,
|
|
88
89
|
resolveGemmaConfig,
|
|
89
90
|
saveModelChange
|
|
90
|
-
} from "./chunk-
|
|
91
|
+
} from "./chunk-LODNDE3S.js";
|
|
91
92
|
import {
|
|
92
93
|
cleanupCheckpoints,
|
|
93
94
|
registerCleanup,
|
|
@@ -96,32 +97,44 @@ import {
|
|
|
96
97
|
runExitCleanup,
|
|
97
98
|
runSyncCleanup,
|
|
98
99
|
setupSignalHandlers
|
|
99
|
-
} from "./chunk-
|
|
100
|
+
} from "./chunk-SYPUOR3U.js";
|
|
100
101
|
import {
|
|
101
102
|
AuthType,
|
|
102
103
|
ChatRecordingService,
|
|
103
104
|
Client,
|
|
104
105
|
Config,
|
|
106
|
+
CoreToolCallStatus,
|
|
105
107
|
ExitCodes,
|
|
106
108
|
FileDiscoveryService,
|
|
107
109
|
FolderTrustDiscoveryService,
|
|
110
|
+
GeminiEventType,
|
|
108
111
|
IdeClient,
|
|
112
|
+
IntegrityStatus,
|
|
109
113
|
InvalidStreamError,
|
|
110
114
|
JsonFormatter,
|
|
115
|
+
JsonStreamEventType,
|
|
111
116
|
LegacyAgentSession,
|
|
117
|
+
LlmRole,
|
|
112
118
|
Logger,
|
|
113
119
|
MCPServerConfig,
|
|
120
|
+
MCPServerStatus,
|
|
121
|
+
OutputFormat,
|
|
114
122
|
PolicyIntegrityManager,
|
|
115
123
|
ROOT_SCHEDULER_ID,
|
|
116
124
|
ReadManyFilesTool,
|
|
117
125
|
Scheduler,
|
|
126
|
+
SessionEndReason,
|
|
127
|
+
SessionStartSource,
|
|
118
128
|
ShellExecutionService,
|
|
129
|
+
StreamEventType,
|
|
119
130
|
StreamJsonFormatter,
|
|
120
131
|
ToolCallEvent,
|
|
132
|
+
TrustLevel,
|
|
121
133
|
UserAccountManager,
|
|
122
134
|
UserPromptEvent,
|
|
123
135
|
ValidationCancelledError,
|
|
124
136
|
ValidationRequiredError,
|
|
137
|
+
WarningPriority,
|
|
125
138
|
addMemory,
|
|
126
139
|
applyAdminAllowlist,
|
|
127
140
|
applyRequiredServers,
|
|
@@ -183,9 +196,11 @@ import {
|
|
|
183
196
|
updatePolicy,
|
|
184
197
|
writeToStderr,
|
|
185
198
|
writeToStdout
|
|
186
|
-
} from "./chunk-
|
|
199
|
+
} from "./chunk-RENFZ63F.js";
|
|
187
200
|
import {
|
|
188
201
|
ASK_USER_TOOL_NAME,
|
|
202
|
+
ApprovalMode,
|
|
203
|
+
CoreEvent,
|
|
189
204
|
DEFAULT_FILE_FILTERING_OPTIONS,
|
|
190
205
|
DEFAULT_GEMINI_EMBEDDING_MODEL,
|
|
191
206
|
DEFAULT_GEMINI_FLASH_LITE_MODEL,
|
|
@@ -202,8 +217,10 @@ import {
|
|
|
202
217
|
FatalSandboxError,
|
|
203
218
|
FatalToolExecutionError,
|
|
204
219
|
FatalTurnLimitedError,
|
|
220
|
+
FatalUntrustedWorkspaceError,
|
|
205
221
|
GEMINI_DIR,
|
|
206
222
|
GEMINI_MODEL_ALIAS_AUTO,
|
|
223
|
+
Kind,
|
|
207
224
|
PREVIEW_GEMINI_3_1_CUSTOM_TOOLS_MODEL,
|
|
208
225
|
PREVIEW_GEMINI_3_1_FLASH_LITE_MODEL,
|
|
209
226
|
PREVIEW_GEMINI_3_1_MODEL,
|
|
@@ -213,6 +230,7 @@ import {
|
|
|
213
230
|
REFERENCE_CONTENT_START,
|
|
214
231
|
Storage,
|
|
215
232
|
ToolConfirmationOutcome,
|
|
233
|
+
ToolErrorType,
|
|
216
234
|
coreEvents,
|
|
217
235
|
debugLogger,
|
|
218
236
|
external_exports,
|
|
@@ -226,7 +244,7 @@ import {
|
|
|
226
244
|
loadServerHierarchicalMemory,
|
|
227
245
|
resolveToRealPath,
|
|
228
246
|
setGeminiMdFilename
|
|
229
|
-
} from "./chunk-
|
|
247
|
+
} from "./chunk-F73F75XM.js";
|
|
230
248
|
import "./chunk-664ZODQF.js";
|
|
231
249
|
import "./chunk-RJTRUG2J.js";
|
|
232
250
|
import "./chunk-IUUIT4SU.js";
|
|
@@ -5511,7 +5529,7 @@ async function getMcpServersFromConfig(settings) {
|
|
|
5511
5529
|
async function testMCPConnection(serverName, config, isTrusted, activeSettings) {
|
|
5512
5530
|
const isStdio = !!config.command;
|
|
5513
5531
|
if (isStdio && !isTrusted) {
|
|
5514
|
-
return
|
|
5532
|
+
return MCPServerStatus.DISCONNECTED;
|
|
5515
5533
|
}
|
|
5516
5534
|
const client = new Client({
|
|
5517
5535
|
name: "mcp-test-client",
|
|
@@ -5547,16 +5565,16 @@ async function testMCPConnection(serverName, config, isTrusted, activeSettings)
|
|
|
5547
5565
|
transport = await createTransport(serverName, config, false, mcpContext);
|
|
5548
5566
|
} catch {
|
|
5549
5567
|
await client.close();
|
|
5550
|
-
return
|
|
5568
|
+
return MCPServerStatus.DISCONNECTED;
|
|
5551
5569
|
}
|
|
5552
5570
|
try {
|
|
5553
5571
|
await client.connect(transport, { timeout: 5e3 });
|
|
5554
5572
|
await client.ping();
|
|
5555
5573
|
await client.close();
|
|
5556
|
-
return
|
|
5574
|
+
return MCPServerStatus.CONNECTED;
|
|
5557
5575
|
} catch {
|
|
5558
5576
|
await transport.close();
|
|
5559
|
-
return
|
|
5577
|
+
return MCPServerStatus.DISCONNECTED;
|
|
5560
5578
|
}
|
|
5561
5579
|
}
|
|
5562
5580
|
async function getServerStatus(serverName, server, isTrusted, activeSettings) {
|
|
@@ -5569,9 +5587,9 @@ async function getServerStatus(serverName, server, isTrusted, activeSettings) {
|
|
|
5569
5587
|
});
|
|
5570
5588
|
if (!loadResult.allowed) {
|
|
5571
5589
|
if (loadResult.blockType === "admin" || loadResult.blockType === "allowlist" || loadResult.blockType === "excludelist") {
|
|
5572
|
-
return
|
|
5590
|
+
return MCPServerStatus.BLOCKED;
|
|
5573
5591
|
}
|
|
5574
|
-
return
|
|
5592
|
+
return MCPServerStatus.DISABLED;
|
|
5575
5593
|
}
|
|
5576
5594
|
return testMCPConnection(serverName, server, isTrusted, activeSettings);
|
|
5577
5595
|
}
|
|
@@ -5605,23 +5623,23 @@ async function listMcpServers(loadedSettingsArg) {
|
|
|
5605
5623
|
let statusIndicator = "";
|
|
5606
5624
|
let statusText = "";
|
|
5607
5625
|
switch (status) {
|
|
5608
|
-
case
|
|
5626
|
+
case MCPServerStatus.CONNECTED:
|
|
5609
5627
|
statusIndicator = import_chalk.default.green("\u2713");
|
|
5610
5628
|
statusText = "Connected";
|
|
5611
5629
|
break;
|
|
5612
|
-
case
|
|
5630
|
+
case MCPServerStatus.CONNECTING:
|
|
5613
5631
|
statusIndicator = import_chalk.default.yellow("\u2026");
|
|
5614
5632
|
statusText = "Connecting";
|
|
5615
5633
|
break;
|
|
5616
|
-
case
|
|
5634
|
+
case MCPServerStatus.BLOCKED:
|
|
5617
5635
|
statusIndicator = import_chalk.default.red("\u26D4");
|
|
5618
5636
|
statusText = "Blocked";
|
|
5619
5637
|
break;
|
|
5620
|
-
case
|
|
5638
|
+
case MCPServerStatus.DISABLED:
|
|
5621
5639
|
statusIndicator = import_chalk.default.gray("\u25CB");
|
|
5622
5640
|
statusText = "Disabled";
|
|
5623
5641
|
break;
|
|
5624
|
-
case
|
|
5642
|
+
case MCPServerStatus.DISCONNECTED:
|
|
5625
5643
|
default:
|
|
5626
5644
|
statusIndicator = import_chalk.default.red("\u2717");
|
|
5627
5645
|
statusText = "Disconnected";
|
|
@@ -5907,7 +5925,7 @@ async function handleInstall(args) {
|
|
|
5907
5925
|
);
|
|
5908
5926
|
if (confirmed) {
|
|
5909
5927
|
const trustedFolders = loadTrustedFolders();
|
|
5910
|
-
await trustedFolders.setValue(realPath,
|
|
5928
|
+
await trustedFolders.setValue(realPath, TrustLevel.TRUST_FOLDER);
|
|
5911
5929
|
} else {
|
|
5912
5930
|
throw new Error(
|
|
5913
5931
|
`Installation aborted: Folder "${absolutePath}" is not trusted.`
|
|
@@ -7952,7 +7970,7 @@ async function loadSandboxConfig(settings, argv) {
|
|
|
7952
7970
|
}
|
|
7953
7971
|
const command2 = getSandboxCommand(sandboxValue);
|
|
7954
7972
|
const packageJson = await getPackageJson(__dirname3);
|
|
7955
|
-
const image = process.env["GEMINI_SANDBOX_IMAGE"] ?? "us-docker.pkg.dev/gemini-code-dev/gemini-cli/sandbox:0.40.0-
|
|
7973
|
+
const image = process.env["GEMINI_SANDBOX_IMAGE"] ?? "us-docker.pkg.dev/gemini-code-dev/gemini-cli/sandbox:0.40.0-preview.3" ?? customImage ?? packageJson?.config?.sandboxImageUri;
|
|
7956
7974
|
const isNative = command2 === "windows-native" || command2 === "sandbox-exec" || command2 === "lxc";
|
|
7957
7975
|
return command2 && (image || isNative) ? { enabled: true, allowedPaths, networkAccess, command: command2, image } : void 0;
|
|
7958
7976
|
}
|
|
@@ -8011,9 +8029,9 @@ async function resolveWorkspacePolicyState(options) {
|
|
|
8011
8029
|
cwd,
|
|
8012
8030
|
potentialWorkspacePoliciesDir
|
|
8013
8031
|
);
|
|
8014
|
-
if (integrityResult.status ===
|
|
8032
|
+
if (integrityResult.status === IntegrityStatus.MATCH) {
|
|
8015
8033
|
workspacePoliciesDir = potentialWorkspacePoliciesDir;
|
|
8016
|
-
} else if (integrityResult.status ===
|
|
8034
|
+
} else if (integrityResult.status === IntegrityStatus.NEW && integrityResult.fileCount === 0) {
|
|
8017
8035
|
workspacePoliciesDir = void 0;
|
|
8018
8036
|
} else if (interactive && !autoAcceptWorkspacePolicies) {
|
|
8019
8037
|
policyUpdateConfirmationRequest = {
|
|
@@ -8164,6 +8182,10 @@ async function parseArguments(settings) {
|
|
|
8164
8182
|
type: "string",
|
|
8165
8183
|
nargs: 1,
|
|
8166
8184
|
description: "Execute the provided prompt and continue in interactive mode"
|
|
8185
|
+
}).option("skip-trust", {
|
|
8186
|
+
type: "boolean",
|
|
8187
|
+
description: "Trust the current workspace for this session.",
|
|
8188
|
+
default: false
|
|
8167
8189
|
}).option("worktree", {
|
|
8168
8190
|
alias: "w",
|
|
8169
8191
|
type: "string",
|
|
@@ -8285,9 +8307,16 @@ async function parseArguments(settings) {
|
|
|
8285
8307
|
yargsInstance.wrap(yargsInstance.terminalWidth());
|
|
8286
8308
|
let result;
|
|
8287
8309
|
try {
|
|
8288
|
-
|
|
8310
|
+
const parsed = await yargsInstance.parse();
|
|
8311
|
+
if (!isRecord(parsed)) {
|
|
8312
|
+
throw new Error("Failed to parse arguments");
|
|
8313
|
+
}
|
|
8314
|
+
result = parsed;
|
|
8315
|
+
if (result["skip-trust"]) {
|
|
8316
|
+
process3.env["GEMINI_CLI_TRUST_WORKSPACE"] = "true";
|
|
8317
|
+
}
|
|
8289
8318
|
} catch (e) {
|
|
8290
|
-
const msg =
|
|
8319
|
+
const msg = getErrorMessage(e);
|
|
8291
8320
|
debugLogger.error(msg);
|
|
8292
8321
|
yargsInstance.showHelp();
|
|
8293
8322
|
await runExitCleanup();
|
|
@@ -8297,8 +8326,13 @@ async function parseArguments(settings) {
|
|
|
8297
8326
|
await runExitCleanup();
|
|
8298
8327
|
process3.exit(0);
|
|
8299
8328
|
}
|
|
8300
|
-
const queryArg = result
|
|
8301
|
-
|
|
8329
|
+
const queryArg = result["query"];
|
|
8330
|
+
let q;
|
|
8331
|
+
if (Array.isArray(queryArg)) {
|
|
8332
|
+
q = queryArg.join(" ");
|
|
8333
|
+
} else if (typeof queryArg === "string") {
|
|
8334
|
+
q = queryArg;
|
|
8335
|
+
}
|
|
8302
8336
|
if (q && !result["prompt"]) {
|
|
8303
8337
|
if (!isHeadlessMode()) {
|
|
8304
8338
|
startupMessages.push(
|
|
@@ -8329,7 +8363,7 @@ async function loadCliConfig(settings, sessionId, argv, options = {}) {
|
|
|
8329
8363
|
const includeDirectoryTree = settings.context?.includeDirectoryTree ?? true;
|
|
8330
8364
|
const ideMode = settings.ide?.enabled ?? false;
|
|
8331
8365
|
const folderTrust = process3.env["GEMINI_CLI_INTEGRATION_TEST"] === "true" || process3.env["VITEST"] === "true" ? false : settings.security?.folderTrust?.enabled ?? false;
|
|
8332
|
-
const trustedFolder = isWorkspaceTrusted(settings, cwd,
|
|
8366
|
+
const trustedFolder = isWorkspaceTrusted(settings, cwd, {
|
|
8333
8367
|
prompt: argv.prompt,
|
|
8334
8368
|
query: argv.query
|
|
8335
8369
|
})?.isTrusted ?? false;
|
|
@@ -8358,7 +8392,7 @@ async function loadCliConfig(settings, sessionId, argv, options = {}) {
|
|
|
8358
8392
|
return resolveToRealPath(trimmedPath) !== realCwd;
|
|
8359
8393
|
} catch (e) {
|
|
8360
8394
|
debugLogger.debug(
|
|
8361
|
-
`[IDE] Skipping inaccessible workspace folder: ${trimmedPath} (${
|
|
8395
|
+
`[IDE] Skipping inaccessible workspace folder: ${trimmedPath} (${getErrorMessage(e)})`
|
|
8362
8396
|
);
|
|
8363
8397
|
return false;
|
|
8364
8398
|
}
|
|
@@ -8409,23 +8443,23 @@ async function loadCliConfig(settings, sessionId, argv, options = {}) {
|
|
|
8409
8443
|
if (rawApprovalMode) {
|
|
8410
8444
|
switch (rawApprovalMode) {
|
|
8411
8445
|
case "yolo":
|
|
8412
|
-
approvalMode =
|
|
8446
|
+
approvalMode = ApprovalMode.YOLO;
|
|
8413
8447
|
break;
|
|
8414
8448
|
case "auto_edit":
|
|
8415
|
-
approvalMode =
|
|
8449
|
+
approvalMode = ApprovalMode.AUTO_EDIT;
|
|
8416
8450
|
break;
|
|
8417
8451
|
case "plan":
|
|
8418
8452
|
if (!(settings.general?.plan?.enabled ?? true)) {
|
|
8419
8453
|
debugLogger.warn(
|
|
8420
8454
|
'Approval mode "plan" is disabled in your settings. Falling back to "default".'
|
|
8421
8455
|
);
|
|
8422
|
-
approvalMode =
|
|
8456
|
+
approvalMode = ApprovalMode.DEFAULT;
|
|
8423
8457
|
} else {
|
|
8424
|
-
approvalMode =
|
|
8458
|
+
approvalMode = ApprovalMode.PLAN;
|
|
8425
8459
|
}
|
|
8426
8460
|
break;
|
|
8427
8461
|
case "default":
|
|
8428
|
-
approvalMode =
|
|
8462
|
+
approvalMode = ApprovalMode.DEFAULT;
|
|
8429
8463
|
break;
|
|
8430
8464
|
default:
|
|
8431
8465
|
throw new Error(
|
|
@@ -8433,10 +8467,10 @@ async function loadCliConfig(settings, sessionId, argv, options = {}) {
|
|
|
8433
8467
|
);
|
|
8434
8468
|
}
|
|
8435
8469
|
} else {
|
|
8436
|
-
approvalMode =
|
|
8470
|
+
approvalMode = ApprovalMode.DEFAULT;
|
|
8437
8471
|
}
|
|
8438
8472
|
if (settings.security?.disableYoloMode || settings.admin?.secureModeEnabled) {
|
|
8439
|
-
if (approvalMode ===
|
|
8473
|
+
if (approvalMode === ApprovalMode.YOLO) {
|
|
8440
8474
|
if (settings.admin?.secureModeEnabled) {
|
|
8441
8475
|
debugLogger.error(
|
|
8442
8476
|
'YOLO mode is disabled by "secureModeEnabled" setting.'
|
|
@@ -8454,16 +8488,16 @@ async function loadCliConfig(settings, sessionId, argv, options = {}) {
|
|
|
8454
8488
|
)
|
|
8455
8489
|
);
|
|
8456
8490
|
}
|
|
8457
|
-
} else if (approvalMode ===
|
|
8491
|
+
} else if (approvalMode === ApprovalMode.YOLO) {
|
|
8458
8492
|
debugLogger.warn(
|
|
8459
8493
|
"YOLO mode is enabled. All tool calls will be automatically approved."
|
|
8460
8494
|
);
|
|
8461
8495
|
}
|
|
8462
|
-
if (!trustedFolder && approvalMode !==
|
|
8496
|
+
if (!trustedFolder && approvalMode !== ApprovalMode.DEFAULT) {
|
|
8463
8497
|
debugLogger.warn(
|
|
8464
8498
|
`Approval mode overridden to "default" because the current folder is not trusted.`
|
|
8465
8499
|
);
|
|
8466
|
-
approvalMode =
|
|
8500
|
+
approvalMode = ApprovalMode.DEFAULT;
|
|
8467
8501
|
}
|
|
8468
8502
|
let telemetrySettings;
|
|
8469
8503
|
try {
|
|
@@ -8751,7 +8785,7 @@ async function resolveWorktreeSettings(cwd) {
|
|
|
8751
8785
|
worktreeBaseSha = stdout.trim();
|
|
8752
8786
|
} catch (e) {
|
|
8753
8787
|
debugLogger.debug(
|
|
8754
|
-
`Failed to resolve worktree base SHA at ${worktreePath}: ${
|
|
8788
|
+
`Failed to resolve worktree base SHA at ${worktreePath}: ${getErrorMessage(e)}`
|
|
8755
8789
|
);
|
|
8756
8790
|
}
|
|
8757
8791
|
if (!worktreeBaseSha) {
|
|
@@ -9852,7 +9886,7 @@ import path9 from "node:path";
|
|
|
9852
9886
|
import process4 from "node:process";
|
|
9853
9887
|
var homeDirectoryCheck = {
|
|
9854
9888
|
id: "home-directory",
|
|
9855
|
-
priority:
|
|
9889
|
+
priority: WarningPriority.Low,
|
|
9856
9890
|
check: async (workspaceRoot, settings) => {
|
|
9857
9891
|
if (settings.ui?.showHomeDirectoryWarning === false) {
|
|
9858
9892
|
return null;
|
|
@@ -9876,7 +9910,7 @@ var homeDirectoryCheck = {
|
|
|
9876
9910
|
};
|
|
9877
9911
|
var rootDirectoryCheck = {
|
|
9878
9912
|
id: "root-directory",
|
|
9879
|
-
priority:
|
|
9913
|
+
priority: WarningPriority.High,
|
|
9880
9914
|
check: async (workspaceRoot, _settings) => {
|
|
9881
9915
|
try {
|
|
9882
9916
|
const workspaceRealPath = await fs9.realpath(workspaceRoot);
|
|
@@ -9890,9 +9924,29 @@ var rootDirectoryCheck = {
|
|
|
9890
9924
|
}
|
|
9891
9925
|
}
|
|
9892
9926
|
};
|
|
9927
|
+
var folderTrustCheck = {
|
|
9928
|
+
id: "folder-trust",
|
|
9929
|
+
priority: WarningPriority.High,
|
|
9930
|
+
check: async (workspaceRoot, settings) => {
|
|
9931
|
+
if (!isFolderTrustEnabled(settings)) {
|
|
9932
|
+
return null;
|
|
9933
|
+
}
|
|
9934
|
+
const { isTrusted } = isWorkspaceTrusted(settings, workspaceRoot);
|
|
9935
|
+
if (isTrusted === true) {
|
|
9936
|
+
return null;
|
|
9937
|
+
}
|
|
9938
|
+
if (isHeadlessMode()) {
|
|
9939
|
+
throw new FatalUntrustedWorkspaceError(
|
|
9940
|
+
"Gemini CLI is not running in a trusted directory. To proceed, either use `--skip-trust`, set the `GEMINI_CLI_TRUST_WORKSPACE=true` environment variable, or trust this directory in interactive mode. For more details, see https://geminicli.com/docs/cli/trusted-folders/#headless-and-automated-environments"
|
|
9941
|
+
);
|
|
9942
|
+
}
|
|
9943
|
+
return null;
|
|
9944
|
+
}
|
|
9945
|
+
};
|
|
9893
9946
|
var WARNING_CHECKS = [
|
|
9894
9947
|
homeDirectoryCheck,
|
|
9895
|
-
rootDirectoryCheck
|
|
9948
|
+
rootDirectoryCheck,
|
|
9949
|
+
folderTrustCheck
|
|
9896
9950
|
];
|
|
9897
9951
|
async function getUserStartupWarnings(settings, workspaceRoot = process4.cwd(), options) {
|
|
9898
9952
|
const results = await Promise.all(
|
|
@@ -10060,12 +10114,12 @@ function handleError(error, config, customErrorCode) {
|
|
|
10060
10114
|
error,
|
|
10061
10115
|
config.getContentGeneratorConfig()?.authType
|
|
10062
10116
|
);
|
|
10063
|
-
if (config.getOutputFormat() ===
|
|
10117
|
+
if (config.getOutputFormat() === OutputFormat.STREAM_JSON) {
|
|
10064
10118
|
const streamFormatter = new StreamJsonFormatter();
|
|
10065
10119
|
const errorCode = customErrorCode ?? extractErrorCode(error);
|
|
10066
10120
|
const metrics = uiTelemetryService.getMetrics();
|
|
10067
10121
|
streamFormatter.emitEvent({
|
|
10068
|
-
type:
|
|
10122
|
+
type: JsonStreamEventType.RESULT,
|
|
10069
10123
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10070
10124
|
status: "error",
|
|
10071
10125
|
error: {
|
|
@@ -10076,7 +10130,7 @@ function handleError(error, config, customErrorCode) {
|
|
|
10076
10130
|
});
|
|
10077
10131
|
runSyncCleanup();
|
|
10078
10132
|
process.exit(getNumericExitCode(errorCode));
|
|
10079
|
-
} else if (config.getOutputFormat() ===
|
|
10133
|
+
} else if (config.getOutputFormat() === OutputFormat.JSON) {
|
|
10080
10134
|
const formatter = new JsonFormatter();
|
|
10081
10135
|
const errorCode = customErrorCode ?? extractErrorCode(error);
|
|
10082
10136
|
const formattedError = formatter.formatError(
|
|
@@ -10096,11 +10150,11 @@ function handleToolError(toolName, toolError, config, errorType, resultDisplay)
|
|
|
10096
10150
|
const isFatal = isFatalToolError(errorType);
|
|
10097
10151
|
if (isFatal) {
|
|
10098
10152
|
const toolExecutionError = new FatalToolExecutionError(errorMessage);
|
|
10099
|
-
if (config.getOutputFormat() ===
|
|
10153
|
+
if (config.getOutputFormat() === OutputFormat.STREAM_JSON) {
|
|
10100
10154
|
const streamFormatter = new StreamJsonFormatter();
|
|
10101
10155
|
const metrics = uiTelemetryService.getMetrics();
|
|
10102
10156
|
streamFormatter.emitEvent({
|
|
10103
|
-
type:
|
|
10157
|
+
type: JsonStreamEventType.RESULT,
|
|
10104
10158
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10105
10159
|
status: "error",
|
|
10106
10160
|
error: {
|
|
@@ -10109,7 +10163,7 @@ function handleToolError(toolName, toolError, config, errorType, resultDisplay)
|
|
|
10109
10163
|
},
|
|
10110
10164
|
stats: streamFormatter.convertToStreamStats(metrics, 0)
|
|
10111
10165
|
});
|
|
10112
|
-
} else if (config.getOutputFormat() ===
|
|
10166
|
+
} else if (config.getOutputFormat() === OutputFormat.JSON) {
|
|
10113
10167
|
const formatter = new JsonFormatter();
|
|
10114
10168
|
const formattedError = formatter.formatError(
|
|
10115
10169
|
toolExecutionError,
|
|
@@ -10127,11 +10181,11 @@ function handleToolError(toolName, toolError, config, errorType, resultDisplay)
|
|
|
10127
10181
|
}
|
|
10128
10182
|
function handleCancellationError(config) {
|
|
10129
10183
|
const cancellationError = new FatalCancellationError("Operation cancelled.");
|
|
10130
|
-
if (config.getOutputFormat() ===
|
|
10184
|
+
if (config.getOutputFormat() === OutputFormat.STREAM_JSON) {
|
|
10131
10185
|
const streamFormatter = new StreamJsonFormatter();
|
|
10132
10186
|
const metrics = uiTelemetryService.getMetrics();
|
|
10133
10187
|
streamFormatter.emitEvent({
|
|
10134
|
-
type:
|
|
10188
|
+
type: JsonStreamEventType.RESULT,
|
|
10135
10189
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10136
10190
|
status: "error",
|
|
10137
10191
|
error: {
|
|
@@ -10142,7 +10196,7 @@ function handleCancellationError(config) {
|
|
|
10142
10196
|
});
|
|
10143
10197
|
runSyncCleanup();
|
|
10144
10198
|
process.exit(cancellationError.exitCode);
|
|
10145
|
-
} else if (config.getOutputFormat() ===
|
|
10199
|
+
} else if (config.getOutputFormat() === OutputFormat.JSON) {
|
|
10146
10200
|
const formatter = new JsonFormatter();
|
|
10147
10201
|
const formattedError = formatter.formatError(
|
|
10148
10202
|
cancellationError,
|
|
@@ -10162,11 +10216,11 @@ function handleMaxTurnsExceededError(config) {
|
|
|
10162
10216
|
const maxTurnsError = new FatalTurnLimitedError(
|
|
10163
10217
|
"Reached max session turns for this session. Increase the number of turns by specifying maxSessionTurns in settings.json."
|
|
10164
10218
|
);
|
|
10165
|
-
if (config.getOutputFormat() ===
|
|
10219
|
+
if (config.getOutputFormat() === OutputFormat.STREAM_JSON) {
|
|
10166
10220
|
const streamFormatter = new StreamJsonFormatter();
|
|
10167
10221
|
const metrics = uiTelemetryService.getMetrics();
|
|
10168
10222
|
streamFormatter.emitEvent({
|
|
10169
|
-
type:
|
|
10223
|
+
type: JsonStreamEventType.RESULT,
|
|
10170
10224
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10171
10225
|
status: "error",
|
|
10172
10226
|
error: {
|
|
@@ -10177,7 +10231,7 @@ function handleMaxTurnsExceededError(config) {
|
|
|
10177
10231
|
});
|
|
10178
10232
|
runSyncCleanup();
|
|
10179
10233
|
process.exit(maxTurnsError.exitCode);
|
|
10180
|
-
} else if (config.getOutputFormat() ===
|
|
10234
|
+
} else if (config.getOutputFormat() === OutputFormat.JSON) {
|
|
10181
10235
|
const formatter = new JsonFormatter();
|
|
10182
10236
|
const formattedError = formatter.formatError(
|
|
10183
10237
|
maxTurnsError,
|
|
@@ -10257,7 +10311,7 @@ async function runNonInteractive({
|
|
|
10257
10311
|
}
|
|
10258
10312
|
});
|
|
10259
10313
|
if (process.env["GEMINI_CLI_ACTIVITY_LOG_TARGET"]) {
|
|
10260
|
-
const { setupInitialActivityLogger } = await import("./devtoolsService-
|
|
10314
|
+
const { setupInitialActivityLogger } = await import("./devtoolsService-YCRNWWXE.js");
|
|
10261
10315
|
setupInitialActivityLogger(config);
|
|
10262
10316
|
}
|
|
10263
10317
|
const { stdout: workingStdout } = createWorkingStdio();
|
|
@@ -10273,7 +10327,7 @@ async function runNonInteractive({
|
|
|
10273
10327
|
}
|
|
10274
10328
|
};
|
|
10275
10329
|
const startTime = Date.now();
|
|
10276
|
-
const streamFormatter = config.getOutputFormat() ===
|
|
10330
|
+
const streamFormatter = config.getOutputFormat() === OutputFormat.STREAM_JSON ? new StreamJsonFormatter() : null;
|
|
10277
10331
|
const abortController = new AbortController();
|
|
10278
10332
|
let isAborting = false;
|
|
10279
10333
|
let cancelMessageTimer = null;
|
|
@@ -10326,13 +10380,13 @@ async function runNonInteractive({
|
|
|
10326
10380
|
};
|
|
10327
10381
|
try {
|
|
10328
10382
|
consolePatcher.patch();
|
|
10329
|
-
if (config.getRawOutput() && !config.getAcceptRawOutputRisk() && config.getOutputFormat() ===
|
|
10383
|
+
if (config.getRawOutput() && !config.getAcceptRawOutputRisk() && config.getOutputFormat() === OutputFormat.TEXT) {
|
|
10330
10384
|
process.stderr.write(
|
|
10331
10385
|
"[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"
|
|
10332
10386
|
);
|
|
10333
10387
|
}
|
|
10334
10388
|
setupStdinCancellation();
|
|
10335
|
-
coreEvents.on(
|
|
10389
|
+
coreEvents.on(CoreEvent.UserFeedback, handleUserFeedback);
|
|
10336
10390
|
coreEvents.drainBacklogs();
|
|
10337
10391
|
process.stdout.on("error", (err) => {
|
|
10338
10392
|
if (err.code === "EPIPE") {
|
|
@@ -10358,7 +10412,7 @@ async function runNonInteractive({
|
|
|
10358
10412
|
}
|
|
10359
10413
|
if (streamFormatter) {
|
|
10360
10414
|
streamFormatter.emitEvent({
|
|
10361
|
-
type:
|
|
10415
|
+
type: JsonStreamEventType.INIT,
|
|
10362
10416
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10363
10417
|
session_id: config.getSessionId(),
|
|
10364
10418
|
model: config.getModel()
|
|
@@ -10396,7 +10450,7 @@ async function runNonInteractive({
|
|
|
10396
10450
|
}
|
|
10397
10451
|
if (streamFormatter) {
|
|
10398
10452
|
streamFormatter.emitEvent({
|
|
10399
|
-
type:
|
|
10453
|
+
type: JsonStreamEventType.MESSAGE,
|
|
10400
10454
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10401
10455
|
role: "user",
|
|
10402
10456
|
content: input
|
|
@@ -10435,12 +10489,12 @@ async function runNonInteractive({
|
|
|
10435
10489
|
const metrics = uiTelemetryService.getMetrics();
|
|
10436
10490
|
const durationMs = Date.now() - startTime;
|
|
10437
10491
|
streamFormatter.emitEvent({
|
|
10438
|
-
type:
|
|
10492
|
+
type: JsonStreamEventType.RESULT,
|
|
10439
10493
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10440
10494
|
status: "success",
|
|
10441
10495
|
stats: streamFormatter.convertToStreamStats(metrics, durationMs)
|
|
10442
10496
|
});
|
|
10443
|
-
} else if (config.getOutputFormat() ===
|
|
10497
|
+
} else if (config.getOutputFormat() === OutputFormat.JSON) {
|
|
10444
10498
|
const formatter = new JsonFormatter();
|
|
10445
10499
|
const stats = uiTelemetryService.getMetrics();
|
|
10446
10500
|
textOutput.write(
|
|
@@ -10526,13 +10580,13 @@ async function runNonInteractive({
|
|
|
10526
10580
|
const output = isRaw ? part.text : stripAnsi(part.text);
|
|
10527
10581
|
if (streamFormatter) {
|
|
10528
10582
|
streamFormatter.emitEvent({
|
|
10529
|
-
type:
|
|
10583
|
+
type: JsonStreamEventType.MESSAGE,
|
|
10530
10584
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10531
10585
|
role: "assistant",
|
|
10532
10586
|
content: output,
|
|
10533
10587
|
delta: true
|
|
10534
10588
|
});
|
|
10535
|
-
} else if (config.getOutputFormat() ===
|
|
10589
|
+
} else if (config.getOutputFormat() === OutputFormat.JSON) {
|
|
10536
10590
|
responseText += output;
|
|
10537
10591
|
} else {
|
|
10538
10592
|
if (part.text) {
|
|
@@ -10545,13 +10599,13 @@ async function runNonInteractive({
|
|
|
10545
10599
|
break;
|
|
10546
10600
|
}
|
|
10547
10601
|
case "tool_request": {
|
|
10548
|
-
if (config.getOutputFormat() ===
|
|
10602
|
+
if (config.getOutputFormat() === OutputFormat.JSON) {
|
|
10549
10603
|
preToolResponseText = responseText || preToolResponseText;
|
|
10550
10604
|
responseText = "";
|
|
10551
10605
|
}
|
|
10552
10606
|
if (streamFormatter) {
|
|
10553
10607
|
streamFormatter.emitEvent({
|
|
10554
|
-
type:
|
|
10608
|
+
type: JsonStreamEventType.TOOL_USE,
|
|
10555
10609
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10556
10610
|
tool_name: event.name,
|
|
10557
10611
|
tool_id: event.requestId,
|
|
@@ -10567,7 +10621,7 @@ async function runNonInteractive({
|
|
|
10567
10621
|
const displayText = displayContentToString(display);
|
|
10568
10622
|
const errorMsg = getTextContent(event.content) ?? "Tool error";
|
|
10569
10623
|
streamFormatter.emitEvent({
|
|
10570
|
-
type:
|
|
10624
|
+
type: JsonStreamEventType.TOOL_RESULT,
|
|
10571
10625
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10572
10626
|
tool_id: event.requestId,
|
|
10573
10627
|
status: event.isError ? "error" : "success",
|
|
@@ -10582,17 +10636,17 @@ async function runNonInteractive({
|
|
|
10582
10636
|
const display = event.display?.result;
|
|
10583
10637
|
const displayText = displayContentToString(display);
|
|
10584
10638
|
const errorMsg = getTextContent(event.content) ?? "Tool error";
|
|
10585
|
-
if (event.data?.["errorType"] ===
|
|
10586
|
-
if (config.getOutputFormat() ===
|
|
10639
|
+
if (event.data?.["errorType"] === ToolErrorType.STOP_EXECUTION) {
|
|
10640
|
+
if (config.getOutputFormat() === OutputFormat.JSON && !responseText && preToolResponseText) {
|
|
10587
10641
|
responseText = preToolResponseText;
|
|
10588
10642
|
}
|
|
10589
10643
|
const stopMessage = `Agent execution stopped: ${errorMsg}`;
|
|
10590
|
-
if (config.getOutputFormat() ===
|
|
10644
|
+
if (config.getOutputFormat() === OutputFormat.TEXT) {
|
|
10591
10645
|
process.stderr.write(`${stopMessage}
|
|
10592
10646
|
`);
|
|
10593
10647
|
}
|
|
10594
10648
|
}
|
|
10595
|
-
if (event.data?.["errorType"] ===
|
|
10649
|
+
if (event.data?.["errorType"] === ToolErrorType.NO_SPACE_LEFT) {
|
|
10596
10650
|
throw new FatalToolExecutionError(
|
|
10597
10651
|
"Error executing tool " + event.name + ": " + (displayText || errorMsg)
|
|
10598
10652
|
);
|
|
@@ -10613,20 +10667,20 @@ async function runNonInteractive({
|
|
|
10613
10667
|
}
|
|
10614
10668
|
const errorCode = event._meta?.["code"];
|
|
10615
10669
|
if (errorCode === "AGENT_EXECUTION_BLOCKED") {
|
|
10616
|
-
if (config.getOutputFormat() ===
|
|
10670
|
+
if (config.getOutputFormat() === OutputFormat.TEXT) {
|
|
10617
10671
|
process.stderr.write(`[WARNING] ${event.message}
|
|
10618
10672
|
`);
|
|
10619
10673
|
}
|
|
10620
10674
|
break;
|
|
10621
10675
|
}
|
|
10622
10676
|
const severity = event.status === "RESOURCE_EXHAUSTED" ? "error" : "warning";
|
|
10623
|
-
if (config.getOutputFormat() ===
|
|
10677
|
+
if (config.getOutputFormat() === OutputFormat.TEXT) {
|
|
10624
10678
|
process.stderr.write(`[WARNING] ${event.message}
|
|
10625
10679
|
`);
|
|
10626
10680
|
}
|
|
10627
10681
|
if (streamFormatter) {
|
|
10628
10682
|
streamFormatter.emitEvent({
|
|
10629
|
-
type:
|
|
10683
|
+
type: JsonStreamEventType.ERROR,
|
|
10630
10684
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10631
10685
|
severity,
|
|
10632
10686
|
message: event.message
|
|
@@ -10645,7 +10699,7 @@ async function runNonInteractive({
|
|
|
10645
10699
|
);
|
|
10646
10700
|
} else if (streamFormatter) {
|
|
10647
10701
|
streamFormatter.emitEvent({
|
|
10648
|
-
type:
|
|
10702
|
+
type: JsonStreamEventType.ERROR,
|
|
10649
10703
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10650
10704
|
severity: "error",
|
|
10651
10705
|
message: "Maximum session turns exceeded"
|
|
@@ -10653,7 +10707,7 @@ async function runNonInteractive({
|
|
|
10653
10707
|
}
|
|
10654
10708
|
}
|
|
10655
10709
|
const stopMessage = typeof event.data?.["message"] === "string" ? event.data["message"] : "";
|
|
10656
|
-
if (stopMessage && config.getOutputFormat() ===
|
|
10710
|
+
if (stopMessage && config.getOutputFormat() === OutputFormat.TEXT) {
|
|
10657
10711
|
process.stderr.write(`Agent execution stopped: ${stopMessage}
|
|
10658
10712
|
`);
|
|
10659
10713
|
}
|
|
@@ -10683,7 +10737,7 @@ async function runNonInteractive({
|
|
|
10683
10737
|
abortController.signal.removeEventListener("abort", abortSession);
|
|
10684
10738
|
scheduler?.dispose();
|
|
10685
10739
|
consolePatcher.cleanup();
|
|
10686
|
-
coreEvents.off(
|
|
10740
|
+
coreEvents.off(CoreEvent.UserFeedback, handleUserFeedback);
|
|
10687
10741
|
}
|
|
10688
10742
|
if (errorToHandle) {
|
|
10689
10743
|
handleError(errorToHandle, config);
|
|
@@ -10708,7 +10762,7 @@ async function runNonInteractive2(params) {
|
|
|
10708
10762
|
}
|
|
10709
10763
|
});
|
|
10710
10764
|
if (process.env["GEMINI_CLI_ACTIVITY_LOG_TARGET"]) {
|
|
10711
|
-
const { setupInitialActivityLogger } = await import("./devtoolsService-
|
|
10765
|
+
const { setupInitialActivityLogger } = await import("./devtoolsService-YCRNWWXE.js");
|
|
10712
10766
|
setupInitialActivityLogger(config);
|
|
10713
10767
|
}
|
|
10714
10768
|
const { stdout: workingStdout } = createWorkingStdio();
|
|
@@ -10724,7 +10778,7 @@ async function runNonInteractive2(params) {
|
|
|
10724
10778
|
}
|
|
10725
10779
|
};
|
|
10726
10780
|
const startTime = Date.now();
|
|
10727
|
-
const streamFormatter = config.getOutputFormat() ===
|
|
10781
|
+
const streamFormatter = config.getOutputFormat() === OutputFormat.STREAM_JSON ? new StreamJsonFormatter() : null;
|
|
10728
10782
|
const abortController = new AbortController();
|
|
10729
10783
|
let isAborting = false;
|
|
10730
10784
|
let cancelMessageTimer = null;
|
|
@@ -10775,13 +10829,13 @@ async function runNonInteractive2(params) {
|
|
|
10775
10829
|
let scheduler;
|
|
10776
10830
|
try {
|
|
10777
10831
|
consolePatcher.patch();
|
|
10778
|
-
if (config.getRawOutput() && !config.getAcceptRawOutputRisk() && config.getOutputFormat() ===
|
|
10832
|
+
if (config.getRawOutput() && !config.getAcceptRawOutputRisk() && config.getOutputFormat() === OutputFormat.TEXT) {
|
|
10779
10833
|
process.stderr.write(
|
|
10780
10834
|
"[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"
|
|
10781
10835
|
);
|
|
10782
10836
|
}
|
|
10783
10837
|
setupStdinCancellation();
|
|
10784
|
-
coreEvents.on(
|
|
10838
|
+
coreEvents.on(CoreEvent.UserFeedback, handleUserFeedback);
|
|
10785
10839
|
coreEvents.drainBacklogs();
|
|
10786
10840
|
process.stdout.on("error", (err) => {
|
|
10787
10841
|
if (err.code === "EPIPE") {
|
|
@@ -10805,7 +10859,7 @@ async function runNonInteractive2(params) {
|
|
|
10805
10859
|
}
|
|
10806
10860
|
if (streamFormatter) {
|
|
10807
10861
|
streamFormatter.emitEvent({
|
|
10808
|
-
type:
|
|
10862
|
+
type: JsonStreamEventType.INIT,
|
|
10809
10863
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10810
10864
|
session_id: config.getSessionId(),
|
|
10811
10865
|
model: config.getModel()
|
|
@@ -10843,7 +10897,7 @@ async function runNonInteractive2(params) {
|
|
|
10843
10897
|
}
|
|
10844
10898
|
if (streamFormatter) {
|
|
10845
10899
|
streamFormatter.emitEvent({
|
|
10846
|
-
type:
|
|
10900
|
+
type: JsonStreamEventType.MESSAGE,
|
|
10847
10901
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10848
10902
|
role: "user",
|
|
10849
10903
|
content: input
|
|
@@ -10870,28 +10924,28 @@ async function runNonInteractive2(params) {
|
|
|
10870
10924
|
if (abortController.signal.aborted) {
|
|
10871
10925
|
handleCancellationError(config);
|
|
10872
10926
|
}
|
|
10873
|
-
if (event.type ===
|
|
10927
|
+
if (event.type === GeminiEventType.Content) {
|
|
10874
10928
|
const isRaw = config.getRawOutput() || config.getAcceptRawOutputRisk();
|
|
10875
10929
|
const output = isRaw ? event.value : stripAnsi(event.value);
|
|
10876
10930
|
if (streamFormatter) {
|
|
10877
10931
|
streamFormatter.emitEvent({
|
|
10878
|
-
type:
|
|
10932
|
+
type: JsonStreamEventType.MESSAGE,
|
|
10879
10933
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10880
10934
|
role: "assistant",
|
|
10881
10935
|
content: output,
|
|
10882
10936
|
delta: true
|
|
10883
10937
|
});
|
|
10884
|
-
} else if (config.getOutputFormat() ===
|
|
10938
|
+
} else if (config.getOutputFormat() === OutputFormat.JSON) {
|
|
10885
10939
|
responseText += output;
|
|
10886
10940
|
} else {
|
|
10887
10941
|
if (event.value) {
|
|
10888
10942
|
textOutput.write(output);
|
|
10889
10943
|
}
|
|
10890
10944
|
}
|
|
10891
|
-
} else if (event.type ===
|
|
10945
|
+
} else if (event.type === GeminiEventType.ToolCallRequest) {
|
|
10892
10946
|
if (streamFormatter) {
|
|
10893
10947
|
streamFormatter.emitEvent({
|
|
10894
|
-
type:
|
|
10948
|
+
type: JsonStreamEventType.TOOL_USE,
|
|
10895
10949
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10896
10950
|
tool_name: event.value.name,
|
|
10897
10951
|
tool_id: event.value.callId,
|
|
@@ -10899,29 +10953,29 @@ async function runNonInteractive2(params) {
|
|
|
10899
10953
|
});
|
|
10900
10954
|
}
|
|
10901
10955
|
toolCallRequests.push(event.value);
|
|
10902
|
-
} else if (event.type ===
|
|
10956
|
+
} else if (event.type === GeminiEventType.LoopDetected) {
|
|
10903
10957
|
if (streamFormatter) {
|
|
10904
10958
|
streamFormatter.emitEvent({
|
|
10905
|
-
type:
|
|
10959
|
+
type: JsonStreamEventType.ERROR,
|
|
10906
10960
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10907
10961
|
severity: "warning",
|
|
10908
10962
|
message: "Loop detected, stopping execution"
|
|
10909
10963
|
});
|
|
10910
10964
|
}
|
|
10911
|
-
} else if (event.type ===
|
|
10965
|
+
} else if (event.type === GeminiEventType.MaxSessionTurns) {
|
|
10912
10966
|
if (streamFormatter) {
|
|
10913
10967
|
streamFormatter.emitEvent({
|
|
10914
|
-
type:
|
|
10968
|
+
type: JsonStreamEventType.ERROR,
|
|
10915
10969
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10916
10970
|
severity: "error",
|
|
10917
10971
|
message: "Maximum session turns exceeded"
|
|
10918
10972
|
});
|
|
10919
10973
|
}
|
|
10920
|
-
} else if (event.type ===
|
|
10974
|
+
} else if (event.type === GeminiEventType.Error) {
|
|
10921
10975
|
throw event.value.error;
|
|
10922
|
-
} else if (event.type ===
|
|
10976
|
+
} else if (event.type === GeminiEventType.AgentExecutionStopped) {
|
|
10923
10977
|
const stopMessage = `Agent execution stopped: ${event.value.systemMessage?.trim() || event.value.reason}`;
|
|
10924
|
-
if (config.getOutputFormat() ===
|
|
10978
|
+
if (config.getOutputFormat() === OutputFormat.TEXT) {
|
|
10925
10979
|
process.stderr.write(`${stopMessage}
|
|
10926
10980
|
`);
|
|
10927
10981
|
}
|
|
@@ -10929,7 +10983,7 @@ async function runNonInteractive2(params) {
|
|
|
10929
10983
|
const metrics = uiTelemetryService.getMetrics();
|
|
10930
10984
|
const durationMs = Date.now() - startTime;
|
|
10931
10985
|
streamFormatter.emitEvent({
|
|
10932
|
-
type:
|
|
10986
|
+
type: JsonStreamEventType.RESULT,
|
|
10933
10987
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10934
10988
|
status: "success",
|
|
10935
10989
|
stats: streamFormatter.convertToStreamStats(
|
|
@@ -10939,9 +10993,9 @@ async function runNonInteractive2(params) {
|
|
|
10939
10993
|
});
|
|
10940
10994
|
}
|
|
10941
10995
|
return;
|
|
10942
|
-
} else if (event.type ===
|
|
10996
|
+
} else if (event.type === GeminiEventType.AgentExecutionBlocked) {
|
|
10943
10997
|
const blockMessage = `Agent execution blocked: ${event.value.systemMessage?.trim() || event.value.reason}`;
|
|
10944
|
-
if (config.getOutputFormat() ===
|
|
10998
|
+
if (config.getOutputFormat() === OutputFormat.TEXT) {
|
|
10945
10999
|
process.stderr.write(`[WARNING] ${blockMessage}
|
|
10946
11000
|
`);
|
|
10947
11001
|
}
|
|
@@ -10959,7 +11013,7 @@ async function runNonInteractive2(params) {
|
|
|
10959
11013
|
const requestInfo = completedToolCall.request;
|
|
10960
11014
|
if (streamFormatter) {
|
|
10961
11015
|
streamFormatter.emitEvent({
|
|
10962
|
-
type:
|
|
11016
|
+
type: JsonStreamEventType.TOOL_RESULT,
|
|
10963
11017
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10964
11018
|
tool_id: requestInfo.callId,
|
|
10965
11019
|
status: completedToolCall.status === "error" ? "error" : "success",
|
|
@@ -10993,11 +11047,11 @@ async function runNonInteractive2(params) {
|
|
|
10993
11047
|
);
|
|
10994
11048
|
}
|
|
10995
11049
|
const stopExecutionTool = completedToolCalls.find(
|
|
10996
|
-
(tc) => tc.response.errorType ===
|
|
11050
|
+
(tc) => tc.response.errorType === ToolErrorType.STOP_EXECUTION
|
|
10997
11051
|
);
|
|
10998
11052
|
if (stopExecutionTool && stopExecutionTool.response.error) {
|
|
10999
11053
|
const stopMessage = `Agent execution stopped: ${stopExecutionTool.response.error.message}`;
|
|
11000
|
-
if (config.getOutputFormat() ===
|
|
11054
|
+
if (config.getOutputFormat() === OutputFormat.TEXT) {
|
|
11001
11055
|
process.stderr.write(`${stopMessage}
|
|
11002
11056
|
`);
|
|
11003
11057
|
}
|
|
@@ -11005,7 +11059,7 @@ async function runNonInteractive2(params) {
|
|
|
11005
11059
|
const metrics = uiTelemetryService.getMetrics();
|
|
11006
11060
|
const durationMs = Date.now() - startTime;
|
|
11007
11061
|
streamFormatter.emitEvent({
|
|
11008
|
-
type:
|
|
11062
|
+
type: JsonStreamEventType.RESULT,
|
|
11009
11063
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
11010
11064
|
status: "success",
|
|
11011
11065
|
stats: streamFormatter.convertToStreamStats(
|
|
@@ -11013,7 +11067,7 @@ async function runNonInteractive2(params) {
|
|
|
11013
11067
|
durationMs
|
|
11014
11068
|
)
|
|
11015
11069
|
});
|
|
11016
|
-
} else if (config.getOutputFormat() ===
|
|
11070
|
+
} else if (config.getOutputFormat() === OutputFormat.JSON) {
|
|
11017
11071
|
const formatter = new JsonFormatter();
|
|
11018
11072
|
const stats = uiTelemetryService.getMetrics();
|
|
11019
11073
|
textOutput.write(
|
|
@@ -11030,12 +11084,12 @@ async function runNonInteractive2(params) {
|
|
|
11030
11084
|
const metrics = uiTelemetryService.getMetrics();
|
|
11031
11085
|
const durationMs = Date.now() - startTime;
|
|
11032
11086
|
streamFormatter.emitEvent({
|
|
11033
|
-
type:
|
|
11087
|
+
type: JsonStreamEventType.RESULT,
|
|
11034
11088
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
11035
11089
|
status: "success",
|
|
11036
11090
|
stats: streamFormatter.convertToStreamStats(metrics, durationMs)
|
|
11037
11091
|
});
|
|
11038
|
-
} else if (config.getOutputFormat() ===
|
|
11092
|
+
} else if (config.getOutputFormat() === OutputFormat.JSON) {
|
|
11039
11093
|
const formatter = new JsonFormatter();
|
|
11040
11094
|
const stats = uiTelemetryService.getMetrics();
|
|
11041
11095
|
textOutput.write(
|
|
@@ -11053,7 +11107,7 @@ async function runNonInteractive2(params) {
|
|
|
11053
11107
|
cleanupStdinCancellation();
|
|
11054
11108
|
scheduler?.dispose();
|
|
11055
11109
|
consolePatcher.cleanup();
|
|
11056
|
-
coreEvents.off(
|
|
11110
|
+
coreEvents.off(CoreEvent.UserFeedback, handleUserFeedback);
|
|
11057
11111
|
}
|
|
11058
11112
|
if (errorToHandle) {
|
|
11059
11113
|
handleError(errorToHandle, config);
|
|
@@ -13524,12 +13578,12 @@ var GeminiAgent = class _GeminiAgent {
|
|
|
13524
13578
|
this.clientCapabilities = args.clientCapabilities;
|
|
13525
13579
|
const authMethods = [
|
|
13526
13580
|
{
|
|
13527
|
-
id:
|
|
13581
|
+
id: AuthType.LOGIN_WITH_GOOGLE,
|
|
13528
13582
|
name: "Log in with Google",
|
|
13529
13583
|
description: "Log in with your Google account"
|
|
13530
13584
|
},
|
|
13531
13585
|
{
|
|
13532
|
-
id:
|
|
13586
|
+
id: AuthType.USE_GEMINI,
|
|
13533
13587
|
name: "Gemini API key",
|
|
13534
13588
|
description: "Use an API key with Gemini Developer API",
|
|
13535
13589
|
_meta: {
|
|
@@ -13539,12 +13593,12 @@ var GeminiAgent = class _GeminiAgent {
|
|
|
13539
13593
|
}
|
|
13540
13594
|
},
|
|
13541
13595
|
{
|
|
13542
|
-
id:
|
|
13596
|
+
id: AuthType.USE_VERTEX_AI,
|
|
13543
13597
|
name: "Vertex AI",
|
|
13544
13598
|
description: "Use an API key with Vertex AI GenAI API"
|
|
13545
13599
|
},
|
|
13546
13600
|
{
|
|
13547
|
-
id:
|
|
13601
|
+
id: AuthType.GATEWAY,
|
|
13548
13602
|
name: "AI API Gateway",
|
|
13549
13603
|
description: "Use a custom AI API Gateway",
|
|
13550
13604
|
_meta: {
|
|
@@ -13639,7 +13693,7 @@ var GeminiAgent = class _GeminiAgent {
|
|
|
13639
13693
|
mcpServers,
|
|
13640
13694
|
loadedSettings
|
|
13641
13695
|
);
|
|
13642
|
-
const authType = loadedSettings.merged.security.auth.selectedType ||
|
|
13696
|
+
const authType = loadedSettings.merged.security.auth.selectedType || AuthType.USE_GEMINI;
|
|
13643
13697
|
let isAuthenticated = false;
|
|
13644
13698
|
let authErrorMessage = "";
|
|
13645
13699
|
try {
|
|
@@ -13651,7 +13705,7 @@ var GeminiAgent = class _GeminiAgent {
|
|
|
13651
13705
|
);
|
|
13652
13706
|
isAuthenticated = true;
|
|
13653
13707
|
const contentGeneratorConfig = config.getContentGeneratorConfig();
|
|
13654
|
-
if (authType ===
|
|
13708
|
+
if (authType === AuthType.USE_GEMINI && (!contentGeneratorConfig || !contentGeneratorConfig.apiKey)) {
|
|
13655
13709
|
isAuthenticated = false;
|
|
13656
13710
|
authErrorMessage = "Gemini API key is missing or not configured.";
|
|
13657
13711
|
}
|
|
@@ -13961,7 +14015,7 @@ ${thought.description}`;
|
|
|
13961
14015
|
await this.sendUpdate({
|
|
13962
14016
|
sessionUpdate: "tool_call",
|
|
13963
14017
|
toolCallId: toolCall.id,
|
|
13964
|
-
status: toolCall.status ===
|
|
14018
|
+
status: toolCall.status === CoreToolCallStatus.Success ? "completed" : "failed",
|
|
13965
14019
|
title: toolCall.displayName || toolCall.name,
|
|
13966
14020
|
content: toolCallContent,
|
|
13967
14021
|
kind: tool ? toAcpToolKind(tool.kind) : "other"
|
|
@@ -14014,7 +14068,7 @@ ${thought.description}`;
|
|
|
14014
14068
|
while (nextMessage !== null) {
|
|
14015
14069
|
if (pendingSend.signal.aborted) {
|
|
14016
14070
|
chat.addHistory(nextMessage);
|
|
14017
|
-
return { stopReason:
|
|
14071
|
+
return { stopReason: CoreToolCallStatus.Cancelled };
|
|
14018
14072
|
}
|
|
14019
14073
|
const functionCalls = [];
|
|
14020
14074
|
try {
|
|
@@ -14034,7 +14088,7 @@ ${thought.description}`;
|
|
|
14034
14088
|
nextMessage?.parts ?? [],
|
|
14035
14089
|
promptId,
|
|
14036
14090
|
pendingSend.signal,
|
|
14037
|
-
|
|
14091
|
+
LlmRole.MAIN
|
|
14038
14092
|
);
|
|
14039
14093
|
nextMessage = null;
|
|
14040
14094
|
let turnInputTokens = 0;
|
|
@@ -14042,16 +14096,16 @@ ${thought.description}`;
|
|
|
14042
14096
|
let turnModelId = model;
|
|
14043
14097
|
for await (const resp of responseStream) {
|
|
14044
14098
|
if (pendingSend.signal.aborted) {
|
|
14045
|
-
return { stopReason:
|
|
14099
|
+
return { stopReason: CoreToolCallStatus.Cancelled };
|
|
14046
14100
|
}
|
|
14047
|
-
if (resp.type ===
|
|
14101
|
+
if (resp.type === StreamEventType.CHUNK && resp.value.usageMetadata) {
|
|
14048
14102
|
turnInputTokens = resp.value.usageMetadata.promptTokenCount ?? turnInputTokens;
|
|
14049
14103
|
turnOutputTokens = resp.value.usageMetadata.candidatesTokenCount ?? turnOutputTokens;
|
|
14050
14104
|
if (resp.value.modelVersion) {
|
|
14051
14105
|
turnModelId = resp.value.modelVersion;
|
|
14052
14106
|
}
|
|
14053
14107
|
}
|
|
14054
|
-
if (resp.type ===
|
|
14108
|
+
if (resp.type === StreamEventType.CHUNK && resp.value.candidates && resp.value.candidates.length > 0) {
|
|
14055
14109
|
const candidate = resp.value.candidates[0];
|
|
14056
14110
|
for (const part of candidate.content?.parts ?? []) {
|
|
14057
14111
|
if (!part.text) {
|
|
@@ -14067,7 +14121,7 @@ ${thought.description}`;
|
|
|
14067
14121
|
});
|
|
14068
14122
|
}
|
|
14069
14123
|
}
|
|
14070
|
-
if (resp.type ===
|
|
14124
|
+
if (resp.type === StreamEventType.CHUNK && resp.value.functionCalls) {
|
|
14071
14125
|
functionCalls.push(...resp.value.functionCalls);
|
|
14072
14126
|
}
|
|
14073
14127
|
}
|
|
@@ -14083,7 +14137,7 @@ ${thought.description}`;
|
|
|
14083
14137
|
modelUsageMap.set(turnModelId, existing);
|
|
14084
14138
|
}
|
|
14085
14139
|
if (pendingSend.signal.aborted) {
|
|
14086
|
-
return { stopReason:
|
|
14140
|
+
return { stopReason: CoreToolCallStatus.Cancelled };
|
|
14087
14141
|
}
|
|
14088
14142
|
} catch (error) {
|
|
14089
14143
|
if (getErrorStatus(error) === 429) {
|
|
@@ -14093,7 +14147,7 @@ ${thought.description}`;
|
|
|
14093
14147
|
);
|
|
14094
14148
|
}
|
|
14095
14149
|
if (pendingSend.signal.aborted || error instanceof Error && error.name === "AbortError") {
|
|
14096
|
-
return { stopReason:
|
|
14150
|
+
return { stopReason: CoreToolCallStatus.Cancelled };
|
|
14097
14151
|
}
|
|
14098
14152
|
if (error instanceof InvalidStreamError || error && typeof error === "object" && "type" in error && (error.type === "NO_RESPONSE_TEXT" || error.type === "NO_FINISH_REASON" || error.type === "MALFORMED_FUNCTION_CALL" || error.type === "UNEXPECTED_TOOL_CALL")) {
|
|
14099
14153
|
return {
|
|
@@ -14257,7 +14311,7 @@ ${thought.description}`;
|
|
|
14257
14311
|
const output = RequestPermissionResponseSchema.parse(
|
|
14258
14312
|
await this.connection.requestPermission(params)
|
|
14259
14313
|
);
|
|
14260
|
-
const outcome = output.outcome.outcome === "cancelled" ?
|
|
14314
|
+
const outcome = output.outcome.outcome === "cancelled" ? ToolConfirmationOutcome.Cancel : external_exports.nativeEnum(ToolConfirmationOutcome).parse(output.outcome.optionId);
|
|
14261
14315
|
await confirmationDetails.onConfirm(outcome);
|
|
14262
14316
|
await updatePolicy(
|
|
14263
14317
|
tool,
|
|
@@ -14268,16 +14322,16 @@ ${thought.description}`;
|
|
|
14268
14322
|
invocation
|
|
14269
14323
|
);
|
|
14270
14324
|
switch (outcome) {
|
|
14271
|
-
case
|
|
14325
|
+
case ToolConfirmationOutcome.Cancel:
|
|
14272
14326
|
return errorResponse(
|
|
14273
14327
|
new Error(`Tool "${fc.name}" was canceled by the user.`)
|
|
14274
14328
|
);
|
|
14275
|
-
case
|
|
14276
|
-
case
|
|
14277
|
-
case
|
|
14278
|
-
case
|
|
14279
|
-
case
|
|
14280
|
-
case
|
|
14329
|
+
case ToolConfirmationOutcome.ProceedOnce:
|
|
14330
|
+
case ToolConfirmationOutcome.ProceedAlways:
|
|
14331
|
+
case ToolConfirmationOutcome.ProceedAlwaysAndSave:
|
|
14332
|
+
case ToolConfirmationOutcome.ProceedAlwaysServer:
|
|
14333
|
+
case ToolConfirmationOutcome.ProceedAlwaysTool:
|
|
14334
|
+
case ToolConfirmationOutcome.ModifyWithEditor:
|
|
14281
14335
|
break;
|
|
14282
14336
|
default: {
|
|
14283
14337
|
const resultOutcome = outcome;
|
|
@@ -14325,7 +14379,7 @@ ${thought.description}`;
|
|
|
14325
14379
|
);
|
|
14326
14380
|
this.chat.recordCompletedToolCalls(this.context.config.getActiveModel(), [
|
|
14327
14381
|
{
|
|
14328
|
-
status:
|
|
14382
|
+
status: CoreToolCallStatus.Success,
|
|
14329
14383
|
request: {
|
|
14330
14384
|
callId,
|
|
14331
14385
|
name: fc.name,
|
|
@@ -14370,7 +14424,7 @@ ${thought.description}`;
|
|
|
14370
14424
|
});
|
|
14371
14425
|
this.chat.recordCompletedToolCalls(this.context.config.getActiveModel(), [
|
|
14372
14426
|
{
|
|
14373
|
-
status:
|
|
14427
|
+
status: CoreToolCallStatus.Error,
|
|
14374
14428
|
request: {
|
|
14375
14429
|
callId,
|
|
14376
14430
|
name: fc.name,
|
|
@@ -14485,12 +14539,12 @@ ${thought.description}`;
|
|
|
14485
14539
|
sessionId: this.id,
|
|
14486
14540
|
options: [
|
|
14487
14541
|
{
|
|
14488
|
-
optionId:
|
|
14542
|
+
optionId: ToolConfirmationOutcome.ProceedOnce,
|
|
14489
14543
|
name: "Allow once",
|
|
14490
14544
|
kind: "allow_once"
|
|
14491
14545
|
},
|
|
14492
14546
|
{
|
|
14493
|
-
optionId:
|
|
14547
|
+
optionId: ToolConfirmationOutcome.Cancel,
|
|
14494
14548
|
name: "Deny",
|
|
14495
14549
|
kind: "reject_once"
|
|
14496
14550
|
}
|
|
@@ -14515,8 +14569,8 @@ ${thought.description}`;
|
|
|
14515
14569
|
const output = RequestPermissionResponseSchema.parse(
|
|
14516
14570
|
await this.connection.requestPermission(params)
|
|
14517
14571
|
);
|
|
14518
|
-
const outcome = output.outcome.outcome === "cancelled" ?
|
|
14519
|
-
if (outcome ===
|
|
14572
|
+
const outcome = output.outcome.outcome === "cancelled" ? ToolConfirmationOutcome.Cancel : external_exports.nativeEnum(ToolConfirmationOutcome).parse(output.outcome.optionId);
|
|
14573
|
+
if (outcome === ToolConfirmationOutcome.ProceedOnce) {
|
|
14520
14574
|
this.context.config.getWorkspaceContext().addReadOnlyPath(absolutePath);
|
|
14521
14575
|
validationError = null;
|
|
14522
14576
|
} else {
|
|
@@ -14893,12 +14947,12 @@ function toToolCallContent(toolResult) {
|
|
|
14893
14947
|
}
|
|
14894
14948
|
var basicPermissionOptions = [
|
|
14895
14949
|
{
|
|
14896
|
-
optionId:
|
|
14950
|
+
optionId: ToolConfirmationOutcome.ProceedOnce,
|
|
14897
14951
|
name: "Allow",
|
|
14898
14952
|
kind: "allow_once"
|
|
14899
14953
|
},
|
|
14900
14954
|
{
|
|
14901
|
-
optionId:
|
|
14955
|
+
optionId: ToolConfirmationOutcome.Cancel,
|
|
14902
14956
|
name: "Reject",
|
|
14903
14957
|
kind: "reject_once"
|
|
14904
14958
|
}
|
|
@@ -14910,13 +14964,13 @@ function toPermissionOptions(confirmation, config, enablePermanentToolApproval =
|
|
|
14910
14964
|
switch (confirmation.type) {
|
|
14911
14965
|
case "edit":
|
|
14912
14966
|
options.push({
|
|
14913
|
-
optionId:
|
|
14967
|
+
optionId: ToolConfirmationOutcome.ProceedAlways,
|
|
14914
14968
|
name: "Allow for this session",
|
|
14915
14969
|
kind: "allow_always"
|
|
14916
14970
|
});
|
|
14917
14971
|
if (enablePermanentToolApproval) {
|
|
14918
14972
|
options.push({
|
|
14919
|
-
optionId:
|
|
14973
|
+
optionId: ToolConfirmationOutcome.ProceedAlwaysAndSave,
|
|
14920
14974
|
name: "Allow for this file in all future sessions",
|
|
14921
14975
|
kind: "allow_always"
|
|
14922
14976
|
});
|
|
@@ -14924,13 +14978,13 @@ function toPermissionOptions(confirmation, config, enablePermanentToolApproval =
|
|
|
14924
14978
|
break;
|
|
14925
14979
|
case "exec":
|
|
14926
14980
|
options.push({
|
|
14927
|
-
optionId:
|
|
14981
|
+
optionId: ToolConfirmationOutcome.ProceedAlways,
|
|
14928
14982
|
name: "Allow for this session",
|
|
14929
14983
|
kind: "allow_always"
|
|
14930
14984
|
});
|
|
14931
14985
|
if (enablePermanentToolApproval) {
|
|
14932
14986
|
options.push({
|
|
14933
|
-
optionId:
|
|
14987
|
+
optionId: ToolConfirmationOutcome.ProceedAlwaysAndSave,
|
|
14934
14988
|
name: "Allow this command for all future sessions",
|
|
14935
14989
|
kind: "allow_always"
|
|
14936
14990
|
});
|
|
@@ -14939,19 +14993,19 @@ function toPermissionOptions(confirmation, config, enablePermanentToolApproval =
|
|
|
14939
14993
|
case "mcp":
|
|
14940
14994
|
options.push(
|
|
14941
14995
|
{
|
|
14942
|
-
optionId:
|
|
14996
|
+
optionId: ToolConfirmationOutcome.ProceedAlwaysServer,
|
|
14943
14997
|
name: "Allow all server tools for this session",
|
|
14944
14998
|
kind: "allow_always"
|
|
14945
14999
|
},
|
|
14946
15000
|
{
|
|
14947
|
-
optionId:
|
|
15001
|
+
optionId: ToolConfirmationOutcome.ProceedAlwaysTool,
|
|
14948
15002
|
name: "Allow tool for this session",
|
|
14949
15003
|
kind: "allow_always"
|
|
14950
15004
|
}
|
|
14951
15005
|
);
|
|
14952
15006
|
if (enablePermanentToolApproval) {
|
|
14953
15007
|
options.push({
|
|
14954
|
-
optionId:
|
|
15008
|
+
optionId: ToolConfirmationOutcome.ProceedAlwaysAndSave,
|
|
14955
15009
|
name: "Allow tool for all future sessions",
|
|
14956
15010
|
kind: "allow_always"
|
|
14957
15011
|
});
|
|
@@ -14959,13 +15013,13 @@ function toPermissionOptions(confirmation, config, enablePermanentToolApproval =
|
|
|
14959
15013
|
break;
|
|
14960
15014
|
case "info":
|
|
14961
15015
|
options.push({
|
|
14962
|
-
optionId:
|
|
15016
|
+
optionId: ToolConfirmationOutcome.ProceedAlways,
|
|
14963
15017
|
name: "Allow for this session",
|
|
14964
15018
|
kind: "allow_always"
|
|
14965
15019
|
});
|
|
14966
15020
|
if (enablePermanentToolApproval) {
|
|
14967
15021
|
options.push({
|
|
14968
|
-
optionId:
|
|
15022
|
+
optionId: ToolConfirmationOutcome.ProceedAlwaysAndSave,
|
|
14969
15023
|
name: "Allow for all future sessions",
|
|
14970
15024
|
kind: "allow_always"
|
|
14971
15025
|
});
|
|
@@ -14997,21 +15051,21 @@ function toPermissionOptions(confirmation, config, enablePermanentToolApproval =
|
|
|
14997
15051
|
}
|
|
14998
15052
|
function toAcpToolKind(kind) {
|
|
14999
15053
|
switch (kind) {
|
|
15000
|
-
case
|
|
15001
|
-
case
|
|
15002
|
-
case
|
|
15003
|
-
case
|
|
15004
|
-
case
|
|
15005
|
-
case
|
|
15006
|
-
case
|
|
15007
|
-
case
|
|
15008
|
-
case
|
|
15009
|
-
case
|
|
15054
|
+
case Kind.Read:
|
|
15055
|
+
case Kind.Edit:
|
|
15056
|
+
case Kind.Execute:
|
|
15057
|
+
case Kind.Search:
|
|
15058
|
+
case Kind.Delete:
|
|
15059
|
+
case Kind.Move:
|
|
15060
|
+
case Kind.Think:
|
|
15061
|
+
case Kind.Fetch:
|
|
15062
|
+
case Kind.SwitchMode:
|
|
15063
|
+
case Kind.Other:
|
|
15010
15064
|
return kind;
|
|
15011
|
-
case
|
|
15065
|
+
case Kind.Agent:
|
|
15012
15066
|
return "think";
|
|
15013
|
-
case
|
|
15014
|
-
case
|
|
15067
|
+
case Kind.Plan:
|
|
15068
|
+
case Kind.Communicate:
|
|
15015
15069
|
default:
|
|
15016
15070
|
return "other";
|
|
15017
15071
|
}
|
|
@@ -15019,24 +15073,24 @@ function toAcpToolKind(kind) {
|
|
|
15019
15073
|
function buildAvailableModes(isPlanEnabled) {
|
|
15020
15074
|
const modes = [
|
|
15021
15075
|
{
|
|
15022
|
-
id:
|
|
15076
|
+
id: ApprovalMode.DEFAULT,
|
|
15023
15077
|
name: "Default",
|
|
15024
15078
|
description: "Prompts for approval"
|
|
15025
15079
|
},
|
|
15026
15080
|
{
|
|
15027
|
-
id:
|
|
15081
|
+
id: ApprovalMode.AUTO_EDIT,
|
|
15028
15082
|
name: "Auto Edit",
|
|
15029
15083
|
description: "Auto-approves edit tools"
|
|
15030
15084
|
},
|
|
15031
15085
|
{
|
|
15032
|
-
id:
|
|
15086
|
+
id: ApprovalMode.YOLO,
|
|
15033
15087
|
name: "YOLO",
|
|
15034
15088
|
description: "Auto-approves all tools"
|
|
15035
15089
|
}
|
|
15036
15090
|
];
|
|
15037
15091
|
if (isPlanEnabled) {
|
|
15038
15092
|
modes.push({
|
|
15039
|
-
id:
|
|
15093
|
+
id: ApprovalMode.PLAN,
|
|
15040
15094
|
name: "Plan",
|
|
15041
15095
|
description: "Read-only mode"
|
|
15042
15096
|
});
|
|
@@ -15049,7 +15103,7 @@ function buildAvailableModels(config, settings) {
|
|
|
15049
15103
|
const useGemini31 = config.getGemini31LaunchedSync?.() ?? false;
|
|
15050
15104
|
const useGemini31FlashLite = config.getGemini31FlashLiteLaunchedSync?.() ?? false;
|
|
15051
15105
|
const selectedAuthType = settings.merged.security.auth.selectedType;
|
|
15052
|
-
const useCustomToolModel = useGemini31 && selectedAuthType ===
|
|
15106
|
+
const useCustomToolModel = useGemini31 && selectedAuthType === AuthType.USE_GEMINI;
|
|
15053
15107
|
if (config.getExperimentalDynamicModelConfiguration?.() === true && config.getModelConfigService) {
|
|
15054
15108
|
const options = config.getModelConfigService().getAvailableModelOptions({
|
|
15055
15109
|
useGemini3_1: useGemini31,
|
|
@@ -15147,7 +15201,7 @@ async function validateNonInteractiveAuth(configuredAuthType, useExternalAuth, n
|
|
|
15147
15201
|
}
|
|
15148
15202
|
return authType;
|
|
15149
15203
|
} catch (error) {
|
|
15150
|
-
if (nonInteractiveConfig.getOutputFormat() ===
|
|
15204
|
+
if (nonInteractiveConfig.getOutputFormat() === OutputFormat.JSON) {
|
|
15151
15205
|
handleError(
|
|
15152
15206
|
error instanceof Error ? error : new Error(String(error)),
|
|
15153
15207
|
nonInteractiveConfig,
|
|
@@ -15343,10 +15397,10 @@ var SlashCommandConflictHandler = class {
|
|
|
15343
15397
|
this.handleConflicts = this.handleConflicts.bind(this);
|
|
15344
15398
|
}
|
|
15345
15399
|
start() {
|
|
15346
|
-
coreEvents.on(
|
|
15400
|
+
coreEvents.on(CoreEvent.SlashCommandConflicts, this.handleConflicts);
|
|
15347
15401
|
}
|
|
15348
15402
|
stop() {
|
|
15349
|
-
coreEvents.off(
|
|
15403
|
+
coreEvents.off(CoreEvent.SlashCommandConflicts, this.handleConflicts);
|
|
15350
15404
|
if (this.flushTimeout) {
|
|
15351
15405
|
clearTimeout(this.flushTimeout);
|
|
15352
15406
|
this.flushTimeout = null;
|
|
@@ -15557,7 +15611,7 @@ async function resolveSessionId(resumeArg) {
|
|
|
15557
15611
|
}
|
|
15558
15612
|
}
|
|
15559
15613
|
async function startInteractiveUI(config, settings, startupWarnings, workspaceRoot = process.cwd(), resumedSessionData, initializationResult) {
|
|
15560
|
-
const { startInteractiveUI: doStartUI } = await import("./interactiveCli-
|
|
15614
|
+
const { startInteractiveUI: doStartUI } = await import("./interactiveCli-MVHR4VV7.js");
|
|
15561
15615
|
await doStartUI(
|
|
15562
15616
|
config,
|
|
15563
15617
|
settings,
|
|
@@ -15656,12 +15710,12 @@ async function main() {
|
|
|
15656
15710
|
dns.setDefaultResultOrder(
|
|
15657
15711
|
validateDnsResolutionOrder(settings.merged.advanced.dnsResolutionOrder)
|
|
15658
15712
|
);
|
|
15659
|
-
if (!settings.merged.security.auth.selectedType || settings.merged.security.auth.selectedType ===
|
|
15713
|
+
if (!settings.merged.security.auth.selectedType || settings.merged.security.auth.selectedType === AuthType.LEGACY_CLOUD_SHELL) {
|
|
15660
15714
|
if (process.env["CLOUD_SHELL"] === "true" || process.env["GEMINI_CLI_USE_COMPUTE_ADC"] === "true") {
|
|
15661
15715
|
settings.setValue(
|
|
15662
15716
|
"User" /* User */,
|
|
15663
15717
|
"security.auth.selectedType",
|
|
15664
|
-
|
|
15718
|
+
AuthType.COMPUTE_ADC
|
|
15665
15719
|
);
|
|
15666
15720
|
}
|
|
15667
15721
|
}
|
|
@@ -15759,7 +15813,7 @@ ${finalArgs[promptIndex + 1]}`;
|
|
|
15759
15813
|
await config.storage.initialize();
|
|
15760
15814
|
adminControlsListner.setConfig(config);
|
|
15761
15815
|
if (config.isInteractive() && settings.merged.general.devtools) {
|
|
15762
|
-
const { setupInitialActivityLogger } = await import("./devtoolsService-
|
|
15816
|
+
const { setupInitialActivityLogger } = await import("./devtoolsService-YCRNWWXE.js");
|
|
15763
15817
|
setupInitialActivityLogger(config);
|
|
15764
15818
|
}
|
|
15765
15819
|
registerTelemetryConfig(config);
|
|
@@ -15767,7 +15821,7 @@ ${finalArgs[promptIndex + 1]}`;
|
|
|
15767
15821
|
const messageBus = config.getMessageBus();
|
|
15768
15822
|
createPolicyUpdater2(policyEngine, messageBus, config.storage);
|
|
15769
15823
|
registerCleanup(async () => {
|
|
15770
|
-
await config.getHookSystem()?.fireSessionEndEvent(
|
|
15824
|
+
await config.getHookSystem()?.fireSessionEndEvent(SessionEndReason.Exit);
|
|
15771
15825
|
});
|
|
15772
15826
|
cleanupExpiredSessions(config, settings.merged).catch((e) => {
|
|
15773
15827
|
debugLogger.error("Failed to cleanup expired sessions:", e);
|
|
@@ -15815,7 +15869,7 @@ ${finalArgs[promptIndex + 1]}`;
|
|
|
15815
15869
|
const initAppHandle = startupProfiler.start("initialize_app");
|
|
15816
15870
|
const initializationResult = await initializeApp(config, settings);
|
|
15817
15871
|
initAppHandle?.end();
|
|
15818
|
-
import("./liteRtServerManager-
|
|
15872
|
+
import("./liteRtServerManager-PI4ZNFB5.js").then(({ LiteRtServerManager }) => {
|
|
15819
15873
|
const mergedGemma = settings.merged.experimental?.gemmaModelRouter;
|
|
15820
15874
|
if (!mergedGemma) return;
|
|
15821
15875
|
const userGemma = settings.forScope("User" /* User */).settings.experimental?.gemmaModelRouter;
|
|
@@ -15825,7 +15879,7 @@ ${finalArgs[promptIndex + 1]}`;
|
|
|
15825
15879
|
autoStartServer: userGemma?.autoStartServer
|
|
15826
15880
|
});
|
|
15827
15881
|
}).catch((e) => debugLogger.warn("LiteRT auto-start import failed:", e));
|
|
15828
|
-
if (settings.merged.security.auth.selectedType ===
|
|
15882
|
+
if (settings.merged.security.auth.selectedType === AuthType.LOGIN_WITH_GOOGLE && config.isBrowserLaunchSuppressed()) {
|
|
15829
15883
|
await getOauthClient(settings.merged.security.auth.selectedType, config);
|
|
15830
15884
|
}
|
|
15831
15885
|
if (config.getAcpMode()) {
|
|
@@ -15841,13 +15895,18 @@ ${finalArgs[promptIndex + 1]}`;
|
|
|
15841
15895
|
...rawStartupWarnings.map((message) => ({
|
|
15842
15896
|
id: `startup-${createHash2("sha256").update(message).digest("hex").substring(0, 16)}`,
|
|
15843
15897
|
message,
|
|
15844
|
-
priority:
|
|
15898
|
+
priority: WarningPriority.High
|
|
15845
15899
|
})),
|
|
15846
15900
|
...await getUserStartupWarnings(settings.merged, void 0, {
|
|
15847
15901
|
isAlternateBuffer: useAlternateBuffer
|
|
15848
15902
|
})
|
|
15849
15903
|
];
|
|
15850
15904
|
cliStartupHandle?.end();
|
|
15905
|
+
if (!config.isInteractive()) {
|
|
15906
|
+
for (const warning of startupWarnings) {
|
|
15907
|
+
writeToStderr(warning.message + "\n");
|
|
15908
|
+
}
|
|
15909
|
+
}
|
|
15851
15910
|
if (config.isInteractive()) {
|
|
15852
15911
|
if (process.stdin.isTTY) {
|
|
15853
15912
|
process.stdin.resume();
|
|
@@ -15873,7 +15932,7 @@ ${finalArgs[promptIndex + 1]}`;
|
|
|
15873
15932
|
${input}` : stdinData;
|
|
15874
15933
|
}
|
|
15875
15934
|
}
|
|
15876
|
-
const sessionStartSource = resumedSessionData ?
|
|
15935
|
+
const sessionStartSource = resumedSessionData ? SessionStartSource.Resume : SessionStartSource.Startup;
|
|
15877
15936
|
const hookSystem = config?.getHookSystem();
|
|
15878
15937
|
if (hookSystem) {
|
|
15879
15938
|
const result = await hookSystem.fireSessionStartEvent(sessionStartSource);
|
|
@@ -15930,16 +15989,16 @@ ${input}` : wrappedContext;
|
|
|
15930
15989
|
}
|
|
15931
15990
|
}
|
|
15932
15991
|
function initializeOutputListenersAndFlush() {
|
|
15933
|
-
if (coreEvents.listenerCount(
|
|
15934
|
-
coreEvents.on(
|
|
15992
|
+
if (coreEvents.listenerCount(CoreEvent.Output) === 0) {
|
|
15993
|
+
coreEvents.on(CoreEvent.Output, (payload) => {
|
|
15935
15994
|
if (payload.isStderr) {
|
|
15936
15995
|
writeToStderr(payload.chunk, payload.encoding);
|
|
15937
15996
|
} else {
|
|
15938
15997
|
writeToStdout(payload.chunk, payload.encoding);
|
|
15939
15998
|
}
|
|
15940
15999
|
});
|
|
15941
|
-
if (coreEvents.listenerCount(
|
|
15942
|
-
coreEvents.on(
|
|
16000
|
+
if (coreEvents.listenerCount(CoreEvent.ConsoleLog) === 0) {
|
|
16001
|
+
coreEvents.on(CoreEvent.ConsoleLog, (payload) => {
|
|
15943
16002
|
if (payload.type === "error" || payload.type === "warn") {
|
|
15944
16003
|
writeToStderr(payload.content);
|
|
15945
16004
|
} else {
|
|
@@ -15947,8 +16006,8 @@ function initializeOutputListenersAndFlush() {
|
|
|
15947
16006
|
}
|
|
15948
16007
|
});
|
|
15949
16008
|
}
|
|
15950
|
-
if (coreEvents.listenerCount(
|
|
15951
|
-
coreEvents.on(
|
|
16009
|
+
if (coreEvents.listenerCount(CoreEvent.UserFeedback) === 0) {
|
|
16010
|
+
coreEvents.on(CoreEvent.UserFeedback, (payload) => {
|
|
15952
16011
|
if (payload.severity === "error" || payload.severity === "warning") {
|
|
15953
16012
|
writeToStderr(payload.message);
|
|
15954
16013
|
} else {
|