@sema-agent/core 1.444.0 → 1.445.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/dist/tools/fs/index.js +30 -0
- package/package.json +1 -1
package/dist/tools/fs/index.js
CHANGED
|
@@ -1300,6 +1300,36 @@ export function classifyCompoundReadonly(command, allow) {
|
|
|
1300
1300
|
const nonOption = toks.slice(1).filter((t) => !t.startsWith("-"));
|
|
1301
1301
|
if (!(pipeFed[si] ?? false)) {
|
|
1302
1302
|
const floor = STDIN_FILE_FLOOR[name];
|
|
1303
|
+
const restArgs = toks.slice(1);
|
|
1304
|
+
const grepPatternSuppliedByFlag = name === "grep" && restArgs.some((t) => t === "-e" || t.startsWith("-e") || t === "-f" || t.startsWith("--regexp") || t.startsWith("--file"));
|
|
1305
|
+
let sawNonFlagOperand = false;
|
|
1306
|
+
let hasStdinDash = false;
|
|
1307
|
+
if (name !== "tr") {
|
|
1308
|
+
for (let k = 0; k < restArgs.length; k++) {
|
|
1309
|
+
const t = restArgs[k];
|
|
1310
|
+
if (name === "cut" && (t === "-d" || t === "--delimiter")) {
|
|
1311
|
+
k++;
|
|
1312
|
+
continue;
|
|
1313
|
+
}
|
|
1314
|
+
if (name === "grep" && (t === "-f-" || t === "--file=-")) {
|
|
1315
|
+
hasStdinDash = true;
|
|
1316
|
+
break;
|
|
1317
|
+
}
|
|
1318
|
+
if (t.startsWith("-") && t !== "-")
|
|
1319
|
+
continue;
|
|
1320
|
+
const isGrepPatternPosition = name === "grep" && !grepPatternSuppliedByFlag && !sawNonFlagOperand;
|
|
1321
|
+
sawNonFlagOperand = true;
|
|
1322
|
+
if (isGrepPatternPosition)
|
|
1323
|
+
continue;
|
|
1324
|
+
if (t === "-") {
|
|
1325
|
+
hasStdinDash = true;
|
|
1326
|
+
break;
|
|
1327
|
+
}
|
|
1328
|
+
}
|
|
1329
|
+
}
|
|
1330
|
+
if (floor !== undefined && hasStdinDash) {
|
|
1331
|
+
return `"${name}" reads stdin via an explicit "-" argument and would block until the tool timeout — not auto-allowed`;
|
|
1332
|
+
}
|
|
1303
1333
|
if (floor !== undefined && nonOption.length < floor) {
|
|
1304
1334
|
return `"${name}" with no file argument reads stdin and would block until the tool timeout — not auto-allowed`;
|
|
1305
1335
|
}
|