@soleri/core 2.0.1 → 2.0.2
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/dist/brain/brain.d.ts +3 -12
- package/dist/brain/brain.d.ts.map +1 -1
- package/dist/brain/brain.js +13 -305
- package/dist/brain/brain.js.map +1 -1
- package/dist/curator/curator.d.ts +28 -0
- package/dist/curator/curator.d.ts.map +1 -0
- package/dist/curator/curator.js +523 -0
- package/dist/curator/curator.js.map +1 -0
- package/dist/curator/types.d.ts +87 -0
- package/dist/curator/types.d.ts.map +1 -0
- package/dist/curator/types.js +3 -0
- package/dist/curator/types.js.map +1 -0
- package/dist/facades/types.d.ts +1 -1
- package/dist/index.d.ts +9 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -2
- package/dist/index.js.map +1 -1
- package/dist/llm/llm-client.d.ts +28 -0
- package/dist/llm/llm-client.d.ts.map +1 -0
- package/dist/llm/llm-client.js +219 -0
- package/dist/llm/llm-client.js.map +1 -0
- package/dist/runtime/core-ops.d.ts +17 -0
- package/dist/runtime/core-ops.d.ts.map +1 -0
- package/dist/runtime/core-ops.js +448 -0
- package/dist/runtime/core-ops.js.map +1 -0
- package/dist/runtime/domain-ops.d.ts +25 -0
- package/dist/runtime/domain-ops.d.ts.map +1 -0
- package/dist/runtime/domain-ops.js +130 -0
- package/dist/runtime/domain-ops.js.map +1 -0
- package/dist/runtime/runtime.d.ts +19 -0
- package/dist/runtime/runtime.d.ts.map +1 -0
- package/dist/runtime/runtime.js +62 -0
- package/dist/runtime/runtime.js.map +1 -0
- package/dist/runtime/types.d.ts +39 -0
- package/dist/runtime/types.d.ts.map +1 -0
- package/dist/runtime/types.js +2 -0
- package/dist/{cognee → runtime}/types.js.map +1 -1
- package/dist/text/similarity.d.ts +8 -0
- package/dist/text/similarity.d.ts.map +1 -0
- package/dist/text/similarity.js +161 -0
- package/dist/text/similarity.js.map +1 -0
- package/package.json +6 -2
- package/src/__tests__/brain.test.ts +27 -265
- package/src/__tests__/core-ops.test.ts +190 -0
- package/src/__tests__/curator.test.ts +479 -0
- package/src/__tests__/domain-ops.test.ts +124 -0
- package/src/__tests__/llm-client.test.ts +69 -0
- package/src/__tests__/runtime.test.ts +93 -0
- package/src/brain/brain.ts +19 -342
- package/src/curator/curator.ts +662 -0
- package/src/curator/types.ts +114 -0
- package/src/index.ts +40 -11
- package/src/llm/llm-client.ts +316 -0
- package/src/runtime/core-ops.ts +472 -0
- package/src/runtime/domain-ops.ts +144 -0
- package/src/runtime/runtime.ts +71 -0
- package/src/runtime/types.ts +37 -0
- package/src/text/similarity.ts +168 -0
- package/dist/cognee/client.d.ts +0 -35
- package/dist/cognee/client.d.ts.map +0 -1
- package/dist/cognee/client.js +0 -291
- package/dist/cognee/client.js.map +0 -1
- package/dist/cognee/types.d.ts +0 -46
- package/dist/cognee/types.d.ts.map +0 -1
- package/dist/cognee/types.js +0 -3
- package/src/__tests__/cognee-client.test.ts +0 -524
- package/src/cognee/client.ts +0 -352
- package/src/cognee/types.ts +0 -62
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { Vault } from '../vault/vault.js';
|
|
2
|
+
import type { Brain } from '../brain/brain.js';
|
|
3
|
+
import type { Planner } from '../planning/planner.js';
|
|
4
|
+
import type { Curator } from '../curator/curator.js';
|
|
5
|
+
import type { KeyPool } from '../llm/key-pool.js';
|
|
6
|
+
import type { LLMClient } from '../llm/llm-client.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Configuration for creating an agent runtime.
|
|
10
|
+
* Only `agentId` is required — everything else has sensible defaults.
|
|
11
|
+
*/
|
|
12
|
+
export interface AgentRuntimeConfig {
|
|
13
|
+
/** Agent identifier (kebab-case), e.g. 'my-agent'. Used for paths: ~/.{agentId}/ */
|
|
14
|
+
agentId: string;
|
|
15
|
+
/** Path to vault database. Default: ~/.{agentId}/vault.db */
|
|
16
|
+
vaultPath?: string;
|
|
17
|
+
/** Path to plans JSON store. Default: ~/.{agentId}/plans.json */
|
|
18
|
+
plansPath?: string;
|
|
19
|
+
/** Intelligence data directory to seed vault from. Optional. */
|
|
20
|
+
dataDir?: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Fully initialized agent runtime — all modules ready.
|
|
25
|
+
* Created by `createAgentRuntime(config)`.
|
|
26
|
+
*/
|
|
27
|
+
export interface AgentRuntime {
|
|
28
|
+
config: AgentRuntimeConfig;
|
|
29
|
+
vault: Vault;
|
|
30
|
+
brain: Brain;
|
|
31
|
+
planner: Planner;
|
|
32
|
+
curator: Curator;
|
|
33
|
+
keyPool: { openai: KeyPool; anthropic: KeyPool };
|
|
34
|
+
llmClient: LLMClient;
|
|
35
|
+
/** Close the vault database connection. Call on shutdown. */
|
|
36
|
+
close(): void;
|
|
37
|
+
}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
// ─── Shared Text Processing & Similarity Utilities ──────────────────
|
|
2
|
+
// Pure functions used by Brain (ranked search) and Curator (dedup, contradictions).
|
|
3
|
+
|
|
4
|
+
export type SparseVector = Map<string, number>;
|
|
5
|
+
|
|
6
|
+
// ─── Stopwords ─────────────────────────────────────────────────────
|
|
7
|
+
|
|
8
|
+
export const STOPWORDS = new Set([
|
|
9
|
+
'a',
|
|
10
|
+
'an',
|
|
11
|
+
'the',
|
|
12
|
+
'and',
|
|
13
|
+
'or',
|
|
14
|
+
'but',
|
|
15
|
+
'in',
|
|
16
|
+
'on',
|
|
17
|
+
'at',
|
|
18
|
+
'to',
|
|
19
|
+
'for',
|
|
20
|
+
'of',
|
|
21
|
+
'with',
|
|
22
|
+
'by',
|
|
23
|
+
'from',
|
|
24
|
+
'as',
|
|
25
|
+
'is',
|
|
26
|
+
'was',
|
|
27
|
+
'are',
|
|
28
|
+
'were',
|
|
29
|
+
'been',
|
|
30
|
+
'be',
|
|
31
|
+
'have',
|
|
32
|
+
'has',
|
|
33
|
+
'had',
|
|
34
|
+
'do',
|
|
35
|
+
'does',
|
|
36
|
+
'did',
|
|
37
|
+
'will',
|
|
38
|
+
'would',
|
|
39
|
+
'could',
|
|
40
|
+
'should',
|
|
41
|
+
'may',
|
|
42
|
+
'might',
|
|
43
|
+
'shall',
|
|
44
|
+
'can',
|
|
45
|
+
'need',
|
|
46
|
+
'must',
|
|
47
|
+
'it',
|
|
48
|
+
'its',
|
|
49
|
+
'this',
|
|
50
|
+
'that',
|
|
51
|
+
'these',
|
|
52
|
+
'those',
|
|
53
|
+
'i',
|
|
54
|
+
'you',
|
|
55
|
+
'he',
|
|
56
|
+
'she',
|
|
57
|
+
'we',
|
|
58
|
+
'they',
|
|
59
|
+
'me',
|
|
60
|
+
'him',
|
|
61
|
+
'her',
|
|
62
|
+
'us',
|
|
63
|
+
'them',
|
|
64
|
+
'my',
|
|
65
|
+
'your',
|
|
66
|
+
'his',
|
|
67
|
+
'our',
|
|
68
|
+
'their',
|
|
69
|
+
'what',
|
|
70
|
+
'which',
|
|
71
|
+
'who',
|
|
72
|
+
'whom',
|
|
73
|
+
'when',
|
|
74
|
+
'where',
|
|
75
|
+
'why',
|
|
76
|
+
'how',
|
|
77
|
+
'all',
|
|
78
|
+
'each',
|
|
79
|
+
'every',
|
|
80
|
+
'both',
|
|
81
|
+
'few',
|
|
82
|
+
'more',
|
|
83
|
+
'most',
|
|
84
|
+
'other',
|
|
85
|
+
'some',
|
|
86
|
+
'such',
|
|
87
|
+
'no',
|
|
88
|
+
'not',
|
|
89
|
+
'only',
|
|
90
|
+
'same',
|
|
91
|
+
'so',
|
|
92
|
+
'than',
|
|
93
|
+
'too',
|
|
94
|
+
'very',
|
|
95
|
+
'just',
|
|
96
|
+
'because',
|
|
97
|
+
'if',
|
|
98
|
+
'then',
|
|
99
|
+
'else',
|
|
100
|
+
'about',
|
|
101
|
+
'up',
|
|
102
|
+
'out',
|
|
103
|
+
'into',
|
|
104
|
+
]);
|
|
105
|
+
|
|
106
|
+
// ─── Text Processing ───────────────────────────────────────────────
|
|
107
|
+
|
|
108
|
+
export function tokenize(text: string): string[] {
|
|
109
|
+
return text
|
|
110
|
+
.toLowerCase()
|
|
111
|
+
.replace(/[^a-z0-9\s-]/g, ' ')
|
|
112
|
+
.split(/\s+/)
|
|
113
|
+
.filter((t) => t.length > 2 && !STOPWORDS.has(t));
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export function calculateTf(tokens: string[]): SparseVector {
|
|
117
|
+
const tf: SparseVector = new Map();
|
|
118
|
+
for (const token of tokens) {
|
|
119
|
+
tf.set(token, (tf.get(token) ?? 0) + 1);
|
|
120
|
+
}
|
|
121
|
+
const len = tokens.length || 1;
|
|
122
|
+
for (const [term, count] of tf) {
|
|
123
|
+
tf.set(term, count / len);
|
|
124
|
+
}
|
|
125
|
+
return tf;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export function calculateTfIdf(tokens: string[], vocabulary: Map<string, number>): SparseVector {
|
|
129
|
+
const tf = calculateTf(tokens);
|
|
130
|
+
const tfidf: SparseVector = new Map();
|
|
131
|
+
for (const [term, tfValue] of tf) {
|
|
132
|
+
const idf = vocabulary.get(term) ?? 0;
|
|
133
|
+
if (idf > 0) {
|
|
134
|
+
tfidf.set(term, tfValue * idf);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return tfidf;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export function cosineSimilarity(a: SparseVector, b: SparseVector): number {
|
|
141
|
+
let dot = 0;
|
|
142
|
+
let normA = 0;
|
|
143
|
+
let normB = 0;
|
|
144
|
+
for (const [term, valA] of a) {
|
|
145
|
+
normA += valA * valA;
|
|
146
|
+
const valB = b.get(term);
|
|
147
|
+
if (valB !== undefined) {
|
|
148
|
+
dot += valA * valB;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
for (const [, valB] of b) {
|
|
152
|
+
normB += valB * valB;
|
|
153
|
+
}
|
|
154
|
+
const denom = Math.sqrt(normA) * Math.sqrt(normB);
|
|
155
|
+
return denom === 0 ? 0 : dot / denom;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export function jaccardSimilarity(a: string[], b: string[]): number {
|
|
159
|
+
if (a.length === 0 && b.length === 0) return 0;
|
|
160
|
+
const setA = new Set(a);
|
|
161
|
+
const setB = new Set(b);
|
|
162
|
+
let intersection = 0;
|
|
163
|
+
for (const item of setA) {
|
|
164
|
+
if (setB.has(item)) intersection++;
|
|
165
|
+
}
|
|
166
|
+
const union = new Set([...a, ...b]).size;
|
|
167
|
+
return union === 0 ? 0 : intersection / union;
|
|
168
|
+
}
|
package/dist/cognee/client.d.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import type { CogneeConfig, CogneeSearchResult, CogneeSearchType, CogneeStatus, CogneeAddResult, CogneeCognifyResult } from './types.js';
|
|
2
|
-
import type { IntelligenceEntry } from '../intelligence/types.js';
|
|
3
|
-
export declare class CogneeClient {
|
|
4
|
-
private config;
|
|
5
|
-
private healthCache;
|
|
6
|
-
private accessToken;
|
|
7
|
-
private cognifyTimers;
|
|
8
|
-
private pendingDatasets;
|
|
9
|
-
constructor(config?: Partial<CogneeConfig>);
|
|
10
|
-
get isAvailable(): boolean;
|
|
11
|
-
healthCheck(): Promise<CogneeStatus>;
|
|
12
|
-
addEntries(entries: IntelligenceEntry[]): Promise<CogneeAddResult>;
|
|
13
|
-
cognify(dataset?: string): Promise<CogneeCognifyResult>;
|
|
14
|
-
/**
|
|
15
|
-
* Schedule a debounced cognify for a dataset.
|
|
16
|
-
* Sliding window: each call resets the timer. When it expires,
|
|
17
|
-
* cognify fires once. Prevents pipeline dedup on rapid ingests.
|
|
18
|
-
*/
|
|
19
|
-
private scheduleCognify;
|
|
20
|
-
/** Flush all pending debounced cognify calls immediately. */
|
|
21
|
-
flushPendingCognify(): Promise<void>;
|
|
22
|
-
/** Cancel all pending cognify calls without firing them. For test teardown. */
|
|
23
|
-
resetPendingCognify(): void;
|
|
24
|
-
search(query: string, opts?: {
|
|
25
|
-
searchType?: CogneeSearchType;
|
|
26
|
-
limit?: number;
|
|
27
|
-
}): Promise<CogneeSearchResult[]>;
|
|
28
|
-
getConfig(): Readonly<CogneeConfig>;
|
|
29
|
-
getStatus(): CogneeStatus | null;
|
|
30
|
-
private ensureAuth;
|
|
31
|
-
private authHeaders;
|
|
32
|
-
private serializeEntry;
|
|
33
|
-
private post;
|
|
34
|
-
}
|
|
35
|
-
//# sourceMappingURL=client.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/cognee/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,kBAAkB,EAClB,gBAAgB,EAChB,YAAY,EACZ,eAAe,EACf,mBAAmB,EACpB,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAmClE,qBAAa,YAAY;IACvB,OAAO,CAAC,MAAM,CAAe;IAC7B,OAAO,CAAC,WAAW,CAA2D;IAC9E,OAAO,CAAC,WAAW,CAAuB;IAC1C,OAAO,CAAC,aAAa,CAAyD;IAC9E,OAAO,CAAC,eAAe,CAA0B;gBAErC,MAAM,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC;IAY1C,IAAI,WAAW,IAAI,OAAO,CAKzB;IAEK,WAAW,IAAI,OAAO,CAAC,YAAY,CAAC;IAoCpC,UAAU,CAAC,OAAO,EAAE,iBAAiB,EAAE,GAAG,OAAO,CAAC,eAAe,CAAC;IAqClE,OAAO,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAiB7D;;;;OAIG;IACH,OAAO,CAAC,eAAe;IAkBvB,6DAA6D;IACvD,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC;IAa1C,+EAA+E;IAC/E,mBAAmB,IAAI,IAAI;IAQrB,MAAM,CACV,KAAK,EAAE,MAAM,EACb,IAAI,CAAC,EAAE;QAAE,UAAU,CAAC,EAAE,gBAAgB,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GACvD,OAAO,CAAC,kBAAkB,EAAE,CAAC;IAwChC,SAAS,IAAI,QAAQ,CAAC,YAAY,CAAC;IAInC,SAAS,IAAI,YAAY,GAAG,IAAI;YAQlB,UAAU;YAqDV,WAAW;IAYzB,OAAO,CAAC,cAAc;YASR,IAAI;CASnB"}
|
package/dist/cognee/client.js
DELETED
|
@@ -1,291 +0,0 @@
|
|
|
1
|
-
// ─── Defaults ──────────────────────────────────────────────────────
|
|
2
|
-
// Aligned with Salvador MCP's battle-tested Cognee integration.
|
|
3
|
-
const DEFAULT_SERVICE_EMAIL = 'soleri-agent@cognee.dev';
|
|
4
|
-
const DEFAULT_SERVICE_PASSWORD = 'soleri-cognee-local';
|
|
5
|
-
/** Only allow default service credentials for local endpoints. */
|
|
6
|
-
function isLocalUrl(url) {
|
|
7
|
-
try {
|
|
8
|
-
const { hostname } = new URL(url);
|
|
9
|
-
return (hostname === 'localhost' ||
|
|
10
|
-
hostname === '127.0.0.1' ||
|
|
11
|
-
hostname === '::1' ||
|
|
12
|
-
hostname === '0.0.0.0');
|
|
13
|
-
}
|
|
14
|
-
catch {
|
|
15
|
-
return false;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
const DEFAULT_CONFIG = {
|
|
19
|
-
baseUrl: 'http://localhost:8000',
|
|
20
|
-
dataset: 'vault',
|
|
21
|
-
timeoutMs: 30_000,
|
|
22
|
-
searchTimeoutMs: 120_000, // Ollama cold start can take 90s
|
|
23
|
-
healthTimeoutMs: 5_000,
|
|
24
|
-
healthCacheTtlMs: 60_000,
|
|
25
|
-
cognifyDebounceMs: 30_000,
|
|
26
|
-
};
|
|
27
|
-
// ─── CogneeClient ──────────────────────────────────────────────────
|
|
28
|
-
export class CogneeClient {
|
|
29
|
-
config;
|
|
30
|
-
healthCache = null;
|
|
31
|
-
accessToken = null;
|
|
32
|
-
cognifyTimers = new Map();
|
|
33
|
-
pendingDatasets = new Set();
|
|
34
|
-
constructor(config) {
|
|
35
|
-
this.config = { ...DEFAULT_CONFIG, ...config };
|
|
36
|
-
// Strip trailing slash
|
|
37
|
-
this.config.baseUrl = this.config.baseUrl.replace(/\/+$/, '');
|
|
38
|
-
// Pre-set token if provided
|
|
39
|
-
if (this.config.apiToken) {
|
|
40
|
-
this.accessToken = this.config.apiToken;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
// ─── Health ────────────────────────────────────────────────────
|
|
44
|
-
get isAvailable() {
|
|
45
|
-
if (!this.healthCache)
|
|
46
|
-
return false;
|
|
47
|
-
const age = Date.now() - this.healthCache.cachedAt;
|
|
48
|
-
if (age > this.config.healthCacheTtlMs)
|
|
49
|
-
return false;
|
|
50
|
-
return this.healthCache.status.available;
|
|
51
|
-
}
|
|
52
|
-
async healthCheck() {
|
|
53
|
-
const start = Date.now();
|
|
54
|
-
try {
|
|
55
|
-
// Cognee health endpoint is GET / (returns {"message":"Hello, World, I am alive!"})
|
|
56
|
-
const res = await globalThis.fetch(`${this.config.baseUrl}/`, {
|
|
57
|
-
signal: AbortSignal.timeout(this.config.healthTimeoutMs),
|
|
58
|
-
});
|
|
59
|
-
const latencyMs = Date.now() - start;
|
|
60
|
-
if (res.ok) {
|
|
61
|
-
const status = { available: true, url: this.config.baseUrl, latencyMs };
|
|
62
|
-
this.healthCache = { status, cachedAt: Date.now() };
|
|
63
|
-
return status;
|
|
64
|
-
}
|
|
65
|
-
const status = {
|
|
66
|
-
available: false,
|
|
67
|
-
url: this.config.baseUrl,
|
|
68
|
-
latencyMs,
|
|
69
|
-
error: `HTTP ${res.status}`,
|
|
70
|
-
};
|
|
71
|
-
this.healthCache = { status, cachedAt: Date.now() };
|
|
72
|
-
return status;
|
|
73
|
-
}
|
|
74
|
-
catch (err) {
|
|
75
|
-
const latencyMs = Date.now() - start;
|
|
76
|
-
const status = {
|
|
77
|
-
available: false,
|
|
78
|
-
url: this.config.baseUrl,
|
|
79
|
-
latencyMs,
|
|
80
|
-
error: err instanceof Error ? err.message : String(err),
|
|
81
|
-
};
|
|
82
|
-
this.healthCache = { status, cachedAt: Date.now() };
|
|
83
|
-
return status;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
// ─── Ingest ────────────────────────────────────────────────────
|
|
87
|
-
async addEntries(entries) {
|
|
88
|
-
if (!this.isAvailable || entries.length === 0)
|
|
89
|
-
return { added: 0 };
|
|
90
|
-
try {
|
|
91
|
-
const token = await this.ensureAuth().catch(() => null);
|
|
92
|
-
// Cognee /add expects multipart/form-data with files + datasetName
|
|
93
|
-
const formData = new FormData();
|
|
94
|
-
formData.append('datasetName', this.config.dataset);
|
|
95
|
-
for (const entry of entries) {
|
|
96
|
-
const text = this.serializeEntry(entry);
|
|
97
|
-
const blob = new Blob([text], { type: 'text/plain' });
|
|
98
|
-
formData.append('data', blob, `${entry.id}.txt`);
|
|
99
|
-
}
|
|
100
|
-
const headers = {};
|
|
101
|
-
if (token)
|
|
102
|
-
headers.Authorization = `Bearer ${token}`;
|
|
103
|
-
const res = await globalThis.fetch(`${this.config.baseUrl}/api/v1/add`, {
|
|
104
|
-
method: 'POST',
|
|
105
|
-
headers,
|
|
106
|
-
body: formData,
|
|
107
|
-
signal: AbortSignal.timeout(this.config.timeoutMs),
|
|
108
|
-
});
|
|
109
|
-
if (!res.ok)
|
|
110
|
-
return { added: 0 };
|
|
111
|
-
// Schedule debounced cognify (multiple rapid ingests coalesce)
|
|
112
|
-
this.scheduleCognify(this.config.dataset);
|
|
113
|
-
return { added: entries.length };
|
|
114
|
-
}
|
|
115
|
-
catch {
|
|
116
|
-
return { added: 0 };
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
async cognify(dataset) {
|
|
120
|
-
if (!this.isAvailable)
|
|
121
|
-
return { status: 'unavailable' };
|
|
122
|
-
try {
|
|
123
|
-
const res = await this.post('/api/v1/cognify', {
|
|
124
|
-
datasets: [dataset ?? this.config.dataset],
|
|
125
|
-
});
|
|
126
|
-
if (!res.ok)
|
|
127
|
-
return { status: `error: HTTP ${res.status}` };
|
|
128
|
-
return { status: 'ok' };
|
|
129
|
-
}
|
|
130
|
-
catch (err) {
|
|
131
|
-
return { status: `error: ${err instanceof Error ? err.message : String(err)}` };
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
// ─── Cognify debounce ───────────────────────────────────────────
|
|
135
|
-
/**
|
|
136
|
-
* Schedule a debounced cognify for a dataset.
|
|
137
|
-
* Sliding window: each call resets the timer. When it expires,
|
|
138
|
-
* cognify fires once. Prevents pipeline dedup on rapid ingests.
|
|
139
|
-
*/
|
|
140
|
-
scheduleCognify(dataset) {
|
|
141
|
-
const existing = this.cognifyTimers.get(dataset);
|
|
142
|
-
if (existing)
|
|
143
|
-
clearTimeout(existing);
|
|
144
|
-
this.pendingDatasets.add(dataset);
|
|
145
|
-
const timer = setTimeout(() => {
|
|
146
|
-
this.cognifyTimers.delete(dataset);
|
|
147
|
-
this.pendingDatasets.delete(dataset);
|
|
148
|
-
this.post('/api/v1/cognify', { datasets: [dataset] }).catch(() => { });
|
|
149
|
-
}, this.config.cognifyDebounceMs);
|
|
150
|
-
// Unref so the timer doesn't keep the process alive during shutdown
|
|
151
|
-
if (typeof timer === 'object' && 'unref' in timer)
|
|
152
|
-
timer.unref();
|
|
153
|
-
this.cognifyTimers.set(dataset, timer);
|
|
154
|
-
}
|
|
155
|
-
/** Flush all pending debounced cognify calls immediately. */
|
|
156
|
-
async flushPendingCognify() {
|
|
157
|
-
const datasets = [...this.pendingDatasets];
|
|
158
|
-
for (const timer of this.cognifyTimers.values())
|
|
159
|
-
clearTimeout(timer);
|
|
160
|
-
this.cognifyTimers.clear();
|
|
161
|
-
this.pendingDatasets.clear();
|
|
162
|
-
if (datasets.length === 0)
|
|
163
|
-
return;
|
|
164
|
-
await Promise.allSettled(datasets.map((ds) => this.post('/api/v1/cognify', { datasets: [ds] }).catch(() => { })));
|
|
165
|
-
}
|
|
166
|
-
/** Cancel all pending cognify calls without firing them. For test teardown. */
|
|
167
|
-
resetPendingCognify() {
|
|
168
|
-
for (const timer of this.cognifyTimers.values())
|
|
169
|
-
clearTimeout(timer);
|
|
170
|
-
this.cognifyTimers.clear();
|
|
171
|
-
this.pendingDatasets.clear();
|
|
172
|
-
}
|
|
173
|
-
// ─── Search ────────────────────────────────────────────────────
|
|
174
|
-
async search(query, opts) {
|
|
175
|
-
if (!this.isAvailable)
|
|
176
|
-
return [];
|
|
177
|
-
// Default to CHUNKS (pure vector similarity) — GRAPH_COMPLETION requires
|
|
178
|
-
// the LLM to produce instructor-compatible JSON which small local models
|
|
179
|
-
// (llama3.2) can't do reliably, causing infinite retries and timeouts.
|
|
180
|
-
const searchType = opts?.searchType ?? 'CHUNKS';
|
|
181
|
-
const topK = opts?.limit ?? 10;
|
|
182
|
-
try {
|
|
183
|
-
const res = await this.post('/api/v1/search', { query, search_type: searchType, datasets: [this.config.dataset], topK }, this.config.searchTimeoutMs);
|
|
184
|
-
if (!res.ok)
|
|
185
|
-
return [];
|
|
186
|
-
const data = (await res.json());
|
|
187
|
-
// Position-based scoring when Cognee omits scores.
|
|
188
|
-
// Cognee returns results ordered by relevance but may not include numeric scores.
|
|
189
|
-
return data.slice(0, topK).map((item, idx) => ({
|
|
190
|
-
id: item.payload?.id ?? item.id ?? '',
|
|
191
|
-
score: item.score ?? positionScore(idx, data.length),
|
|
192
|
-
text: typeof item.text === 'string' ? item.text : String(item.text ?? ''),
|
|
193
|
-
searchType,
|
|
194
|
-
}));
|
|
195
|
-
}
|
|
196
|
-
catch {
|
|
197
|
-
return [];
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
// ─── Config access ─────────────────────────────────────────────
|
|
201
|
-
getConfig() {
|
|
202
|
-
return { ...this.config };
|
|
203
|
-
}
|
|
204
|
-
getStatus() {
|
|
205
|
-
return this.healthCache?.status ?? null;
|
|
206
|
-
}
|
|
207
|
-
// ─── Auth ──────────────────────────────────────────────────────
|
|
208
|
-
// Auto-register + login pattern from Salvador MCP.
|
|
209
|
-
// Tries login first (account may already exist), falls back to register.
|
|
210
|
-
async ensureAuth() {
|
|
211
|
-
if (this.accessToken)
|
|
212
|
-
return this.accessToken;
|
|
213
|
-
const email = this.config.serviceEmail ?? DEFAULT_SERVICE_EMAIL;
|
|
214
|
-
const password = this.config.servicePassword ?? DEFAULT_SERVICE_PASSWORD;
|
|
215
|
-
// Refuse default credentials for non-local endpoints
|
|
216
|
-
if (!isLocalUrl(this.config.baseUrl) &&
|
|
217
|
-
email === DEFAULT_SERVICE_EMAIL &&
|
|
218
|
-
password === DEFAULT_SERVICE_PASSWORD) {
|
|
219
|
-
throw new Error('Explicit Cognee credentials are required for non-local endpoints');
|
|
220
|
-
}
|
|
221
|
-
// Try login first
|
|
222
|
-
const loginResp = await globalThis.fetch(`${this.config.baseUrl}/api/v1/auth/login`, {
|
|
223
|
-
method: 'POST',
|
|
224
|
-
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
|
225
|
-
body: `username=${encodeURIComponent(email)}&password=${encodeURIComponent(password)}`,
|
|
226
|
-
signal: AbortSignal.timeout(this.config.healthTimeoutMs),
|
|
227
|
-
});
|
|
228
|
-
if (loginResp.ok) {
|
|
229
|
-
const data = (await loginResp.json());
|
|
230
|
-
this.accessToken = data.access_token;
|
|
231
|
-
return this.accessToken;
|
|
232
|
-
}
|
|
233
|
-
// Register, then retry login
|
|
234
|
-
await globalThis.fetch(`${this.config.baseUrl}/api/v1/auth/register`, {
|
|
235
|
-
method: 'POST',
|
|
236
|
-
headers: { 'Content-Type': 'application/json' },
|
|
237
|
-
body: JSON.stringify({ email, password }),
|
|
238
|
-
signal: AbortSignal.timeout(this.config.healthTimeoutMs),
|
|
239
|
-
});
|
|
240
|
-
const retryLogin = await globalThis.fetch(`${this.config.baseUrl}/api/v1/auth/login`, {
|
|
241
|
-
method: 'POST',
|
|
242
|
-
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
|
243
|
-
body: `username=${encodeURIComponent(email)}&password=${encodeURIComponent(password)}`,
|
|
244
|
-
signal: AbortSignal.timeout(this.config.healthTimeoutMs),
|
|
245
|
-
});
|
|
246
|
-
if (!retryLogin.ok) {
|
|
247
|
-
throw new Error(`Cognee auth failed: HTTP ${retryLogin.status}`);
|
|
248
|
-
}
|
|
249
|
-
const retryData = (await retryLogin.json());
|
|
250
|
-
this.accessToken = retryData.access_token;
|
|
251
|
-
return this.accessToken;
|
|
252
|
-
}
|
|
253
|
-
async authHeaders() {
|
|
254
|
-
try {
|
|
255
|
-
const token = await this.ensureAuth();
|
|
256
|
-
return { 'Content-Type': 'application/json', Authorization: `Bearer ${token}` };
|
|
257
|
-
}
|
|
258
|
-
catch {
|
|
259
|
-
// Fall back to no auth (works if AUTH_REQUIRED=false)
|
|
260
|
-
return { 'Content-Type': 'application/json' };
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
// ─── Private helpers ───────────────────────────────────────────
|
|
264
|
-
serializeEntry(entry) {
|
|
265
|
-
// Prefix with vault ID so we can cross-reference search results back to vault entries.
|
|
266
|
-
// Cognee assigns its own UUIDs to chunks — the vault ID would otherwise be lost.
|
|
267
|
-
const parts = [`[vault-id:${entry.id}]`, entry.title, entry.description];
|
|
268
|
-
if (entry.context)
|
|
269
|
-
parts.push(entry.context);
|
|
270
|
-
if (entry.tags.length > 0)
|
|
271
|
-
parts.push(`Tags: ${entry.tags.join(', ')}`);
|
|
272
|
-
return parts.join('\n');
|
|
273
|
-
}
|
|
274
|
-
async post(path, body, timeoutMs) {
|
|
275
|
-
const headers = await this.authHeaders();
|
|
276
|
-
return globalThis.fetch(`${this.config.baseUrl}${path}`, {
|
|
277
|
-
method: 'POST',
|
|
278
|
-
headers,
|
|
279
|
-
body: JSON.stringify(body),
|
|
280
|
-
signal: AbortSignal.timeout(timeoutMs ?? this.config.timeoutMs),
|
|
281
|
-
});
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
// ─── Helpers ──────────────────────────────────────────────────────
|
|
285
|
-
/** Position-based score: first result gets ~1.0, last gets ~0.05. */
|
|
286
|
-
function positionScore(index, total) {
|
|
287
|
-
if (total <= 1)
|
|
288
|
-
return 1.0;
|
|
289
|
-
return Math.max(0.05, 1.0 - (index / (total - 1)) * 0.95);
|
|
290
|
-
}
|
|
291
|
-
//# sourceMappingURL=client.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/cognee/client.ts"],"names":[],"mappings":"AAUA,sEAAsE;AACtE,gEAAgE;AAEhE,MAAM,qBAAqB,GAAG,yBAAyB,CAAC;AACxD,MAAM,wBAAwB,GAAG,qBAAqB,CAAC;AAEvD,kEAAkE;AAClE,SAAS,UAAU,CAAC,GAAW;IAC7B,IAAI,CAAC;QACH,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;QAClC,OAAO,CACL,QAAQ,KAAK,WAAW;YACxB,QAAQ,KAAK,WAAW;YACxB,QAAQ,KAAK,KAAK;YAClB,QAAQ,KAAK,SAAS,CACvB,CAAC;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED,MAAM,cAAc,GAAiB;IACnC,OAAO,EAAE,uBAAuB;IAChC,OAAO,EAAE,OAAO;IAChB,SAAS,EAAE,MAAM;IACjB,eAAe,EAAE,OAAO,EAAE,iCAAiC;IAC3D,eAAe,EAAE,KAAK;IACtB,gBAAgB,EAAE,MAAM;IACxB,iBAAiB,EAAE,MAAM;CAC1B,CAAC;AAEF,sEAAsE;AAEtE,MAAM,OAAO,YAAY;IACf,MAAM,CAAe;IACrB,WAAW,GAAsD,IAAI,CAAC;IACtE,WAAW,GAAkB,IAAI,CAAC;IAClC,aAAa,GAA+C,IAAI,GAAG,EAAE,CAAC;IACtE,eAAe,GAAgB,IAAI,GAAG,EAAE,CAAC;IAEjD,YAAY,MAA8B;QAC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IAAI,CAAC,CAAC;AAC5D,CAAC"}
|
package/dist/cognee/types.d.ts
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
export interface CogneeConfig {
|
|
2
|
-
/** Base URL of the Cognee API (default: http://localhost:8000) */
|
|
3
|
-
baseUrl: string;
|
|
4
|
-
/** Dataset name for this agent's vault entries */
|
|
5
|
-
dataset: string;
|
|
6
|
-
/** Bearer token for Cognee API authentication (auto-acquired if not set) */
|
|
7
|
-
apiToken?: string;
|
|
8
|
-
/** Service account email for auto-login (default: soleri-agent@cognee.dev) */
|
|
9
|
-
serviceEmail?: string;
|
|
10
|
-
/** Service account password for auto-login */
|
|
11
|
-
servicePassword?: string;
|
|
12
|
-
/** Default request timeout in milliseconds (default: 30000) */
|
|
13
|
-
timeoutMs: number;
|
|
14
|
-
/** Search timeout in milliseconds — Ollama cold start can take 90s (default: 120000) */
|
|
15
|
-
searchTimeoutMs: number;
|
|
16
|
-
/** Health check timeout in milliseconds (default: 5000) */
|
|
17
|
-
healthTimeoutMs: number;
|
|
18
|
-
/** Health check cache TTL in milliseconds (default: 60000) */
|
|
19
|
-
healthCacheTtlMs: number;
|
|
20
|
-
/** Cognify debounce window in milliseconds (default: 30000) */
|
|
21
|
-
cognifyDebounceMs: number;
|
|
22
|
-
}
|
|
23
|
-
export interface CogneeSearchResult {
|
|
24
|
-
/** Vault entry ID (cross-reference key) */
|
|
25
|
-
id: string;
|
|
26
|
-
/** Relevance score (0–1). Position-based when Cognee omits scores. */
|
|
27
|
-
score: number;
|
|
28
|
-
/** Text content from Cognee */
|
|
29
|
-
text: string;
|
|
30
|
-
/** Cognee search type that produced this result */
|
|
31
|
-
searchType: CogneeSearchType;
|
|
32
|
-
}
|
|
33
|
-
export type CogneeSearchType = 'SUMMARIES' | 'CHUNKS' | 'RAG_COMPLETION' | 'TRIPLET_COMPLETION' | 'GRAPH_COMPLETION' | 'GRAPH_SUMMARY_COMPLETION' | 'NATURAL_LANGUAGE' | 'GRAPH_COMPLETION_COT' | 'FEELING_LUCKY' | 'CHUNKS_LEXICAL';
|
|
34
|
-
export interface CogneeStatus {
|
|
35
|
-
available: boolean;
|
|
36
|
-
url: string;
|
|
37
|
-
latencyMs: number;
|
|
38
|
-
error?: string;
|
|
39
|
-
}
|
|
40
|
-
export interface CogneeAddResult {
|
|
41
|
-
added: number;
|
|
42
|
-
}
|
|
43
|
-
export interface CogneeCognifyResult {
|
|
44
|
-
status: string;
|
|
45
|
-
}
|
|
46
|
-
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/cognee/types.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,YAAY;IAC3B,kEAAkE;IAClE,OAAO,EAAE,MAAM,CAAC;IAChB,kDAAkD;IAClD,OAAO,EAAE,MAAM,CAAC;IAChB,4EAA4E;IAC5E,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,8EAA8E;IAC9E,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,8CAA8C;IAC9C,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,+DAA+D;IAC/D,SAAS,EAAE,MAAM,CAAC;IAClB,wFAAwF;IACxF,eAAe,EAAE,MAAM,CAAC;IACxB,2DAA2D;IAC3D,eAAe,EAAE,MAAM,CAAC;IACxB,8DAA8D;IAC9D,gBAAgB,EAAE,MAAM,CAAC;IACzB,+DAA+D;IAC/D,iBAAiB,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,kBAAkB;IACjC,2CAA2C;IAC3C,EAAE,EAAE,MAAM,CAAC;IACX,sEAAsE;IACtE,KAAK,EAAE,MAAM,CAAC;IACd,+BAA+B;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,mDAAmD;IACnD,UAAU,EAAE,gBAAgB,CAAC;CAC9B;AAED,MAAM,MAAM,gBAAgB,GACxB,WAAW,GACX,QAAQ,GACR,gBAAgB,GAChB,oBAAoB,GACpB,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