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