@ai.ntellect/core 0.8.3 → 1.1.0
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 +2 -1
- package/AGENTS.md +50 -0
- package/ARCHITECTURE.md +58 -0
- package/BENCHMARK.md +38 -0
- package/CHANGELOG.md +224 -0
- package/README.md +413 -199
- package/agent/agent-workflow.ts +569 -0
- package/agent/agent.ts +183 -0
- package/{modules/agent → agent}/base/executor.ts +11 -8
- package/{modules/agent → agent}/base/index.ts +2 -14
- 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/{modules/agent → agent}/prompt-builder.ts +1 -1
- 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/{modules/agent → agent}/base/executor.d.ts +3 -3
- package/dist/agent/base/executor.d.ts.map +1 -0
- package/dist/{modules/agent → agent}/base/executor.js +8 -5
- package/dist/agent/base/executor.js.map +1 -0
- package/dist/{modules/agent → agent}/base/index.d.ts +1 -1
- package/dist/agent/base/index.d.ts.map +1 -0
- package/dist/{modules/agent → agent}/base/index.js +0 -12
- 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/{modules/agent → agent}/generic-executor.d.ts +37 -27
- 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.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/{modules/agent → agent}/prompt-builder.d.ts +1 -1
- package/dist/agent/prompt-builder.d.ts.map +1 -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.map +1 -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/{graph → execution}/event-manager.js +4 -114
- package/dist/execution/event-manager.js.map +1 -0
- package/dist/{graph → execution}/index.d.ts +50 -2
- 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.map +1 -0
- package/dist/execution/logger.js.map +1 -0
- package/dist/{graph → execution}/node.d.ts +6 -1
- package/dist/execution/node.d.ts.map +1 -0
- package/dist/{graph → execution}/node.js +83 -10
- package/dist/execution/node.js.map +1 -0
- package/dist/execution/observer.d.ts.map +1 -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.map +1 -0
- package/dist/execution/visualizer.js.map +1 -0
- package/dist/index.d.ts +27 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +42 -8
- package/dist/index.js.map +1 -1
- package/dist/interfaces/index.d.ts +32 -1
- package/dist/interfaces/index.d.ts.map +1 -1
- package/dist/interfaces/index.js.map +1 -1
- 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/nlp/engine.d.ts.map +1 -1
- package/dist/modules/nlp/engine.js +0 -1
- package/dist/modules/nlp/engine.js.map +1 -1
- 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 +144 -88
- package/dist/types/agent.d.ts.map +1 -1
- package/dist/types/agent.js +49 -0
- package/dist/types/agent.js.map +1 -1
- package/dist/types/index.d.ts +46 -4
- package/dist/types/index.d.ts.map +1 -1
- package/dist/utils/generate-action-schema.d.ts +2 -3
- package/dist/utils/generate-action-schema.d.ts.map +1 -1
- package/dist/utils/generate-action-schema.js +3 -1
- package/dist/utils/generate-action-schema.js.map +1 -1
- 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/{graph → execution}/event-manager.ts +4 -117
- package/{graph → execution}/index.ts +376 -8
- package/{graph → execution}/node.ts +116 -12
- 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/index.ts +35 -8
- package/interfaces/index.ts +37 -0
- package/modules/cli/index.ts +580 -0
- package/modules/nlp/engine.ts +0 -1
- package/package.json +50 -16
- 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/{graph → execution}/controller.test.ts +2 -2
- package/test/{graph → execution}/event-manager.test.ts +1 -1
- package/test/{graph → execution}/index.test.ts +24 -15
- package/test/{graph → execution}/node.test.ts +3 -3
- package/test/{graph → execution}/observer.test.ts +2 -2
- 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/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 +5 -2
- package/types/agent.ts +126 -4
- package/types/index.ts +66 -5
- package/utils/generate-action-schema.ts +5 -4
- package/utils/logger.ts +40 -0
- package/dist/graph/controller.d.ts.map +0 -1
- package/dist/graph/controller.js.map +0 -1
- package/dist/graph/event-manager.d.ts +0 -101
- package/dist/graph/event-manager.d.ts.map +0 -1
- package/dist/graph/event-manager.js.map +0 -1
- package/dist/graph/index.d.ts.map +0 -1
- package/dist/graph/index.js +0 -340
- package/dist/graph/index.js.map +0 -1
- package/dist/graph/logger.d.ts.map +0 -1
- package/dist/graph/logger.js.map +0 -1
- package/dist/graph/node.d.ts.map +0 -1
- package/dist/graph/node.js.map +0 -1
- package/dist/graph/observer.d.ts.map +0 -1
- package/dist/graph/observer.js.map +0 -1
- package/dist/graph/visualizer.d.ts.map +0 -1
- package/dist/graph/visualizer.js.map +0 -1
- package/dist/modules/agent/agent.d.ts +0 -35
- package/dist/modules/agent/agent.d.ts.map +0 -1
- package/dist/modules/agent/agent.js +0 -103
- package/dist/modules/agent/agent.js.map +0 -1
- package/dist/modules/agent/base/executor.d.ts.map +0 -1
- package/dist/modules/agent/base/executor.js.map +0 -1
- package/dist/modules/agent/base/index.d.ts.map +0 -1
- package/dist/modules/agent/base/index.js.map +0 -1
- package/dist/modules/agent/generic-assistant.d.ts +0 -20
- package/dist/modules/agent/generic-assistant.d.ts.map +0 -1
- package/dist/modules/agent/generic-assistant.js +0 -89
- package/dist/modules/agent/generic-assistant.js.map +0 -1
- package/dist/modules/agent/generic-executor.d.ts.map +0 -1
- package/dist/modules/agent/generic-executor.js +0 -189
- package/dist/modules/agent/generic-executor.js.map +0 -1
- package/dist/modules/agent/llm-factory.d.ts.map +0 -1
- package/dist/modules/agent/llm-factory.js +0 -56
- package/dist/modules/agent/llm-factory.js.map +0 -1
- package/dist/modules/agent/prompt-builder.d.ts.map +0 -1
- package/dist/modules/agent/prompt-builder.js.map +0 -1
- package/dist/modules/memory/adapters/in-memory/index.d.ts +0 -120
- package/dist/modules/memory/adapters/in-memory/index.d.ts.map +0 -1
- package/dist/modules/memory/adapters/in-memory/index.js +0 -212
- package/dist/modules/memory/adapters/in-memory/index.js.map +0 -1
- package/dist/modules/memory/adapters/meilisearch/index.d.ts +0 -110
- package/dist/modules/memory/adapters/meilisearch/index.d.ts.map +0 -1
- package/dist/modules/memory/adapters/meilisearch/index.js +0 -324
- package/dist/modules/memory/adapters/meilisearch/index.js.map +0 -1
- package/dist/modules/memory/adapters/redis/index.d.ts +0 -82
- package/dist/modules/memory/adapters/redis/index.d.ts.map +0 -1
- package/dist/modules/memory/adapters/redis/index.js +0 -160
- package/dist/modules/memory/adapters/redis/index.js.map +0 -1
- package/dist/modules/memory/index.d.ts +0 -67
- package/dist/modules/memory/index.d.ts.map +0 -1
- package/dist/modules/memory/index.js +0 -104
- package/dist/modules/memory/index.js.map +0 -1
- package/modules/agent/agent.ts +0 -107
- package/modules/agent/generic-assistant.ts +0 -92
- package/modules/agent/generic-executor.ts +0 -252
- package/modules/agent/llm-factory.ts +0 -47
- package/modules/memory/adapters/in-memory/index.ts +0 -208
- package/modules/memory/adapters/meilisearch/index.ts +0 -364
- package/modules/memory/adapters/redis/index.ts +0 -165
- package/modules/memory/index.ts +0 -93
- package/test/modules/memory/adapters/in-memory.test.ts +0 -153
- package/test/modules/memory/adapters/meilisearch.test.ts +0 -287
- package/test/modules/memory/base.test.ts +0 -230
- /package/dist/{modules/agent → agent}/llm-factory.d.ts +0 -0
- /package/dist/{modules/agent → agent}/prompt-builder.js +0 -0
- /package/dist/{graph → execution}/controller.d.ts +0 -0
- /package/dist/{graph → execution}/controller.js +0 -0
- /package/dist/{graph → execution}/logger.d.ts +0 -0
- /package/dist/{graph → execution}/logger.js +0 -0
- /package/dist/{graph → execution}/observer.d.ts +0 -0
- /package/dist/{graph → execution}/observer.js +0 -0
- /package/dist/{graph → execution}/visualizer.d.ts +0 -0
- /package/dist/{graph → execution}/visualizer.js +0 -0
- /package/{graph → execution}/controller.ts +0 -0
- /package/{graph → execution}/logger.ts +0 -0
- /package/{graph → execution}/observer.ts +0 -0
- /package/{graph → execution}/visualizer.ts +0 -0
package/README.md
CHANGED
|
@@ -1,247 +1,461 @@
|
|
|
1
1
|
# @ai.ntellect/core
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**Stop your AI agents from going off-rails in production.**
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
*LLMs generate. You control.*
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
One LLM call $\rightarrow$ deterministic execution $\rightarrow$ no routing hallucinations.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Why
|
|
12
|
+
|
|
13
|
+
LLMs are great at generating text.
|
|
14
|
+
**They are bad at controlling systems.**
|
|
15
|
+
|
|
16
|
+
Most frameworks let the LLM decide everything:
|
|
17
|
+
- which tool to call
|
|
18
|
+
- in what order
|
|
19
|
+
- with what context
|
|
20
|
+
|
|
21
|
+
$\rightarrow$ This breaks as complexity grows.
|
|
22
|
+
|
|
23
|
+
**This framework does the opposite:**
|
|
24
|
+
- LLM decides **intent (once)**
|
|
25
|
+
- Your system handles **execution (deterministically)**
|
|
26
|
+
|
|
27
|
+
No drift. No hidden loops. No surprises.
|
|
28
|
+
|
|
29
|
+
**This is not an agent framework. It's a control layer for LLM systems.**
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
### The Contrast
|
|
34
|
+
|
|
35
|
+
**Most frameworks:**
|
|
36
|
+
`User` $\rightarrow$ `LLM` $\rightarrow$ `LLM` $\rightarrow$ `LLM` $\rightarrow$ `Tool` $\rightarrow$ `LLM` (Probabilistic Chaos)
|
|
37
|
+
|
|
38
|
+
**This framework:**
|
|
39
|
+
`User` $\rightarrow$ `LLM` $\rightarrow$ `System` $\rightarrow$ `Done` (Deterministic Control)
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## Why this works
|
|
44
|
+
|
|
45
|
+
We replaced probabilistic guessing with explicit definitions. Routing is **defined**, not **learned**.
|
|
46
|
+
|
|
47
|
+
- **No prompt drift**: Your agent won't change its behavior because of a minor prompt tweak.
|
|
48
|
+
- **No hidden loops**: Execution paths are explicit and finite.
|
|
49
|
+
- **No probabilistic branching**: If the intent is X, the path is ALWAYS Y.
|
|
50
|
+
|
|
51
|
+
Just state + transitions.
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## Quick Reference
|
|
56
|
+
|
|
57
|
+
```
|
|
58
|
+
User → LLM (intent) → Petri Net (routing) → GraphFlow (execution)
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
One decision. Then control.
|
|
62
|
+
|
|
63
|
+
---
|
|
14
64
|
|
|
15
65
|
## Installation
|
|
16
66
|
|
|
17
67
|
```sh
|
|
18
|
-
|
|
68
|
+
pnpm add @ai.ntellect/core zod
|
|
19
69
|
```
|
|
20
70
|
|
|
21
|
-
|
|
71
|
+
**Requirements**: TypeScript 5.x+, Node.js 18+.
|
|
22
72
|
|
|
23
|
-
|
|
73
|
+
---
|
|
24
74
|
|
|
25
|
-
|
|
26
|
-
import { z } from "zod";
|
|
27
|
-
import { GraphFlow } from "@ai.ntellect/core";
|
|
28
|
-
import { GraphContext, GraphNodeConfig } from "@ai.ntellect/core/types";
|
|
75
|
+
## Table of Contents
|
|
29
76
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
77
|
+
- [Core Thesis](#core-thesis)
|
|
78
|
+
- [Source Structure](#source-structure)
|
|
79
|
+
- [GraphFlow — Typed Execution](#graphflow--typed-execution)
|
|
80
|
+
- [CortexFlow — Intent Routing](#cortexflow--intent-routing)
|
|
81
|
+
- [Agent — Cognitive Loop](#agent--cognitive-loop)
|
|
82
|
+
- [AgentPipeline — Declarative Pipelines](#agentpipeline--declarative-pipelines)
|
|
83
|
+
- [Persistence — Memory & Checkpoints](#persistence--memory--checkpoints)
|
|
84
|
+
- [Planner & Compiler](#planner--compiler)
|
|
85
|
+
- [CLI (Interactive REPL)](#cli-interactive-repl)
|
|
86
|
+
- [Testing & Build](#testing--build)
|
|
34
87
|
|
|
35
|
-
|
|
36
|
-
const greetNode = {
|
|
37
|
-
name: "greet",
|
|
38
|
-
execute: async (context: GraphContext<typeof Schema>) => {
|
|
39
|
-
context.message = "Hello, World!";
|
|
40
|
-
},
|
|
41
|
-
};
|
|
88
|
+
---
|
|
42
89
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
schema: Schema,
|
|
47
|
-
context: { message: "" },
|
|
48
|
-
nodes: [greetNode],
|
|
49
|
-
});
|
|
90
|
+
## Core Thesis
|
|
91
|
+
|
|
92
|
+
The framework architecture is the **Classifier-Controller Split**:
|
|
50
93
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
.state()
|
|
57
|
-
.subscribe((context) => {
|
|
58
|
-
console.log(context);
|
|
59
|
-
});
|
|
94
|
+
| Layer | Role | Technology | Correctness |
|
|
95
|
+
|-------|------|-----------|-------------|
|
|
96
|
+
| **Intent** | Classify user input | LLM | Probabilistic (confidence threshold) |
|
|
97
|
+
| **Routing** | Choose execution path | Petri Net | Deterministic (verified) |
|
|
98
|
+
| **Execution** | Run business logic | GraphFlow | Typed (Zod validated) |
|
|
60
99
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
100
|
+
This split means the LLM is called exactly **once per turn** for intent classification. All subsequent routing and execution is handled by verified, typed code.
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
## Source Structure
|
|
64
105
|
|
|
65
|
-
main();
|
|
66
106
|
```
|
|
107
|
+
@ai.ntellect/core
|
|
108
|
+
├── execution/ # GraphFlow engine (typed nodes, events, checkpoints, planner, compiler)
|
|
109
|
+
├── routing/ # PetriNet, CortexFlowOrchestrator, IntentClassifier
|
|
110
|
+
├── agent/ # Agent, GenericExecutor, handlers, tools
|
|
111
|
+
├── persistence/ # Barrel: Memory + checkpoint adapters
|
|
112
|
+
├── pipeline/ # AgentPipeline (trigger → stages → gate)
|
|
113
|
+
├── modules/ # Plugins: agenda, cli, embedding, memory, nlp
|
|
114
|
+
├── interfaces/ # Contract interfaces
|
|
115
|
+
├── types/ # Zod schemas
|
|
116
|
+
└── index.ts # Barrel: all public API exports
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### Path Aliases
|
|
67
120
|
|
|
68
|
-
|
|
121
|
+
- `@ai.ntellect/core` — root barrel (all major exports)
|
|
122
|
+
- `@ai.ntellect/core/execution/...` — deep imports for GraphFlow internals
|
|
123
|
+
- `@ai.ntellect/core/routing/...` — deep imports for PetriNet / CortexFlow
|
|
124
|
+
- `@ai.ntellect/core/agent/...` — deep imports for Agent module
|
|
125
|
+
- `@ai.ntellect/core/pipeline/...` — deep imports for AgentPipeline
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
## GraphFlow — Typed Execution
|
|
130
|
+
|
|
131
|
+
A `GraphFlow` is a **typed state machine** where each node is a discrete unit of logic.
|
|
69
132
|
|
|
70
133
|
```typescript
|
|
71
134
|
import { z } from "zod";
|
|
72
135
|
import { GraphFlow } from "@ai.ntellect/core";
|
|
73
|
-
import { GraphContext } from "@ai.ntellect/core/types";
|
|
74
136
|
|
|
75
|
-
|
|
76
|
-
const OrderSchema = z.object({
|
|
77
|
-
orderId: z.string(),
|
|
78
|
-
status: z.string(),
|
|
79
|
-
amount: z.number(),
|
|
80
|
-
});
|
|
137
|
+
const schema = z.object({ count: z.number().default(0) });
|
|
81
138
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
context.status = "processing";
|
|
92
|
-
},
|
|
93
|
-
next: ["validation"],
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
const validationNode: GraphNodeConfig<typeof OrderSchema> = {
|
|
97
|
-
name: "validation",
|
|
98
|
-
when: {
|
|
99
|
-
events: ["payment.validated", "inventory.checked"],
|
|
100
|
-
timeout: 5000,
|
|
101
|
-
strategy: {
|
|
102
|
-
type: "correlate",
|
|
103
|
-
correlation: (events) => {
|
|
104
|
-
return events.every(
|
|
105
|
-
(e) => e.payload.orderId === events[0].payload.orderId
|
|
106
|
-
);
|
|
107
|
-
},
|
|
139
|
+
const workflow = new GraphFlow({
|
|
140
|
+
name: "counter",
|
|
141
|
+
schema,
|
|
142
|
+
context: { count: 0 },
|
|
143
|
+
nodes: [
|
|
144
|
+
{
|
|
145
|
+
name: "increment",
|
|
146
|
+
execute: async (ctx) => { ctx.count++; },
|
|
147
|
+
next: "double",
|
|
108
148
|
},
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
// Create workflow
|
|
116
|
-
const orderWorkflow = new GraphFlow({
|
|
117
|
-
name: "order",
|
|
118
|
-
schema: OrderSchema,
|
|
119
|
-
context: {
|
|
120
|
-
orderId: "",
|
|
121
|
-
status: "pending",
|
|
122
|
-
amount: 0,
|
|
123
|
-
},
|
|
124
|
-
nodes: [paymentNode, validationNode],
|
|
149
|
+
{
|
|
150
|
+
name: "double",
|
|
151
|
+
execute: async (ctx) => { ctx.count *= 2; },
|
|
152
|
+
},
|
|
153
|
+
],
|
|
125
154
|
});
|
|
126
155
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
orderId: "123",
|
|
144
|
-
amount: 100,
|
|
145
|
-
});
|
|
146
|
-
}, 100);
|
|
147
|
-
|
|
148
|
-
// Observe payment received event
|
|
149
|
-
orderWorkflow
|
|
150
|
-
.observe()
|
|
151
|
-
.event("payment.received")
|
|
152
|
-
.subscribe((event) => {
|
|
153
|
-
console.log("Payment received:", event);
|
|
154
|
-
orderWorkflow.emit("inventory.checked", {
|
|
155
|
-
orderId: event.payload.orderId,
|
|
156
|
-
});
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
// Observe inventory checked event
|
|
160
|
-
orderWorkflow
|
|
161
|
-
.observe()
|
|
162
|
-
.event("inventory.checked")
|
|
163
|
-
.subscribe((event) => {
|
|
164
|
-
console.log("Inventory checked:", event);
|
|
165
|
-
orderWorkflow.emit("payment.validated", {
|
|
166
|
-
orderId: event.payload.orderId,
|
|
167
|
-
});
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
// Observe payment validated event
|
|
171
|
-
orderWorkflow
|
|
172
|
-
.observe()
|
|
173
|
-
.event("payment.validated")
|
|
174
|
-
.subscribe((event) => {
|
|
175
|
-
console.log("Payment validated:", event);
|
|
176
|
-
});
|
|
177
|
-
};
|
|
178
|
-
|
|
179
|
-
main();
|
|
180
|
-
```
|
|
181
|
-
|
|
182
|
-
### Creating a workflow with Agent
|
|
156
|
+
await workflow.execute("increment");
|
|
157
|
+
console.log(workflow.context.count); // 2
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### Node Types
|
|
161
|
+
|
|
162
|
+
| Type | Description |
|
|
163
|
+
|------|-------------|
|
|
164
|
+
| **Sequential** | `next: "nodeName"` or `next: (ctx) => condition ? "a" : "b"` |
|
|
165
|
+
| **Parallel** | `parallel: { enabled: true, joinNode: "merge" }` — fork-join model |
|
|
166
|
+
| **Send API** | Dynamic fan-out: create N parallel branches at runtime |
|
|
167
|
+
| **Event-Driven** | `when: "event.name"` — pause and wait for external event |
|
|
168
|
+
|
|
169
|
+
### Checkpoints
|
|
170
|
+
|
|
171
|
+
Save/resume workflow state with time-travel debugging and human-in-the-loop breakpoints:
|
|
183
172
|
|
|
184
173
|
```typescript
|
|
185
|
-
import {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
to: z.string(),
|
|
191
|
-
subject: z.string(),
|
|
192
|
-
content: z.string(),
|
|
193
|
-
status: z.string(),
|
|
174
|
+
import { InMemoryCheckpointAdapter } from "@ai.ntellect/core";
|
|
175
|
+
|
|
176
|
+
const adapter = new InMemoryCheckpointAdapter();
|
|
177
|
+
const cpId = await workflow.executeWithCheckpoint("start", adapter, {
|
|
178
|
+
breakpoints: ["approve_payment"],
|
|
194
179
|
});
|
|
195
180
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
181
|
+
// Later, resume with optional state modification:
|
|
182
|
+
await workflow.resumeFromCheckpoint(cpId, adapter, {
|
|
183
|
+
contextModifications: { status: "approved" },
|
|
184
|
+
});
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
---
|
|
188
|
+
|
|
189
|
+
## CortexFlow — Intent Routing
|
|
190
|
+
|
|
191
|
+
CortexFlow wraps intent classification + Petri Net routing. The LLM identifies intent once; the Petri Net handles all control flow deterministically.
|
|
192
|
+
|
|
193
|
+
### Basic Usage
|
|
194
|
+
|
|
195
|
+
```typescript
|
|
196
|
+
import { CortexFlowOrchestrator, IntentClassifier } from "@ai.ntellect/core/routing/orchestrator";
|
|
197
|
+
import { ToolRegistry } from "@ai.ntellect/core";
|
|
198
|
+
import { GraphFlow } from "@ai.ntellect/core";
|
|
199
|
+
|
|
200
|
+
const llmFn = async (prompt: string) => { /* your LLM call */ };
|
|
201
|
+
const registry = new ToolRegistry();
|
|
202
|
+
const orchestrator = new CortexFlowOrchestrator("mail_assistant", registry);
|
|
203
|
+
|
|
204
|
+
const classifier = new IntentClassifier(llmFn, {
|
|
205
|
+
intents: ["FETCH_MAILS", "SUMMARIZE", "UNKNOWN"],
|
|
206
|
+
confidenceThreshold: 0.7,
|
|
207
|
+
});
|
|
208
|
+
orchestrator.setIntentClassifier(IntentClassifier.toFn(classifier), classifier);
|
|
209
|
+
orchestrator.setLLMCall(llmFn);
|
|
210
|
+
|
|
211
|
+
// Build Petri Net
|
|
212
|
+
const net = orchestrator.petri;
|
|
213
|
+
net.addPlace({ id: "idle", type: "initial", tokens: [{ id: "start", data: {}, createdAt: 0 }] });
|
|
214
|
+
net.addPlace({ id: "done", type: "final", tokens: [] });
|
|
215
|
+
net.addTransition({
|
|
216
|
+
id: "process_mails",
|
|
217
|
+
from: ["idle"],
|
|
218
|
+
to: "done",
|
|
219
|
+
action: { type: "graphflow", name: "mail_fetch" },
|
|
215
220
|
});
|
|
216
221
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
222
|
+
registry.register({ name: "mail_fetch", description: "...", graph: new GraphFlow({...}), startNode: "fetch" });
|
|
223
|
+
|
|
224
|
+
const sessionId = orchestrator.startSession();
|
|
225
|
+
const result = await orchestrator.orchestrate("Summarise my last 5 emails", sessionId);
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
### Key Components
|
|
229
|
+
|
|
230
|
+
| Export | Source | Description |
|
|
231
|
+
|--------|--------|-------------|
|
|
232
|
+
| `PetriNet` | `@ai.ntellect/core` | Core Petri Net engine |
|
|
233
|
+
| `CortexFlowOrchestrator` | `@ai.ntellect/core/routing` | Intent → routing → execution |
|
|
234
|
+
| `IntentClassifier` | `@ai.ntellect/core/routing` | LLM-based intent classification |
|
|
235
|
+
| `HybridIntentClassifier` | `@ai.ntellect/core/routing` | Keyword + LLM fallback |
|
|
236
|
+
|
|
237
|
+
### Advanced Features
|
|
238
|
+
|
|
239
|
+
- **Hybrid Fallback**: Delegate to conversational LLM on low confidence
|
|
240
|
+
- **Multi-Intent**: Execute multiple intents sequentially
|
|
241
|
+
- **Formal Verification**: Deadlock detection via incidence matrices
|
|
242
|
+
- **Persistence**: Redis/PostgreSQL checkpoint adapters
|
|
243
|
+
|
|
244
|
+
---
|
|
245
|
+
|
|
246
|
+
## Agent — Cognitive Loop
|
|
247
|
+
|
|
248
|
+
The `Agent` class wraps a cognitive loop (think → execute → reply) on top of GraphFlow, with LLM-driven tool selection.
|
|
249
|
+
|
|
250
|
+
```typescript
|
|
251
|
+
import { Agent, createCalculatorTool } from "@ai.ntellect/core";
|
|
252
|
+
|
|
253
|
+
const agent = new Agent({
|
|
254
|
+
role: "Math Assistant",
|
|
255
|
+
tools: [createCalculatorTool()],
|
|
221
256
|
llmConfig: {
|
|
222
|
-
provider: "
|
|
223
|
-
model: "
|
|
224
|
-
apiKey: process.env.
|
|
257
|
+
provider: "groq",
|
|
258
|
+
model: "llama-3.1-8b-instant",
|
|
259
|
+
apiKey: process.env.GROQ_API_KEY,
|
|
225
260
|
},
|
|
226
261
|
});
|
|
227
262
|
|
|
228
|
-
const
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
263
|
+
const result = await agent.process("What is 25 + 7?");
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
### Cognitive Loop Components
|
|
267
|
+
|
|
268
|
+
| Component | Location | Description |
|
|
269
|
+
|-----------|----------|-------------|
|
|
270
|
+
| `Agent` | `agent/agent.ts` | Public API: orchestrates the cognitive loop |
|
|
271
|
+
| `GenericExecutor` | `agent/generic-executor.ts` | Decision-making + action execution |
|
|
272
|
+
| `DynamicGoalHandler` | `agent/handlers/` | Context-aware goal computation |
|
|
273
|
+
| `DynamicNextHandler` | `agent/handlers/` | Next-state routing |
|
|
274
|
+
| `LLMFactory` | `agent/llm-factory.ts` | Multi-provider LLM client |
|
|
275
|
+
| `PromptBuilder` | `agent/prompt-builder.ts` | Structured prompt construction |
|
|
276
|
+
| Tools (`file-system`, etc.) | `agent/tools/` | Prebuilt agent tools |
|
|
277
|
+
|
|
278
|
+
### Built-in Agent Tools
|
|
279
|
+
|
|
280
|
+
```typescript
|
|
281
|
+
import {
|
|
282
|
+
createFileReaderTool,
|
|
283
|
+
createFileWriterTool,
|
|
284
|
+
createShellTool,
|
|
285
|
+
createDirectoryListerTool,
|
|
286
|
+
createAllAgentTools,
|
|
287
|
+
createCalculatorTool,
|
|
288
|
+
} from "@ai.ntellect/core";
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
---
|
|
292
|
+
|
|
293
|
+
## AgentPipeline — Declarative Pipelines
|
|
294
|
+
|
|
295
|
+
Declarative pipelines with triggers, typed stages, and human gates.
|
|
296
|
+
|
|
297
|
+
```typescript
|
|
298
|
+
import { AgentPipeline } from "@ai.ntellect/core";
|
|
299
|
+
import { InMemoryPetriCheckpointAdapter } from "@ai.ntellect/core";
|
|
300
|
+
|
|
301
|
+
const pipeline = new AgentPipeline({
|
|
302
|
+
name: "price-monitor",
|
|
303
|
+
stages: [
|
|
304
|
+
{
|
|
305
|
+
id: "fetch",
|
|
306
|
+
run: async (ctx) => ({ data: await fetchData() }),
|
|
307
|
+
retry: { max: 3, delayMs: 1000 },
|
|
308
|
+
},
|
|
309
|
+
{
|
|
310
|
+
id: "process",
|
|
311
|
+
run: async (ctx) => ({ result: processData(ctx.data) }),
|
|
312
|
+
},
|
|
313
|
+
],
|
|
314
|
+
trigger: { type: "cron", expression: "*/5 * * * *" },
|
|
315
|
+
gate: "human",
|
|
316
|
+
checkpointAdapter: new InMemoryPetriCheckpointAdapter(),
|
|
317
|
+
});
|
|
318
|
+
|
|
319
|
+
await pipeline.start();
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
---
|
|
323
|
+
|
|
324
|
+
## Persistence — Memory & Checkpoints
|
|
325
|
+
|
|
326
|
+
The `persistence/` barrel provides a unified interface for storage:
|
|
327
|
+
|
|
328
|
+
```typescript
|
|
329
|
+
import {
|
|
330
|
+
Memory,
|
|
331
|
+
InMemoryCheckpointAdapter,
|
|
332
|
+
InMemoryPetriCheckpointAdapter,
|
|
333
|
+
RedisPetriCheckpointAdapter,
|
|
334
|
+
PostgresPetriCheckpointAdapter,
|
|
335
|
+
} from "@ai.ntellect/core";
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
### Memory
|
|
339
|
+
|
|
340
|
+
```typescript
|
|
341
|
+
import { Memory } from "@ai.ntellect/core";
|
|
342
|
+
import { InMemoryAdapter } from "@ai.ntellect/core/modules/memory";
|
|
343
|
+
|
|
344
|
+
const memory = new Memory(new InMemoryAdapter());
|
|
345
|
+
await memory.init();
|
|
346
|
+
await memory.createMemory({ content: "Hello", roomId: "default" });
|
|
347
|
+
const results = await memory.getMemoryByIndex("Hello", { roomId: "default" });
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
### Checkpoint Adapters
|
|
351
|
+
|
|
352
|
+
| Adapter | Use Case |
|
|
353
|
+
|---------|----------|
|
|
354
|
+
| `InMemoryCheckpointAdapter` | Testing / development |
|
|
355
|
+
| `InMemoryPetriCheckpointAdapter` | PetriNet checkpoint testing |
|
|
356
|
+
| `RedisPetriCheckpointAdapter` | Distributed / production |
|
|
357
|
+
| `PostgresPetriCheckpointAdapter` | SQL-backed persistence |
|
|
358
|
+
| `Neo4jPetriCheckpointAdapter` | Graph-backed persistence |
|
|
359
|
+
|
|
360
|
+
### Graph Observability & Persistence (Neo4j)
|
|
361
|
+
|
|
362
|
+
Because the framework relies on explicit routing (Petri Nets) and state machines (GraphFlow), **Neo4j** is supported as a first-class citizen. It allows you to visually audit execution traces, map long-term memory relations, and persist agent entity resolutions without polluting your business logic.
|
|
363
|
+
|
|
364
|
+
```typescript
|
|
365
|
+
import {
|
|
366
|
+
createDriver,
|
|
367
|
+
Neo4jMemoryAdapter,
|
|
368
|
+
Neo4jExecutionTracer,
|
|
369
|
+
Neo4jEntityStore
|
|
370
|
+
} from "@ai.ntellect/core/persistence";
|
|
371
|
+
|
|
372
|
+
const { driver } = await createDriver({ url: "bolt://localhost:7687", username: "neo4j", password: "password" });
|
|
373
|
+
|
|
374
|
+
// 1. Graph Memory (Semantic & Relational)
|
|
375
|
+
const memoryAdapter = new Neo4jMemoryAdapter(driver);
|
|
376
|
+
await memoryAdapter.addRelation({ fromId: "mem-1", toId: "mem-2", type: "RELATES_TO", roomId: "user-1" });
|
|
377
|
+
|
|
378
|
+
// 2. Visual Execution Tracing (Zero-invasion event listener)
|
|
379
|
+
const tracer = Neo4jExecutionTracer.attach(workflow, driver, "exec-123");
|
|
380
|
+
// Visually query in Neo4j Browser: MATCH path=(e:Execution)-[:HAS_RUN]->(n:NodeRun) RETURN path
|
|
381
|
+
|
|
382
|
+
// 3. Persistent Entity Resolution
|
|
383
|
+
const entityStore = new Neo4jEntityStore(driver);
|
|
384
|
+
await entityStore.recordResolution("ent-1", "find user intent", 0.95);
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
---
|
|
388
|
+
|
|
389
|
+
## Planner & Compiler
|
|
390
|
+
|
|
391
|
+
For advanced workflows, the LLM generates a Zod-validated JSON plan that is compiled into a deterministic GraphFlow at runtime.
|
|
392
|
+
|
|
393
|
+
```typescript
|
|
394
|
+
import { Planner, Compiler } from "@ai.ntellect/core";
|
|
395
|
+
|
|
396
|
+
const planner = new Planner(llmFn);
|
|
397
|
+
const plan = await planner.createPlan("Send 0.5 ETH to Alice after checking balance");
|
|
398
|
+
|
|
399
|
+
const compiler = new Compiler();
|
|
400
|
+
const workflow = compiler.compile(plan);
|
|
401
|
+
|
|
402
|
+
await workflow.execute("start");
|
|
403
|
+
```
|
|
404
|
+
|
|
405
|
+
---
|
|
406
|
+
|
|
407
|
+
## CLI (Interactive REPL)
|
|
234
408
|
|
|
235
|
-
|
|
409
|
+
```sh
|
|
410
|
+
pnpm cli -p groq -m llama-3.1-8b-instant
|
|
411
|
+
pnpm cli -p openai -m gpt-4o-mini
|
|
412
|
+
pnpm cli -p ollama -m llama3
|
|
413
|
+
```
|
|
414
|
+
|
|
415
|
+
**Slash commands**: `/status`, `/history`, `/list`, `/resume [cpId]`, `/approve`, `/reject`, `/modify k=v`, `/clear`, `/help`.
|
|
416
|
+
|
|
417
|
+
The CLI automatically loads API keys from `.env` (`GROQ_API_KEY`, `OPENAI_API_KEY`, `OPENROUTER_API_KEY`, `GOOGLE_API_KEY`).
|
|
418
|
+
|
|
419
|
+
---
|
|
420
|
+
|
|
421
|
+
## GraphController
|
|
422
|
+
|
|
423
|
+
Orchestrate multiple GraphFlows in parallel or sequence:
|
|
424
|
+
|
|
425
|
+
```typescript
|
|
426
|
+
import { GraphController } from "@ai.ntellect/core";
|
|
427
|
+
|
|
428
|
+
const controller = new GraphController();
|
|
429
|
+
controller.add("workflow_a", graphA);
|
|
430
|
+
controller.add("workflow_b", graphB);
|
|
431
|
+
|
|
432
|
+
await controller.parallel("workflow_a", "workflow_b");
|
|
433
|
+
await controller.sequential("workflow_a", "workflow_b");
|
|
236
434
|
```
|
|
237
435
|
|
|
238
|
-
|
|
436
|
+
---
|
|
437
|
+
|
|
438
|
+
## Testing & Build
|
|
239
439
|
|
|
240
|
-
|
|
440
|
+
```sh
|
|
441
|
+
pnpm run build # tsc → dist/
|
|
442
|
+
pnpm test # Mocha via ts-node (5s timeout)
|
|
443
|
+
pnpm run test:all # Full suite (test/**/*.test.ts)
|
|
444
|
+
pnpm test --grep "suite name" # Focused suite
|
|
445
|
+
pnpm run test:watch # Watch mode
|
|
446
|
+
```
|
|
241
447
|
|
|
242
|
-
|
|
448
|
+
**Real LLM tests**: `pnpm test --grep "CortexFlow Real LLM"` (requires Ollama `llama3:latest` on `localhost:11434`).
|
|
449
|
+
|
|
450
|
+
**Examples**:
|
|
451
|
+
|
|
452
|
+
```sh
|
|
453
|
+
pnpm run example:hello
|
|
454
|
+
pnpm run example:agent
|
|
455
|
+
pnpm run example:onchain
|
|
456
|
+
```
|
|
243
457
|
|
|
244
|
-
|
|
458
|
+
---
|
|
245
459
|
|
|
246
460
|
## License
|
|
247
461
|
|