@google/gemini-cli 0.68.0-preview.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/bundle/{chunk-VBHMFLBY.js → chunk-2KKDGWF2.js} +1 -1
- package/bundle/{chunk-ODU7Z2RJ.js → chunk-2ONJU4V7.js} +1 -1
- package/bundle/chunk-3HEOCQDN.js +65 -0
- package/bundle/{chunk-HRM7UWGB.js → chunk-4SOPZCNA.js} +22 -6
- package/bundle/{chunk-JMHCFAD6.js → chunk-6KCLIS6W.js} +1 -1
- package/bundle/{chunk-CXMHAFLN.js → chunk-BRHBBQC5.js} +2 -2
- package/bundle/{chunk-KKKD4FID.js → chunk-C5BED6L6.js} +2 -2
- package/bundle/{chunk-OZOUOK43.js → chunk-CGQSFR2I.js} +7 -2
- package/bundle/{chunk-RD2EMHV2.js → chunk-CWHEOJXF.js} +7 -2
- package/bundle/{chunk-ZZOOHVBL.js → chunk-DWMZSQYG.js} +4479 -1925
- package/bundle/{chunk-ZEK4UYYW.js → chunk-GDCMMKZ2.js} +1 -1
- package/bundle/{chunk-44PCK4QK.js → chunk-GQ7FZNO2.js} +1 -1
- package/bundle/{chunk-XPTXBYQQ.js → chunk-JJWPYMIO.js} +3 -3
- package/bundle/{chunk-L57AYV6U.js → chunk-KUXCUQKX.js} +4357 -1897
- package/bundle/{chunk-6A5BTTNC.js → chunk-LYKP3S67.js} +22 -6
- package/bundle/{chunk-RCF66HCI.js → chunk-MP4TVGOP.js} +4479 -1925
- package/bundle/{chunk-XVNEFQR3.js → chunk-PH5XENTH.js} +1 -1
- package/bundle/{chunk-B2FKXXUH.js → chunk-RBDD6IBU.js} +617 -228
- package/bundle/{chunk-BKVNBJ5C.js → chunk-SYOIMUZI.js} +617 -228
- package/bundle/{chunk-VCO4TMD6.js → chunk-U3FFDEKY.js} +22 -6
- package/bundle/{chunk-LQDISFTJ.js → chunk-U5FJ6OGB.js} +2 -2
- package/bundle/{chunk-WEP47ZZU.js → chunk-UAHZWXSG.js} +7 -2
- package/bundle/chunk-UW3ZS3BH.js +65 -0
- package/bundle/{chunk-Q76ZDILI.js → chunk-V7L3FMBE.js} +3 -3
- package/bundle/chunk-VQTELFV3.js +65 -0
- package/bundle/{chunk-YPPJDFYP.js → chunk-YODS6HR2.js} +3 -3
- package/bundle/{chunk-G7EMTV2Q.js → chunk-YP5TA33N.js} +617 -228
- package/bundle/{cleanup-CCR2EOHA.js → cleanup-3T2KXSP4.js} +2 -2
- package/bundle/{cleanup-OQV2G5Y3.js → cleanup-NNQCI4KC.js} +2 -2
- package/bundle/{cleanup-T24OFMOA.js → cleanup-TA4VYDXQ.js} +2 -2
- package/bundle/{core-NQRKBS47.js → core-6XF5EO7Z.js} +35 -1
- package/bundle/{core-UIPNZ5VU.js → core-TUJHM7E7.js} +35 -1
- package/bundle/{devtoolsService-3G5ZA3JV.js → devtoolsService-7EMPANTX.js} +2 -2
- package/bundle/{devtoolsService-V3OEHE5V.js → devtoolsService-I7WFRUEA.js} +2 -2
- package/bundle/{devtoolsService-EWNQDTC7.js → devtoolsService-RCBUZGYD.js} +2 -2
- package/bundle/{dist-OYZDNSTI.js → dist-OSQFIX7F.js} +35 -1
- package/bundle/docs/changelogs/index.md +18 -0
- package/bundle/docs/changelogs/latest.md +89 -84
- package/bundle/docs/changelogs/preview.md +106 -92
- package/bundle/docs/cli/themes.md +50 -5
- package/bundle/docs/cli/trusted-folders.md +13 -0
- package/bundle/docs/reference/commands.md +4 -0
- package/bundle/docs/reference/configuration.md +8 -0
- 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-YFCTZ76S.js → gemini-22ON2CZG.js} +493 -132
- package/bundle/{gemini-FSHMUCSM.js → gemini-HLS52ZNZ.js} +493 -132
- package/bundle/{gemini-2P73372G.js → gemini-ZZZEFPSK.js} +493 -132
- package/bundle/gemini.js +14 -13
- package/bundle/{interactiveCli-F5RRE2VJ.js → interactiveCli-5HMWVTK2.js} +1641 -1208
- package/bundle/{interactiveCli-X54KN2EM.js → interactiveCli-HQBE3C3C.js} +1641 -1208
- package/bundle/{interactiveCli-I75IWUIA.js → interactiveCli-NKFQZXB5.js} +1641 -1208
- package/bundle/{liteRtServerManager-JTOIS4KU.js → liteRtServerManager-2IOXWO76.js} +4 -4
- package/bundle/{liteRtServerManager-UVQ2I6NL.js → liteRtServerManager-AG4Y5JMZ.js} +4 -4
- package/bundle/{liteRtServerManager-FLPMMDNM.js → liteRtServerManager-OFNVXXQ4.js} +4 -4
- package/bundle/{oauth2-provider-AYO4BU7A.js → oauth2-provider-2DHNJ2S3.js} +1 -1
- package/bundle/{oauth2-provider-NCQY7TJE.js → oauth2-provider-OEGXLWIL.js} +1 -1
- package/bundle/{oauth2-provider-VMBYZOC7.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-IXQ2E7L6.js → start-7GJH3MKY.js} +6 -6
- package/bundle/{start-YEKGRZVH.js → start-JSVKPUTV.js} +6 -6
- package/bundle/{start-DFHM4HI4.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-JJWPYMIO.js";
|
|
6
|
+
import {
|
|
7
|
+
formatCliError
|
|
8
|
+
} from "./chunk-UW3ZS3BH.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-RBDD6IBU.js";
|
|
49
52
|
import {
|
|
50
53
|
exitCli,
|
|
51
54
|
require_source
|
|
52
|
-
} from "./chunk-
|
|
55
|
+
} from "./chunk-6KCLIS6W.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-LYKP3S67.js";
|
|
93
96
|
import {
|
|
94
97
|
RELAUNCH_EXIT_CODE,
|
|
95
98
|
require_semver
|
|
96
|
-
} from "./chunk-
|
|
97
|
-
import "./chunk-
|
|
99
|
+
} from "./chunk-U5FJ6OGB.js";
|
|
100
|
+
import "./chunk-GDCMMKZ2.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-CWHEOJXF.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-DWMZSQYG.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
|
}
|
|
@@ -6718,7 +6725,7 @@ async function handleEnable3(args) {
|
|
|
6718
6725
|
const result = enableSkill(settings, name);
|
|
6719
6726
|
const feedback = renderSkillActionFeedback(
|
|
6720
6727
|
result,
|
|
6721
|
-
(label,
|
|
6728
|
+
(label, path19) => `${import_chalk5.default.bold(label)} (${import_chalk5.default.dim(path19)})`
|
|
6722
6729
|
);
|
|
6723
6730
|
debugLogger.log(feedback);
|
|
6724
6731
|
}
|
|
@@ -6748,7 +6755,7 @@ async function handleDisable3(args) {
|
|
|
6748
6755
|
const result = disableSkill(settings, name, scope);
|
|
6749
6756
|
const feedback = renderSkillActionFeedback(
|
|
6750
6757
|
result,
|
|
6751
|
-
(label,
|
|
6758
|
+
(label, path19) => `${import_chalk6.default.bold(label)} (${import_chalk6.default.dim(path19)})`
|
|
6752
6759
|
);
|
|
6753
6760
|
debugLogger.log(feedback);
|
|
6754
6761
|
}
|
|
@@ -7878,6 +7885,16 @@ var RequestPermissionResponseSchema = external_exports.object({
|
|
|
7878
7885
|
})
|
|
7879
7886
|
])
|
|
7880
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
|
+
}
|
|
7881
7898
|
function toToolCallContent(toolResult) {
|
|
7882
7899
|
if (toolResult.error?.message) {
|
|
7883
7900
|
throw new Error(toolResult.error.message);
|
|
@@ -7888,6 +7905,12 @@ function toToolCallContent(toolResult) {
|
|
|
7888
7905
|
type: "content",
|
|
7889
7906
|
content: { type: "text", text: toolResult.returnDisplay }
|
|
7890
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 } };
|
|
7891
7914
|
} else {
|
|
7892
7915
|
if ("fileName" in toolResult.returnDisplay) {
|
|
7893
7916
|
return {
|
|
@@ -8364,7 +8387,7 @@ async function loadSandboxConfig(settings, argv) {
|
|
|
8364
8387
|
}
|
|
8365
8388
|
const command2 = getSandboxCommand(sandboxValue);
|
|
8366
8389
|
const packageJson = await getPackageJson(__dirname3);
|
|
8367
|
-
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-nightly.20261104.g89e9d25d6" ?? customImage ?? packageJson?.config?.sandboxImageUri;
|
|
8368
8391
|
const isNative = command2 === "windows-native" || command2 === "sandbox-exec" || command2 === "lxc";
|
|
8369
8392
|
return command2 && (image || isNative) ? { enabled: true, allowedPaths, networkAccess, command: command2, image } : void 0;
|
|
8370
8393
|
}
|
|
@@ -8767,6 +8790,40 @@ async function parseArguments(settings) {
|
|
|
8767
8790
|
} else if (typeof queryArg === "string") {
|
|
8768
8791
|
q = queryArg;
|
|
8769
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
|
+
}
|
|
8770
8827
|
if (q && !result["prompt"]) {
|
|
8771
8828
|
if (!isHeadlessMode()) {
|
|
8772
8829
|
startupMessages.push(
|
|
@@ -9097,12 +9154,13 @@ async function loadCliConfig(settings, sessionId, argv, options = {}) {
|
|
|
9097
9154
|
usageStatisticsEnabled: settings.privacy?.usageStatisticsEnabled,
|
|
9098
9155
|
fileFiltering,
|
|
9099
9156
|
checkpointing: settings.general?.checkpointing?.enabled,
|
|
9100
|
-
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"],
|
|
9101
9158
|
cwd,
|
|
9102
9159
|
fileDiscoveryService: fileService,
|
|
9103
9160
|
bugCommand: settings.advanced?.bugCommand,
|
|
9104
9161
|
model: resolvedModel,
|
|
9105
9162
|
maxSessionTurns: settings.model?.maxSessionTurns,
|
|
9163
|
+
requestTimeoutMs: settings.model?.requestTimeoutMs,
|
|
9106
9164
|
listExtensions: argv.listExtensions || false,
|
|
9107
9165
|
listSessions: argv.listSessions || false,
|
|
9108
9166
|
deleteSession: argv.deleteSession,
|
|
@@ -9233,22 +9291,30 @@ async function resolveWorktreeSettings(cwd) {
|
|
|
9233
9291
|
}
|
|
9234
9292
|
|
|
9235
9293
|
// packages/cli/src/utils/readStdin.ts
|
|
9236
|
-
function
|
|
9237
|
-
|
|
9238
|
-
if (buf.length <= maxBytes) return
|
|
9294
|
+
function truncateUtf8Buffer(buf, maxBytes) {
|
|
9295
|
+
if (maxBytes <= 0) return "";
|
|
9296
|
+
if (buf.length <= maxBytes) return buf.toString("utf8");
|
|
9239
9297
|
let end = maxBytes;
|
|
9240
9298
|
while (end > 0 && (buf[end] & 192) === 128) {
|
|
9241
9299
|
end--;
|
|
9242
9300
|
}
|
|
9243
9301
|
return buf.subarray(0, end).toString("utf8");
|
|
9244
9302
|
}
|
|
9303
|
+
function truncateUtf8Bytes(str, maxBytes) {
|
|
9304
|
+
if (maxBytes <= 0) return "";
|
|
9305
|
+
return truncateUtf8Buffer(Buffer.from(str, "utf8"), maxBytes);
|
|
9306
|
+
}
|
|
9245
9307
|
async function readStdin() {
|
|
9308
|
+
if (process.stdin.isTTY || process.stdin.destroyed || process.stdin.readableEnded) {
|
|
9309
|
+
return "";
|
|
9310
|
+
}
|
|
9246
9311
|
const MAX_STDIN_SIZE = 8 * 1024 * 1024;
|
|
9247
9312
|
return new Promise((resolve10, reject) => {
|
|
9248
9313
|
let data = "";
|
|
9249
9314
|
let totalSize = 0;
|
|
9315
|
+
let settled = false;
|
|
9250
9316
|
process.stdin.setEncoding("utf8");
|
|
9251
|
-
const pipedInputShouldBeAvailableInMs =
|
|
9317
|
+
const pipedInputShouldBeAvailableInMs = 1e3;
|
|
9252
9318
|
let pipedInputTimerId = setTimeout(() => {
|
|
9253
9319
|
onEnd();
|
|
9254
9320
|
}, pipedInputShouldBeAvailableInMs);
|
|
@@ -9259,26 +9325,46 @@ async function readStdin() {
|
|
|
9259
9325
|
clearTimeout(pipedInputTimerId);
|
|
9260
9326
|
pipedInputTimerId = null;
|
|
9261
9327
|
}
|
|
9262
|
-
|
|
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
|
+
}
|
|
9263
9338
|
if (totalSize + chunkByteLength > MAX_STDIN_SIZE) {
|
|
9264
9339
|
const remainingBytes = MAX_STDIN_SIZE - totalSize;
|
|
9265
|
-
data += truncateUtf8Bytes(
|
|
9340
|
+
data += chunkBuffer ? truncateUtf8Buffer(chunkBuffer, remainingBytes) : truncateUtf8Bytes(chunkStr, remainingBytes);
|
|
9266
9341
|
debugLogger.warn(
|
|
9267
9342
|
`Warning: stdin input truncated to ${MAX_STDIN_SIZE} bytes.`
|
|
9268
9343
|
);
|
|
9269
|
-
|
|
9270
|
-
|
|
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);
|
|
9271
9353
|
break;
|
|
9272
9354
|
}
|
|
9273
|
-
data +=
|
|
9355
|
+
data += chunkBuffer ? chunkBuffer.toString("utf8") : chunkStr;
|
|
9274
9356
|
totalSize += chunkByteLength;
|
|
9275
9357
|
}
|
|
9276
9358
|
};
|
|
9277
9359
|
const onEnd = () => {
|
|
9360
|
+
if (settled) return;
|
|
9361
|
+
settled = true;
|
|
9278
9362
|
cleanup();
|
|
9279
9363
|
resolve10(data);
|
|
9280
9364
|
};
|
|
9281
9365
|
const onError = (err) => {
|
|
9366
|
+
if (settled) return;
|
|
9367
|
+
settled = true;
|
|
9282
9368
|
cleanup();
|
|
9283
9369
|
reject(err);
|
|
9284
9370
|
};
|
|
@@ -9307,7 +9393,7 @@ import { createHash as createHash2 } from "node:crypto";
|
|
|
9307
9393
|
import v8 from "node:v8";
|
|
9308
9394
|
import os6 from "node:os";
|
|
9309
9395
|
import dns from "node:dns";
|
|
9310
|
-
import * as
|
|
9396
|
+
import * as path18 from "node:path";
|
|
9311
9397
|
import * as fsPromises from "node:fs/promises";
|
|
9312
9398
|
|
|
9313
9399
|
// packages/cli/src/utils/sandbox.ts
|
|
@@ -9646,6 +9732,9 @@ var BUILTIN_SEATBELT_PROFILE_CONTENTS = {
|
|
|
9646
9732
|
(global-name "com.apple.SystemConfiguration.DNSConfiguration")
|
|
9647
9733
|
(global-name "com.apple.SystemConfiguration.configd")
|
|
9648
9734
|
)
|
|
9735
|
+
(allow mach-lookup
|
|
9736
|
+
(global-name "com.apple.FSEvents")
|
|
9737
|
+
)
|
|
9649
9738
|
(allow system-socket
|
|
9650
9739
|
(require-all
|
|
9651
9740
|
(socket-domain AF_SYSTEM)
|
|
@@ -9812,6 +9901,9 @@ var BUILTIN_SEATBELT_PROFILE_CONTENTS = {
|
|
|
9812
9901
|
(global-name "com.apple.SystemConfiguration.DNSConfiguration")
|
|
9813
9902
|
(global-name "com.apple.SystemConfiguration.configd")
|
|
9814
9903
|
)
|
|
9904
|
+
(allow mach-lookup
|
|
9905
|
+
(global-name "com.apple.FSEvents")
|
|
9906
|
+
)
|
|
9815
9907
|
(allow system-socket
|
|
9816
9908
|
(require-all
|
|
9817
9909
|
(socket-domain AF_SYSTEM)
|
|
@@ -9900,6 +9992,7 @@ var BUILTIN_SEATBELT_PROFILE_CONTENTS = {
|
|
|
9900
9992
|
(allow file-read*
|
|
9901
9993
|
(literal (string-append (param "HOME_DIR") "/.gemini/settings.json"))
|
|
9902
9994
|
(literal (string-append (param "HOME_DIR") "/.gemini/keybindings.json"))
|
|
9995
|
+
(literal (string-append (param "HOME_DIR") "/.gemini/theme.json"))
|
|
9903
9996
|
)
|
|
9904
9997
|
(allow process-exec)
|
|
9905
9998
|
(allow process-fork)
|
|
@@ -10047,6 +10140,7 @@ var BUILTIN_SEATBELT_PROFILE_CONTENTS = {
|
|
|
10047
10140
|
(allow file-read*
|
|
10048
10141
|
(literal (string-append (param "HOME_DIR") "/.gemini/settings.json"))
|
|
10049
10142
|
(literal (string-append (param "HOME_DIR") "/.gemini/keybindings.json"))
|
|
10143
|
+
(literal (string-append (param "HOME_DIR") "/.gemini/theme.json"))
|
|
10050
10144
|
)
|
|
10051
10145
|
(allow process-exec)
|
|
10052
10146
|
(allow process-fork)
|
|
@@ -10197,6 +10291,7 @@ var BUILTIN_SEATBELT_PROFILE_CONTENTS = {
|
|
|
10197
10291
|
(subpath (param "CACHE_DIR"))
|
|
10198
10292
|
(literal (string-append (param "HOME_DIR") "/.gemini/settings.json"))
|
|
10199
10293
|
(literal (string-append (param "HOME_DIR") "/.gemini/keybindings.json"))
|
|
10294
|
+
(literal (string-append (param "HOME_DIR") "/.gemini/theme.json"))
|
|
10200
10295
|
(subpath (string-append (param "HOME_DIR") "/.npm"))
|
|
10201
10296
|
(subpath (string-append (param "HOME_DIR") "/.cache"))
|
|
10202
10297
|
(literal (string-append (param "HOME_DIR") "/.gitconfig"))
|
|
@@ -10370,6 +10465,7 @@ var BUILTIN_SEATBELT_PROFILE_CONTENTS = {
|
|
|
10370
10465
|
(subpath (param "CACHE_DIR"))
|
|
10371
10466
|
(literal (string-append (param "HOME_DIR") "/.gemini/settings.json"))
|
|
10372
10467
|
(literal (string-append (param "HOME_DIR") "/.gemini/keybindings.json"))
|
|
10468
|
+
(literal (string-append (param "HOME_DIR") "/.gemini/theme.json"))
|
|
10373
10469
|
(subpath (string-append (param "HOME_DIR") "/.npm"))
|
|
10374
10470
|
(subpath (string-append (param "HOME_DIR") "/.cache"))
|
|
10375
10471
|
(literal (string-append (param "HOME_DIR") "/.gitconfig"))
|
|
@@ -12571,6 +12667,159 @@ async function ensureSandboxImageIsPresent(sandbox, image, cliConfig) {
|
|
|
12571
12667
|
return false;
|
|
12572
12668
|
}
|
|
12573
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
|
+
|
|
12574
12823
|
// packages/cli/src/utils/startupWarnings.ts
|
|
12575
12824
|
import fs8 from "node:fs/promises";
|
|
12576
12825
|
import os4 from "node:os";
|
|
@@ -12598,7 +12847,7 @@ async function getStartupWarnings() {
|
|
|
12598
12847
|
// packages/cli/src/utils/userStartupWarnings.ts
|
|
12599
12848
|
import fs9 from "node:fs/promises";
|
|
12600
12849
|
import { homedir as osHomedir } from "node:os";
|
|
12601
|
-
import
|
|
12850
|
+
import path12 from "node:path";
|
|
12602
12851
|
import process5 from "node:process";
|
|
12603
12852
|
var homeDirectoryCheck = {
|
|
12604
12853
|
id: "home-directory",
|
|
@@ -12612,7 +12861,7 @@ var homeDirectoryCheck = {
|
|
|
12612
12861
|
fs9.realpath(workspaceRoot),
|
|
12613
12862
|
fs9.realpath(osHomedir())
|
|
12614
12863
|
]);
|
|
12615
|
-
if (
|
|
12864
|
+
if (path12.resolve(workspaceRealPath) === path12.resolve(homeRealPath)) {
|
|
12616
12865
|
if (isFolderTrustEnabled(settings) && isWorkspaceTrusted(settings).isTrusted) {
|
|
12617
12866
|
return null;
|
|
12618
12867
|
}
|
|
@@ -12631,7 +12880,7 @@ var rootDirectoryCheck = {
|
|
|
12631
12880
|
try {
|
|
12632
12881
|
const workspaceRealPath = await fs9.realpath(workspaceRoot);
|
|
12633
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.";
|
|
12634
|
-
if (
|
|
12883
|
+
if (path12.dirname(workspaceRealPath) === workspaceRealPath) {
|
|
12635
12884
|
return errorMessage;
|
|
12636
12885
|
}
|
|
12637
12886
|
return null;
|
|
@@ -12690,7 +12939,7 @@ async function getUserStartupWarnings(settings, workspaceRoot = process5.cwd(),
|
|
|
12690
12939
|
}
|
|
12691
12940
|
|
|
12692
12941
|
// packages/cli/src/nonInteractiveCli.ts
|
|
12693
|
-
import
|
|
12942
|
+
import readline4 from "node:readline";
|
|
12694
12943
|
|
|
12695
12944
|
// packages/cli/src/ui/noninteractive/nonInteractiveUi.ts
|
|
12696
12945
|
function createNonInteractiveUI() {
|
|
@@ -12897,8 +13146,11 @@ function handleToolError(toolName, toolError, config, errorType, resultDisplay)
|
|
|
12897
13146
|
}
|
|
12898
13147
|
debugLogger.warn(errorMessage);
|
|
12899
13148
|
}
|
|
12900
|
-
function handleCancellationError(config) {
|
|
12901
|
-
const cancellationError = new FatalCancellationError(
|
|
13149
|
+
function handleCancellationError(config, exitCode = 130) {
|
|
13150
|
+
const cancellationError = new FatalCancellationError(
|
|
13151
|
+
"Operation cancelled.",
|
|
13152
|
+
exitCode
|
|
13153
|
+
);
|
|
12902
13154
|
if (config.getOutputFormat() === "stream-json" /* STREAM_JSON */) {
|
|
12903
13155
|
const streamFormatter = new StreamJsonFormatter();
|
|
12904
13156
|
const metrics = uiTelemetryService.getMetrics();
|
|
@@ -13014,7 +13266,7 @@ var TextOutput = class {
|
|
|
13014
13266
|
};
|
|
13015
13267
|
|
|
13016
13268
|
// packages/cli/src/nonInteractiveCliAgentSession.ts
|
|
13017
|
-
import
|
|
13269
|
+
import readline3 from "node:readline";
|
|
13018
13270
|
async function runNonInteractive({
|
|
13019
13271
|
config,
|
|
13020
13272
|
settings,
|
|
@@ -13032,7 +13284,7 @@ async function runNonInteractive({
|
|
|
13032
13284
|
}
|
|
13033
13285
|
});
|
|
13034
13286
|
if (process.env["GEMINI_CLI_ACTIVITY_LOG_TARGET"]) {
|
|
13035
|
-
const { setupInitialActivityLogger } = await import("./devtoolsService-
|
|
13287
|
+
const { setupInitialActivityLogger } = await import("./devtoolsService-7EMPANTX.js");
|
|
13036
13288
|
setupInitialActivityLogger(config);
|
|
13037
13289
|
}
|
|
13038
13290
|
const { stdout: workingStdout } = createWorkingStdio();
|
|
@@ -13063,9 +13315,17 @@ async function runNonInteractive({
|
|
|
13063
13315
|
}
|
|
13064
13316
|
throw err;
|
|
13065
13317
|
};
|
|
13066
|
-
|
|
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
|
+
}
|
|
13067
13327
|
if (isAborting) {
|
|
13068
|
-
process.exit(
|
|
13328
|
+
process.exit(abortExitCode);
|
|
13069
13329
|
}
|
|
13070
13330
|
isAborting = true;
|
|
13071
13331
|
cancelMessageTimer = setTimeout(() => {
|
|
@@ -13073,30 +13333,35 @@ async function runNonInteractive({
|
|
|
13073
13333
|
}, 200);
|
|
13074
13334
|
abortController.abort();
|
|
13075
13335
|
};
|
|
13336
|
+
const onSigint = () => triggerAbort("SIGINT");
|
|
13337
|
+
const onSigterm = () => triggerAbort("SIGTERM");
|
|
13338
|
+
const onSighup = () => triggerAbort("SIGHUP");
|
|
13076
13339
|
const setupCancellation = () => {
|
|
13077
|
-
process.on("SIGINT",
|
|
13078
|
-
process.on("SIGTERM",
|
|
13340
|
+
process.on("SIGINT", onSigint);
|
|
13341
|
+
process.on("SIGTERM", onSigterm);
|
|
13342
|
+
process.on("SIGHUP", onSighup);
|
|
13079
13343
|
if (!process.stdin?.isTTY) {
|
|
13080
13344
|
return;
|
|
13081
13345
|
}
|
|
13082
13346
|
stdinWasRaw = process.stdin.isRaw || false;
|
|
13083
13347
|
process.stdin.setRawMode(true);
|
|
13084
13348
|
process.stdin.resume();
|
|
13085
|
-
rl =
|
|
13349
|
+
rl = readline3.createInterface({
|
|
13086
13350
|
input: process.stdin,
|
|
13087
13351
|
escapeCodeTimeout: 0
|
|
13088
13352
|
});
|
|
13089
|
-
|
|
13353
|
+
readline3.emitKeypressEvents(process.stdin, rl);
|
|
13090
13354
|
keypressHandler = (str, key) => {
|
|
13091
13355
|
if (key && key.ctrl && key.name === "c" || str === "") {
|
|
13092
|
-
triggerAbort();
|
|
13356
|
+
triggerAbort("SIGINT");
|
|
13093
13357
|
}
|
|
13094
13358
|
};
|
|
13095
13359
|
process.stdin.on("keypress", keypressHandler);
|
|
13096
13360
|
};
|
|
13097
13361
|
const cleanupCancellation = () => {
|
|
13098
|
-
process.off("SIGINT",
|
|
13099
|
-
process.off("SIGTERM",
|
|
13362
|
+
process.off("SIGINT", onSigint);
|
|
13363
|
+
process.off("SIGTERM", onSigterm);
|
|
13364
|
+
process.off("SIGHUP", onSighup);
|
|
13100
13365
|
process.stdout.off("error", handleStdoutError);
|
|
13101
13366
|
if (cancelMessageTimer) {
|
|
13102
13367
|
clearTimeout(cancelMessageTimer);
|
|
@@ -13202,7 +13467,7 @@ async function runNonInteractive({
|
|
|
13202
13467
|
};
|
|
13203
13468
|
abortController.signal.addEventListener("abort", abortSession);
|
|
13204
13469
|
if (abortController.signal.aborted) {
|
|
13205
|
-
throw new FatalCancellationError("Operation cancelled.");
|
|
13470
|
+
throw new FatalCancellationError("Operation cancelled.", abortExitCode);
|
|
13206
13471
|
}
|
|
13207
13472
|
const { streamId } = await session.send({
|
|
13208
13473
|
message: {
|
|
@@ -13248,64 +13513,63 @@ async function runNonInteractive({
|
|
|
13248
13513
|
const reconstructFatalError = (event) => {
|
|
13249
13514
|
const errorMeta = event._meta;
|
|
13250
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);
|
|
13251
13525
|
let errToThrow;
|
|
13252
13526
|
switch (name) {
|
|
13253
13527
|
case "FatalAuthenticationError":
|
|
13254
|
-
errToThrow = new FatalAuthenticationError(
|
|
13528
|
+
errToThrow = new FatalAuthenticationError(normalized.message);
|
|
13255
13529
|
break;
|
|
13256
13530
|
case "FatalInputError":
|
|
13257
|
-
errToThrow = new FatalInputError(
|
|
13531
|
+
errToThrow = new FatalInputError(normalized.message);
|
|
13258
13532
|
break;
|
|
13259
13533
|
case "FatalSandboxError":
|
|
13260
|
-
errToThrow = new FatalSandboxError(
|
|
13534
|
+
errToThrow = new FatalSandboxError(normalized.message);
|
|
13261
13535
|
break;
|
|
13262
13536
|
case "FatalConfigError":
|
|
13263
|
-
errToThrow = new FatalConfigError(
|
|
13537
|
+
errToThrow = new FatalConfigError(normalized.message);
|
|
13264
13538
|
break;
|
|
13265
13539
|
case "FatalTurnLimitedError":
|
|
13266
|
-
errToThrow = new FatalTurnLimitedError(
|
|
13540
|
+
errToThrow = new FatalTurnLimitedError(normalized.message);
|
|
13267
13541
|
break;
|
|
13268
13542
|
case "FatalToolExecutionError":
|
|
13269
|
-
errToThrow = new FatalToolExecutionError(
|
|
13543
|
+
errToThrow = new FatalToolExecutionError(normalized.message);
|
|
13270
13544
|
break;
|
|
13271
13545
|
case "FatalCancellationError":
|
|
13272
|
-
errToThrow = new FatalCancellationError(
|
|
13546
|
+
errToThrow = new FatalCancellationError(
|
|
13547
|
+
normalized.message,
|
|
13548
|
+
abortExitCode
|
|
13549
|
+
);
|
|
13273
13550
|
break;
|
|
13274
13551
|
case "FatalError":
|
|
13275
13552
|
errToThrow = new FatalError(
|
|
13276
|
-
|
|
13553
|
+
normalized.message,
|
|
13277
13554
|
typeof errorMeta?.["exitCode"] === "number" ? errorMeta["exitCode"] : 1
|
|
13278
13555
|
);
|
|
13279
13556
|
break;
|
|
13280
13557
|
default:
|
|
13281
|
-
errToThrow =
|
|
13282
|
-
|
|
13283
|
-
|
|
13284
|
-
|
|
13285
|
-
|
|
13286
|
-
}
|
|
13287
|
-
|
|
13558
|
+
errToThrow = Object.assign(
|
|
13559
|
+
new Error(
|
|
13560
|
+
normalized.message,
|
|
13561
|
+
rawError !== void 0 ? { cause: rawError } : void 0
|
|
13562
|
+
),
|
|
13563
|
+
name ? { name } : {}
|
|
13564
|
+
);
|
|
13288
13565
|
break;
|
|
13289
13566
|
}
|
|
13290
|
-
|
|
13291
|
-
|
|
13292
|
-
|
|
13293
|
-
|
|
13294
|
-
}
|
|
13295
|
-
}
|
|
13296
|
-
if (errorMeta?.["code"] !== void 0) {
|
|
13297
|
-
Object.defineProperty(errToThrow, "code", {
|
|
13298
|
-
value: errorMeta["code"],
|
|
13299
|
-
enumerable: true
|
|
13300
|
-
});
|
|
13301
|
-
}
|
|
13302
|
-
if (errorMeta?.["status"] !== void 0) {
|
|
13303
|
-
Object.defineProperty(errToThrow, "status", {
|
|
13304
|
-
value: errorMeta["status"],
|
|
13305
|
-
enumerable: true
|
|
13306
|
-
});
|
|
13307
|
-
}
|
|
13308
|
-
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
|
+
});
|
|
13309
13573
|
};
|
|
13310
13574
|
let responseText = "";
|
|
13311
13575
|
let preToolResponseText;
|
|
@@ -13532,7 +13796,8 @@ async function runNonInteractive({
|
|
|
13532
13796
|
await runExitCleanup();
|
|
13533
13797
|
}
|
|
13534
13798
|
if (abortController.signal.aborted || isFatalCancellationError(errorToHandle)) {
|
|
13535
|
-
|
|
13799
|
+
const exitCode = isFatalCancellationError(errorToHandle) ? errorToHandle.exitCode : abortExitCode;
|
|
13800
|
+
handleCancellationError(config, exitCode);
|
|
13536
13801
|
}
|
|
13537
13802
|
if (errorToHandle) {
|
|
13538
13803
|
handleError(errorToHandle, config);
|
|
@@ -13560,7 +13825,7 @@ async function runNonInteractive2(params) {
|
|
|
13560
13825
|
}
|
|
13561
13826
|
});
|
|
13562
13827
|
if (process.env["GEMINI_CLI_ACTIVITY_LOG_TARGET"]) {
|
|
13563
|
-
const { setupInitialActivityLogger } = await import("./devtoolsService-
|
|
13828
|
+
const { setupInitialActivityLogger } = await import("./devtoolsService-7EMPANTX.js");
|
|
13564
13829
|
setupInitialActivityLogger(config);
|
|
13565
13830
|
}
|
|
13566
13831
|
const { stdout: workingStdout } = createWorkingStdio();
|
|
@@ -13591,9 +13856,17 @@ async function runNonInteractive2(params) {
|
|
|
13591
13856
|
}
|
|
13592
13857
|
throw err;
|
|
13593
13858
|
};
|
|
13594
|
-
|
|
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
|
+
}
|
|
13595
13868
|
if (isAborting) {
|
|
13596
|
-
process.exit(
|
|
13869
|
+
process.exit(abortExitCode);
|
|
13597
13870
|
}
|
|
13598
13871
|
isAborting = true;
|
|
13599
13872
|
cancelMessageTimer = setTimeout(() => {
|
|
@@ -13601,30 +13874,35 @@ async function runNonInteractive2(params) {
|
|
|
13601
13874
|
}, 200);
|
|
13602
13875
|
abortController.abort();
|
|
13603
13876
|
};
|
|
13877
|
+
const handleSigInt = () => triggerAbort("SIGINT");
|
|
13878
|
+
const handleSigTerm = () => triggerAbort("SIGTERM");
|
|
13879
|
+
const handleSigHup = () => triggerAbort("SIGHUP");
|
|
13604
13880
|
const setupCancellation = () => {
|
|
13605
|
-
process.on("SIGINT",
|
|
13606
|
-
process.on("SIGTERM",
|
|
13881
|
+
process.on("SIGINT", handleSigInt);
|
|
13882
|
+
process.on("SIGTERM", handleSigTerm);
|
|
13883
|
+
process.on("SIGHUP", handleSigHup);
|
|
13607
13884
|
if (!process.stdin?.isTTY) {
|
|
13608
13885
|
return;
|
|
13609
13886
|
}
|
|
13610
13887
|
stdinWasRaw = process.stdin.isRaw || false;
|
|
13611
13888
|
process.stdin.setRawMode(true);
|
|
13612
13889
|
process.stdin.resume();
|
|
13613
|
-
rl =
|
|
13890
|
+
rl = readline4.createInterface({
|
|
13614
13891
|
input: process.stdin,
|
|
13615
13892
|
escapeCodeTimeout: 0
|
|
13616
13893
|
});
|
|
13617
|
-
|
|
13894
|
+
readline4.emitKeypressEvents(process.stdin, rl);
|
|
13618
13895
|
keypressHandler = (str, key) => {
|
|
13619
13896
|
if (key && key.ctrl && key.name === "c" || str === "") {
|
|
13620
|
-
triggerAbort();
|
|
13897
|
+
triggerAbort("SIGINT");
|
|
13621
13898
|
}
|
|
13622
13899
|
};
|
|
13623
13900
|
process.stdin.on("keypress", keypressHandler);
|
|
13624
13901
|
};
|
|
13625
13902
|
const cleanupCancellation = () => {
|
|
13626
|
-
process.off("SIGINT",
|
|
13627
|
-
process.off("SIGTERM",
|
|
13903
|
+
process.off("SIGINT", handleSigInt);
|
|
13904
|
+
process.off("SIGTERM", handleSigTerm);
|
|
13905
|
+
process.off("SIGHUP", handleSigHup);
|
|
13628
13906
|
process.stdout.off("error", handleStdoutError);
|
|
13629
13907
|
if (cancelMessageTimer) {
|
|
13630
13908
|
clearTimeout(cancelMessageTimer);
|
|
@@ -13737,7 +14015,7 @@ async function runNonInteractive2(params) {
|
|
|
13737
14015
|
let responseText = "";
|
|
13738
14016
|
for await (const event of responseStream) {
|
|
13739
14017
|
if (abortController.signal.aborted) {
|
|
13740
|
-
handleCancellationError(config);
|
|
14018
|
+
handleCancellationError(config, abortExitCode);
|
|
13741
14019
|
}
|
|
13742
14020
|
if (event.type === "content" /* Content */) {
|
|
13743
14021
|
const isRaw = config.getRawOutput() || config.getAcceptRawOutputRisk();
|
|
@@ -13791,7 +14069,20 @@ async function runNonInteractive2(params) {
|
|
|
13791
14069
|
}
|
|
13792
14070
|
warnings.push(message);
|
|
13793
14071
|
} else if (event.type === "error" /* Error */) {
|
|
13794
|
-
|
|
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;
|
|
13795
14086
|
} else if (event.type === "agent_execution_stopped" /* AgentExecutionStopped */) {
|
|
13796
14087
|
const stopMessage = `Agent execution stopped: ${event.value.systemMessage?.trim() || event.value.reason}`;
|
|
13797
14088
|
if (config.getOutputFormat() === "text" /* TEXT */) {
|
|
@@ -13880,13 +14171,27 @@ async function runNonInteractive2(params) {
|
|
|
13880
14171
|
}
|
|
13881
14172
|
if (toolCallRequests.length > 0) {
|
|
13882
14173
|
if (abortController.signal.aborted) {
|
|
13883
|
-
throw new FatalCancellationError(
|
|
14174
|
+
throw new FatalCancellationError(
|
|
14175
|
+
"Operation cancelled.",
|
|
14176
|
+
abortExitCode
|
|
14177
|
+
);
|
|
13884
14178
|
}
|
|
13885
14179
|
textOutput.ensureTrailingNewline();
|
|
13886
|
-
|
|
13887
|
-
|
|
13888
|
-
|
|
13889
|
-
|
|
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
|
+
}
|
|
13890
14195
|
const toolResponseParts = [];
|
|
13891
14196
|
for (const completedToolCall of completedToolCalls) {
|
|
13892
14197
|
const toolResponse = completedToolCall.response;
|
|
@@ -13964,6 +14269,12 @@ async function runNonInteractive2(params) {
|
|
|
13964
14269
|
}
|
|
13965
14270
|
return;
|
|
13966
14271
|
}
|
|
14272
|
+
if (abortController.signal.aborted) {
|
|
14273
|
+
throw new FatalCancellationError(
|
|
14274
|
+
"Operation cancelled.",
|
|
14275
|
+
abortExitCode
|
|
14276
|
+
);
|
|
14277
|
+
}
|
|
13967
14278
|
currentMessages = [{ role: "user", parts: toolResponseParts }];
|
|
13968
14279
|
} else {
|
|
13969
14280
|
if (streamFormatter) {
|
|
@@ -14003,7 +14314,8 @@ async function runNonInteractive2(params) {
|
|
|
14003
14314
|
await runExitCleanup();
|
|
14004
14315
|
}
|
|
14005
14316
|
if (abortController.signal.aborted || isFatalCancellationError(errorToHandle)) {
|
|
14006
|
-
|
|
14317
|
+
const exitCode = isFatalCancellationError(errorToHandle) ? errorToHandle.exitCode : abortExitCode;
|
|
14318
|
+
handleCancellationError(config, exitCode);
|
|
14007
14319
|
}
|
|
14008
14320
|
if (errorToHandle) {
|
|
14009
14321
|
handleError(errorToHandle, config);
|
|
@@ -15549,7 +15861,7 @@ var RequestError = class _RequestError extends Error {
|
|
|
15549
15861
|
};
|
|
15550
15862
|
|
|
15551
15863
|
// packages/cli/src/acp/acpStdioTransport.ts
|
|
15552
|
-
import { Readable, Writable } from "node:stream";
|
|
15864
|
+
import { Readable, Writable as Writable2 } from "node:stream";
|
|
15553
15865
|
|
|
15554
15866
|
// packages/cli/src/acp/acpErrors.ts
|
|
15555
15867
|
function getAcpErrorMessage(error) {
|
|
@@ -15576,7 +15888,7 @@ import { randomUUID as randomUUID2 } from "node:crypto";
|
|
|
15576
15888
|
|
|
15577
15889
|
// packages/cli/src/acp/acpSession.ts
|
|
15578
15890
|
import * as fs12 from "node:fs/promises";
|
|
15579
|
-
import * as
|
|
15891
|
+
import * as path15 from "node:path";
|
|
15580
15892
|
import { randomUUID } from "node:crypto";
|
|
15581
15893
|
|
|
15582
15894
|
// packages/cli/src/acp/commands/commandRegistry.ts
|
|
@@ -16018,7 +16330,7 @@ var UpdateExtensionCommand = class {
|
|
|
16018
16330
|
|
|
16019
16331
|
// packages/cli/src/acp/commands/init.ts
|
|
16020
16332
|
import * as fs10 from "node:fs";
|
|
16021
|
-
import * as
|
|
16333
|
+
import * as path13 from "node:path";
|
|
16022
16334
|
var InitCommand = class {
|
|
16023
16335
|
name = "init";
|
|
16024
16336
|
description = "Analyzes the project and creates a tailored GEMINI.md file";
|
|
@@ -16028,7 +16340,7 @@ var InitCommand = class {
|
|
|
16028
16340
|
if (!targetDir) {
|
|
16029
16341
|
throw new Error("Command requires a workspace.");
|
|
16030
16342
|
}
|
|
16031
|
-
const geminiMdPath =
|
|
16343
|
+
const geminiMdPath = path13.join(targetDir, "GEMINI.md");
|
|
16032
16344
|
const result = performInit(fs10.existsSync(geminiMdPath));
|
|
16033
16345
|
switch (result.type) {
|
|
16034
16346
|
case "message":
|
|
@@ -16061,7 +16373,7 @@ ${result.content}`
|
|
|
16061
16373
|
|
|
16062
16374
|
// packages/cli/src/acp/commands/restore.ts
|
|
16063
16375
|
import * as fs11 from "node:fs/promises";
|
|
16064
|
-
import * as
|
|
16376
|
+
import * as path14 from "node:path";
|
|
16065
16377
|
var RestoreCommand = class {
|
|
16066
16378
|
name = "restore";
|
|
16067
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";
|
|
@@ -16083,7 +16395,7 @@ var RestoreCommand = class {
|
|
|
16083
16395
|
}
|
|
16084
16396
|
const selectedFile = argsStr.endsWith(".json") ? argsStr : `${argsStr}.json`;
|
|
16085
16397
|
const checkpointDir = config.storage.getProjectTempCheckpointsDir();
|
|
16086
|
-
const filePath =
|
|
16398
|
+
const filePath = path14.join(checkpointDir, selectedFile);
|
|
16087
16399
|
let data;
|
|
16088
16400
|
try {
|
|
16089
16401
|
data = await fs11.readFile(filePath, "utf-8");
|
|
@@ -16157,7 +16469,7 @@ var ListCheckpointsCommand = class {
|
|
|
16157
16469
|
}
|
|
16158
16470
|
const checkpointFiles = /* @__PURE__ */ new Map();
|
|
16159
16471
|
for (const file of jsonFiles) {
|
|
16160
|
-
const filePath =
|
|
16472
|
+
const filePath = path14.join(checkpointDir, file);
|
|
16161
16473
|
const data = await fs11.readFile(filePath, "utf-8");
|
|
16162
16474
|
checkpointFiles.set(file, data);
|
|
16163
16475
|
}
|
|
@@ -16367,6 +16679,7 @@ var Session = class {
|
|
|
16367
16679
|
"approval-mode-changed" /* ApprovalModeChanged */,
|
|
16368
16680
|
this.handleApprovalModeChanged
|
|
16369
16681
|
);
|
|
16682
|
+
coreEvents.on("retry-attempt" /* RetryAttempt */, this.handleRetryAttempt);
|
|
16370
16683
|
this.context.config.getMessageBus()?.subscribe(
|
|
16371
16684
|
"tool-confirmation-request" /* TOOL_CONFIRMATION_REQUEST */,
|
|
16372
16685
|
this.handleToolConfirmationRequest,
|
|
@@ -16460,11 +16773,26 @@ var Session = class {
|
|
|
16460
16773
|
});
|
|
16461
16774
|
}
|
|
16462
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
|
+
};
|
|
16463
16790
|
async dispose() {
|
|
16464
16791
|
coreEvents.off(
|
|
16465
16792
|
"approval-mode-changed" /* ApprovalModeChanged */,
|
|
16466
16793
|
this.handleApprovalModeChanged
|
|
16467
16794
|
);
|
|
16795
|
+
coreEvents.off("retry-attempt" /* RetryAttempt */, this.handleRetryAttempt);
|
|
16468
16796
|
this.disposeController.abort();
|
|
16469
16797
|
if (this.context.config?.dispose) {
|
|
16470
16798
|
try {
|
|
@@ -16641,6 +16969,7 @@ ${thought.description}`;
|
|
|
16641
16969
|
let currentParts = parts;
|
|
16642
16970
|
let turnCount = 0;
|
|
16643
16971
|
const maxTurns = this.context.config.getMaxSessionTurns();
|
|
16972
|
+
let isFirstChunkAfterRetry = false;
|
|
16644
16973
|
while (true) {
|
|
16645
16974
|
turnCount++;
|
|
16646
16975
|
if (maxTurns >= 0 && turnCount > maxTurns) {
|
|
@@ -16672,10 +17001,13 @@ ${thought.description}`;
|
|
|
16672
17001
|
type: "text",
|
|
16673
17002
|
text: event.value
|
|
16674
17003
|
};
|
|
16675
|
-
|
|
17004
|
+
const update = {
|
|
16676
17005
|
sessionUpdate: "agent_message_chunk",
|
|
16677
|
-
content
|
|
16678
|
-
|
|
17006
|
+
content,
|
|
17007
|
+
...isFirstChunkAfterRetry ? { _meta: { retry: true, reset: true } } : {}
|
|
17008
|
+
};
|
|
17009
|
+
isFirstChunkAfterRetry = false;
|
|
17010
|
+
await this.sendUpdate(update);
|
|
16679
17011
|
break;
|
|
16680
17012
|
}
|
|
16681
17013
|
case "thought" /* Thought */: {
|
|
@@ -16687,6 +17019,22 @@ ${event.value.description}`;
|
|
|
16687
17019
|
});
|
|
16688
17020
|
break;
|
|
16689
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
|
+
}
|
|
16690
17038
|
case "tool_call_request" /* ToolCallRequest */:
|
|
16691
17039
|
toolCallRequests.push(event.value);
|
|
16692
17040
|
break;
|
|
@@ -17158,7 +17506,7 @@ ${event.value.description}`;
|
|
|
17158
17506
|
} else if (result.status === "invalid") {
|
|
17159
17507
|
continue;
|
|
17160
17508
|
} else {
|
|
17161
|
-
absolutePath =
|
|
17509
|
+
absolutePath = path15.resolve(
|
|
17162
17510
|
this.context.config.getTargetDir(),
|
|
17163
17511
|
pathName
|
|
17164
17512
|
);
|
|
@@ -17232,7 +17580,7 @@ ${event.value.description}`;
|
|
|
17232
17580
|
}
|
|
17233
17581
|
try {
|
|
17234
17582
|
if (!validationError) {
|
|
17235
|
-
if ((
|
|
17583
|
+
if ((path15.isAbsolute(pathName) || !isWithinRoot(
|
|
17236
17584
|
absolutePath,
|
|
17237
17585
|
this.context.config.getTargetDir()
|
|
17238
17586
|
)) && !readDirectly) {
|
|
@@ -17330,7 +17678,7 @@ ${contentToPush}`;
|
|
|
17330
17678
|
const lines = globResult.llmContent.split("\n");
|
|
17331
17679
|
if (lines.length > 1 && lines[1]) {
|
|
17332
17680
|
const firstMatchAbsolute = lines[1].trim();
|
|
17333
|
-
currentPathSpec =
|
|
17681
|
+
currentPathSpec = path15.relative(
|
|
17334
17682
|
this.context.config.getTargetDir(),
|
|
17335
17683
|
firstMatchAbsolute
|
|
17336
17684
|
);
|
|
@@ -17455,13 +17803,15 @@ ${REFERENCE_CONTENT_START}`
|
|
|
17455
17803
|
const match = fileContentRegex.exec(part);
|
|
17456
17804
|
if (match) {
|
|
17457
17805
|
const filePathSpecInContent = match[1];
|
|
17458
|
-
const fileActualContent = match[2]
|
|
17806
|
+
const fileActualContent = match[2];
|
|
17459
17807
|
processedQueryParts.push({
|
|
17460
17808
|
text: `
|
|
17461
17809
|
Content from @${filePathSpecInContent}:
|
|
17462
17810
|
`
|
|
17463
17811
|
});
|
|
17464
|
-
|
|
17812
|
+
if (fileActualContent !== "") {
|
|
17813
|
+
processedQueryParts.push({ text: fileActualContent });
|
|
17814
|
+
}
|
|
17465
17815
|
} else {
|
|
17466
17816
|
processedQueryParts.push({ text: part });
|
|
17467
17817
|
}
|
|
@@ -17551,7 +17901,7 @@ Content from @${contextPart.uri}:
|
|
|
17551
17901
|
|
|
17552
17902
|
// packages/cli/src/acp/acpFileSystemService.ts
|
|
17553
17903
|
import os5 from "node:os";
|
|
17554
|
-
import
|
|
17904
|
+
import path16 from "node:path";
|
|
17555
17905
|
var AcpFileSystemService = class {
|
|
17556
17906
|
constructor(connection, sessionId, capabilities, fallback, root) {
|
|
17557
17907
|
this.connection = connection;
|
|
@@ -17560,7 +17910,7 @@ var AcpFileSystemService = class {
|
|
|
17560
17910
|
this.fallback = fallback;
|
|
17561
17911
|
this.root = root;
|
|
17562
17912
|
}
|
|
17563
|
-
geminiDir =
|
|
17913
|
+
geminiDir = path16.join(os5.homedir(), ".gemini");
|
|
17564
17914
|
shouldUseFallback(filePath) {
|
|
17565
17915
|
return !isWithinRoot(filePath, this.root) || isWithinRoot(filePath, this.geminiDir);
|
|
17566
17916
|
}
|
|
@@ -18115,7 +18465,7 @@ var GeminiAgent = class {
|
|
|
18115
18465
|
// packages/cli/src/acp/acpStdioTransport.ts
|
|
18116
18466
|
async function runAcpClient(config, settings, argv) {
|
|
18117
18467
|
const { stdout: workingStdout } = createWorkingStdio();
|
|
18118
|
-
const stdout =
|
|
18468
|
+
const stdout = Writable2.toWeb(workingStdout);
|
|
18119
18469
|
const stdin = Readable.toWeb(process.stdin);
|
|
18120
18470
|
const stream = ndJsonStream(stdout, stdin);
|
|
18121
18471
|
const connection = new AgentSideConnection(
|
|
@@ -18261,6 +18611,7 @@ async function setupTerminalAndTheme(config, settings) {
|
|
|
18261
18611
|
terminalCapabilityManager.areAmbiguousCharactersWide()
|
|
18262
18612
|
);
|
|
18263
18613
|
}
|
|
18614
|
+
themeManager.loadUserThemes?.();
|
|
18264
18615
|
themeManager.loadCustomThemes(settings.merged.ui.customThemes);
|
|
18265
18616
|
if (settings.merged.ui.theme) {
|
|
18266
18617
|
if (!themeManager.setActiveTheme(settings.merged.ui.theme)) {
|
|
@@ -18294,7 +18645,7 @@ async function setupTerminalAndTheme(config, settings) {
|
|
|
18294
18645
|
|
|
18295
18646
|
// packages/cli/src/utils/logCleanup.ts
|
|
18296
18647
|
import { promises as fs13 } from "node:fs";
|
|
18297
|
-
import * as
|
|
18648
|
+
import * as path17 from "node:path";
|
|
18298
18649
|
var RETENTION_PERIOD_MS = 7 * 24 * 60 * 60 * 1e3;
|
|
18299
18650
|
async function cleanupBackgroundLogs(debugMode = false) {
|
|
18300
18651
|
try {
|
|
@@ -18309,7 +18660,7 @@ async function cleanupBackgroundLogs(debugMode = false) {
|
|
|
18309
18660
|
let deletedCount = 0;
|
|
18310
18661
|
for (const entry of entries) {
|
|
18311
18662
|
if (entry.isFile() && entry.name.endsWith(".log")) {
|
|
18312
|
-
const filePath =
|
|
18663
|
+
const filePath = path17.join(logDir, entry.name);
|
|
18313
18664
|
try {
|
|
18314
18665
|
const stats = await fs13.stat(filePath);
|
|
18315
18666
|
if (now - stats.mtime.getTime() > RETENTION_PERIOD_MS) {
|
|
@@ -18654,8 +19005,8 @@ async function resolveSessionId(resumeArg, sessionIdArg, sessionFileArg) {
|
|
|
18654
19005
|
sessionData.projectHash = getProjectHash(storage.getProjectRoot());
|
|
18655
19006
|
sessionData.startTime = isoNow;
|
|
18656
19007
|
sessionData.lastUpdated = isoNow;
|
|
18657
|
-
const chatsDir =
|
|
18658
|
-
const newSessionPath =
|
|
19008
|
+
const chatsDir = path18.join(storage.getProjectTempDir(), "chats");
|
|
19009
|
+
const newSessionPath = path18.join(
|
|
18659
19010
|
chatsDir,
|
|
18660
19011
|
`session-${now}-${newSessionId.slice(0, 8)}.jsonl`
|
|
18661
19012
|
);
|
|
@@ -18723,7 +19074,7 @@ async function resolveSessionId(resumeArg, sessionIdArg, sessionFileArg) {
|
|
|
18723
19074
|
}
|
|
18724
19075
|
}
|
|
18725
19076
|
async function startInteractiveUI(config, settings, startupWarnings, workspaceRoot = process.cwd(), resumedSessionData, initializationResult) {
|
|
18726
|
-
const { startInteractiveUI: doStartUI } = await import("./interactiveCli-
|
|
19077
|
+
const { startInteractiveUI: doStartUI } = await import("./interactiveCli-HQBE3C3C.js");
|
|
18727
19078
|
await doStartUI(
|
|
18728
19079
|
config,
|
|
18729
19080
|
settings,
|
|
@@ -18842,6 +19193,7 @@ async function main() {
|
|
|
18842
19193
|
});
|
|
18843
19194
|
adminControlsListner.setConfig(partialConfig);
|
|
18844
19195
|
let initialAuthFailed = false;
|
|
19196
|
+
let initialAuthError = void 0;
|
|
18845
19197
|
if (!settings.merged.security.auth.useExternal && !argv.isCommand) {
|
|
18846
19198
|
try {
|
|
18847
19199
|
if (partialConfig.isInteractive() && settings.merged.security.auth.selectedType) {
|
|
@@ -18869,8 +19221,9 @@ async function main() {
|
|
|
18869
19221
|
process.exit(ExitCodes.SUCCESS);
|
|
18870
19222
|
}
|
|
18871
19223
|
if (!(err instanceof ValidationRequiredError)) {
|
|
18872
|
-
debugLogger.
|
|
19224
|
+
debugLogger.debug("Error authenticating:", err);
|
|
18873
19225
|
initialAuthFailed = true;
|
|
19226
|
+
initialAuthError = err;
|
|
18874
19227
|
}
|
|
18875
19228
|
}
|
|
18876
19229
|
}
|
|
@@ -18906,6 +19259,9 @@ async function main() {
|
|
|
18906
19259
|
const sandboxConfig = await loadSandboxConfig(settings.merged, argv);
|
|
18907
19260
|
if (sandboxConfig) {
|
|
18908
19261
|
if (initialAuthFailed) {
|
|
19262
|
+
writeToStderr(
|
|
19263
|
+
formatCliError(initialAuthError, { debug: isDebugMode2 }) + "\n"
|
|
19264
|
+
);
|
|
18909
19265
|
await runExitCleanup();
|
|
18910
19266
|
process.exit(ExitCodes.FATAL_AUTHENTICATION_ERROR);
|
|
18911
19267
|
}
|
|
@@ -18930,6 +19286,11 @@ ${finalArgs[promptIndex + 1]}`;
|
|
|
18930
19286
|
return finalArgs;
|
|
18931
19287
|
};
|
|
18932
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
|
+
});
|
|
18933
19294
|
await relaunchOnExitCode(
|
|
18934
19295
|
() => start_sandbox(sandboxConfig, memoryArgs, partialConfig, sandboxArgs)
|
|
18935
19296
|
);
|
|
@@ -18948,7 +19309,7 @@ ${finalArgs[promptIndex + 1]}`;
|
|
|
18948
19309
|
await config.storage.initialize();
|
|
18949
19310
|
adminControlsListner.setConfig(config);
|
|
18950
19311
|
if (config.isInteractive() && settings.merged.general.devtools) {
|
|
18951
|
-
const { setupInitialActivityLogger } = await import("./devtoolsService-
|
|
19312
|
+
const { setupInitialActivityLogger } = await import("./devtoolsService-7EMPANTX.js");
|
|
18952
19313
|
setupInitialActivityLogger(config);
|
|
18953
19314
|
}
|
|
18954
19315
|
registerTelemetryConfig(config);
|
|
@@ -19007,7 +19368,7 @@ ${finalArgs[promptIndex + 1]}`;
|
|
|
19007
19368
|
const initAppHandle = startupProfiler.start("initialize_app");
|
|
19008
19369
|
const initializationResult = await initializeApp(config, settings);
|
|
19009
19370
|
initAppHandle?.end();
|
|
19010
|
-
import("./liteRtServerManager-
|
|
19371
|
+
import("./liteRtServerManager-AG4Y5JMZ.js").then(({ LiteRtServerManager }) => {
|
|
19011
19372
|
const mergedGemma = settings.merged.experimental?.gemmaModelRouter;
|
|
19012
19373
|
if (!mergedGemma) return;
|
|
19013
19374
|
const userGemma = settings.forScope("User" /* User */).settings.experimental?.gemmaModelRouter;
|