@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,358 @@
|
|
|
1
|
+
import { PetriNet } from '../routing/index';
|
|
2
|
+
import { CortexFlowOrchestrator } from '../routing/orchestrator';
|
|
3
|
+
import { ToolRegistry } from '../execution/registry';
|
|
4
|
+
import * as fs from 'fs/promises';
|
|
5
|
+
import * as path from 'path';
|
|
6
|
+
|
|
7
|
+
export interface DocumentationOptions {
|
|
8
|
+
outputDir: string;
|
|
9
|
+
format: 'markdown' | 'all'; // all = markdown + mermaid + html
|
|
10
|
+
includeHistory?: boolean;
|
|
11
|
+
includeState?: boolean;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export class PetriDocumentationGenerator {
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Generate living documentation for a Petri net
|
|
18
|
+
*/
|
|
19
|
+
async generateForPetri(
|
|
20
|
+
net: PetriNet,
|
|
21
|
+
options: DocumentationOptions
|
|
22
|
+
): Promise<void> {
|
|
23
|
+
const { outputDir, format } = options;
|
|
24
|
+
await fs.mkdir(outputDir, { recursive: true });
|
|
25
|
+
|
|
26
|
+
// Generate Mermaid diagram
|
|
27
|
+
const mermaid = this.generateMermaid(net);
|
|
28
|
+
await fs.writeFile(
|
|
29
|
+
path.join(outputDir, `${this.sanitizeFilename(net.name)}-diagram.mmd`),
|
|
30
|
+
mermaid
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
// Generate Markdown documentation
|
|
34
|
+
const markdown = this.generateMarkdown(net, mermaid);
|
|
35
|
+
await fs.writeFile(
|
|
36
|
+
path.join(outputDir, `${this.sanitizeFilename(net.name)}.md`),
|
|
37
|
+
markdown
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
// Generate HTML preview if 'all' format
|
|
41
|
+
if (format === 'all') {
|
|
42
|
+
const html = this.generateHTML(net, mermaid);
|
|
43
|
+
await fs.writeFile(
|
|
44
|
+
path.join(outputDir, `${this.sanitizeFilename(net.name)}.html`),
|
|
45
|
+
html
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
console.log(`✅ Documentation generated in ${outputDir}`);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Generate living documentation for an orchestrator session
|
|
54
|
+
*/
|
|
55
|
+
async generateForSession(
|
|
56
|
+
orchestrator: CortexFlowOrchestrator,
|
|
57
|
+
sessionId: string,
|
|
58
|
+
options: DocumentationOptions
|
|
59
|
+
): Promise<void> {
|
|
60
|
+
const { outputDir } = options;
|
|
61
|
+
await fs.mkdir(outputDir, { recursive: true });
|
|
62
|
+
|
|
63
|
+
const net = orchestrator.petri;
|
|
64
|
+
const session = (orchestrator as any).sessions?.get(sessionId);
|
|
65
|
+
|
|
66
|
+
// Current state
|
|
67
|
+
const marking = (net as any).state.marking as Map<string, any[]>;
|
|
68
|
+
const history = (net as any).state.history || [];
|
|
69
|
+
const enabled = net.getEnabledTransitions();
|
|
70
|
+
|
|
71
|
+
// Generate state documentation
|
|
72
|
+
const stateDoc = this.generateStateDoc(net, marking, history, enabled, session);
|
|
73
|
+
await fs.writeFile(
|
|
74
|
+
path.join(outputDir, `session-${sessionId}-state.md`),
|
|
75
|
+
stateDoc
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
// Generate Mermaid with current state highlighted
|
|
79
|
+
const mermaidWithState = this.generateMermaidWithState(net, marking, enabled);
|
|
80
|
+
await fs.writeFile(
|
|
81
|
+
path.join(outputDir, `session-${sessionId}-state.mmd`),
|
|
82
|
+
mermaidWithState
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
// Generate full session report
|
|
86
|
+
const sessionReport = this.generateSessionReport(net, session, history, enabled);
|
|
87
|
+
await fs.writeFile(
|
|
88
|
+
path.join(outputDir, `session-${sessionId}-report.md`),
|
|
89
|
+
sessionReport
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
console.log(`✅ Session documentation generated in ${outputDir}`);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Generate Mermaid diagram for Petri net
|
|
97
|
+
*/
|
|
98
|
+
private generateMermaid(net: PetriNet): string {
|
|
99
|
+
const lines: string[] = ['graph TD'];
|
|
100
|
+
|
|
101
|
+
// Add places
|
|
102
|
+
for (const [id, place] of net.places) {
|
|
103
|
+
const label = `${id}\\n(${place.type})`;
|
|
104
|
+
const shape = place.type === 'initial' ? `((${label}))` :
|
|
105
|
+
place.type === 'final' ? `(((${label})))` :
|
|
106
|
+
`[${label}]`;
|
|
107
|
+
lines.push(` ${id}${shape}`);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// Add transitions
|
|
111
|
+
for (const [id, trans] of net.transitions) {
|
|
112
|
+
const desc = (trans as any).description || id;
|
|
113
|
+
lines.push(` ${id}[/${desc}/]`);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// Add arcs (from transitions to places = output, places to transitions = input)
|
|
117
|
+
for (const [tid, trans] of net.transitions) {
|
|
118
|
+
// Input arcs (place -> transition)
|
|
119
|
+
for (const pid of trans.from) {
|
|
120
|
+
lines.push(` ${pid} -->|${tid}| ${tid}`);
|
|
121
|
+
}
|
|
122
|
+
// Output arcs (transition -> place)
|
|
123
|
+
for (const pid of trans.to) {
|
|
124
|
+
lines.push(` ${tid} -->|${tid}| ${pid}`);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// Add style for initial/final places
|
|
129
|
+
lines.push('');
|
|
130
|
+
lines.push(' style initial fill:#90EE90,stroke:#228B22');
|
|
131
|
+
lines.push(' style final fill:#FFB6C1,stroke:#DC143C');
|
|
132
|
+
|
|
133
|
+
return lines.join('\n');
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Generate Mermaid with current state highlighted
|
|
138
|
+
*/
|
|
139
|
+
private generateMermaidWithState(
|
|
140
|
+
net: PetriNet,
|
|
141
|
+
marking: Map<string, any[]>,
|
|
142
|
+
enabled: string[]
|
|
143
|
+
): string {
|
|
144
|
+
const lines = this.generateMermaid(net).split('\n');
|
|
145
|
+
|
|
146
|
+
// Highlight places with tokens
|
|
147
|
+
for (const [pid, tokens] of marking) {
|
|
148
|
+
if (tokens.length > 0) {
|
|
149
|
+
lines.push(` style ${pid} fill:#FFD700,stroke:#FFA500`);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// Highlight enabled transitions
|
|
154
|
+
for (const tid of enabled) {
|
|
155
|
+
lines.push(` style ${tid} fill:#90EE90,stroke:#228B22`);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
return lines.join('\n');
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Generate Markdown documentation
|
|
163
|
+
*/
|
|
164
|
+
private generateMarkdown(net: PetriNet, mermaid: string): string {
|
|
165
|
+
const lines: string[] = [
|
|
166
|
+
`# Petri Net: ${net.name}`,
|
|
167
|
+
'',
|
|
168
|
+
'## Overview',
|
|
169
|
+
'',
|
|
170
|
+
`- **Name**: ${net.name}`,
|
|
171
|
+
`- **Places**: ${net.places.size}`,
|
|
172
|
+
`- **Transitions**: ${net.transitions.size}`,
|
|
173
|
+
'',
|
|
174
|
+
'## Mermaid Diagram',
|
|
175
|
+
'',
|
|
176
|
+
'```mermaid',
|
|
177
|
+
mermaid,
|
|
178
|
+
'```',
|
|
179
|
+
'',
|
|
180
|
+
'## Places',
|
|
181
|
+
'',
|
|
182
|
+
];
|
|
183
|
+
|
|
184
|
+
for (const [id, place] of net.places) {
|
|
185
|
+
lines.push(`### ${id} (${place.type})`);
|
|
186
|
+
lines.push('');
|
|
187
|
+
lines.push(`- Type: ${place.type}`);
|
|
188
|
+
lines.push('');
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
lines.push('## Transitions');
|
|
192
|
+
lines.push('');
|
|
193
|
+
|
|
194
|
+
for (const [id, trans] of net.transitions) {
|
|
195
|
+
lines.push(`### ${id}`);
|
|
196
|
+
lines.push('');
|
|
197
|
+
lines.push(`- **Description**: ${trans.description || id}`);
|
|
198
|
+
lines.push(`- **From**: ${Array.isArray(trans.from) ? trans.from.join(', ') : trans.from}`);
|
|
199
|
+
lines.push(`- **To**: ${Array.isArray(trans.to) ? trans.to.join(', ') : trans.to}`);
|
|
200
|
+
lines.push('');
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
return lines.join('\n');
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Generate state documentation
|
|
208
|
+
*/
|
|
209
|
+
private generateStateDoc(
|
|
210
|
+
net: PetriNet,
|
|
211
|
+
marking: Map<string, any[]>,
|
|
212
|
+
history: string[],
|
|
213
|
+
enabled: string[],
|
|
214
|
+
session: any
|
|
215
|
+
): string {
|
|
216
|
+
const lines: string[] = [
|
|
217
|
+
`# Session State: ${session?.id || 'unknown'}`,
|
|
218
|
+
'',
|
|
219
|
+
'## Current Marking',
|
|
220
|
+
'',
|
|
221
|
+
];
|
|
222
|
+
|
|
223
|
+
for (const [pid, tokens] of marking) {
|
|
224
|
+
const place = net.places.get(pid);
|
|
225
|
+
lines.push(`- **${pid}** (${place?.type}): ${tokens.length} token(s)`);
|
|
226
|
+
if (tokens.length > 0) {
|
|
227
|
+
tokens.forEach((t, i) => {
|
|
228
|
+
lines.push(` - Token ${i + 1}: ${JSON.stringify(t.data).substring(0, 100)}`);
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
lines.push('');
|
|
234
|
+
lines.push('## Enabled Transitions');
|
|
235
|
+
lines.push('');
|
|
236
|
+
|
|
237
|
+
if (enabled.length === 0) {
|
|
238
|
+
lines.push('*No enabled transitions*');
|
|
239
|
+
} else {
|
|
240
|
+
enabled.forEach(tid => {
|
|
241
|
+
const trans = net.transitions.get(tid);
|
|
242
|
+
lines.push(`- **${tid}**: ${(trans as any)?.description || tid}`);
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
lines.push('');
|
|
247
|
+
lines.push('## Session Context');
|
|
248
|
+
lines.push('');
|
|
249
|
+
if (session?.context) {
|
|
250
|
+
lines.push('```json');
|
|
251
|
+
lines.push(JSON.stringify(session.context, null, 2));
|
|
252
|
+
lines.push('```');
|
|
253
|
+
} else {
|
|
254
|
+
lines.push('*No context*');
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
lines.push('');
|
|
258
|
+
lines.push('## History (last 20)');
|
|
259
|
+
lines.push('');
|
|
260
|
+
history.slice(-20).forEach((h, i) => {
|
|
261
|
+
lines.push(`${history.length - 20 + i + 1}. ${h}`);
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
return lines.join('\n');
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* Generate session report
|
|
269
|
+
*/
|
|
270
|
+
private generateSessionReport(
|
|
271
|
+
net: PetriNet,
|
|
272
|
+
session: any,
|
|
273
|
+
history: string[],
|
|
274
|
+
enabled: string[]
|
|
275
|
+
): string {
|
|
276
|
+
const lines: string[] = [
|
|
277
|
+
`# Session Report: ${session?.id || 'unknown'}`,
|
|
278
|
+
'',
|
|
279
|
+
`Generated: ${new Date().toISOString()}`,
|
|
280
|
+
'',
|
|
281
|
+
'## Summary',
|
|
282
|
+
'',
|
|
283
|
+
`- **Petri Net**: ${net.name}`,
|
|
284
|
+
`- **Session ID**: ${session?.id || 'N/A'}`,
|
|
285
|
+
`- **Total Transitions Fired**: ${history.length}`,
|
|
286
|
+
`- **Enabled Transitions**: ${enabled.length}`,
|
|
287
|
+
'',
|
|
288
|
+
'## Timeline',
|
|
289
|
+
'',
|
|
290
|
+
];
|
|
291
|
+
|
|
292
|
+
history.forEach((h, i) => {
|
|
293
|
+
lines.push(`${i + 1}. ${h}`);
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
lines.push('');
|
|
297
|
+
lines.push('## Final State');
|
|
298
|
+
lines.push('');
|
|
299
|
+
|
|
300
|
+
const marking = (net as any).state.marking as Map<string, any[]>;
|
|
301
|
+
for (const [pid, tokens] of marking) {
|
|
302
|
+
lines.push(`- **${pid}**: ${tokens.length} token(s)`);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
return lines.join('\n');
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* Generate HTML preview
|
|
310
|
+
*/
|
|
311
|
+
private generateHTML(net: PetriNet, mermaid: string): string {
|
|
312
|
+
return `<!DOCTYPE html>
|
|
313
|
+
<html>
|
|
314
|
+
<head>
|
|
315
|
+
<title>Petri Net: ${net.name}</title>
|
|
316
|
+
<script src="https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.min.js"></script>
|
|
317
|
+
<style>
|
|
318
|
+
body { font-family: Arial, sans-serif; margin: 40px; background: #f5f5f5; }
|
|
319
|
+
.container { background: white; padding: 30px; border-radius: 8px; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
|
|
320
|
+
h1 { color: #333; }
|
|
321
|
+
.mermaid { background: white; padding: 20px; border: 1px solid #ddd; border-radius: 4px; }
|
|
322
|
+
pre { background: #f8f8f8; padding: 15px; border-radius: 4px; overflow-x: auto; }
|
|
323
|
+
</style>
|
|
324
|
+
</head>
|
|
325
|
+
<body>
|
|
326
|
+
<div class="container">
|
|
327
|
+
<h1>Petri Net: ${net.name}</h1>
|
|
328
|
+
|
|
329
|
+
<h2>Visualization</h2>
|
|
330
|
+
<div class="mermaid">
|
|
331
|
+
${mermaid}
|
|
332
|
+
</div>
|
|
333
|
+
|
|
334
|
+
<h2>Places</h2>
|
|
335
|
+
<ul>
|
|
336
|
+
${Array.from(net.places.entries()).map(([id, p]) => `<li><strong>${id}</strong> (${p.type})</li>`).join('\n ')}
|
|
337
|
+
</ul>
|
|
338
|
+
|
|
339
|
+
<h2>Transitions</h2>
|
|
340
|
+
<ul>
|
|
341
|
+
${Array.from(net.transitions.entries()).map(([id, t]) => `<li><strong>${id}</strong>: ${t.description || id} | from: ${Array.isArray(t.from) ? t.from.join(', ') : t.from} → to: ${Array.isArray(t.to) ? t.to.join(', ') : t.to}</li>`).join('\n ')}
|
|
342
|
+
</ul>
|
|
343
|
+
</div>
|
|
344
|
+
|
|
345
|
+
<script>
|
|
346
|
+
mermaid.initialize({ startOnLoad: true, theme: 'default' });
|
|
347
|
+
</script>
|
|
348
|
+
</body>
|
|
349
|
+
</html>`;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* Sanitize filename
|
|
354
|
+
*/
|
|
355
|
+
private sanitizeFilename(name: string): string {
|
|
356
|
+
return name.replace(/[^a-zA-Z0-9_-]/g, '_');
|
|
357
|
+
}
|
|
358
|
+
}
|