@o-lang/olang 1.0.9 → 1.0.11

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 (3) hide show
  1. package/cli.js +12 -0
  2. package/package.json +1 -1
  3. package/src/runtime.js +20 -7
package/cli.js CHANGED
@@ -68,6 +68,8 @@ async function builtInMathResolver(action, context) {
68
68
 
69
69
  return null;
70
70
  }
71
+ // Add resolver metadata so workflow policy recognizes it
72
+ builtInMathResolver.resolverName = 'builtInMathResolver';
71
73
 
72
74
  /**
73
75
  * Resolver chaining with verbose + context logging
@@ -164,7 +166,17 @@ program
164
166
  const content = fs.readFileSync(file, 'utf8');
165
167
  const workflow = parse(content);
166
168
 
169
+ if (!workflow || typeof workflow !== 'object') {
170
+ console.error('❌ Error: Parsed workflow is invalid or empty');
171
+ process.exit(1);
172
+ }
173
+
174
+ if (options.verbose) {
175
+ console.log('📄 Parsed Workflow:', JSON.stringify(workflow, null, 2));
176
+ }
177
+
167
178
  const resolver = loadResolverChain(options.resolver, options.verbose);
179
+
168
180
  const result = await execute(workflow, options.input, resolver, options.verbose);
169
181
 
170
182
  console.log('\n=== Workflow Result ===');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@o-lang/olang",
3
- "version": "1.0.9",
3
+ "version": "1.0.11",
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/runtime.js CHANGED
@@ -145,13 +145,26 @@ class RuntimeAPI {
145
145
  const stepType = step.type;
146
146
 
147
147
  const validateResolver = (resolver) => {
148
- const resolverName = resolver?.name || resolver?.resolverName;
149
- if (!resolverName) throw new Error('[O-Lang] Resolver missing name metadata');
150
- if (!this.allowedResolvers.has(resolverName)) {
151
- this.logDisallowedResolver(resolverName, step.actionRaw || step.tool || step.target);
152
- throw new Error(`[O-Lang] Resolver "${resolverName}" is not allowed by workflow policy`);
153
- }
154
- };
148
+ // Get resolver name from metadata, trim whitespace
149
+ const resolverName = (resolver?.resolverName || resolver?.name || '').trim();
150
+
151
+ if (!resolverName) throw new Error('[O-Lang] Resolver missing name metadata');
152
+
153
+ // Normalize allowed resolver names for comparison
154
+ const allowed = Array.from(this.allowedResolvers || []).map(r => r.trim());
155
+
156
+ // Auto-inject builtInMathResolver if math is required
157
+ if (resolverName === 'builtInMathResolver' && workflow.__requiresMath && !allowed.includes('builtInMathResolver')) {
158
+ this.allowedResolvers.add('builtInMathResolver');
159
+ allowed.push('builtInMathResolver');
160
+ }
161
+
162
+ if (!allowed.includes(resolverName)) {
163
+ this.logDisallowedResolver(resolverName, step.actionRaw || step.tool || step.target);
164
+ throw new Error(`[O-Lang] Resolver "${resolverName}" is not allowed by workflow policy`);
165
+ }
166
+ };
167
+
155
168
 
156
169
  const runResolvers = async (action) => {
157
170
  const outputs = [];