@genkaku/dsh-user-plugin 0.1.2 → 0.1.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.
Files changed (2) hide show
  1. package/lib/client.js +129 -0
  2. package/package.json +14 -5
package/lib/client.js ADDED
@@ -0,0 +1,129 @@
1
+ window.__ModuleLoader__.load({
2
+ id: "@genkaku/dsh-user-plugin",
3
+ factory: (require) => {
4
+ var module = { exports: {} };
5
+ var exports = module.exports;
6
+ "use strict";
7
+ var __defProp = Object.defineProperty;
8
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
9
+ var __getOwnPropNames = Object.getOwnPropertyNames;
10
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
11
+ var __export = (target, all) => {
12
+ for (var name in all)
13
+ __defProp(target, name, { get: all[name], enumerable: true });
14
+ };
15
+ var __copyProps = (to, from, except, desc) => {
16
+ if (from && typeof from === "object" || typeof from === "function") {
17
+ for (let key of __getOwnPropNames(from))
18
+ if (!__hasOwnProp.call(to, key) && key !== except)
19
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
20
+ }
21
+ return to;
22
+ };
23
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
24
+
25
+ // src/client/index.tsx
26
+ var index_exports = {};
27
+ __export(index_exports, {
28
+ apply: () => apply,
29
+ inject: () => inject
30
+ });
31
+ module.exports = __toCommonJS(index_exports);
32
+ var import_react = require("react");
33
+ var import_jsx_runtime = require("react/jsx-runtime");
34
+ var PANEL_ID = "genkaku-user";
35
+ var STATUS_URL = "http://127.0.0.1:47821/genkaku/status";
36
+ var inject = ["slots"];
37
+ function Icon({ size = 16 }) {
38
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("svg", { width: size, height: size, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.6", "aria-hidden": "true", children: [
39
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: "7", cy: "17", r: "2.5" }),
40
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: "17", cy: "7", r: "2.5" }),
41
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: "17", cy: "17", r: "2.5" }),
42
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M9.2 15.6 14.8 8.4M9.5 17h5", strokeLinecap: "round" })
43
+ ] });
44
+ }
45
+ var row = { display: "flex", justifyContent: "space-between", gap: 12, padding: "6px 0" };
46
+ var dim = { opacity: 0.6 };
47
+ var box = { border: "1px solid rgba(255,255,255,0.12)", borderRadius: 10, padding: 12, marginTop: 12 };
48
+ function Page() {
49
+ const [status, setStatus] = (0, import_react.useState)(null);
50
+ const [error, setError] = (0, import_react.useState)(null);
51
+ const load = (0, import_react.useCallback)(async () => {
52
+ try {
53
+ const res = await fetch(STATUS_URL);
54
+ if (!res.ok) throw new Error(`status ${res.status}`);
55
+ setStatus(await res.json());
56
+ setError(null);
57
+ } catch (e) {
58
+ setError(e instanceof Error ? e.message : String(e));
59
+ }
60
+ }, []);
61
+ (0, import_react.useEffect)(() => {
62
+ void load();
63
+ const timer = setInterval(() => {
64
+ void load();
65
+ }, 5e3);
66
+ return () => clearInterval(timer);
67
+ }, [load]);
68
+ if (error != null) {
69
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: { padding: 16 }, children: [
70
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", { style: { margin: 0 }, children: "GenKaKu network" }),
71
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { style: { ...dim, marginTop: 8 }, children: [
72
+ "Worker status unreachable: ",
73
+ error
74
+ ] }),
75
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { style: { ...dim, fontSize: 12 }, children: "The plugin starts its status server on 127.0.0.1:47821." })
76
+ ] });
77
+ }
78
+ if (status == null) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: { padding: 16, ...dim }, children: "Loading worker status\u2026" });
79
+ const offers = status.offers ?? [];
80
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: { padding: 16, maxWidth: 720 }, children: [
81
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", { style: { margin: 0 }, children: "GenKaKu network" }),
82
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: { ...dim, marginTop: 4 }, children: status.role ?? "unknown role" }),
83
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: box, children: [
84
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: row, children: [
85
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { style: dim, children: "Peer" }),
86
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("code", { children: status.peerId ?? "\u2014" })
87
+ ] }),
88
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: row, children: [
89
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { style: dim, children: "Sessions served" }),
90
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: status.sessions ?? 0 })
91
+ ] }),
92
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: row, children: [
93
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { style: dim, children: "Published on-chain" }),
94
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: status.published === true ? "yes" : "no" })
95
+ ] }),
96
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: row, children: [
97
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { style: dim, children: "Addresses" }),
98
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: (status.peerAddrs ?? []).length })
99
+ ] })
100
+ ] }),
101
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: box, children: [
102
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: { ...dim, fontSize: 12, textTransform: "uppercase", letterSpacing: 1 }, children: "Models on the network" }),
103
+ offers.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { style: { ...dim, marginBottom: 0 }, children: "Nothing offered yet. The worker auto-lists local Ollama models on start." }) : offers.map((offer, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: row, children: [
104
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: offer.model ?? "\u2014" }),
105
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { style: dim, children: [
106
+ offer.pricePerHour ?? "?",
107
+ " / hour",
108
+ offer.tier === "chat" ? " \xB7 not for agents" : ""
109
+ ] })
110
+ ] }, `${offer.model ?? i}`))
111
+ ] })
112
+ ] });
113
+ }
114
+ function apply(ctx) {
115
+ ctx.effect(() => ctx.slots.inject("main", () => ctx.slots.register({
116
+ name: "main",
117
+ key: PANEL_ID
118
+ }, Page)), "genkaku-user: panel page");
119
+ ctx.effect(() => ctx.slots.inject("sidebar.panellist", () => ctx.slots.register({
120
+ name: "sidebar.panellist",
121
+ id: PANEL_ID,
122
+ order: 41,
123
+ label: () => "GenKaKu"
124
+ }, Icon)), "genkaku-user: panel entry");
125
+ }
126
+
127
+ return module.exports;
128
+ }
129
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@genkaku/dsh-user-plugin",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "Buy peer-to-peer inference from the GenKaKu network",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -11,22 +11,31 @@
11
11
  "types": "./dist/index.d.ts",
