@ai.ntellect/core 1.0.0 → 1.1.1
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/.mocharc.json +6 -0
- package/AGENTS.md +50 -0
- package/ARCHITECTURE.md +58 -0
- package/BENCHMARK.md +38 -0
- package/CHANGELOG.md +224 -0
- package/README.md +363 -142
- package/agent/agent-workflow.ts +569 -0
- package/agent/agent.ts +183 -0
- package/agent/base/executor.ts +103 -0
- package/agent/base/index.ts +87 -0
- package/agent/entity-resolver/confidence.ts +54 -0
- package/agent/entity-resolver/entity-index.ts +241 -0
- package/agent/entity-resolver/explore-strategy.ts +82 -0
- package/agent/entity-resolver/index.ts +22 -0
- package/agent/entity-resolver/resolver.ts +193 -0
- package/agent/entity-resolver/scorer.ts +211 -0
- package/agent/entity-resolver/types.ts +98 -0
- package/agent/generic-executor.ts +713 -0
- package/agent/handlers/cognitive-handler.ts +197 -0
- package/agent/handlers/index.ts +1 -0
- package/agent/handoff.ts +58 -0
- package/agent/llm-factory.ts +343 -0
- package/agent/orchestrator.ts +45 -0
- package/agent/prompt-builder.ts +78 -0
- package/agent/registry.ts +64 -0
- package/agent/tools/file-system.ts +471 -0
- package/agent/tools/index.ts +23 -0
- package/agent/tools/logger.ts +105 -0
- package/agent/tools/tool-resolver.ts +104 -0
- package/benchmark/cortexflow-workflow.ts +182 -0
- package/benchmark/langgraph-workflow.ts +201 -0
- package/benchmark/llm-client.ts +76 -0
- package/benchmark/run-benchmark.ts +222 -0
- package/cli-dev.ts +419 -0
- package/dist/agent/agent-workflow.d.ts +41 -0
- package/dist/agent/agent-workflow.d.ts.map +1 -0
- package/dist/agent/agent-workflow.js +560 -0
- package/dist/agent/agent-workflow.js.map +1 -0
- package/dist/agent/agent.d.ts +38 -0
- package/dist/agent/agent.d.ts.map +1 -0
- package/dist/agent/agent.js +149 -0
- package/dist/agent/agent.js.map +1 -0
- package/dist/agent/base/executor.d.ts +51 -0
- package/dist/agent/base/executor.d.ts.map +1 -0
- package/dist/agent/base/executor.js +69 -0
- package/dist/agent/base/executor.js.map +1 -0
- package/dist/agent/base/index.d.ts +30 -0
- package/dist/agent/base/index.d.ts.map +1 -0
- package/dist/agent/base/index.js +88 -0
- package/dist/agent/base/index.js.map +1 -0
- package/dist/agent/entity-resolver/confidence.d.ts +4 -0
- package/dist/agent/entity-resolver/confidence.d.ts.map +1 -0
- package/dist/agent/entity-resolver/confidence.js +47 -0
- package/dist/agent/entity-resolver/confidence.js.map +1 -0
- package/dist/agent/entity-resolver/entity-index.d.ts +40 -0
- package/dist/agent/entity-resolver/entity-index.d.ts.map +1 -0
- package/dist/agent/entity-resolver/entity-index.js +244 -0
- package/dist/agent/entity-resolver/entity-index.js.map +1 -0
- package/dist/agent/entity-resolver/explore-strategy.d.ts +13 -0
- package/dist/agent/entity-resolver/explore-strategy.d.ts.map +1 -0
- package/dist/agent/entity-resolver/explore-strategy.js +109 -0
- package/dist/agent/entity-resolver/explore-strategy.js.map +1 -0
- package/dist/agent/entity-resolver/index.d.ts +8 -0
- package/dist/agent/entity-resolver/index.d.ts.map +1 -0
- package/dist/agent/entity-resolver/index.js +16 -0
- package/dist/agent/entity-resolver/index.js.map +1 -0
- package/dist/agent/entity-resolver/resolver.d.ts +18 -0
- package/dist/agent/entity-resolver/resolver.d.ts.map +1 -0
- package/dist/agent/entity-resolver/resolver.js +158 -0
- package/dist/agent/entity-resolver/resolver.js.map +1 -0
- package/dist/agent/entity-resolver/scorer.d.ts +3 -0
- package/dist/agent/entity-resolver/scorer.d.ts.map +1 -0
- package/dist/agent/entity-resolver/scorer.js +182 -0
- package/dist/agent/entity-resolver/scorer.js.map +1 -0
- package/dist/agent/entity-resolver/types.d.ts +89 -0
- package/dist/agent/entity-resolver/types.d.ts.map +1 -0
- package/dist/agent/entity-resolver/types.js +3 -0
- package/dist/agent/entity-resolver/types.js.map +1 -0
- package/dist/agent/generic-executor.d.ts +68 -0
- package/dist/agent/generic-executor.d.ts.map +1 -0
- package/dist/agent/generic-executor.js +620 -0
- package/dist/agent/generic-executor.js.map +1 -0
- package/dist/agent/handlers/cognitive-handler.d.ts +44 -0
- package/dist/agent/handlers/cognitive-handler.d.ts.map +1 -0
- package/dist/agent/handlers/cognitive-handler.js +172 -0
- package/dist/agent/handlers/cognitive-handler.js.map +1 -0
- package/dist/agent/handlers/index.d.ts +2 -0
- package/dist/agent/handlers/index.d.ts.map +1 -0
- package/dist/agent/handlers/index.js +7 -0
- package/dist/agent/handlers/index.js.map +1 -0
- package/dist/agent/handoff.d.ts +12 -0
- package/dist/agent/handoff.d.ts.map +1 -0
- package/dist/agent/handoff.js +62 -0
- package/dist/agent/handoff.js.map +1 -0
- package/dist/agent/llm-factory.d.ts +19 -0
- package/dist/agent/llm-factory.d.ts.map +1 -0
- package/dist/agent/llm-factory.js +297 -0
- package/dist/agent/llm-factory.js.map +1 -0
- package/dist/agent/orchestrator.d.ts +18 -0
- package/dist/agent/orchestrator.d.ts.map +1 -0
- package/dist/agent/orchestrator.js +44 -0
- package/dist/agent/orchestrator.js.map +1 -0
- package/dist/agent/prompt-builder.d.ts +35 -0
- package/dist/agent/prompt-builder.d.ts.map +1 -0
- package/dist/agent/prompt-builder.js +76 -0
- package/dist/agent/prompt-builder.js.map +1 -0
- package/dist/agent/registry.d.ts +19 -0
- package/dist/agent/registry.d.ts.map +1 -0
- package/dist/agent/registry.js +48 -0
- package/dist/agent/registry.js.map +1 -0
- package/dist/agent/tools/file-system.d.ts +11 -0
- package/dist/agent/tools/file-system.d.ts.map +1 -0
- package/dist/agent/tools/file-system.js +528 -0
- package/dist/agent/tools/file-system.js.map +1 -0
- package/dist/agent/tools/index.d.ts +4 -0
- package/dist/agent/tools/index.d.ts.map +1 -0
- package/dist/agent/tools/index.js +20 -0
- package/dist/agent/tools/index.js.map +1 -0
- package/dist/agent/tools/logger.d.ts +33 -0
- package/dist/agent/tools/logger.d.ts.map +1 -0
- package/dist/agent/tools/logger.js +86 -0
- package/dist/agent/tools/logger.js.map +1 -0
- package/dist/agent/tools/tool-resolver.d.ts +7 -0
- package/dist/agent/tools/tool-resolver.d.ts.map +1 -0
- package/dist/agent/tools/tool-resolver.js +122 -0
- package/dist/agent/tools/tool-resolver.js.map +1 -0
- package/dist/execution/adapters/in-memory-checkpoint.d.ts +11 -0
- package/dist/execution/adapters/in-memory-checkpoint.d.ts.map +1 -0
- package/dist/execution/adapters/in-memory-checkpoint.js +54 -0
- package/dist/execution/adapters/in-memory-checkpoint.js.map +1 -0
- package/dist/execution/compiler.d.ts +8 -0
- package/dist/execution/compiler.d.ts.map +1 -0
- package/dist/execution/compiler.js +50 -0
- package/dist/execution/compiler.js.map +1 -0
- package/dist/execution/controller.d.ts +30 -0
- package/dist/execution/controller.d.ts.map +1 -0
- package/dist/execution/controller.js +80 -0
- package/dist/execution/controller.js.map +1 -0
- package/dist/execution/event-manager.d.ts +29 -0
- package/dist/execution/event-manager.d.ts.map +1 -0
- package/dist/execution/event-manager.js +264 -0
- package/dist/execution/event-manager.js.map +1 -0
- package/dist/execution/index.d.ts +221 -0
- package/dist/execution/index.d.ts.map +1 -0
- package/dist/execution/index.js +638 -0
- package/dist/execution/index.js.map +1 -0
- package/dist/execution/logger.d.ts +46 -0
- package/dist/execution/logger.d.ts.map +1 -0
- package/dist/execution/logger.js +69 -0
- package/dist/execution/logger.js.map +1 -0
- package/dist/execution/node.d.ts +65 -0
- package/dist/execution/node.d.ts.map +1 -0
- package/dist/execution/node.js +250 -0
- package/dist/execution/node.js.map +1 -0
- package/dist/execution/observer.d.ts +38 -0
- package/dist/execution/observer.d.ts.map +1 -0
- package/dist/execution/observer.js +111 -0
- package/dist/execution/observer.js.map +1 -0
- package/dist/execution/planner.d.ts +14 -0
- package/dist/execution/planner.d.ts.map +1 -0
- package/dist/execution/planner.js +43 -0
- package/dist/execution/planner.js.map +1 -0
- package/dist/execution/reducer.d.ts +19 -0
- package/dist/execution/reducer.d.ts.map +1 -0
- package/dist/execution/reducer.js +61 -0
- package/dist/execution/reducer.js.map +1 -0
- package/dist/execution/registry.d.ts +38 -0
- package/dist/execution/registry.d.ts.map +1 -0
- package/dist/execution/registry.js +63 -0
- package/dist/execution/registry.js.map +1 -0
- package/dist/execution/send-api.d.ts +24 -0
- package/dist/execution/send-api.d.ts.map +1 -0
- package/dist/execution/send-api.js +52 -0
- package/dist/execution/send-api.js.map +1 -0
- package/dist/execution/types.parallel.d.ts +61 -0
- package/dist/execution/types.parallel.d.ts.map +1 -0
- package/dist/execution/types.parallel.js +3 -0
- package/dist/execution/types.parallel.js.map +1 -0
- package/dist/execution/visualizer.d.ts +35 -0
- package/dist/execution/visualizer.d.ts.map +1 -0
- package/dist/execution/visualizer.js +131 -0
- package/dist/execution/visualizer.js.map +1 -0
- package/dist/index.d.ts +47 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +78 -0
- package/dist/index.js.map +1 -0
- package/dist/interfaces/index.d.ts +487 -0
- package/dist/interfaces/index.d.ts.map +1 -0
- package/dist/interfaces/index.js +75 -0
- package/dist/interfaces/index.js.map +1 -0
- package/dist/modules/agenda/adapters/node-cron/index.d.ts +17 -0
- package/dist/modules/agenda/adapters/node-cron/index.d.ts.map +1 -0
- package/dist/modules/agenda/adapters/node-cron/index.js +30 -0
- package/dist/modules/agenda/adapters/node-cron/index.js.map +1 -0
- package/dist/modules/agenda/index.d.ts +63 -0
- package/dist/modules/agenda/index.d.ts.map +1 -0
- package/dist/modules/agenda/index.js +141 -0
- package/dist/modules/agenda/index.js.map +1 -0
- package/dist/modules/cli/index.d.ts +13 -0
- package/dist/modules/cli/index.d.ts.map +1 -0
- package/dist/modules/cli/index.js +672 -0
- package/dist/modules/cli/index.js.map +1 -0
- package/dist/modules/embedding/adapters/ai/index.d.ts +29 -0
- package/dist/modules/embedding/adapters/ai/index.d.ts.map +1 -0
- package/dist/modules/embedding/adapters/ai/index.js +58 -0
- package/dist/modules/embedding/adapters/ai/index.js.map +1 -0
- package/dist/modules/embedding/index.d.ts +36 -0
- package/dist/modules/embedding/index.d.ts.map +1 -0
- package/dist/modules/embedding/index.js +60 -0
- package/dist/modules/embedding/index.js.map +1 -0
- package/dist/modules/nlp/engine.d.ts +126 -0
- package/dist/modules/nlp/engine.d.ts.map +1 -0
- package/dist/modules/nlp/engine.js +299 -0
- package/dist/modules/nlp/engine.js.map +1 -0
- package/dist/modules/nlp/index.d.ts +27 -0
- package/dist/modules/nlp/index.d.ts.map +1 -0
- package/dist/modules/nlp/index.js +56 -0
- package/dist/modules/nlp/index.js.map +1 -0
- package/dist/persistence/index.d.ts +12 -0
- package/dist/persistence/index.d.ts.map +1 -0
- package/dist/persistence/index.js +24 -0
- package/dist/persistence/index.js.map +1 -0
- package/dist/persistence/neo4j/driver.d.ts +26 -0
- package/dist/persistence/neo4j/driver.d.ts.map +1 -0
- package/dist/persistence/neo4j/driver.js +64 -0
- package/dist/persistence/neo4j/driver.js.map +1 -0
- package/dist/persistence/neo4j/entity-store.d.ts +15 -0
- package/dist/persistence/neo4j/entity-store.d.ts.map +1 -0
- package/dist/persistence/neo4j/entity-store.js +136 -0
- package/dist/persistence/neo4j/entity-store.js.map +1 -0
- package/dist/persistence/neo4j/execution-tracer.d.ts +19 -0
- package/dist/persistence/neo4j/execution-tracer.d.ts.map +1 -0
- package/dist/persistence/neo4j/execution-tracer.js +166 -0
- package/dist/persistence/neo4j/execution-tracer.js.map +1 -0
- package/dist/persistence/neo4j/memory-adapter.d.ts +35 -0
- package/dist/persistence/neo4j/memory-adapter.d.ts.map +1 -0
- package/dist/persistence/neo4j/memory-adapter.js +252 -0
- package/dist/persistence/neo4j/memory-adapter.js.map +1 -0
- package/dist/persistence/neo4j/petri-checkpoint-adapter.d.ts +22 -0
- package/dist/persistence/neo4j/petri-checkpoint-adapter.d.ts.map +1 -0
- package/dist/persistence/neo4j/petri-checkpoint-adapter.js +141 -0
- package/dist/persistence/neo4j/petri-checkpoint-adapter.js.map +1 -0
- package/dist/pipeline/agent-pipeline.d.ts +99 -0
- package/dist/pipeline/agent-pipeline.d.ts.map +1 -0
- package/dist/pipeline/agent-pipeline.js +356 -0
- package/dist/pipeline/agent-pipeline.js.map +1 -0
- package/dist/routing/checkpoint-adapter.d.ts +30 -0
- package/dist/routing/checkpoint-adapter.d.ts.map +1 -0
- package/dist/routing/checkpoint-adapter.js +83 -0
- package/dist/routing/checkpoint-adapter.js.map +1 -0
- package/dist/routing/documentation-generator.d.ts +47 -0
- package/dist/routing/documentation-generator.d.ts.map +1 -0
- package/dist/routing/documentation-generator.js +320 -0
- package/dist/routing/documentation-generator.js.map +1 -0
- package/dist/routing/index.d.ts +38 -0
- package/dist/routing/index.d.ts.map +1 -0
- package/dist/routing/index.js +375 -0
- package/dist/routing/index.js.map +1 -0
- package/dist/routing/intent-classifier.d.ts +206 -0
- package/dist/routing/intent-classifier.d.ts.map +1 -0
- package/dist/routing/intent-classifier.js +267 -0
- package/dist/routing/intent-classifier.js.map +1 -0
- package/dist/routing/matrix.d.ts +6 -0
- package/dist/routing/matrix.d.ts.map +1 -0
- package/dist/routing/matrix.js +131 -0
- package/dist/routing/matrix.js.map +1 -0
- package/dist/routing/orchestrator.d.ts +87 -0
- package/dist/routing/orchestrator.d.ts.map +1 -0
- package/dist/routing/orchestrator.js +425 -0
- package/dist/routing/orchestrator.js.map +1 -0
- package/dist/routing/postgres-checkpoint-adapter.d.ts +32 -0
- package/dist/routing/postgres-checkpoint-adapter.d.ts.map +1 -0
- package/dist/routing/postgres-checkpoint-adapter.js +167 -0
- package/dist/routing/postgres-checkpoint-adapter.js.map +1 -0
- package/dist/routing/redis-checkpoint-adapter.d.ts +34 -0
- package/dist/routing/redis-checkpoint-adapter.d.ts.map +1 -0
- package/dist/routing/redis-checkpoint-adapter.js +170 -0
- package/dist/routing/redis-checkpoint-adapter.js.map +1 -0
- package/dist/routing/types.d.ts +49 -0
- package/dist/routing/types.d.ts.map +1 -0
- package/dist/routing/types.js +3 -0
- package/dist/routing/types.js.map +1 -0
- package/dist/types/agent.d.ts +289 -0
- package/dist/types/agent.d.ts.map +1 -0
- package/dist/types/agent.js +78 -0
- package/dist/types/agent.js.map +1 -0
- package/dist/types/index.d.ts +343 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +3 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/generate-action-schema.d.ts +4 -0
- package/dist/utils/generate-action-schema.d.ts.map +1 -0
- package/dist/utils/generate-action-schema.js +46 -0
- package/dist/utils/generate-action-schema.js.map +1 -0
- package/dist/utils/header-builder.d.ts +12 -0
- package/dist/utils/header-builder.d.ts.map +1 -0
- package/dist/utils/header-builder.js +35 -0
- package/dist/utils/header-builder.js.map +1 -0
- package/dist/utils/logger.d.ts +27 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +45 -0
- package/dist/utils/logger.js.map +1 -0
- package/docs/.gitbook/assets/image (1).png +0 -0
- package/docs/.gitbook/assets/image (2).png +0 -0
- package/docs/.gitbook/assets/image (3).png +0 -0
- package/docs/.gitbook/assets/image (4).png +0 -0
- package/docs/.gitbook/assets/image (5).png +0 -0
- package/docs/.gitbook/assets/image (6).png +0 -0
- package/docs/.gitbook/assets/image.png +0 -0
- package/docs/README.md +57 -0
- package/docs/SUMMARY.md +34 -0
- package/docs/cas-dusages.md +69 -0
- package/docs/cli/README.md +65 -0
- package/docs/concepts-cles.md +50 -0
- package/docs/core/architecture.md +87 -0
- package/docs/core/benchmark.md +59 -0
- package/docs/core/checkpoint.md +72 -0
- package/docs/core/documentation.md +55 -0
- package/docs/core/graphcontroller.md +63 -0
- package/docs/core/graphflow.md +137 -0
- package/docs/core/introduction.md +41 -0
- package/docs/core/les-evenements.md +95 -0
- package/docs/modules/agenda/README.md +63 -0
- package/docs/modules/agenda/interface-iagenda.md +170 -0
- package/docs/modules/agenda/les-adaptateurs/README.md +237 -0
- package/docs/modules/agenda/les-adaptateurs/nodecronadapter.md +91 -0
- package/docs/modules/introduction.md +55 -0
- package/docs/modules/les-adaptateurs.md +52 -0
- package/docs/modules/memoire/README.md +68 -0
- package/docs/modules/memoire/interface-imemory.md +183 -0
- package/docs/modules/memoire/les-adaptateurs/README.md +209 -0
- package/docs/modules/memoire/les-adaptateurs/inmemoryadapter.md +110 -0
- package/docs/modules/memoire/les-adaptateurs/meilisearchadapter.md +147 -0
- package/docs/modules/memoire/les-adaptateurs/redisadapter.md +212 -0
- package/docs/modules/nlp/README.md +44 -0
- package/docs/philosophie.md +51 -0
- package/docs/tutoriels/ajouter-des-conditions.md +150 -0
- package/docs/tutoriels/branching.md +194 -0
- package/docs/tutoriels/checkpoint-usage.md +99 -0
- package/docs/tutoriels/creer-agent-onchain.md +1041 -0
- package/docs/tutoriels/creer-un-agent.md +108 -0
- package/docs/tutoriels/creer-un-graphe-simple.md +92 -0
- package/docs/tutoriels/gerer-les-erreurs.md +124 -0
- package/docs/tutoriels/pour-commencer.md +73 -0
- package/docs/tutoriels/retry.md +166 -0
- package/execution/adapters/in-memory-checkpoint.ts +35 -0
- package/execution/compiler.ts +47 -0
- package/execution/controller.ts +84 -0
- package/execution/event-manager.ts +331 -0
- package/execution/index.ts +800 -0
- package/execution/logger.ts +70 -0
- package/execution/node.ts +315 -0
- package/execution/observer.ts +192 -0
- package/execution/planner.ts +40 -0
- package/execution/reducer.ts +73 -0
- package/execution/registry.ts +86 -0
- package/execution/send-api.ts +58 -0
- package/execution/types.parallel.ts +81 -0
- package/execution/visualizer.ts +158 -0
- package/index.ts +55 -465
- package/interfaces/index.ts +597 -0
- package/modules/agenda/adapters/node-cron/index.ts +25 -0
- package/modules/agenda/index.ts +146 -0
- package/modules/cli/index.ts +580 -0
- package/modules/embedding/adapters/ai/index.ts +42 -0
- package/modules/embedding/index.ts +45 -0
- package/modules/nlp/engine.ts +324 -0
- package/modules/nlp/index.ts +45 -0
- package/package.json +81 -9
- package/persistence/index.ts +27 -0
- package/persistence/neo4j/driver.ts +34 -0
- package/persistence/neo4j/entity-store.ts +141 -0
- package/persistence/neo4j/execution-tracer.ts +194 -0
- package/persistence/neo4j/memory-adapter.ts +281 -0
- package/persistence/neo4j/petri-checkpoint-adapter.ts +153 -0
- package/pipeline/agent-pipeline.ts +426 -0
- package/routing/checkpoint-adapter.ts +79 -0
- package/routing/documentation-generator.ts +358 -0
- package/routing/index.ts +459 -0
- package/routing/intent-classifier.ts +360 -0
- package/routing/matrix.ts +138 -0
- package/routing/orchestrator.ts +498 -0
- package/routing/patterns/data-extraction.json +79 -0
- package/routing/patterns/human-approval.json +64 -0
- package/routing/patterns/rag-search.json +68 -0
- package/routing/postgres-checkpoint-adapter.ts +172 -0
- package/routing/redis-checkpoint-adapter.ts +187 -0
- package/routing/types.ts +59 -0
- package/routing/web-server.ts +260 -0
- package/scripts/generate-petri-docs.ts +70 -0
- package/scripts/get-gmail-token.js +65 -0
- package/scripts/get-gmail-token.ts +65 -0
- package/test/agent/agent.test.ts +92 -0
- package/test/agent/clone.test.ts +143 -0
- package/test/agent/cognitive-handler.test.ts +78 -0
- package/test/agent/entity-store.test.ts +80 -0
- package/test/agent/generic-executor.test.ts +230 -0
- package/test/agent/handoff.test.ts +163 -0
- package/test/agent/llm-factory.test.ts +40 -0
- package/test/agent/orchestrator.test.ts +156 -0
- package/test/agent/registry.test.ts +97 -0
- package/test/agent/tools.test.ts +267 -0
- package/test/execution/checkpoint.test.ts +811 -0
- package/test/execution/controller.test.ts +236 -0
- package/test/execution/event-manager.test.ts +118 -0
- package/test/execution/index.test.ts +690 -0
- package/test/execution/node.test.ts +464 -0
- package/test/execution/observer.test.ts +393 -0
- package/test/execution/parallel.test.ts +135 -0
- package/test/execution/plan-llm-integration.test.ts +290 -0
- package/test/execution/plan-real-onchain.test.ts +226 -0
- package/test/execution/send-api.test.ts +121 -0
- package/test/modules/agenda/node-cron.test.ts +307 -0
- package/test/modules/cli/index.test.ts +125 -0
- package/test/persistence/neo4j-execution-tracer.test.ts +96 -0
- package/test/persistence/neo4j-memory-adapter.test.ts +107 -0
- package/test/persistence/neo4j-petri-checkpoint.test.ts +89 -0
- package/test/pipeline/agent-pipeline.test.ts +118 -0
- package/test/routing/checkpoint-persistence.test.ts +58 -0
- package/test/routing/documentation-generator.test.ts +76 -0
- package/test/routing/integration.test.ts +261 -0
- package/test/routing/intent-classifier.test.ts +102 -0
- package/test/routing/petri.test.ts +156 -0
- package/test/routing/real-llm.test.ts +260 -0
- package/test-petri-features.ts +218 -0
- package/test-pipeline-api.ts +163 -0
- package/tsconfig.json +30 -108
- package/types/agent.ts +296 -0
- package/types/index.ts +387 -0
- package/utils/generate-action-schema.ts +47 -0
- package/utils/header-builder.ts +40 -0
- package/utils/logger.ts +40 -0
- package/package copy.json +0 -21
- package/types.ts +0 -62
- package/utils/executor.ts +0 -42
package/docs/README.md
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# Documentation: @ai.ntellect/core
|
|
2
|
+
|
|
3
|
+
Welcome to the official documentation for **@ai.ntellect/core**, the framework for building production-grade LLM agents that don't drift.
|
|
4
|
+
|
|
5
|
+
## The Core Thesis
|
|
6
|
+
**LLMs are exceptional at generating text, but they are unreliable at controlling systems.**
|
|
7
|
+
|
|
8
|
+
Most AI frameworks treat the LLM as the "brain" that makes every routing decision. As your agent grows in complexity, this leads to:
|
|
9
|
+
- **Routing Hallucinations**: The LLM forgets the rules and calls tools in the wrong order.
|
|
10
|
+
- **Context Bloat**: The prompt grows too large as it tries to explain every possible path.
|
|
11
|
+
- **Unpredictability**: The same input can lead to different execution paths.
|
|
12
|
+
|
|
13
|
+
**@ai.ntellect/core solves this by splitting the brain:**
|
|
14
|
+
1. **The LLM is the Classifier**: It identifies *intent* once.
|
|
15
|
+
2. **The System is the Controller**: A verified Petri Net handles the *routing* deterministically.
|
|
16
|
+
3. **GraphFlow is the Executor**: Typed graphs handle the *execution* without further LLM interference.
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## 🧭 Navigation Guide
|
|
21
|
+
|
|
22
|
+
### 🚀 Getting Started
|
|
23
|
+
- [Quick Start Guide](./tutoriels/pour-commencer.md) — From `npm install` to your first workflow in 5 minutes.
|
|
24
|
+
- [The Philosophy](./philosophie.md) — Understand why deterministic control is the only way to scale AI agents.
|
|
25
|
+
- [Key Concepts](./concepts-cles.md) — GraphFlow, CortexFlow, and State Management.
|
|
26
|
+
|
|
27
|
+
### 🛠️ The Engine
|
|
28
|
+
- [GraphFlow Deep Dive](./core/graphflow.md) — Nodes, Parallelism, and the Send API.
|
|
29
|
+
- [Event-Driven Architectures](./core/les-evenements.md) — Building reactive systems that wait for the world.
|
|
30
|
+
- [Resilience & Checkpoints](./core/checkpoint.md) — Time-travel debugging and human-in-the-loop.
|
|
31
|
+
- [Technical Architecture](./core/architecture.md) — The blueprint of the engine.
|
|
32
|
+
|
|
33
|
+
### 🧠 AI Orchestration (CortexFlow)
|
|
34
|
+
- [Deterministic Routing](./core/graphflow.md) — How intent classification works.
|
|
35
|
+
- [Formal Verification](./core/architecture.md) — Deadlock detection and reachability analysis.
|
|
36
|
+
- [Hybrid Fallback](./core/architecture.md) — Balancing determinism with conversational flexibility.
|
|
37
|
+
|
|
38
|
+
### 🧩 Modules & Tooling
|
|
39
|
+
- [Memory Systems](./modules/memoire/) — Pluggable persistence (Redis, Meilisearch).
|
|
40
|
+
- [Agenda & Scheduling](./modules/agenda/) — Cron-based automation.
|
|
41
|
+
- [Interactive CLI](./cli/) — Debugging and running agents from your terminal.
|
|
42
|
+
|
|
43
|
+
### 📈 Real-World Application
|
|
44
|
+
- [Design Patterns](./cas-dusages.md) — How to model Approval Flows, RAG, and ETL pipelines.
|
|
45
|
+
- [Benchmarks](./core/benchmark.md) — CortexFlow vs LangGraph: Performance and Reliability.
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## 🛠️ Quick Reference
|
|
50
|
+
|
|
51
|
+
| If you want to... | Go to... |
|
|
52
|
+
| :--- | :--- |
|
|
53
|
+
| Build a simple sequence of tasks | [GraphFlow](./core/graphflow.md) |
|
|
54
|
+
| Create an agent that handles intents | [CortexFlow](./core/graphflow.md) |
|
|
55
|
+
| Make a workflow pause for a human | [Checkpoints](./core/checkpoint.md) |
|
|
56
|
+
| Trigger a workflow via Webhook | [Events](./core/les-evenements.md) |
|
|
57
|
+
| Run an agent in your terminal | [CLI](./cli/) |
|
package/docs/SUMMARY.md
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Table of Contents
|
|
2
|
+
|
|
3
|
+
* [Welcome](./README.md)
|
|
4
|
+
|
|
5
|
+
## 🚀 Getting Started
|
|
6
|
+
* [Quick Start Guide](./tutoriels/pour-commencer.md)
|
|
7
|
+
* [The Philosophy](./philosophie.md)
|
|
8
|
+
* [Key Concepts](./concepts-cles.md)
|
|
9
|
+
|
|
10
|
+
## 🛠️ The Engine (Core)
|
|
11
|
+
* [GraphFlow Deep Dive](./core/graphflow.md)
|
|
12
|
+
* [Event-Driven Architectures](./core/les-evenements.md)
|
|
13
|
+
* [Resilience & Checkpoints](./core/checkpoint.md)
|
|
14
|
+
* [Multi-Graph Orchestration](./core/graphcontroller.md)
|
|
15
|
+
* [Technical Architecture](./core/architecture.md)
|
|
16
|
+
* [Visualizing Your Agents](./core/documentation.md)
|
|
17
|
+
* [Performance Benchmarks](./core/benchmark.md)
|
|
18
|
+
|
|
19
|
+
## 🧩 Modules & Tooling
|
|
20
|
+
* [Modular Extensions](./modules/introduction.md)
|
|
21
|
+
* [Memory Systems](./modules/memoire/)
|
|
22
|
+
* [Agenda & Scheduling](./modules/agenda/)
|
|
23
|
+
* [Interactive CLI](./cli/README.md)
|
|
24
|
+
|
|
25
|
+
## 📖 Tutorials
|
|
26
|
+
* [Building Your First Workflow](./tutoriels/creer-un-graphe-simple.md)
|
|
27
|
+
* [Building Tool-Using Agents](./tutoriels/creer-un-agent.md)
|
|
28
|
+
* [Implementing Human-in-the-Loop](./tutoriels/checkpoint-usage.md)
|
|
29
|
+
* [Advanced Branching](./tutoriels/branching.md)
|
|
30
|
+
* [Handling Errors & Retries](./tutoriels/retry.md)
|
|
31
|
+
|
|
32
|
+
## 🔗 Links
|
|
33
|
+
* [NPM Package](https://www.npmjs.com/package/@ai.ntellect/core)
|
|
34
|
+
* [GitHub Repository](https://github.com/ai-ntellect/core)
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# Use Cases & Design Patterns
|
|
2
|
+
|
|
3
|
+
`@ai.ntellect/core` is designed for scenarios where **failure is not an option**. While simple chatbots can use raw LLM loops, production systems require structured, predictable execution.
|
|
4
|
+
|
|
5
|
+
Here are the primary patterns you can build with this framework.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 1. Task-Based Assistants (The "Router" Pattern)
|
|
10
|
+
Perfect for applications that provide a suite of specific services.
|
|
11
|
+
|
|
12
|
+
**The Pattern**: `Natural Language` $\rightarrow$ `Intent Classification` $\rightarrow$ `Deterministic Workflow`.
|
|
13
|
+
|
|
14
|
+
- **Example**: A Banking Assistant.
|
|
15
|
+
- "What's my balance?" $\rightarrow$ `GET_BALANCE` intent $\rightarrow$ `fetchBalance` GraphFlow.
|
|
16
|
+
- "Pay my electricity bill" $\rightarrow$ `PAY_BILL` intent $\rightarrow$ `validateAccount` $\rightarrow$ `executePayment` $\rightarrow$ `notifyUser` GraphFlow.
|
|
17
|
+
- **Why this wins**: The LLM cannot "hallucinate" a new payment method or skip the validation step. The path is hardcoded in the Petri Net.
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## 2. Human-in-the-Loop (The "Approval" Pattern)
|
|
22
|
+
Essential for high-stakes actions that require a human "sanity check."
|
|
23
|
+
|
|
24
|
+
**The Pattern**: `Workflow Execution` $\rightarrow$ `Checkpoint` $\rightarrow$ `Awaiting Approval` $\rightarrow$ `Resume`.
|
|
25
|
+
|
|
26
|
+
- **Example**: Enterprise Expense Approval.
|
|
27
|
+
- Employee submits a \$5,000 expense.
|
|
28
|
+
- GraphFlow processes the request and hits a **Breakpoint**.
|
|
29
|
+
- Execution pauses; state is saved to Redis.
|
|
30
|
+
- Manager receives a notification and calls `/approve`.
|
|
31
|
+
- GraphFlow resumes from the exact same state and completes the payment.
|
|
32
|
+
- **Why this wins**: You don't have to write complex "polling" logic. The system natively supports pausing and resuming long-running processes.
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## 3. Event-Driven Orchestration (The "Reactive" Pattern)
|
|
37
|
+
For systems that must react to the real world (Webhooks, IoT, Blockchain).
|
|
38
|
+
|
|
39
|
+
**The Pattern**: `Event Trigger` $\rightarrow$ `Context Correlation` $\rightarrow$ `Workflow Trigger`.
|
|
40
|
+
|
|
41
|
+
- **Example**: Crypto Whale Alert & Trade.
|
|
42
|
+
- **Event**: A large transfer is detected on-chain.
|
|
43
|
+
- **Action**: Trigger a GraphFlow that analyzes the wallet history, calculates the impact, and executes a hedge trade.
|
|
44
|
+
- **Why this wins**: By using **Event-Driven Nodes**, your workflows can "sleep" for days and wake up the instant a specific external condition is met.
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## 4. Financial & Critical Workflows (The "Zero-Failure" Pattern)
|
|
49
|
+
For systems where a single error can result in financial loss or compliance breach.
|
|
50
|
+
|
|
51
|
+
**The Pattern**: `Formal Verification` $\rightarrow$ `Zod Validation` $\rightarrow$ `Atomic Execution`.
|
|
52
|
+
|
|
53
|
+
- **Example**: Automated Compliance Reporting.
|
|
54
|
+
- Collect data from 5 different APIs.
|
|
55
|
+
- Validate each piece of data against a strict Zod schema.
|
|
56
|
+
- Use a **Fork-Join** model to process reports in parallel.
|
|
57
|
+
- Merge results using a custom **Reducer** to ensure no data is lost.
|
|
58
|
+
- **Why this wins**: The use of Petri Nets allows you to prove that the workflow will never enter an invalid state (Deadlock Detection), and Zod ensures that no corrupted data ever reaches your core logic.
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## 🚀 Summary: When to use what?
|
|
63
|
+
|
|
64
|
+
| If you need... | Use this pattern | Key Primitive |
|
|
65
|
+
| :--- | :--- | :--- |
|
|
66
|
+
| Predictable routing | **Task-Based** | `CortexFlow` (Intent $\rightarrow$ Net) |
|
|
67
|
+
| Safety / Oversight | **Approval** | `Checkpoints` + `Breakpoints` |
|
|
68
|
+
| External triggers | **Reactive** | `Event-Driven Nodes` |
|
|
69
|
+
| Mathematical certainty | **Zero-Failure** | `Petri Net Verification` + `Zod` |
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# Interactive CLI: Debugging & Control
|
|
2
|
+
|
|
3
|
+
The `@ai.ntellect/core` CLI is not just a runner—it is a **control center** for your agents. It allows you to interact with agents in real-time, inspect their internal state, and manually steer execution using checkpoints.
|
|
4
|
+
|
|
5
|
+
## 🚀 Getting Started
|
|
6
|
+
|
|
7
|
+
Launch the REPL by specifying your LLM provider and model:
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
pnpm cli -p groq -m llama-3.1-8b-instant # High-speed Groq
|
|
11
|
+
pnpm cli -p openai -m gpt-4o-mini # Versatile OpenAI
|
|
12
|
+
pnpm cli -p ollama -m llama3 # Local Privacy (Ollama)
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
### Configuration
|
|
16
|
+
The CLI automatically loads your `.env` file for API keys (`GROQ_API_KEY`, `OPENAI_API_KEY`, etc.), so you don't have to pass them manually.
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## ⌨️ Control Commands (Slash Commands)
|
|
21
|
+
|
|
22
|
+
While in the interactive session, use these commands to manage the agent's lifecycle:
|
|
23
|
+
|
|
24
|
+
### 🔍 State Inspection
|
|
25
|
+
- `/status` — View the current execution state and active node.
|
|
26
|
+
- `/history` — Print the full conversation and tool execution history.
|
|
27
|
+
- `/list` — List all available checkpoints for the current session.
|
|
28
|
+
|
|
29
|
+
### 🕹️ Execution Control
|
|
30
|
+
- `/resume [cpId]` — **Time Travel**: Jump back to a specific checkpoint and continue from there.
|
|
31
|
+
- `/approve` — Signal a "Yes" to a pending human-in-the-loop breakpoint.
|
|
32
|
+
- `/reject` — Signal a "No" to a pending human-in-the-loop breakpoint.
|
|
33
|
+
- `/modify k=v` — **State Injection**: Change a variable in the context *before* resuming execution.
|
|
34
|
+
|
|
35
|
+
### 🧹 Session Management
|
|
36
|
+
- `/clear` — Reset the current conversation context.
|
|
37
|
+
- `/help` — Show all available commands.
|
|
38
|
+
- `/exit` — Gracefully terminate the session.
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## 🛑 Human-in-the-Loop (HITL)
|
|
43
|
+
|
|
44
|
+
The CLI is designed for **safe AI deployment**. By default, the agent is configured with a breakpoint before the `think` node (the LLM call).
|
|
45
|
+
|
|
46
|
+
**The Workflow:**
|
|
47
|
+
1. The agent identifies a need to call a tool.
|
|
48
|
+
2. The CLI **pauses** execution.
|
|
49
|
+
3. You review the proposed action.
|
|
50
|
+
4. You type `/approve` to let it proceed or `/modify` to correct the parameters.
|
|
51
|
+
|
|
52
|
+
This ensures that no destructive action (like a financial transfer or a file deletion) happens without explicit human consent.
|
|
53
|
+
|
|
54
|
+
## 📖 Example Session
|
|
55
|
+
|
|
56
|
+
```text
|
|
57
|
+
> /role Financial Assistant
|
|
58
|
+
> Transfer $50 to Alice
|
|
59
|
+
[BREAKPOINT] Agent wants to execute: transfer_funds { amount: 50, to: "Alice" }
|
|
60
|
+
> /approve
|
|
61
|
+
[Executing...]
|
|
62
|
+
Transaction successful. Reference: TX_9921.
|
|
63
|
+
> /status
|
|
64
|
+
Current Node: notify_user | Status: COMPLETED
|
|
65
|
+
```
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Key Concepts
|
|
2
|
+
|
|
3
|
+
To understand `@ai.ntellect/core`, you need to shift your mental model from "autonomous agents" to "deterministic orchestration."
|
|
4
|
+
|
|
5
|
+
## 🧠 The Classifier-Controller Split
|
|
6
|
+
|
|
7
|
+
The core innovation of this framework is the separation of **Intent Classification** from **Execution Logic**.
|
|
8
|
+
|
|
9
|
+
### 1. The Classifier (LLM)
|
|
10
|
+
The LLM is used as a high-dimensional pattern matcher. Its only job is to map a user's natural language input to a pre-defined **Intent**.
|
|
11
|
+
- **Input**: "I need to check my balance and transfer $50 to Alice."
|
|
12
|
+
- **Output**: `{ intent: "TRANSFER_FUNDS", confidence: 0.98 }`
|
|
13
|
+
|
|
14
|
+
By restricting the LLM to classification, we eliminate the "routing hallucinations" that occur when the LLM tries to decide the next step in a complex workflow.
|
|
15
|
+
|
|
16
|
+
### 2. The Controller (Petri Net)
|
|
17
|
+
Once the intent is classified, the **CortexFlow Orchestrator** takes over. It uses a verified Petri Net to determine the exact sequence of steps.
|
|
18
|
+
- **Deterministic**: The same intent always triggers the same path.
|
|
19
|
+
- **Verifiable**: We can mathematically prove the workflow will never deadlock.
|
|
20
|
+
- **Observably**: Every transition is a discrete event that can be logged and audited.
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## 🏗️ The Execution Engine: GraphFlow
|
|
25
|
+
|
|
26
|
+
While the Controller decides *which* workflow to run, **GraphFlow** is the engine that actually *runs* it.
|
|
27
|
+
|
|
28
|
+
### Workflow as a Typed Graph
|
|
29
|
+
A `GraphFlow` is a directed graph where each node is a discrete unit of logic. Unlike simple scripts, GraphFlows are:
|
|
30
|
+
- **Strongly Typed**: Every transition is validated via Zod.
|
|
31
|
+
- **Stateful**: They maintain a shared context that evolves as the graph is traversed.
|
|
32
|
+
- **Resilient**: Built-in retry logic and checkpointing allow workflows to survive crashes or wait for human approval.
|
|
33
|
+
|
|
34
|
+
### Orchestration vs. Automation
|
|
35
|
+
- **Automation**: A linear sequence of "If X then Y." It's brittle and fails when the world changes.
|
|
36
|
+
- **Orchestration**: The coordination of multiple asynchronous processes, handling parallel branches, and reacting to external events.
|
|
37
|
+
|
|
38
|
+
`@ai.ntellect/core` provides **orchestration**, allowing you to build systems that are as flexible as a human operator but as reliable as a compiler.
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## 🔄 The Lifecycle of a Request
|
|
43
|
+
|
|
44
|
+
1. **Input**: User sends a message.
|
|
45
|
+
2. **Classify**: LLM identifies the **Intent**.
|
|
46
|
+
3. **Route**: The **Petri Net** finds the matching transition.
|
|
47
|
+
4. **Execute**: The **GraphFlow** associated with that transition runs its nodes.
|
|
48
|
+
5. **Respond**: The final state is returned to the user.
|
|
49
|
+
|
|
50
|
+
**Total LLM calls for routing: 1.**
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# System Architecture
|
|
2
|
+
|
|
3
|
+
`@ai.ntellect/core` is designed as a layered system that separates **Intent**, **Routing**, and **Execution**. This architecture ensures that as your AI agent becomes more complex, it remains maintainable and verifiable.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 📐 The Three-Layer Model
|
|
8
|
+
|
|
9
|
+
### Layer 1: The Intent Layer (Probabilistic)
|
|
10
|
+
This is the only place where "uncertainty" is allowed. We use an LLM to classify user input.
|
|
11
|
+
- **Component**: `IntentClassifier`
|
|
12
|
+
- **Responsibility**: Map `String` $\rightarrow$ `IntentID`.
|
|
13
|
+
- **Guardrail**: Confidence thresholds. If the LLM is unsure, the system triggers a clarification request rather than guessing.
|
|
14
|
+
|
|
15
|
+
### Layer 2: The Routing Layer (Deterministic)
|
|
16
|
+
Once the intent is known, the system enters the **CortexFlow** layer. Routing is handled by a **Petri Net**.
|
|
17
|
+
- **Component**: `CortexFlowOrchestrator`
|
|
18
|
+
- **Responsibility**: Map `IntentID` $\rightarrow$ `WorkflowPath`.
|
|
19
|
+
- **Guardrail**: Formal Verification. Because Petri Nets are mathematical objects, we use incidence matrices to detect deadlocks and bounded states at build-time.
|
|
20
|
+
|
|
21
|
+
### Layer 3: The Execution Layer (Typed)
|
|
22
|
+
The final layer is the **GraphFlow** engine, which executes the specific steps of the chosen path.
|
|
23
|
+
- **Component**: `GraphFlow` / `GraphNode`
|
|
24
|
+
- **Responsibility**: Execute business logic and update state.
|
|
25
|
+
- **Guardrail**: Zod Validation. Every state transition is validated against a schema to ensure data integrity.
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## 🔄 Data Flow & State Management
|
|
30
|
+
|
|
31
|
+
### The Shared Context
|
|
32
|
+
Every workflow instance has a **Context**. This is a single source of truth that is passed from node to node.
|
|
33
|
+
- **Immutable-ish**: Nodes modify the context, but these modifications are tracked.
|
|
34
|
+
- **Validated**: The context is validated against the `GraphFlow` schema at every node transition.
|
|
35
|
+
|
|
36
|
+
### Checkpointing & Persistence
|
|
37
|
+
To support long-running workflows (e.g., waiting for an event for 3 days), the architecture uses **Checkpoint Adapters**.
|
|
38
|
+
- After every node execution, the current context and the "marking" (current position in the Petri Net) are snapshotted.
|
|
39
|
+
- This allows the system to be completely stateless; a workflow can be resumed on a different server just by loading its `checkpointId` from Redis or PostgreSQL.
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## 🧩 Modularity & Adapters
|
|
44
|
+
|
|
45
|
+
The framework follows the **Dependency Inversion Principle**. Core logic does not depend on specific technologies.
|
|
46
|
+
|
|
47
|
+
### Pluggable Modules
|
|
48
|
+
We provide interfaces for common agent needs:
|
|
49
|
+
- `IMemoryAdapter`: For long-term memory (InMemory $\rightarrow$ Redis $\rightarrow$ Meilisearch).
|
|
50
|
+
- `ICheckpointAdapter`: For state persistence (InMemory $\rightarrow$ Postgres).
|
|
51
|
+
- `IEventEmitter`: For event handling (Node.js EventEmitter $\rightarrow$ RabbitMQ $\rightarrow$ Kafka).
|
|
52
|
+
|
|
53
|
+
### The GraphController
|
|
54
|
+
For complex systems, a single graph isn't enough. The `GraphController` allows you to treat `GraphFlows` as building blocks, orchestrating them in parallel or sequence to build "Super-Graphs."
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## 📁 Source Code Structure (Bounded Contexts)
|
|
61
|
+
|
|
62
|
+
The framework source is organized into **Bounded Contexts** that mirror the three-layer model:
|
|
63
|
+
|
|
64
|
+
```
|
|
65
|
+
execution/ → Layer 3: GraphFlow engine (typed nodes, events, planner, compiler)
|
|
66
|
+
routing/ → Layer 2: PetriNet, CortexFlowOrchestrator, IntentClassifier
|
|
67
|
+
agent/ → Cognitive loop: Agent, GenericExecutor, handlers, tools
|
|
68
|
+
persistence/ → Barrel: Memory + checkpoint adapters
|
|
69
|
+
pipeline/ → AgentPipeline (trigger → stages → gate)
|
|
70
|
+
modules/ → Plugins: agenda, cli, embedding, memory, nlp
|
|
71
|
+
interfaces/ → Contract interfaces
|
|
72
|
+
types/ → Zod schemas
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
This structure ensures that each concern (routing, execution, agent loop) lives in its own directory with clear boundaries and no circular dependencies.
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## 🚀 Summary of the Architectural Edge
|
|
80
|
+
|
|
81
|
+
| Feature | Traditional AI Frameworks | @ai.ntellect/core |
|
|
82
|
+
| :--- | :--- | :--- |
|
|
83
|
+
| **Control Flow** | LLM-driven (Probabilistic) | Petri Net-driven (Deterministic) |
|
|
84
|
+
| **State** | Loose / Prompt-based | Strongly Typed (Zod) |
|
|
85
|
+
| **Verification** | Trial and Error | Mathematical Proof (Deadlock detection) |
|
|
86
|
+
| **Persistence** | Session-based | Checkpoint-based (Time-travel) |
|
|
87
|
+
| **Latency** | Multiple LLM calls for routing | Single LLM call for classification |
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# Benchmark: CortexFlow vs. LangGraph
|
|
2
|
+
|
|
3
|
+
To validate our thesis that **deterministic routing is superior to probabilistic routing**, we conducted a rigorous benchmark comparing `CortexFlow` against a standard `LangGraph` implementation.
|
|
4
|
+
|
|
5
|
+
## 🧪 The Test Scenario
|
|
6
|
+
|
|
7
|
+
**The Task**: An AI Agent must process an inbox of 5 emails. It must:
|
|
8
|
+
1. Fetch emails $\rightarrow$ 2. Classify urgency $\rightarrow$ 3. Draft responses for urgent ones $\rightarrow$ 4. Archive non-urgent ones.
|
|
9
|
+
|
|
10
|
+
This is a classic "routing" task where an agent must decide between different paths based on input.
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## 📊 The Results
|
|
15
|
+
|
|
16
|
+
### Test 1: Local Execution (Ollama — llama3:latest)
|
|
17
|
+
*Observation: Local LLM calls have high latency (~2s per call), making the number of calls the primary bottleneck.*
|
|
18
|
+
|
|
19
|
+
| Metric | CortexFlow | LangGraph (Naive) | LangGraph (Optimized) |
|
|
20
|
+
| :--- | :--- | :--- | :--- |
|
|
21
|
+
| **LLM Calls** | **1** | 7 | 2 |
|
|
22
|
+
| **Total Time** | **13.4s** | 3.7s | 4.2s |
|
|
23
|
+
| **Reliability** | 100% (Deterministic) | ~85% (Occasional Drift) | ~95% (Manual Batching) |
|
|
24
|
+
|
|
25
|
+
**Analysis**: CortexFlow is slower in local mode because it performs **Formal Verification** (deadlock/boundedness checks) at the start. However, it reduces LLM calls by **86%**.
|
|
26
|
+
|
|
27
|
+
### Test 2: Cloud Execution (Groq API — llama-3.1-8b-instant)
|
|
28
|
+
*Observation: Cloud LLMs have extremely low latency, shifting the bottleneck to the orchestration overhead.*
|
|
29
|
+
|
|
30
|
+
| Metric | CortexFlow | LangGraph (Naive) | LangGraph (Optimized) |
|
|
31
|
+
| :--- | :--- | :--- | :--- |
|
|
32
|
+
| **LLM Calls** | **1** | 7 | 2 |
|
|
33
|
+
| **Total Time** | **1,650 ms** | 2,192 ms | 1,668 ms |
|
|
34
|
+
| **Performance** | **1.33x Faster** | Baseline | 1.31x Faster |
|
|
35
|
+
|
|
36
|
+
**Analysis**: In a production environment (low-latency LLM), **CortexFlow is the fastest**. By eliminating the "routing loops," it removes multiple network round-trips.
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## 📉 The "LLM Call" Tax
|
|
41
|
+
|
|
42
|
+
The biggest find from this benchmark is the **LLM Call Tax**.
|
|
43
|
+
In traditional frameworks, every decision is a call:
|
|
44
|
+
`User` $\rightarrow$ `Call 1 (Route)` $\rightarrow$ `Call 2 (Validate)` $\rightarrow$ `Call 3 (Act)` $\rightarrow$ `Call 4 (Summarize)`.
|
|
45
|
+
|
|
46
|
+
In CortexFlow, we pay the tax **once**:
|
|
47
|
+
`User` $\rightarrow$ `Call 1 (Classify Intent)` $\rightarrow$ `System (Deterministic Route)` $\rightarrow$ `Done`.
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## 🏆 Final Verdict: Why Choose CortexFlow?
|
|
52
|
+
|
|
53
|
+
The benchmark proves that the gain is not just about milliseconds—it's about **Reliability**.
|
|
54
|
+
|
|
55
|
+
1. **Zero Routing Hallucinations**: Because the routing is in a Petri Net, the agent *cannot* decide to go to a node that doesn't exist or skip a mandatory step.
|
|
56
|
+
2. **Constant Complexity**: Whether the conversation is 2 turns or 200 turns, the routing cost remains **1 LLM call**.
|
|
57
|
+
3. **Formal Guarantees**: You get a mathematical proof that your agent will never deadlock, regardless of what the LLM outputs.
|
|
58
|
+
|
|
59
|
+
**LangGraph is a great tool for autonomous exploration. CortexFlow is the tool for production systems.**
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# Resilience & Checkpoints
|
|
2
|
+
|
|
3
|
+
In production, workflows fail. Servers crash, APIs timeout, and humans take days to approve requests. The **Checkpoint System** is what makes `@ai.ntellect/core` production-grade.
|
|
4
|
+
|
|
5
|
+
## 📌 What is a Checkpoint?
|
|
6
|
+
|
|
7
|
+
A checkpoint is a **serialized snapshot** of a workflow's entire state at a specific point in time. It includes:
|
|
8
|
+
1. The current **Context** (the data).
|
|
9
|
+
2. The current **Node/Position** (where we are).
|
|
10
|
+
3. The **Run ID** (which execution this belongs to).
|
|
11
|
+
4. **Metadata** (timestamps, error states, approval status).
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## 🛠️ Core Functionalities
|
|
16
|
+
|
|
17
|
+
### 1. Automatic State Persistence
|
|
18
|
+
By using `executeWithCheckpoint`, the engine automatically saves the state after every single node execution. If the process crashes, you don't lose progress; you simply resume from the last successful node.
|
|
19
|
+
|
|
20
|
+
### 2. Breakpoints (Human-in-the-Loop)
|
|
21
|
+
Breakpoints allow you to intentionally pause a workflow *before* a critical node executes.
|
|
22
|
+
```typescript
|
|
23
|
+
await workflow.executeWithCheckpoint("start", adapter, {
|
|
24
|
+
breakpoints: ["execute_payment"],
|
|
25
|
+
});
|
|
26
|
+
```
|
|
27
|
+
The workflow will stop exactly before `execute_payment`. It stays in a `awaiting_approval` state until an external command calls `resumeFromCheckpoint`.
|
|
28
|
+
|
|
29
|
+
### 3. Time-Travel Debugging
|
|
30
|
+
This is the most powerful tool for developers. You can resume a workflow from *any* previous checkpoint in its history, and you can even **modify the state** before resuming.
|
|
31
|
+
|
|
32
|
+
```typescript
|
|
33
|
+
// "What would have happened if the user had entered 'USD' instead of 'EUR'?"
|
|
34
|
+
await workflow.resumeFromCheckpoint(cpId, adapter, {
|
|
35
|
+
contextModifications: { currency: "USD" },
|
|
36
|
+
});
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## 🔌 Adapters
|
|
42
|
+
|
|
43
|
+
You can choose where your checkpoints are stored based on your needs:
|
|
44
|
+
|
|
45
|
+
| Adapter | Best For | Persistence |
|
|
46
|
+
| :--- | :--- | :--- |
|
|
47
|
+
| `InMemoryCheckpointAdapter` | Local dev, unit tests | Volatile (Lost on restart) |
|
|
48
|
+
| `RedisPetriCheckpointAdapter` | High-performance production | Persistent / Distributed |
|
|
49
|
+
| `PostgresPetriCheckpointAdapter` | Audit-heavy, relational data | Persistent / ACID |
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## 🧠 Petri Net Checkpoints
|
|
54
|
+
|
|
55
|
+
For **CortexFlow** workflows, checkpoints are even more critical. We save the **Petri Net Marking** (the distribution of tokens across places).
|
|
56
|
+
|
|
57
|
+
This means you can:
|
|
58
|
+
- Pause a complex orchestration.
|
|
59
|
+
- Restore the exact state of the Petri Net.
|
|
60
|
+
- See exactly which transitions were enabled at the moment of the pause.
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## ⚠️ Error Handling & Recovery
|
|
65
|
+
|
|
66
|
+
When a node fails, the system creates an **Error Checkpoint**.
|
|
67
|
+
Instead of the whole system crashing, the workflow enters a `failed` state. A developer or an automated process can then:
|
|
68
|
+
1. Analyze the error in the checkpoint metadata.
|
|
69
|
+
2. Fix the underlying issue (or modify the context).
|
|
70
|
+
3. Resume the workflow from the failed node.
|
|
71
|
+
|
|
72
|
+
**This eliminates the need to restart long-running workflows from scratch.**
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# Living Documentation: Visualizing Your Agents
|
|
2
|
+
|
|
3
|
+
One of the biggest challenges in AI orchestration is the "Black Box" problem: you don't know why an agent took a certain path. `@ai.ntellect/core` solves this by treating **documentation as code**.
|
|
4
|
+
|
|
5
|
+
CortexFlow can automatically generate visual and textual documentation directly from your Petri Net definitions.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 🛠️ Generation Tools
|
|
10
|
+
|
|
11
|
+
### 1. CLI Generation
|
|
12
|
+
You can generate documentation for any JSON-defined Petri Net using the provided script:
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npx ts-node scripts/generate-petri-docs.ts <petri-net.json> [output-dir]
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
**What you get:**
|
|
19
|
+
- **Markdown (`.md`)**: A human-readable explanation of all places, transitions, and the intended flow.
|
|
20
|
+
- **Mermaid Diagram (`.mmd`)**: A visual graph that can be rendered in GitHub, Notion, or Obsidian.
|
|
21
|
+
- **Interactive HTML (`.html`)**: A standalone page with an embedded render of the workflow.
|
|
22
|
+
|
|
23
|
+
### 2. Programmatic Generation
|
|
24
|
+
You can integrate documentation generation into your CI/CD pipeline or your own admin dashboard:
|
|
25
|
+
|
|
26
|
+
```typescript
|
|
27
|
+
import { PetriDocumentationGenerator } from "@ai.ntellect/core/routing/documentation-generator";
|
|
28
|
+
|
|
29
|
+
const generator = new PetriDocumentationGenerator();
|
|
30
|
+
await generator.generateForPetri(net, {
|
|
31
|
+
outputDir: "./docs/petri",
|
|
32
|
+
format: "all",
|
|
33
|
+
});
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## 🔍 Session-Based Documentation (The "Audit Trail")
|
|
39
|
+
|
|
40
|
+
Unlike static documentation, **Session Documentation** captures the *actual* execution of a specific request.
|
|
41
|
+
|
|
42
|
+
When you generate documentation for a session:
|
|
43
|
+
1. **State Highlighting**: The resulting diagram highlights exactly where the tokens were located at the time of the snapshot.
|
|
44
|
+
2. **Transition History**: The Markdown report lists every transition that was fired, in order, with its associated `traceId`.
|
|
45
|
+
3. **Enabled Analysis**: The report shows which transitions were "enabled" (ready to fire) but were not chosen.
|
|
46
|
+
|
|
47
|
+
**This turns your documentation into a forensic tool for debugging production agents.**
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## 📈 Why "Living" Docs?
|
|
52
|
+
|
|
53
|
+
- **Zero Drift**: Since the docs are generated from the `PetriNet` object, they can never be out of sync with the code.
|
|
54
|
+
- **Accessibility**: Non-technical stakeholders (Product Managers, Compliance Officers) can review the Mermaid diagrams to verify the business logic.
|
|
55
|
+
- **Fast Onboarding**: New developers can visualize the entire agent's decision tree without reading thousands of lines of code.
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# GraphController: Multi-Graph Orchestration
|
|
2
|
+
|
|
3
|
+
While a `GraphFlow` is powerful for a single workflow, real-world applications often require the coordination of multiple independent workflows. The `GraphController` is the orchestrator that manages these relationships.
|
|
4
|
+
|
|
5
|
+
## 🎯 Purpose
|
|
6
|
+
|
|
7
|
+
The `GraphController` allows you to treat individual `GraphFlows` as modular components. Instead of building one giant, monolithic graph, you can build small, testable graphs and compose them into complex pipelines.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## 🚀 Execution Modes
|
|
12
|
+
|
|
13
|
+
### 1. Sequential Execution
|
|
14
|
+
Use `executeSequential` when Workflow B depends on the successful completion of Workflow A.
|
|
15
|
+
|
|
16
|
+
```typescript
|
|
17
|
+
const controller = new GraphController();
|
|
18
|
+
|
|
19
|
+
await controller.executeSequential([
|
|
20
|
+
{ graph: userValidationGraph, startNode: "start" },
|
|
21
|
+
{ graph: paymentProcessingGraph, startNode: "init" },
|
|
22
|
+
{ graph: notificationGraph, startNode: "send" },
|
|
23
|
+
]);
|
|
24
|
+
```
|
|
25
|
+
If any graph in the sequence fails, the chain stops, and the error is propagated, preventing inconsistent states.
|
|
26
|
+
|
|
27
|
+
### 2. Parallel Execution
|
|
28
|
+
Use `executeParallel` to trigger multiple independent workflows simultaneously, reducing overall latency.
|
|
29
|
+
|
|
30
|
+
```typescript
|
|
31
|
+
const results = await controller.executeParallel([
|
|
32
|
+
{ graph: fetchStockGraph, startNode: "start" },
|
|
33
|
+
{ graph: fetchPriceGraph, startNode: "start" },
|
|
34
|
+
{ graph: checkComplianceGraph, startNode: "start" },
|
|
35
|
+
]);
|
|
36
|
+
```
|
|
37
|
+
The `GraphController` manages the `Promise.all` logic internally and returns an array of results once all graphs have completed.
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## 🛠️ Advanced Patterns
|
|
42
|
+
|
|
43
|
+
### The "Super-Graph" Pattern
|
|
44
|
+
You can use a `GraphController` inside a `GraphNode` of another `GraphFlow`. This allows you to create hierarchical workflows:
|
|
45
|
+
- **Parent Graph**: Handles high-level business logic.
|
|
46
|
+
- **Child Graphs (via Controller)**: Handle specific technical implementations.
|
|
47
|
+
|
|
48
|
+
### Cross-Graph Event Communication
|
|
49
|
+
Graphs managed by a controller can communicate via the event system.
|
|
50
|
+
1. `Graph A` emits an event `data.ready`.
|
|
51
|
+
2. `Graph B` has a node waiting for `data.ready`.
|
|
52
|
+
3. `Graph B` wakes up and processes the data produced by `Graph A`.
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## ⚖️ When to use GraphController vs. Parallel Nodes?
|
|
57
|
+
|
|
58
|
+
| Feature | Parallel Nodes (within GraphFlow) | GraphController (across GraphFlows) |
|
|
59
|
+
| :--- | :--- | :--- |
|
|
60
|
+
| **Scope** | Intra-graph (Internal) | Inter-graph (External) |
|
|
61
|
+
| **State** | Shares the same `Context` | Each graph has its own `Context` |
|
|
62
|
+
| **Coupling** | Tightly coupled | Loosely coupled (Modular) |
|
|
63
|
+
| **Use Case** | Splitting a single task into sub-tasks | Orchestrating different business modules |
|