@seaveyon/harness-switch 0.28.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 +130 -33
- package/package.json +1 -1
- package/public/assets/main.3ac68990.js +62 -0
- package/public/index.html +1 -1
- package/public/assets/main.bafc6210.js +0 -62
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",
|
|
@@ -7347,7 +7348,7 @@ var en_default = {
|
|
|
7347
7348
|
label: "Provider type",
|
|
7348
7349
|
option: {
|
|
7349
7350
|
custom: "Custom provider",
|
|
7350
|
-
official: "DeepSeek official"
|
|
7351
|
+
official: "DeepSeek official API"
|
|
7351
7352
|
}
|
|
7352
7353
|
},
|
|
7353
7354
|
providerId: {
|
|
@@ -7394,6 +7395,7 @@ var en_default = {
|
|
|
7394
7395
|
providers: "Providers",
|
|
7395
7396
|
profileCount_one: "{{count}} custom profile",
|
|
7396
7397
|
profileCount_other: "{{count}} custom profiles",
|
|
7398
|
+
copy: "Copy {{name}}",
|
|
7397
7399
|
noProfiles: "No profiles yet",
|
|
7398
7400
|
manualOverride: "Manual override",
|
|
7399
7401
|
edit: "Edit {{name}}",
|
|
@@ -7402,12 +7404,14 @@ var en_default = {
|
|
|
7402
7404
|
deleteTitle: "Delete profile?",
|
|
7403
7405
|
deleteBody: "This deletes {{harness}} / {{profile}}. {{extra}}This cannot be undone.",
|
|
7404
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. ",
|
|
7405
7408
|
official: "Official login",
|
|
7406
7409
|
officialActive: "In use",
|
|
7407
7410
|
officialSwitch: "Back to official",
|
|
7408
7411
|
officialHintClaude: "Use Claude Code's own Anthropic account login",
|
|
7409
7412
|
officialHintCodex: "Use Codex's own ChatGPT / OpenAI account login",
|
|
7410
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",
|
|
7411
7415
|
application: "Application",
|
|
7412
7416
|
writeMode: "Write mode",
|
|
7413
7417
|
modeReplace: "Replace current configuration",
|
|
@@ -7416,6 +7420,7 @@ var en_default = {
|
|
|
7416
7420
|
profile: {
|
|
7417
7421
|
editTitle: "Edit {{harness}} / {{profile}}",
|
|
7418
7422
|
createTitle: "New {{harness}} profile",
|
|
7423
|
+
copyTitle: "Copy {{harness}} / {{profile}}",
|
|
7419
7424
|
intro: "Saving writes to {{targets}}.",
|
|
7420
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.",
|
|
7421
7426
|
useSharedProvider: "Use a shared provider (vault)",
|
|
@@ -7439,6 +7444,7 @@ var en_default = {
|
|
|
7439
7444
|
apiKeyKeep: "Leave empty to keep the current key",
|
|
7440
7445
|
apiKeyRequiredPlaceholder: "Required",
|
|
7441
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.",
|
|
7442
7448
|
fallbackModel: "Fallback model (ANTHROPIC_MODEL)",
|
|
7443
7449
|
model: "Model",
|
|
7444
7450
|
fallbackModelPlaceholder: "Optional; used when no tier matches, e.g. glm-5",
|
|
@@ -7470,6 +7476,7 @@ var en_default = {
|
|
|
7470
7476
|
nameRequired: "Enter a profile name",
|
|
7471
7477
|
nameSlash: "A profile name cannot contain / or \\",
|
|
7472
7478
|
nameTooLong: "A profile name is at most {{max}} characters",
|
|
7479
|
+
nameDuplicate: "A profile with this name already exists",
|
|
7473
7480
|
baseUrlRequired: "Enter an API base URL",
|
|
7474
7481
|
apiKeyRequired: "Enter an API key",
|
|
7475
7482
|
modelRequired: "Enter a model name",
|
|
@@ -7757,6 +7764,7 @@ var en_default = {
|
|
|
7757
7764
|
activation: {
|
|
7758
7765
|
officialLoginUnsupported: "{{harness}} does not support official account login",
|
|
7759
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}}",
|
|
7760
7768
|
noActiveProfile: "This tool has no active profile, so there is nothing to render",
|
|
7761
7769
|
officialProfileCannotAdopt: "The official login is active, so there is no profile to adopt into",
|
|
7762
7770
|
adoptUnsupported: "This tool cannot adopt a live configuration",
|
|
@@ -8255,7 +8263,7 @@ var zh_CN_default = {
|
|
|
8255
8263
|
label: "提供方类型",
|
|
8256
8264
|
option: {
|
|
8257
8265
|
custom: "自定义提供方",
|
|
8258
|
-
official: "DeepSeek 官方"
|
|
8266
|
+
official: "DeepSeek 官方 API"
|
|
8259
8267
|
}
|
|
8260
8268
|
},
|
|
8261
8269
|
providerId: {
|
|
@@ -8302,6 +8310,7 @@ var zh_CN_default = {
|
|
|
8302
8310
|
providers: "提供方",
|
|
8303
8311
|
profileCount_one: "{{count}} 个自定义配置",
|
|
8304
8312
|
profileCount_other: "{{count}} 个自定义配置",
|
|
8313
|
+
copy: "复制 {{name}}",
|
|
8305
8314
|
noProfiles: "还没有配置档案",
|
|
8306
8315
|
manualOverride: "手动接管",
|
|
8307
8316
|
edit: "编辑 {{name}}",
|
|
@@ -8310,12 +8319,14 @@ var zh_CN_default = {
|
|
|
8310
8319
|
deleteTitle: "删除配置?",
|
|
8311
8320
|
deleteBody: "将删除 {{harness}} / {{profile}}。{{extra}}此操作不可撤销。",
|
|
8312
8321
|
deleteAdditiveExtra: "它在配置文件里的 provider 条目也会被一并摘掉。",
|
|
8322
|
+
deleteDshOfficialExtra: "它的 DeepSeek 原生路由和凭据引用也会被一并移除。",
|
|
8313
8323
|
official: "官方登录",
|
|
8314
8324
|
officialActive: "已使用",
|
|
8315
8325
|
officialSwitch: "切回官方",
|
|
8316
8326
|
officialHintClaude: "使用 Claude Code 自身的 Anthropic 账号登录",
|
|
8317
8327
|
officialHintCodex: "使用 Codex 自身的 ChatGPT / OpenAI 账号登录",
|
|
8318
8328
|
officialHintKimi: "使用 Kimi Code 自身的 Kimi 账号登录(/login 写入的 OAuth 凭据)",
|
|
8329
|
+
officialHintDsh: "检测并切换到 DeepSeek Harness 已有的 DeepSeek 官方 API Key 配置。",
|
|
8319
8330
|
application: "应用",
|
|
8320
8331
|
writeMode: "写入模式",
|
|
8321
8332
|
modeReplace: "替换当前配置",
|
|
@@ -8324,6 +8335,7 @@ var zh_CN_default = {
|
|
|
8324
8335
|
profile: {
|
|
8325
8336
|
editTitle: "编辑 {{harness}} / {{profile}}",
|
|
8326
8337
|
createTitle: "新增 {{harness}} 配置",
|
|
8338
|
+
copyTitle: "复制 {{harness}} / {{profile}}",
|
|
8327
8339
|
intro: "保存后会写入 {{targets}}。",
|
|
8328
8340
|
additiveNote: "该工具的配置文件按 provider 共存,切换只会移动当前指针,不会删除你手写的其他 provider。",
|
|
8329
8341
|
useSharedProvider: "使用共享 Provider(凭据库)",
|
|
@@ -8347,6 +8359,7 @@ var zh_CN_default = {
|
|
|
8347
8359
|
apiKeyKeep: "留空表示保持不变",
|
|
8348
8360
|
apiKeyRequiredPlaceholder: "必填",
|
|
8349
8361
|
apiKeySharedHint: "已引用共享 Provider,密钥在「凭据库」中统一轮换。",
|
|
8362
|
+
dshOfficialApiKeyHint: "填写 DeepSeek 开放平台 API Key;它会安全写入 DSH 的 .credentials.yaml,并以 DEEPSEEK_API_KEY 被 settings.yaml 引用。",
|
|
8350
8363
|
fallbackModel: "回退模型(ANTHROPIC_MODEL)",
|
|
8351
8364
|
model: "模型",
|
|
8352
8365
|
fallbackModelPlaceholder: "可选;各档未匹配时使用,例如 glm-5",
|
|
@@ -8378,6 +8391,7 @@ var zh_CN_default = {
|
|
|
8378
8391
|
nameRequired: "请输入配置名称",
|
|
8379
8392
|
nameSlash: "配置名称不能包含 / 或 \\",
|
|
8380
8393
|
nameTooLong: "配置名称最多 {{max}} 个字符",
|
|
8394
|
+
nameDuplicate: "同名配置已经存在",
|
|
8381
8395
|
baseUrlRequired: "请输入 API Base URL",
|
|
8382
8396
|
apiKeyRequired: "请输入 API Key",
|
|
8383
8397
|
modelRequired: "请输入模型名称",
|
|
@@ -8665,6 +8679,7 @@ var zh_CN_default = {
|
|
|
8665
8679
|
activation: {
|
|
8666
8680
|
officialLoginUnsupported: "{{harness}} 不支持官方账号登录模式",
|
|
8667
8681
|
officialLoginMissing: "未检测到 {{harness}} 的官方登录条目,请先在终端完成一次官方登录",
|
|
8682
|
+
officialApiKeyMissing: "未检测到 {{harness}} 的 DeepSeek 官方 API Key 配置",
|
|
8668
8683
|
noActiveProfile: "该工具未激活任何配置,无可渲染的内容",
|
|
8669
8684
|
officialProfileCannotAdopt: "当前处于官方登录状态,没有可回填的配置档案",
|
|
8670
8685
|
adoptUnsupported: "该工具不支持采纳现场配置",
|
|
@@ -23292,6 +23307,7 @@ var loginRequestSchema = exports_external.object({
|
|
|
23292
23307
|
});
|
|
23293
23308
|
var createProfileRequestSchema = exports_external.object({
|
|
23294
23309
|
name: entityName,
|
|
23310
|
+
copySourceName: entityName.optional(),
|
|
23295
23311
|
baseUrl: optionalText(MAX_URL).optional(),
|
|
23296
23312
|
apiKey: optionalText(MAX_KEY).optional(),
|
|
23297
23313
|
model: optionalText(MAX_NAME).optional(),
|
|
@@ -27388,6 +27404,14 @@ class ClaudeAdapter {
|
|
|
27388
27404
|
MODEL_VAR,
|
|
27389
27405
|
...MODEL_MAPPINGS.flatMap(({ envVar, nameEnvVar }) => nameEnvVar ? [envVar, nameEnvVar] : [envVar])
|
|
27390
27406
|
];
|
|
27407
|
+
official(_current) {
|
|
27408
|
+
return {
|
|
27409
|
+
kind: "account-login",
|
|
27410
|
+
available: true,
|
|
27411
|
+
titleCode: "harness.official",
|
|
27412
|
+
hintCode: "harness.officialHintClaude"
|
|
27413
|
+
};
|
|
27414
|
+
}
|
|
27391
27415
|
fields = [
|
|
27392
27416
|
{
|
|
27393
27417
|
key: "authVar",
|
|
@@ -27697,6 +27721,14 @@ class CodexAdapter {
|
|
|
27697
27721
|
envVarNames = [DEFAULT_ENV_KEY];
|
|
27698
27722
|
envNote = "仅「环境变量」认证模式需要 env.sh,其余模式的凭据自包含在 config.toml 里。";
|
|
27699
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
|
+
}
|
|
27700
27732
|
fields = [
|
|
27701
27733
|
{
|
|
27702
27734
|
key: "authMode",
|
|
@@ -27905,6 +27937,7 @@ class DshAdapter {
|
|
|
27905
27937
|
envVarNames = [];
|
|
27906
27938
|
envNote = "API key 安全写入 DSH 的 .credentials.yaml,并由 settings.yaml 引用。";
|
|
27907
27939
|
envNoteCode = "harness.field.dsh.envNote";
|
|
27940
|
+
officialNeedsCurrent = true;
|
|
27908
27941
|
fields = [
|
|
27909
27942
|
{
|
|
27910
27943
|
key: "providerType",
|
|
@@ -28078,6 +28111,40 @@ class DshAdapter {
|
|
|
28078
28111
|
rendered[SETTINGS2] = settings.toString();
|
|
28079
28112
|
return rendered;
|
|
28080
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
|
+
}
|
|
28081
28148
|
revoke(profile, current) {
|
|
28082
28149
|
const official = this.isOfficial(profile);
|
|
28083
28150
|
const providerId2 = official ? "deepseek-official" : this.providerId(profile);
|
|
@@ -28226,6 +28293,14 @@ class KimiAdapter {
|
|
|
28226
28293
|
envVarNames = [];
|
|
28227
28294
|
envNote = "Kimi Code 不从 shell 读取凭据,env.sh 对它无效。";
|
|
28228
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
|
+
}
|
|
28229
28304
|
fields = [
|
|
28230
28305
|
{
|
|
28231
28306
|
key: "providerType",
|
|
@@ -29720,11 +29795,15 @@ class ProfileService {
|
|
|
29720
29795
|
this.harnesses.require(harness);
|
|
29721
29796
|
const name = input.name.trim();
|
|
29722
29797
|
const sourceName = isCreate ? name : input.sourceName?.trim() || name;
|
|
29798
|
+
const copySourceName = isCreate ? input.copySourceName?.trim() : undefined;
|
|
29723
29799
|
this.assertName(name);
|
|
29724
29800
|
this.assertName(sourceName);
|
|
29801
|
+
if (copySourceName)
|
|
29802
|
+
this.assertName(copySourceName);
|
|
29725
29803
|
const store = this.read();
|
|
29726
29804
|
store[harness] ||= {};
|
|
29727
29805
|
const prior = store[harness][sourceName];
|
|
29806
|
+
const copySource = copySourceName ? store[harness][copySourceName] : undefined;
|
|
29728
29807
|
if (isCreate && prior) {
|
|
29729
29808
|
throw new HttpError(409, "profile already exists", {
|
|
29730
29809
|
code: ERROR_CODES.profileAlreadyExists
|
|
@@ -29733,6 +29812,9 @@ class ProfileService {
|
|
|
29733
29812
|
if (!isCreate && !prior) {
|
|
29734
29813
|
throw new HttpError(404, "profile not found", { code: ERROR_CODES.profileNotFound });
|
|
29735
29814
|
}
|
|
29815
|
+
if (isCreate && copySourceName && !copySource) {
|
|
29816
|
+
throw new HttpError(404, "profile not found", { code: ERROR_CODES.profileNotFound });
|
|
29817
|
+
}
|
|
29736
29818
|
if (!isCreate && sourceName !== name && store[harness][name]) {
|
|
29737
29819
|
throw new HttpError(409, "profile already exists", {
|
|
29738
29820
|
code: ERROR_CODES.profileAlreadyExists
|
|
@@ -29743,8 +29825,9 @@ class ProfileService {
|
|
|
29743
29825
|
const providerEndpoint = input.providerEndpoint?.trim() || undefined;
|
|
29744
29826
|
const hasInlineKey = input.apiKey !== undefined && input.apiKey.trim() !== "";
|
|
29745
29827
|
const inlineKey = (input.apiKey ?? "").trim();
|
|
29746
|
-
|
|
29747
|
-
let
|
|
29828
|
+
const inherited = prior ?? copySource;
|
|
29829
|
+
let nextProviderId = inherited?.provider_id;
|
|
29830
|
+
let nextProviderEndpoint = inherited?.provider_endpoint;
|
|
29748
29831
|
let apiKey = "";
|
|
29749
29832
|
if (hasProvider && providerId2) {
|
|
29750
29833
|
const entry = this.vault.get(providerId2);
|
|
@@ -29765,24 +29848,24 @@ class ProfileService {
|
|
|
29765
29848
|
} else if (hasProvider && !providerId2) {
|
|
29766
29849
|
nextProviderId = undefined;
|
|
29767
29850
|
nextProviderEndpoint = undefined;
|
|
29768
|
-
apiKey = hasInlineKey ? inlineKey :
|
|
29851
|
+
apiKey = hasInlineKey ? inlineKey : inherited ? this.resolveKey(inherited) : "";
|
|
29769
29852
|
} else if (hasInlineKey) {
|
|
29770
29853
|
nextProviderId = undefined;
|
|
29771
29854
|
nextProviderEndpoint = undefined;
|
|
29772
29855
|
apiKey = inlineKey;
|
|
29773
|
-
} else if (
|
|
29774
|
-
apiKey =
|
|
29856
|
+
} else if (inherited) {
|
|
29857
|
+
apiKey = this.resolveKey(inherited);
|
|
29775
29858
|
}
|
|
29776
29859
|
if (isCreate && !apiKey) {
|
|
29777
29860
|
throw new HttpError(400, "apiKey is required", { code: ERROR_CODES.profileApiKeyRequired });
|
|
29778
29861
|
}
|
|
29779
|
-
const baseUrl = this.resolveBaseUrl((input.baseUrl ??
|
|
29862
|
+
const baseUrl = this.resolveBaseUrl((input.baseUrl ?? inherited?.base_url ?? "").trim(), providerId2 || nextProviderId, providerEndpoint || nextProviderEndpoint);
|
|
29780
29863
|
const next = {
|
|
29781
29864
|
base_url: baseUrl,
|
|
29782
29865
|
api_key: this.crypto.encrypt(apiKey),
|
|
29783
|
-
model: (input.model ??
|
|
29784
|
-
notes: input.notes ??
|
|
29785
|
-
extras: input.extras ??
|
|
29866
|
+
model: (input.model ?? inherited?.model ?? "").trim(),
|
|
29867
|
+
notes: input.notes ?? inherited?.notes ?? "",
|
|
29868
|
+
extras: input.extras ?? inherited?.extras ?? {},
|
|
29786
29869
|
overrides: input.overrides ?? prior?.overrides ?? {},
|
|
29787
29870
|
provider_id: nextProviderId,
|
|
29788
29871
|
provider_endpoint: nextProviderEndpoint,
|
|
@@ -31996,19 +32079,33 @@ function createHarnessRoutes(services) {
|
|
|
31996
32079
|
const probe = services.get(IProbeService);
|
|
31997
32080
|
function summary(id) {
|
|
31998
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;
|
|
31999
32087
|
return {
|
|
32000
32088
|
id,
|
|
32001
32089
|
label: harnesses.label(id),
|
|
32002
32090
|
mode: adapter.mode,
|
|
32003
32091
|
active: activation.getActive(id),
|
|
32004
|
-
profiles:
|
|
32092
|
+
profiles: profileList,
|
|
32005
32093
|
fields: adapter.fields,
|
|
32006
32094
|
modelRequired: adapter.modelRequired,
|
|
32007
|
-
targets
|
|
32095
|
+
targets,
|
|
32008
32096
|
envVars: adapter.envVarNames,
|
|
32009
32097
|
envNote: adapter.envNote,
|
|
32010
32098
|
envNoteCode: adapter.envNoteCode,
|
|
32011
|
-
|
|
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
|
+
} : {}
|
|
32012
32109
|
};
|
|
32013
32110
|
}
|
|
32014
32111
|
app.get("/", (c) => c.json({
|
|
@@ -32019,13 +32116,15 @@ function createHarnessRoutes(services) {
|
|
|
32019
32116
|
app.post("/:harnessId/profiles", async (c) => {
|
|
32020
32117
|
const harnessId = harnesses.require(c.req.param("harnessId"));
|
|
32021
32118
|
const body = await readJsonBody(c, createProfileRequestSchema);
|
|
32022
|
-
|
|
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")) {
|
|
32023
32121
|
throw new HttpError(409, "DeepSeek 官方配置已存在,请直接编辑现有官方配置", {
|
|
32024
32122
|
code: ERROR_CODES.officialProfileAlreadyExists
|
|
32025
32123
|
});
|
|
32026
32124
|
}
|
|
32027
32125
|
const profile = profiles.upsert(harnessId, {
|
|
32028
32126
|
name: body.name,
|
|
32127
|
+
copySourceName: body.copySourceName,
|
|
32029
32128
|
baseUrl: body.baseUrl,
|
|
32030
32129
|
apiKey: body.apiKey,
|
|
32031
32130
|
model: body.model,
|
|
@@ -33028,24 +33127,22 @@ function createApp(services) {
|
|
|
33028
33127
|
guarded("/drift", createDriftRoutes(services));
|
|
33029
33128
|
app.route("/api", api2);
|
|
33030
33129
|
const publicDir = environment.publicDir;
|
|
33031
|
-
|
|
33032
|
-
|
|
33033
|
-
|
|
33034
|
-
|
|
33035
|
-
|
|
33036
|
-
|
|
33037
|
-
|
|
33038
|
-
|
|
33039
|
-
|
|
33040
|
-
|
|
33041
|
-
|
|
33042
|
-
|
|
33043
|
-
|
|
33044
|
-
|
|
33045
|
-
|
|
33046
|
-
|
|
33047
|
-
});
|
|
33048
|
-
}
|
|
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
|
+
});
|
|
33049
33146
|
app.notFound((c) => {
|
|
33050
33147
|
const code = ERROR_CODES.requestFailed;
|
|
33051
33148
|
return c.json({ code, msg: localizeMessage(requestLanguage(c.req.header("Accept-Language")), code) }, 404);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seaveyon/harness-switch",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.29.0",
|
|
4
4
|
"description": "A secure web control plane that switches API providers for Claude Code, Codex, Kimi Code, Pi and DeepSeek Harness by writing their native config files on SSH servers.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"claude-code",
|