@google/gemini-cli 0.70.0-preview.0 → 0.71.0-nightly.20261120.gd4cb1713f
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-O5EBPO5F.js → chunk-22NLCXU3.js} +2 -2
- package/bundle/{chunk-SXOGAWDG.js → chunk-3DBVNRC7.js} +1 -1
- package/bundle/{chunk-F6P6PQSG.js → chunk-3VKSDKQA.js} +1 -1
- package/bundle/{chunk-65MRMUKB.js → chunk-43QQPZRQ.js} +2 -2
- package/bundle/{chunk-NFBC76U4.js → chunk-4FKCNBUM.js} +1 -1
- package/bundle/{chunk-CJ7YZ55P.js → chunk-4SEHQOPY.js} +3 -3
- package/bundle/{chunk-BOYVA4SV.js → chunk-4V6FXIV7.js} +1 -1
- package/bundle/{chunk-ZUQTNDGH.js → chunk-4YWPS6WG.js} +7 -7
- package/bundle/{chunk-STY67ND2.js → chunk-6VJSIYX5.js} +9 -8
- package/bundle/{chunk-TX3SX2WI.js → chunk-7CGFKAQQ.js} +2 -2
- package/bundle/{chunk-CMUPNBQQ.js → chunk-7WRW57EW.js} +2 -2
- package/bundle/{chunk-I5QSCSQU.js → chunk-AQR7HAVC.js} +878 -371
- package/bundle/{chunk-T7277DWX.js → chunk-AWAS7A4U.js} +1 -1
- package/bundle/{chunk-IS5SQ7HP.js → chunk-BFYOZTEC.js} +8 -6
- package/bundle/{chunk-6XLLXGZQ.js → chunk-CVDUPOPD.js} +1 -1
- package/bundle/{chunk-AMGYQYS7.js → chunk-EV4MLSRK.js} +2 -2
- package/bundle/{chunk-NFAJ5FW5.js → chunk-H35O2XC7.js} +1 -1
- package/bundle/{chunk-HBTS2REO.js → chunk-HBX5SUG6.js} +1 -1
- package/bundle/chunk-ID6HT5PN.js +512 -0
- package/bundle/chunk-JUDLPWWJ.js +1962 -0
- package/bundle/{chunk-RVYQZ73V.js → chunk-JVBEESQE.js} +3 -3
- package/bundle/{chunk-FDIF7V5C.js → chunk-L7GW5P2N.js} +1 -1
- package/bundle/{chunk-O2DXIYZO.js → chunk-MFOWRKY4.js} +782 -323
- package/bundle/chunk-MPPDWK6R.js +40024 -0
- package/bundle/{chunk-FGTABIOQ.js → chunk-NF46UAZ5.js} +1 -1
- package/bundle/chunk-P3QKD7NI.js +190 -0
- package/bundle/chunk-P5SMSWOI.js +65 -0
- package/bundle/{chunk-ECLDXLDB.js → chunk-Q3MSDTUZ.js} +3 -3
- package/bundle/{chunk-L5UVIFFB.js → chunk-QYILFI2Q.js} +7 -7
- package/bundle/{chunk-RTIGPATB.js → chunk-R5O4JOJ7.js} +1 -1
- package/bundle/chunk-T5ERFODG.js +118 -0
- package/bundle/{chunk-SA2VIQNQ.js → chunk-TKCJYF6S.js} +8765 -15613
- package/bundle/{chunk-BCL7DJOQ.js → chunk-WEQEDCCJ.js} +71 -58
- package/bundle/chunk-YGBB6EOP.js +1571 -0
- package/bundle/chunk-ZL2NEMMB.js +420386 -0
- package/bundle/chunk-ZM7BCSH5.js +60338 -0
- package/bundle/{cleanup-44LV7E4R.js → cleanup-2V4YG4JU.js} +2 -2
- package/bundle/{cleanup-O4QBMRVU.js → cleanup-577T3DEI.js} +2 -2
- package/bundle/{cleanup-WMYSWXJR.js → cleanup-A7BQ5O2C.js} +2 -2
- package/bundle/cleanup-BER5KF3M.js +34 -0
- package/bundle/{core-LJXCBOFM.js → core-J5GAQUTA.js} +31 -1
- package/bundle/{devtoolsService-D4VCGQMJ.js → devtoolsService-5ICQIIYF.js} +2 -2
- package/bundle/{devtoolsService-G4CPAW3U.js → devtoolsService-7E2XLRN6.js} +2 -2
- package/bundle/{devtoolsService-EBOCEFTO.js → devtoolsService-B2G4MIWC.js} +4 -3
- package/bundle/devtoolsService-HFMB7OZU.js +919 -0
- package/bundle/{dist-QSS2VWMY.js → dist-63TFONDS.js} +31 -1
- package/bundle/{core-DJ7VMWCC.js → dist-J4SRUOE6.js} +31 -1
- package/bundle/dist-J54GSUG2.js +2372 -0
- package/bundle/docs/changelogs/index.md +46 -0
- package/bundle/docs/changelogs/latest.md +82 -100
- package/bundle/docs/changelogs/preview.md +82 -115
- package/bundle/{formatError-I5Q2HGMN.js → formatError-ISWUYAZB.js} +2 -2
- package/bundle/{formatError-NLKMYJNL.js → formatError-IX7HHO6M.js} +2 -2
- package/bundle/{formatError-3QIVJAE5.js → formatError-MZRXOV55.js} +2 -2
- package/bundle/formatError-U2ZQLJHB.js +14 -0
- package/bundle/{gemini-4325ARIU.js → gemini-FRGLIXP7.js} +15 -15
- package/bundle/{gemini-LOYZXP6I.js → gemini-GSQARDB2.js} +224 -208
- package/bundle/gemini-KZFVMGY3.js +20020 -0
- package/bundle/{gemini-J7ZRUAXR.js → gemini-ZZBTL6TA.js} +15 -15
- package/bundle/gemini.js +8 -8
- package/bundle/{interactiveCli-AQ67IY7V.js → interactiveCli-AHDFCTRR.js} +157 -32
- package/bundle/{interactiveCli-CEIWZCYF.js → interactiveCli-MVGIIVAP.js} +157 -32
- package/bundle/{interactiveCli-O2L63RLG.js → interactiveCli-UN4BNLK2.js} +468 -324
- package/bundle/interactiveCli-XW2S7MKZ.js +36447 -0
- package/bundle/{liteRtServerManager-HMCB6A65.js → liteRtServerManager-3MOGK3XY.js} +4 -4
- package/bundle/{liteRtServerManager-MH32CAZ5.js → liteRtServerManager-O727KCKA.js} +4 -4
- package/bundle/{liteRtServerManager-EZFHT2B3.js → liteRtServerManager-TSG2V5XN.js} +4 -4
- package/bundle/liteRtServerManager-YLE7JTV7.js +65 -0
- package/bundle/{oauth2-provider-NPOZQDQO.js → oauth2-provider-3EEFSHG4.js} +1 -1
- package/bundle/{oauth2-provider-3TFNA7VY.js → oauth2-provider-DWO2KVCY.js} +1 -1
- package/bundle/{oauth2-provider-UXC7XFV6.js → oauth2-provider-G25ZRGDY.js} +41 -79
- package/bundle/oauth2-provider-RHT5OSMO.js +273 -0
- package/bundle/{start-JIKLB3S3.js → start-4XOSRN5A.js} +6 -6
- package/bundle/{start-NSYEL7UE.js → start-7JXWL6XR.js} +6 -6
- package/bundle/{start-I2GOKFKQ.js → start-CAA6RQBK.js} +6 -6
- package/bundle/start-I3RUABAZ.js +18 -0
- package/package.json +1 -1
|
@@ -257243,6 +257243,51 @@ import {
|
|
|
257243
257243
|
spawn,
|
|
257244
257244
|
spawnSync
|
|
257245
257245
|
} from "node:child_process";
|
|
257246
|
+
|
|
257247
|
+
// packages/core/src/utils/shell-parse-cache.ts
|
|
257248
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
257249
|
+
var CommandParseCache = class {
|
|
257250
|
+
completed = /* @__PURE__ */ new Map();
|
|
257251
|
+
inFlight = /* @__PURE__ */ new Map();
|
|
257252
|
+
makeKey(executable, command) {
|
|
257253
|
+
return `${executable}\0${command}`;
|
|
257254
|
+
}
|
|
257255
|
+
hasCompleted(executable, command) {
|
|
257256
|
+
return this.completed.has(this.makeKey(executable, command));
|
|
257257
|
+
}
|
|
257258
|
+
getCompleted(executable, command) {
|
|
257259
|
+
return this.completed.get(this.makeKey(executable, command));
|
|
257260
|
+
}
|
|
257261
|
+
setCompleted(executable, command, result) {
|
|
257262
|
+
this.completed.set(this.makeKey(executable, command), result);
|
|
257263
|
+
}
|
|
257264
|
+
getInFlight(executable, command) {
|
|
257265
|
+
return this.inFlight.get(this.makeKey(executable, command));
|
|
257266
|
+
}
|
|
257267
|
+
trackInFlight(executable, command, promise2) {
|
|
257268
|
+
const key = this.makeKey(executable, command);
|
|
257269
|
+
this.inFlight.set(key, promise2);
|
|
257270
|
+
void promise2.finally(() => {
|
|
257271
|
+
if (this.inFlight.get(key) === promise2) {
|
|
257272
|
+
this.inFlight.delete(key);
|
|
257273
|
+
}
|
|
257274
|
+
});
|
|
257275
|
+
return promise2;
|
|
257276
|
+
}
|
|
257277
|
+
};
|
|
257278
|
+
var commandParseCacheStorage = new AsyncLocalStorage();
|
|
257279
|
+
function getActiveCommandParseCache() {
|
|
257280
|
+
return commandParseCacheStorage.getStore();
|
|
257281
|
+
}
|
|
257282
|
+
function runWithCommandParseCache(fn3, cache2) {
|
|
257283
|
+
const targetCache = cache2 ?? commandParseCacheStorage.getStore() ?? new CommandParseCache();
|
|
257284
|
+
if (commandParseCacheStorage.getStore() === targetCache) {
|
|
257285
|
+
return fn3(targetCache);
|
|
257286
|
+
}
|
|
257287
|
+
return commandParseCacheStorage.run(targetCache, () => fn3(targetCache));
|
|
257288
|
+
}
|
|
257289
|
+
|
|
257290
|
+
// packages/core/src/utils/shell-utils.ts
|
|
257246
257291
|
import * as readline from "node:readline";
|
|
257247
257292
|
|
|
257248
257293
|
// node_modules/web-tree-sitter/tree-sitter.js
|
|
@@ -264349,7 +264394,7 @@ async function getCommandName(command, args2) {
|
|
|
264349
264394
|
await initializeShellParsers();
|
|
264350
264395
|
const fullCmd = [command, ...args2].join(" ");
|
|
264351
264396
|
const stripped = stripShellWrapper(fullCmd);
|
|
264352
|
-
const roots =
|
|
264397
|
+
const roots = (await getCommandRootsAsync(stripped)).filter(
|
|
264353
264398
|
(r9) => r9 !== "shopt" && r9 !== "set"
|
|
264354
264399
|
);
|
|
264355
264400
|
if (roots.length > 0) {
|
|
@@ -264755,7 +264800,51 @@ function parseBashCommandDetails(command) {
|
|
|
264755
264800
|
hasError: hasError2
|
|
264756
264801
|
};
|
|
264757
264802
|
}
|
|
264758
|
-
function
|
|
264803
|
+
function isRawPowerShellCommand(value) {
|
|
264804
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
264805
|
+
}
|
|
264806
|
+
function isRawPowerShellParsePayload(value) {
|
|
264807
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
264808
|
+
}
|
|
264809
|
+
function parsePowerShellParserOutput(rawStdout, originalCommand) {
|
|
264810
|
+
const output = rawStdout.trim();
|
|
264811
|
+
if (!output) {
|
|
264812
|
+
return { details: [], hasError: true };
|
|
264813
|
+
}
|
|
264814
|
+
let parsedUnknown;
|
|
264815
|
+
try {
|
|
264816
|
+
parsedUnknown = JSON.parse(output);
|
|
264817
|
+
} catch {
|
|
264818
|
+
return { details: [], hasError: true };
|
|
264819
|
+
}
|
|
264820
|
+
if (!isRawPowerShellParsePayload(parsedUnknown) || parsedUnknown.success !== true) {
|
|
264821
|
+
return { details: [], hasError: true };
|
|
264822
|
+
}
|
|
264823
|
+
const rawCommandsField = parsedUnknown.commands;
|
|
264824
|
+
const rawCommands = Array.isArray(rawCommandsField) ? rawCommandsField : isRawPowerShellCommand(rawCommandsField) ? [rawCommandsField] : [];
|
|
264825
|
+
const details = rawCommands.map((commandDetail) => {
|
|
264826
|
+
if (!isRawPowerShellCommand(commandDetail) || typeof commandDetail.name !== "string") {
|
|
264827
|
+
return null;
|
|
264828
|
+
}
|
|
264829
|
+
const name3 = normalizeCommandName(commandDetail.name);
|
|
264830
|
+
const text = typeof commandDetail.text === "string" ? commandDetail.text.trim() : originalCommand;
|
|
264831
|
+
const rawArgs = commandDetail.args;
|
|
264832
|
+
return {
|
|
264833
|
+
name: name3,
|
|
264834
|
+
text,
|
|
264835
|
+
startIndex: typeof commandDetail.startIndex === "number" ? commandDetail.startIndex : 0,
|
|
264836
|
+
args: Array.isArray(rawArgs) ? rawArgs.filter((arg) => typeof arg === "string") : void 0
|
|
264837
|
+
};
|
|
264838
|
+
}).filter((detail) => detail !== null).sort((a2, b3) => a2.startIndex - b3.startIndex);
|
|
264839
|
+
return {
|
|
264840
|
+
details,
|
|
264841
|
+
hasError: details.length === 0,
|
|
264842
|
+
hasRedirection: typeof parsedUnknown.hasRedirection === "boolean" ? parsedUnknown.hasRedirection : void 0,
|
|
264843
|
+
hasCommandSubstitution: typeof parsedUnknown.hasCommandSubstitution === "boolean" ? parsedUnknown.hasCommandSubstitution : false
|
|
264844
|
+
};
|
|
264845
|
+
}
|
|
264846
|
+
var globalInFlightPowerShellParses = /* @__PURE__ */ new Map();
|
|
264847
|
+
function parsePowerShellCommandDetails(command, executable, cache2) {
|
|
264759
264848
|
const trimmed = command.trim();
|
|
264760
264849
|
if (!trimmed) {
|
|
264761
264850
|
return {
|
|
@@ -264763,6 +264852,10 @@ function parsePowerShellCommandDetails(command, executable) {
|
|
|
264763
264852
|
hasError: true
|
|
264764
264853
|
};
|
|
264765
264854
|
}
|
|
264855
|
+
const activeCache = cache2 ?? getActiveCommandParseCache();
|
|
264856
|
+
if (activeCache?.hasCompleted(executable, command)) {
|
|
264857
|
+
return activeCache.getCompleted(executable, command) ?? null;
|
|
264858
|
+
}
|
|
264766
264859
|
try {
|
|
264767
264860
|
const result = spawnSync(
|
|
264768
264861
|
executable,
|
|
@@ -264782,51 +264875,136 @@ function parsePowerShellCommandDetails(command, executable) {
|
|
|
264782
264875
|
}
|
|
264783
264876
|
);
|
|
264784
264877
|
if (result.error || result.status !== 0) {
|
|
264878
|
+
activeCache?.setCompleted(executable, command, null);
|
|
264785
264879
|
return null;
|
|
264786
264880
|
}
|
|
264787
|
-
const
|
|
264788
|
-
|
|
264789
|
-
|
|
264881
|
+
const parsed = parsePowerShellParserOutput(
|
|
264882
|
+
(result.stdout ?? "").toString(),
|
|
264883
|
+
command
|
|
264884
|
+
);
|
|
264885
|
+
activeCache?.setCompleted(executable, command, parsed);
|
|
264886
|
+
return parsed;
|
|
264887
|
+
} catch {
|
|
264888
|
+
activeCache?.setCompleted(executable, command, null);
|
|
264889
|
+
return null;
|
|
264890
|
+
}
|
|
264891
|
+
}
|
|
264892
|
+
async function parsePowerShellCommandDetailsAsync(command, executable, cache2, signal) {
|
|
264893
|
+
const trimmed = command.trim();
|
|
264894
|
+
if (!trimmed) {
|
|
264895
|
+
return {
|
|
264896
|
+
details: [],
|
|
264897
|
+
hasError: true
|
|
264898
|
+
};
|
|
264899
|
+
}
|
|
264900
|
+
if (signal?.aborted) {
|
|
264901
|
+
return null;
|
|
264902
|
+
}
|
|
264903
|
+
const activeCache = cache2 ?? getActiveCommandParseCache();
|
|
264904
|
+
if (activeCache?.hasCompleted(executable, command)) {
|
|
264905
|
+
return activeCache.getCompleted(executable, command) ?? null;
|
|
264906
|
+
}
|
|
264907
|
+
const existingInFlight = activeCache?.getInFlight(executable, command);
|
|
264908
|
+
if (existingInFlight) {
|
|
264909
|
+
return existingInFlight;
|
|
264910
|
+
}
|
|
264911
|
+
const globalKey = `${executable}\0${command}`;
|
|
264912
|
+
if (!signal) {
|
|
264913
|
+
const existingGlobalInFlight = globalInFlightPowerShellParses.get(globalKey);
|
|
264914
|
+
if (existingGlobalInFlight) {
|
|
264915
|
+
const joinedPromise = existingGlobalInFlight.then((result) => {
|
|
264916
|
+
activeCache?.setCompleted(executable, command, result);
|
|
264917
|
+
return result;
|
|
264918
|
+
});
|
|
264919
|
+
if (activeCache) {
|
|
264920
|
+
return activeCache.trackInFlight(executable, command, joinedPromise);
|
|
264921
|
+
}
|
|
264922
|
+
return joinedPromise;
|
|
264790
264923
|
}
|
|
264791
|
-
|
|
264924
|
+
}
|
|
264925
|
+
const parsePromise = new Promise((resolve30) => {
|
|
264926
|
+
let settled = false;
|
|
264927
|
+
const finish = (value, cacheResult = true) => {
|
|
264928
|
+
if (!settled) {
|
|
264929
|
+
settled = true;
|
|
264930
|
+
if (cacheResult && !signal?.aborted) {
|
|
264931
|
+
activeCache?.setCompleted(executable, command, value);
|
|
264932
|
+
}
|
|
264933
|
+
resolve30(value);
|
|
264934
|
+
}
|
|
264935
|
+
};
|
|
264936
|
+
let child;
|
|
264792
264937
|
try {
|
|
264793
|
-
|
|
264938
|
+
child = spawn(
|
|
264939
|
+
executable,
|
|
264940
|
+
[
|
|
264941
|
+
"-NoLogo",
|
|
264942
|
+
"-NoProfile",
|
|
264943
|
+
"-NonInteractive",
|
|
264944
|
+
"-EncodedCommand",
|
|
264945
|
+
POWERSHELL_PARSER_SCRIPT
|
|
264946
|
+
],
|
|
264947
|
+
{
|
|
264948
|
+
env: {
|
|
264949
|
+
...process.env,
|
|
264950
|
+
[POWERSHELL_COMMAND_ENV]: command
|
|
264951
|
+
},
|
|
264952
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
264953
|
+
windowsHide: true,
|
|
264954
|
+
...signal ? { signal } : {}
|
|
264955
|
+
}
|
|
264956
|
+
);
|
|
264794
264957
|
} catch {
|
|
264795
|
-
|
|
264796
|
-
|
|
264797
|
-
if (!parsed?.success) {
|
|
264798
|
-
return { details: [], hasError: true };
|
|
264958
|
+
finish(null, !signal?.aborted);
|
|
264959
|
+
return;
|
|
264799
264960
|
}
|
|
264800
|
-
|
|
264801
|
-
|
|
264802
|
-
|
|
264803
|
-
|
|
264961
|
+
let stdout = "";
|
|
264962
|
+
child.stdout?.setEncoding("utf-8");
|
|
264963
|
+
child.stdout?.on("data", (chunk) => {
|
|
264964
|
+
stdout += chunk.toString();
|
|
264965
|
+
});
|
|
264966
|
+
child.stderr?.on("data", () => {
|
|
264967
|
+
});
|
|
264968
|
+
child.on("error", (err2) => {
|
|
264969
|
+
if (err2.name === "AbortError" || signal?.aborted) {
|
|
264970
|
+
finish(null, false);
|
|
264971
|
+
return;
|
|
264804
264972
|
}
|
|
264805
|
-
|
|
264806
|
-
|
|
264807
|
-
|
|
264808
|
-
|
|
264809
|
-
|
|
264810
|
-
|
|
264811
|
-
|
|
264812
|
-
|
|
264813
|
-
|
|
264814
|
-
|
|
264815
|
-
|
|
264816
|
-
|
|
264817
|
-
|
|
264818
|
-
|
|
264819
|
-
|
|
264820
|
-
|
|
264821
|
-
|
|
264973
|
+
finish(null);
|
|
264974
|
+
});
|
|
264975
|
+
child.on("close", (code) => {
|
|
264976
|
+
if (signal?.aborted) {
|
|
264977
|
+
finish(null, false);
|
|
264978
|
+
return;
|
|
264979
|
+
}
|
|
264980
|
+
if (code !== 0) {
|
|
264981
|
+
finish(null);
|
|
264982
|
+
return;
|
|
264983
|
+
}
|
|
264984
|
+
const parsed = parsePowerShellParserOutput(stdout, command);
|
|
264985
|
+
finish(parsed);
|
|
264986
|
+
});
|
|
264987
|
+
});
|
|
264988
|
+
if (!signal) {
|
|
264989
|
+
globalInFlightPowerShellParses.set(globalKey, parsePromise);
|
|
264990
|
+
void parsePromise.finally(() => {
|
|
264991
|
+
if (globalInFlightPowerShellParses.get(globalKey) === parsePromise) {
|
|
264992
|
+
globalInFlightPowerShellParses.delete(globalKey);
|
|
264993
|
+
}
|
|
264994
|
+
});
|
|
264995
|
+
}
|
|
264996
|
+
if (activeCache) {
|
|
264997
|
+
return activeCache.trackInFlight(executable, command, parsePromise);
|
|
264822
264998
|
}
|
|
264999
|
+
return parsePromise;
|
|
264823
265000
|
}
|
|
264824
|
-
function parseCommandDetails(command) {
|
|
265001
|
+
function parseCommandDetails(command, cache2) {
|
|
264825
265002
|
const configuration = getShellConfiguration();
|
|
264826
265003
|
if (configuration.shell === "powershell") {
|
|
264827
265004
|
const result = parsePowerShellCommandDetails(
|
|
264828
265005
|
command,
|
|
264829
|
-
configuration.executable
|
|
265006
|
+
configuration.executable,
|
|
265007
|
+
cache2
|
|
264830
265008
|
);
|
|
264831
265009
|
if (!result || result.hasError) {
|
|
264832
265010
|
if (detectPowerShellSubstitution(command)) {
|
|
@@ -264844,6 +265022,43 @@ function parseCommandDetails(command) {
|
|
|
264844
265022
|
}
|
|
264845
265023
|
return null;
|
|
264846
265024
|
}
|
|
265025
|
+
async function parseCommandDetailsAsync(command, cache2, signal) {
|
|
265026
|
+
if (signal?.aborted) {
|
|
265027
|
+
return null;
|
|
265028
|
+
}
|
|
265029
|
+
const configuration = getShellConfiguration();
|
|
265030
|
+
if (configuration.shell === "powershell") {
|
|
265031
|
+
const result = await parsePowerShellCommandDetailsAsync(
|
|
265032
|
+
command,
|
|
265033
|
+
configuration.executable,
|
|
265034
|
+
cache2,
|
|
265035
|
+
signal
|
|
265036
|
+
);
|
|
265037
|
+
if (signal?.aborted) {
|
|
265038
|
+
return null;
|
|
265039
|
+
}
|
|
265040
|
+
if (!result || result.hasError) {
|
|
265041
|
+
if (detectPowerShellSubstitution(command)) {
|
|
265042
|
+
return result ?? { details: [], hasError: true };
|
|
265043
|
+
}
|
|
265044
|
+
await initializeShellParsers();
|
|
265045
|
+
const bashResult = parseBashCommandDetails(command);
|
|
265046
|
+
if (bashResult && !bashResult.hasError) {
|
|
265047
|
+
return bashResult;
|
|
265048
|
+
}
|
|
265049
|
+
}
|
|
265050
|
+
return result;
|
|
265051
|
+
}
|
|
265052
|
+
if (configuration.shell === "bash") {
|
|
265053
|
+
await initializeShellParsers();
|
|
265054
|
+
return parseBashCommandDetails(command);
|
|
265055
|
+
}
|
|
265056
|
+
return null;
|
|
265057
|
+
}
|
|
265058
|
+
var defaultParseCommandDetailsRef = parseCommandDetails;
|
|
265059
|
+
function isDefaultParseCommandDetails(fn3) {
|
|
265060
|
+
return fn3 === defaultParseCommandDetailsRef;
|
|
265061
|
+
}
|
|
264847
265062
|
function getShellConfiguration() {
|
|
264848
265063
|
if (isWindows()) {
|
|
264849
265064
|
const powershellArgsPrefix = ["-NoProfile", "-NonInteractive", "-Command"];
|
|
@@ -264895,7 +265110,23 @@ function escapeShellArg(arg, shell) {
|
|
|
264895
265110
|
return (0, import_shell_quote.quote)([arg]);
|
|
264896
265111
|
}
|
|
264897
265112
|
}
|
|
264898
|
-
function
|
|
265113
|
+
function hasBashTreeRedirection(command, fallbackCheck) {
|
|
265114
|
+
const tree = parseCommandTree(command);
|
|
265115
|
+
if (!tree) return fallbackCheck();
|
|
265116
|
+
const stack = [tree.rootNode];
|
|
265117
|
+
while (stack.length > 0) {
|
|
265118
|
+
const current = stack.pop();
|
|
265119
|
+
if (current.type === "redirected_statement" || current.type === "file_redirect" || current.type === "heredoc_redirect" || current.type === "herestring_redirect") {
|
|
265120
|
+
return true;
|
|
265121
|
+
}
|
|
265122
|
+
for (let i3 = current.childCount - 1; i3 >= 0; i3 -= 1) {
|
|
265123
|
+
const child = current.child(i3);
|
|
265124
|
+
if (child) stack.push(child);
|
|
265125
|
+
}
|
|
265126
|
+
}
|
|
265127
|
+
return false;
|
|
265128
|
+
}
|
|
265129
|
+
function hasRedirection(command, cache2) {
|
|
264899
265130
|
const fallbackCheck = () => /[><]/.test(command);
|
|
264900
265131
|
if (!fallbackCheck()) {
|
|
264901
265132
|
return false;
|
|
@@ -264904,26 +265135,43 @@ function hasRedirection(command) {
|
|
|
264904
265135
|
if (configuration.shell === "powershell") {
|
|
264905
265136
|
const parsed = parsePowerShellCommandDetails(
|
|
264906
265137
|
command,
|
|
264907
|
-
configuration.executable
|
|
265138
|
+
configuration.executable,
|
|
265139
|
+
cache2
|
|
264908
265140
|
);
|
|
264909
265141
|
return parsed && !parsed.hasError ? !!parsed.hasRedirection : fallbackCheck();
|
|
264910
265142
|
}
|
|
264911
265143
|
if (configuration.shell === "bash" && bashLanguage) {
|
|
264912
|
-
|
|
264913
|
-
|
|
264914
|
-
|
|
264915
|
-
|
|
264916
|
-
|
|
264917
|
-
|
|
264918
|
-
|
|
264919
|
-
|
|
264920
|
-
|
|
264921
|
-
|
|
264922
|
-
if (child) stack.push(child);
|
|
264923
|
-
}
|
|
264924
|
-
}
|
|
265144
|
+
return hasBashTreeRedirection(command, fallbackCheck);
|
|
265145
|
+
}
|
|
265146
|
+
return fallbackCheck();
|
|
265147
|
+
}
|
|
265148
|
+
async function hasRedirectionAsync(command, cache2, signal) {
|
|
265149
|
+
if (signal?.aborted) {
|
|
265150
|
+
return false;
|
|
265151
|
+
}
|
|
265152
|
+
const fallbackCheck = () => /[><]/.test(command);
|
|
265153
|
+
if (!fallbackCheck()) {
|
|
264925
265154
|
return false;
|
|
264926
265155
|
}
|
|
265156
|
+
const configuration = getShellConfiguration();
|
|
265157
|
+
if (configuration.shell === "powershell") {
|
|
265158
|
+
const parsed = await parsePowerShellCommandDetailsAsync(
|
|
265159
|
+
command,
|
|
265160
|
+
configuration.executable,
|
|
265161
|
+
cache2,
|
|
265162
|
+
signal
|
|
265163
|
+
);
|
|
265164
|
+
if (signal?.aborted) {
|
|
265165
|
+
return false;
|
|
265166
|
+
}
|
|
265167
|
+
return parsed && !parsed.hasError ? !!parsed.hasRedirection : fallbackCheck();
|
|
265168
|
+
}
|
|
265169
|
+
if (configuration.shell === "bash") {
|
|
265170
|
+
await initializeShellParsers();
|
|
265171
|
+
if (bashLanguage) {
|
|
265172
|
+
return hasBashTreeRedirection(command, fallbackCheck);
|
|
265173
|
+
}
|
|
265174
|
+
}
|
|
264927
265175
|
return fallbackCheck();
|
|
264928
265176
|
}
|
|
264929
265177
|
var SHELL_EXPANSION_NODE_TYPES = /* @__PURE__ */ new Set([
|
|
@@ -265060,30 +265308,66 @@ function hasUnresolvedShellExpansion(command) {
|
|
|
265060
265308
|
tree.delete();
|
|
265061
265309
|
}
|
|
265062
265310
|
}
|
|
265063
|
-
function splitCommands(command) {
|
|
265064
|
-
const parsed = parseCommandDetails(command);
|
|
265311
|
+
function splitCommands(command, cache2) {
|
|
265312
|
+
const parsed = parseCommandDetails(command, cache2);
|
|
265065
265313
|
if (!parsed || parsed.hasError) {
|
|
265066
265314
|
return [];
|
|
265067
265315
|
}
|
|
265068
265316
|
return parsed.details.filter((detail) => !REDIRECTION_NAMES.has(detail.name)).map((detail) => detail.text).filter(Boolean);
|
|
265069
265317
|
}
|
|
265070
|
-
function
|
|
265071
|
-
const parsed =
|
|
265318
|
+
async function splitCommandsAsync(command, cache2, signal) {
|
|
265319
|
+
const parsed = await parseCommandDetailsAsync(command, cache2, signal);
|
|
265320
|
+
if (!parsed || parsed.hasError) {
|
|
265321
|
+
return [];
|
|
265322
|
+
}
|
|
265323
|
+
return parsed.details.filter((detail) => !REDIRECTION_NAMES.has(detail.name)).map((detail) => detail.text).filter(Boolean);
|
|
265324
|
+
}
|
|
265325
|
+
function getCommandRoot(command, cache2) {
|
|
265326
|
+
const parsed = parseCommandDetails(command, cache2);
|
|
265072
265327
|
if (!parsed || parsed.hasError || parsed.details.length === 0) {
|
|
265073
265328
|
return void 0;
|
|
265074
265329
|
}
|
|
265075
265330
|
return parsed.details[0]?.name;
|
|
265076
265331
|
}
|
|
265077
|
-
function
|
|
265332
|
+
async function getCommandRootAsync(command, cache2, signal) {
|
|
265333
|
+
const parsed = await parseCommandDetailsAsync(command, cache2, signal);
|
|
265334
|
+
if (!parsed || parsed.hasError || parsed.details.length === 0) {
|
|
265335
|
+
return void 0;
|
|
265336
|
+
}
|
|
265337
|
+
return parsed.details[0]?.name;
|
|
265338
|
+
}
|
|
265339
|
+
function getCommandRoots(command, cache2) {
|
|
265078
265340
|
if (!command) {
|
|
265079
265341
|
return [];
|
|
265080
265342
|
}
|
|
265081
|
-
const parsed = parseCommandDetails(command);
|
|
265343
|
+
const parsed = parseCommandDetails(command, cache2);
|
|
265082
265344
|
if (!parsed || parsed.hasError) {
|
|
265083
265345
|
return [];
|
|
265084
265346
|
}
|
|
265085
265347
|
return parsed.details.map((detail) => detail.name).filter((name3) => !REDIRECTION_NAMES.has(name3)).filter(Boolean);
|
|
265086
265348
|
}
|
|
265349
|
+
async function getCommandRootsAsync(command, cache2, signal) {
|
|
265350
|
+
if (!command) {
|
|
265351
|
+
return [];
|
|
265352
|
+
}
|
|
265353
|
+
const parsed = await parseCommandDetailsAsync(command, cache2, signal);
|
|
265354
|
+
if (!parsed || parsed.hasError) {
|
|
265355
|
+
return [];
|
|
265356
|
+
}
|
|
265357
|
+
return parsed.details.map((detail) => detail.name).filter((name3) => !REDIRECTION_NAMES.has(name3)).filter(Boolean);
|
|
265358
|
+
}
|
|
265359
|
+
var defaultHasRedirectionRef = hasRedirection;
|
|
265360
|
+
var defaultSplitCommandsRef = splitCommands;
|
|
265361
|
+
var defaultGetCommandRootsRef = getCommandRoots;
|
|
265362
|
+
function isDefaultHasRedirection(fn3) {
|
|
265363
|
+
return fn3 === defaultHasRedirectionRef;
|
|
265364
|
+
}
|
|
265365
|
+
function isDefaultSplitCommands(fn3) {
|
|
265366
|
+
return fn3 === defaultSplitCommandsRef;
|
|
265367
|
+
}
|
|
265368
|
+
function isDefaultGetCommandRoots(fn3) {
|
|
265369
|
+
return fn3 === defaultGetCommandRootsRef;
|
|
265370
|
+
}
|
|
265087
265371
|
var PS_WRAPPER_FLAGS = /* @__PURE__ */ new Set([
|
|
265088
265372
|
"-nologo",
|
|
265089
265373
|
"-noprofile",
|
|
@@ -266342,10 +266626,7 @@ function isInteractiveGeminiSegment(segment) {
|
|
|
266342
266626
|
}
|
|
266343
266627
|
return true;
|
|
266344
266628
|
}
|
|
266345
|
-
function
|
|
266346
|
-
if (!command || !command.trim()) {
|
|
266347
|
-
return false;
|
|
266348
|
-
}
|
|
266629
|
+
function unwrapCommandForGeminiCheck(command) {
|
|
266349
266630
|
let unwrapped = command.trim();
|
|
266350
266631
|
for (let depth = 0; depth < 3; depth++) {
|
|
266351
266632
|
const next = stripShellWrapper(unwrapped);
|
|
@@ -266354,10 +266635,59 @@ function isInteractiveGeminiCommand(command) {
|
|
|
266354
266635
|
}
|
|
266355
266636
|
unwrapped = next;
|
|
266356
266637
|
}
|
|
266357
|
-
|
|
266638
|
+
return unwrapped;
|
|
266639
|
+
}
|
|
266640
|
+
var GEMINI_SUBSEQUENCE = "gemini";
|
|
266641
|
+
function containsGeminiSubsequence(input) {
|
|
266642
|
+
const lower = input.toLowerCase();
|
|
266643
|
+
let pos = 0;
|
|
266644
|
+
for (const ch of GEMINI_SUBSEQUENCE) {
|
|
266645
|
+
const found = lower.indexOf(ch, pos);
|
|
266646
|
+
if (found === -1) {
|
|
266647
|
+
return false;
|
|
266648
|
+
}
|
|
266649
|
+
pos = found + 1;
|
|
266650
|
+
}
|
|
266651
|
+
return true;
|
|
266652
|
+
}
|
|
266653
|
+
function isKnownInteractiveGeminiCommandSync(command) {
|
|
266654
|
+
if (!command || !command.trim()) {
|
|
266655
|
+
return false;
|
|
266656
|
+
}
|
|
266657
|
+
const unwrapped = unwrapCommandForGeminiCheck(command);
|
|
266658
|
+
if (!containsGeminiSubsequence(unwrapped)) {
|
|
266659
|
+
return false;
|
|
266660
|
+
}
|
|
266358
266661
|
const fallbackSegments = splitShellCommandSegments(unwrapped);
|
|
266359
|
-
|
|
266360
|
-
|
|
266662
|
+
if (fallbackSegments.some((segment) => isInteractiveGeminiSegment(segment))) {
|
|
266663
|
+
return true;
|
|
266664
|
+
}
|
|
266665
|
+
return void 0;
|
|
266666
|
+
}
|
|
266667
|
+
function isInteractiveGeminiCommand(command, cache2) {
|
|
266668
|
+
const fastResult = isKnownInteractiveGeminiCommandSync(command);
|
|
266669
|
+
if (fastResult !== void 0) {
|
|
266670
|
+
return fastResult;
|
|
266671
|
+
}
|
|
266672
|
+
const unwrapped = unwrapCommandForGeminiCheck(command);
|
|
266673
|
+
const parsedSegments = splitCommands(unwrapped, cache2);
|
|
266674
|
+
return parsedSegments.some((segment) => isInteractiveGeminiSegment(segment));
|
|
266675
|
+
}
|
|
266676
|
+
async function isInteractiveGeminiCommandAsync(command, cache2, signal) {
|
|
266677
|
+
if (signal?.aborted) {
|
|
266678
|
+
return false;
|
|
266679
|
+
}
|
|
266680
|
+
const fastResult = isKnownInteractiveGeminiCommandSync(command);
|
|
266681
|
+
if (fastResult !== void 0) {
|
|
266682
|
+
return fastResult;
|
|
266683
|
+
}
|
|
266684
|
+
const unwrapped = unwrapCommandForGeminiCheck(command);
|
|
266685
|
+
const parsedSegments = await splitCommandsAsync(unwrapped, cache2, signal);
|
|
266686
|
+
return parsedSegments.some((segment) => isInteractiveGeminiSegment(segment));
|
|
266687
|
+
}
|
|
266688
|
+
var defaultIsInteractiveGeminiCommandRef = isInteractiveGeminiCommand;
|
|
266689
|
+
function isDefaultIsInteractiveGeminiCommand(fn3) {
|
|
266690
|
+
return fn3 === defaultIsInteractiveGeminiCommandRef;
|
|
266361
266691
|
}
|
|
266362
266692
|
|
|
266363
266693
|
// packages/core/src/sandbox/utils/commandSafety.ts
|
|
@@ -266926,7 +267256,7 @@ async function isStrictlyApproved(command, args2, approvedTools, cwd, workspaceR
|
|
|
266926
267256
|
await initializeShellParsers();
|
|
266927
267257
|
const fullCmd = [command, ...args2].join(" ");
|
|
266928
267258
|
const stripped = stripShellWrapper(fullCmd);
|
|
266929
|
-
const pipelineCommands = splitCommands(stripped);
|
|
267259
|
+
const pipelineCommands = isDefaultSplitCommands(splitCommands) ? await splitCommandsAsync(stripped) : splitCommands(stripped);
|
|
266930
267260
|
if (pipelineCommands.length === 0) {
|
|
266931
267261
|
return tools.includes(command) || isKnownSafeCommand2([command, ...args2], cwd, workspaceRoot);
|
|
266932
267262
|
}
|
|
@@ -267435,35 +267765,38 @@ async function isStrictlyApproved2(req, approvedTools) {
|
|
|
267435
267765
|
if (!approvedTools || approvedTools.length === 0) {
|
|
267436
267766
|
return false;
|
|
267437
267767
|
}
|
|
267438
|
-
|
|
267439
|
-
|
|
267440
|
-
|
|
267441
|
-
|
|
267442
|
-
|
|
267443
|
-
|
|
267444
|
-
|
|
267445
|
-
|
|
267446
|
-
|
|
267447
|
-
|
|
267448
|
-
|
|
267449
|
-
|
|
267450
|
-
|
|
267451
|
-
if (pipelineCommands.length === 0) return false;
|
|
267452
|
-
for (const cmdString of pipelineCommands) {
|
|
267453
|
-
const parsedArgs = (0, import_shell_quote4.parse)(cmdString).map(String);
|
|
267454
|
-
if (!isKnownSafeCommand(parsedArgs)) {
|
|
267768
|
+
return runWithCommandParseCache(async () => {
|
|
267769
|
+
await initializeShellParsers();
|
|
267770
|
+
const fullCmd = [req.command, ...req.args].join(" ");
|
|
267771
|
+
const stripped = stripShellWrapper(fullCmd);
|
|
267772
|
+
const roots = isDefaultGetCommandRoots(getCommandRoots) ? await getCommandRootsAsync(stripped) : getCommandRoots(stripped);
|
|
267773
|
+
if (roots.length === 0) return false;
|
|
267774
|
+
const allRootsApproved = roots.every(
|
|
267775
|
+
(root) => approvedTools.includes(root)
|
|
267776
|
+
);
|
|
267777
|
+
if (allRootsApproved) {
|
|
267778
|
+
return true;
|
|
267779
|
+
}
|
|
267780
|
+
if (hasUnresolvedShellExpansion(stripped)) {
|
|
267455
267781
|
return false;
|
|
267456
267782
|
}
|
|
267457
|
-
|
|
267458
|
-
|
|
267783
|
+
const pipelineCommands = isDefaultSplitCommands(splitCommands) ? await splitCommandsAsync(stripped) : splitCommands(stripped);
|
|
267784
|
+
if (pipelineCommands.length === 0) return false;
|
|
267785
|
+
for (const cmdString of pipelineCommands) {
|
|
267786
|
+
const parsedArgs = (0, import_shell_quote4.parse)(cmdString).map(String);
|
|
267787
|
+
if (!isKnownSafeCommand(parsedArgs)) {
|
|
267788
|
+
return false;
|
|
267789
|
+
}
|
|
267790
|
+
}
|
|
267791
|
+
return true;
|
|
267792
|
+
});
|
|
267459
267793
|
}
|
|
267460
267794
|
async function getCommandName2(req) {
|
|
267461
267795
|
await initializeShellParsers();
|
|
267462
267796
|
const fullCmd = [req.command, ...req.args].join(" ");
|
|
267463
267797
|
const stripped = stripShellWrapper(fullCmd);
|
|
267464
|
-
const
|
|
267465
|
-
|
|
267466
|
-
);
|
|
267798
|
+
const computedRoots = isDefaultGetCommandRoots(getCommandRoots) ? await getCommandRootsAsync(stripped) : getCommandRoots(stripped);
|
|
267799
|
+
const roots = computedRoots.filter((r9) => r9 !== "shopt" && r9 !== "set");
|
|
267467
267800
|
if (roots.length > 0) {
|
|
267468
267801
|
return roots[0];
|
|
267469
267802
|
}
|
|
@@ -268839,6 +269172,9 @@ var WindowsSandboxManager = class _WindowsSandboxManager {
|
|
|
268839
269172
|
* Prepares a command for sandboxed execution on Windows.
|
|
268840
269173
|
*/
|
|
268841
269174
|
async prepareCommand(req) {
|
|
269175
|
+
return runWithCommandParseCache(() => this.prepareCommandInternal(req));
|
|
269176
|
+
}
|
|
269177
|
+
async prepareCommandInternal(req) {
|
|
268842
269178
|
await this.ensureHelperCompiled();
|
|
268843
269179
|
const sanitizationConfig = getSecureSanitizationConfig(
|
|
268844
269180
|
req.policy?.sanitizationConfig
|
|
@@ -268875,9 +269211,8 @@ var WindowsSandboxManager = class _WindowsSandboxManager {
|
|
|
268875
269211
|
await initializeShellParsers();
|
|
268876
269212
|
const fullCmd = [command, ...args2].join(" ");
|
|
268877
269213
|
const stripped = stripShellWrapper(fullCmd);
|
|
268878
|
-
const
|
|
268879
|
-
|
|
268880
|
-
);
|
|
269214
|
+
const computedRoots = isDefaultGetCommandRoots(getCommandRoots) ? await getCommandRootsAsync(stripped) : getCommandRoots(stripped);
|
|
269215
|
+
const roots = computedRoots.filter((r9) => r9 !== "shopt" && r9 !== "set");
|
|
268881
269216
|
const isGitCommand = roots.includes("git");
|
|
268882
269217
|
const resolvedPaths = await resolveSandboxPaths(
|
|
268883
269218
|
this.options,
|
|
@@ -295413,8 +295748,8 @@ function isValidToolName(name3, options = {}) {
|
|
|
295413
295748
|
}
|
|
295414
295749
|
|
|
295415
295750
|
// packages/core/src/generated/git-commit.ts
|
|
295416
|
-
var GIT_COMMIT_INFO = "
|
|
295417
|
-
var CLI_VERSION = "0.
|
|
295751
|
+
var GIT_COMMIT_INFO = "d4cb1713f";
|
|
295752
|
+
var CLI_VERSION = "0.71.0-nightly.20261118.g615d6bc8c";
|
|
295418
295753
|
|
|
295419
295754
|
// packages/core/src/ide/detect-ide.ts
|
|
295420
295755
|
var IDE_DEFINITIONS = {
|
|
@@ -328408,7 +328743,7 @@ function getVersion() {
|
|
|
328408
328743
|
}
|
|
328409
328744
|
versionPromise = (async () => {
|
|
328410
328745
|
const pkgJson = await getPackageJson(__dirname4);
|
|
328411
|
-
return "0.
|
|
328746
|
+
return "0.71.0-nightly.20261118.g615d6bc8c";
|
|
328412
328747
|
})();
|
|
328413
328748
|
return versionPromise;
|
|
328414
328749
|
}
|
|
@@ -330601,8 +330936,8 @@ var BaseLlmClient = class {
|
|
|
330601
330936
|
};
|
|
330602
330937
|
|
|
330603
330938
|
// packages/core/src/utils/promptIdContext.ts
|
|
330604
|
-
import { AsyncLocalStorage } from "node:async_hooks";
|
|
330605
|
-
var promptIdContext = new
|
|
330939
|
+
import { AsyncLocalStorage as AsyncLocalStorage2 } from "node:async_hooks";
|
|
330940
|
+
var promptIdContext = new AsyncLocalStorage2();
|
|
330606
330941
|
function getPromptIdWithFallback(componentName) {
|
|
330607
330942
|
const promptId = promptIdContext.getStore();
|
|
330608
330943
|
if (promptId) {
|
|
@@ -331314,24 +331649,17 @@ function findUntrustedFlags(command, untrustedContext, options) {
|
|
|
331314
331649
|
}
|
|
331315
331650
|
return Array.from(detected);
|
|
331316
331651
|
}
|
|
331317
|
-
function
|
|
331318
|
-
if (!command) {
|
|
331319
|
-
return false;
|
|
331320
|
-
}
|
|
331652
|
+
function evaluateBuildOrTestCommandFromRoots(command, roots) {
|
|
331321
331653
|
const getBaseName = (cmd) => {
|
|
331322
331654
|
const base2 = cmd.replace(/\\/g, "/").split("/").pop();
|
|
331323
331655
|
if (!base2) return cmd.toLowerCase();
|
|
331324
331656
|
return base2.toLowerCase().replace(/\.(exe|cmd|bat)$/, "");
|
|
331325
331657
|
};
|
|
331326
|
-
|
|
331327
|
-
|
|
331328
|
-
|
|
331329
|
-
return
|
|
331330
|
-
|
|
331331
|
-
return BUILD_TEST_COMMAND_ROOTS.has(base2) || BUILD_TEST_COMMAND_ROOTS.has(root2.toLowerCase());
|
|
331332
|
-
});
|
|
331333
|
-
}
|
|
331334
|
-
} catch {
|
|
331658
|
+
if (roots.length > 0) {
|
|
331659
|
+
return roots.some((root2) => {
|
|
331660
|
+
const base2 = getBaseName(root2);
|
|
331661
|
+
return BUILD_TEST_COMMAND_ROOTS.has(base2) || BUILD_TEST_COMMAND_ROOTS.has(root2.toLowerCase());
|
|
331662
|
+
});
|
|
331335
331663
|
}
|
|
331336
331664
|
const parts2 = command.trim().split(/\s+/);
|
|
331337
331665
|
let rootIndex = 0;
|
|
@@ -331343,18 +331671,33 @@ function isBuildOrTestCommand(command) {
|
|
|
331343
331671
|
const base = getBaseName(root);
|
|
331344
331672
|
return BUILD_TEST_COMMAND_ROOTS.has(base) || BUILD_TEST_COMMAND_ROOTS.has(root.toLowerCase());
|
|
331345
331673
|
}
|
|
331346
|
-
function
|
|
331674
|
+
function isBuildOrTestCommand(command) {
|
|
331347
331675
|
if (!command) {
|
|
331348
331676
|
return false;
|
|
331349
331677
|
}
|
|
331350
331678
|
let roots = [];
|
|
331351
331679
|
try {
|
|
331352
|
-
roots = getCommandRoots(command)
|
|
331680
|
+
roots = getCommandRoots(command);
|
|
331353
331681
|
} catch {
|
|
331354
331682
|
}
|
|
331683
|
+
return evaluateBuildOrTestCommandFromRoots(command, roots);
|
|
331684
|
+
}
|
|
331685
|
+
function evaluateRemoteContentCommandFromRoots(command, rawRoots) {
|
|
331686
|
+
const roots = rawRoots.map((root) => normalizeCommand(root));
|
|
331355
331687
|
const candidates = roots.length === 0 || roots.some((root) => COMMAND_WRAPPER_ROOTS.has(root)) ? command.trim().split(/[\s;&|()]+/).map((word) => normalizeCommand(word)) : roots;
|
|
331356
331688
|
return candidates.some((name3) => REMOTE_CONTENT_COMMAND_ROOTS.has(name3));
|
|
331357
331689
|
}
|
|
331690
|
+
async function isRemoteContentCommandAsync(command) {
|
|
331691
|
+
if (!command) {
|
|
331692
|
+
return false;
|
|
331693
|
+
}
|
|
331694
|
+
let rawRoots = [];
|
|
331695
|
+
try {
|
|
331696
|
+
rawRoots = isDefaultGetCommandRoots(getCommandRoots) ? await getCommandRootsAsync(command) : getCommandRoots(command);
|
|
331697
|
+
} catch {
|
|
331698
|
+
}
|
|
331699
|
+
return evaluateRemoteContentCommandFromRoots(command, rawRoots);
|
|
331700
|
+
}
|
|
331358
331701
|
var MODIFIED_BUILD_FILES_SYMBOL = Symbol("sessionModifiedBuildFiles");
|
|
331359
331702
|
var ACKNOWLEDGED_UNTRUSTED_FLAGS_SYMBOL = Symbol(
|
|
331360
331703
|
"sessionAcknowledgedUntrustedFlags"
|
|
@@ -336279,7 +336622,7 @@ function canNegationMatchInsideDir(dir, negations) {
|
|
|
336279
336622
|
}
|
|
336280
336623
|
return false;
|
|
336281
336624
|
}
|
|
336282
|
-
function expandWildcardDirectoryPatterns(rawPatterns, extraRawPatterns) {
|
|
336625
|
+
function expandWildcardDirectoryPatterns(rawPatterns, extraRawPatterns, hasNestedNegation) {
|
|
336283
336626
|
const negations = /* @__PURE__ */ new Set();
|
|
336284
336627
|
const allPatternSources = extraRawPatterns ? [...rawPatterns, ...extraRawPatterns] : rawPatterns;
|
|
336285
336628
|
for (const p2 of allPatternSources) {
|
|
@@ -336305,7 +336648,7 @@ function expandWildcardDirectoryPatterns(rawPatterns, extraRawPatterns) {
|
|
|
336305
336648
|
if (withoutGlob === "" || withoutGlob.includes("*") || withoutGlob.includes("?") || withoutGlob.includes("[")) {
|
|
336306
336649
|
continue;
|
|
336307
336650
|
}
|
|
336308
|
-
if (!canNegationMatchInsideDir(withoutGlob, negations)) {
|
|
336651
|
+
if (!canNegationMatchInsideDir(withoutGlob, negations) && !hasNestedNegation?.(withoutGlob)) {
|
|
336309
336652
|
expanded.push(`/${withoutGlob}/`);
|
|
336310
336653
|
}
|
|
336311
336654
|
}
|
|
@@ -336354,9 +336697,42 @@ var GitIgnoreParser = class {
|
|
|
336354
336697
|
return this.processPatterns(rawPatterns, relativeBaseDir);
|
|
336355
336698
|
}
|
|
336356
336699
|
processPatterns(rawPatterns, relativeBaseDir) {
|
|
336700
|
+
const checkedDirs = /* @__PURE__ */ new Map();
|
|
336701
|
+
const hasNestedNegation = (dir) => {
|
|
336702
|
+
let result = checkedDirs.get(dir);
|
|
336703
|
+
if (result !== void 0) {
|
|
336704
|
+
return result;
|
|
336705
|
+
}
|
|
336706
|
+
const targetRelDir = relativeBaseDir && relativeBaseDir !== "." ? path49.posix.join(relativeBaseDir, dir) : dir;
|
|
336707
|
+
const gitignorePath = path49.resolve(
|
|
336708
|
+
this.projectRoot,
|
|
336709
|
+
targetRelDir,
|
|
336710
|
+
".gitignore"
|
|
336711
|
+
);
|
|
336712
|
+
if (!isWithinRoot(gitignorePath, this.projectRoot)) {
|
|
336713
|
+
checkedDirs.set(dir, false);
|
|
336714
|
+
return false;
|
|
336715
|
+
}
|
|
336716
|
+
try {
|
|
336717
|
+
const content = fs41.readFileSync(gitignorePath, "utf-8");
|
|
336718
|
+
result = false;
|
|
336719
|
+
for (const line of content.split(/\r\n|\n|\r/)) {
|
|
336720
|
+
const trimmed = line.trim();
|
|
336721
|
+
if (trimmed.startsWith("!") && trimmed.slice(1).trim() !== "") {
|
|
336722
|
+
result = true;
|
|
336723
|
+
break;
|
|
336724
|
+
}
|
|
336725
|
+
}
|
|
336726
|
+
} catch {
|
|
336727
|
+
result = false;
|
|
336728
|
+
}
|
|
336729
|
+
checkedDirs.set(dir, result);
|
|
336730
|
+
return result;
|
|
336731
|
+
};
|
|
336357
336732
|
const expandedPatterns = expandWildcardDirectoryPatterns(
|
|
336358
336733
|
rawPatterns,
|
|
336359
|
-
this.extraPatterns
|
|
336734
|
+
this.extraPatterns,
|
|
336735
|
+
hasNestedNegation
|
|
336360
336736
|
);
|
|
336361
336737
|
return expandedPatterns.map((p2) => p2.trimStart()).filter((p2) => p2 !== "" && !p2.startsWith("#")).map((p2) => {
|
|
336362
336738
|
const isNegative = p2.startsWith("!");
|
|
@@ -345179,8 +345555,8 @@ ${truncated}`;
|
|
|
345179
345555
|
};
|
|
345180
345556
|
|
|
345181
345557
|
// packages/core/src/utils/toolCallContext.ts
|
|
345182
|
-
import { AsyncLocalStorage as
|
|
345183
|
-
var toolCallContext = new
|
|
345558
|
+
import { AsyncLocalStorage as AsyncLocalStorage3 } from "node:async_hooks";
|
|
345559
|
+
var toolCallContext = new AsyncLocalStorage3();
|
|
345184
345560
|
function runWithToolCallContext(context2, fn3) {
|
|
345185
345561
|
return toolCallContext.run(context2, fn3);
|
|
345186
345562
|
}
|
|
@@ -345346,6 +345722,47 @@ var ShellToolInvocation = class extends BaseToolInvocation {
|
|
|
345346
345722
|
}
|
|
345347
345723
|
proactivePermissionsConfirmed;
|
|
345348
345724
|
confirmedCommand;
|
|
345725
|
+
parseCache = new CommandParseCache();
|
|
345726
|
+
runInCommandParseCache(fn3) {
|
|
345727
|
+
return runWithCommandParseCache(fn3, this.parseCache);
|
|
345728
|
+
}
|
|
345729
|
+
async prepareCommandParseCache(signal) {
|
|
345730
|
+
if (signal?.aborted || typeof stripShellWrapper !== "function" || !isDefaultParseCommandDetails(parseCommandDetails)) {
|
|
345731
|
+
return;
|
|
345732
|
+
}
|
|
345733
|
+
const rawCommand = this.params.command;
|
|
345734
|
+
const stripped = stripShellWrapper(rawCommand);
|
|
345735
|
+
let unwrapped = stripped;
|
|
345736
|
+
for (let depth = 0; depth < 3; depth++) {
|
|
345737
|
+
const next = stripShellWrapper(unwrapped);
|
|
345738
|
+
if (next === unwrapped) {
|
|
345739
|
+
break;
|
|
345740
|
+
}
|
|
345741
|
+
unwrapped = next;
|
|
345742
|
+
}
|
|
345743
|
+
await parseCommandDetailsAsync(stripped, this.parseCache, signal);
|
|
345744
|
+
if (unwrapped !== stripped && !signal?.aborted) {
|
|
345745
|
+
await parseCommandDetailsAsync(unwrapped, this.parseCache, signal);
|
|
345746
|
+
}
|
|
345747
|
+
}
|
|
345748
|
+
hasCachedCommandParse(command) {
|
|
345749
|
+
if (typeof getShellConfiguration !== "function") {
|
|
345750
|
+
return false;
|
|
345751
|
+
}
|
|
345752
|
+
const configuration = getShellConfiguration();
|
|
345753
|
+
if (configuration.shell !== "powershell") {
|
|
345754
|
+
return true;
|
|
345755
|
+
}
|
|
345756
|
+
let unwrapped = command.trim();
|
|
345757
|
+
for (let depth = 0; depth < 3; depth++) {
|
|
345758
|
+
const next = stripShellWrapper(unwrapped);
|
|
345759
|
+
if (next === unwrapped) {
|
|
345760
|
+
break;
|
|
345761
|
+
}
|
|
345762
|
+
unwrapped = next;
|
|
345763
|
+
}
|
|
345764
|
+
return this.parseCache.hasCompleted(configuration.executable, command) && this.parseCache.hasCompleted(configuration.executable, unwrapped);
|
|
345765
|
+
}
|
|
345349
345766
|
/**
|
|
345350
345767
|
* Wraps a command in a subshell to capture background process IDs (PIDs)
|
|
345351
345768
|
* using an EXIT trap. Uses newlines to prevent breaking heredocs or trailing
|
|
@@ -345504,205 +345921,235 @@ exit $__code`;
|
|
|
345504
345921
|
return getUnacknowledgedUntrustedFlags(untrustedFlags, roots, config2);
|
|
345505
345922
|
}
|
|
345506
345923
|
hasTaintedOrBuildFileRisk() {
|
|
345507
|
-
|
|
345508
|
-
|
|
345509
|
-
|
|
345510
|
-
|
|
345511
|
-
|
|
345924
|
+
return this.runInCommandParseCache(() => {
|
|
345925
|
+
const command = stripShellWrapper(this.params.command);
|
|
345926
|
+
const untrustedFlags = this.getUntrustedFlags(command);
|
|
345927
|
+
const modifiedBuildFiles = getModifiedBuildFiles(this.context.config);
|
|
345928
|
+
const isBuildCmd = isBuildOrTestCommand(command);
|
|
345929
|
+
return untrustedFlags.length > 0 || isBuildCmd && modifiedBuildFiles.length > 0;
|
|
345930
|
+
});
|
|
345512
345931
|
}
|
|
345513
345932
|
getPolicyUpdateOptions(outcome) {
|
|
345514
|
-
|
|
345515
|
-
|
|
345516
|
-
|
|
345517
|
-
|
|
345518
|
-
|
|
345519
|
-
|
|
345520
|
-
|
|
345521
|
-
|
|
345522
|
-
|
|
345933
|
+
return this.runInCommandParseCache(() => {
|
|
345934
|
+
if (outcome === "proceed_always_and_save" /* ProceedAlwaysAndSave */ || outcome === "proceed_always" /* ProceedAlways */) {
|
|
345935
|
+
const command = stripShellWrapper(this.params.command);
|
|
345936
|
+
if (this.hasTaintedOrBuildFileRisk()) {
|
|
345937
|
+
return void 0;
|
|
345938
|
+
}
|
|
345939
|
+
const rootCommands = [...new Set(getCommandRoots(command))];
|
|
345940
|
+
const allowRedirection = hasRedirection(command) ? true : void 0;
|
|
345941
|
+
const allowCommandSubstitution = detectCommandSubstitution(command) ? true : void 0;
|
|
345942
|
+
if (rootCommands.length > 0) {
|
|
345943
|
+
return {
|
|
345944
|
+
commandPrefix: rootCommands,
|
|
345945
|
+
allowRedirection,
|
|
345946
|
+
...allowCommandSubstitution !== void 0 ? { allowCommandSubstitution } : {}
|
|
345947
|
+
};
|
|
345948
|
+
}
|
|
345523
345949
|
return {
|
|
345524
|
-
commandPrefix:
|
|
345950
|
+
commandPrefix: this.params.command,
|
|
345525
345951
|
allowRedirection,
|
|
345526
345952
|
...allowCommandSubstitution !== void 0 ? { allowCommandSubstitution } : {}
|
|
345527
345953
|
};
|
|
345528
345954
|
}
|
|
345529
|
-
return
|
|
345530
|
-
|
|
345531
|
-
allowRedirection,
|
|
345532
|
-
...allowCommandSubstitution !== void 0 ? { allowCommandSubstitution } : {}
|
|
345533
|
-
};
|
|
345534
|
-
}
|
|
345535
|
-
return void 0;
|
|
345955
|
+
return void 0;
|
|
345956
|
+
});
|
|
345536
345957
|
}
|
|
345537
345958
|
async shouldConfirmExecute(abortSignal, forcedDecision) {
|
|
345538
|
-
|
|
345539
|
-
|
|
345540
|
-
|
|
345541
|
-
|
|
345542
|
-
|
|
345543
|
-
|
|
345544
|
-
|
|
345545
|
-
|
|
345546
|
-
|
|
345547
|
-
|
|
345548
|
-
|
|
345549
|
-
|
|
345550
|
-
|
|
345551
|
-
|
|
345552
|
-
|
|
345553
|
-
|
|
345554
|
-
|
|
345555
|
-
|
|
345556
|
-
|
|
345557
|
-
|
|
345558
|
-
|
|
345559
|
-
|
|
345560
|
-
|
|
345561
|
-
|
|
345562
|
-
|
|
345563
|
-
|
|
345564
|
-
|
|
345565
|
-
|
|
345566
|
-
|
|
345567
|
-
|
|
345568
|
-
|
|
345569
|
-
|
|
345570
|
-
const
|
|
345571
|
-
|
|
345572
|
-
|
|
345573
|
-
|
|
345574
|
-
|
|
345575
|
-
|
|
345576
|
-
|
|
345577
|
-
|
|
345578
|
-
|
|
345579
|
-
|
|
345580
|
-
|
|
345581
|
-
|
|
345582
|
-
|
|
345583
|
-
|
|
345584
|
-
|
|
345959
|
+
return this.runInCommandParseCache(async () => {
|
|
345960
|
+
await this.prepareCommandParseCache(abortSignal);
|
|
345961
|
+
const strippedForInteractiveCheck = stripShellWrapper(
|
|
345962
|
+
this.params.command
|
|
345963
|
+
);
|
|
345964
|
+
const isInteractive = isDefaultIsInteractiveGeminiCommand(
|
|
345965
|
+
isInteractiveGeminiCommand
|
|
345966
|
+
) ? await isInteractiveGeminiCommandAsync(
|
|
345967
|
+
strippedForInteractiveCheck,
|
|
345968
|
+
this.parseCache,
|
|
345969
|
+
abortSignal
|
|
345970
|
+
) : isInteractiveGeminiCommand(strippedForInteractiveCheck);
|
|
345971
|
+
if (isInteractive) {
|
|
345972
|
+
return false;
|
|
345973
|
+
}
|
|
345974
|
+
if (forcedDecision === "deny") {
|
|
345975
|
+
return super.shouldConfirmExecute(abortSignal, forcedDecision);
|
|
345976
|
+
}
|
|
345977
|
+
if (this.hasTaintedOrBuildFileRisk()) {
|
|
345978
|
+
return this.getConfirmationDetails(abortSignal);
|
|
345979
|
+
}
|
|
345980
|
+
if (this.context.config.getApprovalMode() === "yolo" /* YOLO */ && forcedDecision !== "ask_user") {
|
|
345981
|
+
return super.shouldConfirmExecute(abortSignal, forcedDecision);
|
|
345982
|
+
}
|
|
345983
|
+
if (this.params[PARAM_ADDITIONAL_PERMISSIONS]) {
|
|
345984
|
+
return this.getConfirmationDetails(abortSignal);
|
|
345985
|
+
}
|
|
345986
|
+
if (this.context.config.getSandboxEnabled()) {
|
|
345987
|
+
const command = stripShellWrapper(this.params.command);
|
|
345988
|
+
const rootCommands = isDefaultGetCommandRoots(getCommandRoots) ? await getCommandRootsAsync(command, this.parseCache, abortSignal) : getCommandRoots(command);
|
|
345989
|
+
const rawRootCommand = rootCommands[0];
|
|
345990
|
+
if (rawRootCommand) {
|
|
345991
|
+
const rootCommand = normalizeCommand(rawRootCommand);
|
|
345992
|
+
const proactive = await getProactiveToolSuggestions(rootCommand);
|
|
345993
|
+
if (proactive) {
|
|
345994
|
+
const mode = this.context.config.getApprovalMode();
|
|
345995
|
+
const modeConfig = this.context.config.sandboxPolicyManager.getModeConfig(mode);
|
|
345996
|
+
const approved = this.context.config.sandboxPolicyManager.getCommandPermissions(
|
|
345997
|
+
rootCommand
|
|
345998
|
+
);
|
|
345999
|
+
const hasNetwork = modeConfig.network || approved.network;
|
|
346000
|
+
const missingNetwork = !!proactive.network && !hasNetwork;
|
|
346001
|
+
const parsed = isDefaultParseCommandDetails(parseCommandDetails) ? await parseCommandDetailsAsync(
|
|
346002
|
+
command,
|
|
346003
|
+
this.parseCache,
|
|
346004
|
+
abortSignal
|
|
346005
|
+
) : parseCommandDetails(command);
|
|
346006
|
+
const subCommand = parsed?.details[0]?.args?.[0];
|
|
346007
|
+
const needsNetwork = isNetworkReliantCommand(
|
|
346008
|
+
rootCommand,
|
|
346009
|
+
subCommand
|
|
346010
|
+
);
|
|
346011
|
+
if (needsNetwork) {
|
|
346012
|
+
const isReadonlyMode = modeConfig.readonly ?? false;
|
|
346013
|
+
if (isReadonlyMode) {
|
|
346014
|
+
const cwd = this.params.dir_path || this.context.config.getTargetDir();
|
|
346015
|
+
proactive.fileSystem = proactive.fileSystem || {
|
|
346016
|
+
read: [],
|
|
346017
|
+
write: []
|
|
346018
|
+
};
|
|
346019
|
+
proactive.fileSystem.write = proactive.fileSystem.write || [];
|
|
346020
|
+
if (!proactive.fileSystem.write.includes(cwd)) {
|
|
346021
|
+
proactive.fileSystem.write.push(cwd);
|
|
346022
|
+
proactive.fileSystem.read = proactive.fileSystem.read || [];
|
|
346023
|
+
if (!proactive.fileSystem.read.includes(cwd)) {
|
|
346024
|
+
proactive.fileSystem.read.push(cwd);
|
|
346025
|
+
}
|
|
345585
346026
|
}
|
|
345586
346027
|
}
|
|
345587
|
-
|
|
345588
|
-
|
|
345589
|
-
|
|
345590
|
-
|
|
345591
|
-
|
|
346028
|
+
const isApproved = (requestedPath, approvedPaths) => {
|
|
346029
|
+
if (!approvedPaths || approvedPaths.length === 0) return false;
|
|
346030
|
+
const requestedRealIdentity = toPathKey(
|
|
346031
|
+
resolveToRealPath(requestedPath)
|
|
346032
|
+
);
|
|
346033
|
+
return approvedPaths.some((p2) => {
|
|
346034
|
+
const approvedRealIdentity = toPathKey(resolveToRealPath(p2));
|
|
346035
|
+
return requestedRealIdentity === approvedRealIdentity || isSubpath(approvedRealIdentity, requestedRealIdentity);
|
|
346036
|
+
});
|
|
346037
|
+
};
|
|
346038
|
+
const missingRead = (proactive.fileSystem?.read || []).filter(
|
|
346039
|
+
(p2) => !isApproved(p2, approved.fileSystem?.read)
|
|
345592
346040
|
);
|
|
345593
|
-
|
|
345594
|
-
|
|
345595
|
-
return requestedRealIdentity === approvedRealIdentity || isSubpath(approvedRealIdentity, requestedRealIdentity);
|
|
345596
|
-
});
|
|
345597
|
-
};
|
|
345598
|
-
const missingRead = (proactive.fileSystem?.read || []).filter(
|
|
345599
|
-
(p2) => !isApproved(p2, approved.fileSystem?.read)
|
|
345600
|
-
);
|
|
345601
|
-
const missingWrite = (proactive.fileSystem?.write || []).filter(
|
|
345602
|
-
(p2) => !isApproved(p2, approved.fileSystem?.write)
|
|
345603
|
-
);
|
|
345604
|
-
const needsExpansion = missingRead.length > 0 || missingWrite.length > 0 || missingNetwork;
|
|
345605
|
-
if (needsExpansion) {
|
|
345606
|
-
const details = await this.getConfirmationDetails(
|
|
345607
|
-
abortSignal,
|
|
345608
|
-
proactive
|
|
346041
|
+
const missingWrite = (proactive.fileSystem?.write || []).filter(
|
|
346042
|
+
(p2) => !isApproved(p2, approved.fileSystem?.write)
|
|
345609
346043
|
);
|
|
345610
|
-
|
|
345611
|
-
|
|
345612
|
-
details
|
|
345613
|
-
|
|
345614
|
-
|
|
345615
|
-
|
|
345616
|
-
|
|
345617
|
-
|
|
346044
|
+
const needsExpansion = missingRead.length > 0 || missingWrite.length > 0 || missingNetwork;
|
|
346045
|
+
if (needsExpansion) {
|
|
346046
|
+
const details = await this.getConfirmationDetails(
|
|
346047
|
+
abortSignal,
|
|
346048
|
+
proactive
|
|
346049
|
+
);
|
|
346050
|
+
if (details && details.type === "sandbox_expansion") {
|
|
346051
|
+
const originalOnConfirm = details.onConfirm;
|
|
346052
|
+
details.onConfirm = async (outcome) => {
|
|
346053
|
+
await originalOnConfirm(outcome);
|
|
346054
|
+
if (outcome !== "cancel" /* Cancel */) {
|
|
346055
|
+
this.proactivePermissionsConfirmed = proactive;
|
|
346056
|
+
}
|
|
346057
|
+
};
|
|
346058
|
+
}
|
|
346059
|
+
return details;
|
|
345618
346060
|
}
|
|
345619
|
-
return details;
|
|
345620
346061
|
}
|
|
345621
346062
|
}
|
|
345622
346063
|
}
|
|
345623
346064
|
}
|
|
345624
|
-
|
|
345625
|
-
|
|
346065
|
+
return super.shouldConfirmExecute(abortSignal, forcedDecision);
|
|
346066
|
+
});
|
|
345626
346067
|
}
|
|
345627
|
-
async getConfirmationDetails(
|
|
345628
|
-
|
|
345629
|
-
|
|
345630
|
-
|
|
345631
|
-
|
|
345632
|
-
|
|
345633
|
-
|
|
345634
|
-
|
|
345635
|
-
rootCommandDisplay
|
|
346068
|
+
async getConfirmationDetails(abortSignal, proactivePermissions) {
|
|
346069
|
+
return this.runInCommandParseCache(async () => {
|
|
346070
|
+
const command = stripShellWrapper(this.params.command);
|
|
346071
|
+
const parsed = isDefaultParseCommandDetails(parseCommandDetails) ? await parseCommandDetailsAsync(command, this.parseCache, abortSignal) : parseCommandDetails(command);
|
|
346072
|
+
const commandHasRedirection = isDefaultHasRedirection(hasRedirection) ? await hasRedirectionAsync(command, this.parseCache, abortSignal) : hasRedirection(command);
|
|
346073
|
+
let rootCommandDisplay = "";
|
|
346074
|
+
if (!parsed || parsed.hasError || parsed.details.length === 0) {
|
|
346075
|
+
const fallback = command.trim().split(/\s+/)[0];
|
|
346076
|
+
rootCommandDisplay = fallback || "shell command";
|
|
346077
|
+
if (commandHasRedirection) {
|
|
346078
|
+
rootCommandDisplay += ", redirection";
|
|
346079
|
+
}
|
|
346080
|
+
} else {
|
|
346081
|
+
rootCommandDisplay = parsed.details.map((detail) => detail.name).join(", ");
|
|
345636
346082
|
}
|
|
345637
|
-
|
|
345638
|
-
|
|
345639
|
-
|
|
345640
|
-
|
|
345641
|
-
|
|
345642
|
-
|
|
345643
|
-
|
|
345644
|
-
|
|
345645
|
-
|
|
345646
|
-
|
|
345647
|
-
|
|
345648
|
-
|
|
345649
|
-
|
|
345650
|
-
|
|
345651
|
-
|
|
345652
|
-
|
|
345653
|
-
|
|
345654
|
-
|
|
345655
|
-
|
|
346083
|
+
let rootCommands = [];
|
|
346084
|
+
try {
|
|
346085
|
+
const computedRoots = isDefaultGetCommandRoots(getCommandRoots) ? await getCommandRootsAsync(command, this.parseCache, abortSignal) : getCommandRoots(command);
|
|
346086
|
+
rootCommands = [...new Set(computedRoots)];
|
|
346087
|
+
} catch {
|
|
346088
|
+
rootCommands = [command.trim().split(/\s+/)[0] || "shell"];
|
|
346089
|
+
}
|
|
346090
|
+
const rootCommand = rootCommands[0] || "shell";
|
|
346091
|
+
const untrustedFlags = this.getUntrustedFlags(command);
|
|
346092
|
+
const modifiedBuildFiles = getModifiedBuildFiles(this.context.config);
|
|
346093
|
+
const isBuildCmd = isBuildOrTestCommand(command);
|
|
346094
|
+
const hasSecurityWarning = untrustedFlags.length > 0 || isBuildCmd && modifiedBuildFiles.length > 0;
|
|
346095
|
+
const effectiveAdditionalPermissions = this.params[PARAM_ADDITIONAL_PERMISSIONS] || proactivePermissions;
|
|
346096
|
+
if (effectiveAdditionalPermissions && !hasSecurityWarning) {
|
|
346097
|
+
return {
|
|
346098
|
+
type: "sandbox_expansion",
|
|
346099
|
+
title: proactivePermissions ? "Sandbox Expansion Request (Recommended)" : "Sandbox Expansion Request",
|
|
346100
|
+
command: this.params.command,
|
|
346101
|
+
rootCommand: rootCommandDisplay,
|
|
346102
|
+
additionalPermissions: effectiveAdditionalPermissions,
|
|
346103
|
+
onConfirm: async (outcome) => {
|
|
346104
|
+
if (outcome !== "cancel" /* Cancel */ && outcome !== "modify_with_editor" /* ModifyWithEditor */) {
|
|
346105
|
+
this.confirmedCommand = this.params.command;
|
|
346106
|
+
}
|
|
346107
|
+
if (outcome === "proceed_always_and_save" /* ProceedAlwaysAndSave */) {
|
|
346108
|
+
this.context.config.sandboxPolicyManager.addPersistentApproval(
|
|
346109
|
+
rootCommand,
|
|
346110
|
+
effectiveAdditionalPermissions
|
|
346111
|
+
);
|
|
346112
|
+
} else if (outcome === "proceed_always" /* ProceedAlways */) {
|
|
346113
|
+
this.context.config.sandboxPolicyManager.addSessionApproval(
|
|
346114
|
+
rootCommand,
|
|
346115
|
+
effectiveAdditionalPermissions
|
|
346116
|
+
);
|
|
346117
|
+
}
|
|
346118
|
+
}
|
|
346119
|
+
};
|
|
346120
|
+
}
|
|
346121
|
+
const confirmationDetails = {
|
|
346122
|
+
type: "exec",
|
|
346123
|
+
title: "Confirm Shell Command",
|
|
345656
346124
|
command: this.params.command,
|
|
345657
346125
|
rootCommand: rootCommandDisplay,
|
|
345658
|
-
|
|
346126
|
+
rootCommands,
|
|
346127
|
+
hasRedirection: commandHasRedirection,
|
|
346128
|
+
untrustedFlags: untrustedFlags.length > 0 ? untrustedFlags : void 0,
|
|
346129
|
+
modifiedBuildFiles: isBuildCmd && modifiedBuildFiles.length > 0 ? modifiedBuildFiles : void 0,
|
|
345659
346130
|
onConfirm: async (outcome) => {
|
|
345660
|
-
if (outcome
|
|
345661
|
-
|
|
346131
|
+
if (outcome === "cancel" /* Cancel */ || outcome === "modify_with_editor" /* ModifyWithEditor */) {
|
|
346132
|
+
return;
|
|
345662
346133
|
}
|
|
345663
|
-
|
|
345664
|
-
|
|
345665
|
-
|
|
345666
|
-
|
|
345667
|
-
|
|
345668
|
-
|
|
345669
|
-
|
|
345670
|
-
|
|
345671
|
-
effectiveAdditionalPermissions
|
|
345672
|
-
);
|
|
346134
|
+
this.confirmedCommand = this.params.command;
|
|
346135
|
+
acknowledgeUntrustedFlags(
|
|
346136
|
+
untrustedFlags,
|
|
346137
|
+
rootCommands,
|
|
346138
|
+
this.context.config
|
|
346139
|
+
);
|
|
346140
|
+
if (isBuildCmd && modifiedBuildFiles.length > 0) {
|
|
346141
|
+
resetModifiedBuildFiles(this.context.config);
|
|
345673
346142
|
}
|
|
345674
346143
|
}
|
|
345675
346144
|
};
|
|
345676
|
-
|
|
345677
|
-
|
|
345678
|
-
type: "exec",
|
|
345679
|
-
title: "Confirm Shell Command",
|
|
345680
|
-
command: this.params.command,
|
|
345681
|
-
rootCommand: rootCommandDisplay,
|
|
345682
|
-
rootCommands,
|
|
345683
|
-
untrustedFlags: untrustedFlags.length > 0 ? untrustedFlags : void 0,
|
|
345684
|
-
modifiedBuildFiles: isBuildCmd && modifiedBuildFiles.length > 0 ? modifiedBuildFiles : void 0,
|
|
345685
|
-
onConfirm: async (outcome) => {
|
|
345686
|
-
if (outcome === "cancel" /* Cancel */ || outcome === "modify_with_editor" /* ModifyWithEditor */) {
|
|
345687
|
-
return;
|
|
345688
|
-
}
|
|
345689
|
-
this.confirmedCommand = this.params.command;
|
|
345690
|
-
acknowledgeUntrustedFlags(
|
|
345691
|
-
untrustedFlags,
|
|
345692
|
-
rootCommands,
|
|
345693
|
-
this.context.config
|
|
345694
|
-
);
|
|
345695
|
-
if (isBuildCmd && modifiedBuildFiles.length > 0) {
|
|
345696
|
-
resetModifiedBuildFiles(this.context.config);
|
|
345697
|
-
}
|
|
345698
|
-
}
|
|
345699
|
-
};
|
|
345700
|
-
return confirmationDetails;
|
|
346145
|
+
return confirmationDetails;
|
|
346146
|
+
});
|
|
345701
346147
|
}
|
|
345702
346148
|
async isCommandSubstitutionAllowed(options) {
|
|
345703
346149
|
if ((options.isClientInitiated ?? false) || (options.isUserConfirmed ?? false) || this.confirmedCommand === this.params.command) {
|
|
345704
346150
|
return true;
|
|
345705
346151
|
}
|
|
346152
|
+
await this.prepareCommandParseCache(options.abortSignal);
|
|
345706
346153
|
if (this.hasTaintedOrBuildFileRisk()) {
|
|
345707
346154
|
return false;
|
|
345708
346155
|
}
|
|
@@ -345723,6 +346170,9 @@ exit $__code`;
|
|
|
345723
346170
|
return this.context.config?.getApprovalMode?.() === "yolo" /* YOLO */;
|
|
345724
346171
|
}
|
|
345725
346172
|
async execute(options) {
|
|
346173
|
+
return this.runInCommandParseCache(() => this.executeInternal(options));
|
|
346174
|
+
}
|
|
346175
|
+
async executeInternal(options) {
|
|
345726
346176
|
const {
|
|
345727
346177
|
abortSignal: signal,
|
|
345728
346178
|
updateOutput,
|
|
@@ -345730,7 +346180,23 @@ exit $__code`;
|
|
|
345730
346180
|
setExecutionIdCallback
|
|
345731
346181
|
} = options;
|
|
345732
346182
|
const strippedCommand = stripShellWrapper(this.params.command);
|
|
345733
|
-
|
|
346183
|
+
let isInteractiveGemini;
|
|
346184
|
+
if (!isDefaultIsInteractiveGeminiCommand(isInteractiveGeminiCommand)) {
|
|
346185
|
+
isInteractiveGemini = isInteractiveGeminiCommand(strippedCommand);
|
|
346186
|
+
} else if (this.hasCachedCommandParse(strippedCommand)) {
|
|
346187
|
+
isInteractiveGemini = isInteractiveGeminiCommand(
|
|
346188
|
+
strippedCommand,
|
|
346189
|
+
this.parseCache
|
|
346190
|
+
);
|
|
346191
|
+
} else {
|
|
346192
|
+
const knownInteractive = isKnownInteractiveGeminiCommandSync(strippedCommand);
|
|
346193
|
+
isInteractiveGemini = knownInteractive ?? await isInteractiveGeminiCommandAsync(
|
|
346194
|
+
strippedCommand,
|
|
346195
|
+
this.parseCache,
|
|
346196
|
+
signal
|
|
346197
|
+
);
|
|
346198
|
+
}
|
|
346199
|
+
if (isInteractiveGemini) {
|
|
345734
346200
|
return {
|
|
345735
346201
|
llmContent: INTERACTIVE_GEMINI_SHELL_ERROR,
|
|
345736
346202
|
returnDisplay: INTERACTIVE_GEMINI_SHELL_ERROR,
|
|
@@ -346099,7 +346565,8 @@ ${result.output}`;
|
|
|
346099
346565
|
const sandboxDenial = this.context.config.sandboxManager.parseDenials(result);
|
|
346100
346566
|
if (sandboxDenial) {
|
|
346101
346567
|
const strippedCommand2 = stripShellWrapper(this.params.command);
|
|
346102
|
-
const
|
|
346568
|
+
const computedRootCommands = isDefaultGetCommandRoots(getCommandRoots) ? await getCommandRootsAsync(strippedCommand2, this.parseCache) : getCommandRoots(strippedCommand2);
|
|
346569
|
+
const rootCommands = computedRootCommands.filter(
|
|
346103
346570
|
(r9) => r9 !== "shopt"
|
|
346104
346571
|
);
|
|
346105
346572
|
const rootCommandDisplay = rootCommands.length > 0 ? rootCommands[0] : "shell";
|
|
@@ -346195,7 +346662,7 @@ ${result.output}`;
|
|
|
346195
346662
|
}
|
|
346196
346663
|
}
|
|
346197
346664
|
const summarizeConfig = this.context.config.getSummarizeToolOutputConfig();
|
|
346198
|
-
const outputSource =
|
|
346665
|
+
const outputSource = await isRemoteContentCommandAsync(strippedCommand) ? REMOTE_SHELL_OUTPUT_SOURCE : void 0;
|
|
346199
346666
|
const executionError = result.error ? {
|
|
346200
346667
|
error: {
|
|
346201
346668
|
message: result.error.message,
|
|
@@ -363364,7 +363831,7 @@ var A2AAuthProviderFactory = class _A2AAuthProviderFactory {
|
|
|
363364
363831
|
return provider;
|
|
363365
363832
|
}
|
|
363366
363833
|
case "oauth2": {
|
|
363367
|
-
const { OAuth2AuthProvider } = await import("./oauth2-provider-
|
|
363834
|
+
const { OAuth2AuthProvider } = await import("./oauth2-provider-3EEFSHG4.js");
|
|
363368
363835
|
const provider = new OAuth2AuthProvider(
|
|
363369
363836
|
authConfig,
|
|
363370
363837
|
options.agentName ?? "unknown",
|
|
@@ -365263,6 +365730,9 @@ function isAutoEditTransition(tool, outcome) {
|
|
|
365263
365730
|
}
|
|
365264
365731
|
async function handleStandardPolicyUpdate(tool, outcome, confirmationDetails, messageBus, persistScope, toolInvocation, config2, modes) {
|
|
365265
365732
|
if (outcome === "proceed_always" /* ProceedAlways */ || outcome === "proceed_always_and_save" /* ProceedAlwaysAndSave */) {
|
|
365733
|
+
if (typeof toolInvocation === "object" && toolInvocation !== null && "prepareCommandParseCache" in toolInvocation && typeof toolInvocation.prepareCommandParseCache === "function") {
|
|
365734
|
+
await toolInvocation.prepareCommandParseCache();
|
|
365735
|
+
}
|
|
365266
365736
|
const options = toolInvocation?.getPolicyUpdateOptions?.(outcome) || {};
|
|
365267
365737
|
if (!options.commandPrefix && confirmationDetails?.type === "exec") {
|
|
365268
365738
|
options.commandPrefix = confirmationDetails.rootCommands;
|
|
@@ -371729,6 +372199,15 @@ var ToolModificationHandler = class {
|
|
|
371729
372199
|
};
|
|
371730
372200
|
|
|
371731
372201
|
// packages/core/src/scheduler/scheduler.ts
|
|
372202
|
+
function isCommandParseCacheAware(invocation) {
|
|
372203
|
+
return typeof invocation === "object" && invocation !== null && "runInCommandParseCache" in invocation && typeof invocation.runInCommandParseCache === "function" && "prepareCommandParseCache" in invocation && typeof invocation.prepareCommandParseCache === "function";
|
|
372204
|
+
}
|
|
372205
|
+
function runWithInvocationParseCache(invocation, fn3) {
|
|
372206
|
+
if (isCommandParseCacheAware(invocation)) {
|
|
372207
|
+
return invocation.runInCommandParseCache(fn3);
|
|
372208
|
+
}
|
|
372209
|
+
return runWithCommandParseCache(fn3);
|
|
372210
|
+
}
|
|
371732
372211
|
function isTaintRiskDetectable(invocation) {
|
|
371733
372212
|
return typeof invocation === "object" && invocation !== null && "hasTaintedOrBuildFileRisk" in invocation && typeof invocation.hasTaintedOrBuildFileRisk === "function";
|
|
371734
372213
|
}
|
|
@@ -372171,83 +372650,88 @@ var Scheduler = class {
|
|
|
372171
372650
|
toolCall.request.inputModifiedByHook = true;
|
|
372172
372651
|
toolCall.invocation = newInvocation;
|
|
372173
372652
|
}
|
|
372174
|
-
|
|
372175
|
-
|
|
372176
|
-
|
|
372177
|
-
this.subagent
|
|
372178
|
-
);
|
|
372179
|
-
let decision = policyDecision;
|
|
372180
|
-
if (hookDecision === "ask") {
|
|
372181
|
-
decision = "ask_user" /* ASK_USER */;
|
|
372182
|
-
}
|
|
372183
|
-
const hasTaintRisk = isTaintRiskDetectable(toolCall.invocation) && toolCall.invocation.hasTaintedOrBuildFileRisk();
|
|
372184
|
-
if (decision === "allow" /* ALLOW */ && hasTaintRisk) {
|
|
372185
|
-
decision = this.config.isInteractive?.() ?? true ? "ask_user" /* ASK_USER */ : "deny" /* DENY */;
|
|
372186
|
-
}
|
|
372187
|
-
if (decision === "deny" /* DENY */) {
|
|
372188
|
-
const { errorMessage, errorType } = getPolicyDenialError(
|
|
372653
|
+
await runWithInvocationParseCache(toolCall.invocation, async () => {
|
|
372654
|
+
const { decision: policyDecision, rule } = await checkPolicy(
|
|
372655
|
+
toolCall,
|
|
372189
372656
|
this.config,
|
|
372190
|
-
|
|
372657
|
+
this.subagent
|
|
372191
372658
|
);
|
|
372192
|
-
|
|
372193
|
-
|
|
372194
|
-
"
|
|
372195
|
-
createErrorResponse(
|
|
372196
|
-
toolCall.request,
|
|
372197
|
-
new Error(errorMessage),
|
|
372198
|
-
errorType
|
|
372199
|
-
)
|
|
372200
|
-
);
|
|
372201
|
-
return;
|
|
372202
|
-
}
|
|
372203
|
-
let outcome = "proceed_once" /* ProceedOnce */;
|
|
372204
|
-
let lastDetails;
|
|
372205
|
-
if (decision === "ask_user" /* ASK_USER */) {
|
|
372206
|
-
const forcedDecision = hookDecision === "ask" || policyDecision === "allow" /* ALLOW */ && hasTaintRisk ? "ask_user" : void 0;
|
|
372207
|
-
const result = await resolveConfirmation(toolCall, signal, {
|
|
372208
|
-
config: this.config,
|
|
372209
|
-
messageBus: this.messageBus,
|
|
372210
|
-
state: this.state,
|
|
372211
|
-
modifier: this.modifier,
|
|
372212
|
-
getPreferredEditor: this.getPreferredEditor,
|
|
372213
|
-
schedulerId: this.schedulerId,
|
|
372214
|
-
onWaitingForConfirmation: this.onWaitingForConfirmation,
|
|
372215
|
-
systemMessage: hookSystemMessage,
|
|
372216
|
-
forcedDecision
|
|
372217
|
-
});
|
|
372218
|
-
outcome = result.outcome;
|
|
372219
|
-
lastDetails = result.lastDetails;
|
|
372220
|
-
if ((result.confirmedByUser ?? false) && outcome !== "cancel" /* Cancel */) {
|
|
372221
|
-
toolCall.request.isUserConfirmed = true;
|
|
372222
|
-
const updatedCall = this.state.getToolCall(callId);
|
|
372223
|
-
if (updatedCall) {
|
|
372224
|
-
updatedCall.request.isUserConfirmed = true;
|
|
372225
|
-
}
|
|
372226
|
-
}
|
|
372227
|
-
}
|
|
372228
|
-
this.state.setOutcome(callId, outcome);
|
|
372229
|
-
if (decision === "ask_user" /* ASK_USER */ && outcome) {
|
|
372230
|
-
await updatePolicy(
|
|
372231
|
-
toolCall.tool,
|
|
372232
|
-
outcome,
|
|
372233
|
-
lastDetails,
|
|
372234
|
-
this.context,
|
|
372235
|
-
this.messageBus,
|
|
372236
|
-
toolCall.invocation
|
|
372237
|
-
);
|
|
372238
|
-
}
|
|
372239
|
-
if (outcome === "cancel" /* Cancel */) {
|
|
372240
|
-
this.state.updateStatus(
|
|
372241
|
-
callId,
|
|
372242
|
-
"cancelled" /* Cancelled */,
|
|
372243
|
-
"User denied execution."
|
|
372244
|
-
);
|
|
372245
|
-
if (this.cancelAllQueuedOnCancel) {
|
|
372246
|
-
this.state.cancelAllQueued("User cancelled operation");
|
|
372659
|
+
let decision = policyDecision;
|
|
372660
|
+
if (hookDecision === "ask") {
|
|
372661
|
+
decision = "ask_user" /* ASK_USER */;
|
|
372247
372662
|
}
|
|
372248
|
-
|
|
372249
|
-
|
|
372250
|
-
|
|
372663
|
+
if (isCommandParseCacheAware(toolCall.invocation)) {
|
|
372664
|
+
await toolCall.invocation.prepareCommandParseCache(signal);
|
|
372665
|
+
}
|
|
372666
|
+
const hasTaintRisk = isTaintRiskDetectable(toolCall.invocation) && toolCall.invocation.hasTaintedOrBuildFileRisk();
|
|
372667
|
+
if (decision === "allow" /* ALLOW */ && hasTaintRisk) {
|
|
372668
|
+
decision = this.config.isInteractive?.() ?? true ? "ask_user" /* ASK_USER */ : "deny" /* DENY */;
|
|
372669
|
+
}
|
|
372670
|
+
if (decision === "deny" /* DENY */) {
|
|
372671
|
+
const { errorMessage, errorType } = getPolicyDenialError(
|
|
372672
|
+
this.config,
|
|
372673
|
+
rule
|
|
372674
|
+
);
|
|
372675
|
+
this.state.updateStatus(
|
|
372676
|
+
callId,
|
|
372677
|
+
"error" /* Error */,
|
|
372678
|
+
createErrorResponse(
|
|
372679
|
+
toolCall.request,
|
|
372680
|
+
new Error(errorMessage),
|
|
372681
|
+
errorType
|
|
372682
|
+
)
|
|
372683
|
+
);
|
|
372684
|
+
return;
|
|
372685
|
+
}
|
|
372686
|
+
let outcome = "proceed_once" /* ProceedOnce */;
|
|
372687
|
+
let lastDetails;
|
|
372688
|
+
if (decision === "ask_user" /* ASK_USER */) {
|
|
372689
|
+
const forcedDecision = hookDecision === "ask" || policyDecision === "allow" /* ALLOW */ && hasTaintRisk ? "ask_user" : void 0;
|
|
372690
|
+
const result = await resolveConfirmation(toolCall, signal, {
|
|
372691
|
+
config: this.config,
|
|
372692
|
+
messageBus: this.messageBus,
|
|
372693
|
+
state: this.state,
|
|
372694
|
+
modifier: this.modifier,
|
|
372695
|
+
getPreferredEditor: this.getPreferredEditor,
|
|
372696
|
+
schedulerId: this.schedulerId,
|
|
372697
|
+
onWaitingForConfirmation: this.onWaitingForConfirmation,
|
|
372698
|
+
systemMessage: hookSystemMessage,
|
|
372699
|
+
forcedDecision
|
|
372700
|
+
});
|
|
372701
|
+
outcome = result.outcome;
|
|
372702
|
+
lastDetails = result.lastDetails;
|
|
372703
|
+
if ((result.confirmedByUser ?? false) && outcome !== "cancel" /* Cancel */) {
|
|
372704
|
+
toolCall.request.isUserConfirmed = true;
|
|
372705
|
+
const updatedCall = this.state.getToolCall(callId);
|
|
372706
|
+
if (updatedCall) {
|
|
372707
|
+
updatedCall.request.isUserConfirmed = true;
|
|
372708
|
+
}
|
|
372709
|
+
}
|
|
372710
|
+
}
|
|
372711
|
+
this.state.setOutcome(callId, outcome);
|
|
372712
|
+
if (decision === "ask_user" /* ASK_USER */ && outcome) {
|
|
372713
|
+
await updatePolicy(
|
|
372714
|
+
toolCall.tool,
|
|
372715
|
+
outcome,
|
|
372716
|
+
lastDetails,
|
|
372717
|
+
this.context,
|
|
372718
|
+
this.messageBus,
|
|
372719
|
+
toolCall.invocation
|
|
372720
|
+
);
|
|
372721
|
+
}
|
|
372722
|
+
if (outcome === "cancel" /* Cancel */) {
|
|
372723
|
+
this.state.updateStatus(
|
|
372724
|
+
callId,
|
|
372725
|
+
"cancelled" /* Cancelled */,
|
|
372726
|
+
"User denied execution."
|
|
372727
|
+
);
|
|
372728
|
+
if (this.cancelAllQueuedOnCancel) {
|
|
372729
|
+
this.state.cancelAllQueued("User cancelled operation");
|
|
372730
|
+
}
|
|
372731
|
+
return;
|
|
372732
|
+
}
|
|
372733
|
+
this.state.updateStatus(callId, "scheduled" /* Scheduled */);
|
|
372734
|
+
});
|
|
372251
372735
|
}
|
|
372252
372736
|
// --- Sub-phase Handlers ---
|
|
372253
372737
|
/**
|
|
@@ -372687,7 +373171,7 @@ ${wrapInput(safeInput)}`;
|
|
|
372687
373171
|
}
|
|
372688
373172
|
|
|
372689
373173
|
// packages/core/src/config/scoped-config.ts
|
|
372690
|
-
import { AsyncLocalStorage as
|
|
373174
|
+
import { AsyncLocalStorage as AsyncLocalStorage4 } from "node:async_hooks";
|
|
372691
373175
|
import * as path73 from "node:path";
|
|
372692
373176
|
|
|
372693
373177
|
// packages/core/src/utils/workspaceContext.ts
|
|
@@ -372886,9 +373370,9 @@ var WorkspaceContext = class {
|
|
|
372886
373370
|
};
|
|
372887
373371
|
|
|
372888
373372
|
// packages/core/src/config/scoped-config.ts
|
|
372889
|
-
var workspaceContextOverride = new
|
|
372890
|
-
var memoryInboxAccessOverride = new
|
|
372891
|
-
var autoMemoryExtractionWriteAccessOverride = new
|
|
373373
|
+
var workspaceContextOverride = new AsyncLocalStorage4();
|
|
373374
|
+
var memoryInboxAccessOverride = new AsyncLocalStorage4();
|
|
373375
|
+
var autoMemoryExtractionWriteAccessOverride = new AsyncLocalStorage4();
|
|
372892
373376
|
function getWorkspaceContextOverride() {
|
|
372893
373377
|
return workspaceContextOverride.getStore();
|
|
372894
373378
|
}
|
|
@@ -387138,9 +387622,10 @@ var PolicyEngine = class {
|
|
|
387138
387622
|
isAlwaysAllowRule(rule) {
|
|
387139
387623
|
return rule.priority !== void 0 && Math.round(rule.priority % 1 * 1e3) === ALWAYS_ALLOW_PRIORITY_FRACTION;
|
|
387140
387624
|
}
|
|
387141
|
-
shouldDowngradeForRedirection(command, allowRedirection, rule) {
|
|
387625
|
+
async shouldDowngradeForRedirection(command, allowRedirection, rule) {
|
|
387142
387626
|
if (allowRedirection) return false;
|
|
387143
|
-
|
|
387627
|
+
const redirected = isDefaultHasRedirection(hasRedirection) ? await hasRedirectionAsync(command) : hasRedirection(command);
|
|
387628
|
+
if (!redirected) return false;
|
|
387144
387629
|
if (rule?.argsPattern && !allowRedirection) {
|
|
387145
387630
|
return true;
|
|
387146
387631
|
}
|
|
@@ -387237,7 +387722,7 @@ var PolicyEngine = class {
|
|
|
387237
387722
|
};
|
|
387238
387723
|
}
|
|
387239
387724
|
await initializeShellParsers();
|
|
387240
|
-
const parsed = parseCommandDetails(command);
|
|
387725
|
+
const parsed = isDefaultParseCommandDetails(parseCommandDetails) ? await parseCommandDetailsAsync(command) : parseCommandDetails(command);
|
|
387241
387726
|
const subCommands = parsed?.details ?? [];
|
|
387242
387727
|
if (subCommands.length === 0 || parsed?.hasError) {
|
|
387243
387728
|
if (ruleDecision === "deny" /* DENY */) {
|
|
@@ -387271,11 +387756,7 @@ var PolicyEngine = class {
|
|
|
387271
387756
|
}
|
|
387272
387757
|
let aggregateDecision = ruleDecision;
|
|
387273
387758
|
let responsibleRule = rule && ruleDecision === rule.decision ? rule : void 0;
|
|
387274
|
-
const hasTopLevelRedirectionDowngrade = this.shouldDowngradeForRedirection(
|
|
387275
|
-
command,
|
|
387276
|
-
allowRedirection,
|
|
387277
|
-
rule
|
|
387278
|
-
);
|
|
387759
|
+
const hasTopLevelRedirectionDowngrade = await this.shouldDowngradeForRedirection(command, allowRedirection, rule);
|
|
387279
387760
|
if (hasTopLevelRedirectionDowngrade) {
|
|
387280
387761
|
if (aggregateDecision === "allow" /* ALLOW */) {
|
|
387281
387762
|
debugLogger.debug(
|
|
@@ -387353,7 +387834,7 @@ var PolicyEngine = class {
|
|
|
387353
387834
|
}
|
|
387354
387835
|
aggregateDecision = "ask_user" /* ASK_USER */;
|
|
387355
387836
|
}
|
|
387356
|
-
if (subResult.decision === "allow" /* ALLOW */ && (this.shouldDowngradeForRedirection(
|
|
387837
|
+
if (subResult.decision === "allow" /* ALLOW */ && (await this.shouldDowngradeForRedirection(
|
|
387357
387838
|
subCmd,
|
|
387358
387839
|
subResult.rule?.allowRedirection ?? allowRedirection,
|
|
387359
387840
|
subResult.rule
|
|
@@ -387397,6 +387878,17 @@ var PolicyEngine = class {
|
|
|
387397
387878
|
* Returns the decision and the matching rule (if any).
|
|
387398
387879
|
*/
|
|
387399
387880
|
async check(toolCall, serverName, toolAnnotations, subagent, skipHeuristics = false) {
|
|
387881
|
+
return runWithCommandParseCache(
|
|
387882
|
+
() => this.checkInternal(
|
|
387883
|
+
toolCall,
|
|
387884
|
+
serverName,
|
|
387885
|
+
toolAnnotations,
|
|
387886
|
+
subagent,
|
|
387887
|
+
skipHeuristics
|
|
387888
|
+
)
|
|
387889
|
+
);
|
|
387890
|
+
}
|
|
387891
|
+
async checkInternal(toolCall, serverName, toolAnnotations, subagent, skipHeuristics = false) {
|
|
387400
387892
|
if (!serverName && isMcpToolAnnotation(toolAnnotations)) {
|
|
387401
387893
|
serverName = toolAnnotations._serverName;
|
|
387402
387894
|
}
|
|
@@ -425355,6 +425847,9 @@ export {
|
|
|
425355
425847
|
external_exports,
|
|
425356
425848
|
debugLogger,
|
|
425357
425849
|
require_shell_quote,
|
|
425850
|
+
CommandParseCache,
|
|
425851
|
+
getActiveCommandParseCache,
|
|
425852
|
+
runWithCommandParseCache,
|
|
425358
425853
|
ToolErrorType,
|
|
425359
425854
|
isFatalToolError,
|
|
425360
425855
|
GEMINI_DIR,
|
|
@@ -425473,19 +425968,31 @@ export {
|
|
|
425473
425968
|
normalizeCommand,
|
|
425474
425969
|
parseBashCommandDetails,
|
|
425475
425970
|
parseCommandDetails,
|
|
425971
|
+
parseCommandDetailsAsync,
|
|
425972
|
+
isDefaultParseCommandDetails,
|
|
425476
425973
|
getShellConfiguration,
|
|
425477
425974
|
isWindows,
|
|
425478
425975
|
escapeShellArg,
|
|
425479
425976
|
hasRedirection,
|
|
425977
|
+
hasRedirectionAsync,
|
|
425480
425978
|
hasUnresolvedShellExpansion,
|
|
425481
425979
|
splitCommands,
|
|
425980
|
+
splitCommandsAsync,
|
|
425482
425981
|
getCommandRoot,
|
|
425982
|
+
getCommandRootAsync,
|
|
425483
425983
|
getCommandRoots,
|
|
425984
|
+
getCommandRootsAsync,
|
|
425985
|
+
isDefaultHasRedirection,
|
|
425986
|
+
isDefaultSplitCommands,
|
|
425987
|
+
isDefaultGetCommandRoots,
|
|
425484
425988
|
stripShellWrapper,
|
|
425485
425989
|
spawnAsync,
|
|
425486
425990
|
execStreaming,
|
|
425487
425991
|
detectCommandSubstitution,
|
|
425992
|
+
isKnownInteractiveGeminiCommandSync,
|
|
425488
425993
|
isInteractiveGeminiCommand,
|
|
425994
|
+
isInteractiveGeminiCommandAsync,
|
|
425995
|
+
isDefaultIsInteractiveGeminiCommand,
|
|
425489
425996
|
import_fixed_deque,
|
|
425490
425997
|
import_lru_cache,
|
|
425491
425998
|
import_lru_map_with_delete,
|