12
12
  "default": "./dist/index.js"
13
13
  },
14
+ "./client": "./lib/client.js",
14
15
  "./package.json": "./package.json"
15
16
  },
16
17
  "files": [
17
18
  "dist/**/*.js",
18
19
  "dist/**/*.d.ts",
19
20
  "dist/**/*.d.ts.map",
21
+ "lib/client.js",
20
22
  "README.md",
21
23
  "LICENSE"
22
24
  ],
23
25
  "dsh": {
24
- "target": ">=0.2.2-rc.2"
26
+ "client": {
27
+ "inject": [
28
+ "@deepseek-ai/dsh-client-ui-slots",
29
+ "@deepseek-ai/dsh-client-ui-layout"
30
+ ],
31
+ "platform": "web"
32
+ },
33
+ "target": ">=0.2.2-rc.1"
25
34
  },
26
35
  "dependencies": {
27
36
  "@deepseek-ai/dsh-llm": "0.2.2-rc.1",
28
- "@genkaku/dsh-runtime": "0.1.2",
29
- "@genkaku/protocol": "0.1.2"
37
+ "@genkaku/dsh-runtime": "0.1.3",
38
+ "@genkaku/protocol": "0.1.3"
30
39
  },
31
40
  "peerDependencies": {
32
41
  "@deepseek-ai/cordis": "^4.1.0",
@@ -57,7 +66,7 @@
57
66
  "base"
58
67
  ],
59
68
  "scripts": {
60
- "build": "tsc -p tsconfig.json",
69
+ "build": "tsc -p tsconfig.json && node ../../scripts/build-client.mjs . @genkaku/dsh-user-plugin",
61
70
  "typecheck": "tsc -p tsconfig.json --noEmit",
62
71
  "test": "tsc -p tsconfig.json && node --test dist/*.test.js"
63
72
  }