feat(app-instance): 集成Beaver后端并更新配置管理
集成新的Beaver后端服务到应用实例中,替换原有的nanobot实现。 主要变更包括: - 在Dockerfile和环境配置中添加Beaver相关路径和配置变量 - 更新工作目录结构从.nanobot到.beaver - 实现Beaver引擎加载器,支持配置文件加载和工具组装 - 添加内置工具如ListDirectoryTool、ReadFileTool、SearchFilesTool - 更新消息处理流程,支持通道适配器和网关模式 - 重构技能系统,支持显式工具提示和嵌入式检索 - 改进错误处理和生命周期管理 此变更使应用实例能够使用统一的Beaver后端进行AI代理运行时管理。
This commit is contained in:
@ -20,7 +20,7 @@ import shutil
|
||||
from typing import Any
|
||||
|
||||
|
||||
def parse_frontmatter(content: str) -> tuple[dict[str, str], str]:
|
||||
def parse_frontmatter(content: str) -> tuple[dict[str, Any], str]:
|
||||
"""解析 Markdown 文件顶部的极简 frontmatter。
|
||||
|
||||
当前先只支持最常见的:
|
||||
@ -43,12 +43,36 @@ def parse_frontmatter(content: str) -> tuple[dict[str, str], str]:
|
||||
if match is None:
|
||||
return {}, content
|
||||
|
||||
metadata: dict[str, str] = {}
|
||||
for line in match.group(1).splitlines():
|
||||
metadata: dict[str, Any] = {}
|
||||
lines = match.group(1).splitlines()
|
||||
index = 0
|
||||
while index < len(lines):
|
||||
line = lines[index]
|
||||
if ":" not in line:
|
||||
index += 1
|
||||
continue
|
||||
key, value = line.split(":", 1)
|
||||
metadata[key.strip()] = value.strip().strip('"\'')
|
||||
key = key.strip()
|
||||
value = value.strip()
|
||||
if not value:
|
||||
items: list[str] = []
|
||||
lookahead = index + 1
|
||||
while lookahead < len(lines):
|
||||
candidate = lines[lookahead]
|
||||
stripped = candidate.strip()
|
||||
if not stripped:
|
||||
lookahead += 1
|
||||
continue
|
||||
if not stripped.startswith("- "):
|
||||
break
|
||||
items.append(stripped[2:].strip().strip('"\''))
|
||||
lookahead += 1
|
||||
if items:
|
||||
metadata[key] = items
|
||||
index = lookahead
|
||||
continue
|
||||
metadata[key] = value.strip('"\'')
|
||||
index += 1
|
||||
body = content[match.end():].strip()
|
||||
return metadata, body
|
||||
|
||||
|
||||
Reference in New Issue
Block a user