@ninebix/nmt-system 1.0.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/LICENSE +70 -0
- package/README.md +465 -0
- package/dist/api/cli-server.d.ts +83 -0
- package/dist/api/cli-server.d.ts.map +1 -0
- package/dist/api/cli-server.js +597 -0
- package/dist/api/cli-server.js.map +1 -0
- package/dist/api/index.d.ts +6 -0
- package/dist/api/index.d.ts.map +1 -0
- package/dist/api/index.js +6 -0
- package/dist/api/index.js.map +1 -0
- package/dist/api/middleware/index.d.ts +12 -0
- package/dist/api/middleware/index.d.ts.map +1 -0
- package/dist/api/middleware/index.js +13 -0
- package/dist/api/middleware/index.js.map +1 -0
- package/dist/api/middleware/logger.d.ts +21 -0
- package/dist/api/middleware/logger.d.ts.map +1 -0
- package/dist/api/middleware/logger.js +134 -0
- package/dist/api/middleware/logger.js.map +1 -0
- package/dist/api/middleware/rate-limit.d.ts +26 -0
- package/dist/api/middleware/rate-limit.d.ts.map +1 -0
- package/dist/api/middleware/rate-limit.js +107 -0
- package/dist/api/middleware/rate-limit.js.map +1 -0
- package/dist/api/middleware/response.d.ts +61 -0
- package/dist/api/middleware/response.d.ts.map +1 -0
- package/dist/api/middleware/response.js +86 -0
- package/dist/api/middleware/response.js.map +1 -0
- package/dist/api/middleware/validation.d.ts +43 -0
- package/dist/api/middleware/validation.d.ts.map +1 -0
- package/dist/api/middleware/validation.js +257 -0
- package/dist/api/middleware/validation.js.map +1 -0
- package/dist/api/server.d.ts +79 -0
- package/dist/api/server.d.ts.map +1 -0
- package/dist/api/server.js +2011 -0
- package/dist/api/server.js.map +1 -0
- package/dist/bin/nmt.d.ts +9 -0
- package/dist/bin/nmt.d.ts.map +1 -0
- package/dist/bin/nmt.js +1142 -0
- package/dist/bin/nmt.js.map +1 -0
- package/dist/cli/commands/attractor.d.ts +6 -0
- package/dist/cli/commands/attractor.d.ts.map +1 -0
- package/dist/cli/commands/attractor.js +167 -0
- package/dist/cli/commands/attractor.js.map +1 -0
- package/dist/cli/commands/dimension.d.ts +6 -0
- package/dist/cli/commands/dimension.d.ts.map +1 -0
- package/dist/cli/commands/dimension.js +85 -0
- package/dist/cli/commands/dimension.js.map +1 -0
- package/dist/cli/commands/index.d.ts +11 -0
- package/dist/cli/commands/index.d.ts.map +1 -0
- package/dist/cli/commands/index.js +11 -0
- package/dist/cli/commands/index.js.map +1 -0
- package/dist/cli/commands/infer.d.ts +6 -0
- package/dist/cli/commands/infer.d.ts.map +1 -0
- package/dist/cli/commands/infer.js +139 -0
- package/dist/cli/commands/infer.js.map +1 -0
- package/dist/cli/commands/learn.d.ts +6 -0
- package/dist/cli/commands/learn.d.ts.map +1 -0
- package/dist/cli/commands/learn.js +87 -0
- package/dist/cli/commands/learn.js.map +1 -0
- package/dist/cli/commands/orchestrate.d.ts +6 -0
- package/dist/cli/commands/orchestrate.d.ts.map +1 -0
- package/dist/cli/commands/orchestrate.js +279 -0
- package/dist/cli/commands/orchestrate.js.map +1 -0
- package/dist/cli/commands/prob.d.ts +6 -0
- package/dist/cli/commands/prob.d.ts.map +1 -0
- package/dist/cli/commands/prob.js +256 -0
- package/dist/cli/commands/prob.js.map +1 -0
- package/dist/cli/commands/quantum.d.ts +6 -0
- package/dist/cli/commands/quantum.d.ts.map +1 -0
- package/dist/cli/commands/quantum.js +150 -0
- package/dist/cli/commands/quantum.js.map +1 -0
- package/dist/cli/commands/sync.d.ts +65 -0
- package/dist/cli/commands/sync.d.ts.map +1 -0
- package/dist/cli/commands/sync.js +338 -0
- package/dist/cli/commands/sync.js.map +1 -0
- package/dist/cli/index.d.ts +9 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +9 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/probabilistic-commands.d.ts +39 -0
- package/dist/cli/probabilistic-commands.d.ts.map +1 -0
- package/dist/cli/probabilistic-commands.js +112 -0
- package/dist/cli/probabilistic-commands.js.map +1 -0
- package/dist/cli/types.d.ts +69 -0
- package/dist/cli/types.d.ts.map +1 -0
- package/dist/cli/types.js +5 -0
- package/dist/cli/types.js.map +1 -0
- package/dist/cli/utils/formatters.d.ts +51 -0
- package/dist/cli/utils/formatters.d.ts.map +1 -0
- package/dist/cli/utils/formatters.js +79 -0
- package/dist/cli/utils/formatters.js.map +1 -0
- package/dist/cli/utils/helpers.d.ts +21 -0
- package/dist/cli/utils/helpers.d.ts.map +1 -0
- package/dist/cli/utils/helpers.js +51 -0
- package/dist/cli/utils/helpers.js.map +1 -0
- package/dist/cli/utils/index.d.ts +7 -0
- package/dist/cli/utils/index.d.ts.map +1 -0
- package/dist/cli/utils/index.js +13 -0
- package/dist/cli/utils/index.js.map +1 -0
- package/dist/cli/utils/validators.d.ts +162 -0
- package/dist/cli/utils/validators.d.ts.map +1 -0
- package/dist/cli/utils/validators.js +351 -0
- package/dist/cli/utils/validators.js.map +1 -0
- package/dist/core/advanced-embedding.d.ts +154 -0
- package/dist/core/advanced-embedding.d.ts.map +1 -0
- package/dist/core/advanced-embedding.js +367 -0
- package/dist/core/advanced-embedding.js.map +1 -0
- package/dist/core/attractor-model.d.ts +381 -0
- package/dist/core/attractor-model.d.ts.map +1 -0
- package/dist/core/attractor-model.js +821 -0
- package/dist/core/attractor-model.js.map +1 -0
- package/dist/core/bidirectional-inference.d.ts +143 -0
- package/dist/core/bidirectional-inference.d.ts.map +1 -0
- package/dist/core/bidirectional-inference.js +501 -0
- package/dist/core/bidirectional-inference.js.map +1 -0
- package/dist/core/chunk-engine.d.ts +78 -0
- package/dist/core/chunk-engine.d.ts.map +1 -0
- package/dist/core/chunk-engine.js +192 -0
- package/dist/core/chunk-engine.js.map +1 -0
- package/dist/core/dynamic-embedding.d.ts +327 -0
- package/dist/core/dynamic-embedding.d.ts.map +1 -0
- package/dist/core/dynamic-embedding.js +527 -0
- package/dist/core/dynamic-embedding.js.map +1 -0
- package/dist/core/embedding-similarity.d.ts +68 -0
- package/dist/core/embedding-similarity.d.ts.map +1 -0
- package/dist/core/embedding-similarity.js +291 -0
- package/dist/core/embedding-similarity.js.map +1 -0
- package/dist/core/evolution-scheduler.d.ts +101 -0
- package/dist/core/evolution-scheduler.d.ts.map +1 -0
- package/dist/core/evolution-scheduler.js +235 -0
- package/dist/core/evolution-scheduler.js.map +1 -0
- package/dist/core/hierarchical-chunker.d.ts +108 -0
- package/dist/core/hierarchical-chunker.d.ts.map +1 -0
- package/dist/core/hierarchical-chunker.js +296 -0
- package/dist/core/hierarchical-chunker.js.map +1 -0
- package/dist/core/hnsw-index.d.ts +111 -0
- package/dist/core/hnsw-index.d.ts.map +1 -0
- package/dist/core/hnsw-index.js +466 -0
- package/dist/core/hnsw-index.js.map +1 -0
- package/dist/core/index.d.ts +23 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +25 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/language-analyzers.d.ts +124 -0
- package/dist/core/language-analyzers.d.ts.map +1 -0
- package/dist/core/language-analyzers.js +365 -0
- package/dist/core/language-analyzers.js.map +1 -0
- package/dist/core/local-embedding.d.ts +109 -0
- package/dist/core/local-embedding.d.ts.map +1 -0
- package/dist/core/local-embedding.js +222 -0
- package/dist/core/local-embedding.js.map +1 -0
- package/dist/core/merkle-engine.d.ts +263 -0
- package/dist/core/merkle-engine.d.ts.map +1 -0
- package/dist/core/merkle-engine.js +528 -0
- package/dist/core/merkle-engine.js.map +1 -0
- package/dist/core/multi-layer-reasoning.d.ts +178 -0
- package/dist/core/multi-layer-reasoning.d.ts.map +1 -0
- package/dist/core/multi-layer-reasoning.js +607 -0
- package/dist/core/multi-layer-reasoning.js.map +1 -0
- package/dist/core/neuron-graph.d.ts +134 -0
- package/dist/core/neuron-graph.d.ts.map +1 -0
- package/dist/core/neuron-graph.js +436 -0
- package/dist/core/neuron-graph.js.map +1 -0
- package/dist/core/probabilistic-neuron.d.ts +251 -0
- package/dist/core/probabilistic-neuron.d.ts.map +1 -0
- package/dist/core/probabilistic-neuron.js +618 -0
- package/dist/core/probabilistic-neuron.js.map +1 -0
- package/dist/core/probabilistic-orchestrator.d.ts +408 -0
- package/dist/core/probabilistic-orchestrator.d.ts.map +1 -0
- package/dist/core/probabilistic-orchestrator.js +798 -0
- package/dist/core/probabilistic-orchestrator.js.map +1 -0
- package/dist/core/semantic-chunker.d.ts +117 -0
- package/dist/core/semantic-chunker.d.ts.map +1 -0
- package/dist/core/semantic-chunker.js +464 -0
- package/dist/core/semantic-chunker.js.map +1 -0
- package/dist/events/event-bus.d.ts +166 -0
- package/dist/events/event-bus.d.ts.map +1 -0
- package/dist/events/event-bus.js +228 -0
- package/dist/events/event-bus.js.map +1 -0
- package/dist/events/index.d.ts +7 -0
- package/dist/events/index.d.ts.map +1 -0
- package/dist/events/index.js +7 -0
- package/dist/events/index.js.map +1 -0
- package/dist/events/progress-tracker.d.ts +150 -0
- package/dist/events/progress-tracker.d.ts.map +1 -0
- package/dist/events/progress-tracker.js +290 -0
- package/dist/events/progress-tracker.js.map +1 -0
- package/dist/extensions/clustering/community-detection.d.ts +90 -0
- package/dist/extensions/clustering/community-detection.d.ts.map +1 -0
- package/dist/extensions/clustering/community-detection.js +470 -0
- package/dist/extensions/clustering/community-detection.js.map +1 -0
- package/dist/extensions/clustering/index.d.ts +114 -0
- package/dist/extensions/clustering/index.d.ts.map +1 -0
- package/dist/extensions/clustering/index.js +468 -0
- package/dist/extensions/clustering/index.js.map +1 -0
- package/dist/extensions/clustering/topic-modeling.d.ts +86 -0
- package/dist/extensions/clustering/topic-modeling.d.ts.map +1 -0
- package/dist/extensions/clustering/topic-modeling.js +355 -0
- package/dist/extensions/clustering/topic-modeling.js.map +1 -0
- package/dist/extensions/distributed/coordinator.d.ts +114 -0
- package/dist/extensions/distributed/coordinator.d.ts.map +1 -0
- package/dist/extensions/distributed/coordinator.js +319 -0
- package/dist/extensions/distributed/coordinator.js.map +1 -0
- package/dist/extensions/distributed/index.d.ts +10 -0
- package/dist/extensions/distributed/index.d.ts.map +1 -0
- package/dist/extensions/distributed/index.js +10 -0
- package/dist/extensions/distributed/index.js.map +1 -0
- package/dist/extensions/distributed/queue.d.ts +157 -0
- package/dist/extensions/distributed/queue.d.ts.map +1 -0
- package/dist/extensions/distributed/queue.js +326 -0
- package/dist/extensions/distributed/queue.js.map +1 -0
- package/dist/extensions/distributed/scheduler.d.ts +107 -0
- package/dist/extensions/distributed/scheduler.d.ts.map +1 -0
- package/dist/extensions/distributed/scheduler.js +301 -0
- package/dist/extensions/distributed/scheduler.js.map +1 -0
- package/dist/extensions/distributed/worker.d.ts +112 -0
- package/dist/extensions/distributed/worker.d.ts.map +1 -0
- package/dist/extensions/distributed/worker.js +260 -0
- package/dist/extensions/distributed/worker.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/server.d.ts +43 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +494 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/services/adaptive-fallback.d.ts +140 -0
- package/dist/services/adaptive-fallback.d.ts.map +1 -0
- package/dist/services/adaptive-fallback.js +273 -0
- package/dist/services/adaptive-fallback.js.map +1 -0
- package/dist/services/answer-gate.d.ts +112 -0
- package/dist/services/answer-gate.d.ts.map +1 -0
- package/dist/services/answer-gate.js +299 -0
- package/dist/services/answer-gate.js.map +1 -0
- package/dist/services/auto-learning.d.ts +135 -0
- package/dist/services/auto-learning.d.ts.map +1 -0
- package/dist/services/auto-learning.js +413 -0
- package/dist/services/auto-learning.js.map +1 -0
- package/dist/services/context-compressor.d.ts +77 -0
- package/dist/services/context-compressor.d.ts.map +1 -0
- package/dist/services/context-compressor.js +234 -0
- package/dist/services/context-compressor.js.map +1 -0
- package/dist/services/efficient-rag.d.ts +140 -0
- package/dist/services/efficient-rag.d.ts.map +1 -0
- package/dist/services/efficient-rag.js +311 -0
- package/dist/services/efficient-rag.js.map +1 -0
- package/dist/services/embedding-provider.d.ts +72 -0
- package/dist/services/embedding-provider.d.ts.map +1 -0
- package/dist/services/embedding-provider.js +176 -0
- package/dist/services/embedding-provider.js.map +1 -0
- package/dist/services/file-ingestion.d.ts +72 -0
- package/dist/services/file-ingestion.d.ts.map +1 -0
- package/dist/services/file-ingestion.js +237 -0
- package/dist/services/file-ingestion.js.map +1 -0
- package/dist/services/four-stage-learning.d.ts +552 -0
- package/dist/services/four-stage-learning.d.ts.map +1 -0
- package/dist/services/four-stage-learning.js +1110 -0
- package/dist/services/four-stage-learning.js.map +1 -0
- package/dist/services/graph.d.ts +94 -0
- package/dist/services/graph.d.ts.map +1 -0
- package/dist/services/graph.js +292 -0
- package/dist/services/graph.js.map +1 -0
- package/dist/services/index.d.ts +15 -0
- package/dist/services/index.d.ts.map +1 -0
- package/dist/services/index.js +18 -0
- package/dist/services/index.js.map +1 -0
- package/dist/services/ingestion.d.ts +98 -0
- package/dist/services/ingestion.d.ts.map +1 -0
- package/dist/services/ingestion.js +259 -0
- package/dist/services/ingestion.js.map +1 -0
- package/dist/services/learning.d.ts +67 -0
- package/dist/services/learning.d.ts.map +1 -0
- package/dist/services/learning.js +262 -0
- package/dist/services/learning.js.map +1 -0
- package/dist/services/llm-router.d.ts +143 -0
- package/dist/services/llm-router.d.ts.map +1 -0
- package/dist/services/llm-router.js +284 -0
- package/dist/services/llm-router.js.map +1 -0
- package/dist/services/llm.d.ts +86 -0
- package/dist/services/llm.d.ts.map +1 -0
- package/dist/services/llm.js +283 -0
- package/dist/services/llm.js.map +1 -0
- package/dist/services/metrics-dashboard.d.ts +262 -0
- package/dist/services/metrics-dashboard.d.ts.map +1 -0
- package/dist/services/metrics-dashboard.js +417 -0
- package/dist/services/metrics-dashboard.js.map +1 -0
- package/dist/services/neuron-lifecycle.d.ts +137 -0
- package/dist/services/neuron-lifecycle.d.ts.map +1 -0
- package/dist/services/neuron-lifecycle.js +422 -0
- package/dist/services/neuron-lifecycle.js.map +1 -0
- package/dist/services/nmt-pipeline.d.ts +219 -0
- package/dist/services/nmt-pipeline.d.ts.map +1 -0
- package/dist/services/nmt-pipeline.js +449 -0
- package/dist/services/nmt-pipeline.js.map +1 -0
- package/dist/services/query-cache.d.ts +136 -0
- package/dist/services/query-cache.d.ts.map +1 -0
- package/dist/services/query-cache.js +255 -0
- package/dist/services/query-cache.js.map +1 -0
- package/dist/services/query-normalize.d.ts +107 -0
- package/dist/services/query-normalize.d.ts.map +1 -0
- package/dist/services/query-normalize.js +366 -0
- package/dist/services/query-normalize.js.map +1 -0
- package/dist/services/query.d.ts +102 -0
- package/dist/services/query.d.ts.map +1 -0
- package/dist/services/query.js +227 -0
- package/dist/services/query.js.map +1 -0
- package/dist/services/text-embedding.d.ts +183 -0
- package/dist/services/text-embedding.d.ts.map +1 -0
- package/dist/services/text-embedding.js +633 -0
- package/dist/services/text-embedding.js.map +1 -0
- package/dist/services/verification-gate.d.ts +147 -0
- package/dist/services/verification-gate.d.ts.map +1 -0
- package/dist/services/verification-gate.js +344 -0
- package/dist/services/verification-gate.js.map +1 -0
- package/dist/services/verify.d.ts +114 -0
- package/dist/services/verify.d.ts.map +1 -0
- package/dist/services/verify.js +237 -0
- package/dist/services/verify.js.map +1 -0
- package/dist/services/web-search.d.ts +145 -0
- package/dist/services/web-search.d.ts.map +1 -0
- package/dist/services/web-search.js +534 -0
- package/dist/services/web-search.js.map +1 -0
- package/dist/src/api/cli-server.d.ts +83 -0
- package/dist/src/api/cli-server.d.ts.map +1 -0
- package/dist/src/api/cli-server.js +597 -0
- package/dist/src/api/cli-server.js.map +1 -0
- package/dist/src/api/index.d.ts +6 -0
- package/dist/src/api/index.d.ts.map +1 -0
- package/dist/src/api/index.js +6 -0
- package/dist/src/api/index.js.map +1 -0
- package/dist/src/cli/commands/attractor.d.ts +6 -0
- package/dist/src/cli/commands/attractor.d.ts.map +1 -0
- package/dist/src/cli/commands/attractor.js +167 -0
- package/dist/src/cli/commands/attractor.js.map +1 -0
- package/dist/src/cli/commands/dimension.d.ts +6 -0
- package/dist/src/cli/commands/dimension.d.ts.map +1 -0
- package/dist/src/cli/commands/dimension.js +85 -0
- package/dist/src/cli/commands/dimension.js.map +1 -0
- package/dist/src/cli/commands/index.d.ts +11 -0
- package/dist/src/cli/commands/index.d.ts.map +1 -0
- package/dist/src/cli/commands/index.js +11 -0
- package/dist/src/cli/commands/index.js.map +1 -0
- package/dist/src/cli/commands/infer.d.ts +6 -0
- package/dist/src/cli/commands/infer.d.ts.map +1 -0
- package/dist/src/cli/commands/infer.js +139 -0
- package/dist/src/cli/commands/infer.js.map +1 -0
- package/dist/src/cli/commands/learn.d.ts +6 -0
- package/dist/src/cli/commands/learn.d.ts.map +1 -0
- package/dist/src/cli/commands/learn.js +87 -0
- package/dist/src/cli/commands/learn.js.map +1 -0
- package/dist/src/cli/commands/orchestrate.d.ts +6 -0
- package/dist/src/cli/commands/orchestrate.d.ts.map +1 -0
- package/dist/src/cli/commands/orchestrate.js +279 -0
- package/dist/src/cli/commands/orchestrate.js.map +1 -0
- package/dist/src/cli/commands/prob.d.ts +6 -0
- package/dist/src/cli/commands/prob.d.ts.map +1 -0
- package/dist/src/cli/commands/prob.js +256 -0
- package/dist/src/cli/commands/prob.js.map +1 -0
- package/dist/src/cli/commands/sync.d.ts +65 -0
- package/dist/src/cli/commands/sync.d.ts.map +1 -0
- package/dist/src/cli/commands/sync.js +338 -0
- package/dist/src/cli/commands/sync.js.map +1 -0
- package/dist/src/cli/index.d.ts +9 -0
- package/dist/src/cli/index.d.ts.map +1 -0
- package/dist/src/cli/index.js +9 -0
- package/dist/src/cli/index.js.map +1 -0
- package/dist/src/cli/probabilistic-commands.d.ts +39 -0
- package/dist/src/cli/probabilistic-commands.d.ts.map +1 -0
- package/dist/src/cli/probabilistic-commands.js +112 -0
- package/dist/src/cli/probabilistic-commands.js.map +1 -0
- package/dist/src/cli/types.d.ts +69 -0
- package/dist/src/cli/types.d.ts.map +1 -0
- package/dist/src/cli/types.js +5 -0
- package/dist/src/cli/types.js.map +1 -0
- package/dist/src/cli/utils/formatters.d.ts +51 -0
- package/dist/src/cli/utils/formatters.d.ts.map +1 -0
- package/dist/src/cli/utils/formatters.js +79 -0
- package/dist/src/cli/utils/formatters.js.map +1 -0
- package/dist/src/cli/utils/helpers.d.ts +21 -0
- package/dist/src/cli/utils/helpers.d.ts.map +1 -0
- package/dist/src/cli/utils/helpers.js +51 -0
- package/dist/src/cli/utils/helpers.js.map +1 -0
- package/dist/src/cli/utils/index.d.ts +7 -0
- package/dist/src/cli/utils/index.d.ts.map +1 -0
- package/dist/src/cli/utils/index.js +13 -0
- package/dist/src/cli/utils/index.js.map +1 -0
- package/dist/src/cli/utils/validators.d.ts +162 -0
- package/dist/src/cli/utils/validators.d.ts.map +1 -0
- package/dist/src/cli/utils/validators.js +351 -0
- package/dist/src/cli/utils/validators.js.map +1 -0
- package/dist/src/core/attractor-model.d.ts +381 -0
- package/dist/src/core/attractor-model.d.ts.map +1 -0
- package/dist/src/core/attractor-model.js +821 -0
- package/dist/src/core/attractor-model.js.map +1 -0
- package/dist/src/core/bidirectional-inference.d.ts +143 -0
- package/dist/src/core/bidirectional-inference.d.ts.map +1 -0
- package/dist/src/core/bidirectional-inference.js +501 -0
- package/dist/src/core/bidirectional-inference.js.map +1 -0
- package/dist/src/core/chunk-engine.d.ts +78 -0
- package/dist/src/core/chunk-engine.d.ts.map +1 -0
- package/dist/src/core/chunk-engine.js +192 -0
- package/dist/src/core/chunk-engine.js.map +1 -0
- package/dist/src/core/dynamic-embedding.d.ts +327 -0
- package/dist/src/core/dynamic-embedding.d.ts.map +1 -0
- package/dist/src/core/dynamic-embedding.js +527 -0
- package/dist/src/core/dynamic-embedding.js.map +1 -0
- package/dist/src/core/evolution-scheduler.d.ts +101 -0
- package/dist/src/core/evolution-scheduler.d.ts.map +1 -0
- package/dist/src/core/evolution-scheduler.js +235 -0
- package/dist/src/core/evolution-scheduler.js.map +1 -0
- package/dist/src/core/hnsw-index.d.ts +111 -0
- package/dist/src/core/hnsw-index.d.ts.map +1 -0
- package/dist/src/core/hnsw-index.js +466 -0
- package/dist/src/core/hnsw-index.js.map +1 -0
- package/dist/src/core/index.d.ts +23 -0
- package/dist/src/core/index.d.ts.map +1 -0
- package/dist/src/core/index.js +25 -0
- package/dist/src/core/index.js.map +1 -0
- package/dist/src/core/merkle-engine.d.ts +263 -0
- package/dist/src/core/merkle-engine.d.ts.map +1 -0
- package/dist/src/core/merkle-engine.js +528 -0
- package/dist/src/core/merkle-engine.js.map +1 -0
- package/dist/src/core/neuron-graph.d.ts +134 -0
- package/dist/src/core/neuron-graph.d.ts.map +1 -0
- package/dist/src/core/neuron-graph.js +436 -0
- package/dist/src/core/neuron-graph.js.map +1 -0
- package/dist/src/core/probabilistic-neuron.d.ts +251 -0
- package/dist/src/core/probabilistic-neuron.d.ts.map +1 -0
- package/dist/src/core/probabilistic-neuron.js +618 -0
- package/dist/src/core/probabilistic-neuron.js.map +1 -0
- package/dist/src/core/probabilistic-orchestrator.d.ts +408 -0
- package/dist/src/core/probabilistic-orchestrator.d.ts.map +1 -0
- package/dist/src/core/probabilistic-orchestrator.js +798 -0
- package/dist/src/core/probabilistic-orchestrator.js.map +1 -0
- package/dist/src/events/event-bus.d.ts +166 -0
- package/dist/src/events/event-bus.d.ts.map +1 -0
- package/dist/src/events/event-bus.js +228 -0
- package/dist/src/events/event-bus.js.map +1 -0
- package/dist/src/events/index.d.ts +7 -0
- package/dist/src/events/index.d.ts.map +1 -0
- package/dist/src/events/index.js +7 -0
- package/dist/src/events/index.js.map +1 -0
- package/dist/src/events/progress-tracker.d.ts +150 -0
- package/dist/src/events/progress-tracker.d.ts.map +1 -0
- package/dist/src/events/progress-tracker.js +290 -0
- package/dist/src/events/progress-tracker.js.map +1 -0
- package/dist/src/extensions/clustering/index.d.ts +114 -0
- package/dist/src/extensions/clustering/index.d.ts.map +1 -0
- package/dist/src/extensions/clustering/index.js +468 -0
- package/dist/src/extensions/clustering/index.js.map +1 -0
- package/dist/src/index.d.ts +14 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +20 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/mcp/server.d.ts +43 -0
- package/dist/src/mcp/server.d.ts.map +1 -0
- package/dist/src/mcp/server.js +494 -0
- package/dist/src/mcp/server.js.map +1 -0
- package/dist/src/services/embedding-provider.d.ts +72 -0
- package/dist/src/services/embedding-provider.d.ts.map +1 -0
- package/dist/src/services/embedding-provider.js +176 -0
- package/dist/src/services/embedding-provider.js.map +1 -0
- package/dist/src/services/four-stage-learning.d.ts +552 -0
- package/dist/src/services/four-stage-learning.d.ts.map +1 -0
- package/dist/src/services/four-stage-learning.js +1110 -0
- package/dist/src/services/four-stage-learning.js.map +1 -0
- package/dist/src/services/index.d.ts +15 -0
- package/dist/src/services/index.d.ts.map +1 -0
- package/dist/src/services/index.js +18 -0
- package/dist/src/services/index.js.map +1 -0
- package/dist/src/services/ingestion.d.ts +98 -0
- package/dist/src/services/ingestion.d.ts.map +1 -0
- package/dist/src/services/ingestion.js +259 -0
- package/dist/src/services/ingestion.js.map +1 -0
- package/dist/src/services/query.d.ts +102 -0
- package/dist/src/services/query.d.ts.map +1 -0
- package/dist/src/services/query.js +227 -0
- package/dist/src/services/query.js.map +1 -0
- package/dist/src/services/text-embedding.d.ts +183 -0
- package/dist/src/services/text-embedding.d.ts.map +1 -0
- package/dist/src/services/text-embedding.js +633 -0
- package/dist/src/services/text-embedding.js.map +1 -0
- package/dist/src/services/verify.d.ts +114 -0
- package/dist/src/services/verify.d.ts.map +1 -0
- package/dist/src/services/verify.js +237 -0
- package/dist/src/services/verify.js.map +1 -0
- package/dist/src/storage/chunk-store.d.ts +107 -0
- package/dist/src/storage/chunk-store.d.ts.map +1 -0
- package/dist/src/storage/chunk-store.js +293 -0
- package/dist/src/storage/chunk-store.js.map +1 -0
- package/dist/src/storage/index-store.d.ts +126 -0
- package/dist/src/storage/index-store.d.ts.map +1 -0
- package/dist/src/storage/index-store.js +316 -0
- package/dist/src/storage/index-store.js.map +1 -0
- package/dist/src/storage/index.d.ts +45 -0
- package/dist/src/storage/index.d.ts.map +1 -0
- package/dist/src/storage/index.js +52 -0
- package/dist/src/storage/index.js.map +1 -0
- package/dist/src/storage/neuron-store.d.ts +121 -0
- package/dist/src/storage/neuron-store.d.ts.map +1 -0
- package/dist/src/storage/neuron-store.js +466 -0
- package/dist/src/storage/neuron-store.js.map +1 -0
- package/dist/src/storage/probabilistic-store.d.ts +104 -0
- package/dist/src/storage/probabilistic-store.d.ts.map +1 -0
- package/dist/src/storage/probabilistic-store.js +257 -0
- package/dist/src/storage/probabilistic-store.js.map +1 -0
- package/dist/src/sync/change-journal.d.ts +171 -0
- package/dist/src/sync/change-journal.d.ts.map +1 -0
- package/dist/src/sync/change-journal.js +362 -0
- package/dist/src/sync/change-journal.js.map +1 -0
- package/dist/src/sync/index.d.ts +8 -0
- package/dist/src/sync/index.d.ts.map +1 -0
- package/dist/src/sync/index.js +8 -0
- package/dist/src/sync/index.js.map +1 -0
- package/dist/src/sync/state-sync.d.ts +241 -0
- package/dist/src/sync/state-sync.d.ts.map +1 -0
- package/dist/src/sync/state-sync.js +396 -0
- package/dist/src/sync/state-sync.js.map +1 -0
- package/dist/src/sync/vector-clock.d.ts +144 -0
- package/dist/src/sync/vector-clock.d.ts.map +1 -0
- package/dist/src/sync/vector-clock.js +266 -0
- package/dist/src/sync/vector-clock.js.map +1 -0
- package/dist/src/types/index.d.ts +224 -0
- package/dist/src/types/index.d.ts.map +1 -0
- package/dist/src/types/index.js +24 -0
- package/dist/src/types/index.js.map +1 -0
- package/dist/src/utils/hash.d.ts +39 -0
- package/dist/src/utils/hash.d.ts.map +1 -0
- package/dist/src/utils/hash.js +56 -0
- package/dist/src/utils/hash.js.map +1 -0
- package/dist/src/utils/index.d.ts +26 -0
- package/dist/src/utils/index.d.ts.map +1 -0
- package/dist/src/utils/index.js +50 -0
- package/dist/src/utils/index.js.map +1 -0
- package/dist/src/utils/logger.d.ts +88 -0
- package/dist/src/utils/logger.d.ts.map +1 -0
- package/dist/src/utils/logger.js +157 -0
- package/dist/src/utils/logger.js.map +1 -0
- package/dist/src/utils/metrics.d.ts +232 -0
- package/dist/src/utils/metrics.d.ts.map +1 -0
- package/dist/src/utils/metrics.js +387 -0
- package/dist/src/utils/metrics.js.map +1 -0
- package/dist/src/utils/similarity.d.ts +64 -0
- package/dist/src/utils/similarity.d.ts.map +1 -0
- package/dist/src/utils/similarity.js +151 -0
- package/dist/src/utils/similarity.js.map +1 -0
- package/dist/src/utils/uuid.d.ts +23 -0
- package/dist/src/utils/uuid.d.ts.map +1 -0
- package/dist/src/utils/uuid.js +29 -0
- package/dist/src/utils/uuid.js.map +1 -0
- package/dist/storage/chunk-store.d.ts +107 -0
- package/dist/storage/chunk-store.d.ts.map +1 -0
- package/dist/storage/chunk-store.js +293 -0
- package/dist/storage/chunk-store.js.map +1 -0
- package/dist/storage/hybrid-adapters.d.ts +111 -0
- package/dist/storage/hybrid-adapters.d.ts.map +1 -0
- package/dist/storage/hybrid-adapters.js +223 -0
- package/dist/storage/hybrid-adapters.js.map +1 -0
- package/dist/storage/hybrid-store.d.ts +125 -0
- package/dist/storage/hybrid-store.d.ts.map +1 -0
- package/dist/storage/hybrid-store.js +655 -0
- package/dist/storage/hybrid-store.js.map +1 -0
- package/dist/storage/index-store.d.ts +126 -0
- package/dist/storage/index-store.d.ts.map +1 -0
- package/dist/storage/index-store.js +316 -0
- package/dist/storage/index-store.js.map +1 -0
- package/dist/storage/index.d.ts +45 -0
- package/dist/storage/index.d.ts.map +1 -0
- package/dist/storage/index.js +52 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/storage/neuron-store.d.ts +121 -0
- package/dist/storage/neuron-store.d.ts.map +1 -0
- package/dist/storage/neuron-store.js +466 -0
- package/dist/storage/neuron-store.js.map +1 -0
- package/dist/storage/ontology-store.d.ts +132 -0
- package/dist/storage/ontology-store.d.ts.map +1 -0
- package/dist/storage/ontology-store.js +319 -0
- package/dist/storage/ontology-store.js.map +1 -0
- package/dist/storage/probabilistic-store.d.ts +104 -0
- package/dist/storage/probabilistic-store.d.ts.map +1 -0
- package/dist/storage/probabilistic-store.js +257 -0
- package/dist/storage/probabilistic-store.js.map +1 -0
- package/dist/storage/redis-adapters.d.ts +102 -0
- package/dist/storage/redis-adapters.d.ts.map +1 -0
- package/dist/storage/redis-adapters.js +205 -0
- package/dist/storage/redis-adapters.js.map +1 -0
- package/dist/storage/redis-ontology-store.d.ts +146 -0
- package/dist/storage/redis-ontology-store.d.ts.map +1 -0
- package/dist/storage/redis-ontology-store.js +384 -0
- package/dist/storage/redis-ontology-store.js.map +1 -0
- package/dist/storage/redis-store.d.ts +174 -0
- package/dist/storage/redis-store.d.ts.map +1 -0
- package/dist/storage/redis-store.js +506 -0
- package/dist/storage/redis-store.js.map +1 -0
- package/dist/sync/change-journal.d.ts +171 -0
- package/dist/sync/change-journal.d.ts.map +1 -0
- package/dist/sync/change-journal.js +362 -0
- package/dist/sync/change-journal.js.map +1 -0
- package/dist/sync/index.d.ts +8 -0
- package/dist/sync/index.d.ts.map +1 -0
- package/dist/sync/index.js +8 -0
- package/dist/sync/index.js.map +1 -0
- package/dist/sync/state-sync.d.ts +241 -0
- package/dist/sync/state-sync.d.ts.map +1 -0
- package/dist/sync/state-sync.js +396 -0
- package/dist/sync/state-sync.js.map +1 -0
- package/dist/sync/vector-clock.d.ts +144 -0
- package/dist/sync/vector-clock.d.ts.map +1 -0
- package/dist/sync/vector-clock.js +266 -0
- package/dist/sync/vector-clock.js.map +1 -0
- package/dist/types/index.d.ts +224 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +24 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/hash.d.ts +39 -0
- package/dist/utils/hash.d.ts.map +1 -0
- package/dist/utils/hash.js +56 -0
- package/dist/utils/hash.js.map +1 -0
- package/dist/utils/index.d.ts +26 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +50 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/logger.d.ts +88 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +157 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/metrics.d.ts +232 -0
- package/dist/utils/metrics.d.ts.map +1 -0
- package/dist/utils/metrics.js +387 -0
- package/dist/utils/metrics.js.map +1 -0
- package/dist/utils/similarity.d.ts +64 -0
- package/dist/utils/similarity.d.ts.map +1 -0
- package/dist/utils/similarity.js +151 -0
- package/dist/utils/similarity.js.map +1 -0
- package/dist/utils/uuid.d.ts +23 -0
- package/dist/utils/uuid.d.ts.map +1 -0
- package/dist/utils/uuid.js +29 -0
- package/dist/utils/uuid.js.map +1 -0
- package/package.json +72 -0
|
@@ -0,0 +1,798 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Probabilistic Orchestrator - Unified control for probabilistic modules
|
|
3
|
+
*
|
|
4
|
+
* Coordinates between:
|
|
5
|
+
* - BidirectionalInferenceEngine (추론)
|
|
6
|
+
* - AttractorModel (끌개)
|
|
7
|
+
* - FourStageLearningSystem (학습)
|
|
8
|
+
* - ProbabilisticNeuronManager (뉴런)
|
|
9
|
+
* - DynamicEmbeddingManager (차원)
|
|
10
|
+
*
|
|
11
|
+
* @module core/probabilistic-orchestrator
|
|
12
|
+
*/
|
|
13
|
+
import { EvolutionScheduler } from './evolution-scheduler.js';
|
|
14
|
+
import { cosineSimilarity } from '../utils/similarity.js';
|
|
15
|
+
import { createLogger } from '../utils/logger.js';
|
|
16
|
+
import { getMetrics, MetricNames } from '../utils/metrics.js';
|
|
17
|
+
const logger = createLogger('orchestrator');
|
|
18
|
+
/**
|
|
19
|
+
* Default configuration
|
|
20
|
+
*/
|
|
21
|
+
const DEFAULT_CONFIG = {
|
|
22
|
+
autoSaveInterval: 300000, // 5 minutes
|
|
23
|
+
enableAutoEvolution: true,
|
|
24
|
+
enableAutoSave: true,
|
|
25
|
+
neuronEvolveInterval: 60000, // 1 minute
|
|
26
|
+
attractorDecayInterval: 3600000, // 1 hour
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Probabilistic Orchestrator
|
|
30
|
+
*
|
|
31
|
+
* Unified coordination layer for all probabilistic ontology modules.
|
|
32
|
+
* Manages the interaction between inference, attractors, learning,
|
|
33
|
+
* probabilistic neurons, and dynamic embeddings.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```typescript
|
|
37
|
+
* const orchestrator = new ProbabilisticOrchestrator({
|
|
38
|
+
* neuronStore,
|
|
39
|
+
* attractorModel,
|
|
40
|
+
* learningSystem,
|
|
41
|
+
* neuronManager,
|
|
42
|
+
* embeddingManager,
|
|
43
|
+
* config: { enableAutoEvolution: true }
|
|
44
|
+
* });
|
|
45
|
+
*
|
|
46
|
+
* await orchestrator.init();
|
|
47
|
+
*
|
|
48
|
+
* // Learn from user interaction
|
|
49
|
+
* await orchestrator.learnFromInteraction({
|
|
50
|
+
* input: 'user question',
|
|
51
|
+
* output: 'system response',
|
|
52
|
+
* success: true
|
|
53
|
+
* });
|
|
54
|
+
*
|
|
55
|
+
* // Clean shutdown
|
|
56
|
+
* await orchestrator.shutdown();
|
|
57
|
+
* ```
|
|
58
|
+
*
|
|
59
|
+
* @see {@link OrchestratorOptions} for configuration options
|
|
60
|
+
* @see {@link UnifiedInferenceResult} for inference result structure
|
|
61
|
+
*/
|
|
62
|
+
export class ProbabilisticOrchestrator {
|
|
63
|
+
store;
|
|
64
|
+
inference;
|
|
65
|
+
attractors;
|
|
66
|
+
learning;
|
|
67
|
+
neurons;
|
|
68
|
+
dimensions;
|
|
69
|
+
probabilisticStore;
|
|
70
|
+
config;
|
|
71
|
+
scheduler;
|
|
72
|
+
// State management
|
|
73
|
+
initialized = false;
|
|
74
|
+
autoSaveTimer;
|
|
75
|
+
lastSaveTime;
|
|
76
|
+
constructor(options) {
|
|
77
|
+
this.store = options.neuronStore;
|
|
78
|
+
this.inference = options.inferenceEngine;
|
|
79
|
+
this.attractors = options.attractorModel;
|
|
80
|
+
this.learning = options.learningSystem;
|
|
81
|
+
this.neurons = options.neuronManager;
|
|
82
|
+
this.dimensions = options.embeddingManager;
|
|
83
|
+
this.probabilisticStore = options.probabilisticStore;
|
|
84
|
+
this.config = { ...DEFAULT_CONFIG, ...options.config };
|
|
85
|
+
}
|
|
86
|
+
// ==================== Lifecycle Methods ====================
|
|
87
|
+
/**
|
|
88
|
+
* Initialize the orchestrator
|
|
89
|
+
* - Initialize probabilistic store
|
|
90
|
+
* - Load saved state
|
|
91
|
+
* - Start auto-save timer
|
|
92
|
+
*/
|
|
93
|
+
async init() {
|
|
94
|
+
if (this.initialized)
|
|
95
|
+
return;
|
|
96
|
+
const metrics = getMetrics();
|
|
97
|
+
const end = logger.time('init');
|
|
98
|
+
// Register health check
|
|
99
|
+
metrics.registerHealthCheck('orchestrator', async () => ({
|
|
100
|
+
name: 'orchestrator',
|
|
101
|
+
healthy: this.initialized,
|
|
102
|
+
message: this.initialized ? 'Orchestrator running' : 'Not initialized',
|
|
103
|
+
}));
|
|
104
|
+
// Initialize store if available
|
|
105
|
+
if (this.probabilisticStore) {
|
|
106
|
+
await this.probabilisticStore.init();
|
|
107
|
+
logger.info('Probabilistic store initialized');
|
|
108
|
+
// Load saved state
|
|
109
|
+
await this.loadState();
|
|
110
|
+
}
|
|
111
|
+
// Start auto-save timer
|
|
112
|
+
if (this.config.enableAutoSave && this.probabilisticStore) {
|
|
113
|
+
this.startAutoSave();
|
|
114
|
+
logger.info('Auto-save enabled', { interval: this.config.autoSaveInterval });
|
|
115
|
+
}
|
|
116
|
+
// Start evolution scheduler
|
|
117
|
+
if (this.config.enableAutoEvolution && (this.neurons || this.attractors)) {
|
|
118
|
+
this.scheduler = new EvolutionScheduler({
|
|
119
|
+
neuronManager: this.neurons,
|
|
120
|
+
attractorModel: this.attractors,
|
|
121
|
+
neuronEvolveInterval: this.config.neuronEvolveInterval,
|
|
122
|
+
attractorDecayInterval: this.config.attractorDecayInterval,
|
|
123
|
+
onEvolve: async (stats) => {
|
|
124
|
+
logger.debug('Evolution completed', {
|
|
125
|
+
neuronsEvolved: stats.neuronsEvolved,
|
|
126
|
+
attractorsDecayed: stats.attractorsDecayed,
|
|
127
|
+
});
|
|
128
|
+
// Auto-save after evolution
|
|
129
|
+
if (this.config.enableAutoSave && this.probabilisticStore) {
|
|
130
|
+
await this.saveState();
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
});
|
|
134
|
+
this.scheduler.start();
|
|
135
|
+
logger.info('Evolution scheduler started', {
|
|
136
|
+
neuronInterval: this.config.neuronEvolveInterval,
|
|
137
|
+
attractorInterval: this.config.attractorDecayInterval,
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
this.initialized = true;
|
|
141
|
+
end();
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Shutdown the orchestrator
|
|
145
|
+
* - Save current state
|
|
146
|
+
* - Stop timers
|
|
147
|
+
* - Close store
|
|
148
|
+
*/
|
|
149
|
+
async shutdown() {
|
|
150
|
+
if (!this.initialized)
|
|
151
|
+
return;
|
|
152
|
+
const metrics = getMetrics();
|
|
153
|
+
metrics.unregisterHealthCheck('orchestrator');
|
|
154
|
+
logger.info('Shutting down orchestrator');
|
|
155
|
+
// Stop evolution scheduler
|
|
156
|
+
if (this.scheduler) {
|
|
157
|
+
this.scheduler.stop();
|
|
158
|
+
this.scheduler = undefined;
|
|
159
|
+
logger.debug('Evolution scheduler stopped');
|
|
160
|
+
}
|
|
161
|
+
// Stop auto-save timer
|
|
162
|
+
this.stopAutoSave();
|
|
163
|
+
// Save final state
|
|
164
|
+
if (this.probabilisticStore) {
|
|
165
|
+
await this.saveState();
|
|
166
|
+
await this.probabilisticStore.close();
|
|
167
|
+
logger.debug('State saved and store closed');
|
|
168
|
+
}
|
|
169
|
+
this.initialized = false;
|
|
170
|
+
logger.info('Orchestrator shutdown complete');
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Save all module states to persistent storage
|
|
174
|
+
*/
|
|
175
|
+
async saveState() {
|
|
176
|
+
const result = {
|
|
177
|
+
saved: false,
|
|
178
|
+
timestamp: new Date().toISOString(),
|
|
179
|
+
modules: {
|
|
180
|
+
attractors: false,
|
|
181
|
+
learning: false,
|
|
182
|
+
neurons: false,
|
|
183
|
+
dimensions: false,
|
|
184
|
+
},
|
|
185
|
+
};
|
|
186
|
+
if (!this.probabilisticStore) {
|
|
187
|
+
return result;
|
|
188
|
+
}
|
|
189
|
+
const states = {};
|
|
190
|
+
// Serialize each module
|
|
191
|
+
if (this.attractors) {
|
|
192
|
+
states.attractors = this.attractors.serialize();
|
|
193
|
+
result.modules.attractors = true;
|
|
194
|
+
}
|
|
195
|
+
if (this.learning) {
|
|
196
|
+
states.learning = this.learning.serialize();
|
|
197
|
+
result.modules.learning = true;
|
|
198
|
+
}
|
|
199
|
+
if (this.neurons) {
|
|
200
|
+
states.neurons = this.neurons.serialize();
|
|
201
|
+
result.modules.neurons = true;
|
|
202
|
+
}
|
|
203
|
+
if (this.dimensions) {
|
|
204
|
+
states.dimensions = this.dimensions.serializeAll();
|
|
205
|
+
result.modules.dimensions = true;
|
|
206
|
+
}
|
|
207
|
+
// Save all at once
|
|
208
|
+
await this.probabilisticStore.saveAll(states);
|
|
209
|
+
this.lastSaveTime = result.timestamp;
|
|
210
|
+
result.saved = true;
|
|
211
|
+
return result;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Load all module states from persistent storage
|
|
215
|
+
*/
|
|
216
|
+
async loadState() {
|
|
217
|
+
const result = {
|
|
218
|
+
loaded: false,
|
|
219
|
+
modules: {
|
|
220
|
+
attractors: false,
|
|
221
|
+
learning: false,
|
|
222
|
+
neurons: false,
|
|
223
|
+
dimensions: false,
|
|
224
|
+
},
|
|
225
|
+
};
|
|
226
|
+
if (!this.probabilisticStore) {
|
|
227
|
+
return result;
|
|
228
|
+
}
|
|
229
|
+
const states = await this.probabilisticStore.loadAll();
|
|
230
|
+
// Load each module
|
|
231
|
+
if (states.attractors && this.attractors) {
|
|
232
|
+
this.attractors.load(states.attractors);
|
|
233
|
+
result.modules.attractors = true;
|
|
234
|
+
}
|
|
235
|
+
if (states.learning && this.learning) {
|
|
236
|
+
this.learning.load(states.learning);
|
|
237
|
+
result.modules.learning = true;
|
|
238
|
+
}
|
|
239
|
+
if (states.neurons && this.neurons) {
|
|
240
|
+
this.neurons.load(states.neurons);
|
|
241
|
+
result.modules.neurons = true;
|
|
242
|
+
}
|
|
243
|
+
if (states.dimensions && this.dimensions) {
|
|
244
|
+
this.dimensions.loadAll(states.dimensions);
|
|
245
|
+
result.modules.dimensions = true;
|
|
246
|
+
}
|
|
247
|
+
result.loaded = true;
|
|
248
|
+
return result;
|
|
249
|
+
}
|
|
250
|
+
// ==================== Core Methods ====================
|
|
251
|
+
/**
|
|
252
|
+
* Perform unified inference combining all available modules.
|
|
253
|
+
*
|
|
254
|
+
* Combines bidirectional inference, attractor influences, and probabilistic
|
|
255
|
+
* state analysis to provide comprehensive reasoning about a neuron.
|
|
256
|
+
*
|
|
257
|
+
* @param neuronId - The ID of the neuron to analyze
|
|
258
|
+
* @param options - Configuration for the inference
|
|
259
|
+
* @param options.includeAttractors - Include attractor influence analysis (default: true)
|
|
260
|
+
* @param options.includeProbabilistic - Include probabilistic state analysis (default: true)
|
|
261
|
+
* @param options.maxDepth - Maximum inference depth (default: 3)
|
|
262
|
+
* @returns Unified inference result with paths, influences, and recommendations
|
|
263
|
+
*
|
|
264
|
+
* @example
|
|
265
|
+
* ```typescript
|
|
266
|
+
* const result = await orchestrator.unifiedInfer('neuron-123', {
|
|
267
|
+
* includeAttractors: true,
|
|
268
|
+
* includeProbabilistic: true,
|
|
269
|
+
* maxDepth: 5
|
|
270
|
+
* });
|
|
271
|
+
* console.log(result.forwardPaths); // Cause -> Effect paths
|
|
272
|
+
* console.log(result.dominantAttractor); // Most influential goal
|
|
273
|
+
* ```
|
|
274
|
+
*/
|
|
275
|
+
async unifiedInfer(neuronId, options = {}) {
|
|
276
|
+
const metrics = getMetrics();
|
|
277
|
+
const timer = metrics.startTimer(MetricNames.INFERENCE_DURATION_MS, { type: 'unified' });
|
|
278
|
+
metrics.increment(MetricNames.INFERENCE_REQUESTS, { type: 'unified' });
|
|
279
|
+
const result = {
|
|
280
|
+
forwardPaths: [],
|
|
281
|
+
backwardPaths: [],
|
|
282
|
+
attractorInfluences: new Map(),
|
|
283
|
+
recommendations: [],
|
|
284
|
+
};
|
|
285
|
+
const neuron = await this.store.getNeuron(neuronId);
|
|
286
|
+
if (!neuron) {
|
|
287
|
+
timer();
|
|
288
|
+
return result;
|
|
289
|
+
}
|
|
290
|
+
// 1. Bidirectional inference
|
|
291
|
+
if (this.inference) {
|
|
292
|
+
const forward = await this.inference.forwardInfer(neuron);
|
|
293
|
+
result.forwardPaths = forward.map(r => ({
|
|
294
|
+
neuronId: r.target?.id ?? r.source.id,
|
|
295
|
+
confidence: r.confidence,
|
|
296
|
+
}));
|
|
297
|
+
const backward = await this.inference.backwardInfer(neuron);
|
|
298
|
+
result.backwardPaths = backward.map(r => ({
|
|
299
|
+
neuronId: r.source.id,
|
|
300
|
+
confidence: r.confidence,
|
|
301
|
+
}));
|
|
302
|
+
}
|
|
303
|
+
// 2. Attractor influences
|
|
304
|
+
if (this.attractors && options.includeAttractors !== false) {
|
|
305
|
+
result.attractorInfluences = this.attractors.calculateInfluence(neuron.embedding);
|
|
306
|
+
const dominant = this.attractors.getDominantAttractor(neuron.embedding);
|
|
307
|
+
if (dominant) {
|
|
308
|
+
result.dominantAttractor = dominant.id;
|
|
309
|
+
// Find path to dominant attractor
|
|
310
|
+
const pathResult = await this.attractors.findPathToAttractor(neuronId, dominant.id);
|
|
311
|
+
if (pathResult) {
|
|
312
|
+
result.pathToGoal = pathResult.path;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
// 3. Probabilistic state analysis
|
|
317
|
+
if (this.neurons && options.includeProbabilistic !== false) {
|
|
318
|
+
const probNeuron = this.neurons.getNeuron(neuronId);
|
|
319
|
+
if (probNeuron) {
|
|
320
|
+
const states = probNeuron.superposition.states;
|
|
321
|
+
let mostProbableIndex = 0;
|
|
322
|
+
let maxAmplitude = 0;
|
|
323
|
+
for (let i = 0; i < states.length; i++) {
|
|
324
|
+
if (states[i].probability > maxAmplitude) {
|
|
325
|
+
maxAmplitude = states[i].probability;
|
|
326
|
+
mostProbableIndex = i;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
result.stateDistribution = {
|
|
330
|
+
entropy: this.neurons.getUncertainty(neuronId),
|
|
331
|
+
mostProbableState: mostProbableIndex,
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
// 4. Generate recommendations
|
|
336
|
+
result.recommendations = this.generateRecommendations(result, neuron);
|
|
337
|
+
timer();
|
|
338
|
+
return result;
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* Learn from a user interaction using the full 4-stage learning system.
|
|
342
|
+
*
|
|
343
|
+
* Implements the complete learning pipeline:
|
|
344
|
+
* 1. Extract - Find meaningful content from input/output
|
|
345
|
+
* 2. Patterns - Identify recurring patterns
|
|
346
|
+
* 3. Process - Learn the transformation steps
|
|
347
|
+
* 4. Outcome - Record success/failure for future reference
|
|
348
|
+
*
|
|
349
|
+
* @param data - The interaction data to learn from
|
|
350
|
+
* @param data.input - The user's input text
|
|
351
|
+
* @param data.output - The system's output text
|
|
352
|
+
* @param data.success - Whether the interaction was successful
|
|
353
|
+
* @param data.feedback - Quality score (0-1, optional)
|
|
354
|
+
* @param data.inputNeuronId - Existing neuron ID for input (optional)
|
|
355
|
+
* @param data.outputNeuronId - Existing neuron ID for output (optional)
|
|
356
|
+
* @returns Learning result with statistics on what was learned
|
|
357
|
+
*
|
|
358
|
+
* @example
|
|
359
|
+
* ```typescript
|
|
360
|
+
* const result = await orchestrator.learnFromInteraction({
|
|
361
|
+
* input: "How do I implement a binary search?",
|
|
362
|
+
* output: "Here's how to implement binary search...",
|
|
363
|
+
* success: true,
|
|
364
|
+
* feedback: 0.9
|
|
365
|
+
* });
|
|
366
|
+
*
|
|
367
|
+
* console.log(`Learned ${result.patternsLearned} patterns`);
|
|
368
|
+
* ```
|
|
369
|
+
*/
|
|
370
|
+
async learnFromInteraction(data) {
|
|
371
|
+
const metrics = getMetrics();
|
|
372
|
+
metrics.increment(MetricNames.LEARNING_SESSIONS, { type: 'interaction' });
|
|
373
|
+
const result = {
|
|
374
|
+
patternsLearned: 0,
|
|
375
|
+
attractorsUpdated: 0,
|
|
376
|
+
neuronsUpdated: 0,
|
|
377
|
+
extractsCreated: 0,
|
|
378
|
+
processLearned: false,
|
|
379
|
+
outcomeRecorded: false,
|
|
380
|
+
};
|
|
381
|
+
// 1. Get or create input/output neurons
|
|
382
|
+
let inputNeuronId = data.inputNeuronId;
|
|
383
|
+
let outputNeuronId = data.outputNeuronId;
|
|
384
|
+
// If no input neuron provided, try to find similar or note absence
|
|
385
|
+
if (!inputNeuronId && this.dimensions) {
|
|
386
|
+
// Create a simple embedding from input text for matching
|
|
387
|
+
const inputEmbedding = this.createSimpleEmbedding(data.input);
|
|
388
|
+
const similar = await this.store.findSimilar(inputEmbedding, 1);
|
|
389
|
+
if (similar.length > 0) {
|
|
390
|
+
const similarity = cosineSimilarity(inputEmbedding, similar[0].embedding);
|
|
391
|
+
if (similarity > 0.8) {
|
|
392
|
+
inputNeuronId = similar[0].id;
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
// 2. Full learning system integration
|
|
397
|
+
if (this.learning && inputNeuronId) {
|
|
398
|
+
const learningResult = await this.learning.learnFromInteraction(inputNeuronId, data.input, data.processSteps ?? [], outputNeuronId, data.output, data.success, data.feedback ?? (data.success ? 0.8 : 0.2));
|
|
399
|
+
result.extractsCreated = learningResult.extracts.length;
|
|
400
|
+
result.patternsLearned = learningResult.patterns.length;
|
|
401
|
+
result.processLearned = learningResult.process !== null;
|
|
402
|
+
result.outcomeRecorded = learningResult.outcome !== null;
|
|
403
|
+
}
|
|
404
|
+
// 3. Update attractors based on success/failure
|
|
405
|
+
if (this.attractors && data.success !== undefined) {
|
|
406
|
+
if (data.success && data.feedback !== undefined && data.feedback > 0.7) {
|
|
407
|
+
// Create or strengthen attractor for successful pattern
|
|
408
|
+
const outputEmbedding = outputNeuronId
|
|
409
|
+
? (await this.store.getNeuron(outputNeuronId))?.embedding
|
|
410
|
+
: this.createSimpleEmbedding(data.output);
|
|
411
|
+
if (outputEmbedding) {
|
|
412
|
+
// Find or create attractor for this successful outcome
|
|
413
|
+
const dominant = this.attractors.getDominantAttractor(outputEmbedding);
|
|
414
|
+
if (dominant) {
|
|
415
|
+
// Strengthen existing attractor
|
|
416
|
+
result.attractorsUpdated = 1;
|
|
417
|
+
}
|
|
418
|
+
else {
|
|
419
|
+
// Create new attractor for highly successful outcomes
|
|
420
|
+
if (data.feedback >= 0.9) {
|
|
421
|
+
const attractorId = `attr_success_${Date.now()}`;
|
|
422
|
+
this.attractors.createAttractor(attractorId, `Success Pattern`, `Auto-created from successful interaction`, outputEmbedding, { strength: data.feedback });
|
|
423
|
+
result.attractorsUpdated = 1;
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
// 4. Create probabilistic neurons for new patterns
|
|
430
|
+
if (this.neurons && inputNeuronId) {
|
|
431
|
+
const inputNeuron = await this.store.getNeuron(inputNeuronId);
|
|
432
|
+
if (inputNeuron) {
|
|
433
|
+
const existingProb = this.neurons.getNeuron(inputNeuronId);
|
|
434
|
+
if (!existingProb) {
|
|
435
|
+
await this.neurons.createProbabilisticNeuron(inputNeuron);
|
|
436
|
+
result.neuronsUpdated++;
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
if (this.neurons && outputNeuronId) {
|
|
441
|
+
const outputNeuron = await this.store.getNeuron(outputNeuronId);
|
|
442
|
+
if (outputNeuron) {
|
|
443
|
+
const existingProb = this.neurons.getNeuron(outputNeuronId);
|
|
444
|
+
if (!existingProb) {
|
|
445
|
+
await this.neurons.createProbabilisticNeuron(outputNeuron);
|
|
446
|
+
result.neuronsUpdated++;
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
// 5. Store neuron IDs in result
|
|
451
|
+
result.inputNeuronId = inputNeuronId;
|
|
452
|
+
result.outputNeuronId = outputNeuronId;
|
|
453
|
+
// 6. Auto-save after learning
|
|
454
|
+
if (this.config.enableAutoSave && this.probabilisticStore) {
|
|
455
|
+
await this.saveState();
|
|
456
|
+
}
|
|
457
|
+
// 7. Record metrics
|
|
458
|
+
if (result.extractsCreated > 0) {
|
|
459
|
+
metrics.increment(MetricNames.EXTRACTS_CREATED, undefined, result.extractsCreated);
|
|
460
|
+
}
|
|
461
|
+
if (result.patternsLearned > 0) {
|
|
462
|
+
metrics.increment(MetricNames.PATTERNS_LEARNED, undefined, result.patternsLearned);
|
|
463
|
+
}
|
|
464
|
+
if (result.attractorsUpdated > 0) {
|
|
465
|
+
metrics.increment(MetricNames.ATTRACTOR_ACTIVATIONS, undefined, result.attractorsUpdated);
|
|
466
|
+
}
|
|
467
|
+
return result;
|
|
468
|
+
}
|
|
469
|
+
/**
|
|
470
|
+
* Provide feedback for a previous interaction.
|
|
471
|
+
*
|
|
472
|
+
* Updates the learning system with quality feedback, which helps
|
|
473
|
+
* improve future pattern matching and process selection.
|
|
474
|
+
*
|
|
475
|
+
* @param inputNeuronId - The input neuron from the original interaction
|
|
476
|
+
* @param outputNeuronId - The output neuron from the original interaction
|
|
477
|
+
* @param quality - Quality score between 0 (poor) and 1 (excellent)
|
|
478
|
+
* @param feedbackText - Optional textual feedback description
|
|
479
|
+
* @returns Whether the feedback was successfully recorded
|
|
480
|
+
*
|
|
481
|
+
* @example
|
|
482
|
+
* ```typescript
|
|
483
|
+
* await orchestrator.provideFeedback(
|
|
484
|
+
* 'input-neuron-id',
|
|
485
|
+
* 'output-neuron-id',
|
|
486
|
+
* 0.85,
|
|
487
|
+
* 'Good answer but could be more concise'
|
|
488
|
+
* );
|
|
489
|
+
* ```
|
|
490
|
+
*/
|
|
491
|
+
async provideFeedback(inputNeuronId, outputNeuronId, quality, feedbackText) {
|
|
492
|
+
if (!this.learning) {
|
|
493
|
+
return { updated: false };
|
|
494
|
+
}
|
|
495
|
+
// Find the process that was used
|
|
496
|
+
const inputNeuron = await this.store.getNeuron(inputNeuronId);
|
|
497
|
+
if (!inputNeuron) {
|
|
498
|
+
return { updated: false };
|
|
499
|
+
}
|
|
500
|
+
// Get relevant patterns to find the process
|
|
501
|
+
const relevantPatterns = await this.learning.findRelevantPatterns(inputNeuron.embedding, 1);
|
|
502
|
+
if (relevantPatterns.length > 0) {
|
|
503
|
+
// Record outcome with feedback
|
|
504
|
+
await this.learning.learnOutcome(relevantPatterns[0].id, // Use pattern ID as process reference
|
|
505
|
+
inputNeuronId, outputNeuronId, quality >= 0.5, quality, feedbackText);
|
|
506
|
+
// Update attractors based on feedback
|
|
507
|
+
if (this.attractors && quality >= 0.8) {
|
|
508
|
+
const outputNeuron = await this.store.getNeuron(outputNeuronId);
|
|
509
|
+
if (outputNeuron) {
|
|
510
|
+
const dominant = this.attractors.getDominantAttractor(outputNeuron.embedding);
|
|
511
|
+
if (!dominant) {
|
|
512
|
+
const attractorId = `attr_feedback_${Date.now()}`;
|
|
513
|
+
this.attractors.createAttractor(attractorId, `Feedback Pattern`, `Auto-created from positive feedback`, outputNeuron.embedding, { strength: quality });
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
return { updated: true };
|
|
518
|
+
}
|
|
519
|
+
return { updated: false };
|
|
520
|
+
}
|
|
521
|
+
/**
|
|
522
|
+
* Reinforce a successful path between neurons.
|
|
523
|
+
*
|
|
524
|
+
* Strengthens the connection between two neurons that produced a
|
|
525
|
+
* successful outcome, making similar paths more likely in the future.
|
|
526
|
+
*
|
|
527
|
+
* @param fromId - Source neuron ID
|
|
528
|
+
* @param toId - Target neuron ID
|
|
529
|
+
* @param strength - Reinforcement strength (default: 0.1)
|
|
530
|
+
* @returns Whether the path was successfully reinforced
|
|
531
|
+
*
|
|
532
|
+
* @example
|
|
533
|
+
* ```typescript
|
|
534
|
+
* // After a successful interaction, reinforce the path
|
|
535
|
+
* await orchestrator.reinforceSuccessfulPath(
|
|
536
|
+
* 'input-neuron',
|
|
537
|
+
* 'output-neuron',
|
|
538
|
+
* 0.2
|
|
539
|
+
* );
|
|
540
|
+
* ```
|
|
541
|
+
*/
|
|
542
|
+
async reinforceSuccessfulPath(fromId, toId, strength = 0.1) {
|
|
543
|
+
// Update probabilistic neurons if they exist
|
|
544
|
+
if (this.neurons) {
|
|
545
|
+
const fromProb = this.neurons.getNeuron(fromId);
|
|
546
|
+
const toProb = this.neurons.getNeuron(toId);
|
|
547
|
+
if (fromProb && toProb) {
|
|
548
|
+
// Entangle successful pairs
|
|
549
|
+
this.neurons.entangle(fromId, toId);
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
// Update attractor model - strengthen path
|
|
553
|
+
if (this.attractors) {
|
|
554
|
+
const fromNeuron = await this.store.getNeuron(fromId);
|
|
555
|
+
const toNeuron = await this.store.getNeuron(toId);
|
|
556
|
+
if (fromNeuron && toNeuron) {
|
|
557
|
+
// The path is successful, so the destination could be an attractor
|
|
558
|
+
const dominant = this.attractors.getDominantAttractor(toNeuron.embedding);
|
|
559
|
+
if (dominant) {
|
|
560
|
+
// Path leads to a known goal - this is good
|
|
561
|
+
return { reinforced: true };
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
return { reinforced: true };
|
|
566
|
+
}
|
|
567
|
+
/**
|
|
568
|
+
* Create a goal-driven neuron biased toward an attractor.
|
|
569
|
+
*
|
|
570
|
+
* Creates a probabilistic neuron with states weighted toward
|
|
571
|
+
* the specified attractor (goal), implementing teleological
|
|
572
|
+
* determinism where future goals influence present state.
|
|
573
|
+
*
|
|
574
|
+
* @param baseNeuronId - The base neuron to enhance with goal direction
|
|
575
|
+
* @param attractorId - The target attractor (goal) to move toward
|
|
576
|
+
* @returns Goal-driven neuron info or null if creation failed
|
|
577
|
+
*/
|
|
578
|
+
async createGoalDrivenNeuron(baseNeuronId, attractorId) {
|
|
579
|
+
if (!this.neurons || !this.attractors) {
|
|
580
|
+
return null;
|
|
581
|
+
}
|
|
582
|
+
const baseNeuron = await this.store.getNeuron(baseNeuronId);
|
|
583
|
+
if (!baseNeuron)
|
|
584
|
+
return null;
|
|
585
|
+
// Create probabilistic neuron
|
|
586
|
+
const probNeuron = await this.neurons.createProbabilisticNeuron(baseNeuron);
|
|
587
|
+
// Get path to attractor
|
|
588
|
+
const pathResult = await this.attractors.findPathToAttractor(baseNeuronId, attractorId);
|
|
589
|
+
return {
|
|
590
|
+
neuronId: baseNeuronId,
|
|
591
|
+
initialState: 0,
|
|
592
|
+
pathProbability: pathResult?.probability ?? 0,
|
|
593
|
+
};
|
|
594
|
+
}
|
|
595
|
+
/**
|
|
596
|
+
* Expand embedding dimensions for a new concept.
|
|
597
|
+
*
|
|
598
|
+
* Registers a new semantic dimension, allowing the system to
|
|
599
|
+
* capture novel concepts that weren't in the original embedding space.
|
|
600
|
+
*
|
|
601
|
+
* @param concept - The concept name to register
|
|
602
|
+
* @param category - Semantic category for organization (default: 'custom')
|
|
603
|
+
* @returns The new dimension name and total dimension count
|
|
604
|
+
*/
|
|
605
|
+
async expandForConcept(concept, category = 'custom') {
|
|
606
|
+
if (!this.dimensions) {
|
|
607
|
+
return { dimensionName: concept, totalDimensions: 384 };
|
|
608
|
+
}
|
|
609
|
+
this.dimensions.registerDimension(concept, {
|
|
610
|
+
name: concept,
|
|
611
|
+
semanticCategory: category,
|
|
612
|
+
description: `Dimension for concept: ${concept}`,
|
|
613
|
+
createdAt: new Date().toISOString(),
|
|
614
|
+
usageCount: 0,
|
|
615
|
+
});
|
|
616
|
+
const stats = this.dimensions.getStats();
|
|
617
|
+
return {
|
|
618
|
+
dimensionName: concept,
|
|
619
|
+
totalDimensions: stats.totalDimensions,
|
|
620
|
+
};
|
|
621
|
+
}
|
|
622
|
+
/**
|
|
623
|
+
* Get comprehensive statistics from all modules.
|
|
624
|
+
*
|
|
625
|
+
* Provides a unified view of the system's current state including
|
|
626
|
+
* inference availability, attractor counts, learning progress,
|
|
627
|
+
* neuron statistics, and persistence status.
|
|
628
|
+
*
|
|
629
|
+
* @returns Aggregated statistics from all modules
|
|
630
|
+
*
|
|
631
|
+
* @example
|
|
632
|
+
* ```typescript
|
|
633
|
+
* const stats = orchestrator.getStats();
|
|
634
|
+
* console.log(`Active attractors: ${stats.attractors.active}`);
|
|
635
|
+
* console.log(`Patterns learned: ${stats.learning.patterns}`);
|
|
636
|
+
* console.log(`Last saved: ${stats.persistence.lastSave}`);
|
|
637
|
+
* ```
|
|
638
|
+
*/
|
|
639
|
+
getStats() {
|
|
640
|
+
return {
|
|
641
|
+
inference: {
|
|
642
|
+
available: !!this.inference,
|
|
643
|
+
},
|
|
644
|
+
attractors: this.attractors ? {
|
|
645
|
+
count: this.attractors.getStats().totalAttractors,
|
|
646
|
+
active: this.attractors.getStats().activeAttractors,
|
|
647
|
+
} : { count: 0, active: 0 },
|
|
648
|
+
learning: this.learning ? {
|
|
649
|
+
patterns: this.learning.getStats().patterns,
|
|
650
|
+
processes: this.learning.getStats().processes,
|
|
651
|
+
} : { patterns: 0, processes: 0 },
|
|
652
|
+
neurons: this.neurons ? {
|
|
653
|
+
count: this.neurons.getStats().totalNeurons,
|
|
654
|
+
avgEntropy: this.neurons.getStats().averageEntropy,
|
|
655
|
+
} : { count: 0, avgEntropy: 0 },
|
|
656
|
+
dimensions: this.dimensions ? {
|
|
657
|
+
total: this.dimensions.getStats().totalDimensions,
|
|
658
|
+
expanded: this.dimensions.getStats().expandedDimensions,
|
|
659
|
+
} : { total: 384, expanded: 0 },
|
|
660
|
+
persistence: {
|
|
661
|
+
enabled: !!this.probabilisticStore,
|
|
662
|
+
lastSave: this.lastSaveTime,
|
|
663
|
+
},
|
|
664
|
+
};
|
|
665
|
+
}
|
|
666
|
+
/**
|
|
667
|
+
* Check if orchestrator is initialized
|
|
668
|
+
*/
|
|
669
|
+
isInitialized() {
|
|
670
|
+
return this.initialized;
|
|
671
|
+
}
|
|
672
|
+
/**
|
|
673
|
+
* Get configuration
|
|
674
|
+
*/
|
|
675
|
+
getConfig() {
|
|
676
|
+
return { ...this.config };
|
|
677
|
+
}
|
|
678
|
+
/**
|
|
679
|
+
* Get evolution scheduler status
|
|
680
|
+
*/
|
|
681
|
+
getEvolutionStatus() {
|
|
682
|
+
if (!this.scheduler)
|
|
683
|
+
return null;
|
|
684
|
+
return this.scheduler.getStatus();
|
|
685
|
+
}
|
|
686
|
+
/**
|
|
687
|
+
* Trigger manual evolution of all modules
|
|
688
|
+
*/
|
|
689
|
+
async triggerEvolution() {
|
|
690
|
+
if (!this.scheduler)
|
|
691
|
+
return null;
|
|
692
|
+
return this.scheduler.evolveNow();
|
|
693
|
+
}
|
|
694
|
+
/**
|
|
695
|
+
* Update evolution intervals (applies immediately)
|
|
696
|
+
*/
|
|
697
|
+
setEvolutionIntervals(intervals) {
|
|
698
|
+
if (intervals.neuronEvolveInterval !== undefined) {
|
|
699
|
+
this.config.neuronEvolveInterval = intervals.neuronEvolveInterval;
|
|
700
|
+
}
|
|
701
|
+
if (intervals.attractorDecayInterval !== undefined) {
|
|
702
|
+
this.config.attractorDecayInterval = intervals.attractorDecayInterval;
|
|
703
|
+
}
|
|
704
|
+
if (this.scheduler) {
|
|
705
|
+
this.scheduler.setIntervals({
|
|
706
|
+
neuronEvolve: intervals.neuronEvolveInterval,
|
|
707
|
+
attractorDecay: intervals.attractorDecayInterval,
|
|
708
|
+
});
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
// ==================== Auto-Save Management ====================
|
|
712
|
+
startAutoSave() {
|
|
713
|
+
if (this.autoSaveTimer) {
|
|
714
|
+
clearInterval(this.autoSaveTimer);
|
|
715
|
+
}
|
|
716
|
+
this.autoSaveTimer = setInterval(async () => {
|
|
717
|
+
try {
|
|
718
|
+
await this.saveState();
|
|
719
|
+
}
|
|
720
|
+
catch (error) {
|
|
721
|
+
console.error('[Orchestrator] Auto-save failed:', error);
|
|
722
|
+
}
|
|
723
|
+
}, this.config.autoSaveInterval);
|
|
724
|
+
}
|
|
725
|
+
stopAutoSave() {
|
|
726
|
+
if (this.autoSaveTimer) {
|
|
727
|
+
clearInterval(this.autoSaveTimer);
|
|
728
|
+
this.autoSaveTimer = undefined;
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
// ==================== Private Helpers ====================
|
|
732
|
+
generateRecommendations(result, neuron) {
|
|
733
|
+
const recommendations = [];
|
|
734
|
+
// Forward paths with high confidence
|
|
735
|
+
for (const path of result.forwardPaths.slice(0, 3)) {
|
|
736
|
+
if (path.confidence > 0.5) {
|
|
737
|
+
recommendations.push({
|
|
738
|
+
neuronId: path.neuronId,
|
|
739
|
+
reason: 'Strong forward causal connection',
|
|
740
|
+
score: path.confidence,
|
|
741
|
+
});
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
// Backward paths (abductive reasoning)
|
|
745
|
+
for (const path of result.backwardPaths.slice(0, 2)) {
|
|
746
|
+
if (path.confidence > 0.5) {
|
|
747
|
+
recommendations.push({
|
|
748
|
+
neuronId: path.neuronId,
|
|
749
|
+
reason: 'Likely cause (abductive)',
|
|
750
|
+
score: path.confidence * 0.9,
|
|
751
|
+
});
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
// Attractor-influenced paths
|
|
755
|
+
if (result.pathToGoal && result.pathToGoal.length > 1) {
|
|
756
|
+
const nextStep = result.pathToGoal[1];
|
|
757
|
+
recommendations.push({
|
|
758
|
+
neuronId: nextStep,
|
|
759
|
+
reason: `Step toward goal attractor`,
|
|
760
|
+
score: 0.8,
|
|
761
|
+
});
|
|
762
|
+
}
|
|
763
|
+
// Sort by score
|
|
764
|
+
recommendations.sort((a, b) => b.score - a.score);
|
|
765
|
+
return recommendations.slice(0, 5);
|
|
766
|
+
}
|
|
767
|
+
/**
|
|
768
|
+
* Create a simple embedding from text
|
|
769
|
+
* Uses a deterministic hash-based approach for text without external embedding service
|
|
770
|
+
*/
|
|
771
|
+
createSimpleEmbedding(text) {
|
|
772
|
+
const embedding = new Float32Array(384);
|
|
773
|
+
const words = text.toLowerCase().split(/\s+/);
|
|
774
|
+
// Simple bag-of-words style embedding
|
|
775
|
+
for (let i = 0; i < words.length; i++) {
|
|
776
|
+
const word = words[i];
|
|
777
|
+
for (let j = 0; j < word.length; j++) {
|
|
778
|
+
const charCode = word.charCodeAt(j);
|
|
779
|
+
const index = (charCode * (i + 1) * (j + 1)) % 384;
|
|
780
|
+
embedding[index] += 1 / (1 + Math.log(1 + i));
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
// Normalize
|
|
784
|
+
let norm = 0;
|
|
785
|
+
for (let i = 0; i < 384; i++) {
|
|
786
|
+
norm += embedding[i] * embedding[i];
|
|
787
|
+
}
|
|
788
|
+
norm = Math.sqrt(norm);
|
|
789
|
+
if (norm > 0) {
|
|
790
|
+
for (let i = 0; i < 384; i++) {
|
|
791
|
+
embedding[i] /= norm;
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
return embedding;
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
export default ProbabilisticOrchestrator;
|
|
798
|
+
//# sourceMappingURL=probabilistic-orchestrator.js.map
|