@google/gemini-cli 0.70.0-preview.0 → 0.71.0-preview.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundle/{chunk-T7277DWX.js → chunk-3XHFESDF.js} +1 -1
- package/bundle/{chunk-65MRMUKB.js → chunk-532N7TZB.js} +2 -2
- package/bundle/{chunk-CJ7YZ55P.js → chunk-5SC43MXU.js} +3 -3
- package/bundle/{chunk-L5UVIFFB.js → chunk-6E6XAAYL.js} +7 -7
- package/bundle/{chunk-BOYVA4SV.js → chunk-7UJSGYFD.js} +1 -1
- package/bundle/{chunk-IS5SQ7HP.js → chunk-7YXHVH7Y.js} +2 -2
- package/bundle/{chunk-O5EBPO5F.js → chunk-AJZTZFAS.js} +2 -2
- package/bundle/{chunk-SXOGAWDG.js → chunk-AQXZKJST.js} +1 -1
- package/bundle/{chunk-I5QSCSQU.js → chunk-BTH7KEMH.js} +842 -368
- package/bundle/{chunk-F6P6PQSG.js → chunk-DCBU7GEJ.js} +1 -1
- package/bundle/{chunk-RVYQZ73V.js → chunk-DPAMHBTE.js} +3 -3
- package/bundle/{chunk-RTIGPATB.js → chunk-EERY2AEY.js} +1 -1
- package/bundle/{chunk-ECLDXLDB.js → chunk-FUOK6VUJ.js} +3 -3
- package/bundle/{chunk-ZUQTNDGH.js → chunk-IBD2PLWE.js} +7 -7
- package/bundle/{chunk-SA2VIQNQ.js → chunk-JJNQ5PWH.js} +842 -368
- package/bundle/{chunk-STY67ND2.js → chunk-KSDBDSBI.js} +1 -1
- package/bundle/{chunk-BCL7DJOQ.js → chunk-LGRO4U3O.js} +7 -7
- package/bundle/{chunk-NFAJ5FW5.js → chunk-NATMLC5X.js} +1 -1
- package/bundle/{chunk-CMUPNBQQ.js → chunk-NMOD2T37.js} +2 -2
- package/bundle/{chunk-6XLLXGZQ.js → chunk-NQGCTXGR.js} +1 -1
- package/bundle/{chunk-FGTABIOQ.js → chunk-QGOT25K4.js} +1 -1
- package/bundle/{chunk-AMGYQYS7.js → chunk-QQNZHLIF.js} +2 -2
- package/bundle/{chunk-NFBC76U4.js → chunk-UTK4LRWO.js} +1 -1
- package/bundle/{chunk-HBTS2REO.js → chunk-VIXTMKUM.js} +1 -1
- package/bundle/{chunk-FDIF7V5C.js → chunk-W7J7YSH2.js} +1 -1
- package/bundle/{chunk-TX3SX2WI.js → chunk-Y6WF3A3Q.js} +2 -2
- package/bundle/{chunk-O2DXIYZO.js → chunk-YQO7IBVQ.js} +751 -320
- package/bundle/{cleanup-44LV7E4R.js → cleanup-4WL7SSTL.js} +2 -2
- package/bundle/{cleanup-O4QBMRVU.js → cleanup-62ECCOLP.js} +2 -2
- package/bundle/{cleanup-WMYSWXJR.js → cleanup-JWSUGSQB.js} +2 -2
- package/bundle/{core-LJXCBOFM.js → core-6V72TKM3.js} +31 -1
- package/bundle/{dist-QSS2VWMY.js → core-NP64K3HR.js} +31 -1
- package/bundle/{devtoolsService-G4CPAW3U.js → devtoolsService-3G6P4EBB.js} +2 -2
- package/bundle/{devtoolsService-D4VCGQMJ.js → devtoolsService-DWVXCWJ7.js} +2 -2
- package/bundle/{devtoolsService-EBOCEFTO.js → devtoolsService-XMEVE7R4.js} +2 -2
- package/bundle/{core-DJ7VMWCC.js → dist-AAGC2327.js} +31 -1
- package/bundle/docs/changelogs/index.md +23 -0
- package/bundle/docs/changelogs/latest.md +112 -98
- package/bundle/docs/changelogs/preview.md +82 -115
- package/bundle/{formatError-I5Q2HGMN.js → formatError-7YP6B7ZW.js} +2 -2
- package/bundle/{formatError-NLKMYJNL.js → formatError-P6NGVTF2.js} +2 -2
- package/bundle/{formatError-3QIVJAE5.js → formatError-QS36O76I.js} +2 -2
- package/bundle/{gemini-J7ZRUAXR.js → gemini-3VVVLE4J.js} +15 -15
- package/bundle/{gemini-LOYZXP6I.js → gemini-AC4RONBV.js} +15 -15
- package/bundle/{gemini-4325ARIU.js → gemini-TY6A5Q5C.js} +15 -15
- package/bundle/gemini.js +8 -8
- package/bundle/{interactiveCli-O2L63RLG.js → interactiveCli-AO75ICTD.js} +157 -32
- package/bundle/{interactiveCli-CEIWZCYF.js → interactiveCli-BHEEEW2H.js} +157 -32
- package/bundle/{interactiveCli-AQ67IY7V.js → interactiveCli-XULKUHW4.js} +157 -32
- package/bundle/{liteRtServerManager-HMCB6A65.js → liteRtServerManager-7VEEHSC6.js} +4 -4
- package/bundle/{liteRtServerManager-MH32CAZ5.js → liteRtServerManager-DRZ6V4ZL.js} +4 -4
- package/bundle/{liteRtServerManager-EZFHT2B3.js → liteRtServerManager-GFU4D3JF.js} +4 -4
- package/bundle/{oauth2-provider-3TFNA7VY.js → oauth2-provider-S7DQJKA5.js} +1 -1
- package/bundle/{oauth2-provider-NPOZQDQO.js → oauth2-provider-XYK3N74K.js} +1 -1
- package/bundle/{oauth2-provider-UXC7XFV6.js → oauth2-provider-YZI5V6PH.js} +1 -1
- package/bundle/{start-JIKLB3S3.js → start-EMZSUYV6.js} +6 -6
- package/bundle/{start-NSYEL7UE.js → start-JGS6ZUFX.js} +6 -6
- package/bundle/{start-I2GOKFKQ.js → start-QQTZCWPJ.js} +6 -6
- package/package.json +1 -1
|
@@ -257240,6 +257240,51 @@ import os4 from "node:os";
|
|
|
257240
257240
|
import fs8 from "node:fs";
|
|
257241
257241
|
import path8 from "node:path";
|
|
257242
257242
|
import { spawn, spawnSync } from "node:child_process";
|
|
257243
|
+
|
|
257244
|
+
// packages/core/dist/src/utils/shell-parse-cache.js
|
|
257245
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
257246
|
+
var CommandParseCache = class {
|
|
257247
|
+
completed = /* @__PURE__ */ new Map();
|
|
257248
|
+
inFlight = /* @__PURE__ */ new Map();
|
|
257249
|
+
makeKey(executable, command) {
|
|
257250
|
+
return `${executable}\0${command}`;
|
|
257251
|
+
}
|
|
257252
|
+
hasCompleted(executable, command) {
|
|
257253
|
+
return this.completed.has(this.makeKey(executable, command));
|
|
257254
|
+
}
|
|
257255
|
+
getCompleted(executable, command) {
|
|
257256
|
+
return this.completed.get(this.makeKey(executable, command));
|
|
257257
|
+
}
|
|
257258
|
+
setCompleted(executable, command, result) {
|
|
257259
|
+
this.completed.set(this.makeKey(executable, command), result);
|
|
257260
|
+
}
|
|
257261
|
+
getInFlight(executable, command) {
|
|
257262
|
+
return this.inFlight.get(this.makeKey(executable, command));
|
|
257263
|
+
}
|
|
257264
|
+
trackInFlight(executable, command, promise2) {
|
|
257265
|
+
const key = this.makeKey(executable, command);
|
|
257266
|
+
this.inFlight.set(key, promise2);
|
|
257267
|
+
void promise2.finally(() => {
|
|
257268
|
+
if (this.inFlight.get(key) === promise2) {
|
|
257269
|
+
this.inFlight.delete(key);
|
|
257270
|
+
}
|
|
257271
|
+
});
|
|
257272
|
+
return promise2;
|
|
257273
|
+
}
|
|
257274
|
+
};
|
|
257275
|
+
var commandParseCacheStorage = new AsyncLocalStorage();
|
|
257276
|
+
function getActiveCommandParseCache() {
|
|
257277
|
+
return commandParseCacheStorage.getStore();
|
|
257278
|
+
}
|
|
257279
|
+
function runWithCommandParseCache(fn3, cache2) {
|
|
257280
|
+
const targetCache = cache2 ?? commandParseCacheStorage.getStore() ?? new CommandParseCache();
|
|
257281
|
+
if (commandParseCacheStorage.getStore() === targetCache) {
|
|
257282
|
+
return fn3(targetCache);
|
|
257283
|
+
}
|
|
257284
|
+
return commandParseCacheStorage.run(targetCache, () => fn3(targetCache));
|
|
257285
|
+
}
|
|
257286
|
+
|
|
257287
|
+
// packages/core/dist/src/utils/shell-utils.js
|
|
257243
257288
|
import * as readline from "node:readline";
|
|
257244
257289
|
|
|
257245
257290
|
// node_modules/web-tree-sitter/tree-sitter.js
|
|
@@ -264265,7 +264310,7 @@ async function getCommandName(command, args2) {
|
|
|
264265
264310
|
await initializeShellParsers();
|
|
264266
264311
|
const fullCmd = [command, ...args2].join(" ");
|
|
264267
264312
|
const stripped = stripShellWrapper(fullCmd);
|
|
264268
|
-
const roots =
|
|
264313
|
+
const roots = (await getCommandRootsAsync(stripped)).filter((r9) => r9 !== "shopt" && r9 !== "set");
|
|
264269
264314
|
if (roots.length > 0) {
|
|
264270
264315
|
return roots[0];
|
|
264271
264316
|
}
|
|
@@ -264656,7 +264701,51 @@ function parseBashCommandDetails(command) {
|
|
|
264656
264701
|
hasError: hasError2
|
|
264657
264702
|
};
|
|
264658
264703
|
}
|
|
264659
|
-
function
|
|
264704
|
+
function isRawPowerShellCommand(value) {
|
|
264705
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
264706
|
+
}
|
|
264707
|
+
function isRawPowerShellParsePayload(value) {
|
|
264708
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
264709
|
+
}
|
|
264710
|
+
function parsePowerShellParserOutput(rawStdout, originalCommand) {
|
|
264711
|
+
const output = rawStdout.trim();
|
|
264712
|
+
if (!output) {
|
|
264713
|
+
return { details: [], hasError: true };
|
|
264714
|
+
}
|
|
264715
|
+
let parsedUnknown;
|
|
264716
|
+
try {
|
|
264717
|
+
parsedUnknown = JSON.parse(output);
|
|
264718
|
+
} catch {
|
|
264719
|
+
return { details: [], hasError: true };
|
|
264720
|
+
}
|
|
264721
|
+
if (!isRawPowerShellParsePayload(parsedUnknown) || parsedUnknown.success !== true) {
|
|
264722
|
+
return { details: [], hasError: true };
|
|
264723
|
+
}
|
|
264724
|
+
const rawCommandsField = parsedUnknown.commands;
|
|
264725
|
+
const rawCommands = Array.isArray(rawCommandsField) ? rawCommandsField : isRawPowerShellCommand(rawCommandsField) ? [rawCommandsField] : [];
|
|
264726
|
+
const details = rawCommands.map((commandDetail) => {
|
|
264727
|
+
if (!isRawPowerShellCommand(commandDetail) || typeof commandDetail.name !== "string") {
|
|
264728
|
+
return null;
|
|
264729
|
+
}
|
|
264730
|
+
const name3 = normalizeCommandName(commandDetail.name);
|
|
264731
|
+
const text = typeof commandDetail.text === "string" ? commandDetail.text.trim() : originalCommand;
|
|
264732
|
+
const rawArgs = commandDetail.args;
|
|
264733
|
+
return {
|
|
264734
|
+
name: name3,
|
|
264735
|
+
text,
|
|
264736
|
+
startIndex: typeof commandDetail.startIndex === "number" ? commandDetail.startIndex : 0,
|
|
264737
|
+
args: Array.isArray(rawArgs) ? rawArgs.filter((arg) => typeof arg === "string") : void 0
|
|
264738
|
+
};
|
|
264739
|
+
}).filter((detail) => detail !== null).sort((a2, b3) => a2.startIndex - b3.startIndex);
|
|
264740
|
+
return {
|
|
264741
|
+
details,
|
|
264742
|
+
hasError: details.length === 0,
|
|
264743
|
+
hasRedirection: typeof parsedUnknown.hasRedirection === "boolean" ? parsedUnknown.hasRedirection : void 0,
|
|
264744
|
+
hasCommandSubstitution: typeof parsedUnknown.hasCommandSubstitution === "boolean" ? parsedUnknown.hasCommandSubstitution : false
|
|
264745
|
+
};
|
|
264746
|
+
}
|
|
264747
|
+
var globalInFlightPowerShellParses = /* @__PURE__ */ new Map();
|
|
264748
|
+
function parsePowerShellCommandDetails(command, executable, cache2) {
|
|
264660
264749
|
const trimmed = command.trim();
|
|
264661
264750
|
if (!trimmed) {
|
|
264662
264751
|
return {
|
|
@@ -264664,6 +264753,10 @@ function parsePowerShellCommandDetails(command, executable) {
|
|
|
264664
264753
|
hasError: true
|
|
264665
264754
|
};
|
|
264666
264755
|
}
|
|
264756
|
+
const activeCache = cache2 ?? getActiveCommandParseCache();
|
|
264757
|
+
if (activeCache?.hasCompleted(executable, command)) {
|
|
264758
|
+
return activeCache.getCompleted(executable, command) ?? null;
|
|
264759
|
+
}
|
|
264667
264760
|
try {
|
|
264668
264761
|
const result = spawnSync(executable, [
|
|
264669
264762
|
"-NoLogo",
|
|
@@ -264679,49 +264772,126 @@ function parsePowerShellCommandDetails(command, executable) {
|
|
|
264679
264772
|
encoding: "utf-8"
|
|
264680
264773
|
});
|
|
264681
264774
|
if (result.error || result.status !== 0) {
|
|
264775
|
+
activeCache?.setCompleted(executable, command, null);
|
|
264682
264776
|
return null;
|
|
264683
264777
|
}
|
|
264684
|
-
const
|
|
264685
|
-
|
|
264686
|
-
|
|
264778
|
+
const parsed = parsePowerShellParserOutput((result.stdout ?? "").toString(), command);
|
|
264779
|
+
activeCache?.setCompleted(executable, command, parsed);
|
|
264780
|
+
return parsed;
|
|
264781
|
+
} catch {
|
|
264782
|
+
activeCache?.setCompleted(executable, command, null);
|
|
264783
|
+
return null;
|
|
264784
|
+
}
|
|
264785
|
+
}
|
|
264786
|
+
async function parsePowerShellCommandDetailsAsync(command, executable, cache2, signal) {
|
|
264787
|
+
const trimmed = command.trim();
|
|
264788
|
+
if (!trimmed) {
|
|
264789
|
+
return {
|
|
264790
|
+
details: [],
|
|
264791
|
+
hasError: true
|
|
264792
|
+
};
|
|
264793
|
+
}
|
|
264794
|
+
if (signal?.aborted) {
|
|
264795
|
+
return null;
|
|
264796
|
+
}
|
|
264797
|
+
const activeCache = cache2 ?? getActiveCommandParseCache();
|
|
264798
|
+
if (activeCache?.hasCompleted(executable, command)) {
|
|
264799
|
+
return activeCache.getCompleted(executable, command) ?? null;
|
|
264800
|
+
}
|
|
264801
|
+
const existingInFlight = activeCache?.getInFlight(executable, command);
|
|
264802
|
+
if (existingInFlight) {
|
|
264803
|
+
return existingInFlight;
|
|
264804
|
+
}
|
|
264805
|
+
const globalKey = `${executable}\0${command}`;
|
|
264806
|
+
if (!signal) {
|
|
264807
|
+
const existingGlobalInFlight = globalInFlightPowerShellParses.get(globalKey);
|
|
264808
|
+
if (existingGlobalInFlight) {
|
|
264809
|
+
const joinedPromise = existingGlobalInFlight.then((result) => {
|
|
264810
|
+
activeCache?.setCompleted(executable, command, result);
|
|
264811
|
+
return result;
|
|
264812
|
+
});
|
|
264813
|
+
if (activeCache) {
|
|
264814
|
+
return activeCache.trackInFlight(executable, command, joinedPromise);
|
|
264815
|
+
}
|
|
264816
|
+
return joinedPromise;
|
|
264687
264817
|
}
|
|
264688
|
-
|
|
264818
|
+
}
|
|
264819
|
+
const parsePromise = new Promise((resolve30) => {
|
|
264820
|
+
let settled = false;
|
|
264821
|
+
const finish = (value, cacheResult = true) => {
|
|
264822
|
+
if (!settled) {
|
|
264823
|
+
settled = true;
|
|
264824
|
+
if (cacheResult && !signal?.aborted) {
|
|
264825
|
+
activeCache?.setCompleted(executable, command, value);
|
|
264826
|
+
}
|
|
264827
|
+
resolve30(value);
|
|
264828
|
+
}
|
|
264829
|
+
};
|
|
264830
|
+
let child;
|
|
264689
264831
|
try {
|
|
264690
|
-
|
|
264832
|
+
child = spawn(executable, [
|
|
264833
|
+
"-NoLogo",
|
|
264834
|
+
"-NoProfile",
|
|
264835
|
+
"-NonInteractive",
|
|
264836
|
+
"-EncodedCommand",
|
|
264837
|
+
POWERSHELL_PARSER_SCRIPT
|
|
264838
|
+
], {
|
|
264839
|
+
env: {
|
|
264840
|
+
...process.env,
|
|
264841
|
+
[POWERSHELL_COMMAND_ENV]: command
|
|
264842
|
+
},
|
|
264843
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
264844
|
+
windowsHide: true,
|
|
264845
|
+
...signal ? { signal } : {}
|
|
264846
|
+
});
|
|
264691
264847
|
} catch {
|
|
264692
|
-
|
|
264693
|
-
|
|
264694
|
-
if (!parsed?.success) {
|
|
264695
|
-
return { details: [], hasError: true };
|
|
264848
|
+
finish(null, !signal?.aborted);
|
|
264849
|
+
return;
|
|
264696
264850
|
}
|
|
264697
|
-
|
|
264698
|
-
|
|
264699
|
-
|
|
264700
|
-
|
|
264851
|
+
let stdout = "";
|
|
264852
|
+
child.stdout?.setEncoding("utf-8");
|
|
264853
|
+
child.stdout?.on("data", (chunk) => {
|
|
264854
|
+
stdout += chunk.toString();
|
|
264855
|
+
});
|
|
264856
|
+
child.stderr?.on("data", () => {
|
|
264857
|
+
});
|
|
264858
|
+
child.on("error", (err2) => {
|
|
264859
|
+
if (err2.name === "AbortError" || signal?.aborted) {
|
|
264860
|
+
finish(null, false);
|
|
264861
|
+
return;
|
|
264701
264862
|
}
|
|
264702
|
-
|
|
264703
|
-
|
|
264704
|
-
|
|
264705
|
-
|
|
264706
|
-
|
|
264707
|
-
|
|
264708
|
-
|
|
264709
|
-
|
|
264710
|
-
|
|
264711
|
-
|
|
264712
|
-
|
|
264713
|
-
|
|
264714
|
-
|
|
264715
|
-
|
|
264716
|
-
|
|
264717
|
-
|
|
264718
|
-
|
|
264863
|
+
finish(null);
|
|
264864
|
+
});
|
|
264865
|
+
child.on("close", (code) => {
|
|
264866
|
+
if (signal?.aborted) {
|
|
264867
|
+
finish(null, false);
|
|
264868
|
+
return;
|
|
264869
|
+
}
|
|
264870
|
+
if (code !== 0) {
|
|
264871
|
+
finish(null);
|
|
264872
|
+
return;
|
|
264873
|
+
}
|
|
264874
|
+
const parsed = parsePowerShellParserOutput(stdout, command);
|
|
264875
|
+
finish(parsed);
|
|
264876
|
+
});
|
|
264877
|
+
});
|
|
264878
|
+
if (!signal) {
|
|
264879
|
+
globalInFlightPowerShellParses.set(globalKey, parsePromise);
|
|
264880
|
+
void parsePromise.finally(() => {
|
|
264881
|
+
if (globalInFlightPowerShellParses.get(globalKey) === parsePromise) {
|
|
264882
|
+
globalInFlightPowerShellParses.delete(globalKey);
|
|
264883
|
+
}
|
|
264884
|
+
});
|
|
264885
|
+
}
|
|
264886
|
+
if (activeCache) {
|
|
264887
|
+
return activeCache.trackInFlight(executable, command, parsePromise);
|
|
264719
264888
|
}
|
|
264889
|
+
return parsePromise;
|
|
264720
264890
|
}
|
|
264721
|
-
function parseCommandDetails(command) {
|
|
264891
|
+
function parseCommandDetails(command, cache2) {
|
|
264722
264892
|
const configuration = getShellConfiguration();
|
|
264723
264893
|
if (configuration.shell === "powershell") {
|
|
264724
|
-
const result = parsePowerShellCommandDetails(command, configuration.executable);
|
|
264894
|
+
const result = parsePowerShellCommandDetails(command, configuration.executable, cache2);
|
|
264725
264895
|
if (!result || result.hasError) {
|
|
264726
264896
|
if (detectPowerShellSubstitution(command)) {
|
|
264727
264897
|
return result ?? { details: [], hasError: true };
|
|
@@ -264738,6 +264908,38 @@ function parseCommandDetails(command) {
|
|
|
264738
264908
|
}
|
|
264739
264909
|
return null;
|
|
264740
264910
|
}
|
|
264911
|
+
async function parseCommandDetailsAsync(command, cache2, signal) {
|
|
264912
|
+
if (signal?.aborted) {
|
|
264913
|
+
return null;
|
|
264914
|
+
}
|
|
264915
|
+
const configuration = getShellConfiguration();
|
|
264916
|
+
if (configuration.shell === "powershell") {
|
|
264917
|
+
const result = await parsePowerShellCommandDetailsAsync(command, configuration.executable, cache2, signal);
|
|
264918
|
+
if (signal?.aborted) {
|
|
264919
|
+
return null;
|
|
264920
|
+
}
|
|
264921
|
+
if (!result || result.hasError) {
|
|
264922
|
+
if (detectPowerShellSubstitution(command)) {
|
|
264923
|
+
return result ?? { details: [], hasError: true };
|
|
264924
|
+
}
|
|
264925
|
+
await initializeShellParsers();
|
|
264926
|
+
const bashResult = parseBashCommandDetails(command);
|
|
264927
|
+
if (bashResult && !bashResult.hasError) {
|
|
264928
|
+
return bashResult;
|
|
264929
|
+
}
|
|
264930
|
+
}
|
|
264931
|
+
return result;
|
|
264932
|
+
}
|
|
264933
|
+
if (configuration.shell === "bash") {
|
|
264934
|
+
await initializeShellParsers();
|
|
264935
|
+
return parseBashCommandDetails(command);
|
|
264936
|
+
}
|
|
264937
|
+
return null;
|
|
264938
|
+
}
|
|
264939
|
+
var defaultParseCommandDetailsRef = parseCommandDetails;
|
|
264940
|
+
function isDefaultParseCommandDetails(fn3) {
|
|
264941
|
+
return fn3 === defaultParseCommandDetailsRef;
|
|
264942
|
+
}
|
|
264741
264943
|
function getShellConfiguration() {
|
|
264742
264944
|
if (isWindows()) {
|
|
264743
264945
|
const powershellArgsPrefix = ["-NoProfile", "-NonInteractive", "-Command"];
|
|
@@ -264789,34 +264991,61 @@ function escapeShellArg(arg, shell) {
|
|
|
264789
264991
|
return (0, import_shell_quote.quote)([arg]);
|
|
264790
264992
|
}
|
|
264791
264993
|
}
|
|
264792
|
-
function
|
|
264994
|
+
function hasBashTreeRedirection(command, fallbackCheck) {
|
|
264995
|
+
const tree = parseCommandTree(command);
|
|
264996
|
+
if (!tree)
|
|
264997
|
+
return fallbackCheck();
|
|
264998
|
+
const stack = [tree.rootNode];
|
|
264999
|
+
while (stack.length > 0) {
|
|
265000
|
+
const current = stack.pop();
|
|
265001
|
+
if (current.type === "redirected_statement" || current.type === "file_redirect" || current.type === "heredoc_redirect" || current.type === "herestring_redirect") {
|
|
265002
|
+
return true;
|
|
265003
|
+
}
|
|
265004
|
+
for (let i3 = current.childCount - 1; i3 >= 0; i3 -= 1) {
|
|
265005
|
+
const child = current.child(i3);
|
|
265006
|
+
if (child)
|
|
265007
|
+
stack.push(child);
|
|
265008
|
+
}
|
|
265009
|
+
}
|
|
265010
|
+
return false;
|
|
265011
|
+
}
|
|
265012
|
+
function hasRedirection(command, cache2) {
|
|
264793
265013
|
const fallbackCheck = () => /[><]/.test(command);
|
|
264794
265014
|
if (!fallbackCheck()) {
|
|
264795
265015
|
return false;
|
|
264796
265016
|
}
|
|
264797
265017
|
const configuration = getShellConfiguration();
|
|
264798
265018
|
if (configuration.shell === "powershell") {
|
|
264799
|
-
const parsed = parsePowerShellCommandDetails(command, configuration.executable);
|
|
265019
|
+
const parsed = parsePowerShellCommandDetails(command, configuration.executable, cache2);
|
|
264800
265020
|
return parsed && !parsed.hasError ? !!parsed.hasRedirection : fallbackCheck();
|
|
264801
265021
|
}
|
|
264802
265022
|
if (configuration.shell === "bash" && bashLanguage) {
|
|
264803
|
-
|
|
264804
|
-
|
|
264805
|
-
|
|
264806
|
-
|
|
264807
|
-
|
|
264808
|
-
|
|
264809
|
-
|
|
264810
|
-
|
|
264811
|
-
|
|
264812
|
-
|
|
264813
|
-
const child = current.child(i3);
|
|
264814
|
-
if (child)
|
|
264815
|
-
stack.push(child);
|
|
264816
|
-
}
|
|
264817
|
-
}
|
|
265023
|
+
return hasBashTreeRedirection(command, fallbackCheck);
|
|
265024
|
+
}
|
|
265025
|
+
return fallbackCheck();
|
|
265026
|
+
}
|
|
265027
|
+
async function hasRedirectionAsync(command, cache2, signal) {
|
|
265028
|
+
if (signal?.aborted) {
|
|
265029
|
+
return false;
|
|
265030
|
+
}
|
|
265031
|
+
const fallbackCheck = () => /[><]/.test(command);
|
|
265032
|
+
if (!fallbackCheck()) {
|
|
264818
265033
|
return false;
|
|
264819
265034
|
}
|
|
265035
|
+
const configuration = getShellConfiguration();
|
|
265036
|
+
if (configuration.shell === "powershell") {
|
|
265037
|
+
const parsed = await parsePowerShellCommandDetailsAsync(command, configuration.executable, cache2, signal);
|
|
265038
|
+
if (signal?.aborted) {
|
|
265039
|
+
return false;
|
|
265040
|
+
}
|
|
265041
|
+
return parsed && !parsed.hasError ? !!parsed.hasRedirection : fallbackCheck();
|
|
265042
|
+
}
|
|
265043
|
+
if (configuration.shell === "bash") {
|
|
265044
|
+
await initializeShellParsers();
|
|
265045
|
+
if (bashLanguage) {
|
|
265046
|
+
return hasBashTreeRedirection(command, fallbackCheck);
|
|
265047
|
+
}
|
|
265048
|
+
}
|
|
264820
265049
|
return fallbackCheck();
|
|
264821
265050
|
}
|
|
264822
265051
|
var SHELL_EXPANSION_NODE_TYPES = /* @__PURE__ */ new Set([
|
|
@@ -264953,30 +265182,66 @@ function hasUnresolvedShellExpansion(command) {
|
|
|
264953
265182
|
tree.delete();
|
|
264954
265183
|
}
|
|
264955
265184
|
}
|
|
264956
|
-
function splitCommands(command) {
|
|
264957
|
-
const parsed = parseCommandDetails(command);
|
|
265185
|
+
function splitCommands(command, cache2) {
|
|
265186
|
+
const parsed = parseCommandDetails(command, cache2);
|
|
265187
|
+
if (!parsed || parsed.hasError) {
|
|
265188
|
+
return [];
|
|
265189
|
+
}
|
|
265190
|
+
return parsed.details.filter((detail) => !REDIRECTION_NAMES.has(detail.name)).map((detail) => detail.text).filter(Boolean);
|
|
265191
|
+
}
|
|
265192
|
+
async function splitCommandsAsync(command, cache2, signal) {
|
|
265193
|
+
const parsed = await parseCommandDetailsAsync(command, cache2, signal);
|
|
264958
265194
|
if (!parsed || parsed.hasError) {
|
|
264959
265195
|
return [];
|
|
264960
265196
|
}
|
|
264961
265197
|
return parsed.details.filter((detail) => !REDIRECTION_NAMES.has(detail.name)).map((detail) => detail.text).filter(Boolean);
|
|
264962
265198
|
}
|
|
264963
|
-
function getCommandRoot(command) {
|
|
264964
|
-
const parsed = parseCommandDetails(command);
|
|
265199
|
+
function getCommandRoot(command, cache2) {
|
|
265200
|
+
const parsed = parseCommandDetails(command, cache2);
|
|
264965
265201
|
if (!parsed || parsed.hasError || parsed.details.length === 0) {
|
|
264966
265202
|
return void 0;
|
|
264967
265203
|
}
|
|
264968
265204
|
return parsed.details[0]?.name;
|
|
264969
265205
|
}
|
|
264970
|
-
function
|
|
265206
|
+
async function getCommandRootAsync(command, cache2, signal) {
|
|
265207
|
+
const parsed = await parseCommandDetailsAsync(command, cache2, signal);
|
|
265208
|
+
if (!parsed || parsed.hasError || parsed.details.length === 0) {
|
|
265209
|
+
return void 0;
|
|
265210
|
+
}
|
|
265211
|
+
return parsed.details[0]?.name;
|
|
265212
|
+
}
|
|
265213
|
+
function getCommandRoots(command, cache2) {
|
|
265214
|
+
if (!command) {
|
|
265215
|
+
return [];
|
|
265216
|
+
}
|
|
265217
|
+
const parsed = parseCommandDetails(command, cache2);
|
|
265218
|
+
if (!parsed || parsed.hasError) {
|
|
265219
|
+
return [];
|
|
265220
|
+
}
|
|
265221
|
+
return parsed.details.map((detail) => detail.name).filter((name3) => !REDIRECTION_NAMES.has(name3)).filter(Boolean);
|
|
265222
|
+
}
|
|
265223
|
+
async function getCommandRootsAsync(command, cache2, signal) {
|
|
264971
265224
|
if (!command) {
|
|
264972
265225
|
return [];
|
|
264973
265226
|
}
|
|
264974
|
-
const parsed =
|
|
265227
|
+
const parsed = await parseCommandDetailsAsync(command, cache2, signal);
|
|
264975
265228
|
if (!parsed || parsed.hasError) {
|
|
264976
265229
|
return [];
|
|
264977
265230
|
}
|
|
264978
265231
|
return parsed.details.map((detail) => detail.name).filter((name3) => !REDIRECTION_NAMES.has(name3)).filter(Boolean);
|
|
264979
265232
|
}
|
|
265233
|
+
var defaultHasRedirectionRef = hasRedirection;
|
|
265234
|
+
var defaultSplitCommandsRef = splitCommands;
|
|
265235
|
+
var defaultGetCommandRootsRef = getCommandRoots;
|
|
265236
|
+
function isDefaultHasRedirection(fn3) {
|
|
265237
|
+
return fn3 === defaultHasRedirectionRef;
|
|
265238
|
+
}
|
|
265239
|
+
function isDefaultSplitCommands(fn3) {
|
|
265240
|
+
return fn3 === defaultSplitCommandsRef;
|
|
265241
|
+
}
|
|
265242
|
+
function isDefaultGetCommandRoots(fn3) {
|
|
265243
|
+
return fn3 === defaultGetCommandRootsRef;
|
|
265244
|
+
}
|
|
264980
265245
|
var PS_WRAPPER_FLAGS = /* @__PURE__ */ new Set([
|
|
264981
265246
|
"-nologo",
|
|
264982
265247
|
"-noprofile",
|
|
@@ -266218,10 +266483,7 @@ function isInteractiveGeminiSegment(segment) {
|
|
|
266218
266483
|
}
|
|
266219
266484
|
return true;
|
|
266220
266485
|
}
|
|
266221
|
-
function
|
|
266222
|
-
if (!command || !command.trim()) {
|
|
266223
|
-
return false;
|
|
266224
|
-
}
|
|
266486
|
+
function unwrapCommandForGeminiCheck(command) {
|
|
266225
266487
|
let unwrapped = command.trim();
|
|
266226
266488
|
for (let depth = 0; depth < 3; depth++) {
|
|
266227
266489
|
const next = stripShellWrapper(unwrapped);
|
|
@@ -266230,10 +266492,59 @@ function isInteractiveGeminiCommand(command) {
|
|
|
266230
266492
|
}
|
|
266231
266493
|
unwrapped = next;
|
|
266232
266494
|
}
|
|
266233
|
-
|
|
266495
|
+
return unwrapped;
|
|
266496
|
+
}
|
|
266497
|
+
var GEMINI_SUBSEQUENCE = "gemini";
|
|
266498
|
+
function containsGeminiSubsequence(input) {
|
|
266499
|
+
const lower = input.toLowerCase();
|
|
266500
|
+
let pos = 0;
|
|
266501
|
+
for (const ch of GEMINI_SUBSEQUENCE) {
|
|
266502
|
+
const found = lower.indexOf(ch, pos);
|
|
266503
|
+
if (found === -1) {
|
|
266504
|
+
return false;
|
|
266505
|
+
}
|
|
266506
|
+
pos = found + 1;
|
|
266507
|
+
}
|
|
266508
|
+
return true;
|
|
266509
|
+
}
|
|
266510
|
+
function isKnownInteractiveGeminiCommandSync(command) {
|
|
266511
|
+
if (!command || !command.trim()) {
|
|
266512
|
+
return false;
|
|
266513
|
+
}
|
|
266514
|
+
const unwrapped = unwrapCommandForGeminiCheck(command);
|
|
266515
|
+
if (!containsGeminiSubsequence(unwrapped)) {
|
|
266516
|
+
return false;
|
|
266517
|
+
}
|
|
266234
266518
|
const fallbackSegments = splitShellCommandSegments(unwrapped);
|
|
266235
|
-
|
|
266236
|
-
|
|
266519
|
+
if (fallbackSegments.some((segment) => isInteractiveGeminiSegment(segment))) {
|
|
266520
|
+
return true;
|
|
266521
|
+
}
|
|
266522
|
+
return void 0;
|
|
266523
|
+
}
|
|
266524
|
+
function isInteractiveGeminiCommand(command, cache2) {
|
|
266525
|
+
const fastResult = isKnownInteractiveGeminiCommandSync(command);
|
|
266526
|
+
if (fastResult !== void 0) {
|
|
266527
|
+
return fastResult;
|
|
266528
|
+
}
|
|
266529
|
+
const unwrapped = unwrapCommandForGeminiCheck(command);
|
|
266530
|
+
const parsedSegments = splitCommands(unwrapped, cache2);
|
|
266531
|
+
return parsedSegments.some((segment) => isInteractiveGeminiSegment(segment));
|
|
266532
|
+
}
|
|
266533
|
+
async function isInteractiveGeminiCommandAsync(command, cache2, signal) {
|
|
266534
|
+
if (signal?.aborted) {
|
|
266535
|
+
return false;
|
|
266536
|
+
}
|
|
266537
|
+
const fastResult = isKnownInteractiveGeminiCommandSync(command);
|
|
266538
|
+
if (fastResult !== void 0) {
|
|
266539
|
+
return fastResult;
|
|
266540
|
+
}
|
|
266541
|
+
const unwrapped = unwrapCommandForGeminiCheck(command);
|
|
266542
|
+
const parsedSegments = await splitCommandsAsync(unwrapped, cache2, signal);
|
|
266543
|
+
return parsedSegments.some((segment) => isInteractiveGeminiSegment(segment));
|
|
266544
|
+
}
|
|
266545
|
+
var defaultIsInteractiveGeminiCommandRef = isInteractiveGeminiCommand;
|
|
266546
|
+
function isDefaultIsInteractiveGeminiCommand(fn3) {
|
|
266547
|
+
return fn3 === defaultIsInteractiveGeminiCommandRef;
|
|
266237
266548
|
}
|
|
266238
266549
|
|
|
266239
266550
|
// packages/core/dist/src/sandbox/utils/commandSafety.js
|
|
@@ -266807,7 +267118,7 @@ async function isStrictlyApproved(command, args2, approvedTools, cwd, workspaceR
|
|
|
266807
267118
|
await initializeShellParsers();
|
|
266808
267119
|
const fullCmd = [command, ...args2].join(" ");
|
|
266809
267120
|
const stripped = stripShellWrapper(fullCmd);
|
|
266810
|
-
const pipelineCommands = splitCommands(stripped);
|
|
267121
|
+
const pipelineCommands = isDefaultSplitCommands(splitCommands) ? await splitCommandsAsync(stripped) : splitCommands(stripped);
|
|
266811
267122
|
if (pipelineCommands.length === 0) {
|
|
266812
267123
|
return tools.includes(command) || isKnownSafeCommand2([command, ...args2], cwd, workspaceRoot);
|
|
266813
267124
|
}
|
|
@@ -267301,35 +267612,38 @@ async function isStrictlyApproved2(req, approvedTools) {
|
|
|
267301
267612
|
if (!approvedTools || approvedTools.length === 0) {
|
|
267302
267613
|
return false;
|
|
267303
267614
|
}
|
|
267304
|
-
|
|
267305
|
-
|
|
267306
|
-
|
|
267307
|
-
|
|
267308
|
-
|
|
267309
|
-
|
|
267310
|
-
const allRootsApproved = roots.every((root) => approvedTools.includes(root));
|
|
267311
|
-
if (allRootsApproved) {
|
|
267312
|
-
return true;
|
|
267313
|
-
}
|
|
267314
|
-
if (hasUnresolvedShellExpansion(stripped)) {
|
|
267315
|
-
return false;
|
|
267316
|
-
}
|
|
267317
|
-
const pipelineCommands = splitCommands(stripped);
|
|
267318
|
-
if (pipelineCommands.length === 0)
|
|
267319
|
-
return false;
|
|
267320
|
-
for (const cmdString of pipelineCommands) {
|
|
267321
|
-
const parsedArgs = (0, import_shell_quote4.parse)(cmdString).map(String);
|
|
267322
|
-
if (!isKnownSafeCommand(parsedArgs)) {
|
|
267615
|
+
return runWithCommandParseCache(async () => {
|
|
267616
|
+
await initializeShellParsers();
|
|
267617
|
+
const fullCmd = [req.command, ...req.args].join(" ");
|
|
267618
|
+
const stripped = stripShellWrapper(fullCmd);
|
|
267619
|
+
const roots = isDefaultGetCommandRoots(getCommandRoots) ? await getCommandRootsAsync(stripped) : getCommandRoots(stripped);
|
|
267620
|
+
if (roots.length === 0)
|
|
267323
267621
|
return false;
|
|
267622
|
+
const allRootsApproved = roots.every((root) => approvedTools.includes(root));
|
|
267623
|
+
if (allRootsApproved) {
|
|
267624
|
+
return true;
|
|
267324
267625
|
}
|
|
267325
|
-
|
|
267326
|
-
|
|
267626
|
+
if (hasUnresolvedShellExpansion(stripped)) {
|
|
267627
|
+
return false;
|
|
267628
|
+
}
|
|
267629
|
+
const pipelineCommands = isDefaultSplitCommands(splitCommands) ? await splitCommandsAsync(stripped) : splitCommands(stripped);
|
|
267630
|
+
if (pipelineCommands.length === 0)
|
|
267631
|
+
return false;
|
|
267632
|
+
for (const cmdString of pipelineCommands) {
|
|
267633
|
+
const parsedArgs = (0, import_shell_quote4.parse)(cmdString).map(String);
|
|
267634
|
+
if (!isKnownSafeCommand(parsedArgs)) {
|
|
267635
|
+
return false;
|
|
267636
|
+
}
|
|
267637
|
+
}
|
|
267638
|
+
return true;
|
|
267639
|
+
});
|
|
267327
267640
|
}
|
|
267328
267641
|
async function getCommandName2(req) {
|
|
267329
267642
|
await initializeShellParsers();
|
|
267330
267643
|
const fullCmd = [req.command, ...req.args].join(" ");
|
|
267331
267644
|
const stripped = stripShellWrapper(fullCmd);
|
|
267332
|
-
const
|
|
267645
|
+
const computedRoots = isDefaultGetCommandRoots(getCommandRoots) ? await getCommandRootsAsync(stripped) : getCommandRoots(stripped);
|
|
267646
|
+
const roots = computedRoots.filter((r9) => r9 !== "shopt" && r9 !== "set");
|
|
267333
267647
|
if (roots.length > 0) {
|
|
267334
267648
|
return roots[0];
|
|
267335
267649
|
}
|
|
@@ -268597,6 +268911,9 @@ var WindowsSandboxManager = class _WindowsSandboxManager {
|
|
|
268597
268911
|
* Prepares a command for sandboxed execution on Windows.
|
|
268598
268912
|
*/
|
|
268599
268913
|
async prepareCommand(req) {
|
|
268914
|
+
return runWithCommandParseCache(() => this.prepareCommandInternal(req));
|
|
268915
|
+
}
|
|
268916
|
+
async prepareCommandInternal(req) {
|
|
268600
268917
|
await this.ensureHelperCompiled();
|
|
268601
268918
|
const sanitizationConfig = getSecureSanitizationConfig(req.policy?.sanitizationConfig);
|
|
268602
268919
|
const sanitizedEnv = sanitizeEnvironment(req.env, sanitizationConfig);
|
|
@@ -268631,7 +268948,8 @@ var WindowsSandboxManager = class _WindowsSandboxManager {
|
|
|
268631
268948
|
await initializeShellParsers();
|
|
268632
268949
|
const fullCmd = [command, ...args2].join(" ");
|
|
268633
268950
|
const stripped = stripShellWrapper(fullCmd);
|
|
268634
|
-
const
|
|
268951
|
+
const computedRoots = isDefaultGetCommandRoots(getCommandRoots) ? await getCommandRootsAsync(stripped) : getCommandRoots(stripped);
|
|
268952
|
+
const roots = computedRoots.filter((r9) => r9 !== "shopt" && r9 !== "set");
|
|
268635
268953
|
const isGitCommand = roots.includes("git");
|
|
268636
268954
|
const resolvedPaths = await resolveSandboxPaths(this.options, req, mergedAdditional);
|
|
268637
268955
|
this.ensureGovernanceFilesExist(resolvedPaths.workspace.resolved);
|
|
@@ -295062,8 +295380,8 @@ function isValidToolName(name3, options = {}) {
|
|
|
295062
295380
|
}
|
|
295063
295381
|
|
|
295064
295382
|
// packages/core/dist/src/generated/git-commit.js
|
|
295065
|
-
var GIT_COMMIT_INFO = "
|
|
295066
|
-
var CLI_VERSION = "0.
|
|
295383
|
+
var GIT_COMMIT_INFO = "808199f5c";
|
|
295384
|
+
var CLI_VERSION = "0.71.0-preview.0";
|
|
295067
295385
|
|
|
295068
295386
|
// packages/core/dist/src/ide/detect-ide.js
|
|
295069
295387
|
var IDE_DEFINITIONS = {
|
|
@@ -327681,7 +327999,7 @@ function getVersion() {
|
|
|
327681
327999
|
}
|
|
327682
328000
|
versionPromise = (async () => {
|
|
327683
328001
|
const pkgJson = await getPackageJson(__dirname4);
|
|
327684
|
-
return "0.
|
|
328002
|
+
return "0.71.0-preview.0";
|
|
327685
328003
|
})();
|
|
327686
328004
|
return versionPromise;
|
|
327687
328005
|
}
|
|
@@ -329537,8 +329855,8 @@ var BaseLlmClient = class {
|
|
|
329537
329855
|
};
|
|
329538
329856
|
|
|
329539
329857
|
// packages/core/dist/src/utils/promptIdContext.js
|
|
329540
|
-
import { AsyncLocalStorage } from "node:async_hooks";
|
|
329541
|
-
var promptIdContext = new
|
|
329858
|
+
import { AsyncLocalStorage as AsyncLocalStorage2 } from "node:async_hooks";
|
|
329859
|
+
var promptIdContext = new AsyncLocalStorage2();
|
|
329542
329860
|
function getPromptIdWithFallback(componentName) {
|
|
329543
329861
|
const promptId = promptIdContext.getStore();
|
|
329544
329862
|
if (promptId) {
|
|
@@ -330220,25 +330538,18 @@ function findUntrustedFlags(command, untrustedContext, options) {
|
|
|
330220
330538
|
}
|
|
330221
330539
|
return Array.from(detected);
|
|
330222
330540
|
}
|
|
330223
|
-
function
|
|
330224
|
-
if (!command) {
|
|
330225
|
-
return false;
|
|
330226
|
-
}
|
|
330541
|
+
function evaluateBuildOrTestCommandFromRoots(command, roots) {
|
|
330227
330542
|
const getBaseName = (cmd) => {
|
|
330228
330543
|
const base2 = cmd.replace(/\\/g, "/").split("/").pop();
|
|
330229
330544
|
if (!base2)
|
|
330230
330545
|
return cmd.toLowerCase();
|
|
330231
330546
|
return base2.toLowerCase().replace(/\.(exe|cmd|bat)$/, "");
|
|
330232
330547
|
};
|
|
330233
|
-
|
|
330234
|
-
|
|
330235
|
-
|
|
330236
|
-
return
|
|
330237
|
-
|
|
330238
|
-
return BUILD_TEST_COMMAND_ROOTS.has(base2) || BUILD_TEST_COMMAND_ROOTS.has(root2.toLowerCase());
|
|
330239
|
-
});
|
|
330240
|
-
}
|
|
330241
|
-
} catch {
|
|
330548
|
+
if (roots.length > 0) {
|
|
330549
|
+
return roots.some((root2) => {
|
|
330550
|
+
const base2 = getBaseName(root2);
|
|
330551
|
+
return BUILD_TEST_COMMAND_ROOTS.has(base2) || BUILD_TEST_COMMAND_ROOTS.has(root2.toLowerCase());
|
|
330552
|
+
});
|
|
330242
330553
|
}
|
|
330243
330554
|
const parts2 = command.trim().split(/\s+/);
|
|
330244
330555
|
let rootIndex = 0;
|
|
@@ -330251,18 +330562,33 @@ function isBuildOrTestCommand(command) {
|
|
|
330251
330562
|
const base = getBaseName(root);
|
|
330252
330563
|
return BUILD_TEST_COMMAND_ROOTS.has(base) || BUILD_TEST_COMMAND_ROOTS.has(root.toLowerCase());
|
|
330253
330564
|
}
|
|
330254
|
-
function
|
|
330565
|
+
function isBuildOrTestCommand(command) {
|
|
330255
330566
|
if (!command) {
|
|
330256
330567
|
return false;
|
|
330257
330568
|
}
|
|
330258
330569
|
let roots = [];
|
|
330259
330570
|
try {
|
|
330260
|
-
roots = getCommandRoots(command)
|
|
330571
|
+
roots = getCommandRoots(command);
|
|
330261
330572
|
} catch {
|
|
330262
330573
|
}
|
|
330574
|
+
return evaluateBuildOrTestCommandFromRoots(command, roots);
|
|
330575
|
+
}
|
|
330576
|
+
function evaluateRemoteContentCommandFromRoots(command, rawRoots) {
|
|
330577
|
+
const roots = rawRoots.map((root) => normalizeCommand(root));
|
|
330263
330578
|
const candidates = roots.length === 0 || roots.some((root) => COMMAND_WRAPPER_ROOTS.has(root)) ? command.trim().split(/[\s;&|()]+/).map((word) => normalizeCommand(word)) : roots;
|
|
330264
330579
|
return candidates.some((name3) => REMOTE_CONTENT_COMMAND_ROOTS.has(name3));
|
|
330265
330580
|
}
|
|
330581
|
+
async function isRemoteContentCommandAsync(command) {
|
|
330582
|
+
if (!command) {
|
|
330583
|
+
return false;
|
|
330584
|
+
}
|
|
330585
|
+
let rawRoots = [];
|
|
330586
|
+
try {
|
|
330587
|
+
rawRoots = isDefaultGetCommandRoots(getCommandRoots) ? await getCommandRootsAsync(command) : getCommandRoots(command);
|
|
330588
|
+
} catch {
|
|
330589
|
+
}
|
|
330590
|
+
return evaluateRemoteContentCommandFromRoots(command, rawRoots);
|
|
330591
|
+
}
|
|
330266
330592
|
var MODIFIED_BUILD_FILES_SYMBOL = Symbol("sessionModifiedBuildFiles");
|
|
330267
330593
|
var ACKNOWLEDGED_UNTRUSTED_FLAGS_SYMBOL = Symbol("sessionAcknowledgedUntrustedFlags");
|
|
330268
330594
|
function hasSessionRecord(sessionKey) {
|
|
@@ -342955,8 +343281,8 @@ ${truncated}`;
|
|
|
342955
343281
|
};
|
|
342956
343282
|
|
|
342957
343283
|
// packages/core/dist/src/utils/toolCallContext.js
|
|
342958
|
-
import { AsyncLocalStorage as
|
|
342959
|
-
var toolCallContext = new
|
|
343284
|
+
import { AsyncLocalStorage as AsyncLocalStorage3 } from "node:async_hooks";
|
|
343285
|
+
var toolCallContext = new AsyncLocalStorage3();
|
|
342960
343286
|
function runWithToolCallContext(context2, fn3) {
|
|
342961
343287
|
return toolCallContext.run(context2, fn3);
|
|
342962
343288
|
}
|
|
@@ -343115,10 +343441,51 @@ var ShellToolInvocation = class extends BaseToolInvocation {
|
|
|
343115
343441
|
context;
|
|
343116
343442
|
proactivePermissionsConfirmed;
|
|
343117
343443
|
confirmedCommand;
|
|
343444
|
+
parseCache = new CommandParseCache();
|
|
343118
343445
|
constructor(context2, params, messageBus, _toolName, _toolDisplayName) {
|
|
343119
343446
|
super(params, messageBus, _toolName, _toolDisplayName);
|
|
343120
343447
|
this.context = context2;
|
|
343121
343448
|
}
|
|
343449
|
+
runInCommandParseCache(fn3) {
|
|
343450
|
+
return runWithCommandParseCache(fn3, this.parseCache);
|
|
343451
|
+
}
|
|
343452
|
+
async prepareCommandParseCache(signal) {
|
|
343453
|
+
if (signal?.aborted || typeof stripShellWrapper !== "function" || !isDefaultParseCommandDetails(parseCommandDetails)) {
|
|
343454
|
+
return;
|
|
343455
|
+
}
|
|
343456
|
+
const rawCommand = this.params.command;
|
|
343457
|
+
const stripped = stripShellWrapper(rawCommand);
|
|
343458
|
+
let unwrapped = stripped;
|
|
343459
|
+
for (let depth = 0; depth < 3; depth++) {
|
|
343460
|
+
const next = stripShellWrapper(unwrapped);
|
|
343461
|
+
if (next === unwrapped) {
|
|
343462
|
+
break;
|
|
343463
|
+
}
|
|
343464
|
+
unwrapped = next;
|
|
343465
|
+
}
|
|
343466
|
+
await parseCommandDetailsAsync(stripped, this.parseCache, signal);
|
|
343467
|
+
if (unwrapped !== stripped && !signal?.aborted) {
|
|
343468
|
+
await parseCommandDetailsAsync(unwrapped, this.parseCache, signal);
|
|
343469
|
+
}
|
|
343470
|
+
}
|
|
343471
|
+
hasCachedCommandParse(command) {
|
|
343472
|
+
if (typeof getShellConfiguration !== "function") {
|
|
343473
|
+
return false;
|
|
343474
|
+
}
|
|
343475
|
+
const configuration = getShellConfiguration();
|
|
343476
|
+
if (configuration.shell !== "powershell") {
|
|
343477
|
+
return true;
|
|
343478
|
+
}
|
|
343479
|
+
let unwrapped = command.trim();
|
|
343480
|
+
for (let depth = 0; depth < 3; depth++) {
|
|
343481
|
+
const next = stripShellWrapper(unwrapped);
|
|
343482
|
+
if (next === unwrapped) {
|
|
343483
|
+
break;
|
|
343484
|
+
}
|
|
343485
|
+
unwrapped = next;
|
|
343486
|
+
}
|
|
343487
|
+
return this.parseCache.hasCompleted(configuration.executable, command) && this.parseCache.hasCompleted(configuration.executable, unwrapped);
|
|
343488
|
+
}
|
|
343122
343489
|
/**
|
|
343123
343490
|
* Wraps a command in a subshell to capture background process IDs (PIDs)
|
|
343124
343491
|
* using an EXIT trap. Uses newlines to prevent breaking heredocs or trailing
|
|
@@ -343278,185 +343645,200 @@ exit $__code`;
|
|
|
343278
343645
|
return getUnacknowledgedUntrustedFlags(untrustedFlags, roots, config2);
|
|
343279
343646
|
}
|
|
343280
343647
|
hasTaintedOrBuildFileRisk() {
|
|
343281
|
-
|
|
343282
|
-
|
|
343283
|
-
|
|
343284
|
-
|
|
343285
|
-
|
|
343648
|
+
return this.runInCommandParseCache(() => {
|
|
343649
|
+
const command = stripShellWrapper(this.params.command);
|
|
343650
|
+
const untrustedFlags = this.getUntrustedFlags(command);
|
|
343651
|
+
const modifiedBuildFiles = getModifiedBuildFiles(this.context.config);
|
|
343652
|
+
const isBuildCmd = isBuildOrTestCommand(command);
|
|
343653
|
+
return untrustedFlags.length > 0 || isBuildCmd && modifiedBuildFiles.length > 0;
|
|
343654
|
+
});
|
|
343286
343655
|
}
|
|
343287
343656
|
getPolicyUpdateOptions(outcome) {
|
|
343288
|
-
|
|
343289
|
-
|
|
343290
|
-
|
|
343291
|
-
|
|
343292
|
-
|
|
343293
|
-
|
|
343294
|
-
|
|
343295
|
-
|
|
343296
|
-
|
|
343657
|
+
return this.runInCommandParseCache(() => {
|
|
343658
|
+
if (outcome === ToolConfirmationOutcome.ProceedAlwaysAndSave || outcome === ToolConfirmationOutcome.ProceedAlways) {
|
|
343659
|
+
const command = stripShellWrapper(this.params.command);
|
|
343660
|
+
if (this.hasTaintedOrBuildFileRisk()) {
|
|
343661
|
+
return void 0;
|
|
343662
|
+
}
|
|
343663
|
+
const rootCommands = [...new Set(getCommandRoots(command))];
|
|
343664
|
+
const allowRedirection = hasRedirection(command) ? true : void 0;
|
|
343665
|
+
const allowCommandSubstitution = detectCommandSubstitution(command) ? true : void 0;
|
|
343666
|
+
if (rootCommands.length > 0) {
|
|
343667
|
+
return {
|
|
343668
|
+
commandPrefix: rootCommands,
|
|
343669
|
+
allowRedirection,
|
|
343670
|
+
...allowCommandSubstitution !== void 0 ? { allowCommandSubstitution } : {}
|
|
343671
|
+
};
|
|
343672
|
+
}
|
|
343297
343673
|
return {
|
|
343298
|
-
commandPrefix:
|
|
343674
|
+
commandPrefix: this.params.command,
|
|
343299
343675
|
allowRedirection,
|
|
343300
343676
|
...allowCommandSubstitution !== void 0 ? { allowCommandSubstitution } : {}
|
|
343301
343677
|
};
|
|
343302
343678
|
}
|
|
343303
|
-
return
|
|
343304
|
-
|
|
343305
|
-
allowRedirection,
|
|
343306
|
-
...allowCommandSubstitution !== void 0 ? { allowCommandSubstitution } : {}
|
|
343307
|
-
};
|
|
343308
|
-
}
|
|
343309
|
-
return void 0;
|
|
343679
|
+
return void 0;
|
|
343680
|
+
});
|
|
343310
343681
|
}
|
|
343311
343682
|
async shouldConfirmExecute(abortSignal, forcedDecision) {
|
|
343312
|
-
|
|
343313
|
-
|
|
343314
|
-
|
|
343315
|
-
|
|
343316
|
-
|
|
343317
|
-
|
|
343318
|
-
|
|
343319
|
-
|
|
343320
|
-
|
|
343321
|
-
|
|
343322
|
-
|
|
343323
|
-
|
|
343324
|
-
|
|
343325
|
-
|
|
343326
|
-
|
|
343327
|
-
|
|
343328
|
-
|
|
343329
|
-
|
|
343330
|
-
|
|
343331
|
-
if (
|
|
343332
|
-
const
|
|
343333
|
-
const
|
|
343334
|
-
|
|
343335
|
-
|
|
343336
|
-
const
|
|
343337
|
-
const
|
|
343338
|
-
|
|
343339
|
-
|
|
343340
|
-
|
|
343341
|
-
|
|
343342
|
-
|
|
343343
|
-
|
|
343344
|
-
const
|
|
343345
|
-
|
|
343346
|
-
|
|
343347
|
-
|
|
343348
|
-
|
|
343349
|
-
|
|
343350
|
-
|
|
343351
|
-
|
|
343352
|
-
|
|
343353
|
-
|
|
343354
|
-
|
|
343355
|
-
|
|
343356
|
-
|
|
343683
|
+
return this.runInCommandParseCache(async () => {
|
|
343684
|
+
await this.prepareCommandParseCache(abortSignal);
|
|
343685
|
+
const strippedForInteractiveCheck = stripShellWrapper(this.params.command);
|
|
343686
|
+
const isInteractive = isDefaultIsInteractiveGeminiCommand(isInteractiveGeminiCommand) ? await isInteractiveGeminiCommandAsync(strippedForInteractiveCheck, this.parseCache, abortSignal) : isInteractiveGeminiCommand(strippedForInteractiveCheck);
|
|
343687
|
+
if (isInteractive) {
|
|
343688
|
+
return false;
|
|
343689
|
+
}
|
|
343690
|
+
if (forcedDecision === "deny") {
|
|
343691
|
+
return super.shouldConfirmExecute(abortSignal, forcedDecision);
|
|
343692
|
+
}
|
|
343693
|
+
if (this.hasTaintedOrBuildFileRisk()) {
|
|
343694
|
+
return this.getConfirmationDetails(abortSignal);
|
|
343695
|
+
}
|
|
343696
|
+
if (this.context.config.getApprovalMode() === ApprovalMode.YOLO && forcedDecision !== "ask_user") {
|
|
343697
|
+
return super.shouldConfirmExecute(abortSignal, forcedDecision);
|
|
343698
|
+
}
|
|
343699
|
+
if (this.params[PARAM_ADDITIONAL_PERMISSIONS]) {
|
|
343700
|
+
return this.getConfirmationDetails(abortSignal);
|
|
343701
|
+
}
|
|
343702
|
+
if (this.context.config.getSandboxEnabled()) {
|
|
343703
|
+
const command = stripShellWrapper(this.params.command);
|
|
343704
|
+
const rootCommands = isDefaultGetCommandRoots(getCommandRoots) ? await getCommandRootsAsync(command, this.parseCache, abortSignal) : getCommandRoots(command);
|
|
343705
|
+
const rawRootCommand = rootCommands[0];
|
|
343706
|
+
if (rawRootCommand) {
|
|
343707
|
+
const rootCommand = normalizeCommand(rawRootCommand);
|
|
343708
|
+
const proactive = await getProactiveToolSuggestions(rootCommand);
|
|
343709
|
+
if (proactive) {
|
|
343710
|
+
const mode = this.context.config.getApprovalMode();
|
|
343711
|
+
const modeConfig = this.context.config.sandboxPolicyManager.getModeConfig(mode);
|
|
343712
|
+
const approved = this.context.config.sandboxPolicyManager.getCommandPermissions(rootCommand);
|
|
343713
|
+
const hasNetwork = modeConfig.network || approved.network;
|
|
343714
|
+
const missingNetwork = !!proactive.network && !hasNetwork;
|
|
343715
|
+
const parsed = isDefaultParseCommandDetails(parseCommandDetails) ? await parseCommandDetailsAsync(command, this.parseCache, abortSignal) : parseCommandDetails(command);
|
|
343716
|
+
const subCommand = parsed?.details[0]?.args?.[0];
|
|
343717
|
+
const needsNetwork = isNetworkReliantCommand(rootCommand, subCommand);
|
|
343718
|
+
if (needsNetwork) {
|
|
343719
|
+
const isReadonlyMode = modeConfig.readonly ?? false;
|
|
343720
|
+
if (isReadonlyMode) {
|
|
343721
|
+
const cwd = this.params.dir_path || this.context.config.getTargetDir();
|
|
343722
|
+
proactive.fileSystem = proactive.fileSystem || {
|
|
343723
|
+
read: [],
|
|
343724
|
+
write: []
|
|
343725
|
+
};
|
|
343726
|
+
proactive.fileSystem.write = proactive.fileSystem.write || [];
|
|
343727
|
+
if (!proactive.fileSystem.write.includes(cwd)) {
|
|
343728
|
+
proactive.fileSystem.write.push(cwd);
|
|
343729
|
+
proactive.fileSystem.read = proactive.fileSystem.read || [];
|
|
343730
|
+
if (!proactive.fileSystem.read.includes(cwd)) {
|
|
343731
|
+
proactive.fileSystem.read.push(cwd);
|
|
343732
|
+
}
|
|
343357
343733
|
}
|
|
343358
343734
|
}
|
|
343359
|
-
|
|
343360
|
-
|
|
343361
|
-
|
|
343362
|
-
|
|
343363
|
-
|
|
343364
|
-
|
|
343365
|
-
|
|
343366
|
-
|
|
343367
|
-
}
|
|
343368
|
-
|
|
343369
|
-
|
|
343370
|
-
|
|
343371
|
-
|
|
343372
|
-
|
|
343373
|
-
|
|
343374
|
-
|
|
343375
|
-
|
|
343376
|
-
|
|
343377
|
-
|
|
343378
|
-
|
|
343379
|
-
|
|
343380
|
-
}
|
|
343381
|
-
}
|
|
343735
|
+
const isApproved = (requestedPath, approvedPaths) => {
|
|
343736
|
+
if (!approvedPaths || approvedPaths.length === 0)
|
|
343737
|
+
return false;
|
|
343738
|
+
const requestedRealIdentity = toPathKey(resolveToRealPath(requestedPath));
|
|
343739
|
+
return approvedPaths.some((p2) => {
|
|
343740
|
+
const approvedRealIdentity = toPathKey(resolveToRealPath(p2));
|
|
343741
|
+
return requestedRealIdentity === approvedRealIdentity || isSubpath(approvedRealIdentity, requestedRealIdentity);
|
|
343742
|
+
});
|
|
343743
|
+
};
|
|
343744
|
+
const missingRead = (proactive.fileSystem?.read || []).filter((p2) => !isApproved(p2, approved.fileSystem?.read));
|
|
343745
|
+
const missingWrite = (proactive.fileSystem?.write || []).filter((p2) => !isApproved(p2, approved.fileSystem?.write));
|
|
343746
|
+
const needsExpansion = missingRead.length > 0 || missingWrite.length > 0 || missingNetwork;
|
|
343747
|
+
if (needsExpansion) {
|
|
343748
|
+
const details = await this.getConfirmationDetails(abortSignal, proactive);
|
|
343749
|
+
if (details && details.type === "sandbox_expansion") {
|
|
343750
|
+
const originalOnConfirm = details.onConfirm;
|
|
343751
|
+
details.onConfirm = async (outcome) => {
|
|
343752
|
+
await originalOnConfirm(outcome);
|
|
343753
|
+
if (outcome !== ToolConfirmationOutcome.Cancel) {
|
|
343754
|
+
this.proactivePermissionsConfirmed = proactive;
|
|
343755
|
+
}
|
|
343756
|
+
};
|
|
343757
|
+
}
|
|
343758
|
+
return details;
|
|
343382
343759
|
}
|
|
343383
|
-
return details;
|
|
343384
343760
|
}
|
|
343385
343761
|
}
|
|
343386
343762
|
}
|
|
343387
343763
|
}
|
|
343388
|
-
|
|
343389
|
-
|
|
343764
|
+
return super.shouldConfirmExecute(abortSignal, forcedDecision);
|
|
343765
|
+
});
|
|
343390
343766
|
}
|
|
343391
|
-
async getConfirmationDetails(
|
|
343392
|
-
|
|
343393
|
-
|
|
343394
|
-
|
|
343395
|
-
|
|
343396
|
-
|
|
343397
|
-
|
|
343398
|
-
|
|
343399
|
-
rootCommandDisplay
|
|
343767
|
+
async getConfirmationDetails(abortSignal, proactivePermissions) {
|
|
343768
|
+
return this.runInCommandParseCache(async () => {
|
|
343769
|
+
const command = stripShellWrapper(this.params.command);
|
|
343770
|
+
const parsed = isDefaultParseCommandDetails(parseCommandDetails) ? await parseCommandDetailsAsync(command, this.parseCache, abortSignal) : parseCommandDetails(command);
|
|
343771
|
+
const commandHasRedirection = isDefaultHasRedirection(hasRedirection) ? await hasRedirectionAsync(command, this.parseCache, abortSignal) : hasRedirection(command);
|
|
343772
|
+
let rootCommandDisplay = "";
|
|
343773
|
+
if (!parsed || parsed.hasError || parsed.details.length === 0) {
|
|
343774
|
+
const fallback = command.trim().split(/\s+/)[0];
|
|
343775
|
+
rootCommandDisplay = fallback || "shell command";
|
|
343776
|
+
if (commandHasRedirection) {
|
|
343777
|
+
rootCommandDisplay += ", redirection";
|
|
343778
|
+
}
|
|
343779
|
+
} else {
|
|
343780
|
+
rootCommandDisplay = parsed.details.map((detail) => detail.name).join(", ");
|
|
343400
343781
|
}
|
|
343401
|
-
|
|
343402
|
-
|
|
343403
|
-
|
|
343404
|
-
|
|
343405
|
-
|
|
343406
|
-
|
|
343407
|
-
|
|
343408
|
-
|
|
343409
|
-
|
|
343410
|
-
|
|
343411
|
-
|
|
343412
|
-
|
|
343413
|
-
|
|
343414
|
-
|
|
343415
|
-
|
|
343416
|
-
|
|
343417
|
-
|
|
343418
|
-
|
|
343419
|
-
|
|
343782
|
+
let rootCommands = [];
|
|
343783
|
+
try {
|
|
343784
|
+
const computedRoots = isDefaultGetCommandRoots(getCommandRoots) ? await getCommandRootsAsync(command, this.parseCache, abortSignal) : getCommandRoots(command);
|
|
343785
|
+
rootCommands = [...new Set(computedRoots)];
|
|
343786
|
+
} catch {
|
|
343787
|
+
rootCommands = [command.trim().split(/\s+/)[0] || "shell"];
|
|
343788
|
+
}
|
|
343789
|
+
const rootCommand = rootCommands[0] || "shell";
|
|
343790
|
+
const untrustedFlags = this.getUntrustedFlags(command);
|
|
343791
|
+
const modifiedBuildFiles = getModifiedBuildFiles(this.context.config);
|
|
343792
|
+
const isBuildCmd = isBuildOrTestCommand(command);
|
|
343793
|
+
const hasSecurityWarning = untrustedFlags.length > 0 || isBuildCmd && modifiedBuildFiles.length > 0;
|
|
343794
|
+
const effectiveAdditionalPermissions = this.params[PARAM_ADDITIONAL_PERMISSIONS] || proactivePermissions;
|
|
343795
|
+
if (effectiveAdditionalPermissions && !hasSecurityWarning) {
|
|
343796
|
+
return {
|
|
343797
|
+
type: "sandbox_expansion",
|
|
343798
|
+
title: proactivePermissions ? "Sandbox Expansion Request (Recommended)" : "Sandbox Expansion Request",
|
|
343799
|
+
command: this.params.command,
|
|
343800
|
+
rootCommand: rootCommandDisplay,
|
|
343801
|
+
additionalPermissions: effectiveAdditionalPermissions,
|
|
343802
|
+
onConfirm: async (outcome) => {
|
|
343803
|
+
if (outcome !== ToolConfirmationOutcome.Cancel && outcome !== ToolConfirmationOutcome.ModifyWithEditor) {
|
|
343804
|
+
this.confirmedCommand = this.params.command;
|
|
343805
|
+
}
|
|
343806
|
+
if (outcome === ToolConfirmationOutcome.ProceedAlwaysAndSave) {
|
|
343807
|
+
this.context.config.sandboxPolicyManager.addPersistentApproval(rootCommand, effectiveAdditionalPermissions);
|
|
343808
|
+
} else if (outcome === ToolConfirmationOutcome.ProceedAlways) {
|
|
343809
|
+
this.context.config.sandboxPolicyManager.addSessionApproval(rootCommand, effectiveAdditionalPermissions);
|
|
343810
|
+
}
|
|
343811
|
+
}
|
|
343812
|
+
};
|
|
343813
|
+
}
|
|
343814
|
+
const confirmationDetails = {
|
|
343815
|
+
type: "exec",
|
|
343816
|
+
title: "Confirm Shell Command",
|
|
343420
343817
|
command: this.params.command,
|
|
343421
343818
|
rootCommand: rootCommandDisplay,
|
|
343422
|
-
|
|
343819
|
+
rootCommands,
|
|
343820
|
+
hasRedirection: commandHasRedirection,
|
|
343821
|
+
untrustedFlags: untrustedFlags.length > 0 ? untrustedFlags : void 0,
|
|
343822
|
+
modifiedBuildFiles: isBuildCmd && modifiedBuildFiles.length > 0 ? modifiedBuildFiles : void 0,
|
|
343423
343823
|
onConfirm: async (outcome) => {
|
|
343424
|
-
if (outcome
|
|
343425
|
-
|
|
343824
|
+
if (outcome === ToolConfirmationOutcome.Cancel || outcome === ToolConfirmationOutcome.ModifyWithEditor) {
|
|
343825
|
+
return;
|
|
343426
343826
|
}
|
|
343427
|
-
|
|
343428
|
-
|
|
343429
|
-
|
|
343430
|
-
this.context.config
|
|
343827
|
+
this.confirmedCommand = this.params.command;
|
|
343828
|
+
acknowledgeUntrustedFlags(untrustedFlags, rootCommands, this.context.config);
|
|
343829
|
+
if (isBuildCmd && modifiedBuildFiles.length > 0) {
|
|
343830
|
+
resetModifiedBuildFiles(this.context.config);
|
|
343431
343831
|
}
|
|
343432
343832
|
}
|
|
343433
343833
|
};
|
|
343434
|
-
|
|
343435
|
-
|
|
343436
|
-
type: "exec",
|
|
343437
|
-
title: "Confirm Shell Command",
|
|
343438
|
-
command: this.params.command,
|
|
343439
|
-
rootCommand: rootCommandDisplay,
|
|
343440
|
-
rootCommands,
|
|
343441
|
-
untrustedFlags: untrustedFlags.length > 0 ? untrustedFlags : void 0,
|
|
343442
|
-
modifiedBuildFiles: isBuildCmd && modifiedBuildFiles.length > 0 ? modifiedBuildFiles : void 0,
|
|
343443
|
-
onConfirm: async (outcome) => {
|
|
343444
|
-
if (outcome === ToolConfirmationOutcome.Cancel || outcome === ToolConfirmationOutcome.ModifyWithEditor) {
|
|
343445
|
-
return;
|
|
343446
|
-
}
|
|
343447
|
-
this.confirmedCommand = this.params.command;
|
|
343448
|
-
acknowledgeUntrustedFlags(untrustedFlags, rootCommands, this.context.config);
|
|
343449
|
-
if (isBuildCmd && modifiedBuildFiles.length > 0) {
|
|
343450
|
-
resetModifiedBuildFiles(this.context.config);
|
|
343451
|
-
}
|
|
343452
|
-
}
|
|
343453
|
-
};
|
|
343454
|
-
return confirmationDetails;
|
|
343834
|
+
return confirmationDetails;
|
|
343835
|
+
});
|
|
343455
343836
|
}
|
|
343456
343837
|
async isCommandSubstitutionAllowed(options) {
|
|
343457
343838
|
if ((options.isClientInitiated ?? false) || (options.isUserConfirmed ?? false) || this.confirmedCommand === this.params.command) {
|
|
343458
343839
|
return true;
|
|
343459
343840
|
}
|
|
343841
|
+
await this.prepareCommandParseCache(options.abortSignal);
|
|
343460
343842
|
if (this.hasTaintedOrBuildFileRisk()) {
|
|
343461
343843
|
return false;
|
|
343462
343844
|
}
|
|
@@ -343472,9 +343854,21 @@ exit $__code`;
|
|
|
343472
343854
|
return this.context.config?.getApprovalMode?.() === ApprovalMode.YOLO;
|
|
343473
343855
|
}
|
|
343474
343856
|
async execute(options) {
|
|
343857
|
+
return this.runInCommandParseCache(() => this.executeInternal(options));
|
|
343858
|
+
}
|
|
343859
|
+
async executeInternal(options) {
|
|
343475
343860
|
const { abortSignal: signal, updateOutput, shellExecutionConfig, setExecutionIdCallback } = options;
|
|
343476
343861
|
const strippedCommand = stripShellWrapper(this.params.command);
|
|
343477
|
-
|
|
343862
|
+
let isInteractiveGemini;
|
|
343863
|
+
if (!isDefaultIsInteractiveGeminiCommand(isInteractiveGeminiCommand)) {
|
|
343864
|
+
isInteractiveGemini = isInteractiveGeminiCommand(strippedCommand);
|
|
343865
|
+
} else if (this.hasCachedCommandParse(strippedCommand)) {
|
|
343866
|
+
isInteractiveGemini = isInteractiveGeminiCommand(strippedCommand, this.parseCache);
|
|
343867
|
+
} else {
|
|
343868
|
+
const knownInteractive = isKnownInteractiveGeminiCommandSync(strippedCommand);
|
|
343869
|
+
isInteractiveGemini = knownInteractive ?? await isInteractiveGeminiCommandAsync(strippedCommand, this.parseCache, signal);
|
|
343870
|
+
}
|
|
343871
|
+
if (isInteractiveGemini) {
|
|
343478
343872
|
return {
|
|
343479
343873
|
llmContent: INTERACTIVE_GEMINI_SHELL_ERROR,
|
|
343480
343874
|
returnDisplay: INTERACTIVE_GEMINI_SHELL_ERROR,
|
|
@@ -343812,7 +344206,8 @@ ${result.output}`;
|
|
|
343812
344206
|
const sandboxDenial = this.context.config.sandboxManager.parseDenials(result);
|
|
343813
344207
|
if (sandboxDenial) {
|
|
343814
344208
|
const strippedCommand2 = stripShellWrapper(this.params.command);
|
|
343815
|
-
const
|
|
344209
|
+
const computedRootCommands = isDefaultGetCommandRoots(getCommandRoots) ? await getCommandRootsAsync(strippedCommand2, this.parseCache) : getCommandRoots(strippedCommand2);
|
|
344210
|
+
const rootCommands = computedRootCommands.filter((r9) => r9 !== "shopt");
|
|
343816
344211
|
const rootCommandDisplay = rootCommands.length > 0 ? rootCommands[0] : "shell";
|
|
343817
344212
|
const readPaths = new Set(this.params[PARAM_ADDITIONAL_PERMISSIONS]?.fileSystem?.read || []);
|
|
343818
344213
|
const writePaths = new Set(this.params[PARAM_ADDITIONAL_PERMISSIONS]?.fileSystem?.write || []);
|
|
@@ -343900,7 +344295,7 @@ ${result.output}`;
|
|
|
343900
344295
|
}
|
|
343901
344296
|
}
|
|
343902
344297
|
const summarizeConfig = this.context.config.getSummarizeToolOutputConfig();
|
|
343903
|
-
const outputSource =
|
|
344298
|
+
const outputSource = await isRemoteContentCommandAsync(strippedCommand) ? REMOTE_SHELL_OUTPUT_SOURCE : void 0;
|
|
343904
344299
|
const executionError = result.error ? {
|
|
343905
344300
|
error: {
|
|
343906
344301
|
message: result.error.message,
|
|
@@ -360317,7 +360712,7 @@ var A2AAuthProviderFactory = class _A2AAuthProviderFactory {
|
|
|
360317
360712
|
return provider;
|
|
360318
360713
|
}
|
|
360319
360714
|
case "oauth2": {
|
|
360320
|
-
const { OAuth2AuthProvider } = await import("./oauth2-provider-
|
|
360715
|
+
const { OAuth2AuthProvider } = await import("./oauth2-provider-S7DQJKA5.js");
|
|
360321
360716
|
const provider = new OAuth2AuthProvider(authConfig, options.agentName ?? "unknown", agentCard, options.agentCardUrl);
|
|
360322
360717
|
await provider.initialize();
|
|
360323
360718
|
return provider;
|
|
@@ -362026,6 +362421,9 @@ function isAutoEditTransition(tool, outcome) {
|
|
|
362026
362421
|
}
|
|
362027
362422
|
async function handleStandardPolicyUpdate(tool, outcome, confirmationDetails, messageBus, persistScope, toolInvocation, config2, modes) {
|
|
362028
362423
|
if (outcome === ToolConfirmationOutcome.ProceedAlways || outcome === ToolConfirmationOutcome.ProceedAlwaysAndSave) {
|
|
362424
|
+
if (typeof toolInvocation === "object" && toolInvocation !== null && "prepareCommandParseCache" in toolInvocation && typeof toolInvocation.prepareCommandParseCache === "function") {
|
|
362425
|
+
await toolInvocation.prepareCommandParseCache();
|
|
362426
|
+
}
|
|
362029
362427
|
const options = toolInvocation?.getPolicyUpdateOptions?.(outcome) || {};
|
|
362030
362428
|
if (!options.commandPrefix && confirmationDetails?.type === "exec") {
|
|
362031
362429
|
options.commandPrefix = confirmationDetails.rootCommands;
|
|
@@ -367722,6 +368120,15 @@ var ToolModificationHandler = class {
|
|
|
367722
368120
|
};
|
|
367723
368121
|
|
|
367724
368122
|
// packages/core/dist/src/scheduler/scheduler.js
|
|
368123
|
+
function isCommandParseCacheAware(invocation) {
|
|
368124
|
+
return typeof invocation === "object" && invocation !== null && "runInCommandParseCache" in invocation && typeof invocation.runInCommandParseCache === "function" && "prepareCommandParseCache" in invocation && typeof invocation.prepareCommandParseCache === "function";
|
|
368125
|
+
}
|
|
368126
|
+
function runWithInvocationParseCache(invocation, fn3) {
|
|
368127
|
+
if (isCommandParseCacheAware(invocation)) {
|
|
368128
|
+
return invocation.runInCommandParseCache(fn3);
|
|
368129
|
+
}
|
|
368130
|
+
return runWithCommandParseCache(fn3);
|
|
368131
|
+
}
|
|
367725
368132
|
function isTaintRiskDetectable(invocation) {
|
|
367726
368133
|
return typeof invocation === "object" && invocation !== null && "hasTaintedOrBuildFileRisk" in invocation && typeof invocation.hasTaintedOrBuildFileRisk === "function";
|
|
367727
368134
|
}
|
|
@@ -368085,57 +368492,62 @@ var Scheduler = class {
|
|
|
368085
368492
|
toolCall.request.inputModifiedByHook = true;
|
|
368086
368493
|
toolCall.invocation = newInvocation;
|
|
368087
368494
|
}
|
|
368088
|
-
|
|
368089
|
-
|
|
368090
|
-
|
|
368091
|
-
|
|
368092
|
-
|
|
368093
|
-
|
|
368094
|
-
|
|
368095
|
-
|
|
368096
|
-
|
|
368097
|
-
|
|
368098
|
-
|
|
368099
|
-
|
|
368100
|
-
|
|
368101
|
-
|
|
368102
|
-
|
|
368103
|
-
|
|
368104
|
-
|
|
368105
|
-
|
|
368106
|
-
|
|
368107
|
-
|
|
368108
|
-
|
|
368109
|
-
|
|
368110
|
-
|
|
368111
|
-
|
|
368112
|
-
|
|
368113
|
-
|
|
368114
|
-
|
|
368115
|
-
|
|
368116
|
-
|
|
368117
|
-
|
|
368118
|
-
|
|
368119
|
-
|
|
368120
|
-
|
|
368121
|
-
|
|
368122
|
-
|
|
368123
|
-
|
|
368495
|
+
await runWithInvocationParseCache(toolCall.invocation, async () => {
|
|
368496
|
+
const { decision: policyDecision, rule } = await checkPolicy(toolCall, this.config, this.subagent);
|
|
368497
|
+
let decision = policyDecision;
|
|
368498
|
+
if (hookDecision === "ask") {
|
|
368499
|
+
decision = PolicyDecision.ASK_USER;
|
|
368500
|
+
}
|
|
368501
|
+
if (isCommandParseCacheAware(toolCall.invocation)) {
|
|
368502
|
+
await toolCall.invocation.prepareCommandParseCache(signal);
|
|
368503
|
+
}
|
|
368504
|
+
const hasTaintRisk = isTaintRiskDetectable(toolCall.invocation) && toolCall.invocation.hasTaintedOrBuildFileRisk();
|
|
368505
|
+
if (decision === PolicyDecision.ALLOW && hasTaintRisk) {
|
|
368506
|
+
decision = this.config.isInteractive?.() ?? true ? PolicyDecision.ASK_USER : PolicyDecision.DENY;
|
|
368507
|
+
}
|
|
368508
|
+
if (decision === PolicyDecision.DENY) {
|
|
368509
|
+
const { errorMessage, errorType } = getPolicyDenialError(this.config, rule);
|
|
368510
|
+
this.state.updateStatus(callId, CoreToolCallStatus.Error, createErrorResponse(toolCall.request, new Error(errorMessage), errorType));
|
|
368511
|
+
return;
|
|
368512
|
+
}
|
|
368513
|
+
let outcome = ToolConfirmationOutcome.ProceedOnce;
|
|
368514
|
+
let lastDetails;
|
|
368515
|
+
if (decision === PolicyDecision.ASK_USER) {
|
|
368516
|
+
const forcedDecision = hookDecision === "ask" || policyDecision === PolicyDecision.ALLOW && hasTaintRisk ? "ask_user" : void 0;
|
|
368517
|
+
const result = await resolveConfirmation(toolCall, signal, {
|
|
368518
|
+
config: this.config,
|
|
368519
|
+
messageBus: this.messageBus,
|
|
368520
|
+
state: this.state,
|
|
368521
|
+
modifier: this.modifier,
|
|
368522
|
+
getPreferredEditor: this.getPreferredEditor,
|
|
368523
|
+
schedulerId: this.schedulerId,
|
|
368524
|
+
onWaitingForConfirmation: this.onWaitingForConfirmation,
|
|
368525
|
+
systemMessage: hookSystemMessage,
|
|
368526
|
+
forcedDecision
|
|
368527
|
+
});
|
|
368528
|
+
outcome = result.outcome;
|
|
368529
|
+
lastDetails = result.lastDetails;
|
|
368530
|
+
if ((result.confirmedByUser ?? false) && outcome !== ToolConfirmationOutcome.Cancel) {
|
|
368531
|
+
toolCall.request.isUserConfirmed = true;
|
|
368532
|
+
const updatedCall = this.state.getToolCall(callId);
|
|
368533
|
+
if (updatedCall) {
|
|
368534
|
+
updatedCall.request.isUserConfirmed = true;
|
|
368535
|
+
}
|
|
368124
368536
|
}
|
|
368125
368537
|
}
|
|
368126
|
-
|
|
368127
|
-
|
|
368128
|
-
|
|
368129
|
-
await updatePolicy(toolCall.tool, outcome, lastDetails, this.context, this.messageBus, toolCall.invocation);
|
|
368130
|
-
}
|
|
368131
|
-
if (outcome === ToolConfirmationOutcome.Cancel) {
|
|
368132
|
-
this.state.updateStatus(callId, CoreToolCallStatus.Cancelled, "User denied execution.");
|
|
368133
|
-
if (this.cancelAllQueuedOnCancel) {
|
|
368134
|
-
this.state.cancelAllQueued("User cancelled operation");
|
|
368538
|
+
this.state.setOutcome(callId, outcome);
|
|
368539
|
+
if (decision === PolicyDecision.ASK_USER && outcome) {
|
|
368540
|
+
await updatePolicy(toolCall.tool, outcome, lastDetails, this.context, this.messageBus, toolCall.invocation);
|
|
368135
368541
|
}
|
|
368136
|
-
|
|
368137
|
-
|
|
368138
|
-
|
|
368542
|
+
if (outcome === ToolConfirmationOutcome.Cancel) {
|
|
368543
|
+
this.state.updateStatus(callId, CoreToolCallStatus.Cancelled, "User denied execution.");
|
|
368544
|
+
if (this.cancelAllQueuedOnCancel) {
|
|
368545
|
+
this.state.cancelAllQueued("User cancelled operation");
|
|
368546
|
+
}
|
|
368547
|
+
return;
|
|
368548
|
+
}
|
|
368549
|
+
this.state.updateStatus(callId, CoreToolCallStatus.Scheduled);
|
|
368550
|
+
});
|
|
368139
368551
|
}
|
|
368140
368552
|
// --- Sub-phase Handlers ---
|
|
368141
368553
|
/**
|
|
@@ -368515,7 +368927,7 @@ ${wrapInput(safeInput)}`;
|
|
|
368515
368927
|
}
|
|
368516
368928
|
|
|
368517
368929
|
// packages/core/dist/src/config/scoped-config.js
|
|
368518
|
-
import { AsyncLocalStorage as
|
|
368930
|
+
import { AsyncLocalStorage as AsyncLocalStorage4 } from "node:async_hooks";
|
|
368519
368931
|
import * as path73 from "node:path";
|
|
368520
368932
|
|
|
368521
368933
|
// packages/core/dist/src/utils/workspaceContext.js
|
|
@@ -368709,9 +369121,9 @@ var WorkspaceContext = class {
|
|
|
368709
369121
|
};
|
|
368710
369122
|
|
|
368711
369123
|
// packages/core/dist/src/config/scoped-config.js
|
|
368712
|
-
var workspaceContextOverride = new
|
|
368713
|
-
var memoryInboxAccessOverride = new
|
|
368714
|
-
var autoMemoryExtractionWriteAccessOverride = new
|
|
369124
|
+
var workspaceContextOverride = new AsyncLocalStorage4();
|
|
369125
|
+
var memoryInboxAccessOverride = new AsyncLocalStorage4();
|
|
369126
|
+
var autoMemoryExtractionWriteAccessOverride = new AsyncLocalStorage4();
|
|
368715
369127
|
function getWorkspaceContextOverride() {
|
|
368716
369128
|
return workspaceContextOverride.getStore();
|
|
368717
369129
|
}
|
|
@@ -381920,10 +382332,11 @@ var PolicyEngine = class {
|
|
|
381920
382332
|
isAlwaysAllowRule(rule) {
|
|
381921
382333
|
return rule.priority !== void 0 && Math.round(rule.priority % 1 * 1e3) === ALWAYS_ALLOW_PRIORITY_FRACTION;
|
|
381922
382334
|
}
|
|
381923
|
-
shouldDowngradeForRedirection(command, allowRedirection, rule) {
|
|
382335
|
+
async shouldDowngradeForRedirection(command, allowRedirection, rule) {
|
|
381924
382336
|
if (allowRedirection)
|
|
381925
382337
|
return false;
|
|
381926
|
-
|
|
382338
|
+
const redirected = isDefaultHasRedirection(hasRedirection) ? await hasRedirectionAsync(command) : hasRedirection(command);
|
|
382339
|
+
if (!redirected)
|
|
381927
382340
|
return false;
|
|
381928
382341
|
if (rule?.argsPattern && !allowRedirection) {
|
|
381929
382342
|
return true;
|
|
@@ -382005,7 +382418,7 @@ var PolicyEngine = class {
|
|
|
382005
382418
|
};
|
|
382006
382419
|
}
|
|
382007
382420
|
await initializeShellParsers();
|
|
382008
|
-
const parsed = parseCommandDetails(command);
|
|
382421
|
+
const parsed = isDefaultParseCommandDetails(parseCommandDetails) ? await parseCommandDetailsAsync(command) : parseCommandDetails(command);
|
|
382009
382422
|
const subCommands = parsed?.details ?? [];
|
|
382010
382423
|
if (subCommands.length === 0 || parsed?.hasError) {
|
|
382011
382424
|
if (ruleDecision === PolicyDecision.DENY) {
|
|
@@ -382033,7 +382446,7 @@ var PolicyEngine = class {
|
|
|
382033
382446
|
}
|
|
382034
382447
|
let aggregateDecision = ruleDecision;
|
|
382035
382448
|
let responsibleRule = rule && ruleDecision === rule.decision ? rule : void 0;
|
|
382036
|
-
const hasTopLevelRedirectionDowngrade = this.shouldDowngradeForRedirection(command, allowRedirection, rule);
|
|
382449
|
+
const hasTopLevelRedirectionDowngrade = await this.shouldDowngradeForRedirection(command, allowRedirection, rule);
|
|
382037
382450
|
if (hasTopLevelRedirectionDowngrade) {
|
|
382038
382451
|
if (aggregateDecision === PolicyDecision.ALLOW) {
|
|
382039
382452
|
debugLogger.debug(`[PolicyEngine.check] Downgrading ALLOW to ASK_USER for redirected command: ${command}`);
|
|
@@ -382092,7 +382505,7 @@ var PolicyEngine = class {
|
|
|
382092
382505
|
}
|
|
382093
382506
|
aggregateDecision = PolicyDecision.ASK_USER;
|
|
382094
382507
|
}
|
|
382095
|
-
if (subResult.decision === PolicyDecision.ALLOW && (this.shouldDowngradeForRedirection(subCmd, subResult.rule?.allowRedirection ?? allowRedirection, subResult.rule) || this.shouldDowngradeForCommandSubstitution(subCmd, subResult.rule?.allowCommandSubstitution ?? rule?.allowCommandSubstitution, subResult.rule))) {
|
|
382508
|
+
if (subResult.decision === PolicyDecision.ALLOW && (await this.shouldDowngradeForRedirection(subCmd, subResult.rule?.allowRedirection ?? allowRedirection, subResult.rule) || this.shouldDowngradeForCommandSubstitution(subCmd, subResult.rule?.allowCommandSubstitution ?? rule?.allowCommandSubstitution, subResult.rule))) {
|
|
382096
382509
|
allSubCommandsExplicitlyAllowed = false;
|
|
382097
382510
|
if (aggregateDecision === PolicyDecision.ALLOW) {
|
|
382098
382511
|
aggregateDecision = PolicyDecision.ASK_USER;
|
|
@@ -382128,6 +382541,9 @@ var PolicyEngine = class {
|
|
|
382128
382541
|
* Returns the decision and the matching rule (if any).
|
|
382129
382542
|
*/
|
|
382130
382543
|
async check(toolCall, serverName, toolAnnotations, subagent, skipHeuristics = false) {
|
|
382544
|
+
return runWithCommandParseCache(() => this.checkInternal(toolCall, serverName, toolAnnotations, subagent, skipHeuristics));
|
|
382545
|
+
}
|
|
382546
|
+
async checkInternal(toolCall, serverName, toolAnnotations, subagent, skipHeuristics = false) {
|
|
382131
382547
|
if (!serverName && isMcpToolAnnotation(toolAnnotations)) {
|
|
382132
382548
|
serverName = toolAnnotations._serverName;
|
|
382133
382549
|
}
|
|
@@ -418048,6 +418464,9 @@ export {
|
|
|
418048
418464
|
external_exports,
|
|
418049
418465
|
debugLogger,
|
|
418050
418466
|
require_shell_quote,
|
|
418467
|
+
CommandParseCache,
|
|
418468
|
+
getActiveCommandParseCache,
|
|
418469
|
+
runWithCommandParseCache,
|
|
418051
418470
|
ToolErrorType,
|
|
418052
418471
|
isFatalToolError,
|
|
418053
418472
|
GEMINI_DIR,
|
|
@@ -418166,19 +418585,31 @@ export {
|
|
|
418166
418585
|
normalizeCommand,
|
|
418167
418586
|
parseBashCommandDetails,
|
|
418168
418587
|
parseCommandDetails,
|
|
418588
|
+
parseCommandDetailsAsync,
|
|
418589
|
+
isDefaultParseCommandDetails,
|
|
418169
418590
|
getShellConfiguration,
|
|
418170
418591
|
isWindows,
|
|
418171
418592
|
escapeShellArg,
|
|
418172
418593
|
hasRedirection,
|
|
418594
|
+
hasRedirectionAsync,
|
|
418173
418595
|
hasUnresolvedShellExpansion,
|
|
418174
418596
|
splitCommands,
|
|
418597
|
+
splitCommandsAsync,
|
|
418175
418598
|
getCommandRoot,
|
|
418599
|
+
getCommandRootAsync,
|
|
418176
418600
|
getCommandRoots,
|
|
418601
|
+
getCommandRootsAsync,
|
|
418602
|
+
isDefaultHasRedirection,
|
|
418603
|
+
isDefaultSplitCommands,
|
|
418604
|
+
isDefaultGetCommandRoots,
|
|
418177
418605
|
stripShellWrapper,
|
|
418178
418606
|
spawnAsync,
|
|
418179
418607
|
execStreaming,
|
|
418180
418608
|
detectCommandSubstitution,
|
|
418609
|
+
isKnownInteractiveGeminiCommandSync,
|
|
418181
418610
|
isInteractiveGeminiCommand,
|
|
418611
|
+
isInteractiveGeminiCommandAsync,
|
|
418612
|
+
isDefaultIsInteractiveGeminiCommand,
|
|
418182
418613
|
import_fixed_deque,
|
|
418183
418614
|
import_lru_cache,
|
|
418184
418615
|
import_lru_map_with_delete,
|