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

Method removeComponent

src/agent/ComponentManager.ts:159–181  ·  view source on GitHub ↗

* 移除组件

(id: string)

Source from the content-addressed store, hash-verified

157 * 移除组件
158 */
159 public async removeComponent(id: string): Promise<boolean> {
160 const component = this.components.get(id);
161 if (!component) {
162 return false;
163 }
164
165 try {
166 // 如果管理器已初始化,先销毁组件
167 if (this.isInitialized) {
168 await component.destroy();
169 this.emit('componentDestroyed', { id, component });
170 }
171
172 this.components.delete(id);
173 this.log(`组件 "${id}" 已移除`);
174 this.emit('componentRemoved', { id });
175 return true;
176 } catch (error) {
177 this.log(`移除组件 "${id}" 失败: ${error}`);
178 this.emit('componentRemovalFailed', { id, component, error: error as Error });
179 throw error;
180 }
181 }
182
183 /**
184 * 获取所有组件ID

Callers 1

removeComponentsMethod · 0.95

Calls 5

logMethod · 0.95
getMethod · 0.80
deleteMethod · 0.80
destroyMethod · 0.45
emitMethod · 0.45

Tested by

no test coverage detected