@seaveyon/harness-switch 0.19.0 → 0.20.1

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/README.md CHANGED
@@ -172,6 +172,12 @@ The **Provider Vault** stores an API key once under a named entry with one or mo
172
172
 
173
173
  ## Verify and repair configuration
174
174
 
175
+ ### Test endpoint connectivity
176
+
177
+ Every place a credential meets a base URL offers a **Test connection** button: the profile form (draft values, before saving), each Provider Vault entry (stored credential, against any of its endpoints), and Doctor's `--probe`. The server sends one lightweight `GET {base}/v1/models` request — falling back to `{base}/models`, and carrying both `Authorization: Bearer` and Anthropic-style headers, so OpenAI- and Anthropic-shaped relays both work.
178
+
179
+ The result reports latency and translates one stable code (`probe.timeout`, `probe.unauthorized`, …) instead of a raw stack trace. A successful probe also returns the endpoint's **model catalog**, which fills the model field's dropdown in the profile form — no more mistyped model names discovered only when the CLI fails. The credential itself never appears in any response; draft keys are tested server-side without saving them first.
180
+
175
181
  ### Detect configuration drift
176
182
 
177
183
  The dashboard **Diagnostics** panel also compares what the active profile would render against the actual files on disk, using parsed-value comparison for JSON/TOML/YAML so a re-render that only reorders keys does not count as drift. Each file is reported as:
@@ -191,7 +197,7 @@ Two repair actions are offered per harness:
191
197
 
192
198
  **Diagnostics (Doctor)** run per harness from that tool’s right-hand column: for CLI-delivered tools, whether the executable is on `PATH` (`install`; skipped for web-service harnesses such as DeepSeek Harness), whether each target file exists and is readable/writable (`files`, with a warning when a config file holding credentials is group/other-readable), whether the files parse (`parse`), and whether live state drifts from the active profile (`drift`). A global update check reports whether a newer release exists (`updatedAvailable`).
193
199
 
194
- The connectivity probe is **disabled by default in the MVP**: passing `--probe` only records a `unknown`-status check that reports the active base URL and explains that no network request is made.
200
+ Passing `--probe` adds one more check per harness: a real request against the active profile's endpoint. Reachable endpoints report `ok` with latency and model count; timeouts, refused credentials and other failures report `error`, since the tool itself would fail too. Harnesses without an active profile skip the check as `unknown`. Probes for all harnesses run concurrently.
195
201
 
196
202
  ## Manage local Unix users
197
203
 
@@ -291,6 +297,7 @@ The UI is a React SPA. Authentication uses an HttpOnly `hsw_session` cookie.
291
297
  | `DELETE` | `/api/harnesses/:id/profiles/:name` | Delete; `409` for the active profile |
292
298
  | `GET` | `/api/harnesses/:id/profiles/:name/preview` | The exact content that would be written |
293
299
  | `POST` | `/api/harnesses/:id/profiles/:name/activate` | Write the native config, then commit the switch |
300
+ | `POST` | `/api/harnesses/:id/profiles/:name/probe` | Test the stored credential against the stored base URL |
294
301
  | `POST` | `/api/harnesses/:id/official/activate` | Return a supported harness to its built-in account login |
295
302
  | `GET` | `/api/backups` | Snapshots, newest first |
296
303
  | `POST` | `/api/backups/:id/restore` | Restore a snapshot verbatim |
@@ -300,11 +307,13 @@ The UI is a React SPA. Authentication uses an HttpOnly `hsw_session` cookie.
300
307
  | `GET` | `/api/providers` | Provider Vault entries (no key material) |
301
308
  | `POST` | `/api/providers` | Create a vault entry |
302
309
  | `PATCH` | `/api/providers/:id` | Update; re-applies referencing active profiles |
310
+ | `POST` | `/api/providers/:id/probe` | Test the stored key against an endpoint (`{ "endpoint": "key" }`, default first) |
303
311
  | `DELETE` | `/api/providers/:id` | Delete; `409` while referenced by a profile |
312
+ | `POST` | `/api/probe` | Test unsaved values: `{ "baseUrl", "apiKey" }` or `{ "baseUrl", "providerId" }`, stored nowhere |
304
313
  | `GET` | `/api/drift` | Drift report for every harness |
