@o-lang/olang 1.2.6 โ 1.2.7
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 +91 -30
package/package.json
CHANGED
|
@@ -331,40 +331,101 @@ class RuntimeAPI {
|
|
|
331
331
|
});
|
|
332
332
|
}
|
|
333
333
|
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
334
|
+
// -----------------------------
|
|
335
|
+
// โ
KERNEL-LEVEL LLM HALLUCINATION PREVENTION (MULTILINGUAL 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
|
+
// ๐ MULTILINGUAL INTENT DETECTION (Deterministic, No LLM Required)
|
|
346
|
+
// Patterns ordered by language family โ script โ frequency
|
|
347
|
+
const forbiddenPatterns = [
|
|
348
|
+
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
349
|
+
// ๐ณ๐ฌ NIGERIAN LANGUAGES (Priority for your mission)
|
|
350
|
+
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
351
|
+
|
|
352
|
+
// Yoruba (yo) - Latin script
|
|
353
|
+
{ pattern: /\b(fi\s+(?:owo|แบนฬwแปฬ|ewo|ku|fun|s'แปkแปแป))\b/i, capability: 'transfer', lang: 'yo' },
|
|
354
|
+
{ pattern: /\b(san\s+(?:owo|แบนฬwแปฬ|ewo|fun|wo|lแบนsแบนkแบนsแบน))\b/i, capability: 'payment', lang: 'yo' },
|
|
355
|
+
{ pattern: /\b(gba\s+owo)\b/i, capability: 'withdrawal', lang: 'yo' },
|
|
356
|
+
{ pattern: /\b(mo\s+ti\s+(?:fi|san))\b/i, capability: 'unauthorized_action', lang: 'yo' }, // "I have transferred/paid"
|
|
357
|
+
|
|
358
|
+
// Hausa (ha) - Latin script
|
|
359
|
+
{ pattern: /\b(ciyar\s*(?:da)?|ciya\s*(?:da)?)\b/i, capability: 'transfer', lang: 'ha' },
|
|
360
|
+
{ pattern: /\b(biya\s*(?:da)?|sauce\s+kuษi)\b/i, capability: 'payment', lang: 'ha' },
|
|
361
|
+
{ pattern: /\b(sahawa\s+kuษi|sahawar)\b/i, capability: 'withdrawal', lang: 'ha' },
|
|
362
|
+
{ pattern: /\b(ina\s+(?:ciyar|biya))\b/i, capability: 'unauthorized_action', lang: 'ha' }, // "I am transferring/paying"
|
|
363
|
+
|
|
364
|
+
// Igbo (ig) - Latin script
|
|
365
|
+
{ pattern: /\b(zipu\s+(?:ego|moni|isi|na))\b/i, capability: 'transfer', lang: 'ig' },
|
|
366
|
+
{ pattern: /\b(buru\s+(?:ego|moni|isi))\b/i, capability: 'transfer', lang: 'ig' }, // "carry/send money"
|
|
367
|
+
{ pattern: /\b(tinye\s+(?:ego|moni|isi))\b/i, capability: 'deposit', lang: 'ig' },
|
|
368
|
+
{ pattern: /\b(m\s+(?:ziri|buru|zipuru))\b/i, capability: 'unauthorized_action', lang: 'ig' }, // "I sent/carried"
|
|
369
|
+
|
|
370
|
+
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
371
|
+
// ๐ GLOBAL LANGUAGES (Critical mass coverage)
|
|
372
|
+
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
373
|
+
|
|
374
|
+
// English (en) - Baseline
|
|
375
|
+
{ pattern: /\b(transfer|transferred|transferring|send|sent|sending|wire|wired|pay|paid|paying|withdraw|withdrew|withdrawal|deposit|deposited)\b/i, capability: 'financial_action', lang: 'en' },
|
|
376
|
+
{ pattern: /\bI\s+(?:can|will|am able to|have|'ve|did)\s+(?:transfer|send|pay|withdraw|deposit)\b/i, capability: 'unauthorized_action', lang: 'en' },
|
|
377
|
+
|
|
378
|
+
// French (fr) - Latin script
|
|
379
|
+
{ pattern: /\b(transfรฉrer|transfรฉrรฉ|transfรฉrant|envoyer|envoyรฉ|payer|payรฉ|retirer|retirรฉ|dรฉposer|dรฉposรฉ)\b/i, capability: 'financial_action', lang: 'fr' },
|
|
380
|
+
{ pattern: /\b(je\s+(?:peux|vais|ai)\s+(?:transfรฉrer|envoyer|payer))\b/i, capability: 'unauthorized_action', lang: 'fr' }, // "I can transfer/send/pay"
|
|
381
|
+
|
|
382
|
+
// Arabic (ar) - Right-to-left script (Unicode ranges)
|
|
383
|
+
{ pattern: /[\u0621-\u064A]{0,3}(?:ุญููู|ุญูู|ุฃุฑุณู|ุงุฑุณู|ุงุฏูุน|ุงุฏูุน|ุงูุฏุน|ุงูุฏุน|ุณุญุจ|ุงุณุชุฎุฑุฌ)[\u0621-\u064A]{0,3}/u, capability: 'financial_action', lang: 'ar' },
|
|
384
|
+
{ pattern: /[\u0621-\u064A]{0,3}(?:ุฃูุง)\s*(?:ุญูููุช|ุฃุฑุณูุช|ุฏูุนุช)[\u0621-\u064A]{0,3}/u, capability: 'unauthorized_action', lang: 'ar' }, // "I transferred/sent/paid"
|
|
385
|
+
|
|
386
|
+
// Chinese (zh) - Han script (Simplified)
|
|
387
|
+
{ pattern: /[\u4e00-\u9fff]{0,2}(?:่ฝฌ่ดฆ|่ฝฌๅธ|ๆฏไป|ไปๆฌพ|ๆๆฌพ|ๅๆฌพ|ๅญๆฌพ|ๅญๅ
ฅ)[\u4e00-\u9fff]{0,2}/u, capability: 'financial_action', lang: 'zh' },
|
|
388
|
+
{ pattern: /[\u4e00-\u9fff]{0,2}(?:ๆ)\s*(?:ๅทฒ|ๅทฒ็ป)?\s*(?:่ฝฌ่ดฆ|ๆฏไป|ๆๆฌพ)[\u4e00-\u9fff]{0,2}/u, capability: 'unauthorized_action', lang: 'zh' }, // "I have transferred/paid/withdrawn"
|
|
389
|
+
|
|
390
|
+
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
391
|
+
// ๐ก๏ธ CROSS-LINGUAL DECEPTION PATTERNS (Critical!)
|
|
392
|
+
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
393
|
+
|
|
394
|
+
// Numeric deception (works across ALL languages)
|
|
395
|
+
{ pattern: /\b(\d{1,3}(?:,\d{3})*(?:\.\d{2})?)\s*(?:naira|ngn|โฆ|\$|usd|dollars|euros|โฌ|yuan|ยฅ)\s+(?:sent|transferred|paid|to account)\b/i, capability: 'unauthorized_action', lang: 'multi' },
|
|
396
|
+
|
|
397
|
+
// Account number leakage (PII risk)
|
|
398
|
+
{ pattern: /\b(?:account|acct|a\/c)\s*[:\-]?\s*(\d{8,})\b/i, capability: 'pii_exposure', lang: 'multi' },
|
|
399
|
+
|
|
400
|
+
// Fake confirmation patterns
|
|
401
|
+
{ pattern: /\b(successful(?:ly)?|completed|processed|confirmed|approved)\s+(?:transaction|transfer|payment)\b/i, capability: 'deceptive_claim', lang: 'multi' }
|
|
402
|
+
];
|
|
403
|
+
|
|
404
|
+
// ๐ SCAN OUTPUT FOR FORBIDDEN INTENTS
|
|
405
|
+
for (const { pattern, capability, lang } of forbiddenPatterns) {
|
|
406
|
+
if (pattern.test(output)) {
|
|
407
|
+
// โ
Only block if capability NOT in workflow allowlist
|
|
408
|
+
const hasCapability = allowedCapabilities.some(c =>
|
|
409
|
+
c.includes(capability) ||
|
|
410
|
+
c.includes('transfer') ||
|
|
411
|
+
c.includes('payment') ||
|
|
412
|
+
c.includes('financial')
|
|
413
|
+
);
|
|
414
|
+
|
|
415
|
+
if (!hasCapability) {
|
|
416
|
+
const match = output.match(pattern);
|
|
417
|
+
return {
|
|
418
|
+
passed: false,
|
|
419
|
+
reason: `Hallucinated "${capability}" capability in ${lang} (not in workflow allowlist: ${allowedCapabilities.join(', ') || 'none'})`,
|
|
420
|
+
detected: match ? match[0].trim() : 'unknown pattern',
|
|
421
|
+
language: lang
|
|
422
|
+
};
|
|
362
423
|
}
|
|
363
424
|
}
|
|
364
|
-
|
|
365
|
-
return { passed: true };
|
|
366
425
|
}
|
|
367
426
|
|
|
427
|
+
return { passed: true };
|
|
428
|
+
}
|
|
368
429
|
// -----------------------------
|
|
369
430
|
// โ
CRITICAL FIX: Resolver output unwrapping helper
|
|
370
431
|
// -----------------------------
|