@o-lang/olang 1.4.2 → 1.4.3

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/parser/index.js +26 -15
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@o-lang/olang",
3
- "version": "1.4.2",
3
+ "version": "1.4.3",
4
4
  "author": "Olalekan Ogundipe <info@olang.cloud>",
5
5
  "description": "O-Lang: A governance language for user-directed, rule-enforced agent workflows with native African language PII protection.",
6
6
  "main": "./src/runtime/index.js",
@@ -572,16 +572,16 @@ function parseBlock(lines) {
572
572
  line = line.trim();
573
573
  if (!line || line.startsWith('#')) continue;
574
574
 
575
- // Calculate in Block (NEW v1.4.0)
575
+ // Calculate in Block
576
576
  const calcMatch = line.match(/^Calculate\s+(.+)$/i);
577
577
  if (calcMatch) {
578
578
  flush();
579
- steps.push({
579
+ current = {
580
580
  type: 'calculate',
581
581
  expression: calcMatch[1].trim(),
582
582
  saveAs: null,
583
583
  constraints: {}
584
- });
584
+ };
585
585
  continue;
586
586
  }
587
587
 
@@ -589,12 +589,12 @@ function parseBlock(lines) {
589
589
  const connectMatch = line.match(/^Connect\s+"([^"]+)"\s+to\s+(url|resolver)\s+"([^"]+)"$/i);
590
590
  if (connectMatch) {
591
591
  flush();
592
- steps.push({
592
+ current = {
593
593
  type: 'connect',
594
594
  resource: connectMatch[1],
595
595
  endpoint: connectMatch[3],
596
596
  targetType: connectMatch[2].toLowerCase()
597
- });
597
+ };
598
598
  continue;
599
599
  }
600
600
 
@@ -602,11 +602,11 @@ function parseBlock(lines) {
602
602
  const useMatch = line.match(/^Use\s+"([^"]+)"\s+as\s+"([^"]+)"$/i);
603
603
  if (useMatch) {
604
604
  flush();
605
- steps.push({
605
+ current = {
606
606
  type: 'agent_use',
607
607
  logicalName: useMatch[1],
608
608
  resource: useMatch[2]
609
- });
609
+ };
610
610
  continue;
611
611
  }
612
612
 
@@ -620,7 +620,7 @@ function parseBlock(lines) {
620
620
  actionRaw: stepMatch[2].trim(),
621
621
  saveAs: null,
622
622
  constraints: {},
623
- label: `Step ${stepMatch[1]}` // ✅ ENHANCED: Add label
623
+ label: `Step ${stepMatch[1]}`
624
624
  };
625
625
  continue;
626
626
  }
@@ -636,7 +636,11 @@ function parseBlock(lines) {
636
636
  const debriefMatch = line.match(/^Debrief\s+([^\s]+)\s+with\s+"([^"]*)"$/i);
637
637
  if (debriefMatch) {
638
638
  flush();
639
- steps.push({ type: 'debrief', agent: debriefMatch[1].trim(), message: debriefMatch[2] });
639
+ current = {
640
+ type: 'debrief',
641
+ agent: debriefMatch[1].trim(),
642
+ message: debriefMatch[2]
643
+ };
640
644
  continue;
641
645
  }
642
646
 
@@ -644,7 +648,11 @@ function parseBlock(lines) {
644
648
  const persistMatch = line.match(/^Persist\s+([^\s]+)\s+to\s+"([^"]*)"$/i);
645
649
  if (persistMatch) {
646
650
  flush();
647
- steps.push({ type: 'persist', variable: persistMatch[1].trim(), target: persistMatch[2] });
651
+ current = {
652
+ type: 'persist',
653
+ variable: persistMatch[1].trim(),
654
+ target: persistMatch[2]
655
+ };
648
656
  continue;
649
657
  }
650
658
 
@@ -652,20 +660,24 @@ function parseBlock(lines) {
652
660
  const emitMatch = line.match(/^Emit\s+"([^"]+)"\s+with\s+(.+)$/i);
653
661
  if (emitMatch) {
654
662
  flush();
655
- steps.push({ type: 'emit', event: emitMatch[1], payload: emitMatch[2].trim() });
663
+ current = {
664
+ type: 'emit',
665
+ event: emitMatch[1],
666
+ payload: emitMatch[2].trim()
667
+ };
656
668
  continue;
657
669
  }
658
670
 
659
- // Ask in Block
671
+ // Ask in Block — FIXED: Set as current instead of pushing
660
672
  const askMatch = line.match(/^Ask\s+(.+)$/i);
661
673
  if (askMatch) {
662
674
  flush();
663
- steps.push({
675
+ current = {
664
676
  type: 'action',
665
677
  actionRaw: `Action ${askMatch[1].trim()}`,
666
678
  saveAs: null,
667
679
  constraints: {}
668
- });
680
+ };
669
681
  continue;
670
682
  }
671
683
 
@@ -686,7 +698,6 @@ function parseBlock(lines) {
686
698
  step.saveAs = normalizeSymbol(saveInAction[2].trim());
687
699
  }
688
700
  }
689
- // ✅ NEW: Handle Calculate steps with inline Save as in blocks
690
701
  if (step.type === 'calculate' && step.expression && step.saveAs === null) {
691
702
  const saveInExpr = step.expression.match(/(.+?)\s+Save as\s+(.+)$/i);
692
703
  if (saveInExpr) {