@narumitw/pi-firecrawl 0.50.2 → 0.50.4

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 CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [![npm](https://img.shields.io/npm/v/@narumitw/pi-firecrawl)](https://www.npmjs.com/package/@narumitw/pi-firecrawl) [![Pi extension](https://img.shields.io/badge/Pi-extension-blue)](https://pi.dev) [![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](./LICENSE)
4
4
 
5
- Give Pi on-demand [Firecrawl](https://www.firecrawl.dev/) tools for web search, scraping, crawling, URL discovery, and retrieval-friendly content extraction.
5
+ Add on-demand [Firecrawl](https://www.firecrawl.dev/) tools to Pi for web search, scraping, crawling, URL discovery, and content extraction.
6
6
 
7
7
  ## ✨ Features
8
8
 
@@ -10,35 +10,40 @@ Give Pi on-demand [Firecrawl](https://www.firecrawl.dev/) tools for web search,
10
10
  - Starts crawl jobs, checks their status, and retrieves completed crawl data.
11
11
  - Discovers site URLs and searches the web with optional result-page scraping.
12
12
  - Loads only the Firecrawl capabilities needed for the task and manages availability through `/firecrawl`.
13
- - Supports custom Firecrawl endpoints and shows activity only while a tool is running.
13
+ - Supports custom Firecrawl endpoints and shows status only while a tool is running.
14
14
  - Bounds model-visible output while preserving oversized responses in private temporary files.
15
15
  - Reads the API key from the environment and never logs, displays, or stores it.
16
16
 
17
17
  ## 📦 Install
18
18
 
19
+ Install persistently:
20
+
19
21
  ```bash
20
22
  pi install npm:@narumitw/pi-firecrawl
21
23
  ```
22
24
 
23
- Try without installing permanently:
25
+ Run once from npm:
24
26
 
25
27
  ```bash
26
28
  FIRECRAWL_API_KEY=fc-... pi -e npm:@narumitw/pi-firecrawl
27
29
  ```
28
30
 
29
- Build and try this package locally from the repository root:
31
+ Build and run a local checkout from the repository root:
30
32
 
31
33
  ```bash
32
34
  npm --workspace @narumitw/pi-firecrawl run build
33
35
  FIRECRAWL_API_KEY=fc-... pi -e ./packages/pi-firecrawl
34
36
  ```
35
37
 
36
- The package declares `dist/index.ts`, so an unbuilt local checkout must run the build before Pi loads the package directory.
38
+ The package declares `dist/index.ts`, so build a local checkout before loading its package directory.
39
+
40
+ Pi extensions run with your user permissions.
41
+ Review third-party extension source before installing it.
37
42
 
38
43
  ## 🚀 Quick start
39
44
 
40
45
  Set `FIRECRAWL_API_KEY`, start Pi with the extension, and ask the agent to load the Firecrawl capability needed for the task.
41
- Use `/firecrawl` to review configuration and control which capability tools may be loaded.
46
+ Run `/firecrawl` to review configuration and choose which capabilities the loader may expose.
42
47
 
43
48
  ## ⚙️ Settings
44
49
 
@@ -55,7 +60,28 @@ export FIRECRAWL_API_URL=https://api.firecrawl.dev/v1
55
60
  ```
56
61
 
57
62
  `FIRECRAWL_BASE_URL` is also accepted for compatibility.
58
- The extension never logs or displays the API key.
63
+ The API key remains in the environment and is sent only as a bearer credential to the configured Firecrawl endpoint.
64
+
65
+ Available capability names are saved to:
66
+
67
+ ```text
68
+ ${PI_CODING_AGENT_DIR:-~/.pi/agent}/pi-firecrawl.json
69
+ ```
70
+
71
+ A missing or invalid file leaves the current Firecrawl availability policy unchanged.
72
+ An unsaved catalog remains stable across runtime reloads.
73
+ A valid catalog is restored on startup and `/reload`, with native deferred or eager exposure chosen from model and provider support.
74
+ The first successful availability change creates a missing file.
75
+ Within one Pi process, saves run in invocation order, reread the latest valid document, and preserve unknown fields.
76
+ Malformed JSON or invalid recognized fields block saves without replacing the file.
77
+ A failed save restores the previous availability and loaded capabilities while preserving other extensions' active tools.
78
+ The file stores only tool names and a timestamp, never `FIRECRAWL_API_KEY`, request headers, or other secrets.
79
+
80
+ Older versions used `pi-firecrawl-settings.json`.
81
+ A legacy-only file remains readable with a warning and is never modified automatically; rename it to `pi-firecrawl.json`.
82
+ The next settings save writes the canonical file.
83
+ If both files exist, `pi-firecrawl.json` wins and the legacy file is ignored.
84
+ The legacy filename is deprecated and will be removed in a future major release.
59
85
 
60
86
  ## 🛠️ Tools
61
87
 
@@ -68,110 +94,61 @@ The extension never logs or displays the API key.
68
94
 
69
95
  ### Tool exposure
70
96
 
71
- All six tools are registered.
72
-
73
- On a model/provider with native deferred-tool support, only `firecrawl_load` starts active for this extension.
74
-
97
+ The extension registers six tools: one loader and five API capabilities.
98
+ With native deferred-tool support, only `firecrawl_load` starts active.
75
99
  The loader accepts a task-oriented `query`, filters to capabilities allowed by settings, and adds up to three matching tools by default without removing any active Pi tool.
76
-
77
100
  Set `limit` from 1 to 5 to change the maximum number loaded by one call.
78
-
79
101
  A general website-crawl query can load both `firecrawl_crawl` and `firecrawl_crawl_status`, while a status-specific query loads the status capability.
80
-
81
- Loaded capability tools remain active for the session unless the user makes them unavailable through `/firecrawl`.
82
-
102
+ Loaded capability tools remain active for the current session until you make them unavailable through `/firecrawl`.
83
103
  On reload, resume, or fork, capabilities recorded by `firecrawl_load` on the active branch are restored when the current catalog still allows them.
84
104
 
85
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.
86
-
87
106
  Kimi-compatible models declare `compat.deferredToolsMode: "kimi"` in Pi's model metadata.
88
-
89
107
  `azure-openai-responses` remains eager because Pi's Azure adapter does not implement native deferred tool-search serialization.
90
-
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.
91
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.
92
-
93
110
  After a session enters eager exposure, it stays eager across later model switches to avoid removing tool definitions within that session.
94
-
95
111
  The capability tools omit active-only prompt metadata so native deferred loading does not rebuild the system-prompt prefix.
96
112
 
97
113
  The saved `tools` array controls which capabilities the extension may expose.
98
-
99
114
  An empty array leaves the loader active but makes every Firecrawl API capability unavailable.
100
115
 
101
116
  `firecrawl_load` performs no network request and does not create response artifacts.
102
-
103
117
  Every API capability fails with a clear configuration error when `FIRECRAWL_API_KEY` is missing, and the always-active loader guidance tells the agent not to retry repeatedly.
104
118
 
105
119
  Tool output is limited to 50 KB or 2,000 lines, whichever is reached first.
106
120
  When a response is truncated, the result reports the original and displayed sizes and the path to a complete temporary JSON file.
107
- These files use private permissions, remain available for the current session, and are removed during session shutdown or reload.
108
121
  Tool-result metadata contains only size and artifact information rather than a duplicate of the raw Firecrawl response.
109
122
  Oversized Firecrawl error bodies are bounded in the same way.
110
123
 
111
124
  ## 💬 Commands
112
125
 
113
- ```text
114
- /firecrawl
115
- ```
116
-
117
- Opens a menu with configuration quick start, command usage, tool-catalog status, controls for making all Firecrawl capabilities available or unavailable, and a selector for choosing individual tools.
118
-
119
- Direct subcommands are also available:
120
-
121
- ```text
122
- /firecrawl help
123
- /firecrawl config
124
- /firecrawl quickstart
125
- /firecrawl status
126
- /firecrawl tools
127
- /firecrawl toggle
128
- /firecrawl enable
129
- /firecrawl disable
130
- ```
131
-
132
- - `help` shows command usage.
133
- - `config` shows API-key presence and API URL without displaying the API key value.
134
- - `quickstart` is an alias for `config`.
135
- - `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.
136
- - `tools` opens a width-safe immediate-save selector for choosing available capabilities.
137
- - `toggle` is an alias for `tools`.
138
- - `enable` makes all five API capabilities available and follows the current native-deferred or eager exposure mode.
139
- - `disable` makes all five API capabilities unavailable and unloads affected active definitions.
140
- The slash command and `firecrawl_load` remain available.
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. |
141
135
 
142
- The menu, `tools`, `help`, `config`, `quickstart`, and `status` routes require TUI or RPC mode so their results are observable.
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**.
143
140
 
144
- Print and JSON modes reject those routes and unknown commands explicitly instead of entering unavailable UI or silently notifying a no-op channel.
141
+ ## 🔒 Security and privacy
145
142
 
146
- The deterministic `enable` and `disable` routes remain available in every mode.
143
+ Firecrawl API tools send requested URLs, options, and related data to the configured API endpoint.
144
+ Review the endpoint's privacy policy before sending private or authenticated URLs.
147
145
 
148
- Tool-selector toggles save immediately in user action order.
149
-
150
- Done, Escape, or cancellation closes the selector without undoing changes that were already saved.
151
-
152
- The available capability names are saved to:
153
-
154
- ```text
155
- ${PI_CODING_AGENT_DIR:-~/.pi/agent}/pi-firecrawl.json
156
- ```
157
-
158
- When the file is missing or invalid, the extension preserves Pi's current Firecrawl availability policy instead of replacing it.
159
- An unsaved catalog remains stable across runtime reloads.
160
- A valid saved catalog is restored on Pi startup and `/reload`, with capability definitions exposed natively deferred or eagerly according to model/provider support.
161
- A missing file is created by the first successful availability change.
162
- Within one Pi process, catalog saves run in invocation order, reread the latest valid document, and preserve unknown fields.
163
- Malformed JSON or invalid recognized fields block the save without replacement; a failed save restores both the prior availability and loaded capability state while preserving other extensions' active tools.
164
- The settings file stores only tool names and a timestamp; it never stores `FIRECRAWL_API_KEY`, request headers, or other secrets.
165
-
166
- Compatibility: older versions used `pi-firecrawl-settings.json`.
167
- A legacy-only file remains readable with a warning and is never modified automatically; rename it to `pi-firecrawl.json`.
168
- The first subsequent settings save writes the canonical file.
169
- If both files exist, `pi-firecrawl.json` wins and the legacy file is ignored.
170
- The legacy filename is deprecated and will be removed in a future major release.
146
+ `FIRECRAWL_API_KEY` is sent as a bearer credential but is never logged, displayed, or stored by the extension.
147
+ Truncated response artifacts use private temporary files, remain available only for the current session, and are removed on shutdown or reload.
171
148
 
172
149
  ## 🧪 Examples
173
150
 
174
- Scrape a page as markdown:
151
+ Call `firecrawl_scrape` to scrape a page as Markdown:
175
152
 
176
153
  ```json
177
154
  {
@@ -180,7 +157,7 @@ Scrape a page as markdown:
180
157
  }
181
158
  ```
182
159
 
183
- Map a small site:
160
+ Call `firecrawl_map` to discover URLs on a small site:
184
161
 
185
162
  ```json
186
163
  {
@@ -189,7 +166,7 @@ Map a small site:
189
166
  }
190
167
  ```
191
168
 
192
- Start a crawl with markdown extraction:
169
+ Call `firecrawl_crawl` to start a crawl with Markdown extraction:
193
170
 
194
171
  ```json
195
172
  {
@@ -211,25 +188,17 @@ Start a crawl with markdown extraction:
211
188
 
212
189
  ## 🗂️ Package layout
213
190
 
214
- ```txt
191
+ ```text
215
192
  packages/pi-firecrawl/
216
- ├── dist/ # Generated TypeScript runtime loaded by Jiti
217
- ├── scripts/
218
- │ └── build-runtime.mjs # Deterministic runtime builder and boundary validator
219
- ├── src/
220
- │ ├── index.ts # Pi package entrypoint
221
- │ ├── firecrawl.ts # Extension registration and command orchestration
222
- │ ├── lazy-tools.ts # Deferred capability catalog and loader tool
223
- │ └── *.ts # Package-local client, settings, selector, and tool modules
224
- ├── README.md
225
- ├── LICENSE
226
- ├── tsconfig.json
227
- └── 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
228
199
  ```
229
200
 
230
- `index.ts` is the Pi entrypoint and forwards to `firecrawl.ts`; the other source modules are internal.
231
-
232
- 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`.
233
202
 
234
203
  ## 🔎 Keywords
235
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
- 0,
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
- tempFile,
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
- Type2.Array(Type2.String(), { description: "URL path patterns to include." })
979
- ),
980
- excludePaths: Type2.Optional(
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
- Type2.Boolean({ description: "Deduplicate similar URLs when supported." })
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
- Type2.Boolean({ description: "Only use sitemap URLs when supported." })
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 {