bnpanel 0.5.0 → 0.5.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.
@@ -0,0 +1,6 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="256" height="256" viewBox="0 0 256 256">
2
+ <rect width="256" height="256" rx="56" fill="#14110c"/>
3
+ <rect x="16" y="16" width="224" height="224" rx="44" fill="none" stroke="#e2b657" stroke-width="8"/>
4
+ <path d="M78 168c18-52 34-78 50-78s32 26 50 78" fill="none" stroke="#e2b657" stroke-width="8" stroke-linecap="round"/>
5
+ <circle cx="128" cy="96" r="10" fill="#e2b657"/>
6
+ </svg>
package/client.js CHANGED
@@ -22,6 +22,8 @@
22
22
  --bn-bad:#c23b2e; --bn-bad-soft:rgba(194,59,46,.10);
23
23
  --bn-shadow:0 1px 2px rgba(0,0,0,.04),0 12px 36px rgba(0,0,0,.06);
24
24
  --bn-shadow-hover:0 2px 4px rgba(0,0,0,.05),0 16px 40px rgba(0,0,0,.12);
25
+ --bn-solid:#111111; --bn-on-solid:#d4f07a;
26
+ --bn-toast-bg:#161616; --bn-toast-fg:#f4f1ea;
25
27
  --bn-r:16px; --bn-r-sm:10px;
26
28
  --bn-font:'Plus Jakarta Sans',ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"PingFang SC","Microsoft YaHei",sans-serif;
27
29
  --bn-mono:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;
@@ -37,6 +39,8 @@
37
39
  --bn-bad:#ff7a6b; --bn-bad-soft:rgba(255,122,107,.14);
38
40
  --bn-shadow:0 1px 2px rgba(0,0,0,.4),0 10px 30px rgba(0,0,0,.35);
39
41
  --bn-shadow-hover:0 2px 6px rgba(0,0,0,.45),0 18px 44px rgba(0,0,0,.45);
42
+ --bn-solid:#d4f07a; --bn-on-solid:#141414;
43
+ --bn-toast-bg:#34302c; --bn-toast-fg:#f6f3ec;
40
44
  }
41
45
  }
42
46
  .bn-root{display:grid;grid-template-columns:minmax(0,208px) minmax(0,1fr);height:100%;min-height:520px;width:100%;max-width:100%;min-width:0;overflow:hidden;background:var(--bn-bg);color:var(--bn-ink);font:13px/1.55 var(--bn-font);-webkit-font-smoothing:antialiased}
@@ -45,7 +49,7 @@
45
49
  .bn-logo{display:flex;align-items:center;gap:9px;padding:2px 8px 16px;font-weight:680;letter-spacing:-.01em}
46
50
  .bn-logo .dot{width:22px;height:22px;border-radius:7px;background:var(--bn-ink);box-shadow:inset 0 0 0 2.5px var(--bn-accent),0 2px 8px rgba(0,0,0,.18);overflow:hidden}
47
51
  .bn-logo .dot img{width:100%;height:100%;object-fit:cover;display:block}
48
- .bn-tile img{width:100%;height:100%;object-fit:cover;display:block;border-radius:inherit}
52
+ .bn-tile img,.bn-dd-ico img{width:100%;height:100%;object-fit:cover;display:block;border-radius:0;transform:scale(1.08)}
49
53
  .bn-nav{display:flex;flex-direction:column;gap:2px}
50
54
  .bn-nav button{display:flex;align-items:center;gap:9px;width:100%;border:0;background:transparent;color:var(--bn-muted);padding:8px 10px;border-radius:8px;cursor:pointer;font:inherit;text-align:left;transition:background .12s,color .12s}
51
55
  .bn-nav button:hover{background:var(--bn-line);color:var(--bn-ink-2)}
@@ -86,7 +90,7 @@
86
90
  .bn-wx{display:flex;align-items:center;justify-content:space-between;gap:12px;border:1px solid var(--bn-line);border-radius:12px;padding:10px 10px 10px 12px;text-align:left;background:var(--bn-surface-2)}
