@xzxzzx/bilibili-mcp 1.13.0 → 1.13.1

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 CHANGED
@@ -10,7 +10,6 @@ Bilibili MCP 是一个本地 MCP server,让 AI Agent 读取 Bilibili 内容。
10
10
 
11
11
  <p align="center">
12
12
  <a href="./README_EN.md">English</a> ·
13
- <a href="#快速了解一个-up-主">快速了解 UP 主</a> ·
14
13
  <a href="./docs/client-setup.md">客户端配置指南</a> ·
15
14
  <a href="./docs/tool-reference.md">工具参考</a> ·
16
15
  <a href="#本地-asr可选">本地 ASR(可选)</a> ·
@@ -56,7 +55,7 @@ Bilibili MCP 是一个本地 MCP server,让 AI Agent 读取 Bilibili 内容。
56
55
  npx -y @xzxzzx/bilibili-mcp@latest check
57
56
  npx -y @xzxzzx/bilibili-mcp@latest doctor --json
58
57
  doctor --json 只检查本机配置状态,不能代替后面的实时登录验证。
59
- setup 会询问是否安装可选的本地 ASR 模型,选否即可。自动化环境可用 setup --non-interactive(凭据来自已有的环境变量或全局配置,绝不提示、也绝不从 stdin/argv 读取凭据值);加 --asr-model <tiny|base|small> 可同时安装指定模型。
58
+ setup 会询问是否安装可选的本地 ASR 模型,选否即可。自动化环境可用 setup --non-interactive(凭据来自已有的环境变量或全局配置,绝不提示、也绝不从 stdin/argv 读取凭据值);加 --asr-model <tiny|base|small> 可同时安装指定模型,--asr-device <auto|cpu|cuda> 选择设备偏好(默认 auto)。
60
59
  5. 让我重启或重连客户端。你无法代替我完成这一步时,请明确让我操作。
61
60
  6. 重连后调用 MCP 工具 check_bilibili_credentials。
62
61
  只有 configured: true 且 logged_in: true 才报告成功。
@@ -169,11 +168,13 @@ Bilibili 会把部分视频的 AI 识别字幕标为 `ai-zh`、`ai-en`、`ai-ja`
169
168
 
170
169
  | 模型 | 大小 | 说明 |
171
170
  |---|---|---|
172
- | tiny | ~78 MB | 最小占用 |
173
- | base | ~148 MB | 折中选择 |
174
- | small | ~486 MB | 推荐,Enter 默认选中 |
171
+ | tiny | ~78 MB | 速度优先:适合快速提取和长视频初筛;准确率相对较低 |
172
+ | base | ~148 MB | 均衡:兼顾速度、质量和资源占用 |
173
+ | small | ~486 MB | 质量优先:耗时和内存占用更高;推荐,Enter 默认选中 |
175
174
 
176
- Runtime 固定为 `faster-whisper==1.2.1`,模型存放在用户目录 `~/.bilibili-mcp/asr/`,通过 CPU INT8 加载验证后才算就绪,不需要系统 FFmpeg;同一目录仅保留一个活跃模型。`doctor --json` 的 `asr.status` 和 `asr.model` 报告就绪状态与已选模型(纯信息字段,不影响凭证退出状态)。
175
+ Runtime 固定为 `faster-whisper==1.2.1` 与 `ctranslate2==4.8.0`,模型存放在用户目录 `~/.bilibili-mcp/asr/`,不需要系统 FFmpeg;同一目录仅保留一个活跃模型。选择模型后还需选择设备偏好:`auto`(默认)先用程序生成的固定短 WAV 完整验证 `cuda/float16`,失败时说明脱敏原因并验证、保存 `cpu/int8`;`cpu` 跳过 GPU;`cuda` 验证失败则报错且不回退。`doctor --json` 会报告实际生效的 `device`、`compute_type`、readiness 与脱敏失败类别。
176
+
177
+ 项目不会安装或修改 NVIDIA 驱动、CUDA、cuBLAS、cuDNN、系统 `PATH`、`LD_LIBRARY_PATH` 或全局 Python。GPU 验证失败后,你可以继续使用已经验证的 CPU,也可以自行修复 GPU 环境后重新运行 `setup`;每次重新运行都会再次验证设备。
177
178
 
