@memnexus-ai/mx-agent-cli 0.1.280 → 0.1.281
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/__tests__/coordination-401-production-wiring.test.js +119 -1
- package/dist/__tests__/coordination-401-production-wiring.test.js.map +1 -1
- package/dist/__tests__/coordination-401-recovery.test.js +4 -1
- package/dist/__tests__/coordination-401-recovery.test.js.map +1 -1
- package/dist/__tests__/coordination-command.test.js +78 -1
- package/dist/__tests__/coordination-command.test.js.map +1 -1
- package/dist/__tests__/coordination-history.test.js +95 -1
- package/dist/__tests__/coordination-history.test.js.map +1 -1
- package/dist/__tests__/coordination-provision.test.js +4 -1
- package/dist/__tests__/coordination-provision.test.js.map +1 -1
- package/dist/__tests__/coordination-render.test.js +196 -0
- package/dist/__tests__/coordination-render.test.js.map +1 -1
- package/dist/__tests__/session-pause-provisioning.test.d.ts +19 -0
- package/dist/__tests__/session-pause-provisioning.test.d.ts.map +1 -0
- package/dist/__tests__/session-pause-provisioning.test.js +110 -0
- package/dist/__tests__/session-pause-provisioning.test.js.map +1 -0
- package/dist/commands/coordination.d.ts +88 -4
- package/dist/commands/coordination.d.ts.map +1 -1
- package/dist/commands/coordination.js +137 -25
- package/dist/commands/coordination.js.map +1 -1
- package/dist/commands/session.d.ts.map +1 -1
- package/dist/commands/session.js +33 -2
- package/dist/commands/session.js.map +1 -1
- package/dist/lib/coordination-client.d.ts +13 -2
- package/dist/lib/coordination-client.d.ts.map +1 -1
- package/dist/lib/coordination-client.js +12 -3
- package/dist/lib/coordination-client.js.map +1 -1
- package/dist/lib/coordination-render.d.ts +23 -3
- package/dist/lib/coordination-render.d.ts.map +1 -1
- package/dist/lib/coordination-render.js +80 -8
- package/dist/lib/coordination-render.js.map +1 -1
- package/package.json +1 -1
|
@@ -40,10 +40,23 @@ const ESC_RE = new RegExp(ESC + '[\\s\\S]', 'g');
|
|
|
40
40
|
const VERTICAL_WS_RE = /[\r\n\u000b\u000c\u0085\u2028\u2029]+/g;
|
|
41
41
|
// 4. Remaining C0/C1 control chars (after vertical whitespace is collapsed).
|
|
42
42
|
const CONTROL_RE = /[\x00-\x1f\x7f-\x9f]/g;
|
|
43
|
+
// 5. Zero-width and bidirectional-override formatting characters. These are not
|
|
44
|
+
// C0/C1, so CONTROL_RE never saw them, and they are invisible: a body can use
|
|
45
|
+
// RLO/LRO (U+202D/U+202E) to reverse the DISPLAY order of the text that follows
|
|
46
|
+
// it, or ZWSP/ZWJ/word-joiner (U+200B, U+200D, U+2060) to break up a string a
|
|
47
|
+
// reader is scanning for. Neither can start a line — the collapse in (3) is what
|
|
48
|
+
// guarantees that — so this is a legibility hardening on top of the #4431
|
|
49
|
+
// line-splitting defence, not a replacement for it. Dropped, not replaced with a
|
|
50
|
+
// space, so removing them cannot change the character count of visible text.
|
|
51
|
+
// Ranges: U+200B-200F, U+202A-202E, U+2060-2064, U+2066-206F, U+FEFF.
|
|
52
|
+
// Written as \u escapes so the source stays pure ASCII (an invisible character
|
|
53
|
+
// pasted literally into this line would be unreviewable).
|
|
54
|
+
const INVISIBLE_RE = /[\u200b-\u200f\u202a-\u202e\u2060-\u2064\u2066-\u206f\ufeff]/g;
|
|
43
55
|
/**
|
|
44
56
|
* Neutralize control characters in an untrusted field before it enters a render
|
|
45
57
|
* line: strip ANSI/CSI escape sequences, collapse vertical whitespace (incl.
|
|
46
|
-
* Unicode line separators) to a space,
|
|
58
|
+
* Unicode line separators) to a space, drop other C0/C1 control chars, and drop
|
|
59
|
+
* zero-width / bidi-override formatting characters (SF-6).
|
|
47
60
|
* Without this, a crafted body with an embedded newline could split the line and
|
|
48
61
|
* visually impersonate a second, fabricated message inside the fence. Metadata is
|
|
49
62
|
* server-controlled now — `to` is roster-validated and `from` is the token's
|
|
@@ -55,10 +68,43 @@ export function sanitizeField(s) {
|
|
|
55
68
|
.replace(CSI_RE, '')
|
|
56
69
|
.replace(ESC_RE, '')
|
|
57
70
|
.replace(VERTICAL_WS_RE, ' ')
|
|
58
|
-
.replace(CONTROL_RE, '')
|
|
71
|
+
.replace(CONTROL_RE, '')
|
|
72
|
+
// AFTER CONTROL_RE: strictly additive, and ordered last so it can never
|
|
73
|
+
// re-expose a control character that an earlier pass removed.
|
|
74
|
+
.replace(INVISIBLE_RE, '');
|
|
59
75
|
}
|
|
60
|
-
/**
|
|
61
|
-
|
|
76
|
+
/**
|
|
77
|
+
* Truncation marker (#5188). Four readers in two days missed the old inline
|
|
78
|
+
* `…[truncated]` and acted on a go/no-go attestation that was missing its
|
|
79
|
+
* recommendation, because `sanitizeField` collapses vertical whitespace before
|
|
80
|
+
* the length check — correctly, that is the #4431 line-splitting defence — so a
|
|
81
|
+
* structured attestation arrives as one unbroken line and the marker landed
|
|
82
|
+
* thousands of characters into it.
|
|
83
|
+
*
|
|
84
|
+
* The fix does NOT touch the collapse. The body stays sanitized and stays on one
|
|
85
|
+
* line; what changes is that WE emit a header at the front of the body and a
|
|
86
|
+
* marker on its own line after it. Both are constant text plus digits produced by
|
|
87
|
+
* this function, never anything the sender controls, so no untrusted byte gains
|
|
88
|
+
* the ability to start a new line — the sanitizer's guarantee is unchanged.
|
|
89
|
+
*
|
|
90
|
+
* THE HEAD CARRIES THE PER-RENDER NONCE (SF-1 of the #5188 security review). The
|
|
91
|
+
* own-line marker is unforgeable for free — a sanitized body cannot start a line —
|
|
92
|
+
* but the head is plain text at a fixed position in a line the body also occupies,
|
|
93
|
+
* so a body beginning `[TRUNCATED - first 10 of 99999 chars] nothing` renders a
|
|
94
|
+
* head-shaped prefix on a message that was never cut. It is the more VISIBLE half
|
|
95
|
+
* of the fix and it points the reader at `history`, so a forged one is a lure.
|
|
96
|
+
* Threading the fence nonce through makes it structurally unforgeable by exactly
|
|
97
|
+
* the argument that already covers the fence markers: the sender cannot know a
|
|
98
|
+
* value generated per render invocation.
|
|
99
|
+
*/
|
|
100
|
+
const TRUNCATION_HEAD = (nonce, shown, total) => `[TRUNCATED:${nonce} — first ${shown} of ${total} chars] `;
|
|
101
|
+
const TRUNCATION_MARKER = (id, withheld) => `…[truncated] ${withheld} chars of ${id} withheld — full body: mx-agent coordination history`;
|
|
102
|
+
/**
|
|
103
|
+
* One message → a display block: one line of metadata + body, plus a second line
|
|
104
|
+
* carrying the truncation marker when (and only when) the body was cut.
|
|
105
|
+
*/
|
|
106
|
+
export function renderMessageLine(m, opts = {}) {
|
|
107
|
+
const { maxBodyChars, nonce = makeNonce() } = opts;
|
|
62
108
|
const priority = sanitizeField(String(m.priority));
|
|
63
109
|
const id = sanitizeField(m.id);
|
|
64
110
|
const from = sanitizeField(m.from);
|
|
@@ -67,9 +113,11 @@ export function renderMessageLine(m, maxBodyChars) {
|
|
|
67
113
|
// enqueue; anything else is a pre-#4239 CLAIMED sender and is tagged so a
|
|
68
114
|
// forged pre-deploy `from` is never displayed as if it were verified.
|
|
69
115
|
const senderTag = m.verifiedFrom ? from : `${from} [UNVERIFIED pre-#4239]`;
|
|
70
|
-
|
|
116
|
+
const body = sanitizeField(m.body);
|
|
71
117
|
if (maxBodyChars !== undefined && body.length > maxBodyChars) {
|
|
72
|
-
|
|
118
|
+
const head = TRUNCATION_HEAD(nonce, maxBodyChars, body.length);
|
|
119
|
+
const marker = TRUNCATION_MARKER(id, body.length - maxBodyChars);
|
|
120
|
+
return `[${priority}] ${id} from ${senderTag} to ${to}: ${head}${body.slice(0, maxBodyChars)}\n${marker}`;
|
|
73
121
|
}
|
|
74
122
|
return `[${priority}] ${id} from ${senderTag} to ${to}: ${body}`;
|
|
75
123
|
}
|
|
@@ -85,14 +133,38 @@ export function fenceBlock(lines, nonce = makeNonce()) {
|
|
|
85
133
|
`<<END_MX_COORD_UNTRUSTED:${nonce}>>`,
|
|
86
134
|
].join('\n');
|
|
87
135
|
}
|
|
136
|
+
/**
|
|
137
|
+
* Emitted (and only ever emitted) by this renderer when `maxTotalChars` stops the
|
|
138
|
+
* row set short. Its own line, constant text plus a digit count — a sanitized body
|
|
139
|
+
* cannot start a line, so it cannot be forged.
|
|
140
|
+
*/
|
|
141
|
+
const OVER_BUDGET_LINE = (dropped) => `${dropped} further messages not shown — narrow with --limit`;
|
|
88
142
|
/**
|
|
89
143
|
* Render a set of messages for agent consumption. When `fenced`, the ENTIRE
|
|
90
144
|
* block (every line, including metadata) sits inside one keyed fence with a
|
|
91
145
|
* single per-render nonce. Fields are ALWAYS sanitized regardless of `fenced`.
|
|
146
|
+
*
|
|
147
|
+
* ONE nonce per invocation, shared by the fence markers and every truncation head
|
|
148
|
+
* in the block (SF-1) — the head is only unforgeable because the value in it is
|
|
149
|
+
* the same unguessable value that makes the fence unforgeable.
|
|
92
150
|
*/
|
|
93
151
|
export function renderMessages(messages, opts = {}) {
|
|
94
|
-
const
|
|
95
|
-
|
|
152
|
+
const nonce = makeNonce();
|
|
153
|
+
const budget = opts.maxTotalChars;
|
|
154
|
+
const lines = [];
|
|
155
|
+
let used = 0;
|
|
156
|
+
for (let i = 0; i < messages.length; i++) {
|
|
157
|
+
const line = renderMessageLine(messages[i], { maxBodyChars: opts.maxBodyChars, nonce });
|
|
158
|
+
// The FIRST row always renders, whatever its size: a budget that can produce
|
|
159
|
+
// an empty block would hide the newest message with no way to ask for less.
|
|
160
|
+
if (budget !== undefined && lines.length > 0 && used + line.length > budget) {
|
|
161
|
+
lines.push(OVER_BUDGET_LINE(messages.length - i));
|
|
162
|
+
break;
|
|
163
|
+
}
|
|
164
|
+
lines.push(line);
|
|
165
|
+
used += line.length + 1; // +1 for the newline the join adds
|
|
166
|
+
}
|
|
167
|
+
return opts.fenced ? fenceBlock(lines, nonce) : lines.join('\n');
|
|
96
168
|
}
|
|
97
169
|
/**
|
|
98
170
|
* IN-BAND scope at the routing surface (#4314). `mx-agent escalate --to <team>`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coordination-render.js","sourceRoot":"","sources":["../../src/lib/coordination-render.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,W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