mcp-agent-foundry 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 +21 -0
- package/README.md +477 -0
- package/dist/cli/install-skills.d.ts +11 -0
- package/dist/cli/install-skills.d.ts.map +1 -0
- package/dist/cli/install-skills.js +143 -0
- package/dist/cli/install-skills.js.map +1 -0
- package/dist/cli/recovery-commands.d.ts +41 -0
- package/dist/cli/recovery-commands.d.ts.map +1 -0
- package/dist/cli/recovery-commands.js +241 -0
- package/dist/cli/recovery-commands.js.map +1 -0
- package/dist/cli/setup-wizard.d.ts +25 -0
- package/dist/cli/setup-wizard.d.ts.map +1 -0
- package/dist/cli/setup-wizard.js +1417 -0
- package/dist/cli/setup-wizard.js.map +1 -0
- package/dist/cli/test-connection.d.ts +45 -0
- package/dist/cli/test-connection.d.ts.map +1 -0
- package/dist/cli/test-connection.js +317 -0
- package/dist/cli/test-connection.js.map +1 -0
- package/dist/cli.d.ts +75 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +704 -0
- package/dist/cli.js.map +1 -0
- package/dist/config/defaults.d.ts +57 -0
- package/dist/config/defaults.d.ts.map +1 -0
- package/dist/config/defaults.js +99 -0
- package/dist/config/defaults.js.map +1 -0
- package/dist/config/index.d.ts +14 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +22 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/manager.d.ts +184 -0
- package/dist/config/manager.d.ts.map +1 -0
- package/dist/config/manager.js +347 -0
- package/dist/config/manager.js.map +1 -0
- package/dist/config/merger.d.ts +76 -0
- package/dist/config/merger.d.ts.map +1 -0
- package/dist/config/merger.js +189 -0
- package/dist/config/merger.js.map +1 -0
- package/dist/config/schema.d.ts +20 -0
- package/dist/config/schema.d.ts.map +1 -0
- package/dist/config/schema.js +20 -0
- package/dist/config/schema.js.map +1 -0
- package/dist/config/validator.d.ts +254 -0
- package/dist/config/validator.d.ts.map +1 -0
- package/dist/config/validator.js +363 -0
- package/dist/config/validator.js.map +1 -0
- package/dist/config/worktree-defaults.d.ts +23 -0
- package/dist/config/worktree-defaults.d.ts.map +1 -0
- package/dist/config/worktree-defaults.js +78 -0
- package/dist/config/worktree-defaults.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +44 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/tools/compare-agents.d.ts +25 -0
- package/dist/mcp/tools/compare-agents.d.ts.map +1 -0
- package/dist/mcp/tools/compare-agents.js +177 -0
- package/dist/mcp/tools/compare-agents.js.map +1 -0
- package/dist/mcp/tools/critique-plan.d.ts +26 -0
- package/dist/mcp/tools/critique-plan.d.ts.map +1 -0
- package/dist/mcp/tools/critique-plan.js +162 -0
- package/dist/mcp/tools/critique-plan.js.map +1 -0
- package/dist/mcp/tools/design-feedback.d.ts +26 -0
- package/dist/mcp/tools/design-feedback.d.ts.map +1 -0
- package/dist/mcp/tools/design-feedback.js +216 -0
- package/dist/mcp/tools/design-feedback.js.map +1 -0
- package/dist/mcp/tools/index.d.ts +50 -0
- package/dist/mcp/tools/index.d.ts.map +1 -0
- package/dist/mcp/tools/index.js +191 -0
- package/dist/mcp/tools/index.js.map +1 -0
- package/dist/mcp/tools/invoke-agent.d.ts +25 -0
- package/dist/mcp/tools/invoke-agent.d.ts.map +1 -0
- package/dist/mcp/tools/invoke-agent.js +141 -0
- package/dist/mcp/tools/invoke-agent.js.map +1 -0
- package/dist/mcp/tools/review-code.d.ts +25 -0
- package/dist/mcp/tools/review-code.d.ts.map +1 -0
- package/dist/mcp/tools/review-code.js +170 -0
- package/dist/mcp/tools/review-code.js.map +1 -0
- package/dist/mcp/tools/tasks/claim-next-task.d.ts +22 -0
- package/dist/mcp/tools/tasks/claim-next-task.d.ts.map +1 -0
- package/dist/mcp/tools/tasks/claim-next-task.js +203 -0
- package/dist/mcp/tools/tasks/claim-next-task.js.map +1 -0
- package/dist/mcp/tools/tasks/create-routed-task.d.ts +17 -0
- package/dist/mcp/tools/tasks/create-routed-task.d.ts.map +1 -0
- package/dist/mcp/tools/tasks/create-routed-task.js +178 -0
- package/dist/mcp/tools/tasks/create-routed-task.js.map +1 -0
- package/dist/mcp/tools/tasks/execute-pipeline.d.ts +22 -0
- package/dist/mcp/tools/tasks/execute-pipeline.d.ts.map +1 -0
- package/dist/mcp/tools/tasks/execute-pipeline.js +401 -0
- package/dist/mcp/tools/tasks/execute-pipeline.js.map +1 -0
- package/dist/mcp/tools/tasks/execute-task.d.ts +32 -0
- package/dist/mcp/tools/tasks/execute-task.d.ts.map +1 -0
- package/dist/mcp/tools/tasks/execute-task.js +284 -0
- package/dist/mcp/tools/tasks/execute-task.js.map +1 -0
- package/dist/mcp/tools/tasks/get-pipeline-status.d.ts +26 -0
- package/dist/mcp/tools/tasks/get-pipeline-status.d.ts.map +1 -0
- package/dist/mcp/tools/tasks/get-pipeline-status.js +460 -0
- package/dist/mcp/tools/tasks/get-pipeline-status.js.map +1 -0
- package/dist/mcp/tools/tasks/index.d.ts +36 -0
- package/dist/mcp/tools/tasks/index.d.ts.map +1 -0
- package/dist/mcp/tools/tasks/index.js +66 -0
- package/dist/mcp/tools/tasks/index.js.map +1 -0
- package/dist/mcp/tools/worktree/cleanup-worktrees.d.ts +17 -0
- package/dist/mcp/tools/worktree/cleanup-worktrees.d.ts.map +1 -0
- package/dist/mcp/tools/worktree/cleanup-worktrees.js +147 -0
- package/dist/mcp/tools/worktree/cleanup-worktrees.js.map +1 -0
- package/dist/mcp/tools/worktree/get-worktree-status.d.ts +17 -0
- package/dist/mcp/tools/worktree/get-worktree-status.d.ts.map +1 -0
- package/dist/mcp/tools/worktree/get-worktree-status.js +123 -0
- package/dist/mcp/tools/worktree/get-worktree-status.js.map +1 -0
- package/dist/mcp/tools/worktree/index.d.ts +41 -0
- package/dist/mcp/tools/worktree/index.d.ts.map +1 -0
- package/dist/mcp/tools/worktree/index.js +69 -0
- package/dist/mcp/tools/worktree/index.js.map +1 -0
- package/dist/mcp/tools/worktree/list-worktrees.d.ts +17 -0
- package/dist/mcp/tools/worktree/list-worktrees.d.ts.map +1 -0
- package/dist/mcp/tools/worktree/list-worktrees.js +136 -0
- package/dist/mcp/tools/worktree/list-worktrees.js.map +1 -0
- package/dist/mcp/tools/worktree/resolve-conflicts.d.ts +19 -0
- package/dist/mcp/tools/worktree/resolve-conflicts.d.ts.map +1 -0
- package/dist/mcp/tools/worktree/resolve-conflicts.js +228 -0
- package/dist/mcp/tools/worktree/resolve-conflicts.js.map +1 -0
- package/dist/mcp/transport/stdio.d.ts +13 -0
- package/dist/mcp/transport/stdio.d.ts.map +1 -0
- package/dist/mcp/transport/stdio.js +15 -0
- package/dist/mcp/transport/stdio.js.map +1 -0
- package/dist/observability/logger.d.ts +137 -0
- package/dist/observability/logger.d.ts.map +1 -0
- package/dist/observability/logger.js +235 -0
- package/dist/observability/logger.js.map +1 -0
- package/dist/observability/metrics.d.ts +250 -0
- package/dist/observability/metrics.d.ts.map +1 -0
- package/dist/observability/metrics.js +364 -0
- package/dist/observability/metrics.js.map +1 -0
- package/dist/persistence/index.d.ts +9 -0
- package/dist/persistence/index.d.ts.map +1 -0
- package/dist/persistence/index.js +9 -0
- package/dist/persistence/index.js.map +1 -0
- package/dist/persistence/state-schema.d.ts +116 -0
- package/dist/persistence/state-schema.d.ts.map +1 -0
- package/dist/persistence/state-schema.js +28 -0
- package/dist/persistence/state-schema.js.map +1 -0
- package/dist/persistence/state-store.d.ts +111 -0
- package/dist/persistence/state-store.d.ts.map +1 -0
- package/dist/persistence/state-store.js +291 -0
- package/dist/persistence/state-store.js.map +1 -0
- package/dist/providers/anthropic.d.ts +164 -0
- package/dist/providers/anthropic.d.ts.map +1 -0
- package/dist/providers/anthropic.js +500 -0
- package/dist/providers/anthropic.js.map +1 -0
- package/dist/providers/base.d.ts +151 -0
- package/dist/providers/base.d.ts.map +1 -0
- package/dist/providers/base.js +227 -0
- package/dist/providers/base.js.map +1 -0
- package/dist/providers/gemini.d.ts +85 -0
- package/dist/providers/gemini.d.ts.map +1 -0
- package/dist/providers/gemini.js +414 -0
- package/dist/providers/gemini.js.map +1 -0
- package/dist/providers/kimi.d.ts +19 -0
- package/dist/providers/kimi.d.ts.map +1 -0
- package/dist/providers/kimi.js +20 -0
- package/dist/providers/kimi.js.map +1 -0
- package/dist/providers/manager.d.ts +160 -0
- package/dist/providers/manager.d.ts.map +1 -0
- package/dist/providers/manager.js +264 -0
- package/dist/providers/manager.js.map +1 -0
- package/dist/providers/ollama.d.ts +83 -0
- package/dist/providers/ollama.d.ts.map +1 -0
- package/dist/providers/ollama.js +453 -0
- package/dist/providers/ollama.js.map +1 -0
- package/dist/providers/openai.d.ts +96 -0
- package/dist/providers/openai.d.ts.map +1 -0
- package/dist/providers/openai.js +457 -0
- package/dist/providers/openai.js.map +1 -0
- package/dist/providers/zai.d.ts +19 -0
- package/dist/providers/zai.d.ts.map +1 -0
- package/dist/providers/zai.js +20 -0
- package/dist/providers/zai.js.map +1 -0
- package/dist/router/context-manager.d.ts +2 -0
- package/dist/router/context-manager.d.ts.map +1 -0
- package/dist/router/context-manager.js +3 -0
- package/dist/router/context-manager.js.map +1 -0
- package/dist/router/engine.d.ts +169 -0
- package/dist/router/engine.d.ts.map +1 -0
- package/dist/router/engine.js +435 -0
- package/dist/router/engine.js.map +1 -0
- package/dist/router/pattern-executor.d.ts +317 -0
- package/dist/router/pattern-executor.d.ts.map +1 -0
- package/dist/router/pattern-executor.js +571 -0
- package/dist/router/pattern-executor.js.map +1 -0
- package/dist/router/role-resolver.d.ts +59 -0
- package/dist/router/role-resolver.d.ts.map +1 -0
- package/dist/router/role-resolver.js +95 -0
- package/dist/router/role-resolver.js.map +1 -0
- package/dist/server.d.ts +32 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +223 -0
- package/dist/server.js.map +1 -0
- package/dist/startup.d.ts +78 -0
- package/dist/startup.d.ts.map +1 -0
- package/dist/startup.js +107 -0
- package/dist/startup.js.map +1 -0
- package/dist/tasks/coordinator.d.ts +141 -0
- package/dist/tasks/coordinator.d.ts.map +1 -0
- package/dist/tasks/coordinator.js +331 -0
- package/dist/tasks/coordinator.js.map +1 -0
- package/dist/tasks/index.d.ts +13 -0
- package/dist/tasks/index.d.ts.map +1 -0
- package/dist/tasks/index.js +13 -0
- package/dist/tasks/index.js.map +1 -0
- package/dist/tasks/persistent-state-coordinator.d.ts +89 -0
- package/dist/tasks/persistent-state-coordinator.d.ts.map +1 -0
- package/dist/tasks/persistent-state-coordinator.js +371 -0
- package/dist/tasks/persistent-state-coordinator.js.map +1 -0
- package/dist/tasks/pipeline-manager.d.ts +103 -0
- package/dist/tasks/pipeline-manager.d.ts.map +1 -0
- package/dist/tasks/pipeline-manager.js +358 -0
- package/dist/tasks/pipeline-manager.js.map +1 -0
- package/dist/tasks/state-coordinator.d.ts +79 -0
- package/dist/tasks/state-coordinator.d.ts.map +1 -0
- package/dist/tasks/state-coordinator.js +200 -0
- package/dist/tasks/state-coordinator.js.map +1 -0
- package/dist/tasks/worker-mode.d.ts +65 -0
- package/dist/tasks/worker-mode.d.ts.map +1 -0
- package/dist/tasks/worker-mode.js +208 -0
- package/dist/tasks/worker-mode.js.map +1 -0
- package/dist/translation/errors.d.ts +203 -0
- package/dist/translation/errors.d.ts.map +1 -0
- package/dist/translation/errors.js +477 -0
- package/dist/translation/errors.js.map +1 -0
- package/dist/translation/index.d.ts +12 -0
- package/dist/translation/index.d.ts.map +1 -0
- package/dist/translation/index.js +32 -0
- package/dist/translation/index.js.map +1 -0
- package/dist/translation/messages.d.ts +295 -0
- package/dist/translation/messages.d.ts.map +1 -0
- package/dist/translation/messages.js +557 -0
- package/dist/translation/messages.js.map +1 -0
- package/dist/translation/streaming.d.ts +226 -0
- package/dist/translation/streaming.d.ts.map +1 -0
- package/dist/translation/streaming.js +520 -0
- package/dist/translation/streaming.js.map +1 -0
- package/dist/translation/tools.d.ts +209 -0
- package/dist/translation/tools.d.ts.map +1 -0
- package/dist/translation/tools.js +331 -0
- package/dist/translation/tools.js.map +1 -0
- package/dist/types.d.ts +747 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +86 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/circuit-breaker.d.ts +175 -0
- package/dist/utils/circuit-breaker.d.ts.map +1 -0
- package/dist/utils/circuit-breaker.js +315 -0
- package/dist/utils/circuit-breaker.js.map +1 -0
- package/dist/utils/env.d.ts +2 -0
- package/dist/utils/env.d.ts.map +1 -0
- package/dist/utils/env.js +3 -0
- package/dist/utils/env.js.map +1 -0
- package/dist/utils/git.d.ts +58 -0
- package/dist/utils/git.d.ts.map +1 -0
- package/dist/utils/git.js +197 -0
- package/dist/utils/git.js.map +1 -0
- package/dist/utils/index.d.ts +9 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +9 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/merge-ordering.d.ts +45 -0
- package/dist/utils/merge-ordering.d.ts.map +1 -0
- package/dist/utils/merge-ordering.js +128 -0
- package/dist/utils/merge-ordering.js.map +1 -0
- package/dist/utils/retry.d.ts +106 -0
- package/dist/utils/retry.d.ts.map +1 -0
- package/dist/utils/retry.js +188 -0
- package/dist/utils/retry.js.map +1 -0
- package/dist/worktrees/branch-manager.d.ts +55 -0
- package/dist/worktrees/branch-manager.d.ts.map +1 -0
- package/dist/worktrees/branch-manager.js +129 -0
- package/dist/worktrees/branch-manager.js.map +1 -0
- package/dist/worktrees/conflict-handler.d.ts +72 -0
- package/dist/worktrees/conflict-handler.d.ts.map +1 -0
- package/dist/worktrees/conflict-handler.js +287 -0
- package/dist/worktrees/conflict-handler.js.map +1 -0
- package/dist/worktrees/conflict-parser.d.ts +28 -0
- package/dist/worktrees/conflict-parser.d.ts.map +1 -0
- package/dist/worktrees/conflict-parser.js +140 -0
- package/dist/worktrees/conflict-parser.js.map +1 -0
- package/dist/worktrees/index.d.ts +20 -0
- package/dist/worktrees/index.d.ts.map +1 -0
- package/dist/worktrees/index.js +20 -0
- package/dist/worktrees/index.js.map +1 -0
- package/dist/worktrees/instructions.d.ts +20 -0
- package/dist/worktrees/instructions.d.ts.map +1 -0
- package/dist/worktrees/instructions.js +84 -0
- package/dist/worktrees/instructions.js.map +1 -0
- package/dist/worktrees/manager.d.ts +76 -0
- package/dist/worktrees/manager.d.ts.map +1 -0
- package/dist/worktrees/manager.js +277 -0
- package/dist/worktrees/manager.js.map +1 -0
- package/dist/worktrees/pipeline-merge-orchestrator.d.ts +55 -0
- package/dist/worktrees/pipeline-merge-orchestrator.d.ts.map +1 -0
- package/dist/worktrees/pipeline-merge-orchestrator.js +221 -0
- package/dist/worktrees/pipeline-merge-orchestrator.js.map +1 -0
- package/dist/worktrees/pool.d.ts +95 -0
- package/dist/worktrees/pool.d.ts.map +1 -0
- package/dist/worktrees/pool.js +271 -0
- package/dist/worktrees/pool.js.map +1 -0
- package/dist/worktrees/recovery.d.ts +94 -0
- package/dist/worktrees/recovery.d.ts.map +1 -0
- package/dist/worktrees/recovery.js +371 -0
- package/dist/worktrees/recovery.js.map +1 -0
- package/dist/worktrees/resource-manager.d.ts +74 -0
- package/dist/worktrees/resource-manager.d.ts.map +1 -0
- package/dist/worktrees/resource-manager.js +228 -0
- package/dist/worktrees/resource-manager.js.map +1 -0
- package/package.json +88 -0
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration Validator for AgentRouter
|
|
3
|
+
*
|
|
4
|
+
* Validates configuration objects against a JSON Schema using AJV.
|
|
5
|
+
* Provides detailed, human-readable error messages on validation failure.
|
|
6
|
+
*/
|
|
7
|
+
import { type ErrorObject } from 'ajv';
|
|
8
|
+
import { type Config } from '../types.js';
|
|
9
|
+
/**
|
|
10
|
+
* Validation result returned by the validator.
|
|
11
|
+
*/
|
|
12
|
+
export interface ValidationResult {
|
|
13
|
+
/** Whether validation passed */
|
|
14
|
+
valid: boolean;
|
|
15
|
+
/** Array of error messages (empty if valid) */
|
|
16
|
+
errors: string[];
|
|
17
|
+
/** Detailed error objects from AJV */
|
|
18
|
+
details?: ErrorObject[];
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Configuration validator using AJV.
|
|
22
|
+
*/
|
|
23
|
+
export declare class ConfigValidator {
|
|
24
|
+
private ajv;
|
|
25
|
+
private validateFull;
|
|
26
|
+
private validatePartial;
|
|
27
|
+
constructor();
|
|
28
|
+
/**
|
|
29
|
+
* Validate a complete configuration object.
|
|
30
|
+
* Throws ConfigurationError if validation fails.
|
|
31
|
+
*
|
|
32
|
+
* @param config - Configuration object to validate
|
|
33
|
+
* @returns The validated config (typed as Config)
|
|
34
|
+
* @throws ConfigurationError if validation fails
|
|
35
|
+
*/
|
|
36
|
+
validate(config: unknown): Config;
|
|
37
|
+
/**
|
|
38
|
+
* Validate a partial configuration object (for merging).
|
|
39
|
+
* Throws ConfigurationError if validation fails.
|
|
40
|
+
*
|
|
41
|
+
* @param config - Partial configuration object to validate
|
|
42
|
+
* @returns The validated partial config
|
|
43
|
+
* @throws ConfigurationError if validation fails
|
|
44
|
+
*/
|
|
45
|
+
validatePartialConfig(config: unknown): Partial<Config>;
|
|
46
|
+
/**
|
|
47
|
+
* Validate configuration and return a result object instead of throwing.
|
|
48
|
+
*
|
|
49
|
+
* @param config - Configuration object to validate
|
|
50
|
+
* @param partial - Whether to validate as partial config
|
|
51
|
+
* @returns ValidationResult with valid flag and any errors
|
|
52
|
+
*/
|
|
53
|
+
validateConfig(config: unknown, partial?: boolean): ValidationResult;
|
|
54
|
+
/**
|
|
55
|
+
* Perform semantic validation beyond schema validation.
|
|
56
|
+
* Checks for logical consistency like provider references.
|
|
57
|
+
*
|
|
58
|
+
* @param config - Config object that passed schema validation
|
|
59
|
+
* @throws ConfigurationError if semantic validation fails
|
|
60
|
+
*/
|
|
61
|
+
private validateSemantics;
|
|
62
|
+
/**
|
|
63
|
+
* Format AJV errors into human-readable messages.
|
|
64
|
+
*
|
|
65
|
+
* @param errors - Array of AJV error objects
|
|
66
|
+
* @returns Array of formatted error strings
|
|
67
|
+
*/
|
|
68
|
+
private formatErrors;
|
|
69
|
+
/**
|
|
70
|
+
* Get a human-readable message for an AJV error.
|
|
71
|
+
*
|
|
72
|
+
* @param error - AJV error object
|
|
73
|
+
* @returns Human-readable error message
|
|
74
|
+
*/
|
|
75
|
+
private getErrorMessage;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Convenience function to validate a configuration object.
|
|
79
|
+
* Creates a new validator instance and validates the config.
|
|
80
|
+
*
|
|
81
|
+
* @param config - Configuration object to validate
|
|
82
|
+
* @returns The validated config
|
|
83
|
+
* @throws ConfigurationError if validation fails
|
|
84
|
+
*/
|
|
85
|
+
export declare function validateConfig(config: unknown): Config;
|
|
86
|
+
/**
|
|
87
|
+
* Convenience function to check if a config is valid without throwing.
|
|
88
|
+
*
|
|
89
|
+
* @param config - Configuration object to check
|
|
90
|
+
* @returns True if valid, false otherwise
|
|
91
|
+
*/
|
|
92
|
+
export declare function isValidConfig(config: unknown): config is Config;
|
|
93
|
+
/**
|
|
94
|
+
* Export the schema for external use (e.g., generating schema.json).
|
|
95
|
+
*/
|
|
96
|
+
export declare const configSchema: {
|
|
97
|
+
readonly $schema: "http://json-schema.org/draft-07/schema#";
|
|
98
|
+
readonly type: "object";
|
|
99
|
+
readonly required: readonly ["version", "defaults", "roles", "providers"];
|
|
100
|
+
readonly additionalProperties: false;
|
|
101
|
+
readonly properties: {
|
|
102
|
+
readonly version: {
|
|
103
|
+
readonly type: "string";
|
|
104
|
+
readonly pattern: "^\\d+\\.\\d+$";
|
|
105
|
+
readonly description: "Configuration schema version (e.g., \"1.0\")";
|
|
106
|
+
};
|
|
107
|
+
readonly defaults: {
|
|
108
|
+
readonly type: "object";
|
|
109
|
+
readonly required: readonly ["temperature", "max_tokens", "timeout_ms"];
|
|
110
|
+
readonly additionalProperties: false;
|
|
111
|
+
readonly properties: {
|
|
112
|
+
readonly temperature: {
|
|
113
|
+
readonly type: "number";
|
|
114
|
+
readonly minimum: 0;
|
|
115
|
+
readonly maximum: 2;
|
|
116
|
+
readonly description: "Default temperature for LLM requests (0-2)";
|
|
117
|
+
};
|
|
118
|
+
readonly max_tokens: {
|
|
119
|
+
readonly type: "integer";
|
|
120
|
+
readonly minimum: 1;
|
|
121
|
+
readonly maximum: 200000;
|
|
122
|
+
readonly description: "Default maximum tokens for LLM responses";
|
|
123
|
+
};
|
|
124
|
+
readonly timeout_ms: {
|
|
125
|
+
readonly type: "integer";
|
|
126
|
+
readonly minimum: 1000;
|
|
127
|
+
readonly maximum: 600000;
|
|
128
|
+
readonly description: "Default timeout in milliseconds (1s-10min)";
|
|
129
|
+
};
|
|
130
|
+
};
|
|
131
|
+
};
|
|
132
|
+
readonly roles: {
|
|
133
|
+
readonly type: "object";
|
|
134
|
+
readonly minProperties: 1;
|
|
135
|
+
readonly additionalProperties: {
|
|
136
|
+
readonly $ref: "#/$defs/roleConfig";
|
|
137
|
+
};
|
|
138
|
+
readonly description: "Role definitions mapping role names to configurations";
|
|
139
|
+
};
|
|
140
|
+
readonly providers: {
|
|
141
|
+
readonly type: "object";
|
|
142
|
+
readonly minProperties: 1;
|
|
143
|
+
readonly additionalProperties: {
|
|
144
|
+
readonly $ref: "#/$defs/providerConfig";
|
|
145
|
+
};
|
|
146
|
+
readonly description: "Provider configurations";
|
|
147
|
+
};
|
|
148
|
+
};
|
|
149
|
+
readonly $defs: {
|
|
150
|
+
readonly roleConfig: {
|
|
151
|
+
readonly type: "object";
|
|
152
|
+
readonly required: readonly ["provider", "model"];
|
|
153
|
+
readonly additionalProperties: false;
|
|
154
|
+
readonly properties: {
|
|
155
|
+
readonly provider: {
|
|
156
|
+
readonly type: "string";
|
|
157
|
+
readonly minLength: 1;
|
|
158
|
+
readonly description: "Provider name (must match a key in providers)";
|
|
159
|
+
};
|
|
160
|
+
readonly model: {
|
|
161
|
+
readonly type: "string";
|
|
162
|
+
readonly minLength: 1;
|
|
163
|
+
readonly description: "Model identifier";
|
|
164
|
+
};
|
|
165
|
+
readonly system_prompt: {
|
|
166
|
+
readonly type: "string";
|
|
167
|
+
readonly description: "System prompt / persona for this role";
|
|
168
|
+
};
|
|
169
|
+
readonly temperature: {
|
|
170
|
+
readonly type: "number";
|
|
171
|
+
readonly minimum: 0;
|
|
172
|
+
readonly maximum: 2;
|
|
173
|
+
readonly description: "Temperature override (0-2)";
|
|
174
|
+
};
|
|
175
|
+
readonly max_tokens: {
|
|
176
|
+
readonly type: "integer";
|
|
177
|
+
readonly minimum: 1;
|
|
178
|
+
readonly maximum: 200000;
|
|
179
|
+
readonly description: "Max tokens override";
|
|
180
|
+
};
|
|
181
|
+
readonly timeout_ms: {
|
|
182
|
+
readonly type: "integer";
|
|
183
|
+
readonly minimum: 1000;
|
|
184
|
+
readonly maximum: 600000;
|
|
185
|
+
readonly description: "Timeout override in milliseconds";
|
|
186
|
+
};
|
|
187
|
+
readonly fallback: {
|
|
188
|
+
readonly $ref: "#/$defs/fallbackConfig";
|
|
189
|
+
};
|
|
190
|
+
};
|
|
191
|
+
};
|
|
192
|
+
readonly fallbackConfig: {
|
|
193
|
+
readonly type: "object";
|
|
194
|
+
readonly required: readonly ["provider", "model"];
|
|
195
|
+
readonly additionalProperties: false;
|
|
196
|
+
readonly properties: {
|
|
197
|
+
readonly provider: {
|
|
198
|
+
readonly type: "string";
|
|
199
|
+
readonly minLength: 1;
|
|
200
|
+
readonly description: "Fallback provider name";
|
|
201
|
+
};
|
|
202
|
+
readonly model: {
|
|
203
|
+
readonly type: "string";
|
|
204
|
+
readonly minLength: 1;
|
|
205
|
+
readonly description: "Fallback model identifier";
|
|
206
|
+
};
|
|
207
|
+
};
|
|
208
|
+
};
|
|
209
|
+
readonly providerConfig: {
|
|
210
|
+
readonly type: "object";
|
|
211
|
+
readonly additionalProperties: false;
|
|
212
|
+
readonly properties: {
|
|
213
|
+
readonly api_key: {
|
|
214
|
+
readonly type: "string";
|
|
215
|
+
readonly description: "API key (supports ${ENV_VAR} interpolation)";
|
|
216
|
+
};
|
|
217
|
+
readonly base_url: {
|
|
218
|
+
readonly type: "string";
|
|
219
|
+
readonly format: "uri";
|
|
220
|
+
readonly description: "Base URL for the provider API";
|
|
221
|
+
};
|
|
222
|
+
readonly organization: {
|
|
223
|
+
readonly type: "string";
|
|
224
|
+
readonly description: "Organization ID (OpenAI)";
|
|
225
|
+
};
|
|
226
|
+
readonly project: {
|
|
227
|
+
readonly type: "string";
|
|
228
|
+
readonly description: "Project ID (Google Cloud)";
|
|
229
|
+
};
|
|
230
|
+
readonly location: {
|
|
231
|
+
readonly type: "string";
|
|
232
|
+
readonly description: "Region/location (Google Cloud)";
|
|
233
|
+
};
|
|
234
|
+
readonly headers: {
|
|
235
|
+
readonly type: "object";
|
|
236
|
+
readonly additionalProperties: {
|
|
237
|
+
readonly type: "string";
|
|
238
|
+
};
|
|
239
|
+
readonly description: "Additional headers for API requests";
|
|
240
|
+
};
|
|
241
|
+
readonly access_mode: {
|
|
242
|
+
readonly type: "string";
|
|
243
|
+
readonly enum: readonly ["api", "subscription"];
|
|
244
|
+
readonly description: "Access mode: \"api\" for pay-per-token or \"subscription\" for CLI tools";
|
|
245
|
+
};
|
|
246
|
+
readonly default_model: {
|
|
247
|
+
readonly type: "string";
|
|
248
|
+
readonly description: "Default model for this provider";
|
|
249
|
+
};
|
|
250
|
+
};
|
|
251
|
+
};
|
|
252
|
+
};
|
|
253
|
+
};
|
|
254
|
+
//# sourceMappingURL=validator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validator.d.ts","sourceRoot":"","sources":["../../src/config/validator.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAmB,EAAE,KAAK,WAAW,EAA8C,MAAM,KAAK,CAAC;AAE/F,OAAO,EAAsB,KAAM,MAAM,EAAE,MAAM,aAAa,CAAC;AAuL/D;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,gCAAgC;IAChC,KAAK,EAAE,OAAO,CAAC;IACf,+CAA+C;IAC/C,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,sCAAsC;IACtC,OAAO,CAAC,EAAE,WAAW,EAAE,CAAC;CACzB;AAED;;GAEG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,GAAG,CAAU;IACrB,OAAO,CAAC,YAAY,CAAmB;IACvC,OAAO,CAAC,eAAe,CAAmB;;IAgB1C;;;;;;;OAOG;IACH,QAAQ,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM;IAejC;;;;;;;OAOG;IACH,qBAAqB,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC;IAYvD;;;;;;OAMG;IACH,cAAc,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,UAAQ,GAAG,gBAAgB;IAyBlE;;;;;;OAMG;IACH,OAAO,CAAC,iBAAiB;IA2BzB;;;;;OAKG;IACH,OAAO,CAAC,YAAY;IAQpB;;;;;OAKG;IACH,OAAO,CAAC,eAAe;CAsCxB;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,CAGtD;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,IAAI,MAAM,CAI/D;AAED;;GAEG;AACH,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAAgB,CAAC"}
|
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration Validator for AgentRouter
|
|
3
|
+
*
|
|
4
|
+
* Validates configuration objects against a JSON Schema using AJV.
|
|
5
|
+
* Provides detailed, human-readable error messages on validation failure.
|
|
6
|
+
*/
|
|
7
|
+
import AjvDefault from 'ajv';
|
|
8
|
+
import { ConfigurationError } from '../types.js';
|
|
9
|
+
// Handle ESM/CJS interop - AJV exports both default and named export
|
|
10
|
+
const Ajv = AjvDefault.default ?? AjvDefault;
|
|
11
|
+
/**
|
|
12
|
+
* JSON Schema for AgentRouter configuration.
|
|
13
|
+
* Defines the structure and constraints for config files.
|
|
14
|
+
*/
|
|
15
|
+
const CONFIG_SCHEMA = {
|
|
16
|
+
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
17
|
+
type: 'object',
|
|
18
|
+
required: ['version', 'defaults', 'roles', 'providers'],
|
|
19
|
+
additionalProperties: false,
|
|
20
|
+
properties: {
|
|
21
|
+
version: {
|
|
22
|
+
type: 'string',
|
|
23
|
+
pattern: '^\\d+\\.\\d+$',
|
|
24
|
+
description: 'Configuration schema version (e.g., "1.0")',
|
|
25
|
+
},
|
|
26
|
+
defaults: {
|
|
27
|
+
type: 'object',
|
|
28
|
+
required: ['temperature', 'max_tokens', 'timeout_ms'],
|
|
29
|
+
additionalProperties: false,
|
|
30
|
+
properties: {
|
|
31
|
+
temperature: {
|
|
32
|
+
type: 'number',
|
|
33
|
+
minimum: 0,
|
|
34
|
+
maximum: 2,
|
|
35
|
+
description: 'Default temperature for LLM requests (0-2)',
|
|
36
|
+
},
|
|
37
|
+
max_tokens: {
|
|
38
|
+
type: 'integer',
|
|
39
|
+
minimum: 1,
|
|
40
|
+
maximum: 200000,
|
|
41
|
+
description: 'Default maximum tokens for LLM responses',
|
|
42
|
+
},
|
|
43
|
+
timeout_ms: {
|
|
44
|
+
type: 'integer',
|
|
45
|
+
minimum: 1000,
|
|
46
|
+
maximum: 600000,
|
|
47
|
+
description: 'Default timeout in milliseconds (1s-10min)',
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
roles: {
|
|
52
|
+
type: 'object',
|
|
53
|
+
minProperties: 1,
|
|
54
|
+
additionalProperties: {
|
|
55
|
+
$ref: '#/$defs/roleConfig',
|
|
56
|
+
},
|
|
57
|
+
description: 'Role definitions mapping role names to configurations',
|
|
58
|
+
},
|
|
59
|
+
providers: {
|
|
60
|
+
type: 'object',
|
|
61
|
+
minProperties: 1,
|
|
62
|
+
additionalProperties: {
|
|
63
|
+
$ref: '#/$defs/providerConfig',
|
|
64
|
+
},
|
|
65
|
+
description: 'Provider configurations',
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
$defs: {
|
|
69
|
+
roleConfig: {
|
|
70
|
+
type: 'object',
|
|
71
|
+
required: ['provider', 'model'],
|
|
72
|
+
additionalProperties: false,
|
|
73
|
+
properties: {
|
|
74
|
+
provider: {
|
|
75
|
+
type: 'string',
|
|
76
|
+
minLength: 1,
|
|
77
|
+
description: 'Provider name (must match a key in providers)',
|
|
78
|
+
},
|
|
79
|
+
model: {
|
|
80
|
+
type: 'string',
|
|
81
|
+
minLength: 1,
|
|
82
|
+
description: 'Model identifier',
|
|
83
|
+
},
|
|
84
|
+
system_prompt: {
|
|
85
|
+
type: 'string',
|
|
86
|
+
description: 'System prompt / persona for this role',
|
|
87
|
+
},
|
|
88
|
+
temperature: {
|
|
89
|
+
type: 'number',
|
|
90
|
+
minimum: 0,
|
|
91
|
+
maximum: 2,
|
|
92
|
+
description: 'Temperature override (0-2)',
|
|
93
|
+
},
|
|
94
|
+
max_tokens: {
|
|
95
|
+
type: 'integer',
|
|
96
|
+
minimum: 1,
|
|
97
|
+
maximum: 200000,
|
|
98
|
+
description: 'Max tokens override',
|
|
99
|
+
},
|
|
100
|
+
timeout_ms: {
|
|
101
|
+
type: 'integer',
|
|
102
|
+
minimum: 1000,
|
|
103
|
+
maximum: 600000,
|
|
104
|
+
description: 'Timeout override in milliseconds',
|
|
105
|
+
},
|
|
106
|
+
fallback: {
|
|
107
|
+
$ref: '#/$defs/fallbackConfig',
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
fallbackConfig: {
|
|
112
|
+
type: 'object',
|
|
113
|
+
required: ['provider', 'model'],
|
|
114
|
+
additionalProperties: false,
|
|
115
|
+
properties: {
|
|
116
|
+
provider: {
|
|
117
|
+
type: 'string',
|
|
118
|
+
minLength: 1,
|
|
119
|
+
description: 'Fallback provider name',
|
|
120
|
+
},
|
|
121
|
+
model: {
|
|
122
|
+
type: 'string',
|
|
123
|
+
minLength: 1,
|
|
124
|
+
description: 'Fallback model identifier',
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
providerConfig: {
|
|
129
|
+
type: 'object',
|
|
130
|
+
additionalProperties: false,
|
|
131
|
+
properties: {
|
|
132
|
+
api_key: {
|
|
133
|
+
type: 'string',
|
|
134
|
+
description: 'API key (supports ${ENV_VAR} interpolation)',
|
|
135
|
+
},
|
|
136
|
+
base_url: {
|
|
137
|
+
type: 'string',
|
|
138
|
+
format: 'uri',
|
|
139
|
+
description: 'Base URL for the provider API',
|
|
140
|
+
},
|
|
141
|
+
organization: {
|
|
142
|
+
type: 'string',
|
|
143
|
+
description: 'Organization ID (OpenAI)',
|
|
144
|
+
},
|
|
145
|
+
project: {
|
|
146
|
+
type: 'string',
|
|
147
|
+
description: 'Project ID (Google Cloud)',
|
|
148
|
+
},
|
|
149
|
+
location: {
|
|
150
|
+
type: 'string',
|
|
151
|
+
description: 'Region/location (Google Cloud)',
|
|
152
|
+
},
|
|
153
|
+
headers: {
|
|
154
|
+
type: 'object',
|
|
155
|
+
additionalProperties: { type: 'string' },
|
|
156
|
+
description: 'Additional headers for API requests',
|
|
157
|
+
},
|
|
158
|
+
access_mode: {
|
|
159
|
+
type: 'string',
|
|
160
|
+
enum: ['api', 'subscription'],
|
|
161
|
+
description: 'Access mode: "api" for pay-per-token or "subscription" for CLI tools',
|
|
162
|
+
},
|
|
163
|
+
default_model: {
|
|
164
|
+
type: 'string',
|
|
165
|
+
description: 'Default model for this provider',
|
|
166
|
+
},
|
|
167
|
+
},
|
|
168
|
+
},
|
|
169
|
+
},
|
|
170
|
+
};
|
|
171
|
+
/**
|
|
172
|
+
* Schema for partial configuration (used during merging).
|
|
173
|
+
* All top-level fields are optional.
|
|
174
|
+
*/
|
|
175
|
+
const PARTIAL_CONFIG_SCHEMA = {
|
|
176
|
+
...CONFIG_SCHEMA,
|
|
177
|
+
required: [],
|
|
178
|
+
properties: {
|
|
179
|
+
...CONFIG_SCHEMA.properties,
|
|
180
|
+
defaults: {
|
|
181
|
+
type: 'object',
|
|
182
|
+
additionalProperties: false,
|
|
183
|
+
properties: CONFIG_SCHEMA.properties.defaults.properties,
|
|
184
|
+
},
|
|
185
|
+
},
|
|
186
|
+
};
|
|
187
|
+
/**
|
|
188
|
+
* Configuration validator using AJV.
|
|
189
|
+
*/
|
|
190
|
+
export class ConfigValidator {
|
|
191
|
+
ajv;
|
|
192
|
+
validateFull;
|
|
193
|
+
validatePartial;
|
|
194
|
+
constructor() {
|
|
195
|
+
this.ajv = new Ajv({
|
|
196
|
+
allErrors: true,
|
|
197
|
+
verbose: true,
|
|
198
|
+
strict: true,
|
|
199
|
+
formats: {
|
|
200
|
+
uri: /^https?:\/\/.+/,
|
|
201
|
+
},
|
|
202
|
+
});
|
|
203
|
+
this.validateFull = this.ajv.compile(CONFIG_SCHEMA);
|
|
204
|
+
this.validatePartial = this.ajv.compile(PARTIAL_CONFIG_SCHEMA);
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Validate a complete configuration object.
|
|
208
|
+
* Throws ConfigurationError if validation fails.
|
|
209
|
+
*
|
|
210
|
+
* @param config - Configuration object to validate
|
|
211
|
+
* @returns The validated config (typed as Config)
|
|
212
|
+
* @throws ConfigurationError if validation fails
|
|
213
|
+
*/
|
|
214
|
+
validate(config) {
|
|
215
|
+
const result = this.validateConfig(config, false);
|
|
216
|
+
if (!result.valid) {
|
|
217
|
+
throw new ConfigurationError(`Invalid configuration:\n${result.errors.map((e) => ` - ${e}`).join('\n')}`);
|
|
218
|
+
}
|
|
219
|
+
// Additional semantic validation
|
|
220
|
+
this.validateSemantics(config);
|
|
221
|
+
return config;
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Validate a partial configuration object (for merging).
|
|
225
|
+
* Throws ConfigurationError if validation fails.
|
|
226
|
+
*
|
|
227
|
+
* @param config - Partial configuration object to validate
|
|
228
|
+
* @returns The validated partial config
|
|
229
|
+
* @throws ConfigurationError if validation fails
|
|
230
|
+
*/
|
|
231
|
+
validatePartialConfig(config) {
|
|
232
|
+
const result = this.validateConfig(config, true);
|
|
233
|
+
if (!result.valid) {
|
|
234
|
+
throw new ConfigurationError(`Invalid partial configuration:\n${result.errors.map((e) => ` - ${e}`).join('\n')}`);
|
|
235
|
+
}
|
|
236
|
+
return config;
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Validate configuration and return a result object instead of throwing.
|
|
240
|
+
*
|
|
241
|
+
* @param config - Configuration object to validate
|
|
242
|
+
* @param partial - Whether to validate as partial config
|
|
243
|
+
* @returns ValidationResult with valid flag and any errors
|
|
244
|
+
*/
|
|
245
|
+
validateConfig(config, partial = false) {
|
|
246
|
+
const validator = partial ? this.validatePartial : this.validateFull;
|
|
247
|
+
const valid = validator(config);
|
|
248
|
+
if (valid) {
|
|
249
|
+
return { valid: true, errors: [] };
|
|
250
|
+
}
|
|
251
|
+
const errors = this.formatErrors(validator.errors ?? []);
|
|
252
|
+
const details = validator.errors ?? undefined;
|
|
253
|
+
if (details) {
|
|
254
|
+
return {
|
|
255
|
+
valid: false,
|
|
256
|
+
errors,
|
|
257
|
+
details,
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
return {
|
|
261
|
+
valid: false,
|
|
262
|
+
errors,
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Perform semantic validation beyond schema validation.
|
|
267
|
+
* Checks for logical consistency like provider references.
|
|
268
|
+
*
|
|
269
|
+
* @param config - Config object that passed schema validation
|
|
270
|
+
* @throws ConfigurationError if semantic validation fails
|
|
271
|
+
*/
|
|
272
|
+
validateSemantics(config) {
|
|
273
|
+
const errors = [];
|
|
274
|
+
const providerNames = new Set(Object.keys(config.providers));
|
|
275
|
+
// Check that all role providers exist
|
|
276
|
+
for (const [roleName, roleConfig] of Object.entries(config.roles)) {
|
|
277
|
+
if (!providerNames.has(roleConfig.provider)) {
|
|
278
|
+
errors.push(`Role "${roleName}" references undefined provider "${roleConfig.provider}"`);
|
|
279
|
+
}
|
|
280
|
+
// Check fallback provider exists
|
|
281
|
+
if (roleConfig.fallback && !providerNames.has(roleConfig.fallback.provider)) {
|
|
282
|
+
errors.push(`Role "${roleName}" fallback references undefined provider "${roleConfig.fallback.provider}"`);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
if (errors.length > 0) {
|
|
286
|
+
throw new ConfigurationError(`Configuration semantic errors:\n${errors.map((e) => ` - ${e}`).join('\n')}`);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Format AJV errors into human-readable messages.
|
|
291
|
+
*
|
|
292
|
+
* @param errors - Array of AJV error objects
|
|
293
|
+
* @returns Array of formatted error strings
|
|
294
|
+
*/
|
|
295
|
+
formatErrors(errors) {
|
|
296
|
+
return errors.map((error) => {
|
|
297
|
+
const path = error.instancePath || 'root';
|
|
298
|
+
const message = this.getErrorMessage(error);
|
|
299
|
+
return `${path}: ${message}`;
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Get a human-readable message for an AJV error.
|
|
304
|
+
*
|
|
305
|
+
* @param error - AJV error object
|
|
306
|
+
* @returns Human-readable error message
|
|
307
|
+
*/
|
|
308
|
+
getErrorMessage(error) {
|
|
309
|
+
const params = error.params;
|
|
310
|
+
switch (error.keyword) {
|
|
311
|
+
case 'required':
|
|
312
|
+
return `missing required property "${params['missingProperty']}"`;
|
|
313
|
+
case 'additionalProperties':
|
|
314
|
+
return `unexpected property "${params['additionalProperty']}"`;
|
|
315
|
+
case 'type':
|
|
316
|
+
return `expected ${params['type']}, got ${typeof error.data}`;
|
|
317
|
+
case 'minimum':
|
|
318
|
+
return `value ${error.data} is less than minimum ${params['limit']}`;
|
|
319
|
+
case 'maximum':
|
|
320
|
+
return `value ${error.data} is greater than maximum ${params['limit']}`;
|
|
321
|
+
case 'minLength':
|
|
322
|
+
return `string is too short (minimum ${params['limit']} characters)`;
|
|
323
|
+
case 'pattern':
|
|
324
|
+
return `string does not match required pattern "${params['pattern']}"`;
|
|
325
|
+
case 'format':
|
|
326
|
+
return `invalid format, expected ${params['format']}`;
|
|
327
|
+
case 'minProperties':
|
|
328
|
+
return `object must have at least ${params['limit']} properties`;
|
|
329
|
+
case 'enum':
|
|
330
|
+
return `must be one of: ${params['allowedValues'].join(', ')}`;
|
|
331
|
+
default:
|
|
332
|
+
return error.message ?? 'validation failed';
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* Convenience function to validate a configuration object.
|
|
338
|
+
* Creates a new validator instance and validates the config.
|
|
339
|
+
*
|
|
340
|
+
* @param config - Configuration object to validate
|
|
341
|
+
* @returns The validated config
|
|
342
|
+
* @throws ConfigurationError if validation fails
|
|
343
|
+
*/
|
|
344
|
+
export function validateConfig(config) {
|
|
345
|
+
const validator = new ConfigValidator();
|
|
346
|
+
return validator.validate(config);
|
|
347
|
+
}
|
|
348
|
+
/**
|
|
349
|
+
* Convenience function to check if a config is valid without throwing.
|
|
350
|
+
*
|
|
351
|
+
* @param config - Configuration object to check
|
|
352
|
+
* @returns True if valid, false otherwise
|
|
353
|
+
*/
|
|
354
|
+
export function isValidConfig(config) {
|
|
355
|
+
const validator = new ConfigValidator();
|
|
356
|
+
const result = validator.validateConfig(config, false);
|
|
357
|
+
return result.valid;
|
|
358
|
+
}
|
|
359
|
+
/**
|
|
360
|
+
* Export the schema for external use (e.g., generating schema.json).
|
|
361
|
+
*/
|
|
362
|
+
export const configSchema = CONFIG_SCHEMA;
|
|
363
|
+
//# sourceMappingURL=validator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validator.js","sourceRoot":"","sources":["../../src/config/validator.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,UAA4E,MAAM,KAAK,CAAC;AAE/F,OAAO,EAAE,kBAAkB,EAAgB,MAAM,aAAa,CAAC;AAE/D,qEAAqE;AACrE,MAAM,GAAG,GAAG,UAAU,CAAC,OAAO,IAAI,UAAU,CAAC;AAE7C;;;GAGG;AACH,MAAM,aAAa,GAAG;IACpB,OAAO,EAAE,yCAAyC;IAClD,IAAI,EAAE,QAAQ;IACd,QAAQ,EAAE,CAAC,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,WAAW,CAAC;IACvD,oBAAoB,EAAE,KAAK;IAC3B,UAAU,EAAE;QACV,OAAO,EAAE;YACP,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,eAAe;YACxB,WAAW,EAAE,4CAA4C;SAC1D;QACD,QAAQ,EAAE;YACR,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,CAAC,aAAa,EAAE,YAAY,EAAE,YAAY,CAAC;YACrD,oBAAoB,EAAE,KAAK;YAC3B,UAAU,EAAE;gBACV,WAAW,EAAE;oBACX,IAAI,EAAE,QAAQ;oBACd,OAAO,EAAE,CAAC;oBACV,OAAO,EAAE,CAAC;oBACV,WAAW,EAAE,4CAA4C;iBAC1D;gBACD,UAAU,EAAE;oBACV,IAAI,EAAE,SAAS;oBACf,OAAO,EAAE,CAAC;oBACV,OAAO,EAAE,MAAM;oBACf,WAAW,EAAE,0CAA0C;iBACxD;gBACD,UAAU,EAAE;oBACV,IAAI,EAAE,SAAS;oBACf,OAAO,EAAE,IAAI;oBACb,OAAO,EAAE,MAAM;oBACf,WAAW,EAAE,4CAA4C;iBAC1D;aACF;SACF;QACD,KAAK,EAAE;YACL,IAAI,EAAE,QAAQ;YACd,aAAa,EAAE,CAAC;YAChB,oBAAoB,EAAE;gBACpB,IAA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CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,aAAa,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default Worktree Configuration
|
|
3
|
+
*
|
|
4
|
+
* Defines which roles need worktrees and default worktree settings.
|
|
5
|
+
*/
|
|
6
|
+
import type { WorktreeConfig } from '../types.js';
|
|
7
|
+
/**
|
|
8
|
+
* Roles that need isolated worktrees by default
|
|
9
|
+
*/
|
|
10
|
+
export declare const ROLES_NEEDING_WORKTREE: Set<string>;
|
|
11
|
+
/**
|
|
12
|
+
* Check if a role needs a worktree
|
|
13
|
+
*/
|
|
14
|
+
export declare function roleNeedsWorktree(role: string, configOverride?: boolean): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Default worktree configuration
|
|
17
|
+
*/
|
|
18
|
+
export declare const DEFAULT_WORKTREE_CONFIG: WorktreeConfig;
|
|
19
|
+
/**
|
|
20
|
+
* Merge user config with defaults
|
|
21
|
+
*/
|
|
22
|
+
export declare function mergeWorktreeConfig(userConfig?: Partial<WorktreeConfig>): WorktreeConfig;
|
|
23
|
+
//# sourceMappingURL=worktree-defaults.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worktree-defaults.d.ts","sourceRoot":"","sources":["../../src/config/worktree-defaults.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD;;GAEG;AACH,eAAO,MAAM,sBAAsB,EAAE,GAAG,CAAC,MAAM,CAK7C,CAAC;AAEH;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,OAAO,GAAG,OAAO,CAOjF;AAED;;GAEG;AACH,eAAO,MAAM,uBAAuB,EAAE,cAqBrC,CAAC;AAEF;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,GAAG,cAAc,CAuBxF"}
|