@seaveyon/harness-switch 0.27.0 → 0.28.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.
@@ -7210,6 +7210,167 @@ var en_default = {
7210
7210
  switchHarness: "Switch harness"
7211
7211
  },
7212
7212
  harness: {
7213
+ field: {
7214
+ toggle: {
7215
+ on: "On",
7216
+ off: "Off"
7217
+ },
7218
+ providerId: {
7219
+ label: "Provider ID (optional)",
7220
+ placeholder: "Defaults to the profile name"
7221
+ },
7222
+ contextLength: {
7223
+ label: "Context length"
7224
+ },
7225
+ maxTokens: {
7226
+ label: "Max output tokens"
7227
+ },
7228
+ claude: {
7229
+ authVar: {
7230
+ label: "Credential variable",
7231
+ help: "Third-party relays usually require ANTHROPIC_AUTH_TOKEN; use ANTHROPIC_API_KEY for an official API key.",
7232
+ option: {
7233
+ authToken: "ANTHROPIC_AUTH_TOKEN (third-party relay)",
7234
+ official: "ANTHROPIC_API_KEY (official)"
7235
+ }
7236
+ },
7237
+ haikuModel: {
7238
+ label: "Haiku model mapping"
7239
+ },
7240
+ sonnetModel: {
7241
+ label: "Sonnet model mapping"
7242
+ },
7243
+ opusModel: {
7244
+ label: "Opus model mapping"
7245
+ },
7246
+ fableModel: {
7247
+ label: "Fable model mapping (optional)",
7248
+ help: "Written to ANTHROPIC_DEFAULT_FABLE_MODEL, for newer Claude Code builds that support the Fable tier."
7249
+ },
7250
+ subagentModel: {
7251
+ label: "Subagent model (optional)",
7252
+ help: "Written to CLAUDE_CODE_SUBAGENT_MODEL, so subagents can use a faster or cheaper model."
7253
+ },
7254
+ haikuModelName: {
7255
+ label: "Haiku display name (optional)"
7256
+ },
7257
+ sonnetModelName: {
7258
+ label: "Sonnet display name (optional)"
7259
+ },
7260
+ opusModelName: {
7261
+ label: "Opus display name (optional)"
7262
+ },
7263
+ fableModelName: {
7264
+ label: "Fable display name (optional)"
7265
+ },
7266
+ modelMapping: {
7267
+ help: "Written to {{envVar}}."
7268
+ },
7269
+ modelName: {
7270
+ help: "Written to {{envVar}}; left empty, Claude Code shows the model ID itself.",
7271
+ placeholder: "Leave empty to use the {{role}} model ID"
7272
+ },
7273
+ example: {
7274
+ placeholder: "e.g. {{value}}"
7275
+ },
7276
+ extraEnv: {
7277
+ label: "Extra environment variables (optional)",
7278
+ help: "One KEY=VALUE per line, merged into the env block of settings.json."
7279
+ },
7280
+ oneM: {
7281
+ subagentLabel: "Declare 1M support for subagents",
7282
+ label: "Declare 1M support for {{role}}",
7283
+ 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."
7284
+ }
7285
+ },
7286
+ codex: {
7287
+ envNote: "Only the environment-variable auth mode needs env.sh; the other modes keep their credential inside config.toml.",
7288
+ authMode: {
7289
+ label: "Authentication mode",
7290
+ help: "auth.json is Codex's own login cache. Overwriting it loses the ChatGPT session, so it is left alone by default.",
7291
+ option: {
7292
+ bearerToken: "Write to config.toml (recommended, keeps official login)",
7293
+ envKey: "Environment variable (requires sourcing env.sh)",
7294
+ openaiAuth: "Write to auth.json (overwrites the ChatGPT login cache)"
7295
+ }
7296
+ },
7297
+ providerId: {
7298
+ help: "openai, ollama, lmstudio, amazon-bedrock and similar are reserved by Codex and get renamed automatically."
7299
+ },
7300
+ envKeyName: {
7301
+ label: "Environment variable name",
7302
+ help: "Only used by the environment-variable mode."
7303
+ },
7304
+ reasoningEffort: {
7305
+ label: "Reasoning effort (optional)",
7306
+ option: {
7307
+ unset: "Not set"
7308
+ }
7309
+ },
7310
+ target: {
7311
+ auth: "auth.json (auth.json mode only)"
7312
+ }
7313
+ },
7314
+ kimi: {
7315
+ envNote: "Kimi Code does not read credentials from the shell, so env.sh has no effect on it.",
7316
+ providerType: {
7317
+ label: "Provider type",
7318
+ help: "Decides which protocol implementation Kimi Code uses.",
7319
+ option: {
7320
+ kimi: "kimi (Moonshot / Kimi Code)"
7321
+ }
7322
+ },
7323
+ maxContextSize: {
7324
+ help: "Kimi Code requires every models entry to declare max_context_size."
7325
+ }
7326
+ },
7327
+ pi: {
7328
+ envNote: "The API key is written straight into models.json, so no environment variable is needed; --model still overrides at run time.",
7329
+ providerId: {
7330
+ help: "Models are referenced as provider/model."
7331
+ },
7332
+ api: {
7333
+ label: "Protocol"
7334
+ },
7335
+ authHeader: {
7336
+ label: "Authorization header",
7337
+ help: "Sent as Authorization: Bearer <key>."
7338
+ },
7339
+ reasoning: {
7340
+ label: "Reasoning support",
7341
+ help: "Maps to reasoning in models.json. Enable it for thinking models such as GPT or Claude."
7342
+ }
7343
+ },
7344
+ dsh: {
7345
+ envNote: "The API key is written securely to DSH's .credentials.yaml and referenced from settings.yaml.",
7346
+ providerType: {
7347
+ label: "Provider type",
7348
+ option: {
7349
+ custom: "Custom provider",
7350
+ official: "DeepSeek official"
7351
+ }
7352
+ },
7353
+ providerId: {
7354
+ help: "DSH's model routing identifier; it must start with a lowercase letter."
7355
+ },
7356
+ models: {
7357
+ label: "Model catalog (optional)",
7358
+ placeholder: "One model ID per line; left empty, only the default model above is registered",
7359
+ help: "One provider can register several models; the Model field above is the default for new sessions."
7360
+ },
7361
+ api: {
7362
+ label: "API protocol"
7363
+ },
7364
+ reasoningEfforts: {
7365
+ label: "Supported reasoning levels",
7366
+ help: "DSH only shows the levels declared here that the upstream model actually supports.",
7367
+ option: {
7368
+ unset: "Not declared (provider default)",
7369
+ none: "Model does not support reasoning levels"
7370
+ }
7371
+ }
7372
+ }
7373
+ },
7213
7374
  subtitle: "Manage profiles and safely write this tool's native configuration files.",
7214
7375
  newProfile: "New profile",
7215
7376
  addCustomProvider: "Add custom provider",
@@ -7957,6 +8118,167 @@ var zh_CN_default = {
7957
8118
  switchHarness: "切换 Harness"
7958
8119
  },
7959
8120
  harness: {
8121
+ field: {
8122
+ toggle: {
8123
+ on: "开启",
8124
+ off: "关闭"
8125
+ },
8126
+ providerId: {
8127
+ label: "Provider ID(可选)",
8128
+ placeholder: "默认取配置名称"
8129
+ },
8130
+ contextLength: {
8131
+ label: "上下文长度"
8132
+ },
8133
+ maxTokens: {
8134
+ label: "最大输出 tokens"
8135
+ },
8136
+ claude: {
8137
+ authVar: {
8138
+ label: "凭据变量",
8139
+ help: "第三方中转通常要求 ANTHROPIC_AUTH_TOKEN;官方 API key 用 ANTHROPIC_API_KEY。",
8140
+ option: {
8141
+ authToken: "ANTHROPIC_AUTH_TOKEN(第三方中转)",
8142
+ official: "ANTHROPIC_API_KEY(官方)"
8143
+ }
8144
+ },
8145
+ haikuModel: {
8146
+ label: "Haiku 模型映射"
8147
+ },
8148
+ sonnetModel: {
8149
+ label: "Sonnet 模型映射"
8150
+ },
8151
+ opusModel: {
8152
+ label: "Opus 模型映射"
8153
+ },
8154
+ fableModel: {
8155
+ label: "Fable 模型映射(可选)",
8156
+ help: "写入 ANTHROPIC_DEFAULT_FABLE_MODEL;用于支持 Fable 档位的新版 Claude Code。"
8157
+ },
8158
+ subagentModel: {
8159
+ label: "子代理模型(可选)",
8160
+ help: "写入 CLAUDE_CODE_SUBAGENT_MODEL,可让子代理使用更快或成本更低的模型。"
8161
+ },
8162
+ haikuModelName: {
8163
+ label: "Haiku 显示名称(选填)"
8164
+ },
8165
+ sonnetModelName: {
8166
+ label: "Sonnet 显示名称(选填)"
8167
+ },
8168
+ opusModelName: {
8169
+ label: "Opus 显示名称(选填)"
8170
+ },
8171
+ fableModelName: {
8172
+ label: "Fable 显示名称(选填)"
8173
+ },
8174
+ modelMapping: {
8175
+ help: "写入 {{envVar}}。"
8176
+ },
8177
+ modelName: {
8178
+ help: "写入 {{envVar}};留空时 Claude Code 默认显示对应模型 ID。",
8179
+ placeholder: "留空则使用 {{role}} 模型 ID"
8180
+ },
8181
+ example: {
8182
+ placeholder: "例如:{{value}}"
8183
+ },
8184
+ extraEnv: {
8185
+ label: "追加环境变量(可选)",
8186
+ help: "每行一个 KEY=VALUE,会合并进 settings.json 的 env。"
8187
+ },
8188
+ oneM: {
8189
+ subagentLabel: "子代理 声明支持 1M",
8190
+ label: "{{role}} 声明支持 1M",
8191
+ help: "在模型 ID 末尾追加 [1m],向 Claude Code 声明 1M 上下文;Claude Code 请求上游前会去掉该后缀。仅在该模型确实支持 1M 时开启。"
8192
+ }
8193
+ },
8194
+ codex: {
8195
+ envNote: "仅「环境变量」认证模式需要 env.sh,其余模式的凭据自包含在 config.toml 里。",
8196
+ authMode: {
8197
+ label: "认证方式",
8198
+ help: "auth.json 就是 Codex 的登录缓存,覆盖它会丢失 ChatGPT 登录态,所以默认不碰它。",
8199
+ option: {
8200
+ bearerToken: "写入 config.toml(推荐,保留官方登录)",
8201
+ envKey: "环境变量(需要 source env.sh)",
8202
+ openaiAuth: "写入 auth.json(会覆盖 ChatGPT 登录缓存)"
8203
+ }
8204
+ },
8205
+ providerId: {
8206
+ help: "openai / ollama / lmstudio / amazon-bedrock 等是 Codex 保留字,会自动改名。"
8207
+ },
8208
+ envKeyName: {
8209
+ label: "环境变量名",
8210
+ help: "仅「环境变量」模式生效。"
8211
+ },
8212
+ reasoningEffort: {
8213
+ label: "推理强度(可选)",
8214
+ option: {
8215
+ unset: "不设置"
8216
+ }
8217
+ },
8218
+ target: {
8219
+ auth: "auth.json(仅 auth.json 模式)"
8220
+ }
8221
+ },
8222
+ kimi: {
8223
+ envNote: "Kimi Code 不从 shell 读取凭据,env.sh 对它无效。",
8224
+ providerType: {
8225
+ label: "Provider 类型",
8226
+ help: "决定 Kimi Code 使用哪套协议实现。",
8227
+ option: {
8228
+ kimi: "kimi(Moonshot / Kimi Code)"
8229
+ }
8230
+ },
8231
+ maxContextSize: {
8232
+ help: "Kimi Code 要求 models 条目必须声明 max_context_size。"
8233
+ }
8234
+ },
8235
+ pi: {
8236
+ envNote: "API key 直接写入 models.json,无需环境变量;运行时仍可用 --model 覆盖。",
8237
+ providerId: {
8238
+ help: "模型引用格式为 provider/model。"
8239
+ },
8240
+ api: {
8241
+ label: "协议"
8242
+ },
8243
+ authHeader: {
8244
+ label: "Authorization 头",
8245
+ help: "以 Authorization: Bearer <key> 发送。"
8246
+ },
8247
+ reasoning: {
8248
+ label: "推理能力",
8249
+ help: "对应 models.json 的 reasoning。GPT / Claude 思考模型需要开启。"
8250
+ }
8251
+ },
8252
+ dsh: {
8253
+ envNote: "API key 安全写入 DSH 的 .credentials.yaml,并由 settings.yaml 引用。",
8254
+ providerType: {
8255
+ label: "提供方类型",
8256
+ option: {
8257
+ custom: "自定义提供方",
8258
+ official: "DeepSeek 官方"
8259
+ }
8260
+ },
8261
+ providerId: {
8262
+ help: "DSH 的模型路由标识;必须以小写字母开头。"
8263
+ },
8264
+ models: {
8265
+ label: "模型目录(可选)",
8266
+ placeholder: "每行一个模型 ID;留空时只注册上方的默认模型",
8267
+ help: "一个提供方可注册多个模型;上方“模型”作为新会话的默认模型。"
8268
+ },
8269
+ api: {
8270
+ label: "API 协议"
8271
+ },
8272
+ reasoningEfforts: {
8273
+ label: "支持的思考程度",
8274
+ help: "DSH 只会显示这里声明且上游模型实际支持的档位。",
8275
+ option: {
8276
+ unset: "不声明(提供方默认)",
8277
+ none: "模型不支持思考程度"
8278
+ }
8279
+ }
8280
+ }
8281
+ },
7960
8282
  subtitle: "管理配置档案并安全写入该工具的原生配置文件。",
7961
8283
  newProfile: "新增配置",
7962
8284
  addCustomProvider: "添加自定义提供方",
@@ -24681,7 +25003,6 @@ function localizeMessage(language, code, data) {
24681
25003
  }
24682
25004
  return value.replace(/{{\s*([\w.]+)\s*}}/g, (_match, name) => data?.[name] === undefined ? "" : String(data[name]));
24683
25005
  }
24684
- var localizeError = localizeMessage;
24685
25006
  function getPath2(value, path) {
24686
25007
  return path.split(".").reduce((current, key) => {
24687
25008
  if (typeof current !== "object" || current === null || Array.isArray(current))
@@ -25790,29 +26111,6 @@ import { basename as basename3, join as join8, resolve as resolve2 } from "node:
25790
26111
  // src/services/adapters/claude.ts
25791
26112
  import { join as join3 } from "node:path";
25792
26113
 
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
26114
  // ../../node_modules/smol-toml/dist/date.js
25817
26115
  /*!
25818
26116
  * Copyright (c) Squirrel Chat et al., All rights reserved.
@@ -26895,6 +27193,13 @@ function parseJsonObject(text) {
26895
27193
  const parsed = JSON.parse(text);
26896
27194
  return isPlainObject2(parsed) ? parsed : {};
26897
27195
  }
27196
+ function tryParseJsonObject(text) {
27197
+ try {
27198
+ return parseJsonObject(text);
27199
+ } catch {
27200
+ return;
27201
+ }
27202
+ }
26898
27203
  function stringifyJson(value) {
26899
27204
  return `${JSON.stringify(value, null, 2)}
26900
27205
  `;
@@ -26906,6 +27211,13 @@ function parseTomlObject(text) {
26906
27211
  const parsed = parse6(text);
26907
27212
  return isPlainObject2(parsed) ? parsed : {};
26908
27213
  }
27214
+ function tryParseTomlObject(text) {
27215
+ try {
27216
+ return parseTomlObject(text);
27217
+ } catch {
27218
+ return;
27219
+ }
27220
+ }
26909
27221
  function stringifyToml(value) {
26910
27222
  return `${stringify(value)}
26911
27223
  `;
@@ -26917,6 +27229,13 @@ function parseYamlDocument(text) {
26917
27229
  }
26918
27230
  return document;
26919
27231
  }
27232
+ function tryParseYamlDocument(text) {
27233
+ try {
27234
+ return parseYamlDocument(text);
27235
+ } catch {
27236
+ return;
27237
+ }
27238
+ }
26920
27239
  function assertParsable(format, path, content) {
26921
27240
  try {
26922
27241
  if (format === "json") {
@@ -26959,6 +27278,13 @@ function readString(source, key) {
26959
27278
  const value = source[key];
26960
27279
  return typeof value === "string" ? value : "";
26961
27280
  }
27281
+ function numeric(raw2, fallback) {
27282
+ const parsed = Number(raw2);
27283
+ return Number.isFinite(parsed) && parsed > 0 ? Math.trunc(parsed) : fallback;
27284
+ }
27285
+ function valueString(value, fallback) {
27286
+ return typeof value === "number" && Number.isFinite(value) ? String(value) : fallback || "";
27287
+ }
26962
27288
  function slugify2(value, fallback) {
26963
27289
  const slug = value.trim().toLowerCase().replace(/[^a-z0-9_-]+/g, "-").replace(/^-+|-+$/g, "");
26964
27290
  return slug || `${fallback}-${shortHash(value)}`;
@@ -26972,6 +27298,32 @@ function shortHash(value) {
26972
27298
  return (hash2 >>> 0).toString(36);
26973
27299
  }
26974
27300
 
27301
+ // src/services/adapters/detect.ts
27302
+ function providerId(profile) {
27303
+ return slugify2(profile.extras.providerId || profile.name, "provider");
27304
+ }
27305
+ function seedProfile(extras = {}) {
27306
+ return { name: "", baseUrl: "", apiKey: "", model: "", extras };
27307
+ }
27308
+ function toCandidate(key, seed, values, active) {
27309
+ const baseUrl = values.baseUrl ?? "";
27310
+ const apiKey = values.apiKey ?? "";
27311
+ if (!baseUrl && !apiKey) {
27312
+ return null;
27313
+ }
27314
+ return {
27315
+ key,
27316
+ baseUrl,
27317
+ apiKey,
27318
+ model: values.model ?? "",
27319
+ extras: { ...seed.extras, ...values.extras },
27320
+ active
27321
+ };
27322
+ }
27323
+ function compact(candidates) {
27324
+ return candidates.filter((candidate) => candidate !== null);
27325
+ }
27326
+
26975
27327
  // src/services/adapters/claude.ts
26976
27328
  var SETTINGS = "settings";
26977
27329
  var BASE_URL_VAR = "ANTHROPIC_BASE_URL";
@@ -27009,17 +27361,20 @@ var MODEL_MAPPINGS = [
27009
27361
  { field: "subagentModel", envVar: "CLAUDE_CODE_SUBAGENT_MODEL", oneMField: "subagentModel1m" }
27010
27362
  ];
27011
27363
  var ONE_M_OPTIONS = [
27012
- { value: "false", label: "关闭" },
27013
- { value: "true", label: "开启" }
27364
+ { value: "false", label: "关闭", labelCode: "harness.field.toggle.off" },
27365
+ { value: "true", label: "开启", labelCode: "harness.field.toggle.on" }
27014
27366
  ];
27015
- function oneMField(role, key) {
27367
+ function oneMField(role, key, labelCode) {
27016
27368
  return {
27017
27369
  key,
27018
27370
  label: `${role} 声明支持 1M`,
27371
+ labelCode: labelCode ?? "harness.field.claude.oneM.label",
27372
+ ...labelCode ? {} : { params: { role } },
27019
27373
  kind: "select",
27020
27374
  defaultValue: "false",
27021
27375
  options: ONE_M_OPTIONS,
27022
- help: "在模型 ID 末尾追加 [1m],向 Claude Code 声明 1M 上下文;Claude Code 请求上游前会去掉该后缀。仅在该模型确实支持 1M 时开启。"
27376
+ help: "在模型 ID 末尾追加 [1m],向 Claude Code 声明 1M 上下文;Claude Code 请求上游前会去掉该后缀。仅在该模型确实支持 1M 时开启。",
27377
+ helpCode: "harness.field.claude.oneM.help"
27023
27378
  };
27024
27379
  }
27025
27380
 
@@ -27037,92 +27392,140 @@ class ClaudeAdapter {
27037
27392
  {
27038
27393
  key: "authVar",
27039
27394
  label: "凭据变量",
27395
+ labelCode: "harness.field.claude.authVar.label",
27040
27396
  kind: "select",
27041
27397
  defaultValue: "ANTHROPIC_AUTH_TOKEN",
27042
27398
  help: "第三方中转通常要求 ANTHROPIC_AUTH_TOKEN;官方 API key 用 ANTHROPIC_API_KEY。",
27399
+ helpCode: "harness.field.claude.authVar.help",
27043
27400
  fullWidth: true,
27044
27401
  options: [
27045
- { value: "ANTHROPIC_AUTH_TOKEN", label: "ANTHROPIC_AUTH_TOKEN(第三方中转)" },
27046
- { value: "ANTHROPIC_API_KEY", label: "ANTHROPIC_API_KEY(官方)" }
27402
+ {
27403
+ value: "ANTHROPIC_AUTH_TOKEN",
27404
+ label: "ANTHROPIC_AUTH_TOKEN(第三方中转)",
27405
+ labelCode: "harness.field.claude.authVar.option.authToken"
27406
+ },
27407
+ {
27408
+ value: "ANTHROPIC_API_KEY",
27409
+ label: "ANTHROPIC_API_KEY(官方)",
27410
+ labelCode: "harness.field.claude.authVar.option.official"
27411
+ }
27047
27412
  ]
27048
27413
  },
27049
27414
  {
27050
27415
  key: "haikuModel",
27051
27416
  label: "Haiku 模型映射",
27417
+ labelCode: "harness.field.claude.haikuModel.label",
27052
27418
  kind: "text",
27053
27419
  required: true,
27054
27420
  placeholder: "例如:glm-5-air",
27055
- help: "写入 ANTHROPIC_DEFAULT_HAIKU_MODEL。"
27421
+ placeholderCode: "harness.field.claude.example.placeholder",
27422
+ help: "写入 ANTHROPIC_DEFAULT_HAIKU_MODEL。",
27423
+ helpCode: "harness.field.claude.modelMapping.help",
27424
+ params: { value: "glm-5-air", envVar: "ANTHROPIC_DEFAULT_HAIKU_MODEL" }
27056
27425
  },
27057
27426
  {
27058
27427
  key: "haikuModelName",
27059
27428
  label: "Haiku 显示名称(选填)",
27429
+ labelCode: "harness.field.claude.haikuModelName.label",
27060
27430
  kind: "text",
27061
27431
  placeholder: "留空则使用 Haiku 模型 ID",
27062
- help: "写入 ANTHROPIC_DEFAULT_HAIKU_MODEL_NAME;留空时 Claude Code 默认显示对应模型 ID。"
27432
+ placeholderCode: "harness.field.claude.modelName.placeholder",
27433
+ help: "写入 ANTHROPIC_DEFAULT_HAIKU_MODEL_NAME;留空时 Claude Code 默认显示对应模型 ID。",
27434
+ helpCode: "harness.field.claude.modelName.help",
27435
+ params: { role: "Haiku", envVar: "ANTHROPIC_DEFAULT_HAIKU_MODEL_NAME" }
27063
27436
  },
27064
27437
  {
27065
27438
  key: "sonnetModel",
27066
27439
  label: "Sonnet 模型映射",
27440
+ labelCode: "harness.field.claude.sonnetModel.label",
27067
27441
  kind: "text",
27068
27442
  required: true,
27069
27443
  placeholder: "例如:glm-5",
27070
- help: "写入 ANTHROPIC_DEFAULT_SONNET_MODEL。"
27444
+ placeholderCode: "harness.field.claude.example.placeholder",
27445
+ help: "写入 ANTHROPIC_DEFAULT_SONNET_MODEL。",
27446
+ helpCode: "harness.field.claude.modelMapping.help",
27447
+ params: { value: "glm-5", envVar: "ANTHROPIC_DEFAULT_SONNET_MODEL" }
27071
27448
  },
27072
27449
  {
27073
27450
  key: "sonnetModelName",
27074
27451
  label: "Sonnet 显示名称(选填)",
27452
+ labelCode: "harness.field.claude.sonnetModelName.label",
27075
27453
  kind: "text",
27076
27454
  placeholder: "留空则使用 Sonnet 模型 ID",
27077
- help: "写入 ANTHROPIC_DEFAULT_SONNET_MODEL_NAME;留空时 Claude Code 默认显示对应模型 ID。"
27455
+ placeholderCode: "harness.field.claude.modelName.placeholder",
27456
+ help: "写入 ANTHROPIC_DEFAULT_SONNET_MODEL_NAME;留空时 Claude Code 默认显示对应模型 ID。",
27457
+ helpCode: "harness.field.claude.modelName.help",
27458
+ params: { role: "Sonnet", envVar: "ANTHROPIC_DEFAULT_SONNET_MODEL_NAME" }
27078
27459
  },
27079
27460
  oneMField("Sonnet", "sonnetModel1m"),
27080
27461
  {
27081
27462
  key: "opusModel",
27082
27463
  label: "Opus 模型映射",
27464
+ labelCode: "harness.field.claude.opusModel.label",
27083
27465
  kind: "text",
27084
27466
  required: true,
27085
27467
  placeholder: "例如:glm-5",
27086
- help: "写入 ANTHROPIC_DEFAULT_OPUS_MODEL。"
27468
+ placeholderCode: "harness.field.claude.example.placeholder",
27469
+ help: "写入 ANTHROPIC_DEFAULT_OPUS_MODEL。",
27470
+ helpCode: "harness.field.claude.modelMapping.help",
27471
+ params: { value: "glm-5", envVar: "ANTHROPIC_DEFAULT_OPUS_MODEL" }
27087
27472
  },
27088
27473
  {
27089
27474
  key: "opusModelName",
27090
27475
  label: "Opus 显示名称(选填)",
27476
+ labelCode: "harness.field.claude.opusModelName.label",
27091
27477
  kind: "text",
27092
27478
  placeholder: "留空则使用 Opus 模型 ID",
27093
- help: "写入 ANTHROPIC_DEFAULT_OPUS_MODEL_NAME;留空时 Claude Code 默认显示对应模型 ID。"
27479
+ placeholderCode: "harness.field.claude.modelName.placeholder",
27480
+ help: "写入 ANTHROPIC_DEFAULT_OPUS_MODEL_NAME;留空时 Claude Code 默认显示对应模型 ID。",
27481
+ helpCode: "harness.field.claude.modelName.help",
27482
+ params: { role: "Opus", envVar: "ANTHROPIC_DEFAULT_OPUS_MODEL_NAME" }
27094
27483
  },
27095
27484
  oneMField("Opus", "opusModel1m"),
27096
27485
  {
27097
27486
  key: "fableModel",
27098
27487
  label: "Fable 模型映射(可选)",
27488
+ labelCode: "harness.field.claude.fableModel.label",
27099
27489
  kind: "text",
27100
27490
  placeholder: "例如:glm-5",
27101
- help: "写入 ANTHROPIC_DEFAULT_FABLE_MODEL;用于支持 Fable 档位的新版 Claude Code。"
27491
+ placeholderCode: "harness.field.claude.example.placeholder",
27492
+ help: "写入 ANTHROPIC_DEFAULT_FABLE_MODEL;用于支持 Fable 档位的新版 Claude Code。",
27493
+ helpCode: "harness.field.claude.fableModel.help",
27494
+ params: { value: "glm-5" }
27102
27495
  },
27103
27496
  {
27104
27497
  key: "fableModelName",
27105
27498
  label: "Fable 显示名称(选填)",
27499
+ labelCode: "harness.field.claude.fableModelName.label",
27106
27500
  kind: "text",
27107
27501
  placeholder: "留空则使用 Fable 模型 ID",
27108
- help: "写入 ANTHROPIC_DEFAULT_FABLE_MODEL_NAME;留空时 Claude Code 默认显示对应模型 ID。"
27502
+ placeholderCode: "harness.field.claude.modelName.placeholder",
27503
+ help: "写入 ANTHROPIC_DEFAULT_FABLE_MODEL_NAME;留空时 Claude Code 默认显示对应模型 ID。",
27504
+ helpCode: "harness.field.claude.modelName.help",
27505
+ params: { role: "Fable", envVar: "ANTHROPIC_DEFAULT_FABLE_MODEL_NAME" }
27109
27506
  },
27110
27507
  oneMField("Fable", "fableModel1m"),
27111
27508
  {
27112
27509
  key: "subagentModel",
27113
27510
  label: "子代理模型(可选)",
27511
+ labelCode: "harness.field.claude.subagentModel.label",
27114
27512
  kind: "text",
27115
27513
  placeholder: "例如:glm-5-air",
27116
- help: "写入 CLAUDE_CODE_SUBAGENT_MODEL,可让子代理使用更快或成本更低的模型。"
27514
+ placeholderCode: "harness.field.claude.example.placeholder",
27515
+ help: "写入 CLAUDE_CODE_SUBAGENT_MODEL,可让子代理使用更快或成本更低的模型。",
27516
+ helpCode: "harness.field.claude.subagentModel.help",
27517
+ params: { value: "glm-5-air" }
27117
27518
  },
27118
- oneMField("子代理", "subagentModel1m"),
27519
+ oneMField("子代理", "subagentModel1m", "harness.field.claude.oneM.subagentLabel"),
27119
27520
  {
27120
27521
  key: "extraEnv",
27121
27522
  label: "追加环境变量(可选)",
27523
+ labelCode: "harness.field.claude.extraEnv.label",
27122
27524
  kind: "textarea",
27123
27525
  placeholder: `ANTHROPIC_DEFAULT_SONNET_MODEL=glm-5.2
27124
27526
  API_TIMEOUT_MS=3000000`,
27125
- help: "每行一个 KEY=VALUE,会合并进 settings.json 的 env。"
27527
+ help: "每行一个 KEY=VALUE,会合并进 settings.json 的 env。",
27528
+ helpCode: "harness.field.claude.extraEnv.help"
27126
27529
  }
27127
27530
  ];
27128
27531
  constructor(environment) {
@@ -27213,7 +27616,7 @@ API_TIMEOUT_MS=3000000`,
27213
27616
  return { [SETTINGS]: stringifyJson(settings) };
27214
27617
  }
27215
27618
  backfill(profile, current) {
27216
- const settings = safeParse3(current[SETTINGS]);
27619
+ const settings = tryParseJsonObject(current[SETTINGS]) ?? {};
27217
27620
  const env = settings.env;
27218
27621
  const authVar = this.authVar(profile);
27219
27622
  const apiKey = readString(env, authVar);
@@ -27235,7 +27638,7 @@ API_TIMEOUT_MS=3000000`,
27235
27638
  };
27236
27639
  }
27237
27640
  detect(current) {
27238
- const env = safeParse3(current[SETTINGS]).env;
27641
+ const env = (tryParseJsonObject(current[SETTINGS]) ?? {}).env;
27239
27642
  const authVar = AUTH_VARS.find((name) => readString(env, name)) ?? AUTH_VARS[0];
27240
27643
  const seed = seedProfile({ authVar });
27241
27644
  return compact([toCandidate("claude", seed, this.backfill(seed, current), true)]);
@@ -27252,13 +27655,6 @@ function withOneM(value, enabled) {
27252
27655
  function withoutOneM(value) {
27253
27656
  return value.endsWith(ONE_M_SUFFIX) ? value.slice(0, -ONE_M_SUFFIX.length) : value;
27254
27657
  }
27255
- function safeParse3(text) {
27256
- try {
27257
- return parseJsonObject(text);
27258
- } catch {
27259
- return {};
27260
- }
27261
- }
27262
27658
  function parseEnvLines(raw2) {
27263
27659
  if (!raw2) {
27264
27660
  return [];
@@ -27300,40 +27696,65 @@ class CodexAdapter {
27300
27696
  mode = "replace";
27301
27697
  envVarNames = [DEFAULT_ENV_KEY];
27302
27698
  envNote = "仅「环境变量」认证模式需要 env.sh,其余模式的凭据自包含在 config.toml 里。";
27699
+ envNoteCode = "harness.field.codex.envNote";
27303
27700
  fields = [
27304
27701
  {
27305
27702
  key: "authMode",
27306
27703
  label: "认证方式",
27704
+ labelCode: "harness.field.codex.authMode.label",
27307
27705
  kind: "select",
27308
27706
  defaultValue: "bearer_token",
27309
27707
  help: "auth.json 就是 Codex 的登录缓存,覆盖它会丢失 ChatGPT 登录态,所以默认不碰它。",
27708
+ helpCode: "harness.field.codex.authMode.help",
27310
27709
  options: [
27311
- { value: "bearer_token", label: "写入 config.toml(推荐,保留官方登录)" },
27312
- { value: "env_key", label: "环境变量(需要 source env.sh)" },
27313
- { value: "openai_auth", label: "写入 auth.json(会覆盖 ChatGPT 登录缓存)" }
27710
+ {
27711
+ value: "bearer_token",
27712
+ label: "写入 config.toml(推荐,保留官方登录)",
27713
+ labelCode: "harness.field.codex.authMode.option.bearerToken"
27714
+ },
27715
+ {
27716
+ value: "env_key",
27717
+ label: "环境变量(需要 source env.sh)",
27718
+ labelCode: "harness.field.codex.authMode.option.envKey"
27719
+ },
27720
+ {
27721
+ value: "openai_auth",
27722
+ label: "写入 auth.json(会覆盖 ChatGPT 登录缓存)",
27723
+ labelCode: "harness.field.codex.authMode.option.openaiAuth"
27724
+ }
27314
27725
  ]
27315
27726
  },
27316
27727
  {
27317
27728
  key: "providerId",
27318
27729
  label: "Provider ID(可选)",
27730
+ labelCode: "harness.field.providerId.label",
27319
27731
  kind: "text",
27320
27732
  placeholder: "默认取配置名称",
27321
- help: "openai / ollama / lmstudio / amazon-bedrock 等是 Codex 保留字,会自动改名。"
27733
+ placeholderCode: "harness.field.providerId.placeholder",
27734
+ help: "openai / ollama / lmstudio / amazon-bedrock 等是 Codex 保留字,会自动改名。",
27735
+ helpCode: "harness.field.codex.providerId.help"
27322
27736
  },
27323
27737
  {
27324
27738
  key: "envKeyName",
27325
27739
  label: "环境变量名",
27740
+ labelCode: "harness.field.codex.envKeyName.label",
27326
27741
  kind: "text",
27327
27742
  defaultValue: DEFAULT_ENV_KEY,
27328
- help: "仅「环境变量」模式生效。"
27743
+ help: "仅「环境变量」模式生效。",
27744
+ helpCode: "harness.field.codex.envKeyName.help"
27329
27745
  },
27330
27746
  {
27331
27747
  key: "reasoningEffort",
27332
27748
  label: "推理强度(可选)",
27749
+ labelCode: "harness.field.codex.reasoningEffort.label",
27333
27750
  kind: "select",
27334
27751
  defaultValue: "",
27335
27752
  options: [
27336
- { value: "", label: "不设置" },
27753
+ {
27754
+ value: "",
27755
+ label: "不设置",
27756
+ labelCode: "harness.field.codex.reasoningEffort.option.unset"
27757
+ },
27337
27758
  { value: "low", label: "low" },
27338
27759
  { value: "medium", label: "medium" },
27339
27760
  { value: "high", label: "high" }
@@ -27354,6 +27775,7 @@ class CodexAdapter {
27354
27775
  {
27355
27776
  key: AUTH,
27356
27777
  label: "auth.json(仅 auth.json 模式)",
27778
+ labelCode: "harness.field.codex.target.auth",
27357
27779
  path: join4(this.environment.harnessHomes.codex, "auth.json"),
27358
27780
  format: "json"
27359
27781
  }
@@ -27366,10 +27788,10 @@ class CodexAdapter {
27366
27788
  return { [this.envKeyName(profile)]: profile.apiKey };
27367
27789
  }
27368
27790
  render(profile, current) {
27369
- const providerId = this.providerId(profile);
27791
+ const providerId2 = this.providerId(profile);
27370
27792
  const config2 = parseTomlObject(current[CONFIG]);
27371
27793
  const mode = this.authMode(profile);
27372
- config2.model_provider = providerId;
27794
+ config2.model_provider = providerId2;
27373
27795
  if (profile.model) {
27374
27796
  config2.model = profile.model;
27375
27797
  }
@@ -27378,7 +27800,7 @@ class CodexAdapter {
27378
27800
  config2.model_reasoning_effort = effort;
27379
27801
  }
27380
27802
  const providers = ensureObject(config2, "model_providers");
27381
- const provider = ensureObject(providers, providerId);
27803
+ const provider = ensureObject(providers, providerId2);
27382
27804
  provider.name = profile.name;
27383
27805
  provider.base_url = profile.baseUrl;
27384
27806
  provider.wire_api = "responses";
@@ -27417,16 +27839,14 @@ class CodexAdapter {
27417
27839
  return rendered;
27418
27840
  }
27419
27841
  backfill(profile, current) {
27420
- let config2 = {};
27421
- try {
27422
- config2 = parseTomlObject(current[CONFIG]);
27423
- } catch {
27842
+ const config2 = tryParseTomlObject(current[CONFIG]);
27843
+ if (!config2) {
27424
27844
  return {};
27425
27845
  }
27426
27846
  const providers = config2.model_providers;
27427
27847
  const provider = isPlainObject2(providers) ? providers[this.providerId(profile)] : undefined;
27428
27848
  const mode = this.authMode(profile);
27429
- const token = mode === "bearer_token" ? readString(provider, "experimental_bearer_token") : mode === "openai_auth" ? readString(safeJson(current[AUTH]), DEFAULT_ENV_KEY) : "";
27849
+ const token = mode === "bearer_token" ? readString(provider, "experimental_bearer_token") : mode === "openai_auth" ? readString(tryParseJsonObject(current[AUTH]) ?? {}, DEFAULT_ENV_KEY) : "";
27430
27850
  return {
27431
27851
  baseUrl: readString(provider, "base_url") || profile.baseUrl,
27432
27852
  model: readString(config2, "model"),
@@ -27434,10 +27854,8 @@ class CodexAdapter {
27434
27854
  };
27435
27855
  }
27436
27856
  detect(current) {
27437
- let config2;
27438
- try {
27439
- config2 = parseTomlObject(current[CONFIG]);
27440
- } catch {
27857
+ const config2 = tryParseTomlObject(current[CONFIG]);
27858
+ if (!config2) {
27441
27859
  return [];
27442
27860
  }
27443
27861
  const providers = config2.model_providers;
@@ -27467,17 +27885,10 @@ class CodexAdapter {
27467
27885
  return profile.extras.envKeyName?.trim() || DEFAULT_ENV_KEY;
27468
27886
  }
27469
27887
  providerId(profile) {
27470
- const slug = slugify2(profile.extras.providerId || profile.name, "provider");
27888
+ const slug = providerId(profile);
27471
27889
  return RESERVED_PROVIDER_IDS.has(slug) ? `${slug}-hsw` : slug;
27472
27890
  }
27473
27891
  }
27474
- function safeJson(text) {
27475
- try {
27476
- return parseJsonObject(text);
27477
- } catch {
27478
- return {};
27479
- }
27480
- }
27481
27892
 
27482
27893
  // src/services/adapters/dsh.ts
27483
27894
  import { join as join5 } from "node:path";
@@ -27493,35 +27904,52 @@ class DshAdapter {
27493
27904
  modelRequired = true;
27494
27905
  envVarNames = [];
27495
27906
  envNote = "API key 安全写入 DSH 的 .credentials.yaml,并由 settings.yaml 引用。";
27907
+ envNoteCode = "harness.field.dsh.envNote";
27496
27908
  fields = [
27497
27909
  {
27498
27910
  key: "providerType",
27499
27911
  label: "提供方类型",
27912
+ labelCode: "harness.field.dsh.providerType.label",
27500
27913
  kind: "select",
27501
27914
  defaultValue: "custom",
27502
27915
  options: [
27503
- { value: "custom", label: "自定义提供方" },
27504
- { value: "official", label: "DeepSeek 官方" }
27916
+ {
27917
+ value: "custom",
27918
+ label: "自定义提供方",
27919
+ labelCode: "harness.field.dsh.providerType.option.custom"
27920
+ },
27921
+ {
27922
+ value: "official",
27923
+ label: "DeepSeek 官方",
27924
+ labelCode: "harness.field.dsh.providerType.option.official"
27925
+ }
27505
27926
  ]
27506
27927
  },
27507
27928
  {
27508
27929
  key: "providerId",
27509
27930
  label: "Provider ID(可选)",
27931
+ labelCode: "harness.field.providerId.label",
27510
27932
  kind: "text",
27511
27933
  placeholder: "默认取配置名称",
27512
- help: "DSH 的模型路由标识;必须以小写字母开头。"
27934
+ placeholderCode: "harness.field.providerId.placeholder",
27935
+ help: "DSH 的模型路由标识;必须以小写字母开头。",
27936
+ helpCode: "harness.field.dsh.providerId.help"
27513
27937
  },
27514
27938
  {
27515
27939
  key: "models",
27516
27940
  label: "模型目录(可选)",
27941
+ labelCode: "harness.field.dsh.models.label",
27517
27942
  kind: "textarea",
27518
27943
  fullWidth: true,
27519
27944
  placeholder: "每行一个模型 ID;留空时只注册上方的默认模型",
27520
- help: "一个提供方可注册多个模型;上方“模型”作为新会话的默认模型。"
27945
+ placeholderCode: "harness.field.dsh.models.placeholder",
27946
+ help: "一个提供方可注册多个模型;上方“模型”作为新会话的默认模型。",
27947
+ helpCode: "harness.field.dsh.models.help"
27521
27948
  },
27522
27949
  {
27523
27950
  key: "api",
27524
27951
  label: "API 协议",
27952
+ labelCode: "harness.field.dsh.api.label",
27525
27953
  kind: "select",
27526
27954
  defaultValue: "openai-responses",
27527
27955
  options: [
@@ -27533,27 +27961,39 @@ class DshAdapter {
27533
27961
  {
27534
27962
  key: "contextWindow",
27535
27963
  label: "上下文长度",
27964
+ labelCode: "harness.field.contextLength.label",
27536
27965
  kind: "text",
27537
27966
  defaultValue: String(DEFAULT_CONTEXT)
27538
27967
  },
27539
27968
  {
27540
27969
  key: "maxTokens",
27541
27970
  label: "最大输出 tokens",
27971
+ labelCode: "harness.field.maxTokens.label",
27542
27972
  kind: "text",
27543
27973
  defaultValue: String(DEFAULT_MAX_TOKENS)
27544
27974
  },
27545
27975
  {
27546
27976
  key: "reasoningEfforts",
27547
27977
  label: "支持的思考程度",
27978
+ labelCode: "harness.field.dsh.reasoningEfforts.label",
27548
27979
  kind: "select",
27549
27980
  defaultValue: "",
27550
27981
  help: "DSH 只会显示这里声明且上游模型实际支持的档位。",
27982
+ helpCode: "harness.field.dsh.reasoningEfforts.help",
27551
27983
  options: [
27552
- { value: "", label: "不声明(提供方默认)" },
27984
+ {
27985
+ value: "",
27986
+ label: "不声明(提供方默认)",
27987
+ labelCode: "harness.field.dsh.reasoningEfforts.option.unset"
27988
+ },
27553
27989
  { value: "low,medium,high,xhigh,max", label: "Low / Medium / High / XHigh / Max" },
27554
27990
  { value: "low,medium,high,xhigh", label: "Low / Medium / High / XHigh" },
27555
27991
  { value: "minimal,low,medium,high", label: "Minimal / Low / Medium / High" },
27556
- { value: "false", label: "模型不支持思考程度" }
27992
+ {
27993
+ value: "false",
27994
+ label: "模型不支持思考程度",
27995
+ labelCode: "harness.field.dsh.reasoningEfforts.option.none"
27996
+ }
27557
27997
  ]
27558
27998
  }
27559
27999
  ];
@@ -27596,17 +28036,17 @@ class DshAdapter {
27596
28036
  render(profile, current) {
27597
28037
  this.validate(profile);
27598
28038
  const official = this.isOfficial(profile);
27599
- const providerId = official ? "deepseek-official" : this.providerId(profile);
27600
- const credentialRef = this.credentialRef(providerId);
28039
+ const providerId2 = official ? "deepseek-official" : this.providerId(profile);
28040
+ const credentialRef = this.credentialRef(providerId2);
27601
28041
  const settings = parseYamlDocument(current[SETTINGS2]);
27602
28042
  const models = this.models(profile, official);
27603
28043
  if (official) {
27604
28044
  settings.setIn(["llm-deepseek", "apiKeyEnv"], credentialRef);
27605
28045
  settings.setIn(["llm-deepseek", "baseURL"], profile.baseUrl || "https://api.deepseek.com");
27606
28046
  settings.setIn(["llm-deepseek", "models"], models);
27607
- settings.setIn(["llm-deepseek", "maxTokens"], this.numeric(profile.extras.maxTokens, 256000));
28047
+ settings.setIn(["llm-deepseek", "maxTokens"], numeric(profile.extras.maxTokens, 256000));
27608
28048
  } else {
27609
- settings.setIn(["llm-pi-ai", "providers", providerId], {
28049
+ settings.setIn(["llm-pi-ai", "providers", providerId2], {
27610
28050
  displayName: profile.name,
27611
28051
  apiKeyEnv: credentialRef,
27612
28052
  api: profile.extras.api || "openai-responses",
@@ -27614,7 +28054,7 @@ class DshAdapter {
27614
28054
  models
27615
28055
  });
27616
28056
  }
27617
- settings.setIn(["agent-default-model", "provider"], providerId);
28057
+ settings.setIn(["agent-default-model", "provider"], providerId2);
27618
28058
  settings.setIn(["agent-default-model", "model"], profile.model);
27619
28059
  settings.deleteIn(["agent-default-model", "reasoningEffort"]);
27620
28060
  const credentials = parseYamlDocument(current[CREDENTIALS]);
@@ -27640,72 +28080,68 @@ class DshAdapter {
27640
28080
  }
27641
28081
  revoke(profile, current) {
27642
28082
  const official = this.isOfficial(profile);
27643
- const providerId = official ? "deepseek-official" : this.providerId(profile);
28083
+ const providerId2 = official ? "deepseek-official" : this.providerId(profile);
27644
28084
  const rendered = {};
27645
28085
  if (current[SETTINGS2] !== undefined) {
27646
- try {
27647
- const settings = parseYamlDocument(current[SETTINGS2]);
28086
+ const settings = tryParseYamlDocument(current[SETTINGS2]);
28087
+ if (settings) {
27648
28088
  if (official)
27649
28089
  settings.deleteIn(["llm-deepseek"]);
27650
28090
  else
27651
- settings.deleteIn(["llm-pi-ai", "providers", providerId]);
27652
- if (settings.getIn(["agent-default-model", "provider"]) === providerId) {
28091
+ settings.deleteIn(["llm-pi-ai", "providers", providerId2]);
28092
+ if (settings.getIn(["agent-default-model", "provider"]) === providerId2) {
27653
28093
  settings.deleteIn(["agent-default-model"]);
27654
28094
  }
27655
28095
  rendered[SETTINGS2] = settings.toString();
27656
- } catch {}
28096
+ }
27657
28097
  }
27658
28098
  if (current[CREDENTIALS] !== undefined) {
27659
- try {
27660
- const credentials = parseYamlDocument(current[CREDENTIALS]);
28099
+ const credentials = tryParseYamlDocument(current[CREDENTIALS]);
28100
+ if (credentials) {
27661
28101
  this.normalizeCredentials(credentials);
27662
- credentials.deleteIn(["refs", this.credentialRef(providerId)]);
28102
+ credentials.deleteIn(["refs", this.credentialRef(providerId2)]);
27663
28103
  rendered[CREDENTIALS] = credentials.toString();
27664
- } catch {}
28104
+ }
27665
28105
  }
27666
28106
  return rendered;
27667
28107
  }
27668
28108
  backfill(profile, current) {
27669
- try {
27670
- const official = this.isOfficial(profile);
27671
- const providerId = official ? "deepseek-official" : this.providerId(profile);
27672
- const settings = parseYamlDocument(current[SETTINGS2]);
27673
- const credentials = parseYamlDocument(current[CREDENTIALS]);
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 {
28109
+ const official = this.isOfficial(profile);
28110
+ const providerId2 = official ? "deepseek-official" : this.providerId(profile);
28111
+ const settings = tryParseYamlDocument(current[SETTINGS2]);
28112
+ const credentials = tryParseYamlDocument(current[CREDENTIALS]);
28113
+ if (!settings || !credentials) {
27695
28114
  return {};
27696
28115
  }
28116
+ const route = toPlain(settings.getIn(official ? ["llm-deepseek"] : ["llm-pi-ai", "providers", providerId2]));
28117
+ const models = Array.isArray(route?.models) ? route.models : [];
28118
+ const firstModel = toPlain(models[0]);
28119
+ const ref = this.credentialRef(providerId2);
28120
+ const apiKey = credentials.getIn(["refs", ref]) ?? credentials.getIn([ref]);
28121
+ return {
28122
+ baseUrl: typeof route?.baseURL === "string" ? route.baseURL : profile.baseUrl,
28123
+ apiKey: typeof apiKey === "string" && apiKey ? apiKey : profile.apiKey,
28124
+ model: typeof firstModel?.id === "string" ? firstModel.id : profile.model,
28125
+ extras: {
28126
+ ...profile.extras,
28127
+ providerType: official ? "official" : "custom",
28128
+ api: typeof route?.api === "string" ? route.api : profile.extras.api || "",
28129
+ models: models.map((entry) => toPlain(entry)?.id).filter((id) => typeof id === "string").join(`
28130
+ `),
28131
+ contextWindow: valueString(firstModel?.contextWindow, profile.extras.contextWindow),
28132
+ maxTokens: valueString(firstModel?.maxTokens, profile.extras.maxTokens),
28133
+ reasoningEfforts: reasoningEffortsString(firstModel?.reasoningEfforts, profile.extras.reasoningEfforts)
28134
+ }
28135
+ };
27697
28136
  }
27698
28137
  detect(current) {
27699
- let providers;
27700
- let selected = "";
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 {
28138
+ const settings = tryParseYamlDocument(current[SETTINGS2]);
28139
+ if (!settings) {
27707
28140
  return [];
27708
28141
  }
28142
+ const providers = toPlain(settings.getIn(["llm-pi-ai", "providers"]));
28143
+ const active = settings.getIn(["agent-default-model", "provider"]);
28144
+ const selected = typeof active === "string" ? active : "";
27709
28145
  if (!providers) {
27710
28146
  return [];
27711
28147
  }
@@ -27719,19 +28155,19 @@ class DshAdapter {
27719
28155
  }));
27720
28156
  }
27721
28157
  providerId(profile) {
27722
- const id = slugify2(profile.extras.providerId || profile.name, "provider");
28158
+ const id = providerId(profile);
27723
28159
  return /^[a-z]/.test(id) ? id : `provider-${id}`;
27724
28160
  }
27725
- credentialRef(providerId) {
27726
- return providerId === "deepseek-official" ? "DEEPSEEK_API_KEY" : `${providerId.toUpperCase().replace(/[^A-Z0-9_]/g, "_")}_API_KEY`;
28161
+ credentialRef(providerId2) {
28162
+ return providerId2 === "deepseek-official" ? "DEEPSEEK_API_KEY" : `${providerId2.toUpperCase().replace(/[^A-Z0-9_]/g, "_")}_API_KEY`;
27727
28163
  }
27728
28164
  isOfficial(profile) {
27729
28165
  return profile.extras.providerType === "official";
27730
28166
  }
27731
28167
  models(profile, official) {
27732
28168
  const ids = [profile.model, ...(profile.extras.models || "").split(/[\n,]/)].map((id) => id.trim()).filter(Boolean);
27733
- const contextWindow = this.numeric(profile.extras.contextWindow, official ? 1e6 : DEFAULT_CONTEXT);
27734
- const maxTokens = this.numeric(profile.extras.maxTokens, official ? 256000 : DEFAULT_MAX_TOKENS);
28169
+ const contextWindow = numeric(profile.extras.contextWindow, official ? 1e6 : DEFAULT_CONTEXT);
28170
+ const maxTokens = numeric(profile.extras.maxTokens, official ? 256000 : DEFAULT_MAX_TOKENS);
27735
28171
  const reasoningEfforts = this.reasoningEfforts(profile.extras.reasoningEfforts);
27736
28172
  return [...new Set(ids)].map((id) => ({
27737
28173
  id,
@@ -27751,10 +28187,6 @@ class DshAdapter {
27751
28187
  credentials.deleteIn([key]);
27752
28188
  }
27753
28189
  }
27754
- numeric(raw2, fallback) {
27755
- const parsed = Number(raw2);
27756
- return Number.isFinite(parsed) && parsed > 0 ? Math.trunc(parsed) : fallback;
27757
- }
27758
28190
  reasoningEfforts(raw2) {
27759
28191
  if (!raw2) {
27760
28192
  return;
@@ -27773,9 +28205,6 @@ function toPlain(value) {
27773
28205
  function isYamlNode(value) {
27774
28206
  return typeof value === "object" && value !== null && "toJSON" in value;
27775
28207
  }
27776
- function valueString(value, fallback) {
27777
- return typeof value === "number" && Number.isFinite(value) ? String(value) : fallback || "";
27778
- }
27779
28208
  function reasoningEffortsString(value, fallback) {
27780
28209
  if (value === false) {
27781
28210
  return "false";
@@ -27796,15 +28225,22 @@ class KimiAdapter {
27796
28225
  modelRequired = true;
27797
28226
  envVarNames = [];
27798
28227
  envNote = "Kimi Code 不从 shell 读取凭据,env.sh 对它无效。";
28228
+ envNoteCode = "harness.field.kimi.envNote";
27799
28229
  fields = [
27800
28230
  {
27801
28231
  key: "providerType",
27802
28232
  label: "Provider 类型",
28233
+ labelCode: "harness.field.kimi.providerType.label",
27803
28234
  kind: "select",
27804
28235
  defaultValue: "kimi",
27805
28236
  help: "决定 Kimi Code 使用哪套协议实现。",
28237
+ helpCode: "harness.field.kimi.providerType.help",
27806
28238
  options: [
27807
- { value: "kimi", label: "kimi(Moonshot / Kimi Code)" },
28239
+ {
28240
+ value: "kimi",
28241
+ label: "kimi(Moonshot / Kimi Code)",
28242
+ labelCode: "harness.field.kimi.providerType.option.kimi"
28243
+ },
27808
28244
  { value: "anthropic", label: "anthropic" },
27809
28245
  { value: "openai_responses", label: "openai_responses" },
27810
28246
  { value: "openai_legacy", label: "openai_legacy" }
@@ -27813,15 +28249,19 @@ class KimiAdapter {
27813
28249
  {
27814
28250
  key: "providerId",
27815
28251
  label: "Provider ID(可选)",
28252
+ labelCode: "harness.field.providerId.label",
27816
28253
  kind: "text",
27817
- placeholder: "默认取配置名称"
28254
+ placeholder: "默认取配置名称",
28255
+ placeholderCode: "harness.field.providerId.placeholder"
27818
28256
  },
27819
28257
  {
27820
28258
  key: "maxContextSize",
27821
28259
  label: "上下文长度",
28260
+ labelCode: "harness.field.contextLength.label",
27822
28261
  kind: "text",
27823
28262
  defaultValue: String(DEFAULT_CONTEXT2),
27824
- help: "Kimi Code 要求 models 条目必须声明 max_context_size。"
28263
+ help: "Kimi Code 要求 models 条目必须声明 max_context_size。",
28264
+ helpCode: "harness.field.kimi.maxContextSize.help"
27825
28265
  }
27826
28266
  ];
27827
28267
  constructor(environment) {
@@ -27850,7 +28290,7 @@ class KimiAdapter {
27850
28290
  }
27851
28291
  render(profile, current) {
27852
28292
  this.validate(profile);
27853
- const id = this.providerId(profile);
28293
+ const id = providerId(profile);
27854
28294
  const config2 = parseTomlObject(current[CONFIG2]);
27855
28295
  const provider = ensureObject(ensureObject(config2, "providers"), id);
27856
28296
  provider.type = profile.extras.providerType || "kimi";
@@ -27859,19 +28299,17 @@ class KimiAdapter {
27859
28299
  const model = ensureObject(ensureObject(config2, "models"), id);
27860
28300
  model.provider = id;
27861
28301
  model.model = profile.model;
27862
- model.max_context_size = this.contextSize(profile);
28302
+ model.max_context_size = numeric(profile.extras.maxContextSize, DEFAULT_CONTEXT2);
27863
28303
  config2.default_model = id;
27864
28304
  return { [CONFIG2]: stringifyToml(config2) };
27865
28305
  }
27866
28306
  revoke(profile, current) {
27867
- const id = this.providerId(profile);
28307
+ const id = providerId(profile);
27868
28308
  if (current[CONFIG2] === undefined) {
27869
28309
  return {};
27870
28310
  }
27871
- let config2;
27872
- try {
27873
- config2 = parseTomlObject(current[CONFIG2]);
27874
- } catch {
28311
+ const config2 = tryParseTomlObject(current[CONFIG2]);
28312
+ if (!config2) {
27875
28313
  return {};
27876
28314
  }
27877
28315
  const providers = config2.providers;
@@ -27896,10 +28334,8 @@ class KimiAdapter {
27896
28334
  if (current[CONFIG2] === undefined) {
27897
28335
  return {};
27898
28336
  }
27899
- let config2;
27900
- try {
27901
- config2 = parseTomlObject(current[CONFIG2]);
27902
- } catch {
28337
+ const config2 = tryParseTomlObject(current[CONFIG2]);
28338
+ if (!config2) {
27903
28339
  return {};
27904
28340
  }
27905
28341
  const official = officialModel(config2);
@@ -27913,13 +28349,11 @@ class KimiAdapter {
27913
28349
  return { [CONFIG2]: stringifyToml(config2) };
27914
28350
  }
27915
28351
  backfill(profile, current) {
27916
- let config2;
27917
- try {
27918
- config2 = parseTomlObject(current[CONFIG2]);
27919
- } catch {
28352
+ const config2 = tryParseTomlObject(current[CONFIG2]);
28353
+ if (!config2) {
27920
28354
  return {};
27921
28355
  }
27922
- const id = this.providerId(profile);
28356
+ const id = providerId(profile);
27923
28357
  const providers = config2.providers;
27924
28358
  const provider = isPlainObject2(providers) ? providers[id] : undefined;
27925
28359
  const models = config2.models;
@@ -27932,10 +28366,8 @@ class KimiAdapter {
27932
28366
  };
27933
28367
  }
27934
28368
  detect(current) {
27935
- let config2;
27936
- try {
27937
- config2 = parseTomlObject(current[CONFIG2]);
27938
- } catch {
28369
+ const config2 = tryParseTomlObject(current[CONFIG2]);
28370
+ if (!config2) {
27939
28371
  return [];
27940
28372
  }
27941
28373
  const providers = config2.providers;
@@ -27952,21 +28384,11 @@ class KimiAdapter {
27952
28384
  const seed = seedProfile({
27953
28385
  providerId: id,
27954
28386
  providerType: readString(provider, "type") || "kimi",
27955
- maxContextSize: contextString(isPlainObject2(model) ? model.max_context_size : undefined)
28387
+ maxContextSize: valueString(isPlainObject2(model) ? model.max_context_size : undefined, String(DEFAULT_CONTEXT2))
27956
28388
  });
27957
28389
  return toCandidate(id, seed, this.backfill(seed, current), id === selected);
27958
28390
  }));
27959
28391
  }
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
28392
  }
27971
28393
  var PREFERRED_OFFICIAL_MODELS = ["kimi-code/k3-256k", "kimi-code/kimi-for-coding"];
27972
28394
  function officialModel(config2) {
@@ -27991,17 +28413,22 @@ class PiAdapter {
27991
28413
  modelRequired = true;
27992
28414
  envVarNames = [];
27993
28415
  envNote = "API key 直接写入 models.json,无需环境变量;运行时仍可用 --model 覆盖。";
28416
+ envNoteCode = "harness.field.pi.envNote";
27994
28417
  fields = [
27995
28418
  {
27996
28419
  key: "providerId",
27997
28420
  label: "Provider ID(可选)",
28421
+ labelCode: "harness.field.providerId.label",
27998
28422
  kind: "text",
27999
28423
  placeholder: "默认取配置名称",
28000
- help: "模型引用格式为 provider/model。"
28424
+ placeholderCode: "harness.field.providerId.placeholder",
28425
+ help: "模型引用格式为 provider/model。",
28426
+ helpCode: "harness.field.pi.providerId.help"
28001
28427
  },
28002
28428
  {
28003
28429
  key: "api",
28004
28430
  label: "协议",
28431
+ labelCode: "harness.field.pi.api.label",
28005
28432
  kind: "select",
28006
28433
  defaultValue: "openai-completions",
28007
28434
  options: [
@@ -28013,35 +28440,41 @@ class PiAdapter {
28013
28440
  {
28014
28441
  key: "authHeader",
28015
28442
  label: "Authorization 头",
28443
+ labelCode: "harness.field.pi.authHeader.label",
28016
28444
  kind: "select",
28017
28445
  defaultValue: "true",
28018
28446
  help: "以 Authorization: Bearer <key> 发送。",
28447
+ helpCode: "harness.field.pi.authHeader.help",
28019
28448
  options: [
28020
- { value: "true", label: "开启" },
28021
- { value: "false", label: "关闭" }
28449
+ { value: "true", label: "开启", labelCode: "harness.field.toggle.on" },
28450
+ { value: "false", label: "关闭", labelCode: "harness.field.toggle.off" }
28022
28451
  ]
28023
28452
  },
28024
28453
  {
28025
28454
  key: "contextWindow",
28026
28455
  label: "上下文长度",
28456
+ labelCode: "harness.field.contextLength.label",
28027
28457
  kind: "text",
28028
28458
  defaultValue: String(DEFAULT_CONTEXT3)
28029
28459
  },
28030
28460
  {
28031
28461
  key: "maxTokens",
28032
28462
  label: "最大输出 tokens",
28463
+ labelCode: "harness.field.maxTokens.label",
28033
28464
  kind: "text",
28034
28465
  defaultValue: String(DEFAULT_MAX_TOKENS2)
28035
28466
  },
28036
28467
  {
28037
28468
  key: "reasoning",
28038
28469
  label: "推理能力",
28470
+ labelCode: "harness.field.pi.reasoning.label",
28039
28471
  kind: "select",
28040
28472
  defaultValue: "false",
28041
28473
  help: "对应 models.json 的 reasoning。GPT / Claude 思考模型需要开启。",
28474
+ helpCode: "harness.field.pi.reasoning.help",
28042
28475
  options: [
28043
- { value: "false", label: "关闭" },
28044
- { value: "true", label: "开启" }
28476
+ { value: "false", label: "关闭", labelCode: "harness.field.toggle.off" },
28477
+ { value: "true", label: "开启", labelCode: "harness.field.toggle.on" }
28045
28478
  ]
28046
28479
  }
28047
28480
  ];
@@ -28083,14 +28516,14 @@ class PiAdapter {
28083
28516
  }
28084
28517
  render(profile, current) {
28085
28518
  this.validate(profile);
28086
- const id = this.providerId(profile);
28519
+ const id = providerId(profile);
28087
28520
  const models = parseJsonObject(current[MODELS]);
28088
28521
  const provider = ensureObject(ensureObject(models, "providers"), id);
28089
28522
  const model = {
28090
28523
  id: profile.model,
28091
28524
  name: profile.model,
28092
- contextWindow: this.numeric(profile.extras.contextWindow, DEFAULT_CONTEXT3),
28093
- maxTokens: this.numeric(profile.extras.maxTokens, DEFAULT_MAX_TOKENS2)
28525
+ contextWindow: numeric(profile.extras.contextWindow, DEFAULT_CONTEXT3),
28526
+ maxTokens: numeric(profile.extras.maxTokens, DEFAULT_MAX_TOKENS2)
28094
28527
  };
28095
28528
  if (profile.extras.reasoning === "true") {
28096
28529
  model.reasoning = true;
@@ -28109,66 +28542,64 @@ class PiAdapter {
28109
28542
  };
28110
28543
  }
28111
28544
  revoke(profile, current) {
28112
- const id = this.providerId(profile);
28545
+ const id = providerId(profile);
28113
28546
  const rendered = {};
28114
28547
  if (current[MODELS] !== undefined) {
28115
- try {
28116
- const models = parseJsonObject(current[MODELS]);
28548
+ const models = tryParseJsonObject(current[MODELS]);
28549
+ if (models) {
28117
28550
  const providers = models.providers;
28118
28551
  if (isPlainObject2(providers)) {
28119
28552
  delete providers[id];
28120
28553
  }
28121
28554
  rendered[MODELS] = stringifyJson(models);
28122
- } catch {}
28555
+ }
28123
28556
  }
28124
28557
  if (current[SETTINGS3] !== undefined) {
28125
- try {
28126
- const settings = parseJsonObject(current[SETTINGS3]);
28558
+ const settings = tryParseJsonObject(current[SETTINGS3]);
28559
+ if (settings) {
28127
28560
  if (settings.defaultProvider === id) {
28128
28561
  delete settings.defaultProvider;
28129
28562
  delete settings.defaultModel;
28130
28563
  }
28131
28564
  rendered[SETTINGS3] = stringifyJson(settings);
28132
- } catch {}
28565
+ }
28133
28566
  }
28134
28567
  return rendered;
28135
28568
  }
28136
28569
  backfill(profile, current) {
28137
- try {
28138
- const models = parseJsonObject(current[MODELS]);
28139
- const id = this.providerId(profile);
28140
- const providers = models.providers;
28141
- const provider = isPlainObject2(providers) ? providers[id] : undefined;
28142
- if (!isPlainObject2(provider)) {
28143
- return {};
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 {
28570
+ const models = tryParseJsonObject(current[MODELS]);
28571
+ if (!models) {
28160
28572
  return {};
28161
28573
  }
28574
+ const id = providerId(profile);
28575
+ const providers = models.providers;
28576
+ const provider = isPlainObject2(providers) ? providers[id] : undefined;
28577
+ if (!isPlainObject2(provider)) {
28578
+ return {};
28579
+ }
28580
+ const firstModel = Array.isArray(provider.models) ? provider.models.find((entry) => isPlainObject2(entry)) : undefined;
28581
+ const apiKey = readString(provider, "apiKey");
28582
+ return {
28583
+ baseUrl: readString(provider, "baseUrl") || profile.baseUrl,
28584
+ apiKey: apiKey || profile.apiKey,
28585
+ model: readString(firstModel, "id") || profile.model,
28586
+ extras: {
28587
+ ...profile.extras,
28588
+ api: readString(provider, "api") || profile.extras.api || "",
28589
+ contextWindow: valueString(firstModel?.contextWindow, profile.extras.contextWindow),
28590
+ maxTokens: valueString(firstModel?.maxTokens, profile.extras.maxTokens),
28591
+ reasoning: firstModel?.reasoning === true ? "true" : profile.extras.reasoning || "false"
28592
+ }
28593
+ };
28162
28594
  }
28163
28595
  detect(current) {
28164
- let providers;
28165
- let selected = "";
28166
- try {
28167
- providers = parseJsonObject(current[MODELS]).providers;
28168
- selected = readString(parseJsonObject(current[SETTINGS3]), "defaultProvider");
28169
- } catch {
28596
+ const models = tryParseJsonObject(current[MODELS]);
28597
+ const settings = tryParseJsonObject(current[SETTINGS3]);
28598
+ if (!models || !settings) {
28170
28599
  return [];
28171
28600
  }
28601
+ const providers = models.providers;
28602
+ const selected = readString(settings, "defaultProvider");
28172
28603
  if (!isPlainObject2(providers)) {
28173
28604
  return [];
28174
28605
  }
@@ -28183,16 +28614,6 @@ class PiAdapter {
28183
28614
  return toCandidate(id, seed, this.backfill(seed, current), id === selected);
28184
28615
  }));
28185
28616
  }
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
28617
  }
28197
28618
 
28198
28619
  // src/services/adapters/index.ts
@@ -29318,15 +29739,15 @@ class ProfileService {
29318
29739
  });
29319
29740
  }
29320
29741
  const hasProvider = input.providerId !== undefined;
29321
- const providerId = input.providerId?.trim() || undefined;
29742
+ const providerId2 = input.providerId?.trim() || undefined;
29322
29743
  const providerEndpoint = input.providerEndpoint?.trim() || undefined;
29323
29744
  const hasInlineKey = input.apiKey !== undefined && input.apiKey.trim() !== "";
29324
29745
  const inlineKey = (input.apiKey ?? "").trim();
29325
29746
  let nextProviderId = prior?.provider_id;
29326
29747
  let nextProviderEndpoint = prior?.provider_endpoint;
29327
29748
  let apiKey = "";
29328
- if (hasProvider && providerId) {
29329
- const entry = this.vault.get(providerId);
29749
+ if (hasProvider && providerId2) {
29750
+ const entry = this.vault.get(providerId2);
29330
29751
  if (providerEndpoint) {
29331
29752
  const endpoint = entry.endpoints.find((candidate) => candidate.key === providerEndpoint);
29332
29753
  if (!endpoint) {
@@ -29339,9 +29760,9 @@ class ProfileService {
29339
29760
  } else {
29340
29761
  nextProviderEndpoint = undefined;
29341
29762
  }
29342
- nextProviderId = providerId;
29343
- apiKey = this.vault.decrypt(providerId);
29344
- } else if (hasProvider && !providerId) {
29763
+ nextProviderId = providerId2;
29764
+ apiKey = this.vault.decrypt(providerId2);
29765
+ } else if (hasProvider && !providerId2) {
29345
29766
  nextProviderId = undefined;
29346
29767
  nextProviderEndpoint = undefined;
29347
29768
  apiKey = hasInlineKey ? inlineKey : prior ? this.crypto.decrypt(prior.api_key) : "";
@@ -29355,7 +29776,7 @@ class ProfileService {
29355
29776
  if (isCreate && !apiKey) {
29356
29777
  throw new HttpError(400, "apiKey is required", { code: ERROR_CODES.profileApiKeyRequired });
29357
29778
  }
29358
- const baseUrl = this.resolveBaseUrl((input.baseUrl ?? prior?.base_url ?? "").trim(), providerId || nextProviderId, providerEndpoint || nextProviderEndpoint);
29779
+ const baseUrl = this.resolveBaseUrl((input.baseUrl ?? prior?.base_url ?? "").trim(), providerId2 || nextProviderId, providerEndpoint || nextProviderEndpoint);
29359
29780
  const next = {
29360
29781
  base_url: baseUrl,
29361
29782
  api_key: this.crypto.encrypt(apiKey),
@@ -29494,15 +29915,15 @@ class ProfileService {
29494
29915
  return this.crypto.decrypt(stored.api_key);
29495
29916
  }
29496
29917
  }
29497
- resolveBaseUrl(fallback, providerId, providerEndpoint) {
29498
- if (!providerId || !providerEndpoint) {
29918
+ resolveBaseUrl(fallback, providerId2, providerEndpoint) {
29919
+ if (!providerId2 || !providerEndpoint) {
29499
29920
  return fallback;
29500
29921
  }
29501
29922
  let entry;
29502
29923
  try {
29503
- entry = this.vault.get(providerId);
29924
+ entry = this.vault.get(providerId2);
29504
29925
  } catch {
29505
- this.log.warn(`profile 引用的 provider ${providerId} 不存在,回退到内联 base_url`);
29926
+ this.log.warn(`profile 引用的 provider ${providerId2} 不存在,回退到内联 base_url`);
29506
29927
  return fallback;
29507
29928
  }
29508
29929
  const endpoint = entry.endpoints.find((candidate) => candidate.key === providerEndpoint);
@@ -29510,7 +29931,7 @@ class ProfileService {
29510
29931
  return endpoint.baseUrl;
29511
29932
  }
29512
29933
  if (entry.endpoints.length > 0) {
29513
- this.log.warn(`endpoint ${providerEndpoint} 已不存在,回退到 provider ${providerId} 的首个 endpoint`);
29934
+ this.log.warn(`endpoint ${providerEndpoint} 已不存在,回退到 provider ${providerId2} 的首个 endpoint`);
29514
29935
  return entry.endpoints[0].baseUrl;
29515
29936
  }
29516
29937
  return fallback;
@@ -31586,6 +32007,7 @@ function createHarnessRoutes(services) {
31586
32007
  targets: adapter.targets(),
31587
32008
  envVars: adapter.envVarNames,
31588
32009
  envNote: adapter.envNote,
32010
+ envNoteCode: adapter.envNoteCode,
31589
32011
  supportsOfficialAuth: adapter.renderOfficial !== undefined
31590
32012
  };
31591
32013
  }
@@ -31904,20 +32326,20 @@ class ScanService {
31904
32326
  return { ok: true, imported, skipped, providersCreated, warnings };
31905
32327
  }
31906
32328
  save(harness, candidate, selection, replacing) {
31907
- let providerId;
32329
+ let providerId2;
31908
32330
  let created = 0;
31909
32331
  const apiKey = candidate.apiKey || selection.apiKey?.trim() || "";
31910
32332
  if (selection.target === "vault") {
31911
32333
  if (selection.providerId) {
31912
32334
  this.vault.get(selection.providerId);
31913
- providerId = selection.providerId;
32335
+ providerId2 = selection.providerId;
31914
32336
  } else {
31915
32337
  if (!apiKey) {
31916
32338
  throw new HttpError(400, "这条配置里没有可提取的凭据,请先填写 API key", {
31917
32339
  code: ERROR_CODES.scanApiKeyRequired
31918
32340
  });
31919
32341
  }
31920
- providerId = this.vault.create({
32342
+ providerId2 = this.vault.create({
31921
32343
  name: selection.providerName ?? selection.name,
31922
32344
  apiKey,
31923
32345
  endpoints: candidate.baseUrl ? [{ key: "default", label: "默认", baseUrl: candidate.baseUrl }] : []
@@ -31937,7 +32359,7 @@ class ScanService {
31937
32359
  model: candidate.model,
31938
32360
  notes: `从 ${harness} 现有配置导入(${candidate.key})`,
31939
32361
  extras: candidate.extras,
31940
- ...providerId ? { providerId, providerEndpoint: "default" } : {}
32362
+ ...providerId2 ? { providerId: providerId2, providerEndpoint: "default" } : {}
31941
32363
  }, !replacing);
31942
32364
  return created;
31943
32365
  }
@@ -32458,14 +32880,14 @@ class UserSyncService {
32458
32880
  return isDeepStrictEqual2(this.comparableProfile(source, sourceProviders), this.comparableProfile(target, targetProviders));
32459
32881
  }
32460
32882
  comparableProfile(profile, providers) {
32461
- const { updated_at: _updatedAt, provider_id: providerId, ...content } = profile;
32462
- const provider = providerId ? providers[providerId] : undefined;
32883
+ const { updated_at: _updatedAt, provider_id: providerId2, ...content } = profile;
32884
+ const provider = providerId2 ? providers[providerId2] : undefined;
32463
32885
  const comparableProvider = provider ? {
32464
32886
  name: provider.name,
32465
32887
  notes: provider.notes,
32466
32888
  endpoints: provider.endpoints,
32467
32889
  apiKey: provider.apiKey
32468
- } : providerId ? { missing: true } : undefined;
32890
+ } : providerId2 ? { missing: true } : undefined;
32469
32891
  return { ...content, provider: comparableProvider };
32470
32892
  }
32471
32893
  readVault() {
@@ -32626,7 +33048,7 @@ function createApp(services) {
32626
33048
  }
32627
33049
  app.notFound((c) => {
32628
33050
  const code = ERROR_CODES.requestFailed;
32629
- return c.json({ code, msg: localizeError(requestLanguage(c.req.header("Accept-Language")), code) }, 404);
33051
+ return c.json({ code, msg: localizeMessage(requestLanguage(c.req.header("Accept-Language")), code) }, 404);
32630
33052
  });
32631
33053
  app.onError((error52, c) => {
32632
33054
  const request = `${c.req.method} ${new URL(c.req.url).pathname}`;
@@ -32638,14 +33060,14 @@ function createApp(services) {
32638
33060
  return c.json({
32639
33061
  code: error52.code,
32640
33062
  ...data ? { data } : {},
32641
- msg: localizeError(requestLanguage(c.req.header("Accept-Language")), error52.code, data)
33063
+ msg: localizeMessage(requestLanguage(c.req.header("Accept-Language")), error52.code, data)
32642
33064
  }, error52.status);
32643
33065
  }
32644
33066
  log.error(`unhandled error on ${request}`, error52);
32645
33067
  const code = ERROR_CODES.internalServerError;
32646
33068
  return c.json({
32647
33069
  code,
32648
- msg: localizeError(requestLanguage(c.req.header("Accept-Language")), code)
33070
+ msg: localizeMessage(requestLanguage(c.req.header("Accept-Language")), code)
32649
33071
  }, 500);
32650
33072
  });
32651
33073
  return app;