mirror of
https://github.com/Wei-Shaw/claude-relay-service.git
synced 2026-01-23 00:53:33 +00:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
338d44faee | ||
|
|
968398ffa5 | ||
|
|
645ab43675 |
@@ -65,6 +65,13 @@ function normalizePermissions(permissions) {
|
|||||||
if (permissions === 'all') {
|
if (permissions === 'all') {
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
|
// 兼容逗号分隔格式(修复历史错误数据,如 "claude,openai")
|
||||||
|
if (permissions.includes(',')) {
|
||||||
|
return permissions
|
||||||
|
.split(',')
|
||||||
|
.map((p) => p.trim())
|
||||||
|
.filter(Boolean)
|
||||||
|
}
|
||||||
// 旧单个字符串转为数组
|
// 旧单个字符串转为数组
|
||||||
return [permissions]
|
return [permissions]
|
||||||
}
|
}
|
||||||
@@ -753,6 +760,9 @@ class ApiKeyService {
|
|||||||
if (field === 'restrictedModels' || field === 'allowedClients' || field === 'tags') {
|
if (field === 'restrictedModels' || field === 'allowedClients' || field === 'tags') {
|
||||||
// 特殊处理数组字段
|
// 特殊处理数组字段
|
||||||
updatedData[field] = JSON.stringify(value || [])
|
updatedData[field] = JSON.stringify(value || [])
|
||||||
|
} else if (field === 'permissions') {
|
||||||
|
// 权限字段:规范化后JSON序列化,与createApiKey保持一致
|
||||||
|
updatedData[field] = JSON.stringify(normalizePermissions(value))
|
||||||
} else if (
|
} else if (
|
||||||
field === 'enableModelRestriction' ||
|
field === 'enableModelRestriction' ||
|
||||||
field === 'enableClientRestriction' ||
|
field === 'enableClientRestriction' ||
|
||||||
|
|||||||
@@ -79,6 +79,11 @@ const PROMPT_DEFINITIONS = {
|
|||||||
title: 'Claude Code Compact System Prompt Agent SDK2',
|
title: 'Claude Code Compact System Prompt Agent SDK2',
|
||||||
text: "You are Claude Code, Anthropic's official CLI for Claude, running within the Claude Agent SDK."
|
text: "You are Claude Code, Anthropic's official CLI for Claude, running within the Claude Agent SDK."
|
||||||
},
|
},
|
||||||
|
claudeOtherSystemPrompt5: {
|
||||||
|
category: 'system',
|
||||||
|
title: 'Claude CLI Billing Header',
|
||||||
|
text: 'x-anthropic-billing-header: cc_version=2.1.15.c5a; cc_entrypoint=cli'
|
||||||
|
},
|
||||||
claudeOtherSystemPromptCompact: {
|
claudeOtherSystemPromptCompact: {
|
||||||
category: 'system',
|
category: 'system',
|
||||||
title: 'Claude Code Compact System Prompt',
|
title: 'Claude Code Compact System Prompt',
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ class ClaudeCodeValidator {
|
|||||||
typeof customThreshold === 'number' && Number.isFinite(customThreshold)
|
typeof customThreshold === 'number' && Number.isFinite(customThreshold)
|
||||||
? customThreshold
|
? customThreshold
|
||||||
: SYSTEM_PROMPT_THRESHOLD
|
: SYSTEM_PROMPT_THRESHOLD
|
||||||
|
|
||||||
for (const entry of systemEntries) {
|
for (const entry of systemEntries) {
|
||||||
const rawText = typeof entry?.text === 'string' ? entry.text : ''
|
const rawText = typeof entry?.text === 'string' ? entry.text : ''
|
||||||
const { bestScore, templateId, maskedRaw } = bestSimilarityByTemplates(rawText)
|
const { bestScore, templateId, maskedRaw } = bestSimilarityByTemplates(rawText)
|
||||||
|
|||||||
@@ -1246,6 +1246,12 @@ onMounted(async () => {
|
|||||||
} catch {
|
} catch {
|
||||||
perms = VALID_PERMS.includes(perms) ? [perms] : []
|
perms = VALID_PERMS.includes(perms) ? [perms] : []
|
||||||
}
|
}
|
||||||
|
} else if (perms.includes(',')) {
|
||||||
|
// 兼容逗号分隔格式(如 "claude,openai")
|
||||||
|
perms = perms
|
||||||
|
.split(',')
|
||||||
|
.map((p) => p.trim())
|
||||||
|
.filter((p) => VALID_PERMS.includes(p))
|
||||||
} else if (VALID_PERMS.includes(perms)) {
|
} else if (VALID_PERMS.includes(perms)) {
|
||||||
perms = [perms]
|
perms = [perms]
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user