@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,44 @@
|
|
|
1
|
+
# Module NLP
|
|
2
|
+
|
|
3
|
+
Le module NLP enveloppe `@nlpjs/basic` comme nœuds de graphe pour le traitement du langage naturel.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Le module est inclus dans le package principal:
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
import { NLPEngine } from "@ai.ntellect/core";
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Utilisation de base
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import { NLPEngine } from "@ai.ntellect/core";
|
|
17
|
+
|
|
18
|
+
const nlp = new NLPEngine();
|
|
19
|
+
|
|
20
|
+
// Entraîner le moteur
|
|
21
|
+
await nlp.train([
|
|
22
|
+
{ intent: "greeting", utterances: ["hello", "hi", "hey"], answer: "Hello! How can I help?" },
|
|
23
|
+
{ intent: "goodbye", utterances: ["bye", "see you"], answer: "Goodbye!" },
|
|
24
|
+
]);
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Utilisation comme nœud de graphe
|
|
28
|
+
|
|
29
|
+
```typescript
|
|
30
|
+
{
|
|
31
|
+
name: "process_input",
|
|
32
|
+
execute: async (ctx) => {
|
|
33
|
+
const result = await nlp.process(ctx.userInput);
|
|
34
|
+
ctx.intent = result.intent;
|
|
35
|
+
ctx.answer = result.answer;
|
|
36
|
+
},
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Cas d'usage
|
|
41
|
+
|
|
42
|
+
- **Chatbots** — Détection d'intention sur les entrées utilisateur
|
|
43
|
+
- **Classification** — Catégoriser du texte
|
|
44
|
+
- **Réponses automatiques** — Réponses basées sur des règles simples
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# The Philosophy of Deterministic Control
|
|
2
|
+
|
|
3
|
+
In the current AI landscape, there is a fundamental tension between **autonomy** and **reliability**.
|
|
4
|
+
|
|
5
|
+
## The Problem: The "LLM-as-Brain" Fallacy
|
|
6
|
+
|
|
7
|
+
Most modern agent frameworks are built on the assumption that the LLM should act as the central controller. In this model, the LLM:
|
|
8
|
+
1. Analyzes the state.
|
|
9
|
+
2. Decides which tool to call.
|
|
10
|
+
3. Evaluates the result.
|
|
11
|
+
4. Decides the next step.
|
|
12
|
+
|
|
13
|
+
This is "Autonomous Reasoning." It works beautifully in demos, but it fails in production. Why? Because **probabilistic models are fundamentally unsuitable for control flow.**
|
|
14
|
+
|
|
15
|
+
When an LLM manages routing, you introduce **non-deterministic drift**. A slight change in prompt or a random seed shift can lead the agent to skip a critical validation step or enter an infinite loop.
|
|
16
|
+
|
|
17
|
+
## Our Solution: The Classifier-Controller Split
|
|
18
|
+
|
|
19
|
+
We believe that for an AI agent to be production-ready, it must be **verifiable**. To achieve this, `@ai.ntellect/core` implements a strict separation of concerns:
|
|
20
|
+
|
|
21
|
+
### 1. The LLM as the Classifier (The "What")
|
|
22
|
+
We use the LLM for what it is best at: **high-dimensional pattern matching**.
|
|
23
|
+
Instead of asking the LLM "What should I do next?", we ask "Which known intent does this user request match?". The LLM provides a classification, not a command.
|
|
24
|
+
|
|
25
|
+
### 2. The System as the Controller (The "How")
|
|
26
|
+
Once the intent is identified, the LLM is removed from the routing logic. The flow is handed over to a **verified Petri Net**.
|
|
27
|
+
The Petri Net defines the legal transitions of the system. It doesn't "guess" the next step; it executes a mathematically proven path.
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## The Three Pillars of Our Approach
|
|
32
|
+
|
|
33
|
+
### 🛡️ Determinism over Autonomy
|
|
34
|
+
We prioritize **predictability** over "magic." We believe that a developer should be able to look at a graph and know exactly how the system will behave, regardless of the LLM's temperature.
|
|
35
|
+
|
|
36
|
+
### 🔍 Verifiability over Trust
|
|
37
|
+
"Trusting" an LLM to follow instructions is a risk. **Verifying** a Petri Net for deadlocks or reachability is a guarantee. By using formal methods, we move from "It usually works" to "It is mathematically impossible for this to deadlock."
|
|
38
|
+
|
|
39
|
+
### 🏗️ Transparency over Opacity
|
|
40
|
+
We reject "Black Box" orchestration. Every transition, every state change, and every checkpoint in `@ai.ntellect/core` is observable and traceable. You don't debug a prompt; you debug a state machine.
|
|
41
|
+
|
|
42
|
+
## Alignment with d/acc (Defensive Accelerationism)
|
|
43
|
+
|
|
44
|
+
This technical philosophy is a practical application of **Defensive Accelerationism**. We accelerate the capabilities of AI, but we do so by building **defensive infrastructures**.
|
|
45
|
+
|
|
46
|
+
By wrapping probabilistic AI in deterministic controllers, we create systems that are:
|
|
47
|
+
- **Resilient**: They don't break when the LLM hallucinates.
|
|
48
|
+
- **Sovereign**: The developer, not the model provider, maintains total control over the logic.
|
|
49
|
+
- **Transparent**: The execution path is a visible graph, not a hidden chain of thought.
|
|
50
|
+
|
|
51
|
+
**We don't want agents that "try their best." We want agents that execute precisely.**
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: >-
|
|
3
|
+
Ajoutez des conditions pour orienter l'exécution en fonction des données du
|
|
4
|
+
contexte. Créez des branches conditionnelles pour adapter le parcours.
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Ajouter des conditions
|
|
8
|
+
|
|
9
|
+
Dans ce tutoriel, nous allons apprendre **comment prendre des décisions dynamiques** dans un **GraphFlow**. Nous allons modifier notre graphe pour **choisir un chemin d'exécution** en fonction des données du contexte.
|
|
10
|
+
|
|
11
|
+
Cela permet de :
|
|
12
|
+
|
|
13
|
+
* **Modifier le flux d'exécution** en fonction des entrées.
|
|
14
|
+
* **Créer des branches conditionnelles** (ex : Si `x > 10`, alors `A`, sinon `B`).
|
|
15
|
+
* **Améliorer la flexibilité du graphe** en lui permettant de s'adapter aux données.
|
|
16
|
+
|
|
17
|
+
***
|
|
18
|
+
|
|
19
|
+
### **Ajouter des conditions à un graphe**
|
|
20
|
+
|
|
21
|
+
Nous allons **ajouter une logique conditionnelle** qui :
|
|
22
|
+
|
|
23
|
+
1. **Convert text to uppercase**.
|
|
24
|
+
2. **Check text length**.
|
|
25
|
+
3. **If text length > 10**, mark as **"LONG"**.
|
|
26
|
+
4. **Else**, mark as **"SHORT"**.
|
|
27
|
+
|
|
28
|
+
Nous utiliserons **une fonction `next` dynamique** qui **choisit** la prochaine étape en fonction des données.
|
|
29
|
+
|
|
30
|
+
***
|
|
31
|
+
|
|
32
|
+
### **Implémentation du graphe avec logique conditionnelle**
|
|
33
|
+
|
|
34
|
+
Nous allons modifier **notre précédent GraphFlow** pour ajouter **deux branches conditionnelles**.
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
import { GraphFlow, GraphNodeConfig } from "@ai.ntellect/core";
|
|
38
|
+
import { z } from "zod";
|
|
39
|
+
|
|
40
|
+
// Définition du schéma du contexte
|
|
41
|
+
const schema = z.object({
|
|
42
|
+
input: z.string(),
|
|
43
|
+
processed: z.string().optional(),
|
|
44
|
+
result: z.string().optional(),
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
// Node 1: Convert text to uppercase
|
|
48
|
+
const processText: GraphNodeConfig<typeof schema> = {
|
|
49
|
+
name: "processText",
|
|
50
|
+
execute: async (context) => {
|
|
51
|
+
context.processed = context.input.toUpperCase();
|
|
52
|
+
console.log("Text transformed:", context.processed);
|
|
53
|
+
},
|
|
54
|
+
next: (context) => {
|
|
55
|
+
return (context.processed?.length ?? 0) > 10
|
|
56
|
+
? ["longTextHandler"]
|
|
57
|
+
: ["shortTextHandler"];
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
// Node 2A: Handle long text
|
|
62
|
+
const longTextHandler: GraphNodeConfig<typeof schema> = {
|
|
63
|
+
name: "longTextHandler",
|
|
64
|
+
execute: async (context) => {
|
|
65
|
+
context.result = `LONG: ${context.processed}`;
|
|
66
|
+
console.log("Long text:", context.result);
|
|
67
|
+
},
|
|
68
|
+
next: ["logResult"],
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
// Node 2B: Handle short text
|
|
72
|
+
const shortTextHandler: GraphNodeConfig<typeof schema> = {
|
|
73
|
+
name: "shortTextHandler",
|
|
74
|
+
execute: async (context) => {
|
|
75
|
+
context.result = `COURT: ${context.processed}`;
|
|
76
|
+
console.log("Short text:", context.result);
|
|
77
|
+
},
|
|
78
|
+
next: ["logResult"],
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
// Final node: Display result
|
|
82
|
+
const logResult: GraphNodeConfig<typeof schema> = {
|
|
83
|
+
name: "logResult",
|
|
84
|
+
execute: async (context) => {
|
|
85
|
+
console.log("Final result:", context.result);
|
|
86
|
+
},
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
// Création du graphe
|
|
90
|
+
const graph = new GraphFlow("GraphWithDecision", {
|
|
91
|
+
name: "GraphWithDecision",
|
|
92
|
+
nodes: [processText, longTextHandler, shortTextHandler, logResult],
|
|
93
|
+
context: { input: "" },
|
|
94
|
+
schema,
|
|
95
|
+
entryNode: "processText",
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
// Exécution du graphe avec différents inputs
|
|
99
|
+
(async () => {
|
|
100
|
+
console.log("Execution with short text");
|
|
101
|
+
// ...
|
|
102
|
+
console.log("Execution with long text");
|
|
103
|
+
await graph.execute("processText", { input: "Hello GraphFlow!" });
|
|
104
|
+
})();
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
***
|
|
108
|
+
|
|
109
|
+
### **Explication du code**
|
|
110
|
+
|
|
111
|
+
#### **Ajout d’un `next` dynamique**
|
|
112
|
+
|
|
113
|
+
```typescript
|
|
114
|
+
next: (context) => {
|
|
115
|
+
return (context.processed?.length ?? 0) > 10
|
|
116
|
+
? ["longTextHandler"]
|
|
117
|
+
: ["shortTextHandler"];
|
|
118
|
+
},
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
* **Si le texte est long** (`> 10 caractères`), on va vers **`longTextHandler`**.
|
|
122
|
+
* **Sinon**, on va vers **`shortTextHandler`**.
|
|
123
|
+
|
|
124
|
+
#### **Affichage du résultat final**
|
|
125
|
+
|
|
126
|
+
* `longTextHandler` marque le texte comme **"LONG"**.
|
|
127
|
+
* `shortTextHandler` marque le texte comme **"SHORT"**.
|
|
128
|
+
* Le `logResult` affiche le **résultat final**.
|
|
129
|
+
|
|
130
|
+
***
|
|
131
|
+
|
|
132
|
+
### **Résultat attendu**
|
|
133
|
+
|
|
134
|
+
#### Cas 1 : **Texte court**
|
|
135
|
+
|
|
136
|
+
```
|
|
137
|
+
Execution with short text
|
|
138
|
+
Text transformed: HELLO
|
|
139
|
+
Short text: COURT: HELLO
|
|
140
|
+
Final result: COURT: HELLO
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
#### Cas 2 : **Long text**
|
|
144
|
+
|
|
145
|
+
```
|
|
146
|
+
Execution with long text
|
|
147
|
+
Text transformed: HELLO GRAPHFLOW!
|
|
148
|
+
Long text: LONG: HELLO GRAPHFLOW!
|
|
149
|
+
Final result: LONG: HELLO GRAPHFLOW!
|
|
150
|
+
```
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
# Branching
|
|
2
|
+
|
|
3
|
+
Le branching permet de créer des chemins d'exécution multiples dans votre graphe, que ce soit par condition, en parallèle, ou via un fan-out dynamique.
|
|
4
|
+
|
|
5
|
+
## Branching conditionnel
|
|
6
|
+
|
|
7
|
+
Utilisez `next` avec une condition pour diriger le flux vers différents nœuds :
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
import { GraphFlow } from "@ai.ntellect/core";
|
|
11
|
+
|
|
12
|
+
const workflow = new GraphFlow({
|
|
13
|
+
name: "order-process",
|
|
14
|
+
context: { amount: 0, status: "" },
|
|
15
|
+
nodes: [
|
|
16
|
+
{
|
|
17
|
+
name: "check_amount",
|
|
18
|
+
execute: async (ctx) => {
|
|
19
|
+
ctx.status = ctx.amount > 1000 ? "high" : "normal";
|
|
20
|
+
},
|
|
21
|
+
next: [
|
|
22
|
+
{ when: (ctx) => ctx.status === "high", to: "manager_approval" },
|
|
23
|
+
{ when: (ctx) => ctx.status === "normal", to: "auto_approve" },
|
|
24
|
+
],
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
name: "manager_approval",
|
|
28
|
+
execute: async (ctx) => { ctx.approved = true; },
|
|
29
|
+
next: "notify",
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
name: "auto_approve",
|
|
33
|
+
execute: async (ctx) => { ctx.approved = true; },
|
|
34
|
+
next: "notify",
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
name: "notify",
|
|
38
|
+
execute: async (ctx) => { console.log("Commande approuvée"); },
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
await workflow.execute("check_amount", { amount: 1500 });
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Parallélisation (Fork-Join)
|
|
47
|
+
|
|
48
|
+
Activez `parallel: { enabled: true }` sur un nœud pour exécuter plusieurs branches simultanément. Utilisez `joinNode` pour spécifier où les branches se rejoignent.
|
|
49
|
+
|
|
50
|
+
```typescript
|
|
51
|
+
const workflow = new GraphFlow({
|
|
52
|
+
name: "parallel-processing",
|
|
53
|
+
context: { results: [], data: "test" },
|
|
54
|
+
nodes: [
|
|
55
|
+
{
|
|
56
|
+
name: "split",
|
|
57
|
+
execute: async (ctx) => { ctx.results = []; },
|
|
58
|
+
parallel: { enabled: true },
|
|
59
|
+
next: [
|
|
60
|
+
{ to: "process_a", branchId: "a" },
|
|
61
|
+
{ to: "process_b", branchId: "b" },
|
|
62
|
+
{ to: "process_c", branchId: "c" },
|
|
63
|
+
],
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
name: "process_a",
|
|
67
|
+
execute: async (ctx) => { ctx.results.push("A"); },
|
|
68
|
+
joinNode: "merge",
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
name: "process_b",
|
|
72
|
+
execute: async (ctx) => { ctx.results.push("B"); },
|
|
73
|
+
joinNode: "merge",
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
name: "process_c",
|
|
77
|
+
execute: async (ctx) => { ctx.results.push("C"); },
|
|
78
|
+
joinNode: "merge",
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
name: "merge",
|
|
82
|
+
execute: async (ctx) => {
|
|
83
|
+
console.log("Résultats:", ctx.results); // ["A", "B", "C"]
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
],
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
await workflow.execute("split");
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Chaque branche reçoit une copie isolée du contexte (`structuredClone`). Les résultats sont fusionnés selon les règles de réduction définies.
|
|
93
|
+
|
|
94
|
+
## Reducers (fusion des résultats)
|
|
95
|
+
|
|
96
|
+
Contrôlez comment les résultats des branches parallèles sont fusionnés avec des reducers :
|
|
97
|
+
|
|
98
|
+
```typescript
|
|
99
|
+
import { Reducers } from "@ai.ntellect/core";
|
|
100
|
+
|
|
101
|
+
{
|
|
102
|
+
name: "split",
|
|
103
|
+
execute: async (ctx) => { ctx.results = []; },
|
|
104
|
+
parallel: { enabled: true },
|
|
105
|
+
reducers: [
|
|
106
|
+
{ key: "results", reducer: Reducers.append }, // concatène les tableaux
|
|
107
|
+
],
|
|
108
|
+
next: [
|
|
109
|
+
{ to: "branch_a", branchId: "a" },
|
|
110
|
+
{ to: "branch_b", branchId: "b" },
|
|
111
|
+
],
|
|
112
|
+
}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
Reducers intégrés :
|
|
116
|
+
- `Reducers.append` — concatène les tableaux
|
|
117
|
+
- `Reducers.deepMerge` — fusion profonde (défaut)
|
|
118
|
+
- `Reducers.lastWins` — garde la dernière valeur
|
|
119
|
+
- `Reducers.sum` — additionne les nombres
|
|
120
|
+
|
|
121
|
+
## Send API (fan-out dynamique)
|
|
122
|
+
|
|
123
|
+
Le `send` API permet de créer dynamiquement des branches au runtime :
|
|
124
|
+
|
|
125
|
+
```typescript
|
|
126
|
+
import { SendAPI } from "@ai.ntellect/core";
|
|
127
|
+
|
|
128
|
+
{
|
|
129
|
+
name: "distribute",
|
|
130
|
+
execute: async (ctx) => { ctx.processed = 0; },
|
|
131
|
+
send: (ctx) => {
|
|
132
|
+
const items = ctx.items || ["a", "b", "c"];
|
|
133
|
+
return SendAPI.map(items, (item, i) => ({
|
|
134
|
+
to: "process_item",
|
|
135
|
+
input: { item, index: i },
|
|
136
|
+
branchId: `item_${i}`,
|
|
137
|
+
}));
|
|
138
|
+
},
|
|
139
|
+
reducers: [
|
|
140
|
+
{ key: "processed", reducer: (acc, val) => acc + val },
|
|
141
|
+
],
|
|
142
|
+
joinNode: "done",
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
name: "process_item",
|
|
146
|
+
execute: async (ctx) => {
|
|
147
|
+
console.log("Traitement:", ctx.item);
|
|
148
|
+
return 1; // sera additionné par le reducer
|
|
149
|
+
},
|
|
150
|
+
joinNode: "done",
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
name: "done",
|
|
154
|
+
execute: async (ctx) => {
|
|
155
|
+
console.log("Total traité:", ctx.processed); // 3
|
|
156
|
+
},
|
|
157
|
+
}
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
## Subgraphs (branches complexes)
|
|
161
|
+
|
|
162
|
+
Une branche peut être un graphe complet enregistré via `SubgraphManager` :
|
|
163
|
+
|
|
164
|
+
```typescript
|
|
165
|
+
import { SubgraphManager } from "@ai.ntellect/core";
|
|
166
|
+
|
|
167
|
+
const subgraph = new GraphFlow({
|
|
168
|
+
name: "subtask",
|
|
169
|
+
context: { result: "" },
|
|
170
|
+
nodes: [{
|
|
171
|
+
name: "run",
|
|
172
|
+
execute: async (ctx) => { ctx.result = "done"; },
|
|
173
|
+
}],
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
const manager = new SubgraphManager();
|
|
177
|
+
manager.register("subtask", subgraph);
|
|
178
|
+
|
|
179
|
+
// Utilisable comme branche parallèle
|
|
180
|
+
{
|
|
181
|
+
name: "run_subgraph",
|
|
182
|
+
execute: async (ctx) => {},
|
|
183
|
+
parallel: { enabled: true },
|
|
184
|
+
next: [{ to: "subtask", subgraph: "subtask" }],
|
|
185
|
+
joinNode: "next",
|
|
186
|
+
}
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
## Cas d'usage
|
|
190
|
+
|
|
191
|
+
- **Validation parallèle** : Vérifier plusieurs conditions simultanément
|
|
192
|
+
- **Pipeline de données** : Traiter des éléments indépendants en parallèle
|
|
193
|
+
- **Fan-out dynamique** : Distribuer du travail selon la taille d'un tableau
|
|
194
|
+
- **Subgraphs** : Décomposer un workflow complexe en composants réutilisables
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# Utiliser les Checkpoints
|
|
2
|
+
|
|
3
|
+
Ce tutoriel vous guide dans l'utilisation du système de checkpoints pour sauvegarder et reprendre des workflows.
|
|
4
|
+
|
|
5
|
+
## Prérequis
|
|
6
|
+
|
|
7
|
+
- Avoir lu [Créer un graphe simple](./creer-un-graphe-simple.md)
|
|
8
|
+
- Comprendre les concepts de base de GraphFlow
|
|
9
|
+
|
|
10
|
+
## Configuration de l'adaptateur
|
|
11
|
+
|
|
12
|
+
```typescript
|
|
13
|
+
import { GraphFlow } from "@ai.ntellect/core";
|
|
14
|
+
import { InMemoryCheckpointAdapter } from "@ai.ntellect/core";
|
|
15
|
+
import { z } from "zod";
|
|
16
|
+
|
|
17
|
+
const Schema = z.object({
|
|
18
|
+
step: z.string(),
|
|
19
|
+
data: z.any().optional(),
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
const adapter = new InMemoryCheckpointAdapter();
|
|
23
|
+
|
|
24
|
+
const workflow = new GraphFlow({
|
|
25
|
+
name: "checkpoint-demo",
|
|
26
|
+
schema: Schema,
|
|
27
|
+
context: { step: "start", data: null },
|
|
28
|
+
nodes: [
|
|
29
|
+
{
|
|
30
|
+
name: "step1",
|
|
31
|
+
execute: async (ctx) => {
|
|
32
|
+
ctx.step = "step1";
|
|
33
|
+
ctx.data = "Data processed - node 1";
|
|
34
|
+
},
|
|
35
|
+
next: ["step2"],
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
name: "step2",
|
|
39
|
+
execute: async (ctx) => {
|
|
40
|
+
ctx.step = "step2";
|
|
41
|
+
ctx.data = "Data processed - node 2";
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
});
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Exécution avec checkpoints
|
|
49
|
+
|
|
50
|
+
```typescript
|
|
51
|
+
// Démarrer l'exécution avec checkpointing
|
|
52
|
+
const runId = await workflow.executeWithCheckpoint("step1", adapter);
|
|
53
|
+
|
|
54
|
+
console.log(workflow.getContext().step); // "step1" ou "step2" selon le timing
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Lister les checkpoints
|
|
58
|
+
|
|
59
|
+
```typescript
|
|
60
|
+
const checkpoints = await workflow.listCheckpoints(adapter);
|
|
61
|
+
console.log(checkpoints);
|
|
62
|
+
// Affiche tous les checkpoints du run
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Reprendre l'exécution
|
|
66
|
+
|
|
67
|
+
```typescript
|
|
68
|
+
// Reprendre depuis le dernier checkpoint
|
|
69
|
+
await workflow.resumeFromCheckpoint(runId, adapter);
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Voyage temporel
|
|
73
|
+
|
|
74
|
+
```typescript
|
|
75
|
+
// Reprendre depuis un checkpoint spécifique avec modification d'état
|
|
76
|
+
const cpId = checkpoints[0].id; // Premier checkpoint
|
|
77
|
+
await workflow.resumeFromCheckpoint(cpId, adapter, {
|
|
78
|
+
contextModifications: { step: "modified", data: "Changed!" },
|
|
79
|
+
});
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Utiliser les breakpoints
|
|
83
|
+
|
|
84
|
+
```typescript
|
|
85
|
+
// Pause automatique avant certains nœuds
|
|
86
|
+
await workflow.executeWithCheckpoint("step1", adapter, {
|
|
87
|
+
breakpoints: ["step2"], // Pause avant step2
|
|
88
|
+
});
|
|
89
|
+
// Le workflow s'arrête avant d'exécuter step2
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Résumé
|
|
93
|
+
|
|
94
|
+
Vous savez maintenant:
|
|
95
|
+
- ✅ Configurer un adaptateur de checkpoint
|
|
96
|
+
- ✅ Exécuter un workflow avec sauvegarde automatique
|
|
97
|
+
- ✅ Lister et reprendre des checkpoints
|
|
98
|
+
- ✅ Faire du voyage temporel avec modification d'état
|
|
99
|
+
- ✅ Utiliser des breakpoints pour pause humaine
|