305
314
  | `POST` | `/api/drift/:harnessId/reapply` | Rewrite live files from the active profile |
306
315
  | `POST` | `/api/drift/:harnessId/adopt` | Read live files back into the profile record |
307
- | `GET` | `/api/doctor` | Read-only diagnostics (`?probe=1` includes the MVP-disabled, non-network probe check) |
316
+ | `GET` | `/api/doctor` | Read-only diagnostics (`?probe=1` also tests each active profile's endpoint) |
308
317
  | `GET` | `/api/scan` | Providers the five tools already have on disk; read-only, credentials masked |
309
318
  | `POST` | `/api/scan/import` | Save selected candidates as profiles or vault entries; the tools' own config is untouched |
310
319
  | `GET` | `/api/operations` | Operation receipts, newest first (`?harness=claude` to filter) |
@@ -8674,7 +8674,11 @@ var DOCTOR_CODES = {
8674
8674
  driftInvalid: "doctor.check.driftInvalid",
8675
8675
  driftMismatch: "doctor.check.driftMismatch",
8676
8676
  driftInSync: "doctor.check.driftInSync",
8677
- probeDisabled: "doctor.check.probeDisabled"
8677
+ probeNoProfile: "doctor.check.probeNoProfile",
8678
+ probeOfficialLogin: "doctor.check.probeOfficialLogin",
8679
+ probeMissingCredential: "doctor.check.probeMissingCredential",
8680
+ probeOk: "doctor.check.probeOk",
8681
+ probeFailed: "doctor.check.probeFailed"
8678
8682
  };
8679
8683
  var SCAN_NOTE_CODES = {
8680
8684
  unsupported: "scan.note.unsupported",
@@ -8682,6 +8686,16 @@ var SCAN_NOTE_CODES = {
8682
8686
  unparsable: "scan.note.unparsable",
8683
8687
  noCandidates: "scan.note.noCandidates"
8684
8688
  };
8689
+ var PROBE_CODES = {
8690
+ badUrl: "probe.badUrl",
8691
+ missingBaseUrl: "probe.missingBaseUrl",
8692
+ missingApiKey: "probe.missingApiKey",
8693
+ timeout: "probe.timeout",
8694
+ networkError: "probe.networkError",
8695
+ unauthorized: "probe.unauthorized",
8696
+ httpError: "probe.httpError",
8697
+ invalidResponse: "probe.invalidResponse"
8698
+ };
8685
8699
  // ../../packages/shared/src/harnesses.ts
8686
8700
  var HARNESS_IDS = ["claude", "codex", "kimi", "pi", "dsh"];
8687
8701
  var HARNESS_LABELS = {
@@ -23060,6 +23074,14 @@ var scanImportSelectionSchema = exports_external.object({
23060
23074
  var scanImportRequestSchema = exports_external.object({
23061
23075
  selections: exports_external.array(scanImportSelectionSchema).min(1, "请至少选择一条配置").max(200)
23062
23076
  });
23077
+ var probeRequestSchema = exports_external.object({
23078
+ baseUrl: exports_external.string().trim().min(1, "baseUrl 不能为空").max(MAX_URL),
23079
+ apiKey: optionalText(MAX_KEY).optional(),
23080
+ providerId: optionalText(MAX_NAME).optional()
23081
+ });
23082
+ var probeStoredRequestSchema = exports_external.object({
23083
+ endpoint: optionalText(MAX_NAME).optional()
23084
+ });
23063
23085
  var emptyRequestSchema = exports_external.object({});
23064
23086
  function formatSchemaError(error51) {
23065
23087
  const parts = error51.issues.slice(0, 3).map((issue2) => {
@@ -28241,6 +28263,156 @@ function deepEqual(left, right) {
28241
28263
  return false;
28242
28264
  }
28243
28265
 
28266
+ // src/services/probe.ts
28267
+ var IProbeService = createDecorator("probeService");
28268
+ var TIMEOUT_MS = 1e4;
28269
+ var MAX_BODY_BYTES = 4 * 1024 * 1024;
28270
+ var MAX_MODELS = 1000;
28271
+ var _dec = [
28272
+ inject()
28273
+ ];
28274
+ var _init = __decoratorStart(undefined);
28275
+
28276
+ class ProbeService {
28277
+ async probe(input) {
28278
+ const baseUrl = input.baseUrl.trim();
28279
+ if (!baseUrl) {
28280
+ return failure(PROBE_CODES.missingBaseUrl, "未提供 Base URL,无法测试");
28281
+ }
28282
+ if (!input.apiKey.trim()) {
28283
+ return failure(PROBE_CODES.missingApiKey, "未提供 API Key,无法测试");
28284
+ }
28285
+ let base;
28286
+ try {
28287
+ base = new URL(baseUrl);
28288
+ } catch {
28289
+ return failure(PROBE_CODES.badUrl, `Base URL 无法解析:${baseUrl}`);
28290
+ }
28291
+ if (base.protocol !== "http:" && base.protocol !== "https:") {
28292
+ return failure(PROBE_CODES.badUrl, `Base URL 必须是 http/https:${base.protocol}`);
28293
+ }
28294
+ const path = base.pathname.replace(/\/+$/, "");
28295
+ const candidates = path.endsWith("/v1") || /\/v\d+$/.test(path) ? [joinUrl(base, "models")] : [joinUrl(base, "v1/models"), joinUrl(base, "models")];
28296
+ let lastStatus;
28297
+ for (let index = 0;index < candidates.length; index++) {
28298
+ const result = await this.request(candidates[index], input.apiKey);
28299
+ if (result.status !== 404 || index === candidates.length - 1) {
28300
+ return result;
28301
+ }
28302
+ lastStatus = result.status;
28303
+ }
28304
+ return failure(PROBE_CODES.httpError, `端点返回 ${lastStatus ?? "未知状态"},未找到模型目录`, {
28305
+ status: lastStatus,
28306
+ params: lastStatus === undefined ? undefined : { status: lastStatus }
28307
+ });
28308
+ }
28309
+ async request(url2, apiKey) {
28310
+ const started = performance.now();
28311
+ let response;
28312
+ try {
28313
+ response = await fetch(url2, {
28314
+ headers: {
28315
+ Accept: "application/json",
28316
+ Authorization: `Bearer ${apiKey}`,
28317
+ "x-api-key": apiKey,
28318
+ "anthropic-version": "2023-06-01"
28319
+ },
28320
+ signal: AbortSignal.timeout(TIMEOUT_MS),
28321
+ redirect: "follow"
28322
+ });
28323
+ } catch (error51) {
28324
+ const latencyMs2 = Math.round(performance.now() - started);
28325
+ if (isTimeout(error51)) {
28326
+ return failure(PROBE_CODES.timeout, `请求超时(${TIMEOUT_MS / 1000} 秒)`, {
28327
+ latencyMs: latencyMs2,
28328
+ requestUrl: url2.toString()
28329
+ });
28330
+ }
28331
+ return failure(PROBE_CODES.networkError, reason(error51), {
28332
+ latencyMs: latencyMs2,
28333
+ requestUrl: url2.toString()
28334
+ });
28335
+ }
28336
+ const latencyMs = Math.round(performance.now() - started);
28337
+ const shared = { status: response.status, latencyMs, requestUrl: url2.toString() };
28338
+ if (response.status === 401 || response.status === 403) {
28339
+ return failure(PROBE_CODES.unauthorized, `端点可达但拒绝了凭据(HTTP ${response.status}),请检查 API Key`, { ...shared, params: { status: response.status } });
28340
+ }
28341
+ if (!response.ok) {
28342
+ return failure(PROBE_CODES.httpError, `端点返回 HTTP ${response.status}`, {
28343
+ ...shared,
28344
+ params: { status: response.status }
28345
+ });
28346
+ }
28347
+ const text = await response.text();
28348
+ if (text.length > MAX_BODY_BYTES) {
28349
+ return failure(PROBE_CODES.invalidResponse, "响应体过大,不是模型目录", shared);
28350
+ }
28351
+ const models = extractModels(text);
28352
+ if (models === null) {
28353
+ return failure(PROBE_CODES.invalidResponse, "响应不是已知的模型目录格式", shared);
28354
+ }
28355
+ return { ok: true, ...shared, models };
28356
+ }
28357
+ }
28358
+ ProbeService = __decorateElement(_init, 0, "ProbeService", _dec, ProbeService);
28359
+ __runInitializers(_init, 1, ProbeService);
28360
+ __decoratorMetadata(_init, ProbeService);
28361
+ let _ProbeService = ProbeService;
28362
+ function joinUrl(base, suffix) {
28363
+ const next = new URL(base.toString());
28364
+ next.pathname = `${next.pathname.replace(/\/+$/, "")}/${suffix}`;
28365
+ return next;
28366
+ }
28367
+ function failure(code, message, extra = {}) {
28368
+ return { ok: false, code, message, ...extra };
28369
+ }
28370
+ function isTimeout(error51) {
28371
+ const name = error51?.name;
28372
+ return name === "TimeoutError" || name === "AbortError";
28373
+ }
28374
+ function reason(error51) {
28375
+ const text = error51 instanceof Error ? error51.message : String(error51);
28376
+ return `请求失败:${text}`;
28377
+ }
28378
+ function extractModels(body) {
28379
+ let parsed;
28380
+ try {
28381
+ parsed = JSON.parse(body);
28382
+ } catch {
28383
+ return null;
28384
+ }
28385
+ const list = Array.isArray(parsed) ? parsed : isRecord3(parsed) && Array.isArray(parsed.data) ? parsed.data : isRecord3(parsed) && Array.isArray(parsed.models) ? parsed.models : null;
28386
+ if (list === null) {
28387
+ return null;
28388
+ }
28389
+ const seen = new Set;
28390
+ const models = [];
28391
+ for (const entry of list) {
28392
+ const id = typeof entry === "string" ? entry.trim() : isRecord3(entry) ? firstString(entry, ["id", "name", "model"]) : "";
28393
+ if (id && !seen.has(id)) {
28394
+ seen.add(id);
28395
+ models.push(id);
28396
+ if (models.length >= MAX_MODELS) {
28397
+ break;
28398
+ }
28399
+ }
28400
+ }
28401
+ return models;
28402
+ }
28403
+ function isRecord3(value) {
28404
+ return typeof value === "object" && value !== null;
28405
+ }
28406
+ function firstString(record2, keys) {
28407
+ for (const key of keys) {
28408
+ const value = record2[key];
28409
+ if (typeof value === "string" && value.trim()) {
28410
+ return value.trim();
28411
+ }
28412
+ }
28413
+ return "";
28414
+ }
28415
+
28244
28416
  // src/services/doctor.ts
28245
28417
  var IDoctorService = createDecorator("doctorService");
28246
28418
  var BIN_NAMES = {
@@ -28250,7 +28422,7 @@ var BIN_NAMES = {
28250
28422
  pi: "pi"
28251
28423
  };
28252
28424
  var _dec = [
28253
- inject(IEnvironmentService, IFileService, IHarnessRegistry, IAdapterRegistry, IActivationService, IDriftService)
28425
+ inject(IEnvironmentService, IFileService, IHarnessRegistry, IAdapterRegistry, IActivationService, IDriftService, IProfileService, IProbeService)
28254
28426
  ];
28255
28427
  var _init = __decoratorStart(undefined);
28256
28428
 
@@ -28261,24 +28433,28 @@ class DoctorService {
28261
28433
  adapters;
28262
28434
  activation;
28263
28435
  drift;
28264
- constructor(environment, files, harnesses, adapters, activation, drift) {
28436
+ profiles;
28437
+ probe;
28438
+ constructor(environment, files, harnesses, adapters, activation, drift, profiles, probe) {
28265
28439
  this.environment = environment;
28266
28440
  this.files = files;
28267
28441
  this.harnesses = harnesses;
28268
28442
  this.adapters = adapters;
28269
28443
  this.activation = activation;
28270
28444
  this.drift = drift;
28445
+ this.profiles = profiles;
28446
+ this.probe = probe;
28271
28447
  }
28272
28448
  async run(options = {}) {
28273
28449
  const harnessIds = options.harness ? [this.harnesses.require(options.harness)] : this.harnesses.list().map((item) => item.id);
28274
- const items = [];
28275
- for (const harness of harnessIds) {
28276
- items.push({ harness, checks: this.harnessChecks(harness, options.probe === true) });
28277
- }
28450
+ const items = await Promise.all(harnessIds.map(async (harness) => ({
28451
+ harness,
28452
+ checks: await this.harnessChecks(harness, options.probe === true)
28453
+ })));
28278
28454
  const update = await checkForUpdate();
28279
28455
  return { items, updatedAvailable: update.updateAvailable };
28280
28456
  }
28281
- harnessChecks(harness, probe) {
28457
+ async harnessChecks(harness, probe) {
28282
28458
  const checks3 = [];
28283
28459
  const bin = BIN_NAMES[harness];
28284
28460
  if (bin === undefined) {
@@ -28344,11 +28520,36 @@ class DoctorService {
28344
28520
  checks3.push(ok(`${harness}.drift`, "live 文件与激活配置一致", DOCTOR_CODES.driftInSync));
28345
28521
  }
28346
28522
  if (probe) {
28347
- const active = this.activation.getActive(harness);
28348
- checks3.push(unknown2(`${harness}.probe`, "连通性探测在 MVP 中默认关闭,未发起网络请求", DOCTOR_CODES.probeDisabled, undefined, { baseUrl: active?.baseUrl ?? null, enabled: false }));
28523
+ checks3.push(await this.probeCheck(harness));
28349
28524
  }
28350
28525
  return checks3;
28351
28526
  }
28527
+ async probeCheck(harness) {
28528
+ const active = this.activation.getActive(harness);
28529
+ if (!active) {
28530
+ return unknown2(`${harness}.probe`, "未激活任何配置,跳过连通性探测", DOCTOR_CODES.probeNoProfile, undefined, { probed: false });
28531
+ }
28532
+ if (active.official === true) {
28533
+ return unknown2(`${harness}.probe`, `${HARNESS_LABELS[harness]} 处于官方账号登录状态,无自定义端点可探测`, DOCTOR_CODES.probeOfficialLogin, undefined, { probed: false });
28534
+ }
28535
+ const decrypted = this.profiles.decrypt(harness, active.name);
28536
+ if (!decrypted.baseUrl || !decrypted.apiKey) {
28537
+ return warn(`${harness}.probe`, `配置 ${active.name} 缺少 Base URL 或 API Key,无法探测`, DOCTOR_CODES.probeMissingCredential, { profile: active.name }, { probed: false, baseUrl: decrypted.baseUrl || null });
28538
+ }
28539
+ const result = await this.probe.probe(decrypted);
28540
+ const detail = {
28541
+ probed: true,
28542
+ baseUrl: result.requestUrl ?? decrypted.baseUrl,
28543
+ status: result.status ?? null,
28544
+ latencyMs: result.latencyMs ?? null,
28545
+ modelCount: result.models?.length ?? null,
28546
+ reason: result.code ?? null
28547
+ };
28548
+ if (result.ok) {
28549
+ return ok(`${harness}.probe`, `端点可达(${result.latencyMs ?? "?"}ms,${result.models?.length ?? 0} 个模型)`, DOCTOR_CODES.probeOk, { profile: active.name }, detail);
28550
+ }
28551
+ return error51(`${harness}.probe`, `连通性探测失败:${result.message ?? "未知原因"}`, DOCTOR_CODES.probeFailed, { profile: active.name, reason: result.code ?? PROBE_CODES.networkError }, detail);
28552
+ }
28352
28553
  commandExists(bin) {
28353
28554
  try {
28354
28555
  const result = spawnSync("/bin/sh", ["-c", `command -v ${bin}`], {
@@ -28443,6 +28644,7 @@ function createHarnessRoutes(services) {
28443
28644
  const environment = services.get(IEnvironmentService);
28444
28645
  const files = services.get(IFileService);
28445
28646
  const log = services.get(ILogService);
28647
+ const probe = services.get(IProbeService);
28446
28648
  function summary(id) {
28447
28649
  const adapter = adapters.get(id);
28448
28650
  return {
@@ -28529,6 +28731,13 @@ function createHarnessRoutes(services) {
28529
28731
  const name = decodeURIComponent(c.req.param("name"));
28530
28732
  return c.json({ targets: activation.preview(harnessId, name) });
28531
28733
  });
28734
+ app.post("/:harnessId/profiles/:name/probe", async (c) => {
28735
+ const harnessId = harnesses.require(c.req.param("harnessId"));
28736
+ const name = decodeURIComponent(c.req.param("name"));
28737
+ parseWith(probeStoredRequestSchema, await c.req.json().catch(() => ({})));
28738
+ const decrypted = profiles.decrypt(harnessId, name);
28739
+ return c.json({ result: await probe.probe(decrypted) });
28740
+ });
28532
28741
  app.post("/:harnessId/profiles/:name/activate", (c) => {
28533
28742
  const harnessId = harnesses.require(c.req.param("harnessId"));
28534
28743
  const name = decodeURIComponent(c.req.param("name"));
@@ -28567,6 +28776,36 @@ function createOperationRoutes(services) {
28567
28776
  return app;
28568
28777
  }
28569
28778
 
28779
+ // src/http/routes/probe.ts
28780
+ function createProbeRoutes(services) {
28781
+ const app = new Hono2;
28782
+ const vault = services.get(IVaultService);
28783
+ const probe = services.get(IProbeService);
28784
+ app.post("/", async (c) => {
28785
+ const body = await readJsonBody(c, probeRequestSchema);
28786
+ const apiKey = draftKey(vault, body);
28787
+ if (!apiKey) {
28788
+ return c.json({
28789
+ result: {
28790
+ ok: false,
28791
+ code: PROBE_CODES.missingApiKey,
28792
+ message: "未提供 API Key,也无法从凭据库解析,无法测试"
28793
+ }
28794
+ });
28795
+ }
28796
+ return c.json({
28797
+ result: await probe.probe({ baseUrl: body.baseUrl, apiKey })
28798
+ });
28799
+ });
28800
+ return app;
28801
+ }
28802
+ function draftKey(vault, body) {
28803
+ if (body.providerId?.trim()) {
28804
+ return vault.decrypt(body.providerId.trim());
28805
+ }
28806
+ return body.apiKey?.trim() ?? "";
28807
+ }
28808
+
28570
28809
  // src/http/routes/providers.ts
28571
28810
  function createProviderRoutes(services) {
28572
28811
  const app = new Hono2;
@@ -28574,6 +28813,7 @@ function createProviderRoutes(services) {
28574
28813
  const profiles = services.get(IProfileService);
28575
28814
  const activation = services.get(IActivationService);
28576
28815
  const log = services.get(ILogService);
28816
+ const probe = services.get(IProbeService);
28577
28817
  app.get("/", (c) => c.json({ items: vault.list() }));
28578
28818
  app.get("/:id", (c) => c.json(vault.get(decodeURIComponent(c.req.param("id")))));
28579
28819
  app.post("/", async (c) => {
@@ -28615,12 +28855,37 @@ function createProviderRoutes(services) {
28615
28855
  }
28616
28856
  return c.json({ provider, warnings });
28617
28857
  });
28858
+ app.post("/:id/probe", async (c) => {
28859
+ const id = decodeURIComponent(c.req.param("id"));
28860
+ const body = parseWith(probeStoredRequestSchema, await c.req.json().catch(() => ({})));
28861
+ const apiKey = vault.decrypt(id);
28862
+ const baseUrl = resolveEndpointBaseUrl(vault.get(id), body.endpoint);
28863
+ if (!baseUrl) {
28864
+ return c.json({
28865
+ result: {
28866
+ ok: false,
28867
+ code: PROBE_CODES.missingBaseUrl,
28868
+ message: `provider ${id} 未配置任何 endpoint,无法测试`
28869
+ }
28870
+ });
28871
+ }
28872
+ return c.json({ result: await probe.probe({ baseUrl, apiKey }) });
28873
+ });
28618
28874
  app.delete("/:id", (c) => {
28619
28875
  vault.remove(decodeURIComponent(c.req.param("id")));
28620
28876
  return c.json({ ok: true });
28621
28877
  });
28622
28878
  return app;
28623
28879
  }
28880
+ function resolveEndpointBaseUrl(entry, endpointKey) {
28881
+ if (endpointKey?.trim()) {
28882
+ const named = entry.endpoints.find((candidate) => candidate.key === endpointKey.trim());
28883
+ if (named) {
28884
+ return named.baseUrl;
28885
+ }
28886
+ }
28887
+ return entry.endpoints[0]?.baseUrl ?? null;
28888
+ }
28624
28889
 
28625
28890
  // src/services/scan.ts
28626
28891
  var IScanService = createDecorator("scanService");
@@ -29174,11 +29439,11 @@ class TransferService {
29174
29439
  }
29175
29440
  activeRestored++;
29176
29441
  } catch (error52) {
29177
- const reason = error52.message;
29442
+ const reason2 = error52.message;
29178
29443
  warnings.push({
29179
- message: `${active.harness}/${active.name} 未能恢复激活状态:${reason}`,
29444
+ message: `${active.harness}/${active.name} 未能恢复激活状态:${reason2}`,
29180
29445
  code: WARNING_CODES.transferActiveRestoreFailed,
29181
- params: { harness: active.harness, profile: active.name, reason }
29446
+ params: { harness: active.harness, profile: active.name, reason: reason2 }
29182
29447
  });
29183
29448
  }
29184
29449
  }
@@ -29687,11 +29952,11 @@ class UserSyncService {
29687
29952
  scope: `${harness}/${name}`
29688
29953
  })));
29689
29954
  } catch (error52) {
29690
- const reason = error52 instanceof Error ? error52.message : String(error52);
29955
+ const reason2 = error52 instanceof Error ? error52.message : String(error52);
29691
29956
  warnings.push({
29692
- message: `${harness}/${name} 已更新配置库,但自动重新激活失败:${reason}`,
29957
+ message: `${harness}/${name} 已更新配置库,但自动重新激活失败:${reason2}`,
29693
29958
  code: WARNING_CODES.syncReapplyFailed,
29694
- params: { harness, profile: name, reason }
29959
+ params: { harness, profile: name, reason: reason2 }
29695
29960
  });
29696
29961
  }
29697
29962
  }
@@ -29863,6 +30128,9 @@ function createApp(services) {
29863
30128
  api2.use("/providers/*", createAuthGuard(services));
29864
30129
  api2.use("/providers", createAuthGuard(services));
29865
30130
  api2.route("/providers", createProviderRoutes(services));
30131
+ api2.use("/probe/*", createAuthGuard(services));
30132
+ api2.use("/probe", createAuthGuard(services));
30133
+ api2.route("/probe", createProbeRoutes(services));
29866
30134
  api2.use("/doctor/*", createAuthGuard(services));
29867
30135
  api2.use("/doctor", createAuthGuard(services));
29868
30136
  api2.route("/doctor", createDoctorRoutes(services));
@@ -29963,6 +30231,7 @@ function createServices() {
29963
30231
  collection.set(ILiveWriteService, new SyncDescriptor(LiveWriteService));
29964
30232
  collection.set(IVaultService, new SyncDescriptor(VaultService));
29965
30233
  collection.set(IProfileService, new SyncDescriptor(ProfileService));
30234
+ collection.set(IProbeService, new SyncDescriptor(ProbeService));
29966
30235
  collection.set(IActivationService, new SyncDescriptor(ActivationService));
29967
30236
  collection.set(ITransferService, new SyncDescriptor(TransferService));
29968
30237
  collection.set(IDriftService, new SyncDescriptor(DriftService));
@@ -30518,7 +30787,7 @@ function cliUsage() {
30518
30787
  " create <harness> <name> create a profile from command-line options",
30519
30788
  " delete <harness> <profile> delete an inactive profile (confirmation required)",
30520
30789
  " providers list Provider Vault entries",
30521
- " doctor [--probe] [--strict] run diagnostics; probe reports endpoint metadata only",
30790
+ " doctor [--probe] [--strict] run diagnostics; probe tests the active endpoint",
30522
30791
  " plan <harness> <profile> show the exact content activation would write",
30523
30792
  " activate <harness> <profile> activate a profile (add --yes to skip the prompt)",
30524
30793
  " official <harness> return a harness to its built-in login",
@@ -30534,7 +30803,7 @@ function cliUsage() {
30534
30803
  "options:",
30535
30804
  " --json, -j machine-readable JSON output",
30536
30805
  " --yes, -y skip confirmation for activate, official and delete",
30537
- " --probe show connectivity endpoint metadata (no network request yet)",
30806
+ " --probe test the active profile's endpoint (makes a real request)",
30538
30807
  " --harness H limit doctor to one harness",
30539
30808
  " --strict make doctor exit 1 when any check has error status",
30540
30809
  " --user USER run an API-backed command for this Unix user",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seaveyon/harness-switch",
3
- "version": "0.19.0",
3
+ "version": "0.20.1",
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",