@narumitw/pi-firecrawl 0.50.3 โ 0.50.5
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 +26 -53
- package/dist/index.ts +38 -139
- package/dist/index.ts.map +2 -2
- package/package.json +50 -51
- package/src/client.ts +57 -63
- package/src/firecrawl.ts +211 -235
- package/src/lazy-tools.ts +211 -229
- package/src/response-format.ts +134 -150
- package/src/settings.ts +127 -130
- package/src/tool-names.ts +5 -5
- package/src/tool-selector.ts +267 -280
- package/src/tools.ts +120 -179
package/README.md
CHANGED
|
@@ -105,6 +105,7 @@ On reload, resume, or fork, capabilities recorded by `firecrawl_load` on the act
|
|
|
105
105
|
Pi uses native deferred tool references on compatible Anthropic models, native additional-tools or tool-search loading on compatible OpenAI and Codex Responses models, and native Kimi loading on compatible OpenAI Chat Completions models.
|
|
106
106
|
Kimi-compatible models declare `compat.deferredToolsMode: "kimi"` in Pi's model metadata.
|
|
107
107
|
`azure-openai-responses` remains eager because Pi's Azure adapter does not implement native deferred tool-search serialization.
|
|
108
|
+
Fireworks Messages models also remain eager because their native protocol requires the canonical `ToolSearch` or `tool_search` loader name, while this independently installable package keeps the collision-safe `firecrawl_load` name.
|
|
108
109
|
When the selected model/provider lacks native deferred support, the extension activates every capability allowed by settings before the next model request instead of using Pi's cache-invalidating lazy-loading fallback.
|
|
109
110
|
After a session enters eager exposure, it stays eager across later model switches to avoid removing tool definitions within that session.
|
|
110
111
|
The capability tools omit active-only prompt metadata so native deferred loading does not rebuild the system-prompt prefix.
|
|
@@ -122,41 +123,20 @@ Oversized Firecrawl error bodies are bounded in the same way.
|
|
|
122
123
|
|
|
123
124
|
## ๐ฌ Commands
|
|
124
125
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
/firecrawl toggle
|
|
140
|
-
/firecrawl enable
|
|
141
|
-
/firecrawl disable
|
|
142
|
-
```
|
|
143
|
-
|
|
144
|
-
- `help` shows command usage.
|
|
145
|
-
- `config` shows API-key presence and API URL without displaying the API key value.
|
|
146
|
-
- `quickstart` is an alias for `config`.
|
|
147
|
-
- `status` shows available and loaded capability counts, loader state, the persisted catalog, settings file path, API-key presence, API URL, and active non-Firecrawl tool count.
|
|
148
|
-
- `tools` opens a width-safe immediate-save selector for choosing available capabilities.
|
|
149
|
-
- `toggle` is an alias for `tools`.
|
|
150
|
-
- `enable` makes all five API capabilities available and follows the current native-deferred or eager exposure mode.
|
|
151
|
-
- `disable` makes all five API capabilities unavailable and unloads affected active definitions.
|
|
152
|
-
The slash command and `firecrawl_load` remain available.
|
|
153
|
-
|
|
154
|
-
The menu, `tools`, `help`, `config`, `quickstart`, and `status` routes require TUI or RPC mode.
|
|
155
|
-
Print and JSON modes reject those routes and unknown commands before entering interactive UI.
|
|
156
|
-
The deterministic `enable` and `disable` routes remain available in every mode.
|
|
157
|
-
|
|
158
|
-
Tool-selector toggles save immediately in user action order.
|
|
159
|
-
Done, Escape, or cancellation closes the selector without undoing changes that were already saved.
|
|
126
|
+
| Command | Purpose |
|
|
127
|
+
| --- | --- |
|
|
128
|
+
| `/firecrawl` | Manage available Firecrawl tools and inspect configuration. |
|
|
129
|
+
| `/firecrawl help` | Show command usage. |
|
|
130
|
+
| `/firecrawl config` (alias: `quickstart`) | Show API-key presence and API URL without revealing the key. |
|
|
131
|
+
| `/firecrawl status` | Show available and loaded tools, loader state, saved catalog, and configuration status. |
|
|
132
|
+
| `/firecrawl tools` (aliases: `toggle`, `select`) | Choose available capabilities; each toggle saves immediately. |
|
|
133
|
+
| `/firecrawl enable` (alias: `on`) | Make all five API capabilities available and save the selection. |
|
|
134
|
+
| `/firecrawl disable` (alias: `off`) | Make all API capabilities unavailable and save the empty selection. |
|
|
135
|
+
|
|
136
|
+
All routes support TUI and RPC and reject unknown or trailing arguments.
|
|
137
|
+
Only `enable` and `disable` also support print and JSON modes.
|
|
138
|
+
Disabling capabilities leaves the slash command and `firecrawl_load` available; see [Tool exposure](#tool-exposure) for native-deferred and eager behavior.
|
|
139
|
+
Done, Escape, or cancellation closes the tool selector **without undoing saved changes**.
|
|
160
140
|
|
|
161
141
|
## ๐ Security and privacy
|
|
162
142
|
|
|
@@ -168,7 +148,7 @@ Truncated response artifacts use private temporary files, remain available only
|
|
|
168
148
|
|
|
169
149
|
## ๐งช Examples
|
|
170
150
|
|
|
171
|
-
|
|
151
|
+
Call `firecrawl_scrape` to scrape a page as Markdown:
|
|
172
152
|
|
|
173
153
|
```json
|
|
174
154
|
{
|
|
@@ -177,7 +157,7 @@ Scrape a page as markdown:
|
|
|
177
157
|
}
|
|
178
158
|
```
|
|
179
159
|
|
|
180
|
-
|
|
160
|
+
Call `firecrawl_map` to discover URLs on a small site:
|
|
181
161
|
|
|
182
162
|
```json
|
|
183
163
|
{
|
|
@@ -186,7 +166,7 @@ Map a small site:
|
|
|
186
166
|
}
|
|
187
167
|
```
|
|
188
168
|
|
|
189
|
-
|
|
169
|
+
Call `firecrawl_crawl` to start a crawl with Markdown extraction:
|
|
190
170
|
|
|
191
171
|
```json
|
|
192
172
|
{
|
|
@@ -208,24 +188,17 @@ Start a crawl with markdown extraction:
|
|
|
208
188
|
|
|
209
189
|
## ๐๏ธ Package layout
|
|
210
190
|
|
|
211
|
-
```
|
|
191
|
+
```text
|
|
212
192
|
packages/pi-firecrawl/
|
|
213
|
-
โโโ
|
|
214
|
-
โโโ
|
|
215
|
-
โ โโโ
|
|
216
|
-
โโโ
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
โ โโโ lazy-tools.ts # Deferred capability catalog and loader tool
|
|
220
|
-
โ โโโ *.ts # Package-local client, settings, selector, and tool modules
|
|
221
|
-
โโโ README.md
|
|
222
|
-
โโโ LICENSE
|
|
223
|
-
โโโ tsconfig.json
|
|
224
|
-
โโโ package.json
|
|
193
|
+
โโโ src/ # Authoritative implementation and helpers
|
|
194
|
+
โ โโโ index.ts # Thin Pi entrypoint
|
|
195
|
+
โ โโโ firecrawl.ts # Web tools and command orchestration
|
|
196
|
+
โโโ dist/ # Generated Jiti runtime
|
|
197
|
+
โโโ scripts/build-runtime.mjs # Runtime builder
|
|
198
|
+
โโโ test/ # Behavior and lifecycle coverage
|
|
225
199
|
```
|
|
226
200
|
|
|
227
|
-
|
|
228
|
-
The generated runtime is built from the authoritative `src/index.ts` graph and does not import back into `src`.
|
|
201
|
+
The generated runtime is built from `src/index.ts` and does not import back into `src`.
|
|
229
202
|
|
|
230
203
|
## ๐ Keywords
|
|
231
204
|
|
package/dist/index.ts
CHANGED
|
@@ -6,12 +6,7 @@ import { randomUUID } from "node:crypto";
|
|
|
6
6
|
import { chmod, mkdtemp, rm, writeFile } from "node:fs/promises";
|
|
7
7
|
import { tmpdir } from "node:os";
|
|
8
8
|
import { join } from "node:path";
|
|
9
|
-
import {
|
|
10
|
-
DEFAULT_MAX_BYTES,
|
|
11
|
-
DEFAULT_MAX_LINES,
|
|
12
|
-
formatSize,
|
|
13
|
-
truncateHead
|
|
14
|
-
} from "@earendil-works/pi-coding-agent";
|
|
9
|
+
import { DEFAULT_MAX_BYTES, DEFAULT_MAX_LINES, formatSize, truncateHead } from "@earendil-works/pi-coding-agent";
|
|
15
10
|
var responseArtifactStores = /* @__PURE__ */ new WeakMap();
|
|
16
11
|
var closedArtifactOwners = /* @__PURE__ */ new WeakSet();
|
|
17
12
|
async function formatJsonResult(payload, artifactOwner) {
|
|
@@ -68,14 +63,8 @@ async function boundResponseText(text, artifactOwner, options = {}) {
|
|
|
68
63
|
}
|
|
69
64
|
};
|
|
70
65
|
}
|
|
71
|
-
const nextByteBudget = Math.max(
|
|
72
|
-
|
|
73
|
-
Math.min(excerptByteBudget, maxBytes - Buffer.byteLength(footer, "utf8") - 2)
|
|
74
|
-
);
|
|
75
|
-
const nextLineBudget = Math.max(
|
|
76
|
-
0,
|
|
77
|
-
Math.min(excerptLineBudget, maxLines - countLines(footer) - 1)
|
|
78
|
-
);
|
|
66
|
+
const nextByteBudget = Math.max(0, Math.min(excerptByteBudget, maxBytes - Buffer.byteLength(footer, "utf8") - 2));
|
|
67
|
+
const nextLineBudget = Math.max(0, Math.min(excerptLineBudget, maxLines - countLines(footer) - 1));
|
|
79
68
|
if (nextByteBudget === excerptByteBudget && nextLineBudget === excerptLineBudget) {
|
|
80
69
|
throw new Error("Firecrawl could not fit its truncation notice within Pi's output limits");
|
|
81
70
|
}
|
|
@@ -109,9 +98,7 @@ function writeResponseArtifact(text, extension, artifactOwner) {
|
|
|
109
98
|
}
|
|
110
99
|
function responseArtifactStore(artifactOwner) {
|
|
111
100
|
if (closedArtifactOwners.has(artifactOwner)) {
|
|
112
|
-
throw new Error(
|
|
113
|
-
"Firecrawl response arrived after session shutdown; full response was discarded"
|
|
114
|
-
);
|
|
101
|
+
throw new Error("Firecrawl response arrived after session shutdown; full response was discarded");
|
|
115
102
|
}
|
|
116
103
|
const existing = responseArtifactStores.get(artifactOwner);
|
|
117
104
|
if (existing) return existing;
|
|
@@ -179,9 +166,7 @@ async function firecrawlRequest(method, path, body, signal, artifactOwner) {
|
|
|
179
166
|
function getApiKey() {
|
|
180
167
|
const apiKey = process.env.FIRECRAWL_API_KEY?.trim();
|
|
181
168
|
if (!apiKey) {
|
|
182
|
-
throw new Error(
|
|
183
|
-
"FIRECRAWL_API_KEY is not configured. Set it in your shell or Pi environment, then retry once."
|
|
184
|
-
);
|
|
169
|
+
throw new Error("FIRECRAWL_API_KEY is not configured. Set it in your shell or Pi environment, then retry once.");
|
|
185
170
|
}
|
|
186
171
|
return apiKey;
|
|
187
172
|
}
|
|
@@ -222,9 +207,7 @@ function cleanObject(value) {
|
|
|
222
207
|
}
|
|
223
208
|
|
|
224
209
|
// src/lazy-tools.ts
|
|
225
|
-
import {
|
|
226
|
-
defineTool
|
|
227
|
-
} from "@earendil-works/pi-coding-agent";
|
|
210
|
+
import { defineTool } from "@earendil-works/pi-coding-agent";
|
|
228
211
|
import { Type } from "typebox";
|
|
229
212
|
|
|
230
213
|
// src/tool-names.ts
|
|
@@ -239,9 +222,7 @@ var FIRECRAWL_TOOL_NAMES = [
|
|
|
239
222
|
// src/lazy-tools.ts
|
|
240
223
|
var FIRECRAWL_LOAD_TOOL_NAME = "firecrawl_load";
|
|
241
224
|
var AVAILABLE_TOOLS_STORE = /* @__PURE__ */ Symbol.for("@narumitw/pi-firecrawl.available-tools-store");
|
|
242
|
-
var SESSION_AVAILABLE_TOOLS_STORE = /* @__PURE__ */ Symbol.for(
|
|
243
|
-
"@narumitw/pi-firecrawl.session-available-tools-store"
|
|
244
|
-
);
|
|
225
|
+
var SESSION_AVAILABLE_TOOLS_STORE = /* @__PURE__ */ Symbol.for("@narumitw/pi-firecrawl.session-available-tools-store");
|
|
245
226
|
var sharedGlobal = globalThis;
|
|
246
227
|
var existingAvailableToolsStore = sharedGlobal[AVAILABLE_TOOLS_STORE];
|
|
247
228
|
var availableToolsByApi = existingAvailableToolsStore ?? /* @__PURE__ */ new WeakMap();
|
|
@@ -310,6 +291,7 @@ function firecrawlToolExposureMode(pi) {
|
|
|
310
291
|
function supportsNativeDeferredToolLoading(model) {
|
|
311
292
|
if (!model) return false;
|
|
312
293
|
if (model.api === "anthropic-messages") {
|
|
294
|
+
if (model.provider === "fireworks") return false;
|
|
313
295
|
const configured = compatBoolean(model.compat, "supportsToolReferences");
|
|
314
296
|
if (configured !== void 0) return configured;
|
|
315
297
|
if (model.provider !== "anthropic" || model.id.includes("haiku")) return false;
|
|
@@ -380,10 +362,7 @@ function matchFirecrawlTools(query, limit, available) {
|
|
|
380
362
|
const ranked = FIRECRAWL_TOOL_NAMES.filter((name) => available.has(name)).map((name, index) => ({
|
|
381
363
|
name,
|
|
382
364
|
index,
|
|
383
|
-
score: terms.reduce(
|
|
384
|
-
(score, term) => score + (SEARCH_TEXT[name].split(" ").includes(term) ? 1 : 0),
|
|
385
|
-
0
|
|
386
|
-
)
|
|
365
|
+
score: terms.reduce((score, term) => score + (SEARCH_TEXT[name].split(" ").includes(term) ? 1 : 0), 0)
|
|
387
366
|
})).filter((match) => match.score > 0).sort((left, right) => right.score - left.score || left.index - right.index);
|
|
388
367
|
const bestScore = ranked[0]?.score;
|
|
389
368
|
if (bestScore === void 0) return [];
|
|
@@ -569,11 +548,8 @@ async function saveSettingsNow(settings, operations) {
|
|
|
569
548
|
await mkdir(dirname(filePath), { recursive: true });
|
|
570
549
|
const tempFile = `${filePath}.${process.pid}.${randomUUID2()}.tmp`;
|
|
571
550
|
try {
|
|
572
|
-
await (operations.write ?? DEFAULT_FILE_OPERATIONS.write)(
|
|
573
|
-
|
|
574
|
-
`${JSON.stringify(nextDocument, null, 2)}
|
|
575
|
-
`
|
|
576
|
-
);
|
|
551
|
+
await (operations.write ?? DEFAULT_FILE_OPERATIONS.write)(tempFile, `${JSON.stringify(nextDocument, null, 2)}
|
|
552
|
+
`);
|
|
577
553
|
if (!replaceCanonical && await pathEntryExists(filePath)) {
|
|
578
554
|
throw new Error(`${NEW_SETTINGS_FILE} was created concurrently; reopen settings and retry.`);
|
|
579
555
|
}
|
|
@@ -683,13 +659,7 @@ async function showToolSelector(pi, ctx) {
|
|
|
683
659
|
},
|
|
684
660
|
enableAll: async () => {
|
|
685
661
|
const acceptedTools = availableFirecrawlTools(pi);
|
|
686
|
-
const result2 = await transactSelectedTools(
|
|
687
|
-
pi,
|
|
688
|
-
ctx,
|
|
689
|
-
allFirecrawlTools(),
|
|
690
|
-
generation,
|
|
691
|
-
acceptedTools
|
|
692
|
-
);
|
|
662
|
+
const result2 = await transactSelectedTools(pi, ctx, allFirecrawlTools(), generation, acceptedTools);
|
|
693
663
|
return result2 === "saved" ? { kind: "stay" } : { kind: "rejected" };
|
|
694
664
|
},
|
|
695
665
|
disableAll: async () => {
|
|
@@ -783,9 +753,7 @@ function applyFirecrawlTools(pi, selectedTools, sessionOwner) {
|
|
|
783
753
|
function getToolStatusSummary(pi) {
|
|
784
754
|
const firecrawlToolNames = new Set(FIRECRAWL_TOOL_NAMES);
|
|
785
755
|
const activeToolNames = new Set(pi.getActiveTools());
|
|
786
|
-
const loadedFirecrawlToolCount = FIRECRAWL_TOOL_NAMES.filter(
|
|
787
|
-
(name) => activeToolNames.has(name)
|
|
788
|
-
).length;
|
|
756
|
+
const loadedFirecrawlToolCount = FIRECRAWL_TOOL_NAMES.filter((name) => activeToolNames.has(name)).length;
|
|
789
757
|
const availableFirecrawlToolCount = availableFirecrawlTools(pi).length;
|
|
790
758
|
const activeNonFirecrawlToolCount = Array.from(activeToolNames).filter(
|
|
791
759
|
(name) => !firecrawlToolNames.has(name) && name !== FIRECRAWL_LOAD_TOOL_NAME
|
|
@@ -896,12 +864,7 @@ async function persistSettings(selectedTools) {
|
|
|
896
864
|
}
|
|
897
865
|
|
|
898
866
|
// src/tools.ts
|
|
899
|
-
import {
|
|
900
|
-
DEFAULT_MAX_BYTES as DEFAULT_MAX_BYTES2,
|
|
901
|
-
DEFAULT_MAX_LINES as DEFAULT_MAX_LINES2,
|
|
902
|
-
defineTool as defineTool2,
|
|
903
|
-
formatSize as formatSize2
|
|
904
|
-
} from "@earendil-works/pi-coding-agent";
|
|
867
|
+
import { DEFAULT_MAX_BYTES as DEFAULT_MAX_BYTES2, DEFAULT_MAX_LINES as DEFAULT_MAX_LINES2, defineTool as defineTool2, formatSize as formatSize2 } from "@earendil-works/pi-coding-agent";
|
|
905
868
|
import { Type as Type2 } from "typebox";
|
|
906
869
|
var StringArray = Type2.Array(Type2.String());
|
|
907
870
|
var OUTPUT_LIMIT_DESCRIPTION = `Output is truncated to ${DEFAULT_MAX_LINES2} lines or ${formatSize2(DEFAULT_MAX_BYTES2)}; complete truncated responses are saved temporarily and their path is returned.`;
|
|
@@ -919,15 +882,11 @@ var scrapeTool = defineTool2({
|
|
|
919
882
|
{ description: "Firecrawl output formats. Defaults to Firecrawl's API default." }
|
|
920
883
|
)
|
|
921
884
|
),
|
|
922
|
-
onlyMainContent: Type2.Optional(
|
|
923
|
-
Type2.Boolean({ description: "Return only the main page content when supported." })
|
|
924
|
-
),
|
|
885
|
+
onlyMainContent: Type2.Optional(Type2.Boolean({ description: "Return only the main page content when supported." })),
|
|
925
886
|
includeTags: Type2.Optional(StringArray),
|
|
926
887
|
excludeTags: Type2.Optional(StringArray),
|
|
927
888
|
waitFor: Type2.Optional(Type2.Number({ description: "Milliseconds to wait before scraping." })),
|
|
928
|
-
timeout: Type2.Optional(
|
|
929
|
-
Type2.Number({ description: "Firecrawl request timeout in milliseconds." })
|
|
930
|
-
),
|
|
889
|
+
timeout: Type2.Optional(Type2.Number({ description: "Firecrawl request timeout in milliseconds." })),
|
|
931
890
|
mobile: Type2.Optional(Type2.Boolean({ description: "Use a mobile user agent when supported." })),
|
|
932
891
|
skipTlsVerification: Type2.Optional(
|
|
933
892
|
Type2.Boolean({ description: "Skip TLS certificate verification when supported." })
|
|
@@ -935,17 +894,13 @@ var scrapeTool = defineTool2({
|
|
|
935
894
|
removeBase64Images: Type2.Optional(
|
|
936
895
|
Type2.Boolean({ description: "Remove base64 image data from the response when supported." })
|
|
937
896
|
),
|
|
938
|
-
blockAds: Type2.Optional(
|
|
939
|
-
Type2.Boolean({ description: "Block ads while scraping when supported." })
|
|
940
|
-
),
|
|
897
|
+
blockAds: Type2.Optional(Type2.Boolean({ description: "Block ads while scraping when supported." })),
|
|
941
898
|
headers: Type2.Optional(
|
|
942
899
|
Type2.Record(Type2.String(), Type2.String(), {
|
|
943
900
|
description: "Additional HTTP headers Firecrawl should use while fetching the target URL."
|
|
944
901
|
})
|
|
945
902
|
),
|
|
946
|
-
jsonOptions: Type2.Optional(
|
|
947
|
-
Type2.Any({ description: "Firecrawl jsonOptions for structured extraction." })
|
|
948
|
-
),
|
|
903
|
+
jsonOptions: Type2.Optional(Type2.Any({ description: "Firecrawl jsonOptions for structured extraction." })),
|
|
949
904
|
actions: Type2.Optional(
|
|
950
905
|
Type2.Array(Type2.Any(), {
|
|
951
906
|
description: "Firecrawl browser actions to perform before scraping."
|
|
@@ -955,13 +910,7 @@ var scrapeTool = defineTool2({
|
|
|
955
910
|
}),
|
|
956
911
|
async execute(_toolCallId, params, signal, _onUpdate, ctx) {
|
|
957
912
|
return withStatus(ctx, "scrape", async () => {
|
|
958
|
-
const payload = await firecrawlRequest(
|
|
959
|
-
"POST",
|
|
960
|
-
"/scrape",
|
|
961
|
-
cleanObject(params),
|
|
962
|
-
signal,
|
|
963
|
-
ctx.sessionManager
|
|
964
|
-
);
|
|
913
|
+
const payload = await firecrawlRequest("POST", "/scrape", cleanObject(params), signal, ctx.sessionManager);
|
|
965
914
|
return await jsonResult(payload, ctx.sessionManager);
|
|
966
915
|
});
|
|
967
916
|
}
|
|
@@ -974,36 +923,18 @@ var crawlTool = defineTool2({
|
|
|
974
923
|
url: Type2.String({ description: "Starting URL for the crawl." }),
|
|
975
924
|
limit: Type2.Optional(Type2.Number({ description: "Maximum number of pages to crawl." })),
|
|
976
925
|
maxDepth: Type2.Optional(Type2.Number({ description: "Maximum crawl depth when supported." })),
|
|
977
|
-
includePaths: Type2.Optional(
|
|
978
|
-
|
|
979
|
-
),
|
|
980
|
-
|
|
981
|
-
Type2.Array(Type2.String(), { description: "URL path patterns to exclude." })
|
|
982
|
-
),
|
|
983
|
-
allowBackwardLinks: Type2.Optional(
|
|
984
|
-
Type2.Boolean({ description: "Allow crawling backward links when supported." })
|
|
985
|
-
),
|
|
986
|
-
allowExternalLinks: Type2.Optional(
|
|
987
|
-
Type2.Boolean({ description: "Allow crawling external links when supported." })
|
|
988
|
-
),
|
|
926
|
+
includePaths: Type2.Optional(Type2.Array(Type2.String(), { description: "URL path patterns to include." })),
|
|
927
|
+
excludePaths: Type2.Optional(Type2.Array(Type2.String(), { description: "URL path patterns to exclude." })),
|
|
928
|
+
allowBackwardLinks: Type2.Optional(Type2.Boolean({ description: "Allow crawling backward links when supported." })),
|
|
929
|
+
allowExternalLinks: Type2.Optional(Type2.Boolean({ description: "Allow crawling external links when supported." })),
|
|
989
930
|
ignoreSitemap: Type2.Optional(Type2.Boolean({ description: "Ignore sitemap discovery." })),
|
|
990
|
-
deduplicateSimilarURLs: Type2.Optional(
|
|
991
|
-
|
|
992
|
-
),
|
|
993
|
-
scrapeOptions: Type2.Optional(
|
|
994
|
-
Type2.Any({ description: "Firecrawl scrapeOptions applied to crawled pages." })
|
|
995
|
-
),
|
|
931
|
+
deduplicateSimilarURLs: Type2.Optional(Type2.Boolean({ description: "Deduplicate similar URLs when supported." })),
|
|
932
|
+
scrapeOptions: Type2.Optional(Type2.Any({ description: "Firecrawl scrapeOptions applied to crawled pages." })),
|
|
996
933
|
webhook: Type2.Optional(Type2.Any({ description: "Firecrawl webhook configuration." }))
|
|
997
934
|
}),
|
|
998
935
|
async execute(_toolCallId, params, signal, _onUpdate, ctx) {
|
|
999
936
|
return withStatus(ctx, "crawl", async () => {
|
|
1000
|
-
const payload = await firecrawlRequest(
|
|
1001
|
-
"POST",
|
|
1002
|
-
"/crawl",
|
|
1003
|
-
cleanObject(params),
|
|
1004
|
-
signal,
|
|
1005
|
-
ctx.sessionManager
|
|
1006
|
-
);
|
|
937
|
+
const payload = await firecrawlRequest("POST", "/crawl", cleanObject(params), signal, ctx.sessionManager);
|
|
1007
938
|
return await jsonResult(payload, ctx.sessionManager);
|
|
1008
939
|
});
|
|
1009
940
|
}
|
|
@@ -1034,27 +965,15 @@ var mapTool = defineTool2({
|
|
|
1034
965
|
description: `Discover URLs for a site through Firecrawl's map endpoint. ${OUTPUT_LIMIT_DESCRIPTION}`,
|
|
1035
966
|
parameters: Type2.Object({
|
|
1036
967
|
url: Type2.String({ description: "Website URL to map." }),
|
|
1037
|
-
search: Type2.Optional(
|
|
1038
|
-
Type2.String({ description: "Optional search term to filter discovered URLs." })
|
|
1039
|
-
),
|
|
968
|
+
search: Type2.Optional(Type2.String({ description: "Optional search term to filter discovered URLs." })),
|
|
1040
969
|
ignoreSitemap: Type2.Optional(Type2.Boolean({ description: "Ignore sitemap discovery." })),
|
|
1041
|
-
sitemapOnly: Type2.Optional(
|
|
1042
|
-
|
|
1043
|
-
),
|
|
1044
|
-
includeSubdomains: Type2.Optional(
|
|
1045
|
-
Type2.Boolean({ description: "Include subdomains when supported." })
|
|
1046
|
-
),
|
|
970
|
+
sitemapOnly: Type2.Optional(Type2.Boolean({ description: "Only use sitemap URLs when supported." })),
|
|
971
|
+
includeSubdomains: Type2.Optional(Type2.Boolean({ description: "Include subdomains when supported." })),
|
|
1047
972
|
limit: Type2.Optional(Type2.Number({ description: "Maximum number of URLs to return." }))
|
|
1048
973
|
}),
|
|
1049
974
|
async execute(_toolCallId, params, signal, _onUpdate, ctx) {
|
|
1050
975
|
return withStatus(ctx, "map", async () => {
|
|
1051
|
-
const payload = await firecrawlRequest(
|
|
1052
|
-
"POST",
|
|
1053
|
-
"/map",
|
|
1054
|
-
cleanObject(params),
|
|
1055
|
-
signal,
|
|
1056
|
-
ctx.sessionManager
|
|
1057
|
-
);
|
|
976
|
+
const payload = await firecrawlRequest("POST", "/map", cleanObject(params), signal, ctx.sessionManager);
|
|
1058
977
|
return await jsonResult(payload, ctx.sessionManager);
|
|
1059
978
|
});
|
|
1060
979
|
}
|
|
@@ -1066,23 +985,13 @@ var searchTool = defineTool2({
|
|
|
1066
985
|
parameters: Type2.Object({
|
|
1067
986
|
query: Type2.String({ description: "Search query." }),
|
|
1068
987
|
limit: Type2.Optional(Type2.Number({ description: "Maximum number of search results." })),
|
|
1069
|
-
tbs: Type2.Optional(
|
|
1070
|
-
Type2.String({ description: "Google-style time based search filter when supported." })
|
|
1071
|
-
),
|
|
988
|
+
tbs: Type2.Optional(Type2.String({ description: "Google-style time based search filter when supported." })),
|
|
1072
989
|
location: Type2.Optional(Type2.String({ description: "Search location when supported." })),
|
|
1073
|
-
scrapeOptions: Type2.Optional(
|
|
1074
|
-
Type2.Any({ description: "Firecrawl scrapeOptions for search result pages." })
|
|
1075
|
-
)
|
|
990
|
+
scrapeOptions: Type2.Optional(Type2.Any({ description: "Firecrawl scrapeOptions for search result pages." }))
|
|
1076
991
|
}),
|
|
1077
992
|
async execute(_toolCallId, params, signal, _onUpdate, ctx) {
|
|
1078
993
|
return withStatus(ctx, "search", async () => {
|
|
1079
|
-
const payload = await firecrawlRequest(
|
|
1080
|
-
"POST",
|
|
1081
|
-
"/search",
|
|
1082
|
-
cleanObject(params),
|
|
1083
|
-
signal,
|
|
1084
|
-
ctx.sessionManager
|
|
1085
|
-
);
|
|
994
|
+
const payload = await firecrawlRequest("POST", "/search", cleanObject(params), signal, ctx.sessionManager);
|
|
1086
995
|
return await jsonResult(payload, ctx.sessionManager);
|
|
1087
996
|
});
|
|
1088
997
|
}
|
|
@@ -1135,16 +1044,10 @@ function firecrawl(pi) {
|
|
|
1135
1044
|
recordSettingsNotice(settings);
|
|
1136
1045
|
if (settings.notice) ctx.ui.notify(sanitizeFirecrawlDisplay(settings.notice), "warning");
|
|
1137
1046
|
const availableTools = settings.kind === "loaded" ? settings.settings.tools : availableFirecrawlTools(pi);
|
|
1138
|
-
const loadedTools = loadedFirecrawlToolsFromBranch(
|
|
1139
|
-
ctx.sessionManager.getBranch(),
|
|
1140
|
-
availableTools
|
|
1141
|
-
);
|
|
1047
|
+
const loadedTools = loadedFirecrawlToolsFromBranch(ctx.sessionManager.getBranch(), availableTools);
|
|
1142
1048
|
configureFirecrawlToolExposure(pi, availableTools, loadedTools, ctx.sessionManager, ctx.model);
|
|
1143
1049
|
if (settings.kind === "invalid") {
|
|
1144
|
-
ctx.ui.notify(
|
|
1145
|
-
sanitizeFirecrawlDisplay(`Firecrawl settings ignored: ${settings.reason}`),
|
|
1146
|
-
"warning"
|
|
1147
|
-
);
|
|
1050
|
+
ctx.ui.notify(sanitizeFirecrawlDisplay(`Firecrawl settings ignored: ${settings.reason}`), "warning");
|
|
1148
1051
|
}
|
|
1149
1052
|
});
|
|
1150
1053
|
pi.on("model_select", (event) => {
|
|
@@ -1197,11 +1100,9 @@ async function handleFirecrawlCommand(pi, args, ctx, generation) {
|
|
|
1197
1100
|
throw new Error(sanitizeFirecrawlDisplay(`Unknown /firecrawl command: ${args.trim()}`));
|
|
1198
1101
|
}
|
|
1199
1102
|
ctx.ui.notify(
|
|
1200
|
-
sanitizeFirecrawlDisplay(
|
|
1201
|
-
`Unknown /firecrawl command: ${args.trim()}
|
|
1103
|
+
sanitizeFirecrawlDisplay(`Unknown /firecrawl command: ${args.trim()}
|
|
1202
1104
|
|
|
1203
|
-
${buildCommandGuide()}`
|
|
1204
|
-
),
|
|
1105
|
+
${buildCommandGuide()}`),
|
|
1205
1106
|
"warning"
|
|
1206
1107
|
);
|
|
1207
1108
|
}
|
|
@@ -1292,9 +1193,7 @@ function parseCommand(args) {
|
|
|
1292
1193
|
function commandCompletions(prefix) {
|
|
1293
1194
|
const normalized = prefix.trimStart().toLowerCase();
|
|
1294
1195
|
if (/\s/.test(normalized)) return null;
|
|
1295
|
-
const matches = COMMAND_COMPLETIONS.filter(
|
|
1296
|
-
(completion) => completion.value.startsWith(normalized)
|
|
1297
|
-
);
|
|
1196
|
+
const matches = COMMAND_COMPLETIONS.filter((completion) => completion.value.startsWith(normalized));
|
|
1298
1197
|
return matches.length > 0 ? matches : null;
|
|
1299
1198
|
}
|
|
1300
1199
|
export {
|