Skip to content

Commit 8c616a1

Browse files
committed
Update monitor.ts
1 parent 27c587f commit 8c616a1

1 file changed

Lines changed: 71 additions & 1 deletion

File tree

src/monitor.ts

Lines changed: 71 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ Create a Firecrawl monitor — a recurring scrape or crawl that diffs each resul
9292
9393
Pass the full request body. Required fields: \`name\`, \`schedule\` (with \`cron\` or \`text\`), and \`targets\` (one or more \`{ type: 'scrape', urls: [...] }\` or \`{ type: 'crawl', url: '...' }\`). Optional: \`webhook\`, \`notification\`, \`retentionDays\`.
9494
95-
**Usage Example:**
95+
**Markdown-mode (default):** Each check produces a unified text diff of the page's markdown. No extra configuration needed.
96+
9697
\`\`\`json
9798
{
9899
"name": "firecrawl_monitor_create",
@@ -106,6 +107,49 @@ Pass the full request body. Required fields: \`name\`, \`schedule\` (with \`cron
106107
}
107108
}
108109
\`\`\`
110+
111+
**JSON-mode change tracking:** To detect changes in **specific structured fields** (price, headline, in-stock flag, list items) instead of the whole page, add a \`changeTracking\` format with \`modes: ["json"]\` and a JSON schema to the target's \`scrapeOptions.formats\`. The check response will then carry a per-field diff (keyed by JSON path, e.g. \`plans[0].price\`) and a \`snapshot.json\` with the full current extraction. See \`firecrawl_monitor_check\` for the response shape.
112+
113+
\`\`\`json
114+
{
115+
"name": "firecrawl_monitor_create",
116+
"arguments": {
117+
"body": {
118+
"name": "Pricing watch",
119+
"schedule": { "text": "hourly", "timezone": "UTC" },
120+
"targets": [{
121+
"type": "scrape",
122+
"urls": ["https://example.com/pricing"],
123+
"scrapeOptions": {
124+
"formats": [{
125+
"type": "changeTracking",
126+
"modes": ["json"],
127+
"prompt": "Extract pricing tiers and headline features for each plan.",
128+
"schema": {
129+
"type": "object",
130+
"properties": {
131+
"plans": {
132+
"type": "array",
133+
"items": {
134+
"type": "object",
135+
"properties": {
136+
"name": { "type": "string" },
137+
"price": { "type": "string" },
138+
"features": { "type": "array", "items": { "type": "string" } }
139+
}
140+
}
141+
}
142+
}
143+
}
144+
}]
145+
}
146+
}]
147+
}
148+
}
149+
}
150+
\`\`\`
151+
152+
**Mixed mode (JSON + git-diff):** Use \`modes: ["json", "git-diff"]\` to get both per-field diffs and a markdown sidecar. The page is marked \`changed\` whenever either surface changed.
109153
`,
110154
parameters: z.object({
111155
body: z.record(z.string(), z.any()),
@@ -336,6 +380,32 @@ List historical checks for a monitor.
336380
description: `
337381
Get a single check with page-level diff results. Filter \`pageStatus\` to surface only the pages that changed (or were new, removed, etc.).
338382
383+
Each entry in \`data.pages[]\` has \`url\`, \`status\` (\`same\` | \`new\` | \`changed\` | \`removed\` | \`error\`), and — when changed — a \`diff\` and possibly a \`snapshot\`. The shape of \`diff\` depends on the monitor's \`formats\` configuration:
384+
385+
- **Markdown mode (default).** \`diff.text\` is the unified markdown diff; \`diff.json\` is a parse-diff AST (\`{ files: [...] }\`). No \`snapshot\`.
386+
- **JSON mode** (\`changeTracking\` with \`modes: ["json"]\`). \`diff.json\` is a per-field map keyed by JSON path into the extraction, e.g. \`plans[0].price\`, with each value being \`{ previous, current }\`. \`snapshot.json\` is the full current extraction. No \`diff.text\`.
387+
- **Mixed mode** (\`modes: ["json", "git-diff"]\`). Both \`diff.text\` (markdown sidecar) AND \`diff.json\` (per-field map) are present, plus \`snapshot.json\`.
388+
389+
**Example JSON-mode response \`pages[]\` entry:**
390+
391+
\`\`\`json
392+
{
393+
"url": "https://example.com/pricing",
394+
"status": "changed",
395+
"diff": {
396+
"json": {
397+
"plans[0].price": { "previous": "$19/mo", "current": "$24/mo" },
398+
"plans[1].features[2]": { "previous": "10 GB storage", "current": "25 GB storage" }
399+
}
400+
},
401+
"snapshot": { "json": { "plans": [/* current full extraction matching the monitor's schema */] } }
402+
}
403+
\`\`\`
404+
405+
When summarizing a check for the user, prefer \`diff.json\` paths (e.g. "plans[0].price changed from $19/mo to $24/mo") over re-printing the markdown diff — it's more concise and grounded in the schema fields they asked for.
406+
407+
The endpoint paginates via a top-level \`next\` URL; this tool returns one page at a time. Increase \`limit\` (max 100) to fetch fewer pages.
408+
339409
**Usage Example:**
340410
\`\`\`json
341411
{

0 commit comments

Comments
 (0)