dsh-background-by-model 0.4.1 → 0.4.3
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 +34 -1
- package/README.zh.md +34 -1
- package/lib/client.js +1949 -224
- package/lib/client.js.map +1 -1
- package/lib/host-scan-WjK2VGBe.js +1182 -0
- package/lib/host-scan.js +2 -0
- package/lib/index.js +24 -0
- package/lib/testing.js +611 -0
- package/package.json +128 -122
- package/scripts/host-contract-scan.mjs +182 -0
- package/test/host-check.test.mjs +385 -0
package/lib/host-scan.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as thisPluginDir, c as DSH_FLOOR, i as resolveHostRoots, l as HOST_CONTRACTS, n as listHostPackages, o as versionOf, r as meetsFloor, t as checkHostOnDisk } from "./host-scan-WjK2VGBe.js";
|
|
2
|
+
export { DSH_FLOOR, HOST_CONTRACTS, checkHostOnDisk, listHostPackages, meetsFloor, resolveHostRoots, thisPluginDir, versionOf };
|
package/lib/index.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { t as checkHostOnDisk } from "./host-scan-WjK2VGBe.js";
|
|
1
2
|
import { access, mkdir, readFile, readdir, rename, rm, writeFile } from "node:fs/promises";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
2
4
|
import { dshHomePath } from "@deepseek-ai/dsh-home-paths";
|
|
3
5
|
//#region src/schema.ts
|
|
4
6
|
/** Every accepted `bgMode`, in UI order. */
|
|
@@ -420,6 +422,24 @@ function defaultModel(ctx) {
|
|
|
420
422
|
} catch {}
|
|
421
423
|
return null;
|
|
422
424
|
}
|
|
425
|
+
/**
|
|
426
|
+
* The installed-host half of the self-check.
|
|
427
|
+
*
|
|
428
|
+
* The browser probe behind the "Host check" tab already answers "does this host
|
|
429
|
+
* still provide what I use"; this adds the two facts only the node half can know:
|
|
430
|
+
* the host's own version, and whether the packages on disk still contain the
|
|
431
|
+
* literals the plugin depends on. Reading it costs a handful of file reads, and
|
|
432
|
+
* it is only ever called while that tab is open.
|
|
433
|
+
*/
|
|
434
|
+
let pluginDir = null;
|
|
435
|
+
function thisPluginDir() {
|
|
436
|
+
if (pluginDir === null) pluginDir = fileURLToPath(new URL("..", import.meta.url));
|
|
437
|
+
return pluginDir;
|
|
438
|
+
}
|
|
439
|
+
async function hostCheck(payload) {
|
|
440
|
+
const lang = payload?.lang === "en" ? "en" : "zh";
|
|
441
|
+
return await checkHostOnDisk(thisPluginDir(), lang);
|
|
442
|
+
}
|
|
423
443
|
const NS = "dshBackgroundByModel";
|
|
424
444
|
const RPC_CHANNEL = "/dsh-background-by-model";
|
|
425
445
|
const RPC_BODY_MAX = 314572800;
|
|
@@ -485,6 +505,10 @@ async function handleRpcMethod(ctx, endpoint, payload) {
|
|
|
485
505
|
ok: true,
|
|
486
506
|
value: defaultModel(ctx)
|
|
487
507
|
};
|
|
508
|
+
case "hostCheck": return {
|
|
509
|
+
ok: true,
|
|
510
|
+
value: await hostCheck(payload)
|
|
511
|
+
};
|
|
488
512
|
default: return {
|
|
489
513
|
ok: false,
|
|
490
514
|
error: {
|