@seaveyon/harness-switch 0.6.0 → 0.6.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
|
@@ -189,11 +189,12 @@ bun run dev:server
|
|
|
189
189
|
bun run dev:web
|
|
190
190
|
```
|
|
191
191
|
|
|
192
|
-
|
|
192
|
+
Quality gates are three-layered: **tsc** for type checking, **Oxlint** for diagnostics, **Biome** for format and import organization. `bun run check` runs all three.
|
|
193
193
|
|
|
194
194
|
```bash
|
|
195
195
|
bun run lint
|
|
196
196
|
bun run lint:fix
|
|
197
|
+
bun run typecheck
|
|
197
198
|
bun run format
|
|
198
199
|
bun run format:check
|
|
199
200
|
bun run check
|
|
@@ -217,7 +218,7 @@ The web dev server listens on `http://127.0.0.1:5173` and proxies `/api` to the
|
|
|
217
218
|
|
|
218
219
|
## Release
|
|
219
220
|
|
|
220
|
-
Pushes to `main` run [semantic-release](https://semantic-release.gitbook.io/). It reads conventional commits, bumps `@seaveyon/harness-switch`, tags `v*`, and publishes to npm via Trusted Publishing.
|
|
221
|
+
Pushes to `main` run [semantic-release](https://semantic-release.gitbook.io/). It reads conventional commits, bumps `@seaveyon/harness-switch`, tags `v*`, and publishes to npm via Trusted Publishing. The tarball is published to the npm registry **before** the `v*` tag and GitHub release are created, so a failed registry publish never leaves a tag without a matching npm version, and a re-run skips versions that are already on the registry.
|
|
221
222
|
|
|
222
223
|
| Commit | Version bump |
|
|
223
224
|
|---|---|
|
package/dist/harness-switch.js
CHANGED
|
@@ -9244,7 +9244,7 @@ import {
|
|
|
9244
9244
|
statSync,
|
|
9245
9245
|
writeFileSync
|
|
9246
9246
|
} from "fs";
|
|
9247
|
-
import { dirname as dirname2 } from "path";
|
|
9247
|
+
import { basename, dirname as dirname2 } from "path";
|
|
9248
9248
|
var IFileService = createDecorator("fileService");
|
|
9249
9249
|
var _dec = [
|
|
9250
9250
|
inject(IEnvironmentService)
|
|
@@ -9265,8 +9265,33 @@ class FileService {
|
|
|
9265
9265
|
readOptional(file) {
|
|
9266
9266
|
try {
|
|
9267
9267
|
return readFileSync(file, "utf8");
|
|
9268
|
+
} catch (error) {
|
|
9269
|
+
if (error.code === "ENOENT") {
|
|
9270
|
+
return;
|
|
9271
|
+
}
|
|
9272
|
+
throw error;
|
|
9273
|
+
}
|
|
9274
|
+
}
|
|
9275
|
+
readJsonStrict(file, fallback) {
|
|
9276
|
+
if (!existsSync2(file)) {
|
|
9277
|
+
return fallback;
|
|
9278
|
+
}
|
|
9279
|
+
let text;
|
|
9280
|
+
try {
|
|
9281
|
+
text = this.readText(file);
|
|
9268
9282
|
} catch {
|
|
9269
|
-
|
|
9283
|
+
throw new HttpError(500, `\u6570\u636E\u5B58\u50A8\u4E0D\u53EF\u8BFB\uFF1A${file}`);
|
|
9284
|
+
}
|
|
9285
|
+
try {
|
|
9286
|
+
return JSON.parse(text);
|
|
9287
|
+
} catch {
|
|
9288
|
+
const quarantine = `${file}.corrupt-${Date.now()}`;
|
|
9289
|
+
try {
|
|
9290
|
+
renameSync(file, quarantine);
|
|
9291
|
+
} catch {
|
|
9292
|
+
throw new HttpError(500, `\u6570\u636E\u5B58\u50A8\u635F\u574F\u4E14\u65E0\u6CD5\u9694\u79BB\uFF1A${file}`);
|
|
9293
|
+
}
|
|
9294
|
+
throw new HttpError(500, `\u6570\u636E\u5B58\u50A8\u5DF2\u635F\u574F\uFF0C\u539F\u6587\u4EF6\u5DF2\u9694\u79BB\u4E3A ${basename(quarantine)}\uFF0C\u8BF7\u4ECE\u5907\u4EFD\u6062\u590D\u540E\u518D\u7EE7\u7EED`);
|
|
9270
9295
|
}
|
|
9271
9296
|
}
|
|
9272
9297
|
writeSecure(file, text) {
|
|
@@ -9586,7 +9611,7 @@ function createAuthRoutes(services) {
|
|
|
9586
9611
|
}
|
|
9587
9612
|
|
|
9588
9613
|
// src/services/backup.ts
|
|
9589
|
-
import { basename, join as join3 } from "path";
|
|
9614
|
+
import { basename as basename2, join as join3 } from "path";
|
|
9590
9615
|
var IBackupService = createDecorator("backupService");
|
|
9591
9616
|
var MANIFEST = "manifest.json";
|
|
9592
9617
|
var _dec = [
|
|
@@ -9612,7 +9637,7 @@ class BackupService {
|
|
|
9612
9637
|
if (snapshot.content === undefined) {
|
|
9613
9638
|
return { path: snapshot.path, existed: false };
|
|
9614
9639
|
}
|
|
9615
|
-
const name = `${index}-${
|
|
9640
|
+
const name = `${index}-${basename2(snapshot.path)}`;
|
|
9616
9641
|
this.files.writeSecure(join3(dir, name), snapshot.content);
|
|
9617
9642
|
return { path: snapshot.path, existed: true, stored: name };
|
|
9618
9643
|
});
|
|
@@ -12043,7 +12068,7 @@ class ProfileService {
|
|
|
12043
12068
|
this.files.writeJson(this.environment.files.profiles, store);
|
|
12044
12069
|
}
|
|
12045
12070
|
read() {
|
|
12046
|
-
return this.files.
|
|
12071
|
+
return this.files.readJsonStrict(this.environment.files.profiles, {});
|
|
12047
12072
|
}
|
|
12048
12073
|
toPublic(harness, name, profile) {
|
|
12049
12074
|
return {
|
|
@@ -12216,14 +12241,10 @@ class ActivationService {
|
|
|
12216
12241
|
if (!adapter.revoke) {
|
|
12217
12242
|
return;
|
|
12218
12243
|
}
|
|
12219
|
-
|
|
12220
|
-
|
|
12221
|
-
|
|
12222
|
-
|
|
12223
|
-
this.liveWrite.apply(harness, name, this.toWrites(targets, rendered));
|
|
12224
|
-
} catch (error) {
|
|
12225
|
-
this.log.error(`failed to revoke ${harness}/${name} from live config`, error);
|
|
12226
|
-
}
|
|
12244
|
+
const profile = this.profiles.decrypt(harness, name);
|
|
12245
|
+
const targets = adapter.targets();
|
|
12246
|
+
const rendered = adapter.revoke(profile, this.readCurrent(targets));
|
|
12247
|
+
this.liveWrite.apply(harness, name, this.toWrites(targets, rendered));
|
|
12227
12248
|
}
|
|
12228
12249
|
backfillPrevious(adapter, previous, nextName, warnings) {
|
|
12229
12250
|
if (!adapter.backfill || !previous || previous.official || previous.name === nextName) {
|
|
@@ -12275,7 +12296,7 @@ class ActivationService {
|
|
|
12275
12296
|
return current;
|
|
12276
12297
|
}
|
|
12277
12298
|
read() {
|
|
12278
|
-
return this.files.
|
|
12299
|
+
return this.files.readJsonStrict(this.environment.files.active, {});
|
|
12279
12300
|
}
|
|
12280
12301
|
writeEnv(active) {
|
|
12281
12302
|
const lines = [
|
|
@@ -12334,6 +12355,8 @@ function createHarnessRoutes(services) {
|
|
|
12334
12355
|
const activation = services.get(IActivationService);
|
|
12335
12356
|
const adapters = services.get(IAdapterRegistry);
|
|
12336
12357
|
const environment = services.get(IEnvironmentService);
|
|
12358
|
+
const files = services.get(IFileService);
|
|
12359
|
+
const log = services.get(ILogService);
|
|
12337
12360
|
function summary(id) {
|
|
12338
12361
|
const adapter = adapters.get(id);
|
|
12339
12362
|
return {
|
|
@@ -12372,18 +12395,36 @@ function createHarnessRoutes(services) {
|
|
|
12372
12395
|
const harnessId = harnesses.require(c.req.param("harnessId"));
|
|
12373
12396
|
const name = decodeURIComponent(c.req.param("name"));
|
|
12374
12397
|
const body = await readBody(c.req.json.bind(c.req));
|
|
12375
|
-
const
|
|
12376
|
-
|
|
12377
|
-
|
|
12378
|
-
|
|
12379
|
-
|
|
12380
|
-
|
|
12381
|
-
|
|
12382
|
-
|
|
12383
|
-
|
|
12384
|
-
|
|
12385
|
-
|
|
12386
|
-
|
|
12398
|
+
const wasActive = activation.getActive(harnessId)?.name === name;
|
|
12399
|
+
const snapshot = files.readOptional(environment.files.profiles);
|
|
12400
|
+
let persisted = false;
|
|
12401
|
+
try {
|
|
12402
|
+
const profile = profiles.upsert(harnessId, {
|
|
12403
|
+
name: String(body.name ?? name),
|
|
12404
|
+
sourceName: name,
|
|
12405
|
+
baseUrl: body.baseUrl,
|
|
12406
|
+
apiKey: body.apiKey,
|
|
12407
|
+
model: body.model,
|
|
12408
|
+
notes: body.notes,
|
|
12409
|
+
extras: body.extras,
|
|
12410
|
+
overrides: body.overrides
|
|
12411
|
+
}, false);
|
|
12412
|
+
persisted = true;
|
|
12413
|
+
activation.reconcileProfileUpdate(harnessId, name, profile.name);
|
|
12414
|
+
return c.json(profile);
|
|
12415
|
+
} catch (error) {
|
|
12416
|
+
if (persisted) {
|
|
12417
|
+
restoreProfileStore(files, environment.files.profiles, snapshot);
|
|
12418
|
+
if (wasActive) {
|
|
12419
|
+
try {
|
|
12420
|
+
activation.activate(harnessId, name);
|
|
12421
|
+
} catch (rollbackError) {
|
|
12422
|
+
log.error(`edit rollback: failed to re-activate ${harnessId}/${name}`, rollbackError);
|
|
12423
|
+
}
|
|
12424
|
+
}
|
|
12425
|
+
}
|
|
12426
|
+
throw error;
|
|
12427
|
+
}
|
|
12387
12428
|
});
|
|
12388
12429
|
app.delete("/:harnessId/profiles/:name", (c) => {
|
|
12389
12430
|
const harnessId = harnesses.require(c.req.param("harnessId"));
|
|
@@ -12415,6 +12456,13 @@ async function readBody(read) {
|
|
|
12415
12456
|
throw new HttpError(400, "invalid json");
|
|
12416
12457
|
});
|
|
12417
12458
|
}
|
|
12459
|
+
function restoreProfileStore(files, path, snapshot) {
|
|
12460
|
+
if (snapshot === undefined) {
|
|
12461
|
+
files.remove(path);
|
|
12462
|
+
return;
|
|
12463
|
+
}
|
|
12464
|
+
files.writeSecure(path, snapshot);
|
|
12465
|
+
}
|
|
12418
12466
|
|
|
12419
12467
|
// src/services/transfer.ts
|
|
12420
12468
|
import { createCipheriv as createCipheriv2, createDecipheriv as createDecipheriv2, randomBytes as randomBytes4, scryptSync } from "crypto";
|
|
@@ -12580,7 +12628,7 @@ class TransferService {
|
|
|
12580
12628
|
};
|
|
12581
12629
|
}
|
|
12582
12630
|
readStore() {
|
|
12583
|
-
return this.files.
|
|
12631
|
+
return this.files.readJsonStrict(this.environment.files.profiles, {});
|
|
12584
12632
|
}
|
|
12585
12633
|
assertPassphrase(passphrase) {
|
|
12586
12634
|
if (passphrase.length < 8) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seaveyon/harness-switch",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.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",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(self.webpackChunk_seaveyon_harness_switch_web=self.webpackChunk_seaveyon_harness_switch_web||[]).push([["4952"],{1419(e,n,l){l.r(n),l.d(n,{PierreFileDiff:()=>s});var t=l(1085),o=l(8437),r={themeType:"dark",theme:"pierre-dark",diffStyle:"unified",overflow:"wrap",expandUnchanged:!0,stickyHeader:!0};function s(e){var n=e.file,l=n.path,s=null===n.currentContent?null:{name:l,contents:n.currentContent},i=null===n.content?null:{name:l,contents:n.content};return null
|
|
1
|
+
"use strict";(self.webpackChunk_seaveyon_harness_switch_web=self.webpackChunk_seaveyon_harness_switch_web||[]).push([["4952"],{1419(e,n,l){l.r(n),l.d(n,{PierreFileDiff:()=>s});var t=l(1085),o=l(8437),r={themeType:"dark",theme:"pierre-dark",diffStyle:"unified",overflow:"wrap",expandUnchanged:!0,stickyHeader:!0};function s(e){var n=e.file,l=n.path,s=null===n.currentContent?null:{name:l,contents:n.currentContent},i=null===n.content?null:{name:l,contents:n.content};return null!==s&&null!==i?(0,t.jsx)(o.T,{disableWorkerPool:!0,oldFile:s,newFile:i,options:r}):null!==s?(0,t.jsx)(o.T,{disableWorkerPool:!0,oldFile:s,newFile:null,options:r}):null!==i?(0,t.jsx)(o.T,{disableWorkerPool:!0,oldFile:null,newFile:i,options:r}):(0,t.jsx)("p",{className:"px-3 py-4 text-sm text-muted-foreground",children:"两侧都不存在"})}}}]);
|