@foldrun/core 18.3.0 → 18.3.1
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/src/a2a-client.js +7 -1
- package/dist/src/joiners.d.ts +2 -0
- package/dist/src/joiners.js +35 -0
- package/dist/src/scan.js +9 -4
- package/package.json +1 -1
- package/src/a2a-client.ts +6 -1
- package/src/joiners.ts +35 -0
- package/src/scan.ts +9 -4
package/dist/src/a2a-client.js
CHANGED
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
// exchanges text and JSON only, and a URL in a reply is not an invitation.
|
|
23
23
|
//
|
|
24
24
|
// No vault, no MCP: values in, values out. a2a-tools.ts is the agent's side.
|
|
25
|
+
import { spellingJoiners } from "./joiners.js";
|
|
25
26
|
import crypto from "node:crypto";
|
|
26
27
|
import { viaEgress } from "./egress.js";
|
|
27
28
|
import { capBody, ResponseTooLarge } from "./untrusted-fetch.js";
|
|
@@ -101,7 +102,12 @@ const HIDDEN = /[----\u0000-\u0008\u000B\u000C\u000E-
|
|
|
101
102
|
/** `text` with hidden characters removed, and how many there were. */
|
|
102
103
|
export function stripHidden(text) {
|
|
103
104
|
let removed = 0;
|
|
104
|
-
|
|
105
|
+
// A joiner that is spelling (a Persian half-space, an Indic or emoji
|
|
106
|
+
// joiner — joiners.ts) stays: removing it misspells the word.
|
|
107
|
+
const spelling = spellingJoiners(text);
|
|
108
|
+
const out = text.replace(HIDDEN, (m, at) => {
|
|
109
|
+
if (spelling.has(at))
|
|
110
|
+
return m;
|
|
105
111
|
removed++;
|
|
106
112
|
return "";
|
|
107
113
|
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// ZWNJ (U+200C) and ZWJ (U+200D) are invisible, and they are also spelling.
|
|
2
|
+
//
|
|
3
|
+
// In Persian the half-space is how a word is written: «کانالها», «میشود».
|
|
4
|
+
// Arabic-script, Syriac, Thaana and N'Ko, and the Indic and other Brahmic
|
|
5
|
+
// scripts, use both joiners inside words. An emoji sequence (👨💻, 🏳️🌈) is
|
|
6
|
+
// glued with ZWJ. Flagging those as hidden text (scan.ts
|
|
7
|
+
// content/hidden-unicode) buried real findings under hundreds of false ones
|
|
8
|
+
// on a Persian workspace (cloudhost, 11 Nov 2026), and stripping them from an
|
|
9
|
+
// outside agent's reply (a2a-client.ts) misspelled every such word.
|
|
10
|
+
//
|
|
11
|
+
// So a joiner is spelling when it sits INSIDE a word of a script that uses
|
|
12
|
+
// joiners — a letter or mark of one on BOTH sides — or between two emoji.
|
|
13
|
+
// Anywhere else (between Latin letters, at a word's edge, alone) it is still
|
|
14
|
+
// hidden text. Every other invisible character (zero-width space, bidi
|
|
15
|
+
// overrides and isolates, word joiner, BOM, Unicode tags) is never spelling.
|
|
16
|
+
const JOINER_SCRIPTS = [
|
|
17
|
+
"Arabic", "Syriac", "Thaana", "Nko",
|
|
18
|
+
"Devanagari", "Bengali", "Gurmukhi", "Gujarati", "Oriya", "Tamil", "Telugu", "Kannada", "Malayalam", "Sinhala",
|
|
19
|
+
"Tibetan", "Myanmar", "Khmer", "Mongolian",
|
|
20
|
+
];
|
|
21
|
+
const LETTER = `(?:${JOINER_SCRIPTS.map((s) => `[\\p{scx=${s}}&&[\\p{L}\\p{M}]]`).join("|")})`;
|
|
22
|
+
/** A ZWNJ or ZWJ with a letter or mark of a joining script on each side. */
|
|
23
|
+
const IN_WORD = new RegExp(`(?<=${LETTER})[\\u200C\\u200D](?=${LETTER})`, "gv");
|
|
24
|
+
/** A ZWJ between two emoji (a skin tone or VS16 may follow the first). */
|
|
25
|
+
const IN_EMOJI = /(?<=\p{Extended_Pictographic}\u{FE0F}?[\u{1F3FB}-\u{1F3FF}]?)(?=\p{Extended_Pictographic})/gu;
|
|
26
|
+
/** The indices (UTF-16) of every joiner in `text` that is spelling, not hiding. */
|
|
27
|
+
export function spellingJoiners(text) {
|
|
28
|
+
const at = new Set();
|
|
29
|
+
if (!/[]/.test(text))
|
|
30
|
+
return at;
|
|
31
|
+
for (const re of [IN_WORD, IN_EMOJI])
|
|
32
|
+
for (const m of text.matchAll(re))
|
|
33
|
+
at.add(m.index);
|
|
34
|
+
return at;
|
|
35
|
+
}
|
package/dist/src/scan.js
CHANGED
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
// or `foldrun-ignore-file <rule>: <reason>` anywhere in a file for all of it.
|
|
26
26
|
// The reason is required: an ignore without one ignores nothing and is itself
|
|
27
27
|
// reported, because "why is this allowed?" is the question a reviewer asks.
|
|
28
|
+
import { spellingJoiners } from "./joiners.js";
|
|
28
29
|
import crypto from "node:crypto";
|
|
29
30
|
import matter, { frontmatterErrorLine, frontmatterErrorText, parseLenient, configMatter } from "./matter.js";
|
|
30
31
|
import { refNames } from "./refs.js";
|
|
@@ -566,10 +567,14 @@ function scanContent(file, lines, push, untrusted = false) {
|
|
|
566
567
|
const line = i === 0 ? lines[i].replace(/^/, "") : lines[i];
|
|
567
568
|
if (!untrusted && /^\s*(?:```|~~~)/.test(line))
|
|
568
569
|
fenced = !fenced;
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
570
|
+
// A half-space inside a Persian word, a joiner in an Indic word or an
|
|
571
|
+
// emoji sequence is spelling, not hiding (joiners.ts): not counted.
|
|
572
|
+
const spelling = spellingJoiners(line);
|
|
573
|
+
const hits = [...line.matchAll(HIDDEN)].filter((m) => !spelling.has(m.index));
|
|
574
|
+
if (hits.length) {
|
|
575
|
+
const found = hits.map((m) => m[0]).join("");
|
|
576
|
+
const kind = HIDDEN_NAMES.find(([re]) => re.test(found))?.[1] ?? "invisible characters";
|
|
577
|
+
const n = hits.length;
|
|
573
578
|
const tagged = /\uDB40[\uDC00-\uDC7F]/.test(line) ? ` that read as: "${decodeTags(line).slice(0, 80)}"` : "";
|
|
574
579
|
push("content/hidden-unicode", file.path, i + 1, line, `${n} ${kind}${redactText(tagged)} — invisible to a reviewer, read by the model`);
|
|
575
580
|
}
|
package/package.json
CHANGED
package/src/a2a-client.ts
CHANGED
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
//
|
|
24
24
|
// No vault, no MCP: values in, values out. a2a-tools.ts is the agent's side.
|
|
25
25
|
|
|
26
|
+
import { spellingJoiners } from "./joiners.ts";
|
|
26
27
|
import crypto from "node:crypto";
|
|
27
28
|
import { viaEgress } from "./egress.ts";
|
|
28
29
|
import { capBody, ResponseTooLarge } from "./untrusted-fetch.ts";
|
|
@@ -168,7 +169,11 @@ const HIDDEN = /[----\u0000-\u0008\u000B\u000C\u000E-
|
|
|
168
169
|
/** `text` with hidden characters removed, and how many there were. */
|
|
169
170
|
export function stripHidden(text: string): { text: string; removed: number } {
|
|
170
171
|
let removed = 0;
|
|
171
|
-
|
|
172
|
+
// A joiner that is spelling (a Persian half-space, an Indic or emoji
|
|
173
|
+
// joiner — joiners.ts) stays: removing it misspells the word.
|
|
174
|
+
const spelling = spellingJoiners(text);
|
|
175
|
+
const out = text.replace(HIDDEN, (m: string, at: number) => {
|
|
176
|
+
if (spelling.has(at)) return m;
|
|
172
177
|
removed++;
|
|
173
178
|
return "";
|
|
174
179
|
});
|
package/src/joiners.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// ZWNJ (U+200C) and ZWJ (U+200D) are invisible, and they are also spelling.
|
|
2
|
+
//
|
|
3
|
+
// In Persian the half-space is how a word is written: «کانالها», «میشود».
|
|
4
|
+
// Arabic-script, Syriac, Thaana and N'Ko, and the Indic and other Brahmic
|
|
5
|
+
// scripts, use both joiners inside words. An emoji sequence (👨💻, 🏳️🌈) is
|
|
6
|
+
// glued with ZWJ. Flagging those as hidden text (scan.ts
|
|
7
|
+
// content/hidden-unicode) buried real findings under hundreds of false ones
|
|
8
|
+
// on a Persian workspace (cloudhost, 11 Nov 2026), and stripping them from an
|
|
9
|
+
// outside agent's reply (a2a-client.ts) misspelled every such word.
|
|
10
|
+
//
|
|
11
|
+
// So a joiner is spelling when it sits INSIDE a word of a script that uses
|
|
12
|
+
// joiners — a letter or mark of one on BOTH sides — or between two emoji.
|
|
13
|
+
// Anywhere else (between Latin letters, at a word's edge, alone) it is still
|
|
14
|
+
// hidden text. Every other invisible character (zero-width space, bidi
|
|
15
|
+
// overrides and isolates, word joiner, BOM, Unicode tags) is never spelling.
|
|
16
|
+
|
|
17
|
+
const JOINER_SCRIPTS = [
|
|
18
|
+
"Arabic", "Syriac", "Thaana", "Nko",
|
|
19
|
+
"Devanagari", "Bengali", "Gurmukhi", "Gujarati", "Oriya", "Tamil", "Telugu", "Kannada", "Malayalam", "Sinhala",
|
|
20
|
+
"Tibetan", "Myanmar", "Khmer", "Mongolian",
|
|
21
|
+
];
|
|
22
|
+
const LETTER = `(?:${JOINER_SCRIPTS.map((s) => `[\\p{scx=${s}}&&[\\p{L}\\p{M}]]`).join("|")})`;
|
|
23
|
+
|
|
24
|
+
/** A ZWNJ or ZWJ with a letter or mark of a joining script on each side. */
|
|
25
|
+
const IN_WORD = new RegExp(`(?<=${LETTER})[\\u200C\\u200D](?=${LETTER})`, "gv");
|
|
26
|
+
/** A ZWJ between two emoji (a skin tone or VS16 may follow the first). */
|
|
27
|
+
const IN_EMOJI = /(?<=\p{Extended_Pictographic}\u{FE0F}?[\u{1F3FB}-\u{1F3FF}]?)(?=\p{Extended_Pictographic})/gu;
|
|
28
|
+
|
|
29
|
+
/** The indices (UTF-16) of every joiner in `text` that is spelling, not hiding. */
|
|
30
|
+
export function spellingJoiners(text: string): Set<number> {
|
|
31
|
+
const at = new Set<number>();
|
|
32
|
+
if (!/[]/.test(text)) return at;
|
|
33
|
+
for (const re of [IN_WORD, IN_EMOJI]) for (const m of text.matchAll(re)) at.add(m.index!);
|
|
34
|
+
return at;
|
|
35
|
+
}
|
package/src/scan.ts
CHANGED
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
// The reason is required: an ignore without one ignores nothing and is itself
|
|
27
27
|
// reported, because "why is this allowed?" is the question a reviewer asks.
|
|
28
28
|
|
|
29
|
+
import { spellingJoiners } from "./joiners.ts";
|
|
29
30
|
import crypto from "node:crypto";
|
|
30
31
|
import matter, { frontmatterErrorLine, frontmatterErrorText, parseLenient, configMatter } from "./matter.ts";
|
|
31
32
|
import { refNames } from "./refs.ts";
|
|
@@ -647,10 +648,14 @@ function scanContent(file: ScanFile, lines: string[], push: Push, untrusted = fa
|
|
|
647
648
|
for (let i = 0; i < lines.length; i++) {
|
|
648
649
|
const line = i === 0 ? lines[i]!.replace(/^/, "") : lines[i]!;
|
|
649
650
|
if (!untrusted && /^\s*(?:```|~~~)/.test(line)) fenced = !fenced;
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
651
|
+
// A half-space inside a Persian word, a joiner in an Indic word or an
|
|
652
|
+
// emoji sequence is spelling, not hiding (joiners.ts): not counted.
|
|
653
|
+
const spelling = spellingJoiners(line);
|
|
654
|
+
const hits = [...line.matchAll(HIDDEN)].filter((m) => !spelling.has(m.index!));
|
|
655
|
+
if (hits.length) {
|
|
656
|
+
const found = hits.map((m) => m[0]).join("");
|
|
657
|
+
const kind = HIDDEN_NAMES.find(([re]) => re.test(found))?.[1] ?? "invisible characters";
|
|
658
|
+
const n = hits.length;
|
|
654
659
|
const tagged = /\uDB40[\uDC00-\uDC7F]/.test(line) ? ` that read as: "${decodeTags(line).slice(0, 80)}"` : "";
|
|
655
660
|
push("content/hidden-unicode", file.path, i + 1, line, `${n} ${kind}${redactText(tagged)} — invisible to a reviewer, read by the model`);
|
|
656
661
|
}
|