发布 0.2.1 并完善工具边界与安全性

This commit is contained in:
mid
2026-08-10 14:49:43 +08:00
parent aca004c513
commit 32b7cc827c
47 changed files with 681 additions and 172 deletions
+6 -1
View File
@@ -5,6 +5,9 @@ import { fileURLToPath } from 'node:url'
const serverDir = path.dirname(fileURLToPath(import.meta.url))
const projectRoot = path.resolve(serverDir, '..')
const legacyToolIdAliases = new Map([
['ascii-hex', 'utf8-hex'],
])
async function readJson(filePath) {
return JSON.parse(await readFile(filePath, 'utf8'))
@@ -30,7 +33,9 @@ export function normalizeNavigation(input, catalog, defaults) {
if (!candidate || !categoryIds.has(candidate.id) || seenCategories.has(candidate.id)) continue
seenCategories.add(candidate.id)
const tools = []
for (const toolId of Array.isArray(candidate.tools) ? candidate.tools : []) {
for (const savedToolId of Array.isArray(candidate.tools) ? candidate.tools : []) {
const migratedToolId = legacyToolIdAliases.get(savedToolId)
const toolId = migratedToolId && toolById.has(migratedToolId) ? migratedToolId : savedToolId
if (!toolById.has(toolId) || seenTools.has(toolId)) continue
seenTools.add(toolId)
tools.push(toolId)