@output.ai/core 0.5.2 → 0.5.4

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.
@@ -1,6 +1,6 @@
1
1
  import traverseModule from '@babel/traverse';
2
2
  import { dirname } from 'node:path';
3
- import { parse, toAbsolutePath, getFileKind, isAnyStepsPath, isEvaluatorsPath, isWorkflowPath } from '../tools.js';
3
+ import { parse, toAbsolutePath, getFileKind, isAnyStepsPath, isAnyEvaluatorsPath, isWorkflowPath } from '../tools.js';
4
4
  import { ComponentFile } from '../consts.js';
5
5
  import {
6
6
  isCallExpression,
@@ -27,7 +27,7 @@ const getFileKindLabel = filename => {
27
27
  if ( isAnyStepsPath( filename ) ) {
28
28
  return 'steps.js';
29
29
  }
30
- if ( isEvaluatorsPath( filename ) ) {
30
+ if ( isAnyEvaluatorsPath( filename ) ) {
31
31
  return 'evaluators.js';
32
32
  }
33
33
  if ( /workflow\.js$/.test( filename ) ) {
@@ -48,7 +48,7 @@ const validateInstantiationLocation = ( calleeName, filename ) => {
48
48
  if ( calleeName === 'step' && !isAnyStepsPath( filename ) ) {
49
49
  throw new Error( `Invalid instantiation location: step() can only be called in files with 'steps' in the path. Found in: ${filename}` );
50
50
  }
51
- if ( calleeName === 'evaluator' && !isEvaluatorsPath( filename ) ) {
51
+ if ( calleeName === 'evaluator' && !isAnyEvaluatorsPath( filename ) ) {
52
52
  throw new Error( `Invalid instantiation location: evaluator() can only be called in files with 'evaluators' in the path. Found in: ${filename}` );
53
53
  }
54
54
  if ( calleeName === 'workflow' && !isWorkflowPath( filename ) ) {
@@ -565,6 +565,28 @@ describe( 'workflow_validator loader', () => {
565
565
  rmSync( dir, { recursive: true, force: true } );
566
566
  } );
567
567
 
568
+ it( 'step() called in evaluators.js is blocked by validator', async () => {
569
+ const dir = mkdtempSync( join( tmpdir(), 'step-evals-fail-' ) );
570
+ const src = [
571
+ 'import { step } from "@output.ai/core";',
572
+ 'export const badStep = step({ name: "bad", fn: async () => ({}) });'
573
+ ].join( '\n' );
574
+ await expect( runLoader( join( dir, 'evaluators.js' ), src ) )
575
+ .rejects.toThrow( /Invalid instantiation location.*step\(\).*steps/ );
576
+ rmSync( dir, { recursive: true, force: true } );
577
+ } );
578
+
579
+ it( 'evaluator() called in steps.js is blocked by validator', async () => {
580
+ const dir = mkdtempSync( join( tmpdir(), 'eval-steps-fail-' ) );
581
+ const src = [
582
+ 'import { evaluator } from "@output.ai/core";',
583
+ 'export const badEval = evaluator({ name: "bad", fn: async () => ({ value: 1 }) });'
584
+ ].join( '\n' );
585
+ await expect( runLoader( join( dir, 'steps.js' ), src ) )
586
+ .rejects.toThrow( /Invalid instantiation location.*evaluator\(\).*evaluators/ );
587
+ rmSync( dir, { recursive: true, force: true } );
588
+ } );
589
+
568
590
  it( 'workflow() called in shared/common.js is blocked by validator', async () => {
569
591
  const dir = mkdtempSync( join( tmpdir(), 'wf-shared-fail-' ) );
570
592
  mkdirSync( join( dir, 'shared' ) );