bnpanel 0.6.1 → 0.6.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,7 @@
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="#10181b"/>
3
+ <rect x="16" y="16" width="224" height="224" rx="44" fill="none" stroke="#d8a24a" stroke-width="8"/>
4
+ <path d="M70 170c22-38 34-62 44-62 12 0 8 34 22 34 12 0 18-20 30-44" fill="none" stroke="#d8a24a" stroke-width="10" stroke-linecap="round"/>
5
+ <circle cx="176" cy="82" r="10" fill="#e8d9bd"/>
6
+ <path d="M82 190c24-8 50-8 78 0" fill="none" stroke="#e8d9bd" stroke-width="7" stroke-linecap="round" opacity=".7"/>
7
+ </svg>
package/client.js CHANGED
@@ -868,8 +868,8 @@
868
868
  };
869
869
 
870
870
  const promptsOn = !!(state && state.showcase && state.showcase.promptsEnabled);
871
- const AGENT_ORDER = ['biureel', 'biuremtion', 'biuvibe', 'biutalk'];
872
- const AGENT_FALLBACK = { biureel: 'BiuReel', biuremtion: 'BiuRemo', biuvibe: 'BiuVibe', biutalk: 'BiuTalk' };
871
+ const AGENT_ORDER = ['biureel', 'biuremtion', 'biuvibe', 'biuart', 'biutalk'];
872
+ const AGENT_FALLBACK = { biureel: 'BiuReel', biuremtion: 'BiuRemo', biuvibe: 'BiuVibe', biuart: 'BiuArt', biutalk: 'BiuTalk' };
873
873
  const agentName = (slug) => {
874
874
  const hit = ((state && state.store) || []).find((item) => item.slug === slug);
875
875
  if (hit && hit.name) return hit.name;
@@ -1125,8 +1125,12 @@
1125
1125
  const campaigns = state.license && state.license.canExport ? [] : (state.campaigns || []);
1126
1126
  const camp = campaigns.length ? campaigns[((campIdx % campaigns.length) + campaigns.length) % campaigns.length] : null;
1127
1127
  const campIcons = { spark: '✨', gift: '🎁', rocket: '🚀', crown: '👑', star: '⭐', bolt: '⚡', box: '📦', heart: '💛', fire: '🔥', gem: '💎', party: '🎉', tag: '🏷️' };
1128
- const campHref = camp && state.buyUrl
1129
- ? state.buyUrl + (String(state.buyUrl).indexOf('?') >= 0 ? '&' : '?') + 'c=' + encodeURIComponent(camp.slug)
1128
+ const campHref = camp
1129
+ ? camp.kind === 'link'
1130
+ ? String(camp.linkUrl || '')
1131
+ : state.buyUrl
1132
+ ? state.buyUrl + (String(state.buyUrl).indexOf('?') >= 0 ? '&' : '?') + 'c=' + encodeURIComponent(camp.slug)
1133
+ : ''
1130
1134
  : '';
1131
1135
 
1132
1136
  return h('div', { className: 'bn-root' },
@@ -1150,8 +1154,8 @@
1150
1154
  h('div', { className: 'bn-campaign-name' }, camp.name),
1151
1155
  h('div', { className: 'bn-campaign-desc' }, camp.description || ''),
1152
1156
  h('div', { className: 'bn-campaign-foot' },
1153
- h('div', { className: 'bn-campaign-price' }, '¥' + camp.price),
1154
- campHref ? h('a', { className: 'bn-campaign-go', href: campHref, target: '_blank', rel: 'noreferrer' }, '去看详情') : null,
1157
+ h('div', { className: 'bn-campaign-price' }, camp.kind === 'link' ? '活动' : '¥' + camp.price),
1158
+ campHref ? h('a', { className: 'bn-campaign-go', href: campHref, target: '_blank', rel: 'noreferrer' }, camp.kind === 'link' ? '去看看' : '去看详情') : null,
1155
1159
  ),
1156
1160
  ),
1157
1161
  campaigns.length > 1 ? h('div', { className: 'bn-campaign-dots' },
@@ -1363,6 +1367,7 @@
1363
1367
  push('biutalk', 'BiuTalk', '商店未连通时的兜底', 'icon://biutalk');
1364
1368
  push('biureel', 'BiuReel', '商店未连通时的兜底', 'icon://biureel');
1365
1369
  push('biuvibe', 'BiuVibe', '商店未连通时的兜底', 'icon://biuvibe');
1370
+ push('biuart', 'BiuArt', '商店未连通时的兜底', 'icon://biuart');
1366
1371
  }
1367
1372
  return opts;
1368
1373
  })(),
