@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
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import { CortexFlowOrchestrator } from './routing/orchestrator';
|
|
2
|
+
import { IntentClassifier, HybridIntentClassifier } from './routing/intent-classifier';
|
|
3
|
+
import { ToolRegistry } from './execution/registry';
|
|
4
|
+
import { GraphFlow } from './execution/index';
|
|
5
|
+
import { PetriNet } from './routing/index';
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
import * as fs from 'fs';
|
|
8
|
+
import * as path from 'path';
|
|
9
|
+
|
|
10
|
+
// Chargement manuel du .env
|
|
11
|
+
const envPath = path.join(__dirname, '.env');
|
|
12
|
+
const envContent = fs.readFileSync(envPath, 'utf-8');
|
|
13
|
+
const envVars: Record<string, string> = {};
|
|
14
|
+
envContent.split('\n').forEach(line => {
|
|
15
|
+
const match = line.match(/^([^=]+)=(.*)$/);
|
|
16
|
+
if (match) envVars[match[1]] = match[2];
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
const GROQ_API_KEY = envVars['GROQ_API_KEY'];
|
|
20
|
+
|
|
21
|
+
async function groqCall(prompt: string): Promise<string> {
|
|
22
|
+
const response = await fetch('https://api.groq.com/openai/v1/chat/completions', {
|
|
23
|
+
method: 'POST',
|
|
24
|
+
headers: {
|
|
25
|
+
'Authorization': `Bearer ${GROQ_API_KEY}`,
|
|
26
|
+
'Content-Type': 'application/json',
|
|
27
|
+
},
|
|
28
|
+
body: JSON.stringify({
|
|
29
|
+
model: 'llama-3.1-8b-instant',
|
|
30
|
+
messages: [{ role: 'user', content: prompt }],
|
|
31
|
+
temperature: 0.1,
|
|
32
|
+
}),
|
|
33
|
+
});
|
|
34
|
+
const data = await response.json();
|
|
35
|
+
return data.choices?.[0]?.message?.content || '';
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Schéma pour les outils de test
|
|
39
|
+
const TestSchema = z.object({
|
|
40
|
+
query: z.string().default(''),
|
|
41
|
+
data: z.string().default(''),
|
|
42
|
+
result: z.string().default(''),
|
|
43
|
+
message: z.string().default(''),
|
|
44
|
+
fetched: z.boolean().default(false),
|
|
45
|
+
processed: z.boolean().default(false),
|
|
46
|
+
notified: z.boolean().default(false),
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
type TestContext = z.infer<typeof TestSchema>;
|
|
50
|
+
|
|
51
|
+
function createTestTools(): ToolRegistry {
|
|
52
|
+
const registry = new ToolRegistry();
|
|
53
|
+
|
|
54
|
+
const fetchGraph = new GraphFlow<typeof TestSchema>({
|
|
55
|
+
name: 'fetch_data_graph',
|
|
56
|
+
schema: TestSchema,
|
|
57
|
+
context: { query: '', data: '', result: '', message: '', fetched: false, processed: false, notified: false },
|
|
58
|
+
nodes: [
|
|
59
|
+
{
|
|
60
|
+
name: 'fetch_data',
|
|
61
|
+
execute: async (ctx) => {
|
|
62
|
+
console.log(' [Tool] fetch_data exécuté');
|
|
63
|
+
ctx.data = `Données récupérées`;
|
|
64
|
+
ctx.fetched = true;
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
],
|
|
68
|
+
entryNode: 'fetch_data',
|
|
69
|
+
});
|
|
70
|
+
registry.register({ name: 'fetch_data', description: 'Récupère des données', graph: fetchGraph, startNode: 'fetch_data' });
|
|
71
|
+
|
|
72
|
+
const processGraph = new GraphFlow<typeof TestSchema>({
|
|
73
|
+
name: 'process_data_graph',
|
|
74
|
+
schema: TestSchema,
|
|
75
|
+
context: { query: '', data: '', result: '', message: '', fetched: false, processed: false, notified: false },
|
|
76
|
+
nodes: [
|
|
77
|
+
{
|
|
78
|
+
name: 'process_data',
|
|
79
|
+
execute: async (ctx) => {
|
|
80
|
+
console.log(' [Tool] process_data exécuté');
|
|
81
|
+
ctx.result = `Données traitées: ${ctx.data}`;
|
|
82
|
+
ctx.processed = true;
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
],
|
|
86
|
+
entryNode: 'process_data',
|
|
87
|
+
});
|
|
88
|
+
registry.register({ name: 'process_data', description: 'Traite des données', graph: processGraph, startNode: 'process_data' });
|
|
89
|
+
|
|
90
|
+
return registry;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function setupPetriNet(orchestrator: CortexFlowOrchestrator) {
|
|
94
|
+
const net = orchestrator.petri;
|
|
95
|
+
|
|
96
|
+
net.addPlace({ id: 'idle', type: 'initial', tokens: [{ id: 'start', data: {}, createdAt: Date.now() }] });
|
|
97
|
+
net.addPlace({ id: 'fetching', type: 'normal', tokens: [] });
|
|
98
|
+
net.addPlace({ id: 'processing', type: 'normal', tokens: [] });
|
|
99
|
+
net.addPlace({ id: 'done', type: 'final', tokens: [] });
|
|
100
|
+
|
|
101
|
+
net.addTransition({
|
|
102
|
+
id: 'do_fetch',
|
|
103
|
+
from: ['idle'],
|
|
104
|
+
to: 'fetching',
|
|
105
|
+
guard: {
|
|
106
|
+
type: 'deterministic',
|
|
107
|
+
condition: "context.intent === 'FETCH_DATA'",
|
|
108
|
+
},
|
|
109
|
+
action: { type: 'graphflow', name: 'fetch_data' } as any,
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
net.addTransition({
|
|
113
|
+
id: 'do_process',
|
|
114
|
+
from: ['idle'],
|
|
115
|
+
to: 'processing',
|
|
116
|
+
guard: {
|
|
117
|
+
type: 'deterministic',
|
|
118
|
+
condition: "context.intent === 'PROCESS_DATA'",
|
|
119
|
+
},
|
|
120
|
+
action: { type: 'graphflow', name: 'process_data' } as any,
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
net.addTransition({ id: 'fetch_to_done', from: ['fetching'], to: 'done' });
|
|
124
|
+
net.addTransition({ id: 'process_to_done', from: ['processing'], to: 'done' });
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
async function testMultiIntents(orchestrator: CortexFlowOrchestrator, sessionId: string) {
|
|
128
|
+
console.log('\n=== TEST 1: Multi-intents ===');
|
|
129
|
+
const message = 'Récupère les données et traite-les';
|
|
130
|
+
console.log(`Message: "${message}"`);
|
|
131
|
+
|
|
132
|
+
const result = await orchestrator.orchestrate(message, sessionId);
|
|
133
|
+
console.log('Intent principal:', result.intent.intent);
|
|
134
|
+
console.log('Confiance:', result.intent.confidence);
|
|
135
|
+
console.log('Multi-intents détectés:', result.intent.intents ? result.intent.intents.map(i => i.intent) : 'aucun');
|
|
136
|
+
console.log('Transition exécutée:', result.transitionResult?.transitionId);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
async function testSingleIntent(orchestrator: CortexFlowOrchestrator, sessionId: string) {
|
|
140
|
+
console.log('\n=== TEST 2: Single intent ===');
|
|
141
|
+
const message = 'Récupère les données';
|
|
142
|
+
console.log(`Message: "${message}"`);
|
|
143
|
+
|
|
144
|
+
const result = await orchestrator.orchestrate(message, sessionId);
|
|
145
|
+
console.log('Intent:', result.intent.intent);
|
|
146
|
+
console.log('Confiance:', result.intent.confidence);
|
|
147
|
+
console.log('Transition exécutée:', result.transitionResult?.transitionId);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
async function testFallbackMode(orchestrator: CortexFlowOrchestrator, sessionId: string) {
|
|
151
|
+
console.log('\n=== TEST 3: Fallback Mode (confiance faible) ===');
|
|
152
|
+
const message = 'fais un truc au hasard s\'il te plaît';
|
|
153
|
+
console.log(`Message: "${message}"`);
|
|
154
|
+
|
|
155
|
+
orchestrator.setFallbackLLM(async (message: string, session: any) => {
|
|
156
|
+
console.log(' [Fallback] Message reçu:', message);
|
|
157
|
+
return {
|
|
158
|
+
response: 'Je suis en mode fallback. Je ne peux pas traiter cette demande.',
|
|
159
|
+
shouldReenterPetri: false,
|
|
160
|
+
};
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
const result = await orchestrator.orchestrate(message, sessionId);
|
|
164
|
+
console.log('Intent:', result.intent.intent, '(attendu: UNKNOWN)');
|
|
165
|
+
console.log('Fallback response:', result.fallbackResponse?.substring(0, 60));
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
async function testJsonPattern() {
|
|
169
|
+
console.log('\n=== TEST 4: Chargement pattern JSON ===');
|
|
170
|
+
const patternPath = path.join(__dirname, 'petri', 'patterns', 'human-approval.json');
|
|
171
|
+
const pattern = JSON.parse(fs.readFileSync(patternPath, 'utf-8'));
|
|
172
|
+
|
|
173
|
+
console.log(`Pattern: ${pattern.name}`);
|
|
174
|
+
console.log(`Description: ${pattern.description}`);
|
|
175
|
+
console.log(`Places: ${pattern.places.length}, Transitions: ${pattern.transitions.length}`);
|
|
176
|
+
console.log('✅ Pattern JSON valide');
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
async function main() {
|
|
180
|
+
console.log('🚀 Tests des nouvelles fonctionnalités Petri\n');
|
|
181
|
+
|
|
182
|
+
if (!GROQ_API_KEY) {
|
|
183
|
+
console.error('❌ GROQ_API_KEY manquant');
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
const registry = createTestTools();
|
|
188
|
+
const orchestrator = new CortexFlowOrchestrator('test', registry);
|
|
189
|
+
orchestrator.setLLMCall(groqCall);
|
|
190
|
+
setupPetriNet(orchestrator);
|
|
191
|
+
|
|
192
|
+
const classifier = new IntentClassifier(groqCall, {
|
|
193
|
+
intents: ['FETCH_DATA', 'PROCESS_DATA', 'UNKNOWN'],
|
|
194
|
+
confidenceThreshold: 0.6,
|
|
195
|
+
});
|
|
196
|
+
orchestrator.setIntentClassifier(IntentClassifier.toFn(classifier), classifier);
|
|
197
|
+
orchestrator.setConfidenceThreshold(0.6);
|
|
198
|
+
|
|
199
|
+
const sessionId = orchestrator.startSession();
|
|
200
|
+
|
|
201
|
+
try {
|
|
202
|
+
await testMultiIntents(orchestrator, sessionId);
|
|
203
|
+
await testSingleIntent(orchestrator, sessionId + '_2');
|
|
204
|
+
await testFallbackMode(orchestrator, sessionId + '_fallback');
|
|
205
|
+
await testJsonPattern();
|
|
206
|
+
|
|
207
|
+
console.log('\n✅ Tests terminés avec succès!');
|
|
208
|
+
console.log('\nFonctionnalités implémentées:');
|
|
209
|
+
console.log('1. ✅ Mode hybride/échappatoire (fallback LLM)');
|
|
210
|
+
console.log('2. ✅ Classifieur multi-intents');
|
|
211
|
+
console.log('3. ✅ Patterns prêts à l\'emploi (JSON)');
|
|
212
|
+
console.log('4. ✅ Adapters de persistance (Redis + Postgres)');
|
|
213
|
+
} catch (error) {
|
|
214
|
+
console.error('\n❌ Erreur:', error);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
main();
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import * as fs from "fs";
|
|
2
|
+
import * as path from "path";
|
|
3
|
+
|
|
4
|
+
const envPath = path.resolve(__dirname, ".env");
|
|
5
|
+
if (fs.existsSync(envPath)) {
|
|
6
|
+
for (const line of fs.readFileSync(envPath, "utf-8").split("\n")) {
|
|
7
|
+
const t = line.trim();
|
|
8
|
+
if (!t || t.startsWith("#")) continue;
|
|
9
|
+
const eq = t.indexOf("=");
|
|
10
|
+
if (eq === -1) continue;
|
|
11
|
+
const k = t.slice(0, eq).trim();
|
|
12
|
+
const v = t.slice(eq + 1).trim();
|
|
13
|
+
if (k && !process.env[k]) process.env[k] = v;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
import { AgentPipeline, priceZone } from "./pipeline/agent-pipeline";
|
|
18
|
+
|
|
19
|
+
// ============================================
|
|
20
|
+
// USE CASE 1: Simple 2-stage pipeline (no human gate)
|
|
21
|
+
// ============================================
|
|
22
|
+
async function testSimplePipeline() {
|
|
23
|
+
console.log("\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
|
|
24
|
+
console.log(" USE CASE 1: Simple 2-stage pipeline (auto)");
|
|
25
|
+
console.log("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n");
|
|
26
|
+
|
|
27
|
+
const pipeline = new AgentPipeline({
|
|
28
|
+
name: "simple-analysis",
|
|
29
|
+
trigger: priceZone("BTC", 78000, 79000),
|
|
30
|
+
stages: [
|
|
31
|
+
{
|
|
32
|
+
id: "fetch",
|
|
33
|
+
run: async (ctx) => {
|
|
34
|
+
console.log(` [fetch] Fetching data for ${ctx.asset}...`);
|
|
35
|
+
await new Promise(r => setTimeout(r, 500));
|
|
36
|
+
return { price: 78500, volume: 1000 };
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
id: "analyze",
|
|
41
|
+
run: async (ctx) => {
|
|
42
|
+
console.log(` [analyze] Analyzing price $${ctx.price}...`);
|
|
43
|
+
await new Promise(r => setTimeout(r, 500));
|
|
44
|
+
return { signal: "BUY", confidence: 0.85 };
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
gate: "auto",
|
|
49
|
+
onApprove: async (ctx) => {
|
|
50
|
+
console.log(` [execute] Signal: ${ctx.signal} @ $${ctx.price}`);
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
console.log(`Initial place: ${pipeline.getPlace()}`);
|
|
55
|
+
console.log("Pipeline created with auto gate (no human approval needed)\n");
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// ============================================
|
|
59
|
+
// USE CASE 2: Pipeline with human approval
|
|
60
|
+
// ============================================
|
|
61
|
+
async function testHumanGatePipeline() {
|
|
62
|
+
console.log("\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
|
|
63
|
+
console.log(" USE CASE 2: Pipeline with human gate");
|
|
64
|
+
console.log("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n");
|
|
65
|
+
|
|
66
|
+
const pipeline = new AgentPipeline({
|
|
67
|
+
name: "trading-approval",
|
|
68
|
+
trigger: priceZone("ETH", 2300, 2400),
|
|
69
|
+
stages: [
|
|
70
|
+
{
|
|
71
|
+
id: "alpha",
|
|
72
|
+
run: async (ctx) => {
|
|
73
|
+
console.log(` [@Alpha] Analyzing ${ctx.asset}...`);
|
|
74
|
+
return { signal: "BUY", confidence: 80, entryPrice: 2350 };
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
id: "guardian",
|
|
79
|
+
run: async (ctx) => {
|
|
80
|
+
console.log(` [@Guardian] Auditing...`);
|
|
81
|
+
return { verdict: "ACCEPTABLE", score: 5 };
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
id: "oracle",
|
|
86
|
+
run: async (ctx) => {
|
|
87
|
+
console.log(` [@Oracle] Deciding...`);
|
|
88
|
+
return { decision: "EXECUTE", action: { side: "BUY", sizeUsd: 50 } };
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
],
|
|
92
|
+
gate: "human",
|
|
93
|
+
onApprove: async (ctx) => {
|
|
94
|
+
console.log(` ✓ Human approved! Executing trade: ${ctx.decision}`);
|
|
95
|
+
console.log(` → ${ctx.action.side} $${ctx.action.sizeUsd}`);
|
|
96
|
+
},
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
console.log(`Initial place: ${pipeline.getPlace()}`);
|
|
100
|
+
console.log("Pipeline created with human gate\n");
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// ============================================
|
|
104
|
+
// USE CASE 3: Pipeline with conditional logic
|
|
105
|
+
// ============================================
|
|
106
|
+
async function testConditionalPipeline() {
|
|
107
|
+
console.log("\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
|
|
108
|
+
console.log(" USE CASE 3: Pipeline with conditional execution");
|
|
109
|
+
console.log("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n");
|
|
110
|
+
|
|
111
|
+
const pipeline = new AgentPipeline({
|
|
112
|
+
name: "conditional-trade",
|
|
113
|
+
trigger: priceZone("SOL", 100, 120),
|
|
114
|
+
stages: [
|
|
115
|
+
{
|
|
116
|
+
id: "analyze",
|
|
117
|
+
run: async (ctx) => {
|
|
118
|
+
console.log(` [analyze] Checking market conditions...`);
|
|
119
|
+
const shouldTrade = ctx.price > 110;
|
|
120
|
+
return { shouldTrade, signal: shouldTrade ? "BUY" : "WAIT" };
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
id: "execute_if_approved",
|
|
125
|
+
run: async (ctx) => {
|
|
126
|
+
if (!ctx.shouldTrade) {
|
|
127
|
+
console.log(` [skip] Conditions not met, skipping trade`);
|
|
128
|
+
return { skipped: true };
|
|
129
|
+
}
|
|
130
|
+
console.log(` [execute] Placing trade...`);
|
|
131
|
+
return { executed: true, orderId: "12345" };
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
],
|
|
135
|
+
gate: "auto",
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
console.log("Pipeline with conditional logic created");
|
|
139
|
+
console.log("Stage 2 checks ctx.shouldTrade before executing\n");
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// ============================================
|
|
143
|
+
// Run all use cases
|
|
144
|
+
// ============================================
|
|
145
|
+
async function main() {
|
|
146
|
+
console.log("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
|
|
147
|
+
console.log(" AgentPipeline API — Multiple Use Cases");
|
|
148
|
+
console.log("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
|
|
149
|
+
|
|
150
|
+
await testSimplePipeline();
|
|
151
|
+
await testHumanGatePipeline();
|
|
152
|
+
await testConditionalPipeline();
|
|
153
|
+
|
|
154
|
+
console.log("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
|
|
155
|
+
console.log(" All use cases defined successfully!");
|
|
156
|
+
console.log(" User never sees Petri net, transitions, or fireTransition()");
|
|
157
|
+
console.log("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n");
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
main().catch((e) => {
|
|
161
|
+
console.error("Error:", e);
|
|
162
|
+
process.exit(1);
|
|
163
|
+
});
|
package/tsconfig.json
CHANGED
|
@@ -22,10 +22,13 @@
|
|
|
22
22
|
"include": [
|
|
23
23
|
"index.ts",
|
|
24
24
|
"modules/**/*",
|
|
25
|
-
"
|
|
25
|
+
"execution/**/*",
|
|
26
|
+
"routing/**/*",
|
|
27
|
+
"agent/**/*",
|
|
28
|
+
"persistence/**/*",
|
|
26
29
|
"types/**/*",
|
|
27
30
|
"interfaces/**/*",
|
|
28
31
|
"utils/**/*"
|
|
29
32
|
],
|
|
30
|
-
"exclude": ["node_modules", "dist", "test", "examples"]
|
|
33
|
+
"exclude": ["node_modules", "dist", "test", "examples", "routing/web-server.ts"]
|
|
31
34
|
}
|
package/types/agent.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GraphFlow } from "@/
|
|
1
|
+
import { GraphFlow } from "@/execution";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -12,12 +12,26 @@ import { z } from "zod";
|
|
|
12
12
|
*/
|
|
13
13
|
export type ExecutedAction = {
|
|
14
14
|
name: string;
|
|
15
|
+
parameters?: Record<string, any>;
|
|
15
16
|
isExecuted: boolean;
|
|
16
17
|
error?: string | null;
|
|
17
18
|
result: any;
|
|
18
19
|
timestamp: string;
|
|
19
20
|
};
|
|
20
21
|
|
|
22
|
+
export type ChatMessage = {
|
|
23
|
+
role: "user" | "assistant";
|
|
24
|
+
content: string;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export type ScratchpadEntry = {
|
|
28
|
+
turn: number;
|
|
29
|
+
thought: string;
|
|
30
|
+
action: string;
|
|
31
|
+
observation: string;
|
|
32
|
+
timestamp: string;
|
|
33
|
+
};
|
|
34
|
+
|
|
21
35
|
/**
|
|
22
36
|
* Represents the context in which an agent operates
|
|
23
37
|
* @interface AgentContext
|
|
@@ -28,6 +42,11 @@ export type ExecutedAction = {
|
|
|
28
42
|
* @property {string} response - The agent's response
|
|
29
43
|
* @property {string} [knowledge] - Optional knowledge base or context
|
|
30
44
|
* @property {ExecutedAction[]} executedActions - History of executed actions
|
|
45
|
+
* @property {number} [iteration] - Current iteration count (reset per run)
|
|
46
|
+
* @property {boolean} [progressed] - Whether progress was made in this iteration
|
|
47
|
+
* @property {ChatMessage[]} [messages] - Conversation history
|
|
48
|
+
* @property {ScratchpadEntry[]} scratchpad - Structured journal of thoughts
|
|
49
|
+
* @property {BaseMemoryType[]} memories - Retrieved episodic memories
|
|
31
50
|
*/
|
|
32
51
|
export type AgentContext = {
|
|
33
52
|
input: {
|
|
@@ -38,6 +57,37 @@ export type AgentContext = {
|
|
|
38
57
|
response: string;
|
|
39
58
|
knowledge?: string;
|
|
40
59
|
executedActions: ExecutedAction[];
|
|
60
|
+
iteration?: number;
|
|
61
|
+
progressed?: boolean;
|
|
62
|
+
messages?: ChatMessage[];
|
|
63
|
+
toolResults?: Record<string, any>;
|
|
64
|
+
scratchpad?: ScratchpadEntry[];
|
|
65
|
+
memories?: any[];
|
|
66
|
+
entityState?: {
|
|
67
|
+
currentTarget?: string;
|
|
68
|
+
lastEntityType?: string | null;
|
|
69
|
+
pendingResolutions?: any[];
|
|
70
|
+
resolutionTrace?: any[];
|
|
71
|
+
explored?: boolean;
|
|
72
|
+
handles?: Record<string, { id: string; label: string; path: string; category: string }>;
|
|
73
|
+
};
|
|
74
|
+
conversationState?: {
|
|
75
|
+
currentGoal: string;
|
|
76
|
+
currentTarget: string | null;
|
|
77
|
+
lastResolvedEntity: string | null;
|
|
78
|
+
lastResolvedType: string | null;
|
|
79
|
+
pendingTask: string | null;
|
|
80
|
+
turnCount: number;
|
|
81
|
+
pendingIntent: { action: string | null; unresolvedEntity: string | null; originalInput: string; turn: number; failed: boolean } | null;
|
|
82
|
+
};
|
|
83
|
+
explorationBudget?: {
|
|
84
|
+
maxSteps: number;
|
|
85
|
+
maxExplorations: number;
|
|
86
|
+
maxToolCalls: number;
|
|
87
|
+
stepsUsed: number;
|
|
88
|
+
explorationsUsed: number;
|
|
89
|
+
toolCallsUsed: number;
|
|
90
|
+
};
|
|
41
91
|
};
|
|
42
92
|
|
|
43
93
|
export const AgentContextSchema = z.object({
|
|
@@ -45,6 +95,7 @@ export const AgentContextSchema = z.object({
|
|
|
45
95
|
raw: z.string(),
|
|
46
96
|
embedding: z.array(z.number()).optional(),
|
|
47
97
|
}),
|
|
98
|
+
cwd: z.string().optional(),
|
|
48
99
|
actions: z.array(
|
|
49
100
|
z.object({
|
|
50
101
|
name: z.string(),
|
|
@@ -69,6 +120,56 @@ export const AgentContextSchema = z.object({
|
|
|
69
120
|
})
|
|
70
121
|
)
|
|
71
122
|
.optional(),
|
|
123
|
+
iteration: z.number().optional(),
|
|
124
|
+
progressed: z.boolean().optional(),
|
|
125
|
+
messages: z
|
|
126
|
+
.array(
|
|
127
|
+
z.object({
|
|
128
|
+
role: z.enum(["user", "assistant"]),
|
|
129
|
+
content: z.string(),
|
|
130
|
+
})
|
|
131
|
+
)
|
|
132
|
+
.optional(),
|
|
133
|
+
toolResults: z.record(z.string(), z.unknown()).optional(),
|
|
134
|
+
scratchpad: z.array(z.object({
|
|
135
|
+
turn: z.number(),
|
|
136
|
+
thought: z.string(),
|
|
137
|
+
action: z.string(),
|
|
138
|
+
observation: z.string(),
|
|
139
|
+
timestamp: z.string(),
|
|
140
|
+
})).optional().default([]),
|
|
141
|
+
memories: z.array(z.any()).optional().default([]),
|
|
142
|
+
entityState: z.object({
|
|
143
|
+
currentTarget: z.string().optional(),
|
|
144
|
+
lastEntityType: z.string().nullable().optional(),
|
|
145
|
+
pendingResolutions: z.array(z.any()).optional(),
|
|
146
|
+
resolutionTrace: z.array(z.any()).optional(),
|
|
147
|
+
explored: z.boolean().optional(),
|
|
148
|
+
handles: z.record(z.string(), z.object({ id: z.string(), label: z.string(), path: z.string(), category: z.string() })).optional(),
|
|
149
|
+
}).optional(),
|
|
150
|
+
conversationState: z.object({
|
|
151
|
+
currentGoal: z.string(),
|
|
152
|
+
currentTarget: z.string().nullable(),
|
|
153
|
+
lastResolvedEntity: z.string().nullable(),
|
|
154
|
+
lastResolvedType: z.string().nullable(),
|
|
155
|
+
pendingTask: z.string().nullable(),
|
|
156
|
+
turnCount: z.number(),
|
|
157
|
+
pendingIntent: z.object({
|
|
158
|
+
action: z.string().nullable(),
|
|
159
|
+
unresolvedEntity: z.string().nullable(),
|
|
160
|
+
originalInput: z.string(),
|
|
161
|
+
turn: z.number(),
|
|
162
|
+
failed: z.boolean(),
|
|
163
|
+
}).nullable(),
|
|
164
|
+
}).optional(),
|
|
165
|
+
explorationBudget: z.object({
|
|
166
|
+
maxSteps: z.number(),
|
|
167
|
+
maxExplorations: z.number(),
|
|
168
|
+
maxToolCalls: z.number(),
|
|
169
|
+
stepsUsed: z.number(),
|
|
170
|
+
explorationsUsed: z.number(),
|
|
171
|
+
toolCallsUsed: z.number(),
|
|
172
|
+
}).optional(),
|
|
72
173
|
});
|
|
73
174
|
|
|
74
175
|
/**
|
|
@@ -85,7 +186,7 @@ export type PromptSection = {
|
|
|
85
186
|
/**
|
|
86
187
|
* Supported LLM providers
|
|
87
188
|
*/
|
|
88
|
-
export type LLMProvider = "openai" | "anthropic" | "custom";
|
|
189
|
+
export type LLMProvider = "openai" | "anthropic" | "ollama" | "groq" | "openrouter" | "google" | "custom";
|
|
89
190
|
|
|
90
191
|
/**
|
|
91
192
|
* Supported LLM models
|
|
@@ -115,7 +216,17 @@ export type AgentConfig = {
|
|
|
115
216
|
tools: GraphFlow<any>[];
|
|
116
217
|
memory?: any;
|
|
117
218
|
verbose?: boolean;
|
|
219
|
+
maxIterations?: number;
|
|
118
220
|
llmConfig: ExecutorConfig["llmConfig"];
|
|
221
|
+
dynamicGoal?: boolean;
|
|
222
|
+
dynamicGoalPrompt?: string;
|
|
223
|
+
dynamicNext?: boolean;
|
|
224
|
+
dynamicNextPrompt?: string;
|
|
225
|
+
enableSchedule?: boolean;
|
|
226
|
+
enableClone?: boolean;
|
|
227
|
+
enableReflection?: boolean;
|
|
228
|
+
agenda?: any;
|
|
229
|
+
entityStore?: import("../agent/entity-resolver/entity-index").IEntityStore;
|
|
119
230
|
};
|
|
120
231
|
|
|
121
232
|
/**
|
|
@@ -134,28 +245,39 @@ export type ActionSchema = {
|
|
|
134
245
|
* @interface DecisionOutput
|
|
135
246
|
* @property {ActionSchema[]} actions - The actions to be executed
|
|
136
247
|
* @property {string} response - The agent's response message
|
|
248
|
+
* @property {string} [thought] - The agent's internal reasoning for this turn
|
|
137
249
|
*/
|
|
138
250
|
export type DecisionOutput = {
|
|
139
251
|
actions: ActionSchema[];
|
|
140
252
|
response: string;
|
|
253
|
+
thought?: string;
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
export type LLMCall = {
|
|
257
|
+
promptTokens: number;
|
|
258
|
+
completionTokens: number;
|
|
259
|
+
duration: number;
|
|
260
|
+
timestamp: string;
|
|
141
261
|
};
|
|
142
262
|
|
|
143
263
|
/**
|
|
144
264
|
* Configuration for the Language Model
|
|
145
265
|
* @interface LLMConfig
|
|
146
266
|
* @property {LLMProvider} provider - The LLM provider to use
|
|
147
|
-
* @property {string} apiKey - API key for the provider
|
|
267
|
+
* @property {string} [apiKey] - API key for the provider (not required for Ollama)
|
|
148
268
|
* @property {LLMModel} model - The specific model to use
|
|
149
269
|
* @property {number} [temperature] - Optional temperature parameter for response randomness
|
|
150
270
|
* @property {number} [maxTokens] - Optional maximum tokens for the response
|
|
271
|
+
* @property {string} [baseUrl] - Optional base URL for local providers (e.g., Ollama)
|
|
151
272
|
* @property {Function} [customCall] - Optional custom implementation for API calls
|
|
152
273
|
*/
|
|
153
274
|
export type LLMConfig = {
|
|
154
275
|
provider: LLMProvider;
|
|
155
|
-
apiKey
|
|
276
|
+
apiKey?: string;
|
|
156
277
|
model: LLMModel;
|
|
157
278
|
temperature?: number;
|
|
158
279
|
maxTokens?: number;
|
|
280
|
+
baseUrl?: string;
|
|
159
281
|
customCall?: (
|
|
160
282
|
prompt: string | PromptInput,
|
|
161
283
|
schema: z.ZodType<any>
|