UNPKG

noa-receipt

Version:

NOA Agent Action Receipt — open, offline-verifiable provenance for AI-agent actions. The governance/receipt organ only; the NOA brain is separate and proprietary.

42 lines (41 loc) • 1.32 kB
import { arrayPush, strCharCodeAt, strNormalize, isArray, objectKeys, arrayLength } from "./intrinsics.js"; export function isNFC(s) { for (let i = 0; i < s.length; i++) { if (strCharCodeAt(s, i) > 0x7f) return strNormalize(s, "NFC") === s; } return true; } export function nonNfcPaths(value, limit = 16) { const out = []; const walk = (v, path) => { if (out.length >= limit) return; if (typeof v === "string") { if (!isNFC(v)) arrayPush(out, path); return; } if (isArray(v)) { const n = arrayLength(v); for (let i = 0; i < n && out.length < limit; i++) walk(v[i], `${path}[${i}]`); return; } if (typeof v === "object" && v !== null) { const keys = objectKeys(v); const kn = arrayLength(keys); for (let ki = 0; ki < kn; ki++) { if (out.length >= limit) return; const k = keys[ki]; const child = path === "" ? k : `${path}.${k}`; if (!isNFC(k)) arrayPush(out, `${child} (member name)`); walk(v[k], child); } } }; walk(value, ""); return out; }