aboutsummaryrefslogtreecommitdiff
path: root/modules/core/terminal.js
diff options
context:
space:
mode:
Diffstat (limited to 'modules/core/terminal.js')
-rw-r--r--modules/core/terminal.js34
1 files changed, 21 insertions, 13 deletions
diff --git a/modules/core/terminal.js b/modules/core/terminal.js
index 16e2c7e..4122b3c 100644
--- a/modules/core/terminal.js
+++ b/modules/core/terminal.js
@@ -1361,6 +1361,7 @@
this._safeRegister('FileSystemModule', 'filesystem');
this._safeRegister('ModuleManagerModule', 'module manager');
this._safeRegister('OllamaModule', 'ollama');
+ this._safeRegister('BillingModule', 'billing');
this._safeRegister('SearXNGModule', 'searxng search');
this._safeRegister('ConfigManagerModule', 'config');
this._safeRegister('WebX11AIAssistantModule', 'AI assistant');
@@ -1429,10 +1430,11 @@
BusyBoxModule: typeof BusyBoxModule !== 'undefined' ? BusyBoxModule : undefined,
SmartContextModule: typeof SmartContextModule !== 'undefined' ? SmartContextModule : undefined,
DebugSupervisorModule: typeof DebugSupervisorModule !== 'undefined' ? DebugSupervisorModule : undefined,
+ BillingModule: typeof BillingModule !== 'undefined' ? BillingModule : undefined,
};
const cls = registry[className];
if (typeof cls === 'undefined') {
- console.log(`[SafeRegister] Skipped ${label}: class not loaded (skipped in boot selection)`);
+ console.warn(`[SafeRegister] Skipped ${label}: ${className} is not in the registry map — add it there, not only to loadBuiltInModules()`);
return;
}
try { this.moduleManager.registerModule(new cls()); }
@@ -1570,22 +1572,28 @@
return parts;
}
async executePipeChain(pipeParts) {
- // Parse every stage once, then drop the ones with no argv. `help |` splits to
+ // Parse every stage once, then skip the ones with no argv. `help |` splits to
// ['help',''], `help | ""` to ['help',''] and `| wc -l` to ['','wc -l'] — all three
// produced an empty argv whose parts[0] was undefined and threw TypeError from
- // parts[0].toLowerCase() (989 occurrences, first filed 2026-10-20). Filtering on
+ // parts[0].toLowerCase() (989 occurrences, first filed 2026-10-20). Skipping on
// argv (not just the string) also keeps the LAST real stage final, so its output is
- // never swallowed by a trailing empty segment.
- const stages = pipeParts
- .map(t => this.security._parseArgs(String(t || '').trim()))
- .filter(argv => argv.length > 0);
- if (!stages.length) {
+ // never swallowed by a trailing empty segment, and keeps the loop index aligned
+ // with pipeParts so each stage gets its own raw text.
+ const stages = pipeParts.map(t => this.security._parseArgs(String(t || '').trim()));
+ // Index of the LAST stage that has a real argv — its output is printed, never
+ // piped. -1 means every segment was empty, so there is nothing to run.
+ let lastStage = -1;
+ for (let i = 0; i < stages.length; i++) if (stages[i].length > 0) lastStage = i;
+ if (lastStage < 0) {
this.print('⚠️ Empty pipeline — nothing to run', 'warning');
return;
}
let pipeInput = null;
for (let i = 0; i < stages.length; i++) {
const argv = stages[i];
+ // Skip empty segments, but keep `i` pointing at pipeParts[i] so the raw stage
+ // text handed to the dispatcher always belongs to this argv.
+ if (argv.length === 0) continue;
const cmd = argv[0].toLowerCase();
const args = argv.slice(1);
// Rebuilt from argv so the security classifier sees the same tokenisation the
@@ -1606,19 +1614,19 @@
return;
}
this._pipeInput = pipeInput;
- if (i < stages.length - 1) {
- pipeInput = await this.capturePipeOutput(cmd, args);
+ if (i < lastStage) {
+ pipeInput = await this.capturePipeOutput(cmd, args, pipeParts[i]);
} else {
- await this.dispatchCommand(cmd, args);
+ await this.dispatchCommand(cmd, args, pipeParts[i]);
}
}
this._pipeInput = null;
}
- async capturePipeOutput(cmd, args) {
+ async capturePipeOutput(cmd, args, rawText) {
let output = '';
this._pushPrintCapture(buf => { output += buf; });
try {
- await this.dispatchCommand(cmd, args);
+ await this.dispatchCommand(cmd, args, rawText);
} finally {
this._popPrintCapture();
}