dsh-shlr-bilitoolkit 0.1.25 → 0.1.27
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/AGENTS.md +4 -0
- package/README.md +2 -2
- package/dist/apis/dynamic.d.ts +0 -1
- package/dist/apis/dynamic.js +5 -9
- package/dist/dsh.d.ts +8 -0
- package/dist/dsh.js +7 -1
- package/package.json +1 -1
package/AGENTS.md
CHANGED
|
@@ -5,5 +5,9 @@
|
|
|
5
5
|
**必须调用 bili_gen_qr,并把返回的二维码图片展示给用户扫码**——用 qrDataUrl 以 Markdown 图片 `` 渲染(或引用 qrImageUrl / qrImagePath)。
|
|
6
6
|
禁止只给链接、用 ASCII、让用户自己跑命令。用户确认后调 bili_login_status 完成登录。
|
|
7
7
|
|
|
8
|
+
## 多步查询
|
|
9
|
+
需要多个 B 站数据时(如「视频详情 + 热评 + UP主资料」),尽量在一段代码里完成,不要连续调用多个工具:
|
|
10
|
+
- 独立的只读调用用 `Promise.all` 并发;写操作保持逐条 `await`。
|
|
11
|
+
|
|
8
12
|
## 其它
|
|
9
13
|
写操作(点赞 / 收藏 / 投币 / 关注 / 评论 / 私信 / 三连 / 发动态 / 改资料)会真实修改账号状态,执行前先与用户确认。
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# dsh-shlr-bilitoolkit
|
|
2
2
|
|
|
3
|
-
0.1.15-0.1.19
|
|
3
|
+
0.1.15-0.1.19为工具懒加载版
|
|
4
4
|
|
|
5
5
|
B 站(哔哩哔哩)接口封装的 **TypeScript** 移植版,作为 [dsh](https://dshmp.com)(DeepSeek Harness)插件提供「视频 / 搜索 / 空间」等读取能力。
|
|
6
6
|
|
|
@@ -64,7 +64,7 @@ await client.loadCookies();
|
|
|
64
64
|
const videos = await client.video.recommend(2, 10);
|
|
65
65
|
const detail = await client.video.detail("BV1xx411c7mD");
|
|
66
66
|
const text = await client.video.subtitleText("BV1xx411c7mD"); // 字幕纯文本
|
|
67
|
-
const [videos2, total] = await client.search.videos("
|
|
67
|
+
const [videos2, total] = await client.search.videos("偶像大师");
|
|
68
68
|
const info = await client.space.info(574115689);
|
|
69
69
|
const [ups, _] = await client.space.videos(574115689, 1, 10);
|
|
70
70
|
```
|
package/dist/apis/dynamic.d.ts
CHANGED
|
@@ -8,7 +8,6 @@ import { Dynamic } from "../models.js";
|
|
|
8
8
|
export declare class DynamicAPI {
|
|
9
9
|
private client;
|
|
10
10
|
constructor(client: BiliClient);
|
|
11
|
-
private _detailCache;
|
|
12
11
|
detail(dynamicId: string | number): Promise<Dynamic>;
|
|
13
12
|
feed(page?: number, offset?: string, type?: string): Promise<[Dynamic[], string, boolean]>;
|
|
14
13
|
space(uid: number, offset?: string): Promise<[Dynamic[], string, boolean, number]>;
|
package/dist/apis/dynamic.js
CHANGED
|
@@ -26,19 +26,15 @@ export class DynamicAPI {
|
|
|
26
26
|
client;
|
|
27
27
|
constructor(client) {
|
|
28
28
|
this.client = client;
|
|
29
|
-
this._detailCache = {};
|
|
30
29
|
}
|
|
31
|
-
_detailCache;
|
|
32
30
|
async detail(dynamicId) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
return cached;
|
|
31
|
+
// 动态 id 常超出 JS 安全整数范围(>2^53),绝不能过 Number,否则丢精度、接口报 4101105
|
|
32
|
+
// 不做内存缓存:动态可能被删/改,缓存会返回脏数据,而它只省 HTTP、不省 LLM token。
|
|
33
|
+
const id = String(dynamicId);
|
|
37
34
|
const payload = await this.client.get(endpoints.DYNAMIC_DETAIL, { id, features: FEATURES }, { Referer: `https://t.bilibili.com/${id}` });
|
|
38
35
|
const dynamic = Dynamic.fromApi((payload?.data ?? {}).item);
|
|
39
36
|
if (!dynamic)
|
|
40
37
|
throw new BiliApiError("未找到该动态");
|
|
41
|
-
this._detailCache[id] = dynamic;
|
|
42
38
|
return dynamic;
|
|
43
39
|
}
|
|
44
40
|
async feed(page = 1, offset, type = "all") {
|
|
@@ -182,7 +178,7 @@ export class DynamicAPI {
|
|
|
182
178
|
}
|
|
183
179
|
async repost(dynamicId, text = "") {
|
|
184
180
|
const form = {
|
|
185
|
-
dynamic_id: String(
|
|
181
|
+
dynamic_id: String(dynamicId),
|
|
186
182
|
content: text || "",
|
|
187
183
|
csrf: this.client.csrf,
|
|
188
184
|
csrf_token: this.client.csrf,
|
|
@@ -192,7 +188,7 @@ export class DynamicAPI {
|
|
|
192
188
|
}
|
|
193
189
|
async thumb(dynamicId, liked = true) {
|
|
194
190
|
const body = JSON.stringify({
|
|
195
|
-
dyn_id_str: String(
|
|
191
|
+
dyn_id_str: String(dynamicId),
|
|
196
192
|
up: liked ? 1 : 2,
|
|
197
193
|
});
|
|
198
194
|
await this.client.post(endpoints.DYNAMIC_THUMB, body, {
|
package/dist/dsh.d.ts
CHANGED
|
@@ -38,6 +38,14 @@ export declare const GROUPS: Record<string, {
|
|
|
38
38
|
hint: string;
|
|
39
39
|
ids: string[];
|
|
40
40
|
}>;
|
|
41
|
+
/**
|
|
42
|
+
* 工具输出 schema。必须用 type:"json"(编译成无 type 的注解式 schema,任意 lossless
|
|
43
|
+
* JSON 都放行):我们的工具有的返回数组(recommend / pagelist / subtitles)、有的返回
|
|
44
|
+
* 对象、有的返回标量;若声明 type:"object",数组会被校验器拒("value" must be an object)。
|
|
45
|
+
*/
|
|
46
|
+
export declare const OUTPUT_SCHEMA_SPEC: {
|
|
47
|
+
readonly type: "json";
|
|
48
|
+
};
|
|
41
49
|
export declare function apply(ctx: any): void;
|
|
42
50
|
export * from "./index.js";
|
|
43
51
|
export { BiliClient, Video, User, Page, PlayInfo, Subtitle, Collection };
|
package/dist/dsh.js
CHANGED
|
@@ -1190,10 +1190,16 @@ function closeGroup(group) {
|
|
|
1190
1190
|
if (i >= 0)
|
|
1191
1191
|
groupLru.splice(i, 1);
|
|
1192
1192
|
}
|
|
1193
|
+
/**
|
|
1194
|
+
* 工具输出 schema。必须用 type:"json"(编译成无 type 的注解式 schema,任意 lossless
|
|
1195
|
+
* JSON 都放行):我们的工具有的返回数组(recommend / pagelist / subtitles)、有的返回
|
|
1196
|
+
* 对象、有的返回标量;若声明 type:"object",数组会被校验器拒("value" must be an object)。
|
|
1197
|
+
*/
|
|
1198
|
+
export const OUTPUT_SCHEMA_SPEC = { type: "json" };
|
|
1193
1199
|
/** 把一个内部 DshTool 编译成官方 defineTool 定义。 */
|
|
1194
1200
|
function buildDef(tool) {
|
|
1195
1201
|
const output = {
|
|
1196
|
-
schema:
|
|
1202
|
+
schema: OUTPUT_SCHEMA_SPEC,
|
|
1197
1203
|
render: tool.render ??
|
|
1198
1204
|
((_args, value) => [{ type: "text", text: textOf(value) }]),
|
|
1199
1205
|
};
|