@mcoda/mswarm 0.1.56 → 0.1.60
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/README.md +20 -1
- package/dist/codali-executor.d.ts +266 -0
- package/dist/codali-executor.d.ts.map +1 -0
- package/dist/codali-executor.js +227 -0
- package/dist/codali-executor.js.map +1 -0
- package/dist/runtime.d.ts +47 -1
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +248 -30
- package/dist/runtime.js.map +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +83 -3
- package/dist/server.js.map +1 -1
- package/dist/vendor/codali/agents/AgentProtocol.d.ts +287 -0
- package/dist/vendor/codali/agents/AgentProtocol.d.ts.map +1 -0
- package/dist/vendor/codali/agents/AgentProtocol.js +365 -0
- package/dist/vendor/codali/agents/AgentResolver.d.ts +23 -0
- package/dist/vendor/codali/agents/AgentResolver.d.ts.map +1 -0
- package/dist/vendor/codali/agents/AgentResolver.js +77 -0
- package/dist/vendor/codali/agents/PhaseAgentSelector.d.ts +23 -0
- package/dist/vendor/codali/agents/PhaseAgentSelector.d.ts.map +1 -0
- package/dist/vendor/codali/agents/PhaseAgentSelector.js +287 -0
- package/dist/vendor/codali/cli/EvalCommand.d.ts +37 -0
- package/dist/vendor/codali/cli/EvalCommand.d.ts.map +1 -0
- package/dist/vendor/codali/cli/EvalCommand.js +333 -0
- package/dist/vendor/codali/cli/FeedbackCommand.d.ts +22 -0
- package/dist/vendor/codali/cli/FeedbackCommand.d.ts.map +1 -0
- package/dist/vendor/codali/cli/FeedbackCommand.js +163 -0
- package/dist/vendor/codali/cli/RunCommand.d.ts +78 -0
- package/dist/vendor/codali/cli/RunCommand.d.ts.map +1 -0
- package/dist/vendor/codali/cli/RunCommand.js +2261 -0
- package/dist/vendor/codali/cli.d.ts +3 -0
- package/dist/vendor/codali/cli.d.ts.map +1 -0
- package/dist/vendor/codali/cli.js +109 -0
- package/dist/vendor/codali/cognitive/ArchitectPlanner.d.ts +107 -0
- package/dist/vendor/codali/cognitive/ArchitectPlanner.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/ArchitectPlanner.js +1726 -0
- package/dist/vendor/codali/cognitive/BuilderOutputParser.d.ts +25 -0
- package/dist/vendor/codali/cognitive/BuilderOutputParser.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/BuilderOutputParser.js +164 -0
- package/dist/vendor/codali/cognitive/BuilderRunner.d.ts +76 -0
- package/dist/vendor/codali/cognitive/BuilderRunner.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/BuilderRunner.js +1159 -0
- package/dist/vendor/codali/cognitive/ContextAssembler.d.ts +91 -0
- package/dist/vendor/codali/cognitive/ContextAssembler.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/ContextAssembler.js +4547 -0
- package/dist/vendor/codali/cognitive/ContextBudget.d.ts +19 -0
- package/dist/vendor/codali/cognitive/ContextBudget.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/ContextBudget.js +35 -0
- package/dist/vendor/codali/cognitive/ContextFileLoader.d.ts +30 -0
- package/dist/vendor/codali/cognitive/ContextFileLoader.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/ContextFileLoader.js +307 -0
- package/dist/vendor/codali/cognitive/ContextManager.d.ts +47 -0
- package/dist/vendor/codali/cognitive/ContextManager.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/ContextManager.js +272 -0
- package/dist/vendor/codali/cognitive/ContextRedactor.d.ts +18 -0
- package/dist/vendor/codali/cognitive/ContextRedactor.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/ContextRedactor.js +53 -0
- package/dist/vendor/codali/cognitive/ContextSelector.d.ts +22 -0
- package/dist/vendor/codali/cognitive/ContextSelector.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/ContextSelector.js +431 -0
- package/dist/vendor/codali/cognitive/ContextSerializer.d.ts +8 -0
- package/dist/vendor/codali/cognitive/ContextSerializer.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/ContextSerializer.js +882 -0
- package/dist/vendor/codali/cognitive/ContextStore.d.ts +27 -0
- package/dist/vendor/codali/cognitive/ContextStore.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/ContextStore.js +79 -0
- package/dist/vendor/codali/cognitive/ContextSummarizer.d.ts +16 -0
- package/dist/vendor/codali/cognitive/ContextSummarizer.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/ContextSummarizer.js +45 -0
- package/dist/vendor/codali/cognitive/CostEstimator.d.ts +31 -0
- package/dist/vendor/codali/cognitive/CostEstimator.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/CostEstimator.js +66 -0
- package/dist/vendor/codali/cognitive/CriticEvaluator.d.ts +32 -0
- package/dist/vendor/codali/cognitive/CriticEvaluator.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/CriticEvaluator.js +297 -0
- package/dist/vendor/codali/cognitive/EvidenceGate.d.ts +9 -0
- package/dist/vendor/codali/cognitive/EvidenceGate.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/EvidenceGate.js +75 -0
- package/dist/vendor/codali/cognitive/GoldenExampleIndexer.d.ts +12 -0
- package/dist/vendor/codali/cognitive/GoldenExampleIndexer.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/GoldenExampleIndexer.js +34 -0
- package/dist/vendor/codali/cognitive/GoldenSetStore.d.ts +33 -0
- package/dist/vendor/codali/cognitive/GoldenSetStore.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/GoldenSetStore.js +159 -0
- package/dist/vendor/codali/cognitive/IntentSignals.d.ts +7 -0
- package/dist/vendor/codali/cognitive/IntentSignals.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/IntentSignals.js +285 -0
- package/dist/vendor/codali/cognitive/LearningGovernance.d.ts +100 -0
- package/dist/vendor/codali/cognitive/LearningGovernance.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/LearningGovernance.js +276 -0
- package/dist/vendor/codali/cognitive/MemoryWriteback.d.ts +64 -0
- package/dist/vendor/codali/cognitive/MemoryWriteback.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/MemoryWriteback.js +287 -0
- package/dist/vendor/codali/cognitive/PatchApplier.d.ts +49 -0
- package/dist/vendor/codali/cognitive/PatchApplier.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/PatchApplier.js +199 -0
- package/dist/vendor/codali/cognitive/PatchInterpreter.d.ts +35 -0
- package/dist/vendor/codali/cognitive/PatchInterpreter.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/PatchInterpreter.js +100 -0
- package/dist/vendor/codali/cognitive/PatchOutputNormalizer.d.ts +7 -0
- package/dist/vendor/codali/cognitive/PatchOutputNormalizer.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/PatchOutputNormalizer.js +59 -0
- package/dist/vendor/codali/cognitive/PostMortemAnalyzer.d.ts +17 -0
- package/dist/vendor/codali/cognitive/PostMortemAnalyzer.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/PostMortemAnalyzer.js +131 -0
- package/dist/vendor/codali/cognitive/PreferenceExtraction.d.ts +3 -0
- package/dist/vendor/codali/cognitive/PreferenceExtraction.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/PreferenceExtraction.js +85 -0
- package/dist/vendor/codali/cognitive/Prompts.d.ts +15 -0
- package/dist/vendor/codali/cognitive/Prompts.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/Prompts.js +326 -0
- package/dist/vendor/codali/cognitive/ProviderRouting.d.ts +16 -0
- package/dist/vendor/codali/cognitive/ProviderRouting.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/ProviderRouting.js +24 -0
- package/dist/vendor/codali/cognitive/QueryExtraction.d.ts +12 -0
- package/dist/vendor/codali/cognitive/QueryExtraction.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/QueryExtraction.js +262 -0
- package/dist/vendor/codali/cognitive/RunHistoryIndexer.d.ts +13 -0
- package/dist/vendor/codali/cognitive/RunHistoryIndexer.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/RunHistoryIndexer.js +125 -0
- package/dist/vendor/codali/cognitive/SmartPipeline.d.ts +92 -0
- package/dist/vendor/codali/cognitive/SmartPipeline.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/SmartPipeline.js +4804 -0
- package/dist/vendor/codali/cognitive/Types.d.ts +474 -0
- package/dist/vendor/codali/cognitive/Types.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/Types.js +7 -0
- package/dist/vendor/codali/cognitive/ValidationRunner.d.ts +57 -0
- package/dist/vendor/codali/cognitive/ValidationRunner.d.ts.map +1 -0
- package/dist/vendor/codali/cognitive/ValidationRunner.js +515 -0
- package/dist/vendor/codali/config/Config.d.ts +249 -0
- package/dist/vendor/codali/config/Config.d.ts.map +1 -0
- package/dist/vendor/codali/config/Config.js +200 -0
- package/dist/vendor/codali/config/ConfigLoader.d.ts +56 -0
- package/dist/vendor/codali/config/ConfigLoader.d.ts.map +1 -0
- package/dist/vendor/codali/config/ConfigLoader.js +1246 -0
- package/dist/vendor/codali/docdex/DocdexClient.d.ts +113 -0
- package/dist/vendor/codali/docdex/DocdexClient.d.ts.map +1 -0
- package/dist/vendor/codali/docdex/DocdexClient.js +524 -0
- package/dist/vendor/codali/eval/EvalRunner.d.ts +35 -0
- package/dist/vendor/codali/eval/EvalRunner.d.ts.map +1 -0
- package/dist/vendor/codali/eval/EvalRunner.js +38 -0
- package/dist/vendor/codali/eval/EvalTaskExecutor.d.ts +81 -0
- package/dist/vendor/codali/eval/EvalTaskExecutor.d.ts.map +1 -0
- package/dist/vendor/codali/eval/EvalTaskExecutor.js +371 -0
- package/dist/vendor/codali/eval/GateEvaluator.d.ts +31 -0
- package/dist/vendor/codali/eval/GateEvaluator.d.ts.map +1 -0
- package/dist/vendor/codali/eval/GateEvaluator.js +134 -0
- package/dist/vendor/codali/eval/MetricTypes.d.ts +28 -0
- package/dist/vendor/codali/eval/MetricTypes.d.ts.map +1 -0
- package/dist/vendor/codali/eval/MetricTypes.js +1 -0
- package/dist/vendor/codali/eval/MetricsAggregator.d.ts +4 -0
- package/dist/vendor/codali/eval/MetricsAggregator.d.ts.map +1 -0
- package/dist/vendor/codali/eval/MetricsAggregator.js +97 -0
- package/dist/vendor/codali/eval/RegressionComparator.d.ts +29 -0
- package/dist/vendor/codali/eval/RegressionComparator.d.ts.map +1 -0
- package/dist/vendor/codali/eval/RegressionComparator.js +155 -0
- package/dist/vendor/codali/eval/ReportInputAdapter.d.ts +52 -0
- package/dist/vendor/codali/eval/ReportInputAdapter.d.ts.map +1 -0
- package/dist/vendor/codali/eval/ReportInputAdapter.js +229 -0
- package/dist/vendor/codali/eval/ReportSerializer.d.ts +32 -0
- package/dist/vendor/codali/eval/ReportSerializer.d.ts.map +1 -0
- package/dist/vendor/codali/eval/ReportSerializer.js +33 -0
- package/dist/vendor/codali/eval/ReportStore.d.ts +18 -0
- package/dist/vendor/codali/eval/ReportStore.d.ts.map +1 -0
- package/dist/vendor/codali/eval/ReportStore.js +96 -0
- package/dist/vendor/codali/eval/SuiteLoader.d.ts +12 -0
- package/dist/vendor/codali/eval/SuiteLoader.d.ts.map +1 -0
- package/dist/vendor/codali/eval/SuiteLoader.js +51 -0
- package/dist/vendor/codali/eval/SuiteSchema.d.ts +56 -0
- package/dist/vendor/codali/eval/SuiteSchema.d.ts.map +1 -0
- package/dist/vendor/codali/eval/SuiteSchema.js +357 -0
- package/dist/vendor/codali/index.d.ts +11 -0
- package/dist/vendor/codali/index.d.ts.map +1 -0
- package/dist/vendor/codali/index.js +5 -0
- package/dist/vendor/codali/providers/CodexCliProvider.d.ts +8 -0
- package/dist/vendor/codali/providers/CodexCliProvider.d.ts.map +1 -0
- package/dist/vendor/codali/providers/CodexCliProvider.js +282 -0
- package/dist/vendor/codali/providers/OllamaRemoteProvider.d.ts +8 -0
- package/dist/vendor/codali/providers/OllamaRemoteProvider.d.ts.map +1 -0
- package/dist/vendor/codali/providers/OllamaRemoteProvider.js +300 -0
- package/dist/vendor/codali/providers/OpenAiCompatibleProvider.d.ts +8 -0
- package/dist/vendor/codali/providers/OpenAiCompatibleProvider.d.ts.map +1 -0
- package/dist/vendor/codali/providers/OpenAiCompatibleProvider.js +192 -0
- package/dist/vendor/codali/providers/ProviderRegistry.d.ts +12 -0
- package/dist/vendor/codali/providers/ProviderRegistry.d.ts.map +1 -0
- package/dist/vendor/codali/providers/ProviderRegistry.js +28 -0
- package/dist/vendor/codali/providers/ProviderTypes.d.ts +81 -0
- package/dist/vendor/codali/providers/ProviderTypes.d.ts.map +1 -0
- package/dist/vendor/codali/providers/ProviderTypes.js +1 -0
- package/dist/vendor/codali/runtime/CodaliRuntime.d.ts +183 -0
- package/dist/vendor/codali/runtime/CodaliRuntime.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/CodaliRuntime.js +1363 -0
- package/dist/vendor/codali/runtime/DeepInvestigationErrors.d.ts +39 -0
- package/dist/vendor/codali/runtime/DeepInvestigationErrors.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/DeepInvestigationErrors.js +57 -0
- package/dist/vendor/codali/runtime/RunContext.d.ts +27 -0
- package/dist/vendor/codali/runtime/RunContext.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/RunContext.js +51 -0
- package/dist/vendor/codali/runtime/RunLogQuery.d.ts +48 -0
- package/dist/vendor/codali/runtime/RunLogQuery.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/RunLogQuery.js +36 -0
- package/dist/vendor/codali/runtime/RunLogReader.d.ts +19 -0
- package/dist/vendor/codali/runtime/RunLogReader.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/RunLogReader.js +361 -0
- package/dist/vendor/codali/runtime/RunLogger.d.ts +71 -0
- package/dist/vendor/codali/runtime/RunLogger.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/RunLogger.js +100 -0
- package/dist/vendor/codali/runtime/RunTelemetryTypes.d.ts +117 -0
- package/dist/vendor/codali/runtime/RunTelemetryTypes.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/RunTelemetryTypes.js +299 -0
- package/dist/vendor/codali/runtime/Runner.d.ts +66 -0
- package/dist/vendor/codali/runtime/Runner.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/Runner.js +215 -0
- package/dist/vendor/codali/runtime/StoragePaths.d.ts +3 -0
- package/dist/vendor/codali/runtime/StoragePaths.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/StoragePaths.js +19 -0
- package/dist/vendor/codali/runtime/WorkspaceLock.d.ts +30 -0
- package/dist/vendor/codali/runtime/WorkspaceLock.d.ts.map +1 -0
- package/dist/vendor/codali/runtime/WorkspaceLock.js +141 -0
- package/dist/vendor/codali/session/InstructionLoader.d.ts +14 -0
- package/dist/vendor/codali/session/InstructionLoader.d.ts.map +1 -0
- package/dist/vendor/codali/session/InstructionLoader.js +107 -0
- package/dist/vendor/codali/session/SessionStore.d.ts +81 -0
- package/dist/vendor/codali/session/SessionStore.d.ts.map +1 -0
- package/dist/vendor/codali/session/SessionStore.js +244 -0
- package/dist/vendor/codali/subagents/SubagentOrchestrator.d.ts +68 -0
- package/dist/vendor/codali/subagents/SubagentOrchestrator.d.ts.map +1 -0
- package/dist/vendor/codali/subagents/SubagentOrchestrator.js +150 -0
- package/dist/vendor/codali/tools/ToolRegistry.d.ts +9 -0
- package/dist/vendor/codali/tools/ToolRegistry.d.ts.map +1 -0
- package/dist/vendor/codali/tools/ToolRegistry.js +263 -0
- package/dist/vendor/codali/tools/ToolTypes.d.ts +66 -0
- package/dist/vendor/codali/tools/ToolTypes.d.ts.map +1 -0
- package/dist/vendor/codali/tools/ToolTypes.js +32 -0
- package/dist/vendor/codali/tools/diff/DiffTool.d.ts +3 -0
- package/dist/vendor/codali/tools/diff/DiffTool.d.ts.map +1 -0
- package/dist/vendor/codali/tools/diff/DiffTool.js +34 -0
- package/dist/vendor/codali/tools/docdex/DocdexTools.d.ts +4 -0
- package/dist/vendor/codali/tools/docdex/DocdexTools.d.ts.map +1 -0
- package/dist/vendor/codali/tools/docdex/DocdexTools.js +453 -0
- package/dist/vendor/codali/tools/filesystem/FileTools.d.ts +3 -0
- package/dist/vendor/codali/tools/filesystem/FileTools.d.ts.map +1 -0
- package/dist/vendor/codali/tools/filesystem/FileTools.js +141 -0
- package/dist/vendor/codali/tools/search/SearchTool.d.ts +3 -0
- package/dist/vendor/codali/tools/search/SearchTool.d.ts.map +1 -0
- package/dist/vendor/codali/tools/search/SearchTool.js +46 -0
- package/dist/vendor/codali/tools/shell/ShellTool.d.ts +3 -0
- package/dist/vendor/codali/tools/shell/ShellTool.d.ts.map +1 -0
- package/dist/vendor/codali/tools/shell/ShellTool.js +104 -0
- package/package.json +5 -3
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import type { DocdexCapabilitySnapshot } from "../cognitive/Types.js";
|
|
2
|
+
export interface DocdexClientOptions {
|
|
3
|
+
baseUrl: string;
|
|
4
|
+
repoRoot?: string;
|
|
5
|
+
repoId?: string;
|
|
6
|
+
authToken?: string;
|
|
7
|
+
dagSessionId?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface DocdexSearchOptions {
|
|
10
|
+
limit?: number;
|
|
11
|
+
dagSessionId?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface DocdexSnippetOptions {
|
|
14
|
+
window?: number;
|
|
15
|
+
textOnly?: boolean;
|
|
16
|
+
}
|
|
17
|
+
export interface DocdexImpactOptions {
|
|
18
|
+
maxDepth?: number;
|
|
19
|
+
maxEdges?: number;
|
|
20
|
+
edgeTypes?: string[];
|
|
21
|
+
}
|
|
22
|
+
export interface DocdexDagOptions {
|
|
23
|
+
format?: "json" | "text" | "dot";
|
|
24
|
+
maxNodes?: number;
|
|
25
|
+
}
|
|
26
|
+
export interface DocdexImpactDiagnosticsOptions {
|
|
27
|
+
limit?: number;
|
|
28
|
+
offset?: number;
|
|
29
|
+
file?: string;
|
|
30
|
+
}
|
|
31
|
+
export interface DocdexTreeOptions {
|
|
32
|
+
path?: string;
|
|
33
|
+
maxDepth?: number;
|
|
34
|
+
dirsOnly?: boolean;
|
|
35
|
+
includeHidden?: boolean;
|
|
36
|
+
extraExcludes?: string[];
|
|
37
|
+
}
|
|
38
|
+
export interface DocdexOpenFileOptions {
|
|
39
|
+
startLine?: number;
|
|
40
|
+
endLine?: number;
|
|
41
|
+
head?: number;
|
|
42
|
+
clamp?: boolean;
|
|
43
|
+
}
|
|
44
|
+
export interface DocdexWebResearchOptions {
|
|
45
|
+
forceWeb?: boolean;
|
|
46
|
+
skipLocalSearch?: boolean;
|
|
47
|
+
webLimit?: number;
|
|
48
|
+
noCache?: boolean;
|
|
49
|
+
}
|
|
50
|
+
export interface DocdexWriteMetadata {
|
|
51
|
+
[key: string]: unknown;
|
|
52
|
+
}
|
|
53
|
+
export declare class DocdexClient {
|
|
54
|
+
private options;
|
|
55
|
+
private repoId?;
|
|
56
|
+
private dagSessionId?;
|
|
57
|
+
private healthChecked;
|
|
58
|
+
private repoInitializeAttempted;
|
|
59
|
+
private capabilitySnapshot?;
|
|
60
|
+
constructor(options: DocdexClientOptions);
|
|
61
|
+
setRepoId(repoId: string): void;
|
|
62
|
+
getRepoId(): string | undefined;
|
|
63
|
+
getRepoRoot(): string | undefined;
|
|
64
|
+
setDagSessionId(sessionId: string): void;
|
|
65
|
+
getDagSessionId(): string | undefined;
|
|
66
|
+
clearCapabilityCache(): void;
|
|
67
|
+
private resolveBaseUrl;
|
|
68
|
+
private buildHeaders;
|
|
69
|
+
private ensureHealth;
|
|
70
|
+
healthCheck(): Promise<boolean>;
|
|
71
|
+
initialize(rootUri: string): Promise<{
|
|
72
|
+
repoId?: string;
|
|
73
|
+
repoRoot?: string;
|
|
74
|
+
}>;
|
|
75
|
+
private ensureRepoInitialized;
|
|
76
|
+
private withRepoId;
|
|
77
|
+
search(query: string, options?: DocdexSearchOptions): Promise<unknown>;
|
|
78
|
+
openSnippet(docId: string, options?: DocdexSnippetOptions): Promise<unknown>;
|
|
79
|
+
impactGraph(file: string, options?: DocdexImpactOptions): Promise<unknown>;
|
|
80
|
+
impactDiagnostics(options?: DocdexImpactDiagnosticsOptions): Promise<unknown>;
|
|
81
|
+
indexRebuild(libsSources?: string): Promise<unknown>;
|
|
82
|
+
indexIngest(file: string): Promise<unknown>;
|
|
83
|
+
hooksValidate(files: string[]): Promise<unknown>;
|
|
84
|
+
delegate(payload: Record<string, unknown>): Promise<unknown>;
|
|
85
|
+
dagExport(sessionId: string, options?: DocdexDagOptions): Promise<unknown>;
|
|
86
|
+
callMcp<T>(method: string, params: Record<string, unknown>): Promise<T>;
|
|
87
|
+
private normalizeMcpResult;
|
|
88
|
+
private tryParseJson;
|
|
89
|
+
private buildProjectParams;
|
|
90
|
+
private defaultCapabilityMap;
|
|
91
|
+
private toCapabilityStatus;
|
|
92
|
+
private normalizeCapabilityPayload;
|
|
93
|
+
symbols(pathValue: string): Promise<unknown>;
|
|
94
|
+
ast(pathValue: string, maxNodes?: number): Promise<unknown>;
|
|
95
|
+
stats(): Promise<unknown>;
|
|
96
|
+
files(limit?: number, offset?: number): Promise<unknown>;
|
|
97
|
+
repoInspect(): Promise<unknown>;
|
|
98
|
+
memorySave(text: string, metadata?: DocdexWriteMetadata): Promise<unknown>;
|
|
99
|
+
memoryRecall(query: string, topK?: number): Promise<unknown>;
|
|
100
|
+
tree(options?: DocdexTreeOptions): Promise<unknown>;
|
|
101
|
+
openFile(pathValue: string, options?: DocdexOpenFileOptions): Promise<unknown>;
|
|
102
|
+
getProfile(agentId?: string): Promise<unknown>;
|
|
103
|
+
savePreference(agentId: string, category: string, content: string, metadata?: DocdexWriteMetadata): Promise<unknown>;
|
|
104
|
+
webResearch(query: string, options?: DocdexWebResearchOptions): Promise<unknown>;
|
|
105
|
+
private webResearchHttp;
|
|
106
|
+
rerank(query: string, candidates: unknown[], limit?: number): Promise<unknown>;
|
|
107
|
+
batchSearch(queries: string[], options?: {
|
|
108
|
+
limit?: number;
|
|
109
|
+
includeLibs?: boolean;
|
|
110
|
+
}): Promise<unknown>;
|
|
111
|
+
getCapabilities(forceRefresh?: boolean): Promise<DocdexCapabilitySnapshot>;
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=DocdexClient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DocdexClient.d.ts","sourceRoot":"","sources":["../../src/docdex/DocdexClient.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAEV,wBAAwB,EAEzB,MAAM,uBAAuB,CAAC;AAE/B,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,mBAAmB;IAClC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,oBAAoB;IACnC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;CACtB;AAED,MAAM,WAAW,gBAAgB;IAC/B,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,KAAK,CAAC;IACjC,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,8BAA8B;IAC7C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IA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AA;KAAO,GACtD,OAAO,CAAC,OAAO,CAAC;IAWb,eAAe,CAAC,YAAY,UAAQ,GAAG,OAAO,CAAC,wBAAwB,CAAC;CAmC/E"}
|
|
@@ -0,0 +1,524 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { pathToFileURL } from "node:url";
|
|
4
|
+
const CAPABILITY_KEYS = [
|
|
5
|
+
"score_breakdown",
|
|
6
|
+
"rerank",
|
|
7
|
+
"snippet_provenance",
|
|
8
|
+
"retrieval_explanation",
|
|
9
|
+
"batch_search",
|
|
10
|
+
];
|
|
11
|
+
export class DocdexClient {
|
|
12
|
+
constructor(options) {
|
|
13
|
+
this.options = options;
|
|
14
|
+
this.healthChecked = false;
|
|
15
|
+
this.repoInitializeAttempted = false;
|
|
16
|
+
this.repoId = options.repoId;
|
|
17
|
+
this.dagSessionId = options.dagSessionId;
|
|
18
|
+
}
|
|
19
|
+
setRepoId(repoId) {
|
|
20
|
+
this.repoId = repoId;
|
|
21
|
+
}
|
|
22
|
+
getRepoId() {
|
|
23
|
+
return this.repoId;
|
|
24
|
+
}
|
|
25
|
+
getRepoRoot() {
|
|
26
|
+
return this.options.repoRoot;
|
|
27
|
+
}
|
|
28
|
+
setDagSessionId(sessionId) {
|
|
29
|
+
this.dagSessionId = sessionId;
|
|
30
|
+
}
|
|
31
|
+
getDagSessionId() {
|
|
32
|
+
return this.dagSessionId;
|
|
33
|
+
}
|
|
34
|
+
clearCapabilityCache() {
|
|
35
|
+
this.capabilitySnapshot = undefined;
|
|
36
|
+
}
|
|
37
|
+
resolveBaseUrl() {
|
|
38
|
+
const base = this.options.baseUrl.trim();
|
|
39
|
+
return base.endsWith("/") ? base.slice(0, -1) : base;
|
|
40
|
+
}
|
|
41
|
+
buildHeaders(dagSessionId) {
|
|
42
|
+
const headers = { "content-type": "application/json" };
|
|
43
|
+
if (this.options.authToken)
|
|
44
|
+
headers.authorization = `Bearer ${this.options.authToken}`;
|
|
45
|
+
if (this.repoId)
|
|
46
|
+
headers["x-docdex-repo-id"] = this.repoId;
|
|
47
|
+
if (this.options.repoRoot)
|
|
48
|
+
headers["x-docdex-repo-root"] = path.resolve(this.options.repoRoot);
|
|
49
|
+
const resolvedDagSessionId = dagSessionId ?? this.dagSessionId;
|
|
50
|
+
if (resolvedDagSessionId)
|
|
51
|
+
headers["x-docdex-dag-session"] = resolvedDagSessionId;
|
|
52
|
+
return headers;
|
|
53
|
+
}
|
|
54
|
+
async ensureHealth() {
|
|
55
|
+
if (this.healthChecked)
|
|
56
|
+
return;
|
|
57
|
+
const ok = await this.healthCheck();
|
|
58
|
+
if (!ok) {
|
|
59
|
+
throw new Error("Docdex health check failed");
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
async healthCheck() {
|
|
63
|
+
const response = await fetch(`${this.resolveBaseUrl()}/healthz`);
|
|
64
|
+
this.healthChecked = response.ok;
|
|
65
|
+
return response.ok;
|
|
66
|
+
}
|
|
67
|
+
async initialize(rootUri) {
|
|
68
|
+
await this.ensureHealth();
|
|
69
|
+
const response = await fetch(`${this.resolveBaseUrl()}/v1/initialize`, {
|
|
70
|
+
method: "POST",
|
|
71
|
+
headers: this.buildHeaders(),
|
|
72
|
+
body: JSON.stringify({ rootUri }),
|
|
73
|
+
});
|
|
74
|
+
if (!response.ok) {
|
|
75
|
+
const body = await response.text();
|
|
76
|
+
throw new Error(`Docdex initialize failed (${response.status}): ${body}`);
|
|
77
|
+
}
|
|
78
|
+
const payload = (await response.json());
|
|
79
|
+
const repoId = (payload.repo_id ?? payload.repoId ?? payload.repo);
|
|
80
|
+
const repoRoot = (payload.repo_root ?? payload.repoRoot);
|
|
81
|
+
if (repoId)
|
|
82
|
+
this.repoId = repoId;
|
|
83
|
+
return { repoId, repoRoot };
|
|
84
|
+
}
|
|
85
|
+
async ensureRepoInitialized() {
|
|
86
|
+
if (this.repoId || this.repoInitializeAttempted || !this.options.repoRoot)
|
|
87
|
+
return;
|
|
88
|
+
this.repoInitializeAttempted = true;
|
|
89
|
+
try {
|
|
90
|
+
await this.initialize(pathToFileURL(path.resolve(this.options.repoRoot)).toString());
|
|
91
|
+
}
|
|
92
|
+
catch {
|
|
93
|
+
// Keep endpoint-specific calls responsible for reporting the final failure.
|
|
94
|
+
// Single-repo daemons can still accept repo_root without a prior initialize.
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
withRepoId(params) {
|
|
98
|
+
if (this.repoId)
|
|
99
|
+
params.set("repo_id", this.repoId);
|
|
100
|
+
if (this.options.repoRoot)
|
|
101
|
+
params.set("repo_root", path.resolve(this.options.repoRoot));
|
|
102
|
+
}
|
|
103
|
+
async search(query, options = {}) {
|
|
104
|
+
await this.ensureHealth();
|
|
105
|
+
await this.ensureRepoInitialized();
|
|
106
|
+
const params = new URLSearchParams({ q: query });
|
|
107
|
+
if (options.limit !== undefined)
|
|
108
|
+
params.set("limit", String(options.limit));
|
|
109
|
+
const dagSessionId = options.dagSessionId ?? this.dagSessionId;
|
|
110
|
+
if (dagSessionId)
|
|
111
|
+
params.set("dag_session_id", dagSessionId);
|
|
112
|
+
this.withRepoId(params);
|
|
113
|
+
const response = await fetch(`${this.resolveBaseUrl()}/search?${params.toString()}`, {
|
|
114
|
+
headers: this.buildHeaders(dagSessionId),
|
|
115
|
+
});
|
|
116
|
+
if (!response.ok) {
|
|
117
|
+
const body = await response.text();
|
|
118
|
+
throw new Error(`Docdex search failed (${response.status}): ${body}`);
|
|
119
|
+
}
|
|
120
|
+
return response.json();
|
|
121
|
+
}
|
|
122
|
+
async openSnippet(docId, options = {}) {
|
|
123
|
+
await this.ensureHealth();
|
|
124
|
+
await this.ensureRepoInitialized();
|
|
125
|
+
const params = new URLSearchParams();
|
|
126
|
+
if (options.window !== undefined)
|
|
127
|
+
params.set("window", String(options.window));
|
|
128
|
+
if (options.textOnly)
|
|
129
|
+
params.set("text_only", "true");
|
|
130
|
+
this.withRepoId(params);
|
|
131
|
+
const response = await fetch(`${this.resolveBaseUrl()}/snippet/${encodeURIComponent(docId)}?${params.toString()}`, {
|
|
132
|
+
headers: this.buildHeaders(),
|
|
133
|
+
});
|
|
134
|
+
if (!response.ok) {
|
|
135
|
+
const body = await response.text();
|
|
136
|
+
throw new Error(`Docdex snippet failed (${response.status}): ${body}`);
|
|
137
|
+
}
|
|
138
|
+
const contentType = response.headers.get("content-type") ?? "";
|
|
139
|
+
if (contentType.includes("application/json")) {
|
|
140
|
+
return response.json();
|
|
141
|
+
}
|
|
142
|
+
return response.text();
|
|
143
|
+
}
|
|
144
|
+
async impactGraph(file, options = {}) {
|
|
145
|
+
await this.ensureHealth();
|
|
146
|
+
await this.ensureRepoInitialized();
|
|
147
|
+
const params = new URLSearchParams({ file });
|
|
148
|
+
if (options.maxDepth !== undefined)
|
|
149
|
+
params.set("max_depth", String(options.maxDepth));
|
|
150
|
+
if (options.maxEdges !== undefined)
|
|
151
|
+
params.set("max_edges", String(options.maxEdges));
|
|
152
|
+
if (options.edgeTypes?.length)
|
|
153
|
+
params.set("edge_types", options.edgeTypes.join(","));
|
|
154
|
+
this.withRepoId(params);
|
|
155
|
+
const response = await fetch(`${this.resolveBaseUrl()}/v1/graph/impact?${params.toString()}`, {
|
|
156
|
+
headers: this.buildHeaders(),
|
|
157
|
+
});
|
|
158
|
+
if (!response.ok) {
|
|
159
|
+
const body = await response.text();
|
|
160
|
+
throw new Error(`Docdex impact graph failed (${response.status}): ${body}`);
|
|
161
|
+
}
|
|
162
|
+
return response.json();
|
|
163
|
+
}
|
|
164
|
+
async impactDiagnostics(options = {}) {
|
|
165
|
+
await this.ensureHealth();
|
|
166
|
+
await this.ensureRepoInitialized();
|
|
167
|
+
const params = new URLSearchParams();
|
|
168
|
+
if (options.file)
|
|
169
|
+
params.set("file", options.file);
|
|
170
|
+
if (options.limit !== undefined)
|
|
171
|
+
params.set("limit", String(options.limit));
|
|
172
|
+
if (options.offset !== undefined)
|
|
173
|
+
params.set("offset", String(options.offset));
|
|
174
|
+
this.withRepoId(params);
|
|
175
|
+
const response = await fetch(`${this.resolveBaseUrl()}/v1/graph/impact/diagnostics?${params.toString()}`, {
|
|
176
|
+
headers: this.buildHeaders(),
|
|
177
|
+
});
|
|
178
|
+
if (!response.ok) {
|
|
179
|
+
const body = await response.text();
|
|
180
|
+
throw new Error(`Docdex impact diagnostics failed (${response.status}): ${body}`);
|
|
181
|
+
}
|
|
182
|
+
return response.json();
|
|
183
|
+
}
|
|
184
|
+
async indexRebuild(libsSources) {
|
|
185
|
+
await this.ensureHealth();
|
|
186
|
+
const response = await fetch(`${this.resolveBaseUrl()}/v1/index/rebuild`, {
|
|
187
|
+
method: "POST",
|
|
188
|
+
headers: this.buildHeaders(),
|
|
189
|
+
body: JSON.stringify(libsSources ? { libs_sources: libsSources } : {}),
|
|
190
|
+
});
|
|
191
|
+
if (!response.ok) {
|
|
192
|
+
const body = await response.text();
|
|
193
|
+
throw new Error(`Docdex index rebuild failed (${response.status}): ${body}`);
|
|
194
|
+
}
|
|
195
|
+
return response.json();
|
|
196
|
+
}
|
|
197
|
+
async indexIngest(file) {
|
|
198
|
+
await this.ensureHealth();
|
|
199
|
+
const response = await fetch(`${this.resolveBaseUrl()}/v1/index/ingest`, {
|
|
200
|
+
method: "POST",
|
|
201
|
+
headers: this.buildHeaders(),
|
|
202
|
+
body: JSON.stringify({ file }),
|
|
203
|
+
});
|
|
204
|
+
if (!response.ok) {
|
|
205
|
+
const body = await response.text();
|
|
206
|
+
throw new Error(`Docdex index ingest failed (${response.status}): ${body}`);
|
|
207
|
+
}
|
|
208
|
+
return response.json();
|
|
209
|
+
}
|
|
210
|
+
async hooksValidate(files) {
|
|
211
|
+
await this.ensureHealth();
|
|
212
|
+
const response = await fetch(`${this.resolveBaseUrl()}/v1/hooks/validate`, {
|
|
213
|
+
method: "POST",
|
|
214
|
+
headers: this.buildHeaders(),
|
|
215
|
+
body: JSON.stringify({ files }),
|
|
216
|
+
});
|
|
217
|
+
if (!response.ok) {
|
|
218
|
+
const body = await response.text();
|
|
219
|
+
throw new Error(`Docdex hooks validate failed (${response.status}): ${body}`);
|
|
220
|
+
}
|
|
221
|
+
return response.json();
|
|
222
|
+
}
|
|
223
|
+
async delegate(payload) {
|
|
224
|
+
await this.ensureHealth();
|
|
225
|
+
const response = await fetch(`${this.resolveBaseUrl()}/v1/delegate`, {
|
|
226
|
+
method: "POST",
|
|
227
|
+
headers: this.buildHeaders(),
|
|
228
|
+
body: JSON.stringify(payload),
|
|
229
|
+
});
|
|
230
|
+
if (!response.ok) {
|
|
231
|
+
const body = await response.text();
|
|
232
|
+
throw new Error(`Docdex delegate failed (${response.status}): ${body}`);
|
|
233
|
+
}
|
|
234
|
+
return response.json();
|
|
235
|
+
}
|
|
236
|
+
async dagExport(sessionId, options = {}) {
|
|
237
|
+
await this.ensureHealth();
|
|
238
|
+
await this.ensureRepoInitialized();
|
|
239
|
+
const params = new URLSearchParams({ session_id: sessionId });
|
|
240
|
+
if (options.format)
|
|
241
|
+
params.set("format", options.format);
|
|
242
|
+
if (options.maxNodes !== undefined)
|
|
243
|
+
params.set("max_nodes", String(options.maxNodes));
|
|
244
|
+
this.withRepoId(params);
|
|
245
|
+
const response = await fetch(`${this.resolveBaseUrl()}/v1/dag/export?${params.toString()}`, {
|
|
246
|
+
headers: this.buildHeaders(),
|
|
247
|
+
});
|
|
248
|
+
const body = await response.text();
|
|
249
|
+
if (!response.ok) {
|
|
250
|
+
throw new Error(`Docdex dag export failed (${response.status}): ${body}`);
|
|
251
|
+
}
|
|
252
|
+
const contentType = response.headers.get("content-type") ?? "";
|
|
253
|
+
if (contentType.includes("application/json")) {
|
|
254
|
+
try {
|
|
255
|
+
return JSON.parse(body);
|
|
256
|
+
}
|
|
257
|
+
catch {
|
|
258
|
+
return body;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
return body;
|
|
262
|
+
}
|
|
263
|
+
async callMcp(method, params) {
|
|
264
|
+
await this.ensureHealth();
|
|
265
|
+
const payload = {
|
|
266
|
+
jsonrpc: "2.0",
|
|
267
|
+
id: randomUUID(),
|
|
268
|
+
method,
|
|
269
|
+
params,
|
|
270
|
+
};
|
|
271
|
+
const response = await fetch(`${this.resolveBaseUrl()}/v1/mcp`, {
|
|
272
|
+
method: "POST",
|
|
273
|
+
headers: this.buildHeaders(),
|
|
274
|
+
body: JSON.stringify(payload),
|
|
275
|
+
});
|
|
276
|
+
if (!response.ok) {
|
|
277
|
+
const body = await response.text();
|
|
278
|
+
throw new Error(`Docdex MCP failed (${response.status}): ${body}`);
|
|
279
|
+
}
|
|
280
|
+
const raw = (await response.json());
|
|
281
|
+
if (raw.error) {
|
|
282
|
+
throw new Error(raw.error.message ?? "Docdex MCP error");
|
|
283
|
+
}
|
|
284
|
+
return this.normalizeMcpResult(raw.result);
|
|
285
|
+
}
|
|
286
|
+
normalizeMcpResult(payload) {
|
|
287
|
+
if (!payload || typeof payload !== "object")
|
|
288
|
+
return payload;
|
|
289
|
+
const record = payload;
|
|
290
|
+
if (record.structuredContent !== undefined) {
|
|
291
|
+
return record.structuredContent;
|
|
292
|
+
}
|
|
293
|
+
if (!Array.isArray(record.content) || record.content.length === 0) {
|
|
294
|
+
return payload;
|
|
295
|
+
}
|
|
296
|
+
const textChunks = record.content
|
|
297
|
+
.map((entry) => {
|
|
298
|
+
if (!entry || typeof entry !== "object")
|
|
299
|
+
return undefined;
|
|
300
|
+
const text = entry.text;
|
|
301
|
+
return typeof text === "string" ? text : undefined;
|
|
302
|
+
})
|
|
303
|
+
.filter((text) => typeof text === "string");
|
|
304
|
+
if (textChunks.length === 0) {
|
|
305
|
+
return payload;
|
|
306
|
+
}
|
|
307
|
+
const joined = textChunks.join("\n").trim();
|
|
308
|
+
if (joined.length === 0) {
|
|
309
|
+
return payload;
|
|
310
|
+
}
|
|
311
|
+
const parsed = this.tryParseJson(joined);
|
|
312
|
+
return parsed ?? joined;
|
|
313
|
+
}
|
|
314
|
+
tryParseJson(text) {
|
|
315
|
+
const trimmed = text.trim();
|
|
316
|
+
if (!trimmed)
|
|
317
|
+
return undefined;
|
|
318
|
+
try {
|
|
319
|
+
return JSON.parse(trimmed);
|
|
320
|
+
}
|
|
321
|
+
catch {
|
|
322
|
+
return undefined;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
buildProjectParams(extra) {
|
|
326
|
+
return {
|
|
327
|
+
project_root: this.options.repoRoot,
|
|
328
|
+
...extra,
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
defaultCapabilityMap(status) {
|
|
332
|
+
return {
|
|
333
|
+
score_breakdown: status,
|
|
334
|
+
rerank: status,
|
|
335
|
+
snippet_provenance: status,
|
|
336
|
+
retrieval_explanation: status,
|
|
337
|
+
batch_search: status,
|
|
338
|
+
};
|
|
339
|
+
}
|
|
340
|
+
toCapabilityStatus(value) {
|
|
341
|
+
if (value === true)
|
|
342
|
+
return "available";
|
|
343
|
+
if (value === false)
|
|
344
|
+
return "unavailable";
|
|
345
|
+
if (typeof value === "number")
|
|
346
|
+
return value > 0 ? "available" : "unavailable";
|
|
347
|
+
if (typeof value !== "string")
|
|
348
|
+
return "unknown";
|
|
349
|
+
const normalized = value.trim().toLowerCase();
|
|
350
|
+
if (["available", "enabled", "supported", "ok", "true", "yes"].includes(normalized)) {
|
|
351
|
+
return "available";
|
|
352
|
+
}
|
|
353
|
+
if (["unavailable", "disabled", "unsupported", "none", "false", "no"].includes(normalized)) {
|
|
354
|
+
return "unavailable";
|
|
355
|
+
}
|
|
356
|
+
return "unknown";
|
|
357
|
+
}
|
|
358
|
+
normalizeCapabilityPayload(payload) {
|
|
359
|
+
if (!payload || typeof payload !== "object")
|
|
360
|
+
return undefined;
|
|
361
|
+
const record = payload;
|
|
362
|
+
const source = ((record.capabilities && typeof record.capabilities === "object"
|
|
363
|
+
? record.capabilities
|
|
364
|
+
: undefined) ??
|
|
365
|
+
(record.retrieval && typeof record.retrieval === "object"
|
|
366
|
+
? record.retrieval
|
|
367
|
+
: undefined) ??
|
|
368
|
+
record);
|
|
369
|
+
const scopedSource = (source.retrieval && typeof source.retrieval === "object"
|
|
370
|
+
? source.retrieval
|
|
371
|
+
: source);
|
|
372
|
+
const aliases = {
|
|
373
|
+
score_breakdown: ["score_breakdown", "structured_scoring", "scoring"],
|
|
374
|
+
rerank: ["rerank", "re_rank"],
|
|
375
|
+
snippet_provenance: ["snippet_provenance", "stable_provenance", "provenance"],
|
|
376
|
+
retrieval_explanation: ["retrieval_explanation", "hit_explanations", "explanations", "retrieval_explanations"],
|
|
377
|
+
batch_search: ["batch_search", "batch_retrieval", "batch", "multi_fetch"],
|
|
378
|
+
};
|
|
379
|
+
const result = this.defaultCapabilityMap("unknown");
|
|
380
|
+
let found = false;
|
|
381
|
+
for (const key of CAPABILITY_KEYS) {
|
|
382
|
+
const aliasKeys = aliases[key];
|
|
383
|
+
const raw = aliasKeys.map((alias) => scopedSource[alias]).find((entry) => entry !== undefined);
|
|
384
|
+
if (raw === undefined)
|
|
385
|
+
continue;
|
|
386
|
+
found = true;
|
|
387
|
+
result[key] = this.toCapabilityStatus(raw);
|
|
388
|
+
}
|
|
389
|
+
return found ? result : undefined;
|
|
390
|
+
}
|
|
391
|
+
symbols(pathValue) {
|
|
392
|
+
return this.callMcp("docdex_symbols", this.buildProjectParams({ path: pathValue }));
|
|
393
|
+
}
|
|
394
|
+
ast(pathValue, maxNodes) {
|
|
395
|
+
return this.callMcp("docdex_ast", this.buildProjectParams({ path: pathValue, max_nodes: maxNodes }));
|
|
396
|
+
}
|
|
397
|
+
stats() {
|
|
398
|
+
return this.callMcp("docdex_stats", this.buildProjectParams({}));
|
|
399
|
+
}
|
|
400
|
+
files(limit, offset) {
|
|
401
|
+
return this.callMcp("docdex_files", this.buildProjectParams({ limit, offset }));
|
|
402
|
+
}
|
|
403
|
+
repoInspect() {
|
|
404
|
+
return this.callMcp("docdex_repo_inspect", this.buildProjectParams({}));
|
|
405
|
+
}
|
|
406
|
+
memorySave(text, metadata) {
|
|
407
|
+
return this.callMcp("docdex_memory_save", this.buildProjectParams({ text, metadata }));
|
|
408
|
+
}
|
|
409
|
+
memoryRecall(query, topK) {
|
|
410
|
+
return this.callMcp("docdex_memory_recall", this.buildProjectParams({ query, top_k: topK }));
|
|
411
|
+
}
|
|
412
|
+
tree(options = {}) {
|
|
413
|
+
return this.callMcp("docdex_tree", this.buildProjectParams({
|
|
414
|
+
path: options.path,
|
|
415
|
+
max_depth: options.maxDepth,
|
|
416
|
+
dirs_only: options.dirsOnly,
|
|
417
|
+
include_hidden: options.includeHidden,
|
|
418
|
+
extra_excludes: options.extraExcludes,
|
|
419
|
+
}));
|
|
420
|
+
}
|
|
421
|
+
openFile(pathValue, options = {}) {
|
|
422
|
+
return this.callMcp("docdex_open", this.buildProjectParams({
|
|
423
|
+
path: pathValue,
|
|
424
|
+
start_line: options.startLine,
|
|
425
|
+
end_line: options.endLine,
|
|
426
|
+
head: options.head,
|
|
427
|
+
clamp: options.clamp,
|
|
428
|
+
}));
|
|
429
|
+
}
|
|
430
|
+
getProfile(agentId) {
|
|
431
|
+
const params = {};
|
|
432
|
+
if (agentId)
|
|
433
|
+
params.agent_id = agentId;
|
|
434
|
+
return this.callMcp("docdex_get_profile", params);
|
|
435
|
+
}
|
|
436
|
+
savePreference(agentId, category, content, metadata) {
|
|
437
|
+
return this.callMcp("docdex_save_preference", {
|
|
438
|
+
agent_id: agentId,
|
|
439
|
+
category,
|
|
440
|
+
content,
|
|
441
|
+
metadata,
|
|
442
|
+
});
|
|
443
|
+
}
|
|
444
|
+
webResearch(query, options = {}) {
|
|
445
|
+
return this.callMcp("docdex_web_research", this.buildProjectParams({
|
|
446
|
+
query,
|
|
447
|
+
force_web: options.forceWeb ?? true,
|
|
448
|
+
skip_local_search: options.skipLocalSearch,
|
|
449
|
+
web_limit: options.webLimit,
|
|
450
|
+
no_cache: options.noCache,
|
|
451
|
+
})).catch(() => this.webResearchHttp(query, options));
|
|
452
|
+
}
|
|
453
|
+
async webResearchHttp(query, options = {}) {
|
|
454
|
+
await this.ensureHealth();
|
|
455
|
+
await this.ensureRepoInitialized();
|
|
456
|
+
const params = new URLSearchParams({ q: query });
|
|
457
|
+
params.set("force_web", String(options.forceWeb ?? true));
|
|
458
|
+
if (options.skipLocalSearch !== undefined) {
|
|
459
|
+
params.set("skip_local_search", String(options.skipLocalSearch));
|
|
460
|
+
}
|
|
461
|
+
if (options.webLimit !== undefined) {
|
|
462
|
+
params.set("max_web_results", String(options.webLimit));
|
|
463
|
+
}
|
|
464
|
+
if (options.noCache !== undefined) {
|
|
465
|
+
params.set("no_cache", String(options.noCache));
|
|
466
|
+
}
|
|
467
|
+
this.withRepoId(params);
|
|
468
|
+
const response = await fetch(`${this.resolveBaseUrl()}/search?${params.toString()}`, {
|
|
469
|
+
headers: this.buildHeaders(this.dagSessionId),
|
|
470
|
+
});
|
|
471
|
+
if (!response.ok) {
|
|
472
|
+
const body = await response.text();
|
|
473
|
+
throw new Error(`Docdex web research failed (${response.status}): ${body}`);
|
|
474
|
+
}
|
|
475
|
+
return response.json();
|
|
476
|
+
}
|
|
477
|
+
rerank(query, candidates, limit) {
|
|
478
|
+
return this.callMcp("docdex_rerank", this.buildProjectParams({
|
|
479
|
+
query,
|
|
480
|
+
candidates,
|
|
481
|
+
limit,
|
|
482
|
+
}));
|
|
483
|
+
}
|
|
484
|
+
batchSearch(queries, options = {}) {
|
|
485
|
+
return this.callMcp("docdex_batch_search", this.buildProjectParams({
|
|
486
|
+
queries,
|
|
487
|
+
limit: options.limit,
|
|
488
|
+
include_libs: options.includeLibs,
|
|
489
|
+
}));
|
|
490
|
+
}
|
|
491
|
+
async getCapabilities(forceRefresh = false) {
|
|
492
|
+
if (this.capabilitySnapshot && !forceRefresh) {
|
|
493
|
+
return { ...this.capabilitySnapshot, cached: true };
|
|
494
|
+
}
|
|
495
|
+
try {
|
|
496
|
+
const payload = await this.callMcp("docdex_capabilities", this.buildProjectParams({}));
|
|
497
|
+
const normalizedCapabilities = this.normalizeCapabilityPayload(payload);
|
|
498
|
+
const capabilities = normalizedCapabilities ?? this.defaultCapabilityMap("unknown");
|
|
499
|
+
const warnings = normalizedCapabilities ? undefined : ["probe_missing_capability_fields"];
|
|
500
|
+
const snapshot = {
|
|
501
|
+
cached: false,
|
|
502
|
+
source: "mcp_probe",
|
|
503
|
+
probed_at_ms: Date.now(),
|
|
504
|
+
capabilities,
|
|
505
|
+
warnings,
|
|
506
|
+
};
|
|
507
|
+
this.capabilitySnapshot = snapshot;
|
|
508
|
+
return snapshot;
|
|
509
|
+
}
|
|
510
|
+
catch (error) {
|
|
511
|
+
const snapshot = {
|
|
512
|
+
cached: false,
|
|
513
|
+
source: "fallback",
|
|
514
|
+
probed_at_ms: Date.now(),
|
|
515
|
+
capabilities: this.defaultCapabilityMap("unavailable"),
|
|
516
|
+
warnings: [
|
|
517
|
+
`probe_failed:${error instanceof Error ? error.message : String(error)}`,
|
|
518
|
+
],
|
|
519
|
+
};
|
|
520
|
+
this.capabilitySnapshot = snapshot;
|
|
521
|
+
return snapshot;
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { EvalTaskExecution } from "./EvalTaskExecutor.js";
|
|
2
|
+
import type { EvalTaskDefinition } from "./SuiteSchema.js";
|
|
3
|
+
export interface EvalTaskExecutorLike {
|
|
4
|
+
executeTask(task: EvalTaskDefinition): Promise<EvalTaskExecution>;
|
|
5
|
+
}
|
|
6
|
+
export interface EvalRunSummary {
|
|
7
|
+
total: number;
|
|
8
|
+
passed: number;
|
|
9
|
+
failed: number;
|
|
10
|
+
execution_errors: number;
|
|
11
|
+
}
|
|
12
|
+
export interface EvalRunResult {
|
|
13
|
+
schema_version: 1;
|
|
14
|
+
suite_id: string;
|
|
15
|
+
suite_fingerprint: string;
|
|
16
|
+
started_at: string;
|
|
17
|
+
ended_at: string;
|
|
18
|
+
duration_ms: number;
|
|
19
|
+
task_results: EvalTaskExecution[];
|
|
20
|
+
summary: EvalRunSummary;
|
|
21
|
+
}
|
|
22
|
+
export declare class EvalRunner {
|
|
23
|
+
private readonly suiteId;
|
|
24
|
+
private readonly suiteFingerprint;
|
|
25
|
+
private readonly tasks;
|
|
26
|
+
private readonly executor;
|
|
27
|
+
constructor(params: {
|
|
28
|
+
suite_id: string;
|
|
29
|
+
suite_fingerprint: string;
|
|
30
|
+
tasks: EvalTaskDefinition[];
|
|
31
|
+
executor: EvalTaskExecutorLike;
|
|
32
|
+
});
|
|
33
|
+
run(): Promise<EvalRunResult>;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=EvalRunner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EvalRunner.d.ts","sourceRoot":"","sources":["../../src/eval/EvalRunner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAE3D,MAAM,WAAW,oBAAoB;IACnC,WAAW,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;CACnE;AAED,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,aAAa;IAC5B,cAAc,EAAE,CAAC,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,iBAAiB,EAAE,CAAC;IAClC,OAAO,EAAE,cAAc,CAAC;CACzB;AAED,qBAAa,UAAU;IACrB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IAEjC,OAAO,CAAC,QAAQ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