@ai.ntellect/core 1.0.0 → 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 +6 -0
- package/AGENTS.md +50 -0
- package/ARCHITECTURE.md +58 -0
- package/BENCHMARK.md +38 -0
- package/CHANGELOG.md +224 -0
- package/README.md +411 -142
- package/agent/agent-workflow.ts +569 -0
- package/agent/agent.ts +183 -0
- package/agent/base/executor.ts +103 -0
- package/agent/base/index.ts +87 -0
- package/agent/entity-resolver/confidence.ts +54 -0
- package/agent/entity-resolver/entity-index.ts +241 -0
- package/agent/entity-resolver/explore-strategy.ts +82 -0
- package/agent/entity-resolver/index.ts +22 -0
- package/agent/entity-resolver/resolver.ts +193 -0
- package/agent/entity-resolver/scorer.ts +211 -0
- package/agent/entity-resolver/types.ts +98 -0
- package/agent/generic-executor.ts +713 -0
- package/agent/handlers/cognitive-handler.ts +197 -0
- package/agent/handlers/index.ts +1 -0
- package/agent/handoff.ts +58 -0
- package/agent/llm-factory.ts +343 -0
- package/agent/orchestrator.ts +45 -0
- package/agent/prompt-builder.ts +78 -0
- package/agent/registry.ts +64 -0
- package/agent/tools/file-system.ts +471 -0
- package/agent/tools/index.ts +23 -0
- package/agent/tools/logger.ts +105 -0
- package/agent/tools/tool-resolver.ts +104 -0
- package/benchmark/cortexflow-workflow.ts +182 -0
- package/benchmark/langgraph-workflow.ts +201 -0
- package/benchmark/llm-client.ts +76 -0
- package/benchmark/run-benchmark.ts +222 -0
- package/cli-dev.ts +419 -0
- package/dist/agent/agent-workflow.d.ts +41 -0
- package/dist/agent/agent-workflow.d.ts.map +1 -0
- package/dist/agent/agent-workflow.js +560 -0
- package/dist/agent/agent-workflow.js.map +1 -0
- package/dist/agent/agent.d.ts +38 -0
- package/dist/agent/agent.d.ts.map +1 -0
- package/dist/agent/agent.js +149 -0
- package/dist/agent/agent.js.map +1 -0
- package/dist/agent/base/executor.d.ts +51 -0
- package/dist/agent/base/executor.d.ts.map +1 -0
- package/dist/agent/base/executor.js +69 -0
- package/dist/agent/base/executor.js.map +1 -0
- package/dist/agent/base/index.d.ts +30 -0
- package/dist/agent/base/index.d.ts.map +1 -0
- package/dist/agent/base/index.js +88 -0
- package/dist/agent/base/index.js.map +1 -0
- package/dist/agent/entity-resolver/confidence.d.ts +4 -0
- package/dist/agent/entity-resolver/confidence.d.ts.map +1 -0
- package/dist/agent/entity-resolver/confidence.js +47 -0
- package/dist/agent/entity-resolver/confidence.js.map +1 -0
- package/dist/agent/entity-resolver/entity-index.d.ts +40 -0
- package/dist/agent/entity-resolver/entity-index.d.ts.map +1 -0
- package/dist/agent/entity-resolver/entity-index.js +244 -0
- package/dist/agent/entity-resolver/entity-index.js.map +1 -0
- package/dist/agent/entity-resolver/explore-strategy.d.ts +13 -0
- package/dist/agent/entity-resolver/explore-strategy.d.ts.map +1 -0
- package/dist/agent/entity-resolver/explore-strategy.js +109 -0
- package/dist/agent/entity-resolver/explore-strategy.js.map +1 -0
- package/dist/agent/entity-resolver/index.d.ts +8 -0
- package/dist/agent/entity-resolver/index.d.ts.map +1 -0
- package/dist/agent/entity-resolver/index.js +16 -0
- package/dist/agent/entity-resolver/index.js.map +1 -0
- package/dist/agent/entity-resolver/resolver.d.ts +18 -0
- package/dist/agent/entity-resolver/resolver.d.ts.map +1 -0
- package/dist/agent/entity-resolver/resolver.js +158 -0
- package/dist/agent/entity-resolver/resolver.js.map +1 -0
- package/dist/agent/entity-resolver/scorer.d.ts +3 -0
- package/dist/agent/entity-resolver/scorer.d.ts.map +1 -0
- package/dist/agent/entity-resolver/scorer.js +182 -0
- package/dist/agent/entity-resolver/scorer.js.map +1 -0
- package/dist/agent/entity-resolver/types.d.ts +89 -0
- package/dist/agent/entity-resolver/types.d.ts.map +1 -0
- package/dist/agent/entity-resolver/types.js +3 -0
- package/dist/agent/entity-resolver/types.js.map +1 -0
- package/dist/agent/generic-executor.d.ts +68 -0
- package/dist/agent/generic-executor.d.ts.map +1 -0
- package/dist/agent/generic-executor.js +620 -0
- package/dist/agent/generic-executor.js.map +1 -0
- package/dist/agent/handlers/cognitive-handler.d.ts +44 -0
- package/dist/agent/handlers/cognitive-handler.d.ts.map +1 -0
- package/dist/agent/handlers/cognitive-handler.js +172 -0
- package/dist/agent/handlers/cognitive-handler.js.map +1 -0
- package/dist/agent/handlers/index.d.ts +2 -0
- package/dist/agent/handlers/index.d.ts.map +1 -0
- package/dist/agent/handlers/index.js +7 -0
- package/dist/agent/handlers/index.js.map +1 -0
- package/dist/agent/handoff.d.ts +12 -0
- package/dist/agent/handoff.d.ts.map +1 -0
- package/dist/agent/handoff.js +62 -0
- package/dist/agent/handoff.js.map +1 -0
- package/dist/agent/llm-factory.d.ts +19 -0
- package/dist/agent/llm-factory.d.ts.map +1 -0
- package/dist/agent/llm-factory.js +297 -0
- package/dist/agent/llm-factory.js.map +1 -0
- package/dist/agent/orchestrator.d.ts +18 -0
- package/dist/agent/orchestrator.d.ts.map +1 -0
- package/dist/agent/orchestrator.js +44 -0
- package/dist/agent/orchestrator.js.map +1 -0
- package/dist/agent/prompt-builder.d.ts +35 -0
- package/dist/agent/prompt-builder.d.ts.map +1 -0
- package/dist/agent/prompt-builder.js +76 -0
- package/dist/agent/prompt-builder.js.map +1 -0
- package/dist/agent/registry.d.ts +19 -0
- package/dist/agent/registry.d.ts.map +1 -0
- package/dist/agent/registry.js +48 -0
- package/dist/agent/registry.js.map +1 -0
- package/dist/agent/tools/file-system.d.ts +11 -0
- package/dist/agent/tools/file-system.d.ts.map +1 -0
- package/dist/agent/tools/file-system.js +528 -0
- package/dist/agent/tools/file-system.js.map +1 -0
- package/dist/agent/tools/index.d.ts +4 -0
- package/dist/agent/tools/index.d.ts.map +1 -0
- package/dist/agent/tools/index.js +20 -0
- package/dist/agent/tools/index.js.map +1 -0
- package/dist/agent/tools/logger.d.ts +33 -0
- package/dist/agent/tools/logger.d.ts.map +1 -0
- package/dist/agent/tools/logger.js +86 -0
- package/dist/agent/tools/logger.js.map +1 -0
- package/dist/agent/tools/tool-resolver.d.ts +7 -0
- package/dist/agent/tools/tool-resolver.d.ts.map +1 -0
- package/dist/agent/tools/tool-resolver.js +122 -0
- package/dist/agent/tools/tool-resolver.js.map +1 -0
- package/dist/execution/adapters/in-memory-checkpoint.d.ts +11 -0
- package/dist/execution/adapters/in-memory-checkpoint.d.ts.map +1 -0
- package/dist/execution/adapters/in-memory-checkpoint.js +54 -0
- package/dist/execution/adapters/in-memory-checkpoint.js.map +1 -0
- package/dist/execution/compiler.d.ts +8 -0
- package/dist/execution/compiler.d.ts.map +1 -0
- package/dist/execution/compiler.js +50 -0
- package/dist/execution/compiler.js.map +1 -0
- package/dist/execution/controller.d.ts +30 -0
- package/dist/execution/controller.d.ts.map +1 -0
- package/dist/execution/controller.js +80 -0
- package/dist/execution/controller.js.map +1 -0
- package/dist/execution/event-manager.d.ts +29 -0
- package/dist/execution/event-manager.d.ts.map +1 -0
- package/dist/execution/event-manager.js +264 -0
- package/dist/execution/event-manager.js.map +1 -0
- package/dist/execution/index.d.ts +221 -0
- package/dist/execution/index.d.ts.map +1 -0
- package/dist/execution/index.js +638 -0
- package/dist/execution/index.js.map +1 -0
- package/dist/execution/logger.d.ts +46 -0
- package/dist/execution/logger.d.ts.map +1 -0
- package/dist/execution/logger.js +69 -0
- package/dist/execution/logger.js.map +1 -0
- package/dist/execution/node.d.ts +65 -0
- package/dist/execution/node.d.ts.map +1 -0
- package/dist/execution/node.js +250 -0
- package/dist/execution/node.js.map +1 -0
- package/dist/execution/observer.d.ts +38 -0
- package/dist/execution/observer.d.ts.map +1 -0
- package/dist/execution/observer.js +111 -0
- package/dist/execution/observer.js.map +1 -0
- package/dist/execution/planner.d.ts +14 -0
- package/dist/execution/planner.d.ts.map +1 -0
- package/dist/execution/planner.js +43 -0
- package/dist/execution/planner.js.map +1 -0
- package/dist/execution/reducer.d.ts +19 -0
- package/dist/execution/reducer.d.ts.map +1 -0
- package/dist/execution/reducer.js +61 -0
- package/dist/execution/reducer.js.map +1 -0
- package/dist/execution/registry.d.ts +38 -0
- package/dist/execution/registry.d.ts.map +1 -0
- package/dist/execution/registry.js +63 -0
- package/dist/execution/registry.js.map +1 -0
- package/dist/execution/send-api.d.ts +24 -0
- package/dist/execution/send-api.d.ts.map +1 -0
- package/dist/execution/send-api.js +52 -0
- package/dist/execution/send-api.js.map +1 -0
- package/dist/execution/types.parallel.d.ts +61 -0
- package/dist/execution/types.parallel.d.ts.map +1 -0
- package/dist/execution/types.parallel.js +3 -0
- package/dist/execution/types.parallel.js.map +1 -0
- package/dist/execution/visualizer.d.ts +35 -0
- package/dist/execution/visualizer.d.ts.map +1 -0
- package/dist/execution/visualizer.js +131 -0
- package/dist/execution/visualizer.js.map +1 -0
- package/dist/index.d.ts +47 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +78 -0
- package/dist/index.js.map +1 -0
- package/dist/interfaces/index.d.ts +487 -0
- package/dist/interfaces/index.d.ts.map +1 -0
- package/dist/interfaces/index.js +75 -0
- package/dist/interfaces/index.js.map +1 -0
- package/dist/modules/agenda/adapters/node-cron/index.d.ts +17 -0
- package/dist/modules/agenda/adapters/node-cron/index.d.ts.map +1 -0
- package/dist/modules/agenda/adapters/node-cron/index.js +30 -0
- package/dist/modules/agenda/adapters/node-cron/index.js.map +1 -0
- package/dist/modules/agenda/index.d.ts +63 -0
- package/dist/modules/agenda/index.d.ts.map +1 -0
- package/dist/modules/agenda/index.js +141 -0
- package/dist/modules/agenda/index.js.map +1 -0
- package/dist/modules/cli/index.d.ts +13 -0
- package/dist/modules/cli/index.d.ts.map +1 -0
- package/dist/modules/cli/index.js +672 -0
- package/dist/modules/cli/index.js.map +1 -0
- package/dist/modules/embedding/adapters/ai/index.d.ts +29 -0
- package/dist/modules/embedding/adapters/ai/index.d.ts.map +1 -0
- package/dist/modules/embedding/adapters/ai/index.js +58 -0
- package/dist/modules/embedding/adapters/ai/index.js.map +1 -0
- package/dist/modules/embedding/index.d.ts +36 -0
- package/dist/modules/embedding/index.d.ts.map +1 -0
- package/dist/modules/embedding/index.js +60 -0
- package/dist/modules/embedding/index.js.map +1 -0
- package/dist/modules/nlp/engine.d.ts +126 -0
- package/dist/modules/nlp/engine.d.ts.map +1 -0
- package/dist/modules/nlp/engine.js +299 -0
- package/dist/modules/nlp/engine.js.map +1 -0
- package/dist/modules/nlp/index.d.ts +27 -0
- package/dist/modules/nlp/index.d.ts.map +1 -0
- package/dist/modules/nlp/index.js +56 -0
- package/dist/modules/nlp/index.js.map +1 -0
- package/dist/persistence/index.d.ts +12 -0
- package/dist/persistence/index.d.ts.map +1 -0
- package/dist/persistence/index.js +24 -0
- package/dist/persistence/index.js.map +1 -0
- package/dist/persistence/neo4j/driver.d.ts +26 -0
- package/dist/persistence/neo4j/driver.d.ts.map +1 -0
- package/dist/persistence/neo4j/driver.js +64 -0
- package/dist/persistence/neo4j/driver.js.map +1 -0
- package/dist/persistence/neo4j/entity-store.d.ts +15 -0
- package/dist/persistence/neo4j/entity-store.d.ts.map +1 -0
- package/dist/persistence/neo4j/entity-store.js +136 -0
- package/dist/persistence/neo4j/entity-store.js.map +1 -0
- package/dist/persistence/neo4j/execution-tracer.d.ts +19 -0
- package/dist/persistence/neo4j/execution-tracer.d.ts.map +1 -0
- package/dist/persistence/neo4j/execution-tracer.js +166 -0
- package/dist/persistence/neo4j/execution-tracer.js.map +1 -0
- package/dist/persistence/neo4j/memory-adapter.d.ts +35 -0
- package/dist/persistence/neo4j/memory-adapter.d.ts.map +1 -0
- package/dist/persistence/neo4j/memory-adapter.js +252 -0
- package/dist/persistence/neo4j/memory-adapter.js.map +1 -0
- package/dist/persistence/neo4j/petri-checkpoint-adapter.d.ts +22 -0
- package/dist/persistence/neo4j/petri-checkpoint-adapter.d.ts.map +1 -0
- package/dist/persistence/neo4j/petri-checkpoint-adapter.js +141 -0
- package/dist/persistence/neo4j/petri-checkpoint-adapter.js.map +1 -0
- package/dist/pipeline/agent-pipeline.d.ts +99 -0
- package/dist/pipeline/agent-pipeline.d.ts.map +1 -0
- package/dist/pipeline/agent-pipeline.js +356 -0
- package/dist/pipeline/agent-pipeline.js.map +1 -0
- package/dist/routing/checkpoint-adapter.d.ts +30 -0
- package/dist/routing/checkpoint-adapter.d.ts.map +1 -0
- package/dist/routing/checkpoint-adapter.js +83 -0
- package/dist/routing/checkpoint-adapter.js.map +1 -0
- package/dist/routing/documentation-generator.d.ts +47 -0
- package/dist/routing/documentation-generator.d.ts.map +1 -0
- package/dist/routing/documentation-generator.js +320 -0
- package/dist/routing/documentation-generator.js.map +1 -0
- package/dist/routing/index.d.ts +38 -0
- package/dist/routing/index.d.ts.map +1 -0
- package/dist/routing/index.js +375 -0
- package/dist/routing/index.js.map +1 -0
- package/dist/routing/intent-classifier.d.ts +206 -0
- package/dist/routing/intent-classifier.d.ts.map +1 -0
- package/dist/routing/intent-classifier.js +267 -0
- package/dist/routing/intent-classifier.js.map +1 -0
- package/dist/routing/matrix.d.ts +6 -0
- package/dist/routing/matrix.d.ts.map +1 -0
- package/dist/routing/matrix.js +131 -0
- package/dist/routing/matrix.js.map +1 -0
- package/dist/routing/orchestrator.d.ts +87 -0
- package/dist/routing/orchestrator.d.ts.map +1 -0
- package/dist/routing/orchestrator.js +425 -0
- package/dist/routing/orchestrator.js.map +1 -0
- package/dist/routing/postgres-checkpoint-adapter.d.ts +32 -0
- package/dist/routing/postgres-checkpoint-adapter.d.ts.map +1 -0
- package/dist/routing/postgres-checkpoint-adapter.js +167 -0
- package/dist/routing/postgres-checkpoint-adapter.js.map +1 -0
- package/dist/routing/redis-checkpoint-adapter.d.ts +34 -0
- package/dist/routing/redis-checkpoint-adapter.d.ts.map +1 -0
- package/dist/routing/redis-checkpoint-adapter.js +170 -0
- package/dist/routing/redis-checkpoint-adapter.js.map +1 -0
- package/dist/routing/types.d.ts +49 -0
- package/dist/routing/types.d.ts.map +1 -0
- package/dist/routing/types.js +3 -0
- package/dist/routing/types.js.map +1 -0
- package/dist/types/agent.d.ts +289 -0
- package/dist/types/agent.d.ts.map +1 -0
- package/dist/types/agent.js +78 -0
- package/dist/types/agent.js.map +1 -0
- package/dist/types/index.d.ts +343 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +3 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/generate-action-schema.d.ts +4 -0
- package/dist/utils/generate-action-schema.d.ts.map +1 -0
- package/dist/utils/generate-action-schema.js +46 -0
- package/dist/utils/generate-action-schema.js.map +1 -0
- package/dist/utils/header-builder.d.ts +12 -0
- package/dist/utils/header-builder.d.ts.map +1 -0
- package/dist/utils/header-builder.js +35 -0
- package/dist/utils/header-builder.js.map +1 -0
- package/dist/utils/logger.d.ts +27 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +45 -0
- package/dist/utils/logger.js.map +1 -0
- package/docs/.gitbook/assets/image (1).png +0 -0
- package/docs/.gitbook/assets/image (2).png +0 -0
- package/docs/.gitbook/assets/image (3).png +0 -0
- package/docs/.gitbook/assets/image (4).png +0 -0
- package/docs/.gitbook/assets/image (5).png +0 -0
- package/docs/.gitbook/assets/image (6).png +0 -0
- package/docs/.gitbook/assets/image.png +0 -0
- package/docs/README.md +57 -0
- package/docs/SUMMARY.md +34 -0
- package/docs/cas-dusages.md +69 -0
- package/docs/cli/README.md +65 -0
- package/docs/concepts-cles.md +50 -0
- package/docs/core/architecture.md +87 -0
- package/docs/core/benchmark.md +59 -0
- package/docs/core/checkpoint.md +72 -0
- package/docs/core/documentation.md +55 -0
- package/docs/core/graphcontroller.md +63 -0
- package/docs/core/graphflow.md +137 -0
- package/docs/core/introduction.md +41 -0
- package/docs/core/les-evenements.md +95 -0
- package/docs/modules/agenda/README.md +63 -0
- package/docs/modules/agenda/interface-iagenda.md +170 -0
- package/docs/modules/agenda/les-adaptateurs/README.md +237 -0
- package/docs/modules/agenda/les-adaptateurs/nodecronadapter.md +91 -0
- package/docs/modules/introduction.md +55 -0
- package/docs/modules/les-adaptateurs.md +52 -0
- package/docs/modules/memoire/README.md +68 -0
- package/docs/modules/memoire/interface-imemory.md +183 -0
- package/docs/modules/memoire/les-adaptateurs/README.md +209 -0
- package/docs/modules/memoire/les-adaptateurs/inmemoryadapter.md +110 -0
- package/docs/modules/memoire/les-adaptateurs/meilisearchadapter.md +147 -0
- package/docs/modules/memoire/les-adaptateurs/redisadapter.md +212 -0
- package/docs/modules/nlp/README.md +44 -0
- package/docs/philosophie.md +51 -0
- package/docs/tutoriels/ajouter-des-conditions.md +150 -0
- package/docs/tutoriels/branching.md +194 -0
- package/docs/tutoriels/checkpoint-usage.md +99 -0
- package/docs/tutoriels/creer-agent-onchain.md +1041 -0
- package/docs/tutoriels/creer-un-agent.md +108 -0
- package/docs/tutoriels/creer-un-graphe-simple.md +92 -0
- package/docs/tutoriels/gerer-les-erreurs.md +124 -0
- package/docs/tutoriels/pour-commencer.md +73 -0
- package/docs/tutoriels/retry.md +166 -0
- package/execution/adapters/in-memory-checkpoint.ts +35 -0
- package/execution/compiler.ts +47 -0
- package/execution/controller.ts +84 -0
- package/execution/event-manager.ts +331 -0
- package/execution/index.ts +800 -0
- package/execution/logger.ts +70 -0
- package/execution/node.ts +315 -0
- package/execution/observer.ts +192 -0
- package/execution/planner.ts +40 -0
- package/execution/reducer.ts +73 -0
- package/execution/registry.ts +86 -0
- package/execution/send-api.ts +58 -0
- package/execution/types.parallel.ts +81 -0
- package/execution/visualizer.ts +158 -0
- package/index.ts +55 -465
- package/interfaces/index.ts +597 -0
- package/modules/agenda/adapters/node-cron/index.ts +25 -0
- package/modules/agenda/index.ts +146 -0
- package/modules/cli/index.ts +580 -0
- package/modules/embedding/adapters/ai/index.ts +42 -0
- package/modules/embedding/index.ts +45 -0
- package/modules/nlp/engine.ts +324 -0
- package/modules/nlp/index.ts +45 -0
- package/package.json +81 -9
- package/persistence/index.ts +27 -0
- package/persistence/neo4j/driver.ts +34 -0
- package/persistence/neo4j/entity-store.ts +141 -0
- package/persistence/neo4j/execution-tracer.ts +194 -0
- package/persistence/neo4j/memory-adapter.ts +281 -0
- package/persistence/neo4j/petri-checkpoint-adapter.ts +153 -0
- package/pipeline/agent-pipeline.ts +426 -0
- package/routing/checkpoint-adapter.ts +79 -0
- package/routing/documentation-generator.ts +358 -0
- package/routing/index.ts +459 -0
- package/routing/intent-classifier.ts +360 -0
- package/routing/matrix.ts +138 -0
- package/routing/orchestrator.ts +498 -0
- package/routing/patterns/data-extraction.json +79 -0
- package/routing/patterns/human-approval.json +64 -0
- package/routing/patterns/rag-search.json +68 -0
- package/routing/postgres-checkpoint-adapter.ts +172 -0
- package/routing/redis-checkpoint-adapter.ts +187 -0
- package/routing/types.ts +59 -0
- package/routing/web-server.ts +260 -0
- package/scripts/generate-petri-docs.ts +70 -0
- package/scripts/get-gmail-token.js +65 -0
- package/scripts/get-gmail-token.ts +65 -0
- package/test/agent/agent.test.ts +92 -0
- package/test/agent/clone.test.ts +143 -0
- package/test/agent/cognitive-handler.test.ts +78 -0
- package/test/agent/entity-store.test.ts +80 -0
- package/test/agent/generic-executor.test.ts +230 -0
- package/test/agent/handoff.test.ts +163 -0
- package/test/agent/llm-factory.test.ts +40 -0
- package/test/agent/orchestrator.test.ts +156 -0
- package/test/agent/registry.test.ts +97 -0
- package/test/agent/tools.test.ts +267 -0
- package/test/execution/checkpoint.test.ts +811 -0
- package/test/execution/controller.test.ts +236 -0
- package/test/execution/event-manager.test.ts +118 -0
- package/test/execution/index.test.ts +690 -0
- package/test/execution/node.test.ts +464 -0
- package/test/execution/observer.test.ts +393 -0
- package/test/execution/parallel.test.ts +135 -0
- package/test/execution/plan-llm-integration.test.ts +290 -0
- package/test/execution/plan-real-onchain.test.ts +226 -0
- package/test/execution/send-api.test.ts +121 -0
- package/test/modules/agenda/node-cron.test.ts +307 -0
- package/test/modules/cli/index.test.ts +125 -0
- package/test/persistence/neo4j-execution-tracer.test.ts +96 -0
- package/test/persistence/neo4j-memory-adapter.test.ts +107 -0
- package/test/persistence/neo4j-petri-checkpoint.test.ts +89 -0
- package/test/pipeline/agent-pipeline.test.ts +118 -0
- package/test/routing/checkpoint-persistence.test.ts +58 -0
- package/test/routing/documentation-generator.test.ts +76 -0
- package/test/routing/integration.test.ts +261 -0
- package/test/routing/intent-classifier.test.ts +102 -0
- package/test/routing/petri.test.ts +156 -0
- package/test/routing/real-llm.test.ts +260 -0
- package/test-petri-features.ts +218 -0
- package/test-pipeline-api.ts +163 -0
- package/tsconfig.json +30 -108
- package/types/agent.ts +296 -0
- package/types/index.ts +387 -0
- package/utils/generate-action-schema.ts +47 -0
- package/utils/header-builder.ts +40 -0
- package/utils/logger.ts +40 -0
- package/package copy.json +0 -21
- package/types.ts +0 -62
- package/utils/executor.ts +0 -42
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
# GraphFlow: The Execution Engine
|
|
2
|
+
|
|
3
|
+
`GraphFlow` is the primary primitive for defining a workflow in `@ai.ntellect/core`. Think of it as a **typed state machine** where each transition is a validated step.
|
|
4
|
+
|
|
5
|
+
## 🏗️ Creating a Workflow
|
|
6
|
+
|
|
7
|
+
A GraphFlow consists of a **Schema** (Zod), an initial **Context**, and a set of **Nodes**.
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
import { z } from "zod";
|
|
11
|
+
import { GraphFlow } from "@ai.ntellect/core";
|
|
12
|
+
|
|
13
|
+
// 1. Define the state shape (MANDATORY for validation)
|
|
14
|
+
const OrderSchema = z.object({
|
|
15
|
+
orderId: z.string(),
|
|
16
|
+
status: z.string(),
|
|
17
|
+
amount: z.number(),
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
// 2. Define the workflow
|
|
21
|
+
const orderWorkflow = new GraphFlow({
|
|
22
|
+
name: "OrderProcessing",
|
|
23
|
+
schema: OrderSchema,
|
|
24
|
+
context: { orderId: "", status: "pending", amount: 0 },
|
|
25
|
+
nodes: [
|
|
26
|
+
{
|
|
27
|
+
name: "validate_order",
|
|
28
|
+
execute: async (ctx) => {
|
|
29
|
+
if (ctx.amount <= 0) throw new Error("Invalid amount");
|
|
30
|
+
ctx.status = "validated";
|
|
31
|
+
},
|
|
32
|
+
next: "process_payment",
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
name: "process_payment",
|
|
36
|
+
execute: async (ctx) => {
|
|
37
|
+
// Payment logic here
|
|
38
|
+
ctx.status = "paid";
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
await orderWorkflow.execute("validate_order");
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## 🛣️ Routing Logic
|
|
50
|
+
|
|
51
|
+
### Sequential & Conditional Execution
|
|
52
|
+
Nodes move to the next step via the `next` property. This can be:
|
|
53
|
+
- **Static**: `next: "nextNodeName"`
|
|
54
|
+
- **Dynamic**: `next: (ctx) => ctx.amount > 100 ? "high_value_flow" : "standard_flow"`
|
|
55
|
+
|
|
56
|
+
### Parallel Execution (Fork-Join Model)
|
|
57
|
+
You can execute multiple branches concurrently to reduce latency.
|
|
58
|
+
```typescript
|
|
59
|
+
{
|
|
60
|
+
name: "start",
|
|
61
|
+
parallel: { enabled: true, joinNode: "merge" },
|
|
62
|
+
next: ["fetch_user", "fetch_inventory", "check_credit"],
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
The engine clones the context for each branch, executes them via `Promise.all`, and merges the results into the `joinNode` using a **Reducer**.
|
|
66
|
+
|
|
67
|
+
### Dynamic Fan-Out (The Send API)
|
|
68
|
+
When the number of parallel branches is determined at runtime (e.g., processing a list of items), use the `send` API:
|
|
69
|
+
```typescript
|
|
70
|
+
{
|
|
71
|
+
name: "distribute",
|
|
72
|
+
send: (ctx) => ctx.items.map(item => ({
|
|
73
|
+
to: "processItem",
|
|
74
|
+
input: { item },
|
|
75
|
+
})),
|
|
76
|
+
parallel: { enabled: true, joinNode: "complete" },
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## ⚡ Event-Driven Nodes
|
|
83
|
+
|
|
84
|
+
A node can pause execution and wait for an external signal. This is critical for **Human-in-the-Loop** or **Asynchronous Integrations**.
|
|
85
|
+
|
|
86
|
+
```typescript
|
|
87
|
+
{
|
|
88
|
+
name: "await_approval",
|
|
89
|
+
when: {
|
|
90
|
+
events: ["manager.approved"],
|
|
91
|
+
timeout: 86400000, // 24 hours
|
|
92
|
+
strategy: { type: "single" },
|
|
93
|
+
},
|
|
94
|
+
execute: async (ctx, _, event) => {
|
|
95
|
+
ctx.approvedBy = event.payload.managerId;
|
|
96
|
+
ctx.status = "approved";
|
|
97
|
+
},
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Event Strategies
|
|
102
|
+
- **`single`**: Fires on the first matching event.
|
|
103
|
+
- **`all`**: Fires only after *every* listed event has arrived.
|
|
104
|
+
- **`correlate`**: Fires when events arrive that match a custom correlation function (e.g., matching `orderId`).
|
|
105
|
+
|
|
106
|
+
---
|
|
107
|
+
|
|
108
|
+
## 🔍 Observability & State
|
|
109
|
+
|
|
110
|
+
Because GraphFlow is deterministic, it is fully observable.
|
|
111
|
+
|
|
112
|
+
### Reactive State Tracking
|
|
113
|
+
You can subscribe to context changes in real-time:
|
|
114
|
+
```typescript
|
|
115
|
+
workflow.observe().property("status").subscribe(s => console.log(`Status: ${s}`));
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### Formal Validation
|
|
119
|
+
The Zod schema isn't just for TypeScript types; it's a **runtime guard**. If a node attempts to set the context to an invalid state, the GraphFlow throws an error immediately, preventing corrupted state from propagating.
|
|
120
|
+
|
|
121
|
+
---
|
|
122
|
+
|
|
123
|
+
## 📖 API Reference
|
|
124
|
+
|
|
125
|
+
### `GraphFlow` Methods
|
|
126
|
+
- `execute(nodeName, initialContext)`: Starts the workflow.
|
|
127
|
+
- `emit(event, payload)`: Triggers event-driven nodes.
|
|
128
|
+
- `getContext()`: Returns the current validated state.
|
|
129
|
+
- `observe()`: Returns an observer for state and event tracking.
|
|
130
|
+
|
|
131
|
+
### `GraphNodeConfig` Properties
|
|
132
|
+
- `name`: Unique identifier.
|
|
133
|
+
- `execute`: The core logic function.
|
|
134
|
+
- `next`: Routing logic (string or function).
|
|
135
|
+
- `when`: Event-wait configuration.
|
|
136
|
+
- `parallel`: Fork-Join configuration.
|
|
137
|
+
- `retry`: Backoff and attempt configuration.
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Introduction
|
|
2
|
+
|
|
3
|
+
Welcome to the core of **@ai.ntellect/core**. This framework is built on the principle that **AI agents in production must be deterministic**.
|
|
4
|
+
|
|
5
|
+
While most frameworks focus on "autonomy" (letting the LLM decide everything), we focus on **Orchestration**. We provide the tools to wrap probabilistic AI in a deterministic shell, ensuring your agent doesn't drift, hallucinate its routing, or enter infinite loops.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 🛠️ The Three Pillars of the Core
|
|
10
|
+
|
|
11
|
+
### 1. Graph-Based Execution (GraphFlow)
|
|
12
|
+
At the lowest level, we use **GraphFlow**. A GraphFlow is a typed directed graph where each node is a discrete unit of logic.
|
|
13
|
+
- **Modular**: Each node is an independent action.
|
|
14
|
+
- **Typed**: Every transition is validated via Zod, preventing runtime type errors.
|
|
15
|
+
- **Dynamic**: Nodes can execute sequentially, in parallel (Fork-Join), or based on conditional logic.
|
|
16
|
+
|
|
17
|
+
### 2. Event-Driven Reactivity
|
|
18
|
+
Our engine doesn't just run from start to finish; it lives in a state of reactivity.
|
|
19
|
+
- **External Triggers**: Nodes can pause and wait for webhooks, blockchain events, or user actions.
|
|
20
|
+
- **Asynchronousity**: The system can handle thousands of paused workflows, resuming them only when the required event arrives.
|
|
21
|
+
- **Interoperability**: By using an `IEventEmitter` interface, the framework integrates seamlessly with any event-driven architecture.
|
|
22
|
+
|
|
23
|
+
### 3. Deterministic Orchestration (CortexFlow)
|
|
24
|
+
This is where the "Intelligence" meets "Control." CortexFlow implements the **Classifier-Controller Split**:
|
|
25
|
+
- **The LLM as the Classifier**: It identifies the *Intent* of the user request.
|
|
26
|
+
- **The Petri Net as the Controller**: It routes that intent through a mathematically verified path.
|
|
27
|
+
|
|
28
|
+
By moving the routing logic out of the LLM and into a Petri Net, we achieve **formal verification**. We can prove, before a single line of code runs, that your workflow is free of deadlocks and that all states are reachable.
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## 🚀 Why this matters for Production
|
|
33
|
+
|
|
34
|
+
| The "Autonomous" Approach | The "@ai.ntellect/core" Approach |
|
|
35
|
+
| :--- | :--- |
|
|
36
|
+
| LLM decides the next step at every turn | LLM decides the *intent* once |
|
|
37
|
+
| Hallucinations lead to routing errors | Routing is deterministic and verified |
|
|
38
|
+
| Prompt engineering is used to "fix" flow | Graph structure defines the flow |
|
|
39
|
+
| Debugging involves "guessing" LLM state | Debugging involves tracing a state machine |
|
|
40
|
+
|
|
41
|
+
**In short: We move AI from "guessing" to "executing."**
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# Event-Driven Workflows
|
|
2
|
+
|
|
3
|
+
In most traditional code, a function starts and runs until it returns. In `@ai.ntellect/core`, a workflow can **pause and wait for the world to change**.
|
|
4
|
+
|
|
5
|
+
This is achieved through **Event-Driven Nodes**.
|
|
6
|
+
|
|
7
|
+
## ⚙️ How it Works
|
|
8
|
+
|
|
9
|
+
An event-driven node uses the `when` property to define its trigger conditions. When the engine reaches such a node, it does not execute the `execute` function immediately. Instead, it:
|
|
10
|
+
1. Saves the current state (Checkpoint).
|
|
11
|
+
2. Registers a listener for the specified events.
|
|
12
|
+
3. Pauses execution.
|
|
13
|
+
|
|
14
|
+
Once the event arrives via `workflow.emit()`, the engine wakes up, validates the event, and executes the node logic.
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## 🛠️ Configuration & Strategies
|
|
19
|
+
|
|
20
|
+
### 1. The `single` Strategy
|
|
21
|
+
The simplest form of reactivity. The node fires as soon as any one of the listed events occurs.
|
|
22
|
+
```typescript
|
|
23
|
+
when: {
|
|
24
|
+
events: ["payment.received", "payment.manual_override"],
|
|
25
|
+
strategy: { type: "single" },
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### 2. The `all` Strategy
|
|
30
|
+
Used for synchronization. The node only executes after *all* required events have been received.
|
|
31
|
+
```typescript
|
|
32
|
+
when: {
|
|
33
|
+
events: ["identity.verified", "credit.checked"],
|
|
34
|
+
strategy: { type: "all" },
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### 3. The `correlate` Strategy (Advanced)
|
|
39
|
+
In a multi-user system, you receive thousands of events. You need to ensure the event you receive belongs to the **current workflow instance**.
|
|
40
|
+
|
|
41
|
+
The `correlate` strategy allows you to provide a function that matches event payloads to the workflow context.
|
|
42
|
+
```typescript
|
|
43
|
+
when: {
|
|
44
|
+
events: ["order.shipped"],
|
|
45
|
+
strategy: {
|
|
46
|
+
type: "correlate",
|
|
47
|
+
correlation: (events) =>
|
|
48
|
+
events[0].payload.orderId === ctx.orderId,
|
|
49
|
+
},
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## 📡 Emitting Events
|
|
56
|
+
|
|
57
|
+
Events can be emitted from anywhere in your application—an API endpoint, a webhook handler, or even another GraphFlow.
|
|
58
|
+
|
|
59
|
+
```typescript
|
|
60
|
+
// Trigger a waiting node in a specific workflow instance
|
|
61
|
+
await workflow.emit("payment.received", {
|
|
62
|
+
orderId: "order_123",
|
|
63
|
+
amount: 49.99,
|
|
64
|
+
timestamp: Date.now(),
|
|
65
|
+
});
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
## ⏱️ Timeouts & Resilience
|
|
71
|
+
|
|
72
|
+
What happens if the event never arrives? To prevent "zombie" workflows, you can define a `timeout`.
|
|
73
|
+
|
|
74
|
+
```typescript
|
|
75
|
+
when: {
|
|
76
|
+
events: ["user.approval"],
|
|
77
|
+
timeout: 3600000, // 1 hour
|
|
78
|
+
strategy: { type: "single" },
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
If the timeout is reached, the workflow can either:
|
|
82
|
+
1. Throw a timeout error.
|
|
83
|
+
2. Move to a fallback node (via the `next` logic).
|
|
84
|
+
|
|
85
|
+
## 📈 Use Case: The "Human-in-the-Loop" Pattern
|
|
86
|
+
|
|
87
|
+
Event-driven nodes are the foundation of **Human-in-the-Loop (HITL)**.
|
|
88
|
+
|
|
89
|
+
1. **Workflow reaches a sensitive node** (e.g., `execute_large_transfer`).
|
|
90
|
+
2. **Workflow pauses** using a `when` node waiting for `admin.approved`.
|
|
91
|
+
3. **Admin receives an email** with a link.
|
|
92
|
+
4. **Admin clicks "Approve"**, which triggers an API call to `workflow.emit("admin.approved", { ... })`.
|
|
93
|
+
5. **Workflow resumes** and completes the transfer.
|
|
94
|
+
|
|
95
|
+
This turns a risky autonomous action into a secure, audited business process.
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# Module Agenda
|
|
2
|
+
|
|
3
|
+
Planification de tâches récurrentes avec expressions cron. L'agenda s'exécute en processus — quand le cron correspond, votre fonction de tâche s'exécute.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Le module est inclus dans le package principal:
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
import { Agenda } from "@ai.ntellect/core";
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Utilisation de base
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import { Agenda, NodeCronAdapter } from "@ai.ntellect/core";
|
|
17
|
+
|
|
18
|
+
const agenda = new Agenda(new NodeCronAdapter());
|
|
19
|
+
|
|
20
|
+
// Toutes les heures
|
|
21
|
+
agenda.schedule("0 * * * *", async () => {
|
|
22
|
+
console.log("Tâche horaire en cours");
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
// Tâche nommée pour annulation
|
|
26
|
+
agenda.schedule("daily_cleanup", "0 0 * * *", async () => {
|
|
27
|
+
console.log("Nettoyage quotidien");
|
|
28
|
+
});
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Syntaxe cron
|
|
32
|
+
|
|
33
|
+
Utilise `node-cron` en arrière-plan. La syntaxe suit les conventions cron standard:
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
* * * * * *
|
|
37
|
+
│ │ │ │ │ │
|
|
38
|
+
│ │ │ │ │ └── Jour de la semaine (0-7, 0 et 7 = dimanche)
|
|
39
|
+
│ │ │ │ └──── Mois (1-12)
|
|
40
|
+
│ │ │ └────── Jour du mois (1-31)
|
|
41
|
+
│ │ └──────── Heure (0-23)
|
|
42
|
+
│ └────────── Minute (0-59)
|
|
43
|
+
└──────────── Seconde (0-59, optionnel)
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## API
|
|
47
|
+
|
|
48
|
+
- `schedule(cronExpression: string, task: Function): void`
|
|
49
|
+
- `schedule(name: string, cronExpression: string, task: Function): void`
|
|
50
|
+
- `cancel(name: string): void`
|
|
51
|
+
|
|
52
|
+
## Intégration avec l'Agent
|
|
53
|
+
|
|
54
|
+
L'agent peut utiliser l'agenda pour planifier des réveils:
|
|
55
|
+
|
|
56
|
+
```typescript
|
|
57
|
+
const agent = new Agent({
|
|
58
|
+
role: "Assistant",
|
|
59
|
+
enableSchedule: true,
|
|
60
|
+
agenda: agenda,
|
|
61
|
+
// ...
|
|
62
|
+
});
|
|
63
|
+
```
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: >-
|
|
3
|
+
L’interface IAgenda définit les fonctionnalités essentielles pour planifier,
|
|
4
|
+
exécuter et gérer des tâches dans un système de workflows automatisés.
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Interface IAgenda
|
|
8
|
+
|
|
9
|
+
L’interface **IAgenda** définit les fonctionnalités essentielles pour **planifier, exécuter et gérer des tâches** dans un système automatisé.
|
|
10
|
+
|
|
11
|
+
Ce module suit une approche **agnostique du moteur**, permettant une intégration avec **différents services de planification** (**Node-Cron, Redis, AWS EventBridge**) ainsi qu’un **stockage persistant des tâches** via **IMemoryAdapter**.
|
|
12
|
+
|
|
13
|
+
***
|
|
14
|
+
|
|
15
|
+
### **Objectif de l'interface**
|
|
16
|
+
|
|
17
|
+
L'interface **IAgenda** doit permettre :
|
|
18
|
+
|
|
19
|
+
* **Planification dynamique** de tâches périodiques ou ponctuelles.
|
|
20
|
+
* **Stockage et récupération** des tâches planifiées via **IMemoryAdapter**.
|
|
21
|
+
* **Gestion complète du cycle de vie** des tâches (**création, exécution, annulation**).
|
|
22
|
+
* **Intégration avec un moteur de planification configurable** (**ICronService**).
|
|
23
|
+
* **Persistance des tâches après redémarrage** via un stockage mémoire.
|
|
24
|
+
* **Interopérabilité avec plusieurs moteurs de planification** (local, distribué, cloud).
|
|
25
|
+
|
|
26
|
+
***
|
|
27
|
+
|
|
28
|
+
### **Définition de l’interface**
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
/**
|
|
32
|
+
* Interface pour la gestion des tâches planifiées
|
|
33
|
+
*/
|
|
34
|
+
export interface IAgenda {
|
|
35
|
+
/**
|
|
36
|
+
* Planifie une tâche à exécuter périodiquement ou une seule fois.
|
|
37
|
+
* @param {ScheduledTaskInput} request - Configuration de la tâche à planifier.
|
|
38
|
+
* @param {ScheduledTaskCallbacks} [callbacks] - Callbacks pour suivre l’exécution.
|
|
39
|
+
* @returns {Promise<string>} ID unique de la tâche planifiée.
|
|
40
|
+
*/
|
|
41
|
+
scheduleTask(
|
|
42
|
+
request: ScheduledTaskInput,
|
|
43
|
+
callbacks?: ScheduledTaskCallbacks
|
|
44
|
+
): Promise<string>;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Annule une tâche planifiée en fonction de son ID.
|
|
48
|
+
* @param {string} taskId - ID de la tâche à annuler.
|
|
49
|
+
* @returns {Promise<boolean>} `true` si la tâche a été annulée, sinon `false`.
|
|
50
|
+
*/
|
|
51
|
+
cancelTask(taskId: string): Promise<boolean>;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Récupère toutes les tâches planifiées stockées en mémoire.
|
|
55
|
+
* @returns {Promise<ScheduledTask[]>} Liste des tâches stockées.
|
|
56
|
+
*/
|
|
57
|
+
getScheduledTasks(): Promise<ScheduledTask[]>;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Annule toutes les tâches planifiées.
|
|
61
|
+
* @returns {Promise<void>}
|
|
62
|
+
*/
|
|
63
|
+
cancelAllTasks(): Promise<void>;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Arrête l’ensemble des tâches et libère les ressources.
|
|
67
|
+
* @returns {Promise<void>}
|
|
68
|
+
*/
|
|
69
|
+
shutdown(): Promise<void>;
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
***
|
|
74
|
+
|
|
75
|
+
### **Interfaces associées**
|
|
76
|
+
|
|
77
|
+
#### **ScheduledTaskInput : Définition d’une tâche planifiée**
|
|
78
|
+
|
|
79
|
+
```ts
|
|
80
|
+
/**
|
|
81
|
+
* Configuration d'une tâche planifiée
|
|
82
|
+
*/
|
|
83
|
+
export interface ScheduledTaskInput {
|
|
84
|
+
/** ID unique de la tâche (optionnel) */
|
|
85
|
+
id?: string;
|
|
86
|
+
/** Requête ou action à exécuter */
|
|
87
|
+
originalRequest: string;
|
|
88
|
+
/** Expression `cron` définissant la récurrence */
|
|
89
|
+
cronExpression: string;
|
|
90
|
+
/** Indique si la tâche est récurrente */
|
|
91
|
+
isRecurring?: boolean;
|
|
92
|
+
/** Date de début d’exécution (optionnel) */
|
|
93
|
+
startDate?: Date;
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
***
|
|
98
|
+
|
|
99
|
+
#### **ScheduledTask : Représentation d’une tâche active**
|
|
100
|
+
|
|
101
|
+
```ts
|
|
102
|
+
/**
|
|
103
|
+
* Représentation d'une tâche planifiée
|
|
104
|
+
*/
|
|
105
|
+
export interface ScheduledTask extends ScheduledTaskInput {
|
|
106
|
+
/** ID unique attribué à la tâche */
|
|
107
|
+
id: string;
|
|
108
|
+
/** Date de création de la tâche */
|
|
109
|
+
createdAt: Date;
|
|
110
|
+
}
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
***
|
|
114
|
+
|
|
115
|
+
#### **ScheduledTaskCallbacks : Suivi de l’exécution**
|
|
116
|
+
|
|
117
|
+
```ts
|
|
118
|
+
/**
|
|
119
|
+
* Callbacks pour suivre l'exécution d'une tâche planifiée
|
|
120
|
+
*/
|
|
121
|
+
export interface ScheduledTaskCallbacks {
|
|
122
|
+
/** Appelé lorsque la tâche est planifiée */
|
|
123
|
+
onScheduled?: (id: string) => void;
|
|
124
|
+
/** Appelé lorsque la tâche est exécutée */
|
|
125
|
+
onExecuted?: (id: string, originalRequest: string) => void;
|
|
126
|
+
}
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
***
|
|
130
|
+
|
|
131
|
+
### **Pourquoi cette interface ?**
|
|
132
|
+
|
|
133
|
+
L’interface **IAgenda** offre plusieurs avantages en termes de conception et d’extensibilité :
|
|
134
|
+
|
|
135
|
+
#### **Indépendance du moteur de planification**
|
|
136
|
+
|
|
137
|
+
* Compatible avec **Node-Cron, Redis, AWS EventBridge**, et d’autres solutions.
|
|
138
|
+
* Séparation claire entre **la logique métier** et **le moteur de tâches**.
|
|
139
|
+
|
|
140
|
+
#### **Persistance des tâches**
|
|
141
|
+
|
|
142
|
+
* Intégration avec **IMemoryAdapter** pour **stocker les tâches planifiées** même après un redémarrage.
|
|
143
|
+
* Permet une **synchronisation avec des bases de données** (**Redis, Meilisearch, SQLite, etc.**).
|
|
144
|
+
|
|
145
|
+
#### **Gestion avancée du cycle de vie**
|
|
146
|
+
|
|
147
|
+
* **Annulation, exécution immédiate, reprogrammation dynamique**.
|
|
148
|
+
* Suivi des exécutions via des **callbacks événementiels**.
|
|
149
|
+
|
|
150
|
+
***
|
|
151
|
+
|
|
152
|
+
### **Cas d’usage**
|
|
153
|
+
|
|
154
|
+
L’interface **IAgenda** est conçue pour gérer **la planification automatique des tâches**, avec des cas d’usage variés :
|
|
155
|
+
|
|
156
|
+
#### **Tâches périodiques et planification automatique**
|
|
157
|
+
|
|
158
|
+
* Exécution de **mises à jour programmées** toutes les nuits.
|
|
159
|
+
* **Relances automatiques** en cas d’échec.
|
|
160
|
+
|
|
161
|
+
#### **Orchestration de workflows distribués**
|
|
162
|
+
|
|
163
|
+
* Utilisation d’un **adaptateur Redis** pour **synchroniser plusieurs agents**.
|
|
164
|
+
* Planification de tâches sur **AWS EventBridge** pour **déclencher des workflows serverless**.
|
|
165
|
+
|
|
166
|
+
#### **Persistance et reprise après redémarrage**
|
|
167
|
+
|
|
168
|
+
* **Sauvegarde des tâches planifiées** dans **Meilisearch ou Redis**.
|
|
169
|
+
* Reprise automatique après un **redémarrage du système**.
|
|
170
|
+
|