@seaveyon/harness-switch 0.27.0 → 0.29.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/harness-switch.js
CHANGED
|
@@ -7062,6 +7062,7 @@ var ERROR_CODES = {
|
|
|
7062
7062
|
adapterApiKeyRequired: "adapter.apiKeyRequired",
|
|
7063
7063
|
officialLoginUnsupported: "activation.officialLoginUnsupported",
|
|
7064
7064
|
officialLoginMissing: "activation.officialLoginMissing",
|
|
7065
|
+
officialApiKeyMissing: "activation.officialApiKeyMissing",
|
|
7065
7066
|
noActiveProfile: "activation.noActiveProfile",
|
|
7066
7067
|
officialProfileCannotAdopt: "activation.officialProfileCannotAdopt",
|
|
7067
7068
|
adoptUnsupported: "activation.adoptUnsupported",
|
|
@@ -7210,6 +7211,167 @@ var en_default = {
|
|
|
7210
7211
|
switchHarness: "Switch harness"
|
|
7211
7212
|
},
|
|
7212
7213
|
harness: {
|
|
7214
|
+
field: {
|
|
7215
|
+
toggle: {
|
|
7216
|
+
on: "On",
|
|
7217
|
+
off: "Off"
|
|
7218
|
+
},
|
|
7219
|
+
providerId: {
|
|
7220
|
+
label: "Provider ID (optional)",
|
|
7221
|
+
placeholder: "Defaults to the profile name"
|
|
7222
|
+
},
|
|
7223
|
+
contextLength: {
|
|
7224
|
+
label: "Context length"
|
|
7225
|
+
},
|
|
7226
|
+
maxTokens: {
|
|
7227
|
+
label: "Max output tokens"
|
|
7228
|
+
},
|
|
7229
|
+
claude: {
|
|
7230
|
+
authVar: {
|
|
7231
|
+
label: "Credential variable",
|
|
7232
|
+
help: "Third-party relays usually require ANTHROPIC_AUTH_TOKEN; use ANTHROPIC_API_KEY for an official API key.",
|
|
7233
|
+
option: {
|
|
7234
|
+
authToken: "ANTHROPIC_AUTH_TOKEN (third-party relay)",
|
|
7235
|
+
official: "ANTHROPIC_API_KEY (official)"
|
|
7236
|
+
}
|
|
7237
|
+
},
|
|
7238
|
+
haikuModel: {
|
|
7239
|
+
label: "Haiku model mapping"
|
|
7240
|
+
},
|
|
7241
|
+
sonnetModel: {
|
|
7242
|
+
label: "Sonnet model mapping"
|
|
7243
|
+
},
|
|
7244
|
+
opusModel: {
|
|
7245
|
+
label: "Opus model mapping"
|
|
7246
|
+
},
|
|
7247
|
+
fableModel: {
|
|
7248
|
+
label: "Fable model mapping (optional)",
|
|
7249
|
+
help: "Written to ANTHROPIC_DEFAULT_FABLE_MODEL, for newer Claude Code builds that support the Fable tier."
|
|
7250
|
+
},
|
|
7251
|
+
subagentModel: {
|
|
7252
|
+
label: "Subagent model (optional)",
|
|
7253
|
+
help: "Written to CLAUDE_CODE_SUBAGENT_MODEL, so subagents can use a faster or cheaper model."
|
|
7254
|
+
},
|
|
7255
|
+
haikuModelName: {
|
|
7256
|
+
label: "Haiku display name (optional)"
|
|
7257
|
+
},
|
|
7258
|
+
sonnetModelName: {
|
|
7259
|
+
label: "Sonnet display name (optional)"
|
|
7260
|
+
},
|
|
7261
|
+
opusModelName: {
|
|
7262
|
+
label: "Opus display name (optional)"
|
|
7263
|
+
},
|
|
7264
|
+
fableModelName: {
|
|
7265
|
+
label: "Fable display name (optional)"
|
|
7266
|
+
},
|
|
7267
|
+
modelMapping: {
|
|
7268
|
+
help: "Written to {{envVar}}."
|
|
7269
|
+
},
|
|
7270
|
+
modelName: {
|
|
7271
|
+
help: "Written to {{envVar}}; left empty, Claude Code shows the model ID itself.",
|
|
7272
|
+
placeholder: "Leave empty to use the {{role}} model ID"
|
|
7273
|
+
},
|
|
7274
|
+
example: {
|
|
7275
|
+
placeholder: "e.g. {{value}}"
|
|
7276
|
+
},
|
|
7277
|
+
extraEnv: {
|
|
7278
|
+
label: "Extra environment variables (optional)",
|
|
7279
|
+
help: "One KEY=VALUE per line, merged into the env block of settings.json."
|
|
7280
|
+
},
|
|
7281
|
+
oneM: {
|
|
7282
|
+
subagentLabel: "Declare 1M support for subagents",
|
|
7283
|
+
label: "Declare 1M support for {{role}}",
|
|
7284
|
+
help: "Appends [1m] to the model ID to declare a 1M context window to Claude Code, which strips the suffix before calling the provider. Enable it only when the model really supports 1M."
|
|
7285
|
+
}
|
|
7286
|
+
},
|
|
7287
|
+
codex: {
|
|
7288
|
+
envNote: "Only the environment-variable auth mode needs env.sh; the other modes keep their credential inside config.toml.",
|
|
7289
|
+
authMode: {
|
|
7290
|
+
label: "Authentication mode",
|
|
7291
|
+
help: "auth.json is Codex's own login cache. Overwriting it loses the ChatGPT session, so it is left alone by default.",
|
|
7292
|
+
option: {
|
|
7293
|
+
bearerToken: "Write to config.toml (recommended, keeps official login)",
|
|
7294
|
+
envKey: "Environment variable (requires sourcing env.sh)",
|
|
7295
|
+
openaiAuth: "Write to auth.json (overwrites the ChatGPT login cache)"
|
|
7296
|
+
}
|
|
7297
|
+
},
|
|
7298
|
+
providerId: {
|
|
7299
|
+
help: "openai, ollama, lmstudio, amazon-bedrock and similar are reserved by Codex and get renamed automatically."
|
|
7300
|
+
},
|
|
7301
|
+
envKeyName: {
|
|
7302
|
+
label: "Environment variable name",
|
|
7303
|
+
help: "Only used by the environment-variable mode."
|
|
7304
|
+
},
|
|
7305
|
+
reasoningEffort: {
|
|
7306
|
+
label: "Reasoning effort (optional)",
|
|
7307
|
+
option: {
|
|
7308
|
+
unset: "Not set"
|
|
7309
|
+
}
|
|
7310
|
+
},
|
|
7311
|
+
target: {
|
|
7312
|
+
auth: "auth.json (auth.json mode only)"
|
|
7313
|
+
}
|
|
7314
|
+
},
|
|
7315
|
+
kimi: {
|
|
7316
|
+
envNote: "Kimi Code does not read credentials from the shell, so env.sh has no effect on it.",
|
|
7317
|
+
providerType: {
|
|
7318
|
+
label: "Provider type",
|
|
7319
|
+
help: "Decides which protocol implementation Kimi Code uses.",
|
|
7320
|
+
option: {
|
|
7321
|
+
kimi: "kimi (Moonshot / Kimi Code)"
|
|
7322
|
+
}
|
|
7323
|
+
},
|
|
7324
|
+
maxContextSize: {
|
|
7325
|
+
help: "Kimi Code requires every models entry to declare max_context_size."
|
|
7326
|
+
}
|
|
7327
|
+
},
|
|
7328
|
+
pi: {
|
|
7329
|
+
envNote: "The API key is written straight into models.json, so no environment variable is needed; --model still overrides at run time.",
|
|
7330
|
+
providerId: {
|
|
7331
|
+
help: "Models are referenced as provider/model."
|
|
7332
|
+
},
|
|
7333
|
+
api: {
|
|
7334
|
+
label: "Protocol"
|
|
7335
|
+
},
|
|
7336
|
+
authHeader: {
|
|
7337
|
+
label: "Authorization header",
|
|
7338
|
+
help: "Sent as Authorization: Bearer <key>."
|
|
7339
|
+
},
|
|
7340
|
+
reasoning: {
|
|
7341
|
+
label: "Reasoning support",
|
|
7342
|
+
help: "Maps to reasoning in models.json. Enable it for thinking models such as GPT or Claude."
|
|
7343
|
+
}
|
|
7344
|
+
},
|
|
7345
|
+
dsh: {
|
|
7346
|
+
envNote: "The API key is written securely to DSH's .credentials.yaml and referenced from settings.yaml.",
|
|
7347
|
+
providerType: {
|
|
7348
|
+
label: "Provider type",
|
|
7349
|
+
option: {
|
|
7350
|
+
custom: "Custom provider",
|
|
7351
|
+
official: "DeepSeek official API"
|
|
7352
|
+
}
|
|
7353
|
+
},
|
|
7354
|
+
providerId: {
|
|
7355
|
+
help: "DSH's model routing identifier; it must start with a lowercase letter."
|
|
7356
|
+
},
|
|
7357
|
+
models: {
|
|
7358
|
+
label: "Model catalog (optional)",
|
|
7359
|
+
placeholder: "One model ID per line; left empty, only the default model above is registered",
|
|
7360
|
+
help: "One provider can register several models; the Model field above is the default for new sessions."
|
|
7361
|
+
},
|
|
7362
|
+
api: {
|
|
7363
|
+
label: "API protocol"
|
|
7364
|
+
},
|
|
7365
|
+
reasoningEfforts: {
|
|
7366
|
+
label: "Supported reasoning levels",
|
|
7367
|
+
help: "DSH only shows the levels declared here that the upstream model actually supports.",
|
|
7368
|
+
option: {
|
|
7369
|
+
unset: "Not declared (provider default)",
|
|
7370
|
+
none: "Model does not support reasoning levels"
|
|
7371
|
+
}
|
|
7372
|
+
}
|
|
7373
|
+
}
|
|
7374
|
+
},
|
|
7213
7375
|
subtitle: "Manage profiles and safely write this tool's native configuration files.",
|
|
7214
7376
|
newProfile: "New profile",
|
|
7215
7377
|
addCustomProvider: "Add custom provider",
|
|
@@ -7233,6 +7395,7 @@ var en_default = {
|
|
|
7233
7395
|
providers: "Providers",
|
|
7234
7396
|
profileCount_one: "{{count}} custom profile",
|
|
7235
7397
|
profileCount_other: "{{count}} custom profiles",
|
|
7398
|
+
copy: "Copy {{name}}",
|
|
7236
7399
|
noProfiles: "No profiles yet",
|
|
7237
7400
|
manualOverride: "Manual override",
|
|
7238
7401
|
edit: "Edit {{name}}",
|
|
@@ -7241,12 +7404,14 @@ var en_default = {
|
|
|
7241
7404
|
deleteTitle: "Delete profile?",
|
|
7242
7405
|
deleteBody: "This deletes {{harness}} / {{profile}}. {{extra}}This cannot be undone.",
|
|
7243
7406
|
deleteAdditiveExtra: "Its provider entry in the configuration file is removed as well. ",
|
|
7407
|
+
deleteDshOfficialExtra: "Its native DeepSeek route and credential reference are removed as well. ",
|
|
7244
7408
|
official: "Official login",
|
|
7245
7409
|
officialActive: "In use",
|
|
7246
7410
|
officialSwitch: "Back to official",
|
|
7247
7411
|
officialHintClaude: "Use Claude Code's own Anthropic account login",
|
|
7248
7412
|
officialHintCodex: "Use Codex's own ChatGPT / OpenAI account login",
|
|
7249
7413
|
officialHintKimi: "Use Kimi Code's own Kimi account login (the OAuth credential written by /login)",
|
|
7414
|
+
officialHintDsh: "Detect and switch to DeepSeek Harness's existing official DeepSeek API key configuration",
|
|
7250
7415
|
application: "Application",
|
|
7251
7416
|
writeMode: "Write mode",
|
|
7252
7417
|
modeReplace: "Replace current configuration",
|
|
@@ -7255,6 +7420,7 @@ var en_default = {
|
|
|
7255
7420
|
profile: {
|
|
7256
7421
|
editTitle: "Edit {{harness}} / {{profile}}",
|
|
7257
7422
|
createTitle: "New {{harness}} profile",
|
|
7423
|
+
copyTitle: "Copy {{harness}} / {{profile}}",
|
|
7258
7424
|
intro: "Saving writes to {{targets}}.",
|
|
7259
7425
|
additiveNote: "This tool's config file keeps providers side by side, so switching only moves the current pointer — the other providers you wrote by hand are left alone.",
|
|
7260
7426
|
useSharedProvider: "Use a shared provider (vault)",
|
|
@@ -7278,6 +7444,7 @@ var en_default = {
|
|
|
7278
7444
|
apiKeyKeep: "Leave empty to keep the current key",
|
|
7279
7445
|
apiKeyRequiredPlaceholder: "Required",
|
|
7280
7446
|
apiKeySharedHint: "This profile references a shared provider; rotate the key in the vault instead.",
|
|
7447
|
+
dshOfficialApiKeyHint: "Enter a DeepSeek Platform API key. It is securely written to DSH's .credentials.yaml and referenced as DEEPSEEK_API_KEY from settings.yaml.",
|
|
7281
7448
|
fallbackModel: "Fallback model (ANTHROPIC_MODEL)",
|
|
7282
7449
|
model: "Model",
|
|
7283
7450
|
fallbackModelPlaceholder: "Optional; used when no tier matches, e.g. glm-5",
|
|
@@ -7309,6 +7476,7 @@ var en_default = {
|
|
|
7309
7476
|
nameRequired: "Enter a profile name",
|
|
7310
7477
|
nameSlash: "A profile name cannot contain / or \\",
|
|
7311
7478
|
nameTooLong: "A profile name is at most {{max}} characters",
|
|
7479
|
+
nameDuplicate: "A profile with this name already exists",
|
|
7312
7480
|
baseUrlRequired: "Enter an API base URL",
|
|
7313
7481
|
apiKeyRequired: "Enter an API key",
|
|
7314
7482
|
modelRequired: "Enter a model name",
|
|
@@ -7596,6 +7764,7 @@ var en_default = {
|
|
|
7596
7764
|
activation: {
|
|
7597
7765
|
officialLoginUnsupported: "{{harness}} does not support official account login",
|
|
7598
7766
|
officialLoginMissing: "No official login entry was found for {{harness}}; complete its official login in a terminal once first",
|
|
7767
|
+
officialApiKeyMissing: "No official DeepSeek API key configuration was found for {{harness}}",
|
|
7599
7768
|
noActiveProfile: "This tool has no active profile, so there is nothing to render",
|
|
7600
7769
|
officialProfileCannotAdopt: "The official login is active, so there is no profile to adopt into",
|
|
7601
7770
|
adoptUnsupported: "This tool cannot adopt a live configuration",
|
|
@@ -7957,6 +8126,167 @@ var zh_CN_default = {
|
|
|
7957
8126
|
switchHarness: "切换 Harness"
|
|
7958
8127
|
},
|
|
7959
8128
|
harness: {
|
|
8129
|
+
field: {
|
|
8130
|
+
toggle: {
|
|
8131
|
+
on: "开启",
|
|
8132
|
+
off: "关闭"
|
|
8133
|
+
},
|
|
8134
|
+
providerId: {
|
|
8135
|
+
label: "Provider ID(可选)",
|
|
8136
|
+
placeholder: "默认取配置名称"
|
|
8137
|
+
},
|
|
8138
|
+
contextLength: {
|
|
8139
|
+
label: "上下文长度"
|
|
8140
|
+
},
|
|
8141
|
+
maxTokens: {
|
|
8142
|
+
label: "最大输出 tokens"
|
|
8143
|
+
},
|
|
8144
|
+
claude: {
|
|
8145
|
+
authVar: {
|
|
8146
|
+
label: "凭据变量",
|
|
8147
|
+
help: "第三方中转通常要求 ANTHROPIC_AUTH_TOKEN;官方 API key 用 ANTHROPIC_API_KEY。",
|
|
8148
|
+
option: {
|
|
8149
|
+
authToken: "ANTHROPIC_AUTH_TOKEN(第三方中转)",
|
|
8150
|
+
official: "ANTHROPIC_API_KEY(官方)"
|
|
8151
|
+
}
|
|
8152
|
+
},
|
|
8153
|
+
haikuModel: {
|
|
8154
|
+
label: "Haiku 模型映射"
|
|
8155
|
+
},
|
|
8156
|
+
sonnetModel: {
|
|
8157
|
+
label: "Sonnet 模型映射"
|
|
8158
|
+
},
|
|
8159
|
+
opusModel: {
|
|
8160
|
+
label: "Opus 模型映射"
|
|
8161
|
+
},
|
|
8162
|
+
fableModel: {
|
|
8163
|
+
label: "Fable 模型映射(可选)",
|
|
8164
|
+
help: "写入 ANTHROPIC_DEFAULT_FABLE_MODEL;用于支持 Fable 档位的新版 Claude Code。"
|
|
8165
|
+
},
|
|
8166
|
+
subagentModel: {
|
|
8167
|
+
label: "子代理模型(可选)",
|
|
8168
|
+
help: "写入 CLAUDE_CODE_SUBAGENT_MODEL,可让子代理使用更快或成本更低的模型。"
|
|
8169
|
+
},
|
|
8170
|
+
haikuModelName: {
|
|
8171
|
+
label: "Haiku 显示名称(选填)"
|
|
8172
|
+
},
|
|
8173
|
+
sonnetModelName: {
|
|
8174
|
+
label: "Sonnet 显示名称(选填)"
|
|
8175
|
+
},
|
|
8176
|
+
opusModelName: {
|
|
8177
|
+
label: "Opus 显示名称(选填)"
|
|
8178
|
+
},
|
|
8179
|
+
fableModelName: {
|
|
8180
|
+
label: "Fable 显示名称(选填)"
|
|
8181
|
+
},
|
|
8182
|
+
modelMapping: {
|
|
8183
|
+
help: "写入 {{envVar}}。"
|
|
8184
|
+
},
|
|
8185
|
+
modelName: {
|
|
8186
|
+
help: "写入 {{envVar}};留空时 Claude Code 默认显示对应模型 ID。",
|
|
8187
|
+
placeholder: "留空则使用 {{role}} 模型 ID"
|
|
8188
|
+
},
|
|
8189
|
+
example: {
|
|
8190
|
+
placeholder: "例如:{{value}}"
|
|
8191
|
+
},
|
|
8192
|
+
extraEnv: {
|
|
8193
|
+
label: "追加环境变量(可选)",
|
|
8194
|
+
help: "每行一个 KEY=VALUE,会合并进 settings.json 的 env。"
|
|
8195
|
+
},
|
|
8196
|
+
oneM: {
|
|
8197
|
+
subagentLabel: "子代理 声明支持 1M",
|
|
8198
|
+
label: "{{role}} 声明支持 1M",
|
|
8199
|
+
help: "在模型 ID 末尾追加 [1m],向 Claude Code 声明 1M 上下文;Claude Code 请求上游前会去掉该后缀。仅在该模型确实支持 1M 时开启。"
|
|
8200
|
+
}
|
|
8201
|
+
},
|
|
8202
|
+
codex: {
|
|
8203
|
+
envNote: "仅「环境变量」认证模式需要 env.sh,其余模式的凭据自包含在 config.toml 里。",
|
|
8204
|
+
authMode: {
|
|
8205
|
+
label: "认证方式",
|
|
8206
|
+
help: "auth.json 就是 Codex 的登录缓存,覆盖它会丢失 ChatGPT 登录态,所以默认不碰它。",
|
|
8207
|
+
option: {
|
|
8208
|
+
bearerToken: "写入 config.toml(推荐,保留官方登录)",
|
|
8209
|
+
envKey: "环境变量(需要 source env.sh)",
|
|
8210
|
+
openaiAuth: "写入 auth.json(会覆盖 ChatGPT 登录缓存)"
|
|
8211
|
+
}
|
|
8212
|
+
},
|
|
8213
|
+
providerId: {
|
|
8214
|
+
help: "openai / ollama / lmstudio / amazon-bedrock 等是 Codex 保留字,会自动改名。"
|
|
8215
|
+
},
|
|
8216
|
+
envKeyName: {
|
|
8217
|
+
label: "环境变量名",
|
|
8218
|
+
help: "仅「环境变量」模式生效。"
|
|
8219
|
+
},
|
|
8220
|
+
reasoningEffort: {
|
|
8221
|
+
label: "推理强度(可选)",
|
|
8222
|
+
option: {
|
|
8223
|
+
unset: "不设置"
|
|
8224
|
+
}
|
|
8225
|
+
},
|
|
8226
|
+
target: {
|
|
8227
|
+
auth: "auth.json(仅 auth.json 模式)"
|
|
8228
|
+
}
|
|
8229
|
+
},
|
|
8230
|
+
kimi: {
|
|
8231
|
+
envNote: "Kimi Code 不从 shell 读取凭据,env.sh 对它无效。",
|
|
8232
|
+
providerType: {
|
|
8233
|
+
label: "Provider 类型",
|
|
8234
|
+
help: "决定 Kimi Code 使用哪套协议实现。",
|
|
8235
|
+
option: {
|
|
8236
|
+
kimi: "kimi(Moonshot / Kimi Code)"
|
|
8237
|
+
}
|
|
8238
|
+
},
|
|
8239
|
+
maxContextSize: {
|
|
8240
|
+
help: "Kimi Code 要求 models 条目必须声明 max_context_size。"
|
|
8241
|
+
}
|
|
8242
|
+
},
|
|
8243
|
+
pi: {
|
|
8244
|
+
envNote: "API key 直接写入 models.json,无需环境变量;运行时仍可用 --model 覆盖。",
|
|
8245
|
+
providerId: {
|
|
8246
|
+
help: "模型引用格式为 provider/model。"
|
|
8247
|
+
},
|
|
8248
|
+
api: {
|
|
8249
|
+
label: "协议"
|
|
8250
|
+
},
|
|
8251
|
+
authHeader: {
|
|
8252
|
+
label: "Authorization 头",
|
|
8253
|
+
help: "以 Authorization: Bearer <key> 发送。"
|
|
8254
|
+
},
|
|
8255
|
+
reasoning: {
|
|
8256
|
+
label: "推理能力",
|
|
8257
|
+
help: "对应 models.json 的 reasoning。GPT / Claude 思考模型需要开启。"
|
|
8258
|
+
}
|
|
8259
|
+
},
|
|
8260
|
+
dsh: {
|
|
8261
|
+
envNote: "API key 安全写入 DSH 的 .credentials.yaml,并由 settings.yaml 引用。",
|
|
8262
|
+
providerType: {
|
|
8263
|
+
label: "提供方类型",
|
|
8264
|
+
option: {
|
|
8265
|
+
custom: "自定义提供方",
|
|
8266
|
+
official: "DeepSeek 官方 API"
|
|
8267
|
+
}
|
|
8268
|
+
},
|
|
8269
|
+
providerId: {
|
|
8270
|
+
help: "DSH 的模型路由标识;必须以小写字母开头。"
|
|
8271
|
+
},
|
|
8272
|
+
models: {
|
|
8273
|
+
label: "模型目录(可选)",
|
|
8274
|
+
placeholder: "每行一个模型 ID;留空时只注册上方的默认模型",
|
|
8275
|
+
help: "一个提供方可注册多个模型;上方“模型”作为新会话的默认模型。"
|
|
8276
|
+
},
|
|
8277
|
+
api: {
|
|
8278
|
+
label: "API 协议"
|
|
8279
|
+
},
|
|
8280
|
+
reasoningEfforts: {
|
|
8281
|
+
label: "支持的思考程度",
|
|
8282
|
+
help: "DSH 只会显示这里声明且上游模型实际支持的档位。",
|
|
8283
|
+
option: {
|
|
8284
|
+
unset: "不声明(提供方默认)",
|
|
8285
|
+
none: "模型不支持思考程度"
|
|
8286
|
+
}
|
|
8287
|
+
}
|
|
8288
|
+
}
|
|
8289
|
+
},
|
|
7960
8290
|
subtitle: "管理配置档案并安全写入该工具的原生配置文件。",
|
|
7961
8291
|
newProfile: "新增配置",
|
|
7962
8292
|
addCustomProvider: "添加自定义提供方",
|
|
@@ -7980,6 +8310,7 @@ var zh_CN_default = {
|
|
|
7980
8310
|
providers: "提供方",
|
|
7981
8311
|
profileCount_one: "{{count}} 个自定义配置",
|
|
7982
8312
|
profileCount_other: "{{count}} 个自定义配置",
|
|
8313
|
+
copy: "复制 {{name}}",
|
|
7983
8314
|
noProfiles: "还没有配置档案",
|
|
7984
8315
|
manualOverride: "手动接管",
|
|
7985
8316
|
edit: "编辑 {{name}}",
|
|
@@ -7988,12 +8319,14 @@ var zh_CN_default = {
|
|
|
7988
8319
|
deleteTitle: "删除配置?",
|
|
7989
8320
|
deleteBody: "将删除 {{harness}} / {{profile}}。{{extra}}此操作不可撤销。",
|
|
7990
8321
|
deleteAdditiveExtra: "它在配置文件里的 provider 条目也会被一并摘掉。",
|
|
8322
|
+
deleteDshOfficialExtra: "它的 DeepSeek 原生路由和凭据引用也会被一并移除。",
|
|
7991
8323
|
official: "官方登录",
|
|
7992
8324
|
officialActive: "已使用",
|
|
7993
8325
|
officialSwitch: "切回官方",
|
|
7994
8326
|
officialHintClaude: "使用 Claude Code 自身的 Anthropic 账号登录",
|
|
7995
8327
|
officialHintCodex: "使用 Codex 自身的 ChatGPT / OpenAI 账号登录",
|
|
7996
8328
|
officialHintKimi: "使用 Kimi Code 自身的 Kimi 账号登录(/login 写入的 OAuth 凭据)",
|
|
8329
|
+
officialHintDsh: "检测并切换到 DeepSeek Harness 已有的 DeepSeek 官方 API Key 配置。",
|
|
7997
8330
|
application: "应用",
|
|
7998
8331
|
writeMode: "写入模式",
|
|
7999
8332
|
modeReplace: "替换当前配置",
|
|
@@ -8002,6 +8335,7 @@ var zh_CN_default = {
|
|
|
8002
8335
|
profile: {
|
|
8003
8336
|
editTitle: "编辑 {{harness}} / {{profile}}",
|
|
8004
8337
|
createTitle: "新增 {{harness}} 配置",
|
|
8338
|
+
copyTitle: "复制 {{harness}} / {{profile}}",
|
|
8005
8339
|
intro: "保存后会写入 {{targets}}。",
|
|
8006
8340
|
additiveNote: "该工具的配置文件按 provider 共存,切换只会移动当前指针,不会删除你手写的其他 provider。",
|
|
8007
8341
|
useSharedProvider: "使用共享 Provider(凭据库)",
|
|
@@ -8025,6 +8359,7 @@ var zh_CN_default = {
|
|
|
8025
8359
|
apiKeyKeep: "留空表示保持不变",
|
|
8026
8360
|
apiKeyRequiredPlaceholder: "必填",
|
|
8027
8361
|
apiKeySharedHint: "已引用共享 Provider,密钥在「凭据库」中统一轮换。",
|
|
8362
|
+
dshOfficialApiKeyHint: "填写 DeepSeek 开放平台 API Key;它会安全写入 DSH 的 .credentials.yaml,并以 DEEPSEEK_API_KEY 被 settings.yaml 引用。",
|
|
8028
8363
|
fallbackModel: "回退模型(ANTHROPIC_MODEL)",
|
|
8029
8364
|
model: "模型",
|
|
8030
8365
|
fallbackModelPlaceholder: "可选;各档未匹配时使用,例如 glm-5",
|
|
@@ -8056,6 +8391,7 @@ var zh_CN_default = {
|
|
|
8056
8391
|
nameRequired: "请输入配置名称",
|
|
8057
8392
|
nameSlash: "配置名称不能包含 / 或 \\",
|
|
8058
8393
|
nameTooLong: "配置名称最多 {{max}} 个字符",
|
|
8394
|
+
nameDuplicate: "同名配置已经存在",
|
|
8059
8395
|
baseUrlRequired: "请输入 API Base URL",
|
|
8060
8396
|
apiKeyRequired: "请输入 API Key",
|
|
8061
8397
|
modelRequired: "请输入模型名称",
|
|
@@ -8343,6 +8679,7 @@ var zh_CN_default = {
|
|
|
8343
8679
|
activation: {
|
|
8344
8680
|
officialLoginUnsupported: "{{harness}} 不支持官方账号登录模式",
|
|
8345
8681
|
officialLoginMissing: "未检测到 {{harness}} 的官方登录条目,请先在终端完成一次官方登录",
|
|
8682
|
+
officialApiKeyMissing: "未检测到 {{harness}} 的 DeepSeek 官方 API Key 配置",
|
|
8346
8683
|
noActiveProfile: "该工具未激活任何配置,无可渲染的内容",
|
|
8347
8684
|
officialProfileCannotAdopt: "当前处于官方登录状态,没有可回填的配置档案",
|
|
8348
8685
|
adoptUnsupported: "该工具不支持采纳现场配置",
|
|
@@ -22970,6 +23307,7 @@ var loginRequestSchema = exports_external.object({
|
|
|
22970
23307
|
});
|
|
22971
23308
|
var createProfileRequestSchema = exports_external.object({
|
|
22972
23309
|
name: entityName,
|
|
23310
|
+
copySourceName: entityName.optional(),
|
|
22973
23311
|
baseUrl: optionalText(MAX_URL).optional(),
|
|
22974
23312
|
apiKey: optionalText(MAX_KEY).optional(),
|
|
22975
23313
|
model: optionalText(MAX_NAME).optional(),
|
|
@@ -24681,7 +25019,6 @@ function localizeMessage(language, code, data) {
|
|
|
24681
25019
|
}
|
|
24682
25020
|
return value.replace(/{{\s*([\w.]+)\s*}}/g, (_match, name) => data?.[name] === undefined ? "" : String(data[name]));
|
|
24683
25021
|
}
|
|
24684
|
-
var localizeError = localizeMessage;
|
|
24685
25022
|
function getPath2(value, path) {
|
|
24686
25023
|
return path.split(".").reduce((current, key) => {
|
|
24687
25024
|
if (typeof current !== "object" || current === null || Array.isArray(current))
|
|
@@ -25790,29 +26127,6 @@ import { basename as basename3, join as join8, resolve as resolve2 } from "node:
|
|
|
25790
26127
|
// src/services/adapters/claude.ts
|
|
25791
26128
|
import { join as join3 } from "node:path";
|
|
25792
26129
|
|
|
25793
|
-
// src/services/adapters/detect.ts
|
|
25794
|
-
function seedProfile(extras = {}) {
|
|
25795
|
-
return { name: "", baseUrl: "", apiKey: "", model: "", extras };
|
|
25796
|
-
}
|
|
25797
|
-
function toCandidate(key, seed, values, active) {
|
|
25798
|
-
const baseUrl = values.baseUrl ?? "";
|
|
25799
|
-
const apiKey = values.apiKey ?? "";
|
|
25800
|
-
if (!baseUrl && !apiKey) {
|
|
25801
|
-
return null;
|
|
25802
|
-
}
|
|
25803
|
-
return {
|
|
25804
|
-
key,
|
|
25805
|
-
baseUrl,
|
|
25806
|
-
apiKey,
|
|
25807
|
-
model: values.model ?? "",
|
|
25808
|
-
extras: { ...seed.extras, ...values.extras },
|
|
25809
|
-
active
|
|
25810
|
-
};
|
|
25811
|
-
}
|
|
25812
|
-
function compact(candidates) {
|
|
25813
|
-
return candidates.filter((candidate) => candidate !== null);
|
|
25814
|
-
}
|
|
25815
|
-
|
|
25816
26130
|
// ../../node_modules/smol-toml/dist/date.js
|
|
25817
26131
|
/*!
|
|
25818
26132
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
@@ -26895,6 +27209,13 @@ function parseJsonObject(text) {
|
|
|
26895
27209
|
const parsed = JSON.parse(text);
|
|
26896
27210
|
return isPlainObject2(parsed) ? parsed : {};
|
|
26897
27211
|
}
|
|
27212
|
+
function tryParseJsonObject(text) {
|
|
27213
|
+
try {
|
|
27214
|
+
return parseJsonObject(text);
|
|
27215
|
+
} catch {
|
|
27216
|
+
return;
|
|
27217
|
+
}
|
|
27218
|
+
}
|
|
26898
27219
|
function stringifyJson(value) {
|
|
26899
27220
|
return `${JSON.stringify(value, null, 2)}
|
|
26900
27221
|
`;
|
|
@@ -26906,6 +27227,13 @@ function parseTomlObject(text) {
|
|
|
26906
27227
|
const parsed = parse6(text);
|
|
26907
27228
|
return isPlainObject2(parsed) ? parsed : {};
|
|
26908
27229
|
}
|
|
27230
|
+
function tryParseTomlObject(text) {
|
|
27231
|
+
try {
|
|
27232
|
+
return parseTomlObject(text);
|
|
27233
|
+
} catch {
|
|
27234
|
+
return;
|
|
27235
|
+
}
|
|
27236
|
+
}
|
|
26909
27237
|
function stringifyToml(value) {
|
|
26910
27238
|
return `${stringify(value)}
|
|
26911
27239
|
`;
|
|
@@ -26917,6 +27245,13 @@ function parseYamlDocument(text) {
|
|
|
26917
27245
|
}
|
|
26918
27246
|
return document;
|
|
26919
27247
|
}
|
|
27248
|
+
function tryParseYamlDocument(text) {
|
|
27249
|
+
try {
|
|
27250
|
+
return parseYamlDocument(text);
|
|
27251
|
+
} catch {
|
|
27252
|
+
return;
|
|
27253
|
+
}
|
|
27254
|
+
}
|
|
26920
27255
|
function assertParsable(format, path, content) {
|
|
26921
27256
|
try {
|
|
26922
27257
|
if (format === "json") {
|
|
@@ -26959,6 +27294,13 @@ function readString(source, key) {
|
|
|
26959
27294
|
const value = source[key];
|
|
26960
27295
|
return typeof value === "string" ? value : "";
|
|
26961
27296
|
}
|
|
27297
|
+
function numeric(raw2, fallback) {
|
|
27298
|
+
const parsed = Number(raw2);
|
|
27299
|
+
return Number.isFinite(parsed) && parsed > 0 ? Math.trunc(parsed) : fallback;
|
|
27300
|
+
}
|
|
27301
|
+
function valueString(value, fallback) {
|
|
27302
|
+
return typeof value === "number" && Number.isFinite(value) ? String(value) : fallback || "";
|
|
27303
|
+
}
|
|
26962
27304
|
function slugify2(value, fallback) {
|
|
26963
27305
|
const slug = value.trim().toLowerCase().replace(/[^a-z0-9_-]+/g, "-").replace(/^-+|-+$/g, "");
|
|
26964
27306
|
return slug || `${fallback}-${shortHash(value)}`;
|
|
@@ -26972,6 +27314,32 @@ function shortHash(value) {
|
|
|
26972
27314
|
return (hash2 >>> 0).toString(36);
|
|
26973
27315
|
}
|
|
26974
27316
|
|
|
27317
|
+
// src/services/adapters/detect.ts
|
|
27318
|
+
function providerId(profile) {
|
|
27319
|
+
return slugify2(profile.extras.providerId || profile.name, "provider");
|
|
27320
|
+
}
|
|
27321
|
+
function seedProfile(extras = {}) {
|
|
27322
|
+
return { name: "", baseUrl: "", apiKey: "", model: "", extras };
|
|
27323
|
+
}
|
|
27324
|
+
function toCandidate(key, seed, values, active) {
|
|
27325
|
+
const baseUrl = values.baseUrl ?? "";
|
|
27326
|
+
const apiKey = values.apiKey ?? "";
|
|
27327
|
+
if (!baseUrl && !apiKey) {
|
|
27328
|
+
return null;
|
|
27329
|
+
}
|
|
27330
|
+
return {
|
|
27331
|
+
key,
|
|
27332
|
+
baseUrl,
|
|
27333
|
+
apiKey,
|
|
27334
|
+
model: values.model ?? "",
|
|
27335
|
+
extras: { ...seed.extras, ...values.extras },
|
|
27336
|
+
active
|
|
27337
|
+
};
|
|
27338
|
+
}
|
|
27339
|
+
function compact(candidates) {
|
|
27340
|
+
return candidates.filter((candidate) => candidate !== null);
|
|
27341
|
+
}
|
|
27342
|
+
|
|
26975
27343
|
// src/services/adapters/claude.ts
|
|
26976
27344
|
var SETTINGS = "settings";
|
|
26977
27345
|
var BASE_URL_VAR = "ANTHROPIC_BASE_URL";
|
|
@@ -27009,17 +27377,20 @@ var MODEL_MAPPINGS = [
|
|
|
27009
27377
|
{ field: "subagentModel", envVar: "CLAUDE_CODE_SUBAGENT_MODEL", oneMField: "subagentModel1m" }
|
|
27010
27378
|
];
|
|
27011
27379
|
var ONE_M_OPTIONS = [
|
|
27012
|
-
{ value: "false", label: "关闭" },
|
|
27013
|
-
{ value: "true", label: "开启" }
|
|
27380
|
+
{ value: "false", label: "关闭", labelCode: "harness.field.toggle.off" },
|
|
27381
|
+
{ value: "true", label: "开启", labelCode: "harness.field.toggle.on" }
|
|
27014
27382
|
];
|
|
27015
|
-
function oneMField(role, key) {
|
|
27383
|
+
function oneMField(role, key, labelCode) {
|
|
27016
27384
|
return {
|
|
27017
27385
|
key,
|
|
27018
27386
|
label: `${role} 声明支持 1M`,
|
|
27387
|
+
labelCode: labelCode ?? "harness.field.claude.oneM.label",
|
|
27388
|
+
...labelCode ? {} : { params: { role } },
|
|
27019
27389
|
kind: "select",
|
|
27020
27390
|
defaultValue: "false",
|
|
27021
27391
|
options: ONE_M_OPTIONS,
|
|
27022
|
-
help: "在模型 ID 末尾追加 [1m],向 Claude Code 声明 1M 上下文;Claude Code 请求上游前会去掉该后缀。仅在该模型确实支持 1M 时开启。"
|
|
27392
|
+
help: "在模型 ID 末尾追加 [1m],向 Claude Code 声明 1M 上下文;Claude Code 请求上游前会去掉该后缀。仅在该模型确实支持 1M 时开启。",
|
|
27393
|
+
helpCode: "harness.field.claude.oneM.help"
|
|
27023
27394
|
};
|
|
27024
27395
|
}
|
|
27025
27396
|
|
|
@@ -27033,96 +27404,152 @@ class ClaudeAdapter {
|
|
|
27033
27404
|
MODEL_VAR,
|
|
27034
27405
|
...MODEL_MAPPINGS.flatMap(({ envVar, nameEnvVar }) => nameEnvVar ? [envVar, nameEnvVar] : [envVar])
|
|
27035
27406
|
];
|
|
27407
|
+
official(_current) {
|
|
27408
|
+
return {
|
|
27409
|
+
kind: "account-login",
|
|
27410
|
+
available: true,
|
|
27411
|
+
titleCode: "harness.official",
|
|
27412
|
+
hintCode: "harness.officialHintClaude"
|
|
27413
|
+
};
|
|
27414
|
+
}
|
|
27036
27415
|
fields = [
|
|
27037
27416
|
{
|
|
27038
27417
|
key: "authVar",
|
|
27039
27418
|
label: "凭据变量",
|
|
27419
|
+
labelCode: "harness.field.claude.authVar.label",
|
|
27040
27420
|
kind: "select",
|
|
27041
27421
|
defaultValue: "ANTHROPIC_AUTH_TOKEN",
|
|
27042
27422
|
help: "第三方中转通常要求 ANTHROPIC_AUTH_TOKEN;官方 API key 用 ANTHROPIC_API_KEY。",
|
|
27423
|
+
helpCode: "harness.field.claude.authVar.help",
|
|
27043
27424
|
fullWidth: true,
|
|
27044
27425
|
options: [
|
|
27045
|
-
{
|
|
27046
|
-
|
|
27426
|
+
{
|
|
27427
|
+
value: "ANTHROPIC_AUTH_TOKEN",
|
|
27428
|
+
label: "ANTHROPIC_AUTH_TOKEN(第三方中转)",
|
|
27429
|
+
labelCode: "harness.field.claude.authVar.option.authToken"
|
|
27430
|
+
},
|
|
27431
|
+
{
|
|
27432
|
+
value: "ANTHROPIC_API_KEY",
|
|
27433
|
+
label: "ANTHROPIC_API_KEY(官方)",
|
|
27434
|
+
labelCode: "harness.field.claude.authVar.option.official"
|
|
27435
|
+
}
|
|
27047
27436
|
]
|
|
27048
27437
|
},
|
|
27049
27438
|
{
|
|
27050
27439
|
key: "haikuModel",
|
|
27051
27440
|
label: "Haiku 模型映射",
|
|
27441
|
+
labelCode: "harness.field.claude.haikuModel.label",
|
|
27052
27442
|
kind: "text",
|
|
27053
27443
|
required: true,
|
|
27054
27444
|
placeholder: "例如:glm-5-air",
|
|
27055
|
-
|
|
27445
|
+
placeholderCode: "harness.field.claude.example.placeholder",
|
|
27446
|
+
help: "写入 ANTHROPIC_DEFAULT_HAIKU_MODEL。",
|
|
27447
|
+
helpCode: "harness.field.claude.modelMapping.help",
|
|
27448
|
+
params: { value: "glm-5-air", envVar: "ANTHROPIC_DEFAULT_HAIKU_MODEL" }
|
|
27056
27449
|
},
|
|
27057
27450
|
{
|
|
27058
27451
|
key: "haikuModelName",
|
|
27059
27452
|
label: "Haiku 显示名称(选填)",
|
|
27453
|
+
labelCode: "harness.field.claude.haikuModelName.label",
|
|
27060
27454
|
kind: "text",
|
|
27061
27455
|
placeholder: "留空则使用 Haiku 模型 ID",
|
|
27062
|
-
|
|
27456
|
+
placeholderCode: "harness.field.claude.modelName.placeholder",
|
|
27457
|
+
help: "写入 ANTHROPIC_DEFAULT_HAIKU_MODEL_NAME;留空时 Claude Code 默认显示对应模型 ID。",
|
|
27458
|
+
helpCode: "harness.field.claude.modelName.help",
|
|
27459
|
+
params: { role: "Haiku", envVar: "ANTHROPIC_DEFAULT_HAIKU_MODEL_NAME" }
|
|
27063
27460
|
},
|
|
27064
27461
|
{
|
|
27065
27462
|
key: "sonnetModel",
|
|
27066
27463
|
label: "Sonnet 模型映射",
|
|
27464
|
+
labelCode: "harness.field.claude.sonnetModel.label",
|
|
27067
27465
|
kind: "text",
|
|
27068
27466
|
required: true,
|
|
27069
27467
|
placeholder: "例如:glm-5",
|
|
27070
|
-
|
|
27468
|
+
placeholderCode: "harness.field.claude.example.placeholder",
|
|
27469
|
+
help: "写入 ANTHROPIC_DEFAULT_SONNET_MODEL。",
|
|
27470
|
+
helpCode: "harness.field.claude.modelMapping.help",
|
|
27471
|
+
params: { value: "glm-5", envVar: "ANTHROPIC_DEFAULT_SONNET_MODEL" }
|
|
27071
27472
|
},
|
|
27072
27473
|
{
|
|
27073
27474
|
key: "sonnetModelName",
|
|
27074
27475
|
label: "Sonnet 显示名称(选填)",
|
|
27476
|
+
labelCode: "harness.field.claude.sonnetModelName.label",
|
|
27075
27477
|
kind: "text",
|
|
27076
27478
|
placeholder: "留空则使用 Sonnet 模型 ID",
|
|
27077
|
-
|
|
27479
|
+
placeholderCode: "harness.field.claude.modelName.placeholder",
|
|
27480
|
+
help: "写入 ANTHROPIC_DEFAULT_SONNET_MODEL_NAME;留空时 Claude Code 默认显示对应模型 ID。",
|
|
27481
|
+
helpCode: "harness.field.claude.modelName.help",
|
|
27482
|
+
params: { role: "Sonnet", envVar: "ANTHROPIC_DEFAULT_SONNET_MODEL_NAME" }
|
|
27078
27483
|
},
|
|
27079
27484
|
oneMField("Sonnet", "sonnetModel1m"),
|
|
27080
27485
|
{
|
|
27081
27486
|
key: "opusModel",
|
|
27082
27487
|
label: "Opus 模型映射",
|
|
27488
|
+
labelCode: "harness.field.claude.opusModel.label",
|
|
27083
27489
|
kind: "text",
|
|
27084
27490
|
required: true,
|
|
27085
27491
|
placeholder: "例如:glm-5",
|
|
27086
|
-
|
|
27492
|
+
placeholderCode: "harness.field.claude.example.placeholder",
|
|
27493
|
+
help: "写入 ANTHROPIC_DEFAULT_OPUS_MODEL。",
|
|
27494
|
+
helpCode: "harness.field.claude.modelMapping.help",
|
|
27495
|
+
params: { value: "glm-5", envVar: "ANTHROPIC_DEFAULT_OPUS_MODEL" }
|
|
27087
27496
|
},
|
|
27088
27497
|
{
|
|
27089
27498
|
key: "opusModelName",
|
|
27090
27499
|
label: "Opus 显示名称(选填)",
|
|
27500
|
+
labelCode: "harness.field.claude.opusModelName.label",
|
|
27091
27501
|
kind: "text",
|
|
27092
27502
|
placeholder: "留空则使用 Opus 模型 ID",
|
|
27093
|
-
|
|
27503
|
+
placeholderCode: "harness.field.claude.modelName.placeholder",
|
|
27504
|
+
help: "写入 ANTHROPIC_DEFAULT_OPUS_MODEL_NAME;留空时 Claude Code 默认显示对应模型 ID。",
|
|
27505
|
+
helpCode: "harness.field.claude.modelName.help",
|
|
27506
|
+
params: { role: "Opus", envVar: "ANTHROPIC_DEFAULT_OPUS_MODEL_NAME" }
|
|
27094
27507
|
},
|
|
27095
27508
|
oneMField("Opus", "opusModel1m"),
|
|
27096
27509
|
{
|
|
27097
27510
|
key: "fableModel",
|
|
27098
27511
|
label: "Fable 模型映射(可选)",
|
|
27512
|
+
labelCode: "harness.field.claude.fableModel.label",
|
|
27099
27513
|
kind: "text",
|
|
27100
27514
|
placeholder: "例如:glm-5",
|
|
27101
|
-
|
|
27515
|
+
placeholderCode: "harness.field.claude.example.placeholder",
|
|
27516
|
+
help: "写入 ANTHROPIC_DEFAULT_FABLE_MODEL;用于支持 Fable 档位的新版 Claude Code。",
|
|
27517
|
+
helpCode: "harness.field.claude.fableModel.help",
|
|
27518
|
+
params: { value: "glm-5" }
|
|
27102
27519
|
},
|
|
27103
27520
|
{
|
|
27104
27521
|
key: "fableModelName",
|
|
27105
27522
|
label: "Fable 显示名称(选填)",
|
|
27523
|
+
labelCode: "harness.field.claude.fableModelName.label",
|
|
27106
27524
|
kind: "text",
|
|
27107
27525
|
placeholder: "留空则使用 Fable 模型 ID",
|
|
27108
|
-
|
|
27526
|
+
placeholderCode: "harness.field.claude.modelName.placeholder",
|
|
27527
|
+
help: "写入 ANTHROPIC_DEFAULT_FABLE_MODEL_NAME;留空时 Claude Code 默认显示对应模型 ID。",
|
|
27528
|
+
helpCode: "harness.field.claude.modelName.help",
|
|
27529
|
+
params: { role: "Fable", envVar: "ANTHROPIC_DEFAULT_FABLE_MODEL_NAME" }
|
|
27109
27530
|
},
|
|
27110
27531
|
oneMField("Fable", "fableModel1m"),
|
|
27111
27532
|
{
|
|
27112
27533
|
key: "subagentModel",
|
|
27113
27534
|
label: "子代理模型(可选)",
|
|
27535
|
+
labelCode: "harness.field.claude.subagentModel.label",
|
|
27114
27536
|
kind: "text",
|
|
27115
27537
|
placeholder: "例如:glm-5-air",
|
|
27116
|
-
|
|
27538
|
+
placeholderCode: "harness.field.claude.example.placeholder",
|
|
27539
|
+
help: "写入 CLAUDE_CODE_SUBAGENT_MODEL,可让子代理使用更快或成本更低的模型。",
|
|
27540
|
+
helpCode: "harness.field.claude.subagentModel.help",
|
|
27541
|
+
params: { value: "glm-5-air" }
|
|
27117
27542
|
},
|
|
27118
|
-
oneMField("子代理", "subagentModel1m"),
|
|
27543
|
+
oneMField("子代理", "subagentModel1m", "harness.field.claude.oneM.subagentLabel"),
|
|
27119
27544
|
{
|
|
27120
27545
|
key: "extraEnv",
|
|
27121
27546
|
label: "追加环境变量(可选)",
|
|
27547
|
+
labelCode: "harness.field.claude.extraEnv.label",
|
|
27122
27548
|
kind: "textarea",
|
|
27123
27549
|
placeholder: `ANTHROPIC_DEFAULT_SONNET_MODEL=glm-5.2
|
|
27124
27550
|
API_TIMEOUT_MS=3000000`,
|
|
27125
|
-
help: "每行一个 KEY=VALUE,会合并进 settings.json 的 env。"
|
|
27551
|
+
help: "每行一个 KEY=VALUE,会合并进 settings.json 的 env。",
|
|
27552
|
+
helpCode: "harness.field.claude.extraEnv.help"
|
|
27126
27553
|
}
|
|
27127
27554
|
];
|
|
27128
27555
|
constructor(environment) {
|
|
@@ -27213,7 +27640,7 @@ API_TIMEOUT_MS=3000000`,
|
|
|
27213
27640
|
return { [SETTINGS]: stringifyJson(settings) };
|
|
27214
27641
|
}
|
|
27215
27642
|
backfill(profile, current) {
|
|
27216
|
-
const settings =
|
|
27643
|
+
const settings = tryParseJsonObject(current[SETTINGS]) ?? {};
|
|
27217
27644
|
const env = settings.env;
|
|
27218
27645
|
const authVar = this.authVar(profile);
|
|
27219
27646
|
const apiKey = readString(env, authVar);
|
|
@@ -27235,7 +27662,7 @@ API_TIMEOUT_MS=3000000`,
|
|
|
27235
27662
|
};
|
|
27236
27663
|
}
|
|
27237
27664
|
detect(current) {
|
|
27238
|
-
const env =
|
|
27665
|
+
const env = (tryParseJsonObject(current[SETTINGS]) ?? {}).env;
|
|
27239
27666
|
const authVar = AUTH_VARS.find((name) => readString(env, name)) ?? AUTH_VARS[0];
|
|
27240
27667
|
const seed = seedProfile({ authVar });
|
|
27241
27668
|
return compact([toCandidate("claude", seed, this.backfill(seed, current), true)]);
|
|
@@ -27252,13 +27679,6 @@ function withOneM(value, enabled) {
|
|
|
27252
27679
|
function withoutOneM(value) {
|
|
27253
27680
|
return value.endsWith(ONE_M_SUFFIX) ? value.slice(0, -ONE_M_SUFFIX.length) : value;
|
|
27254
27681
|
}
|
|
27255
|
-
function safeParse3(text) {
|
|
27256
|
-
try {
|
|
27257
|
-
return parseJsonObject(text);
|
|
27258
|
-
} catch {
|
|
27259
|
-
return {};
|
|
27260
|
-
}
|
|
27261
|
-
}
|
|
27262
27682
|
function parseEnvLines(raw2) {
|
|
27263
27683
|
if (!raw2) {
|
|
27264
27684
|
return [];
|
|
@@ -27300,40 +27720,73 @@ class CodexAdapter {
|
|
|
27300
27720
|
mode = "replace";
|
|
27301
27721
|
envVarNames = [DEFAULT_ENV_KEY];
|
|
27302
27722
|
envNote = "仅「环境变量」认证模式需要 env.sh,其余模式的凭据自包含在 config.toml 里。";
|
|
27723
|
+
envNoteCode = "harness.field.codex.envNote";
|
|
27724
|
+
official(_current) {
|
|
27725
|
+
return {
|
|
27726
|
+
kind: "account-login",
|
|
27727
|
+
available: true,
|
|
27728
|
+
titleCode: "harness.official",
|
|
27729
|
+
hintCode: "harness.officialHintCodex"
|
|
27730
|
+
};
|
|
27731
|
+
}
|
|
27303
27732
|
fields = [
|
|
27304
27733
|
{
|
|
27305
27734
|
key: "authMode",
|
|
27306
27735
|
label: "认证方式",
|
|
27736
|
+
labelCode: "harness.field.codex.authMode.label",
|
|
27307
27737
|
kind: "select",
|
|
27308
27738
|
defaultValue: "bearer_token",
|
|
27309
27739
|
help: "auth.json 就是 Codex 的登录缓存,覆盖它会丢失 ChatGPT 登录态,所以默认不碰它。",
|
|
27740
|
+
helpCode: "harness.field.codex.authMode.help",
|
|
27310
27741
|
options: [
|
|
27311
|
-
{
|
|
27312
|
-
|
|
27313
|
-
|
|
27742
|
+
{
|
|
27743
|
+
value: "bearer_token",
|
|
27744
|
+
label: "写入 config.toml(推荐,保留官方登录)",
|
|
27745
|
+
labelCode: "harness.field.codex.authMode.option.bearerToken"
|
|
27746
|
+
},
|
|
27747
|
+
{
|
|
27748
|
+
value: "env_key",
|
|
27749
|
+
label: "环境变量(需要 source env.sh)",
|
|
27750
|
+
labelCode: "harness.field.codex.authMode.option.envKey"
|
|
27751
|
+
},
|
|
27752
|
+
{
|
|
27753
|
+
value: "openai_auth",
|
|
27754
|
+
label: "写入 auth.json(会覆盖 ChatGPT 登录缓存)",
|
|
27755
|
+
labelCode: "harness.field.codex.authMode.option.openaiAuth"
|
|
27756
|
+
}
|
|
27314
27757
|
]
|
|
27315
27758
|
},
|
|
27316
27759
|
{
|
|
27317
27760
|
key: "providerId",
|
|
27318
27761
|
label: "Provider ID(可选)",
|
|
27762
|
+
labelCode: "harness.field.providerId.label",
|
|
27319
27763
|
kind: "text",
|
|
27320
27764
|
placeholder: "默认取配置名称",
|
|
27321
|
-
|
|
27765
|
+
placeholderCode: "harness.field.providerId.placeholder",
|
|
27766
|
+
help: "openai / ollama / lmstudio / amazon-bedrock 等是 Codex 保留字,会自动改名。",
|
|
27767
|
+
helpCode: "harness.field.codex.providerId.help"
|
|
27322
27768
|
},
|
|
27323
27769
|
{
|
|
27324
27770
|
key: "envKeyName",
|
|
27325
27771
|
label: "环境变量名",
|
|
27772
|
+
labelCode: "harness.field.codex.envKeyName.label",
|
|
27326
27773
|
kind: "text",
|
|
27327
27774
|
defaultValue: DEFAULT_ENV_KEY,
|
|
27328
|
-
help: "仅「环境变量」模式生效。"
|
|
27775
|
+
help: "仅「环境变量」模式生效。",
|
|
27776
|
+
helpCode: "harness.field.codex.envKeyName.help"
|
|
27329
27777
|
},
|
|
27330
27778
|
{
|
|
27331
27779
|
key: "reasoningEffort",
|
|
27332
27780
|
label: "推理强度(可选)",
|
|
27781
|
+
labelCode: "harness.field.codex.reasoningEffort.label",
|
|
27333
27782
|
kind: "select",
|
|
27334
27783
|
defaultValue: "",
|
|
27335
27784
|
options: [
|
|
27336
|
-
{
|
|
27785
|
+
{
|
|
27786
|
+
value: "",
|
|
27787
|
+
label: "不设置",
|
|
27788
|
+
labelCode: "harness.field.codex.reasoningEffort.option.unset"
|
|
27789
|
+
},
|
|
27337
27790
|
{ value: "low", label: "low" },
|
|
27338
27791
|
{ value: "medium", label: "medium" },
|
|
27339
27792
|
{ value: "high", label: "high" }
|
|
@@ -27354,6 +27807,7 @@ class CodexAdapter {
|
|
|
27354
27807
|
{
|
|
27355
27808
|
key: AUTH,
|
|
27356
27809
|
label: "auth.json(仅 auth.json 模式)",
|
|
27810
|
+
labelCode: "harness.field.codex.target.auth",
|
|
27357
27811
|
path: join4(this.environment.harnessHomes.codex, "auth.json"),
|
|
27358
27812
|
format: "json"
|
|
27359
27813
|
}
|
|
@@ -27366,10 +27820,10 @@ class CodexAdapter {
|
|
|
27366
27820
|
return { [this.envKeyName(profile)]: profile.apiKey };
|
|
27367
27821
|
}
|
|
27368
27822
|
render(profile, current) {
|
|
27369
|
-
const
|
|
27823
|
+
const providerId2 = this.providerId(profile);
|
|
27370
27824
|
const config2 = parseTomlObject(current[CONFIG]);
|
|
27371
27825
|
const mode = this.authMode(profile);
|
|
27372
|
-
config2.model_provider =
|
|
27826
|
+
config2.model_provider = providerId2;
|
|
27373
27827
|
if (profile.model) {
|
|
27374
27828
|
config2.model = profile.model;
|
|
27375
27829
|
}
|
|
@@ -27378,7 +27832,7 @@ class CodexAdapter {
|
|
|
27378
27832
|
config2.model_reasoning_effort = effort;
|
|
27379
27833
|
}
|
|
27380
27834
|
const providers = ensureObject(config2, "model_providers");
|
|
27381
|
-
const provider = ensureObject(providers,
|
|
27835
|
+
const provider = ensureObject(providers, providerId2);
|
|
27382
27836
|
provider.name = profile.name;
|
|
27383
27837
|
provider.base_url = profile.baseUrl;
|
|
27384
27838
|
provider.wire_api = "responses";
|
|
@@ -27417,16 +27871,14 @@ class CodexAdapter {
|
|
|
27417
27871
|
return rendered;
|
|
27418
27872
|
}
|
|
27419
27873
|
backfill(profile, current) {
|
|
27420
|
-
|
|
27421
|
-
|
|
27422
|
-
config2 = parseTomlObject(current[CONFIG]);
|
|
27423
|
-
} catch {
|
|
27874
|
+
const config2 = tryParseTomlObject(current[CONFIG]);
|
|
27875
|
+
if (!config2) {
|
|
27424
27876
|
return {};
|
|
27425
27877
|
}
|
|
27426
27878
|
const providers = config2.model_providers;
|
|
27427
27879
|
const provider = isPlainObject2(providers) ? providers[this.providerId(profile)] : undefined;
|
|
27428
27880
|
const mode = this.authMode(profile);
|
|
27429
|
-
const token = mode === "bearer_token" ? readString(provider, "experimental_bearer_token") : mode === "openai_auth" ? readString(
|
|
27881
|
+
const token = mode === "bearer_token" ? readString(provider, "experimental_bearer_token") : mode === "openai_auth" ? readString(tryParseJsonObject(current[AUTH]) ?? {}, DEFAULT_ENV_KEY) : "";
|
|
27430
27882
|
return {
|
|
27431
27883
|
baseUrl: readString(provider, "base_url") || profile.baseUrl,
|
|
27432
27884
|
model: readString(config2, "model"),
|
|
@@ -27434,10 +27886,8 @@ class CodexAdapter {
|
|
|
27434
27886
|
};
|
|
27435
27887
|
}
|
|
27436
27888
|
detect(current) {
|
|
27437
|
-
|
|
27438
|
-
|
|
27439
|
-
config2 = parseTomlObject(current[CONFIG]);
|
|
27440
|
-
} catch {
|
|
27889
|
+
const config2 = tryParseTomlObject(current[CONFIG]);
|
|
27890
|
+
if (!config2) {
|
|
27441
27891
|
return [];
|
|
27442
27892
|
}
|
|
27443
27893
|
const providers = config2.model_providers;
|
|
@@ -27467,17 +27917,10 @@ class CodexAdapter {
|
|
|
27467
27917
|
return profile.extras.envKeyName?.trim() || DEFAULT_ENV_KEY;
|
|
27468
27918
|
}
|
|
27469
27919
|
providerId(profile) {
|
|
27470
|
-
const slug =
|
|
27920
|
+
const slug = providerId(profile);
|
|
27471
27921
|
return RESERVED_PROVIDER_IDS.has(slug) ? `${slug}-hsw` : slug;
|
|
27472
27922
|
}
|
|
27473
27923
|
}
|
|
27474
|
-
function safeJson(text) {
|
|
27475
|
-
try {
|
|
27476
|
-
return parseJsonObject(text);
|
|
27477
|
-
} catch {
|
|
27478
|
-
return {};
|
|
27479
|
-
}
|
|
27480
|
-
}
|
|
27481
27924
|
|
|
27482
27925
|
// src/services/adapters/dsh.ts
|
|
27483
27926
|
import { join as join5 } from "node:path";
|
|
@@ -27493,35 +27936,53 @@ class DshAdapter {
|
|
|
27493
27936
|
modelRequired = true;
|
|
27494
27937
|
envVarNames = [];
|
|
27495
27938
|
envNote = "API key 安全写入 DSH 的 .credentials.yaml,并由 settings.yaml 引用。";
|
|
27939
|
+
envNoteCode = "harness.field.dsh.envNote";
|
|
27940
|
+
officialNeedsCurrent = true;
|
|
27496
27941
|
fields = [
|
|
27497
27942
|
{
|
|
27498
27943
|
key: "providerType",
|
|
27499
27944
|
label: "提供方类型",
|
|
27945
|
+
labelCode: "harness.field.dsh.providerType.label",
|
|
27500
27946
|
kind: "select",
|
|
27501
27947
|
defaultValue: "custom",
|
|
27502
27948
|
options: [
|
|
27503
|
-
{
|
|
27504
|
-
|
|
27949
|
+
{
|
|
27950
|
+
value: "custom",
|
|
27951
|
+
label: "自定义提供方",
|
|
27952
|
+
labelCode: "harness.field.dsh.providerType.option.custom"
|
|
27953
|
+
},
|
|
27954
|
+
{
|
|
27955
|
+
value: "official",
|
|
27956
|
+
label: "DeepSeek 官方",
|
|
27957
|
+
labelCode: "harness.field.dsh.providerType.option.official"
|
|
27958
|
+
}
|
|
27505
27959
|
]
|
|
27506
27960
|
},
|
|
27507
27961
|
{
|
|
27508
27962
|
key: "providerId",
|
|
27509
27963
|
label: "Provider ID(可选)",
|
|
27964
|
+
labelCode: "harness.field.providerId.label",
|
|
27510
27965
|
kind: "text",
|
|
27511
27966
|
placeholder: "默认取配置名称",
|
|
27512
|
-
|
|
27967
|
+
placeholderCode: "harness.field.providerId.placeholder",
|
|
27968
|
+
help: "DSH 的模型路由标识;必须以小写字母开头。",
|
|
27969
|
+
helpCode: "harness.field.dsh.providerId.help"
|
|
27513
27970
|
},
|
|
27514
27971
|
{
|
|
27515
27972
|
key: "models",
|
|
27516
27973
|
label: "模型目录(可选)",
|
|
27974
|
+
labelCode: "harness.field.dsh.models.label",
|
|
27517
27975
|
kind: "textarea",
|
|
27518
27976
|
fullWidth: true,
|
|
27519
27977
|
placeholder: "每行一个模型 ID;留空时只注册上方的默认模型",
|
|
27520
|
-
|
|
27978
|
+
placeholderCode: "harness.field.dsh.models.placeholder",
|
|
27979
|
+
help: "一个提供方可注册多个模型;上方“模型”作为新会话的默认模型。",
|
|
27980
|
+
helpCode: "harness.field.dsh.models.help"
|
|
27521
27981
|
},
|
|
27522
27982
|
{
|
|
27523
27983
|
key: "api",
|
|
27524
27984
|
label: "API 协议",
|
|
27985
|
+
labelCode: "harness.field.dsh.api.label",
|
|
27525
27986
|
kind: "select",
|
|
27526
27987
|
defaultValue: "openai-responses",
|
|
27527
27988
|
options: [
|
|
@@ -27533,27 +27994,39 @@ class DshAdapter {
|
|
|
27533
27994
|
{
|
|
27534
27995
|
key: "contextWindow",
|
|
27535
27996
|
label: "上下文长度",
|
|
27997
|
+
labelCode: "harness.field.contextLength.label",
|
|
27536
27998
|
kind: "text",
|
|
27537
27999
|
defaultValue: String(DEFAULT_CONTEXT)
|
|
27538
28000
|
},
|
|
27539
28001
|
{
|
|
27540
28002
|
key: "maxTokens",
|
|
27541
28003
|
label: "最大输出 tokens",
|
|
28004
|
+
labelCode: "harness.field.maxTokens.label",
|
|
27542
28005
|
kind: "text",
|
|
27543
28006
|
defaultValue: String(DEFAULT_MAX_TOKENS)
|
|
27544
28007
|
},
|
|
27545
28008
|
{
|
|
27546
28009
|
key: "reasoningEfforts",
|
|
27547
28010
|
label: "支持的思考程度",
|
|
28011
|
+
labelCode: "harness.field.dsh.reasoningEfforts.label",
|
|
27548
28012
|
kind: "select",
|
|
27549
28013
|
defaultValue: "",
|
|
27550
28014
|
help: "DSH 只会显示这里声明且上游模型实际支持的档位。",
|
|
28015
|
+
helpCode: "harness.field.dsh.reasoningEfforts.help",
|
|
27551
28016
|
options: [
|
|
27552
|
-
{
|
|
28017
|
+
{
|
|
28018
|
+
value: "",
|
|
28019
|
+
label: "不声明(提供方默认)",
|
|
28020
|
+
labelCode: "harness.field.dsh.reasoningEfforts.option.unset"
|
|
28021
|
+
},
|
|
27553
28022
|
{ value: "low,medium,high,xhigh,max", label: "Low / Medium / High / XHigh / Max" },
|
|
27554
28023
|
{ value: "low,medium,high,xhigh", label: "Low / Medium / High / XHigh" },
|
|
27555
28024
|
{ value: "minimal,low,medium,high", label: "Minimal / Low / Medium / High" },
|
|
27556
|
-
{
|
|
28025
|
+
{
|
|
28026
|
+
value: "false",
|
|
28027
|
+
label: "模型不支持思考程度",
|
|
28028
|
+
labelCode: "harness.field.dsh.reasoningEfforts.option.none"
|
|
28029
|
+
}
|
|
27557
28030
|
]
|
|
27558
28031
|
}
|
|
27559
28032
|
];
|
|
@@ -27596,17 +28069,17 @@ class DshAdapter {
|
|
|
27596
28069
|
render(profile, current) {
|
|
27597
28070
|
this.validate(profile);
|
|
27598
28071
|
const official = this.isOfficial(profile);
|
|
27599
|
-
const
|
|
27600
|
-
const credentialRef = this.credentialRef(
|
|
28072
|
+
const providerId2 = official ? "deepseek-official" : this.providerId(profile);
|
|
28073
|
+
const credentialRef = this.credentialRef(providerId2);
|
|
27601
28074
|
const settings = parseYamlDocument(current[SETTINGS2]);
|
|
27602
28075
|
const models = this.models(profile, official);
|
|
27603
28076
|
if (official) {
|
|
27604
28077
|
settings.setIn(["llm-deepseek", "apiKeyEnv"], credentialRef);
|
|
27605
28078
|
settings.setIn(["llm-deepseek", "baseURL"], profile.baseUrl || "https://api.deepseek.com");
|
|
27606
28079
|
settings.setIn(["llm-deepseek", "models"], models);
|
|
27607
|
-
settings.setIn(["llm-deepseek", "maxTokens"],
|
|
28080
|
+
settings.setIn(["llm-deepseek", "maxTokens"], numeric(profile.extras.maxTokens, 256000));
|
|
27608
28081
|
} else {
|
|
27609
|
-
settings.setIn(["llm-pi-ai", "providers",
|
|
28082
|
+
settings.setIn(["llm-pi-ai", "providers", providerId2], {
|
|
27610
28083
|
displayName: profile.name,
|
|
27611
28084
|
apiKeyEnv: credentialRef,
|
|
27612
28085
|
api: profile.extras.api || "openai-responses",
|
|
@@ -27614,7 +28087,7 @@ class DshAdapter {
|
|
|
27614
28087
|
models
|
|
27615
28088
|
});
|
|
27616
28089
|
}
|
|
27617
|
-
settings.setIn(["agent-default-model", "provider"],
|
|
28090
|
+
settings.setIn(["agent-default-model", "provider"], providerId2);
|
|
27618
28091
|
settings.setIn(["agent-default-model", "model"], profile.model);
|
|
27619
28092
|
settings.deleteIn(["agent-default-model", "reasoningEffort"]);
|
|
27620
28093
|
const credentials = parseYamlDocument(current[CREDENTIALS]);
|
|
@@ -27638,74 +28111,104 @@ class DshAdapter {
|
|
|
27638
28111
|
rendered[SETTINGS2] = settings.toString();
|
|
27639
28112
|
return rendered;
|
|
27640
28113
|
}
|
|
28114
|
+
renderOfficial(_profile, current) {
|
|
28115
|
+
const official = this.readOfficialRoute(current);
|
|
28116
|
+
if (!official) {
|
|
28117
|
+
throw new HttpError(400, "未检测到 DeepSeek 官方 API Key 配置", {
|
|
28118
|
+
code: ERROR_CODES.officialApiKeyMissing,
|
|
28119
|
+
params: { harness: "DeepSeek Harness" }
|
|
28120
|
+
});
|
|
28121
|
+
}
|
|
28122
|
+
official.settings.setIn(["agent-default-model", "provider"], "deepseek-official");
|
|
28123
|
+
return { [SETTINGS2]: official.settings.toString() };
|
|
28124
|
+
}
|
|
28125
|
+
official(current) {
|
|
28126
|
+
const official = this.readOfficialRoute(current);
|
|
28127
|
+
if (!official)
|
|
28128
|
+
return;
|
|
28129
|
+
return {
|
|
28130
|
+
kind: "native-api",
|
|
28131
|
+
available: true,
|
|
28132
|
+
titleCode: "harness.deepseekOfficial",
|
|
28133
|
+
hintCode: "harness.officialHintDsh",
|
|
28134
|
+
matchesProfile: (profile) => profile.extras.providerType === "official"
|
|
28135
|
+
};
|
|
28136
|
+
}
|
|
28137
|
+
readOfficialRoute(current) {
|
|
28138
|
+
const settings = tryParseYamlDocument(current[SETTINGS2]);
|
|
28139
|
+
const credentials = tryParseYamlDocument(current[CREDENTIALS]);
|
|
28140
|
+
const route = settings ? toPlain(settings.getIn(["llm-deepseek"])) : undefined;
|
|
28141
|
+
const credentialRef = typeof route?.apiKeyEnv === "string" && route.apiKeyEnv ? route.apiKeyEnv : "DEEPSEEK_API_KEY";
|
|
28142
|
+
const apiKey = credentials?.getIn(["refs", credentialRef]) ?? credentials?.getIn([credentialRef]);
|
|
28143
|
+
if (!settings || route === undefined || typeof apiKey !== "string" || !apiKey.trim()) {
|
|
28144
|
+
return;
|
|
28145
|
+
}
|
|
28146
|
+
return { settings, route, credentialRef, apiKey };
|
|
28147
|
+
}
|
|
27641
28148
|
revoke(profile, current) {
|
|
27642
28149
|
const official = this.isOfficial(profile);
|
|
27643
|
-
const
|
|
28150
|
+
const providerId2 = official ? "deepseek-official" : this.providerId(profile);
|
|
27644
28151
|
const rendered = {};
|
|
27645
28152
|
if (current[SETTINGS2] !== undefined) {
|
|
27646
|
-
|
|
27647
|
-
|
|
28153
|
+
const settings = tryParseYamlDocument(current[SETTINGS2]);
|
|
28154
|
+
if (settings) {
|
|
27648
28155
|
if (official)
|
|
27649
28156
|
settings.deleteIn(["llm-deepseek"]);
|
|
27650
28157
|
else
|
|
27651
|
-
settings.deleteIn(["llm-pi-ai", "providers",
|
|
27652
|
-
if (settings.getIn(["agent-default-model", "provider"]) ===
|
|
28158
|
+
settings.deleteIn(["llm-pi-ai", "providers", providerId2]);
|
|
28159
|
+
if (settings.getIn(["agent-default-model", "provider"]) === providerId2) {
|
|
27653
28160
|
settings.deleteIn(["agent-default-model"]);
|
|
27654
28161
|
}
|
|
27655
28162
|
rendered[SETTINGS2] = settings.toString();
|
|
27656
|
-
}
|
|
28163
|
+
}
|
|
27657
28164
|
}
|
|
27658
28165
|
if (current[CREDENTIALS] !== undefined) {
|
|
27659
|
-
|
|
27660
|
-
|
|
28166
|
+
const credentials = tryParseYamlDocument(current[CREDENTIALS]);
|
|
28167
|
+
if (credentials) {
|
|
27661
28168
|
this.normalizeCredentials(credentials);
|
|
27662
|
-
credentials.deleteIn(["refs", this.credentialRef(
|
|
28169
|
+
credentials.deleteIn(["refs", this.credentialRef(providerId2)]);
|
|
27663
28170
|
rendered[CREDENTIALS] = credentials.toString();
|
|
27664
|
-
}
|
|
28171
|
+
}
|
|
27665
28172
|
}
|
|
27666
28173
|
return rendered;
|
|
27667
28174
|
}
|
|
27668
28175
|
backfill(profile, current) {
|
|
27669
|
-
|
|
27670
|
-
|
|
27671
|
-
|
|
27672
|
-
|
|
27673
|
-
|
|
27674
|
-
const route = toPlain(settings.getIn(official ? ["llm-deepseek"] : ["llm-pi-ai", "providers", providerId]));
|
|
27675
|
-
const models = Array.isArray(route?.models) ? route.models : [];
|
|
27676
|
-
const firstModel = toPlain(models[0]);
|
|
27677
|
-
const ref = this.credentialRef(providerId);
|
|
27678
|
-
const apiKey = credentials.getIn(["refs", ref]) ?? credentials.getIn([ref]);
|
|
27679
|
-
return {
|
|
27680
|
-
baseUrl: typeof route?.baseURL === "string" ? route.baseURL : profile.baseUrl,
|
|
27681
|
-
apiKey: typeof apiKey === "string" && apiKey ? apiKey : profile.apiKey,
|
|
27682
|
-
model: typeof firstModel?.id === "string" ? firstModel.id : profile.model,
|
|
27683
|
-
extras: {
|
|
27684
|
-
...profile.extras,
|
|
27685
|
-
providerType: official ? "official" : "custom",
|
|
27686
|
-
api: typeof route?.api === "string" ? route.api : profile.extras.api || "",
|
|
27687
|
-
models: models.map((entry) => toPlain(entry)?.id).filter((id) => typeof id === "string").join(`
|
|
27688
|
-
`),
|
|
27689
|
-
contextWindow: valueString(firstModel?.contextWindow, profile.extras.contextWindow),
|
|
27690
|
-
maxTokens: valueString(firstModel?.maxTokens, profile.extras.maxTokens),
|
|
27691
|
-
reasoningEfforts: reasoningEffortsString(firstModel?.reasoningEfforts, profile.extras.reasoningEfforts)
|
|
27692
|
-
}
|
|
27693
|
-
};
|
|
27694
|
-
} catch {
|
|
28176
|
+
const official = this.isOfficial(profile);
|
|
28177
|
+
const providerId2 = official ? "deepseek-official" : this.providerId(profile);
|
|
28178
|
+
const settings = tryParseYamlDocument(current[SETTINGS2]);
|
|
28179
|
+
const credentials = tryParseYamlDocument(current[CREDENTIALS]);
|
|
28180
|
+
if (!settings || !credentials) {
|
|
27695
28181
|
return {};
|
|
27696
28182
|
}
|
|
28183
|
+
const route = toPlain(settings.getIn(official ? ["llm-deepseek"] : ["llm-pi-ai", "providers", providerId2]));
|
|
28184
|
+
const models = Array.isArray(route?.models) ? route.models : [];
|
|
28185
|
+
const firstModel = toPlain(models[0]);
|
|
28186
|
+
const ref = this.credentialRef(providerId2);
|
|
28187
|
+
const apiKey = credentials.getIn(["refs", ref]) ?? credentials.getIn([ref]);
|
|
28188
|
+
return {
|
|
28189
|
+
baseUrl: typeof route?.baseURL === "string" ? route.baseURL : profile.baseUrl,
|
|
28190
|
+
apiKey: typeof apiKey === "string" && apiKey ? apiKey : profile.apiKey,
|
|
28191
|
+
model: typeof firstModel?.id === "string" ? firstModel.id : profile.model,
|
|
28192
|
+
extras: {
|
|
28193
|
+
...profile.extras,
|
|
28194
|
+
providerType: official ? "official" : "custom",
|
|
28195
|
+
api: typeof route?.api === "string" ? route.api : profile.extras.api || "",
|
|
28196
|
+
models: models.map((entry) => toPlain(entry)?.id).filter((id) => typeof id === "string").join(`
|
|
28197
|
+
`),
|
|
28198
|
+
contextWindow: valueString(firstModel?.contextWindow, profile.extras.contextWindow),
|
|
28199
|
+
maxTokens: valueString(firstModel?.maxTokens, profile.extras.maxTokens),
|
|
28200
|
+
reasoningEfforts: reasoningEffortsString(firstModel?.reasoningEfforts, profile.extras.reasoningEfforts)
|
|
28201
|
+
}
|
|
28202
|
+
};
|
|
27697
28203
|
}
|
|
27698
28204
|
detect(current) {
|
|
27699
|
-
|
|
27700
|
-
|
|
27701
|
-
try {
|
|
27702
|
-
const settings = parseYamlDocument(current[SETTINGS2]);
|
|
27703
|
-
providers = toPlain(settings.getIn(["llm-pi-ai", "providers"]));
|
|
27704
|
-
const active = settings.getIn(["agent-default-model", "provider"]);
|
|
27705
|
-
selected = typeof active === "string" ? active : "";
|
|
27706
|
-
} catch {
|
|
28205
|
+
const settings = tryParseYamlDocument(current[SETTINGS2]);
|
|
28206
|
+
if (!settings) {
|
|
27707
28207
|
return [];
|
|
27708
28208
|
}
|
|
28209
|
+
const providers = toPlain(settings.getIn(["llm-pi-ai", "providers"]));
|
|
28210
|
+
const active = settings.getIn(["agent-default-model", "provider"]);
|
|
28211
|
+
const selected = typeof active === "string" ? active : "";
|
|
27709
28212
|
if (!providers) {
|
|
27710
28213
|
return [];
|
|
27711
28214
|
}
|
|
@@ -27719,19 +28222,19 @@ class DshAdapter {
|
|
|
27719
28222
|
}));
|
|
27720
28223
|
}
|
|
27721
28224
|
providerId(profile) {
|
|
27722
|
-
const id =
|
|
28225
|
+
const id = providerId(profile);
|
|
27723
28226
|
return /^[a-z]/.test(id) ? id : `provider-${id}`;
|
|
27724
28227
|
}
|
|
27725
|
-
credentialRef(
|
|
27726
|
-
return
|
|
28228
|
+
credentialRef(providerId2) {
|
|
28229
|
+
return providerId2 === "deepseek-official" ? "DEEPSEEK_API_KEY" : `${providerId2.toUpperCase().replace(/[^A-Z0-9_]/g, "_")}_API_KEY`;
|
|
27727
28230
|
}
|
|
27728
28231
|
isOfficial(profile) {
|
|
27729
28232
|
return profile.extras.providerType === "official";
|
|
27730
28233
|
}
|
|
27731
28234
|
models(profile, official) {
|
|
27732
28235
|
const ids = [profile.model, ...(profile.extras.models || "").split(/[\n,]/)].map((id) => id.trim()).filter(Boolean);
|
|
27733
|
-
const contextWindow =
|
|
27734
|
-
const maxTokens =
|
|
28236
|
+
const contextWindow = numeric(profile.extras.contextWindow, official ? 1e6 : DEFAULT_CONTEXT);
|
|
28237
|
+
const maxTokens = numeric(profile.extras.maxTokens, official ? 256000 : DEFAULT_MAX_TOKENS);
|
|
27735
28238
|
const reasoningEfforts = this.reasoningEfforts(profile.extras.reasoningEfforts);
|
|
27736
28239
|
return [...new Set(ids)].map((id) => ({
|
|
27737
28240
|
id,
|
|
@@ -27751,10 +28254,6 @@ class DshAdapter {
|
|
|
27751
28254
|
credentials.deleteIn([key]);
|
|
27752
28255
|
}
|
|
27753
28256
|
}
|
|
27754
|
-
numeric(raw2, fallback) {
|
|
27755
|
-
const parsed = Number(raw2);
|
|
27756
|
-
return Number.isFinite(parsed) && parsed > 0 ? Math.trunc(parsed) : fallback;
|
|
27757
|
-
}
|
|
27758
28257
|
reasoningEfforts(raw2) {
|
|
27759
28258
|
if (!raw2) {
|
|
27760
28259
|
return;
|
|
@@ -27773,9 +28272,6 @@ function toPlain(value) {
|
|
|
27773
28272
|
function isYamlNode(value) {
|
|
27774
28273
|
return typeof value === "object" && value !== null && "toJSON" in value;
|
|
27775
28274
|
}
|
|
27776
|
-
function valueString(value, fallback) {
|
|
27777
|
-
return typeof value === "number" && Number.isFinite(value) ? String(value) : fallback || "";
|
|
27778
|
-
}
|
|
27779
28275
|
function reasoningEffortsString(value, fallback) {
|
|
27780
28276
|
if (value === false) {
|
|
27781
28277
|
return "false";
|
|
@@ -27796,15 +28292,30 @@ class KimiAdapter {
|
|
|
27796
28292
|
modelRequired = true;
|
|
27797
28293
|
envVarNames = [];
|
|
27798
28294
|
envNote = "Kimi Code 不从 shell 读取凭据,env.sh 对它无效。";
|
|
28295
|
+
envNoteCode = "harness.field.kimi.envNote";
|
|
28296
|
+
official(_current) {
|
|
28297
|
+
return {
|
|
28298
|
+
kind: "account-login",
|
|
28299
|
+
available: true,
|
|
28300
|
+
titleCode: "harness.official",
|
|
28301
|
+
hintCode: "harness.officialHintKimi"
|
|
28302
|
+
};
|
|
28303
|
+
}
|
|
27799
28304
|
fields = [
|
|
27800
28305
|
{
|
|
27801
28306
|
key: "providerType",
|
|
27802
28307
|
label: "Provider 类型",
|
|
28308
|
+
labelCode: "harness.field.kimi.providerType.label",
|
|
27803
28309
|
kind: "select",
|
|
27804
28310
|
defaultValue: "kimi",
|
|
27805
28311
|
help: "决定 Kimi Code 使用哪套协议实现。",
|
|
28312
|
+
helpCode: "harness.field.kimi.providerType.help",
|
|
27806
28313
|
options: [
|
|
27807
|
-
{
|
|
28314
|
+
{
|
|
28315
|
+
value: "kimi",
|
|
28316
|
+
label: "kimi(Moonshot / Kimi Code)",
|
|
28317
|
+
labelCode: "harness.field.kimi.providerType.option.kimi"
|
|
28318
|
+
},
|
|
27808
28319
|
{ value: "anthropic", label: "anthropic" },
|
|
27809
28320
|
{ value: "openai_responses", label: "openai_responses" },
|
|
27810
28321
|
{ value: "openai_legacy", label: "openai_legacy" }
|
|
@@ -27813,15 +28324,19 @@ class KimiAdapter {
|
|
|
27813
28324
|
{
|
|
27814
28325
|
key: "providerId",
|
|
27815
28326
|
label: "Provider ID(可选)",
|
|
28327
|
+
labelCode: "harness.field.providerId.label",
|
|
27816
28328
|
kind: "text",
|
|
27817
|
-
placeholder: "默认取配置名称"
|
|
28329
|
+
placeholder: "默认取配置名称",
|
|
28330
|
+
placeholderCode: "harness.field.providerId.placeholder"
|
|
27818
28331
|
},
|
|
27819
28332
|
{
|
|
27820
28333
|
key: "maxContextSize",
|
|
27821
28334
|
label: "上下文长度",
|
|
28335
|
+
labelCode: "harness.field.contextLength.label",
|
|
27822
28336
|
kind: "text",
|
|
27823
28337
|
defaultValue: String(DEFAULT_CONTEXT2),
|
|
27824
|
-
help: "Kimi Code 要求 models 条目必须声明 max_context_size。"
|
|
28338
|
+
help: "Kimi Code 要求 models 条目必须声明 max_context_size。",
|
|
28339
|
+
helpCode: "harness.field.kimi.maxContextSize.help"
|
|
27825
28340
|
}
|
|
27826
28341
|
];
|
|
27827
28342
|
constructor(environment) {
|
|
@@ -27850,7 +28365,7 @@ class KimiAdapter {
|
|
|
27850
28365
|
}
|
|
27851
28366
|
render(profile, current) {
|
|
27852
28367
|
this.validate(profile);
|
|
27853
|
-
const id =
|
|
28368
|
+
const id = providerId(profile);
|
|
27854
28369
|
const config2 = parseTomlObject(current[CONFIG2]);
|
|
27855
28370
|
const provider = ensureObject(ensureObject(config2, "providers"), id);
|
|
27856
28371
|
provider.type = profile.extras.providerType || "kimi";
|
|
@@ -27859,19 +28374,17 @@ class KimiAdapter {
|
|
|
27859
28374
|
const model = ensureObject(ensureObject(config2, "models"), id);
|
|
27860
28375
|
model.provider = id;
|
|
27861
28376
|
model.model = profile.model;
|
|
27862
|
-
model.max_context_size =
|
|
28377
|
+
model.max_context_size = numeric(profile.extras.maxContextSize, DEFAULT_CONTEXT2);
|
|
27863
28378
|
config2.default_model = id;
|
|
27864
28379
|
return { [CONFIG2]: stringifyToml(config2) };
|
|
27865
28380
|
}
|
|
27866
28381
|
revoke(profile, current) {
|
|
27867
|
-
const id =
|
|
28382
|
+
const id = providerId(profile);
|
|
27868
28383
|
if (current[CONFIG2] === undefined) {
|
|
27869
28384
|
return {};
|
|
27870
28385
|
}
|
|
27871
|
-
|
|
27872
|
-
|
|
27873
|
-
config2 = parseTomlObject(current[CONFIG2]);
|
|
27874
|
-
} catch {
|
|
28386
|
+
const config2 = tryParseTomlObject(current[CONFIG2]);
|
|
28387
|
+
if (!config2) {
|
|
27875
28388
|
return {};
|
|
27876
28389
|
}
|
|
27877
28390
|
const providers = config2.providers;
|
|
@@ -27896,10 +28409,8 @@ class KimiAdapter {
|
|
|
27896
28409
|
if (current[CONFIG2] === undefined) {
|
|
27897
28410
|
return {};
|
|
27898
28411
|
}
|
|
27899
|
-
|
|
27900
|
-
|
|
27901
|
-
config2 = parseTomlObject(current[CONFIG2]);
|
|
27902
|
-
} catch {
|
|
28412
|
+
const config2 = tryParseTomlObject(current[CONFIG2]);
|
|
28413
|
+
if (!config2) {
|
|
27903
28414
|
return {};
|
|
27904
28415
|
}
|
|
27905
28416
|
const official = officialModel(config2);
|
|
@@ -27913,13 +28424,11 @@ class KimiAdapter {
|
|
|
27913
28424
|
return { [CONFIG2]: stringifyToml(config2) };
|
|
27914
28425
|
}
|
|
27915
28426
|
backfill(profile, current) {
|
|
27916
|
-
|
|
27917
|
-
|
|
27918
|
-
config2 = parseTomlObject(current[CONFIG2]);
|
|
27919
|
-
} catch {
|
|
28427
|
+
const config2 = tryParseTomlObject(current[CONFIG2]);
|
|
28428
|
+
if (!config2) {
|
|
27920
28429
|
return {};
|
|
27921
28430
|
}
|
|
27922
|
-
const id =
|
|
28431
|
+
const id = providerId(profile);
|
|
27923
28432
|
const providers = config2.providers;
|
|
27924
28433
|
const provider = isPlainObject2(providers) ? providers[id] : undefined;
|
|
27925
28434
|
const models = config2.models;
|
|
@@ -27932,10 +28441,8 @@ class KimiAdapter {
|
|
|
27932
28441
|
};
|
|
27933
28442
|
}
|
|
27934
28443
|
detect(current) {
|
|
27935
|
-
|
|
27936
|
-
|
|
27937
|
-
config2 = parseTomlObject(current[CONFIG2]);
|
|
27938
|
-
} catch {
|
|
28444
|
+
const config2 = tryParseTomlObject(current[CONFIG2]);
|
|
28445
|
+
if (!config2) {
|
|
27939
28446
|
return [];
|
|
27940
28447
|
}
|
|
27941
28448
|
const providers = config2.providers;
|
|
@@ -27952,21 +28459,11 @@ class KimiAdapter {
|
|
|
27952
28459
|
const seed = seedProfile({
|
|
27953
28460
|
providerId: id,
|
|
27954
28461
|
providerType: readString(provider, "type") || "kimi",
|
|
27955
|
-
maxContextSize:
|
|
28462
|
+
maxContextSize: valueString(isPlainObject2(model) ? model.max_context_size : undefined, String(DEFAULT_CONTEXT2))
|
|
27956
28463
|
});
|
|
27957
28464
|
return toCandidate(id, seed, this.backfill(seed, current), id === selected);
|
|
27958
28465
|
}));
|
|
27959
28466
|
}
|
|
27960
|
-
providerId(profile) {
|
|
27961
|
-
return slugify2(profile.extras.providerId || profile.name, "provider");
|
|
27962
|
-
}
|
|
27963
|
-
contextSize(profile) {
|
|
27964
|
-
const parsed = Number(profile.extras.maxContextSize);
|
|
27965
|
-
return Number.isFinite(parsed) && parsed > 0 ? Math.trunc(parsed) : DEFAULT_CONTEXT2;
|
|
27966
|
-
}
|
|
27967
|
-
}
|
|
27968
|
-
function contextString(value) {
|
|
27969
|
-
return typeof value === "number" && Number.isFinite(value) ? String(Math.trunc(value)) : String(DEFAULT_CONTEXT2);
|
|
27970
28467
|
}
|
|
27971
28468
|
var PREFERRED_OFFICIAL_MODELS = ["kimi-code/k3-256k", "kimi-code/kimi-for-coding"];
|
|
27972
28469
|
function officialModel(config2) {
|
|
@@ -27991,17 +28488,22 @@ class PiAdapter {
|
|
|
27991
28488
|
modelRequired = true;
|
|
27992
28489
|
envVarNames = [];
|
|
27993
28490
|
envNote = "API key 直接写入 models.json,无需环境变量;运行时仍可用 --model 覆盖。";
|
|
28491
|
+
envNoteCode = "harness.field.pi.envNote";
|
|
27994
28492
|
fields = [
|
|
27995
28493
|
{
|
|
27996
28494
|
key: "providerId",
|
|
27997
28495
|
label: "Provider ID(可选)",
|
|
28496
|
+
labelCode: "harness.field.providerId.label",
|
|
27998
28497
|
kind: "text",
|
|
27999
28498
|
placeholder: "默认取配置名称",
|
|
28000
|
-
|
|
28499
|
+
placeholderCode: "harness.field.providerId.placeholder",
|
|
28500
|
+
help: "模型引用格式为 provider/model。",
|
|
28501
|
+
helpCode: "harness.field.pi.providerId.help"
|
|
28001
28502
|
},
|
|
28002
28503
|
{
|
|
28003
28504
|
key: "api",
|
|
28004
28505
|
label: "协议",
|
|
28506
|
+
labelCode: "harness.field.pi.api.label",
|
|
28005
28507
|
kind: "select",
|
|
28006
28508
|
defaultValue: "openai-completions",
|
|
28007
28509
|
options: [
|
|
@@ -28013,35 +28515,41 @@ class PiAdapter {
|
|
|
28013
28515
|
{
|
|
28014
28516
|
key: "authHeader",
|
|
28015
28517
|
label: "Authorization 头",
|
|
28518
|
+
labelCode: "harness.field.pi.authHeader.label",
|
|
28016
28519
|
kind: "select",
|
|
28017
28520
|
defaultValue: "true",
|
|
28018
28521
|
help: "以 Authorization: Bearer <key> 发送。",
|
|
28522
|
+
helpCode: "harness.field.pi.authHeader.help",
|
|
28019
28523
|
options: [
|
|
28020
|
-
{ value: "true", label: "开启" },
|
|
28021
|
-
{ value: "false", label: "关闭" }
|
|
28524
|
+
{ value: "true", label: "开启", labelCode: "harness.field.toggle.on" },
|
|
28525
|
+
{ value: "false", label: "关闭", labelCode: "harness.field.toggle.off" }
|
|
28022
28526
|
]
|
|
28023
28527
|
},
|
|
28024
28528
|
{
|
|
28025
28529
|
key: "contextWindow",
|
|
28026
28530
|
label: "上下文长度",
|
|
28531
|
+
labelCode: "harness.field.contextLength.label",
|
|
28027
28532
|
kind: "text",
|
|
28028
28533
|
defaultValue: String(DEFAULT_CONTEXT3)
|
|
28029
28534
|
},
|
|
28030
28535
|
{
|
|
28031
28536
|
key: "maxTokens",
|
|
28032
28537
|
label: "最大输出 tokens",
|
|
28538
|
+
labelCode: "harness.field.maxTokens.label",
|
|
28033
28539
|
kind: "text",
|
|
28034
28540
|
defaultValue: String(DEFAULT_MAX_TOKENS2)
|
|
28035
28541
|
},
|
|
28036
28542
|
{
|
|
28037
28543
|
key: "reasoning",
|
|
28038
28544
|
label: "推理能力",
|
|
28545
|
+
labelCode: "harness.field.pi.reasoning.label",
|
|
28039
28546
|
kind: "select",
|
|
28040
28547
|
defaultValue: "false",
|
|
28041
28548
|
help: "对应 models.json 的 reasoning。GPT / Claude 思考模型需要开启。",
|
|
28549
|
+
helpCode: "harness.field.pi.reasoning.help",
|
|
28042
28550
|
options: [
|
|
28043
|
-
{ value: "false", label: "关闭" },
|
|
28044
|
-
{ value: "true", label: "开启" }
|
|
28551
|
+
{ value: "false", label: "关闭", labelCode: "harness.field.toggle.off" },
|
|
28552
|
+
{ value: "true", label: "开启", labelCode: "harness.field.toggle.on" }
|
|
28045
28553
|
]
|
|
28046
28554
|
}
|
|
28047
28555
|
];
|
|
@@ -28083,14 +28591,14 @@ class PiAdapter {
|
|
|
28083
28591
|
}
|
|
28084
28592
|
render(profile, current) {
|
|
28085
28593
|
this.validate(profile);
|
|
28086
|
-
const id =
|
|
28594
|
+
const id = providerId(profile);
|
|
28087
28595
|
const models = parseJsonObject(current[MODELS]);
|
|
28088
28596
|
const provider = ensureObject(ensureObject(models, "providers"), id);
|
|
28089
28597
|
const model = {
|
|
28090
28598
|
id: profile.model,
|
|
28091
28599
|
name: profile.model,
|
|
28092
|
-
contextWindow:
|
|
28093
|
-
maxTokens:
|
|
28600
|
+
contextWindow: numeric(profile.extras.contextWindow, DEFAULT_CONTEXT3),
|
|
28601
|
+
maxTokens: numeric(profile.extras.maxTokens, DEFAULT_MAX_TOKENS2)
|
|
28094
28602
|
};
|
|
28095
28603
|
if (profile.extras.reasoning === "true") {
|
|
28096
28604
|
model.reasoning = true;
|
|
@@ -28109,66 +28617,64 @@ class PiAdapter {
|
|
|
28109
28617
|
};
|
|
28110
28618
|
}
|
|
28111
28619
|
revoke(profile, current) {
|
|
28112
|
-
const id =
|
|
28620
|
+
const id = providerId(profile);
|
|
28113
28621
|
const rendered = {};
|
|
28114
28622
|
if (current[MODELS] !== undefined) {
|
|
28115
|
-
|
|
28116
|
-
|
|
28623
|
+
const models = tryParseJsonObject(current[MODELS]);
|
|
28624
|
+
if (models) {
|
|
28117
28625
|
const providers = models.providers;
|
|
28118
28626
|
if (isPlainObject2(providers)) {
|
|
28119
28627
|
delete providers[id];
|
|
28120
28628
|
}
|
|
28121
28629
|
rendered[MODELS] = stringifyJson(models);
|
|
28122
|
-
}
|
|
28630
|
+
}
|
|
28123
28631
|
}
|
|
28124
28632
|
if (current[SETTINGS3] !== undefined) {
|
|
28125
|
-
|
|
28126
|
-
|
|
28633
|
+
const settings = tryParseJsonObject(current[SETTINGS3]);
|
|
28634
|
+
if (settings) {
|
|
28127
28635
|
if (settings.defaultProvider === id) {
|
|
28128
28636
|
delete settings.defaultProvider;
|
|
28129
28637
|
delete settings.defaultModel;
|
|
28130
28638
|
}
|
|
28131
28639
|
rendered[SETTINGS3] = stringifyJson(settings);
|
|
28132
|
-
}
|
|
28640
|
+
}
|
|
28133
28641
|
}
|
|
28134
28642
|
return rendered;
|
|
28135
28643
|
}
|
|
28136
28644
|
backfill(profile, current) {
|
|
28137
|
-
|
|
28138
|
-
|
|
28139
|
-
|
|
28140
|
-
|
|
28141
|
-
|
|
28142
|
-
|
|
28143
|
-
|
|
28144
|
-
|
|
28145
|
-
const firstModel = Array.isArray(provider.models) ? provider.models.find((entry) => isPlainObject2(entry)) : undefined;
|
|
28146
|
-
const apiKey = readString(provider, "apiKey");
|
|
28147
|
-
return {
|
|
28148
|
-
baseUrl: readString(provider, "baseUrl") || profile.baseUrl,
|
|
28149
|
-
apiKey: apiKey || profile.apiKey,
|
|
28150
|
-
model: readString(firstModel, "id") || profile.model,
|
|
28151
|
-
extras: {
|
|
28152
|
-
...profile.extras,
|
|
28153
|
-
api: readString(provider, "api") || profile.extras.api || "",
|
|
28154
|
-
contextWindow: valueString2(firstModel?.contextWindow, profile.extras.contextWindow),
|
|
28155
|
-
maxTokens: valueString2(firstModel?.maxTokens, profile.extras.maxTokens),
|
|
28156
|
-
reasoning: firstModel?.reasoning === true ? "true" : profile.extras.reasoning || "false"
|
|
28157
|
-
}
|
|
28158
|
-
};
|
|
28159
|
-
} catch {
|
|
28645
|
+
const models = tryParseJsonObject(current[MODELS]);
|
|
28646
|
+
if (!models) {
|
|
28647
|
+
return {};
|
|
28648
|
+
}
|
|
28649
|
+
const id = providerId(profile);
|
|
28650
|
+
const providers = models.providers;
|
|
28651
|
+
const provider = isPlainObject2(providers) ? providers[id] : undefined;
|
|
28652
|
+
if (!isPlainObject2(provider)) {
|
|
28160
28653
|
return {};
|
|
28161
28654
|
}
|
|
28655
|
+
const firstModel = Array.isArray(provider.models) ? provider.models.find((entry) => isPlainObject2(entry)) : undefined;
|
|
28656
|
+
const apiKey = readString(provider, "apiKey");
|
|
28657
|
+
return {
|
|
28658
|
+
baseUrl: readString(provider, "baseUrl") || profile.baseUrl,
|
|
28659
|
+
apiKey: apiKey || profile.apiKey,
|
|
28660
|
+
model: readString(firstModel, "id") || profile.model,
|
|
28661
|
+
extras: {
|
|
28662
|
+
...profile.extras,
|
|
28663
|
+
api: readString(provider, "api") || profile.extras.api || "",
|
|
28664
|
+
contextWindow: valueString(firstModel?.contextWindow, profile.extras.contextWindow),
|
|
28665
|
+
maxTokens: valueString(firstModel?.maxTokens, profile.extras.maxTokens),
|
|
28666
|
+
reasoning: firstModel?.reasoning === true ? "true" : profile.extras.reasoning || "false"
|
|
28667
|
+
}
|
|
28668
|
+
};
|
|
28162
28669
|
}
|
|
28163
28670
|
detect(current) {
|
|
28164
|
-
|
|
28165
|
-
|
|
28166
|
-
|
|
28167
|
-
providers = parseJsonObject(current[MODELS]).providers;
|
|
28168
|
-
selected = readString(parseJsonObject(current[SETTINGS3]), "defaultProvider");
|
|
28169
|
-
} catch {
|
|
28671
|
+
const models = tryParseJsonObject(current[MODELS]);
|
|
28672
|
+
const settings = tryParseJsonObject(current[SETTINGS3]);
|
|
28673
|
+
if (!models || !settings) {
|
|
28170
28674
|
return [];
|
|
28171
28675
|
}
|
|
28676
|
+
const providers = models.providers;
|
|
28677
|
+
const selected = readString(settings, "defaultProvider");
|
|
28172
28678
|
if (!isPlainObject2(providers)) {
|
|
28173
28679
|
return [];
|
|
28174
28680
|
}
|
|
@@ -28183,16 +28689,6 @@ class PiAdapter {
|
|
|
28183
28689
|
return toCandidate(id, seed, this.backfill(seed, current), id === selected);
|
|
28184
28690
|
}));
|
|
28185
28691
|
}
|
|
28186
|
-
providerId(profile) {
|
|
28187
|
-
return slugify2(profile.extras.providerId || profile.name, "provider");
|
|
28188
|
-
}
|
|
28189
|
-
numeric(raw2, fallback) {
|
|
28190
|
-
const parsed = Number(raw2);
|
|
28191
|
-
return Number.isFinite(parsed) && parsed > 0 ? Math.trunc(parsed) : fallback;
|
|
28192
|
-
}
|
|
28193
|
-
}
|
|
28194
|
-
function valueString2(value, fallback) {
|
|
28195
|
-
return typeof value === "number" && Number.isFinite(value) ? String(value) : fallback || "";
|
|
28196
28692
|
}
|
|
28197
28693
|
|
|
28198
28694
|
// src/services/adapters/index.ts
|
|
@@ -29299,11 +29795,15 @@ class ProfileService {
|
|
|
29299
29795
|
this.harnesses.require(harness);
|
|
29300
29796
|
const name = input.name.trim();
|
|
29301
29797
|
const sourceName = isCreate ? name : input.sourceName?.trim() || name;
|
|
29798
|
+
const copySourceName = isCreate ? input.copySourceName?.trim() : undefined;
|
|
29302
29799
|
this.assertName(name);
|
|
29303
29800
|
this.assertName(sourceName);
|
|
29801
|
+
if (copySourceName)
|
|
29802
|
+
this.assertName(copySourceName);
|
|
29304
29803
|
const store = this.read();
|
|
29305
29804
|
store[harness] ||= {};
|
|
29306
29805
|
const prior = store[harness][sourceName];
|
|
29806
|
+
const copySource = copySourceName ? store[harness][copySourceName] : undefined;
|
|
29307
29807
|
if (isCreate && prior) {
|
|
29308
29808
|
throw new HttpError(409, "profile already exists", {
|
|
29309
29809
|
code: ERROR_CODES.profileAlreadyExists
|
|
@@ -29312,21 +29812,25 @@ class ProfileService {
|
|
|
29312
29812
|
if (!isCreate && !prior) {
|
|
29313
29813
|
throw new HttpError(404, "profile not found", { code: ERROR_CODES.profileNotFound });
|
|
29314
29814
|
}
|
|
29815
|
+
if (isCreate && copySourceName && !copySource) {
|
|
29816
|
+
throw new HttpError(404, "profile not found", { code: ERROR_CODES.profileNotFound });
|
|
29817
|
+
}
|
|
29315
29818
|
if (!isCreate && sourceName !== name && store[harness][name]) {
|
|
29316
29819
|
throw new HttpError(409, "profile already exists", {
|
|
29317
29820
|
code: ERROR_CODES.profileAlreadyExists
|
|
29318
29821
|
});
|
|
29319
29822
|
}
|
|
29320
29823
|
const hasProvider = input.providerId !== undefined;
|
|
29321
|
-
const
|
|
29824
|
+
const providerId2 = input.providerId?.trim() || undefined;
|
|
29322
29825
|
const providerEndpoint = input.providerEndpoint?.trim() || undefined;
|
|
29323
29826
|
const hasInlineKey = input.apiKey !== undefined && input.apiKey.trim() !== "";
|
|
29324
29827
|
const inlineKey = (input.apiKey ?? "").trim();
|
|
29325
|
-
|
|
29326
|
-
let
|
|
29828
|
+
const inherited = prior ?? copySource;
|
|
29829
|
+
let nextProviderId = inherited?.provider_id;
|
|
29830
|
+
let nextProviderEndpoint = inherited?.provider_endpoint;
|
|
29327
29831
|
let apiKey = "";
|
|
29328
|
-
if (hasProvider &&
|
|
29329
|
-
const entry = this.vault.get(
|
|
29832
|
+
if (hasProvider && providerId2) {
|
|
29833
|
+
const entry = this.vault.get(providerId2);
|
|
29330
29834
|
if (providerEndpoint) {
|
|
29331
29835
|
const endpoint = entry.endpoints.find((candidate) => candidate.key === providerEndpoint);
|
|
29332
29836
|
if (!endpoint) {
|
|
@@ -29339,29 +29843,29 @@ class ProfileService {
|
|
|
29339
29843
|
} else {
|
|
29340
29844
|
nextProviderEndpoint = undefined;
|
|
29341
29845
|
}
|
|
29342
|
-
nextProviderId =
|
|
29343
|
-
apiKey = this.vault.decrypt(
|
|
29344
|
-
} else if (hasProvider && !
|
|
29846
|
+
nextProviderId = providerId2;
|
|
29847
|
+
apiKey = this.vault.decrypt(providerId2);
|
|
29848
|
+
} else if (hasProvider && !providerId2) {
|
|
29345
29849
|
nextProviderId = undefined;
|
|
29346
29850
|
nextProviderEndpoint = undefined;
|
|
29347
|
-
apiKey = hasInlineKey ? inlineKey :
|
|
29851
|
+
apiKey = hasInlineKey ? inlineKey : inherited ? this.resolveKey(inherited) : "";
|
|
29348
29852
|
} else if (hasInlineKey) {
|
|
29349
29853
|
nextProviderId = undefined;
|
|
29350
29854
|
nextProviderEndpoint = undefined;
|
|
29351
29855
|
apiKey = inlineKey;
|
|
29352
|
-
} else if (
|
|
29353
|
-
apiKey =
|
|
29856
|
+
} else if (inherited) {
|
|
29857
|
+
apiKey = this.resolveKey(inherited);
|
|
29354
29858
|
}
|
|
29355
29859
|
if (isCreate && !apiKey) {
|
|
29356
29860
|
throw new HttpError(400, "apiKey is required", { code: ERROR_CODES.profileApiKeyRequired });
|
|
29357
29861
|
}
|
|
29358
|
-
const baseUrl = this.resolveBaseUrl((input.baseUrl ??
|
|
29862
|
+
const baseUrl = this.resolveBaseUrl((input.baseUrl ?? inherited?.base_url ?? "").trim(), providerId2 || nextProviderId, providerEndpoint || nextProviderEndpoint);
|
|
29359
29863
|
const next = {
|
|
29360
29864
|
base_url: baseUrl,
|
|
29361
29865
|
api_key: this.crypto.encrypt(apiKey),
|
|
29362
|
-
model: (input.model ??
|
|
29363
|
-
notes: input.notes ??
|
|
29364
|
-
extras: input.extras ??
|
|
29866
|
+
model: (input.model ?? inherited?.model ?? "").trim(),
|
|
29867
|
+
notes: input.notes ?? inherited?.notes ?? "",
|
|
29868
|
+
extras: input.extras ?? inherited?.extras ?? {},
|
|
29365
29869
|
overrides: input.overrides ?? prior?.overrides ?? {},
|
|
29366
29870
|
provider_id: nextProviderId,
|
|
29367
29871
|
provider_endpoint: nextProviderEndpoint,
|
|
@@ -29494,15 +29998,15 @@ class ProfileService {
|
|
|
29494
29998
|
return this.crypto.decrypt(stored.api_key);
|
|
29495
29999
|
}
|
|
29496
30000
|
}
|
|
29497
|
-
resolveBaseUrl(fallback,
|
|
29498
|
-
if (!
|
|
30001
|
+
resolveBaseUrl(fallback, providerId2, providerEndpoint) {
|
|
30002
|
+
if (!providerId2 || !providerEndpoint) {
|
|
29499
30003
|
return fallback;
|
|
29500
30004
|
}
|
|
29501
30005
|
let entry;
|
|
29502
30006
|
try {
|
|
29503
|
-
entry = this.vault.get(
|
|
30007
|
+
entry = this.vault.get(providerId2);
|
|
29504
30008
|
} catch {
|
|
29505
|
-
this.log.warn(`profile 引用的 provider ${
|
|
30009
|
+
this.log.warn(`profile 引用的 provider ${providerId2} 不存在,回退到内联 base_url`);
|
|
29506
30010
|
return fallback;
|
|
29507
30011
|
}
|
|
29508
30012
|
const endpoint = entry.endpoints.find((candidate) => candidate.key === providerEndpoint);
|
|
@@ -29510,7 +30014,7 @@ class ProfileService {
|
|
|
29510
30014
|
return endpoint.baseUrl;
|
|
29511
30015
|
}
|
|
29512
30016
|
if (entry.endpoints.length > 0) {
|
|
29513
|
-
this.log.warn(`endpoint ${providerEndpoint} 已不存在,回退到 provider ${
|
|
30017
|
+
this.log.warn(`endpoint ${providerEndpoint} 已不存在,回退到 provider ${providerId2} 的首个 endpoint`);
|
|
29514
30018
|
return entry.endpoints[0].baseUrl;
|
|
29515
30019
|
}
|
|
29516
30020
|
return fallback;
|
|
@@ -31575,18 +32079,33 @@ function createHarnessRoutes(services) {
|
|
|
31575
32079
|
const probe = services.get(IProbeService);
|
|
31576
32080
|
function summary(id) {
|
|
31577
32081
|
const adapter = adapters.get(id);
|
|
32082
|
+
const targets = adapter.targets();
|
|
32083
|
+
const current = adapter.officialNeedsCurrent ? Object.fromEntries(targets.map((target) => [target.key, files.readOptional(target.path)])) : {};
|
|
32084
|
+
const capability = adapter.official?.(current);
|
|
32085
|
+
const profileList = profiles.list(id);
|
|
32086
|
+
const linkedProfile = capability?.matchesProfile ? profileList.find(capability.matchesProfile) : undefined;
|
|
31578
32087
|
return {
|
|
31579
32088
|
id,
|
|
31580
32089
|
label: harnesses.label(id),
|
|
31581
32090
|
mode: adapter.mode,
|
|
31582
32091
|
active: activation.getActive(id),
|
|
31583
|
-
profiles:
|
|
32092
|
+
profiles: profileList,
|
|
31584
32093
|
fields: adapter.fields,
|
|
31585
32094
|
modelRequired: adapter.modelRequired,
|
|
31586
|
-
targets
|
|
32095
|
+
targets,
|
|
31587
32096
|
envVars: adapter.envVarNames,
|
|
31588
32097
|
envNote: adapter.envNote,
|
|
31589
|
-
|
|
32098
|
+
envNoteCode: adapter.envNoteCode,
|
|
32099
|
+
...capability ? {
|
|
32100
|
+
official: {
|
|
32101
|
+
kind: capability.kind,
|
|
32102
|
+
available: capability.available,
|
|
32103
|
+
active: activation.getActive(id)?.official === true,
|
|
32104
|
+
titleCode: capability.titleCode,
|
|
32105
|
+
hintCode: capability.hintCode,
|
|
32106
|
+
...linkedProfile ? { linkedProfileName: linkedProfile.name } : {}
|
|
32107
|
+
}
|
|
32108
|
+
} : {}
|
|
31590
32109
|
};
|
|
31591
32110
|
}
|
|
31592
32111
|
app.get("/", (c) => c.json({
|
|
@@ -31597,13 +32116,15 @@ function createHarnessRoutes(services) {
|
|
|
31597
32116
|
app.post("/:harnessId/profiles", async (c) => {
|
|
31598
32117
|
const harnessId = harnesses.require(c.req.param("harnessId"));
|
|
31599
32118
|
const body = await readJsonBody(c, createProfileRequestSchema);
|
|
31600
|
-
|
|
32119
|
+
const copiedProviderType = body.copySourceName ? profiles.get(harnessId, body.copySourceName)?.extras.providerType : undefined;
|
|
32120
|
+
if (harnessId === "dsh" && (body.extras?.providerType ?? copiedProviderType) === "official" && profiles.list("dsh").some((profile2) => profile2.extras.providerType === "official")) {
|
|
31601
32121
|
throw new HttpError(409, "DeepSeek 官方配置已存在,请直接编辑现有官方配置", {
|
|
31602
32122
|
code: ERROR_CODES.officialProfileAlreadyExists
|
|
31603
32123
|
});
|
|
31604
32124
|
}
|
|
31605
32125
|
const profile = profiles.upsert(harnessId, {
|
|
31606
32126
|
name: body.name,
|
|
32127
|
+
copySourceName: body.copySourceName,
|
|
31607
32128
|
baseUrl: body.baseUrl,
|
|
31608
32129
|
apiKey: body.apiKey,
|
|
31609
32130
|
model: body.model,
|
|
@@ -31904,20 +32425,20 @@ class ScanService {
|
|
|
31904
32425
|
return { ok: true, imported, skipped, providersCreated, warnings };
|
|
31905
32426
|
}
|
|
31906
32427
|
save(harness, candidate, selection, replacing) {
|
|
31907
|
-
let
|
|
32428
|
+
let providerId2;
|
|
31908
32429
|
let created = 0;
|
|
31909
32430
|
const apiKey = candidate.apiKey || selection.apiKey?.trim() || "";
|
|
31910
32431
|
if (selection.target === "vault") {
|
|
31911
32432
|
if (selection.providerId) {
|
|
31912
32433
|
this.vault.get(selection.providerId);
|
|
31913
|
-
|
|
32434
|
+
providerId2 = selection.providerId;
|
|
31914
32435
|
} else {
|
|
31915
32436
|
if (!apiKey) {
|
|
31916
32437
|
throw new HttpError(400, "这条配置里没有可提取的凭据,请先填写 API key", {
|
|
31917
32438
|
code: ERROR_CODES.scanApiKeyRequired
|
|
31918
32439
|
});
|
|
31919
32440
|
}
|
|
31920
|
-
|
|
32441
|
+
providerId2 = this.vault.create({
|
|
31921
32442
|
name: selection.providerName ?? selection.name,
|
|
31922
32443
|
apiKey,
|
|
31923
32444
|
endpoints: candidate.baseUrl ? [{ key: "default", label: "默认", baseUrl: candidate.baseUrl }] : []
|
|
@@ -31937,7 +32458,7 @@ class ScanService {
|
|
|
31937
32458
|
model: candidate.model,
|
|
31938
32459
|
notes: `从 ${harness} 现有配置导入(${candidate.key})`,
|
|
31939
32460
|
extras: candidate.extras,
|
|
31940
|
-
...
|
|
32461
|
+
...providerId2 ? { providerId: providerId2, providerEndpoint: "default" } : {}
|
|
31941
32462
|
}, !replacing);
|
|
31942
32463
|
return created;
|
|
31943
32464
|
}
|
|
@@ -32458,14 +32979,14 @@ class UserSyncService {
|
|
|
32458
32979
|
return isDeepStrictEqual2(this.comparableProfile(source, sourceProviders), this.comparableProfile(target, targetProviders));
|
|
32459
32980
|
}
|
|
32460
32981
|
comparableProfile(profile, providers) {
|
|
32461
|
-
const { updated_at: _updatedAt, provider_id:
|
|
32462
|
-
const provider =
|
|
32982
|
+
const { updated_at: _updatedAt, provider_id: providerId2, ...content } = profile;
|
|
32983
|
+
const provider = providerId2 ? providers[providerId2] : undefined;
|
|
32463
32984
|
const comparableProvider = provider ? {
|
|
32464
32985
|
name: provider.name,
|
|
32465
32986
|
notes: provider.notes,
|
|
32466
32987
|
endpoints: provider.endpoints,
|
|
32467
32988
|
apiKey: provider.apiKey
|
|
32468
|
-
} :
|
|
32989
|
+
} : providerId2 ? { missing: true } : undefined;
|
|
32469
32990
|
return { ...content, provider: comparableProvider };
|
|
32470
32991
|
}
|
|
32471
32992
|
readVault() {
|
|
@@ -32606,27 +33127,25 @@ function createApp(services) {
|
|
|
32606
33127
|
guarded("/drift", createDriftRoutes(services));
|
|
32607
33128
|
app.route("/api", api2);
|
|
32608
33129
|
const publicDir = environment.publicDir;
|
|
32609
|
-
|
|
32610
|
-
|
|
32611
|
-
|
|
32612
|
-
|
|
32613
|
-
|
|
32614
|
-
|
|
32615
|
-
|
|
32616
|
-
|
|
32617
|
-
|
|
32618
|
-
|
|
32619
|
-
|
|
32620
|
-
|
|
32621
|
-
|
|
32622
|
-
|
|
32623
|
-
|
|
32624
|
-
|
|
32625
|
-
});
|
|
32626
|
-
}
|
|
33130
|
+
app.get("*", async (c, next) => {
|
|
33131
|
+
if (c.req.path.startsWith("/api") || c.req.path === "/healthz") {
|
|
33132
|
+
return next();
|
|
33133
|
+
}
|
|
33134
|
+
const assetPath = resolve3(publicDir, c.req.path.replace(/^\//, ""));
|
|
33135
|
+
if (c.req.path !== "/" && isPublicAsset(publicDir, assetPath) && existsSync5(assetPath)) {
|
|
33136
|
+
c.header("Content-Type", contentType(assetPath));
|
|
33137
|
+
return c.body(readFileSync4(assetPath));
|
|
33138
|
+
}
|
|
33139
|
+
const index = join14(publicDir, "index.html");
|
|
33140
|
+
if (existsSync5(index)) {
|
|
33141
|
+
c.header("Cache-Control", "no-store");
|
|
33142
|
+
return c.html(readFileSync4(index, "utf8"));
|
|
33143
|
+
}
|
|
33144
|
+
return c.text("frontend not built", 503);
|
|
33145
|
+
});
|
|
32627
33146
|
app.notFound((c) => {
|
|
32628
33147
|
const code = ERROR_CODES.requestFailed;
|
|
32629
|
-
return c.json({ code, msg:
|
|
33148
|
+
return c.json({ code, msg: localizeMessage(requestLanguage(c.req.header("Accept-Language")), code) }, 404);
|
|
32630
33149
|
});
|
|
32631
33150
|
app.onError((error52, c) => {
|
|
32632
33151
|
const request = `${c.req.method} ${new URL(c.req.url).pathname}`;
|
|
@@ -32638,14 +33157,14 @@ function createApp(services) {
|
|
|
32638
33157
|
return c.json({
|
|
32639
33158
|
code: error52.code,
|
|
32640
33159
|
...data ? { data } : {},
|
|
32641
|
-
msg:
|
|
33160
|
+
msg: localizeMessage(requestLanguage(c.req.header("Accept-Language")), error52.code, data)
|
|
32642
33161
|
}, error52.status);
|
|
32643
33162
|
}
|
|
32644
33163
|
log.error(`unhandled error on ${request}`, error52);
|
|
32645
33164
|
const code = ERROR_CODES.internalServerError;
|
|
32646
33165
|
return c.json({
|
|
32647
33166
|
code,
|
|
32648
|
-
msg:
|
|
33167
|
+
msg: localizeMessage(requestLanguage(c.req.header("Accept-Language")), code)
|
|
32649
33168
|
}, 500);
|
|
32650
33169
|
});
|
|
32651
33170
|
return app;
|