@ixo/common 1.1.41 → 1.1.42
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/.turbo/turbo-build.log +1 -4
- package/dist/ai/semantic-router-factory/create-semantic-router.js.map +1 -1
- package/dist/ai/utils/load-file.d.ts.map +1 -1
- package/dist/ai/utils/load-file.js +42 -3
- package/dist/ai/utils/load-file.js.map +1 -1
- package/dist/services/env/env.service.js.map +1 -1
- package/dist/services/memory-engine/memory-engine.service.d.ts +5 -4
- package/dist/services/memory-engine/memory-engine.service.d.ts.map +1 -1
- package/dist/services/memory-engine/memory-engine.service.js +75 -98
- package/dist/services/memory-engine/memory-engine.service.js.map +1 -1
- package/dist/services/session-manager/dto.d.ts +0 -5
- package/dist/services/session-manager/dto.d.ts.map +1 -1
- package/dist/services/session-manager/dto.js +0 -30
- package/dist/services/session-manager/dto.js.map +1 -1
- package/dist/services/session-manager/session-manager.service.d.ts +1 -3
- package/dist/services/session-manager/session-manager.service.d.ts.map +1 -1
- package/dist/services/session-manager/session-manager.service.js +1 -25
- package/dist/services/session-manager/session-manager.service.js.map +1 -1
- package/package.json +19 -15
- package/src/ai/semantic-router-factory/create-semantic-router.ts +1 -1
- package/src/ai/utils/load-file.ts +52 -3
- package/src/services/env/env.service.ts +3 -3
- package/src/services/memory-engine/memory-engine.service.ts +146 -114
- package/src/services/session-manager/dto.ts +0 -20
- package/src/services/session-manager/session-manager.service.ts +5 -27
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -5,11 +5,9 @@ import { getChatOpenAiModel, getLLMProvider, getOpenRouterChatModel, getProvider
|
|
|
5
5
|
export class SessionManagerService {
|
|
6
6
|
syncService;
|
|
7
7
|
matrixManger;
|
|
8
|
-
|
|
9
|
-
constructor(syncService, matrixManger = MatrixManager.getInstance(), memoryEngineService) {
|
|
8
|
+
constructor(syncService, matrixManger = MatrixManager.getInstance()) {
|
|
10
9
|
this.syncService = syncService;
|
|
11
10
|
this.matrixManger = matrixManger;
|
|
12
|
-
this.memoryEngineService = memoryEngineService;
|
|
13
11
|
}
|
|
14
12
|
getSessionsStateKey({ oracleEntityDid, }) {
|
|
15
13
|
return `${oracleEntityDid}_sessions`;
|
|
@@ -255,27 +253,6 @@ ___________________________________________________________
|
|
|
255
253
|
roomId,
|
|
256
254
|
isOracleAdmin: true,
|
|
257
255
|
}));
|
|
258
|
-
let userContext;
|
|
259
|
-
if (this.memoryEngineService &&
|
|
260
|
-
(createSessionDto.ucanInvocation ||
|
|
261
|
-
(createSessionDto.oracleToken && createSessionDto.userToken))) {
|
|
262
|
-
try {
|
|
263
|
-
Logger.debug('Gathering user context from Memory Engine');
|
|
264
|
-
userContext = await this.memoryEngineService.gatherUserContext({
|
|
265
|
-
oracleDid: createSessionDto.oracleDid,
|
|
266
|
-
roomId,
|
|
267
|
-
oracleToken: createSessionDto.oracleToken ?? '',
|
|
268
|
-
userToken: createSessionDto.userToken ?? '',
|
|
269
|
-
oracleHomeServer: createSessionDto.oracleHomeServer ?? '',
|
|
270
|
-
userHomeServer: createSessionDto.userHomeServer ?? '',
|
|
271
|
-
ucanInvocation: createSessionDto.ucanInvocation,
|
|
272
|
-
});
|
|
273
|
-
}
|
|
274
|
-
catch (error) {
|
|
275
|
-
Logger.error('Failed to gather user context:', error);
|
|
276
|
-
throw error;
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
256
|
const session = await this.syncSessionSet({
|
|
280
257
|
sessionId: eventId,
|
|
281
258
|
oracleName: createSessionDto.oracleName,
|
|
@@ -284,7 +261,6 @@ ___________________________________________________________
|
|
|
284
261
|
oracleDid: createSessionDto.oracleDid,
|
|
285
262
|
messages: [],
|
|
286
263
|
roomId,
|
|
287
|
-
userContext,
|
|
288
264
|
slackThreadTs: createSessionDto.slackThreadTs,
|
|
289
265
|
});
|
|
290
266
|
return session;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-manager.service.js","sourceRoot":"","sources":["../../../src/services/session-manager/session-manager.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,gCAAgC,EAAE,MAAM,2BAA2B,CAAC;AAE7E,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,sBAAsB,EACtB,iBAAiB,GAClB,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"session-manager.service.js","sourceRoot":"","sources":["../../../src/services/session-manager/session-manager.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,gCAAgC,EAAE,MAAM,2BAA2B,CAAC;AAE7E,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,sBAAsB,EACtB,iBAAiB,GAClB,MAAM,mBAAmB,CAAC;AAe3B,MAAM,OAAO,qBAAqB;IAEb;IACD;IAFlB,YACmB,WAAiC,EAClC,eAAe,aAAa,CAAC,WAAW,EAAE;QADzC,gBAAW,GAAX,WAAW,CAAsB;QAClC,iBAAY,GAAZ,YAAY,CAA8B;IACzD,CAAC;IAEG,mBAAmB,CAAC,EACzB,eAAe,GAGhB;QACC,OAAO,GAAG,eAAe,WAAW,CAAC;IACvC,CAAC;IAEO,KAAK,CAAC,kBAAkB,CAAC,EAC/B,QAAQ,GAGT;QACC,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC1B,OAAO,UAAU,CAAC;QACpB,CAAC;QACD,MAAM,QAAQ,GAAG,cAAc,EAAE,CAAC;QAClC,MAAM,MAAM,GAAG,iBAAiB,EAAE,CAAC;QAEnC,MAAM,GAAG,GACP,QAAQ,KAAK,YAAY;YACvB,CAAC,CAAC,sBAAsB,CAAC;gBACrB,KAAK,EAAE,kCAAkC;gBACzC,WAAW,EAAE,GAAG;gBAChB,O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;gBAC7B,eAAe,EAAE,gBAAgB,CAAC,eAAe;gBACjD,cAAc;aACf,CAAC,CAAC;YACH,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC;QAC3B,CAAC;QAED,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;QACvC,CAAC;QACD,MAAM,OAAO,GACX,eAAe;YACf,CAAC,MAAM,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC;gBACnC,OAAO,EAAE,0BAA0B;gBACnC,MAAM;gBACN,aAAa,EAAE,IAAI;aACpB,CAAC,CAAC,CAAC;QAON,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC;YACxC,SAAS,EAAE,OAAO;YAClB,UAAU,EAAE,gBAAgB,CAAC,UAAU;YACvC,GAAG,EAAE,gBAAgB,CAAC,GAAG;YACzB,eAAe,EAAE,gBAAgB,CAAC,eAAe;YACjD,SAAS,EAAE,gBAAgB,CAAC,SAAS;YACrC,QAAQ,EAAE,EAAE;YACZ,MAAM;YACN,aAAa,EAAE,gBAAgB,CAAC,aAAa;SAC9C,CAAC,CAAC;QAEH,OAAO,OAAO,CAAC;IACjB,CAAC;IAEM,KAAK,CAAC,aAAa,CACxB,gBAAsC;QAEtC,MAAM,EAAE,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,eAAe,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC;QACxE,EAAE,CAAC,OAAO,CAAC,2CAA2C,CAAC,CAAC,GAAG,CACzD,gBAAgB,CAAC,SAAS,CAC3B,CAAC;IACJ,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ixo/common",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.42",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/ixoworld/qiforge.git"
|
|
11
|
+
},
|
|
8
12
|
"type": "module",
|
|
9
13
|
"main": "dist/index.js",
|
|
10
14
|
"types": "dist/index.d.ts",
|
|
@@ -24,7 +28,7 @@
|
|
|
24
28
|
}
|
|
25
29
|
},
|
|
26
30
|
"devDependencies": {
|
|
27
|
-
"@langchain/langgraph-checkpoint-validation": "
|
|
31
|
+
"@langchain/langgraph-checkpoint-validation": "1.0.9",
|
|
28
32
|
"@testcontainers/postgresql": "^10.16.0",
|
|
29
33
|
"@types/better-sqlite3": "^7.6.13",
|
|
30
34
|
"@types/node": "^22.7.3",
|
|
@@ -33,7 +37,7 @@
|
|
|
33
37
|
"testcontainers": "^10.16.0",
|
|
34
38
|
"typescript": "^5.3.3",
|
|
35
39
|
"@ixo/eslint-config": "2.0.0",
|
|
36
|
-
"@ixo/oracles-events": "^1.0.
|
|
40
|
+
"@ixo/oracles-events": "^1.0.5",
|
|
37
41
|
"@ixo/typescript-config": "1.0.0",
|
|
38
42
|
"@ixo/vitest-config": "1.0.0"
|
|
39
43
|
},
|
|
@@ -41,13 +45,13 @@
|
|
|
41
45
|
"@cosmjs/proto-signing": "^0.33.0",
|
|
42
46
|
"@cosmjs/stargate": "^0.33.0",
|
|
43
47
|
"@ixo/impactxclient-sdk": "^2.3.1",
|
|
44
|
-
"@langchain/community": "
|
|
45
|
-
"@langchain/core": "
|
|
46
|
-
"@langchain/langgraph": "
|
|
47
|
-
"@langchain/langgraph-checkpoint": "
|
|
48
|
-
"@langchain/langgraph-checkpoint-sqlite": "
|
|
49
|
-
"@langchain/openai": "
|
|
50
|
-
"@langchain/textsplitters": "
|
|
48
|
+
"@langchain/community": "1.1.28",
|
|
49
|
+
"@langchain/core": "1.1.48",
|
|
50
|
+
"@langchain/langgraph": "1.3.2",
|
|
51
|
+
"@langchain/langgraph-checkpoint": "1.0.2",
|
|
52
|
+
"@langchain/langgraph-checkpoint-sqlite": "1.0.1",
|
|
53
|
+
"@langchain/openai": "1.4.7",
|
|
54
|
+
"@langchain/textsplitters": "1.0.1",
|
|
51
55
|
"@tavily/core": "0.7.2",
|
|
52
56
|
"axios": "^1.7.9",
|
|
53
57
|
"axios-retry": "^4.5.0",
|
|
@@ -56,18 +60,18 @@
|
|
|
56
60
|
"dotenv": "^16.4.5",
|
|
57
61
|
"duck-duck-scrape": "^2.2.5",
|
|
58
62
|
"html-to-text": "9.0.5",
|
|
59
|
-
"langchain": "
|
|
63
|
+
"langchain": "1.4.2",
|
|
60
64
|
"langsmith": "^0.5.25",
|
|
61
65
|
"mammoth": "1.12.0",
|
|
66
|
+
"node-emoji": "^2.2.0",
|
|
62
67
|
"openai": "^6.34.0",
|
|
63
|
-
"
|
|
68
|
+
"pdfjs-dist": "^5.4.296",
|
|
64
69
|
"playwright": "^1.59.1",
|
|
65
|
-
"node-emoji": "^2.2.0",
|
|
66
70
|
"store": "^2.0.12",
|
|
67
71
|
"zod": "^4.3.6",
|
|
68
72
|
"@ixo/logger": "0.0.2",
|
|
69
|
-
"@ixo/matrix": "1.2.
|
|
70
|
-
"@ixo/oracles-chain-client": "1.
|
|
73
|
+
"@ixo/matrix": "1.2.33",
|
|
74
|
+
"@ixo/oracles-chain-client": "1.3.1"
|
|
71
75
|
},
|
|
72
76
|
"scripts": {
|
|
73
77
|
"build": "tsc && tsc-alias",
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import { Logger } from '@ixo/logger';
|
|
2
2
|
import { DocxLoader } from '@langchain/community/document_loaders/fs/docx';
|
|
3
|
-
import { PDFLoader } from '@langchain/community/document_loaders/fs/pdf';
|
|
4
3
|
import { HtmlToTextTransformer } from '@langchain/community/document_transformers/html_to_text';
|
|
5
4
|
import { Document } from '@langchain/core/documents';
|
|
6
5
|
import { RecursiveCharacterTextSplitter } from '@langchain/textsplitters';
|
|
7
6
|
import fs from 'node:fs/promises';
|
|
7
|
+
// `@langchain/community`'s `PDFLoader` / `WebPDFLoader` both import
|
|
8
|
+
// `pdf-parse/lib/pdf.js/v1.10.100/build/pdf.js` — a subpath that pdf-parse 2.x
|
|
9
|
+
// no longer exposes in its `exports` field, throwing `ERR_PACKAGE_PATH_NOT_EXPORTED`
|
|
10
|
+
// at runtime. We use pdfjs-dist (the same engine LangChain wraps) directly
|
|
11
|
+
// and keep one Document per page so callers can preserve page boundaries.
|
|
12
|
+
import { getDocument } from 'pdfjs-dist/legacy/build/pdf.mjs';
|
|
8
13
|
|
|
9
14
|
type SupportedFileType = 'pdf' | 'markdown' | 'html' | 'text' | 'doc';
|
|
10
15
|
const splitter = new RecursiveCharacterTextSplitter({
|
|
@@ -130,8 +135,7 @@ const processFile = async (
|
|
|
130
135
|
): Promise<Document[]> => {
|
|
131
136
|
switch (fileType) {
|
|
132
137
|
case 'pdf': {
|
|
133
|
-
|
|
134
|
-
return pdfLoader.load();
|
|
138
|
+
return loadPdf(blob);
|
|
135
139
|
}
|
|
136
140
|
|
|
137
141
|
case 'markdown': {
|
|
@@ -169,6 +173,51 @@ const loadMarkdown = async (blob: Blob): Promise<Document[]> => {
|
|
|
169
173
|
return splitter.createDocuments([markdown]);
|
|
170
174
|
};
|
|
171
175
|
|
|
176
|
+
const loadPdf = async (blob: Blob): Promise<Document[]> => {
|
|
177
|
+
const data = new Uint8Array(await blob.arrayBuffer());
|
|
178
|
+
// Mirror the parser options LangChain's WebPDFLoader used — disable worker
|
|
179
|
+
// fetch / eval so this runs cleanly in a Node server context.
|
|
180
|
+
const pdf = await getDocument({
|
|
181
|
+
data,
|
|
182
|
+
useWorkerFetch: false,
|
|
183
|
+
useSystemFonts: true,
|
|
184
|
+
}).promise;
|
|
185
|
+
const meta = await pdf.getMetadata().catch(() => null);
|
|
186
|
+
const documents: Document[] = [];
|
|
187
|
+
for (let i = 1; i <= pdf.numPages; i++) {
|
|
188
|
+
const page = await pdf.getPage(i);
|
|
189
|
+
const content = await page.getTextContent();
|
|
190
|
+
if (content.items.length === 0) continue;
|
|
191
|
+
let lastY: number | undefined;
|
|
192
|
+
const parts: string[] = [];
|
|
193
|
+
for (const item of content.items) {
|
|
194
|
+
if (!('str' in item)) continue;
|
|
195
|
+
// Insert a newline when the y-coordinate changes — preserves visual
|
|
196
|
+
// line breaks instead of running text together.
|
|
197
|
+
if (lastY !== undefined && lastY !== item.transform[5]) {
|
|
198
|
+
parts.push('\n');
|
|
199
|
+
}
|
|
200
|
+
parts.push(item.str);
|
|
201
|
+
lastY = item.transform[5];
|
|
202
|
+
}
|
|
203
|
+
documents.push(
|
|
204
|
+
new Document({
|
|
205
|
+
pageContent: parts.join(''),
|
|
206
|
+
metadata: {
|
|
207
|
+
pdf: {
|
|
208
|
+
version: (pdf as unknown as { _pdfInfo?: { fingerprint?: string } })
|
|
209
|
+
._pdfInfo?.fingerprint,
|
|
210
|
+
info: meta?.info,
|
|
211
|
+
totalPages: pdf.numPages,
|
|
212
|
+
},
|
|
213
|
+
loc: { pageNumber: i },
|
|
214
|
+
},
|
|
215
|
+
}),
|
|
216
|
+
);
|
|
217
|
+
}
|
|
218
|
+
return documents;
|
|
219
|
+
};
|
|
220
|
+
|
|
172
221
|
const blobToString = async (blob: Blob): Promise<string> => {
|
|
173
222
|
const buffer = await blob.arrayBuffer(); // Convert Blob to ArrayBuffer
|
|
174
223
|
return Buffer.from(buffer).toString('utf-8'); // Convert ArrayBuffer to string
|
|
@@ -11,7 +11,7 @@ export class EnvService<T extends z.ZodType> {
|
|
|
11
11
|
private constructor(schema: T, onError?: (error: z.ZodError) => void) {
|
|
12
12
|
try {
|
|
13
13
|
// Parse and validate environment variables
|
|
14
|
-
this.validatedEnv = schema.parse(process.env)
|
|
14
|
+
this.validatedEnv = schema.parse(process.env);
|
|
15
15
|
} catch (error) {
|
|
16
16
|
if (error instanceof z.ZodError) {
|
|
17
17
|
if (onError) {
|
|
@@ -33,7 +33,7 @@ export class EnvService<T extends z.ZodType> {
|
|
|
33
33
|
if (EnvService.instance === null) {
|
|
34
34
|
EnvService.instance = new EnvService(schema);
|
|
35
35
|
}
|
|
36
|
-
return EnvService.instance
|
|
36
|
+
return EnvService.instance;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
/**
|
|
@@ -44,7 +44,7 @@ export class EnvService<T extends z.ZodType> {
|
|
|
44
44
|
if (EnvService.instance === null) {
|
|
45
45
|
throw new Error('EnvService must be initialized with a schema first');
|
|
46
46
|
}
|
|
47
|
-
return EnvService.instance
|
|
47
|
+
return EnvService.instance;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
/**
|
|
@@ -18,9 +18,14 @@ interface MemoryEngineAuthHeaders {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
export class MemoryEngineService {
|
|
21
|
-
//
|
|
22
|
-
//
|
|
23
|
-
|
|
21
|
+
// Soft deadline: how long the caller waits before falling back to empty
|
|
22
|
+
// context. The underlying fetch keeps running in the background up to
|
|
23
|
+
// BATCH_HARD_TIMEOUT_MS so the server-side query can still finish (and warm
|
|
24
|
+
// caches) even after the user's turn has moved on.
|
|
25
|
+
private readonly BATCH_TIMEOUT_MS = 30000;
|
|
26
|
+
// Hard cap on the underlying fetch — prevents leaking sockets if the server
|
|
27
|
+
// never responds. Anything slower than this is treated as a real failure.
|
|
28
|
+
private readonly BATCH_HARD_TIMEOUT_MS = 60000;
|
|
24
29
|
|
|
25
30
|
constructor(private readonly memoryEngineUrl: string) {}
|
|
26
31
|
|
|
@@ -105,6 +110,7 @@ export class MemoryEngineService {
|
|
|
105
110
|
|
|
106
111
|
const gatherStart = Date.now();
|
|
107
112
|
const batch = await this.executeBatch(requests, roomId, authHeaders);
|
|
113
|
+
|
|
108
114
|
const gatherElapsed = Date.now() - gatherStart;
|
|
109
115
|
|
|
110
116
|
if (!batch) {
|
|
@@ -179,41 +185,91 @@ export class MemoryEngineService {
|
|
|
179
185
|
|
|
180
186
|
const body: SearchEnhancedBatchRequest = { queries };
|
|
181
187
|
|
|
182
|
-
|
|
183
|
-
|
|
188
|
+
// Hard cap aborts the fetch so a hung server can't leak sockets. The soft
|
|
189
|
+
// deadline below is what the caller actually awaits.
|
|
190
|
+
const hardController = new AbortController();
|
|
191
|
+
const hardTimer = setTimeout(
|
|
192
|
+
() => hardController.abort(),
|
|
193
|
+
this.BATCH_HARD_TIMEOUT_MS,
|
|
194
|
+
);
|
|
184
195
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
196
|
+
const start = Date.now();
|
|
197
|
+
|
|
198
|
+
const requestPromise: Promise<SearchEnhancedBatchResponse | undefined> =
|
|
199
|
+
(async () => {
|
|
200
|
+
try {
|
|
201
|
+
const response = await fetch(
|
|
202
|
+
`${this.memoryEngineUrl}/search-enhanced-batch`,
|
|
203
|
+
{
|
|
204
|
+
method: 'POST',
|
|
205
|
+
headers: this.buildHeaders(auth, roomId),
|
|
206
|
+
body: JSON.stringify(body),
|
|
207
|
+
signal: hardController.signal,
|
|
208
|
+
},
|
|
209
|
+
);
|
|
210
|
+
|
|
211
|
+
if (!response.ok) {
|
|
212
|
+
const errorText = await response.text();
|
|
213
|
+
Logger.warn(
|
|
214
|
+
`[MemoryEngineService] Batch search failed (${response.status}): ${errorText}`,
|
|
215
|
+
);
|
|
216
|
+
return undefined;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
return (await response.json()) as SearchEnhancedBatchResponse;
|
|
220
|
+
} catch (error) {
|
|
221
|
+
if ((error as Error).name === 'AbortError') {
|
|
222
|
+
Logger.warn(
|
|
223
|
+
`[MemoryEngineService] Batch search hit hard cap after ${this.BATCH_HARD_TIMEOUT_MS}ms — aborted`,
|
|
224
|
+
);
|
|
225
|
+
} else {
|
|
226
|
+
Logger.error(`[MemoryEngineService] Batch search threw:`, error);
|
|
227
|
+
}
|
|
228
|
+
return undefined;
|
|
229
|
+
} finally {
|
|
230
|
+
clearTimeout(hardTimer);
|
|
231
|
+
}
|
|
232
|
+
})();
|
|
233
|
+
|
|
234
|
+
type Outcome =
|
|
235
|
+
| { kind: 'result'; value: SearchEnhancedBatchResponse | undefined }
|
|
236
|
+
| { kind: 'timeout' };
|
|
237
|
+
|
|
238
|
+
let softTimer: ReturnType<typeof setTimeout> | undefined;
|
|
239
|
+
const softDeadline = new Promise<Outcome>((resolve) => {
|
|
240
|
+
softTimer = setTimeout(
|
|
241
|
+
() => resolve({ kind: 'timeout' }),
|
|
242
|
+
this.BATCH_TIMEOUT_MS,
|
|
194
243
|
);
|
|
244
|
+
});
|
|
195
245
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
);
|
|
201
|
-
return undefined;
|
|
202
|
-
}
|
|
246
|
+
const outcome = await Promise.race<Outcome>([
|
|
247
|
+
requestPromise.then((value): Outcome => ({ kind: 'result', value })),
|
|
248
|
+
softDeadline,
|
|
249
|
+
]);
|
|
203
250
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
251
|
+
if (softTimer) clearTimeout(softTimer);
|
|
252
|
+
|
|
253
|
+
if (outcome.kind === 'timeout') {
|
|
254
|
+
Logger.warn(
|
|
255
|
+
`[MemoryEngineService] Batch search exceeded ${this.BATCH_TIMEOUT_MS}ms soft deadline — returning empty context, request continues in background (hard cap ${this.BATCH_HARD_TIMEOUT_MS}ms)`,
|
|
256
|
+
);
|
|
257
|
+
void requestPromise.then((result) => {
|
|
258
|
+
const elapsed = Date.now() - start;
|
|
259
|
+
if (result) {
|
|
260
|
+
Logger.info(
|
|
261
|
+
`[MemoryEngineService] Background batch search finished after ${elapsed}ms (caller gave up at ${this.BATCH_TIMEOUT_MS}ms)`,
|
|
262
|
+
);
|
|
263
|
+
} else {
|
|
264
|
+
Logger.warn(
|
|
265
|
+
`[MemoryEngineService] Background batch search returned no data after ${elapsed}ms`,
|
|
266
|
+
);
|
|
267
|
+
}
|
|
268
|
+
});
|
|
213
269
|
return undefined;
|
|
214
|
-
} finally {
|
|
215
|
-
clearTimeout(timer);
|
|
216
270
|
}
|
|
271
|
+
|
|
272
|
+
return outcome.value;
|
|
217
273
|
}
|
|
218
274
|
|
|
219
275
|
// ── Per-query request builders ────────────────────────────────────────────
|
|
@@ -221,14 +277,35 @@ export class MemoryEngineService {
|
|
|
221
277
|
// via the batch endpoint. Order matches the labels array in
|
|
222
278
|
// gatherUserContext — keep the two in sync.
|
|
223
279
|
|
|
280
|
+
// Design notes for the query builders:
|
|
281
|
+
//
|
|
282
|
+
// 1. Queries are natural-language sentences, not keyword bags. Embedding
|
|
283
|
+
// search ranks by semantic similarity — a sentence that names both the
|
|
284
|
+
// abstract concept ("what the user works on") and concrete examples
|
|
285
|
+
// ("tools, projects, people they collaborate with") aligns far better
|
|
286
|
+
// with how real memories are phrased than a thesaurus of synonyms.
|
|
287
|
+
//
|
|
288
|
+
// 2. `edge_types` is deliberately not used. It is AND-ed with node_labels
|
|
289
|
+
// before scoring, and the extractor's edge choices vary too much to
|
|
290
|
+
// predict (a work mention may produce WorksWith, Mentions, Discusses,
|
|
291
|
+
// RelatesTo). One filter miss drops the whole fact. Semantic scoring
|
|
292
|
+
// handles discrimination better than guessing edge types.
|
|
293
|
+
//
|
|
294
|
+
// 3. `node_labels` is kept where it's discriminating but broadened to cover
|
|
295
|
+
// the EntityType variants the extractor actually emits (Event/Experience/
|
|
296
|
+
// Procedure/Task all show up for work episodes, for example).
|
|
297
|
+
//
|
|
298
|
+
// 4. `invalid_at IS NULL` filters out facts that have been superseded —
|
|
299
|
+
// kept everywhere except `recent`, which already constrains on created_at.
|
|
300
|
+
|
|
224
301
|
private buildIdentityRequest(oracleDid: string): SearchEnhancedRequest {
|
|
225
302
|
return {
|
|
226
303
|
oracle_dids: [oracleDid],
|
|
227
304
|
query:
|
|
228
|
-
'
|
|
305
|
+
'Who is the user — their name, age, background, personality traits, communication style, beliefs, values, and the core attributes that define how they see themselves and how they like to be addressed.',
|
|
229
306
|
strategy: 'balanced',
|
|
230
|
-
max_facts:
|
|
231
|
-
max_entities:
|
|
307
|
+
max_facts: 12,
|
|
308
|
+
max_entities: 8,
|
|
232
309
|
max_episodes: 3,
|
|
233
310
|
max_communities: 2,
|
|
234
311
|
knowledge_level: 'both',
|
|
@@ -239,9 +316,9 @@ export class MemoryEngineService {
|
|
|
239
316
|
'Value',
|
|
240
317
|
'Identity',
|
|
241
318
|
'Attribute',
|
|
242
|
-
'Emotion',
|
|
243
319
|
'Belief',
|
|
244
320
|
'CommunicationStyle',
|
|
321
|
+
'Language',
|
|
245
322
|
],
|
|
246
323
|
invalid_at: [[{ date: null, comparison_operator: 'IS NULL' }]],
|
|
247
324
|
},
|
|
@@ -252,31 +329,14 @@ export class MemoryEngineService {
|
|
|
252
329
|
return {
|
|
253
330
|
oracle_dids: [oracleDid],
|
|
254
331
|
query:
|
|
255
|
-
'
|
|
332
|
+
'What the user works on — their job and role, current and past projects, the tools and technologies they use, code or systems they build, technical problems they solve (migrations, refactors, bug fixes, integrations), and the people they collaborate with at work.',
|
|
256
333
|
strategy: 'balanced',
|
|
257
|
-
max_facts:
|
|
258
|
-
max_entities:
|
|
259
|
-
max_episodes:
|
|
334
|
+
max_facts: 15,
|
|
335
|
+
max_entities: 10,
|
|
336
|
+
max_episodes: 5,
|
|
260
337
|
max_communities: 2,
|
|
261
338
|
knowledge_level: 'both',
|
|
262
339
|
search_filters: {
|
|
263
|
-
node_labels: [
|
|
264
|
-
'Job',
|
|
265
|
-
'Project',
|
|
266
|
-
'Organization',
|
|
267
|
-
'Skill',
|
|
268
|
-
'Tool',
|
|
269
|
-
'Expertise',
|
|
270
|
-
'Task',
|
|
271
|
-
],
|
|
272
|
-
edge_types: [
|
|
273
|
-
'EmployedAt',
|
|
274
|
-
'WorksOn',
|
|
275
|
-
'Manages',
|
|
276
|
-
'Uses',
|
|
277
|
-
'ExpertiseIn',
|
|
278
|
-
'WorksWith',
|
|
279
|
-
],
|
|
280
340
|
invalid_at: [[{ date: null, comparison_operator: 'IS NULL' }]],
|
|
281
341
|
},
|
|
282
342
|
};
|
|
@@ -286,23 +346,14 @@ export class MemoryEngineService {
|
|
|
286
346
|
return {
|
|
287
347
|
oracle_dids: [oracleDid],
|
|
288
348
|
query:
|
|
289
|
-
'goals aspirations
|
|
349
|
+
'What the user is trying to achieve or improve — goals and aspirations they have stated, things they are learning, habits and routines they are building, milestones they are working toward, and causes they care about.',
|
|
290
350
|
strategy: 'balanced',
|
|
291
|
-
max_facts:
|
|
292
|
-
max_entities:
|
|
351
|
+
max_facts: 10,
|
|
352
|
+
max_entities: 6,
|
|
293
353
|
max_episodes: 3,
|
|
294
354
|
max_communities: 1,
|
|
295
355
|
knowledge_level: 'both',
|
|
296
356
|
search_filters: {
|
|
297
|
-
node_labels: [
|
|
298
|
-
'Goal',
|
|
299
|
-
'Milestone',
|
|
300
|
-
'Habit',
|
|
301
|
-
'Routine',
|
|
302
|
-
'Pattern',
|
|
303
|
-
'LearningGoal',
|
|
304
|
-
],
|
|
305
|
-
edge_types: ['Pursuing', 'Achieved', 'Practices', 'Motivates'],
|
|
306
357
|
invalid_at: [[{ date: null, comparison_operator: 'IS NULL' }]],
|
|
307
358
|
},
|
|
308
359
|
};
|
|
@@ -312,30 +363,14 @@ export class MemoryEngineService {
|
|
|
312
363
|
return {
|
|
313
364
|
oracle_dids: [oracleDid],
|
|
314
365
|
query:
|
|
315
|
-
'
|
|
366
|
+
'What the user enjoys, cares about, or finds interesting — hobbies, favorite topics, preferences, products and content they engage with, things they like and dislike, and areas they have built expertise in outside of work.',
|
|
316
367
|
strategy: 'balanced',
|
|
317
|
-
max_facts:
|
|
318
|
-
max_entities:
|
|
368
|
+
max_facts: 10,
|
|
369
|
+
max_entities: 6,
|
|
319
370
|
max_episodes: 3,
|
|
320
371
|
max_communities: 1,
|
|
321
372
|
knowledge_level: 'both',
|
|
322
373
|
search_filters: {
|
|
323
|
-
node_labels: [
|
|
324
|
-
'Interest',
|
|
325
|
-
'Hobby',
|
|
326
|
-
'Preference',
|
|
327
|
-
'Product',
|
|
328
|
-
'Content',
|
|
329
|
-
'Expertise',
|
|
330
|
-
'Resource',
|
|
331
|
-
],
|
|
332
|
-
edge_types: [
|
|
333
|
-
'Prefers',
|
|
334
|
-
'Likes',
|
|
335
|
-
'Dislikes',
|
|
336
|
-
'InterestedIn',
|
|
337
|
-
'ExpertiseIn',
|
|
338
|
-
],
|
|
339
374
|
invalid_at: [[{ date: null, comparison_operator: 'IS NULL' }]],
|
|
340
375
|
},
|
|
341
376
|
};
|
|
@@ -345,23 +380,14 @@ export class MemoryEngineService {
|
|
|
345
380
|
return {
|
|
346
381
|
oracle_dids: [oracleDid],
|
|
347
382
|
query:
|
|
348
|
-
'
|
|
383
|
+
'People the user interacts with or has mentioned — colleagues they work with, collaborators on projects, friends and family members, and any named individuals or groups they have brought up in conversation.',
|
|
349
384
|
strategy: 'balanced',
|
|
350
|
-
max_facts:
|
|
351
|
-
max_entities:
|
|
352
|
-
max_episodes:
|
|
385
|
+
max_facts: 8,
|
|
386
|
+
max_entities: 10,
|
|
387
|
+
max_episodes: 3,
|
|
353
388
|
max_communities: 1,
|
|
354
389
|
knowledge_level: 'both',
|
|
355
390
|
search_filters: {
|
|
356
|
-
node_labels: ['Person', 'Group'],
|
|
357
|
-
edge_types: [
|
|
358
|
-
'Knows',
|
|
359
|
-
'WorksWith',
|
|
360
|
-
'MemberOf',
|
|
361
|
-
'Influences',
|
|
362
|
-
'Supports',
|
|
363
|
-
'RelatesTo',
|
|
364
|
-
],
|
|
365
391
|
invalid_at: [[{ date: null, comparison_operator: 'IS NULL' }]],
|
|
366
392
|
},
|
|
367
393
|
};
|
|
@@ -371,6 +397,8 @@ export class MemoryEngineService {
|
|
|
371
397
|
// Server-side `recent_memory` strategy auto-injects a created_at >= now-90d
|
|
372
398
|
// filter. We still pass it explicitly as defense-in-depth — the server's
|
|
373
399
|
// merge logic respects an existing lower bound and won't double-apply.
|
|
400
|
+
// No node_labels filter: recent activity can be of any type, and the
|
|
401
|
+
// created_at window is already doing the heavy filtering.
|
|
374
402
|
const ninetyDaysAgo = new Date();
|
|
375
403
|
ninetyDaysAgo.setDate(ninetyDaysAgo.getDate() - 90);
|
|
376
404
|
const dateString = ninetyDaysAgo.toISOString();
|
|
@@ -378,11 +406,11 @@ export class MemoryEngineService {
|
|
|
378
406
|
return {
|
|
379
407
|
oracle_dids: [oracleDid],
|
|
380
408
|
query:
|
|
381
|
-
'
|
|
409
|
+
'What the user has been doing, focusing on, or talking about recently — current activities, decisions they have made, ongoing problems they are working through, and topics that have come up in recent conversations.',
|
|
382
410
|
strategy: 'recent_memory',
|
|
383
|
-
max_facts:
|
|
384
|
-
max_entities:
|
|
385
|
-
max_episodes:
|
|
411
|
+
max_facts: 10,
|
|
412
|
+
max_entities: 6,
|
|
413
|
+
max_episodes: 8,
|
|
386
414
|
max_communities: 2,
|
|
387
415
|
knowledge_level: 'both',
|
|
388
416
|
search_filters: {
|
|
@@ -397,10 +425,10 @@ export class MemoryEngineService {
|
|
|
397
425
|
async processConversationHistory({
|
|
398
426
|
messages,
|
|
399
427
|
roomId,
|
|
400
|
-
oracleToken,
|
|
401
|
-
userToken,
|
|
402
|
-
oracleHomeServer,
|
|
403
|
-
userHomeServer,
|
|
428
|
+
oracleToken = '',
|
|
429
|
+
userToken = '',
|
|
430
|
+
oracleHomeServer = '',
|
|
431
|
+
userHomeServer = '',
|
|
404
432
|
ucanInvocation,
|
|
405
433
|
}: {
|
|
406
434
|
messages: Array<{
|
|
@@ -411,11 +439,15 @@ export class MemoryEngineService {
|
|
|
411
439
|
source_description?: string;
|
|
412
440
|
}>;
|
|
413
441
|
roomId: string;
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
/**
|
|
442
|
+
/** Deprecated — Matrix bearer auth. Use `ucanInvocation` instead. */
|
|
443
|
+
oracleToken?: string;
|
|
444
|
+
/** Deprecated — Matrix bearer auth. Use `ucanInvocation` instead. */
|
|
445
|
+
userToken?: string;
|
|
446
|
+
/** Deprecated — Matrix bearer auth. Use `ucanInvocation` instead. */
|
|
447
|
+
oracleHomeServer?: string;
|
|
448
|
+
/** Deprecated — Matrix bearer auth. Use `ucanInvocation` instead. */
|
|
449
|
+
userHomeServer?: string;
|
|
450
|
+
/** Required under UCAN-only auth. */
|
|
419
451
|
ucanInvocation?: string;
|
|
420
452
|
}): Promise<{ success: boolean }> {
|
|
421
453
|
if (!roomId) {
|