Revert "PIPE: Add pipe support for passing data into and out of terminal commands (#2395)" (#2524)

This reverts commit 92b8b58588.

Accidental merge on my part - the code is in decent shape, but isn't meant to go in for 3.0.
This commit is contained in:
David Walker
2026-02-22 11:28:10 -08:00
committed by GitHub
parent 92b8b58588
commit 8f4313b180
68 changed files with 479 additions and 2429 deletions
+68 -75
View File
@@ -16,7 +16,6 @@ import { Page } from "../ui/Router";
import { knowAboutBitverse } from "../BitNode/BitNodeUtils";
import { handleStormSeed } from "../DarkNet/effects/webstorm";
import { clampNumber } from "../utils/helpers/clampNumber";
import type { StdIO } from "../Terminal/StdIO/StdIO";
function requireHackingLevel(lvl: number) {
return function () {
@@ -34,7 +33,7 @@ function bitFlumeRequirements() {
};
}
function warnIfNonArgProgramIsRunWithArgs(name: CompletedProgramName, args: string[], stdIO: StdIO): void {
function warnIfNonArgProgramIsRunWithArgs(name: CompletedProgramName, args: string[]): void {
if (args.length === 0) {
return;
}
@@ -42,7 +41,6 @@ function warnIfNonArgProgramIsRunWithArgs(name: CompletedProgramName, args: stri
`You are running ${name} with arguments, but ${name} does not accept arguments. These arguments will be ignored. ` +
`${name} only affects the server ('${Player.currentServer}') that you are connecting via the terminal. ` +
"If you want to pass the target's hostname as an argument, you have to use the respective NS API.",
stdIO,
);
}
@@ -56,25 +54,25 @@ export const Programs: Record<CompletedProgramName, Program> = {
req: requireHackingLevel(1),
time: CONSTANTS.MillisecondsPerFiveMinutes,
},
run: (args: string[], server: BaseServer, stdIO: StdIO): void => {
warnIfNonArgProgramIsRunWithArgs(CompletedProgramName.nuke, args, stdIO);
run: (args: string[], server: BaseServer): void => {
warnIfNonArgProgramIsRunWithArgs(CompletedProgramName.nuke, args);
if (!(server instanceof Server)) {
Terminal.error("Cannot nuke this kind of server.", stdIO);
Terminal.error("Cannot nuke this kind of server.");
return;
}
if (server.hasAdminRights) {
Terminal.print("You already have root access to this computer. There is no reason to run NUKE.exe", stdIO);
Terminal.print("You can now run scripts on this server.", stdIO);
Terminal.print("You already have root access to this computer. There is no reason to run NUKE.exe");
Terminal.print("You can now run scripts on this server.");
return;
}
if (server.openPortCount >= server.numOpenPortsRequired) {
server.hasAdminRights = true;
Terminal.print("NUKE successful! Gained root access to " + server.hostname, stdIO);
Terminal.print("You can now run scripts on this server.", stdIO);
Terminal.print("NUKE successful! Gained root access to " + server.hostname);
Terminal.print("You can now run scripts on this server.");
return;
}
Terminal.print("NUKE unsuccessful. Not enough ports have been opened", stdIO);
Terminal.print("NUKE unsuccessful. Not enough ports have been opened");
},
}),
[CompletedProgramName.bruteSsh]: new Program({
@@ -86,19 +84,19 @@ export const Programs: Record<CompletedProgramName, Program> = {
req: requireHackingLevel(50),
time: CONSTANTS.MillisecondsPerFiveMinutes * 2,
},
run: (args: string[], server: BaseServer, stdIO: StdIO): void => {
warnIfNonArgProgramIsRunWithArgs(CompletedProgramName.bruteSsh, args, stdIO);
run: (args: string[], server: BaseServer): void => {
warnIfNonArgProgramIsRunWithArgs(CompletedProgramName.bruteSsh, args);
if (!(server instanceof Server)) {
Terminal.error("Cannot run BruteSSH.exe on this kind of server.", stdIO);
Terminal.error("Cannot run BruteSSH.exe on this kind of server.");
return;
}
if (server.sshPortOpen) {
Terminal.print("SSH Port (22) is already open!", stdIO);
Terminal.print("SSH Port (22) is already open!");
return;
}
server.sshPortOpen = true;
Terminal.print("Opened SSH Port(22)!", stdIO);
Terminal.print("Opened SSH Port(22)!");
server.openPortCount++;
},
}),
@@ -111,19 +109,19 @@ export const Programs: Record<CompletedProgramName, Program> = {
req: requireHackingLevel(100),
time: CONSTANTS.MillisecondsPerHalfHour,
},
run: (args: string[], server: BaseServer, stdIO: StdIO): void => {
warnIfNonArgProgramIsRunWithArgs(CompletedProgramName.ftpCrack, args, stdIO);
run: (args: string[], server: BaseServer): void => {
warnIfNonArgProgramIsRunWithArgs(CompletedProgramName.ftpCrack, args);
if (!(server instanceof Server)) {
Terminal.error("Cannot run FTPCrack.exe on this kind of server.", stdIO);
Terminal.error("Cannot run FTPCrack.exe on this kind of server.");
return;
}
if (server.ftpPortOpen) {
Terminal.print("FTP Port (21) is already open!", stdIO);
Terminal.print("FTP Port (21) is already open!");
return;
}
server.ftpPortOpen = true;
Terminal.print("Opened FTP Port (21)!", stdIO);
Terminal.print("Opened FTP Port (21)!");
server.openPortCount++;
},
}),
@@ -136,19 +134,19 @@ export const Programs: Record<CompletedProgramName, Program> = {
req: requireHackingLevel(250),
time: CONSTANTS.MillisecondsPer2Hours,
},
run: (args: string[], server: BaseServer, stdIO: StdIO): void => {
warnIfNonArgProgramIsRunWithArgs(CompletedProgramName.relaySmtp, args, stdIO);
run: (args: string[], server: BaseServer): void => {
warnIfNonArgProgramIsRunWithArgs(CompletedProgramName.relaySmtp, args);
if (!(server instanceof Server)) {
Terminal.error("Cannot run relaySMTP.exe on this kind of server.", stdIO);
Terminal.error("Cannot run relaySMTP.exe on this kind of server.");
return;
}
if (server.smtpPortOpen) {
Terminal.print("SMTP Port (25) is already open!", stdIO);
Terminal.print("SMTP Port (25) is already open!");
return;
}
server.smtpPortOpen = true;
Terminal.print("Opened SMTP Port (25)!", stdIO);
Terminal.print("Opened SMTP Port (25)!");
server.openPortCount++;
},
}),
@@ -161,19 +159,19 @@ export const Programs: Record<CompletedProgramName, Program> = {
req: requireHackingLevel(500),
time: CONSTANTS.MillisecondsPer4Hours,
},
run: (args: string[], server: BaseServer, stdIO: StdIO): void => {
warnIfNonArgProgramIsRunWithArgs(CompletedProgramName.httpWorm, args, stdIO);
run: (args: string[], server: BaseServer): void => {
warnIfNonArgProgramIsRunWithArgs(CompletedProgramName.httpWorm, args);
if (!(server instanceof Server)) {
Terminal.error("Cannot run HTTPWorm.exe on this kind of server.", stdIO);
Terminal.error("Cannot run HTTPWorm.exe on this kind of server.");
return;
}
if (server.httpPortOpen) {
Terminal.print("HTTP Port (80) is already open!", stdIO);
Terminal.print("HTTP Port (80) is already open!");
return;
}
server.httpPortOpen = true;
Terminal.print("Opened HTTP Port (80)!", stdIO);
Terminal.print("Opened HTTP Port (80)!");
server.openPortCount++;
},
}),
@@ -186,19 +184,19 @@ export const Programs: Record<CompletedProgramName, Program> = {
req: requireHackingLevel(750),
time: CONSTANTS.MillisecondsPer8Hours,
},
run: (args: string[], server: BaseServer, stdIO: StdIO): void => {
warnIfNonArgProgramIsRunWithArgs(CompletedProgramName.sqlInject, args, stdIO);
run: (args: string[], server: BaseServer): void => {
warnIfNonArgProgramIsRunWithArgs(CompletedProgramName.sqlInject, args);
if (!(server instanceof Server)) {
Terminal.error("Cannot run SQLInject.exe on this kind of server.", stdIO);
Terminal.error("Cannot run SQLInject.exe on this kind of server.");
return;
}
if (server.sqlPortOpen) {
Terminal.print("SQL Port (1433) is already open!", stdIO);
Terminal.print("SQL Port (1433) is already open!");
return;
}
server.sqlPortOpen = true;
Terminal.print("Opened SQL Port (1433)!", stdIO);
Terminal.print("Opened SQL Port (1433)!");
server.openPortCount++;
},
}),
@@ -210,9 +208,9 @@ export const Programs: Record<CompletedProgramName, Program> = {
req: requireHackingLevel(75),
time: CONSTANTS.MillisecondsPerQuarterHour,
},
run: (__, ___, stdIO: StdIO): void => {
Terminal.print("This executable cannot be run.", stdIO);
Terminal.print("DeepscanV1.exe lets you run 'scan-analyze' with a depth up to 5.", stdIO);
run: (): void => {
Terminal.print("This executable cannot be run.");
Terminal.print("DeepscanV1.exe lets you run 'scan-analyze' with a depth up to 5.");
},
}),
[CompletedProgramName.deepScan2]: new Program({
@@ -223,9 +221,9 @@ export const Programs: Record<CompletedProgramName, Program> = {
req: requireHackingLevel(400),
time: CONSTANTS.MillisecondsPer2Hours,
},
run: (__, ___, stdIO: StdIO): void => {
Terminal.print("This executable cannot be run.", stdIO);
Terminal.print("DeepscanV2.exe lets you run 'scan-analyze' with a depth up to 10.", stdIO);
run: (): void => {
Terminal.print("This executable cannot be run.");
Terminal.print("DeepscanV2.exe lets you run 'scan-analyze' with a depth up to 10.");
},
}),
[CompletedProgramName.serverProfiler]: new Program({
@@ -237,47 +235,44 @@ export const Programs: Record<CompletedProgramName, Program> = {
req: requireHackingLevel(75),
time: CONSTANTS.MillisecondsPerHalfHour,
},
run: (args: string[], __, stdIO: StdIO): void => {
run: (args: string[]): void => {
if (args.length !== 1) {
Terminal.error("Must pass a server hostname or IP as an argument for ServerProfiler.exe", stdIO);
Terminal.error("Must pass a server hostname or IP as an argument for ServerProfiler.exe");
return;
}
const targetServer = GetServer(args[0]);
if (targetServer == null) {
Terminal.error("Invalid server IP/hostname", stdIO);
Terminal.error("Invalid server IP/hostname");
return;
}
if (!(targetServer instanceof Server)) {
Terminal.error(`ServerProfiler.exe can only be run on normal servers.`, stdIO);
Terminal.error(`ServerProfiler.exe can only be run on normal servers.`);
return;
}
Terminal.print(targetServer.hostname + ":", stdIO);
Terminal.print("Server base security level: " + targetServer.baseDifficulty, stdIO);
Terminal.print("Server current security level: " + targetServer.hackDifficulty, stdIO);
Terminal.print("Server growth rate: " + targetServer.serverGrowth, stdIO);
Terminal.print(targetServer.hostname + ":");
Terminal.print("Server base security level: " + targetServer.baseDifficulty);
Terminal.print("Server current security level: " + targetServer.hackDifficulty);
Terminal.print("Server growth rate: " + targetServer.serverGrowth);
Terminal.print(
`Netscript hack() execution time: ${convertTimeMsToTimeElapsedString(
calculateHackingTime(targetServer, Player) * 1000,
true,
)}`,
stdIO,
);
Terminal.print(
`Netscript grow() execution time: ${convertTimeMsToTimeElapsedString(
calculateGrowTime(targetServer, Player) * 1000,
true,
)}`,
stdIO,
);
Terminal.print(
`Netscript weaken() execution time: ${convertTimeMsToTimeElapsedString(
calculateWeakenTime(targetServer, Player) * 1000,
true,
)}`,
stdIO,
);
},
}),
@@ -289,10 +284,10 @@ export const Programs: Record<CompletedProgramName, Program> = {
req: requireHackingLevel(25),
time: CONSTANTS.MillisecondsPerQuarterHour,
},
run: (__, ___, stdIO: StdIO): void => {
Terminal.print("This executable cannot be run.", stdIO);
Terminal.print("AutoLink.exe lets you automatically connect to other servers when using 'scan-analyze'.", stdIO);
Terminal.print("When using scan-analyze, click on a server's hostname to connect to it.", stdIO);
run: (): void => {
Terminal.print("This executable cannot be run.");
Terminal.print("AutoLink.exe lets you automatically connect to other servers when using 'scan-analyze'.");
Terminal.print("When using scan-analyze, click on a server's hostname to connect to it.");
},
}),
[CompletedProgramName.formulas]: new Program({
@@ -303,9 +298,9 @@ export const Programs: Record<CompletedProgramName, Program> = {
req: requireHackingLevel(1000),
time: CONSTANTS.MillisecondsPer4Hours,
},
run: (__, ___, stdIO: StdIO): void => {
Terminal.print("This executable cannot be run.", stdIO);
Terminal.print("Formulas.exe lets you use the formulas API.", stdIO);
run: (): void => {
Terminal.print("This executable cannot be run.");
Terminal.print("Formulas.exe lets you use the formulas API.");
},
}),
[CompletedProgramName.bitFlume]: new Program({
@@ -329,45 +324,43 @@ export const Programs: Record<CompletedProgramName, Program> = {
[CompletedProgramName.flight]: new Program({
name: CompletedProgramName.flight,
create: null,
run: (__, ___, stdIO: StdIO): void => {
run: (): void => {
const numAugReq = currentNodeMults.DaedalusAugsRequirement;
const fulfilled =
Player.augmentations.length >= numAugReq && Player.money >= 1e11 && Player.skills.hacking >= 2500;
if (!fulfilled) {
if (Player.augmentations.length >= numAugReq) {
Terminal.print(`[x] Augmentations: ${Player.augmentations.length} / ${numAugReq}`, stdIO);
Terminal.print(`[x] Augmentations: ${Player.augmentations.length} / ${numAugReq}`);
} else {
Terminal.print(`[ ] Augmentations: ${Player.augmentations.length} / ${numAugReq}`, stdIO);
Terminal.print(`[ ] Augmentations: ${Player.augmentations.length} / ${numAugReq}`);
}
if (Player.money >= 1e11) {
Terminal.print(`[x] Money: ${formatMoney(Player.money)} / ${formatMoney(1e11)}`, stdIO);
Terminal.print(`[x] Money: ${formatMoney(Player.money)} / ${formatMoney(1e11)}`);
} else {
Terminal.print(`[ ] Money: ${formatMoney(Player.money)} / ${formatMoney(1e11)}`, stdIO);
Terminal.print(`[ ] Money: ${formatMoney(Player.money)} / ${formatMoney(1e11)}`);
}
if (Player.skills.hacking >= 2500) {
Terminal.print(`[x] Hacking skill: ${Player.skills.hacking} / 2500`, stdIO);
Terminal.print(`[x] Hacking skill: ${Player.skills.hacking} / 2500`);
} else {
Terminal.print(`[ ] Hacking skill: ${Player.skills.hacking} / 2500`, stdIO);
Terminal.print(`[ ] Hacking skill: ${Player.skills.hacking} / 2500`);
}
return;
}
Terminal.print("We will contact you.", stdIO);
Terminal.print(`-- ${FactionName.Daedalus} --`, stdIO);
Terminal.print("We will contact you.");
Terminal.print(`-- ${FactionName.Daedalus} --`);
},
}),
[CompletedProgramName.darkscape]: new Program({
name: CompletedProgramName.darkscape,
create: null,
run: (__, ___, stdIO: StdIO): void => {
Terminal.print("This program gives access to the dark net.", stdIO);
run: (): void => {
Terminal.print("This program gives access to the dark net.");
Terminal.print(
"The dark net is an unstable, constantly shifting network of servers that are only connected to the normal network through the darkweb server.",
stdIO,
);
Terminal.print(
"This network can be accessed using the `ns.dnet` api functions, or the DarkNet UI on the left-hand panel.",
stdIO,
);
},
}),
@@ -375,8 +368,8 @@ export const Programs: Record<CompletedProgramName, Program> = {
name: CompletedProgramName.stormSeed,
nsMethod: "dnet.unleashStormSeed",
create: null,
run: (__, ___, stdIO: StdIO): void => {
Terminal.print("You can feel a storm approaching...", stdIO);
run: (): void => {
Terminal.print("You can feel a storm approaching...");
const connectedServer = Player.getCurrentServer();
handleStormSeed(connectedServer);
},