@swarmvaultai/engine 0.1.4 → 0.1.5
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 -6
- package/dist/index.d.ts +104 -21
- package/dist/index.js +2003 -973
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -21,12 +21,15 @@ If you only want to use SwarmVault as a tool, install `@swarmvaultai/cli` instea
|
|
|
21
21
|
import {
|
|
22
22
|
compileVault,
|
|
23
23
|
createMcpServer,
|
|
24
|
+
createWebSearchAdapter,
|
|
24
25
|
defaultVaultConfig,
|
|
25
26
|
defaultVaultSchema,
|
|
27
|
+
exploreVault,
|
|
26
28
|
importInbox,
|
|
27
29
|
ingestInput,
|
|
28
30
|
initVault,
|
|
29
31
|
installAgent,
|
|
32
|
+
getWebSearchAdapterForTask,
|
|
30
33
|
lintVault,
|
|
31
34
|
loadVaultConfig,
|
|
32
35
|
loadVaultSchema,
|
|
@@ -53,8 +56,11 @@ console.log(schema.path);
|
|
|
53
56
|
await importInbox(rootDir);
|
|
54
57
|
await compileVault(rootDir);
|
|
55
58
|
|
|
56
|
-
const
|
|
57
|
-
console.log(
|
|
59
|
+
const saved = await queryVault(rootDir, "What changed most recently?", true);
|
|
60
|
+
console.log(saved.savedTo);
|
|
61
|
+
|
|
62
|
+
const exploration = await exploreVault(rootDir, "What should I investigate next?", 3);
|
|
63
|
+
console.log(exploration.hubPath);
|
|
58
64
|
|
|
59
65
|
const watcher = await watchVault(rootDir, { lint: true });
|
|
60
66
|
```
|
|
@@ -63,7 +69,7 @@ const watcher = await watchVault(rootDir, { lint: true });
|
|
|
63
69
|
|
|
64
70
|
Each workspace carries a root markdown file named `swarmvault.schema.md`.
|
|
65
71
|
|
|
66
|
-
The engine treats that file as vault-specific operating guidance for compile and query work.
|
|
72
|
+
The engine treats that file as vault-specific operating guidance for compile and query work. Currently:
|
|
67
73
|
|
|
68
74
|
- `initVault()` creates the default schema file
|
|
69
75
|
- `loadVaultSchema()` resolves the canonical file and legacy `schema.md` fallback
|
|
@@ -105,13 +111,19 @@ This matters because many "OpenAI-compatible" backends only implement part of th
|
|
|
105
111
|
### Compile + Query
|
|
106
112
|
|
|
107
113
|
- `compileVault(rootDir)` writes wiki pages, graph data, and search state using the vault schema as guidance
|
|
108
|
-
- `queryVault(rootDir, question, save)` answers against the compiled vault using the same schema layer
|
|
114
|
+
- `queryVault(rootDir, question, save)` answers against the compiled vault using the same schema layer and can persist a first-class output page
|
|
115
|
+
- `exploreVault(rootDir, question, steps)` runs a save-first multi-step exploration loop and writes a hub page plus step outputs
|
|
109
116
|
- `searchVault(rootDir, query, limit)` searches compiled pages directly
|
|
110
117
|
|
|
111
118
|
### Automation
|
|
112
119
|
|
|
113
120
|
- `watchVault(rootDir, options)` watches the inbox and appends run records to `state/jobs.ndjson`
|
|
114
|
-
- `lintVault(rootDir)` runs
|
|
121
|
+
- `lintVault(rootDir, options)` runs structural lint, optional deep lint, and optional web-augmented evidence gathering
|
|
122
|
+
|
|
123
|
+
### Web Search Adapters
|
|
124
|
+
|
|
125
|
+
- `createWebSearchAdapter(rootDir, id, config)` constructs a normalized web search adapter
|
|
126
|
+
- `getWebSearchAdapterForTask(rootDir, "deepLintProvider")` resolves the configured adapter for `lint --deep --web`
|
|
115
127
|
|
|
116
128
|
### MCP
|
|
117
129
|
|
|
@@ -128,7 +140,7 @@ Running the engine produces a local workspace with these main areas:
|
|
|
128
140
|
- `inbox/`: capture staging area for markdown bundles and imported files
|
|
129
141
|
- `raw/sources/`: immutable source copies
|
|
130
142
|
- `raw/assets/`: copied attachments referenced by ingested markdown bundles
|
|
131
|
-
- `wiki/`: generated markdown pages and
|
|
143
|
+
- `wiki/`: generated markdown pages, saved query outputs, and exploration hub pages
|
|
132
144
|
- `state/manifests/`: source manifests
|
|
133
145
|
- `state/extracts/`: extracted text
|
|
134
146
|
- `state/analyses/`: model analysis output
|
|
@@ -136,6 +148,8 @@ Running the engine produces a local workspace with these main areas:
|
|
|
136
148
|
- `state/search.sqlite`: full-text index
|
|
137
149
|
- `state/jobs.ndjson`: watch-mode automation logs
|
|
138
150
|
|
|
151
|
+
Saved outputs are indexed immediately into the graph page registry and search index, then linked back into compiled source, concept, and entity pages during later compile runs.
|
|
152
|
+
|
|
139
153
|
## Notes
|
|
140
154
|
|
|
141
155
|
- The engine expects Node `>=24`
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,9 @@ import { z } from 'zod';
|
|
|
2
2
|
import { Readable, Writable } from 'node:stream';
|
|
3
3
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
4
4
|
|
|
5
|
+
declare function installAgent(rootDir: string, agent: "codex" | "claude" | "cursor"): Promise<string>;
|
|
6
|
+
declare function installConfiguredAgents(rootDir: string): Promise<string[]>;
|
|
7
|
+
|
|
5
8
|
declare const providerCapabilitySchema: z.ZodEnum<{
|
|
6
9
|
responses: "responses";
|
|
7
10
|
chat: "chat";
|
|
@@ -27,6 +30,12 @@ type PageKind = "index" | "source" | "concept" | "entity" | "output";
|
|
|
27
30
|
type Freshness = "fresh" | "stale";
|
|
28
31
|
type ClaimStatus = "extracted" | "inferred" | "conflicted" | "stale";
|
|
29
32
|
type Polarity = "positive" | "negative" | "neutral";
|
|
33
|
+
type OutputOrigin = "query" | "explore";
|
|
34
|
+
declare const webSearchProviderTypeSchema: z.ZodEnum<{
|
|
35
|
+
custom: "custom";
|
|
36
|
+
"http-json": "http-json";
|
|
37
|
+
}>;
|
|
38
|
+
type WebSearchProviderType = z.infer<typeof webSearchProviderTypeSchema>;
|
|
30
39
|
interface GenerationAttachment {
|
|
31
40
|
mimeType: string;
|
|
32
41
|
filePath: string;
|
|
@@ -62,6 +71,32 @@ interface ProviderConfig {
|
|
|
62
71
|
capabilities?: ProviderCapability[];
|
|
63
72
|
apiStyle?: "responses" | "chat";
|
|
64
73
|
}
|
|
74
|
+
interface WebSearchProviderConfig {
|
|
75
|
+
type: WebSearchProviderType;
|
|
76
|
+
endpoint?: string;
|
|
77
|
+
method?: "GET" | "POST";
|
|
78
|
+
apiKeyEnv?: string;
|
|
79
|
+
apiKeyHeader?: string;
|
|
80
|
+
apiKeyPrefix?: string;
|
|
81
|
+
headers?: Record<string, string>;
|
|
82
|
+
queryParam?: string;
|
|
83
|
+
limitParam?: string;
|
|
84
|
+
resultsPath?: string;
|
|
85
|
+
titleField?: string;
|
|
86
|
+
urlField?: string;
|
|
87
|
+
snippetField?: string;
|
|
88
|
+
module?: string;
|
|
89
|
+
}
|
|
90
|
+
interface WebSearchResult {
|
|
91
|
+
title: string;
|
|
92
|
+
url: string;
|
|
93
|
+
snippet: string;
|
|
94
|
+
}
|
|
95
|
+
interface WebSearchAdapter {
|
|
96
|
+
readonly id: string;
|
|
97
|
+
readonly type: WebSearchProviderType;
|
|
98
|
+
search(query: string, limit?: number): Promise<WebSearchResult[]>;
|
|
99
|
+
}
|
|
65
100
|
interface VaultConfig {
|
|
66
101
|
workspace: {
|
|
67
102
|
rawDir: string;
|
|
@@ -81,6 +116,12 @@ interface VaultConfig {
|
|
|
81
116
|
port: number;
|
|
82
117
|
};
|
|
83
118
|
agents: Array<"codex" | "claude" | "cursor">;
|
|
119
|
+
webSearch?: {
|
|
120
|
+
providers: Record<string, WebSearchProviderConfig>;
|
|
121
|
+
tasks: {
|
|
122
|
+
deepLintProvider: string;
|
|
123
|
+
};
|
|
124
|
+
};
|
|
84
125
|
}
|
|
85
126
|
interface ResolvedPaths {
|
|
86
127
|
rootDir: string;
|
|
@@ -177,6 +218,11 @@ interface GraphPage {
|
|
|
177
218
|
backlinks: string[];
|
|
178
219
|
schemaHash: string;
|
|
179
220
|
sourceHashes: Record<string, string>;
|
|
221
|
+
relatedPageIds: string[];
|
|
222
|
+
relatedNodeIds: string[];
|
|
223
|
+
relatedSourceIds: string[];
|
|
224
|
+
origin?: OutputOrigin;
|
|
225
|
+
question?: string;
|
|
180
226
|
}
|
|
181
227
|
interface GraphArtifact {
|
|
182
228
|
generatedAt: string;
|
|
@@ -201,13 +247,21 @@ interface SearchResult {
|
|
|
201
247
|
interface QueryResult {
|
|
202
248
|
answer: string;
|
|
203
249
|
savedTo?: string;
|
|
250
|
+
savedPageId?: string;
|
|
204
251
|
citations: string[];
|
|
252
|
+
relatedPageIds: string[];
|
|
253
|
+
relatedNodeIds: string[];
|
|
254
|
+
relatedSourceIds: string[];
|
|
205
255
|
}
|
|
206
256
|
interface LintFinding {
|
|
207
257
|
severity: "error" | "warning" | "info";
|
|
208
258
|
code: string;
|
|
209
259
|
message: string;
|
|
210
260
|
pagePath?: string;
|
|
261
|
+
relatedSourceIds?: string[];
|
|
262
|
+
relatedPageIds?: string[];
|
|
263
|
+
suggestedQuery?: string;
|
|
264
|
+
evidence?: WebSearchResult[];
|
|
211
265
|
}
|
|
212
266
|
interface InboxImportSkip {
|
|
213
267
|
path: string;
|
|
@@ -241,6 +295,34 @@ interface WatchRunRecord {
|
|
|
241
295
|
interface WatchController {
|
|
242
296
|
close(): Promise<void>;
|
|
243
297
|
}
|
|
298
|
+
interface CompileState {
|
|
299
|
+
generatedAt: string;
|
|
300
|
+
schemaHash: string;
|
|
301
|
+
analyses: Record<string, string>;
|
|
302
|
+
sourceHashes: Record<string, string>;
|
|
303
|
+
outputHashes: Record<string, string>;
|
|
304
|
+
}
|
|
305
|
+
interface LintOptions {
|
|
306
|
+
deep?: boolean;
|
|
307
|
+
web?: boolean;
|
|
308
|
+
}
|
|
309
|
+
interface ExploreStepResult {
|
|
310
|
+
step: number;
|
|
311
|
+
question: string;
|
|
312
|
+
answer: string;
|
|
313
|
+
savedTo: string;
|
|
314
|
+
savedPageId: string;
|
|
315
|
+
citations: string[];
|
|
316
|
+
followUpQuestions: string[];
|
|
317
|
+
}
|
|
318
|
+
interface ExploreResult {
|
|
319
|
+
rootQuestion: string;
|
|
320
|
+
hubPath: string;
|
|
321
|
+
hubPageId: string;
|
|
322
|
+
stepCount: number;
|
|
323
|
+
steps: ExploreStepResult[];
|
|
324
|
+
suggestedQuestions: string[];
|
|
325
|
+
}
|
|
244
326
|
|
|
245
327
|
declare function defaultVaultConfig(): VaultConfig;
|
|
246
328
|
declare function defaultVaultSchema(): string;
|
|
@@ -259,9 +341,27 @@ declare function importInbox(rootDir: string, inputDir?: string): Promise<InboxI
|
|
|
259
341
|
declare function listManifests(rootDir: string): Promise<SourceManifest[]>;
|
|
260
342
|
declare function readExtractedText(rootDir: string, manifest: SourceManifest): Promise<string | undefined>;
|
|
261
343
|
|
|
344
|
+
declare function createMcpServer(rootDir: string): Promise<McpServer>;
|
|
345
|
+
declare function startMcpServer(rootDir: string, stdin?: Readable, stdout?: Writable): Promise<{
|
|
346
|
+
close: () => Promise<void>;
|
|
347
|
+
}>;
|
|
348
|
+
|
|
349
|
+
declare function createProvider(id: string, config: ProviderConfig, rootDir: string): Promise<ProviderAdapter>;
|
|
350
|
+
declare function getProviderForTask(rootDir: string, task: keyof Awaited<ReturnType<typeof loadVaultConfig>>["config"]["tasks"]): Promise<ProviderAdapter>;
|
|
351
|
+
declare function assertProviderCapability(provider: ProviderAdapter, capability: ProviderCapability): void;
|
|
352
|
+
|
|
353
|
+
interface VaultSchema {
|
|
354
|
+
path: string;
|
|
355
|
+
content: string;
|
|
356
|
+
hash: string;
|
|
357
|
+
isLegacyPath: boolean;
|
|
358
|
+
}
|
|
359
|
+
declare function loadVaultSchema(rootDir: string): Promise<VaultSchema>;
|
|
360
|
+
|
|
262
361
|
declare function initVault(rootDir: string): Promise<void>;
|
|
263
362
|
declare function compileVault(rootDir: string): Promise<CompileResult>;
|
|
264
363
|
declare function queryVault(rootDir: string, question: string, save?: boolean): Promise<QueryResult>;
|
|
364
|
+
declare function exploreVault(rootDir: string, question: string, steps?: number): Promise<ExploreResult>;
|
|
265
365
|
declare function searchVault(rootDir: string, query: string, limit?: number): Promise<SearchResult[]>;
|
|
266
366
|
declare function listPages(rootDir: string): Promise<GraphPage[]>;
|
|
267
367
|
declare function readPage(rootDir: string, relativePath: string): Promise<{
|
|
@@ -282,37 +382,20 @@ declare function getWorkspaceInfo(rootDir: string): Promise<{
|
|
|
282
382
|
sourceCount: number;
|
|
283
383
|
pageCount: number;
|
|
284
384
|
}>;
|
|
285
|
-
declare function lintVault(rootDir: string): Promise<LintFinding[]>;
|
|
385
|
+
declare function lintVault(rootDir: string, options?: LintOptions): Promise<LintFinding[]>;
|
|
286
386
|
declare function bootstrapDemo(rootDir: string, input?: string): Promise<{
|
|
287
387
|
manifestId?: string;
|
|
288
388
|
compile?: CompileResult;
|
|
289
389
|
}>;
|
|
290
390
|
|
|
291
|
-
declare function installAgent(rootDir: string, agent: "codex" | "claude" | "cursor"): Promise<string>;
|
|
292
|
-
declare function installConfiguredAgents(rootDir: string): Promise<string[]>;
|
|
293
|
-
|
|
294
|
-
interface VaultSchema {
|
|
295
|
-
path: string;
|
|
296
|
-
content: string;
|
|
297
|
-
hash: string;
|
|
298
|
-
isLegacyPath: boolean;
|
|
299
|
-
}
|
|
300
|
-
declare function loadVaultSchema(rootDir: string): Promise<VaultSchema>;
|
|
301
|
-
|
|
302
391
|
declare function startGraphServer(rootDir: string, port?: number): Promise<{
|
|
303
392
|
port: number;
|
|
304
393
|
close: () => Promise<void>;
|
|
305
394
|
}>;
|
|
306
395
|
|
|
307
|
-
declare function createMcpServer(rootDir: string): Promise<McpServer>;
|
|
308
|
-
declare function startMcpServer(rootDir: string, stdin?: Readable, stdout?: Writable): Promise<{
|
|
309
|
-
close: () => Promise<void>;
|
|
310
|
-
}>;
|
|
311
|
-
|
|
312
396
|
declare function watchVault(rootDir: string, options?: WatchOptions): Promise<WatchController>;
|
|
313
397
|
|
|
314
|
-
declare function
|
|
315
|
-
declare function
|
|
316
|
-
declare function assertProviderCapability(provider: ProviderAdapter, capability: ProviderCapability): void;
|
|
398
|
+
declare function createWebSearchAdapter(id: string, config: WebSearchProviderConfig, rootDir: string): Promise<WebSearchAdapter>;
|
|
399
|
+
declare function getWebSearchAdapterForTask(rootDir: string, task: "deepLintProvider"): Promise<WebSearchAdapter>;
|
|
317
400
|
|
|
318
|
-
export { type AnalyzedTerm, type ClaimStatus, type CompileResult, type Freshness, type GenerationAttachment, type GenerationRequest, type GenerationResponse, type GraphArtifact, type GraphEdge, type GraphNode, type GraphPage, type InboxImportResult, type InboxImportSkip, type LintFinding, type PageKind, type Polarity, type ProviderAdapter, type ProviderCapability, type ProviderConfig, type ProviderType, type QueryResult, type ResolvedPaths, type SearchResult, type SourceAnalysis, type SourceAttachment, type SourceClaim, type SourceManifest, type VaultConfig, type WatchController, type WatchOptions, type WatchRunRecord, assertProviderCapability, bootstrapDemo, compileVault, createMcpServer, createProvider, defaultVaultConfig, defaultVaultSchema, getProviderForTask, getWorkspaceInfo, importInbox, ingestInput, initVault, initWorkspace, installAgent, installConfiguredAgents, lintVault, listManifests, listPages, loadVaultConfig, loadVaultSchema, providerCapabilitySchema, providerTypeSchema, queryVault, readExtractedText, readPage, resolvePaths, searchVault, startGraphServer, startMcpServer, watchVault };
|
|
401
|
+
export { type AnalyzedTerm, type ClaimStatus, type CompileResult, type CompileState, type ExploreResult, type ExploreStepResult, type Freshness, type GenerationAttachment, type GenerationRequest, type GenerationResponse, type GraphArtifact, type GraphEdge, type GraphNode, type GraphPage, type InboxImportResult, type InboxImportSkip, type LintFinding, type LintOptions, type OutputOrigin, type PageKind, type Polarity, type ProviderAdapter, type ProviderCapability, type ProviderConfig, type ProviderType, type QueryResult, type ResolvedPaths, type SearchResult, type SourceAnalysis, type SourceAttachment, type SourceClaim, type SourceManifest, type VaultConfig, type WatchController, type WatchOptions, type WatchRunRecord, type WebSearchAdapter, type WebSearchProviderConfig, type WebSearchProviderType, type WebSearchResult, assertProviderCapability, bootstrapDemo, compileVault, createMcpServer, createProvider, createWebSearchAdapter, defaultVaultConfig, defaultVaultSchema, exploreVault, getProviderForTask, getWebSearchAdapterForTask, getWorkspaceInfo, importInbox, ingestInput, initVault, initWorkspace, installAgent, installConfiguredAgents, lintVault, listManifests, listPages, loadVaultConfig, loadVaultSchema, providerCapabilitySchema, providerTypeSchema, queryVault, readExtractedText, readPage, resolvePaths, searchVault, startGraphServer, startMcpServer, watchVault, webSearchProviderTypeSchema };
|