@ai.ntellect/core 1.0.0 → 1.1.1
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 +363 -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,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AgentContextSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
exports.AgentContextSchema = zod_1.z.object({
|
|
6
|
+
input: zod_1.z.object({
|
|
7
|
+
raw: zod_1.z.string(),
|
|
8
|
+
embedding: zod_1.z.array(zod_1.z.number()).optional(),
|
|
9
|
+
}),
|
|
10
|
+
cwd: zod_1.z.string().optional(),
|
|
11
|
+
actions: zod_1.z.array(zod_1.z.object({
|
|
12
|
+
name: zod_1.z.string(),
|
|
13
|
+
parameters: zod_1.z.array(zod_1.z.object({
|
|
14
|
+
name: zod_1.z.string(),
|
|
15
|
+
value: zod_1.z.any(),
|
|
16
|
+
})),
|
|
17
|
+
isExecuted: zod_1.z.boolean().optional(),
|
|
18
|
+
result: zod_1.z.any().optional(),
|
|
19
|
+
})),
|
|
20
|
+
knowledge: zod_1.z.string().optional(),
|
|
21
|
+
response: zod_1.z.string(),
|
|
22
|
+
executedActions: zod_1.z
|
|
23
|
+
.array(zod_1.z.object({
|
|
24
|
+
name: zod_1.z.string(),
|
|
25
|
+
result: zod_1.z.any(),
|
|
26
|
+
timestamp: zod_1.z.string(),
|
|
27
|
+
}))
|
|
28
|
+
.optional(),
|
|
29
|
+
iteration: zod_1.z.number().optional(),
|
|
30
|
+
progressed: zod_1.z.boolean().optional(),
|
|
31
|
+
messages: zod_1.z
|
|
32
|
+
.array(zod_1.z.object({
|
|
33
|
+
role: zod_1.z.enum(["user", "assistant"]),
|
|
34
|
+
content: zod_1.z.string(),
|
|
35
|
+
}))
|
|
36
|
+
.optional(),
|
|
37
|
+
toolResults: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()).optional(),
|
|
38
|
+
scratchpad: zod_1.z.array(zod_1.z.object({
|
|
39
|
+
turn: zod_1.z.number(),
|
|
40
|
+
thought: zod_1.z.string(),
|
|
41
|
+
action: zod_1.z.string(),
|
|
42
|
+
observation: zod_1.z.string(),
|
|
43
|
+
timestamp: zod_1.z.string(),
|
|
44
|
+
})).optional().default([]),
|
|
45
|
+
memories: zod_1.z.array(zod_1.z.any()).optional().default([]),
|
|
46
|
+
entityState: zod_1.z.object({
|
|
47
|
+
currentTarget: zod_1.z.string().optional(),
|
|
48
|
+
lastEntityType: zod_1.z.string().nullable().optional(),
|
|
49
|
+
pendingResolutions: zod_1.z.array(zod_1.z.any()).optional(),
|
|
50
|
+
resolutionTrace: zod_1.z.array(zod_1.z.any()).optional(),
|
|
51
|
+
explored: zod_1.z.boolean().optional(),
|
|
52
|
+
handles: zod_1.z.record(zod_1.z.string(), zod_1.z.object({ id: zod_1.z.string(), label: zod_1.z.string(), path: zod_1.z.string(), category: zod_1.z.string() })).optional(),
|
|
53
|
+
}).optional(),
|
|
54
|
+
conversationState: zod_1.z.object({
|
|
55
|
+
currentGoal: zod_1.z.string(),
|
|
56
|
+
currentTarget: zod_1.z.string().nullable(),
|
|
57
|
+
lastResolvedEntity: zod_1.z.string().nullable(),
|
|
58
|
+
lastResolvedType: zod_1.z.string().nullable(),
|
|
59
|
+
pendingTask: zod_1.z.string().nullable(),
|
|
60
|
+
turnCount: zod_1.z.number(),
|
|
61
|
+
pendingIntent: zod_1.z.object({
|
|
62
|
+
action: zod_1.z.string().nullable(),
|
|
63
|
+
unresolvedEntity: zod_1.z.string().nullable(),
|
|
64
|
+
originalInput: zod_1.z.string(),
|
|
65
|
+
turn: zod_1.z.number(),
|
|
66
|
+
failed: zod_1.z.boolean(),
|
|
67
|
+
}).nullable(),
|
|
68
|
+
}).optional(),
|
|
69
|
+
explorationBudget: zod_1.z.object({
|
|
70
|
+
maxSteps: zod_1.z.number(),
|
|
71
|
+
maxExplorations: zod_1.z.number(),
|
|
72
|
+
maxToolCalls: zod_1.z.number(),
|
|
73
|
+
stepsUsed: zod_1.z.number(),
|
|
74
|
+
explorationsUsed: zod_1.z.number(),
|
|
75
|
+
toolCallsUsed: zod_1.z.number(),
|
|
76
|
+
}).optional(),
|
|
77
|
+
});
|
|
78
|
+
//# sourceMappingURL=agent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent.js","sourceRoot":"","sources":["../../types/agent.ts"],"names":[],"mappings":";;;AACA,6BAAwB;AA2FX,QAAA,kBAAkB,GAAG,OAAC,CAAC,MAAM,CAAC;IACzC,KAAK,EAAE,OAAC,CAAC,MAAM,CAAC;QACd,GAAG,EAAE,OAAC,CAAC,MAAM,EAAE;QACf,SAAS,EAAE,OAAC,CAAC,KAAK,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;KAC1C,CAAC;IACF,GAAG,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC1B,OAAO,EAAE,OAAC,CAAC,KAAK,CACd,OAAC,CAAC,MAAM,CAAC;QACP,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE;QAChB,UAAU,EAAE,OAAC,CAAC,KAAK,CACjB,OAAC,CAAC,MAAM,CAAC;YACP,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE;YAChB,KAAK,EAAE,OAAC,CAAC,GAAG,EAAE;SACf,CAAC,CACH;QACD,UAAU,EAAE,OAA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CAAC,QAAQ,EAAE;QAClC,SAAS,EAAE,OAAC,CAAC,MAAM,EAAE;QACrB,aAAa,EAAE,OAAC,CAAC,MAAM,CAAC;YACtB,MAAM,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;YAC7B,gBAAgB,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;YACvC,aAAa,EAAE,OAAC,CAAC,MAAM,EAAE;YACzB,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE;YAChB,MAAM,EAAE,OAAC,CAAC,OAAO,EAAE;SACpB,CAAC,CAAC,QAAQ,EAAE;KACd,CAAC,CAAC,QAAQ,EAAE;IACb,iBAAiB,EAAE,OAAC,CAAC,MAAM,CAAC;QAC1B,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE;QACpB,eAAe,EAAE,OAAC,CAAC,MAAM,EAAE;QAC3B,YAAY,EAAE,OAAC,CAAC,MAAM,EAAE;QACxB,SAAS,EAAE,OAAC,CAAC,MAAM,EAAE;QACrB,gBAAgB,EAAE,OAAC,CAAC,MAAM,EAAE;QAC5B,aAAa,EAAE,OAAC,CAAC,MAAM,EAAE;KAC1B,CAAC,CAAC,QAAQ,EAAE;CACd,CAAC,CAAC"}
|
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
import { EventEmitter } from "events";
|
|
2
|
+
import { ZodSchema } from "zod";
|
|
3
|
+
import { IEventEmitter } from "../interfaces";
|
|
4
|
+
/**
|
|
5
|
+
* Represents the input structure for creating a memory entry.
|
|
6
|
+
* @typedef {Object} CreateMemoryInput
|
|
7
|
+
* @property {string} content - The text content to store.
|
|
8
|
+
* @property {string} roomId - The room identifier.
|
|
9
|
+
* @property {string} [id] - Optional stable id.
|
|
10
|
+
* @property {Record<string, any>} [metadata] - Optional metadata.
|
|
11
|
+
* @property {number[]} [embedding] - Optional vector embedding.
|
|
12
|
+
* @property {number} [ttl] - Time-to-live in seconds (optional).
|
|
13
|
+
*/
|
|
14
|
+
export interface CreateMemoryInput {
|
|
15
|
+
id?: string;
|
|
16
|
+
content: string;
|
|
17
|
+
metadata?: Record<string, any>;
|
|
18
|
+
embedding?: number[];
|
|
19
|
+
roomId: string;
|
|
20
|
+
ttl?: number;
|
|
21
|
+
type?: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Represents a stored memory entry.
|
|
25
|
+
* @typedef {Object} BaseMemoryType
|
|
26
|
+
* @property {string} id - Unique identifier of the memory entry.
|
|
27
|
+
* @property {string} content - Stored text content.
|
|
28
|
+
* @property {number[] | null} embedding - Vector representation of the data.
|
|
29
|
+
* @property {string} roomId - The associated room ID.
|
|
30
|
+
* @property {Date} createdAt - Creation date.
|
|
31
|
+
*/
|
|
32
|
+
export interface BaseMemoryType {
|
|
33
|
+
id: string;
|
|
34
|
+
content: string;
|
|
35
|
+
metadata?: Record<string, any>;
|
|
36
|
+
embedding?: number[];
|
|
37
|
+
roomId: string;
|
|
38
|
+
createdAt: Date;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Type for scheduled request entries
|
|
42
|
+
* @typedef {Object} ScheduledRequest
|
|
43
|
+
*/
|
|
44
|
+
export type ScheduledRequest = {
|
|
45
|
+
/** Unique identifier for the scheduled request */
|
|
46
|
+
id: string;
|
|
47
|
+
/** The original request string */
|
|
48
|
+
originalRequest: string;
|
|
49
|
+
/** The cron expression for scheduling */
|
|
50
|
+
cronExpression: string;
|
|
51
|
+
/** Whether the request is recurring */
|
|
52
|
+
isRecurring: boolean;
|
|
53
|
+
/** The creation date */
|
|
54
|
+
createdAt: Date;
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Utility type for extracting schema type from Zod schema
|
|
58
|
+
* @template T - Zod schema type
|
|
59
|
+
*/
|
|
60
|
+
export type SchemaType<T> = T extends ZodSchema<infer U> ? U : never;
|
|
61
|
+
/**
|
|
62
|
+
* Type for graph context based on schema
|
|
63
|
+
* @template T - Schema type
|
|
64
|
+
*/
|
|
65
|
+
export type GraphContext<T extends ZodSchema> = {
|
|
66
|
+
[key: string]: any;
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Configuration for event handling strategies in nodes
|
|
70
|
+
* @typedef {Object} EventStrategy
|
|
71
|
+
* @property {"single" | "all" | "correlate"} type - The type of event handling strategy
|
|
72
|
+
* - single: Waits for any single event from the specified events
|
|
73
|
+
* - all: Waits for all specified events to occur
|
|
74
|
+
* - correlate: Uses a correlation function to match related events
|
|
75
|
+
* @property {(events: any[]) => boolean} [correlation] - Optional correlation function for "correlate" strategy
|
|
76
|
+
*/
|
|
77
|
+
export type EventStrategy = {
|
|
78
|
+
type: "single" | "all" | "correlate";
|
|
79
|
+
correlation?: (events: any[]) => boolean;
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* Configuration for event handling in nodes
|
|
83
|
+
* @typedef {Object} EventConfig
|
|
84
|
+
* @property {string[]} events - Array of event names to wait for
|
|
85
|
+
* @property {number} [timeout] - Optional timeout in milliseconds
|
|
86
|
+
* @property {EventStrategy} strategy - Strategy for handling multiple events
|
|
87
|
+
* @property {(events: any[]) => Promise<void>} [onSuccess] - Optional callback when events are successfully received
|
|
88
|
+
* @property {() => Promise<void>} [onTimeout] - Optional callback when event waiting times out
|
|
89
|
+
* @example
|
|
90
|
+
* ```typescript
|
|
91
|
+
* const eventConfig: EventConfig = {
|
|
92
|
+
* events: ["payment.received", "order.validated"],
|
|
93
|
+
* timeout: 5000,
|
|
94
|
+
* strategy: {
|
|
95
|
+
* type: "correlate",
|
|
96
|
+
* correlation: (events) => events.every(e => e.transactionId === events[0].transactionId)
|
|
97
|
+
* },
|
|
98
|
+
* onSuccess: async (events) => {
|
|
99
|
+
* console.log("Correlated events received:", events);
|
|
100
|
+
* },
|
|
101
|
+
* onTimeout: async () => {
|
|
102
|
+
* console.log("Event waiting timed out");
|
|
103
|
+
* }
|
|
104
|
+
* };
|
|
105
|
+
* ```
|
|
106
|
+
*/
|
|
107
|
+
export type EventConfig = {
|
|
108
|
+
events: string[];
|
|
109
|
+
timeout?: number;
|
|
110
|
+
strategy: EventStrategy;
|
|
111
|
+
onSuccess?: (events: any[]) => Promise<void>;
|
|
112
|
+
onTimeout?: () => Promise<void>;
|
|
113
|
+
};
|
|
114
|
+
/**
|
|
115
|
+
* Represents an event in the graph system
|
|
116
|
+
* @template T - Schema type for context validation
|
|
117
|
+
* @property {string} type - The type/name of the event
|
|
118
|
+
* @property {any} [payload] - Optional payload data
|
|
119
|
+
* @property {number} timestamp - Unix timestamp of when the event occurred
|
|
120
|
+
* @example
|
|
121
|
+
* ```typescript
|
|
122
|
+
* const event: GraphEvent<MySchema> = {
|
|
123
|
+
* type: "payment.received",
|
|
124
|
+
* payload: {
|
|
125
|
+
* transactionId: "tx123",
|
|
126
|
+
* amount: 100,
|
|
127
|
+
* currency: "USD"
|
|
128
|
+
* },
|
|
129
|
+
* timestamp: Date.now()
|
|
130
|
+
* };
|
|
131
|
+
* ```
|
|
132
|
+
*/
|
|
133
|
+
export type GraphEvent<T extends ZodSchema> = {
|
|
134
|
+
type: string;
|
|
135
|
+
payload?: any;
|
|
136
|
+
timestamp: number;
|
|
137
|
+
};
|
|
138
|
+
/**
|
|
139
|
+
* Configuration for waiting on multiple events
|
|
140
|
+
* @template T - Schema type for context validation
|
|
141
|
+
* @property {string[]} events - Array of event names to wait for
|
|
142
|
+
* @property {number} [timeout] - Optional timeout in milliseconds
|
|
143
|
+
* @property {"all" | "any" | "race"} strategy - Strategy for handling multiple events
|
|
144
|
+
* @property {(context: GraphContext<T>) => Promise<void>} [onSuccess] - Optional success callback
|
|
145
|
+
* @example
|
|
146
|
+
* ```typescript
|
|
147
|
+
* const config: WaitForEvents<MySchema> = {
|
|
148
|
+
* events: ["event1", "event2"],
|
|
149
|
+
* timeout: 5000,
|
|
150
|
+
* strategy: "all",
|
|
151
|
+
* onSuccess: async (context) => {
|
|
152
|
+
* console.log("All events received");
|
|
153
|
+
* }
|
|
154
|
+
* };
|
|
155
|
+
* ```
|
|
156
|
+
*/
|
|
157
|
+
export type WaitForEvents<T extends ZodSchema> = {
|
|
158
|
+
events: string[];
|
|
159
|
+
timeout?: number;
|
|
160
|
+
strategy: "all" | "any" | "race";
|
|
161
|
+
onSuccess?: <T extends ZodSchema>(context: GraphContext<T>) => Promise<void>;
|
|
162
|
+
};
|
|
163
|
+
/**
|
|
164
|
+
* Interface representing a node in the graph
|
|
165
|
+
* @interface
|
|
166
|
+
* @template T - Schema type
|
|
167
|
+
* @template P - Parameters type
|
|
168
|
+
*/
|
|
169
|
+
export interface GraphNodeConfig<T extends ZodSchema, P = any> {
|
|
170
|
+
/** Name of the node */
|
|
171
|
+
name: string;
|
|
172
|
+
/** Description of the node */
|
|
173
|
+
description?: string;
|
|
174
|
+
/** Schema for node inputs */
|
|
175
|
+
params?: P extends void ? never : ZodSchema<P>;
|
|
176
|
+
/** Execute function for the node */
|
|
177
|
+
execute: (context: GraphContext<T>, tools?: {
|
|
178
|
+
eventEmitter: IEventEmitter;
|
|
179
|
+
}) => Promise<void>;
|
|
180
|
+
/** Optional condition for node execution */
|
|
181
|
+
condition?: (context: GraphContext<T>, params?: P) => boolean;
|
|
182
|
+
/** Array of next node names or objects with conditions */
|
|
183
|
+
next?: Array<string | {
|
|
184
|
+
node: string;
|
|
185
|
+
condition: (context: GraphContext<T>) => boolean;
|
|
186
|
+
}> | string | ((context: GraphContext<T>) => string[]);
|
|
187
|
+
/** Array of event names that trigger this node */
|
|
188
|
+
events?: string[];
|
|
189
|
+
/** Event handling configuration */
|
|
190
|
+
when?: EventConfig;
|
|
191
|
+
/** Retry configuration */
|
|
192
|
+
retry?: {
|
|
193
|
+
maxAttempts: number;
|
|
194
|
+
delay: number;
|
|
195
|
+
onRetryFailed?: (error: Error, context: GraphContext<T>) => Promise<void>;
|
|
196
|
+
continueOnFailed?: boolean;
|
|
197
|
+
};
|
|
198
|
+
/** Error handler function */
|
|
199
|
+
onError?: (error: Error) => void;
|
|
200
|
+
agent?: string;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Interface for graph definition
|
|
204
|
+
* @interface
|
|
205
|
+
* @template T - Schema type
|
|
206
|
+
*/
|
|
207
|
+
export type GraphConfig<T extends ZodSchema> = {
|
|
208
|
+
/** Name of the graph */
|
|
209
|
+
name: string;
|
|
210
|
+
/** Schema for validation */
|
|
211
|
+
schema: T;
|
|
212
|
+
/** Initial context */
|
|
213
|
+
context: SchemaType<T>;
|
|
214
|
+
/** Array of nodes in the graph */
|
|
215
|
+
nodes: GraphNodeConfig<T, any>[];
|
|
216
|
+
/** Global error handler */
|
|
217
|
+
onError?: (error: Error, context: GraphContext<T>) => void;
|
|
218
|
+
/** Entry node name */
|
|
219
|
+
entryNode?: string;
|
|
220
|
+
/** Event emitter instance */
|
|
221
|
+
eventEmitter?: IEventEmitter | EventEmitter;
|
|
222
|
+
/** Array of events */
|
|
223
|
+
events?: string[];
|
|
224
|
+
};
|
|
225
|
+
/**
|
|
226
|
+
* Type for graph execution result
|
|
227
|
+
* @template T - Schema type
|
|
228
|
+
*/
|
|
229
|
+
export type GraphExecutionResult<T extends ZodSchema> = {
|
|
230
|
+
graphName: string;
|
|
231
|
+
nodeName: string;
|
|
232
|
+
context: GraphContext<T>;
|
|
233
|
+
};
|
|
234
|
+
/**
|
|
235
|
+
* Configuration type for Meilisearch
|
|
236
|
+
* @typedef {Object} MeilisearchConfig
|
|
237
|
+
*/
|
|
238
|
+
export type MeilisearchConfig = {
|
|
239
|
+
/** Meilisearch host URL */
|
|
240
|
+
host: string;
|
|
241
|
+
/** API key for authentication */
|
|
242
|
+
apiKey: string;
|
|
243
|
+
/** Array of searchable attributes */
|
|
244
|
+
searchableAttributes?: string[];
|
|
245
|
+
/** Array of sortable attributes */
|
|
246
|
+
sortableAttributes?: string[];
|
|
247
|
+
};
|
|
248
|
+
/**
|
|
249
|
+
* Settings type for Meilisearch
|
|
250
|
+
* @typedef {Object} MeilisearchSettings
|
|
251
|
+
*/
|
|
252
|
+
export type MeilisearchSettings = {
|
|
253
|
+
/** Array of searchable attributes */
|
|
254
|
+
searchableAttributes?: string[];
|
|
255
|
+
/** Array of sortable attributes */
|
|
256
|
+
sortableAttributes?: string[];
|
|
257
|
+
};
|
|
258
|
+
/**
|
|
259
|
+
* Configuration interface for NLP Engine
|
|
260
|
+
* @interface NLPConfig
|
|
261
|
+
* @property {any} [corpus] - Training corpus data
|
|
262
|
+
* @property {Record<string, any>} [responses] - Response templates
|
|
263
|
+
* @property {Record<string, any>} [entities] - Entity definitions
|
|
264
|
+
* @property {string} [language] - Language code (default: 'en')
|
|
265
|
+
* @property {number} [threshold] - Entity recognition threshold (default: 0.5)
|
|
266
|
+
* @property {string} [path] - Path to save/load model
|
|
267
|
+
*/
|
|
268
|
+
export type NLPConfig = {
|
|
269
|
+
corpus?: any;
|
|
270
|
+
responses?: Record<string, any>;
|
|
271
|
+
entities?: Record<string, any>;
|
|
272
|
+
language?: string;
|
|
273
|
+
threshold?: number;
|
|
274
|
+
path?: string;
|
|
275
|
+
};
|
|
276
|
+
/**
|
|
277
|
+
* Type definition for action handlers
|
|
278
|
+
* @callback ActionHandler
|
|
279
|
+
* @param {any} data - Input data for the action
|
|
280
|
+
* @returns {Promise<any>} Result of the action
|
|
281
|
+
*/
|
|
282
|
+
export type ActionHandler = (data: any) => Promise<any>;
|
|
283
|
+
/**
|
|
284
|
+
* Options for the observer
|
|
285
|
+
* @typedef {Object} ObserverOptions
|
|
286
|
+
* @property {number} [debounce] - Debounce time in milliseconds
|
|
287
|
+
* @property {number} [delay] - Delay time in milliseconds
|
|
288
|
+
* @property {boolean} [stream] - Whether to stream the response
|
|
289
|
+
* @property {(string | number)[]} [properties] - Properties to observe
|
|
290
|
+
*/
|
|
291
|
+
export type ObserverOptions = {
|
|
292
|
+
debounce?: number;
|
|
293
|
+
delay?: number;
|
|
294
|
+
stream?: boolean;
|
|
295
|
+
properties?: (string | number)[];
|
|
296
|
+
onStreamLetter?: (data: {
|
|
297
|
+
letter: string;
|
|
298
|
+
property: string;
|
|
299
|
+
}) => void;
|
|
300
|
+
onStreamComplete?: () => void;
|
|
301
|
+
};
|
|
302
|
+
/**
|
|
303
|
+
* Checkpoint metadata for tracking execution state
|
|
304
|
+
*/
|
|
305
|
+
export type CheckpointMetadata = {
|
|
306
|
+
createdAt: number;
|
|
307
|
+
interrupted?: boolean;
|
|
308
|
+
awaitingApproval?: boolean;
|
|
309
|
+
rejected?: boolean;
|
|
310
|
+
error?: string;
|
|
311
|
+
};
|
|
312
|
+
/**
|
|
313
|
+
* Configuration for checkpoint behavior during execution
|
|
314
|
+
*/
|
|
315
|
+
export type CheckpointConfig = {
|
|
316
|
+
saveEveryNode?: boolean;
|
|
317
|
+
saveOnComplete?: boolean;
|
|
318
|
+
checkpointId?: string;
|
|
319
|
+
breakpoints?: string[];
|
|
320
|
+
runId?: string;
|
|
321
|
+
initialContext?: Record<string, any>;
|
|
322
|
+
};
|
|
323
|
+
/**
|
|
324
|
+
* Result of a human-in-the-loop approval
|
|
325
|
+
*/
|
|
326
|
+
export type ApprovalResult = {
|
|
327
|
+
action: "approved" | "rejected";
|
|
328
|
+
contextModifications?: Record<string, any>;
|
|
329
|
+
};
|
|
330
|
+
/**
|
|
331
|
+
* Represents a saved execution state of a graph
|
|
332
|
+
*/
|
|
333
|
+
export type Checkpoint<T extends ZodSchema = any> = {
|
|
334
|
+
id: string;
|
|
335
|
+
graphName: string;
|
|
336
|
+
runId?: string;
|
|
337
|
+
nodeName: string;
|
|
338
|
+
nextNodes: string[];
|
|
339
|
+
context: Record<string, any>;
|
|
340
|
+
metadata: CheckpointMetadata;
|
|
341
|
+
};
|
|
342
|
+
export type { ParallelConfig, Send, SendFunction, Command, ReducerFunction, StateReducer, WorkerConfig, ParallelNodeConfig, } from "../execution/types.parallel";
|
|
343
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../types/index.ts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OAAO,CAAC;IACxB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACtC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,MAAM,EAAE,UAAU,GAAG,UAAU,CAAC;IAChC,oBAAoB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC5C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,SAAS,GAAG,GAAG,IAAI;IAClD,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC7B,QAAQ,EAAE,kBAAkB,CAAC;CAC9B,CAAC;AAIF,YAAY,EACV,cAAc,EACd,IAAI,EACJ,YAAY,EACZ,OAAO,EACP,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,kBAAkB,GACnB,MAAM,6BAA6B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../types/index.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-action-schema.d.ts","sourceRoot":"","sources":["../../utils/generate-action-schema.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C,eAAO,MAAM,oBAAoB,WAAY,SAAS,CAAC,GAAG,CAAC,EAAE,WAU5D,CAAC;AAGF,eAAO,MAAM,eAAe,WAAY,GAAG,KAAG,MA8B7C,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getSchemaString = exports.generateActionSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const generateActionSchema = (graphs) => {
|
|
6
|
+
return graphs
|
|
7
|
+
.map((graph) => {
|
|
8
|
+
const rootNode = Array.from(graph.nodes.values())[0];
|
|
9
|
+
const schemaStr = rootNode.params
|
|
10
|
+
? (0, exports.getSchemaString)(rootNode.params)
|
|
11
|
+
: "No parameters";
|
|
12
|
+
return `Workflow: ${graph.name}\nParameters: ${schemaStr}`;
|
|
13
|
+
})
|
|
14
|
+
.join("\n\n");
|
|
15
|
+
};
|
|
16
|
+
exports.generateActionSchema = generateActionSchema;
|
|
17
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
18
|
+
const getSchemaString = (schema) => {
|
|
19
|
+
if (schema instanceof zod_1.z.ZodObject) {
|
|
20
|
+
const entries = Object.entries(schema.shape);
|
|
21
|
+
const fields = entries.map(([key, value]) => {
|
|
22
|
+
var _a;
|
|
23
|
+
const description = (_a = value._def) === null || _a === void 0 ? void 0 : _a.description;
|
|
24
|
+
const schemaStr = (0, exports.getSchemaString)(value);
|
|
25
|
+
return description
|
|
26
|
+
? `${key}: ${schemaStr} // ${description}`
|
|
27
|
+
: `${key}: ${schemaStr}`;
|
|
28
|
+
});
|
|
29
|
+
return `z.object({${fields.join(", ")}})`;
|
|
30
|
+
}
|
|
31
|
+
if (schema instanceof zod_1.z.ZodArray) {
|
|
32
|
+
return `z.array(${(0, exports.getSchemaString)(schema.element)})`;
|
|
33
|
+
}
|
|
34
|
+
if (schema instanceof zod_1.z.ZodString) {
|
|
35
|
+
return "z.string()";
|
|
36
|
+
}
|
|
37
|
+
if (schema instanceof zod_1.z.ZodNumber) {
|
|
38
|
+
return "z.number()";
|
|
39
|
+
}
|
|
40
|
+
if (schema instanceof zod_1.z.ZodBoolean) {
|
|
41
|
+
return "z.boolean()";
|
|
42
|
+
}
|
|
43
|
+
return `z.unknown()`;
|
|
44
|
+
};
|
|
45
|
+
exports.getSchemaString = getSchemaString;
|
|
46
|
+
//# sourceMappingURL=generate-action-schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-action-schema.js","sourceRoot":"","sources":["../../utils/generate-action-schema.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAGjB,MAAM,oBAAoB,GAAG,CAAC,MAAwB,EAAE,EAAE;IAC/D,OAAO,MAAM;SACV,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;QACb,MAAM,QAAQ,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QACrD,MAAM,SAAS,GAAG,QAAQ,CAAC,MAAM;YAC/B,CAAC,CAAC,IAAA,uBAAe,EAAC,QAAQ,CAAC,MAAM,CAAC;YAClC,CAAC,CAAC,eAAe,CAAC;QACpB,OAAO,aAAa,KAAK,CAAC,IAAI,iBAAiB,SAAS,EAAE,CAAC;IAC7D,CAAC,CAAC;SACD,IAAI,CAAC,MAAM,CAAC,CAAC;AAClB,CAAC,CAAC;AAVW,QAAA,oBAAoB,wBAU/B;AAEF,8DAA8D;AACvD,MAAM,eAAe,GAAG,CAAC,MAAW,EAAU,EAAE;IACrD,IAAI,MAAM,YAAY,OAAC,CAAC,SAAS,EAAE,CAAC;QAClC,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC7C,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;;YAC1C,MAAM,WAAW,GAAG,MAAC,KAAa,CAAC,IAAI,0CAAE,WAAW,CAAC;YACrD,MAAM,SAAS,GAAG,IAAA,uBAAe,EAAC,KAAK,CAAC,CAAC;YACzC,OAAO,WAAW;gBAChB,CAAC,CAAC,GAAG,GAAG,KAAK,SAAS,OAAO,WAAW,EAAE;gBAC1C,CAAC,CAAC,GAAG,GAAG,KAAK,SAAS,EAAE,CAAC;QAC7B,CAAC,CAAC,CAAC;QACH,OAAO,aAAa,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;IAC5C,CAAC;IAED,IAAI,MAAM,YAAY,OAAC,CAAC,QAAQ,EAAE,CAAC;QACjC,OAAO,WAAW,IAAA,uBAAe,EAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC;IACvD,CAAC;IAED,IAAI,MAAM,YAAY,OAAC,CAAC,SAAS,EAAE,CAAC;QAClC,OAAO,YAAY,CAAC;IACtB,CAAC;IAED,IAAI,MAAM,YAAY,OAAC,CAAC,SAAS,EAAE,CAAC;QAClC,OAAO,YAAY,CAAC;IACtB,CAAC;IAED,IAAI,MAAM,YAAY,OAAC,CAAC,UAAU,EAAE,CAAC;QACnC,OAAO,aAAa,CAAC;IACvB,CAAC;IAED,OAAO,aAAa,CAAC;AACvB,CAAC,CAAC;AA9BW,QAAA,eAAe,mBA8B1B"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
type HeaderValue = string | string[] | undefined;
|
|
2
|
+
export declare class LLMHeaderBuilder {
|
|
3
|
+
private headers;
|
|
4
|
+
private _result;
|
|
5
|
+
constructor();
|
|
6
|
+
addHeader(key: string, value: HeaderValue): LLMHeaderBuilder;
|
|
7
|
+
valueOf(): string;
|
|
8
|
+
toString(): string;
|
|
9
|
+
static create(): LLMHeaderBuilder;
|
|
10
|
+
}
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=header-builder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"header-builder.d.ts","sourceRoot":"","sources":["../../utils/header-builder.ts"],"names":[],"mappings":"AAAA,KAAK,WAAW,GAAG,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC;AAEjD,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,OAAO,CAA2B;IAC1C,OAAO,CAAC,OAAO,CAAS;;IAOxB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,GAAG,gBAAgB;IAiB5D,OAAO,IAAI,MAAM;IAIjB,QAAQ,IAAI,MAAM;IAIlB,MAAM,CAAC,MAAM,IAAI,gBAAgB;CAGlC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LLMHeaderBuilder = void 0;
|
|
4
|
+
class LLMHeaderBuilder {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.headers = new Map();
|
|
7
|
+
this._result = "";
|
|
8
|
+
}
|
|
9
|
+
addHeader(key, value) {
|
|
10
|
+
if (Array.isArray(value)) {
|
|
11
|
+
this.headers.set(key, value.join("\n"));
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
this.headers.set(key, value);
|
|
15
|
+
}
|
|
16
|
+
// Build result immediately
|
|
17
|
+
this._result = Array.from(this.headers.entries())
|
|
18
|
+
.filter(([_, value]) => value !== undefined)
|
|
19
|
+
.map(([key, value]) => `# ${key}: ${value}`)
|
|
20
|
+
.join("\n")
|
|
21
|
+
.trim();
|
|
22
|
+
return this;
|
|
23
|
+
}
|
|
24
|
+
valueOf() {
|
|
25
|
+
return this._result;
|
|
26
|
+
}
|
|
27
|
+
toString() {
|
|
28
|
+
return this._result;
|
|
29
|
+
}
|
|
30
|
+
static create() {
|
|
31
|
+
return new LLMHeaderBuilder();
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.LLMHeaderBuilder = LLMHeaderBuilder;
|
|
35
|
+
//# sourceMappingURL=header-builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"header-builder.js","sourceRoot":"","sources":["../../utils/header-builder.ts"],"names":[],"mappings":";;;AAEA,MAAa,gBAAgB;IAI3B;QACE,IAAI,CAAC,OAAO,GAAG,IAAI,GAAG,EAAE,CAAC;QACzB,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;IACpB,CAAC;IAED,SAAS,CAAC,GAAW,EAAE,KAAkB;QACvC,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YACzB,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAC1C,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QAC/B,CAAC;QAED,2BAA2B;QAC3B,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;aAC9C,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,KAAK,KAAK,SAAS,CAAC;aAC3C,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,KAAK,GAAG,KAAK,KAAK,EAAE,CAAC;aAC3C,IAAI,CAAC,IAAI,CAAC;aACV,IAAI,EAAE,CAAC;QAEV,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO;QACL,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,MAAM,CAAC,MAAM;QACX,OAAO,IAAI,gBAAgB,EAAE,CAAC;IAChC,CAAC;CACF;AArCD,4CAqCC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import pino from 'pino';
|
|
2
|
+
/**
|
|
3
|
+
* Shared Pino logger for the CortexFlow runtime.
|
|
4
|
+
*
|
|
5
|
+
* Pretty-prints in development with `HH:MM:ss Z` timestamps.
|
|
6
|
+
* Use `logger.child({ sessionId, traceId })` inside every session scope so log
|
|
7
|
+
* lines can be correlated across a full orchestration trace.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* import logger from '../utils/logger';
|
|
12
|
+
*
|
|
13
|
+
* const log = logger.child({ sessionId: 'abc', traceId: 'trace_123' });
|
|
14
|
+
* log.info({ intent: 'FETCH_MAILS' }, 'Intent classified');
|
|
15
|
+
* log.warn({ confidence: 0.4 }, 'Low confidence — requesting clarification');
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
declare const logger: pino.Logger<never, boolean>;
|
|
19
|
+
/**
|
|
20
|
+
* Creates a child logger pre-bound with session and trace identifiers.
|
|
21
|
+
*
|
|
22
|
+
* @param sessionId - Stable session ID returned by `CortexFlowOrchestrator.startSession()`.
|
|
23
|
+
* @param traceId - Correlation ID propagated through all token data and log entries.
|
|
24
|
+
*/
|
|
25
|
+
export declare const createLogger: (sessionId?: string, traceId?: string) => pino.Logger<never, boolean>;
|
|
26
|
+
export default logger;
|
|
27
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../utils/logger.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB;;;;;;;;;;;;;;;GAeG;AACH,QAAA,MAAM,MAAM,6BASV,CAAC;AAEH;;;;;GAKG;AACH,eAAO,MAAM,YAAY,eAAgB,MAAM,YAAY,MAAM,gCAEhE,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.createLogger = void 0;
|
|
7
|
+
const pino_1 = __importDefault(require("pino"));
|
|
8
|
+
/**
|
|
9
|
+
* Shared Pino logger for the CortexFlow runtime.
|
|
10
|
+
*
|
|
11
|
+
* Pretty-prints in development with `HH:MM:ss Z` timestamps.
|
|
12
|
+
* Use `logger.child({ sessionId, traceId })` inside every session scope so log
|
|
13
|
+
* lines can be correlated across a full orchestration trace.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* import logger from '../utils/logger';
|
|
18
|
+
*
|
|
19
|
+
* const log = logger.child({ sessionId: 'abc', traceId: 'trace_123' });
|
|
20
|
+
* log.info({ intent: 'FETCH_MAILS' }, 'Intent classified');
|
|
21
|
+
* log.warn({ confidence: 0.4 }, 'Low confidence — requesting clarification');
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
const logger = (0, pino_1.default)({
|
|
25
|
+
transport: {
|
|
26
|
+
target: 'pino-pretty',
|
|
27
|
+
options: {
|
|
28
|
+
colorize: true,
|
|
29
|
+
translateTime: 'HH:MM:ss Z',
|
|
30
|
+
ignore: 'pid,hostname',
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
/**
|
|
35
|
+
* Creates a child logger pre-bound with session and trace identifiers.
|
|
36
|
+
*
|
|
37
|
+
* @param sessionId - Stable session ID returned by `CortexFlowOrchestrator.startSession()`.
|
|
38
|
+
* @param traceId - Correlation ID propagated through all token data and log entries.
|
|
39
|
+
*/
|
|
40
|
+
const createLogger = (sessionId, traceId) => {
|
|
41
|
+
return logger.child({ sessionId, traceId });
|
|
42
|
+
};
|
|
43
|
+
exports.createLogger = createLogger;
|
|
44
|
+
exports.default = logger;
|
|
45
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../utils/logger.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AAExB;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,GAAG,IAAA,cAAI,EAAC;IAClB,SAAS,EAAE;QACT,MAAM,EAAE,aAAa;QACrB,OAAO,EAAE;YACP,QAAQ,EAAE,IAAI;YACd,aAAa,EAAE,YAAY;YAC3B,MAAM,EAAE,cAAc;SACvB;KACF;CACF,CAAC,CAAC;AAEH;;;;;GAKG;AACI,MAAM,YAAY,GAAG,CAAC,SAAkB,EAAE,OAAgB,EAAE,EAAE;IACnE,OAAO,MAAM,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,CAAC;AAC9C,CAAC,CAAC;AAFW,QAAA,YAAY,gBAEvB;AAEF,kBAAe,MAAM,CAAC"}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|