@mingxy/cerebro 1.7.6 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/client.ts +4 -0
- package/src/hooks.ts +13 -1
package/package.json
CHANGED
package/src/client.ts
CHANGED
|
@@ -364,11 +364,15 @@ export class OmemClient {
|
|
|
364
364
|
messages: Array<{ role: string; content: string }>,
|
|
365
365
|
sessionId?: string,
|
|
366
366
|
agentId?: string,
|
|
367
|
+
sessionTitle?: string,
|
|
368
|
+
projectName?: string,
|
|
367
369
|
): Promise<unknown> {
|
|
368
370
|
return this.post("/v1/memories/session-ingest", {
|
|
369
371
|
messages,
|
|
370
372
|
session_id: sessionId,
|
|
371
373
|
agent_id: agentId,
|
|
374
|
+
session_title: sessionTitle,
|
|
375
|
+
project_name: projectName,
|
|
372
376
|
}, 60000);
|
|
373
377
|
}
|
|
374
378
|
}
|
package/src/hooks.ts
CHANGED
|
@@ -419,8 +419,20 @@ export function sessionIdleHook(
|
|
|
419
419
|
return;
|
|
420
420
|
}
|
|
421
421
|
|
|
422
|
+
let sessionTitle: string | undefined;
|
|
423
|
+
let projectName: string | undefined;
|
|
422
424
|
try {
|
|
423
|
-
await
|
|
425
|
+
const sessionInfo = await sdkClient.session.get({ path: { id: sessionID } });
|
|
426
|
+
sessionTitle = sessionInfo?.title;
|
|
427
|
+
projectName = sessionInfo?.project?.rootPath
|
|
428
|
+
? sessionInfo.project.rootPath.split("/").pop()
|
|
429
|
+
: undefined;
|
|
430
|
+
} catch (e) {
|
|
431
|
+
// 获取失败不影响主流程
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
try {
|
|
435
|
+
await omemClient.sessionIngest(conversationMessages, sessionID, undefined, sessionTitle, projectName);
|
|
424
436
|
for (const id of newMessageIds) {
|
|
425
437
|
processedMessageIds.add(id);
|
|
426
438
|
}
|