repositories
loading repo index
repositories
loading repo index
repository
loading code, commits, and activity
public Clawd ADK gateway launch mirror
stars
latest
clone command
git clone gitlawb://did:key:z6Mkq5mY...iFZ5/my-project-publ...git clone gitlawb://did:key:z6Mkq5mY.../my-project-publ...2fa351d6docs: add automaton and perps launch sources16d ago| #1 | import { readJSONSync } from 'fs-extra'; |
| #2 | import { resolve } from 'node:path'; |
| #3 | |
| #4 | import { agentsDir, config } from '../core/constants'; |
| #5 | import { LobeAgent } from '../schema/agentMeta'; |
| #6 | |
| #7 | /** |
| #8 | * Agent 文件解析器 |
| #9 | * 用于解析 Agent 配置文件,提取 ID、语言代码和内容 |
| #10 | */ |
| #11 | export const AgentParser = { |
| #12 | /** |
| #13 | * 解析 Agent 文件 |
| #14 | * @param fileName 文件名 |
| #15 | * @returns 解析结果包含内容、ID 和语言代码 |
| #16 | */ |
| #17 | parseFile: (fileName: string) => { |
| #18 | // 正则表达式匹配格式: <id>.<locale> |
| #19 | // 测试地址: https://regex101.com/r/t744SN/1 |
| #20 | // @ts-ignore |
| #21 | const regexp = /^(?<id>[\w-]*)\.?(?<locale>.*)?$/; |
| #22 | |
| #23 | const match = regexp.exec(fileName.replace('.json', '')); |
| #24 | const { id, locale = config.entryLocale } = match.groups; |
| #25 | |
| #26 | const filePath = resolve(agentsDir, fileName); |
| #27 | const agent: LobeAgent = readJSONSync(filePath); |
| #28 | |
| #29 | return { |
| #30 | content: agent, // Agent 配置内容 |
| #31 | id, // Agent 唯一标识符 |
| #32 | locale, // 语言代码 |
| #33 | }; |
| #34 | }, |
| #35 | }; |
| #36 | |
| #37 | |
| #38 |