koishi-plugin-comic 1.0.10 → 1.0.12
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/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +192 -153
- package/lib/index.js.map +1 -1
- package/package.json +60 -60
- package/lib/comic-api.d.ts +0 -70
- package/lib/comic-api.d.ts.map +0 -1
- package/lib/comic-api.js +0 -110
- package/lib/comic-api.js.map +0 -1
- package/lib/tools.d.ts +0 -112
- package/lib/tools.d.ts.map +0 -1
- package/lib/tools.js +0 -317
- package/lib/tools.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,60 +1,60 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "koishi-plugin-comic",
|
|
3
|
-
"description": "聚合漫画搜索与下载插件,支持禁漫天堂和哔咔漫画,需要自部署 comic-api 后端。支持 ChatLuna 工具调用。",
|
|
4
|
-
"version": "1.0.
|
|
5
|
-
"main": "lib/index.js",
|
|
6
|
-
"typings": "lib/index.d.ts",
|
|
7
|
-
"files": [
|
|
8
|
-
"lib",
|
|
9
|
-
"dist"
|
|
10
|
-
],
|
|
11
|
-
"license": "MIT",
|
|
12
|
-
"repository": {
|
|
13
|
-
"type": "git",
|
|
14
|
-
"url": "git+https://github.com/lumia1998/koishi-plugin-comic.git"
|
|
15
|
-
},
|
|
16
|
-
"bugs": {
|
|
17
|
-
"url": "https://github.com/lumia1998/koishi-plugin-comic/issues"
|
|
18
|
-
},
|
|
19
|
-
"homepage": "https://github.com/lumia1998/koishi-plugin-comic#readme",
|
|
20
|
-
"contributors": [
|
|
21
|
-
"lumia.wang <fenglian19980510@gmail.com>"
|
|
22
|
-
],
|
|
23
|
-
"keywords": [
|
|
24
|
-
"chatbot",
|
|
25
|
-
"koishi",
|
|
26
|
-
"plugin",
|
|
27
|
-
"comic",
|
|
28
|
-
"jmcomic",
|
|
29
|
-
"bika",
|
|
30
|
-
"chatluna"
|
|
31
|
-
],
|
|
32
|
-
"peerDependencies": {
|
|
33
|
-
"koishi": "^4.18.
|
|
34
|
-
"koishi-plugin-chatluna": "^1.3
|
|
35
|
-
},
|
|
36
|
-
"peerDependenciesMeta": {
|
|
37
|
-
"koishi-plugin-chatluna": {
|
|
38
|
-
"optional": true
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
|
-
"koishi": {
|
|
42
|
-
"service": {
|
|
43
|
-
"required": [
|
|
44
|
-
"http"
|
|
45
|
-
],
|
|
46
|
-
"optional": [
|
|
47
|
-
"chatluna"
|
|
48
|
-
]
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
|
-
"dependencies": {
|
|
52
|
-
"@koishijs/plugin-http": "^0.6.0"
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
}
|
|
60
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "koishi-plugin-comic",
|
|
3
|
+
"description": "聚合漫画搜索与下载插件,支持禁漫天堂和哔咔漫画,需要自部署 comic-api 后端。支持 ChatLuna 工具调用。",
|
|
4
|
+
"version": "1.0.12",
|
|
5
|
+
"main": "lib/index.js",
|
|
6
|
+
"typings": "lib/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"lib",
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "git+https://github.com/lumia1998/koishi-plugin-comic.git"
|
|
15
|
+
},
|
|
16
|
+
"bugs": {
|
|
17
|
+
"url": "https://github.com/lumia1998/koishi-plugin-comic/issues"
|
|
18
|
+
},
|
|
19
|
+
"homepage": "https://github.com/lumia1998/koishi-plugin-comic#readme",
|
|
20
|
+
"contributors": [
|
|
21
|
+
"lumia.wang <fenglian19980510@gmail.com>"
|
|
22
|
+
],
|
|
23
|
+
"keywords": [
|
|
24
|
+
"chatbot",
|
|
25
|
+
"koishi",
|
|
26
|
+
"plugin",
|
|
27
|
+
"comic",
|
|
28
|
+
"jmcomic",
|
|
29
|
+
"bika",
|
|
30
|
+
"chatluna"
|
|
31
|
+
],
|
|
32
|
+
"peerDependencies": {
|
|
33
|
+
"koishi": "^4.18.0",
|
|
34
|
+
"koishi-plugin-chatluna": "^1.0.3"
|
|
35
|
+
},
|
|
36
|
+
"peerDependenciesMeta": {
|
|
37
|
+
"koishi-plugin-chatluna": {
|
|
38
|
+
"optional": true
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"koishi": {
|
|
42
|
+
"service": {
|
|
43
|
+
"required": [
|
|
44
|
+
"http"
|
|
45
|
+
],
|
|
46
|
+
"optional": [
|
|
47
|
+
"chatluna"
|
|
48
|
+
]
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
"dependencies": {
|
|
52
|
+
"@koishijs/plugin-http": "^0.6.0"
|
|
53
|
+
},
|
|
54
|
+
"devDependencies": {
|
|
55
|
+
"@langchain/core": "^0.3.80",
|
|
56
|
+
"koishi": "^4.18.0",
|
|
57
|
+
"typescript": "^5.9.3",
|
|
58
|
+
"zod": "3.25.76"
|
|
59
|
+
}
|
|
60
|
+
}
|
package/lib/comic-api.d.ts
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { Context } from 'koishi';
|
|
2
|
-
export interface Config {
|
|
3
|
-
apiBase: string;
|
|
4
|
-
concurrency: number;
|
|
5
|
-
logInfo: boolean;
|
|
6
|
-
pdfPassword?: string;
|
|
7
|
-
}
|
|
8
|
-
export interface ComicItem {
|
|
9
|
-
id: string;
|
|
10
|
-
title: string;
|
|
11
|
-
author?: string;
|
|
12
|
-
source?: string;
|
|
13
|
-
cover?: string;
|
|
14
|
-
}
|
|
15
|
-
export interface SearchResult {
|
|
16
|
-
keyword: string;
|
|
17
|
-
best_match: ComicItem | null;
|
|
18
|
-
all_results: {
|
|
19
|
-
jm: ComicItem[];
|
|
20
|
-
bika: ComicItem[];
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
export interface ComicDetail {
|
|
24
|
-
title: string;
|
|
25
|
-
author?: string;
|
|
26
|
-
description?: string;
|
|
27
|
-
cover?: string;
|
|
28
|
-
source?: string;
|
|
29
|
-
chapters: {
|
|
30
|
-
id: string;
|
|
31
|
-
name: string;
|
|
32
|
-
}[];
|
|
33
|
-
}
|
|
34
|
-
export interface ApiResponse<T = any> {
|
|
35
|
-
success: boolean;
|
|
36
|
-
data?: T;
|
|
37
|
-
error?: string;
|
|
38
|
-
}
|
|
39
|
-
export declare function getPdfPassword(source: string, comicId: string, chapterId: string): string;
|
|
40
|
-
export declare function sanitizeFilename(name: string): string;
|
|
41
|
-
export declare function determineSource(id: string): {
|
|
42
|
-
source: 'jm' | 'bika';
|
|
43
|
-
id: string;
|
|
44
|
-
} | null;
|
|
45
|
-
export declare function formatComics(comics: ComicItem[], sourceLabel?: string): string;
|
|
46
|
-
/**
|
|
47
|
-
* 封装 comic-api 后端的 HTTP 访问,命令与 ChatLuna 工具共用。
|
|
48
|
-
*/
|
|
49
|
-
export declare class ComicAPI {
|
|
50
|
-
private ctx;
|
|
51
|
-
private config;
|
|
52
|
-
constructor(ctx: Context, config: Config);
|
|
53
|
-
get apiBase(): string;
|
|
54
|
-
get concurrency(): number;
|
|
55
|
-
resolvePassword(source: string, comicId: string, chapterId: string): string;
|
|
56
|
-
get<T = any>(path: string, params?: Record<string, string>): Promise<T>;
|
|
57
|
-
search(keyword: string): Promise<SearchResult>;
|
|
58
|
-
detail(source: 'jm' | 'bika', id: string): Promise<ComicDetail>;
|
|
59
|
-
/**
|
|
60
|
-
* 解析用户输入:可能是 ID(jm/bika),也可能是名字(需搜索)。
|
|
61
|
-
* 返回确定的 source 与 id,解析失败返回 null。
|
|
62
|
-
*/
|
|
63
|
-
resolveTarget(input: string): Promise<{
|
|
64
|
-
source: 'jm' | 'bika';
|
|
65
|
-
id: string;
|
|
66
|
-
} | null>;
|
|
67
|
-
buildDownloadUrl(source: 'jm' | 'bika', id: string, chapterId: string, title: string, chapterName: string, password: string): string;
|
|
68
|
-
downloadPdf(url: string): Promise<Buffer>;
|
|
69
|
-
}
|
|
70
|
-
//# sourceMappingURL=comic-api.d.ts.map
|
package/lib/comic-api.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"comic-api.d.ts","sourceRoot":"","sources":["../src/comic-api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;AAGhC,MAAM,WAAW,MAAM;IACrB,OAAO,EAAE,MAAM,CAAA;IACf,WAAW,EAAE,MAAM,CAAA;IACnB,OAAO,EAAE,OAAO,CAAA;IAChB,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAED,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAA;IACf,UAAU,EAAE,SAAS,GAAG,IAAI,CAAA;IAC5B,WAAW,EAAE;QACX,EAAE,EAAE,SAAS,EAAE,CAAA;QACf,IAAI,EAAE,SAAS,EAAE,CAAA;KAClB,CAAA;CACF;AAED,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,CAAA;CACzC;AAED,MAAM,WAAW,WAAW,CAAC,CAAC,GAAG,GAAG;IAClC,OAA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,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IAYzF,gBAAgB,CAAC,MAAM,EAAE,IAAI,GAAG,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM;IAS9H,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAKhD"}
|
package/lib/comic-api.js
DELETED
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ComicAPI = void 0;
|
|
4
|
-
exports.getPdfPassword = getPdfPassword;
|
|
5
|
-
exports.sanitizeFilename = sanitizeFilename;
|
|
6
|
-
exports.determineSource = determineSource;
|
|
7
|
-
exports.formatComics = formatComics;
|
|
8
|
-
const crypto_1 = require("crypto");
|
|
9
|
-
function getPdfPassword(source, comicId, chapterId) {
|
|
10
|
-
const src = source.trim().toLowerCase();
|
|
11
|
-
const seed = `${src}:${comicId}:${chapterId}`;
|
|
12
|
-
const hash = (0, crypto_1.createHash)('sha256').update(seed).digest('hex');
|
|
13
|
-
const value = parseInt(hash.slice(0, 12), 16) % 1000000;
|
|
14
|
-
return value.toString().padStart(6, '0');
|
|
15
|
-
}
|
|
16
|
-
function sanitizeFilename(name) {
|
|
17
|
-
return name.replace(/[\\/:*?"<>|]/g, '_').replace(/\s+/g, '').replace(/_+/g, '_').replace(/^_+|_+$/g, '') || 'comic';
|
|
18
|
-
}
|
|
19
|
-
function determineSource(id) {
|
|
20
|
-
const clean = id.trim();
|
|
21
|
-
const hasJm = /jm/i.test(clean) || /禁漫/i.test(clean);
|
|
22
|
-
const digitMatch = clean.match(/\d+/);
|
|
23
|
-
if (hasJm && digitMatch) {
|
|
24
|
-
return { source: 'jm', id: digitMatch[0] };
|
|
25
|
-
}
|
|
26
|
-
if (/^\d+$/.test(clean)) {
|
|
27
|
-
return { source: 'jm', id: clean };
|
|
28
|
-
}
|
|
29
|
-
if (/^[0-9a-fA-F]{24}$/.test(clean)) {
|
|
30
|
-
return { source: 'bika', id: clean };
|
|
31
|
-
}
|
|
32
|
-
return null;
|
|
33
|
-
}
|
|
34
|
-
function formatComics(comics, sourceLabel = '') {
|
|
35
|
-
if (!comics || comics.length === 0)
|
|
36
|
-
return '没有找到相关漫画。';
|
|
37
|
-
return comics.map((c, i) => {
|
|
38
|
-
const src = c.source === 'jm' ? '禁漫' : c.source === 'bika' ? '哔咔' : sourceLabel;
|
|
39
|
-
return `${i + 1}. [${src}|${c.id}] ${c.title} 作者:${c.author || '佚名'}`;
|
|
40
|
-
}).join('\n');
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* 封装 comic-api 后端的 HTTP 访问,命令与 ChatLuna 工具共用。
|
|
44
|
-
*/
|
|
45
|
-
class ComicAPI {
|
|
46
|
-
constructor(ctx, config) {
|
|
47
|
-
this.ctx = ctx;
|
|
48
|
-
this.config = config;
|
|
49
|
-
}
|
|
50
|
-
get apiBase() {
|
|
51
|
-
return this.config.apiBase.replace(/\/+$/, '');
|
|
52
|
-
}
|
|
53
|
-
get concurrency() {
|
|
54
|
-
return this.config.concurrency;
|
|
55
|
-
}
|
|
56
|
-
resolvePassword(source, comicId, chapterId) {
|
|
57
|
-
return this.config.pdfPassword || getPdfPassword(source, comicId, chapterId);
|
|
58
|
-
}
|
|
59
|
-
async get(path, params) {
|
|
60
|
-
let url = this.apiBase + path;
|
|
61
|
-
if (params) {
|
|
62
|
-
const qs = new URLSearchParams(params).toString();
|
|
63
|
-
if (qs)
|
|
64
|
-
url += '?' + qs;
|
|
65
|
-
}
|
|
66
|
-
if (this.config.logInfo)
|
|
67
|
-
this.ctx.logger('comic').info(`GET ${url}`);
|
|
68
|
-
const res = await this.ctx.http.get(url);
|
|
69
|
-
return res;
|
|
70
|
-
}
|
|
71
|
-
search(keyword) {
|
|
72
|
-
return this.get('/api/search', { keyword });
|
|
73
|
-
}
|
|
74
|
-
detail(source, id) {
|
|
75
|
-
return this.get(`/api/comic/${source}/${id}`);
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* 解析用户输入:可能是 ID(jm/bika),也可能是名字(需搜索)。
|
|
79
|
-
* 返回确定的 source 与 id,解析失败返回 null。
|
|
80
|
-
*/
|
|
81
|
-
async resolveTarget(input) {
|
|
82
|
-
const resolved = determineSource(input);
|
|
83
|
-
if (resolved)
|
|
84
|
-
return resolved;
|
|
85
|
-
const searchResult = await this.search(input);
|
|
86
|
-
const jmList = searchResult.all_results?.jm || [];
|
|
87
|
-
const bikaList = searchResult.all_results?.bika || [];
|
|
88
|
-
if (jmList.length > 0)
|
|
89
|
-
return { source: 'jm', id: jmList[0].id };
|
|
90
|
-
if (bikaList.length > 0)
|
|
91
|
-
return { source: 'bika', id: bikaList[0].id };
|
|
92
|
-
return null;
|
|
93
|
-
}
|
|
94
|
-
buildDownloadUrl(source, id, chapterId, title, chapterName, password) {
|
|
95
|
-
return this.apiBase
|
|
96
|
-
+ `/api/download/${source}/${id}/${chapterId}`
|
|
97
|
-
+ `?title=${encodeURIComponent(title)}`
|
|
98
|
-
+ `&chapter=${encodeURIComponent(chapterName)}`
|
|
99
|
-
+ `&password=${encodeURIComponent(password)}`
|
|
100
|
-
+ `&concurrency=${this.config.concurrency}`;
|
|
101
|
-
}
|
|
102
|
-
async downloadPdf(url) {
|
|
103
|
-
if (this.config.logInfo)
|
|
104
|
-
this.ctx.logger('comic').info(`Downloading: ${url}`);
|
|
105
|
-
const response = await this.ctx.http.get(url, { responseType: 'arraybuffer' });
|
|
106
|
-
return Buffer.from(response);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
exports.ComicAPI = ComicAPI;
|
|
110
|
-
//# sourceMappingURL=comic-api.js.map
|
package/lib/comic-api.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1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EAAE,aAAa,EAAE,CAAC,CAAA;QAC9E,OAAO,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;IAC9B,CAAC;CACF;AAnED,4BAmEC"}
|
package/lib/tools.d.ts
DELETED
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import { Context } from 'koishi';
|
|
2
|
-
import { z } from 'zod';
|
|
3
|
-
import { ComicAPI } from './comic-api';
|
|
4
|
-
declare const StructuredToolBase: any;
|
|
5
|
-
export declare class ComicSearchTool extends StructuredToolBase {
|
|
6
|
-
private api;
|
|
7
|
-
name: string;
|
|
8
|
-
description: string;
|
|
9
|
-
schema: z.ZodObject<{
|
|
10
|
-
keyword: z.ZodString;
|
|
11
|
-
}, "strip", z.ZodTypeAny, {
|
|
12
|
-
keyword: string;
|
|
13
|
-
}, {
|
|
14
|
-
keyword: string;
|
|
15
|
-
}>;
|
|
16
|
-
constructor(api: ComicAPI);
|
|
17
|
-
_call(input: {
|
|
18
|
-
keyword: string;
|
|
19
|
-
}): Promise<string>;
|
|
20
|
-
}
|
|
21
|
-
export declare class ComicDetailTool extends StructuredToolBase {
|
|
22
|
-
private api;
|
|
23
|
-
name: string;
|
|
24
|
-
description: string;
|
|
25
|
-
schema: z.ZodObject<{
|
|
26
|
-
source: z.ZodEnum<["jm", "bika"]>;
|
|
27
|
-
id: z.ZodString;
|
|
28
|
-
}, "strip", z.ZodTypeAny, {
|
|
29
|
-
source: "jm" | "bika";
|
|
30
|
-
id: string;
|
|
31
|
-
}, {
|
|
32
|
-
source: "jm" | "bika";
|
|
33
|
-
id: string;
|
|
34
|
-
}>;
|
|
35
|
-
constructor(api: ComicAPI);
|
|
36
|
-
_call(input: {
|
|
37
|
-
source: 'jm' | 'bika';
|
|
38
|
-
id: string;
|
|
39
|
-
}): Promise<string>;
|
|
40
|
-
}
|
|
41
|
-
export declare class ComicDownloadTool extends StructuredToolBase {
|
|
42
|
-
private api;
|
|
43
|
-
name: string;
|
|
44
|
-
description: string;
|
|
45
|
-
schema: z.ZodObject<{
|
|
46
|
-
id: z.ZodString;
|
|
47
|
-
chapterId: z.ZodOptional<z.ZodString>;
|
|
48
|
-
}, "strip", z.ZodTypeAny, {
|
|
49
|
-
id: string;
|
|
50
|
-
chapterId?: string | undefined;
|
|
51
|
-
}, {
|
|
52
|
-
id: string;
|
|
53
|
-
chapterId?: string | undefined;
|
|
54
|
-
}>;
|
|
55
|
-
constructor(api: ComicAPI);
|
|
56
|
-
_call(input: {
|
|
57
|
-
id: string;
|
|
58
|
-
chapterId?: string;
|
|
59
|
-
}, _runManager?: any, config?: any): Promise<string>;
|
|
60
|
-
}
|
|
61
|
-
export declare class ComicLeaderboardTool extends StructuredToolBase {
|
|
62
|
-
private api;
|
|
63
|
-
name: string;
|
|
64
|
-
description: string;
|
|
65
|
-
schema: z.ZodObject<{
|
|
66
|
-
mode: z.ZodOptional<z.ZodEnum<["day", "week", "month", "total"]>>;
|
|
67
|
-
}, "strip", z.ZodTypeAny, {
|
|
68
|
-
mode?: "day" | "week" | "month" | "total" | undefined;
|
|
69
|
-
}, {
|
|
70
|
-
mode?: "day" | "week" | "month" | "total" | undefined;
|
|
71
|
-
}>;
|
|
72
|
-
constructor(api: ComicAPI);
|
|
73
|
-
_call(input: {
|
|
74
|
-
mode?: 'day' | 'week' | 'month' | 'total';
|
|
75
|
-
}): Promise<string>;
|
|
76
|
-
}
|
|
77
|
-
export declare class ComicCategoryTool extends StructuredToolBase {
|
|
78
|
-
private api;
|
|
79
|
-
name: string;
|
|
80
|
-
description: string;
|
|
81
|
-
schema: z.ZodObject<{
|
|
82
|
-
name: z.ZodString;
|
|
83
|
-
}, "strip", z.ZodTypeAny, {
|
|
84
|
-
name: string;
|
|
85
|
-
}, {
|
|
86
|
-
name: string;
|
|
87
|
-
}>;
|
|
88
|
-
constructor(api: ComicAPI);
|
|
89
|
-
_call(input: {
|
|
90
|
-
name: string;
|
|
91
|
-
}): Promise<string>;
|
|
92
|
-
}
|
|
93
|
-
export declare class ComicBrowseTool extends StructuredToolBase {
|
|
94
|
-
private api;
|
|
95
|
-
name: string;
|
|
96
|
-
description: string;
|
|
97
|
-
schema: z.ZodObject<{
|
|
98
|
-
mode: z.ZodOptional<z.ZodEnum<["latest", "random"]>>;
|
|
99
|
-
}, "strip", z.ZodTypeAny, {
|
|
100
|
-
mode?: "latest" | "random" | undefined;
|
|
101
|
-
}, {
|
|
102
|
-
mode?: "latest" | "random" | undefined;
|
|
103
|
-
}>;
|
|
104
|
-
constructor(api: ComicAPI);
|
|
105
|
-
_call(input: {
|
|
106
|
-
mode?: 'latest' | 'random';
|
|
107
|
-
}): Promise<string>;
|
|
108
|
-
}
|
|
109
|
-
export declare const TOOL_CLASSES: readonly [typeof ComicSearchTool, typeof ComicDetailTool, typeof ComicDownloadTool, typeof ComicLeaderboardTool, typeof ComicCategoryTool, typeof ComicBrowseTool];
|
|
110
|
-
export declare function registerComicTools(ctx: Context, api: ComicAPI): number;
|
|
111
|
-
export {};
|
|
112
|
-
//# sourceMappingURL=tools.d.ts.map
|
package/lib/tools.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAK,MAAM,QAAQ,CAAA;AACnC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAKvB,OAAO,EAAE,QAAQ,EAA+B,MAAM,aAAa,CAAA;AAKnE,QAAA,MAAM,kBAAkB,EAAE,GAAqD,CAAA;AAQ/E,qBAAa,eAAgB,SAAQ,kBAAkB;IAOzC,OAAO,CAAC,GAAG;IANvB,IAAI,SAAiB;IACrB,WAAW,SAAkJ;IAC7J,MAAM;;;;;;OAEJ;gBAEkB,GAAG,EAAE,QAAQ;IAI3B,KAAK,CAAC,KAAK,EAAE;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,MAAM,CAAC;CAwBzD;AAED,qBAAa,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