atlas-pipeline-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.
- package/.env.example +21 -0
- package/LICENSE +21 -0
- package/README.md +175 -0
- package/dist/mcp.d.ts +21 -0
- package/dist/mcp.d.ts.map +1 -0
- package/dist/mcp.js +404 -0
- package/dist/mcp.js.map +1 -0
- package/dist/pipeline.d.ts +39 -0
- package/dist/pipeline.d.ts.map +1 -0
- package/dist/pipeline.js +355 -0
- package/dist/pipeline.js.map +1 -0
- package/dist/providers/index.d.ts +14 -0
- package/dist/providers/index.d.ts.map +1 -0
- package/dist/providers/index.js +13 -0
- package/dist/providers/index.js.map +1 -0
- package/dist/providers/llm-provider.d.ts +71 -0
- package/dist/providers/llm-provider.d.ts.map +1 -0
- package/dist/providers/llm-provider.js +357 -0
- package/dist/providers/llm-provider.js.map +1 -0
- package/dist/server.d.ts +27 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +312 -0
- package/dist/server.js.map +1 -0
- package/dist/tools/context.d.ts +23 -0
- package/dist/tools/context.d.ts.map +1 -0
- package/dist/tools/context.js +363 -0
- package/dist/tools/context.js.map +1 -0
- package/dist/tools/critique.d.ts +40 -0
- package/dist/tools/critique.d.ts.map +1 -0
- package/dist/tools/critique.js +315 -0
- package/dist/tools/critique.js.map +1 -0
- package/dist/tools/decompose.d.ts +34 -0
- package/dist/tools/decompose.d.ts.map +1 -0
- package/dist/tools/decompose.js +328 -0
- package/dist/tools/decompose.js.map +1 -0
- package/dist/tools/git.d.ts +66 -0
- package/dist/tools/git.d.ts.map +1 -0
- package/dist/tools/git.js +333 -0
- package/dist/tools/git.js.map +1 -0
- package/dist/tools/intent.d.ts +24 -0
- package/dist/tools/intent.d.ts.map +1 -0
- package/dist/tools/intent.js +245 -0
- package/dist/tools/intent.js.map +1 -0
- package/dist/tools/ollama.d.ts +104 -0
- package/dist/tools/ollama.d.ts.map +1 -0
- package/dist/tools/ollama.js +299 -0
- package/dist/tools/ollama.js.map +1 -0
- package/dist/tools/optimize.d.ts +64 -0
- package/dist/tools/optimize.d.ts.map +1 -0
- package/dist/tools/optimize.js +302 -0
- package/dist/tools/optimize.js.map +1 -0
- package/dist/tools/variants.d.ts +49 -0
- package/dist/tools/variants.d.ts.map +1 -0
- package/dist/tools/variants.js +252 -0
- package/dist/tools/variants.js.map +1 -0
- package/dist/types.d.ts +447 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +25 -0
- package/dist/types.js.map +1 -0
- package/dist/utils.d.ts +117 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +279 -0
- package/dist/utils.js.map +1 -0
- package/package.json +77 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Atlas Server - Multi-Stage Pipeline
|
|
3
|
+
*
|
|
4
|
+
* Orchestrates the complete AI pipeline:
|
|
5
|
+
* 1. Intent Analysis - Understand what the user wants
|
|
6
|
+
* 2. Context Gathering - Collect relevant code and project info
|
|
7
|
+
* 3. Git Context - Understand repository state
|
|
8
|
+
* 4. Task Decomposition - Break down into subtasks
|
|
9
|
+
* 5. Variant Generation - Create multiple solutions
|
|
10
|
+
* 6. Critique - Review and score variants
|
|
11
|
+
* 7. Optimization - Refine the best solution
|
|
12
|
+
*/
|
|
13
|
+
import type { PipelineRequest, PipelineResponse } from './types.js';
|
|
14
|
+
/**
|
|
15
|
+
* Execute the complete multi-stage pipeline
|
|
16
|
+
*/
|
|
17
|
+
export declare function executePipeline(request: PipelineRequest): Promise<PipelineResponse>;
|
|
18
|
+
/**
|
|
19
|
+
* Execute a lightweight pipeline (skip some stages for speed)
|
|
20
|
+
*/
|
|
21
|
+
export declare function executeLightPipeline(request: PipelineRequest): Promise<PipelineResponse>;
|
|
22
|
+
/**
|
|
23
|
+
* Execute pipeline with streaming progress updates
|
|
24
|
+
*/
|
|
25
|
+
export declare function executePipelineWithProgress(request: PipelineRequest, onProgress: (stage: string, status: 'started' | 'completed' | 'failed', data?: unknown) => void): Promise<PipelineResponse>;
|
|
26
|
+
/**
|
|
27
|
+
* Validate a pipeline request
|
|
28
|
+
*/
|
|
29
|
+
export declare function validateRequest(request: unknown): request is PipelineRequest;
|
|
30
|
+
/**
|
|
31
|
+
* Get pipeline status summary
|
|
32
|
+
*/
|
|
33
|
+
export declare function getPipelineStatus(response: PipelineResponse): {
|
|
34
|
+
status: 'success' | 'partial' | 'failed';
|
|
35
|
+
completedStages: number;
|
|
36
|
+
totalStages: number;
|
|
37
|
+
failedStage?: string;
|
|
38
|
+
};
|
|
39
|
+
//# sourceMappingURL=pipeline.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipeline.d.ts","sourceRoot":"","sources":["../src/pipeline.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EACV,eAAe,EACf,gBAAgB,EAQjB,MAAM,YAAY,CAAC;AAsBpB;;GAEG;AACH,wBAAsB,eAAe,CACnC,OAAO,EAAE,eAAe,GACvB,OAAO,CAAC,gBAAgB,CAAC,CAgO3B;AAkBD;;GAEG;AACH,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,eAAe,GACvB,OAAO,CAAC,gBAAgB,CAAC,CAyF3B;AAED;;GAEG;AACH,wBAAsB,2BAA2B,CAC/C,OAAO,EAAE,eAAe,EACxB,UAAU,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,GAAG,WAAW,GAAG,QAAQ,EAAE,IAAI,CAAC,EAAE,OAAO,KAAK,IAAI,GAC9F,OAAO,CAAC,gBAAgB,CAAC,CA4F3B;AAMD;;GAEG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,IAAI,eAAe,CAc5E;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,gBAAgB,GAAG;IAC7D,MAAM,EAAE,SAAS,GAAG,SAAS,GAAG,QAAQ,CAAC;IACzC,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAeA"}
|
package/dist/pipeline.js
ADDED
|
@@ -0,0 +1,355 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Atlas Server - Multi-Stage Pipeline
|
|
3
|
+
*
|
|
4
|
+
* Orchestrates the complete AI pipeline:
|
|
5
|
+
* 1. Intent Analysis - Understand what the user wants
|
|
6
|
+
* 2. Context Gathering - Collect relevant code and project info
|
|
7
|
+
* 3. Git Context - Understand repository state
|
|
8
|
+
* 4. Task Decomposition - Break down into subtasks
|
|
9
|
+
* 5. Variant Generation - Create multiple solutions
|
|
10
|
+
* 6. Critique - Review and score variants
|
|
11
|
+
* 7. Optimization - Refine the best solution
|
|
12
|
+
*/
|
|
13
|
+
import { analyzeIntent } from './tools/intent.js';
|
|
14
|
+
import { buildContext } from './tools/context.js';
|
|
15
|
+
import { getGitContext } from './tools/git.js';
|
|
16
|
+
import { decomposeTask } from './tools/decompose.js';
|
|
17
|
+
import { generateVariants } from './tools/variants.js';
|
|
18
|
+
import { critiqueVariants } from './tools/critique.js';
|
|
19
|
+
import { optimizeVariant } from './tools/optimize.js';
|
|
20
|
+
import { getOllamaClient } from './tools/ollama.js';
|
|
21
|
+
import { logger, executeStage, createPipelineError, nowISO, formatDuration, } from './utils.js';
|
|
22
|
+
// ============================================================================
|
|
23
|
+
// Pipeline Execution
|
|
24
|
+
// ============================================================================
|
|
25
|
+
/**
|
|
26
|
+
* Execute the complete multi-stage pipeline
|
|
27
|
+
*/
|
|
28
|
+
export async function executePipeline(request) {
|
|
29
|
+
const startTime = performance.now();
|
|
30
|
+
const startedAt = nowISO();
|
|
31
|
+
const stages = [];
|
|
32
|
+
logger.info({
|
|
33
|
+
queryLength: request.query.length,
|
|
34
|
+
hasRepoPath: !!request.repoPath,
|
|
35
|
+
sessionId: request.sessionId,
|
|
36
|
+
}, 'Pipeline execution started');
|
|
37
|
+
try {
|
|
38
|
+
// Stage 1: Intent Analysis
|
|
39
|
+
const { stageResult: intentResult, output: intent } = await executeStage('intent', () => analyzeIntent(request.query));
|
|
40
|
+
stages.push(intentResult);
|
|
41
|
+
if (!intentResult.success || !intent) {
|
|
42
|
+
throw createPipelineError('INTENT_ANALYSIS_FAILED', 'Failed to analyze user intent', 'intent');
|
|
43
|
+
}
|
|
44
|
+
logger.debug({
|
|
45
|
+
primaryIntent: intent.primaryIntent,
|
|
46
|
+
confidence: intent.confidence,
|
|
47
|
+
entityCount: intent.entities.length,
|
|
48
|
+
}, 'Intent analysis complete');
|
|
49
|
+
// Stage 2: Git Context (parallel with context building)
|
|
50
|
+
const gitContextPromise = request.repoPath
|
|
51
|
+
? executeStage('git', () => getGitContext(request.repoPath))
|
|
52
|
+
: Promise.resolve({ stageResult: createSkippedStage('git'), output: null });
|
|
53
|
+
// Stage 3: Context Building
|
|
54
|
+
const { stageResult: gitResult, output: gitContext } = await gitContextPromise;
|
|
55
|
+
stages.push(gitResult);
|
|
56
|
+
const { stageResult: contextResult, output: context } = await executeStage('context', () => buildContext(intent, request.repoPath, gitContext ?? undefined));
|
|
57
|
+
stages.push(contextResult);
|
|
58
|
+
if (!contextResult.success || !context) {
|
|
59
|
+
throw createPipelineError('CONTEXT_BUILD_FAILED', 'Failed to build context', 'context');
|
|
60
|
+
}
|
|
61
|
+
// Stage 4: Task Decomposition
|
|
62
|
+
const { stageResult: decomposeResult, output: decomposition } = await executeStage('decompose', () => decomposeTask(context));
|
|
63
|
+
stages.push(decomposeResult);
|
|
64
|
+
if (!decomposeResult.success || !decomposition) {
|
|
65
|
+
throw createPipelineError('DECOMPOSITION_FAILED', 'Failed to decompose task', 'decompose');
|
|
66
|
+
}
|
|
67
|
+
logger.debug({
|
|
68
|
+
taskCount: decomposition.tasks.length,
|
|
69
|
+
complexity: decomposition.overallComplexity,
|
|
70
|
+
}, 'Task decomposition complete');
|
|
71
|
+
// Stage 5: Variant Generation
|
|
72
|
+
const { stageResult: variantsResult, output: variantData } = await executeStage('variants', () => generateVariants(context, decomposition));
|
|
73
|
+
stages.push(variantsResult);
|
|
74
|
+
if (!variantsResult.success || !variantData) {
|
|
75
|
+
throw createPipelineError('VARIANT_GENERATION_FAILED', 'Failed to generate variants', 'variants');
|
|
76
|
+
}
|
|
77
|
+
logger.debug({
|
|
78
|
+
variantCount: variantData.variants.length,
|
|
79
|
+
recommendedId: variantData.recommendedVariantId,
|
|
80
|
+
}, 'Variant generation complete');
|
|
81
|
+
// Stage 6: Critique
|
|
82
|
+
const { stageResult: critiqueResult, output: critiqueData } = await executeStage('critique', () => critiqueVariants(variantData.variants));
|
|
83
|
+
stages.push(critiqueResult);
|
|
84
|
+
if (!critiqueResult.success || !critiqueData) {
|
|
85
|
+
throw createPipelineError('CRITIQUE_FAILED', 'Failed to critique variants', 'critique');
|
|
86
|
+
}
|
|
87
|
+
logger.debug({
|
|
88
|
+
bestVariantId: critiqueData.bestVariantId,
|
|
89
|
+
summary: critiqueData.summary,
|
|
90
|
+
}, 'Critique complete');
|
|
91
|
+
// Stage 7: Optimization
|
|
92
|
+
const bestVariant = variantData.variants.find((v) => v.id === critiqueData.bestVariantId);
|
|
93
|
+
const bestCritique = critiqueData.critiques.find((c) => c.variantId === critiqueData.bestVariantId);
|
|
94
|
+
if (!bestVariant || !bestCritique) {
|
|
95
|
+
throw createPipelineError('OPTIMIZATION_FAILED', 'Could not find best variant for optimization', 'optimize');
|
|
96
|
+
}
|
|
97
|
+
const { stageResult: optimizeResult, output: optimizedOutput } = await executeStage('optimize', () => optimizeVariant(bestVariant, bestCritique));
|
|
98
|
+
stages.push(optimizeResult);
|
|
99
|
+
if (!optimizeResult.success || !optimizedOutput) {
|
|
100
|
+
throw createPipelineError('OPTIMIZATION_FAILED', 'Failed to optimize variant', 'optimize');
|
|
101
|
+
}
|
|
102
|
+
// Calculate final metrics
|
|
103
|
+
const executionTimeMs = Math.round(performance.now() - startTime);
|
|
104
|
+
const completedAt = nowISO();
|
|
105
|
+
const metadata = {
|
|
106
|
+
executionTimeMs,
|
|
107
|
+
stages,
|
|
108
|
+
model: getOllamaClient().model,
|
|
109
|
+
startedAt,
|
|
110
|
+
completedAt,
|
|
111
|
+
};
|
|
112
|
+
logger.info({
|
|
113
|
+
executionTime: formatDuration(executionTimeMs),
|
|
114
|
+
stagesCompleted: stages.filter((s) => s.success).length,
|
|
115
|
+
totalStages: stages.length,
|
|
116
|
+
}, 'Pipeline execution completed successfully');
|
|
117
|
+
return {
|
|
118
|
+
success: true,
|
|
119
|
+
result: optimizedOutput.content,
|
|
120
|
+
metadata,
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
catch (error) {
|
|
124
|
+
const executionTimeMs = Math.round(performance.now() - startTime);
|
|
125
|
+
const pipelineError = error && typeof error === 'object' && 'code' in error
|
|
126
|
+
? error
|
|
127
|
+
: {
|
|
128
|
+
code: 'PIPELINE_ERROR',
|
|
129
|
+
message: error instanceof Error ? error.message : 'Unknown error',
|
|
130
|
+
};
|
|
131
|
+
logger.error({
|
|
132
|
+
error: pipelineError,
|
|
133
|
+
executionTimeMs,
|
|
134
|
+
stagesCompleted: stages.length,
|
|
135
|
+
}, 'Pipeline execution failed');
|
|
136
|
+
return {
|
|
137
|
+
success: false,
|
|
138
|
+
result: '',
|
|
139
|
+
metadata: {
|
|
140
|
+
executionTimeMs,
|
|
141
|
+
stages,
|
|
142
|
+
model: getOllamaClient().model,
|
|
143
|
+
startedAt,
|
|
144
|
+
completedAt: nowISO(),
|
|
145
|
+
},
|
|
146
|
+
error: {
|
|
147
|
+
code: pipelineError.code,
|
|
148
|
+
message: pipelineError.message,
|
|
149
|
+
stage: pipelineError.stage,
|
|
150
|
+
},
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Create a skipped stage result
|
|
156
|
+
*/
|
|
157
|
+
function createSkippedStage(name) {
|
|
158
|
+
return {
|
|
159
|
+
name,
|
|
160
|
+
success: true,
|
|
161
|
+
durationMs: 0,
|
|
162
|
+
output: null,
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
// ============================================================================
|
|
166
|
+
// Pipeline Variants
|
|
167
|
+
// ============================================================================
|
|
168
|
+
/**
|
|
169
|
+
* Execute a lightweight pipeline (skip some stages for speed)
|
|
170
|
+
*/
|
|
171
|
+
export async function executeLightPipeline(request) {
|
|
172
|
+
const startTime = performance.now();
|
|
173
|
+
const startedAt = nowISO();
|
|
174
|
+
const stages = [];
|
|
175
|
+
logger.info({ mode: 'light' }, 'Light pipeline execution started');
|
|
176
|
+
try {
|
|
177
|
+
// Stage 1: Intent Analysis
|
|
178
|
+
const { stageResult: intentResult, output: intent } = await executeStage('intent', () => analyzeIntent(request.query));
|
|
179
|
+
stages.push(intentResult);
|
|
180
|
+
if (!intent) {
|
|
181
|
+
throw createPipelineError('INTENT_FAILED', 'Intent analysis failed', 'intent');
|
|
182
|
+
}
|
|
183
|
+
// Stage 2: Minimal Context
|
|
184
|
+
const { stageResult: contextResult, output: context } = await executeStage('context', () => buildContext(intent, request.repoPath));
|
|
185
|
+
stages.push(contextResult);
|
|
186
|
+
if (!context) {
|
|
187
|
+
throw createPipelineError('CONTEXT_FAILED', 'Context build failed', 'context');
|
|
188
|
+
}
|
|
189
|
+
// Stage 3: Single Variant Generation (skip decomposition for speed)
|
|
190
|
+
const simpleDecomposition = {
|
|
191
|
+
summary: `${intent.primaryIntent}: ${intent.keywords.join(', ')}`,
|
|
192
|
+
tasks: [{
|
|
193
|
+
id: '1',
|
|
194
|
+
description: 'Implement solution',
|
|
195
|
+
type: 'implementation',
|
|
196
|
+
priority: 1,
|
|
197
|
+
dependencies: [],
|
|
198
|
+
complexity: 'medium',
|
|
199
|
+
}],
|
|
200
|
+
executionOrder: ['1'],
|
|
201
|
+
overallComplexity: 'medium',
|
|
202
|
+
};
|
|
203
|
+
const { stageResult: variantsResult, output: variantData } = await executeStage('variants', () => generateVariants(context, simpleDecomposition, 1));
|
|
204
|
+
stages.push(variantsResult);
|
|
205
|
+
if (!variantData || variantData.variants.length === 0) {
|
|
206
|
+
throw createPipelineError('VARIANTS_FAILED', 'Variant generation failed', 'variants');
|
|
207
|
+
}
|
|
208
|
+
// Return first variant without critique/optimization
|
|
209
|
+
const executionTimeMs = Math.round(performance.now() - startTime);
|
|
210
|
+
return {
|
|
211
|
+
success: true,
|
|
212
|
+
result: variantData.variants[0].content,
|
|
213
|
+
metadata: {
|
|
214
|
+
executionTimeMs,
|
|
215
|
+
stages,
|
|
216
|
+
model: getOllamaClient().model,
|
|
217
|
+
startedAt,
|
|
218
|
+
completedAt: nowISO(),
|
|
219
|
+
},
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
catch (error) {
|
|
223
|
+
const executionTimeMs = Math.round(performance.now() - startTime);
|
|
224
|
+
return {
|
|
225
|
+
success: false,
|
|
226
|
+
result: '',
|
|
227
|
+
metadata: {
|
|
228
|
+
executionTimeMs,
|
|
229
|
+
stages,
|
|
230
|
+
model: getOllamaClient().model,
|
|
231
|
+
startedAt,
|
|
232
|
+
completedAt: nowISO(),
|
|
233
|
+
},
|
|
234
|
+
error: {
|
|
235
|
+
code: 'LIGHT_PIPELINE_ERROR',
|
|
236
|
+
message: error instanceof Error ? error.message : 'Unknown error',
|
|
237
|
+
},
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Execute pipeline with streaming progress updates
|
|
243
|
+
*/
|
|
244
|
+
export async function executePipelineWithProgress(request, onProgress) {
|
|
245
|
+
const startTime = performance.now();
|
|
246
|
+
const startedAt = nowISO();
|
|
247
|
+
const stages = [];
|
|
248
|
+
const runStage = async (name, fn) => {
|
|
249
|
+
onProgress(name, 'started');
|
|
250
|
+
const result = await executeStage(name, fn);
|
|
251
|
+
onProgress(name, result.stageResult.success ? 'completed' : 'failed', result.output);
|
|
252
|
+
return result;
|
|
253
|
+
};
|
|
254
|
+
try {
|
|
255
|
+
// Run all stages with progress callbacks
|
|
256
|
+
const { output: intent } = await runStage('intent', () => analyzeIntent(request.query));
|
|
257
|
+
if (!intent)
|
|
258
|
+
throw new Error('Intent analysis failed');
|
|
259
|
+
stages.push({ name: 'intent', success: true, durationMs: 0 });
|
|
260
|
+
const gitContext = request.repoPath
|
|
261
|
+
? (await runStage('git', () => getGitContext(request.repoPath))).output
|
|
262
|
+
: null;
|
|
263
|
+
stages.push({ name: 'git', success: true, durationMs: 0 });
|
|
264
|
+
const { output: context } = await runStage('context', () => buildContext(intent, request.repoPath, gitContext ?? undefined));
|
|
265
|
+
if (!context)
|
|
266
|
+
throw new Error('Context build failed');
|
|
267
|
+
stages.push({ name: 'context', success: true, durationMs: 0 });
|
|
268
|
+
const { output: decomposition } = await runStage('decompose', () => decomposeTask(context));
|
|
269
|
+
if (!decomposition)
|
|
270
|
+
throw new Error('Decomposition failed');
|
|
271
|
+
stages.push({ name: 'decompose', success: true, durationMs: 0 });
|
|
272
|
+
const { output: variantData } = await runStage('variants', () => generateVariants(context, decomposition));
|
|
273
|
+
if (!variantData)
|
|
274
|
+
throw new Error('Variant generation failed');
|
|
275
|
+
stages.push({ name: 'variants', success: true, durationMs: 0 });
|
|
276
|
+
const { output: critiqueData } = await runStage('critique', () => critiqueVariants(variantData.variants));
|
|
277
|
+
if (!critiqueData)
|
|
278
|
+
throw new Error('Critique failed');
|
|
279
|
+
stages.push({ name: 'critique', success: true, durationMs: 0 });
|
|
280
|
+
const bestVariant = variantData.variants.find((v) => v.id === critiqueData.bestVariantId);
|
|
281
|
+
const bestCritique = critiqueData.critiques.find((c) => c.variantId === critiqueData.bestVariantId);
|
|
282
|
+
if (!bestVariant || !bestCritique)
|
|
283
|
+
throw new Error('Best variant not found');
|
|
284
|
+
const { output: optimized } = await runStage('optimize', () => optimizeVariant(bestVariant, bestCritique));
|
|
285
|
+
if (!optimized)
|
|
286
|
+
throw new Error('Optimization failed');
|
|
287
|
+
stages.push({ name: 'optimize', success: true, durationMs: 0 });
|
|
288
|
+
return {
|
|
289
|
+
success: true,
|
|
290
|
+
result: optimized.content,
|
|
291
|
+
metadata: {
|
|
292
|
+
executionTimeMs: Math.round(performance.now() - startTime),
|
|
293
|
+
stages,
|
|
294
|
+
model: getOllamaClient().model,
|
|
295
|
+
startedAt,
|
|
296
|
+
completedAt: nowISO(),
|
|
297
|
+
},
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
catch (error) {
|
|
301
|
+
return {
|
|
302
|
+
success: false,
|
|
303
|
+
result: '',
|
|
304
|
+
metadata: {
|
|
305
|
+
executionTimeMs: Math.round(performance.now() - startTime),
|
|
306
|
+
stages,
|
|
307
|
+
model: getOllamaClient().model,
|
|
308
|
+
startedAt,
|
|
309
|
+
completedAt: nowISO(),
|
|
310
|
+
},
|
|
311
|
+
error: {
|
|
312
|
+
code: 'PIPELINE_ERROR',
|
|
313
|
+
message: error instanceof Error ? error.message : 'Unknown error',
|
|
314
|
+
},
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
// ============================================================================
|
|
319
|
+
// Pipeline Utilities
|
|
320
|
+
// ============================================================================
|
|
321
|
+
/**
|
|
322
|
+
* Validate a pipeline request
|
|
323
|
+
*/
|
|
324
|
+
export function validateRequest(request) {
|
|
325
|
+
if (!request || typeof request !== 'object')
|
|
326
|
+
return false;
|
|
327
|
+
const req = request;
|
|
328
|
+
if (typeof req['query'] !== 'string' || req['query'].length === 0) {
|
|
329
|
+
return false;
|
|
330
|
+
}
|
|
331
|
+
if (req['repoPath'] !== undefined && typeof req['repoPath'] !== 'string') {
|
|
332
|
+
return false;
|
|
333
|
+
}
|
|
334
|
+
return true;
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* Get pipeline status summary
|
|
338
|
+
*/
|
|
339
|
+
export function getPipelineStatus(response) {
|
|
340
|
+
const completedStages = response.metadata.stages.filter((s) => s.success).length;
|
|
341
|
+
const totalStages = response.metadata.stages.length;
|
|
342
|
+
const failedStage = response.metadata.stages.find((s) => !s.success)?.name;
|
|
343
|
+
let status;
|
|
344
|
+
if (response.success) {
|
|
345
|
+
status = 'success';
|
|
346
|
+
}
|
|
347
|
+
else if (completedStages > 0) {
|
|
348
|
+
status = 'partial';
|
|
349
|
+
}
|
|
350
|
+
else {
|
|
351
|
+
status = 'failed';
|
|
352
|
+
}
|
|
353
|
+
return { status, completedStages, totalStages, failedStage };
|
|
354
|
+
}
|
|
355
|
+
//# sourceMappingURL=pipeline.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipeline.js","sourceRoot":"","sources":["../src/pipeline.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAaH,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EACL,MAAM,EACN,YAAY,EACZ,mBAAmB,EACnB,MAAM,EACN,cAAc,GAEf,MAAM,YAAY,CAAC;AAEpB,+EAA+E;AAC/E,qBAAqB;AACrB,+EAA+E;AAE/E;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,OAAwB;IAExB,MAAM,SAAS,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;IACpC,MAAM,SAAS,GAAG,MAAM,EAAE,CAAC;IAC3B,MAAM,MAAM,GAAkB,EAAE,CAAC;IAEjC,MAAM,CAAC,IAAI,CACT;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E,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC;IAE3E,IAAI,MAAwC,CAAC;IAC7C,IAAI,QAAQ,CAAC,OAAO,EAAE,CAAC;QACrB,MAAM,GAAG,SAAS,CAAC;IACrB,CAAC;SAAM,IAAI,eAAe,GAAG,CAAC,EAAE,CAAC;QAC/B,MAAM,GAAG,SAAS,CAAC;IACrB,CAAC;SAAM,CAAC;QACN,MAAM,GAAG,QAAQ,CAAC;IACpB,CAAC;IAED,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,WAAW,EAAE,WAAW,EAAE,CAAC;AAC/D,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Atlas MCP Server - LLM Provider System
|
|
3
|
+
*
|
|
4
|
+
* Unified interface for multiple LLM providers:
|
|
5
|
+
* - Ollama (local)
|
|
6
|
+
* - OpenAI (GPT-4, GPT-3.5)
|
|
7
|
+
* - Anthropic (Claude)
|
|
8
|
+
* - Custom/Other providers
|
|
9
|
+
*
|
|
10
|
+
* The server auto-detects available providers and uses the best one.
|
|
11
|
+
*/
|
|
12
|
+
export { LLMProvider, createProvider, getActiveProvider, resetProvider, checkProviders, } from './llm-provider.js';
|
|
13
|
+
export type { ProviderConfig, ProviderType, CompletionOptions, CompletionResponse, } from './llm-provider.js';
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/providers/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EACL,WAAW,EACX,cAAc,EACd,iBAAiB,EACjB,aAAa,EACb,cAAc,GACf,MAAM,mBAAmB,CAAC;AAE3B,YAAY,EACV,cAAc,EACd,YAAY,EACZ,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Atlas MCP Server - LLM Provider System
|
|
3
|
+
*
|
|
4
|
+
* Unified interface for multiple LLM providers:
|
|
5
|
+
* - Ollama (local)
|
|
6
|
+
* - OpenAI (GPT-4, GPT-3.5)
|
|
7
|
+
* - Anthropic (Claude)
|
|
8
|
+
* - Custom/Other providers
|
|
9
|
+
*
|
|
10
|
+
* The server auto-detects available providers and uses the best one.
|
|
11
|
+
*/
|
|
12
|
+
export { LLMProvider, createProvider, getActiveProvider, resetProvider, checkProviders, } from './llm-provider.js';
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/providers/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EACL,WAAW,EACX,cAAc,EACd,iBAAiB,EACjB,aAAa,EACb,cAAc,GACf,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Atlas MCP Server - Unified LLM Provider
|
|
3
|
+
*
|
|
4
|
+
* Supports multiple LLM backends with a unified interface:
|
|
5
|
+
* - Ollama (local, free)
|
|
6
|
+
* - OpenAI (GPT-4, GPT-4-turbo, GPT-3.5-turbo)
|
|
7
|
+
* - Anthropic (Claude 3.5, Claude 3)
|
|
8
|
+
*
|
|
9
|
+
* Auto-detects available providers and falls back gracefully.
|
|
10
|
+
*/
|
|
11
|
+
export type ProviderType = 'ollama' | 'openai' | 'anthropic' | 'auto';
|
|
12
|
+
export interface ProviderConfig {
|
|
13
|
+
type: ProviderType;
|
|
14
|
+
ollamaBaseUrl?: string;
|
|
15
|
+
ollamaModel?: string;
|
|
16
|
+
openaiApiKey?: string;
|
|
17
|
+
openaiModel?: string;
|
|
18
|
+
openaiBaseUrl?: string;
|
|
19
|
+
anthropicApiKey?: string;
|
|
20
|
+
anthropicModel?: string;
|
|
21
|
+
maxRetries?: number;
|
|
22
|
+
timeoutMs?: number;
|
|
23
|
+
}
|
|
24
|
+
export interface CompletionOptions {
|
|
25
|
+
systemPrompt?: string;
|
|
26
|
+
temperature?: number;
|
|
27
|
+
maxTokens?: number;
|
|
28
|
+
stop?: string[];
|
|
29
|
+
jsonMode?: boolean;
|
|
30
|
+
}
|
|
31
|
+
export interface CompletionResponse {
|
|
32
|
+
text: string;
|
|
33
|
+
provider: ProviderType;
|
|
34
|
+
model: string;
|
|
35
|
+
usage?: {
|
|
36
|
+
promptTokens: number;
|
|
37
|
+
completionTokens: number;
|
|
38
|
+
totalTokens: number;
|
|
39
|
+
};
|
|
40
|
+
durationMs: number;
|
|
41
|
+
}
|
|
42
|
+
export declare abstract class LLMProvider {
|
|
43
|
+
abstract readonly type: ProviderType;
|
|
44
|
+
abstract readonly model: string;
|
|
45
|
+
abstract isAvailable(): Promise<boolean>;
|
|
46
|
+
abstract complete(prompt: string, options?: CompletionOptions): Promise<CompletionResponse>;
|
|
47
|
+
abstract completeJson<T>(prompt: string, options?: CompletionOptions): Promise<{
|
|
48
|
+
data: T | null;
|
|
49
|
+
raw: string;
|
|
50
|
+
}>;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Create a provider instance based on configuration
|
|
54
|
+
*/
|
|
55
|
+
export declare function createProvider(config: ProviderConfig): LLMProvider;
|
|
56
|
+
/**
|
|
57
|
+
* Get or create the active provider with auto-detection
|
|
58
|
+
*/
|
|
59
|
+
export declare function getActiveProvider(config?: ProviderConfig): Promise<LLMProvider>;
|
|
60
|
+
/**
|
|
61
|
+
* Reset the active provider (for testing or reconfiguration)
|
|
62
|
+
*/
|
|
63
|
+
export declare function resetProvider(): void;
|
|
64
|
+
/**
|
|
65
|
+
* Check if any provider is available
|
|
66
|
+
*/
|
|
67
|
+
export declare function checkProviders(): Promise<{
|
|
68
|
+
available: ProviderType[];
|
|
69
|
+
activeProvider: string | null;
|
|
70
|
+
}>;
|
|
71
|
+
//# sourceMappingURL=llm-provider.d.ts.map
|
|
@@ -0,0 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