@o-lang/olang 1.2.29 → 1.2.31
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/parser/index.js +41 -29
- package/src/runtime/RuntimeAPI.js +46 -30
package/package.json
CHANGED
package/src/parser/index.js
CHANGED
|
@@ -305,7 +305,7 @@ function parseWorkflowLines(lines, filename) {
|
|
|
305
305
|
continue;
|
|
306
306
|
}
|
|
307
307
|
|
|
308
|
-
|
|
308
|
+
// ✅ ADD: Set keyword (e.g., Set analysis_result = "")
|
|
309
309
|
const setMatch = line.match(/^Set\s+(\w+)\s*=\s*(.+)$/i);
|
|
310
310
|
if (setMatch) {
|
|
311
311
|
flushCurrentStep();
|
|
@@ -399,38 +399,41 @@ function parseWorkflowLines(lines, filename) {
|
|
|
399
399
|
}
|
|
400
400
|
|
|
401
401
|
// Ask (for Notify/resolver calls) - ✅ PRESERVE TARGET EXACTLY (NO NORMALIZATION)
|
|
402
|
-
const askMatch = line.match(/^Ask\s+(.+)$/i);
|
|
403
|
-
if (askMatch) {
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
402
|
+
const askMatch = line.match(/^Ask\s+(.+)$/i);
|
|
403
|
+
if (askMatch) {
|
|
404
|
+
flushCurrentStep();
|
|
405
|
+
let actionContent = askMatch[1].trim();
|
|
406
|
+
|
|
407
|
+
// ✅ Multiline heredoc support: Ask llm-groq """
|
|
408
|
+
if (actionContent.endsWith('"""')) {
|
|
409
|
+
// Consume lines until closing """
|
|
410
|
+
let multiline = actionContent.slice(0, -3).trim() + ' ';
|
|
411
|
+
while (i < lines.length) {
|
|
412
|
+
const nextLine = lines[i++].trim();
|
|
413
|
+
if (nextLine === '"""') break;
|
|
414
|
+
multiline += nextLine + ' ';
|
|
415
|
+
}
|
|
416
|
+
actionContent = multiline.trim();
|
|
417
|
+
}
|
|
418
418
|
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
}
|
|
419
|
+
workflow.steps.push({
|
|
420
|
+
type: 'action',
|
|
421
|
+
actionRaw: `Action ${actionContent}`,
|
|
422
|
+
stepNumber: workflow.steps.length + 1,
|
|
423
|
+
saveAs: null,
|
|
424
|
+
constraints: {}
|
|
425
|
+
});
|
|
426
|
+
continue;
|
|
427
|
+
}
|
|
428
428
|
|
|
429
|
-
// Return
|
|
429
|
+
// ✅ ADD: Return keyword support (ensures wf.returnValues is populated)
|
|
430
430
|
const returnMatch = line.match(/^Return\s+(.+)$/i);
|
|
431
431
|
if (returnMatch) {
|
|
432
432
|
flushCurrentStep();
|
|
433
|
-
workflow.returnValues = returnMatch[1]
|
|
433
|
+
workflow.returnValues = returnMatch[1]
|
|
434
|
+
.split(',')
|
|
435
|
+
.map(r => r.trim())
|
|
436
|
+
.filter(r => r !== '');
|
|
434
437
|
continue;
|
|
435
438
|
}
|
|
436
439
|
|
|
@@ -603,7 +606,7 @@ function parseBlock(lines) {
|
|
|
603
606
|
continue;
|
|
604
607
|
}
|
|
605
608
|
|
|
606
|
-
|
|
609
|
+
// ✅ ADD: Set keyword inside blocks (e.g., Set analysis_result = "")
|
|
607
610
|
const setMatch = line.match(/^Set\s+(\w+)\s*=\s*(.+)$/i);
|
|
608
611
|
if (setMatch) {
|
|
609
612
|
flush(); // Flush any pending step
|
|
@@ -615,6 +618,15 @@ function parseBlock(lines) {
|
|
|
615
618
|
});
|
|
616
619
|
continue;
|
|
617
620
|
}
|
|
621
|
+
|
|
622
|
+
// ✅ ADD: Return keyword inside blocks (rare but supported)
|
|
623
|
+
const returnMatch = line.match(/^Return\s+(.+)$/i);
|
|
624
|
+
if (returnMatch) {
|
|
625
|
+
flush();
|
|
626
|
+
// Note: Return inside blocks is unusual; this just parses it
|
|
627
|
+
continue;
|
|
628
|
+
}
|
|
629
|
+
|
|
618
630
|
// Fallback
|
|
619
631
|
if (current) {
|
|
620
632
|
current.actionRaw += ' ' + line; // ← PRESERVED EXACTLY (no normalizeAction)
|
|
@@ -3,7 +3,7 @@ const path = require('path');
|
|
|
3
3
|
const crypto = require('crypto'); // ✅ CRYPTOGRAPHIC AUDIT LOGS
|
|
4
4
|
|
|
5
5
|
// ✅ O-Lang Kernel Version (Safety Logic & Governance Rules)
|
|
6
|
-
const KERNEL_VERSION = '1.2.
|
|
6
|
+
const KERNEL_VERSION = '1.2.30-alpha'; // 🔁 Update when safety rules change
|
|
7
7
|
|
|
8
8
|
class RuntimeAPI {
|
|
9
9
|
constructor({ verbose = false } = {}) {
|
|
@@ -878,41 +878,57 @@ class RuntimeAPI {
|
|
|
878
878
|
if (!output || typeof output !== 'string') return { passed: true };
|
|
879
879
|
|
|
880
880
|
// ── __verified_intent takes priority ──────────────────────────────────────
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
language: 'multi'
|
|
894
|
-
};
|
|
895
|
-
}
|
|
896
|
-
}
|
|
881
|
+
const intent = this.context.__verified_intent;
|
|
882
|
+
if (intent) {
|
|
883
|
+
if (intent.prohibited_actions && Array.isArray(intent.prohibited_actions)) {
|
|
884
|
+
const lower = output.toLowerCase();
|
|
885
|
+
for (const action of intent.prohibited_actions) {
|
|
886
|
+
if (lower.includes(action.toLowerCase())) {
|
|
887
|
+
return {
|
|
888
|
+
passed: false,
|
|
889
|
+
reason: `Output violates prohibited action "${action}" defined in __verified_intent`,
|
|
890
|
+
detected: action,
|
|
891
|
+
language: 'multi'
|
|
892
|
+
};
|
|
897
893
|
}
|
|
894
|
+
}
|
|
895
|
+
}
|
|
898
896
|
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
897
|
+
if (intent.prohibited_topics && Array.isArray(intent.prohibited_topics)) {
|
|
898
|
+
for (const topic of intent.prohibited_topics) {
|
|
899
|
+
const isRegex = typeof topic === 'object' && topic.pattern;
|
|
900
|
+
let matched = false;
|
|
901
|
+
let detected = '';
|
|
902
|
+
|
|
903
|
+
if (isRegex) {
|
|
904
|
+
try {
|
|
905
|
+
const re = new RegExp(topic.pattern, topic.flags || 'i');
|
|
906
|
+
const match = output.match(re);
|
|
907
|
+
matched = !!match;
|
|
908
|
+
detected = match ? match[0] : topic.pattern;
|
|
909
|
+
} catch (e) {
|
|
910
|
+
this.addWarning(`Invalid prohibited_topic regex: "${topic.pattern}" — ${e.message}`);
|
|
911
|
+
continue;
|
|
910
912
|
}
|
|
913
|
+
} else {
|
|
914
|
+
matched = output.toLowerCase().includes(topic.toLowerCase());
|
|
915
|
+
detected = topic;
|
|
911
916
|
}
|
|
912
917
|
|
|
913
|
-
|
|
914
|
-
|
|
918
|
+
if (matched) {
|
|
919
|
+
return {
|
|
920
|
+
passed: false,
|
|
921
|
+
reason: `Output violates prohibited topic "${isRegex ? topic.pattern : topic}" defined in __verified_intent`,
|
|
922
|
+
detected,
|
|
923
|
+
language: 'multi'
|
|
924
|
+
};
|
|
925
|
+
}
|
|
915
926
|
}
|
|
927
|
+
}
|
|
928
|
+
|
|
929
|
+
// __verified_intent present and passed — skip hardcoded patterns
|
|
930
|
+
return { passed: true };
|
|
931
|
+
}
|
|
916
932
|
|
|
917
933
|
// ── No __verified_intent — fall through to hardcoded patterns ─────────────
|
|
918
934
|
// 🔑 Extract allowed capabilities from workflow allowlist
|