@google/gemini-cli 0.40.0-preview.2 → 0.40.0-preview.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundle/{chunk-3GU3LF3I.js → chunk-4XVBQQNJ.js} +181 -16
- package/bundle/{chunk-PLUWJHZZ.js → chunk-547AWTTH.js} +238 -61
- package/bundle/{chunk-EFCQXWIF.js → chunk-63PTTRTA.js} +3 -3
- package/bundle/{chunk-IMEC72NS.js → chunk-ATGIEBEB.js} +1 -1
- package/bundle/{chunk-WL5MCPV2.js → chunk-BV2W6YE6.js} +2 -2
- package/bundle/{chunk-QK7UWGBN.js → chunk-CIO3GUGQ.js} +1382 -1083
- package/bundle/{chunk-HV36F4CL.js → chunk-CJQVVQSH.js} +134 -354
- package/bundle/{chunk-VCGILCZV.js → chunk-F73F75XM.js} +16 -0
- package/bundle/{chunk-TDW6FM3A.js → chunk-G356GKHH.js} +1 -1
- package/bundle/{chunk-4IJPDKI6.js → chunk-H4NQBTXN.js} +146 -364
- package/bundle/{chunk-GXRQOXQF.js → chunk-H7F2VOIJ.js} +178 -14
- package/bundle/chunk-HF7X35D3.js +80012 -0
- package/bundle/{chunk-WHIWQCI5.js → chunk-HGFADN5A.js} +1 -1
- package/bundle/{chunk-NO7STVVM.js → chunk-KG7ZFMJL.js} +1413 -1089
- package/bundle/{chunk-33ANPP4S.js → chunk-LMVZLINC.js} +3 -3
- package/bundle/chunk-LODNDE3S.js +17505 -0
- package/bundle/{chunk-IUVLJUOL.js → chunk-LVHUYMBU.js} +2 -2
- package/bundle/{chunk-NIVCRM5L.js → chunk-M76FWZ5L.js} +134 -354
- package/bundle/{chunk-RM43GNQQ.js → chunk-NV6UCR4K.js} +7711 -12909
- package/bundle/{chunk-MUGUV6RZ.js → chunk-PRZIW6SM.js} +2 -2
- package/bundle/chunk-RENFZ63F.js +351149 -0
- package/bundle/chunk-SYPUOR3U.js +156 -0
- package/bundle/{chunk-2RHFUIH4.js → chunk-UHHRGNIO.js} +16 -0
- package/bundle/chunk-VQ7N6NVX.js +1571 -0
- package/bundle/{chunk-UBXB5AEJ.js → chunk-WSTHO4WR.js} +3 -3
- package/bundle/chunk-ZQNX6OWU.js +118 -0
- package/bundle/{cleanup-A7WXWAMI.js → cleanup-4EFDM2N7.js} +3 -3
- package/bundle/{cleanup-EWPIME2M.js → cleanup-4RRVO4GO.js} +3 -3
- package/bundle/{cleanup-IPLJJT5S.js → cleanup-DNS7PXYC.js} +3 -3
- package/bundle/cleanup-DXHNV2J6.js +33 -0
- package/bundle/{core-VCDK23ZC.js → core-WQSFCPEO.js} +28 -2
- package/bundle/{devtoolsService-6Y6YER6T.js → devtoolsService-JWET4G6G.js} +3 -3
- package/bundle/{devtoolsService-B5VVZ752.js → devtoolsService-LPEBYJVD.js} +3 -3
- package/bundle/{devtoolsService-2JXSALRU.js → devtoolsService-S2LBUUZU.js} +5 -4
- package/bundle/devtoolsService-YCRNWWXE.js +852 -0
- package/bundle/{dist-UIXQETMC.js → dist-ANTOB3YW.js} +28 -2
- package/bundle/{core-BQT6T3CH.js → dist-RIVCP5ZD.js} +28 -2
- package/bundle/dist-UH565MTG.js +2046 -0
- package/bundle/docs/cli/cli-reference.md +1 -0
- package/bundle/docs/cli/trusted-folders.md +28 -0
- package/bundle/docs/reference/configuration.md +14 -0
- package/bundle/{gemini-ID44Z5SV.js → gemini-27FQ5BI4.js} +66 -22
- package/bundle/{gemini-54LH6RUH.js → gemini-57EC2ZF7.js} +241 -182
- package/bundle/{gemini-44W2QEZI.js → gemini-JAZVYRDD.js} +64 -21
- package/bundle/gemini-TQZRS37Q.js +16087 -0
- package/bundle/gemini.js +3 -3
- package/bundle/{interactiveCli-5MTJDFYC.js → interactiveCli-E35R6QQC.js} +17 -167
- package/bundle/{interactiveCli-JFBPGMNM.js → interactiveCli-FPHSBRV3.js} +30 -179
- package/bundle/{interactiveCli-5B3X6RNB.js → interactiveCli-L3EK4XEX.js} +300 -432
- package/bundle/interactiveCli-MVHR4VV7.js +34448 -0
- package/bundle/{liteRtServerManager-76V63PRJ.js → liteRtServerManager-LXEAYAUP.js} +4 -4
- package/bundle/{liteRtServerManager-WQMDPACQ.js → liteRtServerManager-ORSW3R4F.js} +4 -4
- package/bundle/{liteRtServerManager-6GJWEP5W.js → liteRtServerManager-PI4ZNFB5.js} +4 -4
- package/bundle/liteRtServerManager-YYXO5Q3I.js +65 -0
- package/bundle/{memoryDiscovery-RYHYLAPJ.js → memoryDiscovery-CZURD35O.js} +1 -1
- package/bundle/{memoryDiscovery-HWEYBJE7.js → memoryDiscovery-GZLXKRGB.js} +1 -1
- package/bundle/node_modules/@google/gemini-cli-devtools/package.json +1 -1
- package/bundle/{oauth2-provider-EX6SQEZP.js → oauth2-provider-B3NTBNAM.js} +2 -2
- package/bundle/{oauth2-provider-ZF52AWQY.js → oauth2-provider-ENF2D4Q7.js} +39 -73
- package/bundle/{oauth2-provider-JCKLNKRV.js → oauth2-provider-I3G773GE.js} +2 -2
- package/bundle/oauth2-provider-WTF7AHQ2.js +237 -0
- package/bundle/{start-CYDJTOAP.js → start-CRIFZ3SW.js} +6 -6
- package/bundle/{start-SHOUHW3Y.js → start-KVFKS3IT.js} +6 -6
- package/bundle/{start-B6EMQCH5.js → start-OTLGMCNH.js} +6 -6
- package/bundle/start-S3REI3X2.js +18 -0
- package/package.json +1 -1
|
@@ -7,20 +7,20 @@ import {
|
|
|
7
7
|
TOOL_OUTPUTS_DIR,
|
|
8
8
|
ansiRegex,
|
|
9
9
|
checkExhaustive,
|
|
10
|
+
checkPathTrust,
|
|
10
11
|
createCache,
|
|
11
12
|
deleteSessionArtifactsAsync,
|
|
12
13
|
deleteSubagentSessionDirAndArtifactsAsync,
|
|
13
14
|
getFsErrorMessage,
|
|
14
|
-
ideContextStore,
|
|
15
15
|
import_lru_cache,
|
|
16
16
|
isHeadlessMode,
|
|
17
|
-
isWithinRoot,
|
|
18
17
|
loadConversationRecord,
|
|
18
|
+
loadTrustedFolders,
|
|
19
19
|
partListUnionToString,
|
|
20
20
|
require_strip_json_comments,
|
|
21
21
|
sanitizeFilenamePart,
|
|
22
22
|
stripAnsi
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-KG7ZFMJL.js";
|
|
24
24
|
import {
|
|
25
25
|
FatalConfigError,
|
|
26
26
|
GEMINI_DIR,
|
|
@@ -29,9 +29,8 @@ import {
|
|
|
29
29
|
debugLogger,
|
|
30
30
|
external_exports,
|
|
31
31
|
getErrorMessage,
|
|
32
|
-
homedir
|
|
33
|
-
|
|
34
|
-
} from "./chunk-2RHFUIH4.js";
|
|
32
|
+
homedir
|
|
33
|
+
} from "./chunk-UHHRGNIO.js";
|
|
35
34
|
import {
|
|
36
35
|
__commonJS,
|
|
37
36
|
__require,
|
|
@@ -562,10 +561,10 @@ var require_package = __commonJS({
|
|
|
562
561
|
// node_modules/dotenv/lib/main.js
|
|
563
562
|
var require_main = __commonJS({
|
|
564
563
|
"node_modules/dotenv/lib/main.js"(exports, module) {
|
|
565
|
-
var
|
|
566
|
-
var
|
|
564
|
+
var fs6 = __require("fs");
|
|
565
|
+
var path6 = __require("path");
|
|
567
566
|
var os = __require("os");
|
|
568
|
-
var
|
|
567
|
+
var crypto = __require("crypto");
|
|
569
568
|
var packageJson = require_package();
|
|
570
569
|
var version = packageJson.version;
|
|
571
570
|
var TIPS = [
|
|
@@ -692,7 +691,7 @@ var require_main = __commonJS({
|
|
|
692
691
|
if (options && options.path && options.path.length > 0) {
|
|
693
692
|
if (Array.isArray(options.path)) {
|
|
694
693
|
for (const filepath of options.path) {
|
|
695
|
-
if (
|
|
694
|
+
if (fs6.existsSync(filepath)) {
|
|
696
695
|
possibleVaultPath = filepath.endsWith(".vault") ? filepath : `${filepath}.vault`;
|
|
697
696
|
}
|
|
698
697
|
}
|
|
@@ -700,15 +699,15 @@ var require_main = __commonJS({
|
|
|
700
699
|
possibleVaultPath = options.path.endsWith(".vault") ? options.path : `${options.path}.vault`;
|
|
701
700
|
}
|
|
702
701
|
} else {
|
|
703
|
-
possibleVaultPath =
|
|
702
|
+
possibleVaultPath = path6.resolve(process.cwd(), ".env.vault");
|
|
704
703
|
}
|
|
705
|
-
if (
|
|
704
|
+
if (fs6.existsSync(possibleVaultPath)) {
|
|
706
705
|
return possibleVaultPath;
|
|
707
706
|
}
|
|
708
707
|
return null;
|
|
709
708
|
}
|
|
710
709
|
function _resolveHome(envPath) {
|
|
711
|
-
return envPath[0] === "~" ?
|
|
710
|
+
return envPath[0] === "~" ? path6.join(os.homedir(), envPath.slice(1)) : envPath;
|
|
712
711
|
}
|
|
713
712
|
function _configVault(options) {
|
|
714
713
|
const debug = Boolean(options && options.debug);
|
|
@@ -725,7 +724,7 @@ var require_main = __commonJS({
|
|
|
725
724
|
return { parsed };
|
|
726
725
|
}
|
|
727
726
|
function configDotenv(options) {
|
|
728
|
-
const dotenvPath =
|
|
727
|
+
const dotenvPath = path6.resolve(process.cwd(), ".env");
|
|
729
728
|
let encoding = "utf8";
|
|
730
729
|
const debug = Boolean(options && options.debug);
|
|
731
730
|
const quiet = Boolean(options && options.quiet);
|
|
@@ -749,13 +748,13 @@ var require_main = __commonJS({
|
|
|
749
748
|
}
|
|
750
749
|
let lastError;
|
|
751
750
|
const parsedAll = {};
|
|
752
|
-
for (const
|
|
751
|
+
for (const path7 of optionPaths) {
|
|
753
752
|
try {
|
|
754
|
-
const parsed = DotenvModule.parse(
|
|
753
|
+
const parsed = DotenvModule.parse(fs6.readFileSync(path7, { encoding }));
|
|
755
754
|
DotenvModule.populate(parsedAll, parsed, options);
|
|
756
755
|
} catch (e) {
|
|
757
756
|
if (debug) {
|
|
758
|
-
_debug(`Failed to load ${
|
|
757
|
+
_debug(`Failed to load ${path7} ${e.message}`);
|
|
759
758
|
}
|
|
760
759
|
lastError = e;
|
|
761
760
|
}
|
|
@@ -770,7 +769,7 @@ var require_main = __commonJS({
|
|
|
770
769
|
const shortPaths = [];
|
|
771
770
|
for (const filePath of optionPaths) {
|
|
772
771
|
try {
|
|
773
|
-
const relative =
|
|
772
|
+
const relative = path6.relative(process.cwd(), filePath);
|
|
774
773
|
shortPaths.push(relative);
|
|
775
774
|
} catch (e) {
|
|
776
775
|
if (debug) {
|
|
@@ -805,7 +804,7 @@ var require_main = __commonJS({
|
|
|
805
804
|
const authTag = ciphertext.subarray(-16);
|
|
806
805
|
ciphertext = ciphertext.subarray(12, -16);
|
|
807
806
|
try {
|
|
808
|
-
const aesgcm =
|
|
807
|
+
const aesgcm = crypto.createDecipheriv("aes-256-gcm", key, nonce);
|
|
809
808
|
aesgcm.setAuthTag(authTag);
|
|
810
809
|
return `${aesgcm.update(ciphertext)}${aesgcm.final()}`;
|
|
811
810
|
} catch (error) {
|
|
@@ -9907,10 +9906,10 @@ var require_stringify = __commonJS({
|
|
|
9907
9906
|
replacer = null;
|
|
9908
9907
|
indent = EMPTY;
|
|
9909
9908
|
};
|
|
9910
|
-
var
|
|
9909
|
+
var join3 = (one, two, gap) => one ? two ? one + two.trim() + LF + gap : one.trimRight() + LF + gap : two ? two.trimRight() + LF + gap : EMPTY;
|
|
9911
9910
|
var join_content = (inside, value, gap) => {
|
|
9912
9911
|
const comment = process_comments(value, PREFIX_BEFORE, gap + indent, true);
|
|
9913
|
-
return
|
|
9912
|
+
return join3(comment, inside, gap);
|
|
9914
9913
|
};
|
|
9915
9914
|
var array_stringify = (value, gap) => {
|
|
9916
9915
|
const deeper_gap = gap + indent;
|
|
@@ -9921,7 +9920,7 @@ var require_stringify = __commonJS({
|
|
|
9921
9920
|
if (i !== 0) {
|
|
9922
9921
|
inside += COMMA;
|
|
9923
9922
|
}
|
|
9924
|
-
const before =
|
|
9923
|
+
const before = join3(
|
|
9925
9924
|
after_comma,
|
|
9926
9925
|
process_comments(value, BEFORE(i), deeper_gap),
|
|
9927
9926
|
deeper_gap
|
|
@@ -9931,7 +9930,7 @@ var require_stringify = __commonJS({
|
|
|
9931
9930
|
inside += process_comments(value, AFTER_VALUE(i), deeper_gap);
|
|
9932
9931
|
after_comma = process_comments(value, AFTER(i), deeper_gap);
|
|
9933
9932
|
}
|
|
9934
|
-
inside +=
|
|
9933
|
+
inside += join3(
|
|
9935
9934
|
after_comma,
|
|
9936
9935
|
process_comments(value, PREFIX_AFTER, deeper_gap),
|
|
9937
9936
|
deeper_gap
|
|
@@ -9956,7 +9955,7 @@ var require_stringify = __commonJS({
|
|
|
9956
9955
|
inside += COMMA;
|
|
9957
9956
|
}
|
|
9958
9957
|
first = false;
|
|
9959
|
-
const before =
|
|
9958
|
+
const before = join3(
|
|
9960
9959
|
after_comma,
|
|
9961
9960
|
process_comments(value, BEFORE(key), deeper_gap),
|
|
9962
9961
|
deeper_gap
|
|
@@ -9966,7 +9965,7 @@ var require_stringify = __commonJS({
|
|
|
9966
9965
|
after_comma = process_comments(value, AFTER(key), deeper_gap);
|
|
9967
9966
|
};
|
|
9968
9967
|
keys.forEach(iteratee);
|
|
9969
|
-
inside +=
|
|
9968
|
+
inside += join3(
|
|
9970
9969
|
after_comma,
|
|
9971
9970
|
process_comments(value, PREFIX_AFTER, deeper_gap),
|
|
9972
9971
|
deeper_gap
|
|
@@ -10046,255 +10045,19 @@ var require_src2 = __commonJS({
|
|
|
10046
10045
|
});
|
|
10047
10046
|
|
|
10048
10047
|
// packages/cli/src/config/trustedFolders.ts
|
|
10049
|
-
var import_proper_lockfile = __toESM(require_proper_lockfile(), 1);
|
|
10050
|
-
import * as fs from "node:fs";
|
|
10051
|
-
import * as path from "node:path";
|
|
10052
|
-
import * as crypto from "node:crypto";
|
|
10053
|
-
var import_strip_json_comments = __toESM(require_strip_json_comments(), 1);
|
|
10054
|
-
var { promises: fsPromises } = fs;
|
|
10055
|
-
var TRUSTED_FOLDERS_FILENAME = "trustedFolders.json";
|
|
10056
|
-
function getUserSettingsDir() {
|
|
10057
|
-
return path.join(homedir(), GEMINI_DIR);
|
|
10058
|
-
}
|
|
10059
|
-
function getTrustedFoldersPath() {
|
|
10060
|
-
if (process.env["GEMINI_CLI_TRUSTED_FOLDERS_PATH"]) {
|
|
10061
|
-
return process.env["GEMINI_CLI_TRUSTED_FOLDERS_PATH"];
|
|
10062
|
-
}
|
|
10063
|
-
return path.join(getUserSettingsDir(), TRUSTED_FOLDERS_FILENAME);
|
|
10064
|
-
}
|
|
10065
|
-
var TrustLevel = /* @__PURE__ */ ((TrustLevel2) => {
|
|
10066
|
-
TrustLevel2["TRUST_FOLDER"] = "TRUST_FOLDER";
|
|
10067
|
-
TrustLevel2["TRUST_PARENT"] = "TRUST_PARENT";
|
|
10068
|
-
TrustLevel2["DO_NOT_TRUST"] = "DO_NOT_TRUST";
|
|
10069
|
-
return TrustLevel2;
|
|
10070
|
-
})(TrustLevel || {});
|
|
10071
|
-
function isTrustLevel(value) {
|
|
10072
|
-
return typeof value === "string" && // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
10073
|
-
Object.values(TrustLevel).includes(value);
|
|
10074
|
-
}
|
|
10075
|
-
var realPathCache = /* @__PURE__ */ new Map();
|
|
10076
|
-
function parseTrustedFoldersJson(content) {
|
|
10077
|
-
return JSON.parse((0, import_strip_json_comments.default)(content));
|
|
10078
|
-
}
|
|
10079
|
-
function getRealPath(location) {
|
|
10080
|
-
let realPath = realPathCache.get(location);
|
|
10081
|
-
if (realPath !== void 0) {
|
|
10082
|
-
return realPath;
|
|
10083
|
-
}
|
|
10084
|
-
try {
|
|
10085
|
-
realPath = fs.existsSync(location) ? fs.realpathSync(location) : location;
|
|
10086
|
-
} catch {
|
|
10087
|
-
realPath = location;
|
|
10088
|
-
}
|
|
10089
|
-
realPathCache.set(location, realPath);
|
|
10090
|
-
return realPath;
|
|
10091
|
-
}
|
|
10092
|
-
var LoadedTrustedFolders = class {
|
|
10093
|
-
constructor(user, errors) {
|
|
10094
|
-
this.user = user;
|
|
10095
|
-
this.errors = errors;
|
|
10096
|
-
}
|
|
10097
|
-
get rules() {
|
|
10098
|
-
return Object.entries(this.user.config).map(([path7, trustLevel]) => ({
|
|
10099
|
-
path: path7,
|
|
10100
|
-
trustLevel
|
|
10101
|
-
}));
|
|
10102
|
-
}
|
|
10103
|
-
/**
|
|
10104
|
-
* Returns true or false if the path should be "trusted". This function
|
|
10105
|
-
* should only be invoked when the folder trust setting is active.
|
|
10106
|
-
*
|
|
10107
|
-
* @param location path
|
|
10108
|
-
* @returns
|
|
10109
|
-
*/
|
|
10110
|
-
isPathTrusted(location, config, headlessOptions) {
|
|
10111
|
-
if (isHeadlessMode(headlessOptions)) {
|
|
10112
|
-
return true;
|
|
10113
|
-
}
|
|
10114
|
-
const configToUse = config ?? this.user.config;
|
|
10115
|
-
const realLocation = getRealPath(location);
|
|
10116
|
-
let longestMatchLen = -1;
|
|
10117
|
-
let longestMatchTrust = void 0;
|
|
10118
|
-
for (const [rulePath, trustLevel] of Object.entries(configToUse)) {
|
|
10119
|
-
const effectivePath = trustLevel === "TRUST_PARENT" /* TRUST_PARENT */ ? path.dirname(rulePath) : rulePath;
|
|
10120
|
-
const realEffectivePath = getRealPath(effectivePath);
|
|
10121
|
-
if (isWithinRoot(realLocation, realEffectivePath)) {
|
|
10122
|
-
if (rulePath.length > longestMatchLen) {
|
|
10123
|
-
longestMatchLen = rulePath.length;
|
|
10124
|
-
longestMatchTrust = trustLevel;
|
|
10125
|
-
}
|
|
10126
|
-
}
|
|
10127
|
-
}
|
|
10128
|
-
if (longestMatchTrust === "DO_NOT_TRUST" /* DO_NOT_TRUST */) return false;
|
|
10129
|
-
if (longestMatchTrust === "TRUST_FOLDER" /* TRUST_FOLDER */ || longestMatchTrust === "TRUST_PARENT" /* TRUST_PARENT */)
|
|
10130
|
-
return true;
|
|
10131
|
-
return void 0;
|
|
10132
|
-
}
|
|
10133
|
-
async setValue(folderPath, trustLevel) {
|
|
10134
|
-
if (this.errors.length > 0) {
|
|
10135
|
-
const errorMessages = this.errors.map(
|
|
10136
|
-
(error) => `Error in ${error.path}: ${error.message}`
|
|
10137
|
-
);
|
|
10138
|
-
throw new FatalConfigError(
|
|
10139
|
-
`Cannot update trusted folders because the configuration file is invalid:
|
|
10140
|
-
${errorMessages.join("\n")}
|
|
10141
|
-
Please fix the file manually before trying to update it.`
|
|
10142
|
-
);
|
|
10143
|
-
}
|
|
10144
|
-
const dirPath = path.dirname(this.user.path);
|
|
10145
|
-
if (!fs.existsSync(dirPath)) {
|
|
10146
|
-
await fsPromises.mkdir(dirPath, { recursive: true });
|
|
10147
|
-
}
|
|
10148
|
-
if (!fs.existsSync(this.user.path)) {
|
|
10149
|
-
await fsPromises.writeFile(this.user.path, JSON.stringify({}, null, 2), {
|
|
10150
|
-
mode: 384
|
|
10151
|
-
});
|
|
10152
|
-
}
|
|
10153
|
-
const release = await (0, import_proper_lockfile.lock)(this.user.path, {
|
|
10154
|
-
retries: {
|
|
10155
|
-
retries: 10,
|
|
10156
|
-
minTimeout: 100
|
|
10157
|
-
}
|
|
10158
|
-
});
|
|
10159
|
-
try {
|
|
10160
|
-
const content = await fsPromises.readFile(this.user.path, "utf-8");
|
|
10161
|
-
let config;
|
|
10162
|
-
try {
|
|
10163
|
-
config = parseTrustedFoldersJson(content);
|
|
10164
|
-
} catch (error) {
|
|
10165
|
-
coreEvents.emitFeedback(
|
|
10166
|
-
"error",
|
|
10167
|
-
`Failed to parse trusted folders file at ${this.user.path}. The file may be corrupted.`,
|
|
10168
|
-
error
|
|
10169
|
-
);
|
|
10170
|
-
config = {};
|
|
10171
|
-
}
|
|
10172
|
-
const originalTrustLevel = config[folderPath];
|
|
10173
|
-
config[folderPath] = trustLevel;
|
|
10174
|
-
this.user.config[folderPath] = trustLevel;
|
|
10175
|
-
try {
|
|
10176
|
-
saveTrustedFolders({ ...this.user, config });
|
|
10177
|
-
} catch (e) {
|
|
10178
|
-
if (originalTrustLevel === void 0) {
|
|
10179
|
-
delete this.user.config[folderPath];
|
|
10180
|
-
} else {
|
|
10181
|
-
this.user.config[folderPath] = originalTrustLevel;
|
|
10182
|
-
}
|
|
10183
|
-
throw e;
|
|
10184
|
-
}
|
|
10185
|
-
} finally {
|
|
10186
|
-
await release();
|
|
10187
|
-
}
|
|
10188
|
-
}
|
|
10189
|
-
};
|
|
10190
|
-
var loadedTrustedFolders;
|
|
10191
|
-
function loadTrustedFolders() {
|
|
10192
|
-
if (loadedTrustedFolders) {
|
|
10193
|
-
return loadedTrustedFolders;
|
|
10194
|
-
}
|
|
10195
|
-
const errors = [];
|
|
10196
|
-
const userConfig = {};
|
|
10197
|
-
const userPath = getTrustedFoldersPath();
|
|
10198
|
-
try {
|
|
10199
|
-
if (fs.existsSync(userPath)) {
|
|
10200
|
-
const content = fs.readFileSync(userPath, "utf-8");
|
|
10201
|
-
const parsed = parseTrustedFoldersJson(content);
|
|
10202
|
-
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
|
|
10203
|
-
errors.push({
|
|
10204
|
-
message: "Trusted folders file is not a valid JSON object.",
|
|
10205
|
-
path: userPath
|
|
10206
|
-
});
|
|
10207
|
-
} else {
|
|
10208
|
-
for (const [path7, trustLevel] of Object.entries(parsed)) {
|
|
10209
|
-
if (isTrustLevel(trustLevel)) {
|
|
10210
|
-
userConfig[path7] = trustLevel;
|
|
10211
|
-
} else {
|
|
10212
|
-
const possibleValues = Object.values(TrustLevel).join(", ");
|
|
10213
|
-
errors.push({
|
|
10214
|
-
message: `Invalid trust level "${trustLevel}" for path "${path7}". Possible values are: ${possibleValues}.`,
|
|
10215
|
-
path: userPath
|
|
10216
|
-
});
|
|
10217
|
-
}
|
|
10218
|
-
}
|
|
10219
|
-
}
|
|
10220
|
-
}
|
|
10221
|
-
} catch (error) {
|
|
10222
|
-
errors.push({
|
|
10223
|
-
message: getErrorMessage(error),
|
|
10224
|
-
path: userPath
|
|
10225
|
-
});
|
|
10226
|
-
}
|
|
10227
|
-
loadedTrustedFolders = new LoadedTrustedFolders(
|
|
10228
|
-
{ path: userPath, config: userConfig },
|
|
10229
|
-
errors
|
|
10230
|
-
);
|
|
10231
|
-
return loadedTrustedFolders;
|
|
10232
|
-
}
|
|
10233
|
-
function saveTrustedFolders(trustedFoldersFile) {
|
|
10234
|
-
const dirPath = path.dirname(trustedFoldersFile.path);
|
|
10235
|
-
if (!fs.existsSync(dirPath)) {
|
|
10236
|
-
fs.mkdirSync(dirPath, { recursive: true });
|
|
10237
|
-
}
|
|
10238
|
-
const content = JSON.stringify(trustedFoldersFile.config, null, 2);
|
|
10239
|
-
const tempPath = `${trustedFoldersFile.path}.tmp.${crypto.randomUUID()}`;
|
|
10240
|
-
try {
|
|
10241
|
-
fs.writeFileSync(tempPath, content, {
|
|
10242
|
-
encoding: "utf-8",
|
|
10243
|
-
mode: 384
|
|
10244
|
-
});
|
|
10245
|
-
fs.renameSync(tempPath, trustedFoldersFile.path);
|
|
10246
|
-
} catch (error) {
|
|
10247
|
-
if (fs.existsSync(tempPath)) {
|
|
10248
|
-
try {
|
|
10249
|
-
fs.unlinkSync(tempPath);
|
|
10250
|
-
} catch {
|
|
10251
|
-
}
|
|
10252
|
-
}
|
|
10253
|
-
throw error;
|
|
10254
|
-
}
|
|
10255
|
-
}
|
|
10256
10048
|
function isFolderTrustEnabled(settings) {
|
|
10257
10049
|
const folderTrustSetting = settings.security?.folderTrust?.enabled ?? true;
|
|
10258
10050
|
return folderTrustSetting;
|
|
10259
10051
|
}
|
|
10260
|
-
function
|
|
10261
|
-
|
|
10262
|
-
const configToUse = trustConfig ?? folders.user.config;
|
|
10263
|
-
if (folders.errors.length > 0) {
|
|
10264
|
-
const errorMessages = folders.errors.map(
|
|
10265
|
-
(error) => `Error in ${error.path}: ${error.message}`
|
|
10266
|
-
);
|
|
10267
|
-
throw new FatalConfigError(
|
|
10268
|
-
`${errorMessages.join("\n")}
|
|
10269
|
-
Please fix the configuration file and try again.`
|
|
10270
|
-
);
|
|
10271
|
-
}
|
|
10272
|
-
const isTrusted = folders.isPathTrusted(
|
|
10273
|
-
workspaceDir,
|
|
10274
|
-
configToUse,
|
|
10275
|
-
headlessOptions
|
|
10276
|
-
);
|
|
10277
|
-
return {
|
|
10278
|
-
isTrusted,
|
|
10279
|
-
source: isTrusted !== void 0 ? "file" : void 0
|
|
10280
|
-
};
|
|
10052
|
+
function loadTrustedFolders2() {
|
|
10053
|
+
return loadTrustedFolders();
|
|
10281
10054
|
}
|
|
10282
|
-
function isWorkspaceTrusted(settings, workspaceDir = process.cwd(),
|
|
10283
|
-
|
|
10284
|
-
|
|
10285
|
-
|
|
10286
|
-
|
|
10287
|
-
|
|
10288
|
-
}
|
|
10289
|
-
const ideTrust = ideContextStore.get()?.workspaceState?.isTrusted;
|
|
10290
|
-
if (ideTrust !== void 0) {
|
|
10291
|
-
return { isTrusted: ideTrust, source: "ide" };
|
|
10292
|
-
}
|
|
10293
|
-
return getWorkspaceTrustFromLocalConfig(
|
|
10294
|
-
workspaceDir,
|
|
10295
|
-
trustConfig,
|
|
10296
|
-
headlessOptions
|
|
10297
|
-
);
|
|
10055
|
+
function isWorkspaceTrusted(settings, workspaceDir = process.cwd(), headlessOptions) {
|
|
10056
|
+
return checkPathTrust({
|
|
10057
|
+
path: workspaceDir,
|
|
10058
|
+
isFolderTrustEnabled: isFolderTrustEnabled(settings),
|
|
10059
|
+
isHeadless: isHeadlessMode(headlessOptions)
|
|
10060
|
+
});
|
|
10298
10061
|
}
|
|
10299
10062
|
|
|
10300
10063
|
// packages/cli/src/ui/types.ts
|
|
@@ -10323,8 +10086,8 @@ var isTodoList = (res) => typeof res === "object" && res !== null && "todos" in
|
|
|
10323
10086
|
var emptyIcon = " ";
|
|
10324
10087
|
|
|
10325
10088
|
// packages/cli/src/utils/sessionUtils.ts
|
|
10326
|
-
import * as
|
|
10327
|
-
import
|
|
10089
|
+
import * as fs from "node:fs/promises";
|
|
10090
|
+
import path from "node:path";
|
|
10328
10091
|
|
|
10329
10092
|
// packages/cli/src/ui/utils/textUtils.ts
|
|
10330
10093
|
import { stripVTControlCharacters } from "node:util";
|
|
@@ -10660,13 +10423,13 @@ var formatRelativeTime = (timestamp, style = "long") => {
|
|
|
10660
10423
|
};
|
|
10661
10424
|
var getAllSessionFiles = async (chatsDir, currentSessionId, options = {}) => {
|
|
10662
10425
|
try {
|
|
10663
|
-
const files = await
|
|
10426
|
+
const files = await fs.readdir(chatsDir);
|
|
10664
10427
|
const sessionFiles = files.filter(
|
|
10665
10428
|
(f) => f.startsWith(SESSION_FILE_PREFIX) && (f.endsWith(".json") || f.endsWith(".jsonl"))
|
|
10666
10429
|
).sort();
|
|
10667
10430
|
const sessionPromises = sessionFiles.map(
|
|
10668
10431
|
async (file) => {
|
|
10669
|
-
const filePath =
|
|
10432
|
+
const filePath = path.join(chatsDir, file);
|
|
10670
10433
|
try {
|
|
10671
10434
|
const content = await loadConversationRecord(filePath, {
|
|
10672
10435
|
metadataOnly: !options.includeFullContent
|
|
@@ -10756,7 +10519,7 @@ var SessionSelector = class {
|
|
|
10756
10519
|
* Lists all available sessions for the current project.
|
|
10757
10520
|
*/
|
|
10758
10521
|
async listSessions() {
|
|
10759
|
-
const chatsDir =
|
|
10522
|
+
const chatsDir = path.join(this.storage.getProjectTempDir(), "chats");
|
|
10760
10523
|
return getSessionFiles(chatsDir);
|
|
10761
10524
|
}
|
|
10762
10525
|
/**
|
|
@@ -10785,7 +10548,7 @@ var SessionSelector = class {
|
|
|
10785
10548
|
if (!isNaN(index) && index.toString() === trimmedIdentifier && index > 0 && index <= sortedSessions.length) {
|
|
10786
10549
|
return sortedSessions[index - 1];
|
|
10787
10550
|
}
|
|
10788
|
-
const chatsDir =
|
|
10551
|
+
const chatsDir = path.join(this.storage.getProjectTempDir(), "chats");
|
|
10789
10552
|
throw SessionError.invalidSessionIdentifier(trimmedIdentifier, chatsDir);
|
|
10790
10553
|
}
|
|
10791
10554
|
/**
|
|
@@ -10824,8 +10587,8 @@ var SessionSelector = class {
|
|
|
10824
10587
|
* Loads session data for a selected session.
|
|
10825
10588
|
*/
|
|
10826
10589
|
async selectSession(sessionInfo) {
|
|
10827
|
-
const chatsDir =
|
|
10828
|
-
const sessionPath =
|
|
10590
|
+
const chatsDir = path.join(this.storage.getProjectTempDir(), "chats");
|
|
10591
|
+
const sessionPath = path.join(chatsDir, sessionInfo.fileName);
|
|
10829
10592
|
try {
|
|
10830
10593
|
const sessionData = await loadConversationRecord(sessionPath);
|
|
10831
10594
|
if (!sessionData) {
|
|
@@ -10911,8 +10674,8 @@ function convertSessionToHistoryFormats(messages) {
|
|
|
10911
10674
|
}
|
|
10912
10675
|
|
|
10913
10676
|
// packages/cli/src/utils/sessionCleanup.ts
|
|
10914
|
-
import * as
|
|
10915
|
-
import * as
|
|
10677
|
+
import * as fs2 from "node:fs/promises";
|
|
10678
|
+
import * as path2 from "node:path";
|
|
10916
10679
|
var DEFAULT_MIN_RETENTION = "1d";
|
|
10917
10680
|
var MIN_MAX_COUNT = 1;
|
|
10918
10681
|
var MULTIPLIERS = {
|
|
@@ -10935,7 +10698,7 @@ function deriveShortIdFromFileName(fileName) {
|
|
|
10935
10698
|
}
|
|
10936
10699
|
async function cleanupSessionAndSubagentsAsync(sessionId, config) {
|
|
10937
10700
|
const tempDir = config.storage.getProjectTempDir();
|
|
10938
|
-
const chatsDir =
|
|
10701
|
+
const chatsDir = path2.join(tempDir, "chats");
|
|
10939
10702
|
await deleteSessionArtifactsAsync(sessionId, tempDir);
|
|
10940
10703
|
await deleteSubagentSessionDirAndArtifactsAsync(sessionId, chatsDir, tempDir);
|
|
10941
10704
|
}
|
|
@@ -10952,7 +10715,7 @@ async function cleanupExpiredSessions(config, settings) {
|
|
|
10952
10715
|
return { ...result, disabled: true };
|
|
10953
10716
|
}
|
|
10954
10717
|
const retentionConfig = settings.general.sessionRetention;
|
|
10955
|
-
const chatsDir =
|
|
10718
|
+
const chatsDir = path2.join(config.storage.getProjectTempDir(), "chats");
|
|
10956
10719
|
const validationErrorMessage = validateRetentionConfig(
|
|
10957
10720
|
config,
|
|
10958
10721
|
retentionConfig
|
|
@@ -10983,11 +10746,11 @@ async function cleanupExpiredSessions(config, settings) {
|
|
|
10983
10746
|
(f) => f.startsWith(SESSION_FILE_PREFIX) && f.endsWith(`-${shortId}.json`)
|
|
10984
10747
|
);
|
|
10985
10748
|
for (const file of matchingFiles) {
|
|
10986
|
-
const filePath =
|
|
10749
|
+
const filePath = path2.join(chatsDir, file);
|
|
10987
10750
|
let fullSessionId;
|
|
10988
10751
|
try {
|
|
10989
10752
|
try {
|
|
10990
|
-
const fileContent = await
|
|
10753
|
+
const fileContent = await fs2.readFile(filePath, "utf8");
|
|
10991
10754
|
const content = JSON.parse(fileContent);
|
|
10992
10755
|
if (content && typeof content === "object" && "sessionId" in content) {
|
|
10993
10756
|
const record = content;
|
|
@@ -10999,7 +10762,7 @@ async function cleanupExpiredSessions(config, settings) {
|
|
|
10999
10762
|
} catch {
|
|
11000
10763
|
}
|
|
11001
10764
|
if (!fullSessionId || fullSessionId !== config.getSessionId()) {
|
|
11002
|
-
await
|
|
10765
|
+
await fs2.unlink(filePath);
|
|
11003
10766
|
if (fullSessionId) {
|
|
11004
10767
|
await cleanupSessionAndSubagentsAsync(fullSessionId, config);
|
|
11005
10768
|
}
|
|
@@ -11018,8 +10781,8 @@ async function cleanupExpiredSessions(config, settings) {
|
|
|
11018
10781
|
}
|
|
11019
10782
|
}
|
|
11020
10783
|
} else {
|
|
11021
|
-
const sessionPath =
|
|
11022
|
-
await
|
|
10784
|
+
const sessionPath = path2.join(chatsDir, sessionToDelete.fileName);
|
|
10785
|
+
await fs2.unlink(sessionPath);
|
|
11023
10786
|
const sessionId = sessionToDelete.sessionInfo?.id;
|
|
11024
10787
|
if (sessionId) {
|
|
11025
10788
|
await cleanupSessionAndSubagentsAsync(sessionId, config);
|
|
@@ -11175,13 +10938,13 @@ async function cleanupToolOutputFiles(settings, debugMode = false, projectTempDi
|
|
|
11175
10938
|
await storage.initialize();
|
|
11176
10939
|
tempDir = storage.getProjectTempDir();
|
|
11177
10940
|
}
|
|
11178
|
-
const toolOutputDir =
|
|
10941
|
+
const toolOutputDir = path2.join(tempDir, TOOL_OUTPUTS_DIR);
|
|
11179
10942
|
try {
|
|
11180
|
-
await
|
|
10943
|
+
await fs2.access(toolOutputDir);
|
|
11181
10944
|
} catch {
|
|
11182
10945
|
return result;
|
|
11183
10946
|
}
|
|
11184
|
-
const entries = await
|
|
10947
|
+
const entries = await fs2.readdir(toolOutputDir, { withFileTypes: true });
|
|
11185
10948
|
result.scanned = entries.length;
|
|
11186
10949
|
if (entries.length === 0) {
|
|
11187
10950
|
return result;
|
|
@@ -11190,8 +10953,8 @@ async function cleanupToolOutputFiles(settings, debugMode = false, projectTempDi
|
|
|
11190
10953
|
const fileStatsResults = await Promise.all(
|
|
11191
10954
|
files.map(async (file) => {
|
|
11192
10955
|
try {
|
|
11193
|
-
const filePath =
|
|
11194
|
-
const stat2 = await
|
|
10956
|
+
const filePath = path2.join(toolOutputDir, file.name);
|
|
10957
|
+
const stat2 = await fs2.stat(filePath);
|
|
11195
10958
|
return { name: file.name, mtime: stat2.mtime };
|
|
11196
10959
|
} catch (error) {
|
|
11197
10960
|
debugLogger.debug(
|
|
@@ -11244,8 +11007,8 @@ async function cleanupToolOutputFiles(settings, debugMode = false, projectTempDi
|
|
|
11244
11007
|
);
|
|
11245
11008
|
continue;
|
|
11246
11009
|
}
|
|
11247
|
-
const subdirPath =
|
|
11248
|
-
const stat2 = await
|
|
11010
|
+
const subdirPath = path2.join(toolOutputDir, subdir.name);
|
|
11011
|
+
const stat2 = await fs2.stat(subdirPath);
|
|
11249
11012
|
let shouldDelete = false;
|
|
11250
11013
|
if (retentionConfig.maxAge) {
|
|
11251
11014
|
const maxAgeMs = parseRetentionPeriod(retentionConfig.maxAge);
|
|
@@ -11255,7 +11018,7 @@ async function cleanupToolOutputFiles(settings, debugMode = false, projectTempDi
|
|
|
11255
11018
|
}
|
|
11256
11019
|
}
|
|
11257
11020
|
if (shouldDelete) {
|
|
11258
|
-
await
|
|
11021
|
+
await fs2.rm(subdirPath, { recursive: true, force: true });
|
|
11259
11022
|
result.deleted++;
|
|
11260
11023
|
}
|
|
11261
11024
|
} catch (error) {
|
|
@@ -11264,8 +11027,8 @@ async function cleanupToolOutputFiles(settings, debugMode = false, projectTempDi
|
|
|
11264
11027
|
}
|
|
11265
11028
|
for (const fileName of filesToDelete) {
|
|
11266
11029
|
try {
|
|
11267
|
-
const filePath =
|
|
11268
|
-
await
|
|
11030
|
+
const filePath = path2.join(toolOutputDir, fileName);
|
|
11031
|
+
await fs2.unlink(filePath);
|
|
11269
11032
|
result.deleted++;
|
|
11270
11033
|
} catch (error) {
|
|
11271
11034
|
debugLogger.debug(
|
|
@@ -11289,11 +11052,11 @@ async function cleanupToolOutputFiles(settings, debugMode = false, projectTempDi
|
|
|
11289
11052
|
|
|
11290
11053
|
// packages/cli/src/config/settings.ts
|
|
11291
11054
|
var dotenv = __toESM(require_main(), 1);
|
|
11292
|
-
import * as
|
|
11293
|
-
import * as
|
|
11055
|
+
import * as fs4 from "node:fs";
|
|
11056
|
+
import * as path3 from "node:path";
|
|
11294
11057
|
import { platform } from "node:os";
|
|
11295
11058
|
import process2 from "node:process";
|
|
11296
|
-
var
|
|
11059
|
+
var import_strip_json_comments = __toESM(require_strip_json_comments(), 1);
|
|
11297
11060
|
|
|
11298
11061
|
// packages/cli/src/ui/themes/theme.ts
|
|
11299
11062
|
var import_tinygradient = __toESM(require_tinygradient(), 1);
|
|
@@ -14463,6 +14226,19 @@ var SETTINGS_SCHEMA = {
|
|
|
14463
14226
|
showInDialog: false,
|
|
14464
14227
|
items: { type: "string" }
|
|
14465
14228
|
},
|
|
14229
|
+
confirmationRequired: {
|
|
14230
|
+
type: "array",
|
|
14231
|
+
label: "Confirmation Required",
|
|
14232
|
+
category: "Advanced",
|
|
14233
|
+
requiresRestart: true,
|
|
14234
|
+
default: void 0,
|
|
14235
|
+
description: oneLine`
|
|
14236
|
+
Tool names that always require user confirmation.
|
|
14237
|
+
Takes precedence over allowed tools and core tool allowlists.
|
|
14238
|
+
`,
|
|
14239
|
+
showInDialog: false,
|
|
14240
|
+
items: { type: "string" }
|
|
14241
|
+
},
|
|
14466
14242
|
exclude: {
|
|
14467
14243
|
type: "array",
|
|
14468
14244
|
label: "Exclude Tools",
|
|
@@ -16187,7 +15963,7 @@ function resolveEnvVarsInObjectInternal(obj, visited, customEnv) {
|
|
|
16187
15963
|
function isPlainObject(item) {
|
|
16188
15964
|
return !!item && typeof item === "object" && !Array.isArray(item);
|
|
16189
15965
|
}
|
|
16190
|
-
function mergeRecursively(target, source, getMergeStrategyForPath2,
|
|
15966
|
+
function mergeRecursively(target, source, getMergeStrategyForPath2, path6 = []) {
|
|
16191
15967
|
for (const key of Object.keys(source)) {
|
|
16192
15968
|
if (key === "__proto__" || key === "constructor" || key === "prototype") {
|
|
16193
15969
|
continue;
|
|
@@ -16196,7 +15972,7 @@ function mergeRecursively(target, source, getMergeStrategyForPath2, path7 = [])
|
|
|
16196
15972
|
if (srcValue === void 0) {
|
|
16197
15973
|
continue;
|
|
16198
15974
|
}
|
|
16199
|
-
const newPath = [...
|
|
15975
|
+
const newPath = [...path6, key];
|
|
16200
15976
|
const objValue = target[key];
|
|
16201
15977
|
const mergeStrategy = getMergeStrategyForPath2(newPath);
|
|
16202
15978
|
if (mergeStrategy === "shallow_merge" /* SHALLOW_MERGE */ && objValue && srcValue) {
|
|
@@ -16245,13 +16021,13 @@ function customDeepMerge(getMergeStrategyForPath2, ...sources) {
|
|
|
16245
16021
|
|
|
16246
16022
|
// packages/cli/src/utils/commentJson.ts
|
|
16247
16023
|
var import_comment_json = __toESM(require_src2(), 1);
|
|
16248
|
-
import * as
|
|
16024
|
+
import * as fs3 from "node:fs";
|
|
16249
16025
|
function updateSettingsFilePreservingFormat(filePath, updates) {
|
|
16250
|
-
if (!
|
|
16251
|
-
|
|
16026
|
+
if (!fs3.existsSync(filePath)) {
|
|
16027
|
+
fs3.writeFileSync(filePath, JSON.stringify(updates, null, 2), "utf-8");
|
|
16252
16028
|
return;
|
|
16253
16029
|
}
|
|
16254
|
-
const originalContent =
|
|
16030
|
+
const originalContent = fs3.readFileSync(filePath, "utf-8");
|
|
16255
16031
|
let parsed;
|
|
16256
16032
|
try {
|
|
16257
16033
|
parsed = (0, import_comment_json.parse)(originalContent);
|
|
@@ -16265,7 +16041,7 @@ function updateSettingsFilePreservingFormat(filePath, updates) {
|
|
|
16265
16041
|
}
|
|
16266
16042
|
const updatedStructure = applyUpdates(parsed, updates);
|
|
16267
16043
|
const updatedContent = (0, import_comment_json.stringify)(updatedStructure, null, 2);
|
|
16268
|
-
|
|
16044
|
+
fs3.writeFileSync(filePath, updatedContent, "utf-8");
|
|
16269
16045
|
}
|
|
16270
16046
|
function preserveCommentsOnPropertyDeletion(container, propName) {
|
|
16271
16047
|
const target = container;
|
|
@@ -16534,11 +16310,11 @@ function formatValidationError(error, filePath) {
|
|
|
16534
16310
|
const MAX_ERRORS_TO_DISPLAY = 5;
|
|
16535
16311
|
const displayedIssues = error.issues.slice(0, MAX_ERRORS_TO_DISPLAY);
|
|
16536
16312
|
for (const issue of displayedIssues) {
|
|
16537
|
-
const
|
|
16313
|
+
const path6 = issue.path.reduce(
|
|
16538
16314
|
(acc, curr) => typeof curr === "number" ? `${acc}[${curr}]` : `${acc ? acc + "." : ""}${curr}`,
|
|
16539
16315
|
""
|
|
16540
16316
|
);
|
|
16541
|
-
lines.push(`Error in: ${
|
|
16317
|
+
lines.push(`Error in: ${path6 || "(root)"}`);
|
|
16542
16318
|
lines.push(` ${issue.message}`);
|
|
16543
16319
|
if (issue.code === "invalid_type") {
|
|
16544
16320
|
const expected = issue.expected;
|
|
@@ -16559,11 +16335,11 @@ function formatValidationError(error, filePath) {
|
|
|
16559
16335
|
}
|
|
16560
16336
|
|
|
16561
16337
|
// packages/cli/src/config/settings.ts
|
|
16562
|
-
function getMergeStrategyForPath(
|
|
16338
|
+
function getMergeStrategyForPath(path6) {
|
|
16563
16339
|
let current = void 0;
|
|
16564
16340
|
let currentSchema = getSettingsSchema();
|
|
16565
16341
|
let parent = void 0;
|
|
16566
|
-
for (const key of
|
|
16342
|
+
for (const key of path6) {
|
|
16567
16343
|
if (!currentSchema || !currentSchema[key]) {
|
|
16568
16344
|
if (parent?.additionalProperties?.mergeStrategy) {
|
|
16569
16345
|
return parent.additionalProperties.mergeStrategy;
|
|
@@ -16577,7 +16353,7 @@ function getMergeStrategyForPath(path7) {
|
|
|
16577
16353
|
return current?.mergeStrategy;
|
|
16578
16354
|
}
|
|
16579
16355
|
var USER_SETTINGS_PATH = Storage.getGlobalSettingsPath();
|
|
16580
|
-
var USER_SETTINGS_DIR =
|
|
16356
|
+
var USER_SETTINGS_DIR = path3.dirname(USER_SETTINGS_PATH);
|
|
16581
16357
|
var DEFAULT_EXCLUDED_ENV_VARS = [
|
|
16582
16358
|
"DEBUG",
|
|
16583
16359
|
"DEBUG_MODE",
|
|
@@ -16609,8 +16385,8 @@ function getSystemDefaultsPath() {
|
|
|
16609
16385
|
if (process2.env["GEMINI_CLI_SYSTEM_DEFAULTS_PATH"]) {
|
|
16610
16386
|
return process2.env["GEMINI_CLI_SYSTEM_DEFAULTS_PATH"];
|
|
16611
16387
|
}
|
|
16612
|
-
return
|
|
16613
|
-
|
|
16388
|
+
return path3.join(
|
|
16389
|
+
path3.dirname(getSystemSettingsPath()),
|
|
16614
16390
|
"system-defaults.json"
|
|
16615
16391
|
);
|
|
16616
16392
|
}
|
|
@@ -16631,8 +16407,8 @@ var _loadableSettingScopes = [
|
|
|
16631
16407
|
function isLoadableSettingScope(scope) {
|
|
16632
16408
|
return _loadableSettingScopes.includes(scope);
|
|
16633
16409
|
}
|
|
16634
|
-
function setNestedProperty(obj,
|
|
16635
|
-
const keys =
|
|
16410
|
+
function setNestedProperty(obj, path6, value) {
|
|
16411
|
+
const keys = path6.split(".");
|
|
16636
16412
|
const lastKey = keys.pop();
|
|
16637
16413
|
if (!lastKey) return;
|
|
16638
16414
|
let current = obj;
|
|
@@ -16727,7 +16503,7 @@ var LoadedSettings = class {
|
|
|
16727
16503
|
const adminSchema = adminSettingSchema.properties;
|
|
16728
16504
|
const adminDefaults = getDefaultsFromSchema(adminSchema);
|
|
16729
16505
|
merged.admin = customDeepMerge(
|
|
16730
|
-
(
|
|
16506
|
+
(path6) => getMergeStrategyForPath(["admin", ...path6]),
|
|
16731
16507
|
adminDefaults,
|
|
16732
16508
|
this._remoteAdminSettings?.admin ?? {}
|
|
16733
16509
|
);
|
|
@@ -16818,25 +16594,29 @@ var LoadedSettings = class {
|
|
|
16818
16594
|
this._merged = this.computeMergedSettings();
|
|
16819
16595
|
}
|
|
16820
16596
|
};
|
|
16821
|
-
function findEnvFile(startDir) {
|
|
16822
|
-
let currentDir =
|
|
16597
|
+
function findEnvFile(startDir, isTrusted) {
|
|
16598
|
+
let currentDir = path3.resolve(startDir);
|
|
16823
16599
|
while (true) {
|
|
16824
|
-
|
|
16825
|
-
|
|
16826
|
-
|
|
16600
|
+
if (isTrusted) {
|
|
16601
|
+
const geminiEnvPath = path3.join(currentDir, GEMINI_DIR, ".env");
|
|
16602
|
+
if (fs4.existsSync(geminiEnvPath)) {
|
|
16603
|
+
return geminiEnvPath;
|
|
16604
|
+
}
|
|
16827
16605
|
}
|
|
16828
|
-
const envPath =
|
|
16829
|
-
if (
|
|
16606
|
+
const envPath = path3.join(currentDir, ".env");
|
|
16607
|
+
if (fs4.existsSync(envPath)) {
|
|
16830
16608
|
return envPath;
|
|
16831
16609
|
}
|
|
16832
|
-
const parentDir =
|
|
16610
|
+
const parentDir = path3.dirname(currentDir);
|
|
16833
16611
|
if (parentDir === currentDir || !parentDir) {
|
|
16834
|
-
|
|
16835
|
-
|
|
16836
|
-
|
|
16612
|
+
if (isTrusted) {
|
|
16613
|
+
const homeGeminiEnvPath = path3.join(homedir(), GEMINI_DIR, ".env");
|
|
16614
|
+
if (fs4.existsSync(homeGeminiEnvPath)) {
|
|
16615
|
+
return homeGeminiEnvPath;
|
|
16616
|
+
}
|
|
16837
16617
|
}
|
|
16838
|
-
const homeEnvPath =
|
|
16839
|
-
if (
|
|
16618
|
+
const homeEnvPath = path3.join(homedir(), ".env");
|
|
16619
|
+
if (fs4.existsSync(homeEnvPath)) {
|
|
16840
16620
|
return homeEnvPath;
|
|
16841
16621
|
}
|
|
16842
16622
|
return null;
|
|
@@ -16846,8 +16626,8 @@ function findEnvFile(startDir) {
|
|
|
16846
16626
|
}
|
|
16847
16627
|
function setUpCloudShellEnvironment(envFilePath, isTrusted, isSandboxed) {
|
|
16848
16628
|
let value = "cloudshell-gca";
|
|
16849
|
-
if (envFilePath &&
|
|
16850
|
-
const envFileContent =
|
|
16629
|
+
if (envFilePath && fs4.existsSync(envFilePath)) {
|
|
16630
|
+
const envFileContent = fs4.readFileSync(envFilePath);
|
|
16851
16631
|
const parsedEnv = dotenv.parse(envFileContent);
|
|
16852
16632
|
if (parsedEnv["GOOGLE_CLOUD_PROJECT"]) {
|
|
16853
16633
|
value = parsedEnv["GOOGLE_CLOUD_PROJECT"];
|
|
@@ -16859,9 +16639,9 @@ function setUpCloudShellEnvironment(envFilePath, isTrusted, isSandboxed) {
|
|
|
16859
16639
|
process2.env["GOOGLE_CLOUD_PROJECT"] = value;
|
|
16860
16640
|
}
|
|
16861
16641
|
function loadEnvironment(settings, workspaceDir, isWorkspaceTrustedFn = isWorkspaceTrusted) {
|
|
16862
|
-
const envFilePath = findEnvFile(workspaceDir);
|
|
16863
16642
|
const trustResult = isWorkspaceTrustedFn(settings, workspaceDir);
|
|
16864
16643
|
const isTrusted = trustResult.isTrusted ?? false;
|
|
16644
|
+
const envFilePath = findEnvFile(workspaceDir, isTrusted);
|
|
16865
16645
|
const args = process2.argv.slice(2);
|
|
16866
16646
|
const doubleDashIndex = args.indexOf("--");
|
|
16867
16647
|
const relevantArgs = doubleDashIndex === -1 ? args : args.slice(0, doubleDashIndex);
|
|
@@ -16871,14 +16651,14 @@ function loadEnvironment(settings, workspaceDir, isWorkspaceTrustedFn = isWorksp
|
|
|
16871
16651
|
}
|
|
16872
16652
|
if (envFilePath) {
|
|
16873
16653
|
try {
|
|
16874
|
-
const envFileContent =
|
|
16654
|
+
const envFileContent = fs4.readFileSync(envFilePath, "utf-8");
|
|
16875
16655
|
const parsedEnv = dotenv.parse(envFileContent);
|
|
16876
16656
|
const excludedVars = settings?.advanced?.excludedEnvVars || DEFAULT_EXCLUDED_ENV_VARS;
|
|
16877
16657
|
const isProjectEnvFile = !envFilePath.includes(GEMINI_DIR);
|
|
16878
16658
|
for (const key in parsedEnv) {
|
|
16879
16659
|
if (Object.hasOwn(parsedEnv, key)) {
|
|
16880
16660
|
let value = parsedEnv[key];
|
|
16881
|
-
if (!isTrusted
|
|
16661
|
+
if (!isTrusted) {
|
|
16882
16662
|
if (!AUTH_ENV_VAR_WHITELIST.includes(key)) {
|
|
16883
16663
|
continue;
|
|
16884
16664
|
}
|
|
@@ -16905,7 +16685,7 @@ function isWorktreeEnabled(settings) {
|
|
|
16905
16685
|
return settings.merged.experimental.worktrees;
|
|
16906
16686
|
}
|
|
16907
16687
|
function loadSettings(workspaceDir = process2.cwd()) {
|
|
16908
|
-
const normalizedWorkspaceDir =
|
|
16688
|
+
const normalizedWorkspaceDir = path3.resolve(workspaceDir);
|
|
16909
16689
|
return settingsCache.getOrCreate(
|
|
16910
16690
|
normalizedWorkspaceDir,
|
|
16911
16691
|
() => _doLoadSettings(normalizedWorkspaceDir)
|
|
@@ -16923,9 +16703,9 @@ function _doLoadSettings(workspaceDir) {
|
|
|
16923
16703
|
const workspaceSettingsPath = storage.getWorkspaceSettingsPath();
|
|
16924
16704
|
const load = (filePath) => {
|
|
16925
16705
|
try {
|
|
16926
|
-
if (
|
|
16927
|
-
const content =
|
|
16928
|
-
const rawSettings = JSON.parse((0,
|
|
16706
|
+
if (fs4.existsSync(filePath)) {
|
|
16707
|
+
const content = fs4.readFileSync(filePath, "utf-8");
|
|
16708
|
+
const rawSettings = JSON.parse((0, import_strip_json_comments.default)(content));
|
|
16929
16709
|
if (typeof rawSettings !== "object" || rawSettings === null || Array.isArray(rawSettings)) {
|
|
16930
16710
|
settingsErrors.push({
|
|
16931
16711
|
message: "Settings file is not a valid JSON object.",
|
|
@@ -17214,9 +16994,9 @@ function migrateDeprecatedSettings(loadedSettings, removeDeprecated = true) {
|
|
|
17214
16994
|
function saveSettings(settingsFile) {
|
|
17215
16995
|
settingsCache.clear();
|
|
17216
16996
|
try {
|
|
17217
|
-
const dirPath =
|
|
17218
|
-
if (!
|
|
17219
|
-
|
|
16997
|
+
const dirPath = path3.dirname(settingsFile.path);
|
|
16998
|
+
if (!fs4.existsSync(dirPath)) {
|
|
16999
|
+
fs4.mkdirSync(dirPath, { recursive: true });
|
|
17220
17000
|
}
|
|
17221
17001
|
const settingsToSave = settingsFile.originalSettings;
|
|
17222
17002
|
updateSettingsFilePreservingFormat(
|
|
@@ -17341,7 +17121,7 @@ function migrateExperimentalSettings(settings, loadedSettings, scope, removeDepr
|
|
|
17341
17121
|
}
|
|
17342
17122
|
|
|
17343
17123
|
// packages/cli/src/commands/gemma/constants.ts
|
|
17344
|
-
import
|
|
17124
|
+
import path4 from "node:path";
|
|
17345
17125
|
var LITERT_RELEASE_VERSION = "v0.9.0-alpha03";
|
|
17346
17126
|
var LITERT_RELEASE_BASE_URL = "https://github.com/google-ai-edge/LiteRT-LM/releases/download";
|
|
17347
17127
|
var GEMMA_MODEL_NAME = "gemma3-1b-gpu-custom";
|
|
@@ -17360,18 +17140,18 @@ var PLATFORM_BINARY_SHA256 = {
|
|
|
17360
17140
|
"lit.windows_x86_64.exe": "de82d2829d2fb1cbdb318e2d8a78dc2f9659ff14cb11b2894d1f30e0bfde2bf6"
|
|
17361
17141
|
};
|
|
17362
17142
|
function getLiteRtBinDir() {
|
|
17363
|
-
return
|
|
17143
|
+
return path4.join(Storage.getGlobalGeminiDir(), "bin", "litert");
|
|
17364
17144
|
}
|
|
17365
17145
|
function getPidFilePath() {
|
|
17366
|
-
return
|
|
17146
|
+
return path4.join(Storage.getGlobalTempDir(), "litert-server.pid");
|
|
17367
17147
|
}
|
|
17368
17148
|
function getLogFilePath() {
|
|
17369
|
-
return
|
|
17149
|
+
return path4.join(Storage.getGlobalTempDir(), "litert-server.log");
|
|
17370
17150
|
}
|
|
17371
17151
|
|
|
17372
17152
|
// packages/cli/src/commands/gemma/platform.ts
|
|
17373
|
-
import
|
|
17374
|
-
import
|
|
17153
|
+
import fs5 from "node:fs";
|
|
17154
|
+
import path5 from "node:path";
|
|
17375
17155
|
import { execFileSync } from "node:child_process";
|
|
17376
17156
|
function getUserConfiguredBinaryPath(workspaceDir = process.cwd()) {
|
|
17377
17157
|
try {
|
|
@@ -17431,14 +17211,14 @@ function getBinaryPath(binaryName) {
|
|
|
17431
17211
|
}
|
|
17432
17212
|
const name = binaryName ?? detectPlatform()?.binaryName;
|
|
17433
17213
|
if (!name) return null;
|
|
17434
|
-
return
|
|
17214
|
+
return path5.join(getLiteRtBinDir(), name);
|
|
17435
17215
|
}
|
|
17436
17216
|
function getBinaryDownloadUrl(binaryName) {
|
|
17437
17217
|
return `${LITERT_RELEASE_BASE_URL}/${LITERT_RELEASE_VERSION}/${binaryName}`;
|
|
17438
17218
|
}
|
|
17439
17219
|
function isBinaryInstalled(binaryPath = getBinaryPath()) {
|
|
17440
17220
|
if (!binaryPath) return false;
|
|
17441
|
-
return
|
|
17221
|
+
return fs5.existsSync(binaryPath);
|
|
17442
17222
|
}
|
|
17443
17223
|
function isModelDownloaded(binaryPath) {
|
|
17444
17224
|
try {
|
|
@@ -17494,7 +17274,7 @@ function isLiteRtServerProcessInfo(value) {
|
|
|
17494
17274
|
function readServerProcessInfo() {
|
|
17495
17275
|
const pidPath = getPidFilePath();
|
|
17496
17276
|
try {
|
|
17497
|
-
const content =
|
|
17277
|
+
const content = fs5.readFileSync(pidPath, "utf-8").trim();
|
|
17498
17278
|
if (!content) {
|
|
17499
17279
|
return null;
|
|
17500
17280
|
}
|
|
@@ -17508,7 +17288,7 @@ function readServerProcessInfo() {
|
|
|
17508
17288
|
}
|
|
17509
17289
|
}
|
|
17510
17290
|
function writeServerProcessInfo(processInfo) {
|
|
17511
|
-
|
|
17291
|
+
fs5.writeFileSync(getPidFilePath(), JSON.stringify(processInfo), "utf-8");
|
|
17512
17292
|
}
|
|
17513
17293
|
function readServerPid() {
|
|
17514
17294
|
return readServerProcessInfo()?.pid ?? null;
|
|
@@ -17523,7 +17303,7 @@ function normalizeProcessValue(value) {
|
|
|
17523
17303
|
function readProcessCommandLine(pid) {
|
|
17524
17304
|
try {
|
|
17525
17305
|
if (process.platform === "linux") {
|
|
17526
|
-
const output2 =
|
|
17306
|
+
const output2 = fs5.readFileSync(`/proc/${pid}/cmdline`, "utf-8");
|
|
17527
17307
|
return output2.trim() ? output2 : null;
|
|
17528
17308
|
}
|
|
17529
17309
|
if (process.platform === "win32") {
|
|
@@ -17566,7 +17346,7 @@ function isExpectedLiteRtServerCommand(commandLine, options) {
|
|
|
17566
17346
|
}
|
|
17567
17347
|
const normalizedBinaryPath = normalizeProcessValue(options.binaryPath);
|
|
17568
17348
|
const normalizedBinaryName = normalizeProcessValue(
|
|
17569
|
-
|
|
17349
|
+
path5.basename(options.binaryPath)
|
|
17570
17350
|
);
|
|
17571
17351
|
return normalizedCommandLine.includes(normalizedBinaryPath) || normalizedCommandLine.includes(normalizedBinaryName);
|
|
17572
17352
|
}
|
|
@@ -17629,8 +17409,8 @@ export {
|
|
|
17629
17409
|
pickDefaultThemeName,
|
|
17630
17410
|
DefaultLight,
|
|
17631
17411
|
DefaultDark,
|
|
17632
|
-
loadTrustedFolders,
|
|
17633
17412
|
isFolderTrustEnabled,
|
|
17413
|
+
loadTrustedFolders2 as loadTrustedFolders,
|
|
17634
17414
|
isWorkspaceTrusted,
|
|
17635
17415
|
isFullWidth,
|
|
17636
17416
|
isWide,
|