@genkaku/dsh-user-plugin 0.1.11 → 0.1.13

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAKH,oEAAoE;AACpE,eAAO,MAAM,QAAQ,YAAY,CAAA;AAEjC,eAAO,MAAQ,IAAI,UAAE,MAAM,qBAAE,MAAM;;;;;;;;;aAyBk3O,CAAC;oBAAqD,CAAC;YAA6C,CAAC;mBAAoD,CAAC;sBAAuD,CAAC;qBAAsD,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;aAAy6D,CAAC;oBAAqD,CAAC;YAA6C,CAAC;mBAAoD,CAAC;sBAAuD,CAAC;qBAAsD,CAAC;;;;;;;;;;;;;;;;eAzB3yT,KAAK,8GAwBxC,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAKH,oEAAoE;AACpE,eAAO,MAAM,QAAQ,YAAY,CAAA;AAEjC,eAAO,MAAQ,IAAI,UAAE,MAAM,qBAAE,MAAM;;;;;;;;;aAuCgrN,CAAC;oBAAqD,CAAC;YAA6C,CAAC;mBAAoD,CAAC;sBAAuD,CAAC;qBAAsD,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;aAAy6D,CAAC;oBAAqD,CAAC;YAA6C,CAAC;mBAAoD,CAAC;sBAAuD,CAAC;qBAAsD,CAAC;;;;;;;;;;;;;;;;eAvCzmS,KAAK,8GAsCxC,CAAA"}
package/dist/index.js CHANGED
@@ -23,13 +23,26 @@ export const { name, inject, Config, apply } = defineGenkakuPlugin({
23
23
  const log = ctx.logger('genkaku-user');
24
24
  const baseUrl = () => `http://127.0.0.1:${config.port.get()}/v1`;
25
25
  const adapter = new GenkakuAdapter({ baseUrl, log: line => log.info(line) });
26
- ctx.effect(() => ctx.llm.registerAdapter([PROVIDER], adapter), 'genkaku-user: llm adapter');
27
- ctx.effect(() => ctx.llm.registerConfigurableProviders([{
26
+ // Installing the worker plugin next to this one makes the harness reload
27
+ // plugins; a second register for the same provider throws and took the
28
+ // whole web boot down. Reuse the adapter that is already there instead.
29
+ const guard = (label, register) => {
30
+ try {
31
+ const dispose = register();
32
+ return typeof dispose === 'function' ? dispose : () => { };
33
+ }
34
+ catch (error) {
35
+ log.warn('%s: already registered (%s) — reusing the existing one', label, error instanceof Error ? error.message : String(error));
36
+ return () => { };
37
+ }
38
+ };
39
+ ctx.effect(() => guard('llm adapter', () => ctx.llm.registerAdapter([PROVIDER], adapter)), 'genkaku-user: llm adapter');
40
+ ctx.effect(() => guard('provider route', () => ctx.llm.registerConfigurableProviders([{
28
41
  provider: PROVIDER,
29
42
  displayName: 'GenKaKu Network',
30
43
  settingsNs: 'genkaku-user',
31
44
  settingsPath: [],
32
- }]), 'genkaku-user: provider route');
45
+ }])), 'genkaku-user: provider route');
33
46
  },
34
47
  });
35
48
  //# sourceMappingURL=index.js.map
package/lib/client.js CHANGED
@@ -37,7 +37,8 @@ var genkaku_mark_default = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAK4AAA
37
37
  // src/client/index.tsx
38
38
  var import_jsx_runtime = require("react/jsx-runtime");
39
39
  var PANEL_ID = "genkaku-user";
40
- var STATUS_URL = "http://127.0.0.1:47821/genkaku/status";
40
+ var CANDIDATE_PORTS = [47821, 47822, 47823, 47824, 47825, 47826];
41
+ var originOf = (port) => `http://127.0.0.1:${port}`;
41
42
  var inject = ["slots"];
42
43
  function Icon({ size = 16 }) {
43
44
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { style: { display: "inline-flex", width: size, height: size }, "aria-hidden": "true", children: [
@@ -89,14 +90,22 @@ function Page() {
89
90
  const [status, setStatus] = (0, import_react.useState)(null);
90
91
  const [error, setError] = (0, import_react.useState)(null);
91
92
  const load = (0, import_react.useCallback)(async () => {
92
- try {
93
- const res = await fetch(STATUS_URL);
94
- if (!res.ok) throw new Error(`status ${res.status}`);
95
- setStatus(await res.json());
96
- setError(null);
97
- } catch (e) {
98
- setError(e instanceof Error ? e.message : String(e));
93
+ for (const port of CANDIDATE_PORTS) {
94
+ try {
95
+ const res = await fetch(`${originOf(port)}/genkaku/status`, {
96
+ cache: "no-store",
97
+ signal: AbortSignal.timeout(2500)
98
+ });
99
+ if (!res.ok) continue;
100
+ const doc = await res.json();
101
+ if (doc.role !== "user") continue;
102
+ setStatus(doc);
103
+ setError(null);
104
+ return;
105
+ } catch {
106
+ }
99
107
  }
108
+ setError("no GenKaKu user bridge on 47821\u201347826");
100
109
  }, []);
101
110
  (0, import_react.useEffect)(() => {
102
111
  void load();
@@ -112,7 +121,7 @@ function Page() {
112
121
  "Worker status unreachable: ",
113
122
  error
114
123
  ] }),
115
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { style: { ...dim, fontSize: 12 }, children: "The plugin starts its status server on 127.0.0.1:47821." })
124
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { style: { ...dim, fontSize: 12 }, children: "The plugin opens its bridge on the first free port in 47821\u201347826." })
116
125
  ] });
117
126
  }
118
127
  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-user-plugin",
3
- "version": "0.1.11",
3
+ "version": "0.1.13",
4
4
  "description": "Buy peer-to-peer inference from the GenKaKu network",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -39,8 +39,8 @@
39
39
  },
40
40
  "dependencies": {
41
41
  "@deepseek-ai/dsh-llm": "0.2.2-rc.1",
42
- "@genkaku/dsh-runtime": "0.1.14",
43
- "@genkaku/protocol": "0.1.11"
42
+ "@genkaku/protocol": "0.1.12",
43
+ "@genkaku/dsh-runtime": "0.1.16"
44
44
  },
45
45
  "peerDependencies": {
46
46
  "@deepseek-ai/cordis": "^4.1.0",