@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
|
@@ -8,20 +8,20 @@ import {
|
|
|
8
8
|
TOOL_OUTPUTS_DIR,
|
|
9
9
|
ansiRegex,
|
|
10
10
|
checkExhaustive,
|
|
11
|
+
checkPathTrust,
|
|
11
12
|
createCache,
|
|
12
13
|
deleteSessionArtifactsAsync,
|
|
13
14
|
deleteSubagentSessionDirAndArtifactsAsync,
|
|
14
15
|
getFsErrorMessage,
|
|
15
|
-
ideContextStore,
|
|
16
16
|
import_lru_cache,
|
|
17
17
|
isHeadlessMode,
|
|
18
|
-
isWithinRoot,
|
|
19
18
|
loadConversationRecord,
|
|
19
|
+
loadTrustedFolders,
|
|
20
20
|
partListUnionToString,
|
|
21
21
|
require_strip_json_comments,
|
|
22
22
|
sanitizeFilenamePart,
|
|
23
23
|
stripAnsi
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-NV6UCR4K.js";
|
|
25
25
|
import {
|
|
26
26
|
CoreEvent,
|
|
27
27
|
FatalConfigError,
|
|
@@ -31,9 +31,8 @@ import {
|
|
|
31
31
|
debugLogger,
|
|
32
32
|
external_exports,
|
|
33
33
|
getErrorMessage,
|
|
34
|
-
homedir
|
|
35
|
-
|
|
36
|
-
} from "./chunk-VCGILCZV.js";
|
|
34
|
+
homedir
|
|
35
|
+
} from "./chunk-F73F75XM.js";
|
|
37
36
|
import {
|
|
38
37
|
__commonJS,
|
|
39
38
|
__require,
|
|
@@ -564,10 +563,10 @@ var require_package = __commonJS({
|
|
|
564
563
|
// node_modules/dotenv/lib/main.js
|
|
565
564
|
var require_main = __commonJS({
|
|
566
565
|
"node_modules/dotenv/lib/main.js"(exports, module) {
|
|
567
|
-
var
|
|
568
|
-
var
|
|
566
|
+
var fs6 = __require("fs");
|
|
567
|
+
var path6 = __require("path");
|
|
569
568
|
var os = __require("os");
|
|
570
|
-
var
|
|
569
|
+
var crypto = __require("crypto");
|
|
571
570
|
var packageJson = require_package();
|
|
572
571
|
var version = packageJson.version;
|
|
573
572
|
var TIPS = [
|
|
@@ -694,7 +693,7 @@ var require_main = __commonJS({
|
|
|
694
693
|
if (options && options.path && options.path.length > 0) {
|
|
695
694
|
if (Array.isArray(options.path)) {
|
|
696
695
|
for (const filepath of options.path) {
|
|
697
|
-
if (
|
|
696
|
+
if (fs6.existsSync(filepath)) {
|
|
698
697
|
possibleVaultPath = filepath.endsWith(".vault") ? filepath : `${filepath}.vault`;
|
|
699
698
|
}
|
|
700
699
|
}
|
|
@@ -702,15 +701,15 @@ var require_main = __commonJS({
|
|
|
702
701
|
possibleVaultPath = options.path.endsWith(".vault") ? options.path : `${options.path}.vault`;
|
|
703
702
|
}
|
|
704
703
|
} else {
|
|
705
|
-
possibleVaultPath =
|
|
704
|
+
possibleVaultPath = path6.resolve(process.cwd(), ".env.vault");
|
|
706
705
|
}
|
|
707
|
-
if (
|
|
706
|
+
if (fs6.existsSync(possibleVaultPath)) {
|
|
708
707
|
return possibleVaultPath;
|
|
709
708
|
}
|
|
710
709
|
return null;
|
|
711
710
|
}
|
|
712
711
|
function _resolveHome(envPath) {
|
|
713
|
-
return envPath[0] === "~" ?
|
|
712
|
+
return envPath[0] === "~" ? path6.join(os.homedir(), envPath.slice(1)) : envPath;
|
|
714
713
|
}
|
|
715
714
|
function _configVault(options) {
|
|
716
715
|
const debug = Boolean(options && options.debug);
|
|
@@ -727,7 +726,7 @@ var require_main = __commonJS({
|
|
|
727
726
|
return { parsed };
|
|
728
727
|
}
|
|
729
728
|
function configDotenv(options) {
|
|
730
|
-
const dotenvPath =
|
|
729
|
+
const dotenvPath = path6.resolve(process.cwd(), ".env");
|
|
731
730
|
let encoding = "utf8";
|
|
732
731
|
const debug = Boolean(options && options.debug);
|
|
733
732
|
const quiet = Boolean(options && options.quiet);
|
|
@@ -751,13 +750,13 @@ var require_main = __commonJS({
|
|
|
751
750
|
}
|
|
752
751
|
let lastError;
|
|
753
752
|
const parsedAll = {};
|
|
754
|
-
for (const
|
|
753
|
+
for (const path7 of optionPaths) {
|
|
755
754
|
try {
|
|
756
|
-
const parsed = DotenvModule.parse(
|
|
755
|
+
const parsed = DotenvModule.parse(fs6.readFileSync(path7, { encoding }));
|
|
757
756
|
DotenvModule.populate(parsedAll, parsed, options);
|
|
758
757
|
} catch (e) {
|
|
759
758
|
if (debug) {
|
|
760
|
-
_debug(`Failed to load ${
|
|
759
|
+
_debug(`Failed to load ${path7} ${e.message}`);
|
|
761
760
|
}
|
|
762
761
|
lastError = e;
|
|
763
762
|
}
|
|
@@ -772,7 +771,7 @@ var require_main = __commonJS({
|
|
|
772
771
|
const shortPaths = [];
|
|
773
772
|
for (const filePath of optionPaths) {
|
|
774
773
|
try {
|
|
775
|
-
const relative =
|
|
774
|
+
const relative = path6.relative(process.cwd(), filePath);
|
|
776
775
|
shortPaths.push(relative);
|
|
777
776
|
} catch (e) {
|
|
778
777
|
if (debug) {
|
|
@@ -807,7 +806,7 @@ var require_main = __commonJS({
|
|
|
807
806
|
const authTag = ciphertext.subarray(-16);
|
|
808
807
|
ciphertext = ciphertext.subarray(12, -16);
|
|
809
808
|
try {
|
|
810
|
-
const aesgcm =
|
|
809
|
+
const aesgcm = crypto.createDecipheriv("aes-256-gcm", key, nonce);
|
|
811
810
|
aesgcm.setAuthTag(authTag);
|
|
812
811
|
return `${aesgcm.update(ciphertext)}${aesgcm.final()}`;
|
|
813
812
|
} catch (error) {
|
|
@@ -9909,10 +9908,10 @@ var require_stringify = __commonJS({
|
|
|
9909
9908
|
replacer = null;
|
|
9910
9909
|
indent = EMPTY;
|
|
9911
9910
|
};
|
|
9912
|
-
var
|
|
9911
|
+
var join3 = (one, two, gap) => one ? two ? one + two.trim() + LF + gap : one.trimRight() + LF + gap : two ? two.trimRight() + LF + gap : EMPTY;
|
|
9913
9912
|
var join_content = (inside, value, gap) => {
|
|
9914
9913
|
const comment = process_comments(value, PREFIX_BEFORE, gap + indent, true);
|
|
9915
|
-
return
|
|
9914
|
+
return join3(comment, inside, gap);
|
|
9916
9915
|
};
|
|
9917
9916
|
var array_stringify = (value, gap) => {
|
|
9918
9917
|
const deeper_gap = gap + indent;
|
|
@@ -9923,7 +9922,7 @@ var require_stringify = __commonJS({
|
|
|
9923
9922
|
if (i !== 0) {
|
|
9924
9923
|
inside += COMMA;
|
|
9925
9924
|
}
|
|
9926
|
-
const before =
|
|
9925
|
+
const before = join3(
|
|
9927
9926
|
after_comma,
|
|
9928
9927
|
process_comments(value, BEFORE(i), deeper_gap),
|
|
9929
9928
|
deeper_gap
|
|
@@ -9933,7 +9932,7 @@ var require_stringify = __commonJS({
|
|
|
9933
9932
|
inside += process_comments(value, AFTER_VALUE(i), deeper_gap);
|
|
9934
9933
|
after_comma = process_comments(value, AFTER(i), deeper_gap);
|
|
9935
9934
|
}
|
|
9936
|
-
inside +=
|
|
9935
|
+
inside += join3(
|
|
9937
9936
|
after_comma,
|
|
9938
9937
|
process_comments(value, PREFIX_AFTER, deeper_gap),
|
|
9939
9938
|
deeper_gap
|
|
@@ -9958,7 +9957,7 @@ var require_stringify = __commonJS({
|
|
|
9958
9957
|
inside += COMMA;
|
|
9959
9958
|
}
|
|
9960
9959
|
first = false;
|
|
9961
|
-
const before =
|
|
9960
|
+
const before = join3(
|
|
9962
9961
|
after_comma,
|
|
9963
9962
|
process_comments(value, BEFORE(key), deeper_gap),
|
|
9964
9963
|
deeper_gap
|
|
@@ -9968,7 +9967,7 @@ var require_stringify = __commonJS({
|
|
|
9968
9967
|
after_comma = process_comments(value, AFTER(key), deeper_gap);
|
|
9969
9968
|
};
|
|
9970
9969
|
keys.forEach(iteratee);
|
|
9971
|
-
inside +=
|
|
9970
|
+
inside += join3(
|
|
9972
9971
|
after_comma,
|
|
9973
9972
|
process_comments(value, PREFIX_AFTER, deeper_gap),
|
|
9974
9973
|
deeper_gap
|
|
@@ -10048,255 +10047,19 @@ var require_src2 = __commonJS({
|
|
|
10048
10047
|
});
|
|
10049
10048
|
|
|
10050
10049
|
// packages/cli/src/config/trustedFolders.ts
|
|
10051
|
-
var import_proper_lockfile = __toESM(require_proper_lockfile(), 1);
|
|
10052
|
-
import * as fs from "node:fs";
|
|
10053
|
-
import * as path from "node:path";
|
|
10054
|
-
import * as crypto from "node:crypto";
|
|
10055
|
-
var import_strip_json_comments = __toESM(require_strip_json_comments(), 1);
|
|
10056
|
-
var { promises: fsPromises } = fs;
|
|
10057
|
-
var TRUSTED_FOLDERS_FILENAME = "trustedFolders.json";
|
|
10058
|
-
function getUserSettingsDir() {
|
|
10059
|
-
return path.join(homedir(), GEMINI_DIR);
|
|
10060
|
-
}
|
|
10061
|
-
function getTrustedFoldersPath() {
|
|
10062
|
-
if (process.env["GEMINI_CLI_TRUSTED_FOLDERS_PATH"]) {
|
|
10063
|
-
return process.env["GEMINI_CLI_TRUSTED_FOLDERS_PATH"];
|
|
10064
|
-
}
|
|
10065
|
-
return path.join(getUserSettingsDir(), TRUSTED_FOLDERS_FILENAME);
|
|
10066
|
-
}
|
|
10067
|
-
var TrustLevel = /* @__PURE__ */ ((TrustLevel2) => {
|
|
10068
|
-
TrustLevel2["TRUST_FOLDER"] = "TRUST_FOLDER";
|
|
10069
|
-
TrustLevel2["TRUST_PARENT"] = "TRUST_PARENT";
|
|
10070
|
-
TrustLevel2["DO_NOT_TRUST"] = "DO_NOT_TRUST";
|
|
10071
|
-
return TrustLevel2;
|
|
10072
|
-
})(TrustLevel || {});
|
|
10073
|
-
function isTrustLevel(value) {
|
|
10074
|
-
return typeof value === "string" && // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
10075
|
-
Object.values(TrustLevel).includes(value);
|
|
10076
|
-
}
|
|
10077
|
-
var realPathCache = /* @__PURE__ */ new Map();
|
|
10078
|
-
function parseTrustedFoldersJson(content) {
|
|
10079
|
-
return JSON.parse((0, import_strip_json_comments.default)(content));
|
|
10080
|
-
}
|
|
10081
|
-
function getRealPath(location) {
|
|
10082
|
-
let realPath = realPathCache.get(location);
|
|
10083
|
-
if (realPath !== void 0) {
|
|
10084
|
-
return realPath;
|
|
10085
|
-
}
|
|
10086
|
-
try {
|
|
10087
|
-
realPath = fs.existsSync(location) ? fs.realpathSync(location) : location;
|
|
10088
|
-
} catch {
|
|
10089
|
-
realPath = location;
|
|
10090
|
-
}
|
|
10091
|
-
realPathCache.set(location, realPath);
|
|
10092
|
-
return realPath;
|
|
10093
|
-
}
|
|
10094
|
-
var LoadedTrustedFolders = class {
|
|
10095
|
-
constructor(user, errors) {
|
|
10096
|
-
this.user = user;
|
|
10097
|
-
this.errors = errors;
|
|
10098
|
-
}
|
|
10099
|
-
get rules() {
|
|
10100
|
-
return Object.entries(this.user.config).map(([path7, trustLevel]) => ({
|
|
10101
|
-
path: path7,
|
|
10102
|
-
trustLevel
|
|
10103
|
-
}));
|
|
10104
|
-
}
|
|
10105
|
-
/**
|
|
10106
|
-
* Returns true or false if the path should be "trusted". This function
|
|
10107
|
-
* should only be invoked when the folder trust setting is active.
|
|
10108
|
-
*
|
|
10109
|
-
* @param location path
|
|
10110
|
-
* @returns
|
|
10111
|
-
*/
|
|
10112
|
-
isPathTrusted(location, config, headlessOptions) {
|
|
10113
|
-
if (isHeadlessMode(headlessOptions)) {
|
|
10114
|
-
return true;
|
|
10115
|
-
}
|
|
10116
|
-
const configToUse = config ?? this.user.config;
|
|
10117
|
-
const realLocation = getRealPath(location);
|
|
10118
|
-
let longestMatchLen = -1;
|
|
10119
|
-
let longestMatchTrust = void 0;
|
|
10120
|
-
for (const [rulePath, trustLevel] of Object.entries(configToUse)) {
|
|
10121
|
-
const effectivePath = trustLevel === "TRUST_PARENT" /* TRUST_PARENT */ ? path.dirname(rulePath) : rulePath;
|
|
10122
|
-
const realEffectivePath = getRealPath(effectivePath);
|
|
10123
|
-
if (isWithinRoot(realLocation, realEffectivePath)) {
|
|
10124
|
-
if (rulePath.length > longestMatchLen) {
|
|
10125
|
-
longestMatchLen = rulePath.length;
|
|
10126
|
-
longestMatchTrust = trustLevel;
|
|
10127
|
-
}
|
|
10128
|
-
}
|
|
10129
|
-
}
|
|
10130
|
-
if (longestMatchTrust === "DO_NOT_TRUST" /* DO_NOT_TRUST */) return false;
|
|
10131
|
-
if (longestMatchTrust === "TRUST_FOLDER" /* TRUST_FOLDER */ || longestMatchTrust === "TRUST_PARENT" /* TRUST_PARENT */)
|
|
10132
|
-
return true;
|
|
10133
|
-
return void 0;
|
|
10134
|
-
}
|
|
10135
|
-
async setValue(folderPath, trustLevel) {
|
|
10136
|
-
if (this.errors.length > 0) {
|
|
10137
|
-
const errorMessages = this.errors.map(
|
|
10138
|
-
(error) => `Error in ${error.path}: ${error.message}`
|
|
10139
|
-
);
|
|
10140
|
-
throw new FatalConfigError(
|
|
10141
|
-
`Cannot update trusted folders because the configuration file is invalid:
|
|
10142
|
-
${errorMessages.join("\n")}
|
|
10143
|
-
Please fix the file manually before trying to update it.`
|
|
10144
|
-
);
|
|
10145
|
-
}
|
|
10146
|
-
const dirPath = path.dirname(this.user.path);
|
|
10147
|
-
if (!fs.existsSync(dirPath)) {
|
|
10148
|
-
await fsPromises.mkdir(dirPath, { recursive: true });
|
|
10149
|
-
}
|
|
10150
|
-
if (!fs.existsSync(this.user.path)) {
|
|
10151
|
-
await fsPromises.writeFile(this.user.path, JSON.stringify({}, null, 2), {
|
|
10152
|
-
mode: 384
|
|
10153
|
-
});
|
|
10154
|
-
}
|
|
10155
|
-
const release = await (0, import_proper_lockfile.lock)(this.user.path, {
|
|
10156
|
-
retries: {
|
|
10157
|
-
retries: 10,
|
|
10158
|
-
minTimeout: 100
|
|
10159
|
-
}
|
|
10160
|
-
});
|
|
10161
|
-
try {
|
|
10162
|
-
const content = await fsPromises.readFile(this.user.path, "utf-8");
|
|
10163
|
-
let config;
|
|
10164
|
-
try {
|
|
10165
|
-
config = parseTrustedFoldersJson(content);
|
|
10166
|
-
} catch (error) {
|
|
10167
|
-
coreEvents.emitFeedback(
|
|
10168
|
-
"error",
|
|
10169
|
-
`Failed to parse trusted folders file at ${this.user.path}. The file may be corrupted.`,
|
|
10170
|
-
error
|
|
10171
|
-
);
|
|
10172
|
-
config = {};
|
|
10173
|
-
}
|
|
10174
|
-
const originalTrustLevel = config[folderPath];
|
|
10175
|
-
config[folderPath] = trustLevel;
|
|
10176
|
-
this.user.config[folderPath] = trustLevel;
|
|
10177
|
-
try {
|
|
10178
|
-
saveTrustedFolders({ ...this.user, config });
|
|
10179
|
-
} catch (e) {
|
|
10180
|
-
if (originalTrustLevel === void 0) {
|
|
10181
|
-
delete this.user.config[folderPath];
|
|
10182
|
-
} else {
|
|
10183
|
-
this.user.config[folderPath] = originalTrustLevel;
|
|
10184
|
-
}
|
|
10185
|
-
throw e;
|
|
10186
|
-
}
|
|
10187
|
-
} finally {
|
|
10188
|
-
await release();
|
|
10189
|
-
}
|
|
10190
|
-
}
|
|
10191
|
-
};
|
|
10192
|
-
var loadedTrustedFolders;
|
|
10193
|
-
function loadTrustedFolders() {
|
|
10194
|
-
if (loadedTrustedFolders) {
|
|
10195
|
-
return loadedTrustedFolders;
|
|
10196
|
-
}
|
|
10197
|
-
const errors = [];
|
|
10198
|
-
const userConfig = {};
|
|
10199
|
-
const userPath = getTrustedFoldersPath();
|
|
10200
|
-
try {
|
|
10201
|
-
if (fs.existsSync(userPath)) {
|
|
10202
|
-
const content = fs.readFileSync(userPath, "utf-8");
|
|
10203
|
-
const parsed = parseTrustedFoldersJson(content);
|
|
10204
|
-
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
|
|
10205
|
-
errors.push({
|
|
10206
|
-
message: "Trusted folders file is not a valid JSON object.",
|
|
10207
|
-
path: userPath
|
|
10208
|
-
});
|
|
10209
|
-
} else {
|
|
10210
|
-
for (const [path7, trustLevel] of Object.entries(parsed)) {
|
|
10211
|
-
if (isTrustLevel(trustLevel)) {
|
|
10212
|
-
userConfig[path7] = trustLevel;
|
|
10213
|
-
} else {
|
|
10214
|
-
const possibleValues = Object.values(TrustLevel).join(", ");
|
|
10215
|
-
errors.push({
|
|
10216
|
-
message: `Invalid trust level "${trustLevel}" for path "${path7}". Possible values are: ${possibleValues}.`,
|
|
10217
|
-
path: userPath
|
|
10218
|
-
});
|
|
10219
|
-
}
|
|
10220
|
-
}
|
|
10221
|
-
}
|
|
10222
|
-
}
|
|
10223
|
-
} catch (error) {
|
|
10224
|
-
errors.push({
|
|
10225
|
-
message: getErrorMessage(error),
|
|
10226
|
-
path: userPath
|
|
10227
|
-
});
|
|
10228
|
-
}
|
|
10229
|
-
loadedTrustedFolders = new LoadedTrustedFolders(
|
|
10230
|
-
{ path: userPath, config: userConfig },
|
|
10231
|
-
errors
|
|
10232
|
-
);
|
|
10233
|
-
return loadedTrustedFolders;
|
|
10234
|
-
}
|
|
10235
|
-
function saveTrustedFolders(trustedFoldersFile) {
|
|
10236
|
-
const dirPath = path.dirname(trustedFoldersFile.path);
|
|
10237
|
-
if (!fs.existsSync(dirPath)) {
|
|
10238
|
-
fs.mkdirSync(dirPath, { recursive: true });
|
|
10239
|
-
}
|
|
10240
|
-
const content = JSON.stringify(trustedFoldersFile.config, null, 2);
|
|
10241
|
-
const tempPath = `${trustedFoldersFile.path}.tmp.${crypto.randomUUID()}`;
|
|
10242
|
-
try {
|
|
10243
|
-
fs.writeFileSync(tempPath, content, {
|
|
10244
|
-
encoding: "utf-8",
|
|
10245
|
-
mode: 384
|
|
10246
|
-
});
|
|
10247
|
-
fs.renameSync(tempPath, trustedFoldersFile.path);
|
|
10248
|
-
} catch (error) {
|
|
10249
|
-
if (fs.existsSync(tempPath)) {
|
|
10250
|
-
try {
|
|
10251
|
-
fs.unlinkSync(tempPath);
|
|
10252
|
-
} catch {
|
|
10253
|
-
}
|
|
10254
|
-
}
|
|
10255
|
-
throw error;
|
|
10256
|
-
}
|
|
10257
|
-
}
|
|
10258
10050
|
function isFolderTrustEnabled(settings) {
|
|
10259
10051
|
const folderTrustSetting = settings.security?.folderTrust?.enabled ?? true;
|
|
10260
10052
|
return folderTrustSetting;
|
|
10261
10053
|
}
|
|
10262
|
-
function
|
|
10263
|
-
|
|
10264
|
-
const configToUse = trustConfig ?? folders.user.config;
|
|
10265
|
-
if (folders.errors.length > 0) {
|
|
10266
|
-
const errorMessages = folders.errors.map(
|
|
10267
|
-
(error) => `Error in ${error.path}: ${error.message}`
|
|
10268
|
-
);
|
|
10269
|
-
throw new FatalConfigError(
|
|
10270
|
-
`${errorMessages.join("\n")}
|
|
10271
|
-
Please fix the configuration file and try again.`
|
|
10272
|
-
);
|
|
10273
|
-
}
|
|
10274
|
-
const isTrusted = folders.isPathTrusted(
|
|
10275
|
-
workspaceDir,
|
|
10276
|
-
configToUse,
|
|
10277
|
-
headlessOptions
|
|
10278
|
-
);
|
|
10279
|
-
return {
|
|
10280
|
-
isTrusted,
|
|
10281
|
-
source: isTrusted !== void 0 ? "file" : void 0
|
|
10282
|
-
};
|
|
10054
|
+
function loadTrustedFolders2() {
|
|
10055
|
+
return loadTrustedFolders();
|
|
10283
10056
|
}
|
|
10284
|
-
function isWorkspaceTrusted(settings, workspaceDir = process.cwd(),
|
|
10285
|
-
|
|
10286
|
-
|
|
10287
|
-
|
|
10288
|
-
|
|
10289
|
-
|
|
10290
|
-
}
|
|
10291
|
-
const ideTrust = ideContextStore.get()?.workspaceState?.isTrusted;
|
|
10292
|
-
if (ideTrust !== void 0) {
|
|
10293
|
-
return { isTrusted: ideTrust, source: "ide" };
|
|
10294
|
-
}
|
|
10295
|
-
return getWorkspaceTrustFromLocalConfig(
|
|
10296
|
-
workspaceDir,
|
|
10297
|
-
trustConfig,
|
|
10298
|
-
headlessOptions
|
|
10299
|
-
);
|
|
10057
|
+
function isWorkspaceTrusted(settings, workspaceDir = process.cwd(), headlessOptions) {
|
|
10058
|
+
return checkPathTrust({
|
|
10059
|
+
path: workspaceDir,
|
|
10060
|
+
isFolderTrustEnabled: isFolderTrustEnabled(settings),
|
|
10061
|
+
isHeadless: isHeadlessMode(headlessOptions)
|
|
10062
|
+
});
|
|
10300
10063
|
}
|
|
10301
10064
|
|
|
10302
10065
|
// packages/cli/src/ui/types.ts
|
|
@@ -10325,8 +10088,8 @@ var isTodoList = (res) => typeof res === "object" && res !== null && "todos" in
|
|
|
10325
10088
|
var emptyIcon = " ";
|
|
10326
10089
|
|
|
10327
10090
|
// packages/cli/src/utils/sessionUtils.ts
|
|
10328
|
-
import * as
|
|
10329
|
-
import
|
|
10091
|
+
import * as fs from "node:fs/promises";
|
|
10092
|
+
import path from "node:path";
|
|
10330
10093
|
|
|
10331
10094
|
// packages/cli/src/ui/utils/textUtils.ts
|
|
10332
10095
|
import { stripVTControlCharacters } from "node:util";
|
|
@@ -10662,13 +10425,13 @@ var formatRelativeTime = (timestamp, style = "long") => {
|
|
|
10662
10425
|
};
|
|
10663
10426
|
var getAllSessionFiles = async (chatsDir, currentSessionId, options = {}) => {
|
|
10664
10427
|
try {
|
|
10665
|
-
const files = await
|
|
10428
|
+
const files = await fs.readdir(chatsDir);
|
|
10666
10429
|
const sessionFiles = files.filter(
|
|
10667
10430
|
(f) => f.startsWith(SESSION_FILE_PREFIX) && (f.endsWith(".json") || f.endsWith(".jsonl"))
|
|
10668
10431
|
).sort();
|
|
10669
10432
|
const sessionPromises = sessionFiles.map(
|
|
10670
10433
|
async (file) => {
|
|
10671
|
-
const filePath =
|
|
10434
|
+
const filePath = path.join(chatsDir, file);
|
|
10672
10435
|
try {
|
|
10673
10436
|
const content = await loadConversationRecord(filePath, {
|
|
10674
10437
|
metadataOnly: !options.includeFullContent
|
|
@@ -10758,7 +10521,7 @@ var SessionSelector = class {
|
|
|
10758
10521
|
* Lists all available sessions for the current project.
|
|
10759
10522
|
*/
|
|
10760
10523
|
async listSessions() {
|
|
10761
|
-
const chatsDir =
|
|
10524
|
+
const chatsDir = path.join(this.storage.getProjectTempDir(), "chats");
|
|
10762
10525
|
return getSessionFiles(chatsDir);
|
|
10763
10526
|
}
|
|
10764
10527
|
/**
|
|
@@ -10787,7 +10550,7 @@ var SessionSelector = class {
|
|
|
10787
10550
|
if (!isNaN(index) && index.toString() === trimmedIdentifier && index > 0 && index <= sortedSessions.length) {
|
|
10788
10551
|
return sortedSessions[index - 1];
|
|
10789
10552
|
}
|
|
10790
|
-
const chatsDir =
|
|
10553
|
+
const chatsDir = path.join(this.storage.getProjectTempDir(), "chats");
|
|
10791
10554
|
throw SessionError.invalidSessionIdentifier(trimmedIdentifier, chatsDir);
|
|
10792
10555
|
}
|
|
10793
10556
|
/**
|
|
@@ -10826,8 +10589,8 @@ var SessionSelector = class {
|
|
|
10826
10589
|
* Loads session data for a selected session.
|
|
10827
10590
|
*/
|
|
10828
10591
|
async selectSession(sessionInfo) {
|
|
10829
|
-
const chatsDir =
|
|
10830
|
-
const sessionPath =
|
|
10592
|
+
const chatsDir = path.join(this.storage.getProjectTempDir(), "chats");
|
|
10593
|
+
const sessionPath = path.join(chatsDir, sessionInfo.fileName);
|
|
10831
10594
|
try {
|
|
10832
10595
|
const sessionData = await loadConversationRecord(sessionPath);
|
|
10833
10596
|
if (!sessionData) {
|
|
@@ -10913,8 +10676,8 @@ function convertSessionToHistoryFormats(messages) {
|
|
|
10913
10676
|
}
|
|
10914
10677
|
|
|
10915
10678
|
// packages/cli/src/utils/sessionCleanup.ts
|
|
10916
|
-
import * as
|
|
10917
|
-
import * as
|
|
10679
|
+
import * as fs2 from "node:fs/promises";
|
|
10680
|
+
import * as path2 from "node:path";
|
|
10918
10681
|
var DEFAULT_MIN_RETENTION = "1d";
|
|
10919
10682
|
var MIN_MAX_COUNT = 1;
|
|
10920
10683
|
var MULTIPLIERS = {
|
|
@@ -10937,7 +10700,7 @@ function deriveShortIdFromFileName(fileName) {
|
|
|
10937
10700
|
}
|
|
10938
10701
|
async function cleanupSessionAndSubagentsAsync(sessionId, config) {
|
|
10939
10702
|
const tempDir = config.storage.getProjectTempDir();
|
|
10940
|
-
const chatsDir =
|
|
10703
|
+
const chatsDir = path2.join(tempDir, "chats");
|
|
10941
10704
|
await deleteSessionArtifactsAsync(sessionId, tempDir);
|
|
10942
10705
|
await deleteSubagentSessionDirAndArtifactsAsync(sessionId, chatsDir, tempDir);
|
|
10943
10706
|
}
|
|
@@ -10954,7 +10717,7 @@ async function cleanupExpiredSessions(config, settings) {
|
|
|
10954
10717
|
return { ...result, disabled: true };
|
|
10955
10718
|
}
|
|
10956
10719
|
const retentionConfig = settings.general.sessionRetention;
|
|
10957
|
-
const chatsDir =
|
|
10720
|
+
const chatsDir = path2.join(config.storage.getProjectTempDir(), "chats");
|
|
10958
10721
|
const validationErrorMessage = validateRetentionConfig(
|
|
10959
10722
|
config,
|
|
10960
10723
|
retentionConfig
|
|
@@ -10985,11 +10748,11 @@ async function cleanupExpiredSessions(config, settings) {
|
|
|
10985
10748
|
(f) => f.startsWith(SESSION_FILE_PREFIX) && f.endsWith(`-${shortId}.json`)
|
|
10986
10749
|
);
|
|
10987
10750
|
for (const file of matchingFiles) {
|
|
10988
|
-
const filePath =
|
|
10751
|
+
const filePath = path2.join(chatsDir, file);
|
|
10989
10752
|
let fullSessionId;
|
|
10990
10753
|
try {
|
|
10991
10754
|
try {
|
|
10992
|
-
const fileContent = await
|
|
10755
|
+
const fileContent = await fs2.readFile(filePath, "utf8");
|
|
10993
10756
|
const content = JSON.parse(fileContent);
|
|
10994
10757
|
if (content && typeof content === "object" && "sessionId" in content) {
|
|
10995
10758
|
const record = content;
|
|
@@ -11001,7 +10764,7 @@ async function cleanupExpiredSessions(config, settings) {
|
|
|
11001
10764
|
} catch {
|
|
11002
10765
|
}
|
|
11003
10766
|
if (!fullSessionId || fullSessionId !== config.getSessionId()) {
|
|
11004
|
-
await
|
|
10767
|
+
await fs2.unlink(filePath);
|
|
11005
10768
|
if (fullSessionId) {
|
|
11006
10769
|
await cleanupSessionAndSubagentsAsync(fullSessionId, config);
|
|
11007
10770
|
}
|
|
@@ -11020,8 +10783,8 @@ async function cleanupExpiredSessions(config, settings) {
|
|
|
11020
10783
|
}
|
|
11021
10784
|
}
|
|
11022
10785
|
} else {
|
|
11023
|
-
const sessionPath =
|
|
11024
|
-
await
|
|
10786
|
+
const sessionPath = path2.join(chatsDir, sessionToDelete.fileName);
|
|
10787
|
+
await fs2.unlink(sessionPath);
|
|
11025
10788
|
const sessionId = sessionToDelete.sessionInfo?.id;
|
|
11026
10789
|
if (sessionId) {
|
|
11027
10790
|
await cleanupSessionAndSubagentsAsync(sessionId, config);
|
|
@@ -11177,13 +10940,13 @@ async function cleanupToolOutputFiles(settings, debugMode = false, projectTempDi
|
|
|
11177
10940
|
await storage.initialize();
|
|
11178
10941
|
tempDir = storage.getProjectTempDir();
|
|
11179
10942
|
}
|
|
11180
|
-
const toolOutputDir =
|
|
10943
|
+
const toolOutputDir = path2.join(tempDir, TOOL_OUTPUTS_DIR);
|
|
11181
10944
|
try {
|
|
11182
|
-
await
|
|
10945
|
+
await fs2.access(toolOutputDir);
|
|
11183
10946
|
} catch {
|
|
11184
10947
|
return result;
|
|
11185
10948
|
}
|
|
11186
|
-
const entries = await
|
|
10949
|
+
const entries = await fs2.readdir(toolOutputDir, { withFileTypes: true });
|
|
11187
10950
|
result.scanned = entries.length;
|
|
11188
10951
|
if (entries.length === 0) {
|
|
11189
10952
|
return result;
|
|
@@ -11192,8 +10955,8 @@ async function cleanupToolOutputFiles(settings, debugMode = false, projectTempDi
|
|
|
11192
10955
|
const fileStatsResults = await Promise.all(
|
|
11193
10956
|
files.map(async (file) => {
|
|
11194
10957
|
try {
|
|
11195
|
-
const filePath =
|
|
11196
|
-
const stat2 = await
|
|
10958
|
+
const filePath = path2.join(toolOutputDir, file.name);
|
|
10959
|
+
const stat2 = await fs2.stat(filePath);
|
|
11197
10960
|
return { name: file.name, mtime: stat2.mtime };
|
|
11198
10961
|
} catch (error) {
|
|
11199
10962
|
debugLogger.debug(
|
|
@@ -11246,8 +11009,8 @@ async function cleanupToolOutputFiles(settings, debugMode = false, projectTempDi
|
|
|
11246
11009
|
);
|
|
11247
11010
|
continue;
|
|
11248
11011
|
}
|
|
11249
|
-
const subdirPath =
|
|
11250
|
-
const stat2 = await
|
|
11012
|
+
const subdirPath = path2.join(toolOutputDir, subdir.name);
|
|
11013
|
+
const stat2 = await fs2.stat(subdirPath);
|
|
11251
11014
|
let shouldDelete = false;
|
|
11252
11015
|
if (retentionConfig.maxAge) {
|
|
11253
11016
|
const maxAgeMs = parseRetentionPeriod(retentionConfig.maxAge);
|
|
@@ -11257,7 +11020,7 @@ async function cleanupToolOutputFiles(settings, debugMode = false, projectTempDi
|
|
|
11257
11020
|
}
|
|
11258
11021
|
}
|
|
11259
11022
|
if (shouldDelete) {
|
|
11260
|
-
await
|
|
11023
|
+
await fs2.rm(subdirPath, { recursive: true, force: true });
|
|
11261
11024
|
result.deleted++;
|
|
11262
11025
|
}
|
|
11263
11026
|
} catch (error) {
|
|
@@ -11266,8 +11029,8 @@ async function cleanupToolOutputFiles(settings, debugMode = false, projectTempDi
|
|
|
11266
11029
|
}
|
|
11267
11030
|
for (const fileName of filesToDelete) {
|
|
11268
11031
|
try {
|
|
11269
|
-
const filePath =
|
|
11270
|
-
await
|
|
11032
|
+
const filePath = path2.join(toolOutputDir, fileName);
|
|
11033
|
+
await fs2.unlink(filePath);
|
|
11271
11034
|
result.deleted++;
|
|
11272
11035
|
} catch (error) {
|
|
11273
11036
|
debugLogger.debug(
|
|
@@ -11291,11 +11054,11 @@ async function cleanupToolOutputFiles(settings, debugMode = false, projectTempDi
|
|
|
11291
11054
|
|
|
11292
11055
|
// packages/cli/src/config/settings.ts
|
|
11293
11056
|
var dotenv = __toESM(require_main(), 1);
|
|
11294
|
-
import * as
|
|
11295
|
-
import * as
|
|
11057
|
+
import * as fs4 from "node:fs";
|
|
11058
|
+
import * as path3 from "node:path";
|
|
11296
11059
|
import { platform } from "node:os";
|
|
11297
11060
|
import process2 from "node:process";
|
|
11298
|
-
var
|
|
11061
|
+
var import_strip_json_comments = __toESM(require_strip_json_comments(), 1);
|
|
11299
11062
|
|
|
11300
11063
|
// packages/cli/src/ui/themes/theme.ts
|
|
11301
11064
|
var import_tinygradient = __toESM(require_tinygradient(), 1);
|
|
@@ -14465,6 +14228,19 @@ var SETTINGS_SCHEMA = {
|
|
|
14465
14228
|
showInDialog: false,
|
|
14466
14229
|
items: { type: "string" }
|
|
14467
14230
|
},
|
|
14231
|
+
confirmationRequired: {
|
|
14232
|
+
type: "array",
|
|
14233
|
+
label: "Confirmation Required",
|
|
14234
|
+
category: "Advanced",
|
|
14235
|
+
requiresRestart: true,
|
|
14236
|
+
default: void 0,
|
|
14237
|
+
description: oneLine`
|
|
14238
|
+
Tool names that always require user confirmation.
|
|
14239
|
+
Takes precedence over allowed tools and core tool allowlists.
|
|
14240
|
+
`,
|
|
14241
|
+
showInDialog: false,
|
|
14242
|
+
items: { type: "string" }
|
|
14243
|
+
},
|
|
14468
14244
|
exclude: {
|
|
14469
14245
|
type: "array",
|
|
14470
14246
|
label: "Exclude Tools",
|
|
@@ -16189,7 +15965,7 @@ function resolveEnvVarsInObjectInternal(obj, visited, customEnv) {
|
|
|
16189
15965
|
function isPlainObject(item) {
|
|
16190
15966
|
return !!item && typeof item === "object" && !Array.isArray(item);
|
|
16191
15967
|
}
|
|
16192
|
-
function mergeRecursively(target, source, getMergeStrategyForPath2,
|
|
15968
|
+
function mergeRecursively(target, source, getMergeStrategyForPath2, path6 = []) {
|
|
16193
15969
|
for (const key of Object.keys(source)) {
|
|
16194
15970
|
if (key === "__proto__" || key === "constructor" || key === "prototype") {
|
|
16195
15971
|
continue;
|
|
@@ -16198,7 +15974,7 @@ function mergeRecursively(target, source, getMergeStrategyForPath2, path7 = [])
|
|
|
16198
15974
|
if (srcValue === void 0) {
|
|
16199
15975
|
continue;
|
|
16200
15976
|
}
|
|
16201
|
-
const newPath = [...
|
|
15977
|
+
const newPath = [...path6, key];
|
|
16202
15978
|
const objValue = target[key];
|
|
16203
15979
|
const mergeStrategy = getMergeStrategyForPath2(newPath);
|
|
16204
15980
|
if (mergeStrategy === "shallow_merge" /* SHALLOW_MERGE */ && objValue && srcValue) {
|
|
@@ -16247,13 +16023,13 @@ function customDeepMerge(getMergeStrategyForPath2, ...sources) {
|
|
|
16247
16023
|
|
|
16248
16024
|
// packages/cli/src/utils/commentJson.ts
|
|
16249
16025
|
var import_comment_json = __toESM(require_src2(), 1);
|
|
16250
|
-
import * as
|
|
16026
|
+
import * as fs3 from "node:fs";
|
|
16251
16027
|
function updateSettingsFilePreservingFormat(filePath, updates) {
|
|
16252
|
-
if (!
|
|
16253
|
-
|
|
16028
|
+
if (!fs3.existsSync(filePath)) {
|
|
16029
|
+
fs3.writeFileSync(filePath, JSON.stringify(updates, null, 2), "utf-8");
|
|
16254
16030
|
return;
|
|
16255
16031
|
}
|
|
16256
|
-
const originalContent =
|
|
16032
|
+
const originalContent = fs3.readFileSync(filePath, "utf-8");
|
|
16257
16033
|
let parsed;
|
|
16258
16034
|
try {
|
|
16259
16035
|
parsed = (0, import_comment_json.parse)(originalContent);
|
|
@@ -16267,7 +16043,7 @@ function updateSettingsFilePreservingFormat(filePath, updates) {
|
|
|
16267
16043
|
}
|
|
16268
16044
|
const updatedStructure = applyUpdates(parsed, updates);
|
|
16269
16045
|
const updatedContent = (0, import_comment_json.stringify)(updatedStructure, null, 2);
|
|
16270
|
-
|
|
16046
|
+
fs3.writeFileSync(filePath, updatedContent, "utf-8");
|
|
16271
16047
|
}
|
|
16272
16048
|
function preserveCommentsOnPropertyDeletion(container, propName) {
|
|
16273
16049
|
const target = container;
|
|
@@ -16536,11 +16312,11 @@ function formatValidationError(error, filePath) {
|
|
|
16536
16312
|
const MAX_ERRORS_TO_DISPLAY = 5;
|
|
16537
16313
|
const displayedIssues = error.issues.slice(0, MAX_ERRORS_TO_DISPLAY);
|
|
16538
16314
|
for (const issue of displayedIssues) {
|
|
16539
|
-
const
|
|
16315
|
+
const path6 = issue.path.reduce(
|
|
16540
16316
|
(acc, curr) => typeof curr === "number" ? `${acc}[${curr}]` : `${acc ? acc + "." : ""}${curr}`,
|
|
16541
16317
|
""
|
|
16542
16318
|
);
|
|
16543
|
-
lines.push(`Error in: ${
|
|
16319
|
+
lines.push(`Error in: ${path6 || "(root)"}`);
|
|
16544
16320
|
lines.push(` ${issue.message}`);
|
|
16545
16321
|
if (issue.code === "invalid_type") {
|
|
16546
16322
|
const expected = issue.expected;
|
|
@@ -16561,11 +16337,11 @@ function formatValidationError(error, filePath) {
|
|
|
16561
16337
|
}
|
|
16562
16338
|
|
|
16563
16339
|
// packages/cli/src/config/settings.ts
|
|
16564
|
-
function getMergeStrategyForPath(
|
|
16340
|
+
function getMergeStrategyForPath(path6) {
|
|
16565
16341
|
let current = void 0;
|
|
16566
16342
|
let currentSchema = getSettingsSchema();
|
|
16567
16343
|
let parent = void 0;
|
|
16568
|
-
for (const key of
|
|
16344
|
+
for (const key of path6) {
|
|
16569
16345
|
if (!currentSchema || !currentSchema[key]) {
|
|
16570
16346
|
if (parent?.additionalProperties?.mergeStrategy) {
|
|
16571
16347
|
return parent.additionalProperties.mergeStrategy;
|
|
@@ -16579,7 +16355,7 @@ function getMergeStrategyForPath(path7) {
|
|
|
16579
16355
|
return current?.mergeStrategy;
|
|
16580
16356
|
}
|
|
16581
16357
|
var USER_SETTINGS_PATH = Storage.getGlobalSettingsPath();
|
|
16582
|
-
var USER_SETTINGS_DIR =
|
|
16358
|
+
var USER_SETTINGS_DIR = path3.dirname(USER_SETTINGS_PATH);
|
|
16583
16359
|
var DEFAULT_EXCLUDED_ENV_VARS = [
|
|
16584
16360
|
"DEBUG",
|
|
16585
16361
|
"DEBUG_MODE",
|
|
@@ -16611,8 +16387,8 @@ function getSystemDefaultsPath() {
|
|
|
16611
16387
|
if (process2.env["GEMINI_CLI_SYSTEM_DEFAULTS_PATH"]) {
|
|
16612
16388
|
return process2.env["GEMINI_CLI_SYSTEM_DEFAULTS_PATH"];
|
|
16613
16389
|
}
|
|
16614
|
-
return
|
|
16615
|
-
|
|
16390
|
+
return path3.join(
|
|
16391
|
+
path3.dirname(getSystemSettingsPath()),
|
|
16616
16392
|
"system-defaults.json"
|
|
16617
16393
|
);
|
|
16618
16394
|
}
|
|
@@ -16633,8 +16409,8 @@ var _loadableSettingScopes = [
|
|
|
16633
16409
|
function isLoadableSettingScope(scope) {
|
|
16634
16410
|
return _loadableSettingScopes.includes(scope);
|
|
16635
16411
|
}
|
|
16636
|
-
function setNestedProperty(obj,
|
|
16637
|
-
const keys =
|
|
16412
|
+
function setNestedProperty(obj, path6, value) {
|
|
16413
|
+
const keys = path6.split(".");
|
|
16638
16414
|
const lastKey = keys.pop();
|
|
16639
16415
|
if (!lastKey) return;
|
|
16640
16416
|
let current = obj;
|
|
@@ -16729,7 +16505,7 @@ var LoadedSettings = class {
|
|
|
16729
16505
|
const adminSchema = adminSettingSchema.properties;
|
|
16730
16506
|
const adminDefaults = getDefaultsFromSchema(adminSchema);
|
|
16731
16507
|
merged.admin = customDeepMerge(
|
|
16732
|
-
(
|
|
16508
|
+
(path6) => getMergeStrategyForPath(["admin", ...path6]),
|
|
16733
16509
|
adminDefaults,
|
|
16734
16510
|
this._remoteAdminSettings?.admin ?? {}
|
|
16735
16511
|
);
|
|
@@ -16820,25 +16596,29 @@ var LoadedSettings = class {
|
|
|
16820
16596
|
this._merged = this.computeMergedSettings();
|
|
16821
16597
|
}
|
|
16822
16598
|
};
|
|
16823
|
-
function findEnvFile(startDir) {
|
|
16824
|
-
let currentDir =
|
|
16599
|
+
function findEnvFile(startDir, isTrusted) {
|
|
16600
|
+
let currentDir = path3.resolve(startDir);
|
|
16825
16601
|
while (true) {
|
|
16826
|
-
|
|
16827
|
-
|
|
16828
|
-
|
|
16602
|
+
if (isTrusted) {
|
|
16603
|
+
const geminiEnvPath = path3.join(currentDir, GEMINI_DIR, ".env");
|
|
16604
|
+
if (fs4.existsSync(geminiEnvPath)) {
|
|
16605
|
+
return geminiEnvPath;
|
|
16606
|
+
}
|
|
16829
16607
|
}
|
|
16830
|
-
const envPath =
|
|
16831
|
-
if (
|
|
16608
|
+
const envPath = path3.join(currentDir, ".env");
|
|
16609
|
+
if (fs4.existsSync(envPath)) {
|
|
16832
16610
|
return envPath;
|
|
16833
16611
|
}
|
|
16834
|
-
const parentDir =
|
|
16612
|
+
const parentDir = path3.dirname(currentDir);
|
|
16835
16613
|
if (parentDir === currentDir || !parentDir) {
|
|
16836
|
-
|
|
16837
|
-
|
|
16838
|
-
|
|
16614
|
+
if (isTrusted) {
|
|
16615
|
+
const homeGeminiEnvPath = path3.join(homedir(), GEMINI_DIR, ".env");
|
|
16616
|
+
if (fs4.existsSync(homeGeminiEnvPath)) {
|
|
16617
|
+
return homeGeminiEnvPath;
|
|
16618
|
+
}
|
|
16839
16619
|
}
|
|
16840
|
-
const homeEnvPath =
|
|
16841
|
-
if (
|
|
16620
|
+
const homeEnvPath = path3.join(homedir(), ".env");
|
|
16621
|
+
if (fs4.existsSync(homeEnvPath)) {
|
|
16842
16622
|
return homeEnvPath;
|
|
16843
16623
|
}
|
|
16844
16624
|
return null;
|
|
@@ -16848,8 +16628,8 @@ function findEnvFile(startDir) {
|
|
|
16848
16628
|
}
|
|
16849
16629
|
function setUpCloudShellEnvironment(envFilePath, isTrusted, isSandboxed) {
|
|
16850
16630
|
let value = "cloudshell-gca";
|
|
16851
|
-
if (envFilePath &&
|
|
16852
|
-
const envFileContent =
|
|
16631
|
+
if (envFilePath && fs4.existsSync(envFilePath)) {
|
|
16632
|
+
const envFileContent = fs4.readFileSync(envFilePath);
|
|
16853
16633
|
const parsedEnv = dotenv.parse(envFileContent);
|
|
16854
16634
|
if (parsedEnv["GOOGLE_CLOUD_PROJECT"]) {
|
|
16855
16635
|
value = parsedEnv["GOOGLE_CLOUD_PROJECT"];
|
|
@@ -16861,9 +16641,9 @@ function setUpCloudShellEnvironment(envFilePath, isTrusted, isSandboxed) {
|
|
|
16861
16641
|
process2.env["GOOGLE_CLOUD_PROJECT"] = value;
|
|
16862
16642
|
}
|
|
16863
16643
|
function loadEnvironment(settings, workspaceDir, isWorkspaceTrustedFn = isWorkspaceTrusted) {
|
|
16864
|
-
const envFilePath = findEnvFile(workspaceDir);
|
|
16865
16644
|
const trustResult = isWorkspaceTrustedFn(settings, workspaceDir);
|
|
16866
16645
|
const isTrusted = trustResult.isTrusted ?? false;
|
|
16646
|
+
const envFilePath = findEnvFile(workspaceDir, isTrusted);
|
|
16867
16647
|
const args = process2.argv.slice(2);
|
|
16868
16648
|
const doubleDashIndex = args.indexOf("--");
|
|
16869
16649
|
const relevantArgs = doubleDashIndex === -1 ? args : args.slice(0, doubleDashIndex);
|
|
@@ -16873,14 +16653,14 @@ function loadEnvironment(settings, workspaceDir, isWorkspaceTrustedFn = isWorksp
|
|
|
16873
16653
|
}
|
|
16874
16654
|
if (envFilePath) {
|
|
16875
16655
|
try {
|
|
16876
|
-
const envFileContent =
|
|
16656
|
+
const envFileContent = fs4.readFileSync(envFilePath, "utf-8");
|
|
16877
16657
|
const parsedEnv = dotenv.parse(envFileContent);
|
|
16878
16658
|
const excludedVars = settings?.advanced?.excludedEnvVars || DEFAULT_EXCLUDED_ENV_VARS;
|
|
16879
16659
|
const isProjectEnvFile = !envFilePath.includes(GEMINI_DIR);
|
|
16880
16660
|
for (const key in parsedEnv) {
|
|
16881
16661
|
if (Object.hasOwn(parsedEnv, key)) {
|
|
16882
16662
|
let value = parsedEnv[key];
|
|
16883
|
-
if (!isTrusted
|
|
16663
|
+
if (!isTrusted) {
|
|
16884
16664
|
if (!AUTH_ENV_VAR_WHITELIST.includes(key)) {
|
|
16885
16665
|
continue;
|
|
16886
16666
|
}
|
|
@@ -16907,7 +16687,7 @@ function isWorktreeEnabled(settings) {
|
|
|
16907
16687
|
return settings.merged.experimental.worktrees;
|
|
16908
16688
|
}
|
|
16909
16689
|
function loadSettings(workspaceDir = process2.cwd()) {
|
|
16910
|
-
const normalizedWorkspaceDir =
|
|
16690
|
+
const normalizedWorkspaceDir = path3.resolve(workspaceDir);
|
|
16911
16691
|
return settingsCache.getOrCreate(
|
|
16912
16692
|
normalizedWorkspaceDir,
|
|
16913
16693
|
() => _doLoadSettings(normalizedWorkspaceDir)
|
|
@@ -16925,9 +16705,9 @@ function _doLoadSettings(workspaceDir) {
|
|
|
16925
16705
|
const workspaceSettingsPath = storage.getWorkspaceSettingsPath();
|
|
16926
16706
|
const load = (filePath) => {
|
|
16927
16707
|
try {
|
|
16928
|
-
if (
|
|
16929
|
-
const content =
|
|
16930
|
-
const rawSettings = JSON.parse((0,
|
|
16708
|
+
if (fs4.existsSync(filePath)) {
|
|
16709
|
+
const content = fs4.readFileSync(filePath, "utf-8");
|
|
16710
|
+
const rawSettings = JSON.parse((0, import_strip_json_comments.default)(content));
|
|
16931
16711
|
if (typeof rawSettings !== "object" || rawSettings === null || Array.isArray(rawSettings)) {
|
|
16932
16712
|
settingsErrors.push({
|
|
16933
16713
|
message: "Settings file is not a valid JSON object.",
|
|
@@ -17216,9 +16996,9 @@ function migrateDeprecatedSettings(loadedSettings, removeDeprecated = true) {
|
|
|
17216
16996
|
function saveSettings(settingsFile) {
|
|
17217
16997
|
settingsCache.clear();
|
|
17218
16998
|
try {
|
|
17219
|
-
const dirPath =
|
|
17220
|
-
if (!
|
|
17221
|
-
|
|
16999
|
+
const dirPath = path3.dirname(settingsFile.path);
|
|
17000
|
+
if (!fs4.existsSync(dirPath)) {
|
|
17001
|
+
fs4.mkdirSync(dirPath, { recursive: true });
|
|
17222
17002
|
}
|
|
17223
17003
|
const settingsToSave = settingsFile.originalSettings;
|
|
17224
17004
|
updateSettingsFilePreservingFormat(
|
|
@@ -17343,7 +17123,7 @@ function migrateExperimentalSettings(settings, loadedSettings, scope, removeDepr
|
|
|
17343
17123
|
}
|
|
17344
17124
|
|
|
17345
17125
|
// packages/cli/src/commands/gemma/constants.ts
|
|
17346
|
-
import
|
|
17126
|
+
import path4 from "node:path";
|
|
17347
17127
|
var LITERT_RELEASE_VERSION = "v0.9.0-alpha03";
|
|
17348
17128
|
var LITERT_RELEASE_BASE_URL = "https://github.com/google-ai-edge/LiteRT-LM/releases/download";
|
|
17349
17129
|
var GEMMA_MODEL_NAME = "gemma3-1b-gpu-custom";
|
|
@@ -17362,18 +17142,18 @@ var PLATFORM_BINARY_SHA256 = {
|
|
|
17362
17142
|
"lit.windows_x86_64.exe": "de82d2829d2fb1cbdb318e2d8a78dc2f9659ff14cb11b2894d1f30e0bfde2bf6"
|
|
17363
17143
|
};
|
|
17364
17144
|
function getLiteRtBinDir() {
|
|
17365
|
-
return
|
|
17145
|
+
return path4.join(Storage.getGlobalGeminiDir(), "bin", "litert");
|
|
17366
17146
|
}
|
|
17367
17147
|
function getPidFilePath() {
|
|
17368
|
-
return
|
|
17148
|
+
return path4.join(Storage.getGlobalTempDir(), "litert-server.pid");
|
|
17369
17149
|
}
|
|
17370
17150
|
function getLogFilePath() {
|
|
17371
|
-
return
|
|
17151
|
+
return path4.join(Storage.getGlobalTempDir(), "litert-server.log");
|
|
17372
17152
|
}
|
|
17373
17153
|
|
|
17374
17154
|
// packages/cli/src/commands/gemma/platform.ts
|
|
17375
|
-
import
|
|
17376
|
-
import
|
|
17155
|
+
import fs5 from "node:fs";
|
|
17156
|
+
import path5 from "node:path";
|
|
17377
17157
|
import { execFileSync } from "node:child_process";
|
|
17378
17158
|
function getUserConfiguredBinaryPath(workspaceDir = process.cwd()) {
|
|
17379
17159
|
try {
|
|
@@ -17433,14 +17213,14 @@ function getBinaryPath(binaryName) {
|
|
|
17433
17213
|
}
|
|
17434
17214
|
const name = binaryName ?? detectPlatform()?.binaryName;
|
|
17435
17215
|
if (!name) return null;
|
|
17436
|
-
return
|
|
17216
|
+
return path5.join(getLiteRtBinDir(), name);
|
|
17437
17217
|
}
|
|
17438
17218
|
function getBinaryDownloadUrl(binaryName) {
|
|
17439
17219
|
return `${LITERT_RELEASE_BASE_URL}/${LITERT_RELEASE_VERSION}/${binaryName}`;
|
|
17440
17220
|
}
|
|
17441
17221
|
function isBinaryInstalled(binaryPath = getBinaryPath()) {
|
|
17442
17222
|
if (!binaryPath) return false;
|
|
17443
|
-
return
|
|
17223
|
+
return fs5.existsSync(binaryPath);
|
|
17444
17224
|
}
|
|
17445
17225
|
function isModelDownloaded(binaryPath) {
|
|
17446
17226
|
try {
|
|
@@ -17496,7 +17276,7 @@ function isLiteRtServerProcessInfo(value) {
|
|
|
17496
17276
|
function readServerProcessInfo() {
|
|
17497
17277
|
const pidPath = getPidFilePath();
|
|
17498
17278
|
try {
|
|
17499
|
-
const content =
|
|
17279
|
+
const content = fs5.readFileSync(pidPath, "utf-8").trim();
|
|
17500
17280
|
if (!content) {
|
|
17501
17281
|
return null;
|
|
17502
17282
|
}
|
|
@@ -17510,7 +17290,7 @@ function readServerProcessInfo() {
|
|
|
17510
17290
|
}
|
|
17511
17291
|
}
|
|
17512
17292
|
function writeServerProcessInfo(processInfo) {
|
|
17513
|
-
|
|
17293
|
+
fs5.writeFileSync(getPidFilePath(), JSON.stringify(processInfo), "utf-8");
|
|
17514
17294
|
}
|
|
17515
17295
|
function readServerPid() {
|
|
17516
17296
|
return readServerProcessInfo()?.pid ?? null;
|
|
@@ -17525,7 +17305,7 @@ function normalizeProcessValue(value) {
|
|
|
17525
17305
|
function readProcessCommandLine(pid) {
|
|
17526
17306
|
try {
|
|
17527
17307
|
if (process.platform === "linux") {
|
|
17528
|
-
const output2 =
|
|
17308
|
+
const output2 = fs5.readFileSync(`/proc/${pid}/cmdline`, "utf-8");
|
|
17529
17309
|
return output2.trim() ? output2 : null;
|
|
17530
17310
|
}
|
|
17531
17311
|
if (process.platform === "win32") {
|
|
@@ -17568,7 +17348,7 @@ function isExpectedLiteRtServerCommand(commandLine, options) {
|
|
|
17568
17348
|
}
|
|
17569
17349
|
const normalizedBinaryPath = normalizeProcessValue(options.binaryPath);
|
|
17570
17350
|
const normalizedBinaryName = normalizeProcessValue(
|
|
17571
|
-
|
|
17351
|
+
path5.basename(options.binaryPath)
|
|
17572
17352
|
);
|
|
17573
17353
|
return normalizedCommandLine.includes(normalizedBinaryPath) || normalizedCommandLine.includes(normalizedBinaryName);
|
|
17574
17354
|
}
|
|
@@ -17631,8 +17411,8 @@ export {
|
|
|
17631
17411
|
pickDefaultThemeName,
|
|
17632
17412
|
DefaultLight,
|
|
17633
17413
|
DefaultDark,
|
|
17634
|
-
loadTrustedFolders,
|
|
17635
17414
|
isFolderTrustEnabled,
|
|
17415
|
+
loadTrustedFolders2 as loadTrustedFolders,
|
|
17636
17416
|
isWorkspaceTrusted,
|
|
17637
17417
|
isFullWidth,
|
|
17638
17418
|
isWide,
|