@google/gemini-cli 0.67.0 → 0.69.0-preview.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -24
- package/bundle/{chunk-IDJ4QXBF.js → chunk-2KKDGWF2.js} +1 -1
- package/bundle/{chunk-7LX6MRZ6.js → chunk-2ONJU4V7.js} +1 -1
- package/bundle/chunk-3HEOCQDN.js +65 -0
- package/bundle/{chunk-VO6PFWLY.js → chunk-4SOPZCNA.js} +29 -15
- package/bundle/{chunk-56IGTM4O.js → chunk-6KCLIS6W.js} +1 -1
- package/bundle/{chunk-2E3ETS5J.js → chunk-BRHBBQC5.js} +2 -2
- package/bundle/{chunk-M73CYIV5.js → chunk-C5BED6L6.js} +2 -2
- package/bundle/{chunk-VK766A3F.js → chunk-CGQSFR2I.js} +7 -2
- package/bundle/{chunk-OJ62HCXG.js → chunk-CWHEOJXF.js} +7 -2
- package/bundle/{chunk-LAR4JEC7.js → chunk-DWMZSQYG.js} +6050 -2877
- package/bundle/{chunk-QTXJG3I3.js → chunk-GDCMMKZ2.js} +1 -1
- package/bundle/{chunk-YUO7RUF4.js → chunk-GQ7FZNO2.js} +1 -1
- package/bundle/{chunk-GBUWHRK6.js → chunk-JJWPYMIO.js} +3 -3
- package/bundle/{chunk-NGQU3QTQ.js → chunk-KUXCUQKX.js} +5859 -2837
- package/bundle/{chunk-P62CI7AR.js → chunk-LYKP3S67.js} +29 -15
- package/bundle/{chunk-O7MGOE2I.js → chunk-MP4TVGOP.js} +6050 -2877
- package/bundle/{chunk-IGE3G3WZ.js → chunk-PH5XENTH.js} +1 -1
- package/bundle/{chunk-CJFBYU4J.js → chunk-RBDD6IBU.js} +937 -327
- package/bundle/{chunk-5RNHNFYV.js → chunk-SYOIMUZI.js} +937 -327
- package/bundle/{chunk-BW65QRZA.js → chunk-U3FFDEKY.js} +29 -15
- package/bundle/{chunk-MQNW2IRI.js → chunk-U5FJ6OGB.js} +2 -2
- package/bundle/{chunk-PUNFASKY.js → chunk-UAHZWXSG.js} +7 -2
- package/bundle/chunk-UW3ZS3BH.js +65 -0
- package/bundle/{chunk-4JH2G4F4.js → chunk-V7L3FMBE.js} +3 -3
- package/bundle/chunk-VQTELFV3.js +65 -0
- package/bundle/{chunk-QA5FT4VY.js → chunk-YODS6HR2.js} +3 -3
- package/bundle/{chunk-XETHQLRU.js → chunk-YP5TA33N.js} +937 -327
- package/bundle/{cleanup-B6AOSVD4.js → cleanup-3T2KXSP4.js} +2 -2
- package/bundle/{cleanup-BRFB47DL.js → cleanup-NNQCI4KC.js} +2 -2
- package/bundle/{cleanup-S5QFYCEP.js → cleanup-TA4VYDXQ.js} +2 -2
- package/bundle/{core-N27LU4DK.js → core-6XF5EO7Z.js} +37 -1
- package/bundle/{dist-E6RCLXQU.js → core-TUJHM7E7.js} +37 -1
- package/bundle/{devtoolsService-6V46WMXX.js → devtoolsService-7EMPANTX.js} +2 -2
- package/bundle/{devtoolsService-E74ZMDMM.js → devtoolsService-I7WFRUEA.js} +2 -2
- package/bundle/{devtoolsService-EFJXZRFD.js → devtoolsService-RCBUZGYD.js} +2 -2
- package/bundle/{core-GTUUQBGE.js → dist-OSQFIX7F.js} +37 -1
- package/bundle/docs/changelogs/index.md +42 -0
- package/bundle/docs/changelogs/latest.md +89 -91
- package/bundle/docs/changelogs/preview.md +106 -90
- package/bundle/docs/cli/sandbox.md +8 -2
- package/bundle/docs/cli/themes.md +56 -8
- package/bundle/docs/cli/trusted-folders.md +13 -0
- package/bundle/docs/extensions/releasing.md +32 -0
- package/bundle/docs/reference/commands.md +4 -0
- package/bundle/docs/reference/configuration.md +10 -10
- package/bundle/docs/reference/policy-engine.md +6 -0
- package/bundle/formatError-KEQ3HU3Y.js +14 -0
- package/bundle/formatError-LJFIC7G3.js +14 -0
- package/bundle/formatError-MIUNQEYE.js +14 -0
- package/bundle/{gemini-QWDTSJTS.js → gemini-22ON2CZG.js} +601 -142
- package/bundle/{gemini-4JPKPLQN.js → gemini-HLS52ZNZ.js} +601 -142
- package/bundle/{gemini-VF5FS3OM.js → gemini-ZZZEFPSK.js} +601 -142
- package/bundle/gemini.js +14 -13
- package/bundle/{interactiveCli-QJZZISQQ.js → interactiveCli-5HMWVTK2.js} +2967 -2329
- package/bundle/{interactiveCli-FQ3YKGOG.js → interactiveCli-HQBE3C3C.js} +2967 -2329
- package/bundle/{interactiveCli-F2YYMYTP.js → interactiveCli-NKFQZXB5.js} +2967 -2329
- package/bundle/{liteRtServerManager-JAV3GR4V.js → liteRtServerManager-2IOXWO76.js} +4 -4
- package/bundle/{liteRtServerManager-X5CCMKM6.js → liteRtServerManager-AG4Y5JMZ.js} +4 -4
- package/bundle/{liteRtServerManager-27R2M6XE.js → liteRtServerManager-OFNVXXQ4.js} +4 -4
- package/bundle/{oauth2-provider-6UCP23AQ.js → oauth2-provider-2DHNJ2S3.js} +1 -1
- package/bundle/{oauth2-provider-H2KV36NU.js → oauth2-provider-OEGXLWIL.js} +1 -1
- package/bundle/{oauth2-provider-C65IJMNQ.js → oauth2-provider-YDNSNN32.js} +1 -1
- package/bundle/policies/yolo.toml +1 -0
- package/bundle/sandbox-macos-permissive-open.sb +8 -0
- package/bundle/sandbox-macos-permissive-proxied.sb +8 -0
- package/bundle/sandbox-macos-restrictive-open.sb +1 -0
- package/bundle/sandbox-macos-restrictive-proxied.sb +1 -0
- package/bundle/sandbox-macos-strict-open.sb +1 -0
- package/bundle/sandbox-macos-strict-proxied.sb +1 -0
- package/bundle/{start-GNOA75NQ.js → start-7GJH3MKY.js} +6 -6
- package/bundle/{start-K2AYYNST.js → start-JSVKPUTV.js} +6 -6
- package/bundle/{start-E4ZL44QM.js → start-N33LF5WK.js} +6 -6
- package/package.json +1 -1
|
@@ -2,7 +2,10 @@ 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-V7L3FMBE.js";
|
|
6
|
+
import {
|
|
7
|
+
formatCliError
|
|
8
|
+
} from "./chunk-3HEOCQDN.js";
|
|
6
9
|
import {
|
|
7
10
|
BuiltinCommandLoader,
|
|
8
11
|
CommandService,
|
|
@@ -45,11 +48,11 @@ import {
|
|
|
45
48
|
updateExtension,
|
|
46
49
|
validateAuthMethod,
|
|
47
50
|
validateContextFilePath
|
|
48
|
-
} from "./chunk-
|
|
51
|
+
} from "./chunk-SYOIMUZI.js";
|
|
49
52
|
import {
|
|
50
53
|
exitCli,
|
|
51
54
|
require_source
|
|
52
|
-
} from "./chunk-
|
|
55
|
+
} from "./chunk-PH5XENTH.js";
|
|
53
56
|
import {
|
|
54
57
|
appEvents
|
|
55
58
|
} from "./chunk-5PS3AYFU.js";
|
|
@@ -89,12 +92,12 @@ import {
|
|
|
89
92
|
saveModelChange,
|
|
90
93
|
setAmbiguousCharactersWide,
|
|
91
94
|
stripAnsi
|
|
92
|
-
} from "./chunk-
|
|
95
|
+
} from "./chunk-4SOPZCNA.js";
|
|
93
96
|
import {
|
|
94
97
|
RELAUNCH_EXIT_CODE,
|
|
95
98
|
require_semver
|
|
96
|
-
} from "./chunk-
|
|
97
|
-
import "./chunk-
|
|
99
|
+
} from "./chunk-BRHBBQC5.js";
|
|
100
|
+
import "./chunk-2KKDGWF2.js";
|
|
98
101
|
import {
|
|
99
102
|
cleanupCheckpoints,
|
|
100
103
|
registerCleanup,
|
|
@@ -103,7 +106,7 @@ import {
|
|
|
103
106
|
runExitCleanup,
|
|
104
107
|
runSyncCleanup,
|
|
105
108
|
setupSignalHandlers
|
|
106
|
-
} from "./chunk-
|
|
109
|
+
} from "./chunk-UAHZWXSG.js";
|
|
107
110
|
import {
|
|
108
111
|
ASK_USER_TOOL_NAME,
|
|
109
112
|
AjvJsonSchemaValidator,
|
|
@@ -136,6 +139,8 @@ import {
|
|
|
136
139
|
FatalUntrustedWorkspaceError,
|
|
137
140
|
FileDiscoveryService,
|
|
138
141
|
FolderTrustDiscoveryService,
|
|
142
|
+
GEMINI_CLI_IN_SHELL_ENV_VAR,
|
|
143
|
+
GEMINI_CLI_NESTED_SESSION_ENV_VAR,
|
|
139
144
|
GEMINI_DIR,
|
|
140
145
|
GEMINI_MODEL_ALIAS_AUTO,
|
|
141
146
|
IdeClient,
|
|
@@ -156,6 +161,7 @@ import {
|
|
|
156
161
|
MAX_TOKENS_EXCEEDED_SUGGESTION,
|
|
157
162
|
MCPServerConfig,
|
|
158
163
|
McpError,
|
|
164
|
+
NESTED_INTERACTIVE_SESSION_ERROR,
|
|
159
165
|
OTHER_BLOCKED_MESSAGE,
|
|
160
166
|
PREVIEW_GEMINI_3_1_CUSTOM_TOOLS_MODEL,
|
|
161
167
|
PREVIEW_GEMINI_3_1_MODEL,
|
|
@@ -247,6 +253,7 @@ import {
|
|
|
247
253
|
logToolCall,
|
|
248
254
|
logUserPrompt,
|
|
249
255
|
mergeCapabilities,
|
|
256
|
+
normalizeError,
|
|
250
257
|
parseAndFormatApiError,
|
|
251
258
|
partListUnionToString,
|
|
252
259
|
patchStdio,
|
|
@@ -273,7 +280,7 @@ import {
|
|
|
273
280
|
updatePolicy,
|
|
274
281
|
writeToStderr,
|
|
275
282
|
writeToStdout
|
|
276
|
-
} from "./chunk-
|
|
283
|
+
} from "./chunk-MP4TVGOP.js";
|
|
277
284
|
import "./chunk-664ZODQF.js";
|
|
278
285
|
import "./chunk-IUUIT4SU.js";
|
|
279
286
|
import "./chunk-L6PII3GR.js";
|
|
@@ -1558,11 +1565,11 @@ var parser = new YargsParser({
|
|
|
1558
1565
|
resolve: resolve2,
|
|
1559
1566
|
// TODO: figure out a way to combine ESM and CJS coverage, such that
|
|
1560
1567
|
// we can exercise all the lines below:
|
|
1561
|
-
require: (
|
|
1568
|
+
require: (path19) => {
|
|
1562
1569
|
if (typeof __require !== "undefined") {
|
|
1563
|
-
return __require(
|
|
1564
|
-
} else if (
|
|
1565
|
-
return JSON.parse(readFileSync(
|
|
1570
|
+
return __require(path19);
|
|
1571
|
+
} else if (path19.match(/\.json$/)) {
|
|
1572
|
+
return JSON.parse(readFileSync(path19, "utf8"));
|
|
1566
1573
|
} else {
|
|
1567
1574
|
throw Error("only .json config files are supported in ESM");
|
|
1568
1575
|
}
|
|
@@ -6366,27 +6373,27 @@ import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
|
6366
6373
|
var __filename = fileURLToPath2(import.meta.url);
|
|
6367
6374
|
var __dirname2 = dirname3(__filename);
|
|
6368
6375
|
var EXAMPLES_PATH = join(__dirname2, "examples");
|
|
6369
|
-
async function pathExists(
|
|
6376
|
+
async function pathExists(path19) {
|
|
6370
6377
|
try {
|
|
6371
|
-
await access(
|
|
6378
|
+
await access(path19);
|
|
6372
6379
|
return true;
|
|
6373
6380
|
} catch {
|
|
6374
6381
|
return false;
|
|
6375
6382
|
}
|
|
6376
6383
|
}
|
|
6377
|
-
async function createDirectory(
|
|
6378
|
-
if (await pathExists(
|
|
6379
|
-
throw new Error(`Path already exists: ${
|
|
6384
|
+
async function createDirectory(path19) {
|
|
6385
|
+
if (await pathExists(path19)) {
|
|
6386
|
+
throw new Error(`Path already exists: ${path19}`);
|
|
6380
6387
|
}
|
|
6381
|
-
await mkdir(
|
|
6388
|
+
await mkdir(path19, { recursive: true });
|
|
6382
6389
|
}
|
|
6383
|
-
async function copyDirectory(template,
|
|
6384
|
-
await createDirectory(
|
|
6390
|
+
async function copyDirectory(template, path19) {
|
|
6391
|
+
await createDirectory(path19);
|
|
6385
6392
|
const examplePath = join(EXAMPLES_PATH, template);
|
|
6386
6393
|
const entries = await readdir(examplePath, { withFileTypes: true });
|
|
6387
6394
|
for (const entry of entries) {
|
|
6388
6395
|
const srcPath = join(examplePath, entry.name);
|
|
6389
|
-
const destPath = join(
|
|
6396
|
+
const destPath = join(path19, entry.name);
|
|
6390
6397
|
await cp(srcPath, destPath, { recursive: true });
|
|
6391
6398
|
}
|
|
6392
6399
|
}
|
|
@@ -6496,6 +6503,57 @@ async function validateExtension(args) {
|
|
|
6496
6503
|
`Warning: Version '${extensionConfig.version}' does not appear to be standard semver (e.g., 1.0.0).`
|
|
6497
6504
|
);
|
|
6498
6505
|
}
|
|
6506
|
+
if (extensionConfig.mcpServers) {
|
|
6507
|
+
if (typeof extensionConfig.mcpServers !== "object" || extensionConfig.mcpServers === null || Array.isArray(extensionConfig.mcpServers)) {
|
|
6508
|
+
errors.push('The "mcpServers" field must be an object.');
|
|
6509
|
+
} else {
|
|
6510
|
+
for (const [serverName, serverConfig] of Object.entries(
|
|
6511
|
+
extensionConfig.mcpServers
|
|
6512
|
+
)) {
|
|
6513
|
+
if (typeof serverConfig !== "object" || serverConfig === null || Array.isArray(serverConfig)) {
|
|
6514
|
+
errors.push(
|
|
6515
|
+
`MCP server configuration for "${serverName}" must be an object.`
|
|
6516
|
+
);
|
|
6517
|
+
continue;
|
|
6518
|
+
}
|
|
6519
|
+
const hasCommand = typeof serverConfig.command === "string" && serverConfig.command.trim().length > 0;
|
|
6520
|
+
const hasUrl = typeof serverConfig.url === "string" && serverConfig.url.trim().length > 0;
|
|
6521
|
+
const hasHttpUrl = typeof serverConfig.httpUrl === "string" && serverConfig.httpUrl.trim().length > 0;
|
|
6522
|
+
const hasTcp = typeof serverConfig.tcp === "string" && serverConfig.tcp.trim().length > 0 || typeof serverConfig.tcp === "number";
|
|
6523
|
+
if (!hasCommand && !hasUrl && !hasHttpUrl && !hasTcp) {
|
|
6524
|
+
errors.push(
|
|
6525
|
+
`MCP server "${serverName}" must specify a transport (e.g., "command", "url", or "httpUrl").`
|
|
6526
|
+
);
|
|
6527
|
+
}
|
|
6528
|
+
if (hasHttpUrl) {
|
|
6529
|
+
warnings.push(
|
|
6530
|
+
`MCP server "${serverName}" uses deprecated "httpUrl". Consider using "url" with "type": "http" instead.`
|
|
6531
|
+
);
|
|
6532
|
+
}
|
|
6533
|
+
const errorPrefix = `MCP server "${serverName}" specifies an invalid `;
|
|
6534
|
+
if (hasUrl && serverConfig.url) {
|
|
6535
|
+
const hasPlaceholder = serverConfig.url.includes("$");
|
|
6536
|
+
if (!hasPlaceholder) {
|
|
6537
|
+
try {
|
|
6538
|
+
new URL(serverConfig.url);
|
|
6539
|
+
} catch {
|
|
6540
|
+
errors.push(`${errorPrefix}URL: "${serverConfig.url}".`);
|
|
6541
|
+
}
|
|
6542
|
+
}
|
|
6543
|
+
}
|
|
6544
|
+
if (hasHttpUrl && serverConfig.httpUrl) {
|
|
6545
|
+
const hasPlaceholder = serverConfig.httpUrl.includes("$");
|
|
6546
|
+
if (!hasPlaceholder) {
|
|
6547
|
+
try {
|
|
6548
|
+
new URL(serverConfig.httpUrl);
|
|
6549
|
+
} catch {
|
|
6550
|
+
errors.push(`${errorPrefix}httpUrl: "${serverConfig.httpUrl}".`);
|
|
6551
|
+
}
|
|
6552
|
+
}
|
|
6553
|
+
}
|
|
6554
|
+
}
|
|
6555
|
+
}
|
|
6556
|
+
}
|
|
6499
6557
|
if (warnings.length > 0) {
|
|
6500
6558
|
debugLogger.warn("Validation warnings:");
|
|
6501
6559
|
for (const warning of warnings) {
|
|
@@ -6667,7 +6725,7 @@ async function handleEnable3(args) {
|
|
|
6667
6725
|
const result = enableSkill(settings, name);
|
|
6668
6726
|
const feedback = renderSkillActionFeedback(
|
|
6669
6727
|
result,
|
|
6670
|
-
(label,
|
|
6728
|
+
(label, path19) => `${import_chalk5.default.bold(label)} (${import_chalk5.default.dim(path19)})`
|
|
6671
6729
|
);
|
|
6672
6730
|
debugLogger.log(feedback);
|
|
6673
6731
|
}
|
|
@@ -6697,7 +6755,7 @@ async function handleDisable3(args) {
|
|
|
6697
6755
|
const result = disableSkill(settings, name, scope);
|
|
6698
6756
|
const feedback = renderSkillActionFeedback(
|
|
6699
6757
|
result,
|
|
6700
|
-
(label,
|
|
6758
|
+
(label, path19) => `${import_chalk6.default.bold(label)} (${import_chalk6.default.dim(path19)})`
|
|
6701
6759
|
);
|
|
6702
6760
|
debugLogger.log(feedback);
|
|
6703
6761
|
}
|
|
@@ -6940,8 +6998,10 @@ var EVENT_MAPPING = {
|
|
|
6940
6998
|
PostToolUse: "AfterTool",
|
|
6941
6999
|
UserPromptSubmit: "BeforeAgent",
|
|
6942
7000
|
Stop: "AfterAgent",
|
|
6943
|
-
|
|
7001
|
+
SubagentStop: "AfterAgent",
|
|
6944
7002
|
// Gemini doesn't have sub-agents, map to AfterAgent
|
|
7003
|
+
SubAgentStop: "AfterAgent",
|
|
7004
|
+
// Fallback for alternate casing
|
|
6945
7005
|
SessionStart: "SessionStart",
|
|
6946
7006
|
SessionEnd: "SessionEnd",
|
|
6947
7007
|
PreCompact: "PreCompress",
|
|
@@ -7029,7 +7089,10 @@ function migrateClaudeHooks(claudeConfig) {
|
|
|
7029
7089
|
}
|
|
7030
7090
|
return migratedDef;
|
|
7031
7091
|
});
|
|
7032
|
-
geminiHooks[geminiEventName] =
|
|
7092
|
+
geminiHooks[geminiEventName] = [
|
|
7093
|
+
...geminiHooks[geminiEventName] || [],
|
|
7094
|
+
...migratedDefinitions
|
|
7095
|
+
];
|
|
7033
7096
|
}
|
|
7034
7097
|
return geminiHooks;
|
|
7035
7098
|
}
|
|
@@ -7822,6 +7885,16 @@ var RequestPermissionResponseSchema = external_exports.object({
|
|
|
7822
7885
|
})
|
|
7823
7886
|
])
|
|
7824
7887
|
});
|
|
7888
|
+
function isAnsiOutput(value) {
|
|
7889
|
+
return Array.isArray(value) && value.every(
|
|
7890
|
+
(line) => Array.isArray(line) && line.every(
|
|
7891
|
+
(token) => typeof token === "object" && token !== null && "text" in token && typeof token.text === "string"
|
|
7892
|
+
)
|
|
7893
|
+
);
|
|
7894
|
+
}
|
|
7895
|
+
function ansiOutputToPlainText(ansiOutput) {
|
|
7896
|
+
return ansiOutput.map((line) => line.map((token) => token.text).join("")).join("\n").trim();
|
|
7897
|
+
}
|
|
7825
7898
|
function toToolCallContent(toolResult) {
|
|
7826
7899
|
if (toolResult.error?.message) {
|
|
7827
7900
|
throw new Error(toolResult.error.message);
|
|
@@ -7832,6 +7905,12 @@ function toToolCallContent(toolResult) {
|
|
|
7832
7905
|
type: "content",
|
|
7833
7906
|
content: { type: "text", text: toolResult.returnDisplay }
|
|
7834
7907
|
};
|
|
7908
|
+
} else if (isAnsiOutput(toolResult.returnDisplay)) {
|
|
7909
|
+
const text = ansiOutputToPlainText(toolResult.returnDisplay);
|
|
7910
|
+
if (!text) {
|
|
7911
|
+
return null;
|
|
7912
|
+
}
|
|
7913
|
+
return { type: "content", content: { type: "text", text } };
|
|
7835
7914
|
} else {
|
|
7836
7915
|
if ("fileName" in toolResult.returnDisplay) {
|
|
7837
7916
|
return {
|
|
@@ -8308,7 +8387,7 @@ async function loadSandboxConfig(settings, argv) {
|
|
|
8308
8387
|
}
|
|
8309
8388
|
const command2 = getSandboxCommand(sandboxValue);
|
|
8310
8389
|
const packageJson = await getPackageJson(__dirname3);
|
|
8311
|
-
const image = process.env["GEMINI_SANDBOX_IMAGE"] ?? "us-docker.pkg.dev/gemini-code-dev/gemini-cli/sandbox:0.
|
|
8390
|
+
const image = process.env["GEMINI_SANDBOX_IMAGE"] ?? "us-docker.pkg.dev/gemini-code-dev/gemini-cli/sandbox:0.69.0-preview.0" ?? customImage ?? packageJson?.config?.sandboxImageUri;
|
|
8312
8391
|
const isNative = command2 === "windows-native" || command2 === "sandbox-exec" || command2 === "lxc";
|
|
8313
8392
|
return command2 && (image || isNative) ? { enabled: true, allowedPaths, networkAccess, command: command2, image } : void 0;
|
|
8314
8393
|
}
|
|
@@ -8711,6 +8790,40 @@ async function parseArguments(settings) {
|
|
|
8711
8790
|
} else if (typeof queryArg === "string") {
|
|
8712
8791
|
q = queryArg;
|
|
8713
8792
|
}
|
|
8793
|
+
const trimmedQuery = q?.trim() ?? "";
|
|
8794
|
+
const rawQueryTokens = trimmedQuery.length > 0 ? trimmedQuery.split(/\s+/) : [];
|
|
8795
|
+
const firstQueryToken = rawQueryTokens[0]?.toLowerCase();
|
|
8796
|
+
const secondQueryToken = rawQueryTokens[1]?.toLowerCase();
|
|
8797
|
+
const isQuotedPrompt = rawQueryTokens.length > 1 && process3.argv.some((arg) => arg.trim() === trimmedQuery);
|
|
8798
|
+
const isInvalidConfigSubcommand = !result["isCommand"] && (firstQueryToken === "config" && (secondQueryToken === void 0 || secondQueryToken.startsWith("-") || [
|
|
8799
|
+
"set",
|
|
8800
|
+
"get",
|
|
8801
|
+
"list",
|
|
8802
|
+
"delete",
|
|
8803
|
+
"unset",
|
|
8804
|
+
"edit",
|
|
8805
|
+
"show",
|
|
8806
|
+
"default-model",
|
|
8807
|
+
"model"
|
|
8808
|
+
].includes(secondQueryToken)) || (firstQueryToken === "set" || firstQueryToken === "model") && secondQueryToken !== void 0 && ["set", "get", "list", "default-model", "model"].includes(
|
|
8809
|
+
secondQueryToken
|
|
8810
|
+
)) && !isQuotedPrompt;
|
|
8811
|
+
const isInNestedShell = process3.env[GEMINI_CLI_IN_SHELL_ENV_VAR] === "1" || process3.env[GEMINI_CLI_NESTED_SESSION_ENV_VAR] === "1";
|
|
8812
|
+
if (isInNestedShell) {
|
|
8813
|
+
const isAllowedNonInteractive = Boolean(result["isCommand"]) || Boolean(result["listModels"]) || Boolean(result["list-models"]) || Boolean(result["listExtensions"]) || Boolean(result["list-extensions"]) || Boolean(result["listSessions"]) || Boolean(result["list-sessions"]) || Boolean(result["deleteSession"]) || Boolean(result["delete-session"]) || Boolean(result["prompt"]) && !result["promptInteractive"] && !result["prompt-interactive"] && !isInvalidConfigSubcommand;
|
|
8814
|
+
if (!isAllowedNonInteractive) {
|
|
8815
|
+
debugLogger.error(NESTED_INTERACTIVE_SESSION_ERROR);
|
|
8816
|
+
await runExitCleanup();
|
|
8817
|
+
process3.exit(1);
|
|
8818
|
+
}
|
|
8819
|
+
}
|
|
8820
|
+
if (isInvalidConfigSubcommand) {
|
|
8821
|
+
debugLogger.error(
|
|
8822
|
+
`Error: Unknown command "${rawQueryTokens[0]}". To switch models or update settings, use built-in slash commands (/model, /settings).`
|
|
8823
|
+
);
|
|
8824
|
+
await runExitCleanup();
|
|
8825
|
+
process3.exit(1);
|
|
8826
|
+
}
|
|
8714
8827
|
if (q && !result["prompt"]) {
|
|
8715
8828
|
if (!isHeadlessMode()) {
|
|
8716
8829
|
startupMessages.push(
|
|
@@ -9041,12 +9154,13 @@ async function loadCliConfig(settings, sessionId, argv, options = {}) {
|
|
|
9041
9154
|
usageStatisticsEnabled: settings.privacy?.usageStatisticsEnabled,
|
|
9042
9155
|
fileFiltering,
|
|
9043
9156
|
checkpointing: settings.general?.checkpointing?.enabled,
|
|
9044
|
-
proxy: process3.env["HTTPS_PROXY"] || process3.env["https_proxy"] || process3.env["HTTP_PROXY"] || process3.env["http_proxy"],
|
|
9157
|
+
proxy: process3.env["HTTPS_PROXY"] || process3.env["https_proxy"] || process3.env["HTTP_PROXY"] || process3.env["http_proxy"] || process3.env["ALL_PROXY"] || process3.env["all_proxy"],
|
|
9045
9158
|
cwd,
|
|
9046
9159
|
fileDiscoveryService: fileService,
|
|
9047
9160
|
bugCommand: settings.advanced?.bugCommand,
|
|
9048
9161
|
model: resolvedModel,
|
|
9049
9162
|
maxSessionTurns: settings.model?.maxSessionTurns,
|
|
9163
|
+
requestTimeoutMs: settings.model?.requestTimeoutMs,
|
|
9050
9164
|
listExtensions: argv.listExtensions || false,
|
|
9051
9165
|
listSessions: argv.listSessions || false,
|
|
9052
9166
|
deleteSession: argv.deleteSession,
|
|
@@ -9177,22 +9291,30 @@ async function resolveWorktreeSettings(cwd) {
|
|
|
9177
9291
|
}
|
|
9178
9292
|
|
|
9179
9293
|
// packages/cli/src/utils/readStdin.ts
|
|
9180
|
-
function
|
|
9181
|
-
|
|
9182
|
-
if (buf.length <= maxBytes) return
|
|
9294
|
+
function truncateUtf8Buffer(buf, maxBytes) {
|
|
9295
|
+
if (maxBytes <= 0) return "";
|
|
9296
|
+
if (buf.length <= maxBytes) return buf.toString("utf8");
|
|
9183
9297
|
let end = maxBytes;
|
|
9184
9298
|
while (end > 0 && (buf[end] & 192) === 128) {
|
|
9185
9299
|
end--;
|
|
9186
9300
|
}
|
|
9187
9301
|
return buf.subarray(0, end).toString("utf8");
|
|
9188
9302
|
}
|
|
9303
|
+
function truncateUtf8Bytes(str, maxBytes) {
|
|
9304
|
+
if (maxBytes <= 0) return "";
|
|
9305
|
+
return truncateUtf8Buffer(Buffer.from(str, "utf8"), maxBytes);
|
|
9306
|
+
}
|
|
9189
9307
|
async function readStdin() {
|
|
9308
|
+
if (process.stdin.isTTY || process.stdin.destroyed || process.stdin.readableEnded) {
|
|
9309
|
+
return "";
|
|
9310
|
+
}
|
|
9190
9311
|
const MAX_STDIN_SIZE = 8 * 1024 * 1024;
|
|
9191
9312
|
return new Promise((resolve10, reject) => {
|
|
9192
9313
|
let data = "";
|
|
9193
9314
|
let totalSize = 0;
|
|
9315
|
+
let settled = false;
|
|
9194
9316
|
process.stdin.setEncoding("utf8");
|
|
9195
|
-
const pipedInputShouldBeAvailableInMs =
|
|
9317
|
+
const pipedInputShouldBeAvailableInMs = 1e3;
|
|
9196
9318
|
let pipedInputTimerId = setTimeout(() => {
|
|
9197
9319
|
onEnd();
|
|
9198
9320
|
}, pipedInputShouldBeAvailableInMs);
|
|
@@ -9203,26 +9325,46 @@ async function readStdin() {
|
|
|
9203
9325
|
clearTimeout(pipedInputTimerId);
|
|
9204
9326
|
pipedInputTimerId = null;
|
|
9205
9327
|
}
|
|
9206
|
-
|
|
9328
|
+
let chunkByteLength;
|
|
9329
|
+
let chunkBuffer;
|
|
9330
|
+
let chunkStr = "";
|
|
9331
|
+
if (Buffer.isBuffer(chunk)) {
|
|
9332
|
+
chunkBuffer = chunk;
|
|
9333
|
+
chunkByteLength = chunk.length;
|
|
9334
|
+
} else {
|
|
9335
|
+
chunkStr = typeof chunk === "string" ? chunk : String(chunk);
|
|
9336
|
+
chunkByteLength = Buffer.byteLength(chunkStr, "utf8");
|
|
9337
|
+
}
|
|
9207
9338
|
if (totalSize + chunkByteLength > MAX_STDIN_SIZE) {
|
|
9208
9339
|
const remainingBytes = MAX_STDIN_SIZE - totalSize;
|
|
9209
|
-
data += truncateUtf8Bytes(
|
|
9340
|
+
data += chunkBuffer ? truncateUtf8Buffer(chunkBuffer, remainingBytes) : truncateUtf8Bytes(chunkStr, remainingBytes);
|
|
9210
9341
|
debugLogger.warn(
|
|
9211
9342
|
`Warning: stdin input truncated to ${MAX_STDIN_SIZE} bytes.`
|
|
9212
9343
|
);
|
|
9213
|
-
|
|
9214
|
-
|
|
9344
|
+
cleanup();
|
|
9345
|
+
if (typeof process.stdin.unpipe === "function") {
|
|
9346
|
+
process.stdin.unpipe();
|
|
9347
|
+
}
|
|
9348
|
+
if (typeof process.stdin.pause === "function") {
|
|
9349
|
+
process.stdin.pause();
|
|
9350
|
+
}
|
|
9351
|
+
settled = true;
|
|
9352
|
+
resolve10(data);
|
|
9215
9353
|
break;
|
|
9216
9354
|
}
|
|
9217
|
-
data +=
|
|
9355
|
+
data += chunkBuffer ? chunkBuffer.toString("utf8") : chunkStr;
|
|
9218
9356
|
totalSize += chunkByteLength;
|
|
9219
9357
|
}
|
|
9220
9358
|
};
|
|
9221
9359
|
const onEnd = () => {
|
|
9360
|
+
if (settled) return;
|
|
9361
|
+
settled = true;
|
|
9222
9362
|
cleanup();
|
|
9223
9363
|
resolve10(data);
|
|
9224
9364
|
};
|
|
9225
9365
|
const onError = (err) => {
|
|
9366
|
+
if (settled) return;
|
|
9367
|
+
settled = true;
|
|
9226
9368
|
cleanup();
|
|
9227
9369
|
reject(err);
|
|
9228
9370
|
};
|
|
@@ -9251,7 +9393,7 @@ import { createHash as createHash2 } from "node:crypto";
|
|
|
9251
9393
|
import v8 from "node:v8";
|
|
9252
9394
|
import os6 from "node:os";
|
|
9253
9395
|
import dns from "node:dns";
|
|
9254
|
-
import * as
|
|
9396
|
+
import * as path18 from "node:path";
|
|
9255
9397
|
import * as fsPromises from "node:fs/promises";
|
|
9256
9398
|
|
|
9257
9399
|
// packages/cli/src/utils/sandbox.ts
|
|
@@ -9590,6 +9732,9 @@ var BUILTIN_SEATBELT_PROFILE_CONTENTS = {
|
|
|
9590
9732
|
(global-name "com.apple.SystemConfiguration.DNSConfiguration")
|
|
9591
9733
|
(global-name "com.apple.SystemConfiguration.configd")
|
|
9592
9734
|
)
|
|
9735
|
+
(allow mach-lookup
|
|
9736
|
+
(global-name "com.apple.FSEvents")
|
|
9737
|
+
)
|
|
9593
9738
|
(allow system-socket
|
|
9594
9739
|
(require-all
|
|
9595
9740
|
(socket-domain AF_SYSTEM)
|
|
@@ -9756,6 +9901,9 @@ var BUILTIN_SEATBELT_PROFILE_CONTENTS = {
|
|
|
9756
9901
|
(global-name "com.apple.SystemConfiguration.DNSConfiguration")
|
|
9757
9902
|
(global-name "com.apple.SystemConfiguration.configd")
|
|
9758
9903
|
)
|
|
9904
|
+
(allow mach-lookup
|
|
9905
|
+
(global-name "com.apple.FSEvents")
|
|
9906
|
+
)
|
|
9759
9907
|
(allow system-socket
|
|
9760
9908
|
(require-all
|
|
9761
9909
|
(socket-domain AF_SYSTEM)
|
|
@@ -9844,6 +9992,7 @@ var BUILTIN_SEATBELT_PROFILE_CONTENTS = {
|
|
|
9844
9992
|
(allow file-read*
|
|
9845
9993
|
(literal (string-append (param "HOME_DIR") "/.gemini/settings.json"))
|
|
9846
9994
|
(literal (string-append (param "HOME_DIR") "/.gemini/keybindings.json"))
|
|
9995
|
+
(literal (string-append (param "HOME_DIR") "/.gemini/theme.json"))
|
|
9847
9996
|
)
|
|
9848
9997
|
(allow process-exec)
|
|
9849
9998
|
(allow process-fork)
|
|
@@ -9991,6 +10140,7 @@ var BUILTIN_SEATBELT_PROFILE_CONTENTS = {
|
|
|
9991
10140
|
(allow file-read*
|
|
9992
10141
|
(literal (string-append (param "HOME_DIR") "/.gemini/settings.json"))
|
|
9993
10142
|
(literal (string-append (param "HOME_DIR") "/.gemini/keybindings.json"))
|
|
10143
|
+
(literal (string-append (param "HOME_DIR") "/.gemini/theme.json"))
|
|
9994
10144
|
)
|
|
9995
10145
|
(allow process-exec)
|
|
9996
10146
|
(allow process-fork)
|
|
@@ -10141,6 +10291,7 @@ var BUILTIN_SEATBELT_PROFILE_CONTENTS = {
|
|
|
10141
10291
|
(subpath (param "CACHE_DIR"))
|
|
10142
10292
|
(literal (string-append (param "HOME_DIR") "/.gemini/settings.json"))
|
|
10143
10293
|
(literal (string-append (param "HOME_DIR") "/.gemini/keybindings.json"))
|
|
10294
|
+
(literal (string-append (param "HOME_DIR") "/.gemini/theme.json"))
|
|
10144
10295
|
(subpath (string-append (param "HOME_DIR") "/.npm"))
|
|
10145
10296
|
(subpath (string-append (param "HOME_DIR") "/.cache"))
|
|
10146
10297
|
(literal (string-append (param "HOME_DIR") "/.gitconfig"))
|
|
@@ -10314,6 +10465,7 @@ var BUILTIN_SEATBELT_PROFILE_CONTENTS = {
|
|
|
10314
10465
|
(subpath (param "CACHE_DIR"))
|
|
10315
10466
|
(literal (string-append (param "HOME_DIR") "/.gemini/settings.json"))
|
|
10316
10467
|
(literal (string-append (param "HOME_DIR") "/.gemini/keybindings.json"))
|
|
10468
|
+
(literal (string-append (param "HOME_DIR") "/.gemini/theme.json"))
|
|
10317
10469
|
(subpath (string-append (param "HOME_DIR") "/.npm"))
|
|
10318
10470
|
(subpath (string-append (param "HOME_DIR") "/.cache"))
|
|
10319
10471
|
(literal (string-append (param "HOME_DIR") "/.gitconfig"))
|
|
@@ -11376,6 +11528,45 @@ function isRecord3(value) {
|
|
|
11376
11528
|
}
|
|
11377
11529
|
var execAsync = promisify(exec);
|
|
11378
11530
|
var execFileAsync = promisify(execFile);
|
|
11531
|
+
var PODMAN_INFO_TIMEOUT_MS = 5e3;
|
|
11532
|
+
async function isPodmanRootless() {
|
|
11533
|
+
const formats = [
|
|
11534
|
+
"{{.Host.Security.Rootless}}",
|
|
11535
|
+
"{{.Host.ServiceIsRootless}}"
|
|
11536
|
+
];
|
|
11537
|
+
for (const format3 of formats) {
|
|
11538
|
+
try {
|
|
11539
|
+
const { stdout } = await execFileAsync(
|
|
11540
|
+
"podman",
|
|
11541
|
+
["info", "--format", format3],
|
|
11542
|
+
{
|
|
11543
|
+
encoding: "utf-8",
|
|
11544
|
+
timeout: PODMAN_INFO_TIMEOUT_MS,
|
|
11545
|
+
killSignal: "SIGKILL"
|
|
11546
|
+
}
|
|
11547
|
+
);
|
|
11548
|
+
const trimmed = String(stdout ?? "").trim().toLowerCase();
|
|
11549
|
+
if (trimmed === "true") {
|
|
11550
|
+
return true;
|
|
11551
|
+
}
|
|
11552
|
+
if (trimmed === "false") {
|
|
11553
|
+
return false;
|
|
11554
|
+
}
|
|
11555
|
+
} catch (err) {
|
|
11556
|
+
const isMissingBinary = isNodeError(err) && err.code === "ENOENT";
|
|
11557
|
+
const timedOut = isRecord3(err) && err["killed"] === true;
|
|
11558
|
+
if (isMissingBinary || timedOut) {
|
|
11559
|
+
break;
|
|
11560
|
+
}
|
|
11561
|
+
}
|
|
11562
|
+
}
|
|
11563
|
+
return false;
|
|
11564
|
+
}
|
|
11565
|
+
function hasUsernsFlag(flags) {
|
|
11566
|
+
return flags.some(
|
|
11567
|
+
(flag) => flag === "--userns" || flag.startsWith("--userns=")
|
|
11568
|
+
);
|
|
11569
|
+
}
|
|
11379
11570
|
async function start_sandbox(config, nodeArgs = [], cliConfig, cliArgs = []) {
|
|
11380
11571
|
const patcher = new ConsolePatcher({
|
|
11381
11572
|
debugMode: cliConfig?.getDebugMode() || !!process.env["DEBUG"],
|
|
@@ -11714,12 +11905,10 @@ async function start_sandbox(config, nodeArgs = [], cliConfig, cliArgs = []) {
|
|
|
11714
11905
|
if (config.command === "runsc") {
|
|
11715
11906
|
args.push("--runtime=runsc");
|
|
11716
11907
|
}
|
|
11717
|
-
|
|
11718
|
-
|
|
11719
|
-
|
|
11720
|
-
|
|
11721
|
-
args.push(...flags);
|
|
11722
|
-
}
|
|
11908
|
+
const customFlags = process.env["SANDBOX_FLAGS"] ? (0, import_shell_quote2.parse)(process.env["SANDBOX_FLAGS"], process.env).filter(
|
|
11909
|
+
(f) => typeof f === "string"
|
|
11910
|
+
) : [];
|
|
11911
|
+
args.push(...customFlags);
|
|
11723
11912
|
if (process.stdin.isTTY) {
|
|
11724
11913
|
args.push("-t");
|
|
11725
11914
|
}
|
|
@@ -12032,6 +12221,9 @@ async function start_sandbox(config, nodeArgs = [], cliConfig, cliArgs = []) {
|
|
|
12032
12221
|
userFlag = "--user root";
|
|
12033
12222
|
} else if (await shouldUseCurrentUserInSandbox()) {
|
|
12034
12223
|
args.push("--user", "root");
|
|
12224
|
+
if (command2 === "podman" && !hasUsernsFlag(customFlags) && await isPodmanRootless()) {
|
|
12225
|
+
args.push("--userns=keep-id");
|
|
12226
|
+
}
|
|
12035
12227
|
const uid = (await execAsync("id -u")).stdout.trim();
|
|
12036
12228
|
const gid = (await execAsync("id -g")).stdout.trim();
|
|
12037
12229
|
const username = "gemini";
|
|
@@ -12475,6 +12667,159 @@ async function ensureSandboxImageIsPresent(sandbox, image, cliConfig) {
|
|
|
12475
12667
|
return false;
|
|
12476
12668
|
}
|
|
12477
12669
|
|
|
12670
|
+
// packages/cli/src/utils/sandboxFolderTrust.ts
|
|
12671
|
+
import * as path11 from "node:path";
|
|
12672
|
+
import * as readline2 from "node:readline";
|
|
12673
|
+
import { Writable } from "node:stream";
|
|
12674
|
+
var TRUST_WORKSPACE_ENV = "GEMINI_CLI_TRUST_WORKSPACE";
|
|
12675
|
+
function parseTrustChoice(answer) {
|
|
12676
|
+
switch (answer.trim()) {
|
|
12677
|
+
case "1":
|
|
12678
|
+
return "TRUST_FOLDER" /* TRUST_FOLDER */;
|
|
12679
|
+
case "2":
|
|
12680
|
+
return "TRUST_PARENT" /* TRUST_PARENT */;
|
|
12681
|
+
case "3":
|
|
12682
|
+
return "DO_NOT_TRUST" /* DO_NOT_TRUST */;
|
|
12683
|
+
default:
|
|
12684
|
+
return void 0;
|
|
12685
|
+
}
|
|
12686
|
+
}
|
|
12687
|
+
async function resolveFolderTrustForSandbox({
|
|
12688
|
+
sandboxCommand,
|
|
12689
|
+
settings,
|
|
12690
|
+
interactive,
|
|
12691
|
+
workspaceDir = process.cwd(),
|
|
12692
|
+
promptForTrustLevel = promptForFolderTrustLevel
|
|
12693
|
+
}) {
|
|
12694
|
+
if (sandboxCommand !== "sandbox-exec") {
|
|
12695
|
+
return;
|
|
12696
|
+
}
|
|
12697
|
+
if (!isFolderTrustEnabled(settings.merged)) {
|
|
12698
|
+
return;
|
|
12699
|
+
}
|
|
12700
|
+
const trust = isWorkspaceTrusted(settings.merged, workspaceDir);
|
|
12701
|
+
if (trust.source === "env") {
|
|
12702
|
+
return;
|
|
12703
|
+
}
|
|
12704
|
+
let isTrusted = trust.isTrusted;
|
|
12705
|
+
if (isTrusted === void 0) {
|
|
12706
|
+
if (!interactive) {
|
|
12707
|
+
return;
|
|
12708
|
+
}
|
|
12709
|
+
const trustLevel = await promptForTrustLevel(workspaceDir);
|
|
12710
|
+
if (trustLevel === void 0) {
|
|
12711
|
+
throw new FatalCancellationError(
|
|
12712
|
+
"A folder trust level must be selected to continue."
|
|
12713
|
+
);
|
|
12714
|
+
}
|
|
12715
|
+
try {
|
|
12716
|
+
await loadTrustedFolders().setValue(workspaceDir, trustLevel);
|
|
12717
|
+
} catch {
|
|
12718
|
+
throw new FatalConfigError("Failed to save trust settings.");
|
|
12719
|
+
}
|
|
12720
|
+
isTrusted = trustLevel !== "DO_NOT_TRUST" /* DO_NOT_TRUST */;
|
|
12721
|
+
}
|
|
12722
|
+
process.env[TRUST_WORKSPACE_ENV] = isTrusted ? "true" : "false";
|
|
12723
|
+
}
|
|
12724
|
+
function formatFolderTrustPrompt(workspaceDir, discoveryResults) {
|
|
12725
|
+
const folderName = stripAnsi(path11.basename(workspaceDir)).trim() || stripAnsi(workspaceDir);
|
|
12726
|
+
const parentDir = path11.dirname(workspaceDir);
|
|
12727
|
+
const parentFolderName = stripAnsi(path11.basename(parentDir)).trim() || stripAnsi(parentDir);
|
|
12728
|
+
const lines = [
|
|
12729
|
+
"",
|
|
12730
|
+
"Do you trust the files in this folder?",
|
|
12731
|
+
"",
|
|
12732
|
+
"Trusting a folder allows Gemini CLI to load its local configurations, including custom commands, hooks, MCP servers, agent skills, and settings. These configurations could execute code on your behalf or change the behavior of the CLI.",
|
|
12733
|
+
""
|
|
12734
|
+
];
|
|
12735
|
+
const appendSection = (title, items) => {
|
|
12736
|
+
if (items.length === 0) {
|
|
12737
|
+
return;
|
|
12738
|
+
}
|
|
12739
|
+
lines.push(title);
|
|
12740
|
+
for (const item of items) {
|
|
12741
|
+
lines.push(` \u2022 ${stripAnsi(item)}`);
|
|
12742
|
+
}
|
|
12743
|
+
lines.push("");
|
|
12744
|
+
};
|
|
12745
|
+
if (discoveryResults) {
|
|
12746
|
+
appendSection("Discovery Errors:", discoveryResults.discoveryErrors ?? []);
|
|
12747
|
+
appendSection(
|
|
12748
|
+
"Security Warnings:",
|
|
12749
|
+
discoveryResults.securityWarnings ?? []
|
|
12750
|
+
);
|
|
12751
|
+
const groups = [
|
|
12752
|
+
["Commands", discoveryResults.commands ?? []],
|
|
12753
|
+
["MCP Servers", discoveryResults.mcps ?? []],
|
|
12754
|
+
["Hooks", discoveryResults.hooks ?? []],
|
|
12755
|
+
["Skills", discoveryResults.skills ?? []],
|
|
12756
|
+
["Agents", discoveryResults.agents ?? []],
|
|
12757
|
+
["Setting overrides", discoveryResults.settings ?? []]
|
|
12758
|
+
];
|
|
12759
|
+
const nonEmptyGroups = groups.filter(([, items]) => items.length > 0);
|
|
12760
|
+
if (nonEmptyGroups.length > 0) {
|
|
12761
|
+
lines.push("This folder contains:");
|
|
12762
|
+
for (const [label, items] of nonEmptyGroups) {
|
|
12763
|
+
lines.push(` \u2022 ${label} (${items.length}):`);
|
|
12764
|
+
for (const item of items) {
|
|
12765
|
+
lines.push(` - ${stripAnsi(item)}`);
|
|
12766
|
+
}
|
|
12767
|
+
}
|
|
12768
|
+
lines.push("");
|
|
12769
|
+
}
|
|
12770
|
+
}
|
|
12771
|
+
lines.push(
|
|
12772
|
+
` 1. Trust folder (${folderName})`,
|
|
12773
|
+
` 2. Trust parent folder (${parentFolderName})`,
|
|
12774
|
+
" 3. Don't trust",
|
|
12775
|
+
"",
|
|
12776
|
+
"This choice is saved before Gemini CLI starts in the macOS Seatbelt sandbox.",
|
|
12777
|
+
""
|
|
12778
|
+
);
|
|
12779
|
+
return lines.join("\n");
|
|
12780
|
+
}
|
|
12781
|
+
function createTerminalOutput() {
|
|
12782
|
+
return new Writable({
|
|
12783
|
+
decodeStrings: false,
|
|
12784
|
+
write(chunk, _encoding, callback) {
|
|
12785
|
+
writeToStdout(chunk);
|
|
12786
|
+
callback();
|
|
12787
|
+
}
|
|
12788
|
+
});
|
|
12789
|
+
}
|
|
12790
|
+
async function promptForFolderTrustLevel(workspaceDir, input = process.stdin, output = createTerminalOutput()) {
|
|
12791
|
+
let discoveryResults;
|
|
12792
|
+
try {
|
|
12793
|
+
discoveryResults = await FolderTrustDiscoveryService.discover(workspaceDir);
|
|
12794
|
+
} catch {
|
|
12795
|
+
}
|
|
12796
|
+
output.write(formatFolderTrustPrompt(workspaceDir, discoveryResults));
|
|
12797
|
+
return new Promise((resolve10) => {
|
|
12798
|
+
const rl = readline2.createInterface({ input, output, terminal: false });
|
|
12799
|
+
let settled = false;
|
|
12800
|
+
const finish = (trustLevel) => {
|
|
12801
|
+
if (settled) {
|
|
12802
|
+
return;
|
|
12803
|
+
}
|
|
12804
|
+
settled = true;
|
|
12805
|
+
rl.close();
|
|
12806
|
+
resolve10(trustLevel);
|
|
12807
|
+
};
|
|
12808
|
+
rl.on("line", (line) => {
|
|
12809
|
+
const trustLevel = parseTrustChoice(line);
|
|
12810
|
+
if (trustLevel) {
|
|
12811
|
+
finish(trustLevel);
|
|
12812
|
+
return;
|
|
12813
|
+
}
|
|
12814
|
+
output.write("Enter 1, 2, or 3.\n");
|
|
12815
|
+
rl.prompt();
|
|
12816
|
+
});
|
|
12817
|
+
rl.on("close", () => finish(void 0));
|
|
12818
|
+
rl.setPrompt("Select an option [1-3]: ");
|
|
12819
|
+
rl.prompt();
|
|
12820
|
+
});
|
|
12821
|
+
}
|
|
12822
|
+
|
|
12478
12823
|
// packages/cli/src/utils/startupWarnings.ts
|
|
12479
12824
|
import fs8 from "node:fs/promises";
|
|
12480
12825
|
import os4 from "node:os";
|
|
@@ -12502,7 +12847,7 @@ async function getStartupWarnings() {
|
|
|
12502
12847
|
// packages/cli/src/utils/userStartupWarnings.ts
|
|
12503
12848
|
import fs9 from "node:fs/promises";
|
|
12504
12849
|
import { homedir as osHomedir } from "node:os";
|
|
12505
|
-
import
|
|
12850
|
+
import path12 from "node:path";
|
|
12506
12851
|
import process5 from "node:process";
|
|
12507
12852
|
var homeDirectoryCheck = {
|
|
12508
12853
|
id: "home-directory",
|
|
@@ -12516,7 +12861,7 @@ var homeDirectoryCheck = {
|
|
|
12516
12861
|
fs9.realpath(workspaceRoot),
|
|
12517
12862
|
fs9.realpath(osHomedir())
|
|
12518
12863
|
]);
|
|
12519
|
-
if (
|
|
12864
|
+
if (path12.resolve(workspaceRealPath) === path12.resolve(homeRealPath)) {
|
|
12520
12865
|
if (isFolderTrustEnabled(settings) && isWorkspaceTrusted(settings).isTrusted) {
|
|
12521
12866
|
return null;
|
|
12522
12867
|
}
|
|
@@ -12535,7 +12880,7 @@ var rootDirectoryCheck = {
|
|
|
12535
12880
|
try {
|
|
12536
12881
|
const workspaceRealPath = await fs9.realpath(workspaceRoot);
|
|
12537
12882
|
const errorMessage = "Warning: You are running Gemini CLI in the root directory. Your entire folder structure will be used for context. It is strongly recommended to run in a project-specific directory.";
|
|
12538
|
-
if (
|
|
12883
|
+
if (path12.dirname(workspaceRealPath) === workspaceRealPath) {
|
|
12539
12884
|
return errorMessage;
|
|
12540
12885
|
}
|
|
12541
12886
|
return null;
|
|
@@ -12594,7 +12939,7 @@ async function getUserStartupWarnings(settings, workspaceRoot = process5.cwd(),
|
|
|
12594
12939
|
}
|
|
12595
12940
|
|
|
12596
12941
|
// packages/cli/src/nonInteractiveCli.ts
|
|
12597
|
-
import
|
|
12942
|
+
import readline4 from "node:readline";
|
|
12598
12943
|
|
|
12599
12944
|
// packages/cli/src/ui/noninteractive/nonInteractiveUi.ts
|
|
12600
12945
|
function createNonInteractiveUI() {
|
|
@@ -12801,8 +13146,11 @@ function handleToolError(toolName, toolError, config, errorType, resultDisplay)
|
|
|
12801
13146
|
}
|
|
12802
13147
|
debugLogger.warn(errorMessage);
|
|
12803
13148
|
}
|
|
12804
|
-
function handleCancellationError(config) {
|
|
12805
|
-
const cancellationError = new FatalCancellationError(
|
|
13149
|
+
function handleCancellationError(config, exitCode = 130) {
|
|
13150
|
+
const cancellationError = new FatalCancellationError(
|
|
13151
|
+
"Operation cancelled.",
|
|
13152
|
+
exitCode
|
|
13153
|
+
);
|
|
12806
13154
|
if (config.getOutputFormat() === "stream-json" /* STREAM_JSON */) {
|
|
12807
13155
|
const streamFormatter = new StreamJsonFormatter();
|
|
12808
13156
|
const metrics = uiTelemetryService.getMetrics();
|
|
@@ -12918,7 +13266,7 @@ var TextOutput = class {
|
|
|
12918
13266
|
};
|
|
12919
13267
|
|
|
12920
13268
|
// packages/cli/src/nonInteractiveCliAgentSession.ts
|
|
12921
|
-
import
|
|
13269
|
+
import readline3 from "node:readline";
|
|
12922
13270
|
async function runNonInteractive({
|
|
12923
13271
|
config,
|
|
12924
13272
|
settings,
|
|
@@ -12936,7 +13284,7 @@ async function runNonInteractive({
|
|
|
12936
13284
|
}
|
|
12937
13285
|
});
|
|
12938
13286
|
if (process.env["GEMINI_CLI_ACTIVITY_LOG_TARGET"]) {
|
|
12939
|
-
const { setupInitialActivityLogger } = await import("./devtoolsService-
|
|
13287
|
+
const { setupInitialActivityLogger } = await import("./devtoolsService-RCBUZGYD.js");
|
|
12940
13288
|
setupInitialActivityLogger(config);
|
|
12941
13289
|
}
|
|
12942
13290
|
const { stdout: workingStdout } = createWorkingStdio();
|
|
@@ -12967,9 +13315,17 @@ async function runNonInteractive({
|
|
|
12967
13315
|
}
|
|
12968
13316
|
throw err;
|
|
12969
13317
|
};
|
|
12970
|
-
|
|
13318
|
+
let abortExitCode = 130;
|
|
13319
|
+
const triggerAbort = (signal) => {
|
|
13320
|
+
if (signal === "SIGTERM") {
|
|
13321
|
+
abortExitCode = 143;
|
|
13322
|
+
} else if (signal === "SIGHUP") {
|
|
13323
|
+
abortExitCode = 129;
|
|
13324
|
+
} else {
|
|
13325
|
+
abortExitCode = 130;
|
|
13326
|
+
}
|
|
12971
13327
|
if (isAborting) {
|
|
12972
|
-
process.exit(
|
|
13328
|
+
process.exit(abortExitCode);
|
|
12973
13329
|
}
|
|
12974
13330
|
isAborting = true;
|
|
12975
13331
|
cancelMessageTimer = setTimeout(() => {
|
|
@@ -12977,30 +13333,35 @@ async function runNonInteractive({
|
|
|
12977
13333
|
}, 200);
|
|
12978
13334
|
abortController.abort();
|
|
12979
13335
|
};
|
|
13336
|
+
const onSigint = () => triggerAbort("SIGINT");
|
|
13337
|
+
const onSigterm = () => triggerAbort("SIGTERM");
|
|
13338
|
+
const onSighup = () => triggerAbort("SIGHUP");
|
|
12980
13339
|
const setupCancellation = () => {
|
|
12981
|
-
process.on("SIGINT",
|
|
12982
|
-
process.on("SIGTERM",
|
|
13340
|
+
process.on("SIGINT", onSigint);
|
|
13341
|
+
process.on("SIGTERM", onSigterm);
|
|
13342
|
+
process.on("SIGHUP", onSighup);
|
|
12983
13343
|
if (!process.stdin?.isTTY) {
|
|
12984
13344
|
return;
|
|
12985
13345
|
}
|
|
12986
13346
|
stdinWasRaw = process.stdin.isRaw || false;
|
|
12987
13347
|
process.stdin.setRawMode(true);
|
|
12988
13348
|
process.stdin.resume();
|
|
12989
|
-
rl =
|
|
13349
|
+
rl = readline3.createInterface({
|
|
12990
13350
|
input: process.stdin,
|
|
12991
13351
|
escapeCodeTimeout: 0
|
|
12992
13352
|
});
|
|
12993
|
-
|
|
13353
|
+
readline3.emitKeypressEvents(process.stdin, rl);
|
|
12994
13354
|
keypressHandler = (str, key) => {
|
|
12995
13355
|
if (key && key.ctrl && key.name === "c" || str === "") {
|
|
12996
|
-
triggerAbort();
|
|
13356
|
+
triggerAbort("SIGINT");
|
|
12997
13357
|
}
|
|
12998
13358
|
};
|
|
12999
13359
|
process.stdin.on("keypress", keypressHandler);
|
|
13000
13360
|
};
|
|
13001
13361
|
const cleanupCancellation = () => {
|
|
13002
|
-
process.off("SIGINT",
|
|
13003
|
-
process.off("SIGTERM",
|
|
13362
|
+
process.off("SIGINT", onSigint);
|
|
13363
|
+
process.off("SIGTERM", onSigterm);
|
|
13364
|
+
process.off("SIGHUP", onSighup);
|
|
13004
13365
|
process.stdout.off("error", handleStdoutError);
|
|
13005
13366
|
if (cancelMessageTimer) {
|
|
13006
13367
|
clearTimeout(cancelMessageTimer);
|
|
@@ -13106,7 +13467,7 @@ async function runNonInteractive({
|
|
|
13106
13467
|
};
|
|
13107
13468
|
abortController.signal.addEventListener("abort", abortSession);
|
|
13108
13469
|
if (abortController.signal.aborted) {
|
|
13109
|
-
throw new FatalCancellationError("Operation cancelled.");
|
|
13470
|
+
throw new FatalCancellationError("Operation cancelled.", abortExitCode);
|
|
13110
13471
|
}
|
|
13111
13472
|
const { streamId } = await session.send({
|
|
13112
13473
|
message: {
|
|
@@ -13152,64 +13513,63 @@ async function runNonInteractive({
|
|
|
13152
13513
|
const reconstructFatalError = (event) => {
|
|
13153
13514
|
const errorMeta = event._meta;
|
|
13154
13515
|
const name = typeof errorMeta?.["errorName"] === "string" ? errorMeta["errorName"] : void 0;
|
|
13516
|
+
const rawError = errorMeta?.["rawError"];
|
|
13517
|
+
const normalized = normalizeError(
|
|
13518
|
+
rawError ?? {
|
|
13519
|
+
message: event.message,
|
|
13520
|
+
status: errorMeta?.["status"],
|
|
13521
|
+
code: errorMeta?.["code"]
|
|
13522
|
+
}
|
|
13523
|
+
);
|
|
13524
|
+
const code = normalized.code ?? (typeof normalized.status === "string" ? normalized.status : void 0);
|
|
13155
13525
|
let errToThrow;
|
|
13156
13526
|
switch (name) {
|
|
13157
13527
|
case "FatalAuthenticationError":
|
|
13158
|
-
errToThrow = new FatalAuthenticationError(
|
|
13528
|
+
errToThrow = new FatalAuthenticationError(normalized.message);
|
|
13159
13529
|
break;
|
|
13160
13530
|
case "FatalInputError":
|
|
13161
|
-
errToThrow = new FatalInputError(
|
|
13531
|
+
errToThrow = new FatalInputError(normalized.message);
|
|
13162
13532
|
break;
|
|
13163
13533
|
case "FatalSandboxError":
|
|
13164
|
-
errToThrow = new FatalSandboxError(
|
|
13534
|
+
errToThrow = new FatalSandboxError(normalized.message);
|
|
13165
13535
|
break;
|
|
13166
13536
|
case "FatalConfigError":
|
|
13167
|
-
errToThrow = new FatalConfigError(
|
|
13537
|
+
errToThrow = new FatalConfigError(normalized.message);
|
|
13168
13538
|
break;
|
|
13169
13539
|
case "FatalTurnLimitedError":
|
|
13170
|
-
errToThrow = new FatalTurnLimitedError(
|
|
13540
|
+
errToThrow = new FatalTurnLimitedError(normalized.message);
|
|
13171
13541
|
break;
|
|
13172
13542
|
case "FatalToolExecutionError":
|
|
13173
|
-
errToThrow = new FatalToolExecutionError(
|
|
13543
|
+
errToThrow = new FatalToolExecutionError(normalized.message);
|
|
13174
13544
|
break;
|
|
13175
13545
|
case "FatalCancellationError":
|
|
13176
|
-
errToThrow = new FatalCancellationError(
|
|
13546
|
+
errToThrow = new FatalCancellationError(
|
|
13547
|
+
normalized.message,
|
|
13548
|
+
abortExitCode
|
|
13549
|
+
);
|
|
13177
13550
|
break;
|
|
13178
13551
|
case "FatalError":
|
|
13179
13552
|
errToThrow = new FatalError(
|
|
13180
|
-
|
|
13553
|
+
normalized.message,
|
|
13181
13554
|
typeof errorMeta?.["exitCode"] === "number" ? errorMeta["exitCode"] : 1
|
|
13182
13555
|
);
|
|
13183
13556
|
break;
|
|
13184
13557
|
default:
|
|
13185
|
-
errToThrow =
|
|
13186
|
-
|
|
13187
|
-
|
|
13188
|
-
|
|
13189
|
-
|
|
13190
|
-
}
|
|
13191
|
-
|
|
13558
|
+
errToThrow = Object.assign(
|
|
13559
|
+
new Error(
|
|
13560
|
+
normalized.message,
|
|
13561
|
+
rawError !== void 0 ? { cause: rawError } : void 0
|
|
13562
|
+
),
|
|
13563
|
+
name ? { name } : {}
|
|
13564
|
+
);
|
|
13192
13565
|
break;
|
|
13193
13566
|
}
|
|
13194
|
-
|
|
13195
|
-
|
|
13196
|
-
|
|
13197
|
-
|
|
13198
|
-
}
|
|
13199
|
-
}
|
|
13200
|
-
if (errorMeta?.["code"] !== void 0) {
|
|
13201
|
-
Object.defineProperty(errToThrow, "code", {
|
|
13202
|
-
value: errorMeta["code"],
|
|
13203
|
-
enumerable: true
|
|
13204
|
-
});
|
|
13205
|
-
}
|
|
13206
|
-
if (errorMeta?.["status"] !== void 0) {
|
|
13207
|
-
Object.defineProperty(errToThrow, "status", {
|
|
13208
|
-
value: errorMeta["status"],
|
|
13209
|
-
enumerable: true
|
|
13210
|
-
});
|
|
13211
|
-
}
|
|
13212
|
-
return errToThrow;
|
|
13567
|
+
return Object.assign(errToThrow, {
|
|
13568
|
+
...errorMeta?.["exitCode"] !== void 0 ? { exitCode: errorMeta["exitCode"] } : {},
|
|
13569
|
+
...typeof normalized.status === "number" ? { status: normalized.status } : {},
|
|
13570
|
+
...code !== void 0 ? { code } : {},
|
|
13571
|
+
...normalized.details !== void 0 ? { details: normalized.details } : {}
|
|
13572
|
+
});
|
|
13213
13573
|
};
|
|
13214
13574
|
let responseText = "";
|
|
13215
13575
|
let preToolResponseText;
|
|
@@ -13436,7 +13796,8 @@ async function runNonInteractive({
|
|
|
13436
13796
|
await runExitCleanup();
|
|
13437
13797
|
}
|
|
13438
13798
|
if (abortController.signal.aborted || isFatalCancellationError(errorToHandle)) {
|
|
13439
|
-
|
|
13799
|
+
const exitCode = isFatalCancellationError(errorToHandle) ? errorToHandle.exitCode : abortExitCode;
|
|
13800
|
+
handleCancellationError(config, exitCode);
|
|
13440
13801
|
}
|
|
13441
13802
|
if (errorToHandle) {
|
|
13442
13803
|
handleError(errorToHandle, config);
|
|
@@ -13464,7 +13825,7 @@ async function runNonInteractive2(params) {
|
|
|
13464
13825
|
}
|
|
13465
13826
|
});
|
|
13466
13827
|
if (process.env["GEMINI_CLI_ACTIVITY_LOG_TARGET"]) {
|
|
13467
|
-
const { setupInitialActivityLogger } = await import("./devtoolsService-
|
|
13828
|
+
const { setupInitialActivityLogger } = await import("./devtoolsService-RCBUZGYD.js");
|
|
13468
13829
|
setupInitialActivityLogger(config);
|
|
13469
13830
|
}
|
|
13470
13831
|
const { stdout: workingStdout } = createWorkingStdio();
|
|
@@ -13495,9 +13856,17 @@ async function runNonInteractive2(params) {
|
|
|
13495
13856
|
}
|
|
13496
13857
|
throw err;
|
|
13497
13858
|
};
|
|
13498
|
-
|
|
13859
|
+
let abortExitCode = 130;
|
|
13860
|
+
const triggerAbort = (signal) => {
|
|
13861
|
+
if (signal === "SIGTERM") {
|
|
13862
|
+
abortExitCode = 143;
|
|
13863
|
+
} else if (signal === "SIGHUP") {
|
|
13864
|
+
abortExitCode = 129;
|
|
13865
|
+
} else {
|
|
13866
|
+
abortExitCode = 130;
|
|
13867
|
+
}
|
|
13499
13868
|
if (isAborting) {
|
|
13500
|
-
process.exit(
|
|
13869
|
+
process.exit(abortExitCode);
|
|
13501
13870
|
}
|
|
13502
13871
|
isAborting = true;
|
|
13503
13872
|
cancelMessageTimer = setTimeout(() => {
|
|
@@ -13505,30 +13874,35 @@ async function runNonInteractive2(params) {
|
|
|
13505
13874
|
}, 200);
|
|
13506
13875
|
abortController.abort();
|
|
13507
13876
|
};
|
|
13877
|
+
const handleSigInt = () => triggerAbort("SIGINT");
|
|
13878
|
+
const handleSigTerm = () => triggerAbort("SIGTERM");
|
|
13879
|
+
const handleSigHup = () => triggerAbort("SIGHUP");
|
|
13508
13880
|
const setupCancellation = () => {
|
|
13509
|
-
process.on("SIGINT",
|
|
13510
|
-
process.on("SIGTERM",
|
|
13881
|
+
process.on("SIGINT", handleSigInt);
|
|
13882
|
+
process.on("SIGTERM", handleSigTerm);
|
|
13883
|
+
process.on("SIGHUP", handleSigHup);
|
|
13511
13884
|
if (!process.stdin?.isTTY) {
|
|
13512
13885
|
return;
|
|
13513
13886
|
}
|
|
13514
13887
|
stdinWasRaw = process.stdin.isRaw || false;
|
|
13515
13888
|
process.stdin.setRawMode(true);
|
|
13516
13889
|
process.stdin.resume();
|
|
13517
|
-
rl =
|
|
13890
|
+
rl = readline4.createInterface({
|
|
13518
13891
|
input: process.stdin,
|
|
13519
13892
|
escapeCodeTimeout: 0
|
|
13520
13893
|
});
|
|
13521
|
-
|
|
13894
|
+
readline4.emitKeypressEvents(process.stdin, rl);
|
|
13522
13895
|
keypressHandler = (str, key) => {
|
|
13523
13896
|
if (key && key.ctrl && key.name === "c" || str === "") {
|
|
13524
|
-
triggerAbort();
|
|
13897
|
+
triggerAbort("SIGINT");
|
|
13525
13898
|
}
|
|
13526
13899
|
};
|
|
13527
13900
|
process.stdin.on("keypress", keypressHandler);
|
|
13528
13901
|
};
|
|
13529
13902
|
const cleanupCancellation = () => {
|
|
13530
|
-
process.off("SIGINT",
|
|
13531
|
-
process.off("SIGTERM",
|
|
13903
|
+
process.off("SIGINT", handleSigInt);
|
|
13904
|
+
process.off("SIGTERM", handleSigTerm);
|
|
13905
|
+
process.off("SIGHUP", handleSigHup);
|
|
13532
13906
|
process.stdout.off("error", handleStdoutError);
|
|
13533
13907
|
if (cancelMessageTimer) {
|
|
13534
13908
|
clearTimeout(cancelMessageTimer);
|
|
@@ -13641,7 +14015,7 @@ async function runNonInteractive2(params) {
|
|
|
13641
14015
|
let responseText = "";
|
|
13642
14016
|
for await (const event of responseStream) {
|
|
13643
14017
|
if (abortController.signal.aborted) {
|
|
13644
|
-
handleCancellationError(config);
|
|
14018
|
+
handleCancellationError(config, abortExitCode);
|
|
13645
14019
|
}
|
|
13646
14020
|
if (event.type === "content" /* Content */) {
|
|
13647
14021
|
const isRaw = config.getRawOutput() || config.getAcceptRawOutputRisk();
|
|
@@ -13695,7 +14069,20 @@ async function runNonInteractive2(params) {
|
|
|
13695
14069
|
}
|
|
13696
14070
|
warnings.push(message);
|
|
13697
14071
|
} else if (event.type === "error" /* Error */) {
|
|
13698
|
-
|
|
14072
|
+
const normalized = normalizeError(event.value?.error);
|
|
14073
|
+
const code = normalized.code ?? (typeof normalized.status === "string" ? normalized.status : void 0);
|
|
14074
|
+
const err = Object.assign(
|
|
14075
|
+
new Error(
|
|
14076
|
+
normalized.message,
|
|
14077
|
+
normalized.originalError !== void 0 ? { cause: normalized.originalError } : void 0
|
|
14078
|
+
),
|
|
14079
|
+
{
|
|
14080
|
+
...typeof normalized.status === "number" ? { status: normalized.status } : {},
|
|
14081
|
+
...code !== void 0 ? { code } : {},
|
|
14082
|
+
...normalized.details !== void 0 ? { details: normalized.details } : {}
|
|
14083
|
+
}
|
|
14084
|
+
);
|
|
14085
|
+
throw err;
|
|
13699
14086
|
} else if (event.type === "agent_execution_stopped" /* AgentExecutionStopped */) {
|
|
13700
14087
|
const stopMessage = `Agent execution stopped: ${event.value.systemMessage?.trim() || event.value.reason}`;
|
|
13701
14088
|
if (config.getOutputFormat() === "text" /* TEXT */) {
|
|
@@ -13784,13 +14171,27 @@ async function runNonInteractive2(params) {
|
|
|
13784
14171
|
}
|
|
13785
14172
|
if (toolCallRequests.length > 0) {
|
|
13786
14173
|
if (abortController.signal.aborted) {
|
|
13787
|
-
throw new FatalCancellationError(
|
|
14174
|
+
throw new FatalCancellationError(
|
|
14175
|
+
"Operation cancelled.",
|
|
14176
|
+
abortExitCode
|
|
14177
|
+
);
|
|
13788
14178
|
}
|
|
13789
14179
|
textOutput.ensureTrailingNewline();
|
|
13790
|
-
|
|
13791
|
-
|
|
13792
|
-
|
|
13793
|
-
|
|
14180
|
+
let completedToolCalls;
|
|
14181
|
+
try {
|
|
14182
|
+
completedToolCalls = await scheduler.schedule(
|
|
14183
|
+
toolCallRequests,
|
|
14184
|
+
abortController.signal
|
|
14185
|
+
);
|
|
14186
|
+
} catch (scheduleError) {
|
|
14187
|
+
if (abortController.signal.aborted) {
|
|
14188
|
+
throw new FatalCancellationError(
|
|
14189
|
+
"Operation cancelled.",
|
|
14190
|
+
abortExitCode
|
|
14191
|
+
);
|
|
14192
|
+
}
|
|
14193
|
+
throw scheduleError;
|
|
14194
|
+
}
|
|
13794
14195
|
const toolResponseParts = [];
|
|
13795
14196
|
for (const completedToolCall of completedToolCalls) {
|
|
13796
14197
|
const toolResponse = completedToolCall.response;
|
|
@@ -13868,6 +14269,12 @@ async function runNonInteractive2(params) {
|
|
|
13868
14269
|
}
|
|
13869
14270
|
return;
|
|
13870
14271
|
}
|
|
14272
|
+
if (abortController.signal.aborted) {
|
|
14273
|
+
throw new FatalCancellationError(
|
|
14274
|
+
"Operation cancelled.",
|
|
14275
|
+
abortExitCode
|
|
14276
|
+
);
|
|
14277
|
+
}
|
|
13871
14278
|
currentMessages = [{ role: "user", parts: toolResponseParts }];
|
|
13872
14279
|
} else {
|
|
13873
14280
|
if (streamFormatter) {
|
|
@@ -13907,7 +14314,8 @@ async function runNonInteractive2(params) {
|
|
|
13907
14314
|
await runExitCleanup();
|
|
13908
14315
|
}
|
|
13909
14316
|
if (abortController.signal.aborted || isFatalCancellationError(errorToHandle)) {
|
|
13910
|
-
|
|
14317
|
+
const exitCode = isFatalCancellationError(errorToHandle) ? errorToHandle.exitCode : abortExitCode;
|
|
14318
|
+
handleCancellationError(config, exitCode);
|
|
13911
14319
|
}
|
|
13912
14320
|
if (errorToHandle) {
|
|
13913
14321
|
handleError(errorToHandle, config);
|
|
@@ -15453,7 +15861,7 @@ var RequestError = class _RequestError extends Error {
|
|
|
15453
15861
|
};
|
|
15454
15862
|
|
|
15455
15863
|
// packages/cli/src/acp/acpStdioTransport.ts
|
|
15456
|
-
import { Readable, Writable } from "node:stream";
|
|
15864
|
+
import { Readable, Writable as Writable2 } from "node:stream";
|
|
15457
15865
|
|
|
15458
15866
|
// packages/cli/src/acp/acpErrors.ts
|
|
15459
15867
|
function getAcpErrorMessage(error) {
|
|
@@ -15480,7 +15888,7 @@ import { randomUUID as randomUUID2 } from "node:crypto";
|
|
|
15480
15888
|
|
|
15481
15889
|
// packages/cli/src/acp/acpSession.ts
|
|
15482
15890
|
import * as fs12 from "node:fs/promises";
|
|
15483
|
-
import * as
|
|
15891
|
+
import * as path15 from "node:path";
|
|
15484
15892
|
import { randomUUID } from "node:crypto";
|
|
15485
15893
|
|
|
15486
15894
|
// packages/cli/src/acp/commands/commandRegistry.ts
|
|
@@ -15922,7 +16330,7 @@ var UpdateExtensionCommand = class {
|
|
|
15922
16330
|
|
|
15923
16331
|
// packages/cli/src/acp/commands/init.ts
|
|
15924
16332
|
import * as fs10 from "node:fs";
|
|
15925
|
-
import * as
|
|
16333
|
+
import * as path13 from "node:path";
|
|
15926
16334
|
var InitCommand = class {
|
|
15927
16335
|
name = "init";
|
|
15928
16336
|
description = "Analyzes the project and creates a tailored GEMINI.md file";
|
|
@@ -15932,7 +16340,7 @@ var InitCommand = class {
|
|
|
15932
16340
|
if (!targetDir) {
|
|
15933
16341
|
throw new Error("Command requires a workspace.");
|
|
15934
16342
|
}
|
|
15935
|
-
const geminiMdPath =
|
|
16343
|
+
const geminiMdPath = path13.join(targetDir, "GEMINI.md");
|
|
15936
16344
|
const result = performInit(fs10.existsSync(geminiMdPath));
|
|
15937
16345
|
switch (result.type) {
|
|
15938
16346
|
case "message":
|
|
@@ -15965,7 +16373,7 @@ ${result.content}`
|
|
|
15965
16373
|
|
|
15966
16374
|
// packages/cli/src/acp/commands/restore.ts
|
|
15967
16375
|
import * as fs11 from "node:fs/promises";
|
|
15968
|
-
import * as
|
|
16376
|
+
import * as path14 from "node:path";
|
|
15969
16377
|
var RestoreCommand = class {
|
|
15970
16378
|
name = "restore";
|
|
15971
16379
|
description = "Restore to a previous checkpoint, or list available checkpoints to restore. This will reset the conversation and file history to the state it was in when the checkpoint was created";
|
|
@@ -15987,7 +16395,7 @@ var RestoreCommand = class {
|
|
|
15987
16395
|
}
|
|
15988
16396
|
const selectedFile = argsStr.endsWith(".json") ? argsStr : `${argsStr}.json`;
|
|
15989
16397
|
const checkpointDir = config.storage.getProjectTempCheckpointsDir();
|
|
15990
|
-
const filePath =
|
|
16398
|
+
const filePath = path14.join(checkpointDir, selectedFile);
|
|
15991
16399
|
let data;
|
|
15992
16400
|
try {
|
|
15993
16401
|
data = await fs11.readFile(filePath, "utf-8");
|
|
@@ -16061,7 +16469,7 @@ var ListCheckpointsCommand = class {
|
|
|
16061
16469
|
}
|
|
16062
16470
|
const checkpointFiles = /* @__PURE__ */ new Map();
|
|
16063
16471
|
for (const file of jsonFiles) {
|
|
16064
|
-
const filePath =
|
|
16472
|
+
const filePath = path14.join(checkpointDir, file);
|
|
16065
16473
|
const data = await fs11.readFile(filePath, "utf-8");
|
|
16066
16474
|
checkpointFiles.set(file, data);
|
|
16067
16475
|
}
|
|
@@ -16271,6 +16679,7 @@ var Session = class {
|
|
|
16271
16679
|
"approval-mode-changed" /* ApprovalModeChanged */,
|
|
16272
16680
|
this.handleApprovalModeChanged
|
|
16273
16681
|
);
|
|
16682
|
+
coreEvents.on("retry-attempt" /* RetryAttempt */, this.handleRetryAttempt);
|
|
16274
16683
|
this.context.config.getMessageBus()?.subscribe(
|
|
16275
16684
|
"tool-confirmation-request" /* TOOL_CONFIRMATION_REQUEST */,
|
|
16276
16685
|
this.handleToolConfirmationRequest,
|
|
@@ -16364,11 +16773,26 @@ var Session = class {
|
|
|
16364
16773
|
});
|
|
16365
16774
|
}
|
|
16366
16775
|
};
|
|
16776
|
+
handleRetryAttempt = (payload) => {
|
|
16777
|
+
if (payload.sessionId === this.id) {
|
|
16778
|
+
const delaySec = Math.max(1, Math.round(payload.delayMs / 1e3));
|
|
16779
|
+
this.sendUpdate({
|
|
16780
|
+
sessionUpdate: "agent_thought_chunk",
|
|
16781
|
+
content: {
|
|
16782
|
+
type: "text",
|
|
16783
|
+
text: `[Retry ${payload.attempt}/${payload.maxAttempts}] ${payload.error || "Request failed"}. Retrying in ${delaySec}s...`
|
|
16784
|
+
}
|
|
16785
|
+
}).catch((err) => {
|
|
16786
|
+
debugLogger.error(`Failed to send retry session update: ${err}`);
|
|
16787
|
+
});
|
|
16788
|
+
}
|
|
16789
|
+
};
|
|
16367
16790
|
async dispose() {
|
|
16368
16791
|
coreEvents.off(
|
|
16369
16792
|
"approval-mode-changed" /* ApprovalModeChanged */,
|
|
16370
16793
|
this.handleApprovalModeChanged
|
|
16371
16794
|
);
|
|
16795
|
+
coreEvents.off("retry-attempt" /* RetryAttempt */, this.handleRetryAttempt);
|
|
16372
16796
|
this.disposeController.abort();
|
|
16373
16797
|
if (this.context.config?.dispose) {
|
|
16374
16798
|
try {
|
|
@@ -16545,6 +16969,7 @@ ${thought.description}`;
|
|
|
16545
16969
|
let currentParts = parts;
|
|
16546
16970
|
let turnCount = 0;
|
|
16547
16971
|
const maxTurns = this.context.config.getMaxSessionTurns();
|
|
16972
|
+
let isFirstChunkAfterRetry = false;
|
|
16548
16973
|
while (true) {
|
|
16549
16974
|
turnCount++;
|
|
16550
16975
|
if (maxTurns >= 0 && turnCount > maxTurns) {
|
|
@@ -16576,10 +17001,13 @@ ${thought.description}`;
|
|
|
16576
17001
|
type: "text",
|
|
16577
17002
|
text: event.value
|
|
16578
17003
|
};
|
|
16579
|
-
|
|
17004
|
+
const update = {
|
|
16580
17005
|
sessionUpdate: "agent_message_chunk",
|
|
16581
|
-
content
|
|
16582
|
-
|
|
17006
|
+
content,
|
|
17007
|
+
...isFirstChunkAfterRetry ? { _meta: { retry: true, reset: true } } : {}
|
|
17008
|
+
};
|
|
17009
|
+
isFirstChunkAfterRetry = false;
|
|
17010
|
+
await this.sendUpdate(update);
|
|
16583
17011
|
break;
|
|
16584
17012
|
}
|
|
16585
17013
|
case "thought" /* Thought */: {
|
|
@@ -16591,6 +17019,22 @@ ${event.value.description}`;
|
|
|
16591
17019
|
});
|
|
16592
17020
|
break;
|
|
16593
17021
|
}
|
|
17022
|
+
case "retry" /* Retry */: {
|
|
17023
|
+
toolCallRequests.length = 0;
|
|
17024
|
+
debugLogger.warn(
|
|
17025
|
+
"Model stream interrupted mid-response; retrying prompt..."
|
|
17026
|
+
);
|
|
17027
|
+
await this.sendUpdate({
|
|
17028
|
+
sessionUpdate: "agent_thought_chunk",
|
|
17029
|
+
content: {
|
|
17030
|
+
type: "text",
|
|
17031
|
+
text: "_[Stream interrupted. Retrying response...]_"
|
|
17032
|
+
},
|
|
17033
|
+
_meta: { retry: true }
|
|
17034
|
+
});
|
|
17035
|
+
isFirstChunkAfterRetry = true;
|
|
17036
|
+
break;
|
|
17037
|
+
}
|
|
16594
17038
|
case "tool_call_request" /* ToolCallRequest */:
|
|
16595
17039
|
toolCallRequests.push(event.value);
|
|
16596
17040
|
break;
|
|
@@ -17062,7 +17506,7 @@ ${event.value.description}`;
|
|
|
17062
17506
|
} else if (result.status === "invalid") {
|
|
17063
17507
|
continue;
|
|
17064
17508
|
} else {
|
|
17065
|
-
absolutePath =
|
|
17509
|
+
absolutePath = path15.resolve(
|
|
17066
17510
|
this.context.config.getTargetDir(),
|
|
17067
17511
|
pathName
|
|
17068
17512
|
);
|
|
@@ -17136,7 +17580,7 @@ ${event.value.description}`;
|
|
|
17136
17580
|
}
|
|
17137
17581
|
try {
|
|
17138
17582
|
if (!validationError) {
|
|
17139
|
-
if ((
|
|
17583
|
+
if ((path15.isAbsolute(pathName) || !isWithinRoot(
|
|
17140
17584
|
absolutePath,
|
|
17141
17585
|
this.context.config.getTargetDir()
|
|
17142
17586
|
)) && !readDirectly) {
|
|
@@ -17234,7 +17678,7 @@ ${contentToPush}`;
|
|
|
17234
17678
|
const lines = globResult.llmContent.split("\n");
|
|
17235
17679
|
if (lines.length > 1 && lines[1]) {
|
|
17236
17680
|
const firstMatchAbsolute = lines[1].trim();
|
|
17237
|
-
currentPathSpec =
|
|
17681
|
+
currentPathSpec = path15.relative(
|
|
17238
17682
|
this.context.config.getTargetDir(),
|
|
17239
17683
|
firstMatchAbsolute
|
|
17240
17684
|
);
|
|
@@ -17359,13 +17803,15 @@ ${REFERENCE_CONTENT_START}`
|
|
|
17359
17803
|
const match = fileContentRegex.exec(part);
|
|
17360
17804
|
if (match) {
|
|
17361
17805
|
const filePathSpecInContent = match[1];
|
|
17362
|
-
const fileActualContent = match[2]
|
|
17806
|
+
const fileActualContent = match[2];
|
|
17363
17807
|
processedQueryParts.push({
|
|
17364
17808
|
text: `
|
|
17365
17809
|
Content from @${filePathSpecInContent}:
|
|
17366
17810
|
`
|
|
17367
17811
|
});
|
|
17368
|
-
|
|
17812
|
+
if (fileActualContent !== "") {
|
|
17813
|
+
processedQueryParts.push({ text: fileActualContent });
|
|
17814
|
+
}
|
|
17369
17815
|
} else {
|
|
17370
17816
|
processedQueryParts.push({ text: part });
|
|
17371
17817
|
}
|
|
@@ -17455,7 +17901,7 @@ Content from @${contextPart.uri}:
|
|
|
17455
17901
|
|
|
17456
17902
|
// packages/cli/src/acp/acpFileSystemService.ts
|
|
17457
17903
|
import os5 from "node:os";
|
|
17458
|
-
import
|
|
17904
|
+
import path16 from "node:path";
|
|
17459
17905
|
var AcpFileSystemService = class {
|
|
17460
17906
|
constructor(connection, sessionId, capabilities, fallback, root) {
|
|
17461
17907
|
this.connection = connection;
|
|
@@ -17464,7 +17910,7 @@ var AcpFileSystemService = class {
|
|
|
17464
17910
|
this.fallback = fallback;
|
|
17465
17911
|
this.root = root;
|
|
17466
17912
|
}
|
|
17467
|
-
geminiDir =
|
|
17913
|
+
geminiDir = path16.join(os5.homedir(), ".gemini");
|
|
17468
17914
|
shouldUseFallback(filePath) {
|
|
17469
17915
|
return !isWithinRoot(filePath, this.root) || isWithinRoot(filePath, this.geminiDir);
|
|
17470
17916
|
}
|
|
@@ -17714,9 +18160,11 @@ var AcpSessionManager = class {
|
|
|
17714
18160
|
currentModelId
|
|
17715
18161
|
}
|
|
17716
18162
|
};
|
|
17717
|
-
|
|
18163
|
+
try {
|
|
18164
|
+
await session.streamHistory(messages);
|
|
18165
|
+
} catch (err) {
|
|
17718
18166
|
debugLogger.error(`Error streaming history: ${err}`);
|
|
17719
|
-
}
|
|
18167
|
+
}
|
|
17720
18168
|
setTimeout(() => {
|
|
17721
18169
|
session?.sendAvailableCommands().catch((err) => {
|
|
17722
18170
|
debugLogger.error(`Error sending available commands: ${err}`);
|
|
@@ -18017,7 +18465,7 @@ var GeminiAgent = class {
|
|
|
18017
18465
|
// packages/cli/src/acp/acpStdioTransport.ts
|
|
18018
18466
|
async function runAcpClient(config, settings, argv) {
|
|
18019
18467
|
const { stdout: workingStdout } = createWorkingStdio();
|
|
18020
|
-
const stdout =
|
|
18468
|
+
const stdout = Writable2.toWeb(workingStdout);
|
|
18021
18469
|
const stdin = Readable.toWeb(process.stdin);
|
|
18022
18470
|
const stream = ndJsonStream(stdout, stdin);
|
|
18023
18471
|
const connection = new AgentSideConnection(
|
|
@@ -18163,6 +18611,7 @@ async function setupTerminalAndTheme(config, settings) {
|
|
|
18163
18611
|
terminalCapabilityManager.areAmbiguousCharactersWide()
|
|
18164
18612
|
);
|
|
18165
18613
|
}
|
|
18614
|
+
themeManager.loadUserThemes?.();
|
|
18166
18615
|
themeManager.loadCustomThemes(settings.merged.ui.customThemes);
|
|
18167
18616
|
if (settings.merged.ui.theme) {
|
|
18168
18617
|
if (!themeManager.setActiveTheme(settings.merged.ui.theme)) {
|
|
@@ -18196,7 +18645,7 @@ async function setupTerminalAndTheme(config, settings) {
|
|
|
18196
18645
|
|
|
18197
18646
|
// packages/cli/src/utils/logCleanup.ts
|
|
18198
18647
|
import { promises as fs13 } from "node:fs";
|
|
18199
|
-
import * as
|
|
18648
|
+
import * as path17 from "node:path";
|
|
18200
18649
|
var RETENTION_PERIOD_MS = 7 * 24 * 60 * 60 * 1e3;
|
|
18201
18650
|
async function cleanupBackgroundLogs(debugMode = false) {
|
|
18202
18651
|
try {
|
|
@@ -18211,7 +18660,7 @@ async function cleanupBackgroundLogs(debugMode = false) {
|
|
|
18211
18660
|
let deletedCount = 0;
|
|
18212
18661
|
for (const entry of entries) {
|
|
18213
18662
|
if (entry.isFile() && entry.name.endsWith(".log")) {
|
|
18214
|
-
const filePath =
|
|
18663
|
+
const filePath = path17.join(logDir, entry.name);
|
|
18215
18664
|
try {
|
|
18216
18665
|
const stats = await fs13.stat(filePath);
|
|
18217
18666
|
if (now - stats.mtime.getTime() > RETENTION_PERIOD_MS) {
|
|
@@ -18556,8 +19005,8 @@ async function resolveSessionId(resumeArg, sessionIdArg, sessionFileArg) {
|
|
|
18556
19005
|
sessionData.projectHash = getProjectHash(storage.getProjectRoot());
|
|
18557
19006
|
sessionData.startTime = isoNow;
|
|
18558
19007
|
sessionData.lastUpdated = isoNow;
|
|
18559
|
-
const chatsDir =
|
|
18560
|
-
const newSessionPath =
|
|
19008
|
+
const chatsDir = path18.join(storage.getProjectTempDir(), "chats");
|
|
19009
|
+
const newSessionPath = path18.join(
|
|
18561
19010
|
chatsDir,
|
|
18562
19011
|
`session-${now}-${newSessionId.slice(0, 8)}.jsonl`
|
|
18563
19012
|
);
|
|
@@ -18625,7 +19074,7 @@ async function resolveSessionId(resumeArg, sessionIdArg, sessionFileArg) {
|
|
|
18625
19074
|
}
|
|
18626
19075
|
}
|
|
18627
19076
|
async function startInteractiveUI(config, settings, startupWarnings, workspaceRoot = process.cwd(), resumedSessionData, initializationResult) {
|
|
18628
|
-
const { startInteractiveUI: doStartUI } = await import("./interactiveCli-
|
|
19077
|
+
const { startInteractiveUI: doStartUI } = await import("./interactiveCli-NKFQZXB5.js");
|
|
18629
19078
|
await doStartUI(
|
|
18630
19079
|
config,
|
|
18631
19080
|
settings,
|
|
@@ -18744,6 +19193,7 @@ async function main() {
|
|
|
18744
19193
|
});
|
|
18745
19194
|
adminControlsListner.setConfig(partialConfig);
|
|
18746
19195
|
let initialAuthFailed = false;
|
|
19196
|
+
let initialAuthError = void 0;
|
|
18747
19197
|
if (!settings.merged.security.auth.useExternal && !argv.isCommand) {
|
|
18748
19198
|
try {
|
|
18749
19199
|
if (partialConfig.isInteractive() && settings.merged.security.auth.selectedType) {
|
|
@@ -18771,8 +19221,9 @@ async function main() {
|
|
|
18771
19221
|
process.exit(ExitCodes.SUCCESS);
|
|
18772
19222
|
}
|
|
18773
19223
|
if (!(err instanceof ValidationRequiredError)) {
|
|
18774
|
-
debugLogger.
|
|
19224
|
+
debugLogger.debug("Error authenticating:", err);
|
|
18775
19225
|
initialAuthFailed = true;
|
|
19226
|
+
initialAuthError = err;
|
|
18776
19227
|
}
|
|
18777
19228
|
}
|
|
18778
19229
|
}
|
|
@@ -18808,6 +19259,9 @@ async function main() {
|
|
|
18808
19259
|
const sandboxConfig = await loadSandboxConfig(settings.merged, argv);
|
|
18809
19260
|
if (sandboxConfig) {
|
|
18810
19261
|
if (initialAuthFailed) {
|
|
19262
|
+
writeToStderr(
|
|
19263
|
+
formatCliError(initialAuthError, { debug: isDebugMode2 }) + "\n"
|
|
19264
|
+
);
|
|
18811
19265
|
await runExitCleanup();
|
|
18812
19266
|
process.exit(ExitCodes.FATAL_AUTHENTICATION_ERROR);
|
|
18813
19267
|
}
|
|
@@ -18832,6 +19286,11 @@ ${finalArgs[promptIndex + 1]}`;
|
|
|
18832
19286
|
return finalArgs;
|
|
18833
19287
|
};
|
|
18834
19288
|
const sandboxArgs = injectStdinIntoArgs(process.argv, stdinData);
|
|
19289
|
+
await resolveFolderTrustForSandbox({
|
|
19290
|
+
sandboxCommand: sandboxConfig.command,
|
|
19291
|
+
settings,
|
|
19292
|
+
interactive: partialConfig.isInteractive() && !!process.stdin?.isTTY && !!process.stdout?.isTTY
|
|
19293
|
+
});
|
|
18835
19294
|
await relaunchOnExitCode(
|
|
18836
19295
|
() => start_sandbox(sandboxConfig, memoryArgs, partialConfig, sandboxArgs)
|
|
18837
19296
|
);
|
|
@@ -18850,7 +19309,7 @@ ${finalArgs[promptIndex + 1]}`;
|
|
|
18850
19309
|
await config.storage.initialize();
|
|
18851
19310
|
adminControlsListner.setConfig(config);
|
|
18852
19311
|
if (config.isInteractive() && settings.merged.general.devtools) {
|
|
18853
|
-
const { setupInitialActivityLogger } = await import("./devtoolsService-
|
|
19312
|
+
const { setupInitialActivityLogger } = await import("./devtoolsService-RCBUZGYD.js");
|
|
18854
19313
|
setupInitialActivityLogger(config);
|
|
18855
19314
|
}
|
|
18856
19315
|
registerTelemetryConfig(config);
|
|
@@ -18909,7 +19368,7 @@ ${finalArgs[promptIndex + 1]}`;
|
|
|
18909
19368
|
const initAppHandle = startupProfiler.start("initialize_app");
|
|
18910
19369
|
const initializationResult = await initializeApp(config, settings);
|
|
18911
19370
|
initAppHandle?.end();
|
|
18912
|
-
import("./liteRtServerManager-
|
|
19371
|
+
import("./liteRtServerManager-2IOXWO76.js").then(({ LiteRtServerManager }) => {
|
|
18913
19372
|
const mergedGemma = settings.merged.experimental?.gemmaModelRouter;
|
|
18914
19373
|
if (!mergedGemma) return;
|
|
18915
19374
|
const userGemma = settings.forScope("User" /* User */).settings.experimental?.gemmaModelRouter;
|