if(Object.values(result).some(item=>typeofitem!=='string'))thrownewError(`${label}${t('必须是字符串键值 JSON 对象',' must be a JSON object with string keys and values')}`)
if(typeofvalue!=='number'||!Number.isFinite(value)||value<1||value>max)thrownewError(`${label}${t(`必须是 1–${max} 秒之间的数字`,` must be a number from 1 to ${max} seconds`)}`)
returnvalue
}
// Do not silently rewrite executable arguments or secret values copied from chat.
catch{thrownewError(t('服务器配置不是有效 JSON;请检查逗号、引号和无效的 \\_ 转义','The server configuration is not valid JSON. Check commas, quotes, and invalid \\_ escapes.'))}
thrownewError(t('服务器配置含不支持的字段;API Key 请放在 env/environment 的对应变量中,不要放在顶层','The server configuration contains unsupported fields. Put API keys in the corresponding env/environment variables, not at the top level.'))
if(!['stdio','streamable_http','sse'].includes(transportasstring))thrownewError(t('transport 必须是 stdio、streamable_http 或 sse','transport must be stdio, streamable_http, or sse'))
if(typeofname!=='string'||(requireConnection&&!name.trim())||name.trim().length>80)thrownewError(t('服务器名称必须为 1–80 个字符','The server name must contain 1–80 characters'))
try{url=newURL(config.url)}catch{thrownewError(t('url 必须是有效的 HTTP(S) 地址','url must be a valid HTTP(S) address'))}
if(!['http:','https:'].includes(url.protocol)||url.username||url.password||url.hash)thrownewError(t('url 必须为不含账号密码或片段的 HTTP(S) 地址','url must be an HTTP(S) address without credentials or a fragment'))
if(allKeys.some(key=>!validKey.test(key)))thrownewError(`${kind==='environment'?t('环境变量','Environment variable'):'Header'}${t('名称无效;敏感变量名只能填名称,不能填密钥值',' name is invalid; secret variable declarations accept names only, not secret values')}`)
if(active)error.value=`${t('加载失败:','Load failed: ')}${reasoninstanceofError?reason.message:t('无法读取模型路由或提供商','Could not read model routes or providers')}`
if(!available.value.some(provider=>provider.provider_id===draft.provider_id))thrownewError(t('请选择已启用且协议可用的提供商,或切换到本地。','Select an enabled provider with a supported protocol, or switch to local.'))
if(!draft.model.trim())thrownewError(t('请填写所选 API 的模型 ID。','Enter the model ID for the selected API.'))
if(!/^\/[A-Za-z0-9_/-]+$/.test(draft.endpoint)||draft.endpoint.startsWith('//'))thrownewError(t('Endpoint 必须是以 / 开头的相对路径,只能包含字母、数字、下划线、连字符和 /。','Endpoint must be a relative path beginning with / and containing only letters, numbers, underscores, hyphens, and /.'))
if(dimension&&(!/^\d+$/.test(dimension)||!Number.isSafeInteger(Number(dimension))||Number(dimension)<1||Number(dimension)>16384))thrownewError('嵌入维度必须为 1–16384 的整数,或留空使用 API 默认值。')
if(dimension&&(!/^\d+$/.test(dimension)||!Number.isSafeInteger(Number(dimension))||Number(dimension)<1||Number(dimension)>16384))thrownewError(t('嵌入维度必须为 1–16384 的整数,或留空使用 API 默认值。','Embedding dimensions must be an integer from 1 to 16384, or blank to use the API default.'))
?t('配置版本冲突:其他窗口已修改路由。当前输入尚未保存,请重新加载最新配置后再编辑。','Configuration conflict: another window changed these routes. Your input is unsaved; reload the latest settings before editing.')
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.