@o-lang/olang 1.2.6 โ†’ 1.2.8

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.6",
3
+ "version": "1.2.8",
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",
@@ -331,40 +331,156 @@ class RuntimeAPI {
331
331
  });
332
332
  }
333
333
 
334
- // -----------------------------
335
- // โœ… KERNEL-LEVEL LLM HALLUCINATION PREVENTION (ZERO WORKFLOW CHANGES)
336
- // -----------------------------
337
- _validateLLMOutput(output, actionContext) {
338
- if (!output || typeof output !== 'string') return { passed: true };
339
-
340
- // ๐Ÿ”‘ CRITICAL: Extract ONLY allowed capabilities from workflow allowlist
341
- const allowedCapabilities = Array.from(this.allowedResolvers)
342
- .filter(name => !name.startsWith('llm-') && name !== 'builtInMathResolver')
343
- .map(name => name.replace('@o-lang/', '').replace(/-resolver$/, ''));
344
-
345
- // ๐Ÿ”’ Block capability hallucinations (claims to do things outside allowlist)
346
- const forbiddenPatterns = [
347
- { pattern: /\b(transfer|send|wire|pay|withdraw|deposit)\b/i, capability: 'transfer' },
348
- { pattern: /\b(create|open|close|delete)\s+(account|profile)\b/i, capability: 'account_management' },
349
- { pattern: /\bI (can|will|am able to)\s+(transfer|pay|send)/i, capability: 'unauthorized_action' }
350
- ];
351
-
352
- for (const { pattern, capability } of forbiddenPatterns) {
353
- if (pattern.test(output)) {
354
- // โœ… Only block if capability NOT in allowlist
355
- if (!allowedCapabilities.some(c => c.includes(capability) || c.includes('transfer'))) {
356
- return {
357
- passed: false,
358
- reason: `Hallucinated "${capability}" capability (not in workflow allowlist: ${allowedCapabilities.join(', ') || 'none'})`,
359
- detected: output.match(pattern)?.[0] || 'unknown'
360
- };
361
- }
334
+ // -----------------------------
335
+ // โœ… KERNEL-LEVEL LLM HALLUCINATION PREVENTION (PAN-AFRICAN SEMANTIC SAFETY)
336
+ // -----------------------------
337
+ _validateLLMOutput(output, actionContext) {
338
+ if (!output || typeof output !== 'string') return { passed: true };
339
+
340
+ // ๐Ÿ”‘ Extract allowed capabilities from workflow allowlist
341
+ const allowedCapabilities = Array.from(this.allowedResolvers)
342
+ .filter(name => !name.startsWith('llm-') && name !== 'builtInMathResolver')
343
+ .map(name => name.replace('@o-lang/', '').replace(/-resolver$/, ''));
344
+
345
+ // ๐Ÿ”’ PAN-AFRICAN + GLOBAL INTENT DETECTION (Deterministic, No LLM Required)
346
+ const forbiddenPatterns = [
347
+ // โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
348
+ // ๐Ÿ‡ณ๐Ÿ‡ฌ NIGERIAN LANGUAGES (Priority)
349
+ // โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
350
+
351
+ // Yoruba (yo)
352
+ { pattern: /\b(fi\s+(?:owo|แบนฬ€wแปฬ€|ewo|ku|fun|s'แปkแปแป))\b/i, capability: 'transfer', lang: 'yo' },
353
+ { pattern: /\b(san\s+(?:owo|แบนฬ€wแปฬ€|ewo|fun|wo))\b/i, capability: 'payment', lang: 'yo' },
354
+ { pattern: /\b(gba\s+owo)\b/i, capability: 'withdrawal', lang: 'yo' },
355
+ { pattern: /\b(mo\s+ti\s+(?:fi|san|gba))\b/i, capability: 'unauthorized_action', lang: 'yo' },
356
+
357
+ // Hausa (ha)
358
+ { pattern: /\b(ciyar\s*(?:da)?|ciya\s*(?:da)?|shiga\s+kuษ—i)\b/i, capability: 'transfer', lang: 'ha' },
359
+ { pattern: /\b(biya\s*(?:da)?)\b/i, capability: 'payment', lang: 'ha' },
360
+ { pattern: /\b(sahaw[ae]\s+kuษ—i)\b/i, capability: 'withdrawal', lang: 'ha' },
361
+ { pattern: /\b(ina\s+(?:ciyar|biya|sahawa))\b/i, capability: 'unauthorized_action', lang: 'ha' },
362
+
363
+ // Igbo (ig)
364
+ { pattern: /\b(zipu\s+(?:ego|moni|isi|na))\b/i, capability: 'transfer', lang: 'ig' },
365
+ { pattern: /\b(buru\s+(?:ego|moni|isi))\b/i, capability: 'transfer', lang: 'ig' },
366
+ { pattern: /\b(tinye\s+(?:ego|moni|isi))\b/i, capability: 'deposit', lang: 'ig' },
367
+ { pattern: /\b(m\s+(?:ziri|buru|zipuru|tinyere))\b/i, capability: 'unauthorized_action', lang: 'ig' },
368
+
369
+ // โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
370
+ // ๐ŸŒ PAN-AFRICAN LANGUAGES
371
+ // โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
372
+
373
+ // Swahili (sw) - 200M+ speakers
374
+ { pattern: /\b(tuma\s+(?:pesa|fedha)|pelek[ae]?\s+(?:pesa|fedha))\b/i, capability: 'transfer', lang: 'sw' },
375
+ { pattern: /\b(lipa|maliza\s+malipo)\b/i, capability: 'payment', lang: 'sw' },
376
+ { pattern: /\b(ongez[ae]?\s*(?:kiasi|pesa|fedha)|wek[ae]?\s+(?:katika|ndani)\s+(?:akaunti|hisa))\b/i, capability: 'deposit', lang: 'sw' },
377
+ { pattern: /\b(nime(?:tuma|lipa|ongeza|weka|peleka))\b/i, capability: 'unauthorized_action', lang: 'sw' },
378
+
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' },
381
+
382
+ // Oromo (om)
383
+ { pattern: /\b(kuuf\s+(?:qilleensaa|bilbila)|dhiib\s+(?:qilleensaa|bilbila))\b/i, capability: 'transfer', lang: 'om' },
384
+ { 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
+
387
+ // Fula (ff)
388
+ { pattern: /\b(sakkit\s+(?:ndo|ndoo)|tawt\s+(?:ndo|ndoo))\b/i, capability: 'transfer', lang: 'ff' },
389
+ { pattern: /\b(jokk\s*i|soodug\s*i)\b/i, capability: 'payment', lang: 'ff' },
390
+
391
+ // Somali (so)
392
+ { pattern: /\b(dir\s+(?:lacag|maal|qarsoon))\b/i, capability: 'transfer', lang: 'so' },
393
+ { 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
+
396
+ // Zulu (zu)
397
+ { pattern: /\b(thumel\s*a\s+(?:imali|imali))\b/i, capability: 'transfer', lang: 'zu' },
398
+ { pattern: /\b(hlawul\s*a|hlawulel\s*a)\b/i, capability: 'payment', lang: 'zu' },
399
+ { pattern: /\b(siyithumel\s*e|siyihlawul\s*e)\b/i, capability: 'unauthorized_action', lang: 'zu' },
400
+
401
+ // Shona (sn)
402
+ { pattern: /\b(tumir\s*a\s+(?:mhando|ari))\b/i, capability: 'transfer', lang: 'sn' },
403
+ { pattern: /\b(bhadhara|bhadharis\s*o)\b/i, capability: 'payment', lang: 'sn' },
404
+
405
+ // โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
406
+ // ๐ŸŒ GLOBAL LANGUAGES
407
+ // โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
408
+
409
+ // English (en)
410
+ { 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
+ { 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
+
413
+ // French (fr)
414
+ { 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
+
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' },
419
+ { pattern: /[\u0600-\u06FF]{0,3}(?:ุฃู†ุง|ุชู…|ู„ู‚ุฏ)\s*(?:ุญูˆู‘ู„ุช|ุฃุฑุณู„ุช|ุฏูุนุช|ุงูˆุฏุนุช)[\u0600-\u06FF]{0,3}/u, capability: 'unauthorized_action', lang: 'ar' },
420
+
421
+ // Chinese (zh) - Han script U+4E00-U+9FFF
422
+ { pattern: /[\u4e00-\u9fff]{0,2}(?:่ฝฌ่ดฆ|่ฝฌๅธ|ๆ”ฏไป˜|ไป˜ๆฌพ|ๆๆฌพ|ๅ–ๆฌพ|ๅญ˜ๆฌพ|ๅญ˜ๅ…ฅ|ๆฑ‡ๆฌพ|ๅญ˜)[\u4e00-\u9fff]{0,2}/u, capability: 'financial_action', lang: 'zh' },
423
+ { pattern: /[\u4e00-\u9fff]{0,2}(?:ๆˆ‘|ๅทฒ|ๅทฒ็ป)\s*(?:่ฝฌ่ดฆ|ๆ”ฏไป˜|ๆๆฌพ|ๅญ˜ๆฌพ)[\u4e00-\u9fff]{0,2}/u, capability: 'unauthorized_action', lang: 'zh' },
424
+
425
+ // โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
426
+ // ๐Ÿ›ก๏ธ LANGUAGE-AGNOSTIC NUMERIC DECEPTION (Critical!)
427
+ // โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
428
+
429
+ // Universal number formats: 1,000 | 1 000 | 1.000 | 1000 | 10,000.50 | 10.000,50
430
+ {
431
+ 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,
433
+ capability: 'unauthorized_action',
434
+ lang: 'multi'
435
+ },
436
+
437
+ // โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
438
+ // ๐Ÿ”’ PII LEAKAGE PATTERNS
439
+ // โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
440
+
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' },
443
+
444
+ // Nigerian BVN (11 digits)
445
+ { pattern: /\b(?:bvn|bank verification number)\s*[:\-]?\s*(\d{11})\b/i, capability: 'pii_exposure', lang: 'multi' },
446
+
447
+ // Nigerian phone numbers
448
+ { pattern: /\b(?:\+?234\s*|0)(?:70|80|81|90|91)\d{8}\b/, capability: 'pii_exposure', lang: 'multi' },
449
+
450
+ // โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
451
+ // โœ… FAKE CONFIRMATION PATTERNS
452
+ // โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
453
+
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' }
456
+ ];
457
+
458
+ // ๐Ÿ” SCAN OUTPUT FOR FORBIDDEN INTENTS
459
+ for (const { pattern, capability, lang } of forbiddenPatterns) {
460
+ if (pattern.test(output)) {
461
+ // โœ… Only block if capability NOT in workflow allowlist
462
+ const hasCapability = allowedCapabilities.some(c =>
463
+ c.includes(capability) ||
464
+ c.includes('transfer') ||
465
+ c.includes('payment') ||
466
+ c.includes('financial')
467
+ );
468
+
469
+ if (!hasCapability) {
470
+ const match = output.match(pattern);
471
+ return {
472
+ passed: false,
473
+ reason: `Hallucinated "${capability}" capability in ${lang} (not in workflow allowlist: ${allowedCapabilities.join(', ') || 'none'})`,
474
+ detected: match ? match[0].trim() : 'unknown pattern',
475
+ language: lang
476
+ };
362
477
  }
363
478
  }
364
-
365
- return { passed: true };
366
479
  }
367
480
 
481
+ return { passed: true };
482
+ }
483
+ }
368
484
  // -----------------------------
369
485
  // โœ… CRITICAL FIX: Resolver output unwrapping helper
370
486
  // -----------------------------