vektor-slipstream 1.4.4 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/README.md +67 -306
  2. package/package.json +14 -146
  3. package/CHANGELOG.md +0 -139
  4. package/LICENSE +0 -33
  5. package/TENETS.md +0 -189
  6. package/audn-log.js +0 -143
  7. package/axon.js +0 -389
  8. package/boot-patch.js +0 -33
  9. package/boot-screen.html +0 -210
  10. package/briefing.js +0 -150
  11. package/cerebellum.js +0 -439
  12. package/cloak-behaviour.js +0 -596
  13. package/cloak-captcha.js +0 -541
  14. package/cloak-core.js +0 -499
  15. package/cloak-identity.js +0 -484
  16. package/cloak-index.js +0 -261
  17. package/cloak-llms.js +0 -163
  18. package/cloak-pattern-store.js +0 -471
  19. package/cloak-recorder-auto.js +0 -297
  20. package/cloak-recorder-snippet.js +0 -119
  21. package/cloak-turbo-quant.js +0 -357
  22. package/cloak-warmup.js +0 -240
  23. package/cortex.js +0 -221
  24. package/detect-hardware.js +0 -181
  25. package/entity-resolver.js +0 -298
  26. package/errors.js +0 -66
  27. package/examples/example-claude-mcp.js +0 -220
  28. package/examples/example-langchain-researcher.js +0 -82
  29. package/examples/example-openai-assistant.js +0 -84
  30. package/examples/examples-README.md +0 -161
  31. package/export-import.js +0 -221
  32. package/forget.js +0 -148
  33. package/inspect.js +0 -199
  34. package/mistral/README-mistral.md +0 -123
  35. package/mistral/mistral-bridge.js +0 -218
  36. package/mistral/mistral-setup.js +0 -220
  37. package/mistral/vektor-tool-manifest.json +0 -41
  38. package/models/model_quantized.onnx +0 -0
  39. package/models/vocab.json +0 -1
  40. package/namespace.js +0 -186
  41. package/pin.js +0 -91
  42. package/slipstream-core-extended.js +0 -134
  43. package/slipstream-core.js +0 -1
  44. package/slipstream-db.js +0 -140
  45. package/slipstream-embedder.js +0 -338
  46. package/sovereign.js +0 -142
  47. package/token.js +0 -322
  48. package/types/index.d.ts +0 -269
  49. package/vektor-banner-loader.js +0 -109
  50. package/vektor-cli.js +0 -259
  51. package/vektor-licence-prompt.js +0 -128
  52. package/vektor-licence.js +0 -192
  53. package/vektor-setup.js +0 -270
  54. package/vektor-slipstream.dxt +0 -0
  55. package/vektor-tui.js +0 -373
  56. package/visualize.js +0 -235