@@ -1409,6 +1414,65 @@
1409
1414
  h('input', { type: 'checkbox', checked: !(state.settings && state.settings.autoKickoffInDsh === false), onChange: (e) => act(async () => { await api('/settings', { method: 'POST', body: { patch: { autoKickoffInDsh: e.target.checked } } }); }, '已保存') }),
1410
1415
  'Studio 立项后自动进入创作(接通 DSH 对话,等同导入 Agent 丢需求)',
1411
1416
  ),
1417
+ h('div', { style: { marginTop: 14 } },
1418
+ h('div', { className: 'bn-sub', style: { fontSize: 12, marginBottom: 4 } }, '数据目录(Agent 的成片、日志、临时文件都放这里;修改后会自动重启 Agent)'),
1419
+ h('div', { style: { display: 'flex', gap: 6, alignItems: 'center' } },
1420
+ h('input', {
1421
+ type: 'text',
1422
+ id: 'bn-workspace-root-input',
1423
+ key: 'ws-root:' + (state.settings && state.settings.workspaceRoot ? state.settings.workspaceRoot : ''),
1424
+ placeholder: '留空则默认放系统目录',
1425
+ defaultValue: state.settings && state.settings.workspaceRoot ? state.settings.workspaceRoot : '',
1426
+ style: {
1427
+ flex: 1, minWidth: 0, padding: '6px 10px',
1428
+ border: '1px solid var(--bn-line, #ddd)', borderRadius: 6,
1429
+ fontSize: 13, background: '#fff', outline: 'none',
1430
+ },
1431
+ }),
1432
+ h('button', {
1433
+ type: 'button', className: 'bn-btn',
1434
+ style: { background: 'transparent', border: '1px solid var(--bn-line, #ddd)' },
1435
+ onClick: () => {
1436
+ void act(async () => {
1437
+ const r = await api('/pick-dir', { method: 'POST' });
1438
+ if (r && r.dir) {
1439
+ const el = document.getElementById('bn-workspace-root-input');
1440
+ if (el) el.value = r.dir;
1441
+ }
1442
+ }, '正在打开目录选择…');
1443
+ },
1444
+ }, '选择目录…'),
1445
+ h('button', {
1446
+ type: 'button', className: 'bn-btn',
1447
+ onClick: () => {
1448
+ const el = document.getElementById('bn-workspace-root-input');
1449
+ if (!el) return;
1450
+ const val = String(el.value || '').trim();
1451
+ void act(async () => {
1452
+ await api('/settings', { method: 'POST', body: { patch: { workspaceRoot: val || null } } });
1453
+ }, '已保存,Agent 重启中…');
1454
+ },
1455
+ }, '保存'),
1456
+ state.settings && state.settings.workspaceRoot
1457
+ ? h('button', {
1458
+ type: 'button', className: 'bn-btn',
1459
+ style: { background: 'transparent', border: '1px solid var(--bn-line, #ddd)' },
1460
+ onClick: () => {
1461
+ const el = document.getElementById('bn-workspace-root-input');
1462
+ if (el) el.value = '';
1463
+ void act(async () => {
1464
+ await api('/settings', { method: 'POST', body: { patch: { workspaceRoot: null } } });
1465
+ }, '已恢复默认');
1466
+ },
1467
+ }, '恢复默认')
1468
+ : null,
1469
+ ),
1470
+ h('p', { className: 'bn-sub', style: { marginTop: 6, fontSize: 12 } },
1471
+ state.settings && state.settings.workspaceRoot
1472
+ ? `当前生效:${state.settings.workspaceRoot}`
1473
+ : `当前生效:默认系统目录(%LOCALAPPDATA%\\DSH-PANEL\\workspaces)`,
1474
+ ),
1475
+ ),
1412
1476
  state.dsh ? h('p', { className: 'bn-sub', style: { marginTop: 8 } },
1413
1477
  'DSH 接通:skill ' + (state.dsh.skills ? '已就绪' : '未注入') + ' · 会话 ' + (state.dsh.chat ? '已就绪' : '未注入') +
1414
1478
  ((state.dsh.recentKickoffs && state.dsh.recentKickoffs[0])
package/index.js CHANGED
@@ -9,6 +9,7 @@ var __export = (target, all) => {
9
9
  import path15 from "node:path";
10
10
 
11
11
  // src/host/app.js
12
+ import { spawn as spawn2 } from "node:child_process";
12
13
  import crypto8 from "node:crypto";
13
14
  import fs14 from "node:fs";
14
15
  import path14 from "node:path";
@@ -7325,7 +7326,8 @@ var AGENT_NPM_PACKAGES = {
7325
7326
  biureel: "@biunow/agent-biureel",
7326
7327
  biutalk: "@biunow/agent-biutalk",
7327
7328
  biuremtion: "@biunow/agent-biuremtion",
7328
- biuvibe: "@biunow/agent-biuvibe"
7329
+ biuvibe: "@biunow/agent-biuvibe",
7330
+ biuart: "@biunow/agent-biuart"
7329
7331
  };
7330
7332
  function agentNpmPackage(slug) {
7331
7333
  const key = String(slug || "").trim();
@@ -7488,51 +7490,70 @@ function parseRuntimeSpec(spec) {
7488
7490
  if (!name2) throw new Error(`bad runtime spec "${spec}"`);
7489
7491
  return { name: name2, major: version ? Number.parseInt(version, 10) : 0 };
7490
7492
  }
7493
+ function runtimePlatform() {
7494
+ return `${process.platform}-${process.arch}`;
7495
+ }
7491
7496
  function runtimeDir(paths, spec) {
7492
7497
  return path5.join(paths.runtime, spec.name, String(spec.major));
7493
7498
  }
7494
- function resolveRuntime(paths, spec) {
7499
+ function resolveRuntime(paths, spec, platform = runtimePlatform()) {
7495
7500
  const parsed = parseRuntimeSpec(spec);
7496
7501
  const dir = runtimeDir(paths, parsed);
7497
- return fs5.existsSync(path5.join(dir, "manifest.json")) ? dir : null;
7502
+ const manifestPath = path5.join(dir, "manifest.json");
7503
+ if (!fs5.existsSync(manifestPath)) return null;
7504
+ try {
7505
+ const manifest = JSON.parse(fs5.readFileSync(manifestPath, "utf8"));
7506
+ if (manifest?.platform && manifest.platform !== platform) return null;
7507
+ } catch {
7508
+ }
7509
+ return dir;
7498
7510
  }
7499
- function missingRuntime(paths, specs) {
7500
- return specs.filter((s3) => !resolveRuntime(paths, s3));
7511
+ function missingRuntime(paths, specs, platform = runtimePlatform()) {
7512
+ return specs.filter((s3) => !resolveRuntime(paths, s3, platform));
7501
7513
  }
7502
7514
  async function ensureRuntime(paths, spec, source) {
7503
7515
  const parsed = parseRuntimeSpec(spec);
7504
7516
  const dir = runtimeDir(paths, parsed);
7505
- if (fs5.existsSync(path5.join(dir, "manifest.json"))) return dir;
7517
+ const exist = resolveRuntime(paths, spec);
7518
+ if (exist) return exist;
7506
7519
  const staging = path5.join(paths.runtime, ".staging", `${parsed.name}-${parsed.major}-${Date.now()}`);
7507
- fs5.mkdirSync(staging, { recursive: true });
7508
- const archive = path5.join(staging, "payload");
7509
- if (source.kind === "file") {
7510
- fs5.copyFileSync(source.file, archive);
7511
- } else {
7512
- const res = await fetch(source.url);
7513
- if (!res.ok) throw new Error(`runtime download failed: ${res.status} ${res.statusText}`);
7514
- const buf = Buffer.from(await res.arrayBuffer());
7515
- const actual = crypto3.createHash("sha256").update(buf).digest("hex");
7516
- if (actual !== source.sha256) throw new Error(`runtime checksum mismatch for ${spec}`);
7517
- fs5.writeFileSync(archive, buf);
7518
- }
7519
- const unpacked = path5.join(staging, "unpacked");
7520
- fs5.mkdirSync(unpacked, { recursive: true });
7521
- await So({ file: archive, cwd: unpacked });
7522
- const manifestPath = path5.join(unpacked, "manifest.json");
7523
- if (!fs5.existsSync(manifestPath)) throw new Error(`runtime archive for ${spec} has no manifest.json`);
7524
- const manifest = JSON.parse(fs5.readFileSync(manifestPath, "utf8"));
7525
- for (const entry of manifest.files ?? []) {
7526
- const file = path5.join(unpacked, entry.path);
7527
- if (!fs5.existsSync(file)) throw new Error(`runtime file missing: ${entry.path}`);
7528
- const hash = crypto3.createHash("sha256").update(fs5.readFileSync(file)).digest("hex");
7529
- if (hash !== entry.sha256) throw new Error(`runtime file hash mismatch: ${entry.path}`);
7530
- }
7531
- fs5.rmSync(dir, { recursive: true, force: true });
7532
- fs5.mkdirSync(path5.dirname(dir), { recursive: true });
7533
- fs5.renameSync(unpacked, dir);
7534
- fs5.rmSync(staging, { recursive: true, force: true });
7535
- return dir;
7520
+ try {
7521
+ fs5.mkdirSync(staging, { recursive: true });
7522
+ const archive = path5.join(staging, "payload");
7523
+ if (source.kind === "file") {
7524
+ fs5.copyFileSync(source.file, archive);
7525
+ } else {
7526
+ const res = await fetch(source.url);
7527
+ if (!res.ok) throw new Error(`runtime download failed: ${res.status} ${res.statusText}`);
7528
+ const buf = Buffer.from(await res.arrayBuffer());
7529
+ const actual = crypto3.createHash("sha256").update(buf).digest("hex");
7530
+ if (actual !== source.sha256) throw new Error(`runtime checksum mismatch for ${spec}`);
7531
+ fs5.writeFileSync(archive, buf);
7532
+ }
7533
+ const unpacked = path5.join(staging, "unpacked");
7534
+ fs5.mkdirSync(unpacked, { recursive: true });
7535
+ await So({ file: archive, cwd: unpacked });
7536
+ const manifestPath = path5.join(unpacked, "manifest.json");
7537
+ if (!fs5.existsSync(manifestPath)) throw new Error(`runtime archive for ${spec} has no manifest.json`);
7538
+ const manifest = JSON.parse(fs5.readFileSync(manifestPath, "utf8"));
7539
+ if (manifest.platform && manifest.platform !== runtimePlatform()) {
7540
+ throw new Error(`runtime ${spec} \u662F\u4E3A ${manifest.platform} \u6784\u5EFA\u7684\uFF0C\u5F53\u524D\u8BBE\u5907\u4E3A ${runtimePlatform()}`);
7541
+ }
7542
+ for (const entry of manifest.files ?? []) {
7543
+ const file = path5.join(unpacked, entry.path);
7544
+ if (!fs5.existsSync(file)) throw new Error(`runtime file missing: ${entry.path}`);
7545
+ const hash = crypto3.createHash("sha256").update(fs5.readFileSync(file)).digest("hex");
7546
+ if (hash !== entry.sha256) throw new Error(`runtime file hash mismatch: ${entry.path}`);
7547
+ }
7548
+ fs5.rmSync(dir, { recursive: true, force: true });
7549
+ fs5.mkdirSync(path5.dirname(dir), { recursive: true });
7550
+ fs5.renameSync(unpacked, dir);
7551
+ fs5.rmSync(staging, { recursive: true, force: true });
7552
+ return dir;
7553
+ } catch (err) {
7554
+ fs5.rmSync(staging, { recursive: true, force: true });
7555
+ throw err;
7556
+ }
7536
7557
  }
7537
7558
  async function importRuntimeArchive(paths, file) {
7538
7559
  const os5 = await import("node:os");
@@ -7568,6 +7589,23 @@ function npmModuleRoot(runtimeDirPath, manifest) {
7568
7589
  const fallback = path5.join(runtimeDirPath, "node_modules");
7569
7590
  return fs5.existsSync(fallback) ? fallback : null;
7570
7591
  }
7592
+ function runtimeEnvironment(paths, specs) {
7593
+ const env = {};
7594
+ const pathPrepend = [];
7595
+ for (const spec of specs) {
7596
+ const dir = resolveRuntime(paths, spec);
7597
+ if (!dir) continue;
7598
+ const manifest = readRuntimeManifest(paths, spec);
7599
+ if (!manifest) continue;
7600
+ for (const [key, value] of Object.entries(manifest.env ?? {})) {
7601
+ if (typeof value === "string") env[key] = value.replaceAll("${dir}", dir);
7602
+ }
7603
+ for (const rel of manifest.pathPrepend ?? []) {
7604
+ if (typeof rel === "string" && rel) pathPrepend.push(path5.join(dir, rel));
7605
+ }
7606
+ }
7607
+ return { env, pathPrepend };
7608
+ }
7571
7609
  function linkAgentNpmRuntimes(paths, agentDir2, specs) {
7572
7610
  const engineDir = path5.join(agentDir2, "engine");
7573
7611
  if (!fs5.existsSync(engineDir)) return [];
@@ -7832,7 +7870,8 @@ var Supervisor = class {
7832
7870
  if (this.running.has(agent.id)) return this.list().find((r) => r.id === agent.id);
7833
7871
  const port = await freePort();
7834
7872
  const entry = path7.resolve(agent.dir, agent.manifest.entry.host);
7835
- const workspace = path7.join(this.paths.workspaces, agent.id);
7873
+ const workspaceRoot = opts.workspaceRoot ? path7.isAbsolute(opts.workspaceRoot) ? opts.workspaceRoot : path7.resolve(opts.workspaceRoot) : this.paths.workspaces;
7874
+ const workspace = path7.join(workspaceRoot, agent.id);
7836
7875
  fs7.mkdirSync(workspace, { recursive: true });
7837
7876
  const env = {
7838
7877
  ...process.env,
@@ -8017,7 +8056,8 @@ var DEFAULT_SETTINGS = {
8017
8056
  engineRoots: {},
8018
8057
  permissionsAck: {},
8019
8058
  autoKickoffInDsh: true,
8020
- panelNpmRegistry: "https://registry.npmmirror.com"
8059
+ panelNpmRegistry: "https://registry.npmmirror.com",
8060
+ workspaceRoot: null
8021
8061
  };
8022
8062
  function readSettings(paths) {
8023
8063
  if (!fs8.existsSync(paths.settings)) return { ...DEFAULT_SETTINGS };
@@ -9259,11 +9299,12 @@ function createPanelApp(options = {}) {
9259
9299
  await pipeline(Readable.fromWeb(res2.body), createWriteStream(file));
9260
9300
  }
9261
9301
  async function installRuntimeFromStore(name2, major) {
9262
- const url = `${settings.licenseBaseUrl}/v1/store/runtimes/download?name=${encodeURIComponent(name2)}&major=${major}`;
9302
+ const platform = `${process.platform}-${process.arch}`;
9303
+ const url = `${settings.licenseBaseUrl}/v1/store/runtimes/download?name=${encodeURIComponent(name2)}&major=${major}&platform=${encodeURIComponent(platform)}`;
9263
9304
  const res2 = await fetch(url, { headers: { accept: "application/json, application/gzip" } });
9264
9305
  if (!res2.ok) throw new Error("\u7EC4\u4EF6\u6682\u65F6\u4E0B\u8F7D\u4E0D\u4E86\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5");
9265
9306
  fs14.mkdirSync(paths.downloads, { recursive: true });
9266
- const file = path14.join(paths.downloads, `runtime-${name2}-${major}.tar.gz`);
9307
+ const file = path14.join(paths.downloads, `runtime-${name2}-${major}-${platform}.tar.gz`);
9267
9308
  const type = String(res2.headers.get("content-type") || "");
9268
9309
  if (type.includes("json")) {
9269
9310
  const body = await res2.json();
@@ -9437,6 +9478,11 @@ function createPanelApp(options = {}) {
9437
9478
  e.code = "RUNTIME_LINK_FAILED";
9438
9479
  throw e;
9439
9480
  }
9481
+ const runtimeEnv = runtimeEnvironment(paths, shared);
9482
+ if (runtimeEnv.pathPrepend.length) {
9483
+ const pathKey = Object.keys(process.env).find((key) => key.toUpperCase() === "PATH") || "PATH";
9484
+ runtimeEnv.env[pathKey] = [...runtimeEnv.pathPrepend, process.env[pathKey] || ""].filter(Boolean).join(path14.delimiter);
9485
+ }
9440
9486
  const running = await supervisor.start(agent, {
9441
9487
  engineRoot,
9442
9488
  panelCallbackUrl: publicBase ? `${publicBase}${basePath}/agents/progress` : void 0,
@@ -9444,7 +9490,8 @@ function createPanelApp(options = {}) {
9444
9490
  product: product ?? agent.id,
9445
9491
  canExport: entitled,
9446
9492
  trial: !licensed && trialLeft > 0,
9447
- extraEnv: { PANEL_MEMBER: licensed ? "1" : "0" }
9493
+ extraEnv: { ...runtimeEnv.env, PANEL_MEMBER: licensed ? "1" : "0" },
9494
+ workspaceRoot: settings.workspaceRoot || void 0
9448
9495
  });
9449
9496
  started.set(agent.id, running);
9450
9497
  syncAgentSkills(agent);
@@ -9644,7 +9691,9 @@ function createPanelApp(options = {}) {
9644
9691
  description: String(item.description || ""),
9645
9692
  price: Number(item.price) || 0,
9646
9693
  compareAt: Number(item.compareAt) || 0,
9647
- gradient: String(item.gradient || "lime")
9694
+ gradient: String(item.gradient || "lime"),
9695
+ kind: item.kind === "link" ? "link" : "sale",
9696
+ linkUrl: String(item.linkUrl || "")
9648
9697
  })).filter((item) => item.slug && item.name);
9649
9698
  campaignCache = { at: now, items };
9650
9699
  return items;
@@ -10211,6 +10260,32 @@ function createPanelApp(options = {}) {
10211
10260
  }
10212
10261
  case "GET /settings":
10213
10262
  return send(res, 200, { settings });
10263
+ case "POST /pick-dir": {
10264
+ if (process.platform !== "win32") return send(res, 200, { dir: null, platform: process.platform });
10265
+ try {
10266
+ const script = `[Console]::OutputEncoding = [System.Text.Encoding]::UTF8; Add-Type -AssemblyName System.Windows.Forms; $d = New-Object System.Windows.Forms.FolderBrowserDialog; $d.Description = '\u9009\u62E9 BiuNow Agent \u6570\u636E\u5B58\u653E\u76EE\u5F55'; $d.ShowNewFolderButton = $true; if ($d.ShowDialog() -eq 'OK') { Write-Output $d.SelectedPath } else { Write-Output '' }`;
10267
+ const result = await new Promise((resolve, reject) => {
10268
+ const p2 = spawn2("powershell", ["-NoProfile", "-NonInteractive", "-Command", script], { windowsHide: true });
10269
+ let out = "";
10270
+ let err = "";
10271
+ p2.stdout.on("data", (d) => {
10272
+ out += String(d);
10273
+ });
10274
+ p2.stderr.on("data", (d) => {
10275
+ err += String(d);
10276
+ });
10277
+ p2.on("error", reject);
10278
+ p2.on("close", (code) => {
10279
+ if (code !== 0) reject(new Error(err || `exit ${code}`));
10280
+ else resolve(out.trim());
10281
+ });
10282
+ });
10283
+ const dir = String(result || "").trim();
10284
+ return send(res, 200, { dir: dir || null });
10285
+ } catch (err) {
10286
+ return send(res, 500, { error: err?.message || String(err) });
10287
+ }
10288
+ }
10214
10289
  case "POST /settings": {
10215
10290
  const body = await readJson(req);
10216
10291
  const patch = body.patch ?? body ?? {};
@@ -10219,7 +10294,40 @@ function createPanelApp(options = {}) {
10219
10294
  if (typeof patch.autoKickoffInDsh === "boolean") allowed.autoKickoffInDsh = patch.autoKickoffInDsh;
10220
10295
  if (typeof patch.autoUpdate === "boolean") allowed.autoUpdate = patch.autoUpdate;
10221
10296
  if (typeof patch.concurrency === "number" && Number.isFinite(patch.concurrency)) allowed.concurrency = patch.concurrency;
10297
+ if (Object.prototype.hasOwnProperty.call(patch, "workspaceRoot")) {
10298
+ const raw = String(patch.workspaceRoot ?? "").trim();
10299
+ if (!raw) {
10300
+ allowed.workspaceRoot = null;
10301
+ } else {
10302
+ try {
10303
+ const target = path14.isAbsolute(raw) ? raw : path14.resolve(raw);
10304
+ fs14.mkdirSync(target, { recursive: true });
10305
+ const probe = path14.join(target, `.bnpanel-write-test-${Date.now()}`);
10306
+ fs14.writeFileSync(probe, "ok");
10307
+ fs14.unlinkSync(probe);
10308
+ allowed.workspaceRoot = target;
10309
+ } catch (err) {
10310
+ return send(res, 400, { error: `\u76EE\u5F55\u4E0D\u53EF\u7528\uFF1A${err?.message || err}` });
10311
+ }
10312
+ }
10313
+ }
10314
+ const prevRoot = settings.workspaceRoot || null;
10222
10315
  settings = writeSettings(paths, allowed);
10316
+ const nextRoot = settings.workspaceRoot || null;
10317
+ if (nextRoot !== prevRoot) {
10318
+ const runningSnapshot = supervisor.list();
10319
+ await supervisor.stopAll();
10320
+ started.clear();
10321
+ for (const rec of runningSnapshot) {
10322
+ const agent = listInstalled(paths).find((a) => a.id === rec.id);
10323
+ if (agent) {
10324
+ try {
10325
+ await startAgent(agent);
10326
+ } catch (_2) {
10327
+ }
10328
+ }
10329
+ }
10330
+ }
10223
10331
  return send(res, 200, { settings });
10224
10332
  }
10225
10333
  case "POST /agents/upload":
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bnpanel",
3
- "version": "0.6.1",
3
+ "version": "0.6.3",
4
4
  "type": "module",
5
5
  "description": "无需AI生图/生视频,本机低配置即可运行的‘解说、动效、风格化’视频创作工厂。",
6
6
  "license": "UNLICENSED",