178
179
  **边界:**本地转录始终被约束在安全范围内——显式选择、资源受限、Cookie 隔离:
179
180
 
package/README_EN.md CHANGED
@@ -57,7 +57,7 @@ Please help me install the Bilibili MCP server: @xzxzzx/bilibili-mcp.
57
57
  npx -y @xzxzzx/bilibili-mcp@latest check
58
58
  npx -y @xzxzzx/bilibili-mcp@latest doctor --json
59
59
  doctor --json checks local configuration only; it does not replace the live login verification below.
60
- setup will ask about installing the optional local ASR model; choosing no is fine. Automated environments can run setup --non-interactive (credentials come from existing environment variables or the global config file; no prompts, and credential values are never read from stdin/argv); add --asr-model <tiny|base|small> to also install a given model.
60
+ setup will ask about installing the optional local ASR model; choosing no is fine. Automated environments can run setup --non-interactive (credentials come from existing environment variables or the global config file; no prompts, and credential values are never read from stdin/argv); add --asr-model <tiny|base|small> to install a model and --asr-device <auto|cpu|cuda> to choose the device preference (default: auto).
61
61
  5. Ask me to restart or reconnect the client. When you can't do it for me,
62
62
  tell me explicitly to do it myself.
63
63
  6. After reconnect, call the MCP tool check_bilibili_credentials.
