@o-lang/olang 1.2.21 → 1.2.22
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 +67 -0
package/package.json
CHANGED
|
@@ -721,6 +721,70 @@ class RuntimeAPI {
|
|
|
721
721
|
});
|
|
722
722
|
}
|
|
723
723
|
|
|
724
|
+
// -----------------------------
|
|
725
|
+
// ✅ KERNEL-LEVEL INPUT VALIDATION (Pre-Flight Safety)
|
|
726
|
+
// -----------------------------
|
|
727
|
+
_validateInputs(inputs) {
|
|
728
|
+
// Only scan specific input fields that contain user text
|
|
729
|
+
const fieldsToScan = ['user_message', 'user_question', 'text', 'prompt', 'document_text'];
|
|
730
|
+
|
|
731
|
+
for (const field of fieldsToScan) {
|
|
732
|
+
const text = inputs[field];
|
|
733
|
+
if (!text || typeof text !== 'string') continue;
|
|
734
|
+
|
|
735
|
+
// Re-use the exact same forbiddenPatterns from _validateLLMOutput
|
|
736
|
+
// 🔒 CONJUGATION-AWARE + EVASION-RESISTANT PAN-AFRICAN INTENT DETECTION
|
|
737
|
+
const forbiddenPatterns = [
|
|
738
|
+
// 🇳🇬 NIGERIAN LANGUAGES
|
|
739
|
+
{ pattern: /\b(fi\s+(?:owo|ẹ̀wọ̀|ewo|ku|fun|s'ọkọọ))\b/i, capability: 'transfer', lang: 'yo' },
|
|
740
|
+
{ pattern: /\b(ranṣẹ\s+(?:owo|pesa|kuɗi|ego)|fi\s+.*\s+ranṣẹ)\b/i, capability: 'transfer', lang: 'yo' },
|
|
741
|
+
{ pattern: /\b(ciyar\s*(?:da)?|shiga\s+kuɗi)\b/i, capability: 'transfer', lang: 'ha' },
|
|
742
|
+
{ pattern: /\b(aika\s+(?:kuɗi)|turo\s+.*\s+aika)\b/i, capability: 'transfer', lang: 'ha' },
|
|
743
|
+
{ pattern: /\b(zipu\s+(?:ego|moni)|zi\s+.*\s+zipu)\b/i, capability: 'transfer', lang: 'ig' },
|
|
744
|
+
{ pattern: /\b(buru\s+(?:ego|moni))\b/i, capability: 'transfer', lang: 'ig' },
|
|
745
|
+
// 🌐 GLOBAL
|
|
746
|
+
{ pattern: /\b(transfer(?:red|ring)?|send(?:t|ing)?|wire(?:d)?)\b/i, capability: 'financial_action', lang: 'en' },
|
|
747
|
+
{ pattern: /\bI\s+(?:can|will|am able to)\s+(?:transfer|send|pay)\b/i, capability: 'unauthorized_action', lang: 'en' },
|
|
748
|
+
// 🛡️ PII
|
|
749
|
+
{ pattern: /\b(?:account|acct|akaunti|asusu|hesabu|namba|#)\s*[:\-—–]?\s*(\d{6,})\b/i, capability: 'pii_exposure', lang: 'multi' },
|
|
750
|
+
{ pattern: /\b(?:bvn|bank verification number)\s*[:\-]?\s*(\d{11})\b/i, capability: 'pii_exposure', lang: 'multi' },
|
|
751
|
+
{ pattern: /\b(?:\+?234\s*|0)(?:70|80|81|90|91)\d{8}\b/, capability: 'pii_exposure', lang: 'multi' },
|
|
752
|
+
];
|
|
753
|
+
|
|
754
|
+
for (const { pattern, capability, lang } of forbiddenPatterns) {
|
|
755
|
+
if (pattern.test(text)) {
|
|
756
|
+
const match = text.match(pattern);
|
|
757
|
+
const isAfrican = ['yo', 'ig', 'ha', 'sw', 'zu', 'am', 'om', 'ff', 'so', 'sn'].includes(lang);
|
|
758
|
+
const isFinancial = ['transfer', 'payment', 'withdrawal', 'deposit', 'financial_action'].includes(capability);
|
|
759
|
+
|
|
760
|
+
// ✅ AUDIT LOG: Input Safety Violation
|
|
761
|
+
this._createAuditEntry('input_safety_violation', {
|
|
762
|
+
type: 'blocked_input',
|
|
763
|
+
field: field,
|
|
764
|
+
detected_phrase: match ? match[0].trim() : 'unknown pattern',
|
|
765
|
+
capability: capability,
|
|
766
|
+
language: lang,
|
|
767
|
+
african_language_detected: isAfrican,
|
|
768
|
+
financial_expression_found: isFinancial,
|
|
769
|
+
severity: 'high'
|
|
770
|
+
});
|
|
771
|
+
|
|
772
|
+
throw new Error(
|
|
773
|
+
`[O-Lang SAFETY] Blocked Input in "${lang}":\n` +
|
|
774
|
+
` → Detected: "${match ? match[0].trim() : 'Pattern Match'}"\n` +
|
|
775
|
+
` → Capability: ${capability}\n` +
|
|
776
|
+
` → Field: ${field}\n` +
|
|
777
|
+
` → African Language Detected: ${isAfrican}\n` +
|
|
778
|
+
` → Financial Expression: ${isFinancial}\n` +
|
|
779
|
+
`\n🛑 Workflow halted before execution.`
|
|
780
|
+
);
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
return { passed: true };
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
|
|
724
788
|
// -----------------------------
|
|
725
789
|
// ✅ KERNEL-LEVEL LLM HALLUCINATION PREVENTION (CONJUGATION-AWARE + EVASION-RESISTANT)
|
|
726
790
|
// -----------------------------
|
|
@@ -1446,6 +1510,9 @@ class RuntimeAPI {
|
|
|
1446
1510
|
workflow_name: workflow.name
|
|
1447
1511
|
};
|
|
1448
1512
|
|
|
1513
|
+
// ✅ NEW: Validate Inputs BEFORE any step runs
|
|
1514
|
+
this._validateInputs(inputs);
|
|
1515
|
+
|
|
1449
1516
|
// ✅ AUDIT LOG: Workflow start (ENHANCED with governance metadata)
|
|
1450
1517
|
const governanceHash = this._generateGovernanceProfileHash(workflow);
|
|
1451
1518
|
|