From 22fa9597ca286a29fb460fcc0b70da7e868c5a68 Mon Sep 17 00:00:00 2001 From: Geoff Seemueller Date: Fri, 15 Nov 2024 00:08:01 -0500 Subject: [PATCH] Update dependencies and add logging Upgraded package.json to version 1.1.0 and added several development dependencies. Introduced a logger for better tracking of operations. Additionally, improved type definitions across the project and integrated enhanced ESLint configurations. --- .prettierrc | 6 + eslint.config.js | 90 +++------ package.json | 9 +- pnpm-lock.yaml | 497 ++++++++++++++++++++++++++++++++++++++++++++++- src/cli.ts | 30 ++- src/index.ts | 95 +++++---- src/logger.ts | 10 + src/types.d.ts | 18 ++ tsconfig.json | 2 +- 9 files changed, 632 insertions(+), 125 deletions(-) create mode 100644 src/logger.ts create mode 100644 src/types.d.ts diff --git a/.prettierrc b/.prettierrc index 10411d7..3ed9ea3 100644 --- a/.prettierrc +++ b/.prettierrc @@ -15,6 +15,12 @@ "embeddedLanguageFormatting": "auto", "singleAttributePerLine": false, "overrides": [ + { + "files": "*.{ts,tsx}", + "options": { + "parser": "typescript" + } + }, { "files": "*.md", "options": { diff --git a/eslint.config.js b/eslint.config.js index 8f0c483..c982b67 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -1,74 +1,38 @@ -import globals from 'globals'; +// eslint.config.js import js from '@eslint/js'; +import typescript from '@typescript-eslint/eslint-plugin'; +import typescriptParser from '@typescript-eslint/parser'; +import globals from 'globals'; -/** @type {import('eslint').Linter.Config[]} */ export default [ + js.configs.recommended, { - ignores: ['dist/**', 'node_modules/**', '*.min.js', '*.d.ts'], - }, - { + files: ['**/*.{ts,tsx}'], + plugins: { + '@typescript-eslint': typescript, + }, languageOptions: { - ecmaVersion: 2024, - sourceType: 'module', + parser: typescriptParser, + parserOptions: { + ecmaVersion: 'latest', + sourceType: 'module', + project: './tsconfig.json', + }, globals: { ...globals.node, - ...globals.browser, - }, - }, - linterOptions: { - reportUnusedDisableDirectives: true, - }, - rules: { - ...js.configs.recommended.rules, - 'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off', - 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off', - 'no-unused-vars': ['error', { argsIgnorePattern: '^_' }], - 'no-constant-condition': ['error', { checkLoops: false }], - 'no-multiple-empty-lines': ['error', { max: 1, maxEOF: 0 }], - quotes: ['error', 'single', { avoidEscape: true }], - semi: ['error', 'always'], - indent: ['error', 2, { SwitchCase: 1 }], - 'comma-dangle': ['error', 'always-multiline'], - 'arrow-parens': ['error', 'as-needed'], // Changed from 'avoid' to 'as-needed' - 'object-curly-spacing': ['error', 'always'], - 'array-bracket-spacing': ['error', 'never'], - 'space-before-function-paren': [ - 'error', - { - anonymous: 'never', - named: 'never', - asyncArrow: 'always', - }, - ], - 'no-trailing-spaces': 'error', - 'eol-last': ['error', 'always'], - 'prefer-const': 'error', - 'no-var': 'error', - eqeqeq: ['error', 'always'], - curly: ['error', 'all'], - 'brace-style': ['error', '1tbs', { allowSingleLine: false }], - 'keyword-spacing': ['error', { before: true, after: true }], - 'space-infix-ops': 'error', - 'comma-spacing': ['error', { before: false, after: true }], - 'no-multi-spaces': 'error', - 'no-irregular-whitespace': 'error', - 'no-mixed-spaces-and-tabs': 'error', - 'no-else-return': 'error', - }, - }, - { - files: ['src/TokenCleaner.js'], - rules: { - 'no-useless-escape': 'off', - }, - }, - { - files: ['**/*.test.js', '**/*.spec.js'], - - languageOptions: { - globals: { ...globals.jest, }, }, + rules: { + ...typescript.configs['recommended'].rules, + '@typescript-eslint/no-explicit-any': 'warn', + '@typescript-eslint/explicit-function-return-type': 'warn', + '@typescript-eslint/explicit-module-boundary-types': 'warn', + '@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }], + 'no-console': ['warn', { allow: ['warn', 'error'] }] + }, }, -]; + { + ignores: ['dist/**', '*.test.{js,ts}', '**/*.spec.{js,ts}'], + }, +]; \ No newline at end of file diff --git a/package.json b/package.json index 99273c0..8c62b3a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "workflow-function-manifold", - "version": "1.0.9", + "version": "1.1.0", "type": "module", "description": "for building dynamic, LLM-driven workflows using a region-based execution model", "main": "src/index.ts", @@ -34,10 +34,15 @@ "devDependencies": { "@eslint/js": "^9.14.0", "@types/bun": "latest", + "@types/jest": "^29.5.14", + "@types/node": "^22.9.0", + "@typescript-eslint/eslint-plugin": "^8.14.0", + "@typescript-eslint/parser": "^8.14.0", "bun": "^1.1.34", "eslint": "^9.14.0", "globals": "^15.12.0", "prettier": "^3.3.3", - "typescript": "^5.6.3" + "typescript": "^5.6.3", + "tslog": "^4.9.3" } } \ No newline at end of file diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 3a44193..2b1d805 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -9,8 +9,20 @@ devDependencies: specifier: ^9.14.0 version: 9.14.0 '@types/bun': - specifier: ^1.1.13 + specifier: latest version: 1.1.13 + '@types/jest': + specifier: ^29.5.14 + version: 29.5.14 + '@types/node': + specifier: ^22.9.0 + version: 22.9.0 + '@typescript-eslint/eslint-plugin': + specifier: ^8.14.0 + version: 8.14.0(@typescript-eslint/parser@8.14.0)(eslint@9.14.0)(typescript@5.6.3) + '@typescript-eslint/parser': + specifier: ^8.14.0 + version: 8.14.0(eslint@9.14.0)(typescript@5.6.3) bun: specifier: ^1.1.34 version: 1.1.34 @@ -23,12 +35,29 @@ devDependencies: prettier: specifier: ^3.3.3 version: 3.3.3 + tslog: + specifier: ^4.9.3 + version: 4.9.3 typescript: specifier: ^5.6.3 version: 5.6.3 packages: + /@babel/code-frame@7.26.2: + resolution: {integrity: sha512-RJlIHRueQgwWitWgF8OdFYGZX328Ax5BCemNGlqHfplnRT9ESi8JkFlvaVYbS+UubVY6dpv87Fs2u5M29iNFVQ==} + engines: {node: '>=6.9.0'} + dependencies: + '@babel/helper-validator-identifier': 7.25.9 + js-tokens: 4.0.0 + picocolors: 1.1.1 + dev: true + + /@babel/helper-validator-identifier@7.25.9: + resolution: {integrity: sha512-Ed61U6XJc3CVRfkERJWDz4dJwKe7iLmmJsbOGu9wSloNSFttHV0I8g6UAgb7qnK5ly5bGLPd4oXZlxCdANBOWQ==} + engines: {node: '>=6.9.0'} + dev: true + /@eslint-community/eslint-utils@4.4.1(eslint@9.14.0): resolution: {integrity: sha512-s3O3waFUrMV8P/XaF/+ZTp1X9XBZW1a4B97ZnjQF2KYWaFD2A8KyFBsrsfSjEmjn3RGWAIuvlneuZm3CUK3jbA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} @@ -122,6 +151,53 @@ packages: engines: {node: '>=18.18'} dev: true + /@jest/expect-utils@29.7.0: + resolution: {integrity: sha512-GlsNBWiFQFCVi9QVSx7f5AgMeLxe9YCCs5PuP2O2LdjDAA8Jh9eX7lA1Jq/xdXw3Wb3hyvlFNfZIfcRetSzYcA==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + dependencies: + jest-get-type: 29.6.3 + dev: true + + /@jest/schemas@29.6.3: + resolution: {integrity: sha512-mo5j5X+jIZmJQveBKeS/clAueipV7KgiX1vMgCxam1RNYiqE1w62n0/tJJnHtjW8ZHcQco5gY85jA3mi0L+nSA==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + dependencies: + '@sinclair/typebox': 0.27.8 + dev: true + + /@jest/types@29.6.3: + resolution: {integrity: sha512-u3UPsIilWKOM3F9CXtrG8LEJmNxwoCQC/XVj4IKYXvvpx7QIi/Kg1LI5uDmDpKlac62NUtX7eLjRh+jVZcLOzw==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + dependencies: + '@jest/schemas': 29.6.3 + '@types/istanbul-lib-coverage': 2.0.6 + '@types/istanbul-reports': 3.0.4 + '@types/node': 22.9.0 + '@types/yargs': 17.0.33 + chalk: 4.1.2 + dev: true + + /@nodelib/fs.scandir@2.1.5: + resolution: {integrity: sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==} + engines: {node: '>= 8'} + dependencies: + '@nodelib/fs.stat': 2.0.5 + run-parallel: 1.2.0 + dev: true + + /@nodelib/fs.stat@2.0.5: + resolution: {integrity: sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==} + engines: {node: '>= 8'} + dev: true + + /@nodelib/fs.walk@1.2.8: + resolution: {integrity: sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==} + engines: {node: '>= 8'} + dependencies: + '@nodelib/fs.scandir': 2.1.5 + fastq: 1.17.1 + dev: true + /@oven/bun-darwin-aarch64@1.1.34: resolution: {integrity: sha512-p+E2CkJhCYsQyzRcuUsTA5HIHSRMq0J+aX6fiPo5iheFQAZCrhdfeAWmlU8cjZmIBvmZYbNZ96g1VVlx+ooJkg==} cpu: [arm64] @@ -186,6 +262,10 @@ packages: dev: true optional: true + /@sinclair/typebox@0.27.8: + resolution: {integrity: sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA==} + dev: true + /@types/bun@1.1.13: resolution: {integrity: sha512-KmQxSBgVWCl6RSuerlLGZlIWfdxkKqat0nxN61+qu4y1KDn0Ll3j7v1Pl8GnaL3a/U6GGWVTJh75ap62kR1E8Q==} dependencies: @@ -196,6 +276,29 @@ packages: resolution: {integrity: sha512-AYnb1nQyY49te+VRAVgmzfcgjYS91mY5P0TKUDCLEM+gNnA+3T6rWITXRLYCpahpqSQbN5cE+gHpnPyXjHWxcw==} dev: true + /@types/istanbul-lib-coverage@2.0.6: + resolution: {integrity: sha512-2QF/t/auWm0lsy8XtKVPG19v3sSOQlJe/YHZgfjb/KBBHOGSV+J2q/S671rcq9uTBrLAXmZpqJiaQbMT+zNU1w==} + dev: true + + /@types/istanbul-lib-report@3.0.3: + resolution: {integrity: sha512-NQn7AHQnk/RSLOxrBbGyJM/aVQ+pjj5HCgasFxc0K/KhoATfQ/47AyUl15I2yBUpihjmas+a+VJBOqecrFH+uA==} + dependencies: + '@types/istanbul-lib-coverage': 2.0.6 + dev: true + + /@types/istanbul-reports@3.0.4: + resolution: {integrity: sha512-pk2B1NWalF9toCRu6gjBzR69syFjP4Od8WRAX+0mmf9lAjCRicLOWc+ZrxZHx/0XRjotgkF9t6iaMJ+aXcOdZQ==} + dependencies: + '@types/istanbul-lib-report': 3.0.3 + dev: true + + /@types/jest@29.5.14: + resolution: {integrity: sha512-ZN+4sdnLUbo8EVvVc2ao0GFW6oVrQRPn4K2lglySj7APvSrgzxHiNNK99us4WDMi57xxA2yggblIAMNhXOotLQ==} + dependencies: + expect: 29.7.0 + pretty-format: 29.7.0 + dev: true + /@types/json-schema@7.0.15: resolution: {integrity: sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==} dev: true @@ -206,10 +309,156 @@ packages: undici-types: 5.26.5 dev: true + /@types/node@22.9.0: + resolution: {integrity: sha512-vuyHg81vvWA1Z1ELfvLko2c8f34gyA0zaic0+Rllc5lbCnbSyuvb2Oxpm6TAUAC/2xZN3QGqxBNggD1nNR2AfQ==} + dependencies: + undici-types: 6.19.8 + dev: true + + /@types/stack-utils@2.0.3: + resolution: {integrity: sha512-9aEbYZ3TbYMznPdcdr3SmIrLXwC/AKZXQeCf9Pgao5CKb8CyHuEX5jzWPTkvregvhRJHcpRO6BFoGW9ycaOkYw==} + dev: true + /@types/ws@8.5.13: resolution: {integrity: sha512-osM/gWBTPKgHV8XkTunnegTRIsvF6owmf5w+JtAfOw472dptdm0dlGv4xCt6GwQRcC2XVOvvRE/0bAoQcL2QkA==} dependencies: - '@types/node': 20.12.14 + '@types/node': 22.9.0 + dev: true + + /@types/yargs-parser@21.0.3: + resolution: {integrity: sha512-I4q9QU9MQv4oEOz4tAHJtNz1cwuLxn2F3xcc2iV5WdqLPpUnj30aUuxt1mAxYTG+oe8CZMV/+6rU4S4gRDzqtQ==} + dev: true + + /@types/yargs@17.0.33: + resolution: {integrity: sha512-WpxBCKWPLr4xSsHgz511rFJAM+wS28w2zEO1QDNY5zM/S8ok70NNfztH0xwhqKyaK0OHCbN98LDAZuy1ctxDkA==} + dependencies: + '@types/yargs-parser': 21.0.3 + dev: true + + /@typescript-eslint/eslint-plugin@8.14.0(@typescript-eslint/parser@8.14.0)(eslint@9.14.0)(typescript@5.6.3): + resolution: {integrity: sha512-tqp8H7UWFaZj0yNO6bycd5YjMwxa6wIHOLZvWPkidwbgLCsBMetQoGj7DPuAlWa2yGO3H48xmPwjhsSPPCGU5w==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + peerDependencies: + '@typescript-eslint/parser': ^8.0.0 || ^8.0.0-alpha.0 + eslint: ^8.57.0 || ^9.0.0 + typescript: '*' + peerDependenciesMeta: + typescript: + optional: true + dependencies: + '@eslint-community/regexpp': 4.12.1 + '@typescript-eslint/parser': 8.14.0(eslint@9.14.0)(typescript@5.6.3) + '@typescript-eslint/scope-manager': 8.14.0 + '@typescript-eslint/type-utils': 8.14.0(eslint@9.14.0)(typescript@5.6.3) + '@typescript-eslint/utils': 8.14.0(eslint@9.14.0)(typescript@5.6.3) + '@typescript-eslint/visitor-keys': 8.14.0 + eslint: 9.14.0 + graphemer: 1.4.0 + ignore: 5.3.2 + natural-compare: 1.4.0 + ts-api-utils: 1.4.0(typescript@5.6.3) + typescript: 5.6.3 + transitivePeerDependencies: + - supports-color + dev: true + + /@typescript-eslint/parser@8.14.0(eslint@9.14.0)(typescript@5.6.3): + resolution: {integrity: sha512-2p82Yn9juUJq0XynBXtFCyrBDb6/dJombnz6vbo6mgQEtWHfvHbQuEa9kAOVIt1c9YFwi7H6WxtPj1kg+80+RA==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + peerDependencies: + eslint: ^8.57.0 || ^9.0.0 + typescript: '*' + peerDependenciesMeta: + typescript: + optional: true + dependencies: + '@typescript-eslint/scope-manager': 8.14.0 + '@typescript-eslint/types': 8.14.0 + '@typescript-eslint/typescript-estree': 8.14.0(typescript@5.6.3) + '@typescript-eslint/visitor-keys': 8.14.0 + debug: 4.3.7 + eslint: 9.14.0 + typescript: 5.6.3 + transitivePeerDependencies: + - supports-color + dev: true + + /@typescript-eslint/scope-manager@8.14.0: + resolution: {integrity: sha512-aBbBrnW9ARIDn92Zbo7rguLnqQ/pOrUguVpbUwzOhkFg2npFDwTgPGqFqE0H5feXcOoJOfX3SxlJaKEVtq54dw==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + dependencies: + '@typescript-eslint/types': 8.14.0 + '@typescript-eslint/visitor-keys': 8.14.0 + dev: true + + /@typescript-eslint/type-utils@8.14.0(eslint@9.14.0)(typescript@5.6.3): + resolution: {integrity: sha512-Xcz9qOtZuGusVOH5Uk07NGs39wrKkf3AxlkK79RBK6aJC1l03CobXjJbwBPSidetAOV+5rEVuiT1VSBUOAsanQ==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + peerDependencies: + typescript: '*' + peerDependenciesMeta: + typescript: + optional: true + dependencies: + '@typescript-eslint/typescript-estree': 8.14.0(typescript@5.6.3) + '@typescript-eslint/utils': 8.14.0(eslint@9.14.0)(typescript@5.6.3) + debug: 4.3.7 + ts-api-utils: 1.4.0(typescript@5.6.3) + typescript: 5.6.3 + transitivePeerDependencies: + - eslint + - supports-color + dev: true + + /@typescript-eslint/types@8.14.0: + resolution: {integrity: sha512-yjeB9fnO/opvLJFAsPNYlKPnEM8+z4og09Pk504dkqonT02AyL5Z9SSqlE0XqezS93v6CXn49VHvB2G7XSsl0g==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + dev: true + + /@typescript-eslint/typescript-estree@8.14.0(typescript@5.6.3): + resolution: {integrity: sha512-OPXPLYKGZi9XS/49rdaCbR5j/S14HazviBlUQFvSKz3npr3NikF+mrgK7CFVur6XEt95DZp/cmke9d5i3vtVnQ==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + peerDependencies: + typescript: '*' + peerDependenciesMeta: + typescript: + optional: true + dependencies: + '@typescript-eslint/types': 8.14.0 + '@typescript-eslint/visitor-keys': 8.14.0 + debug: 4.3.7 + fast-glob: 3.3.2 + is-glob: 4.0.3 + minimatch: 9.0.5 + semver: 7.6.3 + ts-api-utils: 1.4.0(typescript@5.6.3) + typescript: 5.6.3 + transitivePeerDependencies: + - supports-color + dev: true + + /@typescript-eslint/utils@8.14.0(eslint@9.14.0)(typescript@5.6.3): + resolution: {integrity: sha512-OGqj6uB8THhrHj0Fk27DcHPojW7zKwKkPmHXHvQ58pLYp4hy8CSUdTKykKeh+5vFqTTVmjz0zCOOPKRovdsgHA==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + peerDependencies: + eslint: ^8.57.0 || ^9.0.0 + dependencies: + '@eslint-community/eslint-utils': 4.4.1(eslint@9.14.0) + '@typescript-eslint/scope-manager': 8.14.0 + '@typescript-eslint/types': 8.14.0 + '@typescript-eslint/typescript-estree': 8.14.0(typescript@5.6.3) + eslint: 9.14.0 + transitivePeerDependencies: + - supports-color + - typescript + dev: true + + /@typescript-eslint/visitor-keys@8.14.0: + resolution: {integrity: sha512-vG0XZo8AdTH9OE6VFRwAZldNc7qtJ/6NLGWak+BtENuEUXGZgFpihILPiBvKXvJ2nFu27XNGC6rKiwuaoMbYzQ==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + dependencies: + '@typescript-eslint/types': 8.14.0 + eslint-visitor-keys: 3.4.3 dev: true /acorn-jsx@5.3.2(acorn@8.14.0): @@ -242,6 +491,11 @@ packages: color-convert: 2.0.1 dev: true + /ansi-styles@5.2.0: + resolution: {integrity: sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==} + engines: {node: '>=10'} + dev: true + /argparse@2.0.1: resolution: {integrity: sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==} dev: true @@ -257,6 +511,19 @@ packages: concat-map: 0.0.1 dev: true + /brace-expansion@2.0.1: + resolution: {integrity: sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==} + dependencies: + balanced-match: 1.0.2 + dev: true + + /braces@3.0.3: + resolution: {integrity: sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==} + engines: {node: '>=8'} + dependencies: + fill-range: 7.1.1 + dev: true + /bun-types@1.1.34: resolution: {integrity: sha512-br5QygTEL/TwB4uQOb96Ky22j4Gq2WxWH/8Oqv20fk5HagwKXo/akB+LiYgSfzexCt6kkcUaVm+bKiPl71xPvw==} dependencies: @@ -294,6 +561,11 @@ packages: supports-color: 7.2.0 dev: true + /ci-info@3.9.0: + resolution: {integrity: sha512-NIxF55hv4nSqQswkAeiOi1r83xy8JldOFDTWiug55KBu9Jnblncd2U6ViHmYgHf01TPZS77NJBhBMKdWj9HQMQ==} + engines: {node: '>=8'} + dev: true + /color-convert@2.0.1: resolution: {integrity: sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==} engines: {node: '>=7.0.0'} @@ -334,6 +606,16 @@ packages: resolution: {integrity: sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==} dev: true + /diff-sequences@29.6.3: + resolution: {integrity: sha512-EjePK1srD3P08o2j4f0ExnylqRs5B9tJjcp9t1krH2qRi8CCdsYfwe9JgSLurFBWwq4uOlipzfk5fHNvwFKr8Q==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + dev: true + + /escape-string-regexp@2.0.0: + resolution: {integrity: sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==} + engines: {node: '>=8'} + dev: true + /escape-string-regexp@4.0.0: resolution: {integrity: sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==} engines: {node: '>=10'} @@ -439,10 +721,32 @@ packages: engines: {node: '>=0.10.0'} dev: true + /expect@29.7.0: + resolution: {integrity: sha512-2Zks0hf1VLFYI1kbh0I5jP3KHHyCHpkfyHBzsSXRFgl/Bg9mWYfMW8oD+PdMPlEwy5HNsR9JutYy6pMeOh61nw==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + dependencies: + '@jest/expect-utils': 29.7.0 + jest-get-type: 29.6.3 + jest-matcher-utils: 29.7.0 + jest-message-util: 29.7.0 + jest-util: 29.7.0 + dev: true + /fast-deep-equal@3.1.3: resolution: {integrity: sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==} dev: true + /fast-glob@3.3.2: + resolution: {integrity: sha512-oX2ruAFQwf/Orj8m737Y5adxDQO0LAB7/S5MnxCdTNDd4p6BsyIVsv9JQsATbTSq8KHRpLwIHbVlUNatxd+1Ow==} + engines: {node: '>=8.6.0'} + dependencies: + '@nodelib/fs.stat': 2.0.5 + '@nodelib/fs.walk': 1.2.8 + glob-parent: 5.1.2 + merge2: 1.4.1 + micromatch: 4.0.8 + dev: true + /fast-json-stable-stringify@2.1.0: resolution: {integrity: sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==} dev: true @@ -451,6 +755,12 @@ packages: resolution: {integrity: sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==} dev: true + /fastq@1.17.1: + resolution: {integrity: sha512-sRVD3lWVIXWg6By68ZN7vho9a1pQcN/WBFaAAsDDFzlJjvoGx0P8z7V1t72grFJfJhu3YPZBuu25f7Kaw2jN1w==} + dependencies: + reusify: 1.0.4 + dev: true + /file-entry-cache@8.0.0: resolution: {integrity: sha512-XXTUwCvisa5oacNGRP9SfNtYBNAMi+RPwBFmblZEF7N7swHYQS6/Zfk7SRwx4D5j3CH211YNRco1DEMNVfZCnQ==} engines: {node: '>=16.0.0'} @@ -458,6 +768,13 @@ packages: flat-cache: 4.0.1 dev: true + /fill-range@7.1.1: + resolution: {integrity: sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==} + engines: {node: '>=8'} + dependencies: + to-regex-range: 5.0.1 + dev: true + /find-up@5.0.0: resolution: {integrity: sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==} engines: {node: '>=10'} @@ -478,6 +795,13 @@ packages: resolution: {integrity: sha512-X8cqMLLie7KsNUDSdzeN8FYK9rEt4Dt67OsG/DNGnYTSDBG4uFAJFBnUeiV+zCVAvwFy56IjM9sH51jVaEhNxw==} dev: true + /glob-parent@5.1.2: + resolution: {integrity: sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==} + engines: {node: '>= 6'} + dependencies: + is-glob: 4.0.3 + dev: true + /glob-parent@6.0.2: resolution: {integrity: sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==} engines: {node: '>=10.13.0'} @@ -495,6 +819,14 @@ packages: engines: {node: '>=18'} dev: true + /graceful-fs@4.2.11: + resolution: {integrity: sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==} + dev: true + + /graphemer@1.4.0: + resolution: {integrity: sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==} + dev: true + /has-flag@4.0.0: resolution: {integrity: sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==} engines: {node: '>=8'} @@ -530,10 +862,71 @@ packages: is-extglob: 2.1.1 dev: true + /is-number@7.0.0: + resolution: {integrity: sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==} + engines: {node: '>=0.12.0'} + dev: true + /isexe@2.0.0: resolution: {integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==} dev: true + /jest-diff@29.7.0: + resolution: {integrity: sha512-LMIgiIrhigmPrs03JHpxUh2yISK3vLFPkAodPeo0+BuF7wA2FoQbkEg1u8gBYBThncu7e1oEDUfIXVuTqLRUjw==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + dependencies: + chalk: 4.1.2 + diff-sequences: 29.6.3 + jest-get-type: 29.6.3 + pretty-format: 29.7.0 + dev: true + + /jest-get-type@29.6.3: + resolution: {integrity: sha512-zrteXnqYxfQh7l5FHyL38jL39di8H8rHoecLH3JNxH3BwOrBsNeabdap5e0I23lD4HHI8W5VFBZqG4Eaq5LNcw==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + dev: true + + /jest-matcher-utils@29.7.0: + resolution: {integrity: sha512-sBkD+Xi9DtcChsI3L3u0+N0opgPYnCRPtGcQYrgXmR+hmt/fYfWAL0xRXYU8eWOdfuLgBe0YCW3AFtnRLagq/g==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + dependencies: + chalk: 4.1.2 + jest-diff: 29.7.0 + jest-get-type: 29.6.3 + pretty-format: 29.7.0 + dev: true + + /jest-message-util@29.7.0: + resolution: {integrity: sha512-GBEV4GRADeP+qtB2+6u61stea8mGcOT4mCtrYISZwfu9/ISHFJ/5zOMXYbpBE9RsS5+Gb63DW4FgmnKJ79Kf6w==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + dependencies: + '@babel/code-frame': 7.26.2 + '@jest/types': 29.6.3 + '@types/stack-utils': 2.0.3 + chalk: 4.1.2 + graceful-fs: 4.2.11 + micromatch: 4.0.8 + pretty-format: 29.7.0 + slash: 3.0.0 + stack-utils: 2.0.6 + dev: true + + /jest-util@29.7.0: + resolution: {integrity: sha512-z6EbKajIpqGKU56y5KBUgy1dt1ihhQJgWzUlZHArA/+X2ad7Cb5iF+AK1EWVL/Bo7Rz9uurpqw6SiBCefUbCGA==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + dependencies: + '@jest/types': 29.6.3 + '@types/node': 22.9.0 + chalk: 4.1.2 + ci-info: 3.9.0 + graceful-fs: 4.2.11 + picomatch: 2.3.1 + dev: true + + /js-tokens@4.0.0: + resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==} + dev: true + /js-yaml@4.1.0: resolution: {integrity: sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==} hasBin: true @@ -578,12 +971,32 @@ packages: resolution: {integrity: sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==} dev: true + /merge2@1.4.1: + resolution: {integrity: sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==} + engines: {node: '>= 8'} + dev: true + + /micromatch@4.0.8: + resolution: {integrity: sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==} + engines: {node: '>=8.6'} + dependencies: + braces: 3.0.3 + picomatch: 2.3.1 + dev: true + /minimatch@3.1.2: resolution: {integrity: sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==} dependencies: brace-expansion: 1.1.11 dev: true + /minimatch@9.0.5: + resolution: {integrity: sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==} + engines: {node: '>=16 || 14 >=14.17'} + dependencies: + brace-expansion: 2.0.1 + dev: true + /ms@2.1.3: resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==} dev: true @@ -635,6 +1048,15 @@ packages: engines: {node: '>=8'} dev: true + /picocolors@1.1.1: + resolution: {integrity: sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==} + dev: true + + /picomatch@2.3.1: + resolution: {integrity: sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==} + engines: {node: '>=8.6'} + dev: true + /prelude-ls@1.2.1: resolution: {integrity: sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==} engines: {node: '>= 0.8.0'} @@ -646,16 +1068,50 @@ packages: hasBin: true dev: true + /pretty-format@29.7.0: + resolution: {integrity: sha512-Pdlw/oPxN+aXdmM9R00JVC9WVFoCLTKJvDVLgmJ+qAffBMxsV85l/Lu7sNx4zSzPyoL2euImuEwHhOXdEgNFZQ==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + dependencies: + '@jest/schemas': 29.6.3 + ansi-styles: 5.2.0 + react-is: 18.3.1 + dev: true + /punycode@2.3.1: resolution: {integrity: sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==} engines: {node: '>=6'} dev: true + /queue-microtask@1.2.3: + resolution: {integrity: sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==} + dev: true + + /react-is@18.3.1: + resolution: {integrity: sha512-/LLMVyas0ljjAtoYiPqYiL8VWXzUUdThrmU5+n20DZv+a+ClRoevUzw5JxU+Ieh5/c87ytoTBV9G1FiKfNJdmg==} + dev: true + /resolve-from@4.0.0: resolution: {integrity: sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==} engines: {node: '>=4'} dev: true + /reusify@1.0.4: + resolution: {integrity: sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==} + engines: {iojs: '>=1.0.0', node: '>=0.10.0'} + dev: true + + /run-parallel@1.2.0: + resolution: {integrity: sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==} + dependencies: + queue-microtask: 1.2.3 + dev: true + + /semver@7.6.3: + resolution: {integrity: sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==} + engines: {node: '>=10'} + hasBin: true + dev: true + /shebang-command@2.0.0: resolution: {integrity: sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==} engines: {node: '>=8'} @@ -668,6 +1124,18 @@ packages: engines: {node: '>=8'} dev: true + /slash@3.0.0: + resolution: {integrity: sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==} + engines: {node: '>=8'} + dev: true + + /stack-utils@2.0.6: + resolution: {integrity: sha512-XlkWvfIm6RmsWtNJx+uqtKLS8eqFbxUg0ZzLXqY0caEy9l7hruX8IpiDnjsLavoBgqCCR71TqWO8MaXYheJ3RQ==} + engines: {node: '>=10'} + dependencies: + escape-string-regexp: 2.0.0 + dev: true + /strip-json-comments@3.1.1: resolution: {integrity: sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==} engines: {node: '>=8'} @@ -684,6 +1152,27 @@ packages: resolution: {integrity: sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==} dev: true + /to-regex-range@5.0.1: + resolution: {integrity: sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==} + engines: {node: '>=8.0'} + dependencies: + is-number: 7.0.0 + dev: true + + /ts-api-utils@1.4.0(typescript@5.6.3): + resolution: {integrity: sha512-032cPxaEKwM+GT3vA5JXNzIaizx388rhsSW79vGRNGXfRRAdEAn2mvk36PvK5HnOchyWZ7afLEXqYCvPCrzuzQ==} + engines: {node: '>=16'} + peerDependencies: + typescript: '>=4.2.0' + dependencies: + typescript: 5.6.3 + dev: true + + /tslog@4.9.3: + resolution: {integrity: sha512-oDWuGVONxhVEBtschLf2cs/Jy8i7h1T+CpdkTNWQgdAF7DhRo2G8vMCgILKe7ojdEkLhICWgI1LYSSKaJsRgcw==} + engines: {node: '>=16'} + dev: true + /type-check@0.4.0: resolution: {integrity: sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==} engines: {node: '>= 0.8.0'} @@ -701,6 +1190,10 @@ packages: resolution: {integrity: sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==} dev: true + /undici-types@6.19.8: + resolution: {integrity: sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==} + dev: true + /uri-js@4.4.1: resolution: {integrity: sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==} dependencies: diff --git a/src/cli.ts b/src/cli.ts index 4046468..4847893 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -1,26 +1,28 @@ #!/usr/bin/env node + import { DummyIntentMap, ManifoldRegion, WorkflowFunctionManifold, WorkflowOperator, - NestedManifoldRegion, + NestedManifoldRegion } from './index'; +import { WorkflowState } from './types'; -async function demonstrateNestedManifold() { +async function demonstrateNestedManifold(): Promise { const nestedIntentService = new DummyIntentMap(); const nestedManifold = new WorkflowFunctionManifold(nestedIntentService); - const validateOp = new WorkflowOperator('validation', async (state: any) => { + const validateOp = new WorkflowOperator('validation', async (state: WorkflowState) => { return { ...state, validated: true }; }); - const cleanOp = new WorkflowOperator('cleaning', async (state: any) => { + + const cleanOp = new WorkflowOperator('cleaning', async (state: WorkflowState) => { return { ...state, cleaned: true }; }); const validateRegion = new ManifoldRegion('validation', [validateOp]); const cleanRegion = new ManifoldRegion('cleaning', [cleanOp]); - validateRegion.connectTo(cleanRegion); nestedManifold.addRegion(validateRegion); nestedManifold.addRegion(cleanRegion); @@ -28,10 +30,11 @@ async function demonstrateNestedManifold() { const mainIntentService = new DummyIntentMap(); const mainManifold = new WorkflowFunctionManifold(mainIntentService); - const analysisOp = new WorkflowOperator('analysis', async (state: any) => { + const analysisOp = new WorkflowOperator('analysis', async (state: WorkflowState) => { return { ...state, analyzed: true }; }); - const transformOp = new WorkflowOperator('transformation', async (state: any) => { + + const transformOp = new WorkflowOperator('transformation', async (state: WorkflowState) => { return { ...state, transformed: true }; }); @@ -56,22 +59,13 @@ async function demonstrateNestedManifold() { for (const { text, description } of prompts) { try { const navigated = await mainManifold.navigate(text); - if (navigated) { - console.log(`📍 Step: ${description}`); - } const executed = await mainManifold.executeWorkflow(text); - if (executed) { - console.log(`✅ Execution complete`); - } else { - console.log(`⚠️ Execution failed`); - } } catch (error) { - console.error(`❌ Error: ${error.message}`); + // Handle errors silently in demo } } } -demonstrateNestedManifold().catch(error => { - console.error(`❌ Critical Error: ${error.message}`); +demonstrateNestedManifold().catch(() => { process.exit(1); }); \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index 727621b..f8d13ef 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,33 +1,42 @@ +import { log } from './logger'; + export class DummyIntentMap { - async query(prompt: string): Promise<{ confidence: number; action: string }> { - const intents: Record = { + async query(prompt: string): Promise { + log.debug(`Processing intent query for prompt: ${prompt}`); + const intents: Record = { analyze: { confidence: 0.9, action: 'analysis' }, process: { confidence: 0.8, action: 'processing' }, 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 + test: { confidence: 0.9, action: 'testOperation' }, + operator1: { confidence: 0.9, action: 'operator1' }, operator2: { confidence: 0.9, action: 'operator2' } }; const matchedIntent = Object.entries(intents).find(([key]) => - prompt.toLowerCase().includes(key) + prompt.toLowerCase().includes(key) ); - return matchedIntent ? matchedIntent[1] : { confidence: 0.1, action: 'unknown' }; + const result = matchedIntent ? matchedIntent[1] : { confidence: 0.1, action: 'unknown' }; + log.debug(`Intent match result: ${JSON.stringify(result)}`); + return result; } } export class WorkflowOperator { name: string; - operation: (state: any) => Promise; + operation: (state: WorkflowState) => Promise; - constructor(name: string, operation: (state: any) => Promise) { + constructor(name: string, operation: (state: WorkflowState) => Promise) { this.name = name; this.operation = operation; + log.info(`Created new WorkflowOperator: ${name}`); } - async execute(state: any): Promise { - return await this.operation(state); + async execute(state: WorkflowState): Promise { + log.debug(`Executing operator ${this.name} with state: ${JSON.stringify(state)}`); + const result = await this.operation(state); + log.debug(`Operator ${this.name} execution complete. New state: ${JSON.stringify(result)}`); + return result; } } @@ -40,60 +49,66 @@ export class ManifoldRegion { this.name = name; this.operators = operators; this.adjacentRegions = new Set(); + log.info(`Created new ManifoldRegion: ${name} with ${operators.length} operators`); } addOperator(operator: WorkflowOperator): void { + log.debug(`Adding operator ${operator.name} to region ${this.name}`); this.operators.push(operator); } connectTo(region: ManifoldRegion): void { + log.info(`Connecting region ${this.name} to ${region.name}`); this.adjacentRegions.add(region); region.adjacentRegions.add(this); } - async getValidOperators(_state: any): Promise { + async getValidOperators(state: WorkflowState): Promise { + log.debug(`Getting valid operators for region ${this.name}`); return this.operators; } } -// 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 = {}; + log.info(`Created new NestedManifoldRegion: ${name}`); } - async getValidOperators(state: any): Promise { + async getValidOperators(state: WorkflowState): Promise { + log.debug(`Getting valid operators for nested region ${this.name}`); if (!this.nestedManifold.currentRegion) { + log.warn(`No current region in nested manifold for ${this.name}`); return []; } return await this.nestedManifold.currentRegion.getValidOperators(state); } async navigate(prompt: string): Promise { + log.debug(`Navigating nested manifold in ${this.name} with prompt: ${prompt}`); return await this.nestedManifold.navigate(prompt); } async executeWorkflow(prompt: string): Promise { + log.debug(`Executing nested workflow in ${this.name} with prompt: ${prompt}`); const result = await this.nestedManifold.executeWorkflow(prompt); if (result) { - // Merge nested manifold state with parent manifold state + log.debug(`Nested workflow execution successful, updating 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; + state: WorkflowState; parentManifold?: WorkflowFunctionManifold; constructor(intentMap: DummyIntentMap) { @@ -101,76 +116,79 @@ export class WorkflowFunctionManifold { this.regions = new Map(); this.currentRegion = null; this.state = {}; + log.info('Created new WorkflowFunctionManifold'); } addRegion(region: ManifoldRegion): void { + log.info(`Adding region ${region.name} to manifold`); this.regions.set(region.name, region); if (!this.currentRegion) { + log.debug(`Setting ${region.name} as current region`); this.currentRegion = region; } if (region instanceof NestedManifoldRegion) { + log.debug(`Setting parent manifold for nested region ${region.name}`); region.nestedManifold.parentManifold = this; } } async navigate(prompt: string): Promise { try { - console.log(`Navigating with prompt: "${prompt}"`); + log.debug(`Attempting navigation with prompt: ${prompt}`); if (this.currentRegion instanceof NestedManifoldRegion) { + log.debug('Current region is nested, attempting nested navigation'); const nestedNavigated = await this.currentRegion.navigate(prompt); if (nestedNavigated) { + log.debug('Nested navigation successful'); 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}"`); + log.warn(`Low confidence intent match: ${intent.confidence}`); return false; } if (!this.currentRegion) { - console.warn('No current region available for navigation'); + log.error('No current region set'); return false; } - // First try exact match let nextRegion = Array.from(this.currentRegion.adjacentRegions).find(region => - region.name.toLowerCase() === intent.action.toLowerCase() + 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()) + region.name.toLowerCase().includes(intent.action.toLowerCase()) ); } if (nextRegion) { + log.info(`Navigating from ${this.currentRegion.name} to ${nextRegion.name}`); this.currentRegion = nextRegion; - console.log(`Navigated to region: "${nextRegion.name}"`); return true; - } else { - console.warn(`No matching region found for intent action: "${intent.action}"`); } + log.warn(`No valid navigation target found for prompt: ${prompt}`); return false; } catch (error) { - console.warn('Navigation error:', error); + log.error('Navigation error:', error); return false; } } async executeWorkflow(prompt: string): Promise { try { + log.debug(`Executing workflow with prompt: ${prompt}`); + if (this.currentRegion instanceof NestedManifoldRegion) { + log.debug('Executing nested workflow'); const nestedResult = await this.currentRegion.executeWorkflow(prompt); if (nestedResult) { - // Propagate state changes up to parent + log.debug('Nested workflow successful, updating state'); this.state = { ...this.state, ...this.currentRegion.nestedManifold.state @@ -181,34 +199,33 @@ export class WorkflowFunctionManifold { const intent = await this.intentMap.query(prompt); if (!this.currentRegion) { - console.warn('No current region available for execution'); + log.error('No current region set for workflow execution'); return false; } const operators = await this.currentRegion.getValidOperators(this.state); const matchedOperator = operators.find(op => - op.name.toLowerCase() === intent.action.toLowerCase() + op.name.toLowerCase() === intent.action.toLowerCase() ); if (matchedOperator && intent.confidence > 0.5) { + log.info(`Executing operator ${matchedOperator.name}`); 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) { + log.debug('Updating parent manifold state'); this.parentManifold.state = { ...this.parentManifold.state, ...this.state }; } - return true; } - console.warn(`No matching operator found for intent action: "${intent.action}"`); + log.warn(`No matching operator found for prompt: ${prompt}`); return false; } catch (error) { - console.warn('Execution error:', error); + log.error('Workflow execution error:', error); return false; } } diff --git a/src/logger.ts b/src/logger.ts new file mode 100644 index 0000000..1123651 --- /dev/null +++ b/src/logger.ts @@ -0,0 +1,10 @@ +// src/logger.ts +import { Logger, ILogObj } from "tslog"; + +export const log: Logger = new Logger({ + name: "workflow-function-manifold", + prettyLogTemplate: "{{yyyy}}-{{mm}}-{{dd}} {{hh}}:{{MM}}:{{ss}}:{{ms}} {{logLevelName}} [{{name}}] ", + prettyLogTimeZone: "local" +}); + +export default log; \ No newline at end of file diff --git a/src/types.d.ts b/src/types.d.ts new file mode 100644 index 0000000..b89b719 --- /dev/null +++ b/src/types.d.ts @@ -0,0 +1,18 @@ +// src/types.d.ts +interface WorkflowState { + [key: string]: unknown; + validated?: boolean; + cleaned?: boolean; + analyzed?: boolean; + transformed?: boolean; + test?: boolean; + executed?: boolean; + modified?: boolean; + step1?: boolean; + step2?: boolean; +} + +interface IntentResult { + confidence: number; + action: string; +} \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index 34a590e..b4a0026 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -7,6 +7,6 @@ "strict": true, "skipLibCheck": true, "moduleResolution": "node", - "types": ["bun"] + "types": ["bun", "src/types.d.ts"] } } \ No newline at end of file