@kilnai/core 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agents/circuit-breaker.d.ts +26 -0
- package/dist/agents/circuit-breaker.d.ts.map +1 -0
- package/dist/agents/circuit-breaker.js +90 -0
- package/dist/agents/circuit-breaker.js.map +1 -0
- package/dist/agents/context-compressor.d.ts +13 -0
- package/dist/agents/context-compressor.d.ts.map +1 -0
- package/dist/agents/context-compressor.js +21 -0
- package/dist/agents/context-compressor.js.map +1 -0
- package/dist/agents/index.d.ts +68 -0
- package/dist/agents/index.d.ts.map +1 -0
- package/dist/agents/index.js +13 -0
- package/dist/agents/index.js.map +1 -0
- package/dist/agents/infrastructure/anthropic.d.ts +24 -0
- package/dist/agents/infrastructure/anthropic.d.ts.map +1 -0
- package/dist/agents/infrastructure/anthropic.js +226 -0
- package/dist/agents/infrastructure/anthropic.js.map +1 -0
- package/dist/agents/infrastructure/deepseek.d.ts +10 -0
- package/dist/agents/infrastructure/deepseek.d.ts.map +1 -0
- package/dist/agents/infrastructure/deepseek.js +14 -0
- package/dist/agents/infrastructure/deepseek.js.map +1 -0
- package/dist/agents/infrastructure/ollama.d.ts +20 -0
- package/dist/agents/infrastructure/ollama.d.ts.map +1 -0
- package/dist/agents/infrastructure/ollama.js +128 -0
- package/dist/agents/infrastructure/ollama.js.map +1 -0
- package/dist/agents/infrastructure/openai-compat.d.ts +25 -0
- package/dist/agents/infrastructure/openai-compat.d.ts.map +1 -0
- package/dist/agents/infrastructure/openai-compat.js +211 -0
- package/dist/agents/infrastructure/openai-compat.js.map +1 -0
- package/dist/agents/infrastructure/openai.d.ts +12 -0
- package/dist/agents/infrastructure/openai.d.ts.map +1 -0
- package/dist/agents/infrastructure/openai.js +16 -0
- package/dist/agents/infrastructure/openai.js.map +1 -0
- package/dist/agents/infrastructure/retry.d.ts +10 -0
- package/dist/agents/infrastructure/retry.d.ts.map +1 -0
- package/dist/agents/infrastructure/retry.js +22 -0
- package/dist/agents/infrastructure/retry.js.map +1 -0
- package/dist/agents/mcp-client.d.ts +22 -0
- package/dist/agents/mcp-client.d.ts.map +1 -0
- package/dist/agents/mcp-client.js +104 -0
- package/dist/agents/mcp-client.js.map +1 -0
- package/dist/agents/model-pricing.d.ts +9 -0
- package/dist/agents/model-pricing.d.ts.map +1 -0
- package/dist/agents/model-pricing.js +17 -0
- package/dist/agents/model-pricing.js.map +1 -0
- package/dist/agents/provider-registry.d.ts +25 -0
- package/dist/agents/provider-registry.d.ts.map +1 -0
- package/dist/agents/provider-registry.js +62 -0
- package/dist/agents/provider-registry.js.map +1 -0
- package/dist/agents/tool-cache.d.ts +13 -0
- package/dist/agents/tool-cache.d.ts.map +1 -0
- package/dist/agents/tool-cache.js +52 -0
- package/dist/agents/tool-cache.js.map +1 -0
- package/dist/agents/tool-rag.d.ts +15 -0
- package/dist/agents/tool-rag.d.ts.map +1 -0
- package/dist/agents/tool-rag.js +92 -0
- package/dist/agents/tool-rag.js.map +1 -0
- package/dist/agents/tool-registry.d.ts +29 -0
- package/dist/agents/tool-registry.d.ts.map +1 -0
- package/dist/agents/tool-registry.js +64 -0
- package/dist/agents/tool-registry.js.map +1 -0
- package/dist/cost/cost-tracker.d.ts +27 -0
- package/dist/cost/cost-tracker.d.ts.map +1 -0
- package/dist/cost/cost-tracker.js +103 -0
- package/dist/cost/cost-tracker.js.map +1 -0
- package/dist/cost/index.d.ts +30 -0
- package/dist/cost/index.d.ts.map +1 -0
- package/dist/cost/index.js +2 -0
- package/dist/cost/index.js.map +1 -0
- package/dist/domain/domain-package-adapter.d.ts +13 -0
- package/dist/domain/domain-package-adapter.d.ts.map +1 -0
- package/dist/domain/domain-package-adapter.js +66 -0
- package/dist/domain/domain-package-adapter.js.map +1 -0
- package/dist/domain/domain-registry.d.ts +26 -0
- package/dist/domain/domain-registry.d.ts.map +1 -0
- package/dist/domain/domain-registry.js +119 -0
- package/dist/domain/domain-registry.js.map +1 -0
- package/dist/domain/index.d.ts +22 -0
- package/dist/domain/index.d.ts.map +1 -0
- package/dist/domain/index.js +30 -0
- package/dist/domain/index.js.map +1 -0
- package/dist/domain/yaml-parser.d.ts +18 -0
- package/dist/domain/yaml-parser.d.ts.map +1 -0
- package/dist/domain/yaml-parser.js +47 -0
- package/dist/domain/yaml-parser.js.map +1 -0
- package/dist/domain/yaml-schema.d.ts +26 -0
- package/dist/domain/yaml-schema.d.ts.map +1 -0
- package/dist/domain/yaml-schema.js +66 -0
- package/dist/domain/yaml-schema.js.map +1 -0
- package/dist/engine/composites/app.d.ts +39 -0
- package/dist/engine/composites/app.d.ts.map +1 -0
- package/dist/engine/composites/app.js +125 -0
- package/dist/engine/composites/app.js.map +1 -0
- package/dist/engine/composites/router.d.ts +20 -0
- package/dist/engine/composites/router.d.ts.map +1 -0
- package/dist/engine/composites/router.js +31 -0
- package/dist/engine/composites/router.js.map +1 -0
- package/dist/engine/composites/team.d.ts +36 -0
- package/dist/engine/composites/team.d.ts.map +1 -0
- package/dist/engine/composites/team.js +100 -0
- package/dist/engine/composites/team.js.map +1 -0
- package/dist/engine/domain/a2a-config.d.ts +53 -0
- package/dist/engine/domain/a2a-config.d.ts.map +1 -0
- package/dist/engine/domain/a2a-config.js +32 -0
- package/dist/engine/domain/a2a-config.js.map +1 -0
- package/dist/engine/domain/agent.d.ts +18 -0
- package/dist/engine/domain/agent.d.ts.map +1 -0
- package/dist/engine/domain/agent.js +4 -0
- package/dist/engine/domain/agent.js.map +1 -0
- package/dist/engine/domain/capability.d.ts +24 -0
- package/dist/engine/domain/capability.d.ts.map +1 -0
- package/dist/engine/domain/capability.js +3 -0
- package/dist/engine/domain/capability.js.map +1 -0
- package/dist/engine/domain/channel.d.ts +37 -0
- package/dist/engine/domain/channel.d.ts.map +1 -0
- package/dist/engine/domain/channel.js +4 -0
- package/dist/engine/domain/channel.js.map +1 -0
- package/dist/engine/domain/chunker.d.ts +22 -0
- package/dist/engine/domain/chunker.d.ts.map +1 -0
- package/dist/engine/domain/chunker.js +3 -0
- package/dist/engine/domain/chunker.js.map +1 -0
- package/dist/engine/domain/content.d.ts +57 -0
- package/dist/engine/domain/content.d.ts.map +1 -0
- package/dist/engine/domain/content.js +63 -0
- package/dist/engine/domain/content.js.map +1 -0
- package/dist/engine/domain/cron.d.ts +15 -0
- package/dist/engine/domain/cron.d.ts.map +1 -0
- package/dist/engine/domain/cron.js +114 -0
- package/dist/engine/domain/cron.js.map +1 -0
- package/dist/engine/domain/embedding.d.ts +9 -0
- package/dist/engine/domain/embedding.d.ts.map +1 -0
- package/dist/engine/domain/embedding.js +4 -0
- package/dist/engine/domain/embedding.js.map +1 -0
- package/dist/engine/domain/eval-config.d.ts +36 -0
- package/dist/engine/domain/eval-config.d.ts.map +1 -0
- package/dist/engine/domain/eval-config.js +155 -0
- package/dist/engine/domain/eval-config.js.map +1 -0
- package/dist/engine/domain/knowledge-config.d.ts +34 -0
- package/dist/engine/domain/knowledge-config.d.ts.map +1 -0
- package/dist/engine/domain/knowledge-config.js +62 -0
- package/dist/engine/domain/knowledge-config.js.map +1 -0
- package/dist/engine/domain/mcp-config.d.ts +15 -0
- package/dist/engine/domain/mcp-config.d.ts.map +1 -0
- package/dist/engine/domain/mcp-config.js +26 -0
- package/dist/engine/domain/mcp-config.js.map +1 -0
- package/dist/engine/domain/memory.d.ts +17 -0
- package/dist/engine/domain/memory.d.ts.map +1 -0
- package/dist/engine/domain/memory.js +4 -0
- package/dist/engine/domain/memory.js.map +1 -0
- package/dist/engine/domain/modality.d.ts +5 -0
- package/dist/engine/domain/modality.d.ts.map +1 -0
- package/dist/engine/domain/modality.js +19 -0
- package/dist/engine/domain/modality.js.map +1 -0
- package/dist/engine/domain/orchestrator-config.d.ts +11 -0
- package/dist/engine/domain/orchestrator-config.d.ts.map +1 -0
- package/dist/engine/domain/orchestrator-config.js +4 -0
- package/dist/engine/domain/orchestrator-config.js.map +1 -0
- package/dist/engine/domain/prompt-assembler.d.ts +32 -0
- package/dist/engine/domain/prompt-assembler.d.ts.map +1 -0
- package/dist/engine/domain/prompt-assembler.js +60 -0
- package/dist/engine/domain/prompt-assembler.js.map +1 -0
- package/dist/engine/domain/safety-config.d.ts +51 -0
- package/dist/engine/domain/safety-config.d.ts.map +1 -0
- package/dist/engine/domain/safety-config.js +74 -0
- package/dist/engine/domain/safety-config.js.map +1 -0
- package/dist/engine/domain/speech-config.d.ts +53 -0
- package/dist/engine/domain/speech-config.d.ts.map +1 -0
- package/dist/engine/domain/speech-config.js +26 -0
- package/dist/engine/domain/speech-config.js.map +1 -0
- package/dist/engine/domain/task.d.ts +16 -0
- package/dist/engine/domain/task.d.ts.map +1 -0
- package/dist/engine/domain/task.js +4 -0
- package/dist/engine/domain/task.js.map +1 -0
- package/dist/engine/domain/tool-selection-config.d.ts +12 -0
- package/dist/engine/domain/tool-selection-config.d.ts.map +1 -0
- package/dist/engine/domain/tool-selection-config.js +22 -0
- package/dist/engine/domain/tool-selection-config.js.map +1 -0
- package/dist/engine/domain/trigger.d.ts +43 -0
- package/dist/engine/domain/trigger.d.ts.map +1 -0
- package/dist/engine/domain/trigger.js +39 -0
- package/dist/engine/domain/trigger.js.map +1 -0
- package/dist/engine/domain/vector-store.d.ts +27 -0
- package/dist/engine/domain/vector-store.d.ts.map +1 -0
- package/dist/engine/domain/vector-store.js +3 -0
- package/dist/engine/domain/vector-store.js.map +1 -0
- package/dist/engine/domain/workflow.d.ts +11 -0
- package/dist/engine/domain/workflow.d.ts.map +1 -0
- package/dist/engine/domain/workflow.js +4 -0
- package/dist/engine/domain/workflow.js.map +1 -0
- package/dist/engine/error-catalog.d.ts +8 -0
- package/dist/engine/error-catalog.d.ts.map +1 -0
- package/dist/engine/error-catalog.js +335 -0
- package/dist/engine/error-catalog.js.map +1 -0
- package/dist/engine/errors.d.ts +18 -0
- package/dist/engine/errors.d.ts.map +1 -0
- package/dist/engine/errors.js +20 -0
- package/dist/engine/errors.js.map +1 -0
- package/dist/engine/gateway/delegation-config.d.ts +52 -0
- package/dist/engine/gateway/delegation-config.d.ts.map +1 -0
- package/dist/engine/gateway/delegation-config.js +48 -0
- package/dist/engine/gateway/delegation-config.js.map +1 -0
- package/dist/engine/gateway/gateway-config.d.ts +33 -0
- package/dist/engine/gateway/gateway-config.d.ts.map +1 -0
- package/dist/engine/gateway/gateway-config.js +61 -0
- package/dist/engine/gateway/gateway-config.js.map +1 -0
- package/dist/engine/gateway/gateway-loader.d.ts +10 -0
- package/dist/engine/gateway/gateway-loader.d.ts.map +1 -0
- package/dist/engine/gateway/gateway-loader.js +150 -0
- package/dist/engine/gateway/gateway-loader.js.map +1 -0
- package/dist/engine/gateway/mode-b-config.d.ts +44 -0
- package/dist/engine/gateway/mode-b-config.d.ts.map +1 -0
- package/dist/engine/gateway/mode-b-config.js +45 -0
- package/dist/engine/gateway/mode-b-config.js.map +1 -0
- package/dist/engine/gateway/mode-b-loader.d.ts +14 -0
- package/dist/engine/gateway/mode-b-loader.d.ts.map +1 -0
- package/dist/engine/gateway/mode-b-loader.js +104 -0
- package/dist/engine/gateway/mode-b-loader.js.map +1 -0
- package/dist/engine/gateway/observability-config.d.ts +19 -0
- package/dist/engine/gateway/observability-config.d.ts.map +1 -0
- package/dist/engine/gateway/observability-config.js +27 -0
- package/dist/engine/gateway/observability-config.js.map +1 -0
- package/dist/engine/gateway/tenant-config.d.ts +59 -0
- package/dist/engine/gateway/tenant-config.d.ts.map +1 -0
- package/dist/engine/gateway/tenant-config.js +44 -0
- package/dist/engine/gateway/tenant-config.js.map +1 -0
- package/dist/engine/index.d.ts +49 -0
- package/dist/engine/index.d.ts.map +1 -0
- package/dist/engine/index.js +27 -0
- package/dist/engine/index.js.map +1 -0
- package/dist/engine/loader/app-loader.d.ts +18 -0
- package/dist/engine/loader/app-loader.d.ts.map +1 -0
- package/dist/engine/loader/app-loader.js +947 -0
- package/dist/engine/loader/app-loader.js.map +1 -0
- package/dist/engine/loader/preset-loader.d.ts +13 -0
- package/dist/engine/loader/preset-loader.d.ts.map +1 -0
- package/dist/engine/loader/preset-loader.js +51 -0
- package/dist/engine/loader/preset-loader.js.map +1 -0
- package/dist/eval/dataset-loader.d.ts +3 -0
- package/dist/eval/dataset-loader.d.ts.map +1 -0
- package/dist/eval/dataset-loader.js +70 -0
- package/dist/eval/dataset-loader.js.map +1 -0
- package/dist/eval/experiment-comparator.d.ts +16 -0
- package/dist/eval/experiment-comparator.d.ts.map +1 -0
- package/dist/eval/experiment-comparator.js +34 -0
- package/dist/eval/experiment-comparator.js.map +1 -0
- package/dist/eval/experiment-runner.d.ts +20 -0
- package/dist/eval/experiment-runner.d.ts.map +1 -0
- package/dist/eval/experiment-runner.js +54 -0
- package/dist/eval/experiment-runner.js.map +1 -0
- package/dist/eval/index.d.ts +21 -0
- package/dist/eval/index.d.ts.map +1 -0
- package/dist/eval/index.js +19 -0
- package/dist/eval/index.js.map +1 -0
- package/dist/eval/scorer-factory.d.ts +4 -0
- package/dist/eval/scorer-factory.d.ts.map +1 -0
- package/dist/eval/scorer-factory.js +67 -0
- package/dist/eval/scorer-factory.js.map +1 -0
- package/dist/eval/scorers/coherence-scorer.d.ts +8 -0
- package/dist/eval/scorers/coherence-scorer.d.ts.map +1 -0
- package/dist/eval/scorers/coherence-scorer.js +22 -0
- package/dist/eval/scorers/coherence-scorer.js.map +1 -0
- package/dist/eval/scorers/composite-scorer.d.ts +8 -0
- package/dist/eval/scorers/composite-scorer.d.ts.map +1 -0
- package/dist/eval/scorers/composite-scorer.js +19 -0
- package/dist/eval/scorers/composite-scorer.js.map +1 -0
- package/dist/eval/scorers/contains-scorer.d.ts +8 -0
- package/dist/eval/scorers/contains-scorer.d.ts.map +1 -0
- package/dist/eval/scorers/contains-scorer.js +30 -0
- package/dist/eval/scorers/contains-scorer.js.map +1 -0
- package/dist/eval/scorers/cost-scorer.d.ts +8 -0
- package/dist/eval/scorers/cost-scorer.d.ts.map +1 -0
- package/dist/eval/scorers/cost-scorer.js +19 -0
- package/dist/eval/scorers/cost-scorer.js.map +1 -0
- package/dist/eval/scorers/custom-prompt-scorer.d.ts +9 -0
- package/dist/eval/scorers/custom-prompt-scorer.d.ts.map +1 -0
- package/dist/eval/scorers/custom-prompt-scorer.js +24 -0
- package/dist/eval/scorers/custom-prompt-scorer.js.map +1 -0
- package/dist/eval/scorers/exact-match-scorer.d.ts +6 -0
- package/dist/eval/scorers/exact-match-scorer.d.ts.map +1 -0
- package/dist/eval/scorers/exact-match-scorer.js +16 -0
- package/dist/eval/scorers/exact-match-scorer.js.map +1 -0
- package/dist/eval/scorers/faithfulness-scorer.d.ts +8 -0
- package/dist/eval/scorers/faithfulness-scorer.d.ts.map +1 -0
- package/dist/eval/scorers/faithfulness-scorer.js +27 -0
- package/dist/eval/scorers/faithfulness-scorer.js.map +1 -0
- package/dist/eval/scorers/hallucination-scorer.d.ts +8 -0
- package/dist/eval/scorers/hallucination-scorer.d.ts.map +1 -0
- package/dist/eval/scorers/hallucination-scorer.js +31 -0
- package/dist/eval/scorers/hallucination-scorer.js.map +1 -0
- package/dist/eval/scorers/json-validity-scorer.d.ts +8 -0
- package/dist/eval/scorers/json-validity-scorer.d.ts.map +1 -0
- package/dist/eval/scorers/json-validity-scorer.js +32 -0
- package/dist/eval/scorers/json-validity-scorer.js.map +1 -0
- package/dist/eval/scorers/latency-scorer.d.ts +8 -0
- package/dist/eval/scorers/latency-scorer.d.ts.map +1 -0
- package/dist/eval/scorers/latency-scorer.js +19 -0
- package/dist/eval/scorers/latency-scorer.js.map +1 -0
- package/dist/eval/scorers/length-scorer.d.ts +9 -0
- package/dist/eval/scorers/length-scorer.d.ts.map +1 -0
- package/dist/eval/scorers/length-scorer.js +26 -0
- package/dist/eval/scorers/length-scorer.js.map +1 -0
- package/dist/eval/scorers/parse-llm-response.d.ts +5 -0
- package/dist/eval/scorers/parse-llm-response.d.ts.map +1 -0
- package/dist/eval/scorers/parse-llm-response.js +13 -0
- package/dist/eval/scorers/parse-llm-response.js.map +1 -0
- package/dist/eval/scorers/relevance-scorer.d.ts +8 -0
- package/dist/eval/scorers/relevance-scorer.d.ts.map +1 -0
- package/dist/eval/scorers/relevance-scorer.js +23 -0
- package/dist/eval/scorers/relevance-scorer.js.map +1 -0
- package/dist/eval/scorers/toxicity-scorer.d.ts +8 -0
- package/dist/eval/scorers/toxicity-scorer.d.ts.map +1 -0
- package/dist/eval/scorers/toxicity-scorer.js +26 -0
- package/dist/eval/scorers/toxicity-scorer.js.map +1 -0
- package/dist/eval/types.d.ts +51 -0
- package/dist/eval/types.d.ts.map +1 -0
- package/dist/eval/types.js +3 -0
- package/dist/eval/types.js.map +1 -0
- package/dist/events/event-bus.d.ts +36 -0
- package/dist/events/event-bus.d.ts.map +1 -0
- package/dist/events/event-bus.js +116 -0
- package/dist/events/event-bus.js.map +1 -0
- package/dist/events/event-store.d.ts +11 -0
- package/dist/events/event-store.d.ts.map +1 -0
- package/dist/events/event-store.js +2 -0
- package/dist/events/event-store.js.map +1 -0
- package/dist/events/index.d.ts +295 -0
- package/dist/events/index.d.ts.map +1 -0
- package/dist/events/index.js +48 -0
- package/dist/events/index.js.map +1 -0
- package/dist/events/trace.d.ts +30 -0
- package/dist/events/trace.d.ts.map +1 -0
- package/dist/events/trace.js +45 -0
- package/dist/events/trace.js.map +1 -0
- package/dist/index.d.ts +58 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +42 -0
- package/dist/index.js.map +1 -0
- package/dist/knowledge/index.d.ts +10 -0
- package/dist/knowledge/index.d.ts.map +1 -0
- package/dist/knowledge/index.js +9 -0
- package/dist/knowledge/index.js.map +1 -0
- package/dist/knowledge/infrastructure/memory-vector-store.d.ts +12 -0
- package/dist/knowledge/infrastructure/memory-vector-store.d.ts.map +1 -0
- package/dist/knowledge/infrastructure/memory-vector-store.js +71 -0
- package/dist/knowledge/infrastructure/memory-vector-store.js.map +1 -0
- package/dist/knowledge/infrastructure/ollama-embedding.d.ts +15 -0
- package/dist/knowledge/infrastructure/ollama-embedding.d.ts.map +1 -0
- package/dist/knowledge/infrastructure/ollama-embedding.js +38 -0
- package/dist/knowledge/infrastructure/ollama-embedding.js.map +1 -0
- package/dist/knowledge/infrastructure/openai-embedding.d.ts +18 -0
- package/dist/knowledge/infrastructure/openai-embedding.d.ts.map +1 -0
- package/dist/knowledge/infrastructure/openai-embedding.js +66 -0
- package/dist/knowledge/infrastructure/openai-embedding.js.map +1 -0
- package/dist/knowledge/knowledge-capability.d.ts +15 -0
- package/dist/knowledge/knowledge-capability.d.ts.map +1 -0
- package/dist/knowledge/knowledge-capability.js +36 -0
- package/dist/knowledge/knowledge-capability.js.map +1 -0
- package/dist/knowledge/markdown-chunker.d.ts +8 -0
- package/dist/knowledge/markdown-chunker.d.ts.map +1 -0
- package/dist/knowledge/markdown-chunker.js +146 -0
- package/dist/knowledge/markdown-chunker.js.map +1 -0
- package/dist/knowledge/recursive-chunker.d.ts +8 -0
- package/dist/knowledge/recursive-chunker.d.ts.map +1 -0
- package/dist/knowledge/recursive-chunker.js +73 -0
- package/dist/knowledge/recursive-chunker.js.map +1 -0
- package/dist/knowledge/reranker.d.ts +5 -0
- package/dist/knowledge/reranker.d.ts.map +1 -0
- package/dist/knowledge/reranker.js +3 -0
- package/dist/knowledge/reranker.js.map +1 -0
- package/dist/knowledge/retrieval-pipeline.d.ts +26 -0
- package/dist/knowledge/retrieval-pipeline.d.ts.map +1 -0
- package/dist/knowledge/retrieval-pipeline.js +56 -0
- package/dist/knowledge/retrieval-pipeline.js.map +1 -0
- package/dist/memory/chunk-importer.d.ts +16 -0
- package/dist/memory/chunk-importer.d.ts.map +1 -0
- package/dist/memory/chunk-importer.js +58 -0
- package/dist/memory/chunk-importer.js.map +1 -0
- package/dist/memory/compactor.d.ts +59 -0
- package/dist/memory/compactor.d.ts.map +1 -0
- package/dist/memory/compactor.js +100 -0
- package/dist/memory/compactor.js.map +1 -0
- package/dist/memory/decay-curves.d.ts +33 -0
- package/dist/memory/decay-curves.d.ts.map +1 -0
- package/dist/memory/decay-curves.js +48 -0
- package/dist/memory/decay-curves.js.map +1 -0
- package/dist/memory/developer-identity.d.ts +7 -0
- package/dist/memory/developer-identity.d.ts.map +1 -0
- package/dist/memory/developer-identity.js +20 -0
- package/dist/memory/developer-identity.js.map +1 -0
- package/dist/memory/git-sync-manager.d.ts +28 -0
- package/dist/memory/git-sync-manager.d.ts.map +1 -0
- package/dist/memory/git-sync-manager.js +77 -0
- package/dist/memory/git-sync-manager.js.map +1 -0
- package/dist/memory/index.d.ts +46 -0
- package/dist/memory/index.d.ts.map +1 -0
- package/dist/memory/index.js +11 -0
- package/dist/memory/index.js.map +1 -0
- package/dist/memory/memory-manager.d.ts +34 -0
- package/dist/memory/memory-manager.d.ts.map +1 -0
- package/dist/memory/memory-manager.js +151 -0
- package/dist/memory/memory-manager.js.map +1 -0
- package/dist/memory/project-store.d.ts +28 -0
- package/dist/memory/project-store.d.ts.map +1 -0
- package/dist/memory/project-store.js +159 -0
- package/dist/memory/project-store.js.map +1 -0
- package/dist/memory/sqlite-store.d.ts +41 -0
- package/dist/memory/sqlite-store.d.ts.map +1 -0
- package/dist/memory/sqlite-store.js +320 -0
- package/dist/memory/sqlite-store.js.map +1 -0
- package/dist/observability/index.d.ts +5 -0
- package/dist/observability/index.d.ts.map +1 -0
- package/dist/observability/index.js +3 -0
- package/dist/observability/index.js.map +1 -0
- package/dist/observability/otel-exporter.d.ts +41 -0
- package/dist/observability/otel-exporter.d.ts.map +1 -0
- package/dist/observability/otel-exporter.js +166 -0
- package/dist/observability/otel-exporter.js.map +1 -0
- package/dist/observability/span-mapper.d.ts +24 -0
- package/dist/observability/span-mapper.d.ts.map +1 -0
- package/dist/observability/span-mapper.js +375 -0
- package/dist/observability/span-mapper.js.map +1 -0
- package/dist/orchestrator/checkpoint-store.d.ts +9 -0
- package/dist/orchestrator/checkpoint-store.d.ts.map +1 -0
- package/dist/orchestrator/checkpoint-store.js +2 -0
- package/dist/orchestrator/checkpoint-store.js.map +1 -0
- package/dist/orchestrator/checkpoint-types.d.ts +30 -0
- package/dist/orchestrator/checkpoint-types.d.ts.map +1 -0
- package/dist/orchestrator/checkpoint-types.js +2 -0
- package/dist/orchestrator/checkpoint-types.js.map +1 -0
- package/dist/orchestrator/guardrails.d.ts +23 -0
- package/dist/orchestrator/guardrails.d.ts.map +1 -0
- package/dist/orchestrator/guardrails.js +136 -0
- package/dist/orchestrator/guardrails.js.map +1 -0
- package/dist/orchestrator/index.d.ts +45 -0
- package/dist/orchestrator/index.d.ts.map +1 -0
- package/dist/orchestrator/index.js +8 -0
- package/dist/orchestrator/index.js.map +1 -0
- package/dist/orchestrator/interrupt.d.ts +20 -0
- package/dist/orchestrator/interrupt.d.ts.map +1 -0
- package/dist/orchestrator/interrupt.js +4 -0
- package/dist/orchestrator/interrupt.js.map +1 -0
- package/dist/orchestrator/orchestrator.d.ts +170 -0
- package/dist/orchestrator/orchestrator.d.ts.map +1 -0
- package/dist/orchestrator/orchestrator.js +509 -0
- package/dist/orchestrator/orchestrator.js.map +1 -0
- package/dist/orchestrator/phase-machine.d.ts +48 -0
- package/dist/orchestrator/phase-machine.d.ts.map +1 -0
- package/dist/orchestrator/phase-machine.js +176 -0
- package/dist/orchestrator/phase-machine.js.map +1 -0
- package/dist/orchestrator/schemas.d.ts +145 -0
- package/dist/orchestrator/schemas.d.ts.map +1 -0
- package/dist/orchestrator/schemas.js +126 -0
- package/dist/orchestrator/schemas.js.map +1 -0
- package/dist/orchestrator/sqlite-checkpoint-store.d.ts +15 -0
- package/dist/orchestrator/sqlite-checkpoint-store.d.ts.map +1 -0
- package/dist/orchestrator/sqlite-checkpoint-store.js +98 -0
- package/dist/orchestrator/sqlite-checkpoint-store.js.map +1 -0
- package/dist/orchestrator/strategies/index.d.ts +28 -0
- package/dist/orchestrator/strategies/index.d.ts.map +1 -0
- package/dist/orchestrator/strategies/index.js +20 -0
- package/dist/orchestrator/strategies/index.js.map +1 -0
- package/dist/orchestrator/strategies/sequential-strategy.d.ts +13 -0
- package/dist/orchestrator/strategies/sequential-strategy.d.ts.map +1 -0
- package/dist/orchestrator/strategies/sequential-strategy.js +29 -0
- package/dist/orchestrator/strategies/sequential-strategy.js.map +1 -0
- package/dist/orchestrator/strategies/supervisor-strategy.d.ts +43 -0
- package/dist/orchestrator/strategies/supervisor-strategy.d.ts.map +1 -0
- package/dist/orchestrator/strategies/supervisor-strategy.js +118 -0
- package/dist/orchestrator/strategies/supervisor-strategy.js.map +1 -0
- package/dist/orchestrator/strategies/swarm-strategy.d.ts +36 -0
- package/dist/orchestrator/strategies/swarm-strategy.d.ts.map +1 -0
- package/dist/orchestrator/strategies/swarm-strategy.js +126 -0
- package/dist/orchestrator/strategies/swarm-strategy.js.map +1 -0
- package/dist/package/index.d.ts +7 -0
- package/dist/package/index.d.ts.map +1 -0
- package/dist/package/index.js +6 -0
- package/dist/package/index.js.map +1 -0
- package/dist/package/security.d.ts +18 -0
- package/dist/package/security.d.ts.map +1 -0
- package/dist/package/security.js +110 -0
- package/dist/package/security.js.map +1 -0
- package/dist/package/types.d.ts +34 -0
- package/dist/package/types.d.ts.map +1 -0
- package/dist/package/types.js +4 -0
- package/dist/package/types.js.map +1 -0
- package/dist/package/yaml-parser.d.ts +22 -0
- package/dist/package/yaml-parser.d.ts.map +1 -0
- package/dist/package/yaml-parser.js +109 -0
- package/dist/package/yaml-parser.js.map +1 -0
- package/dist/package/yaml-schema.d.ts +42 -0
- package/dist/package/yaml-schema.d.ts.map +1 -0
- package/dist/package/yaml-schema.js +141 -0
- package/dist/package/yaml-schema.js.map +1 -0
- package/dist/safety/content-classifier.d.ts +31 -0
- package/dist/safety/content-classifier.d.ts.map +1 -0
- package/dist/safety/content-classifier.js +107 -0
- package/dist/safety/content-classifier.js.map +1 -0
- package/dist/safety/index.d.ts +10 -0
- package/dist/safety/index.d.ts.map +1 -0
- package/dist/safety/index.js +10 -0
- package/dist/safety/index.js.map +1 -0
- package/dist/safety/pii-scanner.d.ts +26 -0
- package/dist/safety/pii-scanner.d.ts.map +1 -0
- package/dist/safety/pii-scanner.js +82 -0
- package/dist/safety/pii-scanner.js.map +1 -0
- package/dist/safety/rails.d.ts +33 -0
- package/dist/safety/rails.d.ts.map +1 -0
- package/dist/safety/rails.js +134 -0
- package/dist/safety/rails.js.map +1 -0
- package/dist/safety/safety-pipeline.d.ts +41 -0
- package/dist/safety/safety-pipeline.d.ts.map +1 -0
- package/dist/safety/safety-pipeline.js +153 -0
- package/dist/safety/safety-pipeline.js.map +1 -0
- package/dist/safety/types.d.ts +38 -0
- package/dist/safety/types.d.ts.map +1 -0
- package/dist/safety/types.js +3 -0
- package/dist/safety/types.js.map +1 -0
- package/dist/sandbox/index.d.ts +17 -0
- package/dist/sandbox/index.d.ts.map +1 -0
- package/dist/sandbox/index.js +4 -0
- package/dist/sandbox/index.js.map +1 -0
- package/dist/sandbox/network-filter.d.ts +13 -0
- package/dist/sandbox/network-filter.d.ts.map +1 -0
- package/dist/sandbox/network-filter.js +43 -0
- package/dist/sandbox/network-filter.js.map +1 -0
- package/dist/sandbox/path-validator.d.ts +16 -0
- package/dist/sandbox/path-validator.d.ts.map +1 -0
- package/dist/sandbox/path-validator.js +47 -0
- package/dist/sandbox/path-validator.js.map +1 -0
- package/dist/sandbox/policies.d.ts +38 -0
- package/dist/sandbox/policies.d.ts.map +1 -0
- package/dist/sandbox/policies.js +145 -0
- package/dist/sandbox/policies.js.map +1 -0
- package/dist/security/audit-log.d.ts +17 -0
- package/dist/security/audit-log.d.ts.map +1 -0
- package/dist/security/audit-log.js +214 -0
- package/dist/security/audit-log.js.map +1 -0
- package/dist/security/guardian.d.ts +24 -0
- package/dist/security/guardian.d.ts.map +1 -0
- package/dist/security/guardian.js +177 -0
- package/dist/security/guardian.js.map +1 -0
- package/dist/security/index.d.ts +10 -0
- package/dist/security/index.d.ts.map +1 -0
- package/dist/security/index.js +7 -0
- package/dist/security/index.js.map +1 -0
- package/dist/security/prompt-scanner.d.ts +23 -0
- package/dist/security/prompt-scanner.d.ts.map +1 -0
- package/dist/security/prompt-scanner.js +376 -0
- package/dist/security/prompt-scanner.js.map +1 -0
- package/dist/security/secret-store.d.ts +18 -0
- package/dist/security/secret-store.d.ts.map +1 -0
- package/dist/security/secret-store.js +123 -0
- package/dist/security/secret-store.js.map +1 -0
- package/dist/security/self-audit.d.ts +33 -0
- package/dist/security/self-audit.d.ts.map +1 -0
- package/dist/security/self-audit.js +142 -0
- package/dist/security/self-audit.js.map +1 -0
- package/dist/security/types.d.ts +107 -0
- package/dist/security/types.d.ts.map +1 -0
- package/dist/security/types.js +3 -0
- package/dist/security/types.js.map +1 -0
- package/dist/skill/index.d.ts +7 -0
- package/dist/skill/index.d.ts.map +1 -0
- package/dist/skill/index.js +4 -0
- package/dist/skill/index.js.map +1 -0
- package/dist/skill/skill-registry.d.ts +26 -0
- package/dist/skill/skill-registry.d.ts.map +1 -0
- package/dist/skill/skill-registry.js +81 -0
- package/dist/skill/skill-registry.js.map +1 -0
- package/dist/skill/types.d.ts +17 -0
- package/dist/skill/types.d.ts.map +1 -0
- package/dist/skill/types.js +2 -0
- package/dist/skill/types.js.map +1 -0
- package/dist/skill/yaml-parser.d.ts +18 -0
- package/dist/skill/yaml-parser.d.ts.map +1 -0
- package/dist/skill/yaml-parser.js +61 -0
- package/dist/skill/yaml-parser.js.map +1 -0
- package/dist/skill/yaml-schema.d.ts +20 -0
- package/dist/skill/yaml-schema.d.ts.map +1 -0
- package/dist/skill/yaml-schema.js +80 -0
- package/dist/skill/yaml-schema.js.map +1 -0
- package/dist/tree/batch-executor.d.ts +28 -0
- package/dist/tree/batch-executor.d.ts.map +1 -0
- package/dist/tree/batch-executor.js +78 -0
- package/dist/tree/batch-executor.js.map +1 -0
- package/dist/tree/index.d.ts +26 -0
- package/dist/tree/index.d.ts.map +1 -0
- package/dist/tree/index.js +3 -0
- package/dist/tree/index.js.map +1 -0
- package/dist/tree/task-tree.d.ts +74 -0
- package/dist/tree/task-tree.d.ts.map +1 -0
- package/dist/tree/task-tree.js +262 -0
- package/dist/tree/task-tree.js.map +1 -0
- package/dist/verification/coverage-parser.d.ts +6 -0
- package/dist/verification/coverage-parser.d.ts.map +1 -0
- package/dist/verification/coverage-parser.js +29 -0
- package/dist/verification/coverage-parser.js.map +1 -0
- package/dist/verification/gate-runner.d.ts +18 -0
- package/dist/verification/gate-runner.d.ts.map +1 -0
- package/dist/verification/gate-runner.js +63 -0
- package/dist/verification/gate-runner.js.map +1 -0
- package/dist/verification/index.d.ts +24 -0
- package/dist/verification/index.d.ts.map +1 -0
- package/dist/verification/index.js +4 -0
- package/dist/verification/index.js.map +1 -0
- package/dist/verification/verification-loop.d.ts +32 -0
- package/dist/verification/verification-loop.d.ts.map +1 -0
- package/dist/verification/verification-loop.js +71 -0
- package/dist/verification/verification-loop.js.map +1 -0
- package/package.json +58 -0
|
@@ -0,0 +1,947 @@
|
|
|
1
|
+
// Engine loader: AppLoader -- parses App YAML into typed composites
|
|
2
|
+
// Validates dependency graph: team refs in router must exist in teams
|
|
3
|
+
import { parse } from "yaml";
|
|
4
|
+
import { KilnError } from "../errors.js";
|
|
5
|
+
import { validateApp } from "../composites/app.js";
|
|
6
|
+
import { VALID_MODALITIES } from "../domain/modality.js";
|
|
7
|
+
import { validateVoiceConfig } from "../domain/speech-config.js";
|
|
8
|
+
import { validateKnowledgeConfig } from "../domain/knowledge-config.js";
|
|
9
|
+
import { validateEvalConfig } from "../domain/eval-config.js";
|
|
10
|
+
import { validateMcpConfig } from "../domain/mcp-config.js";
|
|
11
|
+
import { validateToolSelectionConfig } from "../domain/tool-selection-config.js";
|
|
12
|
+
import { validateSafetyConfig } from "../domain/safety-config.js";
|
|
13
|
+
/** Error class for YAML loader failures, aggregating all validation errors */
|
|
14
|
+
export class AppLoaderError extends KilnError {
|
|
15
|
+
errors;
|
|
16
|
+
constructor(errors) {
|
|
17
|
+
const msg = errors.map((e) => ` ${e.field}: ${e.message}`).join("\n");
|
|
18
|
+
super("APP_YAML_INVALID", `Invalid app YAML:\n${msg}`, {
|
|
19
|
+
context: { errors },
|
|
20
|
+
retryable: false,
|
|
21
|
+
});
|
|
22
|
+
this.name = "AppLoaderError";
|
|
23
|
+
this.errors = errors;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
// ---------------------------------------------------------------------------
|
|
27
|
+
// Mapping helpers
|
|
28
|
+
// ---------------------------------------------------------------------------
|
|
29
|
+
const VALID_TIERS = ["reasoning", "coding", "fast"];
|
|
30
|
+
function mapAgent(identifier, raw, path) {
|
|
31
|
+
const errors = [];
|
|
32
|
+
// name: persona name from YAML (required) -- falls back to identifier for safety
|
|
33
|
+
const name = typeof raw.name === "string" && raw.name.trim() !== ""
|
|
34
|
+
? raw.name.trim()
|
|
35
|
+
: identifier;
|
|
36
|
+
if (!raw.name || typeof raw.name !== "string" || raw.name.trim() === "") {
|
|
37
|
+
errors.push({ field: `${path}.name`, message: "must be a non-empty string (persona name)" });
|
|
38
|
+
}
|
|
39
|
+
// role: expertise / function (required)
|
|
40
|
+
const role = typeof raw.role === "string" ? raw.role.trim() : "";
|
|
41
|
+
if (!raw.role || typeof raw.role !== "string" || raw.role.trim() === "") {
|
|
42
|
+
errors.push({ field: `${path}.role`, message: "must be a non-empty string (expertise/function)" });
|
|
43
|
+
}
|
|
44
|
+
// goal: what agent is trying to achieve (required)
|
|
45
|
+
const goal = typeof raw.goal === "string" ? raw.goal.trim() : "";
|
|
46
|
+
if (!raw.goal || typeof raw.goal !== "string" || raw.goal.trim() === "") {
|
|
47
|
+
errors.push({ field: `${path}.goal`, message: "must be a non-empty string (what agent achieves)" });
|
|
48
|
+
}
|
|
49
|
+
// tier: model class (required)
|
|
50
|
+
const tier = raw.tier;
|
|
51
|
+
if (!tier || !VALID_TIERS.includes(tier)) {
|
|
52
|
+
errors.push({ field: `${path}.tier`, message: `must be one of: ${VALID_TIERS.join(", ")}` });
|
|
53
|
+
}
|
|
54
|
+
// tools: capability references (can be [])
|
|
55
|
+
const tools = [];
|
|
56
|
+
if (raw.tools !== undefined) {
|
|
57
|
+
if (!Array.isArray(raw.tools)) {
|
|
58
|
+
errors.push({ field: `${path}.tools`, message: "must be an array" });
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
for (const t of raw.tools) {
|
|
62
|
+
if (typeof t !== "string") {
|
|
63
|
+
errors.push({ field: `${path}.tools`, message: "all entries must be strings" });
|
|
64
|
+
break;
|
|
65
|
+
}
|
|
66
|
+
tools.push(t);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
// modalities: optional content type declarations
|
|
71
|
+
let modalities;
|
|
72
|
+
if (raw.modalities !== undefined) {
|
|
73
|
+
if (!Array.isArray(raw.modalities)) {
|
|
74
|
+
errors.push({ field: `${path}.modalities`, message: "must be an array" });
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
modalities = [];
|
|
78
|
+
for (const m of raw.modalities) {
|
|
79
|
+
if (typeof m !== "string") {
|
|
80
|
+
errors.push({ field: `${path}.modalities`, message: "all entries must be strings" });
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
if (!VALID_MODALITIES.includes(m)) {
|
|
84
|
+
errors.push({ field: `${path}.modalities`, message: `unknown modality "${m}", must be one of: ${VALID_MODALITIES.join(", ")}` });
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
modalities.push(m);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
const agent = {
|
|
93
|
+
name,
|
|
94
|
+
role,
|
|
95
|
+
goal,
|
|
96
|
+
tier: tier ?? "coding",
|
|
97
|
+
tools,
|
|
98
|
+
...(typeof raw.backstory === "string" ? { backstory: raw.backstory.trim() } : {}),
|
|
99
|
+
...(typeof raw.instructions === "string" ? { instructions: raw.instructions.trim() } : {}),
|
|
100
|
+
...(typeof raw.structured === "boolean" ? { structured: raw.structured } : {}),
|
|
101
|
+
...(typeof raw.count === "number" ? { count: raw.count } : {}),
|
|
102
|
+
...(typeof raw.sandbox === "boolean" ? { sandbox: raw.sandbox } : {}),
|
|
103
|
+
...(modalities && modalities.length > 0 ? { modalities } : {}),
|
|
104
|
+
};
|
|
105
|
+
return { agent, errors };
|
|
106
|
+
}
|
|
107
|
+
function mapWorkflow(raw, path) {
|
|
108
|
+
const errors = [];
|
|
109
|
+
const phases = [];
|
|
110
|
+
if (!raw.phases || !Array.isArray(raw.phases)) {
|
|
111
|
+
errors.push({ field: `${path}.phases`, message: "must be a non-empty array" });
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
for (const p of raw.phases) {
|
|
115
|
+
if (typeof p !== "string") {
|
|
116
|
+
errors.push({ field: `${path}.phases`, message: "all entries must be strings" });
|
|
117
|
+
break;
|
|
118
|
+
}
|
|
119
|
+
phases.push(p);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
const gates = {};
|
|
123
|
+
if (raw.gates !== undefined) {
|
|
124
|
+
if (typeof raw.gates !== "object" || raw.gates === null || Array.isArray(raw.gates)) {
|
|
125
|
+
errors.push({ field: `${path}.gates`, message: "must be an object" });
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
for (const [phaseName, gateRaw] of Object.entries(raw.gates)) {
|
|
129
|
+
const requires = [];
|
|
130
|
+
if (Array.isArray(gateRaw?.requires)) {
|
|
131
|
+
for (const r of gateRaw.requires) {
|
|
132
|
+
if (typeof r === "string")
|
|
133
|
+
requires.push(r);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
gates[phaseName] = { requires };
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
const workflow = {
|
|
141
|
+
phases,
|
|
142
|
+
gates,
|
|
143
|
+
...(typeof raw.maxIterations === "number" ? { maxIterations: raw.maxIterations } : {}),
|
|
144
|
+
};
|
|
145
|
+
return { workflow, errors };
|
|
146
|
+
}
|
|
147
|
+
function mapCapability(raw, path) {
|
|
148
|
+
const errors = [];
|
|
149
|
+
if (!raw.name || typeof raw.name !== "string") {
|
|
150
|
+
errors.push({ field: `${path}.name`, message: "must be a non-empty string" });
|
|
151
|
+
}
|
|
152
|
+
if (!raw.description || typeof raw.description !== "string") {
|
|
153
|
+
errors.push({ field: `${path}.description`, message: "must be a non-empty string" });
|
|
154
|
+
}
|
|
155
|
+
const tags = [];
|
|
156
|
+
if (raw.tags !== undefined) {
|
|
157
|
+
if (!Array.isArray(raw.tags)) {
|
|
158
|
+
errors.push({ field: `${path}.tags`, message: "must be an array" });
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
for (const t of raw.tags) {
|
|
162
|
+
if (typeof t === "string")
|
|
163
|
+
tags.push(t);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
// Validate guardrailRetries
|
|
168
|
+
if (raw.guardrailRetries !== undefined) {
|
|
169
|
+
if (typeof raw.guardrailRetries !== "number" || !Number.isInteger(raw.guardrailRetries) || raw.guardrailRetries < 1) {
|
|
170
|
+
errors.push({ field: `${path}.guardrailRetries`, message: "must be a positive integer" });
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
// Validate outputSchema
|
|
174
|
+
if (raw.outputSchema !== undefined) {
|
|
175
|
+
if (typeof raw.outputSchema !== "object" || raw.outputSchema === null || Array.isArray(raw.outputSchema)) {
|
|
176
|
+
errors.push({ field: `${path}.outputSchema`, message: "must be a valid object" });
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
const capability = {
|
|
180
|
+
name: typeof raw.name === "string" ? raw.name : "",
|
|
181
|
+
description: typeof raw.description === "string" ? raw.description : "",
|
|
182
|
+
schema: typeof raw.schema === "object" && raw.schema !== null && !Array.isArray(raw.schema)
|
|
183
|
+
? raw.schema
|
|
184
|
+
: {},
|
|
185
|
+
tags,
|
|
186
|
+
...(raw.annotations ? { annotations: raw.annotations } : {}),
|
|
187
|
+
...(typeof raw.type === "string" ? { type: raw.type } : {}),
|
|
188
|
+
...(typeof raw.targetApp === "string" ? { targetApp: raw.targetApp } : {}),
|
|
189
|
+
...(typeof raw.task === "string" ? { task: raw.task } : {}),
|
|
190
|
+
...(typeof raw.timeout === "number" && raw.timeout > 0 ? { timeout: raw.timeout } : {}),
|
|
191
|
+
...(typeof raw.guardrail === "string" ? { guardrail: raw.guardrail } : {}),
|
|
192
|
+
...(typeof raw.guardrailRetries === "number" && Number.isInteger(raw.guardrailRetries) && raw.guardrailRetries >= 1
|
|
193
|
+
? { guardrailRetries: raw.guardrailRetries }
|
|
194
|
+
: {}),
|
|
195
|
+
...(typeof raw.outputSchema === "object" && raw.outputSchema !== null && !Array.isArray(raw.outputSchema)
|
|
196
|
+
? { outputSchema: raw.outputSchema }
|
|
197
|
+
: {}),
|
|
198
|
+
};
|
|
199
|
+
if (raw.type === "delegation") {
|
|
200
|
+
if (typeof raw.targetApp !== "string" || raw.targetApp === "") {
|
|
201
|
+
errors.push({ field: `${path}.targetApp`, message: "required when type is 'delegation'" });
|
|
202
|
+
}
|
|
203
|
+
if (typeof raw.task !== "string" || raw.task === "") {
|
|
204
|
+
errors.push({ field: `${path}.task`, message: "required when type is 'delegation'" });
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
if (raw.type === "a2a") {
|
|
208
|
+
if (typeof raw.targetApp !== "string" || raw.targetApp === "") {
|
|
209
|
+
errors.push({ field: `${path}.targetApp`, message: "required when type is 'a2a' (must be agent URL)" });
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
return { capability, errors };
|
|
213
|
+
}
|
|
214
|
+
function mapQualityGate(raw, path) {
|
|
215
|
+
const errors = [];
|
|
216
|
+
if (!raw.name || typeof raw.name !== "string") {
|
|
217
|
+
errors.push({ field: `${path}.name`, message: "must be a non-empty string" });
|
|
218
|
+
}
|
|
219
|
+
if (!raw.command || typeof raw.command !== "string") {
|
|
220
|
+
errors.push({ field: `${path}.command`, message: "must be a non-empty string" });
|
|
221
|
+
}
|
|
222
|
+
if (!raw.description || typeof raw.description !== "string") {
|
|
223
|
+
errors.push({ field: `${path}.description`, message: "must be a non-empty string" });
|
|
224
|
+
}
|
|
225
|
+
const gate = {
|
|
226
|
+
name: typeof raw.name === "string" ? raw.name : "",
|
|
227
|
+
command: typeof raw.command === "string" ? raw.command : "",
|
|
228
|
+
description: typeof raw.description === "string" ? raw.description : "",
|
|
229
|
+
required: typeof raw.required === "boolean" ? raw.required : true,
|
|
230
|
+
};
|
|
231
|
+
return { gate, errors };
|
|
232
|
+
}
|
|
233
|
+
function mapTeam(name, raw, path) {
|
|
234
|
+
const errors = [];
|
|
235
|
+
const agents = {};
|
|
236
|
+
// Agents
|
|
237
|
+
if (!raw.agents || typeof raw.agents !== "object" || Array.isArray(raw.agents)) {
|
|
238
|
+
errors.push({ field: `${path}.agents`, message: "must be an object" });
|
|
239
|
+
}
|
|
240
|
+
else {
|
|
241
|
+
for (const [agentName, agentRaw] of Object.entries(raw.agents)) {
|
|
242
|
+
const { agent, errors: agentErrors } = mapAgent(agentName, agentRaw ?? {}, `${path}.agents.${agentName}`);
|
|
243
|
+
agents[agentName] = agent;
|
|
244
|
+
errors.push(...agentErrors);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
// Workflow
|
|
248
|
+
let workflow = { phases: [], gates: {} };
|
|
249
|
+
if (!raw.workflow || typeof raw.workflow !== "object" || Array.isArray(raw.workflow)) {
|
|
250
|
+
errors.push({ field: `${path}.workflow`, message: "must be an object" });
|
|
251
|
+
}
|
|
252
|
+
else {
|
|
253
|
+
const { workflow: wf, errors: wfErrors } = mapWorkflow(raw.workflow, `${path}.workflow`);
|
|
254
|
+
workflow = wf;
|
|
255
|
+
errors.push(...wfErrors);
|
|
256
|
+
}
|
|
257
|
+
// Capabilities
|
|
258
|
+
const capabilities = [];
|
|
259
|
+
if (raw.capabilities !== undefined) {
|
|
260
|
+
if (!Array.isArray(raw.capabilities)) {
|
|
261
|
+
errors.push({ field: `${path}.capabilities`, message: "must be an array" });
|
|
262
|
+
}
|
|
263
|
+
else {
|
|
264
|
+
for (let i = 0; i < raw.capabilities.length; i++) {
|
|
265
|
+
const { capability, errors: capErrors } = mapCapability(raw.capabilities[i], `${path}.capabilities[${i}]`);
|
|
266
|
+
capabilities.push(capability);
|
|
267
|
+
errors.push(...capErrors);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
// Quality gates -- support both `qualityGates` and `quality` keys
|
|
272
|
+
const qualityGates = [];
|
|
273
|
+
const rawGates = raw.qualityGates ?? raw.quality;
|
|
274
|
+
if (rawGates !== undefined) {
|
|
275
|
+
if (!Array.isArray(rawGates)) {
|
|
276
|
+
errors.push({ field: `${path}.qualityGates`, message: "must be an array" });
|
|
277
|
+
}
|
|
278
|
+
else {
|
|
279
|
+
for (let i = 0; i < rawGates.length; i++) {
|
|
280
|
+
const { gate, errors: gateErrors } = mapQualityGate(rawGates[i], `${path}.qualityGates[${i}]`);
|
|
281
|
+
qualityGates.push(gate);
|
|
282
|
+
errors.push(...gateErrors);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
// Mode
|
|
287
|
+
const validModes = ["sequential", "supervisor", "swarm"];
|
|
288
|
+
let mode;
|
|
289
|
+
if (raw.mode !== undefined) {
|
|
290
|
+
if (typeof raw.mode !== "string" || !validModes.includes(raw.mode)) {
|
|
291
|
+
errors.push({ field: `${path}.mode`, message: `must be one of: ${validModes.join(", ")}` });
|
|
292
|
+
}
|
|
293
|
+
else {
|
|
294
|
+
mode = raw.mode;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
// Manager
|
|
298
|
+
let manager;
|
|
299
|
+
if (raw.manager !== undefined) {
|
|
300
|
+
if (typeof raw.manager !== "string" || raw.manager === "") {
|
|
301
|
+
errors.push({ field: `${path}.manager`, message: "must be a non-empty string" });
|
|
302
|
+
}
|
|
303
|
+
else {
|
|
304
|
+
manager = raw.manager;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
const team = {
|
|
308
|
+
name,
|
|
309
|
+
agents,
|
|
310
|
+
workflow,
|
|
311
|
+
capabilities,
|
|
312
|
+
qualityGates,
|
|
313
|
+
...(mode ? { mode } : {}),
|
|
314
|
+
...(manager ? { manager } : {}),
|
|
315
|
+
};
|
|
316
|
+
return { team, errors };
|
|
317
|
+
}
|
|
318
|
+
function mapRouter(raw, path) {
|
|
319
|
+
const errors = [];
|
|
320
|
+
const rules = [];
|
|
321
|
+
if (raw.rules !== undefined) {
|
|
322
|
+
if (!Array.isArray(raw.rules)) {
|
|
323
|
+
errors.push({ field: `${path}.rules`, message: "must be an array" });
|
|
324
|
+
}
|
|
325
|
+
else {
|
|
326
|
+
for (let i = 0; i < raw.rules.length; i++) {
|
|
327
|
+
const ruleRaw = raw.rules[i];
|
|
328
|
+
if (!ruleRaw.match || typeof ruleRaw.match !== "string") {
|
|
329
|
+
errors.push({ field: `${path}.rules[${i}].match`, message: "must be a non-empty string" });
|
|
330
|
+
}
|
|
331
|
+
if (!ruleRaw.team || typeof ruleRaw.team !== "string") {
|
|
332
|
+
errors.push({ field: `${path}.rules[${i}].team`, message: "must be a non-empty string" });
|
|
333
|
+
}
|
|
334
|
+
rules.push({
|
|
335
|
+
match: typeof ruleRaw.match === "string" ? ruleRaw.match : "",
|
|
336
|
+
team: typeof ruleRaw.team === "string" ? ruleRaw.team : "",
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
if (!raw.fallback || typeof raw.fallback !== "string") {
|
|
342
|
+
errors.push({ field: `${path}.fallback`, message: "must be a non-empty string" });
|
|
343
|
+
}
|
|
344
|
+
let classifier;
|
|
345
|
+
if (raw.classifier !== undefined) {
|
|
346
|
+
const classifierRaw = raw.classifier;
|
|
347
|
+
const { agent, errors: classifierErrors } = mapAgent("classifier", { ...classifierRaw, tier: classifierRaw.tier ?? "fast" }, `${path}.classifier`);
|
|
348
|
+
classifier = agent;
|
|
349
|
+
errors.push(...classifierErrors);
|
|
350
|
+
}
|
|
351
|
+
const router = {
|
|
352
|
+
rules,
|
|
353
|
+
fallback: typeof raw.fallback === "string" ? raw.fallback : "",
|
|
354
|
+
...(classifier ? { classifier } : {}),
|
|
355
|
+
};
|
|
356
|
+
return { router, errors };
|
|
357
|
+
}
|
|
358
|
+
function mapMemory(raw, path) {
|
|
359
|
+
const errors = [];
|
|
360
|
+
const scopes = [];
|
|
361
|
+
if (!raw.scopes || !Array.isArray(raw.scopes)) {
|
|
362
|
+
errors.push({ field: `${path}.scopes`, message: "must be a non-empty array" });
|
|
363
|
+
}
|
|
364
|
+
else {
|
|
365
|
+
for (const s of raw.scopes) {
|
|
366
|
+
if (typeof s === "string")
|
|
367
|
+
scopes.push(s);
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
if (!raw.backend || typeof raw.backend !== "string") {
|
|
371
|
+
errors.push({ field: `${path}.backend`, message: "must be a non-empty string" });
|
|
372
|
+
}
|
|
373
|
+
const memory = {
|
|
374
|
+
scopes,
|
|
375
|
+
backend: typeof raw.backend === "string" ? raw.backend : "",
|
|
376
|
+
...(typeof raw.sync === "string" ? { sync: raw.sync } : {}),
|
|
377
|
+
};
|
|
378
|
+
return { memory, errors };
|
|
379
|
+
}
|
|
380
|
+
const VALID_TRIGGER_TYPES = ["webhook", "event", "schedule"];
|
|
381
|
+
function mapTrigger(raw, path) {
|
|
382
|
+
const errors = [];
|
|
383
|
+
if (!raw.name || typeof raw.name !== "string") {
|
|
384
|
+
errors.push({ field: `${path}.name`, message: "must be a non-empty string" });
|
|
385
|
+
}
|
|
386
|
+
if (!raw.type || typeof raw.type !== "string" || !VALID_TRIGGER_TYPES.includes(raw.type)) {
|
|
387
|
+
errors.push({ field: `${path}.type`, message: `must be one of: ${VALID_TRIGGER_TYPES.join(", ")}` });
|
|
388
|
+
}
|
|
389
|
+
if (!raw.team || typeof raw.team !== "string") {
|
|
390
|
+
errors.push({ field: `${path}.team`, message: "must be a non-empty string" });
|
|
391
|
+
}
|
|
392
|
+
const base = {
|
|
393
|
+
name: typeof raw.name === "string" ? raw.name : "",
|
|
394
|
+
team: typeof raw.team === "string" ? raw.team : "",
|
|
395
|
+
...(typeof raw.task === "string" ? { task: raw.task } : {}),
|
|
396
|
+
...(typeof raw.enabled === "boolean" ? { enabled: raw.enabled } : {}),
|
|
397
|
+
};
|
|
398
|
+
const type = typeof raw.type === "string" ? raw.type : "";
|
|
399
|
+
switch (type) {
|
|
400
|
+
case "webhook": {
|
|
401
|
+
if (!raw.path || typeof raw.path !== "string") {
|
|
402
|
+
errors.push({ field: `${path}.path`, message: "must be a non-empty string" });
|
|
403
|
+
}
|
|
404
|
+
const trigger = {
|
|
405
|
+
...base,
|
|
406
|
+
type: "webhook",
|
|
407
|
+
path: typeof raw.path === "string" ? raw.path : "",
|
|
408
|
+
...(typeof raw.method === "string" ? { method: raw.method } : {}),
|
|
409
|
+
...(typeof raw.secretEnv === "string" ? { secretEnv: raw.secretEnv } : {}),
|
|
410
|
+
};
|
|
411
|
+
return { trigger, errors };
|
|
412
|
+
}
|
|
413
|
+
case "event": {
|
|
414
|
+
if (!raw.event || typeof raw.event !== "string") {
|
|
415
|
+
errors.push({ field: `${path}.event`, message: "must be a non-empty string" });
|
|
416
|
+
}
|
|
417
|
+
const trigger = {
|
|
418
|
+
...base,
|
|
419
|
+
type: "event",
|
|
420
|
+
event: typeof raw.event === "string" ? raw.event : "",
|
|
421
|
+
...(raw.filter && typeof raw.filter === "object" && !Array.isArray(raw.filter)
|
|
422
|
+
? { filter: raw.filter }
|
|
423
|
+
: {}),
|
|
424
|
+
};
|
|
425
|
+
return { trigger, errors };
|
|
426
|
+
}
|
|
427
|
+
case "schedule": {
|
|
428
|
+
if (!raw.cron || typeof raw.cron !== "string") {
|
|
429
|
+
errors.push({ field: `${path}.cron`, message: "must be a non-empty string" });
|
|
430
|
+
}
|
|
431
|
+
const trigger = {
|
|
432
|
+
...base,
|
|
433
|
+
type: "schedule",
|
|
434
|
+
cron: typeof raw.cron === "string" ? raw.cron : "",
|
|
435
|
+
...(typeof raw.timezone === "string" ? { timezone: raw.timezone } : {}),
|
|
436
|
+
};
|
|
437
|
+
return { trigger, errors };
|
|
438
|
+
}
|
|
439
|
+
default: {
|
|
440
|
+
// Return a webhook trigger as placeholder to satisfy the type system; the type error was already recorded
|
|
441
|
+
const trigger = {
|
|
442
|
+
...base,
|
|
443
|
+
type: "webhook",
|
|
444
|
+
path: "",
|
|
445
|
+
};
|
|
446
|
+
return { trigger, errors };
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
function mapKnowledge(raw) {
|
|
451
|
+
const errors = [];
|
|
452
|
+
if (!raw || typeof raw !== "object") {
|
|
453
|
+
return { knowledge: undefined, errors: [] };
|
|
454
|
+
}
|
|
455
|
+
const rawEmbedding = raw.embedding;
|
|
456
|
+
const rawStore = raw.store;
|
|
457
|
+
const rawChunking = raw.chunking;
|
|
458
|
+
const embedding = {
|
|
459
|
+
provider: (typeof rawEmbedding?.provider === "string" ? rawEmbedding.provider : ""),
|
|
460
|
+
model: typeof rawEmbedding?.model === "string" ? rawEmbedding.model : undefined,
|
|
461
|
+
apiKeyEnv: typeof rawEmbedding?.apiKeyEnv === "string" ? rawEmbedding.apiKeyEnv : undefined,
|
|
462
|
+
baseUrl: typeof rawEmbedding?.baseUrl === "string" ? rawEmbedding.baseUrl : undefined,
|
|
463
|
+
};
|
|
464
|
+
const store = {
|
|
465
|
+
backend: (typeof rawStore?.backend === "string" ? rawStore.backend : ""),
|
|
466
|
+
connectionString: typeof rawStore?.connectionString === "string" ? rawStore.connectionString : undefined,
|
|
467
|
+
};
|
|
468
|
+
const chunking = {
|
|
469
|
+
strategy: (typeof rawChunking?.strategy === "string" ? rawChunking.strategy : ""),
|
|
470
|
+
chunkSize: typeof rawChunking?.chunkSize === "number" ? rawChunking.chunkSize : undefined,
|
|
471
|
+
chunkOverlap: typeof rawChunking?.chunkOverlap === "number" ? rawChunking.chunkOverlap : undefined,
|
|
472
|
+
};
|
|
473
|
+
const sources = [];
|
|
474
|
+
if (Array.isArray(raw.sources)) {
|
|
475
|
+
for (let i = 0; i < raw.sources.length; i++) {
|
|
476
|
+
const source = raw.sources[i];
|
|
477
|
+
if (!source)
|
|
478
|
+
continue;
|
|
479
|
+
const rawSourceChunking = source.chunking;
|
|
480
|
+
const sourceChunking = rawSourceChunking ? {
|
|
481
|
+
strategy: (typeof rawSourceChunking.strategy === "string" ? rawSourceChunking.strategy : ""),
|
|
482
|
+
chunkSize: typeof rawSourceChunking.chunkSize === "number" ? rawSourceChunking.chunkSize : undefined,
|
|
483
|
+
chunkOverlap: typeof rawSourceChunking.chunkOverlap === "number" ? rawSourceChunking.chunkOverlap : undefined,
|
|
484
|
+
} : undefined;
|
|
485
|
+
sources.push({
|
|
486
|
+
name: typeof source.name === "string" ? source.name : "",
|
|
487
|
+
path: typeof source.path === "string" ? source.path : "",
|
|
488
|
+
watch: typeof source.watch === "boolean" ? source.watch : undefined,
|
|
489
|
+
chunking: sourceChunking,
|
|
490
|
+
});
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
const allowedAgents = Array.isArray(raw.allowedAgents)
|
|
494
|
+
? raw.allowedAgents.filter((a) => typeof a === "string")
|
|
495
|
+
: undefined;
|
|
496
|
+
const knowledge = {
|
|
497
|
+
embedding,
|
|
498
|
+
store,
|
|
499
|
+
chunking,
|
|
500
|
+
sources,
|
|
501
|
+
...(allowedAgents && allowedAgents.length > 0 ? { allowedAgents } : {}),
|
|
502
|
+
};
|
|
503
|
+
const validationErrors = validateKnowledgeConfig(knowledge);
|
|
504
|
+
for (const ve of validationErrors) {
|
|
505
|
+
errors.push(ve);
|
|
506
|
+
}
|
|
507
|
+
return { knowledge: validationErrors.length > 0 ? undefined : knowledge, errors };
|
|
508
|
+
}
|
|
509
|
+
const VALID_SCORER_TYPES = [
|
|
510
|
+
"exact-match", "contains", "json-validity", "length", "latency", "cost",
|
|
511
|
+
"faithfulness", "relevance", "coherence", "hallucination", "toxicity",
|
|
512
|
+
"custom-prompt", "composite",
|
|
513
|
+
];
|
|
514
|
+
function mapEvalScorer(raw) {
|
|
515
|
+
const errors = [];
|
|
516
|
+
const subScorers = [];
|
|
517
|
+
if (raw.scorers !== undefined && Array.isArray(raw.scorers)) {
|
|
518
|
+
for (let i = 0; i < raw.scorers.length; i++) {
|
|
519
|
+
const { scorer, errors: subErrors } = mapEvalScorer(raw.scorers[i]);
|
|
520
|
+
subScorers.push(scorer);
|
|
521
|
+
errors.push(...subErrors);
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
let scorerType = "exact-match";
|
|
525
|
+
if (typeof raw.type === "string" && VALID_SCORER_TYPES.includes(raw.type)) {
|
|
526
|
+
scorerType = raw.type;
|
|
527
|
+
}
|
|
528
|
+
else if (typeof raw.type === "string") {
|
|
529
|
+
errors.push({ field: "type", message: `unknown scorer type "${raw.type}", must be one of: ${VALID_SCORER_TYPES.join(", ")}` });
|
|
530
|
+
}
|
|
531
|
+
const scorer = {
|
|
532
|
+
name: typeof raw.name === "string" ? raw.name : "",
|
|
533
|
+
type: scorerType,
|
|
534
|
+
...(subScorers.length > 0 ? { scorers: subScorers } : {}),
|
|
535
|
+
...(typeof raw.schema === "object" && raw.schema !== null && !Array.isArray(raw.schema) ? { schema: raw.schema } : {}),
|
|
536
|
+
...(typeof raw.prompt === "string" ? { prompt: raw.prompt } : {}),
|
|
537
|
+
...(typeof raw.minLength === "number" ? { minLength: raw.minLength } : {}),
|
|
538
|
+
...(typeof raw.maxLength === "number" ? { maxLength: raw.maxLength } : {}),
|
|
539
|
+
...(typeof raw.maxLatencyMs === "number" ? { maxLatencyMs: raw.maxLatencyMs } : {}),
|
|
540
|
+
...(typeof raw.maxCostUsd === "number" ? { maxCostUsd: raw.maxCostUsd } : {}),
|
|
541
|
+
...(Array.isArray(raw.substrings) ? { substrings: raw.substrings.filter((s) => typeof s === "string") } : {}),
|
|
542
|
+
};
|
|
543
|
+
return { scorer, errors };
|
|
544
|
+
}
|
|
545
|
+
function mapEval(raw) {
|
|
546
|
+
const errors = [];
|
|
547
|
+
if (!raw || typeof raw !== "object") {
|
|
548
|
+
return { eval: undefined, errors: [] };
|
|
549
|
+
}
|
|
550
|
+
const datasets = [];
|
|
551
|
+
if (Array.isArray(raw.datasets)) {
|
|
552
|
+
for (const ds of raw.datasets) {
|
|
553
|
+
const rawDs = ds;
|
|
554
|
+
if (!rawDs)
|
|
555
|
+
continue;
|
|
556
|
+
datasets.push({
|
|
557
|
+
name: typeof rawDs.name === "string" ? rawDs.name : "",
|
|
558
|
+
path: typeof rawDs.path === "string" ? rawDs.path : "",
|
|
559
|
+
});
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
const scorers = [];
|
|
563
|
+
if (Array.isArray(raw.scorers)) {
|
|
564
|
+
for (const s of raw.scorers) {
|
|
565
|
+
const { scorer, errors: scorerErrors } = mapEvalScorer(s);
|
|
566
|
+
scorers.push(scorer);
|
|
567
|
+
errors.push(...scorerErrors);
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
const experiments = [];
|
|
571
|
+
if (Array.isArray(raw.experiments)) {
|
|
572
|
+
for (const exp of raw.experiments) {
|
|
573
|
+
const rawExp = exp;
|
|
574
|
+
if (!rawExp)
|
|
575
|
+
continue;
|
|
576
|
+
const expScorers = [];
|
|
577
|
+
if (Array.isArray(rawExp.scorers)) {
|
|
578
|
+
for (const s of rawExp.scorers) {
|
|
579
|
+
if (typeof s === "string")
|
|
580
|
+
expScorers.push(s);
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
experiments.push({
|
|
584
|
+
name: typeof rawExp.name === "string" ? rawExp.name : "",
|
|
585
|
+
dataset: typeof rawExp.dataset === "string" ? rawExp.dataset : "",
|
|
586
|
+
team: typeof rawExp.team === "string" ? rawExp.team : "",
|
|
587
|
+
scorers: expScorers,
|
|
588
|
+
...(typeof rawExp.overrides === "object" && rawExp.overrides !== null && !Array.isArray(rawExp.overrides) ? { overrides: rawExp.overrides } : {}),
|
|
589
|
+
...(typeof rawExp.compare === "string" ? { compare: rawExp.compare } : {}),
|
|
590
|
+
});
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
const evalConfig = {
|
|
594
|
+
datasets,
|
|
595
|
+
scorers,
|
|
596
|
+
experiments,
|
|
597
|
+
};
|
|
598
|
+
const validationErrors = validateEvalConfig(evalConfig);
|
|
599
|
+
for (const ve of validationErrors) {
|
|
600
|
+
errors.push({ field: `eval.${ve.field}`, message: ve.message });
|
|
601
|
+
}
|
|
602
|
+
return { eval: validationErrors.length > 0 ? undefined : evalConfig, errors };
|
|
603
|
+
}
|
|
604
|
+
function mapMcp(raw) {
|
|
605
|
+
const errors = [];
|
|
606
|
+
if (!raw || typeof raw !== "object") {
|
|
607
|
+
return { mcp: undefined, errors: [] };
|
|
608
|
+
}
|
|
609
|
+
const servers = [];
|
|
610
|
+
if (Array.isArray(raw.servers)) {
|
|
611
|
+
for (let i = 0; i < raw.servers.length; i++) {
|
|
612
|
+
const server = raw.servers[i];
|
|
613
|
+
if (!server)
|
|
614
|
+
continue;
|
|
615
|
+
let env;
|
|
616
|
+
if (server.env && typeof server.env === "object" && !Array.isArray(server.env)) {
|
|
617
|
+
const envObj = {};
|
|
618
|
+
for (const [key, value] of Object.entries(server.env)) {
|
|
619
|
+
if (typeof value === "string") {
|
|
620
|
+
envObj[key] = value;
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
if (Object.keys(envObj).length > 0) {
|
|
624
|
+
env = envObj;
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
servers.push({
|
|
628
|
+
name: typeof server.name === "string" ? server.name : "",
|
|
629
|
+
url: typeof server.url === "string" ? server.url : "",
|
|
630
|
+
...(env && Object.keys(env).length > 0 ? { env } : {}),
|
|
631
|
+
...(typeof server.reconnect === "boolean" ? { reconnect: server.reconnect } : {}),
|
|
632
|
+
});
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
const mcpConfig = { servers };
|
|
636
|
+
const validationErrors = validateMcpConfig(mcpConfig);
|
|
637
|
+
for (const ve of validationErrors) {
|
|
638
|
+
errors.push({ field: `mcp.${ve.field}`, message: ve.message });
|
|
639
|
+
}
|
|
640
|
+
return { mcp: validationErrors.length > 0 ? undefined : mcpConfig, errors };
|
|
641
|
+
}
|
|
642
|
+
function mapToolSelection(raw) {
|
|
643
|
+
const errors = [];
|
|
644
|
+
if (!raw || typeof raw !== "object") {
|
|
645
|
+
return { toolSelection: undefined, errors: [] };
|
|
646
|
+
}
|
|
647
|
+
const strategy = typeof raw.strategy === "string" ? raw.strategy : undefined;
|
|
648
|
+
const config = {
|
|
649
|
+
strategy: strategy ?? "all",
|
|
650
|
+
...(typeof raw.maxTools === "number" ? { maxTools: raw.maxTools } : {}),
|
|
651
|
+
...(typeof raw.threshold === "number" ? { threshold: raw.threshold } : {}),
|
|
652
|
+
};
|
|
653
|
+
const validationErrors = validateToolSelectionConfig(config);
|
|
654
|
+
for (const ve of validationErrors) {
|
|
655
|
+
errors.push({ field: `toolSelection.${ve.field}`, message: ve.message });
|
|
656
|
+
}
|
|
657
|
+
return { toolSelection: validationErrors.length > 0 ? undefined : config, errors };
|
|
658
|
+
}
|
|
659
|
+
function mapVoiceConfig(raw) {
|
|
660
|
+
const errors = [];
|
|
661
|
+
if (!raw || typeof raw !== "object") {
|
|
662
|
+
return { voice: undefined, errors: [] };
|
|
663
|
+
}
|
|
664
|
+
const rawStt = raw.stt;
|
|
665
|
+
const rawTts = raw.tts;
|
|
666
|
+
if (!rawStt || typeof rawStt !== "object") {
|
|
667
|
+
errors.push({ field: "voice.stt", message: "must be an object" });
|
|
668
|
+
}
|
|
669
|
+
if (!rawTts || typeof rawTts !== "object") {
|
|
670
|
+
errors.push({ field: "voice.tts", message: "must be an object" });
|
|
671
|
+
}
|
|
672
|
+
if (errors.length > 0)
|
|
673
|
+
return { voice: undefined, errors };
|
|
674
|
+
const stt = {
|
|
675
|
+
provider: (typeof rawStt.provider === "string" ? rawStt.provider : ""),
|
|
676
|
+
...(typeof rawStt.model === "string" ? { model: rawStt.model } : {}),
|
|
677
|
+
...(typeof rawStt.apiKeyEnv === "string" ? { apiKeyEnv: rawStt.apiKeyEnv } : {}),
|
|
678
|
+
...(typeof rawStt.language === "string" ? { language: rawStt.language } : {}),
|
|
679
|
+
};
|
|
680
|
+
const tts = {
|
|
681
|
+
provider: (typeof rawTts.provider === "string" ? rawTts.provider : ""),
|
|
682
|
+
...(typeof rawTts.model === "string" ? { model: rawTts.model } : {}),
|
|
683
|
+
...(typeof rawTts.apiKeyEnv === "string" ? { apiKeyEnv: rawTts.apiKeyEnv } : {}),
|
|
684
|
+
...(typeof rawTts.voice === "string" ? { voice: rawTts.voice } : {}),
|
|
685
|
+
};
|
|
686
|
+
const voice = { stt, tts };
|
|
687
|
+
const validationErrors = validateVoiceConfig(voice);
|
|
688
|
+
for (const ve of validationErrors) {
|
|
689
|
+
errors.push(ve);
|
|
690
|
+
}
|
|
691
|
+
return { voice: validationErrors.length > 0 ? undefined : voice, errors };
|
|
692
|
+
}
|
|
693
|
+
function mapSafety(raw) {
|
|
694
|
+
const errors = [];
|
|
695
|
+
if (!raw || typeof raw !== "object") {
|
|
696
|
+
return { safety: undefined, errors: [] };
|
|
697
|
+
}
|
|
698
|
+
let pii;
|
|
699
|
+
if (raw.pii !== undefined) {
|
|
700
|
+
const rawPii = raw.pii;
|
|
701
|
+
const detect = [];
|
|
702
|
+
if (Array.isArray(rawPii.detect)) {
|
|
703
|
+
for (const d of rawPii.detect) {
|
|
704
|
+
if (typeof d === "string")
|
|
705
|
+
detect.push(d);
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
const allowlist = [];
|
|
709
|
+
if (Array.isArray(rawPii.allowlist)) {
|
|
710
|
+
for (const a of rawPii.allowlist) {
|
|
711
|
+
if (typeof a === "string")
|
|
712
|
+
allowlist.push(a);
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
pii = {
|
|
716
|
+
detect,
|
|
717
|
+
action: (typeof rawPii.action === "string" ? rawPii.action : "detect"),
|
|
718
|
+
...(typeof rawPii.deepScan === "boolean" ? { deepScan: rawPii.deepScan } : {}),
|
|
719
|
+
...(allowlist.length > 0 ? { allowlist } : {}),
|
|
720
|
+
};
|
|
721
|
+
}
|
|
722
|
+
let content;
|
|
723
|
+
if (raw.content !== undefined) {
|
|
724
|
+
const rawContent = raw.content;
|
|
725
|
+
const categories = {};
|
|
726
|
+
if (rawContent.categories && typeof rawContent.categories === "object" && !Array.isArray(rawContent.categories)) {
|
|
727
|
+
for (const [cat, catConfig] of Object.entries(rawContent.categories)) {
|
|
728
|
+
if (!catConfig)
|
|
729
|
+
continue;
|
|
730
|
+
categories[cat] = {
|
|
731
|
+
threshold: typeof catConfig.threshold === "number" ? catConfig.threshold : 0.5,
|
|
732
|
+
action: (typeof catConfig.action === "string" ? catConfig.action : "block"),
|
|
733
|
+
};
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
content = {
|
|
737
|
+
enabled: typeof rawContent.enabled === "boolean" ? rawContent.enabled : true,
|
|
738
|
+
categories,
|
|
739
|
+
...(typeof rawContent.deepScan === "boolean" ? { deepScan: rawContent.deepScan } : {}),
|
|
740
|
+
};
|
|
741
|
+
}
|
|
742
|
+
const rails = [];
|
|
743
|
+
if (raw.rails !== undefined) {
|
|
744
|
+
if (!Array.isArray(raw.rails)) {
|
|
745
|
+
errors.push({ field: "safety.rails", message: "must be an array" });
|
|
746
|
+
}
|
|
747
|
+
else {
|
|
748
|
+
for (let i = 0; i < raw.rails.length; i++) {
|
|
749
|
+
const rawRail = raw.rails[i];
|
|
750
|
+
if (!rawRail)
|
|
751
|
+
continue;
|
|
752
|
+
const railType = typeof rawRail.type === "string" ? rawRail.type : "";
|
|
753
|
+
switch (railType) {
|
|
754
|
+
case "topic": {
|
|
755
|
+
const block = Array.isArray(rawRail.block) ? rawRail.block.filter((b) => typeof b === "string") : [];
|
|
756
|
+
const escalate = Array.isArray(rawRail.escalate) ? rawRail.escalate.filter((e) => typeof e === "string") : [];
|
|
757
|
+
rails.push({ type: "topic", ...(block.length > 0 ? { block } : {}), ...(escalate.length > 0 ? { escalate } : {}) });
|
|
758
|
+
break;
|
|
759
|
+
}
|
|
760
|
+
case "competitor": {
|
|
761
|
+
const competitors = Array.isArray(rawRail.competitors) ? rawRail.competitors.filter((c) => typeof c === "string") : [];
|
|
762
|
+
rails.push({
|
|
763
|
+
type: "competitor",
|
|
764
|
+
competitors,
|
|
765
|
+
response: typeof rawRail.response === "string" ? rawRail.response : "",
|
|
766
|
+
});
|
|
767
|
+
break;
|
|
768
|
+
}
|
|
769
|
+
case "escalation": {
|
|
770
|
+
const triggers = Array.isArray(rawRail.triggers) ? rawRail.triggers.filter((t) => typeof t === "string") : [];
|
|
771
|
+
rails.push({ type: "escalation", triggers });
|
|
772
|
+
break;
|
|
773
|
+
}
|
|
774
|
+
case "compliance": {
|
|
775
|
+
const required = Array.isArray(rawRail.required) ? rawRail.required.filter((r) => typeof r === "string") : [];
|
|
776
|
+
const forbid = Array.isArray(rawRail.forbid) ? rawRail.forbid.filter((f) => typeof f === "string") : [];
|
|
777
|
+
rails.push({
|
|
778
|
+
type: "compliance",
|
|
779
|
+
...(required.length > 0 ? { required } : {}),
|
|
780
|
+
...(forbid.length > 0 ? { forbid } : {}),
|
|
781
|
+
});
|
|
782
|
+
break;
|
|
783
|
+
}
|
|
784
|
+
default:
|
|
785
|
+
errors.push({ field: `safety.rails[${i}].type`, message: `unknown rail type "${railType}"` });
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
const safety = {
|
|
791
|
+
...(pii ? { pii } : {}),
|
|
792
|
+
...(content ? { content } : {}),
|
|
793
|
+
...(rails.length > 0 ? { rails } : {}),
|
|
794
|
+
};
|
|
795
|
+
const validationErrors = validateSafetyConfig(safety);
|
|
796
|
+
for (const ve of validationErrors) {
|
|
797
|
+
errors.push({ field: `safety.${ve.field}`, message: ve.message });
|
|
798
|
+
}
|
|
799
|
+
return { safety: validationErrors.length > 0 ? undefined : safety, errors };
|
|
800
|
+
}
|
|
801
|
+
// ---------------------------------------------------------------------------
|
|
802
|
+
// Public API
|
|
803
|
+
// ---------------------------------------------------------------------------
|
|
804
|
+
/** Parse a YAML string into a typed App composite. Throws AppLoaderError if invalid. */
|
|
805
|
+
export function parseAppYaml(content) {
|
|
806
|
+
let data;
|
|
807
|
+
try {
|
|
808
|
+
data = parse(content);
|
|
809
|
+
}
|
|
810
|
+
catch (err) {
|
|
811
|
+
throw new AppLoaderError([{ field: "yaml", message: String(err) }]);
|
|
812
|
+
}
|
|
813
|
+
const errors = [];
|
|
814
|
+
if (!data || typeof data !== "object" || Array.isArray(data)) {
|
|
815
|
+
throw new AppLoaderError([{ field: "root", message: "must be a YAML object" }]);
|
|
816
|
+
}
|
|
817
|
+
const raw = data;
|
|
818
|
+
// name
|
|
819
|
+
if (!raw.name || typeof raw.name !== "string") {
|
|
820
|
+
errors.push({ field: "name", message: "must be a non-empty string" });
|
|
821
|
+
}
|
|
822
|
+
// channels
|
|
823
|
+
const channels = [];
|
|
824
|
+
if (raw.channels !== undefined) {
|
|
825
|
+
if (!Array.isArray(raw.channels)) {
|
|
826
|
+
errors.push({ field: "channels", message: "must be an array" });
|
|
827
|
+
}
|
|
828
|
+
else {
|
|
829
|
+
for (const c of raw.channels) {
|
|
830
|
+
if (typeof c === "string")
|
|
831
|
+
channels.push(c);
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
// memory
|
|
836
|
+
let memory = { scopes: [], backend: "" };
|
|
837
|
+
if (!raw.memory || typeof raw.memory !== "object" || Array.isArray(raw.memory)) {
|
|
838
|
+
errors.push({ field: "memory", message: "must be an object" });
|
|
839
|
+
}
|
|
840
|
+
else {
|
|
841
|
+
const { memory: mem, errors: memErrors } = mapMemory(raw.memory, "memory");
|
|
842
|
+
memory = mem;
|
|
843
|
+
errors.push(...memErrors);
|
|
844
|
+
}
|
|
845
|
+
// teams
|
|
846
|
+
const teams = {};
|
|
847
|
+
if (!raw.teams || typeof raw.teams !== "object" || Array.isArray(raw.teams)) {
|
|
848
|
+
errors.push({ field: "teams", message: "must be an object" });
|
|
849
|
+
}
|
|
850
|
+
else {
|
|
851
|
+
for (const [teamName, teamRaw] of Object.entries(raw.teams)) {
|
|
852
|
+
const { team, errors: teamErrors } = mapTeam(teamName, teamRaw ?? {}, `teams.${teamName}`);
|
|
853
|
+
teams[teamName] = team;
|
|
854
|
+
errors.push(...teamErrors);
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
// router
|
|
858
|
+
let router = { rules: [], fallback: "" };
|
|
859
|
+
if (!raw.router || typeof raw.router !== "object" || Array.isArray(raw.router)) {
|
|
860
|
+
errors.push({ field: "router", message: "must be an object" });
|
|
861
|
+
}
|
|
862
|
+
else {
|
|
863
|
+
const { router: rt, errors: routerErrors } = mapRouter(raw.router, "router");
|
|
864
|
+
router = rt;
|
|
865
|
+
errors.push(...routerErrors);
|
|
866
|
+
}
|
|
867
|
+
// triggers (optional)
|
|
868
|
+
const triggers = [];
|
|
869
|
+
if (raw.triggers !== undefined) {
|
|
870
|
+
if (!Array.isArray(raw.triggers)) {
|
|
871
|
+
errors.push({ field: "triggers", message: "must be an array" });
|
|
872
|
+
}
|
|
873
|
+
else {
|
|
874
|
+
for (let i = 0; i < raw.triggers.length; i++) {
|
|
875
|
+
const { trigger, errors: triggerErrors } = mapTrigger(raw.triggers[i], `triggers[${i}]`);
|
|
876
|
+
triggers.push(trigger);
|
|
877
|
+
errors.push(...triggerErrors);
|
|
878
|
+
}
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
// knowledge (optional)
|
|
882
|
+
let knowledge;
|
|
883
|
+
if (raw.knowledge !== undefined) {
|
|
884
|
+
const { knowledge: knowledgeConfig, errors: knowledgeErrors } = mapKnowledge(raw.knowledge);
|
|
885
|
+
knowledge = knowledgeConfig;
|
|
886
|
+
errors.push(...knowledgeErrors);
|
|
887
|
+
}
|
|
888
|
+
// eval (optional)
|
|
889
|
+
let evalConfig;
|
|
890
|
+
if (raw.eval !== undefined) {
|
|
891
|
+
const { eval: parsedEval, errors: evalErrors } = mapEval(raw.eval);
|
|
892
|
+
evalConfig = parsedEval;
|
|
893
|
+
errors.push(...evalErrors);
|
|
894
|
+
}
|
|
895
|
+
// mcp (optional)
|
|
896
|
+
let mcpConfig;
|
|
897
|
+
if (raw.mcp !== undefined) {
|
|
898
|
+
const { mcp, errors: mcpErrors } = mapMcp(raw.mcp);
|
|
899
|
+
mcpConfig = mcp;
|
|
900
|
+
errors.push(...mcpErrors);
|
|
901
|
+
}
|
|
902
|
+
// toolSelection (optional)
|
|
903
|
+
let toolSelectionConfig;
|
|
904
|
+
if (raw.toolSelection !== undefined) {
|
|
905
|
+
const { toolSelection, errors: tsErrors } = mapToolSelection(raw.toolSelection);
|
|
906
|
+
toolSelectionConfig = toolSelection;
|
|
907
|
+
errors.push(...tsErrors);
|
|
908
|
+
}
|
|
909
|
+
// voice (optional)
|
|
910
|
+
let voiceConfig;
|
|
911
|
+
if (raw.voice !== undefined) {
|
|
912
|
+
const { voice, errors: voiceErrors } = mapVoiceConfig(raw.voice);
|
|
913
|
+
voiceConfig = voice;
|
|
914
|
+
errors.push(...voiceErrors);
|
|
915
|
+
}
|
|
916
|
+
// safety (optional)
|
|
917
|
+
let safetyConfig;
|
|
918
|
+
if (raw.safety !== undefined) {
|
|
919
|
+
const { safety, errors: safetyErrors } = mapSafety(raw.safety);
|
|
920
|
+
safetyConfig = safety;
|
|
921
|
+
errors.push(...safetyErrors);
|
|
922
|
+
}
|
|
923
|
+
if (errors.length > 0)
|
|
924
|
+
throw new AppLoaderError(errors);
|
|
925
|
+
return {
|
|
926
|
+
name: raw.name,
|
|
927
|
+
teams,
|
|
928
|
+
router,
|
|
929
|
+
memory,
|
|
930
|
+
channels,
|
|
931
|
+
...(triggers.length > 0 ? { triggers } : {}),
|
|
932
|
+
...(knowledge ? { knowledge } : {}),
|
|
933
|
+
...(evalConfig ? { eval: evalConfig } : {}),
|
|
934
|
+
...(mcpConfig ? { mcp: mcpConfig } : {}),
|
|
935
|
+
...(toolSelectionConfig ? { toolSelection: toolSelectionConfig } : {}),
|
|
936
|
+
...(voiceConfig ? { voice: voiceConfig } : {}),
|
|
937
|
+
...(safetyConfig ? { safety: safetyConfig } : {}),
|
|
938
|
+
};
|
|
939
|
+
}
|
|
940
|
+
/** Validate the dependency graph of an App. Returns null if valid, AppLoaderError if not. */
|
|
941
|
+
export function validateAppGraph(app) {
|
|
942
|
+
const appErrors = validateApp(app);
|
|
943
|
+
if (appErrors.length === 0)
|
|
944
|
+
return null;
|
|
945
|
+
return new AppLoaderError(appErrors);
|
|
946
|
+
}
|
|
947
|
+
//# sourceMappingURL=app-loader.js.map
|