@seaveyon/harness-switch 0.15.0 → 0.16.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 +13 -9
- package/dist/harness-switch.js +18 -7
- package/package.json +1 -1
- package/public/assets/main.1443ad7f.js +1 -0
- package/public/index.html +1 -1
- package/public/assets/main.0229c9a5.js +0 -1
package/README.md
CHANGED
|
@@ -33,6 +33,10 @@ ssh -N -L 8787:127.0.0.1:8787 user@your-server
|
|
|
33
33
|
|
|
34
34
|
Then open <http://127.0.0.1:8787> in your local browser.
|
|
35
35
|
|
|
36
|
+
### Interface language
|
|
37
|
+
|
|
38
|
+
The web UI supports English and Simplified Chinese. Use the language button in the login page or dashboard header to switch languages. Chinese remains the default for existing behavior; your selection is stored in the browser and is reused on later visits. The setting affects only the web interface—it does not change profile data or generated configuration files.
|
|
39
|
+
|
|
36
40
|
## Configuration
|
|
37
41
|
|
|
38
42
|
Create one or more profiles per harness in the web UI. A profile holds a display name, API Base URL, API key, model, notes, and whatever extra fields that harness needs. Select **Activate** to make a profile current.
|
|
@@ -70,7 +74,7 @@ Two known limitations:
|
|
|
70
74
|
|
|
71
75
|
### Advanced: taking over the raw file
|
|
72
76
|
|
|
73
|
-
Any field the form does not expose can be set by editing the raw file content in the profile's
|
|
77
|
+
Any field the form does not expose can be set by editing the raw file content in the profile's **Advanced: raw configuration** section. Once edited, that file is generated from your text instead of the form fields until you select **Restore automatic generation**. Content that cannot be parsed back is rejected before it reaches disk.
|
|
74
78
|
|
|
75
79
|
### Backups and rollback
|
|
76
80
|
|
|
@@ -82,17 +86,17 @@ Switching away from a profile first reads the live file back into that profile's
|
|
|
82
86
|
|
|
83
87
|
### Moving every profile to another machine
|
|
84
88
|
|
|
85
|
-
Use
|
|
89
|
+
Use **Import / Export** in the top bar to create one `.hsw-backup` file containing every Harness profile, API key, raw-file override, and current activation choice. The bundle is encrypted with a migration password you choose, so it does not depend on the source machine's `aes-256-gcm.key`.
|
|
86
90
|
|
|
87
91
|
On the destination machine, select the bundle and enter the migration password. The UI shows profile counts and same-name conflicts before it writes anything. Import keeps destination profiles by default; overwriting is an explicit choice. Restoring the exported activation state is optional.
|
|
88
92
|
|
|
89
|
-
A Codex official-login cache (`$CODEX_HOME/auth.json`) is **excluded by default**. When a valid cache is available, you may explicitly include it in the encrypted bundle
|
|
93
|
+
A Codex official-login cache (`$CODEX_HOME/auth.json`) is **excluded by default**. When a valid cache is available, you may explicitly include it in the encrypted bundle. Import offers the separate migration choice only when the bundled and destination JSON values differ. This carries a reusable Codex/ChatGPT login session: share such a bundle only with a trusted recipient, and expect upstream expiry or revocation to still require a fresh `codex login`. An existing destination cache is backed up before replacement; copied caches are written as the destination user with mode `0600`.
|
|
90
94
|
|
|
91
95
|
Keep the migration password separately from the bundle. It cannot be recovered from the export file.
|
|
92
96
|
|
|
93
97
|
### Provider Vault: shared credentials
|
|
94
98
|
|
|
95
|
-
The
|
|
99
|
+
The **Provider Vault** stores an API key once under a named entry with one or more named endpoints (each a base URL), encrypted with the same AES-256-GCM key that protects `profiles.json`. A profile can reference a vault entry instead of carrying its own key:
|
|
96
100
|
|
|
97
101
|
- The vault owns the credential; the profile keeps a materialized cache so existing readers (transfer export, `active.json`, `env.sh`) keep working unchanged.
|
|
98
102
|
- Rotating the vault key or an endpoint re-applies every **active** profile that references the entry, so the live files follow immediately. Failures are reported as warnings.
|
|
@@ -101,7 +105,7 @@ The **凭据库 (Provider Vault)** stores an API key once under a named entry wi
|
|
|
101
105
|
|
|
102
106
|
### Configuration drift
|
|
103
107
|
|
|
104
|
-
The dashboard's
|
|
108
|
+
The dashboard's **Configuration drift** panel 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:
|
|
105
109
|
|
|
106
110
|
- `in-sync` — disk matches what the profile would write,
|
|
107
111
|
- `drifted` — disk differs from what the profile would write,
|
|
@@ -111,12 +115,12 @@ The dashboard's **配置漂移** panel compares what the active profile would re
|
|
|
111
115
|
|
|
112
116
|
Two repair actions are offered per harness:
|
|
113
117
|
|
|
114
|
-
-
|
|
115
|
-
-
|
|
118
|
+
- **Re-apply** rewrites the live files from the active profile, with the usual backup-before-write and all-or-nothing rollback.
|
|
119
|
+
- **Adopt live configuration** reads the live files back into the profile record (same path as the pre-switch backfill). It refuses with `409` when the profile has manual raw overrides, and never adopts content the tool itself could not parse.
|
|
116
120
|
|
|
117
121
|
### Diagnostics (Doctor)
|
|
118
122
|
|
|
119
|
-
The
|
|
123
|
+
The **Diagnostics (Doctor)** panel runs read-only checks per harness: whether the tool's CLI is on `PATH` (`install`), whether each target's config directory exists (`configDir`), 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`).
|
|
120
124
|
|
|
121
125
|
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.
|
|
122
126
|
|
|
@@ -126,7 +130,7 @@ The dashboard header can switch between local login users such as `root` and `al
|
|
|
126
130
|
|
|
127
131
|
“Sync user config” performs a one-time copy of another user's profiles and referenced Provider Vault credentials into the selected user. Secrets are decrypted only on the server and re-encrypted with the destination user's local key. Active state, backups and native config files are not copied. Same-name profiles are skipped by default and can be explicitly overwritten.
|
|
128
132
|
|
|
129
|
-
A source user's Codex official-login cache (`auth.json`) is the sole optional exception
|
|
133
|
+
A source user's Codex official-login cache (`auth.json`) is the sole optional exception. The migration choice appears only when the source and destination JSON values differ; it remains unchecked by default and requires an irreversible confirmation that identifies both users. Choose it only when the destination user is allowed to use that login session. The previous destination cache is backed up, and the replacement is destination-owned with mode `0600`; source ownership and permissions are never copied.
|
|
130
134
|
|
|
131
135
|
Cross-user writes require access to the destination home. Managing both `root` and regular users therefore normally requires running harness-switch as root; newly created files and directories are assigned to the destination UID/GID. The Web password then grants control over every exposed user's configs, so keep the loopback bind and SSH tunnel. Use `HSW_USERS=root,alice` to restrict the manageable accounts.
|
|
132
136
|
|
package/dist/harness-switch.js
CHANGED
|
@@ -13625,6 +13625,7 @@ import { createCipheriv as createCipheriv2, createDecipheriv as createDecipheriv
|
|
|
13625
13625
|
// src/services/codex-login-cache.ts
|
|
13626
13626
|
import { lstatSync } from "fs";
|
|
13627
13627
|
import { join as join11 } from "path";
|
|
13628
|
+
import { isDeepStrictEqual } from "util";
|
|
13628
13629
|
var AUTH_FILE = "auth.json";
|
|
13629
13630
|
var MAX_CACHE_BYTES = 1024 * 1024;
|
|
13630
13631
|
var ICodexLoginCacheService = createDecorator("codexLoginCacheService");
|
|
@@ -13658,6 +13659,11 @@ class CodexLoginCacheService {
|
|
|
13658
13659
|
this.validate(content);
|
|
13659
13660
|
return content;
|
|
13660
13661
|
}
|
|
13662
|
+
matchesCurrent(content) {
|
|
13663
|
+
this.validate(content);
|
|
13664
|
+
const current = this.readOptional();
|
|
13665
|
+
return current !== undefined && isDeepStrictEqual(JSON.parse(content), JSON.parse(current));
|
|
13666
|
+
}
|
|
13661
13667
|
validate(content) {
|
|
13662
13668
|
if (Buffer.byteLength(content, "utf8") > MAX_CACHE_BYTES) {
|
|
13663
13669
|
throw new HttpError(400, "Codex \u767B\u5F55\u7F13\u5B58\u8FC7\u5927\uFF0C\u62D2\u7EDD\u8FC1\u79FB");
|
|
@@ -13812,6 +13818,7 @@ class TransferService {
|
|
|
13812
13818
|
const payload = this.decrypt(envelope, passphrase);
|
|
13813
13819
|
const existing = this.readStore();
|
|
13814
13820
|
const plan = this.planImport(payload, existing, conflictPolicy, restoreActive);
|
|
13821
|
+
const targetCodexLoginCacheExists = this.codexLoginCache.exists();
|
|
13815
13822
|
return {
|
|
13816
13823
|
exportedAt: payload.exportedAt,
|
|
13817
13824
|
profileCount: payload.profiles.length,
|
|
@@ -13826,7 +13833,8 @@ class TransferService {
|
|
|
13826
13833
|
codexActivationAuthEffect: plan.codexActivationAuthEffect,
|
|
13827
13834
|
codexLoginCache: {
|
|
13828
13835
|
available: payload.codexLoginCache !== undefined,
|
|
13829
|
-
targetExists:
|
|
13836
|
+
targetExists: targetCodexLoginCacheExists,
|
|
13837
|
+
migrationNeeded: payload.codexLoginCache !== undefined && !this.codexLoginCache.matchesCurrent(payload.codexLoginCache)
|
|
13830
13838
|
}
|
|
13831
13839
|
};
|
|
13832
13840
|
}
|
|
@@ -13836,7 +13844,7 @@ class TransferService {
|
|
|
13836
13844
|
if (migrateCodexLoginCache && payload.codexLoginCache === undefined) {
|
|
13837
13845
|
throw new HttpError(400, "\u5BFC\u51FA\u5305\u4E0D\u5305\u542B\u53EF\u8FC1\u79FB\u7684 Codex \u767B\u5F55\u7F13\u5B58");
|
|
13838
13846
|
}
|
|
13839
|
-
const cacheWrite = migrateCodexLoginCache ? [
|
|
13847
|
+
const cacheWrite = migrateCodexLoginCache && !this.codexLoginCache.matchesCurrent(payload.codexLoginCache) ? [
|
|
13840
13848
|
{
|
|
13841
13849
|
...this.codexLoginCache.prepareWrite(payload.codexLoginCache),
|
|
13842
13850
|
format: "json",
|
|
@@ -14142,7 +14150,7 @@ function createUpdateRoutes(_services) {
|
|
|
14142
14150
|
}
|
|
14143
14151
|
|
|
14144
14152
|
// src/services/user-sync.ts
|
|
14145
|
-
import { isDeepStrictEqual } from "util";
|
|
14153
|
+
import { isDeepStrictEqual as isDeepStrictEqual2 } from "util";
|
|
14146
14154
|
var IUserSyncService = createDecorator("userSyncService");
|
|
14147
14155
|
var _dec = [
|
|
14148
14156
|
inject(IEnvironmentService, IUserService, IFileService, ICryptoService, ICodexLoginCacheService, ILiveWriteService, IActivationService)
|
|
@@ -14171,6 +14179,8 @@ class UserSyncService {
|
|
|
14171
14179
|
const source = this.requireSource(sourceUsername, target);
|
|
14172
14180
|
const portable = this.readPortable(source);
|
|
14173
14181
|
const targetPortable = this.readPortable(target);
|
|
14182
|
+
const sourceCodexLoginCache = this.environment.runAsUser(source, () => this.codexLoginCache.readOptional());
|
|
14183
|
+
const targetCodexLoginCacheExists = this.codexLoginCache.exists();
|
|
14174
14184
|
const conflicts = [];
|
|
14175
14185
|
let profileCount = 0;
|
|
14176
14186
|
const referencedProviders = new Set;
|
|
@@ -14192,8 +14202,9 @@ class UserSyncService {
|
|
|
14192
14202
|
providerCount: referencedProviders.size,
|
|
14193
14203
|
conflicts,
|
|
14194
14204
|
codexLoginCache: {
|
|
14195
|
-
available:
|
|
14196
|
-
targetExists:
|
|
14205
|
+
available: sourceCodexLoginCache !== undefined,
|
|
14206
|
+
targetExists: targetCodexLoginCacheExists,
|
|
14207
|
+
migrationNeeded: sourceCodexLoginCache !== undefined && !this.codexLoginCache.matchesCurrent(sourceCodexLoginCache)
|
|
14197
14208
|
}
|
|
14198
14209
|
};
|
|
14199
14210
|
}
|
|
@@ -14211,7 +14222,7 @@ class UserSyncService {
|
|
|
14211
14222
|
if (migrateCodexLoginCache && cacheContent === undefined) {
|
|
14212
14223
|
throw new HttpError(400, "\u6765\u6E90\u7528\u6237\u6CA1\u6709\u53EF\u8FC1\u79FB\u7684 Codex \u767B\u5F55\u7F13\u5B58");
|
|
14213
14224
|
}
|
|
14214
|
-
const cacheWrite = cacheContent ? [
|
|
14225
|
+
const cacheWrite = cacheContent && !this.codexLoginCache.matchesCurrent(cacheContent) ? [
|
|
14215
14226
|
{
|
|
14216
14227
|
...this.codexLoginCache.prepareWrite(cacheContent),
|
|
14217
14228
|
format: "json",
|
|
@@ -14349,7 +14360,7 @@ class UserSyncService {
|
|
|
14349
14360
|
return this.files.readJsonStrict(this.environment.files.profiles, {});
|
|
14350
14361
|
}
|
|
14351
14362
|
profilesEqual(source, sourceProviders, target, targetProviders) {
|
|
14352
|
-
return
|
|
14363
|
+
return isDeepStrictEqual2(this.comparableProfile(source, sourceProviders), this.comparableProfile(target, targetProviders));
|
|
14353
14364
|
}
|
|
14354
14365
|
comparableProfile(profile, providers) {
|
|
14355
14366
|
const { updated_at: _updatedAt, provider_id: providerId, ...content } = profile;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seaveyon/harness-switch",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.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",
|