agent-consultation-mcp 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.
Files changed (94) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +140 -0
  3. package/dist/api/index.d.ts +27 -0
  4. package/dist/api/index.js +213 -0
  5. package/dist/api/index.js.map +1 -0
  6. package/dist/api/middleware/security.d.ts +6 -0
  7. package/dist/api/middleware/security.js +28 -0
  8. package/dist/api/middleware/security.js.map +1 -0
  9. package/dist/api/routes/chat.d.ts +2 -0
  10. package/dist/api/routes/chat.js +61 -0
  11. package/dist/api/routes/chat.js.map +1 -0
  12. package/dist/api/routes/config.d.ts +2 -0
  13. package/dist/api/routes/config.js +81 -0
  14. package/dist/api/routes/config.js.map +1 -0
  15. package/dist/api/routes/providers.d.ts +2 -0
  16. package/dist/api/routes/providers.js +225 -0
  17. package/dist/api/routes/providers.js.map +1 -0
  18. package/dist/api/standalone-server.d.ts +12 -0
  19. package/dist/api/standalone-server.js +91 -0
  20. package/dist/api/standalone-server.js.map +1 -0
  21. package/dist/config/defaults.d.ts +17 -0
  22. package/dist/config/defaults.js +30 -0
  23. package/dist/config/defaults.js.map +1 -0
  24. package/dist/config/encryption.d.ts +12 -0
  25. package/dist/config/encryption.js +85 -0
  26. package/dist/config/encryption.js.map +1 -0
  27. package/dist/config/index.d.ts +5 -0
  28. package/dist/config/index.js +6 -0
  29. package/dist/config/index.js.map +1 -0
  30. package/dist/config/manager.d.ts +62 -0
  31. package/dist/config/manager.js +186 -0
  32. package/dist/config/manager.js.map +1 -0
  33. package/dist/config/prompts.d.ts +10 -0
  34. package/dist/config/prompts.js +140 -0
  35. package/dist/config/prompts.js.map +1 -0
  36. package/dist/config/schema.d.ts +141 -0
  37. package/dist/config/schema.js +54 -0
  38. package/dist/config/schema.js.map +1 -0
  39. package/dist/index.d.ts +2 -0
  40. package/dist/index.js +224 -0
  41. package/dist/index.js.map +1 -0
  42. package/dist/providers/base.d.ts +44 -0
  43. package/dist/providers/base.js +84 -0
  44. package/dist/providers/base.js.map +1 -0
  45. package/dist/providers/deepseek.d.ts +30 -0
  46. package/dist/providers/deepseek.js +148 -0
  47. package/dist/providers/deepseek.js.map +1 -0
  48. package/dist/providers/index.d.ts +5 -0
  49. package/dist/providers/index.js +8 -0
  50. package/dist/providers/index.js.map +1 -0
  51. package/dist/providers/openai.d.ts +30 -0
  52. package/dist/providers/openai.js +123 -0
  53. package/dist/providers/openai.js.map +1 -0
  54. package/dist/providers/registry.d.ts +37 -0
  55. package/dist/providers/registry.js +65 -0
  56. package/dist/providers/registry.js.map +1 -0
  57. package/dist/providers/types.d.ts +71 -0
  58. package/dist/providers/types.js +2 -0
  59. package/dist/providers/types.js.map +1 -0
  60. package/dist/server/conversation.d.ts +101 -0
  61. package/dist/server/conversation.js +275 -0
  62. package/dist/server/conversation.js.map +1 -0
  63. package/dist/server/index.d.ts +2 -0
  64. package/dist/server/index.js +3 -0
  65. package/dist/server/index.js.map +1 -0
  66. package/dist/server/tools/consult.d.ts +15 -0
  67. package/dist/server/tools/consult.js +164 -0
  68. package/dist/server/tools/consult.js.map +1 -0
  69. package/dist/server/tools/index.d.ts +1 -0
  70. package/dist/server/tools/index.js +2 -0
  71. package/dist/server/tools/index.js.map +1 -0
  72. package/dist/types/config.d.ts +20 -0
  73. package/dist/types/config.js +2 -0
  74. package/dist/types/config.js.map +1 -0
  75. package/dist/types/index.d.ts +3 -0
  76. package/dist/types/index.js +4 -0
  77. package/dist/types/index.js.map +1 -0
  78. package/dist/types/messages.d.ts +48 -0
  79. package/dist/types/messages.js +2 -0
  80. package/dist/types/messages.js.map +1 -0
  81. package/dist/types/models.d.ts +39 -0
  82. package/dist/types/models.js +66 -0
  83. package/dist/types/models.js.map +1 -0
  84. package/dist/ui/index.html +1044 -0
  85. package/dist/utils/errors.d.ts +32 -0
  86. package/dist/utils/errors.js +53 -0
  87. package/dist/utils/errors.js.map +1 -0
  88. package/dist/utils/index.d.ts +2 -0
  89. package/dist/utils/index.js +3 -0
  90. package/dist/utils/index.js.map +1 -0
  91. package/dist/utils/logger.d.ts +13 -0
  92. package/dist/utils/logger.js +73 -0
  93. package/dist/utils/logger.js.map +1 -0
  94. package/package.json +65 -0
