MCPcopy Create free account
hub / github.com/echoVic/blade-code / init

Method init

src/agent/ContextComponent.ts:78–114  ·  view source on GitHub ↗

* 初始化上下文组件

()

Source from the content-addressed store, hash-verified

76 * 初始化上下文组件
77 */
78 public async init(): Promise<void> {
79 if (!this.config.enabled) {
80 this.log('上下文组件已禁用,跳过初始化');
81 return;
82 }
83
84 if (this.isReady) {
85 throw new Error('上下文组件已经初始化');
86 }
87
88 this.log('初始化上下文组件...');
89
90 try {
91 // 创建上下文管理器配置
92 const managerOptions: Partial<ContextManagerOptions> = {
93 storage: this.config.storage && {
94 maxMemorySize: this.config.storage.maxMemorySize || 1000,
95 persistentPath: this.config.storage.persistentPath,
96 cacheSize: this.config.storage.cacheSize || 100,
97 compressionEnabled: this.config.storage.compressionEnabled || true,
98 },
99 defaultFilter: this.config.defaultFilter,
100 compressionThreshold: this.config.compressionThreshold,
101 enableVectorSearch: this.config.enableVectorSearch,
102 };
103
104 // 创建并初始化上下文管理器
105 this.contextManager = createContextManager(managerOptions);
106 await this.contextManager.initialize();
107
108 this.isReady = true;
109 this.log('上下文组件初始化完成');
110 } catch (error) {
111 this.log(`上下文组件初始化失败: ${error}`);
112 throw error;
113 }
114 }
115
116 /**
117 * 销毁上下文组件

Callers

nothing calls this directly

Calls 3

logMethod · 0.95
createContextManagerFunction · 0.85
initializeMethod · 0.45

Tested by

no test coverage detected