Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "firecrawl-cli",
"version": "1.9.1",
"version": "1.9.2",
"description": "Command-line interface for Firecrawl. Scrape, crawl, and extract data from any website directly from your terminal.",
"main": "dist/index.js",
"bin": {
Expand Down
70 changes: 70 additions & 0 deletions src/__tests__/commands/browser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,44 @@ describe('Browser Commands', () => {
vi.clearAllMocks();
});

it('launch passes origin cli to browser()', async () => {
mockClient.browser.mockResolvedValue({
success: true,
id: 'session-123',
cdpUrl: 'wss://cdp.example.com/session-123',
});

await handleBrowserLaunch({});

expect(mockClient.browser).toHaveBeenCalledWith(
expect.objectContaining({ origin: 'cli' })
);
});

it('launch passes origin cli alongside other options', async () => {
mockClient.browser.mockResolvedValue({
success: true,
id: 'session-123',
cdpUrl: 'wss://cdp.example.com/session-123',
});

await handleBrowserLaunch({
ttl: 600,
ttlInactivity: 120,
profile: 'my-profile',
saveChanges: true,
});

expect(mockClient.browser).toHaveBeenCalledWith(
expect.objectContaining({
origin: 'cli',
ttl: 600,
activityTtl: 120,
profile: { name: 'my-profile', saveChanges: true },
})
);
});

it('launch saves session on success', async () => {
mockClient.browser.mockResolvedValue({
success: true,
Expand Down Expand Up @@ -159,11 +197,43 @@ describe('Browser Commands', () => {
await handleBrowserQuickExecute({ code: 'open https://example.com' });

expect(mockClient.browser).toHaveBeenCalledTimes(1);
expect(mockClient.browser).toHaveBeenCalledWith(
expect.objectContaining({ origin: 'cli' })
);
expect(saveBrowserSession).toHaveBeenCalledWith(
expect.objectContaining({ id: 'new-session' })
);
});

it('quick execute auto-launch passes origin cli with profile', async () => {
const { loadBrowserSession } = await import('../../utils/browser-session');
vi.mocked(loadBrowserSession).mockReturnValueOnce(null);
vi.mocked(loadBrowserSession).mockReturnValue({
id: 'new-session',
cdpUrl: 'wss://new',
createdAt: '2025-01-01T00:00:00Z',
});

mockClient.browser.mockResolvedValue({
success: true,
id: 'new-session',
cdpUrl: 'wss://new',
});

await handleBrowserQuickExecute({
code: 'open https://example.com',
profile: 'dev',
saveChanges: false,
});

expect(mockClient.browser).toHaveBeenCalledWith(
expect.objectContaining({
origin: 'cli',
profile: { name: 'dev', saveChanges: false },
})
);
});

it('quick execute retries with new session on 403 Forbidden', async () => {
const { clearBrowserSession, saveBrowserSession } =
await import('../../utils/browser-session');
Expand Down
3 changes: 2 additions & 1 deletion src/__tests__/commands/crawl.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ describe('executeCrawl', () => {
expect(mockClient.startCrawl).toHaveBeenCalledTimes(1);
expect(mockClient.startCrawl).toHaveBeenCalledWith(
'https://example.com',
{}
{ origin: 'cli' }
);
expect(result).toEqual({
success: true,
Expand Down Expand Up @@ -233,6 +233,7 @@ describe('executeCrawl', () => {
expect(mockClient.startCrawl).toHaveBeenCalledWith(
'https://example.com',
{
origin: 'cli',
limit: 50,
maxDiscoveryDepth: 2,
excludePaths: ['/admin'],
Expand Down
5 changes: 4 additions & 1 deletion src/__tests__/commands/map.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ describe('executeMap', () => {
});

expect(mockClient.map).toHaveBeenCalledTimes(1);
expect(mockClient.map).toHaveBeenCalledWith('https://example.com', {});
expect(mockClient.map).toHaveBeenCalledWith('https://example.com', {
origin: 'cli',
});
});

it('should pass apiUrl to getClient when provided', async () => {
Expand Down Expand Up @@ -229,6 +231,7 @@ describe('executeMap', () => {
});

expect(mockClient.map).toHaveBeenCalledWith('https://example.com', {
origin: 'cli',
limit: 100,
search: 'blog',
sitemap: 'include',
Expand Down
16 changes: 16 additions & 0 deletions src/__tests__/commands/scrape.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ describe('executeScrape', () => {
expect(mockClient.scrape).toHaveBeenCalledTimes(1);
expect(mockClient.scrape).toHaveBeenCalledWith('https://example.com', {
formats: ['markdown'],
origin: 'cli',
});
});

Expand Down Expand Up @@ -99,6 +100,7 @@ describe('executeScrape', () => {

expect(mockClient.scrape).toHaveBeenCalledWith('https://example.com', {
formats: ['html'],
origin: 'cli',
});
});

Expand All @@ -113,6 +115,7 @@ describe('executeScrape', () => {

expect(mockClient.scrape).toHaveBeenCalledWith('https://example.com', {
formats: ['summary'],
origin: 'cli',
});
});

Expand All @@ -130,6 +133,7 @@ describe('executeScrape', () => {

expect(mockClient.scrape).toHaveBeenCalledWith('https://example.com', {
formats: ['screenshot'],
origin: 'cli',
});
});

Expand All @@ -148,6 +152,7 @@ describe('executeScrape', () => {

expect(mockClient.scrape).toHaveBeenCalledWith('https://example.com', {
formats: ['markdown', 'screenshot'],
origin: 'cli',
});
});

Expand All @@ -162,6 +167,7 @@ describe('executeScrape', () => {

expect(mockClient.scrape).toHaveBeenCalledWith('https://example.com', {
formats: ['markdown'],
origin: 'cli',
onlyMainContent: true,
});
});
Expand All @@ -177,6 +183,7 @@ describe('executeScrape', () => {

expect(mockClient.scrape).toHaveBeenCalledWith('https://example.com', {
formats: ['markdown'],
origin: 'cli',
waitFor: 2000,
});
});
Expand All @@ -192,6 +199,7 @@ describe('executeScrape', () => {

expect(mockClient.scrape).toHaveBeenCalledWith('https://example.com', {
formats: ['markdown'],
origin: 'cli',
includeTags: ['article', 'main'],
});
});
Expand All @@ -207,6 +215,7 @@ describe('executeScrape', () => {

expect(mockClient.scrape).toHaveBeenCalledWith('https://example.com', {
formats: ['markdown'],
origin: 'cli',
excludeTags: ['nav', 'footer'],
});
});
Expand All @@ -227,6 +236,7 @@ describe('executeScrape', () => {

expect(mockClient.scrape).toHaveBeenCalledWith('https://example.com', {
formats: ['markdown', 'screenshot'],
origin: 'cli',
onlyMainContent: true,
waitFor: 3000,
includeTags: ['article'],
Expand All @@ -245,6 +255,7 @@ describe('executeScrape', () => {

expect(mockClient.scrape).toHaveBeenCalledWith('https://example.com', {
formats: ['markdown'],
origin: 'cli',
maxAge: 3600,
});
});
Expand All @@ -260,6 +271,7 @@ describe('executeScrape', () => {

expect(mockClient.scrape).toHaveBeenCalledWith('https://example.com', {
formats: ['markdown'],
origin: 'cli',
location: { country: 'US', languages: ['en'] },
});
});
Expand All @@ -275,6 +287,7 @@ describe('executeScrape', () => {

expect(mockClient.scrape).toHaveBeenCalledWith('https://example.com', {
formats: ['markdown'],
origin: 'cli',
location: { country: 'DE' },
});
});
Expand All @@ -290,6 +303,7 @@ describe('executeScrape', () => {

expect(mockClient.scrape).toHaveBeenCalledWith('https://example.com', {
formats: ['markdown'],
origin: 'cli',
location: { languages: ['en', 'es'] },
});
});
Expand All @@ -304,6 +318,7 @@ describe('executeScrape', () => {

expect(mockClient.scrape).toHaveBeenCalledWith('https://example.com', {
formats: ['markdown'],
origin: 'cli',
});
});
});
Expand Down Expand Up @@ -406,6 +421,7 @@ describe('executeScrape', () => {
expect(result.success).toBe(true);
expect(mockClient.scrape).toHaveBeenCalledWith('https://example.com', {
formats: ['markdown', 'links', 'images'],
origin: 'cli',
});
});
});
Expand Down
2 changes: 2 additions & 0 deletions src/__tests__/commands/search.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ describe('executeSearch', () => {
expect(mockClient.search).toHaveBeenCalledTimes(1);
expect(mockClient.search).toHaveBeenCalledWith('test query', {
limit: undefined,
origin: 'cli',
});
});

Expand Down Expand Up @@ -351,6 +352,7 @@ describe('executeSearch', () => {

expect(mockClient.search).toHaveBeenCalledWith('comprehensive test', {
limit: 20,
origin: 'cli',
sources: [{ type: 'web' }, { type: 'news' }],
categories: [{ type: 'github' }],
tbs: 'qdr:w',
Expand Down
2 changes: 2 additions & 0 deletions src/commands/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,10 @@ export async function executeAgent(
maxCredits?: number;
pollInterval?: number;
timeout?: number;
origin?: string;
} = {
prompt,
origin: 'cli',
};

if (options.urls && options.urls.length > 0) {
Expand Down
6 changes: 4 additions & 2 deletions src/commands/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ export async function handleBrowserLaunch(
name: string;
saveChanges?: boolean;
};
} = {};
origin?: string;
} = { origin: 'cli' };
if (options.ttl !== undefined) args.ttl = options.ttl;
if (options.ttlInactivity !== undefined)
args.activityTtl = options.ttlInactivity;
Expand Down Expand Up @@ -290,7 +291,8 @@ export async function handleBrowserQuickExecute(
name: string;
saveChanges?: boolean;
};
} = {};
origin?: string;
} = { origin: 'cli' };
if (options.profile) {
launchArgs.profile = {
name: options.profile,
Expand Down
4 changes: 3 additions & 1 deletion src/commands/crawl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ export async function executeCrawl(
}

// Build crawl options
const crawlOptions: any = {};
const crawlOptions: any = {
origin: 'cli',
};

if (options.limit !== undefined) {
crawlOptions.limit = options.limit;
Expand Down
4 changes: 3 additions & 1 deletion src/commands/map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ export async function executeMap(options: MapOptions): Promise<MapResult> {
const { urlOrJobId } = options;

// Build map options
const mapOptions: any = {};
const mapOptions: any = {
origin: 'cli',
};

if (options.limit !== undefined) {
mapOptions.limit = options.limit;
Expand Down
11 changes: 2 additions & 9 deletions src/commands/scrape.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,9 @@ export async function executeScrape(
formats.push('markdown');
}

const scrapeParams: {
formats?: FormatOption[];
onlyMainContent?: boolean;
waitFor?: number;
includeTags?: string[];
excludeTags?: string[];
maxAge?: number;
location?: ScrapeLocation;
} = {
const scrapeParams: Record<string, unknown> = {
formats,
origin: 'cli',
};

if (options.onlyMainContent !== undefined) {
Expand Down
1 change: 1 addition & 0 deletions src/commands/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export async function executeSearch(
// Build search options for the SDK
const searchParams: Record<string, any> = {
limit: options.limit,
origin: 'cli',
};

// Add sources if specified
Expand Down