@genkaku/dsh-worker-plugin 0.1.27 → 0.1.29

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.
Files changed (2) hide show
  1. package/lib/client.js +23 -5
  2. package/package.json +3 -3
package/lib/client.js CHANGED
@@ -43,6 +43,18 @@ var import_jsx_runtime = require("react/jsx-runtime");
43
43
  var PANEL_ID = "genkaku-worker";
44
44
  var CANDIDATE_PORTS = [47821, 47822, 47823, 47824, 47825, 47826];
45
45
  var originOf = (port) => `http://127.0.0.1:${port}`;
46
+ async function listening(port) {
47
+ try {
48
+ await fetch(`${originOf(port)}/genkaku/status`, {
49
+ mode: "no-cors",
50
+ cache: "no-store",
51
+ signal: AbortSignal.timeout(1500)
52
+ });
53
+ return true;
54
+ } catch {
55
+ return false;
56
+ }
57
+ }
46
58
  var inject = ["slots"];
47
59
  var ZH = typeof navigator !== "undefined" && /^zh/i.test(navigator.language);
48
60
  var t = (en, zh) => ZH ? zh : en;
@@ -251,6 +263,15 @@ function Page() {
251
263
  }
252
264
  }
253
265
  if (next == null) {
266
+ for (const port of CANDIDATE_PORTS) {
267
+ if (await listening(port)) {
268
+ setError(t(
269
+ `Something answers on 127.0.0.1:${port} but refused this window's origin (403). Update the plugin: dsh plugin add @genkaku/dsh-worker-plugin@latest`,
270
+ `127.0.0.1:${port} \u6709\u670D\u52D9\u5728\u8DD1\uFF0C\u4F46\u62D2\u7D55\u4E86\u9019\u500B\u8996\u7A97\u7684\u4F86\u6E90\uFF08403\uFF09\u3002\u8ACB\u66F4\u65B0\u63D2\u4EF6\uFF1Adsh plugin add @genkaku/dsh-worker-plugin@latest`
271
+ ));
272
+ return;
273
+ }
274
+ }
254
275
  setError(t("Worker status unreachable on 47821\u201347826.", "47821\u201347826 \u4E0A\u90FD\u627E\u4E0D\u5230 worker \u72C0\u614B\u670D\u52D9\u3002"));
255
276
  return;
256
277
  }
@@ -422,11 +443,8 @@ function Page() {
422
443
  if (error != null && status == null) {
423
444
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: { padding: 16 }, children: [
424
445
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", { style: { margin: 0 }, children: "GenKaKu worker" }),
425
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { style: { ...dim, marginTop: 8 }, children: [
426
- "Worker status unreachable: ",
427
- error
428
- ] }),
429
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { style: { ...dim, fontSize: 12 }, children: "The plugin starts its status server on 127.0.0.1:47821. If another dsh profile is already using that port, this one cannot bind it." })
446
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { style: { ...dim, marginTop: 8 }, children: error }),
447
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { style: { ...dim, fontSize: 12 }, children: "The plugin starts its status server on the first free port in 47821\u201347826. If another dsh profile already owns that port, this one cannot bind it." })
430
448
  ] });
431
449
  }
432
450
  if (status == null) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: { padding: 16, ...dim }, children: "Loading worker status\u2026" });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@genkaku/dsh-worker-plugin",
3
- "version": "0.1.27",
3
+ "version": "0.1.29",
4
4
  "description": "Share this machine's Ollama models on the GenKaKu network",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -38,8 +38,8 @@
38
38
  }
39
39
  },
40
40
  "dependencies": {
41
- "@genkaku/protocol": "0.1.16",
42
- "@genkaku/dsh-runtime": "0.1.23"
41
+ "@genkaku/dsh-runtime": "0.1.25",
42
+ "@genkaku/protocol": "0.1.18"
43
43
  },
44
44
  "peerDependencies": {
45
45
  "@deepseek-ai/cordis": "^4.1.0"