@@ -0,0 +1,186 @@
1
+ import fs from 'node:fs/promises';
2
+ import path from 'node:path';
3
+ import { ConfigError } from '../utils/index.js';
4
+ import { logger } from '../utils/index.js';
5
+ import { DEFAULT_CONFIG } from './defaults.js';
6
+ import { encrypt, decrypt, isEncrypted } from './encryption.js';
7
+ import { configSchema } from './schema.js';
8
+ /**
9
+ * Configuration file manager
10
+ * Handles loading, saving, and encrypting configuration
11
+ */
12
+ export class ConfigManager {
13
+ config;
14
+ configPath;
15
+ constructor(configPath) {
16
+ this.config = { ...DEFAULT_CONFIG };
17
+ this.configPath =
18
+ configPath || path.join(process.cwd(), 'config', 'config.json');
19
+ }
20
+ /**
21
+ * Initialize the config manager and load configuration
22
+ */
23
+ async init() {
24
+ try {
25
+ await this.load();
26
+ logger.info('Configuration loaded successfully');
27
+ }
28
+ catch (error) {
29
+ if (error.code === 'ENOENT') {
30
+ logger.info('No config file found, using defaults');
31
+ await this.save();
32
+ }
33
+ else {
34
+ throw error;
35
+ }
36
+ }
37
+ }
38
+ /**
39
+ * Load configuration from file
40
+ */
41
+ async load() {
42
+ const data = await fs.readFile(this.configPath, 'utf-8');
43
+ const rawConfig = JSON.parse(data);
44
+ // Decrypt API keys
45
+ const decryptedConfig = this.decryptApiKeys(rawConfig);
46
+ // Validate configuration
47
+ const result = configSchema.safeParse(decryptedConfig);
48
+ if (!result.success) {
49
+ throw new ConfigError(`Invalid configuration: ${result.error.message}`);
50
+ }
51
+ this.config = result.data;
52
+ return this.config;
53
+ }
54
+ /**
55
+ * Save configuration to file
56
+ */
57
+ async save() {
58
+ // Ensure config directory exists
59
+ const configDir = path.dirname(this.configPath);
60
+ await fs.mkdir(configDir, { recursive: true });
61
+ // Encrypt API keys before saving
62
+ const encryptedConfig = this.encryptApiKeys(this.config);
63
+ await fs.writeFile(this.configPath, JSON.stringify(encryptedConfig, null, 2), 'utf-8');
64
+ logger.info('Configuration saved');
65
+ }
66
+ /**
67
+ * Get current configuration (with decrypted keys)
68
+ */
69
+ getConfig() {
70
+ return { ...this.config };
71
+ }
72
+ /**
73
+ * Get configuration without API keys (safe for display)
74
+ */
75
+ getSafeConfig() {
76
+ const safe = { ...this.config };
77
+ for (const provider of Object.keys(safe.providers)) {
78
+ if (safe.providers[provider].apiKey) {
79
+ safe.providers[provider] = {
80
+ ...safe.providers[provider],
81
+ apiKey: '***configured***',
82
+ };
83
+ }
84
+ }
85
+ return safe;
86
+ }
87
+ /**
88
+ * Update configuration
89
+ */
90
+ async update(updates) {
91
+ this.config = {
92
+ ...this.config,
93
+ ...updates,
94
+ providers: {
95
+ ...this.config.providers,
96
+ ...updates.providers,
97
+ },
98
+ };
99
+ // Validate after update
100
+ const result = configSchema.safeParse(this.config);
101
+ if (!result.success) {
102
+ throw new ConfigError(`Invalid configuration update: ${result.error.message}`);
103
+ }
104
+ await this.save();
105
+ }
106
+ /**
107
+ * Set provider API key
108
+ */
109
+ async setProviderKey(provider, apiKey) {
110
+ this.config.providers[provider] = {
111
+ ...this.config.providers[provider],
112
+ enabled: true,
113
+ apiKey,
114
+ };
115
+ await this.save();
116
+ logger.info(`API key set for provider: ${provider}`);
117
+ }
118
+ /**
119
+ * Remove provider API key
120
+ */
121
+ async removeProviderKey(provider) {
122
+ this.config.providers[provider] = {
123
+ enabled: false,
124
+ apiKey: undefined,
125
+ };
126
+ await this.save();
127
+ logger.info(`API key removed for provider: ${provider}`);
128
+ }
129
+ /**
130
+ * Check if a provider is configured
131
+ */
132
+ isProviderConfigured(provider) {
133
+ const providerConfig = this.config.providers[provider];
134
+ return providerConfig.enabled && !!providerConfig.apiKey;
135
+ }
136
+ /**
137
+ * Get API key for a provider (decrypted)
138
+ */
139
+ getProviderKey(provider) {
140
+ return this.config.providers[provider].apiKey;
141
+ }
142
+ /**
143
+ * Encrypt API keys in config object
144
+ */
145
+ encryptApiKeys(config) {
146
+ const encrypted = { ...config, providers: { ...config.providers } };
147
+ for (const provider of Object.keys(encrypted.providers)) {
148
+ const providerConfig = encrypted.providers[provider];
149
+ if (providerConfig.apiKey && !isEncrypted(providerConfig.apiKey)) {
150
+ encrypted.providers[provider] = {
151
+ ...providerConfig,
152
+ apiKey: encrypt(providerConfig.apiKey),
153
+ };
154
+ }
155
+ }
156
+ return encrypted;
157
+ }
158
+ /**
159
+ * Decrypt API keys in config object
160
+ */
161
+ decryptApiKeys(config) {
162
+ const decrypted = { ...config, providers: { ...config.providers } };
163
+ for (const provider of Object.keys(decrypted.providers)) {
164
+ const providerConfig = decrypted.providers[provider];
165
+ if (providerConfig.apiKey && isEncrypted(providerConfig.apiKey)) {
166
+ decrypted.providers[provider] = {
167
+ ...providerConfig,
168
+ apiKey: decrypt(providerConfig.apiKey),
169
+ };
170
+ }
171
+ }
172
+ return decrypted;
173
+ }
174
+ }
175
+ // Singleton instance
176
+ let configManagerInstance = null;
177
+ /**
178
+ * Get the config manager instance
179
+ */
180
+ export function getConfigManager(configPath) {
181
+ if (!configManagerInstance) {
182
+ configManagerInstance = new ConfigManager(configPath);
183
+ }
184
+ return configManagerInstance;
185
+ }
186
+ //# sourceMappingURL=manager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manager.js","sourceRoot":"","sources":["../../src/config/manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAChE,OAAO,EAAE,YAAY,EAA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,cAAc;oBACjB,MAAM,EAAE,OAAO,CAAC,cAAc,CAAC,MAAM,CAAC;iBACvC,CAAC;YACJ,CAAC;QACH,CAAC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;CACF;AAED,qBAAqB;AACrB,IAAI,qBAAqB,GAAyB,IAAI,CAAC;AAEvD;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,UAAmB;IAClD,IAAI,CAAC,qBAAqB,EAAE,CAAC;QAC3B,qBAAqB,GAAG,IAAI,aAAa,CAAC,UAAU,CAAC,CAAC;IACxD,CAAC;IACD,OAAO,qBAAqB,CAAC;AAC/B,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { ConsultationMode } from './schema.js';
2
+ /**
3
+ * Specialized system prompts for different consultation modes
4
+ * These are optimized for DeepSeek Reasoner's reasoning capabilities
5
+ */
6
+ export declare const SYSTEM_PROMPTS: Record<ConsultationMode, string>;
7
+ /**
8
+ * Get the system prompt for a given mode
9
+ */
10
+ export declare function getSystemPromptForMode(mode: ConsultationMode): string;
@@ -0,0 +1,140 @@
1
+ /**
2
+ * Specialized system prompts for different consultation modes
3
+ * These are optimized for DeepSeek Reasoner's reasoning capabilities
4
+ */
5
+ export const SYSTEM_PROMPTS = {
6
+ debug: `You are an expert debugger using systematic reasoning.
7
+
8
+ ANALYZE the problem using this framework:
9
+ 1. **OBSERVE**: What are the symptoms? What error messages exist?
10
+ 2. **HYPOTHESIZE**: What could cause this? List 3-5 possibilities.
11
+ 3. **TEST**: How would you verify each hypothesis?
12
+ 4. **CONCLUDE**: What is the most likely root cause?
13
+ 5. **FIX**: Provide the solution with code.
14
+
15
+ Show your reasoning process explicitly. Think step by step.
16
+
17
+ Format your response as:
18
+ ## Thinking Process
19
+ [Your detailed reasoning]
20
+
21
+ ## Root Cause
22
+ [The identified issue]
23
+
24
+ ## Solution
25
+ [Code fix with explanation]
26
+
27
+ ## Prevention
28
+ [How to avoid this in future]`,
29
+ analyzeCode: `You are a senior code reviewer with expertise in security, performance, and best practices.
30
+
31
+ REVIEW the code systematically:
32
+ 1. **CORRECTNESS**: Does it do what it's supposed to?
33
+ 2. **SECURITY**: Any vulnerabilities? (injection, XSS, auth issues)
34
+ 3. **PERFORMANCE**: Any bottlenecks? N+1 queries? Memory leaks?
35
+ 4. **MAINTAINABILITY**: Is it readable? Well-structured?
36
+ 5. **EDGE CASES**: What could go wrong?
37
+
38
+ Show your analysis process. Be specific with line references.
39
+
40
+ Format your response as:
41
+ ## Analysis Process
42
+ [Your systematic review]
43
+
44
+ ## Issues Found
45
+ [Prioritized list: Critical → Minor]
46
+
47
+ ## Recommendations
48
+ [Specific improvements with code examples]`,
49
+ reviewArchitecture: `You are a software architect helping with system design decisions.
50
+
51
+ ANALYZE the architecture problem:
52
+ 1. **REQUIREMENTS**: What are the functional and non-functional requirements?
53
+ 2. **CONSTRAINTS**: What limitations exist? (budget, team, timeline, tech stack)
54
+ 3. **OPTIONS**: What are the possible approaches? (minimum 3)
55
+ 4. **TRADE-OFFS**: Compare options on scalability, cost, complexity, maintainability
56
+ 5. **RECOMMENDATION**: Which approach and why?
57
+
58
+ Think through each option thoroughly before recommending.
59
+
60
+ Format your response as:
61
+ ## Understanding
62
+ [Problem restatement and requirements]
63
+
64
+ ## Options Analysis
65
+ [Each option with pros/cons]
66
+
67
+ ## Recommendation
68
+ [Your choice with detailed justification]
69
+
70
+ ## Implementation Roadmap
71
+ [High-level steps]`,
72
+ validatePlan: `You are a technical lead reviewing an implementation plan.
73
+
74
+ EVALUATE the plan:
75
+ 1. **COMPLETENESS**: Are all necessary steps included?
76
+ 2. **ORDERING**: Is the sequence logical? Dependencies correct?
77
+ 3. **RISKS**: What could go wrong? What's missing?
78
+ 4. **EFFORT**: Is the estimation realistic?
79
+ 5. **ALTERNATIVES**: Are there better approaches?
80
+
81
+ Be constructive but thorough. Identify gaps.
82
+
83
+ Format your response as:
84
+ ## Plan Assessment
85
+ [Overall evaluation]
86
+
87
+ ## Strengths
88
+ [What's good about the plan]
89
+
90
+ ## Concerns
91
+ [Issues and risks identified]
92
+
93
+ ## Suggestions
94
+ [Specific improvements]`,
95
+ explainConcept: `You are a patient teacher explaining technical concepts.
96
+
97
+ EXPLAIN using this approach:
98
+ 1. **SIMPLE ANALOGY**: Start with a real-world comparison
99
+ 2. **CORE CONCEPT**: Explain the fundamental idea
100
+ 3. **EXAMPLE**: Show a practical code example
101
+ 4. **DEEP DIVE**: Explain the details and nuances
102
+ 5. **COMMON MISTAKES**: What do beginners get wrong?
103
+ 6. **PRACTICE**: Suggest exercises to solidify understanding
104
+
105
+ Assume the learner wants to deeply understand, not just get a quick answer.
106
+
107
+ Format your response as:
108
+ ## In Simple Terms
109
+ [Analogy and basic explanation]
110
+
111
+ ## How It Works
112
+ [Technical explanation with examples]
113
+
114
+ ## Key Points
115
+ [Important things to remember]
116
+
117
+ ## Common Pitfalls
118
+ [Mistakes to avoid]
119
+
120
+ ## Next Steps
121
+ [How to practice and learn more]`,
122
+ general: `You are a helpful AI assistant being consulted for a second opinion on a problem or task.
123
+
124
+ Provide thoughtful, well-reasoned responses that offer a fresh perspective.
125
+
126
+ Structure your response:
127
+ 1. **Understanding**: Restate the problem to confirm understanding
128
+ 2. **Analysis**: Break down the key aspects
129
+ 3. **Recommendation**: Provide your advice with reasoning
130
+ 4. **Considerations**: Note any caveats or alternative approaches
131
+
132
+ Be concise but thorough in your analysis.`,
133
+ };
134
+ /**
135
+ * Get the system prompt for a given mode
136
+ */
137
+ export function getSystemPromptForMode(mode) {
138
+ return SYSTEM_PROMPTS[mode];
139
+ }
140
+ //# sourceMappingURL=prompts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompts.js","sourceRoot":"","sources":["../../src/config/prompts.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAqC;IAC9D,KAAK,EAAE;;;;;;;;;;;;;;;;;;;;;;8BAsBqB;IAE5B,WAAW,EAAE;;;;;;;;;;;;;;;;;;;2CAmB4B;IAEzC,kBAAkB,EAAE;;;;;;;;;;;;;;;;;;;;;;mBAsBH;IAEjB,YAAY,EAAE;;;;;;;;;;;;;;;;;;;;;;wBAsBQ;IAEtB,cAAc,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;iCA0Be;IAE/B,OAAO,EAAE;;;;;;;;;;0CAU+B;CACzC,CAAC;AAEF;;GAEG;AACH,MAAM,UAAU,sBAAsB,CAAC,IAAsB;IAC3D,OAAO,cAAc,CAAC,IAAI,CAAC,CAAC;AAC9B,CAAC"}
@@ -0,0 +1,141 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * Provider configuration schema
4
+ */
5
+ export declare const providerConfigSchema: z.ZodObject<{
6
+ enabled: z.ZodBoolean;
7
+ apiKey: z.ZodOptional<z.ZodString>;
8
+ }, "strip", z.ZodTypeAny, {
9
+ enabled: boolean;
10
+ apiKey?: string | undefined;
11
+ }, {
12
+ enabled: boolean;
13
+ apiKey?: string | undefined;
14
+ }>;
15
+ /**
16
+ * Full configuration schema
17
+ */
18
+ export declare const configSchema: z.ZodObject<{
19
+ defaultModel: z.ZodEnum<["deepseek-chat", "deepseek-reasoner", "gpt-5.2", "gpt-5.2-pro"]>;
20
+ maxMessages: z.ZodNumber;
21
+ providers: z.ZodObject<{
22
+ deepseek: z.ZodObject<{
23
+ enabled: z.ZodBoolean;
24
+ apiKey: z.ZodOptional<z.ZodString>;
25
+ }, "strip", z.ZodTypeAny, {
26
+ enabled: boolean;
27
+ apiKey?: string | undefined;
28
+ }, {
29
+ enabled: boolean;
30
+ apiKey?: string | undefined;
31
+ }>;
32
+ openai: z.ZodObject<{
33
+ enabled: z.ZodBoolean;
34
+ apiKey: z.ZodOptional<z.ZodString>;
35
+ }, "strip", z.ZodTypeAny, {
36
+ enabled: boolean;
37
+ apiKey?: string | undefined;
38
+ }, {
39
+ enabled: boolean;
40
+ apiKey?: string | undefined;
41
+ }>;
42
+ }, "strip", z.ZodTypeAny, {
43
+ deepseek: {
44
+ enabled: boolean;
45
+ apiKey?: string | undefined;
46
+ };
47
+ openai: {
48
+ enabled: boolean;
49
+ apiKey?: string | undefined;
50
+ };
51
+ }, {
52
+ deepseek: {
53
+ enabled: boolean;
54
+ apiKey?: string | undefined;
55
+ };
56
+ openai: {
57
+ enabled: boolean;
58
+ apiKey?: string | undefined;
59
+ };
60
+ }>;
61
+ }, "strip", z.ZodTypeAny, {
62
+ defaultModel: "deepseek-chat" | "deepseek-reasoner" | "gpt-5.2" | "gpt-5.2-pro";
63
+ maxMessages: number;
64
+ providers: {
65
+ deepseek: {
66
+ enabled: boolean;
67
+ apiKey?: string | undefined;
68
+ };
69
+ openai: {
70
+ enabled: boolean;
71
+ apiKey?: string | undefined;
72
+ };
73
+ };
74
+ }, {
75
+ defaultModel: "deepseek-chat" | "deepseek-reasoner" | "gpt-5.2" | "gpt-5.2-pro";
76
+ maxMessages: number;
77
+ providers: {
78
+ deepseek: {
79
+ enabled: boolean;
80
+ apiKey?: string | undefined;
81
+ };
82
+ openai: {
83
+ enabled: boolean;
84
+ apiKey?: string | undefined;
85
+ };
86
+ };
87
+ }>;
88
+ /**
89
+ * Consultation modes for specialized system prompts
90
+ */
91
+ export declare const CONSULTATION_MODES: readonly ["debug", "analyzeCode", "reviewArchitecture", "validatePlan", "explainConcept", "general"];
92
+ export type ConsultationMode = (typeof CONSULTATION_MODES)[number];
93
+ /**
94
+ * Consult request schema (for tool input validation)
95
+ */
96
+ export declare const consultRequestSchema: z.ZodObject<{
97
+ question: z.ZodString;
98
+ model: z.ZodOptional<z.ZodEnum<["deepseek-chat", "deepseek-reasoner", "gpt-5.2", "gpt-5.2-pro"]>>;
99
+ mode: z.ZodOptional<z.ZodEnum<["debug", "analyzeCode", "reviewArchitecture", "validatePlan", "explainConcept", "general"]>>;
100
+ context: z.ZodOptional<z.ZodString>;
101
+ }, "strip", z.ZodTypeAny, {
102
+ question: string;
103
+ model?: "deepseek-chat" | "deepseek-reasoner" | "gpt-5.2" | "gpt-5.2-pro" | undefined;
104
+ mode?: "debug" | "analyzeCode" | "reviewArchitecture" | "validatePlan" | "explainConcept" | "general" | undefined;
105
+ context?: string | undefined;
106
+ }, {
107
+ question: string;
108
+ model?: "deepseek-chat" | "deepseek-reasoner" | "gpt-5.2" | "gpt-5.2-pro" | undefined;
109
+ mode?: "debug" | "analyzeCode" | "reviewArchitecture" | "validatePlan" | "explainConcept" | "general" | undefined;
110
+ context?: string | undefined;
111
+ }>;
112
+ /**
113
+ * Continue conversation request schema
114
+ */
115
+ export declare const continueRequestSchema: z.ZodObject<{
116
+ conversationId: z.ZodString;
117
+ message: z.ZodString;
118
+ }, "strip", z.ZodTypeAny, {
119
+ conversationId: string;
120
+ message: string;
121
+ }, {
122
+ conversationId: string;
123
+ message: string;
124
+ }>;
125
+ /**
126
+ * End conversation request schema
127
+ */
128
+ export declare const endRequestSchema: z.ZodObject<{
129
+ conversationId: z.ZodString;
130
+ }, "strip", z.ZodTypeAny, {
131
+ conversationId: string;
132
+ }, {
133
+ conversationId: string;
134
+ }>;
135
+ /**
136
+ * Type exports from schemas
137
+ */
138
+ export type ValidatedConfig = z.infer<typeof configSchema>;
139
+ export type ValidatedConsultRequest = z.infer<typeof consultRequestSchema>;
140
+ export type ValidatedContinueRequest = z.infer<typeof continueRequestSchema>;
141
+ export type ValidatedEndRequest = z.infer<typeof endRequestSchema>;
@@ -0,0 +1,54 @@
1
+ import { z } from 'zod';
2
+ import { MODEL_TYPES } from '../types/index.js';
3
+ /**
4
+ * Provider configuration schema
5
+ */
6
+ export const providerConfigSchema = z.object({
7
+ enabled: z.boolean(),
8
+ apiKey: z.string().optional(),
9
+ });
10
+ /**
11
+ * Full configuration schema
12
+ */
13
+ export const configSchema = z.object({
14
+ defaultModel: z.enum(MODEL_TYPES),
15
+ maxMessages: z.number().int().min(1).max(10),
16
+ providers: z.object({
17
+ deepseek: providerConfigSchema,
18
+ openai: providerConfigSchema,
19
+ }),
20
+ });
21
+ /**
22
+ * Consultation modes for specialized system prompts
23
+ */
24
+ export const CONSULTATION_MODES = [
25
+ 'debug',
26
+ 'analyzeCode',
27
+ 'reviewArchitecture',
28
+ 'validatePlan',
29
+ 'explainConcept',
30
+ 'general',
31
+ ];
32
+ /**
33
+ * Consult request schema (for tool input validation)
34
+ */
35
+ export const consultRequestSchema = z.object({
36
+ question: z.string().min(1, 'Question is required'),
37
+ model: z.enum(MODEL_TYPES).optional(),
38
+ mode: z.enum(CONSULTATION_MODES).optional(),
39
+ context: z.string().optional(),
40
+ });
41
+ /**
42
+ * Continue conversation request schema
43
+ */
44
+ export const continueRequestSchema = z.object({
45
+ conversationId: z.string().uuid('Invalid conversation ID'),
46
+ message: z.string().min(1, 'Message is required'),
47
+ });
48
+ /**
49
+ * End conversation request schema
50
+ */
51
+ export const endRequestSchema = z.object({
52
+ conversationId: z.string().uuid('Invalid conversation ID'),
53
+ });
54
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/config/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD;;GAEG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3C,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE;IACpB,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAC9B,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,CAAC;IACnC,YAAY,EAAE,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC;IACjC,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC;IAC5C,SAAS,EAAE,CAAC,CAAC,MAAM,CAAC;QAClB,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