@google/gemini-cli 0.41.0 → 0.41.1
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-CZW4D4RQ.js → chunk-2M535E4N.js} +1 -1
- package/bundle/{chunk-J7E7PI4S.js → chunk-3GXWDP2Z.js} +2 -2
- package/bundle/{chunk-7LNZOOC7.js → chunk-5ER6FL2Y.js} +6 -6
- package/bundle/{chunk-TOU7GDCS.js → chunk-7FNKSW4V.js} +3 -3
- package/bundle/{chunk-KHDD5ZQT.js → chunk-ADVHH43I.js} +1 -1
- package/bundle/{chunk-4CB5QYON.js → chunk-B54V2534.js} +1 -1
- package/bundle/{chunk-KYES7RJ6.js → chunk-BDY3Y2BR.js} +67 -54
- package/bundle/{chunk-5ZVQP4WN.js → chunk-C3LH3AWP.js} +1 -1
- package/bundle/chunk-CD2YCJUK.js +1571 -0
- package/bundle/{chunk-G2G5UOIR.js → chunk-ERP434XO.js} +2 -2
- package/bundle/{chunk-KMY2ICHB.js → chunk-GFBZBZM3.js} +1 -1
- package/bundle/chunk-GFQ7AKID.js +80034 -0
- package/bundle/{chunk-5ECQHX5C.js → chunk-HBHMDJOI.js} +2 -2
- package/bundle/{chunk-V7GQYOIO.js → chunk-KZLRP6TK.js} +14 -12
- package/bundle/{chunk-CWJ5KY34.js → chunk-MKCUVUHS.js} +1 -1
- package/bundle/chunk-MTG3QVUK.js +156 -0
- package/bundle/{chunk-CSDNDSTO.js → chunk-NET4RIEQ.js} +5 -6
- package/bundle/{chunk-RVECIZP6.js → chunk-NGEOWUR5.js} +1 -1
- package/bundle/{chunk-GLO32GZ3.js → chunk-QQRBSOY4.js} +6674 -12455
- package/bundle/chunk-RP6RRIFW.js +354495 -0
- package/bundle/chunk-WDKZY7RV.js +118 -0
- package/bundle/chunk-WKN2PII5.js +17656 -0
- package/bundle/{chunk-F6MNV4SZ.js → chunk-WYR3JYKD.js} +6 -6
- package/bundle/{chunk-B2LNN6KY.js → chunk-ZJ6QM64B.js} +5 -6
- package/bundle/{cleanup-KMEBTV6K.js → cleanup-4US6BQ7H.js} +2 -2
- package/bundle/{cleanup-OJM7LXCH.js → cleanup-AUMQFWYH.js} +2 -2
- package/bundle/{cleanup-PMJYRELA.js → cleanup-CCK65JHL.js} +3 -3
- package/bundle/cleanup-PDD4G7CM.js +33 -0
- package/bundle/{core-MMHOAGLI.js → core-IIYBYA3H.js} +1 -1
- package/bundle/{devtoolsService-BDOWEGHR.js → devtoolsService-5ERNFOME.js} +2 -2
- package/bundle/{devtoolsService-YPN2GRY7.js → devtoolsService-BI57Y3RH.js} +2 -2
- package/bundle/{devtoolsService-ARI22QWG.js → devtoolsService-G5DQ5SFK.js} +5 -4
- package/bundle/devtoolsService-V5XEJ55W.js +857 -0
- package/bundle/{dist-V6XXY2AS.js → dist-32N3LPNC.js} +1 -1
- package/bundle/{core-4PBU56P6.js → dist-5VLOJX4U.js} +2 -2
- package/bundle/dist-FEOGEVKF.js +2068 -0
- package/bundle/{gemini-RGSMPB6F.js → gemini-OHH6WLHR.js} +191 -175
- package/bundle/gemini-PXQLGA7D.js +15988 -0
- package/bundle/{gemini-GSCVWK7Y.js → gemini-ZGIV3WZZ.js} +11 -11
- package/bundle/{gemini-LDARUG77.js → gemini-ZQZBCZWU.js} +11 -11
- package/bundle/gemini.js +3 -3
- package/bundle/{interactiveCli-5JCJD3F5.js → interactiveCli-7ONNIC6E.js} +6 -6
- package/bundle/interactiveCli-FBIC3JEN.js +35052 -0
- package/bundle/{interactiveCli-KSSJ4M5C.js → interactiveCli-NFPPWAK4.js} +6 -6
- package/bundle/{interactiveCli-ZNAMZNEE.js → interactiveCli-UPXIMCUC.js} +290 -272
- package/bundle/{liteRtServerManager-I6PXKOCJ.js → liteRtServerManager-5Y2K46O6.js} +3 -3
- package/bundle/{liteRtServerManager-QZCLWSIV.js → liteRtServerManager-BYX3KONC.js} +4 -4
- package/bundle/{liteRtServerManager-PG57YSDR.js → liteRtServerManager-CGOJZBD4.js} +3 -3
- package/bundle/liteRtServerManager-X6WJ4JCX.js +65 -0
- package/bundle/node_modules/@google/gemini-cli-devtools/package.json +1 -1
- package/bundle/{oauth2-provider-MV6Q65XJ.js → oauth2-provider-RRLKUWA6.js} +1 -1
- package/bundle/{oauth2-provider-356MTA5N.js → oauth2-provider-XEGUC3FK.js} +1 -1
- package/bundle/{oauth2-provider-SWABWSBH.js → oauth2-provider-XW4ECB2J.js} +39 -73
- package/bundle/oauth2-provider-YQK2OECL.js +237 -0
- package/bundle/{start-S2GPZKGW.js → start-D3TFWOXP.js} +5 -5
- package/bundle/{start-FWXRAXKY.js → start-EFBJ3Y46.js} +6 -6
- package/bundle/start-SYKO5XMN.js +18 -0
- package/bundle/{start-MWJKRZPA.js → start-XFACWOPQ.js} +5 -5
- package/package.json +1 -1
|
@@ -42,18 +42,18 @@ import {
|
|
|
42
42
|
updateAllUpdatableExtensions,
|
|
43
43
|
updateExtension,
|
|
44
44
|
validateAuthMethod
|
|
45
|
-
} from "./chunk-
|
|
45
|
+
} from "./chunk-BDY3Y2BR.js";
|
|
46
46
|
import {
|
|
47
47
|
appEvents
|
|
48
48
|
} from "./chunk-5PS3AYFU.js";
|
|
49
49
|
import {
|
|
50
50
|
startCommand,
|
|
51
51
|
startServer
|
|
52
|
-
} from "./chunk-
|
|
52
|
+
} from "./chunk-WDKZY7RV.js";
|
|
53
53
|
import {
|
|
54
54
|
exitCli,
|
|
55
55
|
require_source
|
|
56
|
-
} from "./chunk-
|
|
56
|
+
} from "./chunk-2M535E4N.js";
|
|
57
57
|
import {
|
|
58
58
|
DEFAULT_PORT,
|
|
59
59
|
GEMMA_MODEL_NAME,
|
|
@@ -87,7 +87,7 @@ import {
|
|
|
87
87
|
readServerProcessInfo,
|
|
88
88
|
resolveGemmaConfig,
|
|
89
89
|
saveModelChange
|
|
90
|
-
} from "./chunk-
|
|
90
|
+
} from "./chunk-GFBZBZM3.js";
|
|
91
91
|
import {
|
|
92
92
|
cleanupCheckpoints,
|
|
93
93
|
registerCleanup,
|
|
@@ -96,32 +96,44 @@ import {
|
|
|
96
96
|
runExitCleanup,
|
|
97
97
|
runSyncCleanup,
|
|
98
98
|
setupSignalHandlers
|
|
99
|
-
} from "./chunk-
|
|
99
|
+
} from "./chunk-MTG3QVUK.js";
|
|
100
100
|
import {
|
|
101
101
|
AuthType,
|
|
102
102
|
ChatRecordingService,
|
|
103
103
|
Client,
|
|
104
104
|
Config,
|
|
105
|
+
CoreToolCallStatus,
|
|
105
106
|
ExitCodes,
|
|
106
107
|
FileDiscoveryService,
|
|
107
108
|
FolderTrustDiscoveryService,
|
|
109
|
+
GeminiEventType,
|
|
108
110
|
IdeClient,
|
|
111
|
+
IntegrityStatus,
|
|
109
112
|
InvalidStreamError,
|
|
110
113
|
JsonFormatter,
|
|
114
|
+
JsonStreamEventType,
|
|
111
115
|
LegacyAgentSession,
|
|
116
|
+
LlmRole,
|
|
112
117
|
Logger,
|
|
113
118
|
MCPServerConfig,
|
|
119
|
+
MCPServerStatus,
|
|
120
|
+
OutputFormat,
|
|
114
121
|
PolicyIntegrityManager,
|
|
115
122
|
ROOT_SCHEDULER_ID,
|
|
116
123
|
ReadManyFilesTool,
|
|
117
124
|
Scheduler,
|
|
125
|
+
SessionEndReason,
|
|
126
|
+
SessionStartSource,
|
|
118
127
|
ShellExecutionService,
|
|
128
|
+
StreamEventType,
|
|
119
129
|
StreamJsonFormatter,
|
|
120
130
|
ToolCallEvent,
|
|
131
|
+
TrustLevel,
|
|
121
132
|
UserAccountManager,
|
|
122
133
|
UserPromptEvent,
|
|
123
134
|
ValidationCancelledError,
|
|
124
135
|
ValidationRequiredError,
|
|
136
|
+
WarningPriority,
|
|
125
137
|
addMemory,
|
|
126
138
|
applyAdminAllowlist,
|
|
127
139
|
applyRequiredServers,
|
|
@@ -183,9 +195,11 @@ import {
|
|
|
183
195
|
updatePolicy,
|
|
184
196
|
writeToStderr,
|
|
185
197
|
writeToStdout
|
|
186
|
-
} from "./chunk-
|
|
198
|
+
} from "./chunk-NET4RIEQ.js";
|
|
187
199
|
import {
|
|
188
200
|
ASK_USER_TOOL_NAME,
|
|
201
|
+
ApprovalMode,
|
|
202
|
+
CoreEvent,
|
|
189
203
|
DEFAULT_FILE_FILTERING_OPTIONS,
|
|
190
204
|
DEFAULT_GEMINI_EMBEDDING_MODEL,
|
|
191
205
|
DEFAULT_GEMINI_FLASH_LITE_MODEL,
|
|
@@ -205,6 +219,7 @@ import {
|
|
|
205
219
|
FatalUntrustedWorkspaceError,
|
|
206
220
|
GEMINI_DIR,
|
|
207
221
|
GEMINI_MODEL_ALIAS_AUTO,
|
|
222
|
+
Kind,
|
|
208
223
|
PREVIEW_GEMINI_3_1_CUSTOM_TOOLS_MODEL,
|
|
209
224
|
PREVIEW_GEMINI_3_1_FLASH_LITE_MODEL,
|
|
210
225
|
PREVIEW_GEMINI_3_1_MODEL,
|
|
@@ -214,6 +229,7 @@ import {
|
|
|
214
229
|
REFERENCE_CONTENT_START,
|
|
215
230
|
Storage,
|
|
216
231
|
ToolConfirmationOutcome,
|
|
232
|
+
ToolErrorType,
|
|
217
233
|
coreEvents,
|
|
218
234
|
debugLogger,
|
|
219
235
|
external_exports,
|
|
@@ -227,7 +243,7 @@ import {
|
|
|
227
243
|
loadServerHierarchicalMemory,
|
|
228
244
|
resolveToRealPath,
|
|
229
245
|
setGeminiMdFilename
|
|
230
|
-
} from "./chunk-
|
|
246
|
+
} from "./chunk-SAJ72M2G.js";
|
|
231
247
|
import "./chunk-664ZODQF.js";
|
|
232
248
|
import "./chunk-RJTRUG2J.js";
|
|
233
249
|
import "./chunk-IUUIT4SU.js";
|
|
@@ -5357,7 +5373,7 @@ var MCP_LIST_DEFAULT_TIMEOUT_MSEC = 5e3;
|
|
|
5357
5373
|
async function testMCPConnection(serverName, config, isTrusted, activeSettings) {
|
|
5358
5374
|
const isStdio = !!config.command;
|
|
5359
5375
|
if (isStdio && !isTrusted) {
|
|
5360
|
-
return
|
|
5376
|
+
return MCPServerStatus.DISCONNECTED;
|
|
5361
5377
|
}
|
|
5362
5378
|
const client = new Client({
|
|
5363
5379
|
name: "mcp-test-client",
|
|
@@ -5393,7 +5409,7 @@ async function testMCPConnection(serverName, config, isTrusted, activeSettings)
|
|
|
5393
5409
|
transport = await createTransport(serverName, config, false, mcpContext);
|
|
5394
5410
|
} catch {
|
|
5395
5411
|
await client.close();
|
|
5396
|
-
return
|
|
5412
|
+
return MCPServerStatus.DISCONNECTED;
|
|
5397
5413
|
}
|
|
5398
5414
|
try {
|
|
5399
5415
|
const timeout = config.timeout ?? MCP_LIST_DEFAULT_TIMEOUT_MSEC;
|
|
@@ -5407,10 +5423,10 @@ async function testMCPConnection(serverName, config, isTrusted, activeSettings)
|
|
|
5407
5423
|
);
|
|
5408
5424
|
}
|
|
5409
5425
|
await client.close();
|
|
5410
|
-
return
|
|
5426
|
+
return MCPServerStatus.CONNECTED;
|
|
5411
5427
|
} catch {
|
|
5412
5428
|
await transport.close();
|
|
5413
|
-
return
|
|
5429
|
+
return MCPServerStatus.DISCONNECTED;
|
|
5414
5430
|
}
|
|
5415
5431
|
}
|
|
5416
5432
|
async function getServerStatus(serverName, server, isTrusted, activeSettings) {
|
|
@@ -5423,9 +5439,9 @@ async function getServerStatus(serverName, server, isTrusted, activeSettings) {
|
|
|
5423
5439
|
});
|
|
5424
5440
|
if (!loadResult.allowed) {
|
|
5425
5441
|
if (loadResult.blockType === "admin" || loadResult.blockType === "allowlist" || loadResult.blockType === "excludelist") {
|
|
5426
|
-
return
|
|
5442
|
+
return MCPServerStatus.BLOCKED;
|
|
5427
5443
|
}
|
|
5428
|
-
return
|
|
5444
|
+
return MCPServerStatus.DISABLED;
|
|
5429
5445
|
}
|
|
5430
5446
|
return testMCPConnection(serverName, server, isTrusted, activeSettings);
|
|
5431
5447
|
}
|
|
@@ -5459,23 +5475,23 @@ async function listMcpServers(loadedSettingsArg) {
|
|
|
5459
5475
|
let statusIndicator = "";
|
|
5460
5476
|
let statusText = "";
|
|
5461
5477
|
switch (status) {
|
|
5462
|
-
case
|
|
5478
|
+
case MCPServerStatus.CONNECTED:
|
|
5463
5479
|
statusIndicator = import_chalk.default.green("\u2713");
|
|
5464
5480
|
statusText = "Connected";
|
|
5465
5481
|
break;
|
|
5466
|
-
case
|
|
5482
|
+
case MCPServerStatus.CONNECTING:
|
|
5467
5483
|
statusIndicator = import_chalk.default.yellow("\u2026");
|
|
5468
5484
|
statusText = "Connecting";
|
|
5469
5485
|
break;
|
|
5470
|
-
case
|
|
5486
|
+
case MCPServerStatus.BLOCKED:
|
|
5471
5487
|
statusIndicator = import_chalk.default.red("\u26D4");
|
|
5472
5488
|
statusText = "Blocked";
|
|
5473
5489
|
break;
|
|
5474
|
-
case
|
|
5490
|
+
case MCPServerStatus.DISABLED:
|
|
5475
5491
|
statusIndicator = import_chalk.default.gray("\u25CB");
|
|
5476
5492
|
statusText = "Disabled";
|
|
5477
5493
|
break;
|
|
5478
|
-
case
|
|
5494
|
+
case MCPServerStatus.DISCONNECTED:
|
|
5479
5495
|
default:
|
|
5480
5496
|
statusIndicator = import_chalk.default.red("\u2717");
|
|
5481
5497
|
statusText = "Disconnected";
|
|
@@ -5761,7 +5777,7 @@ async function handleInstall(args) {
|
|
|
5761
5777
|
);
|
|
5762
5778
|
if (confirmed) {
|
|
5763
5779
|
const trustedFolders = loadTrustedFolders();
|
|
5764
|
-
await trustedFolders.setValue(realPath,
|
|
5780
|
+
await trustedFolders.setValue(realPath, TrustLevel.TRUST_FOLDER);
|
|
5765
5781
|
} else {
|
|
5766
5782
|
throw new Error(
|
|
5767
5783
|
`Installation aborted: Folder "${absolutePath}" is not trusted.`
|
|
@@ -7806,7 +7822,7 @@ async function loadSandboxConfig(settings, argv) {
|
|
|
7806
7822
|
}
|
|
7807
7823
|
const command2 = getSandboxCommand(sandboxValue);
|
|
7808
7824
|
const packageJson = await getPackageJson(__dirname3);
|
|
7809
|
-
const image = process.env["GEMINI_SANDBOX_IMAGE"] ?? "us-docker.pkg.dev/gemini-code-dev/gemini-cli/sandbox:0.41.
|
|
7825
|
+
const image = process.env["GEMINI_SANDBOX_IMAGE"] ?? "us-docker.pkg.dev/gemini-code-dev/gemini-cli/sandbox:0.41.1" ?? customImage ?? packageJson?.config?.sandboxImageUri;
|
|
7810
7826
|
const isNative = command2 === "windows-native" || command2 === "sandbox-exec" || command2 === "lxc";
|
|
7811
7827
|
return command2 && (image || isNative) ? { enabled: true, allowedPaths, networkAccess, command: command2, image } : void 0;
|
|
7812
7828
|
}
|
|
@@ -7865,9 +7881,9 @@ async function resolveWorkspacePolicyState(options) {
|
|
|
7865
7881
|
cwd,
|
|
7866
7882
|
potentialWorkspacePoliciesDir
|
|
7867
7883
|
);
|
|
7868
|
-
if (integrityResult.status ===
|
|
7884
|
+
if (integrityResult.status === IntegrityStatus.MATCH) {
|
|
7869
7885
|
workspacePoliciesDir = potentialWorkspacePoliciesDir;
|
|
7870
|
-
} else if (integrityResult.status ===
|
|
7886
|
+
} else if (integrityResult.status === IntegrityStatus.NEW && integrityResult.fileCount === 0) {
|
|
7871
7887
|
workspacePoliciesDir = void 0;
|
|
7872
7888
|
} else if (interactive && !autoAcceptWorkspacePolicies) {
|
|
7873
7889
|
policyUpdateConfirmationRequest = {
|
|
@@ -8298,23 +8314,23 @@ async function loadCliConfig(settings, sessionId, argv, options = {}) {
|
|
|
8298
8314
|
if (rawApprovalMode) {
|
|
8299
8315
|
switch (rawApprovalMode) {
|
|
8300
8316
|
case "yolo":
|
|
8301
|
-
approvalMode =
|
|
8317
|
+
approvalMode = ApprovalMode.YOLO;
|
|
8302
8318
|
break;
|
|
8303
8319
|
case "auto_edit":
|
|
8304
|
-
approvalMode =
|
|
8320
|
+
approvalMode = ApprovalMode.AUTO_EDIT;
|
|
8305
8321
|
break;
|
|
8306
8322
|
case "plan":
|
|
8307
8323
|
if (!(settings.general?.plan?.enabled ?? true)) {
|
|
8308
8324
|
debugLogger.warn(
|
|
8309
8325
|
'Approval mode "plan" is disabled in your settings. Falling back to "default".'
|
|
8310
8326
|
);
|
|
8311
|
-
approvalMode =
|
|
8327
|
+
approvalMode = ApprovalMode.DEFAULT;
|
|
8312
8328
|
} else {
|
|
8313
|
-
approvalMode =
|
|
8329
|
+
approvalMode = ApprovalMode.PLAN;
|
|
8314
8330
|
}
|
|
8315
8331
|
break;
|
|
8316
8332
|
case "default":
|
|
8317
|
-
approvalMode =
|
|
8333
|
+
approvalMode = ApprovalMode.DEFAULT;
|
|
8318
8334
|
break;
|
|
8319
8335
|
default:
|
|
8320
8336
|
throw new Error(
|
|
@@ -8322,10 +8338,10 @@ async function loadCliConfig(settings, sessionId, argv, options = {}) {
|
|
|
8322
8338
|
);
|
|
8323
8339
|
}
|
|
8324
8340
|
} else {
|
|
8325
|
-
approvalMode =
|
|
8341
|
+
approvalMode = ApprovalMode.DEFAULT;
|
|
8326
8342
|
}
|
|
8327
8343
|
if (settings.security?.disableYoloMode || settings.admin?.secureModeEnabled) {
|
|
8328
|
-
if (approvalMode ===
|
|
8344
|
+
if (approvalMode === ApprovalMode.YOLO) {
|
|
8329
8345
|
if (settings.admin?.secureModeEnabled) {
|
|
8330
8346
|
debugLogger.error(
|
|
8331
8347
|
'YOLO mode is disabled by "secureModeEnabled" setting.'
|
|
@@ -8343,16 +8359,16 @@ async function loadCliConfig(settings, sessionId, argv, options = {}) {
|
|
|
8343
8359
|
)
|
|
8344
8360
|
);
|
|
8345
8361
|
}
|
|
8346
|
-
} else if (approvalMode ===
|
|
8362
|
+
} else if (approvalMode === ApprovalMode.YOLO) {
|
|
8347
8363
|
debugLogger.warn(
|
|
8348
8364
|
"YOLO mode is enabled. All tool calls will be automatically approved."
|
|
8349
8365
|
);
|
|
8350
8366
|
}
|
|
8351
|
-
if (!trustedFolder && approvalMode !==
|
|
8367
|
+
if (!trustedFolder && approvalMode !== ApprovalMode.DEFAULT) {
|
|
8352
8368
|
debugLogger.warn(
|
|
8353
8369
|
`Approval mode overridden to "default" because the current folder is not trusted.`
|
|
8354
8370
|
);
|
|
8355
|
-
approvalMode =
|
|
8371
|
+
approvalMode = ApprovalMode.DEFAULT;
|
|
8356
8372
|
}
|
|
8357
8373
|
let telemetrySettings;
|
|
8358
8374
|
try {
|
|
@@ -9756,7 +9772,7 @@ import path9 from "node:path";
|
|
|
9756
9772
|
import process4 from "node:process";
|
|
9757
9773
|
var homeDirectoryCheck = {
|
|
9758
9774
|
id: "home-directory",
|
|
9759
|
-
priority:
|
|
9775
|
+
priority: WarningPriority.Low,
|
|
9760
9776
|
check: async (workspaceRoot, settings) => {
|
|
9761
9777
|
if (settings.ui?.showHomeDirectoryWarning === false) {
|
|
9762
9778
|
return null;
|
|
@@ -9780,7 +9796,7 @@ var homeDirectoryCheck = {
|
|
|
9780
9796
|
};
|
|
9781
9797
|
var rootDirectoryCheck = {
|
|
9782
9798
|
id: "root-directory",
|
|
9783
|
-
priority:
|
|
9799
|
+
priority: WarningPriority.High,
|
|
9784
9800
|
check: async (workspaceRoot, _settings) => {
|
|
9785
9801
|
try {
|
|
9786
9802
|
const workspaceRealPath = await fs9.realpath(workspaceRoot);
|
|
@@ -9796,7 +9812,7 @@ var rootDirectoryCheck = {
|
|
|
9796
9812
|
};
|
|
9797
9813
|
var folderTrustCheck = {
|
|
9798
9814
|
id: "folder-trust",
|
|
9799
|
-
priority:
|
|
9815
|
+
priority: WarningPriority.High,
|
|
9800
9816
|
check: async (workspaceRoot, settings) => {
|
|
9801
9817
|
if (!isFolderTrustEnabled(settings)) {
|
|
9802
9818
|
return null;
|
|
@@ -9986,12 +10002,12 @@ function handleError(error, config, customErrorCode) {
|
|
|
9986
10002
|
error,
|
|
9987
10003
|
config.getContentGeneratorConfig()?.authType
|
|
9988
10004
|
);
|
|
9989
|
-
if (config.getOutputFormat() ===
|
|
10005
|
+
if (config.getOutputFormat() === OutputFormat.STREAM_JSON) {
|
|
9990
10006
|
const streamFormatter = new StreamJsonFormatter();
|
|
9991
10007
|
const errorCode = customErrorCode ?? extractErrorCode(error);
|
|
9992
10008
|
const metrics = uiTelemetryService.getMetrics();
|
|
9993
10009
|
streamFormatter.emitEvent({
|
|
9994
|
-
type:
|
|
10010
|
+
type: JsonStreamEventType.RESULT,
|
|
9995
10011
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
9996
10012
|
status: "error",
|
|
9997
10013
|
error: {
|
|
@@ -10002,7 +10018,7 @@ function handleError(error, config, customErrorCode) {
|
|
|
10002
10018
|
});
|
|
10003
10019
|
runSyncCleanup();
|
|
10004
10020
|
process.exit(getNumericExitCode(errorCode));
|
|
10005
|
-
} else if (config.getOutputFormat() ===
|
|
10021
|
+
} else if (config.getOutputFormat() === OutputFormat.JSON) {
|
|
10006
10022
|
const formatter = new JsonFormatter();
|
|
10007
10023
|
const errorCode = customErrorCode ?? extractErrorCode(error);
|
|
10008
10024
|
const formattedError = formatter.formatError(
|
|
@@ -10022,11 +10038,11 @@ function handleToolError(toolName, toolError, config, errorType, resultDisplay)
|
|
|
10022
10038
|
const isFatal = isFatalToolError(errorType);
|
|
10023
10039
|
if (isFatal) {
|
|
10024
10040
|
const toolExecutionError = new FatalToolExecutionError(errorMessage);
|
|
10025
|
-
if (config.getOutputFormat() ===
|
|
10041
|
+
if (config.getOutputFormat() === OutputFormat.STREAM_JSON) {
|
|
10026
10042
|
const streamFormatter = new StreamJsonFormatter();
|
|
10027
10043
|
const metrics = uiTelemetryService.getMetrics();
|
|
10028
10044
|
streamFormatter.emitEvent({
|
|
10029
|
-
type:
|
|
10045
|
+
type: JsonStreamEventType.RESULT,
|
|
10030
10046
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10031
10047
|
status: "error",
|
|
10032
10048
|
error: {
|
|
@@ -10035,7 +10051,7 @@ function handleToolError(toolName, toolError, config, errorType, resultDisplay)
|
|
|
10035
10051
|
},
|
|
10036
10052
|
stats: streamFormatter.convertToStreamStats(metrics, 0)
|
|
10037
10053
|
});
|
|
10038
|
-
} else if (config.getOutputFormat() ===
|
|
10054
|
+
} else if (config.getOutputFormat() === OutputFormat.JSON) {
|
|
10039
10055
|
const formatter = new JsonFormatter();
|
|
10040
10056
|
const formattedError = formatter.formatError(
|
|
10041
10057
|
toolExecutionError,
|
|
@@ -10053,11 +10069,11 @@ function handleToolError(toolName, toolError, config, errorType, resultDisplay)
|
|
|
10053
10069
|
}
|
|
10054
10070
|
function handleCancellationError(config) {
|
|
10055
10071
|
const cancellationError = new FatalCancellationError("Operation cancelled.");
|
|
10056
|
-
if (config.getOutputFormat() ===
|
|
10072
|
+
if (config.getOutputFormat() === OutputFormat.STREAM_JSON) {
|
|
10057
10073
|
const streamFormatter = new StreamJsonFormatter();
|
|
10058
10074
|
const metrics = uiTelemetryService.getMetrics();
|
|
10059
10075
|
streamFormatter.emitEvent({
|
|
10060
|
-
type:
|
|
10076
|
+
type: JsonStreamEventType.RESULT,
|
|
10061
10077
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10062
10078
|
status: "error",
|
|
10063
10079
|
error: {
|
|
@@ -10068,7 +10084,7 @@ function handleCancellationError(config) {
|
|
|
10068
10084
|
});
|
|
10069
10085
|
runSyncCleanup();
|
|
10070
10086
|
process.exit(cancellationError.exitCode);
|
|
10071
|
-
} else if (config.getOutputFormat() ===
|
|
10087
|
+
} else if (config.getOutputFormat() === OutputFormat.JSON) {
|
|
10072
10088
|
const formatter = new JsonFormatter();
|
|
10073
10089
|
const formattedError = formatter.formatError(
|
|
10074
10090
|
cancellationError,
|
|
@@ -10088,11 +10104,11 @@ function handleMaxTurnsExceededError(config) {
|
|
|
10088
10104
|
const maxTurnsError = new FatalTurnLimitedError(
|
|
10089
10105
|
"Reached max session turns for this session. Increase the number of turns by specifying maxSessionTurns in settings.json."
|
|
10090
10106
|
);
|
|
10091
|
-
if (config.getOutputFormat() ===
|
|
10107
|
+
if (config.getOutputFormat() === OutputFormat.STREAM_JSON) {
|
|
10092
10108
|
const streamFormatter = new StreamJsonFormatter();
|
|
10093
10109
|
const metrics = uiTelemetryService.getMetrics();
|
|
10094
10110
|
streamFormatter.emitEvent({
|
|
10095
|
-
type:
|
|
10111
|
+
type: JsonStreamEventType.RESULT,
|
|
10096
10112
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10097
10113
|
status: "error",
|
|
10098
10114
|
error: {
|
|
@@ -10103,7 +10119,7 @@ function handleMaxTurnsExceededError(config) {
|
|
|
10103
10119
|
});
|
|
10104
10120
|
runSyncCleanup();
|
|
10105
10121
|
process.exit(maxTurnsError.exitCode);
|
|
10106
|
-
} else if (config.getOutputFormat() ===
|
|
10122
|
+
} else if (config.getOutputFormat() === OutputFormat.JSON) {
|
|
10107
10123
|
const formatter = new JsonFormatter();
|
|
10108
10124
|
const formattedError = formatter.formatError(
|
|
10109
10125
|
maxTurnsError,
|
|
@@ -10183,7 +10199,7 @@ async function runNonInteractive({
|
|
|
10183
10199
|
}
|
|
10184
10200
|
});
|
|
10185
10201
|
if (process.env["GEMINI_CLI_ACTIVITY_LOG_TARGET"]) {
|
|
10186
|
-
const { setupInitialActivityLogger } = await import("./devtoolsService-
|
|
10202
|
+
const { setupInitialActivityLogger } = await import("./devtoolsService-BI57Y3RH.js");
|
|
10187
10203
|
setupInitialActivityLogger(config);
|
|
10188
10204
|
}
|
|
10189
10205
|
const { stdout: workingStdout } = createWorkingStdio();
|
|
@@ -10199,7 +10215,7 @@ async function runNonInteractive({
|
|
|
10199
10215
|
}
|
|
10200
10216
|
};
|
|
10201
10217
|
const startTime = Date.now();
|
|
10202
|
-
const streamFormatter = config.getOutputFormat() ===
|
|
10218
|
+
const streamFormatter = config.getOutputFormat() === OutputFormat.STREAM_JSON ? new StreamJsonFormatter() : null;
|
|
10203
10219
|
const abortController = new AbortController();
|
|
10204
10220
|
let isAborting = false;
|
|
10205
10221
|
let cancelMessageTimer = null;
|
|
@@ -10252,13 +10268,13 @@ async function runNonInteractive({
|
|
|
10252
10268
|
};
|
|
10253
10269
|
try {
|
|
10254
10270
|
consolePatcher.patch();
|
|
10255
|
-
if (config.getRawOutput() && !config.getAcceptRawOutputRisk() && config.getOutputFormat() ===
|
|
10271
|
+
if (config.getRawOutput() && !config.getAcceptRawOutputRisk() && config.getOutputFormat() === OutputFormat.TEXT) {
|
|
10256
10272
|
process.stderr.write(
|
|
10257
10273
|
"[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"
|
|
10258
10274
|
);
|
|
10259
10275
|
}
|
|
10260
10276
|
setupStdinCancellation();
|
|
10261
|
-
coreEvents.on(
|
|
10277
|
+
coreEvents.on(CoreEvent.UserFeedback, handleUserFeedback);
|
|
10262
10278
|
coreEvents.drainBacklogs();
|
|
10263
10279
|
process.stdout.on("error", (err) => {
|
|
10264
10280
|
if (err.code === "EPIPE") {
|
|
@@ -10284,7 +10300,7 @@ async function runNonInteractive({
|
|
|
10284
10300
|
}
|
|
10285
10301
|
if (streamFormatter) {
|
|
10286
10302
|
streamFormatter.emitEvent({
|
|
10287
|
-
type:
|
|
10303
|
+
type: JsonStreamEventType.INIT,
|
|
10288
10304
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10289
10305
|
session_id: config.getSessionId(),
|
|
10290
10306
|
model: config.getModel()
|
|
@@ -10322,7 +10338,7 @@ async function runNonInteractive({
|
|
|
10322
10338
|
}
|
|
10323
10339
|
if (streamFormatter) {
|
|
10324
10340
|
streamFormatter.emitEvent({
|
|
10325
|
-
type:
|
|
10341
|
+
type: JsonStreamEventType.MESSAGE,
|
|
10326
10342
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10327
10343
|
role: "user",
|
|
10328
10344
|
content: input
|
|
@@ -10361,12 +10377,12 @@ async function runNonInteractive({
|
|
|
10361
10377
|
const metrics = uiTelemetryService.getMetrics();
|
|
10362
10378
|
const durationMs = Date.now() - startTime;
|
|
10363
10379
|
streamFormatter.emitEvent({
|
|
10364
|
-
type:
|
|
10380
|
+
type: JsonStreamEventType.RESULT,
|
|
10365
10381
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10366
10382
|
status: "success",
|
|
10367
10383
|
stats: streamFormatter.convertToStreamStats(metrics, durationMs)
|
|
10368
10384
|
});
|
|
10369
|
-
} else if (config.getOutputFormat() ===
|
|
10385
|
+
} else if (config.getOutputFormat() === OutputFormat.JSON) {
|
|
10370
10386
|
const formatter = new JsonFormatter();
|
|
10371
10387
|
const stats = uiTelemetryService.getMetrics();
|
|
10372
10388
|
textOutput.write(
|
|
@@ -10452,13 +10468,13 @@ async function runNonInteractive({
|
|
|
10452
10468
|
const output = isRaw ? part.text : stripAnsi(part.text);
|
|
10453
10469
|
if (streamFormatter) {
|
|
10454
10470
|
streamFormatter.emitEvent({
|
|
10455
|
-
type:
|
|
10471
|
+
type: JsonStreamEventType.MESSAGE,
|
|
10456
10472
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10457
10473
|
role: "assistant",
|
|
10458
10474
|
content: output,
|
|
10459
10475
|
delta: true
|
|
10460
10476
|
});
|
|
10461
|
-
} else if (config.getOutputFormat() ===
|
|
10477
|
+
} else if (config.getOutputFormat() === OutputFormat.JSON) {
|
|
10462
10478
|
responseText += output;
|
|
10463
10479
|
} else {
|
|
10464
10480
|
if (part.text) {
|
|
@@ -10471,13 +10487,13 @@ async function runNonInteractive({
|
|
|
10471
10487
|
break;
|
|
10472
10488
|
}
|
|
10473
10489
|
case "tool_request": {
|
|
10474
|
-
if (config.getOutputFormat() ===
|
|
10490
|
+
if (config.getOutputFormat() === OutputFormat.JSON) {
|
|
10475
10491
|
preToolResponseText = responseText || preToolResponseText;
|
|
10476
10492
|
responseText = "";
|
|
10477
10493
|
}
|
|
10478
10494
|
if (streamFormatter) {
|
|
10479
10495
|
streamFormatter.emitEvent({
|
|
10480
|
-
type:
|
|
10496
|
+
type: JsonStreamEventType.TOOL_USE,
|
|
10481
10497
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10482
10498
|
tool_name: event.name,
|
|
10483
10499
|
tool_id: event.requestId,
|
|
@@ -10493,7 +10509,7 @@ async function runNonInteractive({
|
|
|
10493
10509
|
const displayText = displayContentToString(display);
|
|
10494
10510
|
const errorMsg = getTextContent(event.content) ?? "Tool error";
|
|
10495
10511
|
streamFormatter.emitEvent({
|
|
10496
|
-
type:
|
|
10512
|
+
type: JsonStreamEventType.TOOL_RESULT,
|
|
10497
10513
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10498
10514
|
tool_id: event.requestId,
|
|
10499
10515
|
status: event.isError ? "error" : "success",
|
|
@@ -10508,17 +10524,17 @@ async function runNonInteractive({
|
|
|
10508
10524
|
const display = event.display?.result;
|
|
10509
10525
|
const displayText = displayContentToString(display);
|
|
10510
10526
|
const errorMsg = getTextContent(event.content) ?? "Tool error";
|
|
10511
|
-
if (event.data?.["errorType"] ===
|
|
10512
|
-
if (config.getOutputFormat() ===
|
|
10527
|
+
if (event.data?.["errorType"] === ToolErrorType.STOP_EXECUTION) {
|
|
10528
|
+
if (config.getOutputFormat() === OutputFormat.JSON && !responseText && preToolResponseText) {
|
|
10513
10529
|
responseText = preToolResponseText;
|
|
10514
10530
|
}
|
|
10515
10531
|
const stopMessage = `Agent execution stopped: ${errorMsg}`;
|
|
10516
|
-
if (config.getOutputFormat() ===
|
|
10532
|
+
if (config.getOutputFormat() === OutputFormat.TEXT) {
|
|
10517
10533
|
process.stderr.write(`${stopMessage}
|
|
10518
10534
|
`);
|
|
10519
10535
|
}
|
|
10520
10536
|
}
|
|
10521
|
-
if (event.data?.["errorType"] ===
|
|
10537
|
+
if (event.data?.["errorType"] === ToolErrorType.NO_SPACE_LEFT) {
|
|
10522
10538
|
throw new FatalToolExecutionError(
|
|
10523
10539
|
"Error executing tool " + event.name + ": " + (displayText || errorMsg)
|
|
10524
10540
|
);
|
|
@@ -10539,20 +10555,20 @@ async function runNonInteractive({
|
|
|
10539
10555
|
}
|
|
10540
10556
|
const errorCode = event._meta?.["code"];
|
|
10541
10557
|
if (errorCode === "AGENT_EXECUTION_BLOCKED") {
|
|
10542
|
-
if (config.getOutputFormat() ===
|
|
10558
|
+
if (config.getOutputFormat() === OutputFormat.TEXT) {
|
|
10543
10559
|
process.stderr.write(`[WARNING] ${event.message}
|
|
10544
10560
|
`);
|
|
10545
10561
|
}
|
|
10546
10562
|
break;
|
|
10547
10563
|
}
|
|
10548
10564
|
const severity = event.status === "RESOURCE_EXHAUSTED" ? "error" : "warning";
|
|
10549
|
-
if (config.getOutputFormat() ===
|
|
10565
|
+
if (config.getOutputFormat() === OutputFormat.TEXT) {
|
|
10550
10566
|
process.stderr.write(`[WARNING] ${event.message}
|
|
10551
10567
|
`);
|
|
10552
10568
|
}
|
|
10553
10569
|
if (streamFormatter) {
|
|
10554
10570
|
streamFormatter.emitEvent({
|
|
10555
|
-
type:
|
|
10571
|
+
type: JsonStreamEventType.ERROR,
|
|
10556
10572
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10557
10573
|
severity,
|
|
10558
10574
|
message: event.message
|
|
@@ -10571,7 +10587,7 @@ async function runNonInteractive({
|
|
|
10571
10587
|
);
|
|
10572
10588
|
} else if (streamFormatter) {
|
|
10573
10589
|
streamFormatter.emitEvent({
|
|
10574
|
-
type:
|
|
10590
|
+
type: JsonStreamEventType.ERROR,
|
|
10575
10591
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10576
10592
|
severity: "error",
|
|
10577
10593
|
message: "Maximum session turns exceeded"
|
|
@@ -10579,7 +10595,7 @@ async function runNonInteractive({
|
|
|
10579
10595
|
}
|
|
10580
10596
|
}
|
|
10581
10597
|
const stopMessage = typeof event.data?.["message"] === "string" ? event.data["message"] : "";
|
|
10582
|
-
if (stopMessage && config.getOutputFormat() ===
|
|
10598
|
+
if (stopMessage && config.getOutputFormat() === OutputFormat.TEXT) {
|
|
10583
10599
|
process.stderr.write(`Agent execution stopped: ${stopMessage}
|
|
10584
10600
|
`);
|
|
10585
10601
|
}
|
|
@@ -10609,7 +10625,7 @@ async function runNonInteractive({
|
|
|
10609
10625
|
abortController.signal.removeEventListener("abort", abortSession);
|
|
10610
10626
|
scheduler?.dispose();
|
|
10611
10627
|
consolePatcher.cleanup();
|
|
10612
|
-
coreEvents.off(
|
|
10628
|
+
coreEvents.off(CoreEvent.UserFeedback, handleUserFeedback);
|
|
10613
10629
|
}
|
|
10614
10630
|
if (errorToHandle) {
|
|
10615
10631
|
handleError(errorToHandle, config);
|
|
@@ -10634,7 +10650,7 @@ async function runNonInteractive2(params) {
|
|
|
10634
10650
|
}
|
|
10635
10651
|
});
|
|
10636
10652
|
if (process.env["GEMINI_CLI_ACTIVITY_LOG_TARGET"]) {
|
|
10637
|
-
const { setupInitialActivityLogger } = await import("./devtoolsService-
|
|
10653
|
+
const { setupInitialActivityLogger } = await import("./devtoolsService-BI57Y3RH.js");
|
|
10638
10654
|
setupInitialActivityLogger(config);
|
|
10639
10655
|
}
|
|
10640
10656
|
const { stdout: workingStdout } = createWorkingStdio();
|
|
@@ -10650,7 +10666,7 @@ async function runNonInteractive2(params) {
|
|
|
10650
10666
|
}
|
|
10651
10667
|
};
|
|
10652
10668
|
const startTime = Date.now();
|
|
10653
|
-
const streamFormatter = config.getOutputFormat() ===
|
|
10669
|
+
const streamFormatter = config.getOutputFormat() === OutputFormat.STREAM_JSON ? new StreamJsonFormatter() : null;
|
|
10654
10670
|
const abortController = new AbortController();
|
|
10655
10671
|
let isAborting = false;
|
|
10656
10672
|
let cancelMessageTimer = null;
|
|
@@ -10701,13 +10717,13 @@ async function runNonInteractive2(params) {
|
|
|
10701
10717
|
let scheduler;
|
|
10702
10718
|
try {
|
|
10703
10719
|
consolePatcher.patch();
|
|
10704
|
-
if (config.getRawOutput() && !config.getAcceptRawOutputRisk() && config.getOutputFormat() ===
|
|
10720
|
+
if (config.getRawOutput() && !config.getAcceptRawOutputRisk() && config.getOutputFormat() === OutputFormat.TEXT) {
|
|
10705
10721
|
process.stderr.write(
|
|
10706
10722
|
"[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"
|
|
10707
10723
|
);
|
|
10708
10724
|
}
|
|
10709
10725
|
setupStdinCancellation();
|
|
10710
|
-
coreEvents.on(
|
|
10726
|
+
coreEvents.on(CoreEvent.UserFeedback, handleUserFeedback);
|
|
10711
10727
|
coreEvents.drainBacklogs();
|
|
10712
10728
|
process.stdout.on("error", (err) => {
|
|
10713
10729
|
if (err.code === "EPIPE") {
|
|
@@ -10731,7 +10747,7 @@ async function runNonInteractive2(params) {
|
|
|
10731
10747
|
}
|
|
10732
10748
|
if (streamFormatter) {
|
|
10733
10749
|
streamFormatter.emitEvent({
|
|
10734
|
-
type:
|
|
10750
|
+
type: JsonStreamEventType.INIT,
|
|
10735
10751
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10736
10752
|
session_id: config.getSessionId(),
|
|
10737
10753
|
model: config.getModel()
|
|
@@ -10769,7 +10785,7 @@ async function runNonInteractive2(params) {
|
|
|
10769
10785
|
}
|
|
10770
10786
|
if (streamFormatter) {
|
|
10771
10787
|
streamFormatter.emitEvent({
|
|
10772
|
-
type:
|
|
10788
|
+
type: JsonStreamEventType.MESSAGE,
|
|
10773
10789
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10774
10790
|
role: "user",
|
|
10775
10791
|
content: input
|
|
@@ -10796,28 +10812,28 @@ async function runNonInteractive2(params) {
|
|
|
10796
10812
|
if (abortController.signal.aborted) {
|
|
10797
10813
|
handleCancellationError(config);
|
|
10798
10814
|
}
|
|
10799
|
-
if (event.type ===
|
|
10815
|
+
if (event.type === GeminiEventType.Content) {
|
|
10800
10816
|
const isRaw = config.getRawOutput() || config.getAcceptRawOutputRisk();
|
|
10801
10817
|
const output = isRaw ? event.value : stripAnsi(event.value);
|
|
10802
10818
|
if (streamFormatter) {
|
|
10803
10819
|
streamFormatter.emitEvent({
|
|
10804
|
-
type:
|
|
10820
|
+
type: JsonStreamEventType.MESSAGE,
|
|
10805
10821
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10806
10822
|
role: "assistant",
|
|
10807
10823
|
content: output,
|
|
10808
10824
|
delta: true
|
|
10809
10825
|
});
|
|
10810
|
-
} else if (config.getOutputFormat() ===
|
|
10826
|
+
} else if (config.getOutputFormat() === OutputFormat.JSON) {
|
|
10811
10827
|
responseText += output;
|
|
10812
10828
|
} else {
|
|
10813
10829
|
if (event.value) {
|
|
10814
10830
|
textOutput.write(output);
|
|
10815
10831
|
}
|
|
10816
10832
|
}
|
|
10817
|
-
} else if (event.type ===
|
|
10833
|
+
} else if (event.type === GeminiEventType.ToolCallRequest) {
|
|
10818
10834
|
if (streamFormatter) {
|
|
10819
10835
|
streamFormatter.emitEvent({
|
|
10820
|
-
type:
|
|
10836
|
+
type: JsonStreamEventType.TOOL_USE,
|
|
10821
10837
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10822
10838
|
tool_name: event.value.name,
|
|
10823
10839
|
tool_id: event.value.callId,
|
|
@@ -10825,29 +10841,29 @@ async function runNonInteractive2(params) {
|
|
|
10825
10841
|
});
|
|
10826
10842
|
}
|
|
10827
10843
|
toolCallRequests.push(event.value);
|
|
10828
|
-
} else if (event.type ===
|
|
10844
|
+
} else if (event.type === GeminiEventType.LoopDetected) {
|
|
10829
10845
|
if (streamFormatter) {
|
|
10830
10846
|
streamFormatter.emitEvent({
|
|
10831
|
-
type:
|
|
10847
|
+
type: JsonStreamEventType.ERROR,
|
|
10832
10848
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10833
10849
|
severity: "warning",
|
|
10834
10850
|
message: "Loop detected, stopping execution"
|
|
10835
10851
|
});
|
|
10836
10852
|
}
|
|
10837
|
-
} else if (event.type ===
|
|
10853
|
+
} else if (event.type === GeminiEventType.MaxSessionTurns) {
|
|
10838
10854
|
if (streamFormatter) {
|
|
10839
10855
|
streamFormatter.emitEvent({
|
|
10840
|
-
type:
|
|
10856
|
+
type: JsonStreamEventType.ERROR,
|
|
10841
10857
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10842
10858
|
severity: "error",
|
|
10843
10859
|
message: "Maximum session turns exceeded"
|
|
10844
10860
|
});
|
|
10845
10861
|
}
|
|
10846
|
-
} else if (event.type ===
|
|
10862
|
+
} else if (event.type === GeminiEventType.Error) {
|
|
10847
10863
|
throw event.value.error;
|
|
10848
|
-
} else if (event.type ===
|
|
10864
|
+
} else if (event.type === GeminiEventType.AgentExecutionStopped) {
|
|
10849
10865
|
const stopMessage = `Agent execution stopped: ${event.value.systemMessage?.trim() || event.value.reason}`;
|
|
10850
|
-
if (config.getOutputFormat() ===
|
|
10866
|
+
if (config.getOutputFormat() === OutputFormat.TEXT) {
|
|
10851
10867
|
process.stderr.write(`${stopMessage}
|
|
10852
10868
|
`);
|
|
10853
10869
|
}
|
|
@@ -10855,7 +10871,7 @@ async function runNonInteractive2(params) {
|
|
|
10855
10871
|
const metrics = uiTelemetryService.getMetrics();
|
|
10856
10872
|
const durationMs = Date.now() - startTime;
|
|
10857
10873
|
streamFormatter.emitEvent({
|
|
10858
|
-
type:
|
|
10874
|
+
type: JsonStreamEventType.RESULT,
|
|
10859
10875
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10860
10876
|
status: "success",
|
|
10861
10877
|
stats: streamFormatter.convertToStreamStats(
|
|
@@ -10865,9 +10881,9 @@ async function runNonInteractive2(params) {
|
|
|
10865
10881
|
});
|
|
10866
10882
|
}
|
|
10867
10883
|
return;
|
|
10868
|
-
} else if (event.type ===
|
|
10884
|
+
} else if (event.type === GeminiEventType.AgentExecutionBlocked) {
|
|
10869
10885
|
const blockMessage = `Agent execution blocked: ${event.value.systemMessage?.trim() || event.value.reason}`;
|
|
10870
|
-
if (config.getOutputFormat() ===
|
|
10886
|
+
if (config.getOutputFormat() === OutputFormat.TEXT) {
|
|
10871
10887
|
process.stderr.write(`[WARNING] ${blockMessage}
|
|
10872
10888
|
`);
|
|
10873
10889
|
}
|
|
@@ -10885,7 +10901,7 @@ async function runNonInteractive2(params) {
|
|
|
10885
10901
|
const requestInfo = completedToolCall.request;
|
|
10886
10902
|
if (streamFormatter) {
|
|
10887
10903
|
streamFormatter.emitEvent({
|
|
10888
|
-
type:
|
|
10904
|
+
type: JsonStreamEventType.TOOL_RESULT,
|
|
10889
10905
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10890
10906
|
tool_id: requestInfo.callId,
|
|
10891
10907
|
status: completedToolCall.status === "error" ? "error" : "success",
|
|
@@ -10919,11 +10935,11 @@ async function runNonInteractive2(params) {
|
|
|
10919
10935
|
);
|
|
10920
10936
|
}
|
|
10921
10937
|
const stopExecutionTool = completedToolCalls.find(
|
|
10922
|
-
(tc) => tc.response.errorType ===
|
|
10938
|
+
(tc) => tc.response.errorType === ToolErrorType.STOP_EXECUTION
|
|
10923
10939
|
);
|
|
10924
10940
|
if (stopExecutionTool && stopExecutionTool.response.error) {
|
|
10925
10941
|
const stopMessage = `Agent execution stopped: ${stopExecutionTool.response.error.message}`;
|
|
10926
|
-
if (config.getOutputFormat() ===
|
|
10942
|
+
if (config.getOutputFormat() === OutputFormat.TEXT) {
|
|
10927
10943
|
process.stderr.write(`${stopMessage}
|
|
10928
10944
|
`);
|
|
10929
10945
|
}
|
|
@@ -10931,7 +10947,7 @@ async function runNonInteractive2(params) {
|
|
|
10931
10947
|
const metrics = uiTelemetryService.getMetrics();
|
|
10932
10948
|
const durationMs = Date.now() - startTime;
|
|
10933
10949
|
streamFormatter.emitEvent({
|
|
10934
|
-
type:
|
|
10950
|
+
type: JsonStreamEventType.RESULT,
|
|
10935
10951
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10936
10952
|
status: "success",
|
|
10937
10953
|
stats: streamFormatter.convertToStreamStats(
|
|
@@ -10939,7 +10955,7 @@ async function runNonInteractive2(params) {
|
|
|
10939
10955
|
durationMs
|
|
10940
10956
|
)
|
|
10941
10957
|
});
|
|
10942
|
-
} else if (config.getOutputFormat() ===
|
|
10958
|
+
} else if (config.getOutputFormat() === OutputFormat.JSON) {
|
|
10943
10959
|
const formatter = new JsonFormatter();
|
|
10944
10960
|
const stats = uiTelemetryService.getMetrics();
|
|
10945
10961
|
textOutput.write(
|
|
@@ -10956,12 +10972,12 @@ async function runNonInteractive2(params) {
|
|
|
10956
10972
|
const metrics = uiTelemetryService.getMetrics();
|
|
10957
10973
|
const durationMs = Date.now() - startTime;
|
|
10958
10974
|
streamFormatter.emitEvent({
|
|
10959
|
-
type:
|
|
10975
|
+
type: JsonStreamEventType.RESULT,
|
|
10960
10976
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10961
10977
|
status: "success",
|
|
10962
10978
|
stats: streamFormatter.convertToStreamStats(metrics, durationMs)
|
|
10963
10979
|
});
|
|
10964
|
-
} else if (config.getOutputFormat() ===
|
|
10980
|
+
} else if (config.getOutputFormat() === OutputFormat.JSON) {
|
|
10965
10981
|
const formatter = new JsonFormatter();
|
|
10966
10982
|
const stats = uiTelemetryService.getMetrics();
|
|
10967
10983
|
textOutput.write(
|
|
@@ -10979,7 +10995,7 @@ async function runNonInteractive2(params) {
|
|
|
10979
10995
|
cleanupStdinCancellation();
|
|
10980
10996
|
scheduler?.dispose();
|
|
10981
10997
|
consolePatcher.cleanup();
|
|
10982
|
-
coreEvents.off(
|
|
10998
|
+
coreEvents.off(CoreEvent.UserFeedback, handleUserFeedback);
|
|
10983
10999
|
}
|
|
10984
11000
|
if (errorToHandle) {
|
|
10985
11001
|
handleError(errorToHandle, config);
|
|
@@ -13450,12 +13466,12 @@ var GeminiAgent = class _GeminiAgent {
|
|
|
13450
13466
|
this.clientCapabilities = args.clientCapabilities;
|
|
13451
13467
|
const authMethods = [
|
|
13452
13468
|
{
|
|
13453
|
-
id:
|
|
13469
|
+
id: AuthType.LOGIN_WITH_GOOGLE,
|
|
13454
13470
|
name: "Log in with Google",
|
|
13455
13471
|
description: "Log in with your Google account"
|
|
13456
13472
|
},
|
|
13457
13473
|
{
|
|
13458
|
-
id:
|
|
13474
|
+
id: AuthType.USE_GEMINI,
|
|
13459
13475
|
name: "Gemini API key",
|
|
13460
13476
|
description: "Use an API key with Gemini Developer API",
|
|
13461
13477
|
_meta: {
|
|
@@ -13465,12 +13481,12 @@ var GeminiAgent = class _GeminiAgent {
|
|
|
13465
13481
|
}
|
|
13466
13482
|
},
|
|
13467
13483
|
{
|
|
13468
|
-
id:
|
|
13484
|
+
id: AuthType.USE_VERTEX_AI,
|
|
13469
13485
|
name: "Vertex AI",
|
|
13470
13486
|
description: "Use an API key with Vertex AI GenAI API"
|
|
13471
13487
|
},
|
|
13472
13488
|
{
|
|
13473
|
-
id:
|
|
13489
|
+
id: AuthType.GATEWAY,
|
|
13474
13490
|
name: "AI API Gateway",
|
|
13475
13491
|
description: "Use a custom AI API Gateway",
|
|
13476
13492
|
_meta: {
|
|
@@ -13565,7 +13581,7 @@ var GeminiAgent = class _GeminiAgent {
|
|
|
13565
13581
|
mcpServers,
|
|
13566
13582
|
loadedSettings
|
|
13567
13583
|
);
|
|
13568
|
-
const authType = loadedSettings.merged.security.auth.selectedType ||
|
|
13584
|
+
const authType = loadedSettings.merged.security.auth.selectedType || AuthType.USE_GEMINI;
|
|
13569
13585
|
let isAuthenticated = false;
|
|
13570
13586
|
let authErrorMessage = "";
|
|
13571
13587
|
try {
|
|
@@ -13577,7 +13593,7 @@ var GeminiAgent = class _GeminiAgent {
|
|
|
13577
13593
|
);
|
|
13578
13594
|
isAuthenticated = true;
|
|
13579
13595
|
const contentGeneratorConfig = config.getContentGeneratorConfig();
|
|
13580
|
-
if (authType ===
|
|
13596
|
+
if (authType === AuthType.USE_GEMINI && (!contentGeneratorConfig || !contentGeneratorConfig.apiKey)) {
|
|
13581
13597
|
isAuthenticated = false;
|
|
13582
13598
|
authErrorMessage = "Gemini API key is missing or not configured.";
|
|
13583
13599
|
}
|
|
@@ -13887,7 +13903,7 @@ ${thought.description}`;
|
|
|
13887
13903
|
await this.sendUpdate({
|
|
13888
13904
|
sessionUpdate: "tool_call",
|
|
13889
13905
|
toolCallId: toolCall.id,
|
|
13890
|
-
status: toolCall.status ===
|
|
13906
|
+
status: toolCall.status === CoreToolCallStatus.Success ? "completed" : "failed",
|
|
13891
13907
|
title: toolCall.displayName || toolCall.name,
|
|
13892
13908
|
content: toolCallContent,
|
|
13893
13909
|
kind: tool ? toAcpToolKind(tool.kind) : "other"
|
|
@@ -13940,7 +13956,7 @@ ${thought.description}`;
|
|
|
13940
13956
|
while (nextMessage !== null) {
|
|
13941
13957
|
if (pendingSend.signal.aborted) {
|
|
13942
13958
|
chat.addHistory(nextMessage);
|
|
13943
|
-
return { stopReason:
|
|
13959
|
+
return { stopReason: CoreToolCallStatus.Cancelled };
|
|
13944
13960
|
}
|
|
13945
13961
|
const functionCalls = [];
|
|
13946
13962
|
try {
|
|
@@ -13960,7 +13976,7 @@ ${thought.description}`;
|
|
|
13960
13976
|
nextMessage?.parts ?? [],
|
|
13961
13977
|
promptId,
|
|
13962
13978
|
pendingSend.signal,
|
|
13963
|
-
|
|
13979
|
+
LlmRole.MAIN
|
|
13964
13980
|
);
|
|
13965
13981
|
nextMessage = null;
|
|
13966
13982
|
let turnInputTokens = 0;
|
|
@@ -13968,16 +13984,16 @@ ${thought.description}`;
|
|
|
13968
13984
|
let turnModelId = model;
|
|
13969
13985
|
for await (const resp of responseStream) {
|
|
13970
13986
|
if (pendingSend.signal.aborted) {
|
|
13971
|
-
return { stopReason:
|
|
13987
|
+
return { stopReason: CoreToolCallStatus.Cancelled };
|
|
13972
13988
|
}
|
|
13973
|
-
if (resp.type ===
|
|
13989
|
+
if (resp.type === StreamEventType.CHUNK && resp.value.usageMetadata) {
|
|
13974
13990
|
turnInputTokens = resp.value.usageMetadata.promptTokenCount ?? turnInputTokens;
|
|
13975
13991
|
turnOutputTokens = resp.value.usageMetadata.candidatesTokenCount ?? turnOutputTokens;
|
|
13976
13992
|
if (resp.value.modelVersion) {
|
|
13977
13993
|
turnModelId = resp.value.modelVersion;
|
|
13978
13994
|
}
|
|
13979
13995
|
}
|
|
13980
|
-
if (resp.type ===
|
|
13996
|
+
if (resp.type === StreamEventType.CHUNK && resp.value.candidates && resp.value.candidates.length > 0) {
|
|
13981
13997
|
const candidate = resp.value.candidates[0];
|
|
13982
13998
|
for (const part of candidate.content?.parts ?? []) {
|
|
13983
13999
|
if (!part.text) {
|
|
@@ -13993,7 +14009,7 @@ ${thought.description}`;
|
|
|
13993
14009
|
});
|
|
13994
14010
|
}
|
|
13995
14011
|
}
|
|
13996
|
-
if (resp.type ===
|
|
14012
|
+
if (resp.type === StreamEventType.CHUNK && resp.value.functionCalls) {
|
|
13997
14013
|
functionCalls.push(...resp.value.functionCalls);
|
|
13998
14014
|
}
|
|
13999
14015
|
}
|
|
@@ -14009,7 +14025,7 @@ ${thought.description}`;
|
|
|
14009
14025
|
modelUsageMap.set(turnModelId, existing);
|
|
14010
14026
|
}
|
|
14011
14027
|
if (pendingSend.signal.aborted) {
|
|
14012
|
-
return { stopReason:
|
|
14028
|
+
return { stopReason: CoreToolCallStatus.Cancelled };
|
|
14013
14029
|
}
|
|
14014
14030
|
} catch (error) {
|
|
14015
14031
|
if (getErrorStatus(error) === 429) {
|
|
@@ -14019,7 +14035,7 @@ ${thought.description}`;
|
|
|
14019
14035
|
);
|
|
14020
14036
|
}
|
|
14021
14037
|
if (pendingSend.signal.aborted || error instanceof Error && error.name === "AbortError") {
|
|
14022
|
-
return { stopReason:
|
|
14038
|
+
return { stopReason: CoreToolCallStatus.Cancelled };
|
|
14023
14039
|
}
|
|
14024
14040
|
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")) {
|
|
14025
14041
|
return {
|
|
@@ -14183,7 +14199,7 @@ ${thought.description}`;
|
|
|
14183
14199
|
const output = RequestPermissionResponseSchema.parse(
|
|
14184
14200
|
await this.connection.requestPermission(params)
|
|
14185
14201
|
);
|
|
14186
|
-
const outcome = output.outcome.outcome === "cancelled" ?
|
|
14202
|
+
const outcome = output.outcome.outcome === "cancelled" ? ToolConfirmationOutcome.Cancel : external_exports.nativeEnum(ToolConfirmationOutcome).parse(output.outcome.optionId);
|
|
14187
14203
|
await confirmationDetails.onConfirm(outcome);
|
|
14188
14204
|
await updatePolicy(
|
|
14189
14205
|
tool,
|
|
@@ -14194,16 +14210,16 @@ ${thought.description}`;
|
|
|
14194
14210
|
invocation
|
|
14195
14211
|
);
|
|
14196
14212
|
switch (outcome) {
|
|
14197
|
-
case
|
|
14213
|
+
case ToolConfirmationOutcome.Cancel:
|
|
14198
14214
|
return errorResponse(
|
|
14199
14215
|
new Error(`Tool "${fc.name}" was canceled by the user.`)
|
|
14200
14216
|
);
|
|
14201
|
-
case
|
|
14202
|
-
case
|
|
14203
|
-
case
|
|
14204
|
-
case
|
|
14205
|
-
case
|
|
14206
|
-
case
|
|
14217
|
+
case ToolConfirmationOutcome.ProceedOnce:
|
|
14218
|
+
case ToolConfirmationOutcome.ProceedAlways:
|
|
14219
|
+
case ToolConfirmationOutcome.ProceedAlwaysAndSave:
|
|
14220
|
+
case ToolConfirmationOutcome.ProceedAlwaysServer:
|
|
14221
|
+
case ToolConfirmationOutcome.ProceedAlwaysTool:
|
|
14222
|
+
case ToolConfirmationOutcome.ModifyWithEditor:
|
|
14207
14223
|
break;
|
|
14208
14224
|
default: {
|
|
14209
14225
|
const resultOutcome = outcome;
|
|
@@ -14251,7 +14267,7 @@ ${thought.description}`;
|
|
|
14251
14267
|
);
|
|
14252
14268
|
this.chat.recordCompletedToolCalls(this.context.config.getActiveModel(), [
|
|
14253
14269
|
{
|
|
14254
|
-
status:
|
|
14270
|
+
status: CoreToolCallStatus.Success,
|
|
14255
14271
|
request: {
|
|
14256
14272
|
callId,
|
|
14257
14273
|
name: fc.name,
|
|
@@ -14296,7 +14312,7 @@ ${thought.description}`;
|
|
|
14296
14312
|
});
|
|
14297
14313
|
this.chat.recordCompletedToolCalls(this.context.config.getActiveModel(), [
|
|
14298
14314
|
{
|
|
14299
|
-
status:
|
|
14315
|
+
status: CoreToolCallStatus.Error,
|
|
14300
14316
|
request: {
|
|
14301
14317
|
callId,
|
|
14302
14318
|
name: fc.name,
|
|
@@ -14411,12 +14427,12 @@ ${thought.description}`;
|
|
|
14411
14427
|
sessionId: this.id,
|
|
14412
14428
|
options: [
|
|
14413
14429
|
{
|
|
14414
|
-
optionId:
|
|
14430
|
+
optionId: ToolConfirmationOutcome.ProceedOnce,
|
|
14415
14431
|
name: "Allow once",
|
|
14416
14432
|
kind: "allow_once"
|
|
14417
14433
|
},
|
|
14418
14434
|
{
|
|
14419
|
-
optionId:
|
|
14435
|
+
optionId: ToolConfirmationOutcome.Cancel,
|
|
14420
14436
|
name: "Deny",
|
|
14421
14437
|
kind: "reject_once"
|
|
14422
14438
|
}
|
|
@@ -14441,8 +14457,8 @@ ${thought.description}`;
|
|
|
14441
14457
|
const output = RequestPermissionResponseSchema.parse(
|
|
14442
14458
|
await this.connection.requestPermission(params)
|
|
14443
14459
|
);
|
|
14444
|
-
const outcome = output.outcome.outcome === "cancelled" ?
|
|
14445
|
-
if (outcome ===
|
|
14460
|
+
const outcome = output.outcome.outcome === "cancelled" ? ToolConfirmationOutcome.Cancel : external_exports.nativeEnum(ToolConfirmationOutcome).parse(output.outcome.optionId);
|
|
14461
|
+
if (outcome === ToolConfirmationOutcome.ProceedOnce) {
|
|
14446
14462
|
this.context.config.getWorkspaceContext().addReadOnlyPath(absolutePath);
|
|
14447
14463
|
validationError = null;
|
|
14448
14464
|
} else {
|
|
@@ -14819,12 +14835,12 @@ function toToolCallContent(toolResult) {
|
|
|
14819
14835
|
}
|
|
14820
14836
|
var basicPermissionOptions = [
|
|
14821
14837
|
{
|
|
14822
|
-
optionId:
|
|
14838
|
+
optionId: ToolConfirmationOutcome.ProceedOnce,
|
|
14823
14839
|
name: "Allow",
|
|
14824
14840
|
kind: "allow_once"
|
|
14825
14841
|
},
|
|
14826
14842
|
{
|
|
14827
|
-
optionId:
|
|
14843
|
+
optionId: ToolConfirmationOutcome.Cancel,
|
|
14828
14844
|
name: "Reject",
|
|
14829
14845
|
kind: "reject_once"
|
|
14830
14846
|
}
|
|
@@ -14836,13 +14852,13 @@ function toPermissionOptions(confirmation, config, enablePermanentToolApproval =
|
|
|
14836
14852
|
switch (confirmation.type) {
|
|
14837
14853
|
case "edit":
|
|
14838
14854
|
options.push({
|
|
14839
|
-
optionId:
|
|
14855
|
+
optionId: ToolConfirmationOutcome.ProceedAlways,
|
|
14840
14856
|
name: "Allow for this session",
|
|
14841
14857
|
kind: "allow_always"
|
|
14842
14858
|
});
|
|
14843
14859
|
if (enablePermanentToolApproval) {
|
|
14844
14860
|
options.push({
|
|
14845
|
-
optionId:
|
|
14861
|
+
optionId: ToolConfirmationOutcome.ProceedAlwaysAndSave,
|
|
14846
14862
|
name: "Allow for this file in all future sessions",
|
|
14847
14863
|
kind: "allow_always"
|
|
14848
14864
|
});
|
|
@@ -14850,13 +14866,13 @@ function toPermissionOptions(confirmation, config, enablePermanentToolApproval =
|
|
|
14850
14866
|
break;
|
|
14851
14867
|
case "exec":
|
|
14852
14868
|
options.push({
|
|
14853
|
-
optionId:
|
|
14869
|
+
optionId: ToolConfirmationOutcome.ProceedAlways,
|
|
14854
14870
|
name: "Allow for this session",
|
|
14855
14871
|
kind: "allow_always"
|
|
14856
14872
|
});
|
|
14857
14873
|
if (enablePermanentToolApproval) {
|
|
14858
14874
|
options.push({
|
|
14859
|
-
optionId:
|
|
14875
|
+
optionId: ToolConfirmationOutcome.ProceedAlwaysAndSave,
|
|
14860
14876
|
name: "Allow this command for all future sessions",
|
|
14861
14877
|
kind: "allow_always"
|
|
14862
14878
|
});
|
|
@@ -14865,19 +14881,19 @@ function toPermissionOptions(confirmation, config, enablePermanentToolApproval =
|
|
|
14865
14881
|
case "mcp":
|
|
14866
14882
|
options.push(
|
|
14867
14883
|
{
|
|
14868
|
-
optionId:
|
|
14884
|
+
optionId: ToolConfirmationOutcome.ProceedAlwaysServer,
|
|
14869
14885
|
name: "Allow all server tools for this session",
|
|
14870
14886
|
kind: "allow_always"
|
|
14871
14887
|
},
|
|
14872
14888
|
{
|
|
14873
|
-
optionId:
|
|
14889
|
+
optionId: ToolConfirmationOutcome.ProceedAlwaysTool,
|
|
14874
14890
|
name: "Allow tool for this session",
|
|
14875
14891
|
kind: "allow_always"
|
|
14876
14892
|
}
|
|
14877
14893
|
);
|
|
14878
14894
|
if (enablePermanentToolApproval) {
|
|
14879
14895
|
options.push({
|
|
14880
|
-
optionId:
|
|
14896
|
+
optionId: ToolConfirmationOutcome.ProceedAlwaysAndSave,
|
|
14881
14897
|
name: "Allow tool for all future sessions",
|
|
14882
14898
|
kind: "allow_always"
|
|
14883
14899
|
});
|
|
@@ -14885,13 +14901,13 @@ function toPermissionOptions(confirmation, config, enablePermanentToolApproval =
|
|
|
14885
14901
|
break;
|
|
14886
14902
|
case "info":
|
|
14887
14903
|
options.push({
|
|
14888
|
-
optionId:
|
|
14904
|
+
optionId: ToolConfirmationOutcome.ProceedAlways,
|
|
14889
14905
|
name: "Allow for this session",
|
|
14890
14906
|
kind: "allow_always"
|
|
14891
14907
|
});
|
|
14892
14908
|
if (enablePermanentToolApproval) {
|
|
14893
14909
|
options.push({
|
|
14894
|
-
optionId:
|
|
14910
|
+
optionId: ToolConfirmationOutcome.ProceedAlwaysAndSave,
|
|
14895
14911
|
name: "Allow for all future sessions",
|
|
14896
14912
|
kind: "allow_always"
|
|
14897
14913
|
});
|
|
@@ -14923,21 +14939,21 @@ function toPermissionOptions(confirmation, config, enablePermanentToolApproval =
|
|
|
14923
14939
|
}
|
|
14924
14940
|
function toAcpToolKind(kind) {
|
|
14925
14941
|
switch (kind) {
|
|
14926
|
-
case
|
|
14927
|
-
case
|
|
14928
|
-
case
|
|
14929
|
-
case
|
|
14930
|
-
case
|
|
14931
|
-
case
|
|
14932
|
-
case
|
|
14933
|
-
case
|
|
14934
|
-
case
|
|
14935
|
-
case
|
|
14942
|
+
case Kind.Read:
|
|
14943
|
+
case Kind.Edit:
|
|
14944
|
+
case Kind.Execute:
|
|
14945
|
+
case Kind.Search:
|
|
14946
|
+
case Kind.Delete:
|
|
14947
|
+
case Kind.Move:
|
|
14948
|
+
case Kind.Think:
|
|
14949
|
+
case Kind.Fetch:
|
|
14950
|
+
case Kind.SwitchMode:
|
|
14951
|
+
case Kind.Other:
|
|
14936
14952
|
return kind;
|
|
14937
|
-
case
|
|
14953
|
+
case Kind.Agent:
|
|
14938
14954
|
return "think";
|
|
14939
|
-
case
|
|
14940
|
-
case
|
|
14955
|
+
case Kind.Plan:
|
|
14956
|
+
case Kind.Communicate:
|
|
14941
14957
|
default:
|
|
14942
14958
|
return "other";
|
|
14943
14959
|
}
|
|
@@ -14945,24 +14961,24 @@ function toAcpToolKind(kind) {
|
|
|
14945
14961
|
function buildAvailableModes(isPlanEnabled) {
|
|
14946
14962
|
const modes = [
|
|
14947
14963
|
{
|
|
14948
|
-
id:
|
|
14964
|
+
id: ApprovalMode.DEFAULT,
|
|
14949
14965
|
name: "Default",
|
|
14950
14966
|
description: "Prompts for approval"
|
|
14951
14967
|
},
|
|
14952
14968
|
{
|
|
14953
|
-
id:
|
|
14969
|
+
id: ApprovalMode.AUTO_EDIT,
|
|
14954
14970
|
name: "Auto Edit",
|
|
14955
14971
|
description: "Auto-approves edit tools"
|
|
14956
14972
|
},
|
|
14957
14973
|
{
|
|
14958
|
-
id:
|
|
14974
|
+
id: ApprovalMode.YOLO,
|
|
14959
14975
|
name: "YOLO",
|
|
14960
14976
|
description: "Auto-approves all tools"
|
|
14961
14977
|
}
|
|
14962
14978
|
];
|
|
14963
14979
|
if (isPlanEnabled) {
|
|
14964
14980
|
modes.push({
|
|
14965
|
-
id:
|
|
14981
|
+
id: ApprovalMode.PLAN,
|
|
14966
14982
|
name: "Plan",
|
|
14967
14983
|
description: "Read-only mode"
|
|
14968
14984
|
});
|
|
@@ -14975,7 +14991,7 @@ function buildAvailableModels(config, settings) {
|
|
|
14975
14991
|
const useGemini31 = config.getGemini31LaunchedSync?.() ?? false;
|
|
14976
14992
|
const useGemini31FlashLite = config.getGemini31FlashLiteLaunchedSync?.() ?? false;
|
|
14977
14993
|
const selectedAuthType = settings.merged.security.auth.selectedType;
|
|
14978
|
-
const useCustomToolModel = useGemini31 && selectedAuthType ===
|
|
14994
|
+
const useCustomToolModel = useGemini31 && selectedAuthType === AuthType.USE_GEMINI;
|
|
14979
14995
|
if (config.getExperimentalDynamicModelConfiguration?.() === true && config.getModelConfigService) {
|
|
14980
14996
|
const options = config.getModelConfigService().getAvailableModelOptions({
|
|
14981
14997
|
useGemini3_1: useGemini31,
|
|
@@ -15073,7 +15089,7 @@ async function validateNonInteractiveAuth(configuredAuthType, useExternalAuth, n
|
|
|
15073
15089
|
}
|
|
15074
15090
|
return authType;
|
|
15075
15091
|
} catch (error) {
|
|
15076
|
-
if (nonInteractiveConfig.getOutputFormat() ===
|
|
15092
|
+
if (nonInteractiveConfig.getOutputFormat() === OutputFormat.JSON) {
|
|
15077
15093
|
handleError(
|
|
15078
15094
|
error instanceof Error ? error : new Error(String(error)),
|
|
15079
15095
|
nonInteractiveConfig,
|
|
@@ -15269,10 +15285,10 @@ var SlashCommandConflictHandler = class {
|
|
|
15269
15285
|
this.handleConflicts = this.handleConflicts.bind(this);
|
|
15270
15286
|
}
|
|
15271
15287
|
start() {
|
|
15272
|
-
coreEvents.on(
|
|
15288
|
+
coreEvents.on(CoreEvent.SlashCommandConflicts, this.handleConflicts);
|
|
15273
15289
|
}
|
|
15274
15290
|
stop() {
|
|
15275
|
-
coreEvents.off(
|
|
15291
|
+
coreEvents.off(CoreEvent.SlashCommandConflicts, this.handleConflicts);
|
|
15276
15292
|
if (this.flushTimeout) {
|
|
15277
15293
|
clearTimeout(this.flushTimeout);
|
|
15278
15294
|
this.flushTimeout = null;
|
|
@@ -15495,7 +15511,7 @@ async function resolveSessionId(resumeArg, sessionIdArg) {
|
|
|
15495
15511
|
}
|
|
15496
15512
|
}
|
|
15497
15513
|
async function startInteractiveUI(config, settings, startupWarnings, workspaceRoot = process.cwd(), resumedSessionData, initializationResult) {
|
|
15498
|
-
const { startInteractiveUI: doStartUI } = await import("./interactiveCli-
|
|
15514
|
+
const { startInteractiveUI: doStartUI } = await import("./interactiveCli-UPXIMCUC.js");
|
|
15499
15515
|
await doStartUI(
|
|
15500
15516
|
config,
|
|
15501
15517
|
settings,
|
|
@@ -15596,12 +15612,12 @@ async function main() {
|
|
|
15596
15612
|
dns.setDefaultResultOrder(
|
|
15597
15613
|
validateDnsResolutionOrder(settings.merged.advanced.dnsResolutionOrder)
|
|
15598
15614
|
);
|
|
15599
|
-
if (!settings.merged.security.auth.selectedType || settings.merged.security.auth.selectedType ===
|
|
15615
|
+
if (!settings.merged.security.auth.selectedType || settings.merged.security.auth.selectedType === AuthType.LEGACY_CLOUD_SHELL) {
|
|
15600
15616
|
if (process.env["CLOUD_SHELL"] === "true" || process.env["GEMINI_CLI_USE_COMPUTE_ADC"] === "true") {
|
|
15601
15617
|
settings.setValue(
|
|
15602
15618
|
"User" /* User */,
|
|
15603
15619
|
"security.auth.selectedType",
|
|
15604
|
-
|
|
15620
|
+
AuthType.COMPUTE_ADC
|
|
15605
15621
|
);
|
|
15606
15622
|
}
|
|
15607
15623
|
}
|
|
@@ -15699,7 +15715,7 @@ ${finalArgs[promptIndex + 1]}`;
|
|
|
15699
15715
|
await config.storage.initialize();
|
|
15700
15716
|
adminControlsListner.setConfig(config);
|
|
15701
15717
|
if (config.isInteractive() && settings.merged.general.devtools) {
|
|
15702
|
-
const { setupInitialActivityLogger } = await import("./devtoolsService-
|
|
15718
|
+
const { setupInitialActivityLogger } = await import("./devtoolsService-BI57Y3RH.js");
|
|
15703
15719
|
setupInitialActivityLogger(config);
|
|
15704
15720
|
}
|
|
15705
15721
|
registerTelemetryConfig(config);
|
|
@@ -15707,7 +15723,7 @@ ${finalArgs[promptIndex + 1]}`;
|
|
|
15707
15723
|
const messageBus = config.getMessageBus();
|
|
15708
15724
|
createPolicyUpdater2(policyEngine, messageBus, config.storage);
|
|
15709
15725
|
registerCleanup(async () => {
|
|
15710
|
-
await config.getHookSystem()?.fireSessionEndEvent(
|
|
15726
|
+
await config.getHookSystem()?.fireSessionEndEvent(SessionEndReason.Exit);
|
|
15711
15727
|
});
|
|
15712
15728
|
if (!config.getAcpMode()) {
|
|
15713
15729
|
registerCleanup(consolePatcher.cleanup);
|
|
@@ -15758,7 +15774,7 @@ ${finalArgs[promptIndex + 1]}`;
|
|
|
15758
15774
|
const initAppHandle = startupProfiler.start("initialize_app");
|
|
15759
15775
|
const initializationResult = await initializeApp(config, settings);
|
|
15760
15776
|
initAppHandle?.end();
|
|
15761
|
-
import("./liteRtServerManager-
|
|
15777
|
+
import("./liteRtServerManager-BYX3KONC.js").then(({ LiteRtServerManager }) => {
|
|
15762
15778
|
const mergedGemma = settings.merged.experimental?.gemmaModelRouter;
|
|
15763
15779
|
if (!mergedGemma) return;
|
|
15764
15780
|
const userGemma = settings.forScope("User" /* User */).settings.experimental?.gemmaModelRouter;
|
|
@@ -15768,7 +15784,7 @@ ${finalArgs[promptIndex + 1]}`;
|
|
|
15768
15784
|
autoStartServer: userGemma?.autoStartServer
|
|
15769
15785
|
});
|
|
15770
15786
|
}).catch((e) => debugLogger.warn("LiteRT auto-start import failed:", e));
|
|
15771
|
-
if (settings.merged.security.auth.selectedType ===
|
|
15787
|
+
if (settings.merged.security.auth.selectedType === AuthType.LOGIN_WITH_GOOGLE && config.isBrowserLaunchSuppressed()) {
|
|
15772
15788
|
await getOauthClient(settings.merged.security.auth.selectedType, config);
|
|
15773
15789
|
}
|
|
15774
15790
|
if (config.getAcpMode()) {
|
|
@@ -15784,7 +15800,7 @@ ${finalArgs[promptIndex + 1]}`;
|
|
|
15784
15800
|
...rawStartupWarnings.map((message) => ({
|
|
15785
15801
|
id: `startup-${createHash2("sha256").update(message).digest("hex").substring(0, 16)}`,
|
|
15786
15802
|
message,
|
|
15787
|
-
priority:
|
|
15803
|
+
priority: WarningPriority.High
|
|
15788
15804
|
})),
|
|
15789
15805
|
...await getUserStartupWarnings(settings.merged, void 0, {
|
|
15790
15806
|
isAlternateBuffer: useAlternateBuffer
|
|
@@ -15821,7 +15837,7 @@ ${finalArgs[promptIndex + 1]}`;
|
|
|
15821
15837
|
${input}` : stdinData;
|
|
15822
15838
|
}
|
|
15823
15839
|
}
|
|
15824
|
-
const sessionStartSource = resumedSessionData ?
|
|
15840
|
+
const sessionStartSource = resumedSessionData ? SessionStartSource.Resume : SessionStartSource.Startup;
|
|
15825
15841
|
const hookSystem = config?.getHookSystem();
|
|
15826
15842
|
if (hookSystem) {
|
|
15827
15843
|
const result = await hookSystem.fireSessionStartEvent(sessionStartSource);
|
|
@@ -15878,16 +15894,16 @@ ${input}` : wrappedContext;
|
|
|
15878
15894
|
}
|
|
15879
15895
|
}
|
|
15880
15896
|
function initializeOutputListenersAndFlush() {
|
|
15881
|
-
if (coreEvents.listenerCount(
|
|
15882
|
-
coreEvents.on(
|
|
15897
|
+
if (coreEvents.listenerCount(CoreEvent.Output) === 0) {
|
|
15898
|
+
coreEvents.on(CoreEvent.Output, (payload) => {
|
|
15883
15899
|
if (payload.isStderr) {
|
|
15884
15900
|
writeToStderr(payload.chunk, payload.encoding);
|
|
15885
15901
|
} else {
|
|
15886
15902
|
writeToStdout(payload.chunk, payload.encoding);
|
|
15887
15903
|
}
|
|
15888
15904
|
});
|
|
15889
|
-
if (coreEvents.listenerCount(
|
|
15890
|
-
coreEvents.on(
|
|
15905
|
+
if (coreEvents.listenerCount(CoreEvent.ConsoleLog) === 0) {
|
|
15906
|
+
coreEvents.on(CoreEvent.ConsoleLog, (payload) => {
|
|
15891
15907
|
if (payload.type === "error" || payload.type === "warn") {
|
|
15892
15908
|
writeToStderr(payload.content + "\n");
|
|
15893
15909
|
} else {
|
|
@@ -15895,8 +15911,8 @@ function initializeOutputListenersAndFlush() {
|
|
|
15895
15911
|
}
|
|
15896
15912
|
});
|
|
15897
15913
|
}
|
|
15898
|
-
if (coreEvents.listenerCount(
|
|
15899
|
-
coreEvents.on(
|
|
15914
|
+
if (coreEvents.listenerCount(CoreEvent.UserFeedback) === 0) {
|
|
15915
|
+
coreEvents.on(CoreEvent.UserFeedback, (payload) => {
|
|
15900
15916
|
writeToStderr(payload.message + "\n");
|
|
15901
15917
|
});
|
|
15902
15918
|
}
|