@o-lang/olang 1.2.10 → 1.2.11
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/package.json +1 -1
- package/src/runtime/RuntimeAPI.js +26 -25
package/package.json
CHANGED
|
@@ -332,7 +332,7 @@ class RuntimeAPI {
|
|
|
332
332
|
}
|
|
333
333
|
|
|
334
334
|
// -----------------------------
|
|
335
|
-
// ✅ KERNEL-LEVEL LLM HALLUCINATION PREVENTION (CONJUGATION-AWARE
|
|
335
|
+
// ✅ KERNEL-LEVEL LLM HALLUCINATION PREVENTION (CONJUGATION-AWARE + EVASION-RESISTANT)
|
|
336
336
|
// -----------------------------
|
|
337
337
|
_validateLLMOutput(output, actionContext) {
|
|
338
338
|
if (!output || typeof output !== 'string') return { passed: true };
|
|
@@ -342,13 +342,13 @@ _validateLLMOutput(output, actionContext) {
|
|
|
342
342
|
.filter(name => !name.startsWith('llm-') && name !== 'builtInMathResolver')
|
|
343
343
|
.map(name => name.replace('@o-lang/', '').replace(/-resolver$/, ''));
|
|
344
344
|
|
|
345
|
-
// 🔒 CONJUGATION-AWARE PAN-AFRICAN INTENT DETECTION
|
|
345
|
+
// 🔒 CONJUGATION-AWARE + EVASION-RESISTANT PAN-AFRICAN INTENT DETECTION
|
|
346
346
|
const forbiddenPatterns = [
|
|
347
347
|
// ────────────────────────────────────────────────
|
|
348
348
|
// 🇳🇬 NIGERIAN LANGUAGES (Conjugation-aware)
|
|
349
349
|
// ────────────────────────────────────────────────
|
|
350
350
|
|
|
351
|
-
// Yoruba (yo) - Perfective
|
|
351
|
+
// Yoruba (yo) - Perfective "ti" + Progressive "ń/ǹ/n"
|
|
352
352
|
{ pattern: /\bti\s+(?:fi|san|gba|da|lo)\b/i, capability: 'unauthorized_action', lang: 'yo' }, // "has transferred/paid/withdrawn"
|
|
353
353
|
{ pattern: /\b(?:ń|ǹ|n)\s+(?:fi|san|gba)\b/i, capability: 'unauthorized_action', lang: 'yo' }, // Progressive "is transferring/paying"
|
|
354
354
|
{ pattern: /\b(fi\s+(?:owo|ẹ̀wọ̀|ewo|ku|fun|s'ọkọọ))\b/i, capability: 'transfer', lang: 'yo' },
|
|
@@ -356,7 +356,7 @@ _validateLLMOutput(output, actionContext) {
|
|
|
356
356
|
{ pattern: /\b(gba\s+owo)\b/i, capability: 'withdrawal', lang: 'yo' },
|
|
357
357
|
{ pattern: /\b(mo\s+ti\s+(?:fi|san|gba))\b/i, capability: 'unauthorized_action', lang: 'yo' },
|
|
358
358
|
|
|
359
|
-
// Hausa (ha) - Perfective
|
|
359
|
+
// Hausa (ha) - Perfective "ya/ta/su" + Future "za a/za ta"
|
|
360
360
|
{ pattern: /\b(?:ya|ta|su)\s+(?:ciyar|biya|sahawa|sake)\b/i, capability: 'unauthorized_action', lang: 'ha' }, // "he/she/they transferred/paid/withdrew/deposited"
|
|
361
361
|
{ pattern: /\b(?:za\sa|za\s+ta)\s+(?:ciyar|biya)\b/i, capability: 'unauthorized_action', lang: 'ha' }, // Future "will transfer/pay"
|
|
362
362
|
{ pattern: /\b(ciyar\s*(?:da)?|ciya\s*(?:da)?|shiga\s+kuɗi)\b/i, capability: 'transfer', lang: 'ha' },
|
|
@@ -364,7 +364,7 @@ _validateLLMOutput(output, actionContext) {
|
|
|
364
364
|
{ pattern: /\b(sahaw[ae]\s+kuɗi)\b/i, capability: 'withdrawal', lang: 'ha' },
|
|
365
365
|
{ pattern: /\b(ina\s+(?:ciyar|biya|sahawa))\b/i, capability: 'unauthorized_action', lang: 'ha' },
|
|
366
366
|
|
|
367
|
-
// Igbo (ig) - Perfective
|
|
367
|
+
// Igbo (ig) - Perfective suffixes
|
|
368
368
|
{ pattern: /\b(?:ziri|bururu|tinyere|gbara)\b/i, capability: 'unauthorized_action', lang: 'ig' }, // "has sent/carried/deposited/withdrawn"
|
|
369
369
|
{ pattern: /\b(zipu\s+(?:ego|moni|isi|na))\b/i, capability: 'transfer', lang: 'ig' },
|
|
370
370
|
{ pattern: /\b(buru\s+(?:ego|moni|isi))\b/i, capability: 'transfer', lang: 'ig' },
|
|
@@ -372,21 +372,23 @@ _validateLLMOutput(output, actionContext) {
|
|
|
372
372
|
{ pattern: /\b(m\s+(?:ziri|buru|zipuru|tinyere))\b/i, capability: 'unauthorized_action', lang: 'ig' },
|
|
373
373
|
|
|
374
374
|
// ────────────────────────────────────────────────
|
|
375
|
-
// 🌍 PAN-AFRICAN LANGUAGES (Conjugation-aware)
|
|
375
|
+
// 🌍 PAN-AFRICAN LANGUAGES (Conjugation-aware + Evasion-resistant)
|
|
376
376
|
// ────────────────────────────────────────────────
|
|
377
377
|
|
|
378
|
-
// Swahili (sw) -
|
|
379
|
-
{ pattern: /\b(?:ni|u|a|tu|m|wa|ki|vi|zi|i)\s*me\s*(?:ongeza|weka|tuma|peleka|lipa)\b/i, capability: 'unauthorized_action', lang: 'sw' }, // "I
|
|
380
|
-
{ pattern: /\b(?:kime|lime|ime|ume|nime|vime|zyme|yame|mame)(?:ongezwa|wekwa|fanyika)\b/i, capability: 'unauthorized_action', lang: 'sw' }, // Passive perfect "has been added
|
|
381
|
-
{ pattern: /\b(
|
|
378
|
+
// Swahili (sw) - ALL ASPECTS: Perfect, Continuous Passive, Future
|
|
379
|
+
{ pattern: /\b(?:ni|u|a|tu|m|wa|ki|vi|zi|i)\s*me\s*(?:ongeza|weka|tuma|peleka|lipa|wasilisha)\b/i, capability: 'unauthorized_action', lang: 'sw' }, // Perfect: "nimeongeza" (I have added)
|
|
380
|
+
{ pattern: /\b(?:kime|lime|ime|ume|nime|vime|zyme|yame|mame)(?:ongezwa|wekwa|tumwa|pelekwa|lipwa|wasilishwa|fanyika)\b/i, capability: 'unauthorized_action', lang: 'sw' }, // Passive perfect: "kimeongezwa" (has been added)
|
|
381
|
+
{ pattern: /\b(?:ki|vi|mi|ma|u|wa|i|zi|ya|li|tu|mu|a|pa|ku)na(?:cho|vyo|yo|lo|mo|o)?(?:tum|pelek|wasil|ongez|wek|lip)\w*wa\b/i, capability: 'unauthorized_action', lang: 'sw' }, // Continuous passive: "kinachowasilishwa" (is being delivered) ← CRITICAL FIX
|
|
382
|
+
{ pattern: /\b(?:ki|vi|mi|ma|u|wa|i|zi|ya|li|tu|mu|a|pa|ku)ta(?:tum|pelek|wasil|ongez|wek|lip)\w*\b/i, capability: 'unauthorized_action', lang: 'sw' }, // Future: "kitatuma" (will send)
|
|
383
|
+
{ pattern: /\b(tuma\s+(?:pesa|fedha)|pelek[ae]?\s+(?:pesa|fedha)|wasilisha)\b/i, capability: 'transfer', lang: 'sw' },
|
|
382
384
|
{ pattern: /\b(lipa|maliza\s+malipo)\b/i, capability: 'payment', lang: 'sw' },
|
|
383
385
|
{ pattern: /\b(ongez[ae]?\s*(?:kiasi|pesa|fedha)|wek[ae]?\s+(?:katika|ndani)\s+(?:akaunti|hisa))\b/i, capability: 'deposit', lang: 'sw' },
|
|
384
386
|
{ pattern: /\b(nime(?:tuma|lipa|ongeza|weka|peleka))\b/i, capability: 'unauthorized_action', lang: 'sw' },
|
|
385
387
|
|
|
386
|
-
// Amharic (am) - Perfective suffix
|
|
387
|
-
{ pattern: /[\u1200-\u137F]{0,4}(?:ተላላፈ|ላክ|ክፈል|ጨምር|ወጣ|ገባ)[\u1200-\u137F]{0,2}(?:\u1205|\u122d|\u1265)[\u1200-\u137F]{0,2}/u, capability: 'financial_action', lang: 'am' },
|
|
388
|
+
// Amharic (am) - Perfective suffix (Ethiopic script)
|
|
389
|
+
{ pattern: /[\u1200-\u137F]{0,4}(?:ተላላፈ|ላክ|ክፈል|ጨምር|ወጣ|ገባ)[\u1200-\u137F]{0,2}(?:\u1205|\u122d|\u1265)[\u1200-\u137F]{0,2}/u, capability: 'financial_action', lang: 'am' },
|
|
388
390
|
|
|
389
|
-
// Oromo (om) - Perfective "ni...e"
|
|
391
|
+
// Oromo (om) - Perfective "ni...e"
|
|
390
392
|
{ pattern: /\bni\s+(?:kuufe|dhiibe|kennine|gurgure)\b/i, capability: 'unauthorized_action', lang: 'om' },
|
|
391
393
|
{ pattern: /\b(kuuf\s+(?:qilleensaa|bilbila)|dhiib\s+(?:qilleensaa|bilbila))\b/i, capability: 'transfer', lang: 'om' },
|
|
392
394
|
{ pattern: /\b(kenn\s*i|gurgur\s*i)\b/i, capability: 'payment', lang: 'om' },
|
|
@@ -395,18 +397,18 @@ _validateLLMOutput(output, actionContext) {
|
|
|
395
397
|
{ pattern: /\b(sakkit\s+(?:ndo|ndoo)|tawt\s+(?:ndo|ndoo))\b/i, capability: 'transfer', lang: 'ff' },
|
|
396
398
|
{ pattern: /\b(jokk\s*i|soodug\s*i)\b/i, capability: 'payment', lang: 'ff' },
|
|
397
399
|
|
|
398
|
-
// Somali (so) - Perfective "waxaa"
|
|
400
|
+
// Somali (so) - Perfective "waxaa"
|
|
399
401
|
{ pattern: /\bwaxaa\s+(?:diray|bixiyay|ku\s+daray|sameeyay)\b/i, capability: 'unauthorized_action', lang: 'so' },
|
|
400
402
|
{ pattern: /\b(dir\s+(?:lacag|maal|qarsoon))\b/i, capability: 'transfer', lang: 'so' },
|
|
401
403
|
{ pattern: /\b(bixi|bixis\s*o)\b/i, capability: 'payment', lang: 'so' },
|
|
402
404
|
|
|
403
|
-
// Zulu (zu) - Perfective
|
|
405
|
+
// Zulu (zu) - Perfective "-ile"
|
|
404
406
|
{ pattern: /\b(?:thumel|hlawul|fik)\s*ile\b/i, capability: 'unauthorized_action', lang: 'zu' },
|
|
405
407
|
{ pattern: /\b(thumel\s*a\s+(?:imali|imali))\b/i, capability: 'transfer', lang: 'zu' },
|
|
406
408
|
{ pattern: /\b(hlawul\s*a|hlawulel\s*a)\b/i, capability: 'payment', lang: 'zu' },
|
|
407
409
|
{ pattern: /\b(siyithumel\s*e|siyihlawul\s*e)\b/i, capability: 'unauthorized_action', lang: 'zu' },
|
|
408
410
|
|
|
409
|
-
// Shona (sn) - Perfective
|
|
411
|
+
// Shona (sn) - Perfective "-a/-e"
|
|
410
412
|
{ pattern: /\b(?:tumir|bhadhar)\s*a\b/i, capability: 'unauthorized_action', lang: 'sn' },
|
|
411
413
|
{ pattern: /\b(tumir\s*a\s+(?:mhando|ari))\b/i, capability: 'transfer', lang: 'sn' },
|
|
412
414
|
{ pattern: /\b(bhadhara|bhadharis\s*o)\b/i, capability: 'payment', lang: 'sn' },
|
|
@@ -415,17 +417,17 @@ _validateLLMOutput(output, actionContext) {
|
|
|
415
417
|
// 🌐 GLOBAL LANGUAGES (Conjugation-aware)
|
|
416
418
|
// ────────────────────────────────────────────────
|
|
417
419
|
|
|
418
|
-
// English (en) - Perfective
|
|
420
|
+
// English (en) - Perfective + Passive
|
|
419
421
|
{ pattern: /\b(?:have|has|had)\s+(?:transferred|sent|paid|withdrawn|deposited|wire[d])\b/i, capability: 'unauthorized_action', lang: 'en' },
|
|
420
422
|
{ pattern: /\b(?:was|were|been)\s+(?:added|credited|transferred|sent|paid)\b/i, capability: 'unauthorized_action', lang: 'en' },
|
|
421
423
|
{ pattern: /\b(transfer(?:red|ring)?|send(?:t|ing)?|wire(?:d)?|pay(?:ed|ing)?|withdraw(?:n)?|deposit(?:ed|ing)?|disburse(?:d)?)\b/i, capability: 'financial_action', lang: 'en' },
|
|
422
424
|
{ pattern: /\bI\s+(?:can|will|am able to|have|'ve|did|already)\s+(?:transfer|send|pay|withdraw|deposit|wire)\b/i, capability: 'unauthorized_action', lang: 'en' },
|
|
423
425
|
|
|
424
|
-
// French (fr) - Past participle
|
|
426
|
+
// French (fr) - Past participle
|
|
425
427
|
{ pattern: /\b(?:j'?ai|tu as|il a|elle a|nous avons|vous avez|ils ont|elles ont)\s+(?:viré|transféré|envoyé|payé|retiré|déposé)\b/i, capability: 'unauthorized_action', lang: 'fr' },
|
|
426
428
|
{ pattern: /\b(virer|transférer|envoyer|payer|retirer|déposer|débiter|créditer)\b/i, capability: 'financial_action', lang: 'fr' },
|
|
427
429
|
|
|
428
|
-
// Arabic (ar) - Perfective past tense
|
|
430
|
+
// Arabic (ar) - Perfective past tense
|
|
429
431
|
{ pattern: /[\u0600-\u06FF]{0,3}(?:حوّل|أرسل|ادفع|اودع|سحب)[\u0600-\u06FF]{0,3}(?:ت|نا|تم|تا|تِ|تُ|تَ)[\u0600-\u06FF]{0,3}/u, capability: 'financial_action', lang: 'ar' },
|
|
430
432
|
{ pattern: /[\u0600-\u06FF]{0,3}(?:أنا|تم|لقد)\s*(?:حوّلت|أرسلت|دفعت|اودعت)[\u0600-\u06FF]{0,3}/u, capability: 'unauthorized_action', lang: 'ar' },
|
|
431
433
|
|
|
@@ -435,13 +437,12 @@ _validateLLMOutput(output, actionContext) {
|
|
|
435
437
|
{ pattern: /[\u4e00-\u9fff]{0,2}(?:我|已|已经)\s*(?:转账|支付|提款|存款)[\u4e00-\u9fff]{0,2}/u, capability: 'unauthorized_action', lang: 'zh' },
|
|
436
438
|
|
|
437
439
|
// ────────────────────────────────────────────────
|
|
438
|
-
// 🛡️
|
|
440
|
+
// 🛡️ EVASION-RESISTANT NUMERIC DECEPTION (Catches obfuscated claims)
|
|
439
441
|
// ────────────────────────────────────────────────
|
|
440
442
|
|
|
441
|
-
//
|
|
443
|
+
// Number + account reference within 40 chars (catches "10,000 ... account 123")
|
|
442
444
|
{
|
|
443
|
-
pattern:
|
|
444
|
-
/(?:^|\s|[:\(\[—–\-])(?:\d{1,3}(?:[,\s.]\d{3})*(?:[.,]\d{1,2})?|\d+(?:[.,]\d{1,2})?)(?:\s*(?:naira|ngn|₦|\$|usd|dollars?|euros?|€|pounds?|£|kes|tzs|ugx|rwf|cdf|xof|xaf|ghs|zar|cfa|francs?|rand|shillings?|birr|naira|kobo|pesa|fedha|maal|qarsoon|lacag|imali|mhando|ari|kuɗi|owo|ego|moni|isi))?\s*(?:added|credited|deposited|transferred|sent|wire[d]?|paid|moved|ongezwa|wekwa|saki|ceba|fi\s+si|zipu|buru|tinye|gba|san|ciyar|biya|tuma|peleka|lipa|viré|transféré|envoyé|payé|retiré|déposé|حوّل|أرسل|ادفع|اودع|سحب|转账|支付|存款|取款)\b/i,
|
|
445
|
+
pattern: /(?:^|\s|[:\(\[])(?:\d{1,3}(?:[,\s.]\d{3})*(?:[.,]\d{1,2})?|\d+(?:[.,]\d{1,2})?)(?:\s*(?:naira|ngn|₦|\$|usd|kes|tzs|ugx|rwf|cdf|xof|xaf|ghs|zar))?.{0,40}(?:account|acct|a\/c|akaunti|asusu|akwụkwọ\s+ọkụ|hesabu|namba|#)\b/i,
|
|
445
446
|
capability: 'unauthorized_action',
|
|
446
447
|
lang: 'multi'
|
|
447
448
|
},
|
|
@@ -450,7 +451,7 @@ _validateLLMOutput(output, actionContext) {
|
|
|
450
451
|
// 🔒 PII LEAKAGE PATTERNS
|
|
451
452
|
// ────────────────────────────────────────────────
|
|
452
453
|
|
|
453
|
-
// Account numbers (6+ digits
|
|
454
|
+
// Account numbers (6+ digits)
|
|
454
455
|
{ pattern: /\b(?:account|acct|a\/c|akaunti|asusu|akwụkwọ\s+ọkụ|hesabu|namba|#)\s*[:\-—–]?\s*(\d{6,})\b/i, capability: 'pii_exposure', lang: 'multi' },
|
|
455
456
|
|
|
456
457
|
// Nigerian BVN (11 digits)
|
|
@@ -460,7 +461,7 @@ _validateLLMOutput(output, actionContext) {
|
|
|
460
461
|
{ pattern: /\b(?:\+?234\s*|0)(?:70|80|81|90|91)\d{8}\b/, capability: 'pii_exposure', lang: 'multi' },
|
|
461
462
|
|
|
462
463
|
// ────────────────────────────────────────────────
|
|
463
|
-
// ✅ FAKE CONFIRMATION PATTERNS
|
|
464
|
+
// ✅ FAKE CONFIRMATION PATTERNS
|
|
464
465
|
// ────────────────────────────────────────────────
|
|
465
466
|
|
|
466
467
|
{ pattern: /\b(successful(?:ly)?|confirmed|approved|completed|processed|accepted|verified|imethibitishwa|imefanikiwa|amthibitishwa|ti\s+da|ti\s+ṣe|gụnyere|kimefanyika|yamekamilika)\b/i, capability: 'deceptive_claim', lang: 'multi' }
|