@google/gemini-cli 0.54.0 → 0.54.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundle/{chunk-G7VQ6O6G.js → chunk-4YSWDUQZ.js} +1 -1
- package/bundle/{chunk-IM5WJKYT.js → chunk-5NT754WV.js} +1 -1
- package/bundle/{chunk-GOQJOV4P.js → chunk-6SBXH4D5.js} +1 -1
- package/bundle/{chunk-UTXCUPDT.js → chunk-7ELLCO6U.js} +2 -2
- package/bundle/{chunk-MOGTJC2T.js → chunk-7SPI3KN6.js} +1 -1
- package/bundle/{chunk-BBNFLOXC.js → chunk-B5CTWZND.js} +1 -1
- package/bundle/{chunk-UW4NSSB6.js → chunk-BCKLMRS4.js} +3 -3
- package/bundle/{chunk-F6IU45OZ.js → chunk-BS6BSLZD.js} +98 -8
- package/bundle/{chunk-VIQEWLM4.js → chunk-D7ZXPN6G.js} +8 -5
- package/bundle/{chunk-WJKZRJIC.js → chunk-DFZESNXJ.js} +3 -3
- package/bundle/chunk-DJWQKPM3.js +1571 -0
- package/bundle/{chunk-NZ6P6XKP.js → chunk-FNQ3CHG6.js} +2 -2
- package/bundle/{chunk-OYZ2XVON.js → chunk-GHCTXZXJ.js} +3 -3
- package/bundle/{chunk-43HYOV6F.js → chunk-HX3M7TQG.js} +1 -1
- package/bundle/{chunk-5SMD2SLQ.js → chunk-IJK6RPHE.js} +2 -2
- package/bundle/{chunk-MZBH35ZS.js → chunk-IX4IHGFA.js} +1 -1
- package/bundle/{chunk-SQWRALPF.js → chunk-K6DV6ZQJ.js} +9 -8
- package/bundle/chunk-K77W7OAI.js +398 -0
- package/bundle/{chunk-SHZORH3T.js → chunk-NWWVQCEM.js} +1 -1
- package/bundle/{chunk-JPCDQXHB.js → chunk-PGCIAGXU.js} +1 -1
- package/bundle/{chunk-HS7THREL.js → chunk-QXLHAGLO.js} +104 -8
- package/bundle/{chunk-2MRUXBJ5.js → chunk-RJSQB7MD.js} +7 -7
- package/bundle/{chunk-RHINAWEP.js → chunk-TOGB2OXA.js} +67 -54
- package/bundle/chunk-TXL73KVK.js +17332 -0
- package/bundle/{chunk-YYWWE5GW.js → chunk-TYAF55F7.js} +7720 -14267
- package/bundle/chunk-UWHDOUIM.js +154 -0
- package/bundle/{chunk-TZAOURRV.js → chunk-WFY6AHA3.js} +1 -1
- package/bundle/chunk-YFMY6TMN.js +118 -0
- package/bundle/chunk-YMKYUNCI.js +397175 -0
- package/bundle/chunk-YOVSXRBK.js +512 -0
- package/bundle/{chunk-LH73BY77.js → chunk-ZJ6RWJBB.js} +7 -7
- package/bundle/chunk-ZT7DTH6P.js +102505 -0
- package/bundle/{cleanup-5UYKVLIF.js → cleanup-ID7KOVH6.js} +2 -2
- package/bundle/{cleanup-6OO5MA6W.js → cleanup-IQDM3OQH.js} +2 -2
- package/bundle/{cleanup-ODOGWYRM.js → cleanup-VC5QYANG.js} +2 -2
- package/bundle/cleanup-XKLXHTQY.js +32 -0
- package/bundle/{core-S5B3NEKC.js → core-L2IMO77B.js} +3 -1
- package/bundle/{devtoolsService-FUTPYP6V.js → devtoolsService-A4MVL3QX.js} +2 -2
- package/bundle/{devtoolsService-YWNTGRUE.js → devtoolsService-FCZAZ7OL.js} +2 -2
- package/bundle/{devtoolsService-NZQZUVCI.js → devtoolsService-MTKVT52L.js} +4 -3
- package/bundle/devtoolsService-OFTYP7HA.js +4359 -0
- package/bundle/{dist-DB6LWOKZ.js → dist-IRKAN2JJ.js} +3 -1
- package/bundle/{core-JL633Z4N.js → dist-OMDZCEPS.js} +3 -1
- package/bundle/dist-UPFVI32N.js +2172 -0
- package/bundle/{gemini-D3BRVDVJ.js → gemini-A2H7FXLW.js} +14 -14
- package/bundle/{gemini-AQASGK5V.js → gemini-ANKKRIYC.js} +214 -198
- package/bundle/{gemini-PPNY5YY6.js → gemini-RXM642S5.js} +14 -14
- package/bundle/gemini-TQ4IKPW2.js +16491 -0
- package/bundle/gemini.js +7 -7
- package/bundle/{interactiveCli-P7QQLIDS.js → interactiveCli-DCR23VNH.js} +21 -15
- package/bundle/{interactiveCli-CXCZMXKQ.js → interactiveCli-LU4ELYJR.js} +21 -15
- package/bundle/{interactiveCli-RU7LCVXL.js → interactiveCli-MMQJKAMI.js} +328 -303
- package/bundle/interactiveCli-XFHD4NND.js +34912 -0
- package/bundle/{liteRtServerManager-ISKYY742.js → liteRtServerManager-3XISBZSR.js} +4 -4
- package/bundle/{liteRtServerManager-MPPOFOTR.js → liteRtServerManager-AW53PI2D.js} +4 -4
- package/bundle/{liteRtServerManager-FIVLVXQJ.js → liteRtServerManager-D6QKXOSW.js} +4 -4
- package/bundle/liteRtServerManager-PKONORB7.js +65 -0
- package/bundle/{oauth2-provider-G6DF4NEU.js → oauth2-provider-7KVPKQ4C.js} +1 -1
- package/bundle/{oauth2-provider-DOIL6PEC.js → oauth2-provider-CU4P6HIT.js} +38 -72
- package/bundle/{oauth2-provider-XR5UQYQV.js → oauth2-provider-MRWRX5R2.js} +1 -1
- package/bundle/oauth2-provider-NQD4RC5Z.js +235 -0
- package/bundle/{start-S77W5RNK.js → start-7U2NBBF2.js} +6 -6
- package/bundle/{start-YWT3TSZW.js → start-HBTVIGJK.js} +6 -6
- package/bundle/{start-AJW7OVPU.js → start-JQFBJ44Q.js} +6 -6
- package/bundle/start-KLUMUSR7.js +18 -0
- package/package.json +1 -1
|
@@ -2,7 +2,7 @@ const require = (await import('node:module')).createRequire(import.meta.url); co
|
|
|
2
2
|
import {
|
|
3
3
|
startCommand,
|
|
4
4
|
startServer
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-GHCTXZXJ.js";
|
|
6
6
|
import {
|
|
7
7
|
BuiltinCommandLoader,
|
|
8
8
|
CommandService,
|
|
@@ -45,11 +45,11 @@ import {
|
|
|
45
45
|
updateAllUpdatableExtensions,
|
|
46
46
|
updateExtension,
|
|
47
47
|
validateAuthMethod
|
|
48
|
-
} from "./chunk-
|
|
48
|
+
} from "./chunk-RJSQB7MD.js";
|
|
49
49
|
import {
|
|
50
50
|
exitCli,
|
|
51
51
|
require_source
|
|
52
|
-
} from "./chunk-
|
|
52
|
+
} from "./chunk-DJWQKPM3.js";
|
|
53
53
|
import {
|
|
54
54
|
appEvents
|
|
55
55
|
} from "./chunk-5PS3AYFU.js";
|
|
@@ -87,11 +87,11 @@ import {
|
|
|
87
87
|
resolveGemmaConfig,
|
|
88
88
|
saveModelChange,
|
|
89
89
|
stripAnsi
|
|
90
|
-
} from "./chunk-
|
|
90
|
+
} from "./chunk-6SBXH4D5.js";
|
|
91
91
|
import {
|
|
92
92
|
RELAUNCH_EXIT_CODE
|
|
93
|
-
} from "./chunk-
|
|
94
|
-
import "./chunk-
|
|
93
|
+
} from "./chunk-7ELLCO6U.js";
|
|
94
|
+
import "./chunk-K6DV6ZQJ.js";
|
|
95
95
|
import {
|
|
96
96
|
cleanupCheckpoints,
|
|
97
97
|
registerCleanup,
|
|
@@ -100,12 +100,15 @@ import {
|
|
|
100
100
|
runExitCleanup,
|
|
101
101
|
runSyncCleanup,
|
|
102
102
|
setupSignalHandlers
|
|
103
|
-
} from "./chunk-
|
|
103
|
+
} from "./chunk-UWHDOUIM.js";
|
|
104
104
|
import {
|
|
105
105
|
ASK_USER_TOOL_NAME,
|
|
106
|
+
ApprovalMode,
|
|
106
107
|
AuthType,
|
|
107
108
|
Client,
|
|
108
109
|
Config,
|
|
110
|
+
CoreEvent,
|
|
111
|
+
CoreToolCallStatus,
|
|
109
112
|
DEFAULT_CONTEXT_FILENAME,
|
|
110
113
|
DEFAULT_FILE_FILTERING_OPTIONS,
|
|
111
114
|
DEFAULT_GEMINI_EMBEDDING_MODEL,
|
|
@@ -127,19 +130,27 @@ import {
|
|
|
127
130
|
FolderTrustDiscoveryService,
|
|
128
131
|
GEMINI_DIR,
|
|
129
132
|
GEMINI_MODEL_ALIAS_AUTO,
|
|
133
|
+
GeminiEventType,
|
|
130
134
|
IdeClient,
|
|
135
|
+
IntegrityStatus,
|
|
131
136
|
InvalidStreamError,
|
|
132
137
|
JsonFormatter,
|
|
138
|
+
JsonStreamEventType,
|
|
139
|
+
Kind,
|
|
133
140
|
LegacyAgentSession,
|
|
134
141
|
Logger,
|
|
135
142
|
MAX_TOKENS_EXCEEDED_SUGGESTION,
|
|
136
143
|
MCPServerConfig,
|
|
144
|
+
MCPServerStatus,
|
|
145
|
+
MessageBusType,
|
|
137
146
|
OTHER_BLOCKED_MESSAGE,
|
|
147
|
+
OutputFormat,
|
|
138
148
|
PREVIEW_GEMINI_3_1_CUSTOM_TOOLS_MODEL,
|
|
139
149
|
PREVIEW_GEMINI_3_1_MODEL,
|
|
140
150
|
PREVIEW_GEMINI_FLASH_LITE_MODEL,
|
|
141
151
|
PREVIEW_GEMINI_FLASH_MODEL,
|
|
142
152
|
PREVIEW_GEMINI_MODEL,
|
|
153
|
+
PolicyDecision,
|
|
143
154
|
PolicyIntegrityManager,
|
|
144
155
|
RECITATION_BLOCKED_MESSAGE,
|
|
145
156
|
REFERENCE_CONTENT_START,
|
|
@@ -147,6 +158,8 @@ import {
|
|
|
147
158
|
ReadManyFilesTool,
|
|
148
159
|
SAFETY_BLOCKED_MESSAGE,
|
|
149
160
|
Scheduler,
|
|
161
|
+
SessionEndReason,
|
|
162
|
+
SessionStartSource,
|
|
150
163
|
ShellExecutionService,
|
|
151
164
|
SimpleExtensionLoader,
|
|
152
165
|
Storage,
|
|
@@ -155,10 +168,13 @@ import {
|
|
|
155
168
|
TRUE_EMPTY_RESPONSE_MESSAGE,
|
|
156
169
|
ToolCallEvent,
|
|
157
170
|
ToolConfirmationOutcome,
|
|
171
|
+
ToolErrorType,
|
|
172
|
+
TrustLevel,
|
|
158
173
|
UserAccountManager,
|
|
159
174
|
UserPromptEvent,
|
|
160
175
|
ValidationCancelledError,
|
|
161
176
|
ValidationRequiredError,
|
|
177
|
+
WarningPriority,
|
|
162
178
|
applyAdminAllowlist,
|
|
163
179
|
applyRequiredServers,
|
|
164
180
|
clearCachedCredentialFile,
|
|
@@ -237,7 +253,7 @@ import {
|
|
|
237
253
|
updatePolicy,
|
|
238
254
|
writeToStderr,
|
|
239
255
|
writeToStdout
|
|
240
|
-
} from "./chunk-
|
|
256
|
+
} from "./chunk-TYAF55F7.js";
|
|
241
257
|
import "./chunk-664ZODQF.js";
|
|
242
258
|
import "./chunk-IUUIT4SU.js";
|
|
243
259
|
import "./chunk-TUDYL3X4.js";
|
|
@@ -5367,7 +5383,7 @@ var MCP_LIST_DEFAULT_TIMEOUT_MSEC = 5e3;
|
|
|
5367
5383
|
async function testMCPConnection(serverName, config, isTrusted, activeSettings) {
|
|
5368
5384
|
const isStdio = !!config.command;
|
|
5369
5385
|
if (isStdio && !isTrusted) {
|
|
5370
|
-
return
|
|
5386
|
+
return MCPServerStatus.DISCONNECTED;
|
|
5371
5387
|
}
|
|
5372
5388
|
const client = new Client({
|
|
5373
5389
|
name: "mcp-test-client",
|
|
@@ -5403,7 +5419,7 @@ async function testMCPConnection(serverName, config, isTrusted, activeSettings)
|
|
|
5403
5419
|
transport = await createTransport(serverName, config, false, mcpContext);
|
|
5404
5420
|
} catch {
|
|
5405
5421
|
await client.close();
|
|
5406
|
-
return
|
|
5422
|
+
return MCPServerStatus.DISCONNECTED;
|
|
5407
5423
|
}
|
|
5408
5424
|
try {
|
|
5409
5425
|
const timeout = config.timeout ?? MCP_LIST_DEFAULT_TIMEOUT_MSEC;
|
|
@@ -5417,10 +5433,10 @@ async function testMCPConnection(serverName, config, isTrusted, activeSettings)
|
|
|
5417
5433
|
);
|
|
5418
5434
|
}
|
|
5419
5435
|
await client.close();
|
|
5420
|
-
return
|
|
5436
|
+
return MCPServerStatus.CONNECTED;
|
|
5421
5437
|
} catch {
|
|
5422
5438
|
await transport.close();
|
|
5423
|
-
return
|
|
5439
|
+
return MCPServerStatus.DISCONNECTED;
|
|
5424
5440
|
}
|
|
5425
5441
|
}
|
|
5426
5442
|
async function getServerStatus(serverName, server, isTrusted, activeSettings, consolidatedExcluded, consolidatedAllowed) {
|
|
@@ -5433,12 +5449,12 @@ async function getServerStatus(serverName, server, isTrusted, activeSettings, co
|
|
|
5433
5449
|
});
|
|
5434
5450
|
if (!loadResult.allowed) {
|
|
5435
5451
|
if (loadResult.blockType === "admin" || loadResult.blockType === "allowlist" || loadResult.blockType === "excludelist") {
|
|
5436
|
-
return
|
|
5452
|
+
return MCPServerStatus.BLOCKED;
|
|
5437
5453
|
}
|
|
5438
|
-
return
|
|
5454
|
+
return MCPServerStatus.DISABLED;
|
|
5439
5455
|
}
|
|
5440
5456
|
if (!isTrusted) {
|
|
5441
|
-
return
|
|
5457
|
+
return MCPServerStatus.DISABLED;
|
|
5442
5458
|
}
|
|
5443
5459
|
return testMCPConnection(serverName, server, isTrusted, activeSettings);
|
|
5444
5460
|
}
|
|
@@ -5484,23 +5500,23 @@ async function listMcpServers(loadedSettingsArg) {
|
|
|
5484
5500
|
let statusIndicator = "";
|
|
5485
5501
|
let statusText = "";
|
|
5486
5502
|
switch (status) {
|
|
5487
|
-
case
|
|
5503
|
+
case MCPServerStatus.CONNECTED:
|
|
5488
5504
|
statusIndicator = import_chalk.default.green("\u2713");
|
|
5489
5505
|
statusText = "Connected";
|
|
5490
5506
|
break;
|
|
5491
|
-
case
|
|
5507
|
+
case MCPServerStatus.CONNECTING:
|
|
5492
5508
|
statusIndicator = import_chalk.default.yellow("\u2026");
|
|
5493
5509
|
statusText = "Connecting";
|
|
5494
5510
|
break;
|
|
5495
|
-
case
|
|
5511
|
+
case MCPServerStatus.BLOCKED:
|
|
5496
5512
|
statusIndicator = import_chalk.default.red("\u26D4");
|
|
5497
5513
|
statusText = "Blocked";
|
|
5498
5514
|
break;
|
|
5499
|
-
case
|
|
5515
|
+
case MCPServerStatus.DISABLED:
|
|
5500
5516
|
statusIndicator = import_chalk.default.gray("\u25CB");
|
|
5501
5517
|
statusText = "Disabled";
|
|
5502
5518
|
break;
|
|
5503
|
-
case
|
|
5519
|
+
case MCPServerStatus.DISCONNECTED:
|
|
5504
5520
|
default:
|
|
5505
5521
|
statusIndicator = import_chalk.default.red("\u2717");
|
|
5506
5522
|
statusText = "Disconnected";
|
|
@@ -5786,7 +5802,7 @@ async function handleInstall(args) {
|
|
|
5786
5802
|
);
|
|
5787
5803
|
if (confirmed) {
|
|
5788
5804
|
const trustedFolders = loadTrustedFolders();
|
|
5789
|
-
await trustedFolders.setValue(realPath,
|
|
5805
|
+
await trustedFolders.setValue(realPath, TrustLevel.TRUST_FOLDER);
|
|
5790
5806
|
} else {
|
|
5791
5807
|
throw new Error(
|
|
5792
5808
|
`Installation aborted: Folder "${absolutePath}" is not trusted.`
|
|
@@ -7831,7 +7847,7 @@ async function loadSandboxConfig(settings, argv) {
|
|
|
7831
7847
|
}
|
|
7832
7848
|
const command2 = getSandboxCommand(sandboxValue);
|
|
7833
7849
|
const packageJson = await getPackageJson(__dirname3);
|
|
7834
|
-
const image = process.env["GEMINI_SANDBOX_IMAGE"] ?? "us-docker.pkg.dev/gemini-code-dev/gemini-cli/sandbox:0.54.
|
|
7850
|
+
const image = process.env["GEMINI_SANDBOX_IMAGE"] ?? "us-docker.pkg.dev/gemini-code-dev/gemini-cli/sandbox:0.54.4" ?? customImage ?? packageJson?.config?.sandboxImageUri;
|
|
7835
7851
|
const isNative = command2 === "windows-native" || command2 === "sandbox-exec" || command2 === "lxc";
|
|
7836
7852
|
return command2 && (image || isNative) ? { enabled: true, allowedPaths, networkAccess, command: command2, image } : void 0;
|
|
7837
7853
|
}
|
|
@@ -7890,9 +7906,9 @@ async function resolveWorkspacePolicyState(options) {
|
|
|
7890
7906
|
cwd,
|
|
7891
7907
|
potentialWorkspacePoliciesDir
|
|
7892
7908
|
);
|
|
7893
|
-
if (integrityResult.status ===
|
|
7909
|
+
if (integrityResult.status === IntegrityStatus.MATCH) {
|
|
7894
7910
|
workspacePoliciesDir = potentialWorkspacePoliciesDir;
|
|
7895
|
-
} else if (integrityResult.status ===
|
|
7911
|
+
} else if (integrityResult.status === IntegrityStatus.NEW && integrityResult.fileCount === 0) {
|
|
7896
7912
|
workspacePoliciesDir = void 0;
|
|
7897
7913
|
} else if (interactive && !autoAcceptWorkspacePolicies) {
|
|
7898
7914
|
policyUpdateConfirmationRequest = {
|
|
@@ -8320,23 +8336,23 @@ async function loadCliConfig(settings, sessionId, argv, options = {}) {
|
|
|
8320
8336
|
if (rawApprovalMode) {
|
|
8321
8337
|
switch (rawApprovalMode) {
|
|
8322
8338
|
case "yolo":
|
|
8323
|
-
approvalMode =
|
|
8339
|
+
approvalMode = ApprovalMode.YOLO;
|
|
8324
8340
|
break;
|
|
8325
8341
|
case "auto_edit":
|
|
8326
|
-
approvalMode =
|
|
8342
|
+
approvalMode = ApprovalMode.AUTO_EDIT;
|
|
8327
8343
|
break;
|
|
8328
8344
|
case "plan":
|
|
8329
8345
|
if (!(settings.general?.plan?.enabled ?? true)) {
|
|
8330
8346
|
debugLogger.warn(
|
|
8331
8347
|
'Approval mode "plan" is disabled in your settings. Falling back to "default".'
|
|
8332
8348
|
);
|
|
8333
|
-
approvalMode =
|
|
8349
|
+
approvalMode = ApprovalMode.DEFAULT;
|
|
8334
8350
|
} else {
|
|
8335
|
-
approvalMode =
|
|
8351
|
+
approvalMode = ApprovalMode.PLAN;
|
|
8336
8352
|
}
|
|
8337
8353
|
break;
|
|
8338
8354
|
case "default":
|
|
8339
|
-
approvalMode =
|
|
8355
|
+
approvalMode = ApprovalMode.DEFAULT;
|
|
8340
8356
|
break;
|
|
8341
8357
|
default:
|
|
8342
8358
|
throw new Error(
|
|
@@ -8344,10 +8360,10 @@ async function loadCliConfig(settings, sessionId, argv, options = {}) {
|
|
|
8344
8360
|
);
|
|
8345
8361
|
}
|
|
8346
8362
|
} else {
|
|
8347
|
-
approvalMode =
|
|
8363
|
+
approvalMode = ApprovalMode.DEFAULT;
|
|
8348
8364
|
}
|
|
8349
8365
|
if (settings.security?.disableYoloMode || settings.admin?.secureModeEnabled) {
|
|
8350
|
-
if (approvalMode ===
|
|
8366
|
+
if (approvalMode === ApprovalMode.YOLO) {
|
|
8351
8367
|
if (settings.admin?.secureModeEnabled) {
|
|
8352
8368
|
debugLogger.error(
|
|
8353
8369
|
'YOLO mode is disabled by "secureModeEnabled" setting.'
|
|
@@ -8365,16 +8381,16 @@ async function loadCliConfig(settings, sessionId, argv, options = {}) {
|
|
|
8365
8381
|
)
|
|
8366
8382
|
);
|
|
8367
8383
|
}
|
|
8368
|
-
} else if (approvalMode ===
|
|
8384
|
+
} else if (approvalMode === ApprovalMode.YOLO) {
|
|
8369
8385
|
debugLogger.warn(
|
|
8370
8386
|
"YOLO mode is enabled. All tool calls will be automatically approved."
|
|
8371
8387
|
);
|
|
8372
8388
|
}
|
|
8373
|
-
if (!trustedFolder && approvalMode !==
|
|
8389
|
+
if (!trustedFolder && approvalMode !== ApprovalMode.DEFAULT) {
|
|
8374
8390
|
debugLogger.warn(
|
|
8375
8391
|
`Approval mode overridden to "default" because the current folder is not trusted.`
|
|
8376
8392
|
);
|
|
8377
|
-
approvalMode =
|
|
8393
|
+
approvalMode = ApprovalMode.DEFAULT;
|
|
8378
8394
|
}
|
|
8379
8395
|
let telemetrySettings;
|
|
8380
8396
|
try {
|
|
@@ -9812,7 +9828,7 @@ import path9 from "node:path";
|
|
|
9812
9828
|
import process4 from "node:process";
|
|
9813
9829
|
var homeDirectoryCheck = {
|
|
9814
9830
|
id: "home-directory",
|
|
9815
|
-
priority:
|
|
9831
|
+
priority: WarningPriority.Low,
|
|
9816
9832
|
check: async (workspaceRoot, settings) => {
|
|
9817
9833
|
if (settings.ui?.showHomeDirectoryWarning === false) {
|
|
9818
9834
|
return null;
|
|
@@ -9836,7 +9852,7 @@ var homeDirectoryCheck = {
|
|
|
9836
9852
|
};
|
|
9837
9853
|
var rootDirectoryCheck = {
|
|
9838
9854
|
id: "root-directory",
|
|
9839
|
-
priority:
|
|
9855
|
+
priority: WarningPriority.High,
|
|
9840
9856
|
check: async (workspaceRoot, _settings) => {
|
|
9841
9857
|
try {
|
|
9842
9858
|
const workspaceRealPath = await fs9.realpath(workspaceRoot);
|
|
@@ -9852,7 +9868,7 @@ var rootDirectoryCheck = {
|
|
|
9852
9868
|
};
|
|
9853
9869
|
var folderTrustCheck = {
|
|
9854
9870
|
id: "folder-trust",
|
|
9855
|
-
priority:
|
|
9871
|
+
priority: WarningPriority.High,
|
|
9856
9872
|
check: async (workspaceRoot, settings) => {
|
|
9857
9873
|
if (!isFolderTrustEnabled(settings)) {
|
|
9858
9874
|
return null;
|
|
@@ -10042,12 +10058,12 @@ function handleError(error, config, customErrorCode) {
|
|
|
10042
10058
|
error,
|
|
10043
10059
|
config.getContentGeneratorConfig()?.authType
|
|
10044
10060
|
);
|
|
10045
|
-
if (config.getOutputFormat() ===
|
|
10061
|
+
if (config.getOutputFormat() === OutputFormat.STREAM_JSON) {
|
|
10046
10062
|
const streamFormatter = new StreamJsonFormatter();
|
|
10047
10063
|
const errorCode = customErrorCode ?? extractErrorCode(error);
|
|
10048
10064
|
const metrics = uiTelemetryService.getMetrics();
|
|
10049
10065
|
streamFormatter.emitEvent({
|
|
10050
|
-
type:
|
|
10066
|
+
type: JsonStreamEventType.RESULT,
|
|
10051
10067
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10052
10068
|
status: "error",
|
|
10053
10069
|
error: {
|
|
@@ -10058,7 +10074,7 @@ function handleError(error, config, customErrorCode) {
|
|
|
10058
10074
|
});
|
|
10059
10075
|
runSyncCleanup();
|
|
10060
10076
|
process.exit(getNumericExitCode(errorCode));
|
|
10061
|
-
} else if (config.getOutputFormat() ===
|
|
10077
|
+
} else if (config.getOutputFormat() === OutputFormat.JSON) {
|
|
10062
10078
|
const formatter = new JsonFormatter();
|
|
10063
10079
|
const errorCode = customErrorCode ?? extractErrorCode(error);
|
|
10064
10080
|
const formattedError = formatter.formatError(
|
|
@@ -10078,11 +10094,11 @@ function handleToolError(toolName, toolError, config, errorType, resultDisplay)
|
|
|
10078
10094
|
const isFatal = isFatalToolError(errorType);
|
|
10079
10095
|
if (isFatal) {
|
|
10080
10096
|
const toolExecutionError = new FatalToolExecutionError(errorMessage);
|
|
10081
|
-
if (config.getOutputFormat() ===
|
|
10097
|
+
if (config.getOutputFormat() === OutputFormat.STREAM_JSON) {
|
|
10082
10098
|
const streamFormatter = new StreamJsonFormatter();
|
|
10083
10099
|
const metrics = uiTelemetryService.getMetrics();
|
|
10084
10100
|
streamFormatter.emitEvent({
|
|
10085
|
-
type:
|
|
10101
|
+
type: JsonStreamEventType.RESULT,
|
|
10086
10102
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10087
10103
|
status: "error",
|
|
10088
10104
|
error: {
|
|
@@ -10091,7 +10107,7 @@ function handleToolError(toolName, toolError, config, errorType, resultDisplay)
|
|
|
10091
10107
|
},
|
|
10092
10108
|
stats: streamFormatter.convertToStreamStats(metrics, 0)
|
|
10093
10109
|
});
|
|
10094
|
-
} else if (config.getOutputFormat() ===
|
|
10110
|
+
} else if (config.getOutputFormat() === OutputFormat.JSON) {
|
|
10095
10111
|
const formatter = new JsonFormatter();
|
|
10096
10112
|
const formattedError = formatter.formatError(
|
|
10097
10113
|
toolExecutionError,
|
|
@@ -10109,11 +10125,11 @@ function handleToolError(toolName, toolError, config, errorType, resultDisplay)
|
|
|
10109
10125
|
}
|
|
10110
10126
|
function handleCancellationError(config) {
|
|
10111
10127
|
const cancellationError = new FatalCancellationError("Operation cancelled.");
|
|
10112
|
-
if (config.getOutputFormat() ===
|
|
10128
|
+
if (config.getOutputFormat() === OutputFormat.STREAM_JSON) {
|
|
10113
10129
|
const streamFormatter = new StreamJsonFormatter();
|
|
10114
10130
|
const metrics = uiTelemetryService.getMetrics();
|
|
10115
10131
|
streamFormatter.emitEvent({
|
|
10116
|
-
type:
|
|
10132
|
+
type: JsonStreamEventType.RESULT,
|
|
10117
10133
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10118
10134
|
status: "error",
|
|
10119
10135
|
error: {
|
|
@@ -10124,7 +10140,7 @@ function handleCancellationError(config) {
|
|
|
10124
10140
|
});
|
|
10125
10141
|
runSyncCleanup();
|
|
10126
10142
|
process.exit(cancellationError.exitCode);
|
|
10127
|
-
} else if (config.getOutputFormat() ===
|
|
10143
|
+
} else if (config.getOutputFormat() === OutputFormat.JSON) {
|
|
10128
10144
|
const formatter = new JsonFormatter();
|
|
10129
10145
|
const formattedError = formatter.formatError(
|
|
10130
10146
|
cancellationError,
|
|
@@ -10144,11 +10160,11 @@ function handleMaxTurnsExceededError(config) {
|
|
|
10144
10160
|
const maxTurnsError = new FatalTurnLimitedError(
|
|
10145
10161
|
"Reached max session turns for this session. Increase the number of turns by specifying maxSessionTurns in settings.json."
|
|
10146
10162
|
);
|
|
10147
|
-
if (config.getOutputFormat() ===
|
|
10163
|
+
if (config.getOutputFormat() === OutputFormat.STREAM_JSON) {
|
|
10148
10164
|
const streamFormatter = new StreamJsonFormatter();
|
|
10149
10165
|
const metrics = uiTelemetryService.getMetrics();
|
|
10150
10166
|
streamFormatter.emitEvent({
|
|
10151
|
-
type:
|
|
10167
|
+
type: JsonStreamEventType.RESULT,
|
|
10152
10168
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10153
10169
|
status: "error",
|
|
10154
10170
|
error: {
|
|
@@ -10159,7 +10175,7 @@ function handleMaxTurnsExceededError(config) {
|
|
|
10159
10175
|
});
|
|
10160
10176
|
runSyncCleanup();
|
|
10161
10177
|
process.exit(maxTurnsError.exitCode);
|
|
10162
|
-
} else if (config.getOutputFormat() ===
|
|
10178
|
+
} else if (config.getOutputFormat() === OutputFormat.JSON) {
|
|
10163
10179
|
const formatter = new JsonFormatter();
|
|
10164
10180
|
const formattedError = formatter.formatError(
|
|
10165
10181
|
maxTurnsError,
|
|
@@ -10239,7 +10255,7 @@ async function runNonInteractive({
|
|
|
10239
10255
|
}
|
|
10240
10256
|
});
|
|
10241
10257
|
if (process.env["GEMINI_CLI_ACTIVITY_LOG_TARGET"]) {
|
|
10242
|
-
const { setupInitialActivityLogger } = await import("./devtoolsService-
|
|
10258
|
+
const { setupInitialActivityLogger } = await import("./devtoolsService-MTKVT52L.js");
|
|
10243
10259
|
setupInitialActivityLogger(config);
|
|
10244
10260
|
}
|
|
10245
10261
|
const { stdout: workingStdout } = createWorkingStdio();
|
|
@@ -10255,7 +10271,7 @@ async function runNonInteractive({
|
|
|
10255
10271
|
}
|
|
10256
10272
|
};
|
|
10257
10273
|
const startTime = Date.now();
|
|
10258
|
-
const streamFormatter = config.getOutputFormat() ===
|
|
10274
|
+
const streamFormatter = config.getOutputFormat() === OutputFormat.STREAM_JSON ? new StreamJsonFormatter() : null;
|
|
10259
10275
|
const abortController = new AbortController();
|
|
10260
10276
|
let isAborting = false;
|
|
10261
10277
|
let cancelMessageTimer = null;
|
|
@@ -10308,13 +10324,13 @@ async function runNonInteractive({
|
|
|
10308
10324
|
};
|
|
10309
10325
|
try {
|
|
10310
10326
|
consolePatcher.patch();
|
|
10311
|
-
if (config.getRawOutput() && !config.getAcceptRawOutputRisk() && config.getOutputFormat() ===
|
|
10327
|
+
if (config.getRawOutput() && !config.getAcceptRawOutputRisk() && config.getOutputFormat() === OutputFormat.TEXT) {
|
|
10312
10328
|
process.stderr.write(
|
|
10313
10329
|
"[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"
|
|
10314
10330
|
);
|
|
10315
10331
|
}
|
|
10316
10332
|
setupStdinCancellation();
|
|
10317
|
-
coreEvents.on(
|
|
10333
|
+
coreEvents.on(CoreEvent.UserFeedback, handleUserFeedback);
|
|
10318
10334
|
coreEvents.drainBacklogs();
|
|
10319
10335
|
process.stdout.on("error", (err) => {
|
|
10320
10336
|
if (err.code === "EPIPE") {
|
|
@@ -10340,7 +10356,7 @@ async function runNonInteractive({
|
|
|
10340
10356
|
}
|
|
10341
10357
|
if (streamFormatter) {
|
|
10342
10358
|
streamFormatter.emitEvent({
|
|
10343
|
-
type:
|
|
10359
|
+
type: JsonStreamEventType.INIT,
|
|
10344
10360
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10345
10361
|
session_id: config.getSessionId(),
|
|
10346
10362
|
model: config.getModel()
|
|
@@ -10378,7 +10394,7 @@ async function runNonInteractive({
|
|
|
10378
10394
|
}
|
|
10379
10395
|
if (streamFormatter) {
|
|
10380
10396
|
streamFormatter.emitEvent({
|
|
10381
|
-
type:
|
|
10397
|
+
type: JsonStreamEventType.MESSAGE,
|
|
10382
10398
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10383
10399
|
role: "user",
|
|
10384
10400
|
content: input
|
|
@@ -10417,12 +10433,12 @@ async function runNonInteractive({
|
|
|
10417
10433
|
const metrics = uiTelemetryService.getMetrics();
|
|
10418
10434
|
const durationMs = Date.now() - startTime;
|
|
10419
10435
|
streamFormatter.emitEvent({
|
|
10420
|
-
type:
|
|
10436
|
+
type: JsonStreamEventType.RESULT,
|
|
10421
10437
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10422
10438
|
status: errorPayload ? "error" : "success",
|
|
10423
10439
|
stats: streamFormatter.convertToStreamStats(metrics, durationMs)
|
|
10424
10440
|
});
|
|
10425
|
-
} else if (config.getOutputFormat() ===
|
|
10441
|
+
} else if (config.getOutputFormat() === OutputFormat.JSON) {
|
|
10426
10442
|
const formatter = new JsonFormatter();
|
|
10427
10443
|
const stats = uiTelemetryService.getMetrics();
|
|
10428
10444
|
textOutput.write(
|
|
@@ -10515,13 +10531,13 @@ async function runNonInteractive({
|
|
|
10515
10531
|
const output = isRaw ? part.text : stripAnsi(part.text);
|
|
10516
10532
|
if (streamFormatter) {
|
|
10517
10533
|
streamFormatter.emitEvent({
|
|
10518
|
-
type:
|
|
10534
|
+
type: JsonStreamEventType.MESSAGE,
|
|
10519
10535
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10520
10536
|
role: "assistant",
|
|
10521
10537
|
content: output,
|
|
10522
10538
|
delta: true
|
|
10523
10539
|
});
|
|
10524
|
-
} else if (config.getOutputFormat() ===
|
|
10540
|
+
} else if (config.getOutputFormat() === OutputFormat.JSON) {
|
|
10525
10541
|
responseText += output;
|
|
10526
10542
|
} else {
|
|
10527
10543
|
if (part.text) {
|
|
@@ -10534,13 +10550,13 @@ async function runNonInteractive({
|
|
|
10534
10550
|
break;
|
|
10535
10551
|
}
|
|
10536
10552
|
case "tool_request": {
|
|
10537
|
-
if (config.getOutputFormat() ===
|
|
10553
|
+
if (config.getOutputFormat() === OutputFormat.JSON) {
|
|
10538
10554
|
preToolResponseText = responseText || preToolResponseText;
|
|
10539
10555
|
responseText = "";
|
|
10540
10556
|
}
|
|
10541
10557
|
if (streamFormatter) {
|
|
10542
10558
|
streamFormatter.emitEvent({
|
|
10543
|
-
type:
|
|
10559
|
+
type: JsonStreamEventType.TOOL_USE,
|
|
10544
10560
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10545
10561
|
tool_name: event.name,
|
|
10546
10562
|
tool_id: event.requestId,
|
|
@@ -10556,7 +10572,7 @@ async function runNonInteractive({
|
|
|
10556
10572
|
const displayText = displayContentToString(display);
|
|
10557
10573
|
const errorMsg = getTextContent(event.content) ?? "Tool error";
|
|
10558
10574
|
streamFormatter.emitEvent({
|
|
10559
|
-
type:
|
|
10575
|
+
type: JsonStreamEventType.TOOL_RESULT,
|
|
10560
10576
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10561
10577
|
tool_id: event.requestId,
|
|
10562
10578
|
status: event.isError ? "error" : "success",
|
|
@@ -10571,17 +10587,17 @@ async function runNonInteractive({
|
|
|
10571
10587
|
const display = event.display?.result;
|
|
10572
10588
|
const displayText = displayContentToString(display);
|
|
10573
10589
|
const errorMsg = getTextContent(event.content) ?? "Tool error";
|
|
10574
|
-
if (event.data?.["errorType"] ===
|
|
10575
|
-
if (config.getOutputFormat() ===
|
|
10590
|
+
if (event.data?.["errorType"] === ToolErrorType.STOP_EXECUTION) {
|
|
10591
|
+
if (config.getOutputFormat() === OutputFormat.JSON && !responseText && preToolResponseText) {
|
|
10576
10592
|
responseText = preToolResponseText;
|
|
10577
10593
|
}
|
|
10578
10594
|
const stopMessage = `Agent execution stopped: ${errorMsg}`;
|
|
10579
|
-
if (config.getOutputFormat() ===
|
|
10595
|
+
if (config.getOutputFormat() === OutputFormat.TEXT) {
|
|
10580
10596
|
process.stderr.write(`${stopMessage}
|
|
10581
10597
|
`);
|
|
10582
10598
|
}
|
|
10583
10599
|
}
|
|
10584
|
-
if (event.data?.["errorType"] ===
|
|
10600
|
+
if (event.data?.["errorType"] === ToolErrorType.NO_SPACE_LEFT) {
|
|
10585
10601
|
throw new FatalToolExecutionError(
|
|
10586
10602
|
"Error executing tool " + event.name + ": " + (displayText || errorMsg)
|
|
10587
10603
|
);
|
|
@@ -10616,12 +10632,12 @@ async function runNonInteractive({
|
|
|
10616
10632
|
}
|
|
10617
10633
|
if (streamFormatter) {
|
|
10618
10634
|
streamFormatter.emitEvent({
|
|
10619
|
-
type:
|
|
10635
|
+
type: JsonStreamEventType.ERROR,
|
|
10620
10636
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10621
10637
|
severity: "error",
|
|
10622
10638
|
message: errorMessage
|
|
10623
10639
|
});
|
|
10624
|
-
} else if (config.getOutputFormat() ===
|
|
10640
|
+
} else if (config.getOutputFormat() === OutputFormat.TEXT) {
|
|
10625
10641
|
process.stderr.write(`[ERROR] ${errorMessage}
|
|
10626
10642
|
`);
|
|
10627
10643
|
}
|
|
@@ -10642,12 +10658,12 @@ async function runNonInteractive({
|
|
|
10642
10658
|
const errorCode = event._meta?.["code"];
|
|
10643
10659
|
if (errorCode === "AGENT_EXECUTION_BLOCKED") {
|
|
10644
10660
|
const blockMessage = `Agent execution blocked: ${event.message.trim()}`;
|
|
10645
|
-
if (config.getOutputFormat() ===
|
|
10661
|
+
if (config.getOutputFormat() === OutputFormat.TEXT) {
|
|
10646
10662
|
process.stderr.write(`[WARNING] ${blockMessage}
|
|
10647
10663
|
`);
|
|
10648
10664
|
} else if (streamFormatter) {
|
|
10649
10665
|
streamFormatter.emitEvent({
|
|
10650
|
-
type:
|
|
10666
|
+
type: JsonStreamEventType.ERROR,
|
|
10651
10667
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10652
10668
|
severity: "warning",
|
|
10653
10669
|
message: stripAnsi(blockMessage)
|
|
@@ -10657,13 +10673,13 @@ async function runNonInteractive({
|
|
|
10657
10673
|
break;
|
|
10658
10674
|
}
|
|
10659
10675
|
const severity = event.status === "RESOURCE_EXHAUSTED" ? "error" : "warning";
|
|
10660
|
-
if (config.getOutputFormat() ===
|
|
10676
|
+
if (config.getOutputFormat() === OutputFormat.TEXT) {
|
|
10661
10677
|
process.stderr.write(`[WARNING] ${event.message}
|
|
10662
10678
|
`);
|
|
10663
10679
|
}
|
|
10664
10680
|
if (streamFormatter) {
|
|
10665
10681
|
streamFormatter.emitEvent({
|
|
10666
|
-
type:
|
|
10682
|
+
type: JsonStreamEventType.ERROR,
|
|
10667
10683
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10668
10684
|
severity,
|
|
10669
10685
|
message: stripAnsi(event.message)
|
|
@@ -10683,7 +10699,7 @@ async function runNonInteractive({
|
|
|
10683
10699
|
);
|
|
10684
10700
|
} else if (streamFormatter) {
|
|
10685
10701
|
streamFormatter.emitEvent({
|
|
10686
|
-
type:
|
|
10702
|
+
type: JsonStreamEventType.ERROR,
|
|
10687
10703
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10688
10704
|
severity: "error",
|
|
10689
10705
|
message: "Maximum session turns exceeded"
|
|
@@ -10691,7 +10707,7 @@ async function runNonInteractive({
|
|
|
10691
10707
|
}
|
|
10692
10708
|
}
|
|
10693
10709
|
const stopMessage = typeof event.data?.["message"] === "string" ? event.data["message"] : "";
|
|
10694
|
-
if (stopMessage && config.getOutputFormat() ===
|
|
10710
|
+
if (stopMessage && config.getOutputFormat() === OutputFormat.TEXT) {
|
|
10695
10711
|
process.stderr.write(`Agent execution stopped: ${stopMessage}
|
|
10696
10712
|
`);
|
|
10697
10713
|
}
|
|
@@ -10721,7 +10737,7 @@ async function runNonInteractive({
|
|
|
10721
10737
|
abortController.signal.removeEventListener("abort", abortSession);
|
|
10722
10738
|
scheduler?.dispose();
|
|
10723
10739
|
consolePatcher.cleanup();
|
|
10724
|
-
coreEvents.off(
|
|
10740
|
+
coreEvents.off(CoreEvent.UserFeedback, handleUserFeedback);
|
|
10725
10741
|
}
|
|
10726
10742
|
if (errorToHandle) {
|
|
10727
10743
|
handleError(errorToHandle, config);
|
|
@@ -10749,7 +10765,7 @@ async function runNonInteractive2(params) {
|
|
|
10749
10765
|
}
|
|
10750
10766
|
});
|
|
10751
10767
|
if (process.env["GEMINI_CLI_ACTIVITY_LOG_TARGET"]) {
|
|
10752
|
-
const { setupInitialActivityLogger } = await import("./devtoolsService-
|
|
10768
|
+
const { setupInitialActivityLogger } = await import("./devtoolsService-MTKVT52L.js");
|
|
10753
10769
|
setupInitialActivityLogger(config);
|
|
10754
10770
|
}
|
|
10755
10771
|
const { stdout: workingStdout } = createWorkingStdio();
|
|
@@ -10765,7 +10781,7 @@ async function runNonInteractive2(params) {
|
|
|
10765
10781
|
}
|
|
10766
10782
|
};
|
|
10767
10783
|
const startTime = Date.now();
|
|
10768
|
-
const streamFormatter = config.getOutputFormat() ===
|
|
10784
|
+
const streamFormatter = config.getOutputFormat() === OutputFormat.STREAM_JSON ? new StreamJsonFormatter() : null;
|
|
10769
10785
|
const abortController = new AbortController();
|
|
10770
10786
|
let isAborting = false;
|
|
10771
10787
|
let cancelMessageTimer = null;
|
|
@@ -10816,13 +10832,13 @@ async function runNonInteractive2(params) {
|
|
|
10816
10832
|
let scheduler;
|
|
10817
10833
|
try {
|
|
10818
10834
|
consolePatcher.patch();
|
|
10819
|
-
if (config.getRawOutput() && !config.getAcceptRawOutputRisk() && config.getOutputFormat() ===
|
|
10835
|
+
if (config.getRawOutput() && !config.getAcceptRawOutputRisk() && config.getOutputFormat() === OutputFormat.TEXT) {
|
|
10820
10836
|
process.stderr.write(
|
|
10821
10837
|
"[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"
|
|
10822
10838
|
);
|
|
10823
10839
|
}
|
|
10824
10840
|
setupStdinCancellation();
|
|
10825
|
-
coreEvents.on(
|
|
10841
|
+
coreEvents.on(CoreEvent.UserFeedback, handleUserFeedback);
|
|
10826
10842
|
coreEvents.drainBacklogs();
|
|
10827
10843
|
process.stdout.on("error", (err) => {
|
|
10828
10844
|
if (err.code === "EPIPE") {
|
|
@@ -10846,7 +10862,7 @@ async function runNonInteractive2(params) {
|
|
|
10846
10862
|
}
|
|
10847
10863
|
if (streamFormatter) {
|
|
10848
10864
|
streamFormatter.emitEvent({
|
|
10849
|
-
type:
|
|
10865
|
+
type: JsonStreamEventType.INIT,
|
|
10850
10866
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10851
10867
|
session_id: config.getSessionId(),
|
|
10852
10868
|
model: config.getModel()
|
|
@@ -10884,7 +10900,7 @@ async function runNonInteractive2(params) {
|
|
|
10884
10900
|
}
|
|
10885
10901
|
if (streamFormatter) {
|
|
10886
10902
|
streamFormatter.emitEvent({
|
|
10887
|
-
type:
|
|
10903
|
+
type: JsonStreamEventType.MESSAGE,
|
|
10888
10904
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10889
10905
|
role: "user",
|
|
10890
10906
|
content: input
|
|
@@ -10912,28 +10928,28 @@ async function runNonInteractive2(params) {
|
|
|
10912
10928
|
if (abortController.signal.aborted) {
|
|
10913
10929
|
handleCancellationError(config);
|
|
10914
10930
|
}
|
|
10915
|
-
if (event.type ===
|
|
10931
|
+
if (event.type === GeminiEventType.Content) {
|
|
10916
10932
|
const isRaw = config.getRawOutput() || config.getAcceptRawOutputRisk();
|
|
10917
10933
|
const output = isRaw ? event.value : stripAnsi(event.value);
|
|
10918
10934
|
if (streamFormatter) {
|
|
10919
10935
|
streamFormatter.emitEvent({
|
|
10920
|
-
type:
|
|
10936
|
+
type: JsonStreamEventType.MESSAGE,
|
|
10921
10937
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10922
10938
|
role: "assistant",
|
|
10923
10939
|
content: output,
|
|
10924
10940
|
delta: true
|
|
10925
10941
|
});
|
|
10926
|
-
} else if (config.getOutputFormat() ===
|
|
10942
|
+
} else if (config.getOutputFormat() === OutputFormat.JSON) {
|
|
10927
10943
|
responseText += output;
|
|
10928
10944
|
} else {
|
|
10929
10945
|
if (event.value) {
|
|
10930
10946
|
textOutput.write(output);
|
|
10931
10947
|
}
|
|
10932
10948
|
}
|
|
10933
|
-
} else if (event.type ===
|
|
10949
|
+
} else if (event.type === GeminiEventType.ToolCallRequest) {
|
|
10934
10950
|
if (streamFormatter) {
|
|
10935
10951
|
streamFormatter.emitEvent({
|
|
10936
|
-
type:
|
|
10952
|
+
type: JsonStreamEventType.TOOL_USE,
|
|
10937
10953
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10938
10954
|
tool_name: event.value.name,
|
|
10939
10955
|
tool_id: event.value.callId,
|
|
@@ -10941,33 +10957,33 @@ async function runNonInteractive2(params) {
|
|
|
10941
10957
|
});
|
|
10942
10958
|
}
|
|
10943
10959
|
toolCallRequests.push(event.value);
|
|
10944
|
-
} else if (event.type ===
|
|
10960
|
+
} else if (event.type === GeminiEventType.LoopDetected) {
|
|
10945
10961
|
const message = "Loop detected, stopping execution";
|
|
10946
10962
|
if (streamFormatter) {
|
|
10947
10963
|
streamFormatter.emitEvent({
|
|
10948
|
-
type:
|
|
10964
|
+
type: JsonStreamEventType.ERROR,
|
|
10949
10965
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10950
10966
|
severity: "warning",
|
|
10951
10967
|
message
|
|
10952
10968
|
});
|
|
10953
10969
|
}
|
|
10954
10970
|
warnings.push(message);
|
|
10955
|
-
} else if (event.type ===
|
|
10971
|
+
} else if (event.type === GeminiEventType.MaxSessionTurns) {
|
|
10956
10972
|
const message = "Maximum session turns exceeded";
|
|
10957
10973
|
if (streamFormatter) {
|
|
10958
10974
|
streamFormatter.emitEvent({
|
|
10959
|
-
type:
|
|
10975
|
+
type: JsonStreamEventType.ERROR,
|
|
10960
10976
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10961
10977
|
severity: "error",
|
|
10962
10978
|
message
|
|
10963
10979
|
});
|
|
10964
10980
|
}
|
|
10965
10981
|
warnings.push(message);
|
|
10966
|
-
} else if (event.type ===
|
|
10982
|
+
} else if (event.type === GeminiEventType.Error) {
|
|
10967
10983
|
throw event.value.error;
|
|
10968
|
-
} else if (event.type ===
|
|
10984
|
+
} else if (event.type === GeminiEventType.AgentExecutionStopped) {
|
|
10969
10985
|
const stopMessage = `Agent execution stopped: ${event.value.systemMessage?.trim() || event.value.reason}`;
|
|
10970
|
-
if (config.getOutputFormat() ===
|
|
10986
|
+
if (config.getOutputFormat() === OutputFormat.TEXT) {
|
|
10971
10987
|
process.stderr.write(`${stopMessage}
|
|
10972
10988
|
`);
|
|
10973
10989
|
}
|
|
@@ -10975,7 +10991,7 @@ async function runNonInteractive2(params) {
|
|
|
10975
10991
|
const metrics = uiTelemetryService.getMetrics();
|
|
10976
10992
|
const durationMs = Date.now() - startTime;
|
|
10977
10993
|
streamFormatter.emitEvent({
|
|
10978
|
-
type:
|
|
10994
|
+
type: JsonStreamEventType.RESULT,
|
|
10979
10995
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10980
10996
|
status: "success",
|
|
10981
10997
|
stats: streamFormatter.convertToStreamStats(
|
|
@@ -10983,7 +10999,7 @@ async function runNonInteractive2(params) {
|
|
|
10983
10999
|
durationMs
|
|
10984
11000
|
)
|
|
10985
11001
|
});
|
|
10986
|
-
} else if (config.getOutputFormat() ===
|
|
11002
|
+
} else if (config.getOutputFormat() === OutputFormat.JSON) {
|
|
10987
11003
|
const formatter = new JsonFormatter();
|
|
10988
11004
|
const stats = uiTelemetryService.getMetrics();
|
|
10989
11005
|
textOutput.write(
|
|
@@ -10999,21 +11015,21 @@ async function runNonInteractive2(params) {
|
|
|
10999
11015
|
textOutput.ensureTrailingNewline();
|
|
11000
11016
|
}
|
|
11001
11017
|
return;
|
|
11002
|
-
} else if (event.type ===
|
|
11018
|
+
} else if (event.type === GeminiEventType.AgentExecutionBlocked) {
|
|
11003
11019
|
const blockMessage = `Agent execution blocked: ${event.value.systemMessage?.trim() || event.value.reason}`;
|
|
11004
|
-
if (config.getOutputFormat() ===
|
|
11020
|
+
if (config.getOutputFormat() === OutputFormat.TEXT) {
|
|
11005
11021
|
process.stderr.write(`[WARNING] ${blockMessage}
|
|
11006
11022
|
`);
|
|
11007
11023
|
} else if (streamFormatter) {
|
|
11008
11024
|
streamFormatter.emitEvent({
|
|
11009
|
-
type:
|
|
11025
|
+
type: JsonStreamEventType.ERROR,
|
|
11010
11026
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
11011
11027
|
severity: "warning",
|
|
11012
11028
|
message: stripAnsi(blockMessage)
|
|
11013
11029
|
});
|
|
11014
11030
|
}
|
|
11015
11031
|
warnings.push(blockMessage);
|
|
11016
|
-
} else if (event.type ===
|
|
11032
|
+
} else if (event.type === GeminiEventType.InvalidStream) {
|
|
11017
11033
|
const eventValue = event.value;
|
|
11018
11034
|
if (eventValue?.type === "NO_RESPONSE_TEXT") {
|
|
11019
11035
|
invalidStreamError = TRUE_EMPTY_RESPONSE_MESSAGE;
|
|
@@ -11036,12 +11052,12 @@ async function runNonInteractive2(params) {
|
|
|
11036
11052
|
);
|
|
11037
11053
|
if (streamFormatter) {
|
|
11038
11054
|
streamFormatter.emitEvent({
|
|
11039
|
-
type:
|
|
11055
|
+
type: JsonStreamEventType.ERROR,
|
|
11040
11056
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
11041
11057
|
severity: "error",
|
|
11042
11058
|
message: invalidStreamError
|
|
11043
11059
|
});
|
|
11044
|
-
} else if (config.getOutputFormat() ===
|
|
11060
|
+
} else if (config.getOutputFormat() === OutputFormat.TEXT) {
|
|
11045
11061
|
process.stderr.write(`[ERROR] ${invalidStreamError}
|
|
11046
11062
|
`);
|
|
11047
11063
|
}
|
|
@@ -11061,7 +11077,7 @@ async function runNonInteractive2(params) {
|
|
|
11061
11077
|
const requestInfo = completedToolCall.request;
|
|
11062
11078
|
if (streamFormatter) {
|
|
11063
11079
|
streamFormatter.emitEvent({
|
|
11064
|
-
type:
|
|
11080
|
+
type: JsonStreamEventType.TOOL_RESULT,
|
|
11065
11081
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
11066
11082
|
tool_id: requestInfo.callId,
|
|
11067
11083
|
status: completedToolCall.status === "error" ? "error" : "success",
|
|
@@ -11095,11 +11111,11 @@ async function runNonInteractive2(params) {
|
|
|
11095
11111
|
);
|
|
11096
11112
|
}
|
|
11097
11113
|
const stopExecutionTool = completedToolCalls.find(
|
|
11098
|
-
(tc) => tc.response.errorType ===
|
|
11114
|
+
(tc) => tc.response.errorType === ToolErrorType.STOP_EXECUTION
|
|
11099
11115
|
);
|
|
11100
11116
|
if (stopExecutionTool && stopExecutionTool.response.error) {
|
|
11101
11117
|
const stopMessage = `Agent execution stopped: ${stopExecutionTool.response.error.message}`;
|
|
11102
|
-
if (config.getOutputFormat() ===
|
|
11118
|
+
if (config.getOutputFormat() === OutputFormat.TEXT) {
|
|
11103
11119
|
process.stderr.write(`${stopMessage}
|
|
11104
11120
|
`);
|
|
11105
11121
|
}
|
|
@@ -11107,7 +11123,7 @@ async function runNonInteractive2(params) {
|
|
|
11107
11123
|
const metrics = uiTelemetryService.getMetrics();
|
|
11108
11124
|
const durationMs = Date.now() - startTime;
|
|
11109
11125
|
streamFormatter.emitEvent({
|
|
11110
|
-
type:
|
|
11126
|
+
type: JsonStreamEventType.RESULT,
|
|
11111
11127
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
11112
11128
|
status: "success",
|
|
11113
11129
|
stats: streamFormatter.convertToStreamStats(
|
|
@@ -11115,7 +11131,7 @@ async function runNonInteractive2(params) {
|
|
|
11115
11131
|
durationMs
|
|
11116
11132
|
)
|
|
11117
11133
|
});
|
|
11118
|
-
} else if (config.getOutputFormat() ===
|
|
11134
|
+
} else if (config.getOutputFormat() === OutputFormat.JSON) {
|
|
11119
11135
|
const formatter = new JsonFormatter();
|
|
11120
11136
|
const stats = uiTelemetryService.getMetrics();
|
|
11121
11137
|
textOutput.write(
|
|
@@ -11138,12 +11154,12 @@ async function runNonInteractive2(params) {
|
|
|
11138
11154
|
const metrics = uiTelemetryService.getMetrics();
|
|
11139
11155
|
const durationMs = Date.now() - startTime;
|
|
11140
11156
|
streamFormatter.emitEvent({
|
|
11141
|
-
type:
|
|
11157
|
+
type: JsonStreamEventType.RESULT,
|
|
11142
11158
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
11143
11159
|
status: invalidStreamError ? "error" : "success",
|
|
11144
11160
|
stats: streamFormatter.convertToStreamStats(metrics, durationMs)
|
|
11145
11161
|
});
|
|
11146
|
-
} else if (config.getOutputFormat() ===
|
|
11162
|
+
} else if (config.getOutputFormat() === OutputFormat.JSON) {
|
|
11147
11163
|
const formatter = new JsonFormatter();
|
|
11148
11164
|
const stats = uiTelemetryService.getMetrics();
|
|
11149
11165
|
textOutput.write(
|
|
@@ -11167,7 +11183,7 @@ async function runNonInteractive2(params) {
|
|
|
11167
11183
|
cleanupStdinCancellation();
|
|
11168
11184
|
scheduler?.dispose();
|
|
11169
11185
|
consolePatcher.cleanup();
|
|
11170
|
-
coreEvents.off(
|
|
11186
|
+
coreEvents.off(CoreEvent.UserFeedback, handleUserFeedback);
|
|
11171
11187
|
}
|
|
11172
11188
|
if (errorToHandle) {
|
|
11173
11189
|
handleError(errorToHandle, config);
|
|
@@ -13558,12 +13574,12 @@ function toToolCallContent(toolResult) {
|
|
|
13558
13574
|
}
|
|
13559
13575
|
var basicPermissionOptions = [
|
|
13560
13576
|
{
|
|
13561
|
-
optionId:
|
|
13577
|
+
optionId: ToolConfirmationOutcome.ProceedOnce,
|
|
13562
13578
|
name: "Allow",
|
|
13563
13579
|
kind: "allow_once"
|
|
13564
13580
|
},
|
|
13565
13581
|
{
|
|
13566
|
-
optionId:
|
|
13582
|
+
optionId: ToolConfirmationOutcome.Cancel,
|
|
13567
13583
|
name: "Reject",
|
|
13568
13584
|
kind: "reject_once"
|
|
13569
13585
|
}
|
|
@@ -13575,13 +13591,13 @@ function toPermissionOptions(confirmation, config, enablePermanentToolApproval =
|
|
|
13575
13591
|
switch (confirmation.type) {
|
|
13576
13592
|
case "edit":
|
|
13577
13593
|
options.push({
|
|
13578
|
-
optionId:
|
|
13594
|
+
optionId: ToolConfirmationOutcome.ProceedAlways,
|
|
13579
13595
|
name: "Allow for this session",
|
|
13580
13596
|
kind: "allow_always"
|
|
13581
13597
|
});
|
|
13582
13598
|
if (enablePermanentToolApproval) {
|
|
13583
13599
|
options.push({
|
|
13584
|
-
optionId:
|
|
13600
|
+
optionId: ToolConfirmationOutcome.ProceedAlwaysAndSave,
|
|
13585
13601
|
name: "Allow for this file in all future sessions",
|
|
13586
13602
|
kind: "allow_always"
|
|
13587
13603
|
});
|
|
@@ -13589,13 +13605,13 @@ function toPermissionOptions(confirmation, config, enablePermanentToolApproval =
|
|
|
13589
13605
|
break;
|
|
13590
13606
|
case "exec":
|
|
13591
13607
|
options.push({
|
|
13592
|
-
optionId:
|
|
13608
|
+
optionId: ToolConfirmationOutcome.ProceedAlways,
|
|
13593
13609
|
name: "Allow for this session",
|
|
13594
13610
|
kind: "allow_always"
|
|
13595
13611
|
});
|
|
13596
13612
|
if (enablePermanentToolApproval) {
|
|
13597
13613
|
options.push({
|
|
13598
|
-
optionId:
|
|
13614
|
+
optionId: ToolConfirmationOutcome.ProceedAlwaysAndSave,
|
|
13599
13615
|
name: "Allow this command for all future sessions",
|
|
13600
13616
|
kind: "allow_always"
|
|
13601
13617
|
});
|
|
@@ -13604,19 +13620,19 @@ function toPermissionOptions(confirmation, config, enablePermanentToolApproval =
|
|
|
13604
13620
|
case "mcp":
|
|
13605
13621
|
options.push(
|
|
13606
13622
|
{
|
|
13607
|
-
optionId:
|
|
13623
|
+
optionId: ToolConfirmationOutcome.ProceedAlwaysServer,
|
|
13608
13624
|
name: "Allow all server tools for this session",
|
|
13609
13625
|
kind: "allow_always"
|
|
13610
13626
|
},
|
|
13611
13627
|
{
|
|
13612
|
-
optionId:
|
|
13628
|
+
optionId: ToolConfirmationOutcome.ProceedAlwaysTool,
|
|
13613
13629
|
name: "Allow tool for this session",
|
|
13614
13630
|
kind: "allow_always"
|
|
13615
13631
|
}
|
|
13616
13632
|
);
|
|
13617
13633
|
if (enablePermanentToolApproval) {
|
|
13618
13634
|
options.push({
|
|
13619
|
-
optionId:
|
|
13635
|
+
optionId: ToolConfirmationOutcome.ProceedAlwaysAndSave,
|
|
13620
13636
|
name: "Allow tool for all future sessions",
|
|
13621
13637
|
kind: "allow_always"
|
|
13622
13638
|
});
|
|
@@ -13624,13 +13640,13 @@ function toPermissionOptions(confirmation, config, enablePermanentToolApproval =
|
|
|
13624
13640
|
break;
|
|
13625
13641
|
case "info":
|
|
13626
13642
|
options.push({
|
|
13627
|
-
optionId:
|
|
13643
|
+
optionId: ToolConfirmationOutcome.ProceedAlways,
|
|
13628
13644
|
name: "Allow for this session",
|
|
13629
13645
|
kind: "allow_always"
|
|
13630
13646
|
});
|
|
13631
13647
|
if (enablePermanentToolApproval) {
|
|
13632
13648
|
options.push({
|
|
13633
|
-
optionId:
|
|
13649
|
+
optionId: ToolConfirmationOutcome.ProceedAlwaysAndSave,
|
|
13634
13650
|
name: "Allow for all future sessions",
|
|
13635
13651
|
kind: "allow_always"
|
|
13636
13652
|
});
|
|
@@ -13662,21 +13678,21 @@ function toPermissionOptions(confirmation, config, enablePermanentToolApproval =
|
|
|
13662
13678
|
}
|
|
13663
13679
|
function toAcpToolKind(kind) {
|
|
13664
13680
|
switch (kind) {
|
|
13665
|
-
case
|
|
13666
|
-
case
|
|
13667
|
-
case
|
|
13668
|
-
case
|
|
13669
|
-
case
|
|
13670
|
-
case
|
|
13671
|
-
case
|
|
13672
|
-
case
|
|
13673
|
-
case
|
|
13674
|
-
case
|
|
13681
|
+
case Kind.Read:
|
|
13682
|
+
case Kind.Edit:
|
|
13683
|
+
case Kind.Execute:
|
|
13684
|
+
case Kind.Search:
|
|
13685
|
+
case Kind.Delete:
|
|
13686
|
+
case Kind.Move:
|
|
13687
|
+
case Kind.Think:
|
|
13688
|
+
case Kind.Fetch:
|
|
13689
|
+
case Kind.SwitchMode:
|
|
13690
|
+
case Kind.Other:
|
|
13675
13691
|
return kind;
|
|
13676
|
-
case
|
|
13692
|
+
case Kind.Agent:
|
|
13677
13693
|
return "think";
|
|
13678
|
-
case
|
|
13679
|
-
case
|
|
13694
|
+
case Kind.Plan:
|
|
13695
|
+
case Kind.Communicate:
|
|
13680
13696
|
default:
|
|
13681
13697
|
return "other";
|
|
13682
13698
|
}
|
|
@@ -13684,24 +13700,24 @@ function toAcpToolKind(kind) {
|
|
|
13684
13700
|
function buildAvailableModes(isPlanEnabled) {
|
|
13685
13701
|
const modes = [
|
|
13686
13702
|
{
|
|
13687
|
-
id:
|
|
13703
|
+
id: ApprovalMode.DEFAULT,
|
|
13688
13704
|
name: "Default",
|
|
13689
13705
|
description: "Prompts for approval"
|
|
13690
13706
|
},
|
|
13691
13707
|
{
|
|
13692
|
-
id:
|
|
13708
|
+
id: ApprovalMode.AUTO_EDIT,
|
|
13693
13709
|
name: "Auto Edit",
|
|
13694
13710
|
description: "Auto-approves edit tools"
|
|
13695
13711
|
},
|
|
13696
13712
|
{
|
|
13697
|
-
id:
|
|
13713
|
+
id: ApprovalMode.YOLO,
|
|
13698
13714
|
name: "YOLO",
|
|
13699
13715
|
description: "Auto-approves all tools"
|
|
13700
13716
|
}
|
|
13701
13717
|
];
|
|
13702
13718
|
if (isPlanEnabled) {
|
|
13703
13719
|
modes.push({
|
|
13704
|
-
id:
|
|
13720
|
+
id: ApprovalMode.PLAN,
|
|
13705
13721
|
name: "Plan",
|
|
13706
13722
|
description: "Read-only mode"
|
|
13707
13723
|
});
|
|
@@ -13714,7 +13730,7 @@ function buildAvailableModels(config, settings) {
|
|
|
13714
13730
|
const useGemini31 = config.getGemini31LaunchedSync?.() ?? false;
|
|
13715
13731
|
const useGemini3_5Flash = config.hasGemini35FlashGAAccess?.() ?? false;
|
|
13716
13732
|
const selectedAuthType = settings.merged.security.auth.selectedType;
|
|
13717
|
-
const useCustomToolModel = useGemini31 && selectedAuthType ===
|
|
13733
|
+
const useCustomToolModel = useGemini31 && selectedAuthType === AuthType.USE_GEMINI;
|
|
13718
13734
|
if (config.getExperimentalDynamicModelConfiguration?.() === true && config.getModelConfigService) {
|
|
13719
13735
|
const options = config.getModelConfigService().getAvailableModelOptions({
|
|
13720
13736
|
useGemini3_1: useGemini31,
|
|
@@ -13800,11 +13816,11 @@ var Session = class {
|
|
|
13800
13816
|
this.connection = connection;
|
|
13801
13817
|
this.settings = settings;
|
|
13802
13818
|
coreEvents.on(
|
|
13803
|
-
|
|
13819
|
+
CoreEvent.ApprovalModeChanged,
|
|
13804
13820
|
this.handleApprovalModeChanged
|
|
13805
13821
|
);
|
|
13806
13822
|
this.context.config.getMessageBus()?.subscribe(
|
|
13807
|
-
|
|
13823
|
+
MessageBusType.TOOL_CONFIRMATION_REQUEST,
|
|
13808
13824
|
this.handleToolConfirmationRequest,
|
|
13809
13825
|
{ signal: this.disposeController.signal }
|
|
13810
13826
|
);
|
|
@@ -13828,7 +13844,7 @@ var Session = class {
|
|
|
13828
13844
|
"Policy engine missing. Denying tool confirmation request."
|
|
13829
13845
|
);
|
|
13830
13846
|
await messageBus.publish({
|
|
13831
|
-
type:
|
|
13847
|
+
type: MessageBusType.TOOL_CONFIRMATION_RESPONSE,
|
|
13832
13848
|
correlationId: request.correlationId,
|
|
13833
13849
|
confirmed: false,
|
|
13834
13850
|
requiresUserConfirmation: false
|
|
@@ -13841,7 +13857,7 @@ var Session = class {
|
|
|
13841
13857
|
"Tool confirmation request missing tool name. Denying."
|
|
13842
13858
|
);
|
|
13843
13859
|
await messageBus.publish({
|
|
13844
|
-
type:
|
|
13860
|
+
type: MessageBusType.TOOL_CONFIRMATION_RESPONSE,
|
|
13845
13861
|
correlationId: request.correlationId,
|
|
13846
13862
|
confirmed: false,
|
|
13847
13863
|
requiresUserConfirmation: false
|
|
@@ -13854,7 +13870,7 @@ var Session = class {
|
|
|
13854
13870
|
`Tool confirmation request for unknown tool: ${toolName}. Denying.`
|
|
13855
13871
|
);
|
|
13856
13872
|
await messageBus.publish({
|
|
13857
|
-
type:
|
|
13873
|
+
type: MessageBusType.TOOL_CONFIRMATION_RESPONSE,
|
|
13858
13874
|
correlationId: request.correlationId,
|
|
13859
13875
|
confirmed: false,
|
|
13860
13876
|
requiresUserConfirmation: false
|
|
@@ -13870,15 +13886,15 @@ var Session = class {
|
|
|
13870
13886
|
request.subagent
|
|
13871
13887
|
);
|
|
13872
13888
|
await messageBus.publish({
|
|
13873
|
-
type:
|
|
13889
|
+
type: MessageBusType.TOOL_CONFIRMATION_RESPONSE,
|
|
13874
13890
|
correlationId: request.correlationId,
|
|
13875
|
-
confirmed: result.decision ===
|
|
13876
|
-
requiresUserConfirmation: result.decision ===
|
|
13891
|
+
confirmed: result.decision === PolicyDecision.ALLOW,
|
|
13892
|
+
requiresUserConfirmation: result.decision === PolicyDecision.ASK_USER
|
|
13877
13893
|
});
|
|
13878
13894
|
} catch (error) {
|
|
13879
13895
|
debugLogger.error("Error handling tool confirmation request:", error);
|
|
13880
13896
|
await this.context.config.getMessageBus()?.publish({
|
|
13881
|
-
type:
|
|
13897
|
+
type: MessageBusType.TOOL_CONFIRMATION_RESPONSE,
|
|
13882
13898
|
correlationId: request.correlationId,
|
|
13883
13899
|
confirmed: false,
|
|
13884
13900
|
requiresUserConfirmation: false
|
|
@@ -13898,7 +13914,7 @@ var Session = class {
|
|
|
13898
13914
|
};
|
|
13899
13915
|
dispose() {
|
|
13900
13916
|
coreEvents.off(
|
|
13901
|
-
|
|
13917
|
+
CoreEvent.ApprovalModeChanged,
|
|
13902
13918
|
this.handleApprovalModeChanged
|
|
13903
13919
|
);
|
|
13904
13920
|
this.disposeController.abort();
|
|
@@ -13987,7 +14003,7 @@ ${thought.description}`;
|
|
|
13987
14003
|
await this.sendUpdate({
|
|
13988
14004
|
sessionUpdate: "tool_call",
|
|
13989
14005
|
toolCallId: toolCall.id,
|
|
13990
|
-
status: toolCall.status ===
|
|
14006
|
+
status: toolCall.status === CoreToolCallStatus.Success ? "completed" : "failed",
|
|
13991
14007
|
title: toolCall.displayName || toolCall.name,
|
|
13992
14008
|
content: toolCallContent,
|
|
13993
14009
|
kind: tool ? toAcpToolKind(tool.kind) : "other"
|
|
@@ -14079,7 +14095,7 @@ ${thought.description}`;
|
|
|
14079
14095
|
return { stopReason: "cancelled" };
|
|
14080
14096
|
}
|
|
14081
14097
|
switch (event.type) {
|
|
14082
|
-
case
|
|
14098
|
+
case GeminiEventType.Content: {
|
|
14083
14099
|
const content = {
|
|
14084
14100
|
type: "text",
|
|
14085
14101
|
text: event.value
|
|
@@ -14090,7 +14106,7 @@ ${thought.description}`;
|
|
|
14090
14106
|
});
|
|
14091
14107
|
break;
|
|
14092
14108
|
}
|
|
14093
|
-
case
|
|
14109
|
+
case GeminiEventType.Thought: {
|
|
14094
14110
|
const thoughtText = `**${event.value.subject}**
|
|
14095
14111
|
${event.value.description}`;
|
|
14096
14112
|
await this.sendUpdate({
|
|
@@ -14099,10 +14115,10 @@ ${event.value.description}`;
|
|
|
14099
14115
|
});
|
|
14100
14116
|
break;
|
|
14101
14117
|
}
|
|
14102
|
-
case
|
|
14118
|
+
case GeminiEventType.ToolCallRequest:
|
|
14103
14119
|
toolCallRequests.push(event.value);
|
|
14104
14120
|
break;
|
|
14105
|
-
case
|
|
14121
|
+
case GeminiEventType.Finished: {
|
|
14106
14122
|
const usage2 = event.value.usageMetadata;
|
|
14107
14123
|
if (usage2) {
|
|
14108
14124
|
turnInputTokens = usage2.promptTokenCount ?? turnInputTokens;
|
|
@@ -14110,19 +14126,19 @@ ${event.value.description}`;
|
|
|
14110
14126
|
}
|
|
14111
14127
|
break;
|
|
14112
14128
|
}
|
|
14113
|
-
case
|
|
14129
|
+
case GeminiEventType.ModelInfo:
|
|
14114
14130
|
turnModelId = event.value;
|
|
14115
14131
|
break;
|
|
14116
|
-
case
|
|
14132
|
+
case GeminiEventType.MaxSessionTurns:
|
|
14117
14133
|
stopReason = "max_turn_requests";
|
|
14118
14134
|
break;
|
|
14119
|
-
case
|
|
14135
|
+
case GeminiEventType.LoopDetected:
|
|
14120
14136
|
stopReason = "max_turn_requests";
|
|
14121
14137
|
break;
|
|
14122
|
-
case
|
|
14138
|
+
case GeminiEventType.ContextWindowWillOverflow:
|
|
14123
14139
|
stopReason = "max_tokens";
|
|
14124
14140
|
break;
|
|
14125
|
-
case
|
|
14141
|
+
case GeminiEventType.Error: {
|
|
14126
14142
|
const parseResult = StructuredErrorSchema.safeParse(
|
|
14127
14143
|
event.value.error
|
|
14128
14144
|
);
|
|
@@ -14350,7 +14366,7 @@ ${event.value.description}`;
|
|
|
14350
14366
|
const output = RequestPermissionResponseSchema.parse(
|
|
14351
14367
|
await this.connection.requestPermission(params)
|
|
14352
14368
|
);
|
|
14353
|
-
const outcome = output.outcome.outcome === "cancelled" ?
|
|
14369
|
+
const outcome = output.outcome.outcome === "cancelled" ? ToolConfirmationOutcome.Cancel : external_exports.nativeEnum(ToolConfirmationOutcome).parse(output.outcome.optionId);
|
|
14354
14370
|
await confirmationDetails.onConfirm(outcome);
|
|
14355
14371
|
await updatePolicy(
|
|
14356
14372
|
tool,
|
|
@@ -14361,16 +14377,16 @@ ${event.value.description}`;
|
|
|
14361
14377
|
invocation
|
|
14362
14378
|
);
|
|
14363
14379
|
switch (outcome) {
|
|
14364
|
-
case
|
|
14380
|
+
case ToolConfirmationOutcome.Cancel:
|
|
14365
14381
|
return errorResponse(
|
|
14366
14382
|
new Error(`Tool "${fc.name}" was canceled by the user.`)
|
|
14367
14383
|
);
|
|
14368
|
-
case
|
|
14369
|
-
case
|
|
14370
|
-
case
|
|
14371
|
-
case
|
|
14372
|
-
case
|
|
14373
|
-
case
|
|
14384
|
+
case ToolConfirmationOutcome.ProceedOnce:
|
|
14385
|
+
case ToolConfirmationOutcome.ProceedAlways:
|
|
14386
|
+
case ToolConfirmationOutcome.ProceedAlwaysAndSave:
|
|
14387
|
+
case ToolConfirmationOutcome.ProceedAlwaysServer:
|
|
14388
|
+
case ToolConfirmationOutcome.ProceedAlwaysTool:
|
|
14389
|
+
case ToolConfirmationOutcome.ModifyWithEditor:
|
|
14374
14390
|
break;
|
|
14375
14391
|
default: {
|
|
14376
14392
|
const resultOutcome = outcome;
|
|
@@ -14424,7 +14440,7 @@ ${event.value.description}`;
|
|
|
14424
14440
|
);
|
|
14425
14441
|
this.chat.recordCompletedToolCalls(this.context.config.getActiveModel(), [
|
|
14426
14442
|
{
|
|
14427
|
-
status:
|
|
14443
|
+
status: CoreToolCallStatus.Success,
|
|
14428
14444
|
request: {
|
|
14429
14445
|
callId,
|
|
14430
14446
|
name: fc.name,
|
|
@@ -14469,7 +14485,7 @@ ${event.value.description}`;
|
|
|
14469
14485
|
});
|
|
14470
14486
|
this.chat.recordCompletedToolCalls(this.context.config.getActiveModel(), [
|
|
14471
14487
|
{
|
|
14472
|
-
status:
|
|
14488
|
+
status: CoreToolCallStatus.Error,
|
|
14473
14489
|
request: {
|
|
14474
14490
|
callId,
|
|
14475
14491
|
name: fc.name,
|
|
@@ -14597,12 +14613,12 @@ ${event.value.description}`;
|
|
|
14597
14613
|
sessionId: this.id,
|
|
14598
14614
|
options: [
|
|
14599
14615
|
{
|
|
14600
|
-
optionId:
|
|
14616
|
+
optionId: ToolConfirmationOutcome.ProceedOnce,
|
|
14601
14617
|
name: "Allow once",
|
|
14602
14618
|
kind: "allow_once"
|
|
14603
14619
|
},
|
|
14604
14620
|
{
|
|
14605
|
-
optionId:
|
|
14621
|
+
optionId: ToolConfirmationOutcome.Cancel,
|
|
14606
14622
|
name: "Deny",
|
|
14607
14623
|
kind: "reject_once"
|
|
14608
14624
|
}
|
|
@@ -14627,8 +14643,8 @@ ${event.value.description}`;
|
|
|
14627
14643
|
const output = RequestPermissionResponseSchema.parse(
|
|
14628
14644
|
await this.connection.requestPermission(params)
|
|
14629
14645
|
);
|
|
14630
|
-
const outcome = output.outcome.outcome === "cancelled" ?
|
|
14631
|
-
if (outcome ===
|
|
14646
|
+
const outcome = output.outcome.outcome === "cancelled" ? ToolConfirmationOutcome.Cancel : external_exports.nativeEnum(ToolConfirmationOutcome).parse(output.outcome.optionId);
|
|
14647
|
+
if (outcome === ToolConfirmationOutcome.ProceedOnce) {
|
|
14632
14648
|
this.context.config.getWorkspaceContext().addReadOnlyPath(absolutePath);
|
|
14633
14649
|
validationError = null;
|
|
14634
14650
|
} else {
|
|
@@ -15065,7 +15081,7 @@ var AcpSessionManager = class {
|
|
|
15065
15081
|
mcpServers,
|
|
15066
15082
|
loadedSettings
|
|
15067
15083
|
);
|
|
15068
|
-
const authType = loadedSettings.merged.security.auth.selectedType || (authDetails.baseUrl || process.env["GOOGLE_GEMINI_BASE_URL"] ?
|
|
15084
|
+
const authType = loadedSettings.merged.security.auth.selectedType || (authDetails.baseUrl || process.env["GOOGLE_GEMINI_BASE_URL"] ? AuthType.GATEWAY : AuthType.USE_GEMINI);
|
|
15069
15085
|
let isAuthenticated = false;
|
|
15070
15086
|
let authErrorMessage = "";
|
|
15071
15087
|
try {
|
|
@@ -15077,7 +15093,7 @@ var AcpSessionManager = class {
|
|
|
15077
15093
|
);
|
|
15078
15094
|
isAuthenticated = true;
|
|
15079
15095
|
const contentGeneratorConfig = config.getContentGeneratorConfig();
|
|
15080
|
-
if (authType ===
|
|
15096
|
+
if (authType === AuthType.USE_GEMINI && (!contentGeneratorConfig || !contentGeneratorConfig.apiKey)) {
|
|
15081
15097
|
isAuthenticated = false;
|
|
15082
15098
|
authErrorMessage = "Gemini API key is missing or not configured.";
|
|
15083
15099
|
}
|
|
@@ -15186,7 +15202,7 @@ var AcpSessionManager = class {
|
|
|
15186
15202
|
return response;
|
|
15187
15203
|
}
|
|
15188
15204
|
async initializeSessionConfig(sessionId, cwd, mcpServers, authDetails) {
|
|
15189
|
-
const selectedAuthType = this.settings.merged.security.auth.selectedType || (authDetails.baseUrl || process.env["GOOGLE_GEMINI_BASE_URL"] ?
|
|
15205
|
+
const selectedAuthType = this.settings.merged.security.auth.selectedType || (authDetails.baseUrl || process.env["GOOGLE_GEMINI_BASE_URL"] ? AuthType.GATEWAY : void 0);
|
|
15190
15206
|
if (!selectedAuthType) {
|
|
15191
15207
|
throw RequestError.authRequired();
|
|
15192
15208
|
}
|
|
@@ -15287,12 +15303,12 @@ var GeminiAgent = class {
|
|
|
15287
15303
|
}
|
|
15288
15304
|
const authMethods = [
|
|
15289
15305
|
{
|
|
15290
|
-
id:
|
|
15306
|
+
id: AuthType.LOGIN_WITH_GOOGLE,
|
|
15291
15307
|
name: "Log in with Google",
|
|
15292
15308
|
description: "Log in with your Google account"
|
|
15293
15309
|
},
|
|
15294
15310
|
{
|
|
15295
|
-
id:
|
|
15311
|
+
id: AuthType.USE_GEMINI,
|
|
15296
15312
|
name: "Gemini API key",
|
|
15297
15313
|
description: "Use an API key with Gemini Developer API",
|
|
15298
15314
|
_meta: {
|
|
@@ -15302,12 +15318,12 @@ var GeminiAgent = class {
|
|
|
15302
15318
|
}
|
|
15303
15319
|
},
|
|
15304
15320
|
{
|
|
15305
|
-
id:
|
|
15321
|
+
id: AuthType.USE_VERTEX_AI,
|
|
15306
15322
|
name: "Vertex AI",
|
|
15307
15323
|
description: "Use an API key with Vertex AI GenAI API"
|
|
15308
15324
|
},
|
|
15309
15325
|
{
|
|
15310
|
-
id:
|
|
15326
|
+
id: AuthType.GATEWAY,
|
|
15311
15327
|
name: "AI API Gateway",
|
|
15312
15328
|
description: "Use a custom AI API Gateway",
|
|
15313
15329
|
_meta: {
|
|
@@ -15480,7 +15496,7 @@ async function validateNonInteractiveAuth(configuredAuthType, useExternalAuth, n
|
|
|
15480
15496
|
}
|
|
15481
15497
|
return authType;
|
|
15482
15498
|
} catch (error) {
|
|
15483
|
-
if (nonInteractiveConfig.getOutputFormat() ===
|
|
15499
|
+
if (nonInteractiveConfig.getOutputFormat() === OutputFormat.JSON) {
|
|
15484
15500
|
handleError(
|
|
15485
15501
|
error instanceof Error ? error : new Error(String(error)),
|
|
15486
15502
|
nonInteractiveConfig,
|
|
@@ -15675,10 +15691,10 @@ var SlashCommandConflictHandler = class {
|
|
|
15675
15691
|
this.handleConflicts = this.handleConflicts.bind(this);
|
|
15676
15692
|
}
|
|
15677
15693
|
start() {
|
|
15678
|
-
coreEvents.on(
|
|
15694
|
+
coreEvents.on(CoreEvent.SlashCommandConflicts, this.handleConflicts);
|
|
15679
15695
|
}
|
|
15680
15696
|
stop() {
|
|
15681
|
-
coreEvents.off(
|
|
15697
|
+
coreEvents.off(CoreEvent.SlashCommandConflicts, this.handleConflicts);
|
|
15682
15698
|
if (this.flushTimeout) {
|
|
15683
15699
|
clearTimeout(this.flushTimeout);
|
|
15684
15700
|
this.flushTimeout = null;
|
|
@@ -15959,7 +15975,7 @@ async function resolveSessionId(resumeArg, sessionIdArg, sessionFileArg) {
|
|
|
15959
15975
|
}
|
|
15960
15976
|
}
|
|
15961
15977
|
async function startInteractiveUI(config, settings, startupWarnings, workspaceRoot = process.cwd(), resumedSessionData, initializationResult) {
|
|
15962
|
-
const { startInteractiveUI: doStartUI } = await import("./interactiveCli-
|
|
15978
|
+
const { startInteractiveUI: doStartUI } = await import("./interactiveCli-LU4ELYJR.js");
|
|
15963
15979
|
await doStartUI(
|
|
15964
15980
|
config,
|
|
15965
15981
|
settings,
|
|
@@ -16062,12 +16078,12 @@ async function main() {
|
|
|
16062
16078
|
dns.setDefaultResultOrder(
|
|
16063
16079
|
validateDnsResolutionOrder(settings.merged.advanced.dnsResolutionOrder)
|
|
16064
16080
|
);
|
|
16065
|
-
if (!settings.merged.security.auth.selectedType || settings.merged.security.auth.selectedType ===
|
|
16081
|
+
if (!settings.merged.security.auth.selectedType || settings.merged.security.auth.selectedType === AuthType.LEGACY_CLOUD_SHELL) {
|
|
16066
16082
|
if (process.env["CLOUD_SHELL"] === "true" || process.env["GEMINI_CLI_USE_COMPUTE_ADC"] === "true") {
|
|
16067
16083
|
settings.setValue(
|
|
16068
16084
|
"User" /* User */,
|
|
16069
16085
|
"security.auth.selectedType",
|
|
16070
|
-
|
|
16086
|
+
AuthType.COMPUTE_ADC
|
|
16071
16087
|
);
|
|
16072
16088
|
}
|
|
16073
16089
|
}
|
|
@@ -16168,7 +16184,7 @@ ${finalArgs[promptIndex + 1]}`;
|
|
|
16168
16184
|
await config.storage.initialize();
|
|
16169
16185
|
adminControlsListner.setConfig(config);
|
|
16170
16186
|
if (config.isInteractive() && settings.merged.general.devtools) {
|
|
16171
|
-
const { setupInitialActivityLogger } = await import("./devtoolsService-
|
|
16187
|
+
const { setupInitialActivityLogger } = await import("./devtoolsService-MTKVT52L.js");
|
|
16172
16188
|
setupInitialActivityLogger(config);
|
|
16173
16189
|
}
|
|
16174
16190
|
registerTelemetryConfig(config);
|
|
@@ -16176,7 +16192,7 @@ ${finalArgs[promptIndex + 1]}`;
|
|
|
16176
16192
|
const messageBus = config.getMessageBus();
|
|
16177
16193
|
createPolicyUpdater2(policyEngine, messageBus, config.storage);
|
|
16178
16194
|
registerCleanup(async () => {
|
|
16179
|
-
await config?.getHookSystem()?.fireSessionEndEvent(
|
|
16195
|
+
await config?.getHookSystem()?.fireSessionEndEvent(SessionEndReason.Exit);
|
|
16180
16196
|
});
|
|
16181
16197
|
if (!config.getAcpMode()) {
|
|
16182
16198
|
registerCleanup(consolePatcher.cleanup);
|
|
@@ -16227,7 +16243,7 @@ ${finalArgs[promptIndex + 1]}`;
|
|
|
16227
16243
|
const initAppHandle = startupProfiler.start("initialize_app");
|
|
16228
16244
|
const initializationResult = await initializeApp(config, settings);
|
|
16229
16245
|
initAppHandle?.end();
|
|
16230
|
-
import("./liteRtServerManager-
|
|
16246
|
+
import("./liteRtServerManager-D6QKXOSW.js").then(({ LiteRtServerManager }) => {
|
|
16231
16247
|
const mergedGemma = settings.merged.experimental?.gemmaModelRouter;
|
|
16232
16248
|
if (!mergedGemma) return;
|
|
16233
16249
|
const userGemma = settings.forScope("User" /* User */).settings.experimental?.gemmaModelRouter;
|
|
@@ -16237,7 +16253,7 @@ ${finalArgs[promptIndex + 1]}`;
|
|
|
16237
16253
|
autoStartServer: userGemma?.autoStartServer
|
|
16238
16254
|
});
|
|
16239
16255
|
}).catch((e) => debugLogger.warn("LiteRT auto-start import failed:", e));
|
|
16240
|
-
if (settings.merged.security.auth.selectedType ===
|
|
16256
|
+
if (settings.merged.security.auth.selectedType === AuthType.LOGIN_WITH_GOOGLE && config.isBrowserLaunchSuppressed()) {
|
|
16241
16257
|
await getOauthClient(settings.merged.security.auth.selectedType, config);
|
|
16242
16258
|
}
|
|
16243
16259
|
if (config.getAcpMode()) {
|
|
@@ -16253,7 +16269,7 @@ ${finalArgs[promptIndex + 1]}`;
|
|
|
16253
16269
|
...rawStartupWarnings.map((message) => ({
|
|
16254
16270
|
id: `startup-${createHash2("sha256").update(message).digest("hex").substring(0, 16)}`,
|
|
16255
16271
|
message,
|
|
16256
|
-
priority:
|
|
16272
|
+
priority: WarningPriority.High
|
|
16257
16273
|
})),
|
|
16258
16274
|
...await getUserStartupWarnings(settings.merged, void 0, {
|
|
16259
16275
|
isAlternateBuffer: useAlternateBuffer
|
|
@@ -16290,7 +16306,7 @@ ${finalArgs[promptIndex + 1]}`;
|
|
|
16290
16306
|
${input}` : stdinData;
|
|
16291
16307
|
}
|
|
16292
16308
|
}
|
|
16293
|
-
const sessionStartSource = resumedSessionData ?
|
|
16309
|
+
const sessionStartSource = resumedSessionData ? SessionStartSource.Resume : SessionStartSource.Startup;
|
|
16294
16310
|
const hookSystem = config?.getHookSystem();
|
|
16295
16311
|
if (hookSystem) {
|
|
16296
16312
|
const result = await hookSystem.fireSessionStartEvent(sessionStartSource);
|
|
@@ -16347,8 +16363,8 @@ ${input}` : wrappedContext;
|
|
|
16347
16363
|
}
|
|
16348
16364
|
}
|
|
16349
16365
|
function initializeOutputListenersAndFlush(config) {
|
|
16350
|
-
if (coreEvents.listenerCount(
|
|
16351
|
-
coreEvents.on(
|
|
16366
|
+
if (coreEvents.listenerCount(CoreEvent.Output) === 0) {
|
|
16367
|
+
coreEvents.on(CoreEvent.Output, (payload) => {
|
|
16352
16368
|
if (payload.isStderr) {
|
|
16353
16369
|
writeToStderr(payload.chunk, payload.encoding);
|
|
16354
16370
|
} else {
|
|
@@ -16356,8 +16372,8 @@ function initializeOutputListenersAndFlush(config) {
|
|
|
16356
16372
|
}
|
|
16357
16373
|
});
|
|
16358
16374
|
}
|
|
16359
|
-
if (coreEvents.listenerCount(
|
|
16360
|
-
coreEvents.on(
|
|
16375
|
+
if (coreEvents.listenerCount(CoreEvent.ConsoleLog) === 0) {
|
|
16376
|
+
coreEvents.on(CoreEvent.ConsoleLog, (payload) => {
|
|
16361
16377
|
if (payload.type === "error" || payload.type === "warn") {
|
|
16362
16378
|
writeToStderr(payload.content + "\n");
|
|
16363
16379
|
} else {
|
|
@@ -16365,8 +16381,8 @@ function initializeOutputListenersAndFlush(config) {
|
|
|
16365
16381
|
}
|
|
16366
16382
|
});
|
|
16367
16383
|
}
|
|
16368
|
-
if (coreEvents.listenerCount(
|
|
16369
|
-
coreEvents.on(
|
|
16384
|
+
if (coreEvents.listenerCount(CoreEvent.UserFeedback) === 0) {
|
|
16385
|
+
coreEvents.on(CoreEvent.UserFeedback, (payload) => {
|
|
16370
16386
|
writeToStderr(payload.message + "\n");
|
|
16371
16387
|
});
|
|
16372
16388
|
}
|
|
@@ -16374,7 +16390,7 @@ function initializeOutputListenersAndFlush(config) {
|
|
|
16374
16390
|
const forceToStderr = outputFormat === "json";
|
|
16375
16391
|
coreEvents.drainBacklogs(
|
|
16376
16392
|
(event, args) => {
|
|
16377
|
-
if (forceToStderr && event ===
|
|
16393
|
+
if (forceToStderr && event === CoreEvent.Output) {
|
|
16378
16394
|
const payload = args[0];
|
|
16379
16395
|
if (!payload.isStderr) {
|
|
16380
16396
|
return {
|