@volter/supercode-teams 0.3.108 → 0.3.109

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/codex-startup.mjs CHANGED
@@ -148,13 +148,30 @@ function codexWindowsCharacter(character) {
148
148
  }
149
149
 
150
150
  /** Text as the raw writes that paste it into a Windows Codex composer: bracketed pastes of at most
151
- * CODEX_WINDOWS_PASTE_CHARS characters each, non-ASCII BMP characters as key events. Written as they are (a terminal
152
- * host turns `\n` into `\r`, which Codex keeps as a line break inside a paste); never submitted here. */
151
+ * CODEX_WINDOWS_PASTE_CHARS written characters each (a key event counts as its whole encoding, so non-ASCII-heavy
152
+ * text takes more, smaller pastes), non-ASCII BMP characters as key events. A piece ends after its last line break
153
+ * when it has one, and never begins with one: a line break arriving first after the gap between pastes could read as
154
+ * Enter and submit part of the text. Line ends are normalized to `\n`. Written as they are (a terminal host turns `\n` into `\r`, which Codex keeps
155
+ * as a line break inside a paste); never submitted here. */
153
156
  export function codexWindowsPastes(text) {
154
- const characters = Array.from(String(text));
157
+ // Line ends as `\n` only: Codex reads a pasted `\r\n` as two line breaks.
158
+ const encoded = Array.from(String(text).replace(/\r\n?/g, '\n')).map(codexWindowsCharacter);
155
159
  const pastes = [];
156
- for (let at = 0; at < characters.length; at += CODEX_WINDOWS_PASTE_CHARS) {
157
- pastes.push(`\u001b[200~${characters.slice(at, at + CODEX_WINDOWS_PASTE_CHARS).map(codexWindowsCharacter).join('')}\u001b[201~`);
160
+ for (let start = 0; start < encoded.length;) {
161
+ let end = start, written = 0, lastBreak = -1;
162
+ while (end < encoded.length && (end === start || written + encoded[end].length <= CODEX_WINDOWS_PASTE_CHARS)) {
163
+ written += encoded[end].length;
164
+ if (encoded[end] === '\n') lastBreak = end;
165
+ end += 1;
166
+ }
167
+ // Cut after the piece's last line break when the text goes on; else keep any line breaks that follow the cut
168
+ // with this piece, so the next one does not open with one.
169
+ if (end < encoded.length) {
170
+ if (lastBreak >= start && lastBreak + 1 < end) end = lastBreak + 1;
171
+ else while (end < encoded.length && encoded[end] === '\n') end += 1;
172
+ }
173
+ pastes.push(`\u001b[200~${encoded.slice(start, end).join('')}\u001b[201~`);
174
+ start = end;
158
175
  }
159
176
  return pastes;
160
177
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@volter/supercode-teams",
3
- "version": "0.3.108",
3
+ "version": "0.3.109",
4
4
  "type": "module",
5
5
  "description": "A machine daemon serving this machine's doors, and a local or remote Teams server for shared session discovery, OpenTelemetry ingestion and access to enrolled machines.",
6
6
  "license": "MIT",
package/terminal-mail.mjs CHANGED
@@ -40,6 +40,8 @@ function confirmed(batch) {
40
40
  const text = textOf(content);
41
41
  if (text === null || text.length === 0) continue;
42
42
  if (text === batch.text) return { fragments: 1 };
43
+ // A Windows Codex is pasted its text with line ends as `\n` (codexWindowsPastes).
44
+ if (batch.kind === 'codex' && text === batch.text.replace(/\r\n?/g, '\n')) return { fragments: 1 };
43
45
  // Older mail delivery omitted the paste delimiter, so terminal newlines
44
46
  // submitted one envelope as several native user messages. Recover only
45
47
  // exact, ordered fragments of the retained bytes, separated by original