@o-lang/olang 1.1.8 → 1.1.9

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.1.8",
3
+ "version": "1.1.9",
4
4
  "author": "Olalekan Ogundipe <info@workfily.com>",
5
5
  "description": "O-Lang: A governance language for user-directed, rule-enforced agent workflows",
6
6
  "main": "./src/index.js",
package/src/parser.js CHANGED
@@ -1,6 +1,6 @@
1
1
  const fs = require('fs');
2
2
 
3
- // ✅ Symbol normalization helper (backward compatible)
3
+ // ✅ Symbol normalization helper (backward compatible - SAFE to keep)
4
4
  function normalizeSymbol(raw) {
5
5
  if (!raw) return raw;
6
6
  // Take only the first word (stop at first whitespace)
@@ -8,17 +8,7 @@ function normalizeSymbol(raw) {
8
8
  return raw.split(/\s+/)[0].replace(/[^\w$]/g, '');
9
9
  }
10
10
 
11
- // ACTION NORMALIZATION HELPER (NEW)
12
- // Strip decorative prefixes for consistent resolver matching
13
- function normalizeAction(actionRaw) {
14
- if (typeof actionRaw !== 'string') return actionRaw;
15
-
16
- // Strip optional decorative prefixes (case-insensitive)
17
- // Preserves semantic prefixes: "Ask", "Use" (handled as separate step types)
18
- return actionRaw
19
- .replace(/^(Action|Do|Perform|Execute|Run|Call|Invoke)\s+/i, '')
20
- .trim();
21
- }
11
+ // REMOVED: normalizeAction() function (was stripping "Action" prefix → broke resolver matching)
22
12
 
23
13
  function parse(content, filename = '<unknown>') {
24
14
  if (typeof content === 'string') {
@@ -269,27 +259,24 @@ function parseWorkflowLines(lines, filename) {
269
259
  }
270
260
  }
271
261
 
272
- // Step declaration - ✅ NORMALIZE ACTION HERE
262
+ // Step declaration - ✅ PRESERVE ACTION EXACTLY (NO NORMALIZATION)
273
263
  const stepMatch = line.match(/^Step\s+(\d+)\s*:\s*(.+)$/i);
274
264
  if (stepMatch) {
275
265
  flushCurrentStep(); // ✅ Flush previous step
276
266
  const stepNumber = parseInt(stepMatch[1], 10);
277
- let stepContent = stepMatch[2].trim();
278
-
279
- // ✅ CRITICAL: Normalize action syntax BEFORE storing in AST
280
- stepContent = normalizeAction(stepContent);
267
+ const stepContent = stepMatch[2].trim(); // ← PRESERVED EXACTLY (no normalizeAction)
281
268
 
282
269
  currentStep = {
283
270
  type: 'action',
284
271
  stepNumber: stepNumber,
285
- actionRaw: stepContent, // ← CLEAN, normalized action string
272
+ actionRaw: stepContent, // ← CRITICAL: No normalization here
286
273
  saveAs: null,
287
274
  constraints: {}
288
275
  };
289
276
  continue;
290
277
  }
291
278
 
292
- // Save as - ✅ Apply normalization
279
+ // Save as - ✅ Apply normalization (safe for symbol names)
293
280
  const saveMatch = line.match(/^Save as\s+(.+)$/i);
294
281
  if (saveMatch && currentStep) {
295
282
  currentStep.saveAs = normalizeSymbol(saveMatch[1].trim());
@@ -383,13 +370,13 @@ function parseWorkflowLines(lines, filename) {
383
370
  continue;
384
371
  }
385
372
 
386
- // Use (for Notify-like actions) - ✅ NORMALIZE TOOL HERE
373
+ // Use (for Notify-like actions) - ✅ PRESERVE TOOL EXACTLY (NO NORMALIZATION)
387
374
  const useMatch = line.match(/^Use\s+(.+)$/i);
388
375
  if (useMatch) {
389
376
  flushCurrentStep();
390
377
  workflow.steps.push({
391
378
  type: 'use',
392
- tool: normalizeAction(useMatch[1].trim()), // Normalize tool name
379
+ tool: useMatch[1].trim(), // PRESERVED EXACTLY (no normalizeAction)
393
380
  stepNumber: workflow.steps.length + 1,
394
381
  saveAs: null,
395
382
  constraints: {}
@@ -397,13 +384,13 @@ function parseWorkflowLines(lines, filename) {
397
384
  continue;
398
385
  }
399
386
 
400
- // Ask (for Notify/resolver calls) - ✅ NORMALIZE TARGET HERE
387
+ // Ask (for Notify/resolver calls) - ✅ PRESERVE TARGET EXACTLY (NO NORMALIZATION)
401
388
  const askMatch = line.match(/^Ask\s+(.+)$/i);
402
389
  if (askMatch) {
403
390
  flushCurrentStep();
404
391
  workflow.steps.push({
405
392
  type: 'ask',
406
- target: normalizeAction(askMatch[1].trim()), // Normalize target
393
+ target: askMatch[1].trim(), // PRESERVED EXACTLY (no normalizeAction)
407
394
  stepNumber: workflow.steps.length + 1,
408
395
  saveAs: null,
409
396
  constraints: {}
@@ -425,12 +412,12 @@ function parseWorkflowLines(lines, filename) {
425
412
  currentStep = {
426
413
  type: 'action',
427
414
  stepNumber: workflow.steps.length + 1,
428
- actionRaw: normalizeAction(line), // Normalize fallback actions too
415
+ actionRaw: line, // PRESERVED EXACTLY (no normalizeAction)
429
416
  saveAs: null,
430
417
  constraints: {}
431
418
  };
432
419
  } else {
433
- currentStep.actionRaw += ' ' + normalizeAction(line);
420
+ currentStep.actionRaw += ' ' + line; // ← PRESERVED EXACTLY (no normalizeAction)
434
421
  }
435
422
  }
436
423
  }
@@ -466,7 +453,7 @@ function parseWorkflowLines(lines, filename) {
466
453
  return workflow;
467
454
  }
468
455
 
469
- // Parses blocks (for parallel, if, escalation levels) - ✅ UPDATED FOR NORMALIZATION
456
+ // Parses blocks (for parallel, if, escalation levels) - ✅ PRESERVE ALL FUNCTIONALITY
470
457
  function parseBlock(lines) {
471
458
  const steps = [];
472
459
  let current = null;
@@ -482,20 +469,17 @@ function parseBlock(lines) {
482
469
  line = line.trim();
483
470
  if (!line || line.startsWith('#')) continue;
484
471
 
485
- // Step declaration in block - ✅ NORMALIZE ACTION HERE
472
+ // Step declaration in block - ✅ PRESERVE ACTION EXACTLY (NO NORMALIZATION)
486
473
  const stepMatch = line.match(/^Step\s+(\d+)\s*:\s*(.+)$/i);
487
474
  if (stepMatch) {
488
475
  flush();
489
476
  const stepNumber = parseInt(stepMatch[1], 10);
490
- let stepContent = stepMatch[2].trim();
491
-
492
- // ✅ CRITICAL: Normalize action syntax in blocks too
493
- stepContent = normalizeAction(stepContent);
477
+ const stepContent = stepMatch[2].trim(); // ← PRESERVED EXACTLY
494
478
 
495
479
  current = {
496
480
  type: 'action',
497
481
  stepNumber: stepNumber,
498
- actionRaw: stepContent,
482
+ actionRaw: stepContent, // ← CRITICAL: No normalization
499
483
  saveAs: null,
500
484
  constraints: {}
501
485
  };
@@ -545,26 +529,26 @@ function parseBlock(lines) {
545
529
  continue;
546
530
  }
547
531
 
548
- // Use in block - ✅ NORMALIZE TOOL HERE
532
+ // Use in block - ✅ PRESERVE TOOL EXACTLY (NO NORMALIZATION)
549
533
  const useMatch = line.match(/^Use\s+(.+)$/i);
550
534
  if (useMatch) {
551
535
  flush();
552
536
  steps.push({
553
537
  type: 'use',
554
- tool: normalizeAction(useMatch[1].trim()), // Normalize
538
+ tool: useMatch[1].trim(), // PRESERVED EXACTLY
555
539
  saveAs: null,
556
540
  constraints: {}
557
541
  });
558
542
  continue;
559
543
  }
560
544
 
561
- // Ask in block - ✅ NORMALIZE TARGET HERE
545
+ // Ask in block - ✅ PRESERVE TARGET EXACTLY (NO NORMALIZATION)
562
546
  const askMatch = line.match(/^Ask\s+(.+)$/i);
563
547
  if (askMatch) {
564
548
  flush();
565
549
  steps.push({
566
550
  type: 'ask',
567
- target: normalizeAction(askMatch[1].trim()), // Normalize
551
+ target: askMatch[1].trim(), // PRESERVED EXACTLY
568
552
  saveAs: null,
569
553
  constraints: {}
570
554
  });
@@ -593,7 +577,7 @@ function parseBlock(lines) {
593
577
 
594
578
  // Fallback
595
579
  if (current) {
596
- current.actionRaw += ' ' + normalizeAction(line);
580
+ current.actionRaw += ' ' + line; // ← PRESERVED EXACTLY (no normalizeAction)
597
581
  }
598
582
  }
599
583
 
@@ -625,4 +609,4 @@ function validate(workflow) {
625
609
  return errors;
626
610
  }
627
611
 
628
- module.exports = { parse, parseFromFile, parseLines, validate, normalizeAction };
612
+ module.exports = { parse, parseFromFile, parseLines, validate };
package/src/runtime.js CHANGED
@@ -842,7 +842,7 @@ class RuntimeAPI {
842
842
  const db = this.dbClient.client.db(process.env.DB_NAME || 'olang');
843
843
  await db.collection(step.collection).insertOne({
844
844
  workflow_name: this.context.workflow_name || 'unknown',
845
- data: sourceValue,
845
+ data: sourceValue, // ✅ FIXED: Added property name "data" (was broken syntax)
846
846
  created_at: new Date()
847
847
  });
848
848
  break;
@@ -915,7 +915,7 @@ class RuntimeAPI {
915
915
  });
916
916
  }
917
917
 
918
- // ✅ SEMANTIC VALIDATION: For return values..
918
+ // ✅ SEMANTIC VALIDATION: For return values
919
919
  const result = {};
920
920
  for (const key of workflow.returnValues) {
921
921
  if (this._requireSemantic(key, 'return')) {