youtube-knowledge-mcp 2.2.0 → 3.0.0
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 +62 -18
- package/dist/harvest-schemas.d.ts +75 -0
- package/dist/harvest-schemas.d.ts.map +1 -0
- package/dist/harvest-schemas.js +106 -0
- package/dist/harvest-schemas.js.map +1 -0
- package/dist/registry/harvest-tools.d.ts +10 -0
- package/dist/registry/harvest-tools.d.ts.map +1 -0
- package/dist/registry/harvest-tools.js +109 -0
- package/dist/registry/harvest-tools.js.map +1 -0
- package/dist/registry/health-tools.d.ts.map +1 -1
- package/dist/registry/health-tools.js +18 -0
- package/dist/registry/health-tools.js.map +1 -1
- package/dist/registry/index.d.ts.map +1 -1
- package/dist/registry/index.js +2 -0
- package/dist/registry/index.js.map +1 -1
- package/dist/registry/video-tools.js +1 -1
- package/dist/registry/video-tools.js.map +1 -1
- package/dist/schemas.d.ts +239 -0
- package/dist/schemas.d.ts.map +1 -1
- package/dist/schemas.js +56 -0
- package/dist/schemas.js.map +1 -1
- package/dist/thumbnail-schemas.d.ts +28 -28
- package/dist/tools/ask-brain.js +1 -1
- package/dist/tools/ask-brain.js.map +1 -1
- package/dist/tools/brain-info.js +1 -1
- package/dist/tools/brain-info.js.map +1 -1
- package/dist/tools/check-health.d.ts +59 -0
- package/dist/tools/check-health.d.ts.map +1 -1
- package/dist/tools/check-health.js +85 -6
- package/dist/tools/check-health.js.map +1 -1
- package/dist/tools/fetch-channel-thumbnails.d.ts +8 -8
- package/dist/tools/fetch-videos.d.ts +15 -4
- package/dist/tools/fetch-videos.d.ts.map +1 -1
- package/dist/tools/fetch-videos.js +63 -22
- package/dist/tools/fetch-videos.js.map +1 -1
- package/dist/tools/get-comments.d.ts +238 -6
- package/dist/tools/get-comments.d.ts.map +1 -1
- package/dist/tools/get-comments.js +85 -21
- package/dist/tools/get-comments.js.map +1 -1
- package/dist/tools/get-coverage.d.ts +122 -0
- package/dist/tools/get-coverage.d.ts.map +1 -0
- package/dist/tools/get-coverage.js +105 -0
- package/dist/tools/get-coverage.js.map +1 -0
- package/dist/tools/harvest-channel.d.ts +92 -0
- package/dist/tools/harvest-channel.d.ts.map +1 -0
- package/dist/tools/harvest-channel.js +62 -0
- package/dist/tools/harvest-channel.js.map +1 -0
- package/dist/tools/harvest-comments.d.ts +81 -0
- package/dist/tools/harvest-comments.d.ts.map +1 -0
- package/dist/tools/harvest-comments.js +115 -0
- package/dist/tools/harvest-comments.js.map +1 -0
- package/dist/tools/library.js +1 -1
- package/dist/tools/library.js.map +1 -1
- package/dist/tools/list-channel-thumbnails.d.ts +10 -10
- package/dist/tools/list-channel-thumbnails.js +1 -1
- package/dist/tools/list-channel-thumbnails.js.map +1 -1
- package/dist/tools/list-library.js +1 -1
- package/dist/tools/list-library.js.map +1 -1
- package/dist/tools/prune-harvest.d.ts +59 -0
- package/dist/tools/prune-harvest.d.ts.map +1 -0
- package/dist/tools/prune-harvest.js +108 -0
- package/dist/tools/prune-harvest.js.map +1 -0
- package/dist/tools/query-comments.d.ts +125 -0
- package/dist/tools/query-comments.d.ts.map +1 -0
- package/dist/tools/query-comments.js +106 -0
- package/dist/tools/query-comments.js.map +1 -0
- package/dist/tools/query-videos.d.ts +118 -0
- package/dist/tools/query-videos.d.ts.map +1 -0
- package/dist/tools/query-videos.js +97 -0
- package/dist/tools/query-videos.js.map +1 -0
- package/dist/tools/repair-store.d.ts +34 -0
- package/dist/tools/repair-store.d.ts.map +1 -0
- package/dist/tools/repair-store.js +58 -0
- package/dist/tools/repair-store.js.map +1 -0
- package/dist/tools/search-channels.d.ts.map +1 -1
- package/dist/tools/search-channels.js +5 -1
- package/dist/tools/search-channels.js.map +1 -1
- package/dist/tools/search-videos.js +1 -1
- package/dist/tools/search-videos.js.map +1 -1
- package/dist/utils/comment-store.d.ts +71 -0
- package/dist/utils/comment-store.d.ts.map +1 -0
- package/dist/utils/comment-store.js +129 -0
- package/dist/utils/comment-store.js.map +1 -0
- package/dist/utils/comment-threads.d.ts +51 -0
- package/dist/utils/comment-threads.d.ts.map +1 -0
- package/dist/utils/comment-threads.js +76 -0
- package/dist/utils/comment-threads.js.map +1 -0
- package/dist/utils/coverage-text.d.ts +3 -0
- package/dist/utils/coverage-text.d.ts.map +1 -0
- package/dist/utils/coverage-text.js +62 -0
- package/dist/utils/coverage-text.js.map +1 -0
- package/dist/utils/coverage.d.ts +57 -0
- package/dist/utils/coverage.d.ts.map +1 -0
- package/dist/utils/coverage.js +142 -0
- package/dist/utils/coverage.js.map +1 -0
- package/dist/utils/errors.d.ts +1 -1
- package/dist/utils/errors.d.ts.map +1 -1
- package/dist/utils/errors.js +9 -1
- package/dist/utils/errors.js.map +1 -1
- package/dist/utils/format.d.ts +17 -1
- package/dist/utils/format.d.ts.map +1 -1
- package/dist/utils/format.js +1 -1
- package/dist/utils/format.js.map +1 -1
- package/dist/utils/harvest-catalog.d.ts +44 -0
- package/dist/utils/harvest-catalog.d.ts.map +1 -0
- package/dist/utils/harvest-catalog.js +164 -0
- package/dist/utils/harvest-catalog.js.map +1 -0
- package/dist/utils/harvest-lock.d.ts +3 -0
- package/dist/utils/harvest-lock.d.ts.map +1 -0
- package/dist/utils/harvest-lock.js +26 -0
- package/dist/utils/harvest-lock.js.map +1 -0
- package/dist/utils/harvest-receipts.d.ts +14 -0
- package/dist/utils/harvest-receipts.d.ts.map +1 -0
- package/dist/utils/harvest-receipts.js +110 -0
- package/dist/utils/harvest-receipts.js.map +1 -0
- package/dist/utils/listing-cursor.d.ts +31 -0
- package/dist/utils/listing-cursor.d.ts.map +1 -0
- package/dist/utils/listing-cursor.js +39 -0
- package/dist/utils/listing-cursor.js.map +1 -0
- package/dist/utils/pot-preflight.d.ts +53 -0
- package/dist/utils/pot-preflight.d.ts.map +1 -0
- package/dist/utils/pot-preflight.js +146 -0
- package/dist/utils/pot-preflight.js.map +1 -0
- package/dist/utils/sleep.d.ts +9 -0
- package/dist/utils/sleep.d.ts.map +1 -0
- package/dist/utils/sleep.js +25 -0
- package/dist/utils/sleep.js.map +1 -0
- package/dist/utils/store-health.d.ts +37 -0
- package/dist/utils/store-health.d.ts.map +1 -0
- package/dist/utils/store-health.js +92 -0
- package/dist/utils/store-health.js.map +1 -0
- package/dist/utils/store-migrations.d.ts +33 -0
- package/dist/utils/store-migrations.d.ts.map +1 -0
- package/dist/utils/store-migrations.js +41 -0
- package/dist/utils/store-migrations.js.map +1 -0
- package/dist/utils/store-paths.d.ts +33 -0
- package/dist/utils/store-paths.d.ts.map +1 -0
- package/dist/utils/store-paths.js +48 -0
- package/dist/utils/store-paths.js.map +1 -0
- package/dist/utils/store-rows.d.ts +22 -0
- package/dist/utils/store-rows.d.ts.map +1 -0
- package/dist/utils/store-rows.js +62 -0
- package/dist/utils/store-rows.js.map +1 -0
- package/dist/utils/store-schema.d.ts +16 -0
- package/dist/utils/store-schema.d.ts.map +1 -0
- package/dist/utils/store-schema.js +168 -0
- package/dist/utils/store-schema.js.map +1 -0
- package/dist/utils/store.d.ts +34 -0
- package/dist/utils/store.d.ts.map +1 -0
- package/dist/utils/store.js +157 -0
- package/dist/utils/store.js.map +1 -0
- package/dist/utils/video-stats-cache.d.ts +16 -0
- package/dist/utils/video-stats-cache.d.ts.map +1 -0
- package/dist/utils/video-stats-cache.js +81 -0
- package/dist/utils/video-stats-cache.js.map +1 -0
- package/dist/utils/video-stats.d.ts +186 -0
- package/dist/utils/video-stats.d.ts.map +1 -0
- package/dist/utils/video-stats.js +168 -0
- package/dist/utils/video-stats.js.map +1 -0
- package/dist/utils/video-store.d.ts +69 -0
- package/dist/utils/video-store.d.ts.map +1 -0
- package/dist/utils/video-store.js +77 -0
- package/dist/utils/video-store.js.map +1 -0
- package/dist/utils/youtube-channel.d.ts +9 -2
- package/dist/utils/youtube-channel.d.ts.map +1 -1
- package/dist/utils/youtube-channel.js +33 -3
- package/dist/utils/youtube-channel.js.map +1 -1
- package/dist/utils/youtube-schemas.d.ts +98 -0
- package/dist/utils/youtube-schemas.d.ts.map +1 -1
- package/dist/utils/youtube-schemas.js +30 -0
- package/dist/utils/youtube-schemas.js.map +1 -1
- package/dist/utils/youtube-video.d.ts +22 -1
- package/dist/utils/youtube-video.d.ts.map +1 -1
- package/dist/utils/youtube-video.js +40 -28
- package/dist/utils/youtube-video.js.map +1 -1
- package/dist/utils/ytdlp-limiter.d.ts +3 -0
- package/dist/utils/ytdlp-limiter.d.ts.map +1 -1
- package/dist/utils/ytdlp-limiter.js +19 -3
- package/dist/utils/ytdlp-limiter.js.map +1 -1
- package/dist/utils/ytdlp-pacer.d.ts +64 -0
- package/dist/utils/ytdlp-pacer.d.ts.map +1 -0
- package/dist/utils/ytdlp-pacer.js +165 -0
- package/dist/utils/ytdlp-pacer.js.map +1 -0
- package/dist/utils/ytdlp-stream.d.ts +32 -0
- package/dist/utils/ytdlp-stream.d.ts.map +1 -0
- package/dist/utils/ytdlp-stream.js +61 -0
- package/dist/utils/ytdlp-stream.js.map +1 -0
- package/dist/utils/ytdlp.d.ts +10 -0
- package/dist/utils/ytdlp.d.ts.map +1 -1
- package/dist/utils/ytdlp.js +36 -25
- package/dist/utils/ytdlp.js.map +1 -1
- package/package.json +2 -2
|
@@ -3,13 +3,10 @@ import type { CallToolResult } from '@modelcontextprotocol/sdk/types.js';
|
|
|
3
3
|
export declare const getCommentsSchema: {
|
|
4
4
|
video: z.ZodString;
|
|
5
5
|
limit: z.ZodDefault<z.ZodNumber>;
|
|
6
|
+
includeReplies: z.ZodDefault<z.ZodBoolean>;
|
|
7
|
+
sort: z.ZodDefault<z.ZodEnum<["top", "new"]>>;
|
|
6
8
|
};
|
|
7
9
|
export declare const getCommentsOutputSchema: {
|
|
8
|
-
total: z.ZodNumber;
|
|
9
|
-
count: z.ZodNumber;
|
|
10
|
-
offset: z.ZodNumber;
|
|
11
|
-
hasMore: z.ZodBoolean;
|
|
12
|
-
nextOffset: z.ZodOptional<z.ZodNumber>;
|
|
13
10
|
comments: z.ZodArray<z.ZodObject<{
|
|
14
11
|
author: z.ZodString;
|
|
15
12
|
text: z.ZodString;
|
|
@@ -26,9 +23,244 @@ export declare const getCommentsOutputSchema: {
|
|
|
26
23
|
text: string;
|
|
27
24
|
isPinned: boolean;
|
|
28
25
|
}>, "many">;
|
|
26
|
+
threads: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
27
|
+
comment: z.ZodObject<{
|
|
28
|
+
id: z.ZodString;
|
|
29
|
+
parentId: z.ZodNullable<z.ZodString>;
|
|
30
|
+
author: z.ZodString;
|
|
31
|
+
authorId: z.ZodOptional<z.ZodString>;
|
|
32
|
+
authorUrl: z.ZodOptional<z.ZodString>;
|
|
33
|
+
authorThumbnailUrl: z.ZodOptional<z.ZodString>;
|
|
34
|
+
authorIsUploader: z.ZodBoolean;
|
|
35
|
+
authorIsVerified: z.ZodBoolean;
|
|
36
|
+
text: z.ZodString;
|
|
37
|
+
likeCount: z.ZodNumber;
|
|
38
|
+
isPinned: z.ZodBoolean;
|
|
39
|
+
isFavorited: z.ZodBoolean;
|
|
40
|
+
timestamp: z.ZodOptional<z.ZodNumber>;
|
|
41
|
+
publishedAt: z.ZodOptional<z.ZodString>;
|
|
42
|
+
timeText: z.ZodOptional<z.ZodString>;
|
|
43
|
+
}, "strip", z.ZodTypeAny, {
|
|
44
|
+
id: string;
|
|
45
|
+
likeCount: number;
|
|
46
|
+
author: string;
|
|
47
|
+
text: string;
|
|
48
|
+
isPinned: boolean;
|
|
49
|
+
parentId: string | null;
|
|
50
|
+
authorIsUploader: boolean;
|
|
51
|
+
authorIsVerified: boolean;
|
|
52
|
+
isFavorited: boolean;
|
|
53
|
+
authorId?: string | undefined;
|
|
54
|
+
authorUrl?: string | undefined;
|
|
55
|
+
authorThumbnailUrl?: string | undefined;
|
|
56
|
+
timestamp?: number | undefined;
|
|
57
|
+
publishedAt?: string | undefined;
|
|
58
|
+
timeText?: string | undefined;
|
|
59
|
+
}, {
|
|
60
|
+
id: string;
|
|
61
|
+
likeCount: number;
|
|
62
|
+
author: string;
|
|
63
|
+
text: string;
|
|
64
|
+
isPinned: boolean;
|
|
65
|
+
parentId: string | null;
|
|
66
|
+
authorIsUploader: boolean;
|
|
67
|
+
authorIsVerified: boolean;
|
|
68
|
+
isFavorited: boolean;
|
|
69
|
+
authorId?: string | undefined;
|
|
70
|
+
authorUrl?: string | undefined;
|
|
71
|
+
authorThumbnailUrl?: string | undefined;
|
|
72
|
+
timestamp?: number | undefined;
|
|
73
|
+
publishedAt?: string | undefined;
|
|
74
|
+
timeText?: string | undefined;
|
|
75
|
+
}>;
|
|
76
|
+
replies: z.ZodArray<z.ZodObject<{
|
|
77
|
+
id: z.ZodString;
|
|
78
|
+
parentId: z.ZodNullable<z.ZodString>;
|
|
79
|
+
author: z.ZodString;
|
|
80
|
+
authorId: z.ZodOptional<z.ZodString>;
|
|
81
|
+
authorUrl: z.ZodOptional<z.ZodString>;
|
|
82
|
+
authorThumbnailUrl: z.ZodOptional<z.ZodString>;
|
|
83
|
+
authorIsUploader: z.ZodBoolean;
|
|
84
|
+
authorIsVerified: z.ZodBoolean;
|
|
85
|
+
text: z.ZodString;
|
|
86
|
+
likeCount: z.ZodNumber;
|
|
87
|
+
isPinned: z.ZodBoolean;
|
|
88
|
+
isFavorited: z.ZodBoolean;
|
|
89
|
+
timestamp: z.ZodOptional<z.ZodNumber>;
|
|
90
|
+
publishedAt: z.ZodOptional<z.ZodString>;
|
|
91
|
+
timeText: z.ZodOptional<z.ZodString>;
|
|
92
|
+
}, "strip", z.ZodTypeAny, {
|
|
93
|
+
id: string;
|
|
94
|
+
likeCount: number;
|
|
95
|
+
author: string;
|
|
96
|
+
text: string;
|
|
97
|
+
isPinned: boolean;
|
|
98
|
+
parentId: string | null;
|
|
99
|
+
authorIsUploader: boolean;
|
|
100
|
+
authorIsVerified: boolean;
|
|
101
|
+
isFavorited: boolean;
|
|
102
|
+
authorId?: string | undefined;
|
|
103
|
+
authorUrl?: string | undefined;
|
|
104
|
+
authorThumbnailUrl?: string | undefined;
|
|
105
|
+
timestamp?: number | undefined;
|
|
106
|
+
publishedAt?: string | undefined;
|
|
107
|
+
timeText?: string | undefined;
|
|
108
|
+
}, {
|
|
109
|
+
id: string;
|
|
110
|
+
likeCount: number;
|
|
111
|
+
author: string;
|
|
112
|
+
text: string;
|
|
113
|
+
isPinned: boolean;
|
|
114
|
+
parentId: string | null;
|
|
115
|
+
authorIsUploader: boolean;
|
|
116
|
+
authorIsVerified: boolean;
|
|
117
|
+
isFavorited: boolean;
|
|
118
|
+
authorId?: string | undefined;
|
|
119
|
+
authorUrl?: string | undefined;
|
|
120
|
+
authorThumbnailUrl?: string | undefined;
|
|
121
|
+
timestamp?: number | undefined;
|
|
122
|
+
publishedAt?: string | undefined;
|
|
123
|
+
timeText?: string | undefined;
|
|
124
|
+
}>, "many">;
|
|
125
|
+
replyCount: z.ZodNumber;
|
|
126
|
+
}, "strip", z.ZodTypeAny, {
|
|
127
|
+
comment: {
|
|
128
|
+
id: string;
|
|
129
|
+
likeCount: number;
|
|
130
|
+
author: string;
|
|
131
|
+
text: string;
|
|
132
|
+
isPinned: boolean;
|
|
133
|
+
parentId: string | null;
|
|
134
|
+
authorIsUploader: boolean;
|
|
135
|
+
authorIsVerified: boolean;
|
|
136
|
+
isFavorited: boolean;
|
|
137
|
+
authorId?: string | undefined;
|
|
138
|
+
authorUrl?: string | undefined;
|
|
139
|
+
authorThumbnailUrl?: string | undefined;
|
|
140
|
+
timestamp?: number | undefined;
|
|
141
|
+
publishedAt?: string | undefined;
|
|
142
|
+
timeText?: string | undefined;
|
|
143
|
+
};
|
|
144
|
+
replies: {
|
|
145
|
+
id: string;
|
|
146
|
+
likeCount: number;
|
|
147
|
+
author: string;
|
|
148
|
+
text: string;
|
|
149
|
+
isPinned: boolean;
|
|
150
|
+
parentId: string | null;
|
|
151
|
+
authorIsUploader: boolean;
|
|
152
|
+
authorIsVerified: boolean;
|
|
153
|
+
isFavorited: boolean;
|
|
154
|
+
authorId?: string | undefined;
|
|
155
|
+
authorUrl?: string | undefined;
|
|
156
|
+
authorThumbnailUrl?: string | undefined;
|
|
157
|
+
timestamp?: number | undefined;
|
|
158
|
+
publishedAt?: string | undefined;
|
|
159
|
+
timeText?: string | undefined;
|
|
160
|
+
}[];
|
|
161
|
+
replyCount: number;
|
|
162
|
+
}, {
|
|
163
|
+
comment: {
|
|
164
|
+
id: string;
|
|
165
|
+
likeCount: number;
|
|
166
|
+
author: string;
|
|
167
|
+
text: string;
|
|
168
|
+
isPinned: boolean;
|
|
169
|
+
parentId: string | null;
|
|
170
|
+
authorIsUploader: boolean;
|
|
171
|
+
authorIsVerified: boolean;
|
|
172
|
+
isFavorited: boolean;
|
|
173
|
+
authorId?: string | undefined;
|
|
174
|
+
authorUrl?: string | undefined;
|
|
175
|
+
authorThumbnailUrl?: string | undefined;
|
|
176
|
+
timestamp?: number | undefined;
|
|
177
|
+
publishedAt?: string | undefined;
|
|
178
|
+
timeText?: string | undefined;
|
|
179
|
+
};
|
|
180
|
+
replies: {
|
|
181
|
+
id: string;
|
|
182
|
+
likeCount: number;
|
|
183
|
+
author: string;
|
|
184
|
+
text: string;
|
|
185
|
+
isPinned: boolean;
|
|
186
|
+
parentId: string | null;
|
|
187
|
+
authorIsUploader: boolean;
|
|
188
|
+
authorIsVerified: boolean;
|
|
189
|
+
isFavorited: boolean;
|
|
190
|
+
authorId?: string | undefined;
|
|
191
|
+
authorUrl?: string | undefined;
|
|
192
|
+
authorThumbnailUrl?: string | undefined;
|
|
193
|
+
timestamp?: number | undefined;
|
|
194
|
+
publishedAt?: string | undefined;
|
|
195
|
+
timeText?: string | undefined;
|
|
196
|
+
}[];
|
|
197
|
+
replyCount: number;
|
|
198
|
+
}>, "many">>;
|
|
199
|
+
extractedTotal: z.ZodNumber;
|
|
200
|
+
orphanReplies: z.ZodNumber;
|
|
201
|
+
coverage: z.ZodObject<{
|
|
202
|
+
scope: z.ZodEnum<["channel-catalog", "video-details", "video-comments"]>;
|
|
203
|
+
targetId: z.ZodString;
|
|
204
|
+
complete: z.ZodBoolean;
|
|
205
|
+
reason: z.ZodEnum<["COMPLETE", "CAP_REACHED", "BUDGET_SPENT", "RATE_LIMITED", "CANCELLED", "TIMEOUT", "SOURCE_REFUSED", "COMMENTS_DISABLED", "SOURCE_SILENT", "PARTIAL_ERROR", "NOT_ATTEMPTED"]>;
|
|
206
|
+
have: z.ZodNumber;
|
|
207
|
+
expected: z.ZodOptional<z.ZodNumber>;
|
|
208
|
+
expectedSource: z.ZodOptional<z.ZodEnum<["youtube:comment_count", "youtube:playlist_count", "source-exhausted"]>>;
|
|
209
|
+
ranToExhaustion: z.ZodOptional<z.ZodBoolean>;
|
|
210
|
+
source: z.ZodString;
|
|
211
|
+
harvestedAt: z.ZodString;
|
|
212
|
+
staleAfter: z.ZodOptional<z.ZodString>;
|
|
213
|
+
limitApplied: z.ZodOptional<z.ZodNumber>;
|
|
214
|
+
sortApplied: z.ZodOptional<z.ZodEnum<["top", "new"]>>;
|
|
215
|
+
resumeToken: z.ZodOptional<z.ZodString>;
|
|
216
|
+
note: z.ZodOptional<z.ZodString>;
|
|
217
|
+
}, "strip", z.ZodTypeAny, {
|
|
218
|
+
have: number;
|
|
219
|
+
scope: "channel-catalog" | "video-details" | "video-comments";
|
|
220
|
+
targetId: string;
|
|
221
|
+
complete: boolean;
|
|
222
|
+
reason: "RATE_LIMITED" | "TIMEOUT" | "CANCELLED" | "COMPLETE" | "CAP_REACHED" | "BUDGET_SPENT" | "SOURCE_REFUSED" | "COMMENTS_DISABLED" | "SOURCE_SILENT" | "PARTIAL_ERROR" | "NOT_ATTEMPTED";
|
|
223
|
+
source: string;
|
|
224
|
+
harvestedAt: string;
|
|
225
|
+
expected?: number | undefined;
|
|
226
|
+
note?: string | undefined;
|
|
227
|
+
ranToExhaustion?: boolean | undefined;
|
|
228
|
+
expectedSource?: "youtube:playlist_count" | "source-exhausted" | "youtube:comment_count" | undefined;
|
|
229
|
+
staleAfter?: string | undefined;
|
|
230
|
+
limitApplied?: number | undefined;
|
|
231
|
+
sortApplied?: "top" | "new" | undefined;
|
|
232
|
+
resumeToken?: string | undefined;
|
|
233
|
+
}, {
|
|
234
|
+
have: number;
|
|
235
|
+
scope: "channel-catalog" | "video-details" | "video-comments";
|
|
236
|
+
targetId: string;
|
|
237
|
+
complete: boolean;
|
|
238
|
+
reason: "RATE_LIMITED" | "TIMEOUT" | "CANCELLED" | "COMPLETE" | "CAP_REACHED" | "BUDGET_SPENT" | "SOURCE_REFUSED" | "COMMENTS_DISABLED" | "SOURCE_SILENT" | "PARTIAL_ERROR" | "NOT_ATTEMPTED";
|
|
239
|
+
source: string;
|
|
240
|
+
harvestedAt: string;
|
|
241
|
+
expected?: number | undefined;
|
|
242
|
+
note?: string | undefined;
|
|
243
|
+
ranToExhaustion?: boolean | undefined;
|
|
244
|
+
expectedSource?: "youtube:playlist_count" | "source-exhausted" | "youtube:comment_count" | undefined;
|
|
245
|
+
staleAfter?: string | undefined;
|
|
246
|
+
limitApplied?: number | undefined;
|
|
247
|
+
sortApplied?: "top" | "new" | undefined;
|
|
248
|
+
resumeToken?: string | undefined;
|
|
249
|
+
}>;
|
|
29
250
|
};
|
|
30
|
-
|
|
251
|
+
/**
|
|
252
|
+
* A sample of a video's comments, with a receipt saying so.
|
|
253
|
+
*
|
|
254
|
+
* There is no cursor: YouTube exposes none for a live comment read, so this
|
|
255
|
+
* cannot page. `coverage.expected` is the video's real comment count, read
|
|
256
|
+
* from a separate metadata pass — yt-dlp overwrites `comment_count` with the
|
|
257
|
+
* number it extracted whenever --write-comments is used, so the number cannot
|
|
258
|
+
* come from the same call that fetched the comments.
|
|
259
|
+
*/
|
|
260
|
+
export declare function getCommentsHandler({ video, limit, includeReplies, sort, }: {
|
|
31
261
|
video: string;
|
|
32
262
|
limit: number;
|
|
263
|
+
includeReplies: boolean;
|
|
264
|
+
sort: 'top' | 'new';
|
|
33
265
|
}): Promise<CallToolResult>;
|
|
34
266
|
//# sourceMappingURL=get-comments.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-comments.d.ts","sourceRoot":"","sources":["../../src/tools/get-comments.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"get-comments.d.ts","sourceRoot":"","sources":["../../src/tools/get-comments.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAOxB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAEzE,eAAO,MAAM,iBAAiB;;;;;CAoB7B,CAAC;AAEF,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAYnC,CAAC;AAEF;;;;;;;;GAQG;AACH,wBAAsB,kBAAkB,CAAC,EACvC,KAAK,EACL,KAAK,EACL,cAAc,EACd,IAAI,GACL,EAAE;IACD,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,cAAc,EAAE,OAAO,CAAC;IACxB,IAAI,EAAE,KAAK,GAAG,KAAK,CAAC;CACrB,GAAG,OAAO,CAAC,cAAc,CAAC,CAuD1B"}
|
|
@@ -1,34 +1,98 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { getComments } from '../utils/youtube.js';
|
|
3
|
-
import {
|
|
4
|
-
import { commentSchema,
|
|
2
|
+
import { getComments, getVideoDetails } from '../utils/youtube-video.js';
|
|
3
|
+
import { toolResult } from '../utils/format.js';
|
|
4
|
+
import { commentSchema, commentThreadSchema } from '../schemas.js';
|
|
5
|
+
import { coverageSchema } from '../harvest-schemas.js';
|
|
6
|
+
import { coverageOf } from '../utils/coverage.js';
|
|
7
|
+
import { renderCoverage } from '../utils/coverage-text.js';
|
|
5
8
|
export const getCommentsSchema = {
|
|
6
|
-
video: z.string().describe('YouTube video ID
|
|
9
|
+
video: z.string().max(2048).describe('YouTube video ID or URL'),
|
|
7
10
|
limit: z
|
|
8
11
|
.number()
|
|
12
|
+
.int()
|
|
9
13
|
.min(1)
|
|
10
|
-
.max(
|
|
14
|
+
.max(500)
|
|
11
15
|
.default(20)
|
|
12
|
-
.describe('
|
|
16
|
+
.describe('Comments to extract, replies included (1-500, default 20)'),
|
|
17
|
+
includeReplies: z
|
|
18
|
+
.boolean()
|
|
19
|
+
.default(false)
|
|
20
|
+
.describe('Return full threads instead of top-level comments only. Replies are fetched either ' +
|
|
21
|
+
'way — this decides whether they are reported or thrown away.'),
|
|
22
|
+
sort: z
|
|
23
|
+
.enum(['top', 'new'])
|
|
24
|
+
.default('top')
|
|
25
|
+
.describe('"top" under a cap is a biased prefix; "new" is what an exhaustive read should use'),
|
|
13
26
|
};
|
|
14
27
|
export const getCommentsOutputSchema = {
|
|
15
|
-
comments: z.array(commentSchema),
|
|
16
|
-
|
|
28
|
+
comments: z.array(commentSchema).describe('Top-level comments, unchanged in shape'),
|
|
29
|
+
threads: z
|
|
30
|
+
.array(commentThreadSchema)
|
|
31
|
+
.optional()
|
|
32
|
+
.describe('Full threads with replies. Present when includeReplies is true.'),
|
|
33
|
+
extractedTotal: z.number().int().describe('Comments held from this read: roots plus replies'),
|
|
34
|
+
orphanReplies: z
|
|
35
|
+
.number()
|
|
36
|
+
.int()
|
|
37
|
+
.describe('Replies whose parent was cut by the cap, so their threads are incomplete'),
|
|
38
|
+
coverage: coverageSchema,
|
|
17
39
|
};
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
40
|
+
/**
|
|
41
|
+
* A sample of a video's comments, with a receipt saying so.
|
|
42
|
+
*
|
|
43
|
+
* There is no cursor: YouTube exposes none for a live comment read, so this
|
|
44
|
+
* cannot page. `coverage.expected` is the video's real comment count, read
|
|
45
|
+
* from a separate metadata pass — yt-dlp overwrites `comment_count` with the
|
|
46
|
+
* number it extracted whenever --write-comments is used, so the number cannot
|
|
47
|
+
* come from the same call that fetched the comments.
|
|
48
|
+
*/
|
|
49
|
+
export async function getCommentsHandler({ video, limit, includeReplies, sort, }) {
|
|
50
|
+
const [result, details] = await Promise.all([
|
|
51
|
+
getComments(video, { limit, sort }),
|
|
52
|
+
getVideoDetails(video).catch(() => undefined),
|
|
53
|
+
]);
|
|
54
|
+
const reported = details?.commentCount;
|
|
55
|
+
const capBound = result.extractedTotal >= limit;
|
|
56
|
+
const coverage = coverageOf({
|
|
57
|
+
scope: 'video-comments',
|
|
58
|
+
targetId: video,
|
|
59
|
+
have: result.extractedTotal,
|
|
60
|
+
source: `yt-dlp --write-comments comment_sort=${sort}`,
|
|
61
|
+
ranToExhaustion: result.ranToExhaustion,
|
|
62
|
+
...(result.commentsDisabled
|
|
63
|
+
? {
|
|
64
|
+
expected: { value: 0, source: 'youtube:comment_count' },
|
|
65
|
+
reason: 'COMMENTS_DISABLED',
|
|
66
|
+
}
|
|
67
|
+
: reported === undefined
|
|
68
|
+
? {}
|
|
69
|
+
: { expected: { value: reported, source: 'youtube:comment_count' } }),
|
|
70
|
+
...(capBound ? { limitApplied: limit } : {}),
|
|
71
|
+
sortApplied: sort,
|
|
72
|
+
...(capBound
|
|
73
|
+
? { note: `Call again with a larger limit, or harvest_channel, to extract more.` }
|
|
74
|
+
: {}),
|
|
75
|
+
});
|
|
76
|
+
const roots = result.threads.filter((thread) => thread.comment.parentId === null);
|
|
77
|
+
const lines = [renderCoverage(coverage), ''];
|
|
78
|
+
roots.forEach((thread, index) => {
|
|
79
|
+
const { comment } = thread;
|
|
80
|
+
lines.push(`${String(index + 1)}. ${comment.author}${comment.isPinned ? ' (pinned)' : ''}`);
|
|
81
|
+
lines.push(` ${comment.text}`);
|
|
82
|
+
lines.push(` ${String(comment.likeCount)} likes${thread.replyCount > 0 ? ` · ${String(thread.replyCount)} replies` : ''}`);
|
|
30
83
|
lines.push('');
|
|
31
84
|
});
|
|
32
|
-
return toolResult(lines.join('\n'),
|
|
85
|
+
return toolResult(lines.join('\n'), {
|
|
86
|
+
comments: roots.map((thread) => ({
|
|
87
|
+
author: thread.comment.author,
|
|
88
|
+
text: thread.comment.text,
|
|
89
|
+
likeCount: thread.comment.likeCount,
|
|
90
|
+
isPinned: thread.comment.isPinned,
|
|
91
|
+
})),
|
|
92
|
+
...(includeReplies ? { threads: result.threads } : {}),
|
|
93
|
+
extractedTotal: result.extractedTotal,
|
|
94
|
+
orphanReplies: result.orphanCount,
|
|
95
|
+
coverage,
|
|
96
|
+
});
|
|
33
97
|
}
|
|
34
98
|
//# sourceMappingURL=get-comments.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-comments.js","sourceRoot":"","sources":["../../src/tools/get-comments.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"get-comments.js","sourceRoot":"","sources":["../../src/tools/get-comments.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AACzE,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,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O,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACtD,cAAc,EAAE,MAAM,CAAC,cAAc;QACrC,aAAa,EAAE,MAAM,CAAC,WAAW;QACjC,QAAQ;KACT,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import type { CallToolResult } from '@modelcontextprotocol/sdk/types.js';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
export declare const getCoverageSchema: {
|
|
4
|
+
scope: z.ZodOptional<z.ZodEnum<["channel-catalog", "video-details", "video-comments"]>>;
|
|
5
|
+
incompleteOnly: z.ZodDefault<z.ZodBoolean>;
|
|
6
|
+
verify: z.ZodDefault<z.ZodBoolean>;
|
|
7
|
+
limit: z.ZodDefault<z.ZodNumber>;
|
|
8
|
+
offset: z.ZodDefault<z.ZodNumber>;
|
|
9
|
+
};
|
|
10
|
+
export declare const getCoverageOutputSchema: {
|
|
11
|
+
total: z.ZodNumber;
|
|
12
|
+
count: z.ZodNumber;
|
|
13
|
+
offset: z.ZodNumber;
|
|
14
|
+
hasMore: z.ZodBoolean;
|
|
15
|
+
nextOffset: z.ZodOptional<z.ZodNumber>;
|
|
16
|
+
receipts: z.ZodArray<z.ZodObject<{
|
|
17
|
+
scope: z.ZodEnum<["channel-catalog", "video-details", "video-comments"]>;
|
|
18
|
+
targetId: z.ZodString;
|
|
19
|
+
complete: z.ZodBoolean;
|
|
20
|
+
reason: z.ZodEnum<["COMPLETE", "CAP_REACHED", "BUDGET_SPENT", "RATE_LIMITED", "CANCELLED", "TIMEOUT", "SOURCE_REFUSED", "COMMENTS_DISABLED", "SOURCE_SILENT", "PARTIAL_ERROR", "NOT_ATTEMPTED"]>;
|
|
21
|
+
have: z.ZodNumber;
|
|
22
|
+
expected: z.ZodOptional<z.ZodNumber>;
|
|
23
|
+
expectedSource: z.ZodOptional<z.ZodEnum<["youtube:comment_count", "youtube:playlist_count", "source-exhausted"]>>;
|
|
24
|
+
ranToExhaustion: z.ZodOptional<z.ZodBoolean>;
|
|
25
|
+
source: z.ZodString;
|
|
26
|
+
harvestedAt: z.ZodString;
|
|
27
|
+
staleAfter: z.ZodOptional<z.ZodString>;
|
|
28
|
+
limitApplied: z.ZodOptional<z.ZodNumber>;
|
|
29
|
+
sortApplied: z.ZodOptional<z.ZodEnum<["top", "new"]>>;
|
|
30
|
+
resumeToken: z.ZodOptional<z.ZodString>;
|
|
31
|
+
note: z.ZodOptional<z.ZodString>;
|
|
32
|
+
}, "strip", z.ZodTypeAny, {
|
|
33
|
+
have: number;
|
|
34
|
+
scope: "channel-catalog" | "video-details" | "video-comments";
|
|
35
|
+
targetId: string;
|
|
36
|
+
complete: boolean;
|
|
37
|
+
reason: "RATE_LIMITED" | "TIMEOUT" | "CANCELLED" | "COMPLETE" | "CAP_REACHED" | "BUDGET_SPENT" | "SOURCE_REFUSED" | "COMMENTS_DISABLED" | "SOURCE_SILENT" | "PARTIAL_ERROR" | "NOT_ATTEMPTED";
|
|
38
|
+
source: string;
|
|
39
|
+
harvestedAt: string;
|
|
40
|
+
expected?: number | undefined;
|
|
41
|
+
note?: string | undefined;
|
|
42
|
+
ranToExhaustion?: boolean | undefined;
|
|
43
|
+
expectedSource?: "youtube:playlist_count" | "source-exhausted" | "youtube:comment_count" | undefined;
|
|
44
|
+
staleAfter?: string | undefined;
|
|
45
|
+
limitApplied?: number | undefined;
|
|
46
|
+
sortApplied?: "top" | "new" | undefined;
|
|
47
|
+
resumeToken?: string | undefined;
|
|
48
|
+
}, {
|
|
49
|
+
have: number;
|
|
50
|
+
scope: "channel-catalog" | "video-details" | "video-comments";
|
|
51
|
+
targetId: string;
|
|
52
|
+
complete: boolean;
|
|
53
|
+
reason: "RATE_LIMITED" | "TIMEOUT" | "CANCELLED" | "COMPLETE" | "CAP_REACHED" | "BUDGET_SPENT" | "SOURCE_REFUSED" | "COMMENTS_DISABLED" | "SOURCE_SILENT" | "PARTIAL_ERROR" | "NOT_ATTEMPTED";
|
|
54
|
+
source: string;
|
|
55
|
+
harvestedAt: string;
|
|
56
|
+
expected?: number | undefined;
|
|
57
|
+
note?: string | undefined;
|
|
58
|
+
ranToExhaustion?: boolean | undefined;
|
|
59
|
+
expectedSource?: "youtube:playlist_count" | "source-exhausted" | "youtube:comment_count" | undefined;
|
|
60
|
+
staleAfter?: string | undefined;
|
|
61
|
+
limitApplied?: number | undefined;
|
|
62
|
+
sortApplied?: "top" | "new" | undefined;
|
|
63
|
+
resumeToken?: string | undefined;
|
|
64
|
+
}>, "many">;
|
|
65
|
+
anyIncomplete: z.ZodBoolean;
|
|
66
|
+
summary: z.ZodObject<{
|
|
67
|
+
complete: z.ZodNumber;
|
|
68
|
+
incomplete: z.ZodNumber;
|
|
69
|
+
stale: z.ZodNumber;
|
|
70
|
+
}, "strip", z.ZodTypeAny, {
|
|
71
|
+
complete: number;
|
|
72
|
+
incomplete: number;
|
|
73
|
+
stale: number;
|
|
74
|
+
}, {
|
|
75
|
+
complete: number;
|
|
76
|
+
incomplete: number;
|
|
77
|
+
stale: number;
|
|
78
|
+
}>;
|
|
79
|
+
store: z.ZodObject<{
|
|
80
|
+
channels: z.ZodNumber;
|
|
81
|
+
videos: z.ZodNumber;
|
|
82
|
+
comments: z.ZodNumber;
|
|
83
|
+
}, "strip", z.ZodTypeAny, {
|
|
84
|
+
videos: number;
|
|
85
|
+
comments: number;
|
|
86
|
+
channels: number;
|
|
87
|
+
}, {
|
|
88
|
+
videos: number;
|
|
89
|
+
comments: number;
|
|
90
|
+
channels: number;
|
|
91
|
+
}>;
|
|
92
|
+
mismatches: z.ZodArray<z.ZodObject<{
|
|
93
|
+
scope: z.ZodEnum<["channel-catalog", "video-details", "video-comments"]>;
|
|
94
|
+
targetId: z.ZodString;
|
|
95
|
+
receiptHave: z.ZodNumber;
|
|
96
|
+
storeHave: z.ZodNumber;
|
|
97
|
+
}, "strip", z.ZodTypeAny, {
|
|
98
|
+
scope: "channel-catalog" | "video-details" | "video-comments";
|
|
99
|
+
targetId: string;
|
|
100
|
+
receiptHave: number;
|
|
101
|
+
storeHave: number;
|
|
102
|
+
}, {
|
|
103
|
+
scope: "channel-catalog" | "video-details" | "video-comments";
|
|
104
|
+
targetId: string;
|
|
105
|
+
receiptHave: number;
|
|
106
|
+
storeHave: number;
|
|
107
|
+
}>, "many">;
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* What this server can actually prove it holds.
|
|
111
|
+
*
|
|
112
|
+
* Reads only the local store and never contacts YouTube, so it is cheap enough
|
|
113
|
+
* for a consumer to call before every claim it makes — which is the point.
|
|
114
|
+
*/
|
|
115
|
+
export declare function getCoverageHandler({ scope, incompleteOnly, verify, limit, offset, }: {
|
|
116
|
+
scope?: 'channel-catalog' | 'video-details' | 'video-comments';
|
|
117
|
+
incompleteOnly: boolean;
|
|
118
|
+
verify: boolean;
|
|
119
|
+
limit: number;
|
|
120
|
+
offset: number;
|
|
121
|
+
}): Promise<CallToolResult>;
|
|
122
|
+
//# sourceMappingURL=get-coverage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-coverage.d.ts","sourceRoot":"","sources":["../../src/tools/get-coverage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AASxB,eAAO,MAAM,iBAAiB;;;;;;CAe7B,CAAC;AAEF,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+BnC,CAAC;AAEF;;;;;GAKG;AACH,wBAAsB,kBAAkB,CAAC,EACvC,KAAK,EACL,cAAc,EACd,MAAM,EACN,KAAK,EACL,MAAM,GACP,EAAE;IACD,KAAK,CAAC,EAAE,iBAAiB,GAAG,eAAe,GAAG,gBAAgB,CAAC;IAC/D,cAAc,EAAE,OAAO,CAAC;IACxB,MAAM,EAAE,OAAO,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB,GAAG,OAAO,CAAC,cAAc,CAAC,CAgE1B"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { toolResult, pageInfo } from '../utils/format.js';
|
|
3
|
+
import { paginationShape } from '../schemas.js';
|
|
4
|
+
import { coverageSchema, harvestScopeSchema } from '../harvest-schemas.js';
|
|
5
|
+
import { getStore } from '../utils/store.js';
|
|
6
|
+
import { countReceipts, listReceipts } from '../utils/harvest-receipts.js';
|
|
7
|
+
import { countRows } from '../utils/store-rows.js';
|
|
8
|
+
import { RECEIPT_STALE_MS } from '../utils/coverage.js';
|
|
9
|
+
export const getCoverageSchema = {
|
|
10
|
+
scope: harvestScopeSchema.optional().describe('Restrict to one kind of harvest'),
|
|
11
|
+
incompleteOnly: z
|
|
12
|
+
.boolean()
|
|
13
|
+
.default(false)
|
|
14
|
+
.describe('Only receipts that are not provably complete'),
|
|
15
|
+
verify: z
|
|
16
|
+
.boolean()
|
|
17
|
+
.default(true)
|
|
18
|
+
.describe('Recount the store and cross-check every receipt against it. A receipt that disagrees ' +
|
|
19
|
+
'is reported in mismatches and treated as incomplete.'),
|
|
20
|
+
limit: z.number().int().min(1).max(500).default(50),
|
|
21
|
+
offset: z.number().int().min(0).default(0),
|
|
22
|
+
};
|
|
23
|
+
export const getCoverageOutputSchema = {
|
|
24
|
+
receipts: z.array(coverageSchema),
|
|
25
|
+
anyIncomplete: z
|
|
26
|
+
.boolean()
|
|
27
|
+
.describe('True when ANY receipt in scope is not provably complete. While this is true a consumer ' +
|
|
28
|
+
'must not describe the data as a full history, for any part of it.'),
|
|
29
|
+
summary: z.object({
|
|
30
|
+
complete: z.number().int(),
|
|
31
|
+
incomplete: z.number().int(),
|
|
32
|
+
stale: z.number().int().describe('Complete receipts past their staleAfter'),
|
|
33
|
+
}),
|
|
34
|
+
store: z.object({
|
|
35
|
+
channels: z.number().int(),
|
|
36
|
+
videos: z.number().int(),
|
|
37
|
+
comments: z.number().int(),
|
|
38
|
+
}),
|
|
39
|
+
mismatches: z
|
|
40
|
+
.array(z.object({
|
|
41
|
+
scope: harvestScopeSchema,
|
|
42
|
+
targetId: z.string(),
|
|
43
|
+
receiptHave: z.number().int(),
|
|
44
|
+
storeHave: z.number().int(),
|
|
45
|
+
}))
|
|
46
|
+
.describe('Empty in normal operation. Non-empty means a receipt was wrong and is not to be trusted.'),
|
|
47
|
+
...paginationShape,
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* What this server can actually prove it holds.
|
|
51
|
+
*
|
|
52
|
+
* Reads only the local store and never contacts YouTube, so it is cheap enough
|
|
53
|
+
* for a consumer to call before every claim it makes — which is the point.
|
|
54
|
+
*/
|
|
55
|
+
export async function getCoverageHandler({ scope, incompleteOnly, verify, limit, offset, }) {
|
|
56
|
+
const store = await getStore();
|
|
57
|
+
const all = listReceipts(store, { ...(scope === undefined ? {} : { scope }), limit, offset });
|
|
58
|
+
const now = Date.now();
|
|
59
|
+
const mismatches = [];
|
|
60
|
+
const receipts = all.map((receipt) => {
|
|
61
|
+
if (!verify || receipt.scope !== 'video-comments')
|
|
62
|
+
return receipt;
|
|
63
|
+
const storeHave = countRows(store.prepare('SELECT COUNT(*) FROM comment WHERE video_id = ?'), receipt.targetId);
|
|
64
|
+
if (storeHave === receipt.have)
|
|
65
|
+
return receipt;
|
|
66
|
+
// The store is the authority. A receipt that disagrees with it was written
|
|
67
|
+
// by something this build did not do, so it loses its claim rather than
|
|
68
|
+
// being believed.
|
|
69
|
+
mismatches.push({
|
|
70
|
+
scope: receipt.scope,
|
|
71
|
+
targetId: receipt.targetId,
|
|
72
|
+
receiptHave: receipt.have,
|
|
73
|
+
storeHave,
|
|
74
|
+
});
|
|
75
|
+
return { ...receipt, complete: false, reason: 'PARTIAL_ERROR', have: storeHave };
|
|
76
|
+
});
|
|
77
|
+
const shown = incompleteOnly ? receipts.filter((receipt) => !receipt.complete) : receipts;
|
|
78
|
+
const stale = receipts.filter((receipt) => receipt.complete && Date.parse(receipt.harvestedAt) + RECEIPT_STALE_MS < now).length;
|
|
79
|
+
const incomplete = receipts.filter((receipt) => !receipt.complete).length;
|
|
80
|
+
const counts = {
|
|
81
|
+
channels: countRows(store.prepare('SELECT COUNT(*) FROM channel')),
|
|
82
|
+
videos: countRows(store.prepare('SELECT COUNT(*) FROM video')),
|
|
83
|
+
comments: countRows(store.prepare('SELECT COUNT(*) FROM comment')),
|
|
84
|
+
};
|
|
85
|
+
const anyIncomplete = incomplete > 0;
|
|
86
|
+
const lines = [
|
|
87
|
+
anyIncomplete
|
|
88
|
+
? `INCOMPLETE: ${String(incomplete)} of ${String(receipts.length)} receipts are not provably complete. Do not describe this data as a full history.`
|
|
89
|
+
: `All ${String(receipts.length)} receipts in scope are provably complete.`,
|
|
90
|
+
`Store: ${String(counts.channels)} channels, ${String(counts.videos)} videos, ${String(counts.comments)} comments.`,
|
|
91
|
+
...(stale > 0 ? [`${String(stale)} complete receipts are past their re-check date.`] : []),
|
|
92
|
+
...(mismatches.length > 0
|
|
93
|
+
? [`${String(mismatches.length)} receipts disagreed with the store and were downgraded.`]
|
|
94
|
+
: []),
|
|
95
|
+
];
|
|
96
|
+
return toolResult(lines.join('\n'), {
|
|
97
|
+
receipts: shown,
|
|
98
|
+
anyIncomplete,
|
|
99
|
+
summary: { complete: receipts.length - incomplete, incomplete, stale },
|
|
100
|
+
store: counts,
|
|
101
|
+
mismatches,
|
|
102
|
+
...pageInfo({ total: countReceipts(store, scope), count: shown.length, offset }),
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=get-coverage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-coverage.js","sourceRoot":"","sources":["../../src/tools/get-coverage.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAA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