bilisum 1.20.0-alpha.3 → 1.20.0-alpha.4
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/README.md +7 -5
- package/bin/bilisum.js +21 -7
- package/lib/args.js +1 -1
- package/lib/env.js +21 -12
- package/lib/server.js +18 -4
- package/package.json +1 -1
- package/runtime/VERSION +1 -1
- package/runtime/apps/service/pyproject.toml +1 -1
- package/runtime/packages/core/pyproject.toml +1 -1
- package/runtime/packages/infra/pyproject.toml +1 -1
package/README.md
CHANGED
|
@@ -43,6 +43,8 @@ bilisum summarize --help
|
|
|
43
43
|
```bash
|
|
44
44
|
bilisum env # 查看环境状态
|
|
45
45
|
bilisum env use cli # 切换到独立环境
|
|
46
|
+
bilisum desktop # 快捷切换到桌面端环境
|
|
47
|
+
bilisum auto # 恢复自动选择
|
|
46
48
|
bilisum env setup # 初始化独立环境(内置运行时,需 Python 3.12)
|
|
47
49
|
bilisum --setting # 打开当前环境的网页设置(cli 环境无需桌面端)
|
|
48
50
|
bilisum summarize <url> --environment cli # 单次使用某环境
|
|
@@ -60,14 +62,14 @@ bilisum summarize <url> --environment cli # 单次使用某环境
|
|
|
60
62
|
|
|
61
63
|
## 它如何"控制现有程序"
|
|
62
64
|
|
|
63
|
-
-
|
|
65
|
+
- `desktop` 环境连接桌面端服务 `http://127.0.0.1:3838`,任务、结果、知识库都与桌面端**同一个数据库**;默认 `auto` 会优先探测 desktop,不可达时使用 cli 独立环境。
|
|
64
66
|
- 访问令牌自动获取:`--token` → `VIDEO_SUM_ACCESS_TOKEN` → 桌面端自己的 token 文件(`%APPDATA%\BiliSum\access-token.json` 等)→ 服务侧 `{数据根}\data\auth.json`。桌面端正在运行时通常无需任何配置。
|
|
65
|
-
- 数据根默认与桌面端一致(Windows `%LOCALAPPDATA%\bilisum`,macOS `~/Library/Application Support/bilisum
|
|
67
|
+
- desktop 数据根默认与桌面端一致(Windows `%LOCALAPPDATA%\bilisum`,macOS `~/Library/Application Support/bilisum`);cli 使用独立的 `CLI_HOME`。
|
|
66
68
|
- 配置(LLM / ASR Key 等)跟随服务端设置,桌面端里配好了,CLI 直接用。
|
|
67
69
|
|
|
68
70
|
## 服务不在线时
|
|
69
71
|
|
|
70
|
-
`summarize / brief / transcribe / status / tasks`
|
|
72
|
+
`summarize / brief / transcribe / status / tasks` 会先探活当前环境。desktop 不可达时用桌面端数据目录拉起服务,cli 不可达时用 CLI 独立数据目录和 venv 拉起服务;custom 只连接指定地址,不会在本机拉起替代服务。CLI 拉起的服务进程记录在 `{数据根}\cli-runtime-<port>.json`:
|
|
71
73
|
|
|
72
74
|
```bash
|
|
73
75
|
bilisum start --no-open # 前台启动(可选,一般不用)
|
|
@@ -84,13 +86,13 @@ bilisum stop # 停止 CLI 拉起的服务
|
|
|
84
86
|
npm install -g bilisum # 或 npx bilisum ...
|
|
85
87
|
```
|
|
86
88
|
|
|
87
|
-
|
|
89
|
+
包内包含构建独立环境所需的 Python 源码;首次执行 `bilisum env setup` 仍要求系统已有 Python 3.12。
|
|
88
90
|
|
|
89
91
|
## 常用选项
|
|
90
92
|
|
|
91
93
|
| 选项 | 说明 |
|
|
92
94
|
|------|------|
|
|
93
|
-
| `--host / --port` |
|
|
95
|
+
| `--host / --port` | 自定义服务地址(显式指定时进入 custom 环境) |
|
|
94
96
|
| `--data <path>` | 桌面端数据根(默认 `%LOCALAPPDATA%\bilisum`) |
|
|
95
97
|
| `--token <token>` | 访问令牌(默认自动读桌面端 token) |
|
|
96
98
|
| `--format json\|markdown\|transcript` | 输出格式,默认 markdown |
|
package/bin/bilisum.js
CHANGED
|
@@ -51,6 +51,7 @@ function printHelp() {
|
|
|
51
51
|
console.log(" npx bilisum status <task-id> [--json] Show task status");
|
|
52
52
|
console.log(" npx bilisum tasks [--limit N] [--json] List tasks");
|
|
53
53
|
console.log(" npx bilisum env [use <name>|setup] Environment status / switch / setup");
|
|
54
|
+
console.log(" npx bilisum desktop|cli|custom|auto Switch environment (shortcut)");
|
|
54
55
|
console.log(" npx bilisum --setting Open the web settings page");
|
|
55
56
|
console.log(" npx bilisum start [options] Start the service");
|
|
56
57
|
console.log(" npx bilisum stop Stop the CLI-started BiliSum service");
|
|
@@ -60,7 +61,7 @@ function printHelp() {
|
|
|
60
61
|
console.log("");
|
|
61
62
|
console.log("环境(bilisum env):desktop 连桌面端服务 / cli 独立环境(自带运行时)/ custom 自定义 / auto 自动");
|
|
62
63
|
console.log("");
|
|
63
|
-
console.log("
|
|
64
|
+
console.log("默认按已保存的环境连接;auto 模式优先桌面端,否则使用 CLI 独立环境。");
|
|
64
65
|
console.log("");
|
|
65
66
|
console.log("Options (all commands):");
|
|
66
67
|
console.log(" --host <host> Host, default 127.0.0.1");
|
|
@@ -132,7 +133,7 @@ function parseConnectionOptions(args, { allowTaskId = false } = {}) {
|
|
|
132
133
|
} else if (arg === "--token") {
|
|
133
134
|
options.token = readValue(++index, arg);
|
|
134
135
|
} else if (arg === "--environment" || arg === "--env-mode") {
|
|
135
|
-
const name = readValue(++index, arg);
|
|
136
|
+
const name = readValue(++index, arg).toLowerCase();
|
|
136
137
|
if (!ENV_NAMES.includes(name)) {
|
|
137
138
|
throw new UsageError(`--environment 仅支持 ${ENV_NAMES.join(" / ")},收到:${name}`);
|
|
138
139
|
}
|
|
@@ -514,11 +515,12 @@ async function envCommand(args) {
|
|
|
514
515
|
|
|
515
516
|
if (sub === "use") {
|
|
516
517
|
const name = String(args[1] || "").toLowerCase();
|
|
517
|
-
if (!ENV_NAMES.includes(name) ||
|
|
518
|
-
throw new UsageError(`用法:bilisum env use ${ENV_NAMES.
|
|
518
|
+
if (!ENV_NAMES.includes(name) || args.length !== 2) {
|
|
519
|
+
throw new UsageError(`用法:bilisum env use ${ENV_NAMES.join("|")}`);
|
|
519
520
|
}
|
|
520
521
|
writeConfig({ ...config, env: name });
|
|
521
|
-
|
|
522
|
+
const suffix = name === "auto" ? "(桌面端可用时优先 desktop,否则 cli)" : "";
|
|
523
|
+
console.log(`已切换到 ${name} 环境${suffix}。`);
|
|
522
524
|
return;
|
|
523
525
|
}
|
|
524
526
|
|
|
@@ -534,6 +536,10 @@ async function envCommand(args) {
|
|
|
534
536
|
return;
|
|
535
537
|
}
|
|
536
538
|
|
|
539
|
+
if (sub) {
|
|
540
|
+
throw new UsageError(`未知 env 子命令:${sub}`);
|
|
541
|
+
}
|
|
542
|
+
|
|
537
543
|
// default: status
|
|
538
544
|
const current = await resolveEnvironment({ environment: config.env || "auto" });
|
|
539
545
|
const desktopUp = await isDesktopReachable();
|
|
@@ -548,7 +554,7 @@ async function envCommand(args) {
|
|
|
548
554
|
console.log(` custom ${config.custom ? "● 已配置" : "○ 未配置(--host/--port/--token)"}`);
|
|
549
555
|
console.log(` auto desktop 优先,否则 cli`);
|
|
550
556
|
console.log("");
|
|
551
|
-
console.log("切换:bilisum env use desktop|cli|custom");
|
|
557
|
+
console.log("切换:bilisum env use desktop|cli|custom|auto(也可直接 bilisum desktop|cli|custom|auto)");
|
|
552
558
|
if (config.env && config.env !== "auto") {
|
|
553
559
|
console.log(`已持久化选择:${config.env}`);
|
|
554
560
|
}
|
|
@@ -557,7 +563,8 @@ async function envCommand(args) {
|
|
|
557
563
|
function printEnvHelp() {
|
|
558
564
|
console.log("Usage:");
|
|
559
565
|
console.log(" bilisum env Show environment status");
|
|
560
|
-
console.log(" bilisum env use <name> Switch environment (desktop|cli|custom)");
|
|
566
|
+
console.log(" bilisum env use <name> Switch environment (desktop|cli|custom|auto)");
|
|
567
|
+
console.log(" bilisum <name> Shortcut for `bilisum env use <name>`");
|
|
561
568
|
console.log(" bilisum env setup Initialize the standalone cli environment");
|
|
562
569
|
console.log("");
|
|
563
570
|
console.log("Environments:");
|
|
@@ -619,6 +626,13 @@ async function main() {
|
|
|
619
626
|
await envCommand(args);
|
|
620
627
|
return;
|
|
621
628
|
}
|
|
629
|
+
if (ENV_NAMES.includes(command)) {
|
|
630
|
+
if (args.length > 0) {
|
|
631
|
+
throw new UsageError(`用法:bilisum ${command}`);
|
|
632
|
+
}
|
|
633
|
+
await envCommand(["use", command]);
|
|
634
|
+
return;
|
|
635
|
+
}
|
|
622
636
|
if (command === "settings" || command === "--setting" || command === "config") {
|
|
623
637
|
await settingsCommand(args);
|
|
624
638
|
return;
|
package/lib/args.js
CHANGED
|
@@ -74,7 +74,7 @@ function parseTaskCommandArgs(args, { defaultFormat = "markdown" } = {}) {
|
|
|
74
74
|
} else if (arg === "--python") {
|
|
75
75
|
options.python = readValue(args, ++index, arg);
|
|
76
76
|
} else if (arg === "--environment" || arg === "--env-mode") {
|
|
77
|
-
const name = readValue(args, ++index, arg);
|
|
77
|
+
const name = readValue(args, ++index, arg).toLowerCase();
|
|
78
78
|
if (!ENV_NAMES.includes(name)) {
|
|
79
79
|
throw new UsageError(`--environment 仅支持 ${ENV_NAMES.join(" / ")},收到:${name}`);
|
|
80
80
|
}
|
package/lib/env.js
CHANGED
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
* - auto (default): probe 127.0.0.1:3838 — reachable => desktop, else cli.
|
|
14
14
|
*
|
|
15
15
|
* Selection precedence:
|
|
16
|
-
* 1. --
|
|
17
|
-
* 2.
|
|
16
|
+
* 1. explicit --host/--port (treated as a custom target)
|
|
17
|
+
* 2. --environment desktop|cli|custom|auto (one-shot override)
|
|
18
18
|
* 3. config.env persisted by `bilisum env use <name>`
|
|
19
19
|
* 4. auto
|
|
20
20
|
*/
|
|
@@ -74,20 +74,29 @@ async function resolveEnvironment(options = {}) {
|
|
|
74
74
|
const config = readConfig();
|
|
75
75
|
const explicitHost = Boolean(options._hostSet);
|
|
76
76
|
const explicitPort = Boolean(options._portSet);
|
|
77
|
-
const
|
|
77
|
+
const rawFlag = String(options.environment || "").trim();
|
|
78
|
+
const flag = normalizeEnvName(rawFlag);
|
|
78
79
|
|
|
79
|
-
|
|
80
|
+
if (rawFlag && !flag) {
|
|
81
|
+
throw new Error(`未知环境:${rawFlag}。可选值:${ENV_NAMES.join(" / ")}`);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
let requestedEnv;
|
|
80
85
|
if (explicitHost || explicitPort) {
|
|
81
86
|
// Explicit connection target always wins (custom).
|
|
82
|
-
|
|
83
|
-
} else if (flag
|
|
84
|
-
|
|
87
|
+
requestedEnv = "custom";
|
|
88
|
+
} else if (flag) {
|
|
89
|
+
// An explicit `auto` is a real one-shot override. It must not fall back to
|
|
90
|
+
// a persisted desktop/cli/custom selection.
|
|
91
|
+
requestedEnv = flag;
|
|
85
92
|
} else {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
93
|
+
requestedEnv = currentEnvName(config);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
let env = requestedEnv;
|
|
97
|
+
if (env === "auto") {
|
|
98
|
+
const probe = options._desktopProbe || isDesktopReachable;
|
|
99
|
+
env = (await probe()) ? "desktop" : "cli";
|
|
91
100
|
}
|
|
92
101
|
|
|
93
102
|
let host;
|
package/lib/server.js
CHANGED
|
@@ -275,10 +275,17 @@ function buildStartupFailureHint(logPath) {
|
|
|
275
275
|
return `详细日志:${logPath}`;
|
|
276
276
|
}
|
|
277
277
|
|
|
278
|
+
function buildAutoStartMessage(options) {
|
|
279
|
+
const url = baseUrlFor(options.host, options.port);
|
|
280
|
+
const dataRootLabel = options.environment === "cli" ? "CLI 独立数据目录" : "桌面端数据目录";
|
|
281
|
+
return `BiliSum 服务未在 ${url} 运行,正在用 ${dataRootLabel} 后台启动...`;
|
|
282
|
+
}
|
|
283
|
+
|
|
278
284
|
/**
|
|
279
|
-
* Make sure a BiliSum service is reachable. If none is running, start
|
|
280
|
-
*
|
|
281
|
-
*
|
|
285
|
+
* Make sure a BiliSum service is reachable. If none is running, start a local
|
|
286
|
+
* service for the desktop/cli environments. A custom target is connection-only
|
|
287
|
+
* and is never replaced with an unrelated local process. When `accessToken` is
|
|
288
|
+
* known it is injected into the spawned service so CLI and service always agree.
|
|
282
289
|
* Returns { started, payload }.
|
|
283
290
|
*/
|
|
284
291
|
async function ensureService(options, { startupTimeoutMs = DEFAULT_STARTUP_TIMEOUT_MS, log = console.error, accessToken = null } = {}) {
|
|
@@ -287,7 +294,13 @@ async function ensureService(options, { startupTimeoutMs = DEFAULT_STARTUP_TIMEO
|
|
|
287
294
|
return { started: false, payload: await health(url) };
|
|
288
295
|
}
|
|
289
296
|
|
|
290
|
-
|
|
297
|
+
if (options.environment === "custom") {
|
|
298
|
+
throw new Error(
|
|
299
|
+
`无法连接自定义 BiliSum 服务(${url})。请确认服务已启动,并检查 --host/--port 配置。`,
|
|
300
|
+
);
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
log(buildAutoStartMessage(options));
|
|
291
304
|
const { child, logPath } = spawnService(options, { background: true, accessToken });
|
|
292
305
|
const controller = new AbortController();
|
|
293
306
|
const earlyExit = new Promise((resolve) => {
|
|
@@ -396,4 +409,5 @@ module.exports = {
|
|
|
396
409
|
cliServiceLogPath,
|
|
397
410
|
readServiceSettings,
|
|
398
411
|
assertSpawnablePort,
|
|
412
|
+
buildAutoStartMessage,
|
|
399
413
|
};
|
package/package.json
CHANGED
package/runtime/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
1.20.0-alpha.
|
|
1
|
+
1.20.0-alpha.4
|