tomoshi 1.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 +28 -0
- package/dist/auth-provider.d.ts +8 -0
- package/dist/auth-provider.d.ts.map +1 -0
- package/dist/auth-provider.js +89 -0
- package/dist/auth-provider.js.map +1 -0
- package/dist/client.d.ts +348 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +240 -0
- package/dist/client.js.map +1 -0
- package/dist/config.d.ts +39 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +57 -0
- package/dist/config.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +151 -0
- package/dist/index.js.map +1 -0
- package/dist/server.d.ts +7 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +87 -0
- package/dist/server.js.map +1 -0
- package/dist/stdio.d.ts +3 -0
- package/dist/stdio.d.ts.map +1 -0
- package/dist/stdio.js +7 -0
- package/dist/stdio.js.map +1 -0
- package/dist/tools/discover.d.ts +52 -0
- package/dist/tools/discover.d.ts.map +1 -0
- package/dist/tools/discover.js +209 -0
- package/dist/tools/discover.js.map +1 -0
- package/dist/tools/extract.d.ts +147 -0
- package/dist/tools/extract.d.ts.map +1 -0
- package/dist/tools/extract.js +351 -0
- package/dist/tools/extract.js.map +1 -0
- package/dist/tools/monitor.d.ts +34 -0
- package/dist/tools/monitor.d.ts.map +1 -0
- package/dist/tools/monitor.js +95 -0
- package/dist/tools/monitor.js.map +1 -0
- package/package.json +53 -0
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
/**
|
|
3
|
+
* Resource-oriented multiplexed extraction tool.
|
|
4
|
+
* Consolidates `cinder_scrape` + `cinder_links` + `cinder_batch_scrape`
|
|
5
|
+
* into a single `cinder_extract` resource (5→1 with scrape_multi).
|
|
6
|
+
*
|
|
7
|
+
* Principle: 1 tool per domain resource with `action` enum
|
|
8
|
+
* (arch.md "Why 7 Tools Instead of 17" — FlarelyLegal 17→7).
|
|
9
|
+
* Reduces token overhead, improves LLM tool-selection accuracy,
|
|
10
|
+
* stays well under MCP client limits.
|
|
11
|
+
*
|
|
12
|
+
* Actions:
|
|
13
|
+
* - `scrape` — single page → markdown (POST /v1/scrape)
|
|
14
|
+
* - `scrape_multi` — sync multi-URL scrape, no Redis (POST /v1/scrape {urls}, max 10, errgroup 5)
|
|
15
|
+
* - `links` — hyperlinks only (POST /v1/scrape {include_links})
|
|
16
|
+
* - `batch` — enqueue up to 20 URLs async (POST /v1/batch/scrape, Redis)
|
|
17
|
+
* - `batch_status` — poll batch (GET /v1/batch/:id, Redis)
|
|
18
|
+
*/
|
|
19
|
+
// ── scrape (single) ──────────────────────────────────────────────────
|
|
20
|
+
const ExtractScrapeShape = v.object({
|
|
21
|
+
action: v.pipe(v.picklist(["scrape"]), v.description("Scrape a single page into markdown")),
|
|
22
|
+
url: v.pipe(v.string(), v.description("The URL to scrape"), v.url("Must be a valid URL")),
|
|
23
|
+
mode: v.optional(v.pipe(v.picklist(["smart", "static", "dynamic"]), v.description("Scraping mode: smart (auto), static (colly), dynamic (chromedp)")), "smart"),
|
|
24
|
+
screenshot: v.optional(v.pipe(v.boolean(), v.description("Capture a screenshot (needs dynamic/smart)")), false),
|
|
25
|
+
screenshot_opts: v.optional(v.pipe(v.object({
|
|
26
|
+
width: v.optional(v.number()),
|
|
27
|
+
height: v.optional(v.number()),
|
|
28
|
+
full_page: v.optional(v.boolean()),
|
|
29
|
+
format: v.optional(v.picklist(["jpeg", "png"])),
|
|
30
|
+
quality: v.optional(v.pipe(v.number(), v.minValue(1), v.maxValue(100))),
|
|
31
|
+
wait_selector: v.optional(v.string()),
|
|
32
|
+
}), v.description("Screenshot configuration (width, height, full_page, format, quality, wait_selector)"))),
|
|
33
|
+
images: v.optional(v.pipe(v.boolean(), v.description("Extract images from the page")), false),
|
|
34
|
+
image_format: v.optional(v.pipe(v.picklist(["url", "blob"]), v.description("Image transport: 'url' (metadata only) or 'blob' (base64)")), "url"),
|
|
35
|
+
max_images: v.optional(v.pipe(v.number(), v.minValue(1), v.maxValue(50), v.description("Max images to extract (default 10)")), 10),
|
|
36
|
+
max_image_size_kb: v.optional(v.pipe(v.number(), v.minValue(1), v.description("Max individual image size in KB (default 5120)")), 5120),
|
|
37
|
+
image_process: v.optional(v.pipe(v.object({
|
|
38
|
+
format: v.optional(v.picklist(["jpeg", "png"])),
|
|
39
|
+
max_width: v.optional(v.number()),
|
|
40
|
+
quality: v.optional(v.pipe(v.number(), v.minValue(1), v.maxValue(100))),
|
|
41
|
+
}), v.description("Resize/re-encode image blobs (format, max_width, quality)"))),
|
|
42
|
+
actions: v.optional(v.pipe(v.array(v.object({
|
|
43
|
+
type: v.picklist([
|
|
44
|
+
"wait_ms",
|
|
45
|
+
"wait_selector",
|
|
46
|
+
"click",
|
|
47
|
+
"scroll_down",
|
|
48
|
+
"scroll_to_bottom",
|
|
49
|
+
]),
|
|
50
|
+
ms: v.optional(v.number()),
|
|
51
|
+
selector: v.optional(v.string()),
|
|
52
|
+
})), v.description("Page interactions before capture (dynamic mode only)"))),
|
|
53
|
+
extract_schema: v.optional(v.pipe(v.record(v.string(), v.object({
|
|
54
|
+
selector: v.string(),
|
|
55
|
+
attr: v.optional(v.string()),
|
|
56
|
+
multiple: v.optional(v.boolean()),
|
|
57
|
+
})), v.description("Deterministic CSS-selector extraction: {field: {selector, attr?, multiple?}}"))),
|
|
58
|
+
summary: v.optional(v.pipe(v.boolean(), v.description("Return an extractive summary (no LLM)")), false),
|
|
59
|
+
summary_sentences: v.optional(v.pipe(v.number(), v.minValue(1), v.maxValue(50), v.description("Sentence count for the summary (default 5)")), 5),
|
|
60
|
+
redact_pii: v.optional(v.pipe(v.boolean(), v.description("Mask emails, phones, and card-shaped numbers")), false),
|
|
61
|
+
block_ads: v.optional(v.pipe(v.boolean(), v.description("Strip ad/tracker containers before conversion")), true),
|
|
62
|
+
remove_base64_images: v.optional(v.pipe(v.boolean(), v.description("Drop inline data: images before conversion")), true),
|
|
63
|
+
include_links: v.optional(v.pipe(v.boolean(), v.description('Include extracted links (default true, Firecrawl formats: ["links"] parity — enriched to {url, text, isInternal})')), true),
|
|
64
|
+
render: v.optional(v.pipe(v.boolean(), v.description("Deprecated: behaves like mode=dynamic")), false),
|
|
65
|
+
});
|
|
66
|
+
// ── scrape_multi (sync, no Redis) ─────────────────────────────────────
|
|
67
|
+
const ExtractMultiScrapeShape = v.object({
|
|
68
|
+
action: v.pipe(v.picklist(["scrape_multi"]), v.description("Scrape multiple URLs synchronously (max 10, no Redis) — mirrors web_fetch_exa & Firecrawl batch sync")),
|
|
69
|
+
urls: v.pipe(v.array(v.pipe(v.string(), v.url("Must be a valid URL"))), v.minLength(1, "At least one URL is required"), v.maxLength(10, "Maximum 10 URLs per sync batch"), v.description("URLs to scrape synchronously (max 10, no Redis, errgroup limit 5)")),
|
|
70
|
+
mode: v.optional(v.pipe(v.picklist(["smart", "static", "dynamic"]), v.description("Scraping mode: smart (auto), static (colly), dynamic (chromedp)")), "smart"),
|
|
71
|
+
screenshot: v.optional(v.pipe(v.boolean(), v.description("Capture a screenshot")), false),
|
|
72
|
+
screenshot_opts: v.optional(v.pipe(v.object({
|
|
73
|
+
width: v.optional(v.number()),
|
|
74
|
+
height: v.optional(v.number()),
|
|
75
|
+
full_page: v.optional(v.boolean()),
|
|
76
|
+
format: v.optional(v.picklist(["jpeg", "png"])),
|
|
77
|
+
quality: v.optional(v.pipe(v.number(), v.minValue(1), v.maxValue(100))),
|
|
78
|
+
wait_selector: v.optional(v.string()),
|
|
79
|
+
}), v.description("Screenshot configuration"))),
|
|
80
|
+
images: v.optional(v.pipe(v.boolean(), v.description("Extract images")), false),
|
|
81
|
+
image_format: v.optional(v.pipe(v.picklist(["url", "blob"]), v.description("Image transport: url or blob")), "url"),
|
|
82
|
+
max_images: v.optional(v.pipe(v.number(), v.minValue(1), v.maxValue(50)), 10),
|
|
83
|
+
max_image_size_kb: v.optional(v.pipe(v.number(), v.minValue(1)), 5120),
|
|
84
|
+
image_process: v.optional(v.pipe(v.object({
|
|
85
|
+
format: v.optional(v.picklist(["jpeg", "png"])),
|
|
86
|
+
max_width: v.optional(v.number()),
|
|
87
|
+
quality: v.optional(v.pipe(v.number(), v.minValue(1), v.maxValue(100))),
|
|
88
|
+
}), v.description("Resize/re-encode image blobs"))),
|
|
89
|
+
actions: v.optional(v.pipe(v.array(v.object({
|
|
90
|
+
type: v.picklist([
|
|
91
|
+
"wait_ms",
|
|
92
|
+
"wait_selector",
|
|
93
|
+
"click",
|
|
94
|
+
"scroll_down",
|
|
95
|
+
"scroll_to_bottom",
|
|
96
|
+
]),
|
|
97
|
+
ms: v.optional(v.number()),
|
|
98
|
+
selector: v.optional(v.string()),
|
|
99
|
+
})), v.description("Page interactions before capture (dynamic mode only)"))),
|
|
100
|
+
extract_schema: v.optional(v.pipe(v.record(v.string(), v.object({
|
|
101
|
+
selector: v.string(),
|
|
102
|
+
attr: v.optional(v.string()),
|
|
103
|
+
multiple: v.optional(v.boolean()),
|
|
104
|
+
})), v.description("Deterministic CSS-selector extraction"))),
|
|
105
|
+
summary: v.optional(v.pipe(v.boolean(), v.description("Return an extractive summary")), false),
|
|
106
|
+
summary_sentences: v.optional(v.pipe(v.number(), v.minValue(1), v.maxValue(50)), 5),
|
|
107
|
+
redact_pii: v.optional(v.pipe(v.boolean(), v.description("Mask emails, phones, card numbers")), false),
|
|
108
|
+
block_ads: v.optional(v.pipe(v.boolean(), v.description("Strip ad/tracker containers")), true),
|
|
109
|
+
remove_base64_images: v.optional(v.pipe(v.boolean(), v.description("Drop inline data: images")), true),
|
|
110
|
+
include_links: v.optional(v.pipe(v.boolean(), v.description("Include extracted links (default true)")), true),
|
|
111
|
+
render: v.optional(v.pipe(v.boolean(), v.description("Deprecated: behaves like mode=dynamic")), false),
|
|
112
|
+
});
|
|
113
|
+
// ── links ──────────────────────────────────────────────────────────────
|
|
114
|
+
const ExtractLinksShape = v.object({
|
|
115
|
+
action: v.pipe(v.picklist(["links"]), v.description("Extract hyperlinks only (lightweight, no markdown)")),
|
|
116
|
+
url: v.pipe(v.string(), v.description("The URL to extract hyperlinks from"), v.url("Must be a valid URL")),
|
|
117
|
+
});
|
|
118
|
+
// ── batch (enqueue) ────────────────────────────────────────────────────
|
|
119
|
+
const ExtractBatchShape = v.object({
|
|
120
|
+
action: v.pipe(v.picklist(["batch"]), v.description("Enqueue async batch scrape (max 20 URLs, requires Redis)")),
|
|
121
|
+
urls: v.pipe(v.array(v.pipe(v.string(), v.url("Must be a valid URL"))), v.minLength(1, "At least one URL is required"), v.maxLength(20, "Maximum 20 URLs per batch"), v.description("URLs to scrape asynchronously (max 20, requires Redis)")),
|
|
122
|
+
});
|
|
123
|
+
// ── batch_status (poll) ────────────────────────────────────────────────
|
|
124
|
+
const ExtractBatchStatusShape = v.object({
|
|
125
|
+
action: v.pipe(v.picklist(["batch_status"]), v.description("Poll async batch status")),
|
|
126
|
+
batch_id: v.pipe(v.string(), v.minLength(1, "Batch ID is required"), v.description("The batch_id returned by cinder_extract action=batch")),
|
|
127
|
+
});
|
|
128
|
+
export const ExtractSchema = v.variant("action", [
|
|
129
|
+
ExtractScrapeShape,
|
|
130
|
+
ExtractMultiScrapeShape,
|
|
131
|
+
ExtractLinksShape,
|
|
132
|
+
ExtractBatchShape,
|
|
133
|
+
ExtractBatchStatusShape,
|
|
134
|
+
]);
|
|
135
|
+
export function createExtractHandler(client) {
|
|
136
|
+
return async (input) => {
|
|
137
|
+
const { action } = input;
|
|
138
|
+
try {
|
|
139
|
+
if (action === "scrape") {
|
|
140
|
+
const params = input;
|
|
141
|
+
const result = await client.scrape(params);
|
|
142
|
+
const titleMatch = result.markdown.match(/^#\s+(.+)/m);
|
|
143
|
+
const title = titleMatch ? titleMatch[1].trim() : result.url;
|
|
144
|
+
const wordCount = result.markdown.split(/\s+/).length;
|
|
145
|
+
const lines = [
|
|
146
|
+
`# Scrape Result: ${title}`,
|
|
147
|
+
"",
|
|
148
|
+
`**URL:** ${result.url}`,
|
|
149
|
+
`**Words:** ${wordCount.toLocaleString()}`,
|
|
150
|
+
];
|
|
151
|
+
if (result.summary)
|
|
152
|
+
lines.push("", "## Summary", "", result.summary);
|
|
153
|
+
if (result.extracted && Object.keys(result.extracted).length > 0) {
|
|
154
|
+
lines.push("", "## Extracted", "");
|
|
155
|
+
for (const [k, val] of Object.entries(result.extracted))
|
|
156
|
+
lines.push(`- **${k}:** ${typeof val === "string" ? val : JSON.stringify(val)}`);
|
|
157
|
+
}
|
|
158
|
+
lines.push("", "---", "", result.markdown);
|
|
159
|
+
if (result.images && result.images.length > 0) {
|
|
160
|
+
lines.push("", "---", "", `## Images (${result.images.length})`, "");
|
|
161
|
+
for (const img of result.images) {
|
|
162
|
+
const label = img.alt || img.title || img.source || img.url || "image";
|
|
163
|
+
if (img.url)
|
|
164
|
+
lines.push(`- [${label}](${img.url})`);
|
|
165
|
+
else if (img.blob)
|
|
166
|
+
lines.push(`- ${label} (base64 ${img.format ?? ""}${img.size_bytes ? `, ${img.size_bytes} bytes` : ""})`);
|
|
167
|
+
else
|
|
168
|
+
lines.push(`- ${label}`);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
if (result.screenshot) {
|
|
172
|
+
lines.push("", "## Screenshot", "");
|
|
173
|
+
if (result.screenshot.url)
|
|
174
|
+
lines.push(`- [screenshot](${result.screenshot.url})`);
|
|
175
|
+
else if (result.screenshot.blob)
|
|
176
|
+
lines.push(`- screenshot captured (base64 ${result.screenshot.format ?? ""}${result.screenshot.size_bytes ? `, ${result.screenshot.size_bytes} bytes` : ""})`);
|
|
177
|
+
}
|
|
178
|
+
if (result.metadata && Object.keys(result.metadata).length > 0) {
|
|
179
|
+
lines.push("", "## Metadata", "");
|
|
180
|
+
for (const [k, val] of Object.entries(result.metadata))
|
|
181
|
+
lines.push(`- **${k}:** ${val}`);
|
|
182
|
+
}
|
|
183
|
+
if (result.links && result.links.length > 0) {
|
|
184
|
+
lines.push("", "## Links", `Found ${result.links.length} link(s):`, "");
|
|
185
|
+
const toShow = result.links.slice(0, 50);
|
|
186
|
+
for (const link of toShow) {
|
|
187
|
+
const label = link.text ? ` — "${link.text.slice(0, 80)}"` : "";
|
|
188
|
+
const scope = link.isInternal ? "internal" : "external";
|
|
189
|
+
lines.push(`- ${link.url}${label} _(${scope})_`);
|
|
190
|
+
}
|
|
191
|
+
if (result.links.length > 50)
|
|
192
|
+
lines.push(`- ... and ${result.links.length - 50} more`);
|
|
193
|
+
}
|
|
194
|
+
return { content: [{ type: "text", text: lines.join("\n") }] };
|
|
195
|
+
}
|
|
196
|
+
if (action === "scrape_multi") {
|
|
197
|
+
const params = input;
|
|
198
|
+
const result = await client.scrapeMulti(params);
|
|
199
|
+
const lines = [
|
|
200
|
+
`# Multi-Scrape Results (${result.results.length} URLs)`,
|
|
201
|
+
"",
|
|
202
|
+
];
|
|
203
|
+
for (let i = 0; i < result.results.length; i++) {
|
|
204
|
+
const item = result.results[i];
|
|
205
|
+
if (item.error) {
|
|
206
|
+
lines.push(`## Result ${i + 1}: ❌ ${item.url}`, "", `**Error:** ${item.error}`, "", "---", "");
|
|
207
|
+
continue;
|
|
208
|
+
}
|
|
209
|
+
const title = item.title || item.url;
|
|
210
|
+
const wc = item.word_count != null
|
|
211
|
+
? `**Words:** ${item.word_count.toLocaleString()}`
|
|
212
|
+
: "";
|
|
213
|
+
lines.push(`## Result ${i + 1}: ${title}`, "", `**URL:** ${item.url}`);
|
|
214
|
+
if (wc)
|
|
215
|
+
lines.push(wc);
|
|
216
|
+
if (item.summary)
|
|
217
|
+
lines.push("", "### Summary", "", item.summary);
|
|
218
|
+
if (item.extracted && Object.keys(item.extracted).length > 0) {
|
|
219
|
+
lines.push("", "### Extracted", "");
|
|
220
|
+
for (const [k, val] of Object.entries(item.extracted))
|
|
221
|
+
lines.push(`- **${k}:** ${typeof val === "string" ? val : JSON.stringify(val)}`);
|
|
222
|
+
}
|
|
223
|
+
lines.push("", "---", "", item.markdown ?? "_(no markdown)_");
|
|
224
|
+
if (item.images && item.images.length > 0) {
|
|
225
|
+
lines.push("", `### Images (${item.images.length})`, "");
|
|
226
|
+
for (const img of item.images) {
|
|
227
|
+
const label = img.alt || img.title || img.source || img.url || "image";
|
|
228
|
+
if (img.url)
|
|
229
|
+
lines.push(`- [${label}](${img.url})`);
|
|
230
|
+
else if (img.blob)
|
|
231
|
+
lines.push(`- ${label} (base64 ${img.format ?? ""}${img.size_bytes ? `, ${img.size_bytes} bytes` : ""})`);
|
|
232
|
+
else
|
|
233
|
+
lines.push(`- ${label}`);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
if (item.screenshot) {
|
|
237
|
+
lines.push("", "### Screenshot", "");
|
|
238
|
+
if (item.screenshot.url)
|
|
239
|
+
lines.push(`- [screenshot](${item.screenshot.url})`);
|
|
240
|
+
else if (item.screenshot.blob)
|
|
241
|
+
lines.push(`- screenshot captured (base64 ${item.screenshot.format ?? ""}${item.screenshot.size_bytes ? `, ${item.screenshot.size_bytes} bytes` : ""})`);
|
|
242
|
+
}
|
|
243
|
+
if (item.metadata && Object.keys(item.metadata).length > 0) {
|
|
244
|
+
lines.push("", "### Metadata", "");
|
|
245
|
+
for (const [k, val] of Object.entries(item.metadata))
|
|
246
|
+
lines.push(`- **${k}:** ${val}`);
|
|
247
|
+
}
|
|
248
|
+
if (item.links && item.links.length > 0) {
|
|
249
|
+
lines.push("", `### Links (${item.links.length})`, "");
|
|
250
|
+
for (const link of item.links.slice(0, 20)) {
|
|
251
|
+
const label = link.text ? ` — "${link.text.slice(0, 60)}"` : "";
|
|
252
|
+
lines.push(`- ${link.url}${label} _(${link.isInternal ? "internal" : "external"})_`);
|
|
253
|
+
}
|
|
254
|
+
if (item.links.length > 20)
|
|
255
|
+
lines.push(`- ... and ${item.links.length - 20} more`);
|
|
256
|
+
}
|
|
257
|
+
lines.push("", "---", "");
|
|
258
|
+
}
|
|
259
|
+
return { content: [{ type: "text", text: lines.join("\n") }] };
|
|
260
|
+
}
|
|
261
|
+
if (action === "links") {
|
|
262
|
+
const { url } = input;
|
|
263
|
+
const result = await client.links(url);
|
|
264
|
+
const links = result.links ?? [];
|
|
265
|
+
const lines = [
|
|
266
|
+
`# Links: ${url}`,
|
|
267
|
+
"",
|
|
268
|
+
`**Found:** ${links.length} link(s)`,
|
|
269
|
+
`**Source:** ${result.url}`,
|
|
270
|
+
"",
|
|
271
|
+
"---",
|
|
272
|
+
"",
|
|
273
|
+
];
|
|
274
|
+
if (links.length === 0)
|
|
275
|
+
lines.push("No links found on this page.");
|
|
276
|
+
else {
|
|
277
|
+
const internal = links.filter((l) => l.isInternal);
|
|
278
|
+
const external = links.filter((l) => !l.isInternal);
|
|
279
|
+
if (internal.length > 0) {
|
|
280
|
+
lines.push(`## Internal (${internal.length})`, "");
|
|
281
|
+
for (const l of internal)
|
|
282
|
+
lines.push(`- ${l.url}${l.text ? ` — "${l.text}"` : ""}`);
|
|
283
|
+
lines.push("");
|
|
284
|
+
}
|
|
285
|
+
if (external.length > 0) {
|
|
286
|
+
lines.push(`## External (${external.length})`, "");
|
|
287
|
+
for (const l of external)
|
|
288
|
+
lines.push(`- ${l.url}${l.text ? ` — "${l.text}"` : ""}`);
|
|
289
|
+
lines.push("");
|
|
290
|
+
}
|
|
291
|
+
if (internal.length === 0 && external.length === 0)
|
|
292
|
+
for (const l of links)
|
|
293
|
+
lines.push(`- ${l.url}${l.text ? ` — "${l.text}"` : ""} (isInternal: ${l.isInternal})`);
|
|
294
|
+
}
|
|
295
|
+
return { content: [{ type: "text", text: lines.join("\n") }] };
|
|
296
|
+
}
|
|
297
|
+
if (action === "batch") {
|
|
298
|
+
const { urls } = input;
|
|
299
|
+
const result = await client.batchScrape({ urls });
|
|
300
|
+
const lines = [
|
|
301
|
+
"# Batch Scrape Enqueued",
|
|
302
|
+
"",
|
|
303
|
+
`**Batch ID:** \`${result.batch_id}\``,
|
|
304
|
+
`**Total:** ${result.tasks.length}`,
|
|
305
|
+
"",
|
|
306
|
+
"## Tasks",
|
|
307
|
+
"",
|
|
308
|
+
];
|
|
309
|
+
for (const t of result.tasks)
|
|
310
|
+
lines.push(`- \`${t.id}\` — ${t.url}`);
|
|
311
|
+
lines.push("", "---", "", `Use \`cinder_extract\` with \`action: "batch_status"\` and \`batch_id: "${result.batch_id}"\` to poll.`, "Requires Redis-backed Cinder instance.");
|
|
312
|
+
return { content: [{ type: "text", text: lines.join("\n") }] };
|
|
313
|
+
}
|
|
314
|
+
// batch_status
|
|
315
|
+
const { batch_id } = input;
|
|
316
|
+
const result = await client.getBatchStatus(batch_id);
|
|
317
|
+
const lines = [
|
|
318
|
+
"# Batch Status",
|
|
319
|
+
"",
|
|
320
|
+
`**Batch ID:** \`${result.batch_id}\``,
|
|
321
|
+
`**Total:** ${result.total} | **Completed:** ${result.completed} | **Failed:** ${result.failed}`,
|
|
322
|
+
"",
|
|
323
|
+
];
|
|
324
|
+
if (result.tasks.length > 0) {
|
|
325
|
+
lines.push("## Tasks", "");
|
|
326
|
+
for (const t of result.tasks)
|
|
327
|
+
lines.push(`- \`${t.id}\` — ${t.url}`);
|
|
328
|
+
}
|
|
329
|
+
if (result.completed === result.total && result.failed === 0)
|
|
330
|
+
lines.push("", "✅ All tasks completed.");
|
|
331
|
+
else if (result.failed > 0)
|
|
332
|
+
lines.push("", `⚠️ ${result.failed} task(s) failed.`);
|
|
333
|
+
else
|
|
334
|
+
lines.push("", "⏳ Batch still in progress — poll again.");
|
|
335
|
+
return { content: [{ type: "text", text: lines.join("\n") }] };
|
|
336
|
+
}
|
|
337
|
+
catch (err) {
|
|
338
|
+
const message = err instanceof Error ? err.message : "Unknown error";
|
|
339
|
+
return {
|
|
340
|
+
content: [
|
|
341
|
+
{
|
|
342
|
+
type: "text",
|
|
343
|
+
text: `Extract ${action} failed: ${message}`,
|
|
344
|
+
},
|
|
345
|
+
],
|
|
346
|
+
isError: true,
|
|
347
|
+
};
|
|
348
|
+
}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,EAAE;qBAC7C;iBACF;gBACD,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
import type { CinderClient } from "../client.js";
|
|
3
|
+
export declare const MonitorSchema: v.VariantSchema<"action", [v.ObjectSchema<{
|
|
4
|
+
readonly action: v.LiteralSchema<"create", undefined>;
|
|
5
|
+
readonly url: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.DescriptionAction<string, "The URL to monitor for content changes">, v.UrlAction<string, "Must be a valid URL">]>;
|
|
6
|
+
readonly interval_seconds: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 3600, undefined>, v.DescriptionAction<number, "Check interval in seconds (minimum 3600 = 1h)">]>, 3600>;
|
|
7
|
+
readonly webhook_url: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.DescriptionAction<string, "POST a change notification here when content changes">]>, undefined>;
|
|
8
|
+
readonly webhook_secret: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.DescriptionAction<string, "HMAC-SHA256 key for the X-Cinder-Signature header">]>, undefined>;
|
|
9
|
+
}, undefined>, v.ObjectSchema<{
|
|
10
|
+
readonly action: v.LiteralSchema<"status", undefined>;
|
|
11
|
+
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.DescriptionAction<string, "The monitor ID to check">, v.MinLengthAction<string, 1, "Monitor ID is required">]>;
|
|
12
|
+
}, undefined>, v.ObjectSchema<{
|
|
13
|
+
readonly action: v.LiteralSchema<"delete", undefined>;
|
|
14
|
+
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.DescriptionAction<string, "The monitor ID to delete">, v.MinLengthAction<string, 1, "Monitor ID is required">]>;
|
|
15
|
+
}, undefined>], undefined>;
|
|
16
|
+
export type MonitorInput = v.InferOutput<typeof MonitorSchema>;
|
|
17
|
+
/**
|
|
18
|
+
* Handler for the cinder_monitor tool.
|
|
19
|
+
* Dispatches to create / status / delete based on the `action` field.
|
|
20
|
+
*/
|
|
21
|
+
export declare function createMonitorHandler(client: CinderClient): (input: Record<string, unknown>) => Promise<{
|
|
22
|
+
content: {
|
|
23
|
+
type: "text";
|
|
24
|
+
text: string;
|
|
25
|
+
}[];
|
|
26
|
+
isError?: undefined;
|
|
27
|
+
} | {
|
|
28
|
+
content: {
|
|
29
|
+
type: "text";
|
|
30
|
+
text: string;
|
|
31
|
+
}[];
|
|
32
|
+
isError: boolean;
|
|
33
|
+
}>;
|
|
34
|
+
//# sourceMappingURL=monitor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"monitor.d.ts","sourceRoot":"","sources":["../../src/tools/monitor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;AAC7B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAsDjD,eAAO,MAAM,aAAa;;;;;;;;;;;;0BAIxB,CAAC;AAEH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,aAAa,CAAC,CAAC;AAE/D;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,YAAY,IACzC,OAAO,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;;;;;;;;;;;;GAgE7C"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
/**
|
|
3
|
+
* Schema for the cinder_monitor tool.
|
|
4
|
+
* A single tool that creates, checks, or deletes a change-tracking monitor,
|
|
5
|
+
* selected by the `action` discriminator (mirrors handlers.MonitorRequest).
|
|
6
|
+
*/
|
|
7
|
+
const MonitorCreateShape = v.object({
|
|
8
|
+
action: v.literal("create"),
|
|
9
|
+
url: v.pipe(v.string(), v.description("The URL to monitor for content changes"), v.url("Must be a valid URL")),
|
|
10
|
+
interval_seconds: v.optional(v.pipe(v.number(), v.minValue(3600), v.description("Check interval in seconds (minimum 3600 = 1h)")), 3600),
|
|
11
|
+
webhook_url: v.optional(v.pipe(v.string(), v.description("POST a change notification here when content changes"))),
|
|
12
|
+
webhook_secret: v.optional(v.pipe(v.string(), v.description("HMAC-SHA256 key for the X-Cinder-Signature header"))),
|
|
13
|
+
});
|
|
14
|
+
const MonitorStatusShape = v.object({
|
|
15
|
+
action: v.literal("status"),
|
|
16
|
+
id: v.pipe(v.string(), v.description("The monitor ID to check"), v.minLength(1, "Monitor ID is required")),
|
|
17
|
+
});
|
|
18
|
+
const MonitorDeleteShape = v.object({
|
|
19
|
+
action: v.literal("delete"),
|
|
20
|
+
id: v.pipe(v.string(), v.description("The monitor ID to delete"), v.minLength(1, "Monitor ID is required")),
|
|
21
|
+
});
|
|
22
|
+
export const MonitorSchema = v.variant("action", [
|
|
23
|
+
MonitorCreateShape,
|
|
24
|
+
MonitorStatusShape,
|
|
25
|
+
MonitorDeleteShape,
|
|
26
|
+
]);
|
|
27
|
+
/**
|
|
28
|
+
* Handler for the cinder_monitor tool.
|
|
29
|
+
* Dispatches to create / status / delete based on the `action` field.
|
|
30
|
+
*/
|
|
31
|
+
export function createMonitorHandler(client) {
|
|
32
|
+
return async (input) => {
|
|
33
|
+
const { action } = input;
|
|
34
|
+
try {
|
|
35
|
+
if (action === "create") {
|
|
36
|
+
const result = await client.createMonitor(input);
|
|
37
|
+
const lines = [
|
|
38
|
+
"# Monitor Created",
|
|
39
|
+
"",
|
|
40
|
+
`**Monitor ID:** \`${result.id}\``,
|
|
41
|
+
`**URL:** ${result.url}`,
|
|
42
|
+
`**Interval:** ${result.interval_seconds}s`,
|
|
43
|
+
`**Next Check:** ${result.next_check}`,
|
|
44
|
+
"",
|
|
45
|
+
"---",
|
|
46
|
+
"",
|
|
47
|
+
'Use `cinder_monitor` with `action: "status"` to check, or `action: "delete"` to stop monitoring.',
|
|
48
|
+
];
|
|
49
|
+
return {
|
|
50
|
+
content: [{ type: "text", text: lines.join("\n") }],
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
if (action === "status") {
|
|
54
|
+
const result = await client.getMonitor(input.id);
|
|
55
|
+
const lines = [
|
|
56
|
+
"# Monitor Status",
|
|
57
|
+
"",
|
|
58
|
+
`**Monitor ID:** \`${result.id}\``,
|
|
59
|
+
`**URL:** ${result.url}`,
|
|
60
|
+
`**Interval:** ${result.interval_seconds}s`,
|
|
61
|
+
`**Next Check:** ${result.next_check}`,
|
|
62
|
+
];
|
|
63
|
+
if (result.last_hash) {
|
|
64
|
+
lines.push(`**Last Hash:** ${result.last_hash}`);
|
|
65
|
+
}
|
|
66
|
+
return {
|
|
67
|
+
content: [{ type: "text", text: lines.join("\n") }],
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
// action === "delete"
|
|
71
|
+
await client.deleteMonitor(input.id);
|
|
72
|
+
return {
|
|
73
|
+
content: [
|
|
74
|
+
{
|
|
75
|
+
type: "text",
|
|
76
|
+
text: `Monitor \`${input.id}\` deleted.`,
|
|
77
|
+
},
|
|
78
|
+
],
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
catch (err) {
|
|
82
|
+
const message = err instanceof Error ? err.message : "Unknown error";
|
|
83
|
+
return {
|
|
84
|
+
content: [
|
|
85
|
+
{
|
|
86
|
+
type: "text",
|
|
87
|
+
text: `Monitor ${action} failed: ${message}`,
|
|
88
|
+
},
|
|
89
|
+
],
|
|
90
|
+
isError: true,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=monitor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"monitor.js","sourceRoot":"","sources":["../../src/tools/monitor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;AAG7B;;;;GAIG;AACH,MAAM,kBAAkB,GAAG,CAAC,CAAC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BAAgB,GAAG;oBAC3C,mBAAmB,MAAM,CAAC,UAAU,EAAE;iBACvC,CAAC;gBACF,IAAI,MAAM,CAAC,SAAS,EAAE,CAAC;oBACrB,KAAK,CAAC,IAAI,CAAC,kBAAkB,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC;gBACnD,CAAC;gBACD,OAAO;oBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;iBAC7D,CAAC;YACJ,CAAC;YAED,sBAAsB;YACtB,MAAM,MAAM,CAAC,aAAa,CAAE,KAAa,CAAC,EAAE,CAAC,CAAC;YAC9C,OAAO;gBACL,OAAO,EAAE;oBACP;wBACE,IAAI,EAAE,MAAe;wBACrB,IAAI,EAAE,aAAc,KAAa,CAAC,EAAE,aAAa;qBAClD;iBACF;aACF,CAAC;QACJ,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,OAAO,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC;YACrE,OAAO;gBACL,OAAO,EAAE;oBACP;wBACE,IAAI,EAAE,MAAe;wBACrB,IAAI,EAAE,WAAW,MAAM,YAAY,OAAO,EAAE;qBAC7C;iBACF;gBACD,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "tomoshi",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Tomoshibi (灯火 — lamp light) — self-hosted web search & scraping for AI agents. One binary, $5/mo.",
|
|
5
|
+
"bin": {
|
|
6
|
+
"tomoshi": "dist/stdio.js",
|
|
7
|
+
"tomoshibi": "dist/stdio.js",
|
|
8
|
+
"tomoshibi-mcp": "dist/stdio.js"
|
|
9
|
+
},
|
|
10
|
+
"type": "module",
|
|
11
|
+
"main": "dist/index.js",
|
|
12
|
+
"types": "dist/index.d.ts",
|
|
13
|
+
"files": ["dist", "README.md", "LICENSE"],
|
|
14
|
+
"publishConfig": {
|
|
15
|
+
"access": "public",
|
|
16
|
+
"provenance": true
|
|
17
|
+
},
|
|
18
|
+
"scripts": {
|
|
19
|
+
"start": "bun run src/index.ts",
|
|
20
|
+
"dev": "bun run --watch src/index.ts",
|
|
21
|
+
"typecheck": "tsc --noEmit",
|
|
22
|
+
"check": "bun run typecheck",
|
|
23
|
+
"build": "tsc -p tsconfig.build.json && chmod +x dist/stdio.js && chmod +x dist/index.js",
|
|
24
|
+
"prepublishOnly": "npm run build",
|
|
25
|
+
"patch:tmcp": "echo \"no patch needed\"",
|
|
26
|
+
"postinstall": "echo \"no patch needed\""
|
|
27
|
+
},
|
|
28
|
+
"keywords": [
|
|
29
|
+
"tmcp",
|
|
30
|
+
"mcp",
|
|
31
|
+
"server",
|
|
32
|
+
"tomoshibi",
|
|
33
|
+
"tomoshi",
|
|
34
|
+
"web-scraping",
|
|
35
|
+
"crawling",
|
|
36
|
+
"search"
|
|
37
|
+
],
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"tmcp": "^1.19.4",
|
|
40
|
+
"@tmcp/adapter-valibot": "^0.1.6",
|
|
41
|
+
"valibot": "^1.4.2",
|
|
42
|
+
"@tmcp/transport-stdio": "^0.4.3",
|
|
43
|
+
"@tmcp/transport-http": "^0.8.6",
|
|
44
|
+
"@tmcp/transport-sse": "^0.5.5",
|
|
45
|
+
"@tmcp/auth": "^0.4.1",
|
|
46
|
+
"srvx": "^0.11.22"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@types/bun": "^1.2.0",
|
|
50
|
+
"@types/node": "^24.0.15",
|
|
51
|
+
"typescript": "^5.7.0"
|
|
52
|
+
}
|
|
53
|
+
}
|