87
91
  .bn-wx .label{font-size:11px;color:var(--bn-muted)}
88
92
  .bn-wx code{display:block;margin-top:2px;font-family:var(--bn-mono);font-size:14px;color:var(--bn-ink);letter-spacing:.01em}
89
- .bn-wx .bn-btn{height:30px;padding:0 12px;background:var(--bn-ink);color:var(--bn-accent);border-color:var(--bn-ink)}
93
+ .bn-wx .bn-btn{height:30px;padding:0 12px;background:var(--bn-solid);color:var(--bn-on-solid);border-color:var(--bn-solid)}
90
94
  .bn-manual{display:flex;align-items:center;justify-content:center;width:100%;margin-top:14px;height:36px;text-decoration:none;box-sizing:border-box}
91
95
  .bn-main{overflow:auto;overflow-x:hidden;padding:22px 26px 40px;min-width:0;max-width:100%}
92
96
  .bn-head{display:flex;align-items:flex-start;gap:12px;margin-bottom:20px}
@@ -96,7 +100,7 @@
96
100
  .bn-btn{display:inline-flex;align-items:center;gap:6px;flex:0 0 auto;white-space:nowrap;border:1px solid var(--bn-line-strong);background:var(--bn-surface);color:var(--bn-ink);border-radius:8px;padding:6px 11px;font:inherit;font-size:12px;cursor:pointer;transition:transform .08s,box-shadow .12s,background .12s,opacity .12s}
97
101
  .bn-btn:hover{box-shadow:var(--bn-shadow)}
98
102
  .bn-btn:active{transform:translateY(1px)}
99
- .bn-btn.primary{background:var(--bn-ink);color:var(--bn-accent);border-color:var(--bn-ink)}
103
+ .bn-btn.primary{background:var(--bn-solid);color:var(--bn-on-solid);border-color:var(--bn-solid)}
100
104
  .bn-btn.ghost{border-color:transparent;background:transparent;color:var(--bn-muted)}
101
105
  .bn-btn.ghost:hover{background:var(--bn-line);color:var(--bn-ink)}
102
106
  .bn-btn.danger{color:var(--bn-bad);border-color:var(--bn-bad);background:transparent}
@@ -116,7 +120,7 @@
116
120
  .bn-un{height:22px;padding:0 8px;border-radius:999px;border:1px solid var(--bn-line);background:color-mix(in srgb,var(--bn-surface) 82%,transparent);color:var(--bn-muted);font:inherit;font-size:11px;line-height:1;cursor:pointer}
117
121
  .bn-un:hover{color:var(--bn-bad);border-color:transparent;background:var(--bn-bad-soft)}
118
122
  .bn-un:disabled{opacity:.42;cursor:not-allowed}
