@o-lang/olang 1.2.32 → 1.2.34

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.32",
3
+ "version": "1.2.34",
4
4
  "author": "Olalekan Ogundipe <info@olang.cloud>",
5
5
  "description": "O-Lang: A governance language for user-directed, rule-enforced agent workflows",
6
6
  "main": "./src/runtime/index.js",
@@ -427,16 +427,23 @@ function parseWorkflowLines(lines, filename) {
427
427
  }
428
428
 
429
429
  // ✅ ADD: Return keyword support (ensures wf.returnValues is populated)
430
- const returnMatch = line.match(/^Return\s+(.+)$/i);
431
- if (returnMatch) {
432
- flushCurrentStep();
433
- workflow.returnValues = returnMatch[1]
434
- .split(',')
435
- .map(r => r.trim())
436
- .filter(r => r !== '');
437
- continue;
438
- }
439
-
430
+ // ADD: Return keyword support (with debug logging)
431
+ const returnMatch = line.match(/^Return\s+(.+)$/i);
432
+ if (returnMatch) {
433
+ flushCurrentStep();
434
+ const rawReturns = returnMatch[1];
435
+ console.log(`[PARSER DEBUG] Return line: "${line}"`);
436
+ console.log(`[PARSER DEBUG] Return match[1]: "${rawReturns}"`);
437
+ console.log(`[PARSER DEBUG] Return match[1] char codes: ${Array.from(rawReturns).map(c => c.charCodeAt(0))}`);
438
+
439
+ workflow.returnValues = rawReturns
440
+ .split(',')
441
+ .map(r => r.trim())
442
+ .filter(r => r !== '');
443
+
444
+ console.log(`[PARSER DEBUG] Parsed returnValues: ${JSON.stringify(workflow.returnValues)}`);
445
+ continue;
446
+ }
440
447
  // Fallback: treat as action
441
448
  if (line.trim() !== '') {
442
449
  if (!currentStep) {
@@ -1258,9 +1258,14 @@ const forbiddenPatterns = [
1258
1258
  throw new Error(errorMessage);
1259
1259
  };
1260
1260
 
1261
- switch (stepType) {
1261
+ switch (stepType) {
1262
1262
  case 'calculate': {
1263
- const result = this.evaluateMath(step.expression || step.actionRaw);
1263
+ // Interpolate variables in the expression before evaluation
1264
+ let expr = step.expression || step.actionRaw;
1265
+ if (typeof expr === 'string' && expr.includes('{')) {
1266
+ expr = this._safeInterpolate(expr, this.context, 'calculate step');
1267
+ }
1268
+ const result = this.evaluateMath(expr);
1264
1269
  if (step.saveAs) this.context[step.saveAs] = result;
1265
1270
  break;
1266
1271
  }