( paths: string[], )
| 50 | |
| 51 | /** 批量验证文件是否存在(只读 check,不返回内容) */ |
| 52 | export async function validatePaths( |
| 53 | paths: string[], |
| 54 | ): Promise<Map<string, boolean>> { |
| 55 | const results = new Map<string, boolean>(); |
| 56 | await Promise.all( |
| 57 | paths.map(async (p) => { |
| 58 | try { |
| 59 | const res = await fetch(`${kbApiBase()}/api/agent-tool`, { |
| 60 | method: "POST", |
| 61 | headers: buildHeaders(), |
| 62 | body: JSON.stringify({ tool: "read_page", args: { path: p } }), |
| 63 | }); |
| 64 | results.set(p, res.ok); |
| 65 | } catch { |
| 66 | results.set(p, false); |
| 67 | } |
| 68 | }), |
| 69 | ); |
| 70 | return results; |
| 71 | } |
| 72 | |
| 73 | export async function executeTool( |
| 74 | name: string, |
no test coverage detected