Compare commits

...

2 Commits

Author SHA1 Message Date
Cursor Agent
01f02f1169 fix firecrawl scrape creditsUsed mapping 2026-03-14 17:44:59 +00:00
Theodore Li
fecc435c10 fix(firecrawl) fix firecrawl scrape credit usage calculation 2026-03-14 10:37:17 -07:00

View File

@@ -38,11 +38,12 @@ export const scrapeTool: ToolConfig<ScrapeParams, ScrapeResponse> = {
pricing: {
type: 'custom',
getCost: (_params, output) => {
if (output.creditsUsed == null) {
const creditsUsedString = (output.metadata as { creditsUsed?: number })?.creditsUsed
if (creditsUsedString == null) {
throw new Error('Firecrawl response missing creditsUsed field')
}
const creditsUsed = Number(output.creditsUsed)
const creditsUsed = Number(creditsUsedString)
if (Number.isNaN(creditsUsed)) {
throw new Error('Firecrawl response returned a non-numeric creditsUsed field')
}
@@ -110,7 +111,7 @@ export const scrapeTool: ToolConfig<ScrapeParams, ScrapeResponse> = {
markdown: data.data.markdown,
html: data.data.html,
metadata: data.data.metadata,
creditsUsed: data.creditsUsed,
creditsUsed: data.data.metadata?.creditsUsed,
},
}
},