@o-lang/olang 1.2.8 → 1.2.10

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@o-lang/olang",
3
- "version": "1.2.8",
3
+ "version": "1.2.10",
4
4
  "author": "Olalekan Ogundipe <info@workfily.com>",
5
5
  "description": "O-Lang: A governance language for user-directed, rule-enforced agent workflows",
6
6
  "main": "./src/index.js",
@@ -332,7 +332,7 @@ class RuntimeAPI {
332
332
  }
333
333
 
334
334
  // -----------------------------
335
- // ✅ KERNEL-LEVEL LLM HALLUCINATION PREVENTION (PAN-AFRICAN SEMANTIC SAFETY)
335
+ // ✅ KERNEL-LEVEL LLM HALLUCINATION PREVENTION (CONJUGATION-AWARE SEMANTIC SAFETY)
336
336
  // -----------------------------
337
337
  _validateLLMOutput(output, actionContext) {
338
338
  if (!output || typeof output !== 'string') return { passed: true };
@@ -342,94 +342,106 @@ _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
- // 🔒 PAN-AFRICAN + GLOBAL INTENT DETECTION (Deterministic, No LLM Required)
345
+ // 🔒 CONJUGATION-AWARE PAN-AFRICAN INTENT DETECTION
346
346
  const forbiddenPatterns = [
347
347
  // ────────────────────────────────────────────────
348
- // 🇳🇬 NIGERIAN LANGUAGES (Priority)
348
+ // 🇳🇬 NIGERIAN LANGUAGES (Conjugation-aware)
349
349
  // ────────────────────────────────────────────────
350
350
 
351
- // Yoruba (yo)
351
+ // Yoruba (yo) - Perfective aspect "ti" (has done) + Progressive "ń/ǹ/n"
352
+ { pattern: /\bti\s+(?:fi|san|gba|da|lo)\b/i, capability: 'unauthorized_action', lang: 'yo' }, // "has transferred/paid/withdrawn"
353
+ { pattern: /\b(?:ń|ǹ|n)\s+(?:fi|san|gba)\b/i, capability: 'unauthorized_action', lang: 'yo' }, // Progressive "is transferring/paying"
352
354
  { pattern: /\b(fi\s+(?:owo|ẹ̀wọ̀|ewo|ku|fun|s'ọkọọ))\b/i, capability: 'transfer', lang: 'yo' },
353
355
  { pattern: /\b(san\s+(?:owo|ẹ̀wọ̀|ewo|fun|wo))\b/i, capability: 'payment', lang: 'yo' },
354
356
  { pattern: /\b(gba\s+owo)\b/i, capability: 'withdrawal', lang: 'yo' },
355
357
  { pattern: /\b(mo\s+ti\s+(?:fi|san|gba))\b/i, capability: 'unauthorized_action', lang: 'yo' },
356
358
 
357
- // Hausa (ha)
359
+ // Hausa (ha) - Perfective aspect "ya/ta/su" (he/she/they did) + Future "za a/za ta"
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
+ { pattern: /\b(?:za\sa|za\s+ta)\s+(?:ciyar|biya)\b/i, capability: 'unauthorized_action', lang: 'ha' }, // Future "will transfer/pay"
358
362
  { pattern: /\b(ciyar\s*(?:da)?|ciya\s*(?:da)?|shiga\s+kuɗi)\b/i, capability: 'transfer', lang: 'ha' },
359
363
  { pattern: /\b(biya\s*(?:da)?)\b/i, capability: 'payment', lang: 'ha' },
360
364
  { pattern: /\b(sahaw[ae]\s+kuɗi)\b/i, capability: 'withdrawal', lang: 'ha' },
361
365
  { pattern: /\b(ina\s+(?:ciyar|biya|sahawa))\b/i, capability: 'unauthorized_action', lang: 'ha' },
362
366
 
363
- // Igbo (ig)
367
+ // Igbo (ig) - Perfective aspect (verb + "riri/ere")
368
+ { pattern: /\b(?:ziri|bururu|tinyere|gbara)\b/i, capability: 'unauthorized_action', lang: 'ig' }, // "has sent/carried/deposited/withdrawn"
364
369
  { pattern: /\b(zipu\s+(?:ego|moni|isi|na))\b/i, capability: 'transfer', lang: 'ig' },
365
370
  { pattern: /\b(buru\s+(?:ego|moni|isi))\b/i, capability: 'transfer', lang: 'ig' },
366
371
  { pattern: /\b(tinye\s+(?:ego|moni|isi))\b/i, capability: 'deposit', lang: 'ig' },
367
372
  { pattern: /\b(m\s+(?:ziri|buru|zipuru|tinyere))\b/i, capability: 'unauthorized_action', lang: 'ig' },
368
373
 
369
374
  // ────────────────────────────────────────────────
370
- // 🌍 PAN-AFRICAN LANGUAGES
375
+ // 🌍 PAN-AFRICAN LANGUAGES (Conjugation-aware)
371
376
  // ────────────────────────────────────────────────
372
377
 
373
- // Swahili (sw) - 200M+ speakers
378
+ // Swahili (sw) - Perfect tense (subject prefix + "me" + verb) + Passive perfect
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/you/he has added/put/sent/paid"
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/put/done"
374
381
  { pattern: /\b(tuma\s+(?:pesa|fedha)|pelek[ae]?\s+(?:pesa|fedha))\b/i, capability: 'transfer', lang: 'sw' },
375
382
  { pattern: /\b(lipa|maliza\s+malipo)\b/i, capability: 'payment', lang: 'sw' },
376
383
  { pattern: /\b(ongez[ae]?\s*(?:kiasi|pesa|fedha)|wek[ae]?\s+(?:katika|ndani)\s+(?:akaunti|hisa))\b/i, capability: 'deposit', lang: 'sw' },
377
384
  { pattern: /\b(nime(?:tuma|lipa|ongeza|weka|peleka))\b/i, capability: 'unauthorized_action', lang: 'sw' },
378
385
 
379
- // Amharic (am) - Ethiopia (Ethiopic script U+1200-U+137F)
380
- { pattern: /[\u1200-\u137F]{0,4}(?:ተላላፈ|ላክ|ክፈል|ጨምር|ወጣ|ገባ)[\u1200-\u137F]{0,4}/u, capability: 'financial_action', lang: 'am' },
386
+ // Amharic (am) - Perfective suffix "-e" / "-u" (Ethiopic script U+1200-U+137F)
387
+ { pattern: /[\u1200-\u137F]{0,4}(?:ተላላፈ|ላክ|ክፈል|ጨምር|ወጣ|ገባ)[\u1200-\u137F]{0,2}(?:\u1205|\u122d|\u1265)[\u1200-\u137F]{0,2}/u, capability: 'financial_action', lang: 'am' }, // Verb + perfective marker
381
388
 
382
- // Oromo (om)
389
+ // Oromo (om) - Perfective "ni...e" construction
390
+ { pattern: /\bni\s+(?:kuufe|dhiibe|kennine|gurgure)\b/i, capability: 'unauthorized_action', lang: 'om' },
383
391
  { pattern: /\b(kuuf\s+(?:qilleensaa|bilbila)|dhiib\s+(?:qilleensaa|bilbila))\b/i, capability: 'transfer', lang: 'om' },
384
392
  { pattern: /\b(kenn\s*i|gurgur\s*i)\b/i, capability: 'payment', lang: 'om' },
385
- { pattern: /\b(ni\s+(?:kuufe|dhiibe|kennine|gurgure))\b/i, capability: 'unauthorized_action', lang: 'om' },
386
393
 
387
394
  // Fula (ff)
388
395
  { pattern: /\b(sakkit\s+(?:ndo|ndoo)|tawt\s+(?:ndo|ndoo))\b/i, capability: 'transfer', lang: 'ff' },
389
396
  { pattern: /\b(jokk\s*i|soodug\s*i)\b/i, capability: 'payment', lang: 'ff' },
390
397
 
391
- // Somali (so)
398
+ // Somali (so) - Perfective "waxaa" + past participle
399
+ { pattern: /\bwaxaa\s+(?:diray|bixiyay|ku\s+daray|sameeyay)\b/i, capability: 'unauthorized_action', lang: 'so' },
392
400
  { pattern: /\b(dir\s+(?:lacag|maal|qarsoon))\b/i, capability: 'transfer', lang: 'so' },
393
401
  { pattern: /\b(bixi|bixis\s*o)\b/i, capability: 'payment', lang: 'so' },
394
- { pattern: /\b(waxaa\s+(?:diray|bixiyay|ku\s+daray))\b/i, capability: 'unauthorized_action', lang: 'so' },
395
402
 
396
- // Zulu (zu)
403
+ // Zulu (zu) - Perfective suffix "-ile" / "-e"
404
+ { pattern: /\b(?:thumel|hlawul|fik)\s*ile\b/i, capability: 'unauthorized_action', lang: 'zu' },
397
405
  { pattern: /\b(thumel\s*a\s+(?:imali|imali))\b/i, capability: 'transfer', lang: 'zu' },
398
406
  { pattern: /\b(hlawul\s*a|hlawulel\s*a)\b/i, capability: 'payment', lang: 'zu' },
399
407
  { pattern: /\b(siyithumel\s*e|siyihlawul\s*e)\b/i, capability: 'unauthorized_action', lang: 'zu' },
400
408
 
401
- // Shona (sn)
409
+ // Shona (sn) - Perfective suffix "-a" / "-e"
410
+ { pattern: /\b(?:tumir|bhadhar)\s*a\b/i, capability: 'unauthorized_action', lang: 'sn' },
402
411
  { pattern: /\b(tumir\s*a\s+(?:mhando|ari))\b/i, capability: 'transfer', lang: 'sn' },
403
412
  { pattern: /\b(bhadhara|bhadharis\s*o)\b/i, capability: 'payment', lang: 'sn' },
404
413
 
405
414
  // ────────────────────────────────────────────────
406
- // 🌐 GLOBAL LANGUAGES
415
+ // 🌐 GLOBAL LANGUAGES (Conjugation-aware)
407
416
  // ────────────────────────────────────────────────
408
417
 
409
- // English (en)
418
+ // English (en) - Perfective "have/has/had + past participle" + Passive "was/were"
419
+ { pattern: /\b(?:have|has|had)\s+(?:transferred|sent|paid|withdrawn|deposited|wire[d])\b/i, capability: 'unauthorized_action', lang: 'en' },
420
+ { pattern: /\b(?:was|were|been)\s+(?:added|credited|transferred|sent|paid)\b/i, capability: 'unauthorized_action', lang: 'en' },
410
421
  { 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' },
411
422
  { 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' },
412
423
 
413
- // French (fr)
424
+ // French (fr) - Past participle "a/ont + verbé"
425
+ { 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' },
414
426
  { pattern: /\b(virer|transférer|envoyer|payer|retirer|déposer|débiter|créditer)\b/i, capability: 'financial_action', lang: 'fr' },
415
- { pattern: /\b(j'?ai\s+(?:viré|transféré|envoyé|payé|retiré|déposé))\b/i, capability: 'unauthorized_action', lang: 'fr' },
416
427
 
417
- // Arabic (ar) - Unicode Arabic block U+0600-U+06FF
418
- { pattern: /[\u0600-\u06FF]{0,3}(?:حوّل|حول|أرسل|ارسل|ادفع|اودع|سحب|استخرج|حوالة|إيداع|سحب)[\u0600-\u06FF]{0,3}/u, capability: 'financial_action', lang: 'ar' },
428
+ // Arabic (ar) - Perfective past tense (fa'ala form) + subject markers
429
+ { pattern: /[\u0600-\u06FF]{0,3}(?:حوّل|أرسل|ادفع|اودع|سحب)[\u0600-\u06FF]{0,3}(?:ت|نا|تم|تا|تِ|تُ|تَ)[\u0600-\u06FF]{0,3}/u, capability: 'financial_action', lang: 'ar' },
419
430
  { pattern: /[\u0600-\u06FF]{0,3}(?:أنا|تم|لقد)\s*(?:حوّلت|أرسلت|دفعت|اودعت)[\u0600-\u06FF]{0,3}/u, capability: 'unauthorized_action', lang: 'ar' },
420
431
 
421
- // Chinese (zh) - Han script U+4E00-U+9FFF
432
+ // Chinese (zh) - Perfective "le" particle
433
+ { pattern: /[\u4e00-\u9fff]{0,2}(?:转账|支付|存款|取款)[\u4e00-\u9fff]{0,2}(?:了)[\u4e00-\u9fff]{0,2}/u, capability: 'financial_action', lang: 'zh' },
422
434
  { pattern: /[\u4e00-\u9fff]{0,2}(?:转账|转帐|支付|付款|提款|取款|存款|存入|汇款|存)[\u4e00-\u9fff]{0,2}/u, capability: 'financial_action', lang: 'zh' },
423
435
  { pattern: /[\u4e00-\u9fff]{0,2}(?:我|已|已经)\s*(?:转账|支付|提款|存款)[\u4e00-\u9fff]{0,2}/u, capability: 'unauthorized_action', lang: 'zh' },
424
436
 
425
437
  // ────────────────────────────────────────────────
426
- // 🛡️ LANGUAGE-AGNOSTIC NUMERIC DECEPTION (Critical!)
438
+ // 🛡️ LANGUAGE-AGNOSTIC NUMERIC DECEPTION (Conjugation-agnostic)
427
439
  // ────────────────────────────────────────────────
428
440
 
429
- // Universal number formats: 1,000 | 1 000 | 1.000 | 1000 | 10,000.50 | 10.000,50
441
+ // Universal number formats + action verbs (catches all conjugations via verb roots)
430
442
  {
431
443
  pattern:
432
- /(?:^|\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*(?:was\s+(?:added|credited|deposited|transferred|sent|wire[d]?|paid|moved)|has\s+been\s+(?:added|credited|deposited|transferred|sent|paid|moved)|will\s+be\s+(?:added|credited|deposited|transferred|sent|paid|moved)|get\s+(?:added|credited|deposited)|na\s+(?:sake|saki|ce|ceba)|ni\s+(?:sake|saki)|an\s+(?:sake|saki|ce|ceba)|ongezwa|wekwa|wekewa|saki|sake|ti\s+wa\s+kun|fi\s+si|zipu|buru|tinye|gba|san|fi\s+owo|ciyar|biya|nime(?:tuma|lipa|ongeza|weka|peleka)|ni(?:kuufe|dhiibe|kennine|gurgure)|waxaa\s+(?:diray|bixiyay|ku\s+daray)|siyi(?:thumelwe|hlawulwe)|tumirirwa|bhadharirwa|ime(?:thibitishwa|fanikiwa|kamilika)|مضاف|محول|مدفوع|مودع|تم|أضيف|حوّل|أرسل|ادفع|اودع|سحب|تمت|الإيداع|السحب|转账|支付|存入|已转账|已支付|已存入|汇款|存|取款)\b/i,
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,
433
445
  capability: 'unauthorized_action',
434
446
  lang: 'multi'
435
447
  },
@@ -438,8 +450,8 @@ _validateLLMOutput(output, actionContext) {
438
450
  // 🔒 PII LEAKAGE PATTERNS
439
451
  // ────────────────────────────────────────────────
440
452
 
441
- // Account numbers (6+ digits)
442
- { pattern: /\b(?:account|acct|a\/c|akaunti|asusu|akwụkwọ\s+ọkụ|hesabu|#)\s*[:\-—–]?\s*(\d{6,})\b/i, capability: 'pii_exposure', lang: 'multi' },
453
+ // Account numbers (6+ digits after context words)
454
+ { 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' },
443
455
 
444
456
  // Nigerian BVN (11 digits)
445
457
  { pattern: /\b(?:bvn|bank verification number)\s*[:\-]?\s*(\d{11})\b/i, capability: 'pii_exposure', lang: 'multi' },
@@ -448,11 +460,10 @@ _validateLLMOutput(output, actionContext) {
448
460
  { pattern: /\b(?:\+?234\s*|0)(?:70|80|81|90|91)\d{8}\b/, capability: 'pii_exposure', lang: 'multi' },
449
461
 
450
462
  // ────────────────────────────────────────────────
451
- // ✅ FAKE CONFIRMATION PATTERNS
463
+ // ✅ FAKE CONFIRMATION PATTERNS (All tenses/aspects)
452
464
  // ────────────────────────────────────────────────
453
465
 
454
- // Success/confirmation in multiple languages
455
- { pattern: /\b(successful(?:ly)?|confirmed|approved|completed|processed|accepted|verified|imethibitishwa|imefanikiwa|amthibitishwa|ti\s+da|ti\s+ṣe|gụnyere)\b/i, capability: 'deceptive_claim', lang: 'multi' }
466
+ { 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' }
456
467
  ];
457
468
 
458
469
  // 🔍 SCAN OUTPUT FOR FORBIDDEN INTENTS
@@ -463,7 +474,9 @@ _validateLLMOutput(output, actionContext) {
463
474
  c.includes(capability) ||
464
475
  c.includes('transfer') ||
465
476
  c.includes('payment') ||
466
- c.includes('financial')
477
+ c.includes('financial') ||
478
+ c.includes('deposit') ||
479
+ c.includes('withdraw')
467
480
  );
468
481
 
469
482
  if (!hasCapability) {
@@ -479,7 +492,6 @@ _validateLLMOutput(output, actionContext) {
479
492
  }
480
493
 
481
494
  return { passed: true };
482
- }
483
495
  }
484
496
  // -----------------------------
485
497
  // ✅ CRITICAL FIX: Resolver output unwrapping helper