bnpanel 0.6.2 → 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.
- package/client.js +59 -0
- package/index.js +66 -3
- package/package.json +1 -1
package/client.js
CHANGED
|
@@ -1414,6 +1414,65 @@
|
|
|
1414
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 } } }); }, '已保存') }),
|
|
1415
1415
|
'Studio 立项后自动进入创作(接通 DSH 对话,等同导入 Agent 丢需求)',
|
|
1416
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
|
+
),
|
|
1417
1476
|
state.dsh ? h('p', { className: 'bn-sub', style: { marginTop: 8 } },
|
|
1418
1477
|
'DSH 接通:skill ' + (state.dsh.skills ? '已就绪' : '未注入') + ' · 会话 ' + (state.dsh.chat ? '已就绪' : '未注入') +
|
|
1419
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";
|
|
@@ -7869,7 +7870,8 @@ var Supervisor = class {
|
|
|
7869
7870
|
if (this.running.has(agent.id)) return this.list().find((r) => r.id === agent.id);
|
|
7870
7871
|
const port = await freePort();
|
|
7871
7872
|
const entry = path7.resolve(agent.dir, agent.manifest.entry.host);
|
|
7872
|
-
const
|
|
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);
|
|
7873
7875
|
fs7.mkdirSync(workspace, { recursive: true });
|
|
7874
7876
|
const env = {
|
|
7875
7877
|
...process.env,
|
|
@@ -8054,7 +8056,8 @@ var DEFAULT_SETTINGS = {
|
|
|
8054
8056
|
engineRoots: {},
|
|
8055
8057
|
permissionsAck: {},
|
|
8056
8058
|
autoKickoffInDsh: true,
|
|
8057
|
-
panelNpmRegistry: "https://registry.npmmirror.com"
|
|
8059
|
+
panelNpmRegistry: "https://registry.npmmirror.com",
|
|
8060
|
+
workspaceRoot: null
|
|
8058
8061
|
};
|
|
8059
8062
|
function readSettings(paths) {
|
|
8060
8063
|
if (!fs8.existsSync(paths.settings)) return { ...DEFAULT_SETTINGS };
|
|
@@ -9487,7 +9490,8 @@ function createPanelApp(options = {}) {
|
|
|
9487
9490
|
product: product ?? agent.id,
|
|
9488
9491
|
canExport: entitled,
|
|
9489
9492
|
trial: !licensed && trialLeft > 0,
|
|
9490
|
-
extraEnv: { ...runtimeEnv.env, PANEL_MEMBER: licensed ? "1" : "0" }
|
|
9493
|
+
extraEnv: { ...runtimeEnv.env, PANEL_MEMBER: licensed ? "1" : "0" },
|
|
9494
|
+
workspaceRoot: settings.workspaceRoot || void 0
|
|
9491
9495
|
});
|
|
9492
9496
|
started.set(agent.id, running);
|
|
9493
9497
|
syncAgentSkills(agent);
|
|
@@ -10256,6 +10260,32 @@ function createPanelApp(options = {}) {
|
|
|
10256
10260
|
}
|
|
10257
10261
|
case "GET /settings":
|
|
10258
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
|
+
}
|
|
10259
10289
|
case "POST /settings": {
|
|
10260
10290
|
const body = await readJson(req);
|
|
10261
10291
|
const patch = body.patch ?? body ?? {};
|
|
@@ -10264,7 +10294,40 @@ function createPanelApp(options = {}) {
|
|
|
10264
10294
|
if (typeof patch.autoKickoffInDsh === "boolean") allowed.autoKickoffInDsh = patch.autoKickoffInDsh;
|
|
10265
10295
|
if (typeof patch.autoUpdate === "boolean") allowed.autoUpdate = patch.autoUpdate;
|
|
10266
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;
|
|
10267
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
|
+
}
|
|
10268
10331
|
return send(res, 200, { settings });
|
|
10269
10332
|
}
|
|
10270
10333
|
case "POST /agents/upload":
|