Skip to content

Commit 40b3fdd

Browse files
committed
Nick: improvements
1 parent c05b34a commit 40b3fdd

4 files changed

Lines changed: 32 additions & 12 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "firecrawl-cli",
3-
"version": "1.12.1",
3+
"version": "1.12.2",
44
"description": "Command-line interface for Firecrawl. Scrape, crawl, and extract data from any website directly from your terminal.",
55
"main": "dist/index.js",
66
"bin": {

src/commands/interact.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,11 @@ export async function handleInteractExecute(
5454
const { apiKey, apiUrl } = resolveApiConfig(options);
5555

5656
const stored = loadInteractSession();
57-
if (!options.scrapeId && stored) {
58-
process.stderr.write(
59-
`Using scrape ${scrapeId}` +
60-
(stored.url ? ` (${stored.url})` : '') +
61-
'\n'
62-
);
63-
}
57+
const storedUrl =
58+
stored?.url && stored.scrapeId === scrapeId ? stored.url : undefined;
59+
process.stderr.write(
60+
`Using scrape ${scrapeId}` + (storedUrl ? ` (${storedUrl})` : '') + '\n'
61+
);
6462

6563
const body: Record<string, unknown> = { origin: 'cli', integration: 'cli' };
6664

src/commands/scrape.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ import type {
1111
} from '../types/scrape';
1212
import { getClient } from '../utils/client';
1313
import { handleScrapeOutput, writeOutput } from '../utils/output';
14-
import { saveInteractSession } from '../utils/interact-session';
14+
import {
15+
saveInteractSession,
16+
clearInteractSession,
17+
} from '../utils/interact-session';
1518
import { getOrigin } from '../utils/url';
1619
import { executeMap } from './map';
1720
import { getStatus } from './status';
@@ -125,14 +128,18 @@ export async function executeScrape(
125128

126129
const scrapeId = result?.metadata?.scrapeId;
127130
if (scrapeId) {
131+
process.stderr.write(`Scrape ID: ${scrapeId}\n`);
128132
try {
129133
saveInteractSession({
130134
scrapeId,
131135
url: options.url,
132136
createdAt: new Date().toISOString(),
133137
});
134138
} catch {
135-
// Non-critical — don't fail the scrape
139+
process.stderr.write(
140+
`Warning: Could not save scrape session. ` +
141+
`Use --scrape-id ${scrapeId} with interact.\n`
142+
);
136143
}
137144
}
138145

@@ -248,13 +255,16 @@ export async function handleMultiScrapeCommand(
248255

249256
await Promise.all(promises);
250257

258+
clearInteractSession();
251259
process.stderr.write(
252260
`\nCompleted: ${completedCount - errorCount}/${total} succeeded`
253261
);
254262
if (errorCount > 0) {
255263
process.stderr.write(`, ${errorCount} failed`);
256264
}
257-
process.stderr.write('\n');
265+
process.stderr.write(
266+
'\nTip: Use --scrape-id <id> with interact to target a specific scrape.\n'
267+
);
258268

259269
if (errorCount === total) {
260270
process.exit(1);

src/utils/interact-session.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,26 @@ export function clearInteractSession(): void {
7373
}
7474
}
7575

76+
const SESSION_STALE_MS = 10 * 60 * 1000; // 10 minutes
77+
7678
/**
7779
* Resolve scrape ID from explicit override or stored session
7880
*/
7981
export function getScrapeId(overrideId?: string): string {
8082
if (overrideId) return overrideId;
8183

8284
const stored = loadInteractSession();
83-
if (stored) return stored.scrapeId;
85+
if (stored) {
86+
const ageMs = Date.now() - new Date(stored.createdAt).getTime();
87+
if (ageMs > SESSION_STALE_MS) {
88+
const mins = Math.round(ageMs / 60_000);
89+
process.stderr.write(
90+
`Warning: Last scrape session is ${mins}m old and may have expired. ` +
91+
`Re-scrape or pass --scrape-id explicitly.\n`
92+
);
93+
}
94+
return stored.scrapeId;
95+
}
8496

8597
throw new Error(
8698
'No active scrape session. Scrape a URL first:\n' +

0 commit comments

Comments
 (0)