package/token.js DELETED
@@ -1,322 +0,0 @@
1
- /**
2
- * cloak_token.js
3
- * Token ledger — aggregates context budget consumption per session.
4
- * Writes ONE summary node per session end (via cloak_axon integration).
5
- * Detects waste patterns: repeated reads, oversized context injections.
6
- *
7
- * Design principles:
8
- * - Aggregated, not per-operation. Never writes on every read/write.
9
- * - Session total written ONCE at Stop (passed to cloak_axon's tokenCount).
10
- * - Waste patterns flagged at session end, not in real time.
11
- * - Uses character-to-token ratios (OpenWolf method, ±15% accurate).
12
- *
13
- * Architecture: CLOAK layer → Vektor temporal graph
14
- * Research: OpenWolf token-ledger pattern
15
- */
16
-
17
- 'use strict';
18
-
19
- // ---------------------------------------------------------------------------
20
- // Token estimation ratios (same as cortex.js for consistency)
21
- // ---------------------------------------------------------------------------
22
- const TOKEN_RATIOS = {
23
- code : 3.5,
24
- prose: 4.0,
25
- mixed: 3.75,
26
- };
27
-
28
- const CODE_EXTS = new Set(['.js','.ts','.jsx','.tsx','.py','.go','.rs','.rb','.java','.c','.cpp']);
29
-
30
- function estimateTokens(content, filePath = '') {
31
- if (!content) return 0;
32
- const ext = (filePath.match(/\.[^.]+$/) || [''])[0].toLowerCase();
33
- const bytes = Buffer.byteLength(String(content), 'utf8');
34
- if (CODE_EXTS.has(ext)) return Math.round(bytes / TOKEN_RATIOS.code);
35
- return Math.round(bytes / TOKEN_RATIOS.mixed);
36
- }
37
-
38
- // ---------------------------------------------------------------------------
39
- // In-RAM session ledger
40
- // ---------------------------------------------------------------------------
41
- const _ledger = {
42
- sessionId : null,
43
- reads : [], // { file, tokens, ts }
44
- writes : [], // { file, tokens, ts }
45
- wasteEvents : [], // { type, description, tokens_wasted }
46
- totalReadTokens : 0,
47
- totalWriteTokens: 0,
48
- };
49
-
50
- function _resetLedger() {
51
- _ledger.sessionId = null;
52
- _ledger.reads = [];
53
- _ledger.writes = [];
54
- _ledger.wasteEvents = [];
55
- _ledger.totalReadTokens = 0;
56
- _ledger.totalWriteTokens = 0;
57
- }
58
-
59
- // ---------------------------------------------------------------------------
60
- // Waste detection thresholds
61
- // ---------------------------------------------------------------------------
62
- const WASTE_RULES = {
63
- REPEATED_READ_THRESHOLD : 2, // same file read > 2x = waste
64
- LARGE_READ_THRESHOLD : 2000, // reading >2000 tokens when anatomy would suffice
65
- REPEATED_READ_PENALTY : 0.8, // assume 80% of repeated read tokens are wasted
66
- };
67
-
68
- // ---------------------------------------------------------------------------
69
- // Session lifecycle
70
- // ---------------------------------------------------------------------------
71
-
72
- /**
73
- * startSession(sessionId)
74
- * Called from cloak_axon onSessionStart. Resets ledger for new session.
75
- */
76
- function startSession(sessionId) {
77
- _resetLedger();
78
- _ledger.sessionId = sessionId;
79
- }
80
-
81
- // ---------------------------------------------------------------------------
82
- // Event tracking — called from hook integration
83
- // ---------------------------------------------------------------------------
84
-
85
- /**
86
- * trackRead({ filePath, content })
87
- * Record a file read. Detects repeated reads and large reads.
88
- */
89
- function trackRead({ filePath, content } = {}) {
90
- if (!_ledger.sessionId) return;
91
-
92
- const tokens = estimateTokens(content, filePath);
93
- const file = filePath || 'unknown';
94
- const ts = Date.now();
95
-
96
- _ledger.reads.push({ file, tokens, ts });
97
- _ledger.totalReadTokens += tokens;
98
-
99
- // Detect repeated reads of same file this session
100
- const readCount = _ledger.reads.filter(r => r.file === file).length;
101
- if (readCount > WASTE_RULES.REPEATED_READ_THRESHOLD) {
102
- const wastedTokens = Math.round(tokens * WASTE_RULES.REPEATED_READ_PENALTY);
103
- _ledger.wasteEvents.push({
104
- type : 'repeated_read',
105
- description : `${file} read ${readCount}x this session`,
106
- tokens_wasted : wastedTokens,
107
- recommendation : 'Use cloak_cortex anatomy to check file before re-reading',
108
- });
109
- }
110
-
111
- // Detect large reads that cortex anatomy could have avoided
112
- if (tokens > WASTE_RULES.LARGE_READ_THRESHOLD) {
113
- _ledger.wasteEvents.push({
114
- type : 'large_read',
115
- description : `${file} read at ~${tokens} tokens`,
116
- tokens_wasted : Math.round(tokens * 0.5), // assume 50% avoidable
117
- recommendation : 'Check cloak_cortex anatomy description first',
118
- });
119
- }
120
- }
121
-
122
- /**
123
- * trackWrite({ filePath, content })
124
- * Record a file write.
125
- */
126
- function trackWrite({ filePath, content } = {}) {
127
- if (!_ledger.sessionId) return;
128
-
129
- const tokens = estimateTokens(content, filePath);
130
- _ledger.writes.push({ file: filePath || 'unknown', tokens, ts: Date.now() });
131
- _ledger.totalWriteTokens += tokens;
132
- }
133
-
134
- // ---------------------------------------------------------------------------
135
- // Session summary — called at session end, returns total for cloak_axon
136
- // ---------------------------------------------------------------------------
137
-
138
- /**
139
- * getSessionSummary()
140
- * Returns aggregated stats for the current session.
141
- * This is passed as tokenCount to cloak_axon.onSessionStop().
142
- */
143
- function getSessionSummary() {
144
- if (!_ledger.sessionId) return null;
145
-
146
- const totalTokens = _ledger.totalReadTokens + _ledger.totalWriteTokens;
147
- const totalWasted = _ledger.wasteEvents.reduce((sum, e) => sum + (e.tokens_wasted || 0), 0);
148
- const wasteRate = totalTokens > 0 ? Math.round((totalWasted / totalTokens) * 100) : 0;
149
-
150
- // Top files by token consumption
151
- const fileTotals = {};
152
- [..._ledger.reads, ..._ledger.writes].forEach(({ file, tokens }) => {
153
- fileTotals[file] = (fileTotals[file] || 0) + tokens;
154
- });
155
- const topFiles = Object.entries(fileTotals)
156
- .sort((a, b) => b[1] - a[1])
157
- .slice(0, 5)
158
- .map(([file, tokens]) => `${file}:~${tokens}t`);
159
-
160
- return {
161
- sessionId : _ledger.sessionId,
162
- totalTokens,
163
- readTokens : _ledger.totalReadTokens,
164
- writeTokens : _ledger.totalWriteTokens,
165
- wastedTokens : totalWasted,
166
- wasteRate : `${wasteRate}%`,
167
- wasteEvents : _ledger.wasteEvents.length,
168
- topFiles,
169
- readCount : _ledger.reads.length,
170
- writeCount : _ledger.writes.length,
171
- uniqueFilesRead : new Set(_ledger.reads.map(r => r.file)).size,
172
- uniqueFilesWritten: new Set(_ledger.writes.map(w => w.file)).size,
173
- };
174
- }
175
-
176
- // ---------------------------------------------------------------------------
177
- // Temporal graph node builder — ONE write per session
178
- // This is called by cloak_axon at session stop, not by token.js directly.
179
- // ---------------------------------------------------------------------------
180
-
181
- /**
182
- * buildTokenNode(summary)
183
- * Builds the Vektor memory string for the temporal graph.
184
- * cloak_axon calls this and includes it in the MemCell, OR it can be
185
- * written as a standalone temporal node. Either way: one write per session.
186
- */
187
- function buildTokenNode(summary) {
188
- if (!summary) return null;
189
-
190
- return [
191
- `[CLOAK_TOKEN_LEDGER]`,
192
- `session:${summary.sessionId}`,
193
- `total_tokens:~${summary.totalTokens}`,
194
- `read_tokens:~${summary.readTokens}`,
195
- `write_tokens:~${summary.writeTokens}`,
196
- `wasted_tokens:~${summary.wastedTokens}`,
197
- `waste_rate:${summary.wasteRate}`,
198
- `waste_events:${summary.wasteEvents}`,
199
- `top_files:${summary.topFiles.join(',')}`,
200
- `logged_at:${new Date().toISOString()}`,
201
- ].join(' | ');
202
- }
203
-
204
- // ---------------------------------------------------------------------------
205
- // Lifetime waste report — queries Vektor for historical patterns
206
- // ---------------------------------------------------------------------------
207
-
208
- /**
209
- * getWasteReport({ memory, days })
210
- * Queries Vektor temporal graph for token waste patterns over N days.
211
- * Returns actionable recommendations. Read-only — no writes.
212
- *
213
- * @param {object} memory - Vektor memory instance
214
- * @param {number} days - Lookback window (default: 30)
215
- */
216
- async function getWasteReport({ memory, days = 30 } = {}) {
217
- if (!memory) throw new Error('cloak_token: memory instance is required');
218
-
219
- let nodes;
220
- try {
221
- nodes = await memory.recall(
222
- `[CLOAK_TOKEN_LEDGER]`,
223
- days
224
- );
225
- } catch (err) {
226
- return { error: err.message, sessions: [] };
227
- }
228
-
229
- if (!nodes || nodes.length === 0) {
230
- return { sessions: [], totalTokens: 0, totalWasted: 0, recommendations: [] };
231
- }
232
-
233
- // Parse historical nodes
234
- const sessions = nodes.map(n => {
235
- const parts = n.content.split(' | ');
236
- const get = key => {
237
- const p = parts.find(p => p.startsWith(`${key}:`));
238
- return p ? p.slice(key.length + 1) : null;
239
- };
240
- return {
241
- sessionId : get('session'),
242
- totalTokens : parseInt(get('total_tokens')?.replace('~','') || '0'),
243
- wastedTokens : parseInt(get('wasted_tokens')?.replace('~','') || '0'),
244
- wasteRate : get('waste_rate'),
245
- wasteEvents : parseInt(get('waste_events') || '0'),
246
- };
247
- });
248
-
249
- const totalTokens = sessions.reduce((s, n) => s + n.totalTokens, 0);
250
- const totalWasted = sessions.reduce((s, n) => s + n.wastedTokens, 0);
251
- const avgWasteRate = totalTokens > 0 ? Math.round((totalWasted / totalTokens) * 100) : 0;
252
-
253
- const recommendations = [];
254
- if (avgWasteRate > 30) {
255
- recommendations.push(`High waste rate (${avgWasteRate}%) — run cloak_cortex scan to refresh anatomy index`);
256
- }
257
- if (sessions.filter(s => s.wasteEvents > 3).length > 3) {
258
- recommendations.push('Repeated waste events — check most-read files and add to anatomy');
259
- }
260
-
261
- return {
262
- sessions : sessions.slice(0, 10),
263
- totalTokens,
264
- totalWasted,
265
- avgWasteRate : `${avgWasteRate}%`,
266
- recommendations,
267
- };
268
- }
269
-
270
- // ---------------------------------------------------------------------------
271
- // Claude Code hook integration
272
- // ---------------------------------------------------------------------------
273
-
274
- /**
275
- * handleHookPayload({ payload, sessionId })
276
- * Routes Claude Code hook events to trackRead / trackWrite.
277
- * Called from the main MCP server hook handler.
278
- */
279
- function handleHookPayload({ payload, sessionId } = {}) {
280
- if (!payload) return null;
281
-
282
- const hookName = payload?.hook_event_name || payload?.event;
283
- const tool = payload?.tool_name;
284
- const input = payload?.tool_input;
285
-
286
- // Start ledger if we receive a session ID and haven't started yet
287
- if (sessionId && !_ledger.sessionId) {
288
- startSession(sessionId);
289
- }
290
-
291
- switch (hookName) {
292
- case 'PostToolUse':
293
- case 'post_tool_use': {
294
- if (tool === 'Read') {
295
- trackRead({
296
- filePath: input?.file_path || input?.path,
297
- content : payload?.tool_response?.content || '',
298
- });
299
- } else if (['Write','Edit','MultiEdit'].includes(tool)) {
300
- trackWrite({
301
- filePath: input?.file_path || input?.path,
302
- content : input?.new_string || input?.content || '',
303
- });
304
- }
305
- break;
306
- }
307
- }
308
-
309
- return null; // token tracking never returns hook responses
310
- }
311
-
312
- module.exports = {
313
- startSession,
314
- trackRead,
315
- trackWrite,
316
- getSessionSummary,
317
- buildTokenNode,
318
- getWasteReport,
319
- handleHookPayload,
320
- estimateTokens,
321
- _ledger, // exported for testing and cloak_axon integration
322
- };
package/types/index.d.ts DELETED
@@ -1,269 +0,0 @@
1
- /**
2
- * vektor-slipstream — TypeScript declarations
3
- * v1.3.7
4
- */
5
-
6
- // ─── Core types ──────────────────────────────────────────────────────────────
7
-
8
- export interface VektorMemory {
9
- id: string;
10
- content: string;
11
- summary?: string;
12
- importance: number;
13
- score?: number;
14
- pinned: boolean;
15
- namespace: string;
16
- created_at: number;
17
- updated_at?: number;
18
- metadata?: Record<string, unknown>;
19
- }
20
-
21
- export interface GraphNode {
22
- id: string;
23
- content: string;
24
- summary?: string;
25
- importance: number;
26
- edges: GraphEdge[];
27
- }
28
-
29
- export interface GraphEdge {
30
- id: string;
31
- source_id: string;
32
- target_id: string;
33
- edge_type: 'semantic' | 'causal' | 'temporal' | 'entity';
34
- weight: number;
35
- }
36
-
37
- export interface DeltaResult {
38
- added: VektorMemory[];
39
- updated: VektorMemory[];
40
- deleted: string[];
41
- summary: string;
42
- }
43
-
44
- export interface BriefingResult {
45
- period: string;
46
- memoryCount: number;
47
- pinnedCount: number;
48
- pinned: VektorMemory[];
49
- memories: VektorMemory[];
50
- summary: string;
51
- }
52
-
53
- export interface InspectResult {
54
- agent_id: string;
55
- namespace: string;
56
- snapshot_at: string;
57
- counts: {
58
- memories: number;
59
- pinned: number;
60
- edges: number;
61
- namespaces: number;
62
- };
63
- graph: {
64
- edgeTypes: Array<{ edge_type: string; n: number }>;
65
- topNodes: Array<{
66
- id: string;
67
- preview: string;
68
- importance: number;
69
- connections: number;
70
- pinned: boolean;
71
- }>;
72
- };
73
- timeline: {
74
- oldest: { id: string; preview: string; at: number } | null;
75
- newest: { id: string; preview: string; at: number } | null;
76
- };
77
- recent: Array<{
78
- id: string;
79
- preview: string;
80
- importance: number;
81
- pinned: boolean;
82
- at: number;
83
- }>;
84
- importance: {
85
- avg: number | null;
86
- distribution: Array<{ bucket: number; n: number }>;
87
- };
88
- rem: {
89
- totalDreams: number;
90
- lastRun: number | null;
91
- compressionRatio: string | null;
92
- fragmentsProcessed: number;
93
- };
94
- audn: {
95
- added: number;
96
- updated: number;
97
- deleted: number;
98
- skipped: number;
99
- } | null;
100
- namespaces: Array<{ namespace: string; memories: number }>;
101
- }
102
-
103
- export interface AudnLogEntry {
104
- id: number;
105
- action: 'ADD' | 'UPDATE' | 'DELETE' | 'NO_OP';
106
- memory_id: string | null;
107
- content: string | null;
108
- reason: string | null;
109
- similarity: number | null;
110
- ran_at: number;
111
- }
112
-
113
- export interface ExportBundle {
114
- _vektor: {
115
- version: string;
116
- exported_at: string;
117
- agent_id: string;
118
- namespace: string;
119
- checksum: string;
120
- counts: { memories: number; edges: number; entities: number };
121
- };
122
- memories: VektorMemory[];
123
- edges: GraphEdge[];
124
- entities: EntityRecord[];
125
- entityMentions: Array<{ memory_id: string; entity_id: string }>;
126
- audnLog: AudnLogEntry[];
127
- }
128
-
129
- export interface EntityRecord {
130
- id: string;
131
- canonical: string;
132
- type: 'person' | 'org' | 'project' | 'concept' | 'unknown';
133
- confidence: number;
134
- aliases: string[];
135
- created_at: number;
136
- }
137
-
138
- export interface NamespaceRecord {
139
- namespace: string;
140
- memories: number;
141
- last_active: number;
142
- pinned: number;
143
- }
144
-
145
- // ─── Error types ─────────────────────────────────────────────────────────────
146
-
147
- export type VektorErrorCode =
148
- | 'ERR_LICENCE_MISSING'
149
- | 'ERR_LICENCE_INVALID'
150
- | 'ERR_LICENCE_EXPIRED'
151
- | 'ERR_MEMORY_NOT_FOUND'
152
- | 'ERR_MEMORY_WRITE_FAILED'
153
- | 'ERR_MEMORY_READ_FAILED'
154
- | 'ERR_MEMORY_DELETE_FAILED'
155
- | 'ERR_GRAPH_NODE_NOT_FOUND'
156
- | 'ERR_GRAPH_CORRUPTED'
157
- | 'ERR_PROVIDER_NOT_SUPPORTED'
158
- | 'ERR_EMBED_FAILED'
159
- | 'ERR_PROVIDER_RATE_LIMIT'
160
- | 'ERR_PROVIDER_AUTH'
161
- | 'ERR_AGENT_ID_MISSING'
162
- | 'ERR_DB_INIT_FAILED'
163
- | 'ERR_EXPORT_FAILED'
164
- | 'ERR_IMPORT_FAILED'
165
- | 'ERR_IMPORT_SCHEMA_MISMATCH'
166
- | 'ERR_NAMESPACE_INVALID';
167
-
168
- export declare class VektorError extends Error {
169
- code: VektorErrorCode;
170
- detail: unknown;
171
- }
172
-
173
- // ─── createMemory options ────────────────────────────────────────────────────
174
-
175
- export type Provider = 'gemini' | 'openai' | 'groq' | 'ollama';
176
-
177
- export interface CreateMemoryOptions {
178
- agentId: string;
179
- licenceKey?: string;
180
- provider: Provider;
181
- apiKey?: string | string[]; // string[] for Gemini key pooling
182
- dbPath?: string;
183
- namespace?: string; // default: 'default'
184
- ollamaModel?: string;
185
- ollamaHost?: string;
186
- }
187
-
188
- // ─── Memory instance ─────────────────────────────────────────────────────────
189
-
190
- export interface Memory {
191
- readonly agentId: string;
192
- readonly namespace: string;
193
-
194
- // Core
195
- remember(content: string, opts?: { metadata?: Record<string, unknown> }): Promise<{ id: string; action: 'ADD' | 'UPDATE' | 'NO_OP' }>;
196
- recall(query: string, k?: number): Promise<VektorMemory[]>;
197
- graph(query: string, opts?: { hops?: number; edgeTypes?: GraphEdge['edge_type'][] }): Promise<GraphNode[]>;
198
- delta(query: string, days?: number): Promise<DeltaResult>;
199
- briefing(opts?: {
200
- since?: string | number;
201
- limit?: number;
202
- minImportance?: number;
203
- raw?: boolean;
204
- }): Promise<BriefingResult>;
205
-
206
- // v1.3.7
207
- forget(id: string): Promise<{ deleted: boolean; edgesRemoved: number }>;
208
- forgetWhere(query: string, opts?: {
209
- limit?: number;
210
- minScore?: number;
211
- dryRun?: boolean;
212
- }): Promise<{ deleted: number; candidates: VektorMemory[] }>;
213
-
214
- pin(id: string): Promise<{ id: string; pinned: true; content: string }>;
215
- unpin(id: string): Promise<{ id: string; pinned: false; content: string }>;
216
- listPinned(): Promise<VektorMemory[]>;
217
-
218
- inspect(): InspectResult;
219
-
220
- auditLog(opts?: {
221
- limit?: number;
222
- action?: 'ADD' | 'UPDATE' | 'DELETE' | 'NO_OP';
223
- since?: string | number;
224
- }): AudnLogEntry[];
225
-
226
- export(opts?: {
227
- includeEmbeddings?: boolean;
228
- since?: string | number;
229
- }): ExportBundle;
230
-
231
- import(bundle: ExportBundle, opts?: {
232
- namespace?: string;
233
- mode?: 'merge' | 'replace';
234
- dryRun?: boolean;
235
- }): { imported: number; skipped: number; edgesAdded: number };
236
-
237
- listNamespaces(): NamespaceRecord[];
238
- deleteNamespace(namespace: string, confirm: string): { deleted: number; namespace: string };
239
- }
240
-
241
- // ─── Factory ─────────────────────────────────────────────────────────────────
242
-
243
- export declare function createMemory(opts: CreateMemoryOptions): Promise<Memory>;
244
-
245
- // ─── Entity resolver (separate import) ───────────────────────────────────────
246
-
247
- export interface EntityResolverOptions {
248
- dbPath?: string;
249
- }
250
-
251
- export declare class EntityResolver {
252
- constructor(memory: Memory, dbPath?: string);
253
- remember(text: string, opts?: Record<string, unknown>): Promise<{
254
- normalised: string;
255
- entityIds: string[];
256
- result: unknown;
257
- }>;
258
- resolve(ref: string, threshold?: number): Promise<EntityRecord | null>;
259
- addEntity(canonical: string, type?: EntityRecord['type'], aliases?: string[]): string;
260
- addAlias(alias: string, entityId: string, source?: string): void;
261
- getEntity(id: string): EntityRecord | null;
262
- listEntities(): EntityRecord[];
263
- mergeEntities(sourceId: string, targetId: string): EntityRecord | null;
264
- findDuplicateCandidates(threshold?: number): Promise<Array<{
265
- entity_a: EntityRecord;
266
- entity_b: EntityRecord;
267
- score: number;
268
- }>>;
269
- }
@@ -1,109 +0,0 @@
1
- 'use strict';
2
-
3
- /**
4
- * vektor-banner-loader.js
5
- * Prints the VEKTOR ASCII banner with a real animated progress bar.
6
- * Bar animates while the process boots, resolves when ready.
7
- * Works on Windows (no ANSI cursor tricks that break cmd.exe).
8
- */
9
-
10
- const PKG = require('./package.json');
11
- const start = Date.now();
12
-
13
- // ── Colours ───────────────────────────────────────────────────────────────────
14
- const ESC = '\x1b[';
15
- const RESET = '\x1b[0m';
16
- const ORANGE = '\x1b[38;5;214m';
17
- const DIM = '\x1b[2m';
18
- const BOLD = '\x1b[1m';
19
- const CYAN = '\x1b[36m';
20
-
21
- // ── Banner lines (stored as plain ASCII — encoding-safe) ──────────────────────
22
- const BANNER = [
23
- ' ██╗ ██╗███████╗██╗ ██╗████████╗ ██████╗ ██████╗ ',
24
- ' ██║ ██║██╔════╝██║ ██╔╝╚══██╔══╝██╔═══██╗██╔══██╗',
25
- ' ██║ ██║█████╗ █████╔╝ ██║ ██║ ██║██████╔╝',
26
- ' ╚██╗ ██╔╝██╔══╝ ██╔═██╗ ██║ ██║ ██║██╔══██╗',
27
- ' ╚████╔╝ ███████╗██║ ██╗ ██║ ╚██████╔╝██║ ██║',
28
- " ╚═══╝ ╚══════╝╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝",
29
- ];
30
-
31
- // ── Print banner immediately ───────────────────────────────────────────────────
32
- process.stderr.write('\n');
33
- BANNER.forEach(l => process.stderr.write(ORANGE + l + RESET + '\n'));
34
- process.stderr.write('\n');
35
- process.stderr.write(DIM + ' SLIPSTREAM v' + PKG.version + ' · Sovereign Agent Memory' + RESET + '\n');
36
- process.stderr.write('\n');
37
-
38
- // ── Progress bar state ────────────────────────────────────────────────────────
39
- const BAR_WIDTH = 20;
40
- let _pct = 0;
41
- let _label = 'Initialising';
42
- let _done = false;
43
- let _timer = null;
44
-
45
- function renderBar(pct, label) {
46
- const filled = Math.round((pct / 100) * BAR_WIDTH);
47
- const empty = BAR_WIDTH - filled;
48
- const bar = '█'.repeat(filled) + '░'.repeat(empty);
49
- const pctStr = String(pct).padStart(3) + '%';
50
- // \r moves to start of line, overwrites in place — works on Windows
51
- // Pad label to 20 chars to fully overwrite any previous longer label on \r
52
- const paddedLabel = (label + ' ').slice(0, 20);
53
- process.stderr.write(
54
- '\r ' + DIM + '└─ ' + RESET +
55
- CYAN + '[' + bar + ']' + RESET + ' ' +
56
- DIM + pctStr + ' ' + paddedLabel + RESET
57
- );
58
- }
59
-
60
- // Animate: slowly tick up to 85% while waiting for real completion
61
- function startAnimation() {
62
- const ticks = [
63
- { at: 100, pct: 10, label: 'Initialising' },
64
- { at: 200, pct: 25, label: 'Loading core' },
65
- { at: 400, pct: 40, label: 'Opening DB' },
66
- { at: 700, pct: 55, label: 'Warming cache' },
67
- { at: 1000, pct: 70, label: 'Ready' },
68
- { at: 1400, pct: 82, label: 'Ready' },
69
- ];
70
-
71
- renderBar(0, 'Initialising');
72
-
73
- ticks.forEach(({ at, pct, label }) => {
74
- setTimeout(() => {
75
- if (_done) return;
76
- _pct = pct;
77
- _label = label;
78
- renderBar(_pct, _label);
79
- }, at);
80
- });
81
- }
82
-
83
- function completeBar(label) {
84
- if (_done) return;
85
- _done = true;
86
- if (_timer) clearInterval(_timer);
87
- renderBar(100, label || 'Ready');
88
- process.stderr.write('\n\n');
89
- }
90
-
91
- // ── Auto-complete on process ready ────────────────────────────────────────────
92
- // If nothing calls complete() explicitly, finish bar when event loop drains
93
- _timer = setTimeout(() => {
94
- if (!_done) completeBar('Ready');
95
- }, 2000);
96
-
97
- // Don't let this timer keep the process alive
98
- if (_timer.unref) _timer.unref();
99
-
100
- // ── Exports ───────────────────────────────────────────────────────────────────
101
- module.exports = {
102
- loadedAt: start,
103
- progress: (pct, label) => { if (!_done) { _pct = pct; _label = label; renderBar(pct, label); } },
104
- complete: completeBar,
105
- fail: (msg) => { completeBar('Error'); process.stderr.write('\n ' + msg + '\n'); },
106
- };
107
-
108
- // Start animation
109
- startAnimation();