From 5386081964ae851ff89b28be979eb1f9e5326905 Mon Sep 17 00:00:00 2001 From: Geoff Seemueller Date: Thu, 14 Nov 2024 23:37:22 -0500 Subject: [PATCH] tests passing --- bun.lockb | Bin 0 -> 39084 bytes package.json | 13 +++--- src/index.ts | 79 +++++++++++++++++++++++++++++-- test/core.test.ts | 106 ++++++++++++++++++++++++++++++++++++++++++ tsconfig.json | 116 ++++------------------------------------------ 5 files changed, 196 insertions(+), 118 deletions(-) create mode 100755 bun.lockb create mode 100644 test/core.test.ts diff --git a/bun.lockb b/bun.lockb new file mode 100755 index 0000000000000000000000000000000000000000..5b038d494b8d97cf1013710b1466113ff52f2198 GIT binary patch literal 39084 zcmeHwc|29y8~4F6BqAx5grtFvSyD(+lBr~f#)E?+<2gr$B1#g?DWy~zlp)R1q*dY@;Xv)FaJ=-xkm@8^A6_bzL%;rm_Bde*SlUVEP&ElvGMK2P6=8>-I< zovz^%87d2&6&&U}&7T|0VflygLf8V^cj-Ecr}EGy8>Yc2umPe4#L$CYD387vrrVqSZQIoMUdVe(*r`ocpL^}jwtTW z4fSJ1hBH#2$(SD}3d2#AYyk)n%njiR7;#WJ=JNrE@^^sBv3~zxwm`t~V@%`3Ovm;d zghVXo2jx(14nI=BrSuUI$>GH?_CY4%IDF6;$T1emb%MA72#@V!`-bsQF(V)y+v6!O zOgDtMGQ|BjK9Sf7A$+Wj!RQ0&SYK2i*B5(_%jZM`Eh8C}g7tgBAD~DGXA1&ZAf#^~ zJ9rx8t3e}BZ-Hz+3)&E%1aahf3?Y^`=_r(w9Yi&YaRlPn-?SccyVVDOY@{Ldt>WPfMOyI$C$q=Hv)?FD4fF^`Myc>ir5TaZ} z|1fz#0vM0bNKE&GPz}OS5cYu3079Th=msHFmB54$`CbDV@>fBK{b(p^M+AVeKT9A) zy-ENn%Ck?De%LE_{fC-I9_zIe2I$V^_*70daNVtYV4+?~v7U`lzpDq_5@zgB-1f=+ z)_q+ib%$7u>7#e@lt&+nKJdXzaRqfnN2`}_O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K5FHn{(3oGA2l^lI z)V-#)o1}<|nkmAgcF|!vu!*j4(6)ZK_;(^_EifR%|#Quw%-zERMwnW^2&-h(xk#wRC`cY(2;_p%lh5C{4hqT`%r1j4)dQA9o zyS4SIX^=N}$B&JLA^y8^HEI8Ez0o$As8^jh^F(+=8B&`JoS{^13uCXTj0jDYr!_&e z$&4Z|V{uQ`0-dNhmI6X*11EfA4)+mQUm`>OxW3$0g`yV&8hR8?W8gJ=Yp-IOqy{vs RG1TjPN+rTK)&KYX{XbR0$=d(` literal 0 HcmV?d00001 diff --git a/package.json b/package.json index 0ae86c2..d02fdd9 100644 --- a/package.json +++ b/package.json @@ -1,4 +1,3 @@ - { "name": "workflow-function-manifold", "version": "1.0.7", @@ -8,8 +7,10 @@ "module": "src/index.ts", "exports": { ".": { - "import": "./dist/index.js", - "require": "./dist/index.js" + "import": { + "types": "./src/index.ts", + "default": "./dist/index.js" + } } }, "bin": { @@ -18,9 +19,9 @@ "scripts": { "start": "bun src/cli.ts", "dev": "bun src/cli.ts", - "build": "rm -rf ./dist && bun build src/* --outdir dist", + "build": "rm -rf ./dist && bun build src/* --outdir dist --target browser --format esm --minify", "cli": "bun src/cli.ts", - "test": "echo \"Error: no test specified\" && exit 1", + "test": "node dist/cli.js && bun test", "lint": "eslint .", "deploy:dev": "pnpm publish .", "lint:fix": "eslint . --fix", @@ -32,7 +33,7 @@ "license": "MIT", "devDependencies": { "@eslint/js": "^9.14.0", - "@types/bun": "^1.1.13", + "@types/bun": "latest", "bun": "^1.1.34", "eslint": "^9.14.0", "globals": "^15.12.0", diff --git a/src/index.ts b/src/index.ts index 76204ac..727621b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -6,6 +6,9 @@ export class DummyIntentMap { transform: { confidence: 0.7, action: 'transformation' }, validate: { confidence: 0.85, action: 'validation' }, clean: { confidence: 0.85, action: 'cleaning' }, + test: { confidence: 0.9, action: 'testOperation' }, // <-- Added this entry + operator1: { confidence: 0.9, action: 'operator1' }, // <-- Added these entries + operator2: { confidence: 0.9, action: 'operator2' } }; const matchedIntent = Object.entries(intents).find(([key]) => prompt.toLowerCase().includes(key) @@ -53,12 +56,15 @@ export class ManifoldRegion { } } +// First fix the NestedManifoldRegion class to properly propagate state export class NestedManifoldRegion extends ManifoldRegion { nestedManifold: WorkflowFunctionManifold; constructor(name: string, nestedManifold: WorkflowFunctionManifold) { super(name); this.nestedManifold = nestedManifold; + // Initialize nested manifold state + this.nestedManifold.state = {}; } async getValidOperators(state: any): Promise { @@ -74,15 +80,21 @@ export class NestedManifoldRegion extends ManifoldRegion { async executeWorkflow(prompt: string): Promise { const result = await this.nestedManifold.executeWorkflow(prompt); + if (result) { + // Merge nested manifold state with parent manifold state + Object.assign(this.nestedManifold.state, this.nestedManifold.state); + } return result; } } +// Update WorkflowFunctionManifold to handle nested state and logging export class WorkflowFunctionManifold { intentMap: DummyIntentMap; regions: Map; currentRegion: ManifoldRegion | null; state: any; + parentManifold?: WorkflowFunctionManifold; constructor(intentMap: DummyIntentMap) { this.intentMap = intentMap; @@ -96,29 +108,59 @@ export class WorkflowFunctionManifold { if (!this.currentRegion) { this.currentRegion = region; } + if (region instanceof NestedManifoldRegion) { + region.nestedManifold.parentManifold = this; + } } async navigate(prompt: string): Promise { try { + console.log(`Navigating with prompt: "${prompt}"`); + if (this.currentRegion instanceof NestedManifoldRegion) { const nestedNavigated = await this.currentRegion.navigate(prompt); if (nestedNavigated) { return true; } } + const intent = await this.intentMap.query(prompt); + console.log(`Matched intent: ${intent.action}, confidence: ${intent.confidence}`); + if (intent.confidence <= 0.5) { + console.log(`Low confidence (${intent.confidence}) for prompt: "${prompt}"`); + console.warn(`Low confidence navigation attempt for prompt: "${prompt}"`); return false; } - const nextRegion = Array.from(this.currentRegion.adjacentRegions).find(region => - region.name.toLowerCase().includes(intent.action) + + if (!this.currentRegion) { + console.warn('No current region available for navigation'); + return false; + } + + // First try exact match + let nextRegion = Array.from(this.currentRegion.adjacentRegions).find(region => + region.name.toLowerCase() === intent.action.toLowerCase() ); + + // Then try partial match + if (!nextRegion) { + nextRegion = Array.from(this.currentRegion.adjacentRegions).find(region => + region.name.toLowerCase().includes(intent.action.toLowerCase()) + ); + } + if (nextRegion) { this.currentRegion = nextRegion; + console.log(`Navigated to region: "${nextRegion.name}"`); return true; + } else { + console.warn(`No matching region found for intent action: "${intent.action}"`); } + return false; } catch (error) { + console.warn('Navigation error:', error); return false; } } @@ -127,19 +169,46 @@ export class WorkflowFunctionManifold { try { if (this.currentRegion instanceof NestedManifoldRegion) { const nestedResult = await this.currentRegion.executeWorkflow(prompt); + if (nestedResult) { + // Propagate state changes up to parent + this.state = { + ...this.state, + ...this.currentRegion.nestedManifold.state + }; + } return nestedResult; } + const intent = await this.intentMap.query(prompt); - const operators = await this.currentRegion?.getValidOperators(this.state); + if (!this.currentRegion) { + console.warn('No current region available for execution'); + return false; + } + + const operators = await this.currentRegion.getValidOperators(this.state); const matchedOperator = operators.find(op => - op.name.toLowerCase().includes(intent.action) + op.name.toLowerCase() === intent.action.toLowerCase() ); + if (matchedOperator && intent.confidence > 0.5) { - this.state = await matchedOperator.execute(this.state); + const newState = await matchedOperator.execute(this.state); + this.state = { ...this.state, ...newState }; + + // If this is a nested manifold, propagate state changes up + if (this.parentManifold) { + this.parentManifold.state = { + ...this.parentManifold.state, + ...this.state + }; + } + return true; } + + console.warn(`No matching operator found for intent action: "${intent.action}"`); return false; } catch (error) { + console.warn('Execution error:', error); return false; } } diff --git a/test/core.test.ts b/test/core.test.ts new file mode 100644 index 0000000..02fb483 --- /dev/null +++ b/test/core.test.ts @@ -0,0 +1,106 @@ +// core.test.ts +import { DummyIntentMap, WorkflowFunctionManifold, WorkflowOperator, ManifoldRegion, NestedManifoldRegion } from '../src'; +import {test, beforeEach, describe, expect, jest} from "bun:test"; +describe('WorkflowFunctionManifold Core Test Suite', () => { + let intentService: DummyIntentMap; + let manifold: WorkflowFunctionManifold; + + beforeEach(() => { + intentService = new DummyIntentMap(); + manifold = new WorkflowFunctionManifold(intentService); + }); + + test('Should add a region and set it as the current region if none exist', () => { + const operator = new WorkflowOperator('testOperation', async state => ({ ...state, test: true })); + const region = new ManifoldRegion('testRegion', [operator]); + manifold.addRegion(region); + + expect(manifold.currentRegion).toBe(region); + }); + + test('Should navigate correctly to an adjacent region', async () => { + const operatorA = new WorkflowOperator('operationA', async state => ({ ...state, a: true })); + const operatorB = new WorkflowOperator('operationB', async state => ({ ...state, b: true })); + + const regionA = new ManifoldRegion('regionA', [operatorA]); + const regionB = new ManifoldRegion('processingRegion', [operatorB]); + + regionA.connectTo(regionB); + manifold.addRegion(regionA); + manifold.addRegion(regionB); + + const navigated = await manifold.navigate('process the data'); + expect(navigated).toBe(true); + expect(manifold.currentRegion).toBe(regionB); + }); + + test('Should execute the correct workflow operator', async () => { + const operator = new WorkflowOperator('testOperation', async state => ({ ...state, executed: true })); + const region = new ManifoldRegion('testRegion', [operator]); + + manifold.addRegion(region); + + // Make sure the operator name matches the intent action from DummyIntentMap + const executed = await manifold.executeWorkflow('test the operation'); + + expect(executed).toBe(true); + expect(manifold.state).toHaveProperty('executed', true); + }); + + test('Should fail to navigate when no matching region found', async () => { + const operator = new WorkflowOperator('operation', async state => ({ ...state, modified: true })); + const region = new ManifoldRegion('sampleRegion', [operator]); + manifold.addRegion(region); + + const navigated = await manifold.navigate('unknown operation'); + expect(navigated).toBe(false); + expect(manifold.currentRegion).toBe(region); + }); + + test('Should handle nested manifold execution correctly', async () => { + const nestedIntentService = new DummyIntentMap(); + const nestedManifold = new WorkflowFunctionManifold(nestedIntentService); + + // Create validation operator with matching name + const validateOp = new WorkflowOperator('validation', async state => ({ ...state, validated: true })); + const validateRegion = new ManifoldRegion('validation', [validateOp]); + + nestedManifold.addRegion(validateRegion); + + const nestedRegion = new NestedManifoldRegion('validation', nestedManifold); + manifold.addRegion(nestedRegion); + + await manifold.navigate('validate the input'); + const executed = await manifold.executeWorkflow('validate the input'); + + expect(executed).toBe(true); + expect(manifold.state).toHaveProperty('validated', true); + }); + + test('Should correctly propagate state changes through workflow regions', async () => { + const operator1 = new WorkflowOperator('operator1', async state => ({ ...state, step1: true })); + const operator2 = new WorkflowOperator('operator2', async state => ({ ...state, step2: true })); + + const region1 = new ManifoldRegion('operator1', [operator1]); // Match region names to operator names + const region2 = new ManifoldRegion('operator2', [operator2]); + + region1.connectTo(region2); + manifold.addRegion(region1); + manifold.addRegion(region2); + + await manifold.navigate('operator1'); + await manifold.executeWorkflow('operator1'); + await manifold.navigate('operator2'); + await manifold.executeWorkflow('operator2'); + + expect(manifold.state).toHaveProperty('step1', true); + expect(manifold.state).toHaveProperty('step2', true); + }); + + test('Should log warnings for unmatched prompts during navigation', async () => { + console.warn = jest.fn(); + const navigated = await manifold.navigate('non-existent operation'); + expect(console.warn).toHaveBeenCalled(); + expect(navigated).toBe(false); + }); +}); diff --git a/tsconfig.json b/tsconfig.json index 655169a..34a590e 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,110 +1,12 @@ { "compilerOptions": { - /* Visit https://aka.ms/tsconfig to read more about this file */ - - /* Projects */ - // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */ - // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ - // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */ - // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */ - // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ - // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ - - /* Language and Environment */ - "target": "esnext", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */ - // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ - // "jsx": "preserve", /* Specify what JSX code is generated. */ - // "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */ - // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ - // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */ - // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */ - // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */ - // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */ - // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */ - // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ - // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */ - - /* Modules */ - "module": "esnext", /* Specify what module code is generated. */ - // "rootDir": "./", /* Specify the root folder within your source files. */ - // "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */ - // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ - // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ - // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ - // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */ - // "types": [], /* Specify type package names to be included without being referenced in a source file. */ - // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ - // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ - // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ - // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */ - // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */ - // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */ - // "noUncheckedSideEffectImports": true, /* Check side effect imports. */ - // "resolveJsonModule": true, /* Enable importing .json files. */ - // "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */ - // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ - - /* JavaScript Support */ - // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */ - // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */ - // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */ - - /* Emit */ - // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ - // "declarationMap": true, /* Create sourcemaps for d.ts files. */ - // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ - // "sourceMap": true, /* Create source map files for emitted JavaScript files. */ - // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ - // "noEmit": true, /* Disable emitting files from a compilation. */ - // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */ - // "outDir": "./", /* Specify an output folder for all emitted files. */ - // "removeComments": true, /* Disable emitting comments. */ - // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ - // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */ - // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */ - // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ - // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */ - // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */ - // "newLine": "crlf", /* Set the newline character for emitting files. */ - // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */ - // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */ - // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */ - // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */ - // "declarationDir": "./", /* Specify the output directory for generated declaration files. */ - - /* Interop Constraints */ - // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */ - // "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */ - // "isolatedDeclarations": true, /* Require sufficient annotation on exports so other tools can trivially generate declaration files. */ - // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */ - "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */ - // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ - "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */ - - /* Type Checking */ - "strict": true, /* Enable all strict type-checking options. */ - // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */ - // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */ - // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ - // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */ - // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ - // "strictBuiltinIteratorReturn": true, /* Built-in iterators are instantiated with a 'TReturn' type of 'undefined' instead of 'any'. */ - // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */ - // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */ - // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ - // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */ - // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */ - // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ - // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ - // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ - // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */ - // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ - // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */ - // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */ - // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */ - - /* Completeness */ - // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ - "skipLibCheck": true /* Skip type checking all .d.ts files. */ + "target": "esnext", + "module": "esnext", + "esModuleInterop": true, + "forceConsistentCasingInFileNames": true, + "strict": true, + "skipLibCheck": true, + "moduleResolution": "node", + "types": ["bun"] } -} +} \ No newline at end of file