@google/gemini-cli 0.46.0-preview.0 → 0.46.0-preview.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-4AGOZ7LL.js → chunk-24H54ISH.js} +7 -7
- package/bundle/{chunk-F2LLVPPS.js → chunk-3EC3ZLRQ.js} +2 -2
- package/bundle/{chunk-2GMVQS2Q.js → chunk-3WW2LTMX.js} +1 -1
- package/bundle/{chunk-ZXN4VW7M.js → chunk-4B7MDBUK.js} +1 -1
- package/bundle/{chunk-J444UQD3.js → chunk-5CWORGE3.js} +1 -1
- package/bundle/{chunk-HMR43ZX2.js → chunk-5IBYZHR7.js} +2 -2
- package/bundle/{chunk-QFEJQS5X.js → chunk-7Y6NU65D.js} +1 -1
- package/bundle/{chunk-4K3E3G6Z.js → chunk-EG7USKV5.js} +8 -5
- package/bundle/{chunk-SHFHGDWR.js → chunk-EZDKSTIF.js} +2 -2
- package/bundle/{chunk-RXG3JOOZ.js → chunk-GRD2P7HY.js} +1 -1
- package/bundle/chunk-HQNVDCXK.js +154 -0
- package/bundle/chunk-ILHDA6XU.js +17320 -0
- package/bundle/{chunk-XRDSBRG4.js → chunk-ITC7TFJU.js} +7560 -14072
- package/bundle/{chunk-BOJOJVNV.js → chunk-JF6RJW53.js} +1 -1
- package/bundle/chunk-JPYTHGMI.js +398 -0
- package/bundle/{chunk-FIM2LOYZ.js → chunk-KOJR46UO.js} +40 -23
- package/bundle/{chunk-MFYAVF7Y.js → chunk-KQ4V7ZN4.js} +67 -54
- package/bundle/chunk-O3UKVEBS.js +81685 -0
- package/bundle/{chunk-S2ICEQVC.js → chunk-ONUDATHO.js} +3 -3
- package/bundle/{chunk-HHFFICNK.js → chunk-QEVRJ7HY.js} +46 -23
- package/bundle/{chunk-LBE2WKE7.js → chunk-QFWAILKU.js} +3 -3
- package/bundle/{chunk-HZNEV3DS.js → chunk-QMCEWHRR.js} +1 -1
- package/bundle/{chunk-ZQGZKIDD.js → chunk-R4LEIQZM.js} +3 -3
- package/bundle/{chunk-5LUCCXOB.js → chunk-RXYIE5L5.js} +1 -1
- package/bundle/{chunk-GTRQQGSJ.js → chunk-UM53YDCH.js} +1 -1
- package/bundle/{chunk-YMNECODB.js → chunk-VEHSYWQT.js} +9 -8
- package/bundle/chunk-VETILJQA.js +1571 -0
- package/bundle/chunk-VOFVOS4I.js +118 -0
- package/bundle/chunk-WRWCUHAM.js +512 -0
- package/bundle/chunk-XVDCGVTF.js +394545 -0
- package/bundle/{chunk-TDYUKPZH.js → chunk-YINW7YTJ.js} +1 -1
- package/bundle/{chunk-773AJHDP.js → chunk-YIOYXRDP.js} +7 -7
- package/bundle/{cleanup-2WXD6UQP.js → cleanup-4ZTB4WMN.js} +2 -2
- package/bundle/{cleanup-L3CLNVX6.js → cleanup-7LLX4OFN.js} +2 -2
- package/bundle/{cleanup-SUDL37MT.js → cleanup-GI5426XS.js} +2 -2
- package/bundle/cleanup-ZBLVGXIK.js +32 -0
- package/bundle/{core-VVRQ2GQD.js → core-3UQQYNJF.js} +3 -1
- package/bundle/{devtoolsService-ZYCBBAV3.js → devtoolsService-GJWWZ2KK.js} +2 -2
- package/bundle/{devtoolsService-E62WA3CY.js → devtoolsService-UNQILSWI.js} +4 -3
- package/bundle/devtoolsService-Z2YXVMYF.js +856 -0
- package/bundle/{devtoolsService-GLW7S6PS.js → devtoolsService-ZYGDAPOV.js} +2 -2
- package/bundle/{dist-GPCRVPKS.js → dist-4NVM6I2N.js} +3 -1
- package/bundle/{core-MOYKPEYV.js → dist-LIQULVXZ.js} +3 -1
- package/bundle/dist-XPP357J7.js +2140 -0
- package/bundle/docs/reference/configuration.md +3 -1
- package/bundle/{gemini-R5NCXCEL.js → gemini-5WY2YO7R.js} +216 -197
- package/bundle/gemini-7GZVH4VW.js +16409 -0
- package/bundle/{gemini-2JTOIMGM.js → gemini-QDOVPRKF.js} +17 -14
- package/bundle/{gemini-KV5CHM4H.js → gemini-RBKWBGCC.js} +17 -14
- package/bundle/gemini.js +7 -7
- package/bundle/{interactiveCli-RMWTSIEN.js → interactiveCli-BMKHWEH4.js} +17 -11
- package/bundle/{interactiveCli-7SIMXKNU.js → interactiveCli-OEFOYFJU.js} +323 -298
- package/bundle/interactiveCli-OGE5OTZB.js +34742 -0
- package/bundle/{interactiveCli-HVAQTBJK.js → interactiveCli-W3CMLQIM.js} +17 -11
- package/bundle/{liteRtServerManager-FY23PYSD.js → liteRtServerManager-3QOJEGNL.js} +4 -4
- package/bundle/{liteRtServerManager-LDS45QKP.js → liteRtServerManager-HPVNUYFX.js} +4 -4
- package/bundle/{liteRtServerManager-BP7XKGNU.js → liteRtServerManager-Q6LTEYH4.js} +4 -4
- package/bundle/liteRtServerManager-YL4YRHOA.js +65 -0
- package/bundle/{oauth2-provider-VVNBQH45.js → oauth2-provider-3WXIASQA.js} +1 -1
- package/bundle/{oauth2-provider-KL44D6HV.js → oauth2-provider-CTPS7JLT.js} +1 -1
- package/bundle/{oauth2-provider-4SSSEI6P.js → oauth2-provider-K52EY6RG.js} +38 -72
- package/bundle/oauth2-provider-PJJE326A.js +235 -0
- package/bundle/{start-FRM2XDGC.js → start-25W6VZG6.js} +6 -6
- package/bundle/{start-OEPJINIW.js → start-JBJSIKIB.js} +6 -6
- package/bundle/{start-DLEOBFRC.js → start-PK22QMBT.js} +6 -6
- package/bundle/start-XAEHV6FV.js +18 -0
- package/package.json +1 -1
|
@@ -41,18 +41,18 @@ import {
|
|
|
41
41
|
updateAllUpdatableExtensions,
|
|
42
42
|
updateExtension,
|
|
43
43
|
validateAuthMethod
|
|
44
|
-
} from "./chunk-
|
|
44
|
+
} from "./chunk-O3UKVEBS.js";
|
|
45
45
|
import {
|
|
46
46
|
appEvents
|
|
47
47
|
} from "./chunk-5PS3AYFU.js";
|
|
48
48
|
import {
|
|
49
49
|
startCommand,
|
|
50
50
|
startServer
|
|
51
|
-
} from "./chunk-
|
|
51
|
+
} from "./chunk-ONUDATHO.js";
|
|
52
52
|
import {
|
|
53
53
|
exitCli,
|
|
54
54
|
require_source
|
|
55
|
-
} from "./chunk-
|
|
55
|
+
} from "./chunk-RXYIE5L5.js";
|
|
56
56
|
import {
|
|
57
57
|
DEFAULT_PORT,
|
|
58
58
|
GEMMA_MODEL_NAME,
|
|
@@ -86,11 +86,11 @@ import {
|
|
|
86
86
|
readServerProcessInfo,
|
|
87
87
|
resolveGemmaConfig,
|
|
88
88
|
saveModelChange
|
|
89
|
-
} from "./chunk-
|
|
89
|
+
} from "./chunk-5CWORGE3.js";
|
|
90
90
|
import {
|
|
91
91
|
RELAUNCH_EXIT_CODE
|
|
92
|
-
} from "./chunk-
|
|
93
|
-
import "./chunk-
|
|
92
|
+
} from "./chunk-JPYTHGMI.js";
|
|
93
|
+
import "./chunk-WRWCUHAM.js";
|
|
94
94
|
import {
|
|
95
95
|
cleanupCheckpoints,
|
|
96
96
|
registerCleanup,
|
|
@@ -99,12 +99,15 @@ import {
|
|
|
99
99
|
runExitCleanup,
|
|
100
100
|
runSyncCleanup,
|
|
101
101
|
setupSignalHandlers
|
|
102
|
-
} from "./chunk-
|
|
102
|
+
} from "./chunk-7Y6NU65D.js";
|
|
103
103
|
import {
|
|
104
104
|
ASK_USER_TOOL_NAME,
|
|
105
|
+
ApprovalMode,
|
|
105
106
|
AuthType,
|
|
106
107
|
Client,
|
|
107
108
|
Config,
|
|
109
|
+
CoreEvent,
|
|
110
|
+
CoreToolCallStatus,
|
|
108
111
|
DEFAULT_CONTEXT_FILENAME,
|
|
109
112
|
DEFAULT_FILE_FILTERING_OPTIONS,
|
|
110
113
|
DEFAULT_GEMINI_EMBEDDING_MODEL,
|
|
@@ -126,32 +129,45 @@ import {
|
|
|
126
129
|
FolderTrustDiscoveryService,
|
|
127
130
|
GEMINI_DIR,
|
|
128
131
|
GEMINI_MODEL_ALIAS_AUTO,
|
|
132
|
+
GeminiEventType,
|
|
129
133
|
IdeClient,
|
|
134
|
+
IntegrityStatus,
|
|
130
135
|
InvalidStreamError,
|
|
131
136
|
JsonFormatter,
|
|
137
|
+
JsonStreamEventType,
|
|
138
|
+
Kind,
|
|
132
139
|
LegacyAgentSession,
|
|
133
140
|
Logger,
|
|
134
141
|
MCPServerConfig,
|
|
142
|
+
MCPServerStatus,
|
|
143
|
+
MessageBusType,
|
|
144
|
+
OutputFormat,
|
|
135
145
|
PREVIEW_GEMINI_3_1_CUSTOM_TOOLS_MODEL,
|
|
136
146
|
PREVIEW_GEMINI_3_1_MODEL,
|
|
137
147
|
PREVIEW_GEMINI_FLASH_LITE_MODEL,
|
|
138
148
|
PREVIEW_GEMINI_FLASH_MODEL,
|
|
139
149
|
PREVIEW_GEMINI_MODEL,
|
|
150
|
+
PolicyDecision,
|
|
140
151
|
PolicyIntegrityManager,
|
|
141
152
|
REFERENCE_CONTENT_START,
|
|
142
153
|
ROOT_SCHEDULER_ID,
|
|
143
154
|
ReadManyFilesTool,
|
|
144
155
|
Scheduler,
|
|
156
|
+
SessionEndReason,
|
|
157
|
+
SessionStartSource,
|
|
145
158
|
ShellExecutionService,
|
|
146
159
|
SimpleExtensionLoader,
|
|
147
160
|
Storage,
|
|
148
161
|
StreamJsonFormatter,
|
|
149
162
|
ToolCallEvent,
|
|
150
163
|
ToolConfirmationOutcome,
|
|
164
|
+
ToolErrorType,
|
|
165
|
+
TrustLevel,
|
|
151
166
|
UserAccountManager,
|
|
152
167
|
UserPromptEvent,
|
|
153
168
|
ValidationCancelledError,
|
|
154
169
|
ValidationRequiredError,
|
|
170
|
+
WarningPriority,
|
|
155
171
|
applyAdminAllowlist,
|
|
156
172
|
applyRequiredServers,
|
|
157
173
|
clearCachedCredentialFile,
|
|
@@ -231,7 +247,7 @@ import {
|
|
|
231
247
|
updatePolicy,
|
|
232
248
|
writeToStderr,
|
|
233
249
|
writeToStdout
|
|
234
|
-
} from "./chunk-
|
|
250
|
+
} from "./chunk-ITC7TFJU.js";
|
|
235
251
|
import "./chunk-6HI7VNOG.js";
|
|
236
252
|
import "./chunk-TUDYL3X4.js";
|
|
237
253
|
import "./chunk-IUUIT4SU.js";
|
|
@@ -5361,7 +5377,7 @@ var MCP_LIST_DEFAULT_TIMEOUT_MSEC = 5e3;
|
|
|
5361
5377
|
async function testMCPConnection(serverName, config, isTrusted, activeSettings) {
|
|
5362
5378
|
const isStdio = !!config.command;
|
|
5363
5379
|
if (isStdio && !isTrusted) {
|
|
5364
|
-
return
|
|
5380
|
+
return MCPServerStatus.DISCONNECTED;
|
|
5365
5381
|
}
|
|
5366
5382
|
const client = new Client({
|
|
5367
5383
|
name: "mcp-test-client",
|
|
@@ -5397,7 +5413,7 @@ async function testMCPConnection(serverName, config, isTrusted, activeSettings)
|
|
|
5397
5413
|
transport = await createTransport(serverName, config, false, mcpContext);
|
|
5398
5414
|
} catch {
|
|
5399
5415
|
await client.close();
|
|
5400
|
-
return
|
|
5416
|
+
return MCPServerStatus.DISCONNECTED;
|
|
5401
5417
|
}
|
|
5402
5418
|
try {
|
|
5403
5419
|
const timeout = config.timeout ?? MCP_LIST_DEFAULT_TIMEOUT_MSEC;
|
|
@@ -5411,10 +5427,10 @@ async function testMCPConnection(serverName, config, isTrusted, activeSettings)
|
|
|
5411
5427
|
);
|
|
5412
5428
|
}
|
|
5413
5429
|
await client.close();
|
|
5414
|
-
return
|
|
5430
|
+
return MCPServerStatus.CONNECTED;
|
|
5415
5431
|
} catch {
|
|
5416
5432
|
await transport.close();
|
|
5417
|
-
return
|
|
5433
|
+
return MCPServerStatus.DISCONNECTED;
|
|
5418
5434
|
}
|
|
5419
5435
|
}
|
|
5420
5436
|
async function getServerStatus(serverName, server, isTrusted, activeSettings, consolidatedExcluded, consolidatedAllowed) {
|
|
@@ -5427,12 +5443,12 @@ async function getServerStatus(serverName, server, isTrusted, activeSettings, co
|
|
|
5427
5443
|
});
|
|
5428
5444
|
if (!loadResult.allowed) {
|
|
5429
5445
|
if (loadResult.blockType === "admin" || loadResult.blockType === "allowlist" || loadResult.blockType === "excludelist") {
|
|
5430
|
-
return
|
|
5446
|
+
return MCPServerStatus.BLOCKED;
|
|
5431
5447
|
}
|
|
5432
|
-
return
|
|
5448
|
+
return MCPServerStatus.DISABLED;
|
|
5433
5449
|
}
|
|
5434
5450
|
if (!isTrusted) {
|
|
5435
|
-
return
|
|
5451
|
+
return MCPServerStatus.DISABLED;
|
|
5436
5452
|
}
|
|
5437
5453
|
return testMCPConnection(serverName, server, isTrusted, activeSettings);
|
|
5438
5454
|
}
|
|
@@ -5478,23 +5494,23 @@ async function listMcpServers(loadedSettingsArg) {
|
|
|
5478
5494
|
let statusIndicator = "";
|
|
5479
5495
|
let statusText = "";
|
|
5480
5496
|
switch (status) {
|
|
5481
|
-
case
|
|
5497
|
+
case MCPServerStatus.CONNECTED:
|
|
5482
5498
|
statusIndicator = import_chalk.default.green("\u2713");
|
|
5483
5499
|
statusText = "Connected";
|
|
5484
5500
|
break;
|
|
5485
|
-
case
|
|
5501
|
+
case MCPServerStatus.CONNECTING:
|
|
5486
5502
|
statusIndicator = import_chalk.default.yellow("\u2026");
|
|
5487
5503
|
statusText = "Connecting";
|
|
5488
5504
|
break;
|
|
5489
|
-
case
|
|
5505
|
+
case MCPServerStatus.BLOCKED:
|
|
5490
5506
|
statusIndicator = import_chalk.default.red("\u26D4");
|
|
5491
5507
|
statusText = "Blocked";
|
|
5492
5508
|
break;
|
|
5493
|
-
case
|
|
5509
|
+
case MCPServerStatus.DISABLED:
|
|
5494
5510
|
statusIndicator = import_chalk.default.gray("\u25CB");
|
|
5495
5511
|
statusText = "Disabled";
|
|
5496
5512
|
break;
|
|
5497
|
-
case
|
|
5513
|
+
case MCPServerStatus.DISCONNECTED:
|
|
5498
5514
|
default:
|
|
5499
5515
|
statusIndicator = import_chalk.default.red("\u2717");
|
|
5500
5516
|
statusText = "Disconnected";
|
|
@@ -5780,7 +5796,7 @@ async function handleInstall(args) {
|
|
|
5780
5796
|
);
|
|
5781
5797
|
if (confirmed) {
|
|
5782
5798
|
const trustedFolders = loadTrustedFolders();
|
|
5783
|
-
await trustedFolders.setValue(realPath,
|
|
5799
|
+
await trustedFolders.setValue(realPath, TrustLevel.TRUST_FOLDER);
|
|
5784
5800
|
} else {
|
|
5785
5801
|
throw new Error(
|
|
5786
5802
|
`Installation aborted: Folder "${absolutePath}" is not trusted.`
|
|
@@ -7825,7 +7841,7 @@ async function loadSandboxConfig(settings, argv) {
|
|
|
7825
7841
|
}
|
|
7826
7842
|
const command2 = getSandboxCommand(sandboxValue);
|
|
7827
7843
|
const packageJson = await getPackageJson(__dirname3);
|
|
7828
|
-
const image = process.env["GEMINI_SANDBOX_IMAGE"] ?? "us-docker.pkg.dev/gemini-code-dev/gemini-cli/sandbox:0.
|
|
7844
|
+
const image = process.env["GEMINI_SANDBOX_IMAGE"] ?? "us-docker.pkg.dev/gemini-code-dev/gemini-cli/sandbox:0.46.0-preview.1" ?? customImage ?? packageJson?.config?.sandboxImageUri;
|
|
7829
7845
|
const isNative = command2 === "windows-native" || command2 === "sandbox-exec" || command2 === "lxc";
|
|
7830
7846
|
return command2 && (image || isNative) ? { enabled: true, allowedPaths, networkAccess, command: command2, image } : void 0;
|
|
7831
7847
|
}
|
|
@@ -7884,9 +7900,9 @@ async function resolveWorkspacePolicyState(options) {
|
|
|
7884
7900
|
cwd,
|
|
7885
7901
|
potentialWorkspacePoliciesDir
|
|
7886
7902
|
);
|
|
7887
|
-
if (integrityResult.status ===
|
|
7903
|
+
if (integrityResult.status === IntegrityStatus.MATCH) {
|
|
7888
7904
|
workspacePoliciesDir = potentialWorkspacePoliciesDir;
|
|
7889
|
-
} else if (integrityResult.status ===
|
|
7905
|
+
} else if (integrityResult.status === IntegrityStatus.NEW && integrityResult.fileCount === 0) {
|
|
7890
7906
|
workspacePoliciesDir = void 0;
|
|
7891
7907
|
} else if (interactive && !autoAcceptWorkspacePolicies) {
|
|
7892
7908
|
policyUpdateConfirmationRequest = {
|
|
@@ -8314,23 +8330,23 @@ async function loadCliConfig(settings, sessionId, argv, options = {}) {
|
|
|
8314
8330
|
if (rawApprovalMode) {
|
|
8315
8331
|
switch (rawApprovalMode) {
|
|
8316
8332
|
case "yolo":
|
|
8317
|
-
approvalMode =
|
|
8333
|
+
approvalMode = ApprovalMode.YOLO;
|
|
8318
8334
|
break;
|
|
8319
8335
|
case "auto_edit":
|
|
8320
|
-
approvalMode =
|
|
8336
|
+
approvalMode = ApprovalMode.AUTO_EDIT;
|
|
8321
8337
|
break;
|
|
8322
8338
|
case "plan":
|
|
8323
8339
|
if (!(settings.general?.plan?.enabled ?? true)) {
|
|
8324
8340
|
debugLogger.warn(
|
|
8325
8341
|
'Approval mode "plan" is disabled in your settings. Falling back to "default".'
|
|
8326
8342
|
);
|
|
8327
|
-
approvalMode =
|
|
8343
|
+
approvalMode = ApprovalMode.DEFAULT;
|
|
8328
8344
|
} else {
|
|
8329
|
-
approvalMode =
|
|
8345
|
+
approvalMode = ApprovalMode.PLAN;
|
|
8330
8346
|
}
|
|
8331
8347
|
break;
|
|
8332
8348
|
case "default":
|
|
8333
|
-
approvalMode =
|
|
8349
|
+
approvalMode = ApprovalMode.DEFAULT;
|
|
8334
8350
|
break;
|
|
8335
8351
|
default:
|
|
8336
8352
|
throw new Error(
|
|
@@ -8338,10 +8354,10 @@ async function loadCliConfig(settings, sessionId, argv, options = {}) {
|
|
|
8338
8354
|
);
|
|
8339
8355
|
}
|
|
8340
8356
|
} else {
|
|
8341
|
-
approvalMode =
|
|
8357
|
+
approvalMode = ApprovalMode.DEFAULT;
|
|
8342
8358
|
}
|
|
8343
8359
|
if (settings.security?.disableYoloMode || settings.admin?.secureModeEnabled) {
|
|
8344
|
-
if (approvalMode ===
|
|
8360
|
+
if (approvalMode === ApprovalMode.YOLO) {
|
|
8345
8361
|
if (settings.admin?.secureModeEnabled) {
|
|
8346
8362
|
debugLogger.error(
|
|
8347
8363
|
'YOLO mode is disabled by "secureModeEnabled" setting.'
|
|
@@ -8359,16 +8375,16 @@ async function loadCliConfig(settings, sessionId, argv, options = {}) {
|
|
|
8359
8375
|
)
|
|
8360
8376
|
);
|
|
8361
8377
|
}
|
|
8362
|
-
} else if (approvalMode ===
|
|
8378
|
+
} else if (approvalMode === ApprovalMode.YOLO) {
|
|
8363
8379
|
debugLogger.warn(
|
|
8364
8380
|
"YOLO mode is enabled. All tool calls will be automatically approved."
|
|
8365
8381
|
);
|
|
8366
8382
|
}
|
|
8367
|
-
if (!trustedFolder && approvalMode !==
|
|
8383
|
+
if (!trustedFolder && approvalMode !== ApprovalMode.DEFAULT) {
|
|
8368
8384
|
debugLogger.warn(
|
|
8369
8385
|
`Approval mode overridden to "default" because the current folder is not trusted.`
|
|
8370
8386
|
);
|
|
8371
|
-
approvalMode =
|
|
8387
|
+
approvalMode = ApprovalMode.DEFAULT;
|
|
8372
8388
|
}
|
|
8373
8389
|
let telemetrySettings;
|
|
8374
8390
|
try {
|
|
@@ -9806,7 +9822,7 @@ import path9 from "node:path";
|
|
|
9806
9822
|
import process4 from "node:process";
|
|
9807
9823
|
var homeDirectoryCheck = {
|
|
9808
9824
|
id: "home-directory",
|
|
9809
|
-
priority:
|
|
9825
|
+
priority: WarningPriority.Low,
|
|
9810
9826
|
check: async (workspaceRoot, settings) => {
|
|
9811
9827
|
if (settings.ui?.showHomeDirectoryWarning === false) {
|
|
9812
9828
|
return null;
|
|
@@ -9830,7 +9846,7 @@ var homeDirectoryCheck = {
|
|
|
9830
9846
|
};
|
|
9831
9847
|
var rootDirectoryCheck = {
|
|
9832
9848
|
id: "root-directory",
|
|
9833
|
-
priority:
|
|
9849
|
+
priority: WarningPriority.High,
|
|
9834
9850
|
check: async (workspaceRoot, _settings) => {
|
|
9835
9851
|
try {
|
|
9836
9852
|
const workspaceRealPath = await fs9.realpath(workspaceRoot);
|
|
@@ -9846,7 +9862,7 @@ var rootDirectoryCheck = {
|
|
|
9846
9862
|
};
|
|
9847
9863
|
var folderTrustCheck = {
|
|
9848
9864
|
id: "folder-trust",
|
|
9849
|
-
priority:
|
|
9865
|
+
priority: WarningPriority.High,
|
|
9850
9866
|
check: async (workspaceRoot, settings) => {
|
|
9851
9867
|
if (!isFolderTrustEnabled(settings)) {
|
|
9852
9868
|
return null;
|
|
@@ -10036,12 +10052,12 @@ function handleError(error, config, customErrorCode) {
|
|
|
10036
10052
|
error,
|
|
10037
10053
|
config.getContentGeneratorConfig()?.authType
|
|
10038
10054
|
);
|
|
10039
|
-
if (config.getOutputFormat() ===
|
|
10055
|
+
if (config.getOutputFormat() === OutputFormat.STREAM_JSON) {
|
|
10040
10056
|
const streamFormatter = new StreamJsonFormatter();
|
|
10041
10057
|
const errorCode = customErrorCode ?? extractErrorCode(error);
|
|
10042
10058
|
const metrics = uiTelemetryService.getMetrics();
|
|
10043
10059
|
streamFormatter.emitEvent({
|
|
10044
|
-
type:
|
|
10060
|
+
type: JsonStreamEventType.RESULT,
|
|
10045
10061
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10046
10062
|
status: "error",
|
|
10047
10063
|
error: {
|
|
@@ -10052,7 +10068,7 @@ function handleError(error, config, customErrorCode) {
|
|
|
10052
10068
|
});
|
|
10053
10069
|
runSyncCleanup();
|
|
10054
10070
|
process.exit(getNumericExitCode(errorCode));
|
|
10055
|
-
} else if (config.getOutputFormat() ===
|
|
10071
|
+
} else if (config.getOutputFormat() === OutputFormat.JSON) {
|
|
10056
10072
|
const formatter = new JsonFormatter();
|
|
10057
10073
|
const errorCode = customErrorCode ?? extractErrorCode(error);
|
|
10058
10074
|
const formattedError = formatter.formatError(
|
|
@@ -10072,11 +10088,11 @@ function handleToolError(toolName, toolError, config, errorType, resultDisplay)
|
|
|
10072
10088
|
const isFatal = isFatalToolError(errorType);
|
|
10073
10089
|
if (isFatal) {
|
|
10074
10090
|
const toolExecutionError = new FatalToolExecutionError(errorMessage);
|
|
10075
|
-
if (config.getOutputFormat() ===
|
|
10091
|
+
if (config.getOutputFormat() === OutputFormat.STREAM_JSON) {
|
|
10076
10092
|
const streamFormatter = new StreamJsonFormatter();
|
|
10077
10093
|
const metrics = uiTelemetryService.getMetrics();
|
|
10078
10094
|
streamFormatter.emitEvent({
|
|
10079
|
-
type:
|
|
10095
|
+
type: JsonStreamEventType.RESULT,
|
|
10080
10096
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10081
10097
|
status: "error",
|
|
10082
10098
|
error: {
|
|
@@ -10085,7 +10101,7 @@ function handleToolError(toolName, toolError, config, errorType, resultDisplay)
|
|
|
10085
10101
|
},
|
|
10086
10102
|
stats: streamFormatter.convertToStreamStats(metrics, 0)
|
|
10087
10103
|
});
|
|
10088
|
-
} else if (config.getOutputFormat() ===
|
|
10104
|
+
} else if (config.getOutputFormat() === OutputFormat.JSON) {
|
|
10089
10105
|
const formatter = new JsonFormatter();
|
|
10090
10106
|
const formattedError = formatter.formatError(
|
|
10091
10107
|
toolExecutionError,
|
|
@@ -10103,11 +10119,11 @@ function handleToolError(toolName, toolError, config, errorType, resultDisplay)
|
|
|
10103
10119
|
}
|
|
10104
10120
|
function handleCancellationError(config) {
|
|
10105
10121
|
const cancellationError = new FatalCancellationError("Operation cancelled.");
|
|
10106
|
-
if (config.getOutputFormat() ===
|
|
10122
|
+
if (config.getOutputFormat() === OutputFormat.STREAM_JSON) {
|
|
10107
10123
|
const streamFormatter = new StreamJsonFormatter();
|
|
10108
10124
|
const metrics = uiTelemetryService.getMetrics();
|
|
10109
10125
|
streamFormatter.emitEvent({
|
|
10110
|
-
type:
|
|
10126
|
+
type: JsonStreamEventType.RESULT,
|
|
10111
10127
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10112
10128
|
status: "error",
|
|
10113
10129
|
error: {
|
|
@@ -10118,7 +10134,7 @@ function handleCancellationError(config) {
|
|
|
10118
10134
|
});
|
|
10119
10135
|
runSyncCleanup();
|
|
10120
10136
|
process.exit(cancellationError.exitCode);
|
|
10121
|
-
} else if (config.getOutputFormat() ===
|
|
10137
|
+
} else if (config.getOutputFormat() === OutputFormat.JSON) {
|
|
10122
10138
|
const formatter = new JsonFormatter();
|
|
10123
10139
|
const formattedError = formatter.formatError(
|
|
10124
10140
|
cancellationError,
|
|
@@ -10138,11 +10154,11 @@ function handleMaxTurnsExceededError(config) {
|
|
|
10138
10154
|
const maxTurnsError = new FatalTurnLimitedError(
|
|
10139
10155
|
"Reached max session turns for this session. Increase the number of turns by specifying maxSessionTurns in settings.json."
|
|
10140
10156
|
);
|
|
10141
|
-
if (config.getOutputFormat() ===
|
|
10157
|
+
if (config.getOutputFormat() === OutputFormat.STREAM_JSON) {
|
|
10142
10158
|
const streamFormatter = new StreamJsonFormatter();
|
|
10143
10159
|
const metrics = uiTelemetryService.getMetrics();
|
|
10144
10160
|
streamFormatter.emitEvent({
|
|
10145
|
-
type:
|
|
10161
|
+
type: JsonStreamEventType.RESULT,
|
|
10146
10162
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10147
10163
|
status: "error",
|
|
10148
10164
|
error: {
|
|
@@ -10153,7 +10169,7 @@ function handleMaxTurnsExceededError(config) {
|
|
|
10153
10169
|
});
|
|
10154
10170
|
runSyncCleanup();
|
|
10155
10171
|
process.exit(maxTurnsError.exitCode);
|
|
10156
|
-
} else if (config.getOutputFormat() ===
|
|
10172
|
+
} else if (config.getOutputFormat() === OutputFormat.JSON) {
|
|
10157
10173
|
const formatter = new JsonFormatter();
|
|
10158
10174
|
const formattedError = formatter.formatError(
|
|
10159
10175
|
maxTurnsError,
|
|
@@ -10233,7 +10249,7 @@ async function runNonInteractive({
|
|
|
10233
10249
|
}
|
|
10234
10250
|
});
|
|
10235
10251
|
if (process.env["GEMINI_CLI_ACTIVITY_LOG_TARGET"]) {
|
|
10236
|
-
const { setupInitialActivityLogger } = await import("./devtoolsService-
|
|
10252
|
+
const { setupInitialActivityLogger } = await import("./devtoolsService-Z2YXVMYF.js");
|
|
10237
10253
|
setupInitialActivityLogger(config);
|
|
10238
10254
|
}
|
|
10239
10255
|
const { stdout: workingStdout } = createWorkingStdio();
|
|
@@ -10249,7 +10265,7 @@ async function runNonInteractive({
|
|
|
10249
10265
|
}
|
|
10250
10266
|
};
|
|
10251
10267
|
const startTime = Date.now();
|
|
10252
|
-
const streamFormatter = config.getOutputFormat() ===
|
|
10268
|
+
const streamFormatter = config.getOutputFormat() === OutputFormat.STREAM_JSON ? new StreamJsonFormatter() : null;
|
|
10253
10269
|
const abortController = new AbortController();
|
|
10254
10270
|
let isAborting = false;
|
|
10255
10271
|
let cancelMessageTimer = null;
|
|
@@ -10302,13 +10318,13 @@ async function runNonInteractive({
|
|
|
10302
10318
|
};
|
|
10303
10319
|
try {
|
|
10304
10320
|
consolePatcher.patch();
|
|
10305
|
-
if (config.getRawOutput() && !config.getAcceptRawOutputRisk() && config.getOutputFormat() ===
|
|
10321
|
+
if (config.getRawOutput() && !config.getAcceptRawOutputRisk() && config.getOutputFormat() === OutputFormat.TEXT) {
|
|
10306
10322
|
process.stderr.write(
|
|
10307
10323
|
"[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"
|
|
10308
10324
|
);
|
|
10309
10325
|
}
|
|
10310
10326
|
setupStdinCancellation();
|
|
10311
|
-
coreEvents.on(
|
|
10327
|
+
coreEvents.on(CoreEvent.UserFeedback, handleUserFeedback);
|
|
10312
10328
|
coreEvents.drainBacklogs();
|
|
10313
10329
|
process.stdout.on("error", (err) => {
|
|
10314
10330
|
if (err.code === "EPIPE") {
|
|
@@ -10334,7 +10350,7 @@ async function runNonInteractive({
|
|
|
10334
10350
|
}
|
|
10335
10351
|
if (streamFormatter) {
|
|
10336
10352
|
streamFormatter.emitEvent({
|
|
10337
|
-
type:
|
|
10353
|
+
type: JsonStreamEventType.INIT,
|
|
10338
10354
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10339
10355
|
session_id: config.getSessionId(),
|
|
10340
10356
|
model: config.getModel()
|
|
@@ -10372,7 +10388,7 @@ async function runNonInteractive({
|
|
|
10372
10388
|
}
|
|
10373
10389
|
if (streamFormatter) {
|
|
10374
10390
|
streamFormatter.emitEvent({
|
|
10375
|
-
type:
|
|
10391
|
+
type: JsonStreamEventType.MESSAGE,
|
|
10376
10392
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10377
10393
|
role: "user",
|
|
10378
10394
|
content: input
|
|
@@ -10411,12 +10427,12 @@ async function runNonInteractive({
|
|
|
10411
10427
|
const metrics = uiTelemetryService.getMetrics();
|
|
10412
10428
|
const durationMs = Date.now() - startTime;
|
|
10413
10429
|
streamFormatter.emitEvent({
|
|
10414
|
-
type:
|
|
10430
|
+
type: JsonStreamEventType.RESULT,
|
|
10415
10431
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10416
10432
|
status: "success",
|
|
10417
10433
|
stats: streamFormatter.convertToStreamStats(metrics, durationMs)
|
|
10418
10434
|
});
|
|
10419
|
-
} else if (config.getOutputFormat() ===
|
|
10435
|
+
} else if (config.getOutputFormat() === OutputFormat.JSON) {
|
|
10420
10436
|
const formatter = new JsonFormatter();
|
|
10421
10437
|
const stats = uiTelemetryService.getMetrics();
|
|
10422
10438
|
textOutput.write(
|
|
@@ -10509,13 +10525,13 @@ async function runNonInteractive({
|
|
|
10509
10525
|
const output = isRaw ? part.text : stripAnsi(part.text);
|
|
10510
10526
|
if (streamFormatter) {
|
|
10511
10527
|
streamFormatter.emitEvent({
|
|
10512
|
-
type:
|
|
10528
|
+
type: JsonStreamEventType.MESSAGE,
|
|
10513
10529
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10514
10530
|
role: "assistant",
|
|
10515
10531
|
content: output,
|
|
10516
10532
|
delta: true
|
|
10517
10533
|
});
|
|
10518
|
-
} else if (config.getOutputFormat() ===
|
|
10534
|
+
} else if (config.getOutputFormat() === OutputFormat.JSON) {
|
|
10519
10535
|
responseText += output;
|
|
10520
10536
|
} else {
|
|
10521
10537
|
if (part.text) {
|
|
@@ -10528,13 +10544,13 @@ async function runNonInteractive({
|
|
|
10528
10544
|
break;
|
|
10529
10545
|
}
|
|
10530
10546
|
case "tool_request": {
|
|
10531
|
-
if (config.getOutputFormat() ===
|
|
10547
|
+
if (config.getOutputFormat() === OutputFormat.JSON) {
|
|
10532
10548
|
preToolResponseText = responseText || preToolResponseText;
|
|
10533
10549
|
responseText = "";
|
|
10534
10550
|
}
|
|
10535
10551
|
if (streamFormatter) {
|
|
10536
10552
|
streamFormatter.emitEvent({
|
|
10537
|
-
type:
|
|
10553
|
+
type: JsonStreamEventType.TOOL_USE,
|
|
10538
10554
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10539
10555
|
tool_name: event.name,
|
|
10540
10556
|
tool_id: event.requestId,
|
|
@@ -10550,7 +10566,7 @@ async function runNonInteractive({
|
|
|
10550
10566
|
const displayText = displayContentToString(display);
|
|
10551
10567
|
const errorMsg = getTextContent(event.content) ?? "Tool error";
|
|
10552
10568
|
streamFormatter.emitEvent({
|
|
10553
|
-
type:
|
|
10569
|
+
type: JsonStreamEventType.TOOL_RESULT,
|
|
10554
10570
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10555
10571
|
tool_id: event.requestId,
|
|
10556
10572
|
status: event.isError ? "error" : "success",
|
|
@@ -10565,17 +10581,17 @@ async function runNonInteractive({
|
|
|
10565
10581
|
const display = event.display?.result;
|
|
10566
10582
|
const displayText = displayContentToString(display);
|
|
10567
10583
|
const errorMsg = getTextContent(event.content) ?? "Tool error";
|
|
10568
|
-
if (event.data?.["errorType"] ===
|
|
10569
|
-
if (config.getOutputFormat() ===
|
|
10584
|
+
if (event.data?.["errorType"] === ToolErrorType.STOP_EXECUTION) {
|
|
10585
|
+
if (config.getOutputFormat() === OutputFormat.JSON && !responseText && preToolResponseText) {
|
|
10570
10586
|
responseText = preToolResponseText;
|
|
10571
10587
|
}
|
|
10572
10588
|
const stopMessage = `Agent execution stopped: ${errorMsg}`;
|
|
10573
|
-
if (config.getOutputFormat() ===
|
|
10589
|
+
if (config.getOutputFormat() === OutputFormat.TEXT) {
|
|
10574
10590
|
process.stderr.write(`${stopMessage}
|
|
10575
10591
|
`);
|
|
10576
10592
|
}
|
|
10577
10593
|
}
|
|
10578
|
-
if (event.data?.["errorType"] ===
|
|
10594
|
+
if (event.data?.["errorType"] === ToolErrorType.NO_SPACE_LEFT) {
|
|
10579
10595
|
throw new FatalToolExecutionError(
|
|
10580
10596
|
"Error executing tool " + event.name + ": " + (displayText || errorMsg)
|
|
10581
10597
|
);
|
|
@@ -10597,12 +10613,12 @@ async function runNonInteractive({
|
|
|
10597
10613
|
const errorCode = event._meta?.["code"];
|
|
10598
10614
|
if (errorCode === "AGENT_EXECUTION_BLOCKED") {
|
|
10599
10615
|
const blockMessage = `Agent execution blocked: ${event.message.trim()}`;
|
|
10600
|
-
if (config.getOutputFormat() ===
|
|
10616
|
+
if (config.getOutputFormat() === OutputFormat.TEXT) {
|
|
10601
10617
|
process.stderr.write(`[WARNING] ${blockMessage}
|
|
10602
10618
|
`);
|
|
10603
10619
|
} else if (streamFormatter) {
|
|
10604
10620
|
streamFormatter.emitEvent({
|
|
10605
|
-
type:
|
|
10621
|
+
type: JsonStreamEventType.ERROR,
|
|
10606
10622
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10607
10623
|
severity: "warning",
|
|
10608
10624
|
message: stripAnsi(blockMessage)
|
|
@@ -10612,13 +10628,13 @@ async function runNonInteractive({
|
|
|
10612
10628
|
break;
|
|
10613
10629
|
}
|
|
10614
10630
|
const severity = event.status === "RESOURCE_EXHAUSTED" ? "error" : "warning";
|
|
10615
|
-
if (config.getOutputFormat() ===
|
|
10631
|
+
if (config.getOutputFormat() === OutputFormat.TEXT) {
|
|
10616
10632
|
process.stderr.write(`[WARNING] ${event.message}
|
|
10617
10633
|
`);
|
|
10618
10634
|
}
|
|
10619
10635
|
if (streamFormatter) {
|
|
10620
10636
|
streamFormatter.emitEvent({
|
|
10621
|
-
type:
|
|
10637
|
+
type: JsonStreamEventType.ERROR,
|
|
10622
10638
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10623
10639
|
severity,
|
|
10624
10640
|
message: stripAnsi(event.message)
|
|
@@ -10638,7 +10654,7 @@ async function runNonInteractive({
|
|
|
10638
10654
|
);
|
|
10639
10655
|
} else if (streamFormatter) {
|
|
10640
10656
|
streamFormatter.emitEvent({
|
|
10641
|
-
type:
|
|
10657
|
+
type: JsonStreamEventType.ERROR,
|
|
10642
10658
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10643
10659
|
severity: "error",
|
|
10644
10660
|
message: "Maximum session turns exceeded"
|
|
@@ -10646,7 +10662,7 @@ async function runNonInteractive({
|
|
|
10646
10662
|
}
|
|
10647
10663
|
}
|
|
10648
10664
|
const stopMessage = typeof event.data?.["message"] === "string" ? event.data["message"] : "";
|
|
10649
|
-
if (stopMessage && config.getOutputFormat() ===
|
|
10665
|
+
if (stopMessage && config.getOutputFormat() === OutputFormat.TEXT) {
|
|
10650
10666
|
process.stderr.write(`Agent execution stopped: ${stopMessage}
|
|
10651
10667
|
`);
|
|
10652
10668
|
}
|
|
@@ -10676,7 +10692,7 @@ async function runNonInteractive({
|
|
|
10676
10692
|
abortController.signal.removeEventListener("abort", abortSession);
|
|
10677
10693
|
scheduler?.dispose();
|
|
10678
10694
|
consolePatcher.cleanup();
|
|
10679
|
-
coreEvents.off(
|
|
10695
|
+
coreEvents.off(CoreEvent.UserFeedback, handleUserFeedback);
|
|
10680
10696
|
}
|
|
10681
10697
|
if (errorToHandle) {
|
|
10682
10698
|
handleError(errorToHandle, config);
|
|
@@ -10704,7 +10720,7 @@ async function runNonInteractive2(params) {
|
|
|
10704
10720
|
}
|
|
10705
10721
|
});
|
|
10706
10722
|
if (process.env["GEMINI_CLI_ACTIVITY_LOG_TARGET"]) {
|
|
10707
|
-
const { setupInitialActivityLogger } = await import("./devtoolsService-
|
|
10723
|
+
const { setupInitialActivityLogger } = await import("./devtoolsService-Z2YXVMYF.js");
|
|
10708
10724
|
setupInitialActivityLogger(config);
|
|
10709
10725
|
}
|
|
10710
10726
|
const { stdout: workingStdout } = createWorkingStdio();
|
|
@@ -10720,7 +10736,7 @@ async function runNonInteractive2(params) {
|
|
|
10720
10736
|
}
|
|
10721
10737
|
};
|
|
10722
10738
|
const startTime = Date.now();
|
|
10723
|
-
const streamFormatter = config.getOutputFormat() ===
|
|
10739
|
+
const streamFormatter = config.getOutputFormat() === OutputFormat.STREAM_JSON ? new StreamJsonFormatter() : null;
|
|
10724
10740
|
const abortController = new AbortController();
|
|
10725
10741
|
let isAborting = false;
|
|
10726
10742
|
let cancelMessageTimer = null;
|
|
@@ -10771,13 +10787,13 @@ async function runNonInteractive2(params) {
|
|
|
10771
10787
|
let scheduler;
|
|
10772
10788
|
try {
|
|
10773
10789
|
consolePatcher.patch();
|
|
10774
|
-
if (config.getRawOutput() && !config.getAcceptRawOutputRisk() && config.getOutputFormat() ===
|
|
10790
|
+
if (config.getRawOutput() && !config.getAcceptRawOutputRisk() && config.getOutputFormat() === OutputFormat.TEXT) {
|
|
10775
10791
|
process.stderr.write(
|
|
10776
10792
|
"[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"
|
|
10777
10793
|
);
|
|
10778
10794
|
}
|
|
10779
10795
|
setupStdinCancellation();
|
|
10780
|
-
coreEvents.on(
|
|
10796
|
+
coreEvents.on(CoreEvent.UserFeedback, handleUserFeedback);
|
|
10781
10797
|
coreEvents.drainBacklogs();
|
|
10782
10798
|
process.stdout.on("error", (err) => {
|
|
10783
10799
|
if (err.code === "EPIPE") {
|
|
@@ -10801,7 +10817,7 @@ async function runNonInteractive2(params) {
|
|
|
10801
10817
|
}
|
|
10802
10818
|
if (streamFormatter) {
|
|
10803
10819
|
streamFormatter.emitEvent({
|
|
10804
|
-
type:
|
|
10820
|
+
type: JsonStreamEventType.INIT,
|
|
10805
10821
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10806
10822
|
session_id: config.getSessionId(),
|
|
10807
10823
|
model: config.getModel()
|
|
@@ -10839,7 +10855,7 @@ async function runNonInteractive2(params) {
|
|
|
10839
10855
|
}
|
|
10840
10856
|
if (streamFormatter) {
|
|
10841
10857
|
streamFormatter.emitEvent({
|
|
10842
|
-
type:
|
|
10858
|
+
type: JsonStreamEventType.MESSAGE,
|
|
10843
10859
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10844
10860
|
role: "user",
|
|
10845
10861
|
content: input
|
|
@@ -10867,28 +10883,28 @@ async function runNonInteractive2(params) {
|
|
|
10867
10883
|
if (abortController.signal.aborted) {
|
|
10868
10884
|
handleCancellationError(config);
|
|
10869
10885
|
}
|
|
10870
|
-
if (event.type ===
|
|
10886
|
+
if (event.type === GeminiEventType.Content) {
|
|
10871
10887
|
const isRaw = config.getRawOutput() || config.getAcceptRawOutputRisk();
|
|
10872
10888
|
const output = isRaw ? event.value : stripAnsi(event.value);
|
|
10873
10889
|
if (streamFormatter) {
|
|
10874
10890
|
streamFormatter.emitEvent({
|
|
10875
|
-
type:
|
|
10891
|
+
type: JsonStreamEventType.MESSAGE,
|
|
10876
10892
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10877
10893
|
role: "assistant",
|
|
10878
10894
|
content: output,
|
|
10879
10895
|
delta: true
|
|
10880
10896
|
});
|
|
10881
|
-
} else if (config.getOutputFormat() ===
|
|
10897
|
+
} else if (config.getOutputFormat() === OutputFormat.JSON) {
|
|
10882
10898
|
responseText += output;
|
|
10883
10899
|
} else {
|
|
10884
10900
|
if (event.value) {
|
|
10885
10901
|
textOutput.write(output);
|
|
10886
10902
|
}
|
|
10887
10903
|
}
|
|
10888
|
-
} else if (event.type ===
|
|
10904
|
+
} else if (event.type === GeminiEventType.ToolCallRequest) {
|
|
10889
10905
|
if (streamFormatter) {
|
|
10890
10906
|
streamFormatter.emitEvent({
|
|
10891
|
-
type:
|
|
10907
|
+
type: JsonStreamEventType.TOOL_USE,
|
|
10892
10908
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10893
10909
|
tool_name: event.value.name,
|
|
10894
10910
|
tool_id: event.value.callId,
|
|
@@ -10896,33 +10912,33 @@ async function runNonInteractive2(params) {
|
|
|
10896
10912
|
});
|
|
10897
10913
|
}
|
|
10898
10914
|
toolCallRequests.push(event.value);
|
|
10899
|
-
} else if (event.type ===
|
|
10915
|
+
} else if (event.type === GeminiEventType.LoopDetected) {
|
|
10900
10916
|
const message = "Loop detected, stopping execution";
|
|
10901
10917
|
if (streamFormatter) {
|
|
10902
10918
|
streamFormatter.emitEvent({
|
|
10903
|
-
type:
|
|
10919
|
+
type: JsonStreamEventType.ERROR,
|
|
10904
10920
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10905
10921
|
severity: "warning",
|
|
10906
10922
|
message
|
|
10907
10923
|
});
|
|
10908
10924
|
}
|
|
10909
10925
|
warnings.push(message);
|
|
10910
|
-
} else if (event.type ===
|
|
10926
|
+
} else if (event.type === GeminiEventType.MaxSessionTurns) {
|
|
10911
10927
|
const message = "Maximum session turns exceeded";
|
|
10912
10928
|
if (streamFormatter) {
|
|
10913
10929
|
streamFormatter.emitEvent({
|
|
10914
|
-
type:
|
|
10930
|
+
type: JsonStreamEventType.ERROR,
|
|
10915
10931
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10916
10932
|
severity: "error",
|
|
10917
10933
|
message
|
|
10918
10934
|
});
|
|
10919
10935
|
}
|
|
10920
10936
|
warnings.push(message);
|
|
10921
|
-
} else if (event.type ===
|
|
10937
|
+
} else if (event.type === GeminiEventType.Error) {
|
|
10922
10938
|
throw event.value.error;
|
|
10923
|
-
} else if (event.type ===
|
|
10939
|
+
} else if (event.type === GeminiEventType.AgentExecutionStopped) {
|
|
10924
10940
|
const stopMessage = `Agent execution stopped: ${event.value.systemMessage?.trim() || event.value.reason}`;
|
|
10925
|
-
if (config.getOutputFormat() ===
|
|
10941
|
+
if (config.getOutputFormat() === OutputFormat.TEXT) {
|
|
10926
10942
|
process.stderr.write(`${stopMessage}
|
|
10927
10943
|
`);
|
|
10928
10944
|
}
|
|
@@ -10930,7 +10946,7 @@ async function runNonInteractive2(params) {
|
|
|
10930
10946
|
const metrics = uiTelemetryService.getMetrics();
|
|
10931
10947
|
const durationMs = Date.now() - startTime;
|
|
10932
10948
|
streamFormatter.emitEvent({
|
|
10933
|
-
type:
|
|
10949
|
+
type: JsonStreamEventType.RESULT,
|
|
10934
10950
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10935
10951
|
status: "success",
|
|
10936
10952
|
stats: streamFormatter.convertToStreamStats(
|
|
@@ -10938,7 +10954,7 @@ async function runNonInteractive2(params) {
|
|
|
10938
10954
|
durationMs
|
|
10939
10955
|
)
|
|
10940
10956
|
});
|
|
10941
|
-
} else if (config.getOutputFormat() ===
|
|
10957
|
+
} else if (config.getOutputFormat() === OutputFormat.JSON) {
|
|
10942
10958
|
const formatter = new JsonFormatter();
|
|
10943
10959
|
const stats = uiTelemetryService.getMetrics();
|
|
10944
10960
|
textOutput.write(
|
|
@@ -10954,30 +10970,30 @@ async function runNonInteractive2(params) {
|
|
|
10954
10970
|
textOutput.ensureTrailingNewline();
|
|
10955
10971
|
}
|
|
10956
10972
|
return;
|
|
10957
|
-
} else if (event.type ===
|
|
10973
|
+
} else if (event.type === GeminiEventType.AgentExecutionBlocked) {
|
|
10958
10974
|
const blockMessage = `Agent execution blocked: ${event.value.systemMessage?.trim() || event.value.reason}`;
|
|
10959
|
-
if (config.getOutputFormat() ===
|
|
10975
|
+
if (config.getOutputFormat() === OutputFormat.TEXT) {
|
|
10960
10976
|
process.stderr.write(`[WARNING] ${blockMessage}
|
|
10961
10977
|
`);
|
|
10962
10978
|
} else if (streamFormatter) {
|
|
10963
10979
|
streamFormatter.emitEvent({
|
|
10964
|
-
type:
|
|
10980
|
+
type: JsonStreamEventType.ERROR,
|
|
10965
10981
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10966
10982
|
severity: "warning",
|
|
10967
10983
|
message: stripAnsi(blockMessage)
|
|
10968
10984
|
});
|
|
10969
10985
|
}
|
|
10970
10986
|
warnings.push(blockMessage);
|
|
10971
|
-
} else if (event.type ===
|
|
10987
|
+
} else if (event.type === GeminiEventType.InvalidStream) {
|
|
10972
10988
|
invalidStreamError = "Invalid stream: The model returned an empty response or malformed tool call.";
|
|
10973
10989
|
if (streamFormatter) {
|
|
10974
10990
|
streamFormatter.emitEvent({
|
|
10975
|
-
type:
|
|
10991
|
+
type: JsonStreamEventType.ERROR,
|
|
10976
10992
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10977
10993
|
severity: "error",
|
|
10978
10994
|
message: invalidStreamError
|
|
10979
10995
|
});
|
|
10980
|
-
} else if (config.getOutputFormat() ===
|
|
10996
|
+
} else if (config.getOutputFormat() === OutputFormat.TEXT) {
|
|
10981
10997
|
process.stderr.write(`[ERROR] ${invalidStreamError}
|
|
10982
10998
|
`);
|
|
10983
10999
|
}
|
|
@@ -10997,7 +11013,7 @@ async function runNonInteractive2(params) {
|
|
|
10997
11013
|
const requestInfo = completedToolCall.request;
|
|
10998
11014
|
if (streamFormatter) {
|
|
10999
11015
|
streamFormatter.emitEvent({
|
|
11000
|
-
type:
|
|
11016
|
+
type: JsonStreamEventType.TOOL_RESULT,
|
|
11001
11017
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
11002
11018
|
tool_id: requestInfo.callId,
|
|
11003
11019
|
status: completedToolCall.status === "error" ? "error" : "success",
|
|
@@ -11031,11 +11047,11 @@ async function runNonInteractive2(params) {
|
|
|
11031
11047
|
);
|
|
11032
11048
|
}
|
|
11033
11049
|
const stopExecutionTool = completedToolCalls.find(
|
|
11034
|
-
(tc) => tc.response.errorType ===
|
|
11050
|
+
(tc) => tc.response.errorType === ToolErrorType.STOP_EXECUTION
|
|
11035
11051
|
);
|
|
11036
11052
|
if (stopExecutionTool && stopExecutionTool.response.error) {
|
|
11037
11053
|
const stopMessage = `Agent execution stopped: ${stopExecutionTool.response.error.message}`;
|
|
11038
|
-
if (config.getOutputFormat() ===
|
|
11054
|
+
if (config.getOutputFormat() === OutputFormat.TEXT) {
|
|
11039
11055
|
process.stderr.write(`${stopMessage}
|
|
11040
11056
|
`);
|
|
11041
11057
|
}
|
|
@@ -11043,7 +11059,7 @@ async function runNonInteractive2(params) {
|
|
|
11043
11059
|
const metrics = uiTelemetryService.getMetrics();
|
|
11044
11060
|
const durationMs = Date.now() - startTime;
|
|
11045
11061
|
streamFormatter.emitEvent({
|
|
11046
|
-
type:
|
|
11062
|
+
type: JsonStreamEventType.RESULT,
|
|
11047
11063
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
11048
11064
|
status: "success",
|
|
11049
11065
|
stats: streamFormatter.convertToStreamStats(
|
|
@@ -11051,7 +11067,7 @@ async function runNonInteractive2(params) {
|
|
|
11051
11067
|
durationMs
|
|
11052
11068
|
)
|
|
11053
11069
|
});
|
|
11054
|
-
} else if (config.getOutputFormat() ===
|
|
11070
|
+
} else if (config.getOutputFormat() === OutputFormat.JSON) {
|
|
11055
11071
|
const formatter = new JsonFormatter();
|
|
11056
11072
|
const stats = uiTelemetryService.getMetrics();
|
|
11057
11073
|
textOutput.write(
|
|
@@ -11074,12 +11090,12 @@ async function runNonInteractive2(params) {
|
|
|
11074
11090
|
const metrics = uiTelemetryService.getMetrics();
|
|
11075
11091
|
const durationMs = Date.now() - startTime;
|
|
11076
11092
|
streamFormatter.emitEvent({
|
|
11077
|
-
type:
|
|
11093
|
+
type: JsonStreamEventType.RESULT,
|
|
11078
11094
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
11079
11095
|
status: invalidStreamError ? "error" : "success",
|
|
11080
11096
|
stats: streamFormatter.convertToStreamStats(metrics, durationMs)
|
|
11081
11097
|
});
|
|
11082
|
-
} else if (config.getOutputFormat() ===
|
|
11098
|
+
} else if (config.getOutputFormat() === OutputFormat.JSON) {
|
|
11083
11099
|
const formatter = new JsonFormatter();
|
|
11084
11100
|
const stats = uiTelemetryService.getMetrics();
|
|
11085
11101
|
textOutput.write(
|
|
@@ -11103,7 +11119,7 @@ async function runNonInteractive2(params) {
|
|
|
11103
11119
|
cleanupStdinCancellation();
|
|
11104
11120
|
scheduler?.dispose();
|
|
11105
11121
|
consolePatcher.cleanup();
|
|
11106
|
-
coreEvents.off(
|
|
11122
|
+
coreEvents.off(CoreEvent.UserFeedback, handleUserFeedback);
|
|
11107
11123
|
}
|
|
11108
11124
|
if (errorToHandle) {
|
|
11109
11125
|
handleError(errorToHandle, config);
|
|
@@ -13494,12 +13510,12 @@ function toToolCallContent(toolResult) {
|
|
|
13494
13510
|
}
|
|
13495
13511
|
var basicPermissionOptions = [
|
|
13496
13512
|
{
|
|
13497
|
-
optionId:
|
|
13513
|
+
optionId: ToolConfirmationOutcome.ProceedOnce,
|
|
13498
13514
|
name: "Allow",
|
|
13499
13515
|
kind: "allow_once"
|
|
13500
13516
|
},
|
|
13501
13517
|
{
|
|
13502
|
-
optionId:
|
|
13518
|
+
optionId: ToolConfirmationOutcome.Cancel,
|
|
13503
13519
|
name: "Reject",
|
|
13504
13520
|
kind: "reject_once"
|
|
13505
13521
|
}
|
|
@@ -13511,13 +13527,13 @@ function toPermissionOptions(confirmation, config, enablePermanentToolApproval =
|
|
|
13511
13527
|
switch (confirmation.type) {
|
|
13512
13528
|
case "edit":
|
|
13513
13529
|
options.push({
|
|
13514
|
-
optionId:
|
|
13530
|
+
optionId: ToolConfirmationOutcome.ProceedAlways,
|
|
13515
13531
|
name: "Allow for this session",
|
|
13516
13532
|
kind: "allow_always"
|
|
13517
13533
|
});
|
|
13518
13534
|
if (enablePermanentToolApproval) {
|
|
13519
13535
|
options.push({
|
|
13520
|
-
optionId:
|
|
13536
|
+
optionId: ToolConfirmationOutcome.ProceedAlwaysAndSave,
|
|
13521
13537
|
name: "Allow for this file in all future sessions",
|
|
13522
13538
|
kind: "allow_always"
|
|
13523
13539
|
});
|
|
@@ -13525,13 +13541,13 @@ function toPermissionOptions(confirmation, config, enablePermanentToolApproval =
|
|
|
13525
13541
|
break;
|
|
13526
13542
|
case "exec":
|
|
13527
13543
|
options.push({
|
|
13528
|
-
optionId:
|
|
13544
|
+
optionId: ToolConfirmationOutcome.ProceedAlways,
|
|
13529
13545
|
name: "Allow for this session",
|
|
13530
13546
|
kind: "allow_always"
|
|
13531
13547
|
});
|
|
13532
13548
|
if (enablePermanentToolApproval) {
|
|
13533
13549
|
options.push({
|
|
13534
|
-
optionId:
|
|
13550
|
+
optionId: ToolConfirmationOutcome.ProceedAlwaysAndSave,
|
|
13535
13551
|
name: "Allow this command for all future sessions",
|
|
13536
13552
|
kind: "allow_always"
|
|
13537
13553
|
});
|
|
@@ -13540,19 +13556,19 @@ function toPermissionOptions(confirmation, config, enablePermanentToolApproval =
|
|
|
13540
13556
|
case "mcp":
|
|
13541
13557
|
options.push(
|
|
13542
13558
|
{
|
|
13543
|
-
optionId:
|
|
13559
|
+
optionId: ToolConfirmationOutcome.ProceedAlwaysServer,
|
|
13544
13560
|
name: "Allow all server tools for this session",
|
|
13545
13561
|
kind: "allow_always"
|
|
13546
13562
|
},
|
|
13547
13563
|
{
|
|
13548
|
-
optionId:
|
|
13564
|
+
optionId: ToolConfirmationOutcome.ProceedAlwaysTool,
|
|
13549
13565
|
name: "Allow tool for this session",
|
|
13550
13566
|
kind: "allow_always"
|
|
13551
13567
|
}
|
|
13552
13568
|
);
|
|
13553
13569
|
if (enablePermanentToolApproval) {
|
|
13554
13570
|
options.push({
|
|
13555
|
-
optionId:
|
|
13571
|
+
optionId: ToolConfirmationOutcome.ProceedAlwaysAndSave,
|
|
13556
13572
|
name: "Allow tool for all future sessions",
|
|
13557
13573
|
kind: "allow_always"
|
|
13558
13574
|
});
|
|
@@ -13560,13 +13576,13 @@ function toPermissionOptions(confirmation, config, enablePermanentToolApproval =
|
|
|
13560
13576
|
break;
|
|
13561
13577
|
case "info":
|
|
13562
13578
|
options.push({
|
|
13563
|
-
optionId:
|
|
13579
|
+
optionId: ToolConfirmationOutcome.ProceedAlways,
|
|
13564
13580
|
name: "Allow for this session",
|
|
13565
13581
|
kind: "allow_always"
|
|
13566
13582
|
});
|
|
13567
13583
|
if (enablePermanentToolApproval) {
|
|
13568
13584
|
options.push({
|
|
13569
|
-
optionId:
|
|
13585
|
+
optionId: ToolConfirmationOutcome.ProceedAlwaysAndSave,
|
|
13570
13586
|
name: "Allow for all future sessions",
|
|
13571
13587
|
kind: "allow_always"
|
|
13572
13588
|
});
|
|
@@ -13598,21 +13614,21 @@ function toPermissionOptions(confirmation, config, enablePermanentToolApproval =
|
|
|
13598
13614
|
}
|
|
13599
13615
|
function toAcpToolKind(kind) {
|
|
13600
13616
|
switch (kind) {
|
|
13601
|
-
case
|
|
13602
|
-
case
|
|
13603
|
-
case
|
|
13604
|
-
case
|
|
13605
|
-
case
|
|
13606
|
-
case
|
|
13607
|
-
case
|
|
13608
|
-
case
|
|
13609
|
-
case
|
|
13610
|
-
case
|
|
13617
|
+
case Kind.Read:
|
|
13618
|
+
case Kind.Edit:
|
|
13619
|
+
case Kind.Execute:
|
|
13620
|
+
case Kind.Search:
|
|
13621
|
+
case Kind.Delete:
|
|
13622
|
+
case Kind.Move:
|
|
13623
|
+
case Kind.Think:
|
|
13624
|
+
case Kind.Fetch:
|
|
13625
|
+
case Kind.SwitchMode:
|
|
13626
|
+
case Kind.Other:
|
|
13611
13627
|
return kind;
|
|
13612
|
-
case
|
|
13628
|
+
case Kind.Agent:
|
|
13613
13629
|
return "think";
|
|
13614
|
-
case
|
|
13615
|
-
case
|
|
13630
|
+
case Kind.Plan:
|
|
13631
|
+
case Kind.Communicate:
|
|
13616
13632
|
default:
|
|
13617
13633
|
return "other";
|
|
13618
13634
|
}
|
|
@@ -13620,24 +13636,24 @@ function toAcpToolKind(kind) {
|
|
|
13620
13636
|
function buildAvailableModes(isPlanEnabled) {
|
|
13621
13637
|
const modes = [
|
|
13622
13638
|
{
|
|
13623
|
-
id:
|
|
13639
|
+
id: ApprovalMode.DEFAULT,
|
|
13624
13640
|
name: "Default",
|
|
13625
13641
|
description: "Prompts for approval"
|
|
13626
13642
|
},
|
|
13627
13643
|
{
|
|
13628
|
-
id:
|
|
13644
|
+
id: ApprovalMode.AUTO_EDIT,
|
|
13629
13645
|
name: "Auto Edit",
|
|
13630
13646
|
description: "Auto-approves edit tools"
|
|
13631
13647
|
},
|
|
13632
13648
|
{
|
|
13633
|
-
id:
|
|
13649
|
+
id: ApprovalMode.YOLO,
|
|
13634
13650
|
name: "YOLO",
|
|
13635
13651
|
description: "Auto-approves all tools"
|
|
13636
13652
|
}
|
|
13637
13653
|
];
|
|
13638
13654
|
if (isPlanEnabled) {
|
|
13639
13655
|
modes.push({
|
|
13640
|
-
id:
|
|
13656
|
+
id: ApprovalMode.PLAN,
|
|
13641
13657
|
name: "Plan",
|
|
13642
13658
|
description: "Read-only mode"
|
|
13643
13659
|
});
|
|
@@ -13648,11 +13664,13 @@ function buildAvailableModels(config, settings) {
|
|
|
13648
13664
|
const preferredModel = config.getModel() || GEMINI_MODEL_ALIAS_AUTO;
|
|
13649
13665
|
const shouldShowPreviewModels = config.getHasAccessToPreviewModel();
|
|
13650
13666
|
const useGemini31 = config.getGemini31LaunchedSync?.() ?? false;
|
|
13667
|
+
const useGemini3_5Flash = config.hasGemini35FlashGAAccess?.() ?? false;
|
|
13651
13668
|
const selectedAuthType = settings.merged.security.auth.selectedType;
|
|
13652
|
-
const useCustomToolModel = useGemini31 && selectedAuthType ===
|
|
13669
|
+
const useCustomToolModel = useGemini31 && selectedAuthType === AuthType.USE_GEMINI;
|
|
13653
13670
|
if (config.getExperimentalDynamicModelConfiguration?.() === true && config.getModelConfigService) {
|
|
13654
13671
|
const options = config.getModelConfigService().getAvailableModelOptions({
|
|
13655
13672
|
useGemini3_1: useGemini31,
|
|
13673
|
+
useGemini3_5Flash,
|
|
13656
13674
|
useCustomTools: useCustomToolModel,
|
|
13657
13675
|
hasAccessToPreview: shouldShowPreviewModels
|
|
13658
13676
|
});
|
|
@@ -13667,7 +13685,8 @@ function buildAvailableModels(config, settings) {
|
|
|
13667
13685
|
title: getDisplayString(GEMINI_MODEL_ALIAS_AUTO),
|
|
13668
13686
|
description: getAutoModelDescription(
|
|
13669
13687
|
shouldShowPreviewModels,
|
|
13670
|
-
useGemini31
|
|
13688
|
+
useGemini31,
|
|
13689
|
+
useGemini3_5Flash
|
|
13671
13690
|
)
|
|
13672
13691
|
}
|
|
13673
13692
|
];
|
|
@@ -13733,11 +13752,11 @@ var Session = class {
|
|
|
13733
13752
|
this.connection = connection;
|
|
13734
13753
|
this.settings = settings;
|
|
13735
13754
|
coreEvents.on(
|
|
13736
|
-
|
|
13755
|
+
CoreEvent.ApprovalModeChanged,
|
|
13737
13756
|
this.handleApprovalModeChanged
|
|
13738
13757
|
);
|
|
13739
13758
|
this.context.config.getMessageBus()?.subscribe(
|
|
13740
|
-
|
|
13759
|
+
MessageBusType.TOOL_CONFIRMATION_REQUEST,
|
|
13741
13760
|
this.handleToolConfirmationRequest,
|
|
13742
13761
|
{ signal: this.disposeController.signal }
|
|
13743
13762
|
);
|
|
@@ -13761,7 +13780,7 @@ var Session = class {
|
|
|
13761
13780
|
"Policy engine missing. Denying tool confirmation request."
|
|
13762
13781
|
);
|
|
13763
13782
|
await messageBus.publish({
|
|
13764
|
-
type:
|
|
13783
|
+
type: MessageBusType.TOOL_CONFIRMATION_RESPONSE,
|
|
13765
13784
|
correlationId: request.correlationId,
|
|
13766
13785
|
confirmed: false,
|
|
13767
13786
|
requiresUserConfirmation: false
|
|
@@ -13774,7 +13793,7 @@ var Session = class {
|
|
|
13774
13793
|
"Tool confirmation request missing tool name. Denying."
|
|
13775
13794
|
);
|
|
13776
13795
|
await messageBus.publish({
|
|
13777
|
-
type:
|
|
13796
|
+
type: MessageBusType.TOOL_CONFIRMATION_RESPONSE,
|
|
13778
13797
|
correlationId: request.correlationId,
|
|
13779
13798
|
confirmed: false,
|
|
13780
13799
|
requiresUserConfirmation: false
|
|
@@ -13787,7 +13806,7 @@ var Session = class {
|
|
|
13787
13806
|
`Tool confirmation request for unknown tool: ${toolName}. Denying.`
|
|
13788
13807
|
);
|
|
13789
13808
|
await messageBus.publish({
|
|
13790
|
-
type:
|
|
13809
|
+
type: MessageBusType.TOOL_CONFIRMATION_RESPONSE,
|
|
13791
13810
|
correlationId: request.correlationId,
|
|
13792
13811
|
confirmed: false,
|
|
13793
13812
|
requiresUserConfirmation: false
|
|
@@ -13803,15 +13822,15 @@ var Session = class {
|
|
|
13803
13822
|
request.subagent
|
|
13804
13823
|
);
|
|
13805
13824
|
await messageBus.publish({
|
|
13806
|
-
type:
|
|
13825
|
+
type: MessageBusType.TOOL_CONFIRMATION_RESPONSE,
|
|
13807
13826
|
correlationId: request.correlationId,
|
|
13808
|
-
confirmed: result.decision ===
|
|
13809
|
-
requiresUserConfirmation: result.decision ===
|
|
13827
|
+
confirmed: result.decision === PolicyDecision.ALLOW,
|
|
13828
|
+
requiresUserConfirmation: result.decision === PolicyDecision.ASK_USER
|
|
13810
13829
|
});
|
|
13811
13830
|
} catch (error) {
|
|
13812
13831
|
debugLogger.error("Error handling tool confirmation request:", error);
|
|
13813
13832
|
await this.context.config.getMessageBus()?.publish({
|
|
13814
|
-
type:
|
|
13833
|
+
type: MessageBusType.TOOL_CONFIRMATION_RESPONSE,
|
|
13815
13834
|
correlationId: request.correlationId,
|
|
13816
13835
|
confirmed: false,
|
|
13817
13836
|
requiresUserConfirmation: false
|
|
@@ -13831,7 +13850,7 @@ var Session = class {
|
|
|
13831
13850
|
};
|
|
13832
13851
|
dispose() {
|
|
13833
13852
|
coreEvents.off(
|
|
13834
|
-
|
|
13853
|
+
CoreEvent.ApprovalModeChanged,
|
|
13835
13854
|
this.handleApprovalModeChanged
|
|
13836
13855
|
);
|
|
13837
13856
|
this.disposeController.abort();
|
|
@@ -13920,7 +13939,7 @@ ${thought.description}`;
|
|
|
13920
13939
|
await this.sendUpdate({
|
|
13921
13940
|
sessionUpdate: "tool_call",
|
|
13922
13941
|
toolCallId: toolCall.id,
|
|
13923
|
-
status: toolCall.status ===
|
|
13942
|
+
status: toolCall.status === CoreToolCallStatus.Success ? "completed" : "failed",
|
|
13924
13943
|
title: toolCall.displayName || toolCall.name,
|
|
13925
13944
|
content: toolCallContent,
|
|
13926
13945
|
kind: tool ? toAcpToolKind(tool.kind) : "other"
|
|
@@ -14012,7 +14031,7 @@ ${thought.description}`;
|
|
|
14012
14031
|
return { stopReason: "cancelled" };
|
|
14013
14032
|
}
|
|
14014
14033
|
switch (event.type) {
|
|
14015
|
-
case
|
|
14034
|
+
case GeminiEventType.Content: {
|
|
14016
14035
|
const content = {
|
|
14017
14036
|
type: "text",
|
|
14018
14037
|
text: event.value
|
|
@@ -14023,7 +14042,7 @@ ${thought.description}`;
|
|
|
14023
14042
|
});
|
|
14024
14043
|
break;
|
|
14025
14044
|
}
|
|
14026
|
-
case
|
|
14045
|
+
case GeminiEventType.Thought: {
|
|
14027
14046
|
const thoughtText = `**${event.value.subject}**
|
|
14028
14047
|
${event.value.description}`;
|
|
14029
14048
|
await this.sendUpdate({
|
|
@@ -14032,10 +14051,10 @@ ${event.value.description}`;
|
|
|
14032
14051
|
});
|
|
14033
14052
|
break;
|
|
14034
14053
|
}
|
|
14035
|
-
case
|
|
14054
|
+
case GeminiEventType.ToolCallRequest:
|
|
14036
14055
|
toolCallRequests.push(event.value);
|
|
14037
14056
|
break;
|
|
14038
|
-
case
|
|
14057
|
+
case GeminiEventType.Finished: {
|
|
14039
14058
|
const usage2 = event.value.usageMetadata;
|
|
14040
14059
|
if (usage2) {
|
|
14041
14060
|
turnInputTokens = usage2.promptTokenCount ?? turnInputTokens;
|
|
@@ -14043,19 +14062,19 @@ ${event.value.description}`;
|
|
|
14043
14062
|
}
|
|
14044
14063
|
break;
|
|
14045
14064
|
}
|
|
14046
|
-
case
|
|
14065
|
+
case GeminiEventType.ModelInfo:
|
|
14047
14066
|
turnModelId = event.value;
|
|
14048
14067
|
break;
|
|
14049
|
-
case
|
|
14068
|
+
case GeminiEventType.MaxSessionTurns:
|
|
14050
14069
|
stopReason = "max_turn_requests";
|
|
14051
14070
|
break;
|
|
14052
|
-
case
|
|
14071
|
+
case GeminiEventType.LoopDetected:
|
|
14053
14072
|
stopReason = "max_turn_requests";
|
|
14054
14073
|
break;
|
|
14055
|
-
case
|
|
14074
|
+
case GeminiEventType.ContextWindowWillOverflow:
|
|
14056
14075
|
stopReason = "max_tokens";
|
|
14057
14076
|
break;
|
|
14058
|
-
case
|
|
14077
|
+
case GeminiEventType.Error: {
|
|
14059
14078
|
const parseResult = StructuredErrorSchema.safeParse(
|
|
14060
14079
|
event.value.error
|
|
14061
14080
|
);
|
|
@@ -14283,7 +14302,7 @@ ${event.value.description}`;
|
|
|
14283
14302
|
const output = RequestPermissionResponseSchema.parse(
|
|
14284
14303
|
await this.connection.requestPermission(params)
|
|
14285
14304
|
);
|
|
14286
|
-
const outcome = output.outcome.outcome === "cancelled" ?
|
|
14305
|
+
const outcome = output.outcome.outcome === "cancelled" ? ToolConfirmationOutcome.Cancel : external_exports.nativeEnum(ToolConfirmationOutcome).parse(output.outcome.optionId);
|
|
14287
14306
|
await confirmationDetails.onConfirm(outcome);
|
|
14288
14307
|
await updatePolicy(
|
|
14289
14308
|
tool,
|
|
@@ -14294,16 +14313,16 @@ ${event.value.description}`;
|
|
|
14294
14313
|
invocation
|
|
14295
14314
|
);
|
|
14296
14315
|
switch (outcome) {
|
|
14297
|
-
case
|
|
14316
|
+
case ToolConfirmationOutcome.Cancel:
|
|
14298
14317
|
return errorResponse(
|
|
14299
14318
|
new Error(`Tool "${fc.name}" was canceled by the user.`)
|
|
14300
14319
|
);
|
|
14301
|
-
case
|
|
14302
|
-
case
|
|
14303
|
-
case
|
|
14304
|
-
case
|
|
14305
|
-
case
|
|
14306
|
-
case
|
|
14320
|
+
case ToolConfirmationOutcome.ProceedOnce:
|
|
14321
|
+
case ToolConfirmationOutcome.ProceedAlways:
|
|
14322
|
+
case ToolConfirmationOutcome.ProceedAlwaysAndSave:
|
|
14323
|
+
case ToolConfirmationOutcome.ProceedAlwaysServer:
|
|
14324
|
+
case ToolConfirmationOutcome.ProceedAlwaysTool:
|
|
14325
|
+
case ToolConfirmationOutcome.ModifyWithEditor:
|
|
14307
14326
|
break;
|
|
14308
14327
|
default: {
|
|
14309
14328
|
const resultOutcome = outcome;
|
|
@@ -14357,7 +14376,7 @@ ${event.value.description}`;
|
|
|
14357
14376
|
);
|
|
14358
14377
|
this.chat.recordCompletedToolCalls(this.context.config.getActiveModel(), [
|
|
14359
14378
|
{
|
|
14360
|
-
status:
|
|
14379
|
+
status: CoreToolCallStatus.Success,
|
|
14361
14380
|
request: {
|
|
14362
14381
|
callId,
|
|
14363
14382
|
name: fc.name,
|
|
@@ -14402,7 +14421,7 @@ ${event.value.description}`;
|
|
|
14402
14421
|
});
|
|
14403
14422
|
this.chat.recordCompletedToolCalls(this.context.config.getActiveModel(), [
|
|
14404
14423
|
{
|
|
14405
|
-
status:
|
|
14424
|
+
status: CoreToolCallStatus.Error,
|
|
14406
14425
|
request: {
|
|
14407
14426
|
callId,
|
|
14408
14427
|
name: fc.name,
|
|
@@ -14530,12 +14549,12 @@ ${event.value.description}`;
|
|
|
14530
14549
|
sessionId: this.id,
|
|
14531
14550
|
options: [
|
|
14532
14551
|
{
|
|
14533
|
-
optionId:
|
|
14552
|
+
optionId: ToolConfirmationOutcome.ProceedOnce,
|
|
14534
14553
|
name: "Allow once",
|
|
14535
14554
|
kind: "allow_once"
|
|
14536
14555
|
},
|
|
14537
14556
|
{
|
|
14538
|
-
optionId:
|
|
14557
|
+
optionId: ToolConfirmationOutcome.Cancel,
|
|
14539
14558
|
name: "Deny",
|
|
14540
14559
|
kind: "reject_once"
|
|
14541
14560
|
}
|
|
@@ -14560,8 +14579,8 @@ ${event.value.description}`;
|
|
|
14560
14579
|
const output = RequestPermissionResponseSchema.parse(
|
|
14561
14580
|
await this.connection.requestPermission(params)
|
|
14562
14581
|
);
|
|
14563
|
-
const outcome = output.outcome.outcome === "cancelled" ?
|
|
14564
|
-
if (outcome ===
|
|
14582
|
+
const outcome = output.outcome.outcome === "cancelled" ? ToolConfirmationOutcome.Cancel : external_exports.nativeEnum(ToolConfirmationOutcome).parse(output.outcome.optionId);
|
|
14583
|
+
if (outcome === ToolConfirmationOutcome.ProceedOnce) {
|
|
14565
14584
|
this.context.config.getWorkspaceContext().addReadOnlyPath(absolutePath);
|
|
14566
14585
|
validationError = null;
|
|
14567
14586
|
} else {
|
|
@@ -14998,7 +15017,7 @@ var AcpSessionManager = class {
|
|
|
14998
15017
|
mcpServers,
|
|
14999
15018
|
loadedSettings
|
|
15000
15019
|
);
|
|
15001
|
-
const authType = loadedSettings.merged.security.auth.selectedType || (authDetails.baseUrl || process.env["GOOGLE_GEMINI_BASE_URL"] ?
|
|
15020
|
+
const authType = loadedSettings.merged.security.auth.selectedType || (authDetails.baseUrl || process.env["GOOGLE_GEMINI_BASE_URL"] ? AuthType.GATEWAY : AuthType.USE_GEMINI);
|
|
15002
15021
|
let isAuthenticated = false;
|
|
15003
15022
|
let authErrorMessage = "";
|
|
15004
15023
|
try {
|
|
@@ -15010,7 +15029,7 @@ var AcpSessionManager = class {
|
|
|
15010
15029
|
);
|
|
15011
15030
|
isAuthenticated = true;
|
|
15012
15031
|
const contentGeneratorConfig = config.getContentGeneratorConfig();
|
|
15013
|
-
if (authType ===
|
|
15032
|
+
if (authType === AuthType.USE_GEMINI && (!contentGeneratorConfig || !contentGeneratorConfig.apiKey)) {
|
|
15014
15033
|
isAuthenticated = false;
|
|
15015
15034
|
authErrorMessage = "Gemini API key is missing or not configured.";
|
|
15016
15035
|
}
|
|
@@ -15119,7 +15138,7 @@ var AcpSessionManager = class {
|
|
|
15119
15138
|
return response;
|
|
15120
15139
|
}
|
|
15121
15140
|
async initializeSessionConfig(sessionId, cwd, mcpServers, authDetails) {
|
|
15122
|
-
const selectedAuthType = this.settings.merged.security.auth.selectedType || (authDetails.baseUrl || process.env["GOOGLE_GEMINI_BASE_URL"] ?
|
|
15141
|
+
const selectedAuthType = this.settings.merged.security.auth.selectedType || (authDetails.baseUrl || process.env["GOOGLE_GEMINI_BASE_URL"] ? AuthType.GATEWAY : void 0);
|
|
15123
15142
|
if (!selectedAuthType) {
|
|
15124
15143
|
throw RequestError.authRequired();
|
|
15125
15144
|
}
|
|
@@ -15220,12 +15239,12 @@ var GeminiAgent = class {
|
|
|
15220
15239
|
}
|
|
15221
15240
|
const authMethods = [
|
|
15222
15241
|
{
|
|
15223
|
-
id:
|
|
15242
|
+
id: AuthType.LOGIN_WITH_GOOGLE,
|
|
15224
15243
|
name: "Log in with Google",
|
|
15225
15244
|
description: "Log in with your Google account"
|
|
15226
15245
|
},
|
|
15227
15246
|
{
|
|
15228
|
-
id:
|
|
15247
|
+
id: AuthType.USE_GEMINI,
|
|
15229
15248
|
name: "Gemini API key",
|
|
15230
15249
|
description: "Use an API key with Gemini Developer API",
|
|
15231
15250
|
_meta: {
|
|
@@ -15235,12 +15254,12 @@ var GeminiAgent = class {
|
|
|
15235
15254
|
}
|
|
15236
15255
|
},
|
|
15237
15256
|
{
|
|
15238
|
-
id:
|
|
15257
|
+
id: AuthType.USE_VERTEX_AI,
|
|
15239
15258
|
name: "Vertex AI",
|
|
15240
15259
|
description: "Use an API key with Vertex AI GenAI API"
|
|
15241
15260
|
},
|
|
15242
15261
|
{
|
|
15243
|
-
id:
|
|
15262
|
+
id: AuthType.GATEWAY,
|
|
15244
15263
|
name: "AI API Gateway",
|
|
15245
15264
|
description: "Use a custom AI API Gateway",
|
|
15246
15265
|
_meta: {
|
|
@@ -15413,7 +15432,7 @@ async function validateNonInteractiveAuth(configuredAuthType, useExternalAuth, n
|
|
|
15413
15432
|
}
|
|
15414
15433
|
return authType;
|
|
15415
15434
|
} catch (error) {
|
|
15416
|
-
if (nonInteractiveConfig.getOutputFormat() ===
|
|
15435
|
+
if (nonInteractiveConfig.getOutputFormat() === OutputFormat.JSON) {
|
|
15417
15436
|
handleError(
|
|
15418
15437
|
error instanceof Error ? error : new Error(String(error)),
|
|
15419
15438
|
nonInteractiveConfig,
|
|
@@ -15608,10 +15627,10 @@ var SlashCommandConflictHandler = class {
|
|
|
15608
15627
|
this.handleConflicts = this.handleConflicts.bind(this);
|
|
15609
15628
|
}
|
|
15610
15629
|
start() {
|
|
15611
|
-
coreEvents.on(
|
|
15630
|
+
coreEvents.on(CoreEvent.SlashCommandConflicts, this.handleConflicts);
|
|
15612
15631
|
}
|
|
15613
15632
|
stop() {
|
|
15614
|
-
coreEvents.off(
|
|
15633
|
+
coreEvents.off(CoreEvent.SlashCommandConflicts, this.handleConflicts);
|
|
15615
15634
|
if (this.flushTimeout) {
|
|
15616
15635
|
clearTimeout(this.flushTimeout);
|
|
15617
15636
|
this.flushTimeout = null;
|
|
@@ -15892,7 +15911,7 @@ async function resolveSessionId(resumeArg, sessionIdArg, sessionFileArg) {
|
|
|
15892
15911
|
}
|
|
15893
15912
|
}
|
|
15894
15913
|
async function startInteractiveUI(config, settings, startupWarnings, workspaceRoot = process.cwd(), resumedSessionData, initializationResult) {
|
|
15895
|
-
const { startInteractiveUI: doStartUI } = await import("./interactiveCli-
|
|
15914
|
+
const { startInteractiveUI: doStartUI } = await import("./interactiveCli-OEFOYFJU.js");
|
|
15896
15915
|
await doStartUI(
|
|
15897
15916
|
config,
|
|
15898
15917
|
settings,
|
|
@@ -15995,12 +16014,12 @@ async function main() {
|
|
|
15995
16014
|
dns.setDefaultResultOrder(
|
|
15996
16015
|
validateDnsResolutionOrder(settings.merged.advanced.dnsResolutionOrder)
|
|
15997
16016
|
);
|
|
15998
|
-
if (!settings.merged.security.auth.selectedType || settings.merged.security.auth.selectedType ===
|
|
16017
|
+
if (!settings.merged.security.auth.selectedType || settings.merged.security.auth.selectedType === AuthType.LEGACY_CLOUD_SHELL) {
|
|
15999
16018
|
if (process.env["CLOUD_SHELL"] === "true" || process.env["GEMINI_CLI_USE_COMPUTE_ADC"] === "true") {
|
|
16000
16019
|
settings.setValue(
|
|
16001
16020
|
"User" /* User */,
|
|
16002
16021
|
"security.auth.selectedType",
|
|
16003
|
-
|
|
16022
|
+
AuthType.COMPUTE_ADC
|
|
16004
16023
|
);
|
|
16005
16024
|
}
|
|
16006
16025
|
}
|
|
@@ -16101,7 +16120,7 @@ ${finalArgs[promptIndex + 1]}`;
|
|
|
16101
16120
|
await config.storage.initialize();
|
|
16102
16121
|
adminControlsListner.setConfig(config);
|
|
16103
16122
|
if (config.isInteractive() && settings.merged.general.devtools) {
|
|
16104
|
-
const { setupInitialActivityLogger } = await import("./devtoolsService-
|
|
16123
|
+
const { setupInitialActivityLogger } = await import("./devtoolsService-Z2YXVMYF.js");
|
|
16105
16124
|
setupInitialActivityLogger(config);
|
|
16106
16125
|
}
|
|
16107
16126
|
registerTelemetryConfig(config);
|
|
@@ -16109,7 +16128,7 @@ ${finalArgs[promptIndex + 1]}`;
|
|
|
16109
16128
|
const messageBus = config.getMessageBus();
|
|
16110
16129
|
createPolicyUpdater2(policyEngine, messageBus, config.storage);
|
|
16111
16130
|
registerCleanup(async () => {
|
|
16112
|
-
await config.getHookSystem()?.fireSessionEndEvent(
|
|
16131
|
+
await config.getHookSystem()?.fireSessionEndEvent(SessionEndReason.Exit);
|
|
16113
16132
|
});
|
|
16114
16133
|
if (!config.getAcpMode()) {
|
|
16115
16134
|
registerCleanup(consolePatcher.cleanup);
|
|
@@ -16160,7 +16179,7 @@ ${finalArgs[promptIndex + 1]}`;
|
|
|
16160
16179
|
const initAppHandle = startupProfiler.start("initialize_app");
|
|
16161
16180
|
const initializationResult = await initializeApp(config, settings);
|
|
16162
16181
|
initAppHandle?.end();
|
|
16163
|
-
import("./liteRtServerManager-
|
|
16182
|
+
import("./liteRtServerManager-3QOJEGNL.js").then(({ LiteRtServerManager }) => {
|
|
16164
16183
|
const mergedGemma = settings.merged.experimental?.gemmaModelRouter;
|
|
16165
16184
|
if (!mergedGemma) return;
|
|
16166
16185
|
const userGemma = settings.forScope("User" /* User */).settings.experimental?.gemmaModelRouter;
|
|
@@ -16170,7 +16189,7 @@ ${finalArgs[promptIndex + 1]}`;
|
|
|
16170
16189
|
autoStartServer: userGemma?.autoStartServer
|
|
16171
16190
|
});
|
|
16172
16191
|
}).catch((e) => debugLogger.warn("LiteRT auto-start import failed:", e));
|
|
16173
|
-
if (settings.merged.security.auth.selectedType ===
|
|
16192
|
+
if (settings.merged.security.auth.selectedType === AuthType.LOGIN_WITH_GOOGLE && config.isBrowserLaunchSuppressed()) {
|
|
16174
16193
|
await getOauthClient(settings.merged.security.auth.selectedType, config);
|
|
16175
16194
|
}
|
|
16176
16195
|
if (config.getAcpMode()) {
|
|
@@ -16186,7 +16205,7 @@ ${finalArgs[promptIndex + 1]}`;
|
|
|
16186
16205
|
...rawStartupWarnings.map((message) => ({
|
|
16187
16206
|
id: `startup-${createHash2("sha256").update(message).digest("hex").substring(0, 16)}`,
|
|
16188
16207
|
message,
|
|
16189
|
-
priority:
|
|
16208
|
+
priority: WarningPriority.High
|
|
16190
16209
|
})),
|
|
16191
16210
|
...await getUserStartupWarnings(settings.merged, void 0, {
|
|
16192
16211
|
isAlternateBuffer: useAlternateBuffer
|
|
@@ -16223,7 +16242,7 @@ ${finalArgs[promptIndex + 1]}`;
|
|
|
16223
16242
|
${input}` : stdinData;
|
|
16224
16243
|
}
|
|
16225
16244
|
}
|
|
16226
|
-
const sessionStartSource = resumedSessionData ?
|
|
16245
|
+
const sessionStartSource = resumedSessionData ? SessionStartSource.Resume : SessionStartSource.Startup;
|
|
16227
16246
|
const hookSystem = config?.getHookSystem();
|
|
16228
16247
|
if (hookSystem) {
|
|
16229
16248
|
const result = await hookSystem.fireSessionStartEvent(sessionStartSource);
|
|
@@ -16280,8 +16299,8 @@ ${input}` : wrappedContext;
|
|
|
16280
16299
|
}
|
|
16281
16300
|
}
|
|
16282
16301
|
function initializeOutputListenersAndFlush(config) {
|
|
16283
|
-
if (coreEvents.listenerCount(
|
|
16284
|
-
coreEvents.on(
|
|
16302
|
+
if (coreEvents.listenerCount(CoreEvent.Output) === 0) {
|
|
16303
|
+
coreEvents.on(CoreEvent.Output, (payload) => {
|
|
16285
16304
|
if (payload.isStderr) {
|
|
16286
16305
|
writeToStderr(payload.chunk, payload.encoding);
|
|
16287
16306
|
} else {
|
|
@@ -16289,8 +16308,8 @@ function initializeOutputListenersAndFlush(config) {
|
|
|
16289
16308
|
}
|
|
16290
16309
|
});
|
|
16291
16310
|
}
|
|
16292
|
-
if (coreEvents.listenerCount(
|
|
16293
|
-
coreEvents.on(
|
|
16311
|
+
if (coreEvents.listenerCount(CoreEvent.ConsoleLog) === 0) {
|
|
16312
|
+
coreEvents.on(CoreEvent.ConsoleLog, (payload) => {
|
|
16294
16313
|
if (payload.type === "error" || payload.type === "warn") {
|
|
16295
16314
|
writeToStderr(payload.content + "\n");
|
|
16296
16315
|
} else {
|
|
@@ -16298,8 +16317,8 @@ function initializeOutputListenersAndFlush(config) {
|
|
|
16298
16317
|
}
|
|
16299
16318
|
});
|
|
16300
16319
|
}
|
|
16301
|
-
if (coreEvents.listenerCount(
|
|
16302
|
-
coreEvents.on(
|
|
16320
|
+
if (coreEvents.listenerCount(CoreEvent.UserFeedback) === 0) {
|
|
16321
|
+
coreEvents.on(CoreEvent.UserFeedback, (payload) => {
|
|
16303
16322
|
writeToStderr(payload.message + "\n");
|
|
16304
16323
|
});
|
|
16305
16324
|
}
|
|
@@ -16307,7 +16326,7 @@ function initializeOutputListenersAndFlush(config) {
|
|
|
16307
16326
|
const forceToStderr = outputFormat === "json";
|
|
16308
16327
|
coreEvents.drainBacklogs(
|
|
16309
16328
|
(event, args) => {
|
|
16310
|
-
if (forceToStderr && event ===
|
|
16329
|
+
if (forceToStderr && event === CoreEvent.Output) {
|
|
16311
16330
|
const payload = args[0];
|
|
16312
16331
|
if (!payload.isStderr) {
|
|
16313
16332
|
return {
|