@swarmvaultai/engine 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -0
- package/dist/index.d.ts +233 -0
- package/dist/index.js +1689 -0
- package/package.json +44 -0
package/README.md
ADDED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
declare const providerCapabilitySchema: z.ZodEnum<{
|
|
4
|
+
responses: "responses";
|
|
5
|
+
chat: "chat";
|
|
6
|
+
structured: "structured";
|
|
7
|
+
tools: "tools";
|
|
8
|
+
vision: "vision";
|
|
9
|
+
embeddings: "embeddings";
|
|
10
|
+
streaming: "streaming";
|
|
11
|
+
local: "local";
|
|
12
|
+
}>;
|
|
13
|
+
type ProviderCapability = z.infer<typeof providerCapabilitySchema>;
|
|
14
|
+
declare const providerTypeSchema: z.ZodEnum<{
|
|
15
|
+
heuristic: "heuristic";
|
|
16
|
+
openai: "openai";
|
|
17
|
+
ollama: "ollama";
|
|
18
|
+
anthropic: "anthropic";
|
|
19
|
+
gemini: "gemini";
|
|
20
|
+
"openai-compatible": "openai-compatible";
|
|
21
|
+
custom: "custom";
|
|
22
|
+
}>;
|
|
23
|
+
type ProviderType = z.infer<typeof providerTypeSchema>;
|
|
24
|
+
type PageKind = "index" | "source" | "concept" | "entity" | "output";
|
|
25
|
+
type Freshness = "fresh" | "stale";
|
|
26
|
+
type ClaimStatus = "extracted" | "inferred" | "conflicted" | "stale";
|
|
27
|
+
type Polarity = "positive" | "negative" | "neutral";
|
|
28
|
+
interface GenerationAttachment {
|
|
29
|
+
mimeType: string;
|
|
30
|
+
filePath: string;
|
|
31
|
+
}
|
|
32
|
+
interface GenerationRequest {
|
|
33
|
+
system?: string;
|
|
34
|
+
prompt: string;
|
|
35
|
+
attachments?: GenerationAttachment[];
|
|
36
|
+
maxOutputTokens?: number;
|
|
37
|
+
}
|
|
38
|
+
interface GenerationResponse {
|
|
39
|
+
text: string;
|
|
40
|
+
usage?: {
|
|
41
|
+
inputTokens?: number;
|
|
42
|
+
outputTokens?: number;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
interface ProviderAdapter {
|
|
46
|
+
readonly id: string;
|
|
47
|
+
readonly type: ProviderType;
|
|
48
|
+
readonly model: string;
|
|
49
|
+
readonly capabilities: Set<ProviderCapability>;
|
|
50
|
+
generateText(request: GenerationRequest): Promise<GenerationResponse>;
|
|
51
|
+
generateStructured<T>(request: GenerationRequest, schema: z.ZodType<T>): Promise<T>;
|
|
52
|
+
}
|
|
53
|
+
interface ProviderConfig {
|
|
54
|
+
type: ProviderType;
|
|
55
|
+
model: string;
|
|
56
|
+
baseUrl?: string;
|
|
57
|
+
apiKeyEnv?: string;
|
|
58
|
+
headers?: Record<string, string>;
|
|
59
|
+
module?: string;
|
|
60
|
+
capabilities?: ProviderCapability[];
|
|
61
|
+
apiStyle?: "responses" | "chat";
|
|
62
|
+
}
|
|
63
|
+
interface VaultConfig {
|
|
64
|
+
workspace: {
|
|
65
|
+
rawDir: string;
|
|
66
|
+
wikiDir: string;
|
|
67
|
+
stateDir: string;
|
|
68
|
+
agentDir: string;
|
|
69
|
+
};
|
|
70
|
+
providers: Record<string, ProviderConfig>;
|
|
71
|
+
tasks: {
|
|
72
|
+
compileProvider: string;
|
|
73
|
+
queryProvider: string;
|
|
74
|
+
lintProvider: string;
|
|
75
|
+
visionProvider: string;
|
|
76
|
+
};
|
|
77
|
+
viewer: {
|
|
78
|
+
port: number;
|
|
79
|
+
};
|
|
80
|
+
agents: Array<"codex" | "claude" | "cursor">;
|
|
81
|
+
}
|
|
82
|
+
interface ResolvedPaths {
|
|
83
|
+
rootDir: string;
|
|
84
|
+
rawDir: string;
|
|
85
|
+
wikiDir: string;
|
|
86
|
+
stateDir: string;
|
|
87
|
+
agentDir: string;
|
|
88
|
+
manifestsDir: string;
|
|
89
|
+
extractsDir: string;
|
|
90
|
+
analysesDir: string;
|
|
91
|
+
viewerDistDir: string;
|
|
92
|
+
graphPath: string;
|
|
93
|
+
searchDbPath: string;
|
|
94
|
+
compileStatePath: string;
|
|
95
|
+
configPath: string;
|
|
96
|
+
}
|
|
97
|
+
interface SourceManifest {
|
|
98
|
+
sourceId: string;
|
|
99
|
+
title: string;
|
|
100
|
+
originType: "file" | "url";
|
|
101
|
+
sourceKind: "markdown" | "text" | "pdf" | "image" | "html" | "binary";
|
|
102
|
+
originalPath?: string;
|
|
103
|
+
url?: string;
|
|
104
|
+
storedPath: string;
|
|
105
|
+
extractedTextPath?: string;
|
|
106
|
+
mimeType: string;
|
|
107
|
+
contentHash: string;
|
|
108
|
+
createdAt: string;
|
|
109
|
+
updatedAt: string;
|
|
110
|
+
}
|
|
111
|
+
interface AnalyzedTerm {
|
|
112
|
+
id: string;
|
|
113
|
+
name: string;
|
|
114
|
+
description: string;
|
|
115
|
+
}
|
|
116
|
+
interface SourceClaim {
|
|
117
|
+
id: string;
|
|
118
|
+
text: string;
|
|
119
|
+
confidence: number;
|
|
120
|
+
status: ClaimStatus;
|
|
121
|
+
polarity: Polarity;
|
|
122
|
+
citation: string;
|
|
123
|
+
}
|
|
124
|
+
interface SourceAnalysis {
|
|
125
|
+
sourceId: string;
|
|
126
|
+
sourceHash: string;
|
|
127
|
+
title: string;
|
|
128
|
+
summary: string;
|
|
129
|
+
concepts: AnalyzedTerm[];
|
|
130
|
+
entities: AnalyzedTerm[];
|
|
131
|
+
claims: SourceClaim[];
|
|
132
|
+
questions: string[];
|
|
133
|
+
producedAt: string;
|
|
134
|
+
}
|
|
135
|
+
interface GraphNode {
|
|
136
|
+
id: string;
|
|
137
|
+
type: "source" | "concept" | "entity";
|
|
138
|
+
label: string;
|
|
139
|
+
pageId?: string;
|
|
140
|
+
freshness?: Freshness;
|
|
141
|
+
confidence?: number;
|
|
142
|
+
sourceIds: string[];
|
|
143
|
+
}
|
|
144
|
+
interface GraphEdge {
|
|
145
|
+
id: string;
|
|
146
|
+
source: string;
|
|
147
|
+
target: string;
|
|
148
|
+
relation: string;
|
|
149
|
+
status: ClaimStatus;
|
|
150
|
+
confidence: number;
|
|
151
|
+
provenance: string[];
|
|
152
|
+
}
|
|
153
|
+
interface GraphPage {
|
|
154
|
+
id: string;
|
|
155
|
+
path: string;
|
|
156
|
+
title: string;
|
|
157
|
+
kind: PageKind;
|
|
158
|
+
sourceIds: string[];
|
|
159
|
+
nodeIds: string[];
|
|
160
|
+
freshness: Freshness;
|
|
161
|
+
confidence: number;
|
|
162
|
+
backlinks: string[];
|
|
163
|
+
sourceHashes: Record<string, string>;
|
|
164
|
+
}
|
|
165
|
+
interface GraphArtifact {
|
|
166
|
+
generatedAt: string;
|
|
167
|
+
nodes: GraphNode[];
|
|
168
|
+
edges: GraphEdge[];
|
|
169
|
+
sources: SourceManifest[];
|
|
170
|
+
pages: GraphPage[];
|
|
171
|
+
}
|
|
172
|
+
interface CompileResult {
|
|
173
|
+
graphPath: string;
|
|
174
|
+
pageCount: number;
|
|
175
|
+
changedPages: string[];
|
|
176
|
+
sourceCount: number;
|
|
177
|
+
}
|
|
178
|
+
interface SearchResult {
|
|
179
|
+
pageId: string;
|
|
180
|
+
path: string;
|
|
181
|
+
title: string;
|
|
182
|
+
snippet: string;
|
|
183
|
+
rank: number;
|
|
184
|
+
}
|
|
185
|
+
interface QueryResult {
|
|
186
|
+
answer: string;
|
|
187
|
+
savedTo?: string;
|
|
188
|
+
citations: string[];
|
|
189
|
+
}
|
|
190
|
+
interface LintFinding {
|
|
191
|
+
severity: "error" | "warning" | "info";
|
|
192
|
+
code: string;
|
|
193
|
+
message: string;
|
|
194
|
+
pagePath?: string;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
declare function defaultVaultConfig(): VaultConfig;
|
|
198
|
+
declare function resolvePaths(rootDir: string, config?: VaultConfig, configPath?: string): ResolvedPaths;
|
|
199
|
+
declare function loadVaultConfig(rootDir: string): Promise<{
|
|
200
|
+
config: VaultConfig;
|
|
201
|
+
paths: ResolvedPaths;
|
|
202
|
+
}>;
|
|
203
|
+
declare function initWorkspace(rootDir: string): Promise<{
|
|
204
|
+
config: VaultConfig;
|
|
205
|
+
paths: ResolvedPaths;
|
|
206
|
+
}>;
|
|
207
|
+
|
|
208
|
+
declare function ingestInput(rootDir: string, input: string): Promise<SourceManifest>;
|
|
209
|
+
declare function listManifests(rootDir: string): Promise<SourceManifest[]>;
|
|
210
|
+
declare function readExtractedText(rootDir: string, manifest: SourceManifest): Promise<string | undefined>;
|
|
211
|
+
|
|
212
|
+
declare function initVault(rootDir: string): Promise<void>;
|
|
213
|
+
declare function compileVault(rootDir: string): Promise<CompileResult>;
|
|
214
|
+
declare function queryVault(rootDir: string, question: string, save?: boolean): Promise<QueryResult>;
|
|
215
|
+
declare function lintVault(rootDir: string): Promise<LintFinding[]>;
|
|
216
|
+
declare function bootstrapDemo(rootDir: string, input?: string): Promise<{
|
|
217
|
+
manifestId?: string;
|
|
218
|
+
compile?: CompileResult;
|
|
219
|
+
}>;
|
|
220
|
+
|
|
221
|
+
declare function installAgent(rootDir: string, agent: "codex" | "claude" | "cursor"): Promise<string>;
|
|
222
|
+
declare function installConfiguredAgents(rootDir: string): Promise<string[]>;
|
|
223
|
+
|
|
224
|
+
declare function startGraphServer(rootDir: string, port?: number): Promise<{
|
|
225
|
+
port: number;
|
|
226
|
+
close: () => Promise<void>;
|
|
227
|
+
}>;
|
|
228
|
+
|
|
229
|
+
declare function createProvider(id: string, config: ProviderConfig, rootDir: string): Promise<ProviderAdapter>;
|
|
230
|
+
declare function getProviderForTask(rootDir: string, task: keyof Awaited<ReturnType<typeof loadVaultConfig>>["config"]["tasks"]): Promise<ProviderAdapter>;
|
|
231
|
+
declare function assertProviderCapability(provider: ProviderAdapter, capability: ProviderCapability): void;
|
|
232
|
+
|
|
233
|
+
export { type AnalyzedTerm, type ClaimStatus, type CompileResult, type Freshness, type GenerationAttachment, type GenerationRequest, type GenerationResponse, type GraphArtifact, type GraphEdge, type GraphNode, type GraphPage, type LintFinding, type PageKind, type Polarity, type ProviderAdapter, type ProviderCapability, type ProviderConfig, type ProviderType, type QueryResult, type ResolvedPaths, type SearchResult, type SourceAnalysis, type SourceClaim, type SourceManifest, type VaultConfig, assertProviderCapability, bootstrapDemo, compileVault, createProvider, defaultVaultConfig, getProviderForTask, ingestInput, initVault, initWorkspace, installAgent, installConfiguredAgents, lintVault, listManifests, loadVaultConfig, providerCapabilitySchema, providerTypeSchema, queryVault, readExtractedText, resolvePaths, startGraphServer };
|