hyacinth-ai 0.9.12 → 0.9.13
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.
|
@@ -61,7 +61,7 @@ export interface AgentComponents {
|
|
|
61
61
|
kbState: {
|
|
62
62
|
lastQuery: string;
|
|
63
63
|
};
|
|
64
|
-
kbWatcher: KnowledgeWatcher;
|
|
64
|
+
kbWatcher: KnowledgeWatcher | null;
|
|
65
65
|
/** 知识库结构化存储(懒加载,只在知识库启用时才创建) */
|
|
66
66
|
structuredStore: StructuredStore | null;
|
|
67
67
|
composeStrategy: ComposeStrategy;
|
package/dist/gateway/factory.js
CHANGED
|
@@ -501,12 +501,18 @@ export async function createAgent(options, supervisor) {
|
|
|
501
501
|
// 结构化知识库工具(4合1:add/update/delete/list)
|
|
502
502
|
toolRegistry.register(createStructuredTool(getStructuredStore, () => knowledgeBase.enabled));
|
|
503
503
|
// ── 知识库文件监控(后台自动索引 files/ 目录变更)─────────────────
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
504
|
+
// 懒创建 — 只在知识库启用后才启动
|
|
505
|
+
let _kbWatcher = null;
|
|
506
|
+
function getWatcher() {
|
|
507
|
+
if (!_kbWatcher) {
|
|
508
|
+
_kbWatcher = new KnowledgeWatcher({
|
|
509
|
+
filesDir: kbFilesDir,
|
|
510
|
+
retriever: knowledgeBase.retriever,
|
|
511
|
+
});
|
|
512
|
+
_kbWatcher.start().catch(() => { });
|
|
513
|
+
}
|
|
514
|
+
return _kbWatcher;
|
|
515
|
+
}
|
|
510
516
|
// ── Command Registry(斜杠命令外部配置化,支持模型修改 + 热重载) ──
|
|
511
517
|
CommandRegistry.getInstance(cwd);
|
|
512
518
|
// ── AgentLoop ─────────────────────────────────────────────────────
|
|
@@ -837,7 +843,7 @@ export async function createAgent(options, supervisor) {
|
|
|
837
843
|
providerConfigLoader,
|
|
838
844
|
knowledgeBase,
|
|
839
845
|
kbState,
|
|
840
|
-
kbWatcher,
|
|
846
|
+
kbWatcher: _kbWatcher,
|
|
841
847
|
structuredStore: _structuredStore,
|
|
842
848
|
composeStrategy,
|
|
843
849
|
companionSessionManager,
|
|
@@ -7,10 +7,13 @@
|
|
|
7
7
|
import type { Retriever, KbDocument, KbSearchResult } from './retriever.js';
|
|
8
8
|
export type { KbDocument as KbDoc, KbSearchResult as KbResult } from './retriever.js';
|
|
9
9
|
export declare class KnowledgeBase {
|
|
10
|
-
|
|
10
|
+
private _retriever;
|
|
11
|
+
private _dbPath;
|
|
11
12
|
private _enabled;
|
|
12
13
|
private _zone4Enabled;
|
|
13
14
|
constructor(dbPathOrRetriever: string | Retriever);
|
|
15
|
+
/** 懒加载 retriever,仅在首次访问时创建 Fts5Retriever */
|
|
16
|
+
get retriever(): Retriever;
|
|
14
17
|
get enabled(): boolean;
|
|
15
18
|
enable(): void;
|
|
16
19
|
disable(): void;
|
package/dist/knowledge/store.js
CHANGED
|
@@ -6,17 +6,25 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { Fts5Retriever } from './fts5-retriever.js';
|
|
8
8
|
export class KnowledgeBase {
|
|
9
|
-
|
|
9
|
+
_retriever = null;
|
|
10
|
+
_dbPath;
|
|
10
11
|
_enabled = false;
|
|
11
12
|
_zone4Enabled = true; // Zone 4 默认开启
|
|
12
13
|
constructor(dbPathOrRetriever) {
|
|
13
14
|
if (typeof dbPathOrRetriever === 'string') {
|
|
14
|
-
this.
|
|
15
|
+
this._dbPath = dbPathOrRetriever;
|
|
15
16
|
}
|
|
16
17
|
else {
|
|
17
|
-
this.
|
|
18
|
+
this._retriever = dbPathOrRetriever;
|
|
18
19
|
}
|
|
19
20
|
}
|
|
21
|
+
/** 懒加载 retriever,仅在首次访问时创建 Fts5Retriever */
|
|
22
|
+
get retriever() {
|
|
23
|
+
if (!this._retriever) {
|
|
24
|
+
this._retriever = new Fts5Retriever(this._dbPath);
|
|
25
|
+
}
|
|
26
|
+
return this._retriever;
|
|
27
|
+
}
|
|
20
28
|
// ── 状态管理 ──────────────────────────────────────────────────────
|
|
21
29
|
get enabled() {
|
|
22
30
|
return this._enabled && this._zone4Enabled;
|