@memnexus-ai/cli 1.7.240 → 1.7.242
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/commands/auth.d.ts.map +1 -1
- package/dist/commands/auth.js +7 -4
- package/dist/commands/auth.js.map +1 -1
- package/dist/commands/commit-context.d.ts.map +1 -1
- package/dist/commands/commit-context.js +7 -3
- package/dist/commands/commit-context.js.map +1 -1
- package/dist/commands/config.d.ts.map +1 -1
- package/dist/commands/config.js +18 -8
- package/dist/commands/config.js.map +1 -1
- package/dist/commands/mcp.d.ts +15 -0
- package/dist/commands/mcp.d.ts.map +1 -1
- package/dist/commands/mcp.js +47 -66
- package/dist/commands/mcp.js.map +1 -1
- package/dist/commands/memories.d.ts.map +1 -1
- package/dist/commands/memories.js +96 -71
- package/dist/commands/memories.js.map +1 -1
- package/dist/commands/system.d.ts.map +1 -1
- package/dist/commands/system.js +4 -2
- package/dist/commands/system.js.map +1 -1
- package/dist/lib/errors.d.ts.map +1 -1
- package/dist/lib/errors.js +17 -11
- package/dist/lib/errors.js.map +1 -1
- package/dist/lib/formatters.d.ts.map +1 -1
- package/dist/lib/formatters.js +46 -26
- package/dist/lib/formatters.js.map +1 -1
- package/dist/lib/mcp-session-errors.d.ts +43 -0
- package/dist/lib/mcp-session-errors.d.ts.map +1 -0
- package/dist/lib/mcp-session-errors.js +67 -0
- package/dist/lib/mcp-session-errors.js.map +1 -0
- package/dist/lib/terminal-safe.d.ts +8 -5
- package/dist/lib/terminal-safe.d.ts.map +1 -1
- package/dist/lib/terminal-safe.js +81 -9
- package/dist/lib/terminal-safe.js.map +1 -1
- package/package.json +2 -2
|
@@ -18,6 +18,69 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
18
18
|
exports.sanitizeTerminalText = sanitizeTerminalText;
|
|
19
19
|
exports.sanitizeTerminalBlock = sanitizeTerminalBlock;
|
|
20
20
|
exports.sanitizeVerifyResults = sanitizeVerifyResults;
|
|
21
|
+
/**
|
|
22
|
+
* Whole terminal escape sequences, removed before the control-byte strip so
|
|
23
|
+
* their parameter text does not survive as visible residue (#5733). Removing
|
|
24
|
+
* only the introducer byte left text such as `[2J` or `]8;;http://evil` in the
|
|
25
|
+
* output: inert, but it changed the content. Alternatives, tried in order at
|
|
26
|
+
* each position:
|
|
27
|
+
*
|
|
28
|
+
* 1. Control strings: OSC (`ESC ]`), and DCS, SOS, PM and APC (`ESC P`,
|
|
29
|
+
* `ESC X`, `ESC ^`, `ESC _`). The terminator is REQUIRED: BEL, or ST
|
|
30
|
+
* (`ESC \` or 8-bit `0x9c`). The body holds no C0, DEL or C1 byte, so it
|
|
31
|
+
* cannot cross a newline or another introducer.
|
|
32
|
+
*
|
|
33
|
+
* Why the terminator is required (CWE-451, security review of #5733): an
|
|
34
|
+
* optional terminator removed everything after an unterminated
|
|
35
|
+
* introducer. One stray `0x9d`, which mojibake (UTF-8 read as Latin-1)
|
|
36
|
+
* also produces, hid the rest of a memory in table and llm output, while
|
|
37
|
+
* JSON and MCP returned the full text. Text the CLI hides from its reader
|
|
38
|
+
* is worse than visible residue. An unterminated introducer now falls
|
|
39
|
+
* through: `ESC ]` matches alternative 3 and its parameters stay as text.
|
|
40
|
+
*
|
|
41
|
+
* Why the body excludes control bytes: with a required terminator, a body
|
|
42
|
+
* that ran to the end of the text would make each unterminated
|
|
43
|
+
* introducer scan the rest of the input, which is quadratic. Stopping at
|
|
44
|
+
* the next control byte bounds each scan to one segment, so the whole
|
|
45
|
+
* pass is linear.
|
|
46
|
+
* 2. CSI (`ESC [`): parameter bytes 0x30-0x3f, intermediate bytes 0x20-0x2f,
|
|
47
|
+
* then one final byte 0x40-0x7e. This covers SGR colour, cursor movement
|
|
48
|
+
* and `2J` screen clear.
|
|
49
|
+
* 3. Any other ESC sequence: intermediate bytes, then one final byte
|
|
50
|
+
* 0x30-0x7e. This covers `ESC c` (full terminal reset) and `ESC 7`.
|
|
51
|
+
*
|
|
52
|
+
* Only 7-bit, ESC-introduced sequences are removed whole. The 8-bit
|
|
53
|
+
* introducers (CSI `0x9b`; OSC `0x9d`; DCS, SOS, PM and APC `0x90`, `0x98`,
|
|
54
|
+
* `0x9e`, `0x9f`) are NOT matched here; the control-byte strip removes the
|
|
55
|
+
* byte itself and the text after it stays (security review of #5733, Info).
|
|
56
|
+
* Mojibake produces these bytes in ordinary text: Czech `Měl` read as Latin-1
|
|
57
|
+
* is `MÄ\x9bl`, and treating `0x9b` as CSI removed the `l` as its final byte.
|
|
58
|
+
* `丝 ab 东` becomes `ä¸\x9d ab ä¸\x9c`, and treating that as an OSC string
|
|
59
|
+
* hid ` ab ä¸`. Removing an 8-bit sequence whole gives no protection the
|
|
60
|
+
* byte strip does not: once the introducer byte is gone, its parameters are
|
|
61
|
+
* inert text.
|
|
62
|
+
*
|
|
63
|
+
* Whatever this leaves, including a lone ESC or an unterminated CSI
|
|
64
|
+
* introducer, is removed by the control-byte strip that runs after it. That
|
|
65
|
+
* strip is the security guarantee: no ESC, C0 or C1 byte reaches the terminal.
|
|
66
|
+
* This regex only decides how much of the surrounding text goes with it.
|
|
67
|
+
*/
|
|
68
|
+
const ESCAPE_SEQUENCE_RE =
|
|
69
|
+
// eslint-disable-next-line no-control-regex
|
|
70
|
+
/\x1b[\]PX^_][^\x00-\x1f\x7f-\x9f]*(?:\x07|\x1b\\|\x9c)|\x1b\[[\x30-\x3f]*[\x20-\x2f]*[\x40-\x7e]|\x1b[\x20-\x2f]*[\x30-\x7e]/g;
|
|
71
|
+
/**
|
|
72
|
+
* Unicode characters that change how text displays without being control
|
|
73
|
+
* bytes (#5733): the bidi embeddings and overrides U+202A-U+202E (U+202E
|
|
74
|
+
* reverses the display order of what follows), the bidi isolates
|
|
75
|
+
* U+2066-U+2069, and the line and paragraph separators U+2028 and U+2029.
|
|
76
|
+
* Zero-width joiners are NOT removed: U+200D is part of emoji sequences and
|
|
77
|
+
* U+200C is required in some scripts. The directional marks LRM (U+200E),
|
|
78
|
+
* RLM (U+200F) and ALM (U+061C) are NOT removed either: legitimate
|
|
79
|
+
* right-to-left text (Arabic, Hebrew) needs them to display correctly, and
|
|
80
|
+
* they set the direction of neighbouring characters only, unlike U+202E,
|
|
81
|
+
* which reverses a whole run.
|
|
82
|
+
*/
|
|
83
|
+
const UNICODE_DISPLAY_CONTROLS_RE = /[\u2028-\u202e\u2066-\u2069]/g;
|
|
21
84
|
/**
|
|
22
85
|
* Strip C0 control characters, DEL, and the C1 control range. Tab, newline and
|
|
23
86
|
* carriage return are removed too: these values are rendered inline in single-line
|
|
@@ -27,23 +90,32 @@ exports.sanitizeVerifyResults = sanitizeVerifyResults;
|
|
|
27
90
|
* escape introducers as C0/ESC: `0x9b` is 8-bit CSI (Control Sequence Introducer)
|
|
28
91
|
* and `0x9d` is 8-bit OSC (Operating System Command). A terminal that honors C1
|
|
29
92
|
* can be driven by these introducers with no `0x1b` ESC byte, so a sanitizer that
|
|
30
|
-
* removed only ESC and C0 left an 8-bit bypass (#5233).
|
|
31
|
-
*
|
|
32
|
-
*
|
|
93
|
+
* removed only ESC and C0 left an 8-bit bypass (#5233).
|
|
94
|
+
*
|
|
95
|
+
* Whole escape sequences are removed first (ESCAPE_SEQUENCE_RE), so the
|
|
96
|
+
* parameter text of a sequence does not remain as residue, and bidi controls
|
|
97
|
+
* and U+2028/U+2029 are removed last (#5733).
|
|
33
98
|
*/
|
|
34
99
|
function sanitizeTerminalText(text) {
|
|
35
|
-
|
|
36
|
-
|
|
100
|
+
return (text
|
|
101
|
+
.replace(ESCAPE_SEQUENCE_RE, '')
|
|
102
|
+
// eslint-disable-next-line no-control-regex
|
|
103
|
+
.replace(/[\x00-\x1f\x7f\x80-\x9f]/g, '')
|
|
104
|
+
.replace(UNICODE_DISPLAY_CONTROLS_RE, ''));
|
|
37
105
|
}
|
|
38
106
|
/**
|
|
39
107
|
* Same filter as `sanitizeTerminalText`, but keeps newline and tab, for
|
|
40
108
|
* multi-line blocks where line breaks are real formatting (for example memory
|
|
41
|
-
* content printed below a table, #5482
|
|
42
|
-
* because a bare `\r` can overwrite the
|
|
109
|
+
* content printed below a table, #5482, and every table cell and key, #5733).
|
|
110
|
+
* Carriage return is still stripped, because a bare `\r` can overwrite the
|
|
111
|
+
* start of a line already printed.
|
|
43
112
|
*/
|
|
44
113
|
function sanitizeTerminalBlock(text) {
|
|
45
|
-
|
|
46
|
-
|
|
114
|
+
return (text
|
|
115
|
+
.replace(ESCAPE_SEQUENCE_RE, '')
|
|
116
|
+
// eslint-disable-next-line no-control-regex
|
|
117
|
+
.replace(/[\x00-\x08\x0b-\x1f\x7f\x80-\x9f]/g, '')
|
|
118
|
+
.replace(UNICODE_DISPLAY_CONTROLS_RE, ''));
|
|
47
119
|
}
|
|
48
120
|
/**
|
|
49
121
|
* Sanitize every message in a set of verification results.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"terminal-safe.js","sourceRoot":"","sources":["../../src/lib/terminal-safe.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;
|
|
1
|
+
{"version":3,"file":"terminal-safe.js","sourceRoot":"","sources":["../../src/lib/terminal-safe.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;AAoFH,oDAQC;AASD,sDAQC;AAUD,sDASC;AA5HD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,MAAM,kBAAkB;AACtB,4CAA4C;AAC5C,+HAA+H,CAAC;AAElI;;;;;;;;;;;GAWG;AACH,MAAM,2BAA2B,GAAG,+BAA+B,CAAC;AAEpE;;;;;;;;;;;;;;GAcG;AACH,SAAgB,oBAAoB,CAAC,IAAY;IAC/C,OAAO,CACL,IAAI;SACD,OAAO,CAAC,kBAAkB,EAAE,EAAE,CAAC;QAChC,4CAA4C;SAC3C,OAAO,CAAC,2BAA2B,EAAE,EAAE,CAAC;SACxC,OAAO,CAAC,2BAA2B,EAAE,EAAE,CAAC,CAC5C,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,qBAAqB,CAAC,IAAY;IAChD,OAAO,CACL,IAAI;SACD,OAAO,CAAC,kBAAkB,EAAE,EAAE,CAAC;QAChC,4CAA4C;SAC3C,OAAO,CAAC,oCAAoC,EAAE,EAAE,CAAC;SACjD,OAAO,CAAC,2BAA2B,EAAE,EAAE,CAAC,CAC5C,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,qBAAqB,CAAC,OAAuB;IAC3D,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QAC9B,GAAG,MAAM;QACT,SAAS,EAAE,oBAAoB,CAAC,MAAM,CAAC,SAAS,CAAC;QACjD,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;YACpC,GAAG,KAAK;YACR,OAAO,EAAE,oBAAoB,CAAC,KAAK,CAAC,OAAO,CAAC;SAC7C,CAAC,CAAC;KACJ,CAAC,CAAC,CAAC;AACN,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@memnexus-ai/cli",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.242",
|
|
4
4
|
"description": "Command-line interface for MemNexus Core API",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"node": ">=18.0.0"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@memnexus-ai/typescript-sdk": "^1.
|
|
38
|
+
"@memnexus-ai/typescript-sdk": "^1.80.2",
|
|
39
39
|
"@modelcontextprotocol/sdk": "^1.27.1",
|
|
40
40
|
"axios": "^1.13.6",
|
|
41
41
|
"chalk": "^5.3.0",
|