@@ -176,11 +176,13 @@ Some videos ship without any subtitle. Once you install a local ASR model, `get_
176
176
 
177
177
  | Model | Size | Notes |
178
178
  |---|---|---|
179
- | tiny | ~78 MB | smallest footprint |
180
- | base | ~148 MB | middle ground |
181
- | small | ~486 MB | recommended, selected on Enter |
179
+ | tiny | ~78 MB | Speed-first: suited to quick extraction and initial review of long videos; relatively lower accuracy |
180
+ | base | ~148 MB | Balanced: balances speed, quality, and resource use |
181
+ | small | ~486 MB | Quality-first: higher runtime and memory use; recommended, selected on Enter |
182
182
 
183
- The runtime is pinned to `faster-whisper==1.2.1`. Models live under `~/.bilibili-mcp/asr/`, are verified by a CPU INT8 load before being marked ready, and do not require system FFmpeg; only one active model is kept per directory. `doctor --json` reports readiness and the selected model via `asr.status` and `asr.model` (informational fields that never affect credential exit codes).
183
+ The runtime is pinned to `faster-whisper==1.2.1` and `ctranslate2==4.8.0`. Models live under `~/.bilibili-mcp/asr/`, do not require system FFmpeg, and only one active model is kept per directory. After choosing a model, choose a device preference: `auto` (default) performs a complete `cuda/float16` check with a generated fixed short WAV, explains a sanitized failure and verifies/saves `cpu/int8` when CUDA is not ready; `cpu` skips GPU probing; `cuda` fails without CPU fallback. `doctor --json` reports the effective device, compute type, readiness, and sanitized failure category.
184
+
185
+ The project never installs or modifies NVIDIA drivers, CUDA, cuBLAS, cuDNN, the system `PATH`, `LD_LIBRARY_PATH`, or global Python. After a GPU failure, you decide whether to keep the verified CPU profile or repair the GPU environment and rerun `setup`; every setup rerun rechecks device readiness.
184
186
 
185
187
  **Boundaries:** local transcription stays within safe bounds — opt-in, resource-capped, Cookie-isolated:
186
188
 
@@ -1,15 +1,22 @@
1
1
  import fs from "fs";
2
- import { type AsrModelKey, type AsrModelSpec, type AsrPaths } from "./state.js";
2
+ import { type AsrExecutionProfile, type AsrDevicePreference, type AsrFailureCategory, type AsrModelKey, type AsrModelSpec, type AsrPaths } from "./state.js";
3
3
  export declare const PYTHON_MIN_MAJOR = 3;
4
4
  export declare const PYTHON_MIN_MINOR = 9;
5
- export declare const COMPUTE_TYPE = "int8";
6
- export declare const DEVICE = "cpu";
5
+ export declare const COMPUTE_TYPE: "int8";
6
+ export declare const DEVICE: "cpu";
7
7
  export interface PythonCommand {
8
8
  executable: string;
9
9
  prefixArgs: string[];
10
10
  }
11
+ export declare class AsrReadinessError extends Error {
12
+ readonly category: AsrFailureCategory;
13
+ readonly device?: AsrExecutionProfile["device"] | undefined;
14
+ readonly gpuFailureCategory?: AsrFailureCategory | undefined;
15
+ readonly allowFallback: boolean;
16
+ constructor(category: AsrFailureCategory, device?: AsrExecutionProfile["device"] | undefined, gpuFailureCategory?: AsrFailureCategory | undefined, allowFallback?: boolean);
17
+ }
11
18
  export declare function buildAsrChildEnv(source: Record<string, string | undefined>): Record<string, string | undefined>;
12
- declare function execFile(file: string, args: string[]): Promise<{
19
+ declare function execFile(file: string, args: string[], signal?: AbortSignal): Promise<{
13
20
  code: number | null;
14
21
  stdout: string;
15
22
  stderr: string;
@@ -23,13 +30,21 @@ export declare function validateModelInstallTree(modelPath: string, maxBytes: nu
23
30
  files: number;
24
31
  };
25
32
  export declare function downloadModel(venvPython: PythonCommand, modelPath: string, modelId: string, revision: string, spawnFn?: typeof execFile, mkdirSyncFn?: typeof fs.mkdirSync, maxBytes?: number): Promise<void>;
26
- export declare function verifyModel(venvPython: PythonCommand, modelPath: string, spawnFn?: typeof execFile): Promise<void>;
33
+ export declare function verifyModel(venvPython: PythonCommand, modelPath: string, executionProfile?: AsrExecutionProfile, spawnFn?: typeof execFile): Promise<void>;
27
34
  export interface InstallResult {
28
35
  success: boolean;
29
36
  error?: string;
30
37
  pythonPath?: string;
38
+ executionProfile?: AsrExecutionProfile;
39
+ failureCategory?: AsrFailureCategory;
40
+ failureDevice?: AsrExecutionProfile["device"];
41
+ gpuFailureCategory?: AsrFailureCategory;
31
42
  asrPaths: AsrPaths;
32
43
  }
44
+ export declare function verifyInstalledDeviceReadiness(paths: Pick<AsrPaths, "venv" | "model">, preference?: AsrDevicePreference, signal?: AbortSignal, spawnFn?: typeof execFile): Promise<{
45
+ executionProfile: AsrExecutionProfile;
46
+ failureCategory?: AsrFailureCategory;
47
+ }>;
33
48
  export declare function runAsrInstallation(options?: {
34
49
  fsMkdirSync?: typeof fs.mkdirSync;
35
50
  fsLstatSync?: typeof fs.lstatSync;
@@ -37,6 +52,7 @@ export declare function runAsrInstallation(options?: {
37
52
  asrBase?: string;
38
53
  pythonOverride?: string;
39
54
  modelKey?: AsrModelKey;
55
+ devicePreference?: AsrDevicePreference;
40
56
  spawnFn?: typeof execFile;
41
57
  onStage?: (stage: string) => void;
42
58
  }): Promise<InstallResult>;
@@ -1 +1 @@
1
- {"version":3,"file":"installer.d.ts","sourceRoot":"","sources":["../../src/asr/installer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB,OAAO,EAKL,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,QAAQ,EAEd,MAAM,YAAY,CAAC;AAEpB,eAAO,MAAM,gBAAgB,IAAI,CAAC;AAClC,eAAO,MAAM,gBAAgB,IAAI,CAAC;AAClC,eAAO,MAAM,YAAY,SAAS,CAAC;AACnC,eAAO,MAAM,MAAM,QAAQ,CAAC;AAO5B,MAAM,WAAW,aAAa;IAC5B,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB;AAuBD,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE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