119
- .bn-tile{width:40px;height:40px;border-radius:11px;display:grid;place-items:center;font-weight:700;font-size:15px;color:var(--bn-accent);background:var(--bn-ink);flex:0 0 auto}
123
+ .bn-tile{width:40px;height:40px;border-radius:12px;overflow:hidden;display:grid;place-items:center;font-weight:700;font-size:15px;color:var(--bn-accent);background:#111;flex:0 0 auto;line-height:0}
120
124
  .bn-name{font-weight:640;font-size:14px;letter-spacing:-.01em;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
121
125
  .bn-meta{color:var(--bn-muted);font-size:11.5px;margin-top:1px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
122
126
  .bn-card .status{position:absolute;top:14px;right:14px;z-index:1;display:flex;align-items:center;gap:6px;max-width:none}
@@ -163,8 +167,8 @@
163
167
  .bn-dd-item.on .bn-dd-hint{color:var(--bn-muted)}
164
168
  .bn-dd-check{flex:0 0 auto;color:var(--bn-ink);margin-left:auto}
165
169
  .bn-dd-hint + .bn-dd-check{margin-left:0}
166
- .bn-dd-ico{width:22px;height:22px;min-width:22px;max-width:22px;min-height:22px;max-height:22px;border-radius:6px;overflow:hidden;flex:0 0 22px;background:var(--bn-ink);color:var(--bn-accent);display:grid;place-items:center;font-size:11px;font-weight:700}
167
- .bn-dd-ico img{width:22px;height:22px;max-width:22px;max-height:22px;object-fit:cover;display:block}
170
+ .bn-dd-ico{width:22px;height:22px;min-width:22px;max-width:22px;min-height:22px;max-height:22px;border-radius:6px;overflow:hidden;flex:0 0 22px;background:#111;color:var(--bn-accent);display:grid;place-items:center;font-size:11px;font-weight:700;line-height:0}
171
+ .bn-dd-ico img{width:22px;height:22px;max-width:22px;max-height:22px}
168
172
  .bn-dd-item.rich{align-items:center;padding:8px 9px}
169
173
  .bn-dd-copy{flex:1;min-width:0;display:flex;flex-direction:column;gap:1px}
170
174
  .bn-dd-item.rich .bn-dd-item-label{flex:none;font-weight:600}
@@ -201,7 +205,7 @@
201
205
  .bn-progress i{display:block;height:100%;background:var(--bn-accent);border-radius:3px;transition:width .3s ease}
202
206
  .bn-task.done .bn-progress i{background:var(--bn-ok)}
203
207
  .bn-task.failed .bn-progress i{background:var(--bn-bad)}
204
- .bn-toast{position:fixed;left:50%;bottom:22px;transform:translateX(-50%);background:var(--bn-ink);color:var(--bn-accent);padding:9px 14px;border-radius:10px;font-size:12.5px;box-shadow:var(--bn-shadow-hover);z-index:50}
208
+ .bn-toast{position:fixed;left:50%;bottom:22px;transform:translateX(-50%);background:var(--bn-toast-bg);color:var(--bn-toast-fg);border:1px solid var(--bn-line-strong);padding:9px 14px;border-radius:10px;font-size:12.5px;box-shadow:var(--bn-shadow-hover);z-index:50}
205
209
  .bn-toast.bad{background:var(--bn-bad);color:#fff}
206
210
  .bn-modal-back{position:fixed;inset:0;background:rgba(10,10,10,.42);display:grid;place-items:center;z-index:40;padding:20px}
207
211
  .bn-modal{width:min(460px,100%);background:var(--bn-surface);border-radius:16px;border:1px solid var(--bn-line);box-shadow:var(--bn-shadow-hover);padding:20px}
@@ -693,7 +697,7 @@
693
697
  setPendingPerm(agent || { id });
694
698
  setModal('permissions');
695
699
  } else if (err.message && err.message.indexOf('未授权') >= 0) {
696
- setProductInput(id === 'biureel' ? 'biureel' : 'biutalk');
700
+ setProductInput(id || 'biutalk');
697
701
  setTab('account');
698
702
  setToast({ text: err.message, bad: true });
699
703
  } else {
@@ -1003,6 +1007,7 @@
1003
1007
  if (!opts.length) {
1004
1008
  push('biutalk', 'BiuTalk', '商店未连通时的兜底', 'icon://biutalk');
1005
1009
  push('biureel', 'BiuReel', '商店未连通时的兜底', 'icon://biureel');
1010
+ push('biuvibe', 'BiuVibe', '商店未连通时的兜底', 'icon://biuvibe');
1006
1011
  }
1007
1012
  return opts;
1008
1013
  })(),
package/index.js CHANGED
@@ -10,7 +10,6 @@ import path15 from "node:path";
10
10
 
11
11
  // src/host/app.js
12
12
  import crypto8 from "node:crypto";
13
- import { spawn as spawn2 } from "node:child_process";
14
13
  import fs14 from "node:fs";
15
14
  import path14 from "node:path";
16
15
  import { fileURLToPath as fileURLToPath2 } from "node:url";
@@ -7195,7 +7194,9 @@ var DeviceViewSchema = external_exports.object({
7195
7194
  appVersion: external_exports.string(),
7196
7195
  firstSeen: external_exports.string(),
7197
7196
  lastSeen: external_exports.string(),
7198
- status: external_exports.enum(["active", "released", "blocked"])
7197
+ status: external_exports.enum(["active", "released", "blocked"]),
7198
+ runCount: external_exports.number().int().nonnegative().default(0),
7199
+ lastRunAt: external_exports.string().nullable().default(null)
7199
7200
  });
7200
7201
 
7201
7202
  // ../panel-core/src/verify.ts
@@ -7323,15 +7324,13 @@ import crypto2 from "node:crypto";
7323
7324
  var AGENT_NPM_PACKAGES = {
7324
7325
  biureel: "@biunow/agent-biureel",
7325
7326
  biutalk: "@biunow/agent-biutalk",
7326
- biuremtion: "@biunow/agent-biuremtion"
7327
+ biuremtion: "@biunow/agent-biuremtion",
7328
+ biuvibe: "@biunow/agent-biuvibe"
7327
7329
  };
7328
7330
  function agentNpmPackage(slug) {
7329
7331
  const key = String(slug || "").trim();
7330
7332
  return AGENT_NPM_PACKAGES[key] ?? null;
7331
7333
  }
7332
- function isNpmRuntimeName(name2) {
7333
- return /-npm$/i.test(String(name2 || ""));
7334
- }
7335
7334
  function registryPackageUrl(registry, name2, version) {
7336
7335
  const base = String(registry || "").replace(/\/$/, "");
7337
7336
  const scoped = name2.startsWith("@") ? name2.replace("/", "%2f") : name2;
@@ -9061,88 +9060,36 @@ function createPanelApp(options = {}) {
9061
9060
  stillMissing: missingRuntime(paths, list)
9062
9061
  };
9063
9062
  }
9064
- function npmBin() {
9065
- return process.platform === "win32" ? "npm.cmd" : "npm";
9066
- }
9067
- function runNpm(args, cwd) {
9068
- return new Promise((resolve, reject) => {
9069
- const child = spawn2(npmBin(), args, {
9070
- cwd,
9071
- env: process.env,
9072
- shell: process.platform === "win32",
9073
- windowsHide: true
9074
- });
9075
- let log = "";
9076
- const take = (buf) => {
9077
- log += buf.toString("utf8");
9078
- if (log.length > 4e3) log = log.slice(-4e3);
9079
- };
9080
- child.stdout?.on("data", take);
9081
- child.stderr?.on("data", take);
9082
- const timer = setTimeout(() => {
9083
- child.kill();
9084
- reject(new Error("\u8FD0\u884C\u73AF\u5883\u5B89\u88C5\u8D85\u65F6\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5"));
9085
- }, 6e5);
9086
- child.on("error", (err) => {
9087
- clearTimeout(timer);
9088
- reject(err);
9089
- });
9090
- child.on("close", (code) => {
9091
- clearTimeout(timer);
9092
- if (code) {
9093
- console.warn("[biunow-panel] runtime install:", (log || `exit ${code}`).trim().slice(-800));
9094
- reject(new Error("\u8FD0\u884C\u73AF\u5883\u5B89\u88C5\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5"));
9095
- } else resolve();
9096
- });
9063
+ async function sha256OfFile(file) {
9064
+ const hash = crypto8.createHash("sha256");
9065
+ await new Promise((resolve, reject) => {
9066
+ const input = fs14.createReadStream(file);
9067
+ input.on("error", reject);
9068
+ hash.on("error", reject);
9069
+ hash.on("finish", resolve);
9070
+ input.pipe(hash);
9097
9071
  });
9072
+ return hash.digest("hex");
9098
9073
  }
9099
- async function runtimePackageJson(registry, name2, major) {
9100
- const res = await fetch(registryPackageUrl(registry, name2), { headers: { accept: "application/json" } });
9101
- if (res.status === 404) {
9102
- throw new Error("\u8FD0\u884C\u73AF\u5883\u8FD8\u5728\u540C\u6B65\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5");
9103
- }
9104
- if (!res.ok) throw new Error("\u8FD0\u884C\u73AF\u5883\u6682\u65F6\u4E0B\u8F7D\u4E0D\u4E86\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5");
9105
- const doc = await res.json();
9106
- const versions = Object.keys(doc.versions || {}).filter((v2) => v2 === String(major) || v2.startsWith(`${major}.`));
9107
- if (!versions.length) throw new Error("\u8FD0\u884C\u73AF\u5883\u8FD8\u5728\u540C\u6B65\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5");
9108
- versions.sort((a, b2) => compareVersions(a, b2));
9109
- const chosen = versions[versions.length - 1];
9110
- const meta = doc.versions[chosen] || {};
9111
- const pkg = {
9112
- name: name2,
9113
- version: chosen,
9114
- license: meta.license || "UNLICENSED",
9115
- dependencies: meta.dependencies || {}
9116
- };
9117
- if (meta.overrides) pkg.overrides = meta.overrides;
9118
- return pkg;
9119
- }
9120
- async function installNpmRuntimeFromRegistry(name2, major) {
9121
- const dir = runtimeDir(paths, { name: name2, major: Number(major) });
9122
- if (fs14.existsSync(path14.join(dir, "manifest.json")) && fs14.existsSync(path14.join(dir, "node_modules"))) return dir;
9123
- fs14.rmSync(dir, { recursive: true, force: true });
9124
- fs14.mkdirSync(dir, { recursive: true });
9125
- const registry = panelRegistryBase();
9074
+ function assertNpmRuntimeReady(dir) {
9075
+ let manifest;
9126
9076
  try {
9127
- const pkg = await runtimePackageJson(registry, name2, major);
9128
- fs14.writeFileSync(path14.join(dir, "package.json"), `${JSON.stringify(pkg, null, 2)}
9129
- `);
9130
- await runNpm(["install", "--omit=dev", "--registry", registry, "--no-fund", "--no-audit"], dir);
9131
- } catch (err) {
9077
+ manifest = JSON.parse(fs14.readFileSync(path14.join(dir, "manifest.json"), "utf8"));
9078
+ } catch {
9079
+ return;
9080
+ }
9081
+ if (manifest.kind !== "npm") return;
9082
+ const here = `${process.platform}-${process.arch}`;
9083
+ if (manifest.platform && manifest.platform !== here) {
9132
9084
  fs14.rmSync(dir, { recursive: true, force: true });
9133
- console.warn("[biunow-panel] runtime:", name2, err?.message || err);
9134
- const friendly = /还在同步|暂时下载不了|请稍后再试/.test(err?.message || "") ? err : new Error("\u8FD0\u884C\u73AF\u5883\u5B89\u88C5\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5");
9135
- throw friendly;
9085
+ console.warn("[biunow-panel] runtime platform", manifest.platform, "!=", here);
9086
+ throw new Error("\u8FD0\u884C\u73AF\u5883\u5B89\u88C5\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5");
9136
9087
  }
9137
- if (!fs14.existsSync(path14.join(dir, "node_modules"))) {
9088
+ if (!fs14.existsSync(path14.join(dir, manifest.moduleRoot || "node_modules"))) {
9138
9089
  fs14.rmSync(dir, { recursive: true, force: true });
9090
+ console.warn("[biunow-panel] runtime archive has no node_modules");
9139
9091
  throw new Error("\u8FD0\u884C\u73AF\u5883\u5B89\u88C5\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5");
9140
9092
  }
9141
- fs14.writeFileSync(
9142
- path14.join(dir, "manifest.json"),
9143
- JSON.stringify({ name: name2, major: Number(major), kind: "npm", moduleRoot: "node_modules" }, null, 2)
9144
- );
9145
- return dir;
9146
9093
  }
9147
9094
  async function downloadToFile(url, file) {
9148
9095
  const res2 = await fetch(url, { redirect: "follow" });
@@ -9157,9 +9104,6 @@ function createPanelApp(options = {}) {
9157
9104
  await pipeline(Readable.fromWeb(res2.body), createWriteStream(file));
9158
9105
  }
9159
9106
  async function installRuntimeFromStore(name2, major) {
9160
- if (isNpmRuntimeName(name2)) {
9161
- return installNpmRuntimeFromRegistry(name2, major);
9162
- }
9163
9107
  const url = `${settings.licenseBaseUrl}/v1/store/runtimes/download?name=${encodeURIComponent(name2)}&major=${major}`;
9164
9108
  const res2 = await fetch(url, { headers: { accept: "application/json, application/gzip" } });
9165
9109
  if (!res2.ok) throw new Error("\u7EC4\u4EF6\u6682\u65F6\u4E0B\u8F7D\u4E0D\u4E86\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5");
@@ -9171,7 +9115,7 @@ function createPanelApp(options = {}) {
9171
9115
  if (!body?.url) throw new Error("\u7EC4\u4EF6\u6682\u65F6\u4E0B\u8F7D\u4E0D\u4E86\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5");
9172
9116
  await downloadToFile(body.url, file);
9173
9117
  if (body.sha256 && !/^0+$/.test(String(body.sha256))) {
9174
- const actual = crypto8.createHash("sha256").update(fs14.readFileSync(file)).digest("hex");
9118
+ const actual = await sha256OfFile(file);
9175
9119
  if (actual !== body.sha256) throw new Error("\u7EC4\u4EF6\u65E0\u6CD5\u9A8C\u8BC1\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5");
9176
9120
  }
9177
9121
  } else if (!res2.body) {
@@ -9182,7 +9126,9 @@ function createPanelApp(options = {}) {
9182
9126
  const { Readable } = await import("node:stream");
9183
9127
  await pipeline(Readable.fromWeb(res2.body), createWriteStream(file));
9184
9128
  }
9185
- return importRuntimeArchive(paths, file);
9129
+ const imported = await importRuntimeArchive(paths, file);
9130
+ assertNpmRuntimeReady(imported.dir);
9131
+ return imported;
9186
9132
  }
9187
9133
  async function installPublishedAgent(product, version, sha, distribution) {
9188
9134
  const npmName = agentNpmPackage(product);
@@ -9327,8 +9273,21 @@ function createPanelApp(options = {}) {
9327
9273
  });
9328
9274
  started.set(agent.id, running);
9329
9275
  syncAgentSkills(agent);
9276
+ void reportUsage(product);
9330
9277
  return running;
9331
9278
  }
9279
+ function reportUsage(product) {
9280
+ if (!product || !license.canUseProduct(product)) return;
9281
+ const token = license.tokenFor(product);
9282
+ const base = String(settings.licenseBaseUrl || "").replace(/\/$/, "");
9283
+ if (!token || !base) return;
9284
+ fetch(`${base}/v1/usage`, {
9285
+ method: "POST",
9286
+ headers: { "content-type": "application/json", authorization: `Bearer ${token}` },
9287
+ body: "{}"
9288
+ }).catch(() => {
9289
+ });
9290
+ }
9332
9291
  function agentSummary(agent) {
9333
9292
  const product = productOf(agent);
9334
9293
  const lic = product ? license.statusFor(product) : license.status();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bnpanel",
3
- "version": "0.5.0",
3
+ "version": "0.5.3",
4
4
  "type": "module",
5
5
  "description": "无需AI生图/生视频,本机低配置即可运行的‘解说、动效、风格化’视频创作工厂。",
6
6
  "license": "UNLICENSED",