fleetbo-cockpit-cli 1.0.129 → 1.0.130
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/cli.js +45 -29
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -250,8 +250,8 @@ if (command === 'alex') {
|
|
|
250
250
|
const initialPrompt = args.slice(1).join(' ');
|
|
251
251
|
|
|
252
252
|
const processAlexRequest = async (prompt) => {
|
|
253
|
-
if (prompt.length >
|
|
254
|
-
console.log('\n\x1b[31m⛔ [Alex Safety] Request too long (' + prompt.length + '/
|
|
253
|
+
if (prompt.length > 4000) {
|
|
254
|
+
console.log('\n\x1b[31m⛔ [Alex Safety] Request too long (' + prompt.length + '/4000 chars).\x1b[0m');
|
|
255
255
|
return;
|
|
256
256
|
}
|
|
257
257
|
|
|
@@ -639,48 +639,64 @@ if (command === 'alex') {
|
|
|
639
639
|
process.stdout.write('\n\x1b[F');
|
|
640
640
|
rl.prompt();
|
|
641
641
|
|
|
642
|
-
let inputBuffer = "";
|
|
643
|
-
let isProcessing = false;
|
|
642
|
+
let inputBuffer = "";
|
|
643
|
+
let isProcessing = false;
|
|
644
|
+
let submitTimer = null;
|
|
645
|
+
|
|
646
|
+
const doSubmit = async () => {
|
|
647
|
+
if (submitTimer) { clearTimeout(submitTimer); submitTimer = null; }
|
|
648
|
+
if (isProcessing || inputBuffer.trim() === "") return;
|
|
649
|
+
|
|
650
|
+
const finalPrompt = inputBuffer.trim();
|
|
651
|
+
inputBuffer = "";
|
|
652
|
+
|
|
653
|
+
if (finalPrompt.length > 4000) {
|
|
654
|
+
console.log(`\n\x1b[31m⛔ [Alex Safety] Mission rejected: Excessive size (${finalPrompt.length}/4000 characters).\x1b[0m`);
|
|
655
|
+
rl.setPrompt(`\x1b[34m${dynamicUsername} ❯ \x1b[0m`);
|
|
656
|
+
rl.prompt();
|
|
657
|
+
return;
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
isProcessing = true;
|
|
661
|
+
rl.setPrompt("");
|
|
662
|
+
await processAlexRequest(finalPrompt);
|
|
663
|
+
isProcessing = false;
|
|
664
|
+
|
|
665
|
+
console.log('');
|
|
666
|
+
rl.setPrompt(`\x1b[34m${dynamicUsername} ❯ \x1b[0m`);
|
|
667
|
+
rl.prompt();
|
|
668
|
+
};
|
|
644
669
|
|
|
645
670
|
rl.on('line', async (line) => {
|
|
646
|
-
if (isProcessing) return;
|
|
671
|
+
if (isProcessing) return;
|
|
647
672
|
|
|
648
673
|
const trimmedLine = line.trim();
|
|
649
674
|
|
|
650
|
-
if (['exit', 'quit'].includes(trimmedLine.toLowerCase())) {
|
|
675
|
+
if (['exit', 'quit'].includes(trimmedLine.toLowerCase())) {
|
|
651
676
|
console.log('\n\x1b[90m Alex session closed.\x1b[0m');
|
|
652
|
-
rl.close();
|
|
653
|
-
return;
|
|
677
|
+
rl.close();
|
|
678
|
+
return;
|
|
654
679
|
}
|
|
655
680
|
|
|
656
681
|
if (trimmedLine !== "") {
|
|
682
|
+
// Ligne non-vide : annule le timer de soumission si une ligne vide
|
|
683
|
+
// était en attente (cas paste avec ligne vide interne)
|
|
684
|
+
if (submitTimer) { clearTimeout(submitTimer); submitTimer = null; }
|
|
657
685
|
inputBuffer += (inputBuffer ? "\n" : "") + line;
|
|
686
|
+
// Affiche le hint immédiatement — comportement original préservé
|
|
658
687
|
rl.setPrompt("\x1b[90m ↵ again to send\x1b[0m");
|
|
659
688
|
rl.prompt();
|
|
660
|
-
}
|
|
661
|
-
else {
|
|
689
|
+
} else {
|
|
662
690
|
if (inputBuffer.trim() !== "") {
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
rl.prompt();
|
|
670
|
-
return;
|
|
671
|
-
}
|
|
672
|
-
|
|
673
|
-
isProcessing = true;
|
|
674
|
-
rl.setPrompt("");
|
|
675
|
-
await processAlexRequest(finalPrompt);
|
|
676
|
-
isProcessing = false;
|
|
677
|
-
|
|
678
|
-
console.log('');
|
|
679
|
-
rl.setPrompt(`\x1b[34m${dynamicUsername} ❯ \x1b[0m`);
|
|
680
|
-
rl.prompt();
|
|
691
|
+
// Ligne vide reçue : attend 400ms avant de soumettre
|
|
692
|
+
// Si une ligne non-vide arrive dans ce délai (paste en cours)
|
|
693
|
+
// → le timer est annulé dans le bloc trimmedLine !== "" ci-dessus
|
|
694
|
+
// Si rien n'arrive → vraie Entrée manuelle → soumet
|
|
695
|
+
if (submitTimer) clearTimeout(submitTimer);
|
|
696
|
+
submitTimer = setTimeout(() => doSubmit(), 400);
|
|
681
697
|
} else {
|
|
682
698
|
rl.setPrompt(`\x1b[34m${dynamicUsername} ❯ \x1b[0m`);
|
|
683
|
-
rl.prompt();
|
|
699
|
+
rl.prompt();
|
|
684
700
|
}
|
|
685
701
|
}
|
|
686
702
|
});
|