更新资源管理器和协议处理逻辑:优化角色资源的合并方式,支持直接处理thought和execution的路径字符串,同时增强对@project://前缀的处理,提升路径解析的灵活性和准确性。

This commit is contained in:
sean
2025-06-11 00:00:25 +08:00
parent 192eb2a0df
commit 64b6b20247
3 changed files with 27 additions and 6 deletions

View File

@ -90,9 +90,15 @@ class ResourceManager {
if (extractedSystemResources[resourceType]) {
if (!mergedRegistry[resourceType]) mergedRegistry[resourceType] = {}
for (const [id, resourceInfo] of Object.entries(extractedSystemResources[resourceType])) {
mergedRegistry[resourceType][id] = {
...resourceInfo,
source: 'system'
// 对于role资源resourceInfo是对象对于thought/executionresourceInfo是字符串
if (resourceType === 'role') {
mergedRegistry[resourceType][id] = {
...resourceInfo,
source: 'system'
}
} else {
// 对于thought和executionresourceInfo直接是路径字符串
mergedRegistry[resourceType][id] = resourceInfo
}
}
}
@ -161,9 +167,16 @@ class ResourceManager {
const protocolHandler = new ProtocolClass()
// 从统一注册表获取协议配置
const protocolConfig = this.registry.protocols[protocolName]
if (protocolConfig && protocolConfig.registry) {
protocolHandler.setRegistry(protocolConfig.registry)
// 对于基础协议(thought, execution等)直接从registry中获取
const protocolRegistry = this.registry[protocolName]
if (protocolRegistry) {
protocolHandler.setRegistry(protocolRegistry)
} else {
// 对于复杂协议配置从protocols配置中获取
const protocolConfig = this.registry.protocols && this.registry.protocols[protocolName]
if (protocolConfig && protocolConfig.registry) {
protocolHandler.setRegistry(protocolConfig.registry)
}
}
handlers.set(protocolName, protocolHandler)