@linxin666/dsh-client-ui-plugin-manager 0.3.23 → 0.4.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/README.i18n.yaml +2 -2
- package/README.md +10 -10
- package/README.zh.md +10 -10
- package/icon.svg +3 -0
- package/lib/client.js +56 -281
- package/lib/client.js.map +1 -1
- package/lib/index.js +128 -19
- package/lib/types/client/PluginManagerTab.d.ts +1 -7
- package/lib/types/client/locales.d.ts +3 -45
- package/lib/types/core/repair.d.ts +3 -16
- package/lib/types/host/console-output.d.ts +40 -0
- package/lib/types/host/http.d.ts +18 -1
- package/package.json +19 -14
package/lib/index.js
CHANGED
|
@@ -790,6 +790,74 @@ async function snapshotGateway(facts, patchText) {
|
|
|
790
790
|
};
|
|
791
791
|
}
|
|
792
792
|
//#endregion
|
|
793
|
+
//#region src/host/console-output.ts
|
|
794
|
+
/** Count the U+FFFD replacement characters one candidate decode produced. */
|
|
795
|
+
function replacementCount(text) {
|
|
796
|
+
let count = 0;
|
|
797
|
+
for (const character of text) if (character === "�") count += 1;
|
|
798
|
+
return count;
|
|
799
|
+
}
|
|
800
|
+
/**
|
|
801
|
+
* Decode one console byte buffer. Strict UTF-8 wins whenever it is valid;
|
|
802
|
+
* otherwise the bytes are not UTF-8 at all and the console wrote its own code
|
|
803
|
+
* page, so the candidate that loses the least text is taken.
|
|
804
|
+
* @param bytes - the captured bytes.
|
|
805
|
+
* @returns the decoded text.
|
|
806
|
+
*/
|
|
807
|
+
function decodeConsoleBytes(bytes) {
|
|
808
|
+
try {
|
|
809
|
+
return new TextDecoder("utf-8", { fatal: true }).decode(bytes);
|
|
810
|
+
} catch {
|
|
811
|
+
let best;
|
|
812
|
+
let bestLoss = Number.POSITIVE_INFINITY;
|
|
813
|
+
for (const label of ["gbk", "utf-8"]) {
|
|
814
|
+
let text;
|
|
815
|
+
try {
|
|
816
|
+
text = new TextDecoder(label).decode(bytes);
|
|
817
|
+
} catch {
|
|
818
|
+
continue;
|
|
819
|
+
}
|
|
820
|
+
const loss = replacementCount(text);
|
|
821
|
+
if (loss < bestLoss) {
|
|
822
|
+
best = text;
|
|
823
|
+
bestLoss = loss;
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
/* v8 ignore next 3 -- reachable only without the legacy code page AND without the lenient pass */
|
|
827
|
+
if (best === void 0) return Buffer.from(bytes).toString("utf8");
|
|
828
|
+
return best;
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
/**
|
|
832
|
+
* Create a capture bounded to a byte budget. Overflow drops from the FRONT
|
|
833
|
+
* (the tail is what carries a failure reason), and the cut never lands inside
|
|
834
|
+
* a character: leading UTF-8 continuation bytes are dropped with it, and a
|
|
835
|
+
* legacy code page's dangling lead byte — indistinguishable from a real byte
|
|
836
|
+
* without knowing the encoding until the whole buffer is decoded — is removed
|
|
837
|
+
* with the one replacement character it produced, so an over-long stream still
|
|
838
|
+
* reads cleanly at the seam.
|
|
839
|
+
* @param maxBytes - maximum retained bytes.
|
|
840
|
+
* @returns the capture.
|
|
841
|
+
*/
|
|
842
|
+
function createOutputCapture(maxBytes) {
|
|
843
|
+
let buffer = Buffer.alloc(0);
|
|
844
|
+
let trimmed = false;
|
|
845
|
+
return {
|
|
846
|
+
push(chunk) {
|
|
847
|
+
buffer = buffer.length === 0 ? Buffer.from(chunk) : Buffer.concat([buffer, Buffer.from(chunk)]);
|
|
848
|
+
if (buffer.length <= maxBytes) return;
|
|
849
|
+
let start = buffer.length - maxBytes;
|
|
850
|
+
while (start < buffer.length && (buffer[start] & 192) === 128) start += 1;
|
|
851
|
+
buffer = Buffer.from(buffer.subarray(start));
|
|
852
|
+
trimmed = true;
|
|
853
|
+
},
|
|
854
|
+
read() {
|
|
855
|
+
const text = decodeConsoleBytes(buffer);
|
|
856
|
+
return trimmed && text.startsWith("�") ? text.slice(1) : text;
|
|
857
|
+
}
|
|
858
|
+
};
|
|
859
|
+
}
|
|
860
|
+
//#endregion
|
|
793
861
|
//#region src/host/gateway.ts
|
|
794
862
|
/**
|
|
795
863
|
* The CLI gateway: installs and removals executed by spawning the official
|
|
@@ -805,6 +873,8 @@ async function snapshotGateway(facts, patchText) {
|
|
|
805
873
|
const ADD_TIMEOUT_MS = 6 * 6e4;
|
|
806
874
|
/** Hard deadline for one CLI remove. */
|
|
807
875
|
const REMOVE_TIMEOUT_MS = 2 * 6e4;
|
|
876
|
+
/** Bounded capture of the CLI output (the tail survives), counted in bytes. */
|
|
877
|
+
const MAX_OUTPUT_BYTES = 32e3;
|
|
808
878
|
/** Ring cap on finished jobs: the newest 100 settled jobs stay queryable; the oldest finished job is evicted beyond the cap so the job table cannot grow without bound. In-progress jobs are never evicted. */
|
|
809
879
|
const MAX_FINISHED_JOBS = 100;
|
|
810
880
|
/**
|
|
@@ -844,12 +914,23 @@ function findDshBinary(env = process.env, platform = process.platform, exists =
|
|
|
844
914
|
}
|
|
845
915
|
}
|
|
846
916
|
if (platform === "darwin") candidates.push("/opt/homebrew/bin/dsh", "/usr/local/bin/dsh");
|
|
917
|
+
if (hostEntryPath !== void 0 && hostEntryPath !== "") {
|
|
918
|
+
const entryDir = pathApi.dirname(hostEntryPath);
|
|
919
|
+
const packageRoot = pathApi.dirname(entryDir);
|
|
920
|
+
candidates.push(pathApi.join(packageRoot, "lib", "bin.js"));
|
|
921
|
+
}
|
|
847
922
|
for (const candidate of candidates) if (exists(candidate)) return candidate;
|
|
848
923
|
return null;
|
|
849
924
|
}
|
|
850
|
-
/**
|
|
925
|
+
/**
|
|
926
|
+
* Append bounded CLI output (stdout + stderr interleaved is not preserved;
|
|
927
|
+
* tail wins). Bytes are accumulated and decoded once at read time: a Windows
|
|
928
|
+
* console writes its OEM code page (CP936/GBK on zh-CN), so per-chunk
|
|
929
|
+
* `toString()` both mis-decodes the encoding and splits characters that
|
|
930
|
+
* straddle two reads into replacement characters (issue #1600).
|
|
931
|
+
*/
|
|
851
932
|
function capture(chunk, buffer) {
|
|
852
|
-
buffer.
|
|
933
|
+
buffer.push(chunk);
|
|
853
934
|
}
|
|
854
935
|
/**
|
|
855
936
|
* The spawn command for the dsh CLI on this platform. Windows runs the
|
|
@@ -869,6 +950,10 @@ function dshSpawnCommand(binary, platform = process.platform, localNodeExists =
|
|
|
869
950
|
};
|
|
870
951
|
const dir = win32.dirname(binary);
|
|
871
952
|
const localNode = win32.join(dir, "node.exe");
|
|
953
|
+
if (win32.basename(binary).toLowerCase() === "bin.js") return {
|
|
954
|
+
command: process.execPath,
|
|
955
|
+
argsPrefix: [binary]
|
|
956
|
+
};
|
|
872
957
|
const binJs = [win32.join(dir, "node_modules", "@deepseek-ai", "dsh", "lib", "bin.js"), win32.join(dir, "..", "@deepseek-ai", "dsh", "lib", "bin.js")].find((candidate) => binJsExists(candidate));
|
|
873
958
|
if (binJs === void 0) return {
|
|
874
959
|
command: binary,
|
|
@@ -933,22 +1018,22 @@ const OFFICIAL_INSTALLER_PATTERN = /^\s*-?\s*id:\s*['"]?plugin-(?:installer|cont
|
|
|
933
1018
|
* @returns true when the dump names the official installer channels.
|
|
934
1019
|
*/
|
|
935
1020
|
async function detectOfficialChannels(binary, profileName, env = process.env, spawnImpl = spawnDsh) {
|
|
936
|
-
const output =
|
|
1021
|
+
const output = createOutputCapture(MAX_OUTPUT_BYTES);
|
|
937
1022
|
const child = spawnImpl(binary, [
|
|
938
1023
|
"--profile",
|
|
939
1024
|
profileName,
|
|
940
1025
|
"--dump-config"
|
|
941
1026
|
], env);
|
|
942
1027
|
child.stdout?.on("data", (chunk) => {
|
|
943
|
-
|
|
1028
|
+
capture(chunk, output);
|
|
944
1029
|
});
|
|
945
1030
|
child.stderr?.on("data", (chunk) => {
|
|
946
|
-
|
|
1031
|
+
capture(chunk, output);
|
|
947
1032
|
});
|
|
948
1033
|
if (await new Promise((resolve) => {
|
|
949
1034
|
child.on("close", resolve);
|
|
950
1035
|
}) !== 0) return false;
|
|
951
|
-
return OFFICIAL_INSTALLER_PATTERN.test(output.
|
|
1036
|
+
return OFFICIAL_INSTALLER_PATTERN.test(output.read());
|
|
952
1037
|
}
|
|
953
1038
|
/** The gateway: serializes CLI operations through one job table and one mutation queue. */
|
|
954
1039
|
var CliGateway = class {
|
|
@@ -1001,7 +1086,7 @@ var CliGateway = class {
|
|
|
1001
1086
|
}
|
|
1002
1087
|
/** Run one CLI command to completion and return the bounded output. */
|
|
1003
1088
|
async runCli(binary, args, timeoutMs) {
|
|
1004
|
-
const output =
|
|
1089
|
+
const output = createOutputCapture(MAX_OUTPUT_BYTES);
|
|
1005
1090
|
const child = this.spawnCli(binary, args);
|
|
1006
1091
|
child.stdout?.on("data", (chunk) => {
|
|
1007
1092
|
capture(chunk, output);
|
|
@@ -1018,7 +1103,7 @@ var CliGateway = class {
|
|
|
1018
1103
|
clearTimeout(timer);
|
|
1019
1104
|
return {
|
|
1020
1105
|
code,
|
|
1021
|
-
output: output.
|
|
1106
|
+
output: output.read().trim()
|
|
1022
1107
|
};
|
|
1023
1108
|
}
|
|
1024
1109
|
/** Full package spec used when restoring a legacy dependency. */
|
|
@@ -1365,7 +1450,7 @@ var CliGateway = class {
|
|
|
1365
1450
|
return;
|
|
1366
1451
|
}
|
|
1367
1452
|
const before = await this.capture();
|
|
1368
|
-
const output =
|
|
1453
|
+
const output = createOutputCapture(MAX_OUTPUT_BYTES);
|
|
1369
1454
|
const child = this.spawnCli(binary, args);
|
|
1370
1455
|
child.stdout?.on("data", (chunk) => {
|
|
1371
1456
|
capture(chunk, output);
|
|
@@ -1382,7 +1467,7 @@ var CliGateway = class {
|
|
|
1382
1467
|
clearTimeout(timer);
|
|
1383
1468
|
if (code !== 0) {
|
|
1384
1469
|
job.phase = "error";
|
|
1385
|
-
const tail = output.
|
|
1470
|
+
const tail = output.read().trim();
|
|
1386
1471
|
job.error = tail === "" ? `plugin-manager: dsh plugin ${job.action} exited with code ${String(code)}` : tail;
|
|
1387
1472
|
return;
|
|
1388
1473
|
}
|
|
@@ -1490,7 +1575,7 @@ var CliGateway = class {
|
|
|
1490
1575
|
let tail = "";
|
|
1491
1576
|
const binary = this.binary();
|
|
1492
1577
|
if (binary !== null) {
|
|
1493
|
-
const output =
|
|
1578
|
+
const output = createOutputCapture(MAX_OUTPUT_BYTES);
|
|
1494
1579
|
const child = this.spawnCli(binary, [
|
|
1495
1580
|
"plugin",
|
|
1496
1581
|
"--profile",
|
|
@@ -1512,7 +1597,7 @@ var CliGateway = class {
|
|
|
1512
1597
|
});
|
|
1513
1598
|
clearTimeout(timer);
|
|
1514
1599
|
rolledBack = code === 0;
|
|
1515
|
-
tail = output.
|
|
1600
|
+
tail = output.read().trim();
|
|
1516
1601
|
}
|
|
1517
1602
|
job.phase = "error";
|
|
1518
1603
|
job.error = rolledBack ? `plugin-manager: ${reason},已自动回滚 ${name}` : `plugin-manager: ${reason};自动回滚失败,请手动执行 dsh plugin --profile ${this.facts.profileName} remove ${name}${tail === "" ? "" : `:\n${tail}`}`;
|
|
@@ -1590,7 +1675,7 @@ var CliGateway = class {
|
|
|
1590
1675
|
const binary = this.binary();
|
|
1591
1676
|
if (binary === null) return;
|
|
1592
1677
|
const name = this.newDependency(before, after);
|
|
1593
|
-
const verifyOutput =
|
|
1678
|
+
const verifyOutput = createOutputCapture(MAX_OUTPUT_BYTES);
|
|
1594
1679
|
const child = this.spawnCli(binary, [
|
|
1595
1680
|
"--profile",
|
|
1596
1681
|
this.facts.profileName,
|
|
@@ -1610,7 +1695,7 @@ var CliGateway = class {
|
|
|
1610
1695
|
});
|
|
1611
1696
|
clearTimeout(timer);
|
|
1612
1697
|
if (code === 0) return;
|
|
1613
|
-
const tail = verifyOutput.
|
|
1698
|
+
const tail = verifyOutput.read().trim();
|
|
1614
1699
|
if (name === void 0) {
|
|
1615
1700
|
job.phase = "error";
|
|
1616
1701
|
job.error = tail === "" ? "plugin-manager: boot preflight failed" : tail;
|
|
@@ -1669,6 +1754,28 @@ function isJsonObject(value) {
|
|
|
1669
1754
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1670
1755
|
}
|
|
1671
1756
|
/**
|
|
1757
|
+
* Request init that asks a remote origin for an uncompressed body.
|
|
1758
|
+
*
|
|
1759
|
+
* The DSH host boots `@deepseek-ai/dsh-http-proxy`, whose top-level import of
|
|
1760
|
+
* the npm `undici` copy replaces the legacy `undici.globalDispatcher.1` slot
|
|
1761
|
+
* Node's built-in `fetch()` reads. That cross-major wrapper drops the
|
|
1762
|
+
* `content-encoding` header and automatic decompression, so a plain fetch
|
|
1763
|
+
* resolves to raw gzip/brotli/zstd bytes — compressed noise no JSON or text
|
|
1764
|
+
* consumer can read. Every host fetch that parses a remote body must request
|
|
1765
|
+
* identity encoding. Caller headers survive; `accept-encoding` is forced to
|
|
1766
|
+
* `identity` because a caller value has no decoder behind it in this host.
|
|
1767
|
+
* @param init - the caller's request init (signal, headers, method, ...).
|
|
1768
|
+
* @returns a copy with `accept-encoding: identity` merged in.
|
|
1769
|
+
*/
|
|
1770
|
+
function withIdentityEncoding(init = {}) {
|
|
1771
|
+
const headers = new Headers(init.headers);
|
|
1772
|
+
headers.set("accept-encoding", "identity");
|
|
1773
|
+
return {
|
|
1774
|
+
...init,
|
|
1775
|
+
headers
|
|
1776
|
+
};
|
|
1777
|
+
}
|
|
1778
|
+
/**
|
|
1672
1779
|
* Write one JSON response. Default headers are the family defaults
|
|
1673
1780
|
* (content-type and referrer-policy); caller headers are appended or
|
|
1674
1781
|
* override them.
|
|
@@ -1870,6 +1977,8 @@ const GATEWAY_PREFIX = "/api/plugin-manager";
|
|
|
1870
1977
|
const REGISTRY_TIMEOUT_MS = 3e4;
|
|
1871
1978
|
/** Deadline for one dsh --version probe. */
|
|
1872
1979
|
const VERSION_TIMEOUT_MS = 1e4;
|
|
1980
|
+
/** Bounded capture of the version probe output, counted in bytes. */
|
|
1981
|
+
const VERSION_MAX_OUTPUT_BYTES = 4096;
|
|
1873
1982
|
/** Grace period after SIGTERM before a stuck probe child is SIGKILLed. */
|
|
1874
1983
|
const VERSION_ESCALATION_TIMEOUT_MS = 5e3;
|
|
1875
1984
|
/** Successful probe freshness window before the host version is re-read. */
|
|
@@ -1880,9 +1989,9 @@ const VERSION_PROBE_COOLDOWN_MS = 6e4;
|
|
|
1880
1989
|
function messageOf(error) {
|
|
1881
1990
|
return error instanceof Error ? error.message : String(error);
|
|
1882
1991
|
}
|
|
1883
|
-
/** Append bounded probe output. */
|
|
1992
|
+
/** Append bounded probe output (bytes accumulate; one decode at read time). */
|
|
1884
1993
|
function captureProbe(chunk, buffer) {
|
|
1885
|
-
buffer.
|
|
1994
|
+
buffer.push(chunk);
|
|
1886
1995
|
}
|
|
1887
1996
|
/**
|
|
1888
1997
|
* Default registry manifest probe for npm packages: `/<name>/latest` returns
|
|
@@ -1891,7 +2000,7 @@ function captureProbe(chunk, buffer) {
|
|
|
1891
2000
|
*/
|
|
1892
2001
|
async function fetchRegistryManifest(name) {
|
|
1893
2002
|
const encoded = name.startsWith("@") ? name.replace("/", "%2F") : name;
|
|
1894
|
-
const response = await fetch(`https://registry.npmjs.org/${encoded}/latest`, { signal: AbortSignal.timeout(REGISTRY_TIMEOUT_MS) });
|
|
2003
|
+
const response = await fetch(`https://registry.npmjs.org/${encoded}/latest`, withIdentityEncoding({ signal: AbortSignal.timeout(REGISTRY_TIMEOUT_MS) }));
|
|
1895
2004
|
if (!response.ok) return void 0;
|
|
1896
2005
|
const body = await response.json();
|
|
1897
2006
|
if (typeof body.version !== "string") return void 0;
|
|
@@ -1912,7 +2021,7 @@ async function probeDshVersion(cliAvailable) {
|
|
|
1912
2021
|
if (!cliAvailable()) return void 0;
|
|
1913
2022
|
const binary = findDshBinary();
|
|
1914
2023
|
if (binary === null) return void 0;
|
|
1915
|
-
const output =
|
|
2024
|
+
const output = createOutputCapture(VERSION_MAX_OUTPUT_BYTES);
|
|
1916
2025
|
const child = spawnDsh(binary, ["--version"], process.env);
|
|
1917
2026
|
child.stdout?.on("data", (chunk) => {
|
|
1918
2027
|
captureProbe(chunk, output);
|
|
@@ -1939,7 +2048,7 @@ async function probeDshVersion(cliAvailable) {
|
|
|
1939
2048
|
child.once("error", () => finish(null));
|
|
1940
2049
|
child.once("close", finish);
|
|
1941
2050
|
}) !== 0) return void 0;
|
|
1942
|
-
const version = output.
|
|
2051
|
+
const version = output.read().trim().split(/\r?\n/, 1)[0]?.trim() ?? "";
|
|
1943
2052
|
return parseDshVersion(version) === void 0 ? void 0 : version;
|
|
1944
2053
|
}
|
|
1945
2054
|
/** Whether a dependency spec is a direct npm-registry selector, not an alias or external source. */
|
|
@@ -5,16 +5,10 @@ import type { InstallProgressItem, InstalledPluginItem, PluginControlItem, Plugi
|
|
|
5
5
|
export interface PluginManagerTabInjected {
|
|
6
6
|
/** Whether this browser has loopback authority to use the host routes. */
|
|
7
7
|
isLoopback: boolean;
|
|
8
|
-
/** Read the installed snapshot. */
|
|
8
|
+
/** Read the installed snapshot (the tab renders it read-only). */
|
|
9
9
|
list: () => Promise<InstalledPluginItem[]>;
|
|
10
|
-
/** Install one plugin from an npm spec or git URL. */
|
|
11
|
-
install: (spec: string) => Promise<InstalledPluginItem>;
|
|
12
10
|
/** Re-install one plugin from its recorded source. */
|
|
13
11
|
update: (id: string) => Promise<InstalledPluginItem>;
|
|
14
|
-
/** Remove one plugin. */
|
|
15
|
-
uninstall: (id: string) => Promise<InstalledPluginItem[]>;
|
|
16
|
-
/** Persist one user plugin's next-start enablement. */
|
|
17
|
-
setEnabled: (id: string, enabled: boolean) => Promise<InstalledPluginItem>;
|
|
18
12
|
/** Compare installed versions against their sources. */
|
|
19
13
|
checkUpdates: () => Promise<PluginUpdateItem[]>;
|
|
20
14
|
/** Read the current install/update progress. */
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
/** Simplified Chinese copy (the key-set source of truth). */
|
|
7
7
|
declare const STATIC_ZH: {
|
|
8
8
|
tab: string;
|
|
9
|
+
manageElsewhere: string;
|
|
9
10
|
loading: string;
|
|
10
11
|
empty: string;
|
|
11
12
|
userPlugins: string;
|
|
@@ -16,10 +17,6 @@ declare const STATIC_ZH: {
|
|
|
16
17
|
conflictChanged: string;
|
|
17
18
|
undoConflict: string;
|
|
18
19
|
conflictHint: string;
|
|
19
|
-
installPlaceholder: string;
|
|
20
|
-
install: string;
|
|
21
|
-
installing: string;
|
|
22
|
-
installHint: string;
|
|
23
20
|
version: string;
|
|
24
21
|
latest: string;
|
|
25
22
|
update: string;
|
|
@@ -29,11 +26,6 @@ declare const STATIC_ZH: {
|
|
|
29
26
|
noUpdates: string;
|
|
30
27
|
updateRequiresDsh: string;
|
|
31
28
|
updateBlockedDsh: string;
|
|
32
|
-
uninstall: string;
|
|
33
|
-
uninstallConfirmTitle: string;
|
|
34
|
-
uninstallConfirmBody: string;
|
|
35
|
-
confirm: string;
|
|
36
|
-
cancel: string;
|
|
37
29
|
restartHint: string;
|
|
38
30
|
failed: string;
|
|
39
31
|
enabled: string;
|
|
@@ -60,17 +52,11 @@ declare const STATIC_ZH: {
|
|
|
60
52
|
exitSafeMode: string;
|
|
61
53
|
npmSource: string;
|
|
62
54
|
gitSource: string;
|
|
63
|
-
enableSwitch: string;
|
|
64
|
-
disableSwitch: string;
|
|
65
55
|
lockedRowHint: string;
|
|
66
56
|
childrenHint: string;
|
|
67
57
|
childrenSummary: string;
|
|
68
58
|
childrenShow: string;
|
|
69
59
|
childrenHide: string;
|
|
70
|
-
repairInstallTitle: string;
|
|
71
|
-
repairInstallSpecLabel: string;
|
|
72
|
-
repairInstallErrorLabel: string;
|
|
73
|
-
repairInstallAsk: string;
|
|
74
60
|
repairFailureTitle: string;
|
|
75
61
|
repairFailurePluginLabel: string;
|
|
76
62
|
repairFailureKindLabel: string;
|
|
@@ -92,6 +78,7 @@ declare const STATIC_ZH: {
|
|
|
92
78
|
};
|
|
93
79
|
export declare const zh: {
|
|
94
80
|
tab: string;
|
|
81
|
+
manageElsewhere: string;
|
|
95
82
|
loading: string;
|
|
96
83
|
empty: string;
|
|
97
84
|
userPlugins: string;
|
|
@@ -102,10 +89,6 @@ export declare const zh: {
|
|
|
102
89
|
conflictChanged: string;
|
|
103
90
|
undoConflict: string;
|
|
104
91
|
conflictHint: string;
|
|
105
|
-
installPlaceholder: string;
|
|
106
|
-
install: string;
|
|
107
|
-
installing: string;
|
|
108
|
-
installHint: string;
|
|
109
92
|
version: string;
|
|
110
93
|
latest: string;
|
|
111
94
|
update: string;
|
|
@@ -115,11 +98,6 @@ export declare const zh: {
|
|
|
115
98
|
noUpdates: string;
|
|
116
99
|
updateRequiresDsh: string;
|
|
117
100
|
updateBlockedDsh: string;
|
|
118
|
-
uninstall: string;
|
|
119
|
-
uninstallConfirmTitle: string;
|
|
120
|
-
uninstallConfirmBody: string;
|
|
121
|
-
confirm: string;
|
|
122
|
-
cancel: string;
|
|
123
101
|
restartHint: string;
|
|
124
102
|
failed: string;
|
|
125
103
|
enabled: string;
|
|
@@ -146,17 +124,11 @@ export declare const zh: {
|
|
|
146
124
|
exitSafeMode: string;
|
|
147
125
|
npmSource: string;
|
|
148
126
|
gitSource: string;
|
|
149
|
-
enableSwitch: string;
|
|
150
|
-
disableSwitch: string;
|
|
151
127
|
lockedRowHint: string;
|
|
152
128
|
childrenHint: string;
|
|
153
129
|
childrenSummary: string;
|
|
154
130
|
childrenShow: string;
|
|
155
131
|
childrenHide: string;
|
|
156
|
-
repairInstallTitle: string;
|
|
157
|
-
repairInstallSpecLabel: string;
|
|
158
|
-
repairInstallErrorLabel: string;
|
|
159
|
-
repairInstallAsk: string;
|
|
160
132
|
repairFailureTitle: string;
|
|
161
133
|
repairFailurePluginLabel: string;
|
|
162
134
|
repairFailureKindLabel: string;
|
|
@@ -178,6 +150,7 @@ export declare const zh: {
|
|
|
178
150
|
};
|
|
179
151
|
export declare const en: {
|
|
180
152
|
tab: string;
|
|
153
|
+
manageElsewhere: string;
|
|
181
154
|
loading: string;
|
|
182
155
|
empty: string;
|
|
183
156
|
userPlugins: string;
|
|
@@ -188,10 +161,6 @@ export declare const en: {
|
|
|
188
161
|
conflictChanged: string;
|
|
189
162
|
undoConflict: string;
|
|
190
163
|
conflictHint: string;
|
|
191
|
-
installPlaceholder: string;
|
|
192
|
-
install: string;
|
|
193
|
-
installing: string;
|
|
194
|
-
installHint: string;
|
|
195
164
|
version: string;
|
|
196
165
|
latest: string;
|
|
197
166
|
update: string;
|
|
@@ -201,11 +170,6 @@ export declare const en: {
|
|
|
201
170
|
noUpdates: string;
|
|
202
171
|
updateRequiresDsh: string;
|
|
203
172
|
updateBlockedDsh: string;
|
|
204
|
-
uninstall: string;
|
|
205
|
-
uninstallConfirmTitle: string;
|
|
206
|
-
uninstallConfirmBody: string;
|
|
207
|
-
confirm: string;
|
|
208
|
-
cancel: string;
|
|
209
173
|
restartHint: string;
|
|
210
174
|
failed: string;
|
|
211
175
|
enabled: string;
|
|
@@ -232,17 +196,11 @@ export declare const en: {
|
|
|
232
196
|
exitSafeMode: string;
|
|
233
197
|
npmSource: string;
|
|
234
198
|
gitSource: string;
|
|
235
|
-
enableSwitch: string;
|
|
236
|
-
disableSwitch: string;
|
|
237
199
|
lockedRowHint: string;
|
|
238
200
|
childrenHint: string;
|
|
239
201
|
childrenSummary: string;
|
|
240
202
|
childrenShow: string;
|
|
241
203
|
childrenHide: string;
|
|
242
|
-
repairInstallTitle: string;
|
|
243
|
-
repairInstallSpecLabel: string;
|
|
244
|
-
repairInstallErrorLabel: string;
|
|
245
|
-
repairInstallAsk: string;
|
|
246
204
|
repairFailureTitle: string;
|
|
247
205
|
repairFailurePluginLabel: string;
|
|
248
206
|
repairFailureKindLabel: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Repair-conversation seed text.
|
|
3
|
-
* through the same shape: a
|
|
4
|
-
*
|
|
2
|
+
* Repair-conversation seed text. The failure surfaces this package still owns
|
|
3
|
+
* hand off to the agent through the same shape: a recorded boot failure (the
|
|
4
|
+
* failure-ring row) and an install-conflict change. The seeded message must be
|
|
5
5
|
* self-contained — the repair session's workspace is the plugin install root,
|
|
6
6
|
* so the agent's file tools reach the plugin code without leaving the
|
|
7
7
|
* workspace boundary.
|
|
@@ -16,10 +16,6 @@ import type { PluginFailureItem } from './protocol.ts';
|
|
|
16
16
|
import type { LayerState } from './patch-diff.ts';
|
|
17
17
|
/** Localized fragments the builders assemble. */
|
|
18
18
|
export interface RepairCopy {
|
|
19
|
-
installTitle: string;
|
|
20
|
-
installSpecLabel: string;
|
|
21
|
-
installErrorLabel: string;
|
|
22
|
-
installAsk: string;
|
|
23
19
|
failureTitle: string;
|
|
24
20
|
failurePluginLabel: string;
|
|
25
21
|
failureKindLabel: string;
|
|
@@ -39,15 +35,6 @@ export interface RepairCopy {
|
|
|
39
35
|
}
|
|
40
36
|
/** Default copy (zh): the package's zh dictionary keys map onto these strings. */
|
|
41
37
|
export declare const DEFAULT_REPAIR_COPY: RepairCopy;
|
|
42
|
-
/**
|
|
43
|
-
* Seed text for a failed install: the target and the rendered error,
|
|
44
|
-
* self-contained for the agent.
|
|
45
|
-
* @param spec - the install target (npm spec or git URL) that failed.
|
|
46
|
-
* @param error - the rendered install error text.
|
|
47
|
-
* @param copy - localized fragments.
|
|
48
|
-
* @returns the repair prompt text.
|
|
49
|
-
*/
|
|
50
|
-
export declare function installRepairMessage(spec: string, error: string, copy?: RepairCopy): string;
|
|
51
38
|
/**
|
|
52
39
|
* Seed text for one boot-failure ring row: the failure record, so the agent
|
|
53
40
|
* can attribute and fix it in place.
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Console-output capture shared by the family's Host halves.
|
|
3
|
+
*
|
|
4
|
+
* A child process's stdout/stderr are raw bytes, and on Windows a console
|
|
5
|
+
* program writes the OEM code page (CP936/GBK on a zh-CN system), not UTF-8.
|
|
6
|
+
* Decoding each chunk on its own corrupts the text twice over: the
|
|
7
|
+
* encoding is guessed wrong, and a multi-byte character split across two reads
|
|
8
|
+
* decodes into two replacement characters. This capture accumulates raw bytes
|
|
9
|
+
* under a byte budget and decodes exactly once, at read time.
|
|
10
|
+
*/
|
|
11
|
+
/** Bounded byte accumulator for one child process's interleaved stdout/stderr. */
|
|
12
|
+
export interface OutputCapture {
|
|
13
|
+
/** Append one raw chunk (the bytes are copied into the budget). */
|
|
14
|
+
push(chunk: Uint8Array): void;
|
|
15
|
+
/**
|
|
16
|
+
* Decode everything captured so far. Idempotent, so a caller may read the
|
|
17
|
+
* tail both after a failure branch and at settlement.
|
|
18
|
+
*/
|
|
19
|
+
read(): string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Decode one console byte buffer. Strict UTF-8 wins whenever it is valid;
|
|
23
|
+
* otherwise the bytes are not UTF-8 at all and the console wrote its own code
|
|
24
|
+
* page, so the candidate that loses the least text is taken.
|
|
25
|
+
* @param bytes - the captured bytes.
|
|
26
|
+
* @returns the decoded text.
|
|
27
|
+
*/
|
|
28
|
+
export declare function decodeConsoleBytes(bytes: Uint8Array): string;
|
|
29
|
+
/**
|
|
30
|
+
* Create a capture bounded to a byte budget. Overflow drops from the FRONT
|
|
31
|
+
* (the tail is what carries a failure reason), and the cut never lands inside
|
|
32
|
+
* a character: leading UTF-8 continuation bytes are dropped with it, and a
|
|
33
|
+
* legacy code page's dangling lead byte — indistinguishable from a real byte
|
|
34
|
+
* without knowing the encoding until the whole buffer is decoded — is removed
|
|
35
|
+
* with the one replacement character it produced, so an over-long stream still
|
|
36
|
+
* reads cleanly at the seam.
|
|
37
|
+
* @param maxBytes - maximum retained bytes.
|
|
38
|
+
* @returns the capture.
|
|
39
|
+
*/
|
|
40
|
+
export declare function createOutputCapture(maxBytes: number): OutputCapture;
|
package/lib/types/host/http.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Shared JSON body/response helpers for the host route families: one strict
|
|
3
3
|
* bounded body reader, one lenient bounded body reader, one JSON object
|
|
4
|
-
* narrow,
|
|
4
|
+
* narrow, one JSON writer, and the outbound request-init helper that keeps a
|
|
5
|
+
* host fetch body decodable (withIdentityEncoding). Previously the readers
|
|
6
|
+
* were copy-pasted across the
|
|
5
7
|
* package route files (routes.ts, update-routes.ts, mobile-api.ts, and each
|
|
6
8
|
* family's route module) with drifting contracts: body caps ranging 4 KiB to
|
|
7
9
|
* 1 MiB and four distinct overflow behaviors (reject, undefined, null, throw).
|
|
@@ -34,6 +36,21 @@ export declare function readJsonBody(req: IncomingMessage, opts?: {
|
|
|
34
36
|
}): Promise<unknown | null>;
|
|
35
37
|
/** Narrow a value to a JSON object, or undefined when it is not one. */
|
|
36
38
|
export declare function asJsonObject(value: unknown): Record<string, unknown> | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* Request init that asks a remote origin for an uncompressed body.
|
|
41
|
+
*
|
|
42
|
+
* The DSH host boots `@deepseek-ai/dsh-http-proxy`, whose top-level import of
|
|
43
|
+
* the npm `undici` copy replaces the legacy `undici.globalDispatcher.1` slot
|
|
44
|
+
* Node's built-in `fetch()` reads. That cross-major wrapper drops the
|
|
45
|
+
* `content-encoding` header and automatic decompression, so a plain fetch
|
|
46
|
+
* resolves to raw gzip/brotli/zstd bytes — compressed noise no JSON or text
|
|
47
|
+
* consumer can read. Every host fetch that parses a remote body must request
|
|
48
|
+
* identity encoding. Caller headers survive; `accept-encoding` is forced to
|
|
49
|
+
* `identity` because a caller value has no decoder behind it in this host.
|
|
50
|
+
* @param init - the caller's request init (signal, headers, method, ...).
|
|
51
|
+
* @returns a copy with `accept-encoding: identity` merged in.
|
|
52
|
+
*/
|
|
53
|
+
export declare function withIdentityEncoding(init?: RequestInit): RequestInit;
|
|
37
54
|
/**
|
|
38
55
|
* Write one JSON response. Default headers are the family defaults
|
|
39
56
|
* (content-type and referrer-policy); caller headers are appended or
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@linxin666/dsh-client-ui-plugin-manager",
|
|
3
3
|
"description": "Plugin manager tab for the dsh web GUI Plugins settings section: installs plugins from npm or git through the official host channels, lists installed plugins with next-start enablement switches, surfaces install-time conflict actions with undo, and hands failures off to repair conversations.",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.4.0",
|
|
5
|
+
"icon": "icon.svg",
|
|
5
6
|
"type": "module",
|
|
6
7
|
"main": "lib/index.js",
|
|
7
8
|
"types": "lib/types/index.d.ts",
|
|
@@ -19,7 +20,7 @@
|
|
|
19
20
|
},
|
|
20
21
|
"dsh": {
|
|
21
22
|
"engines": {
|
|
22
|
-
"dsh": ">=0.1.
|
|
23
|
+
"dsh": ">=0.1.7-rc.1"
|
|
23
24
|
},
|
|
24
25
|
"bundle": {
|
|
25
26
|
"patch": "./cordis.patch.yml"
|
|
@@ -30,25 +31,28 @@
|
|
|
30
31
|
"@deepseek-ai/dsh-api-workspace-controller",
|
|
31
32
|
"@deepseek-ai/dsh-client-connection",
|
|
32
33
|
"@deepseek-ai/dsh-client-ui-renderer",
|
|
33
|
-
"@deepseek-ai/dsh-client-ui-settings"
|
|
34
|
+
"@deepseek-ai/dsh-client-ui-settings",
|
|
35
|
+
"@deepseek-ai/dsh-client-ui-workspace"
|
|
34
36
|
],
|
|
35
37
|
"platform": "web"
|
|
36
38
|
}
|
|
37
39
|
},
|
|
38
40
|
"peerDependencies": {
|
|
41
|
+
"@deepseek-ai/dsh": ">=0.1.7-rc.1",
|
|
39
42
|
"react": "^18.2.0"
|
|
40
43
|
},
|
|
41
44
|
"devDependencies": {
|
|
42
|
-
"@deepseek-ai/cordis": "^4.0.
|
|
43
|
-
"@deepseek-ai/dsh-api-session-controller": "^0.1.
|
|
44
|
-
"@deepseek-ai/dsh-api-workspace-controller": "^0.1.
|
|
45
|
-
"@deepseek-ai/dsh-client-connection": "^0.1.
|
|
46
|
-
"@deepseek-ai/dsh-client-locale": "^0.1.
|
|
47
|
-
"@deepseek-ai/dsh-client-ui-primitives": "^0.1.
|
|
48
|
-
"@deepseek-ai/dsh-client-ui-renderer": "^0.1.
|
|
49
|
-
"@deepseek-ai/dsh-client-ui-settings": "^0.1.
|
|
50
|
-
"@deepseek-ai/dsh-client-ui-slots": "^0.1.
|
|
51
|
-
"@deepseek-ai/dsh-
|
|
45
|
+
"@deepseek-ai/cordis": "^4.0.4",
|
|
46
|
+
"@deepseek-ai/dsh-api-session-controller": "^0.1.7-rc.1",
|
|
47
|
+
"@deepseek-ai/dsh-api-workspace-controller": "^0.1.7-rc.1",
|
|
48
|
+
"@deepseek-ai/dsh-client-connection": "^0.1.7-rc.1",
|
|
49
|
+
"@deepseek-ai/dsh-client-locale": "^0.1.7-rc.1",
|
|
50
|
+
"@deepseek-ai/dsh-client-ui-primitives": "^0.1.7-rc.1",
|
|
51
|
+
"@deepseek-ai/dsh-client-ui-renderer": "^0.1.7-rc.1",
|
|
52
|
+
"@deepseek-ai/dsh-client-ui-settings": "^0.1.7-rc.1",
|
|
53
|
+
"@deepseek-ai/dsh-client-ui-slots": "^0.1.7-rc.1",
|
|
54
|
+
"@deepseek-ai/dsh-client-ui-workspace": "^0.1.7-rc.1",
|
|
55
|
+
"@deepseek-ai/dsh-host-webserver": "^0.1.7-rc.1",
|
|
52
56
|
"@testing-library/react": "^16.1.0",
|
|
53
57
|
"@types/node": "^22.20.0",
|
|
54
58
|
"@types/react": "~18.3.1",
|
|
@@ -65,7 +69,8 @@
|
|
|
65
69
|
"cordis.patch.yml",
|
|
66
70
|
"README.md",
|
|
67
71
|
"README.zh.md",
|
|
68
|
-
"README.i18n.yaml"
|
|
72
|
+
"README.i18n.yaml",
|
|
73
|
+
"icon.svg"
|
|
69
74
|
],
|
|
70
75
|
"license": "BSD-3-Clause",
|
|
71
76
|
"dependencies": {
|