@dmsdc-ai/aigentry-telepty 0.1.95 → 0.1.96
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/daemon.js +18 -9
- package/package.json +1 -1
package/daemon.js
CHANGED
|
@@ -1577,15 +1577,24 @@ app.get('/api/sessions/:id/screen', (req, res) => {
|
|
|
1577
1577
|
// Strip ANSI escape sequences for clean text
|
|
1578
1578
|
function stripAnsi(str) {
|
|
1579
1579
|
return str
|
|
1580
|
-
|
|
1581
|
-
.replace(
|
|
1582
|
-
|
|
1583
|
-
.replace(
|
|
1584
|
-
|
|
1585
|
-
.replace(
|
|
1586
|
-
|
|
1587
|
-
.replace(
|
|
1588
|
-
|
|
1580
|
+
// Replace cursor-forward (ESC[NC, ESC[C) with N spaces to preserve whitespace
|
|
1581
|
+
.replace(/\[(\d*)C/g, (_, n) => ' '.repeat(Number(n) || 1))
|
|
1582
|
+
// CSI sequences: ESC [ ? (optional) params final_byte
|
|
1583
|
+
.replace(/\[\??[0-9;]*[a-zA-Z@`]/g, '')
|
|
1584
|
+
// OSC sequences: ESC ] ... BEL
|
|
1585
|
+
.replace(/\][^]*/g, '')
|
|
1586
|
+
// OSC sequences: ESC ] ... ST (ESC \)
|
|
1587
|
+
.replace(/\][^]*\\/g, '')
|
|
1588
|
+
// Character set selection: ESC ( / ) + charset
|
|
1589
|
+
.replace(/[()][AB012]/g, '')
|
|
1590
|
+
// Keypad and other 2-char ESC sequences
|
|
1591
|
+
.replace(/[>=<78DMEHcNOZ~}|]/g, '')
|
|
1592
|
+
// DCS / PM / APC sequences
|
|
1593
|
+
.replace(/[P^_][^]*\\/g, '')
|
|
1594
|
+
// Any remaining bare ESC + single char
|
|
1595
|
+
.replace(/./g, '')
|
|
1596
|
+
// Carriage returns
|
|
1597
|
+
.replace(/\r/g, '');
|
|
1589
1598
|
}
|
|
1590
1599
|
|
|
1591
1600
|
const cleaned = raw ? fullOutput : stripAnsi(fullOutput);
|