@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/src/lazy-tools.ts CHANGED
@@ -1,301 +1,283 @@
1
- import {
2
- defineTool,
3
- type ExtensionAPI,
4
- type ExtensionContext,
5
- } from "@earendil-works/pi-coding-agent";
1
+ import { defineTool, type ExtensionAPI, type ExtensionContext } from "@earendil-works/pi-coding-agent";
6
2
  import { Type } from "typebox";
7
3
  import { FIRECRAWL_TOOL_NAMES, type FirecrawlToolName } from "./tool-names.js";
8
4
 
9
5
  export const FIRECRAWL_LOAD_TOOL_NAME = "firecrawl_load";
10
6
 
11
7
  const AVAILABLE_TOOLS_STORE = Symbol.for("@narumitw/pi-firecrawl.available-tools-store");
12
- const SESSION_AVAILABLE_TOOLS_STORE = Symbol.for(
13
- "@narumitw/pi-firecrawl.session-available-tools-store",
14
- );
8
+ const SESSION_AVAILABLE_TOOLS_STORE = Symbol.for("@narumitw/pi-firecrawl.session-available-tools-store");
15
9
  type FirecrawlGlobal = typeof globalThis & {
16
- [AVAILABLE_TOOLS_STORE]?: WeakMap<ExtensionAPI, Set<FirecrawlToolName>>;
17
- [SESSION_AVAILABLE_TOOLS_STORE]?: WeakMap<object, Set<FirecrawlToolName>>;
10
+ [AVAILABLE_TOOLS_STORE]?: WeakMap<ExtensionAPI, Set<FirecrawlToolName>>;
11
+ [SESSION_AVAILABLE_TOOLS_STORE]?: WeakMap<object, Set<FirecrawlToolName>>;
18
12
  };
19
13
  const sharedGlobal = globalThis as FirecrawlGlobal;
20
14
  const existingAvailableToolsStore = sharedGlobal[AVAILABLE_TOOLS_STORE];
21
- const availableToolsByApi =
22
- existingAvailableToolsStore ?? new WeakMap<ExtensionAPI, Set<FirecrawlToolName>>();
15
+ const availableToolsByApi = existingAvailableToolsStore ?? new WeakMap<ExtensionAPI, Set<FirecrawlToolName>>();
23
16
  if (!existingAvailableToolsStore) sharedGlobal[AVAILABLE_TOOLS_STORE] = availableToolsByApi;
24
17
  const existingSessionAvailableToolsStore = sharedGlobal[SESSION_AVAILABLE_TOOLS_STORE];
25
- const availableToolsBySession =
26
- existingSessionAvailableToolsStore ?? new WeakMap<object, Set<FirecrawlToolName>>();
18
+ const availableToolsBySession = existingSessionAvailableToolsStore ?? new WeakMap<object, Set<FirecrawlToolName>>();
27
19
  if (!existingSessionAvailableToolsStore) {
28
- sharedGlobal[SESSION_AVAILABLE_TOOLS_STORE] = availableToolsBySession;
20
+ sharedGlobal[SESSION_AVAILABLE_TOOLS_STORE] = availableToolsBySession;
29
21
  }
30
22
  const lazyExposureByApi = new WeakMap<ExtensionAPI, boolean>();
31
23
 
32
24
  const CRAWL_CREATION_TERMS = new Set(["begin", "create", "launch", "start"]);
33
25
 
34
26
  const SEARCH_TEXT: Record<FirecrawlToolName, string> = {
35
- firecrawl_scrape:
36
- "scrape scraping extract extraction single url page pages markdown html raw links screenshot json structured content",
37
- firecrawl_crawl: "crawl crawling website site start pages depth paths sitemap batch",
38
- firecrawl_crawl_status:
39
- "crawl crawling status job monitor check retrieve completed progress results",
40
- firecrawl_map: "map mapping discover discovery url urls links sitemap site inventory",
41
- firecrawl_search:
42
- "search searching web internet query results research discover discovery optionally scrape",
27
+ firecrawl_scrape:
28
+ "scrape scraping extract extraction single url page pages markdown html raw links screenshot json structured content",
29
+ firecrawl_crawl: "crawl crawling website site start pages depth paths sitemap batch",
30
+ firecrawl_crawl_status: "crawl crawling status job monitor check retrieve completed progress results",
31
+ firecrawl_map: "map mapping discover discovery url urls links sitemap site inventory",
32
+ firecrawl_search: "search searching web internet query results research discover discovery optionally scrape",
43
33
  };
44
34
 
45
35
  export function initializeAvailableFirecrawlTools(pi: ExtensionAPI, sessionOwner?: object) {
46
- if (sessionOwner) {
47
- const sessionTools = availableToolsBySession.get(sessionOwner);
48
- if (sessionTools) {
49
- setAvailableTools(pi, sessionTools, sessionOwner);
50
- return;
51
- }
52
- }
53
- const apiTools = availableToolsByApi.get(pi);
54
- if (apiTools) {
55
- if (sessionOwner) setAvailableTools(pi, apiTools, sessionOwner);
56
- return;
57
- }
58
- const activeTools = new Set(pi.getActiveTools());
59
- setAvailableTools(
60
- pi,
61
- FIRECRAWL_TOOL_NAMES.filter((name) => activeTools.has(name)),
62
- sessionOwner,
63
- );
36
+ if (sessionOwner) {
37
+ const sessionTools = availableToolsBySession.get(sessionOwner);
38
+ if (sessionTools) {
39
+ setAvailableTools(pi, sessionTools, sessionOwner);
40
+ return;
41
+ }
42
+ }
43
+ const apiTools = availableToolsByApi.get(pi);
44
+ if (apiTools) {
45
+ if (sessionOwner) setAvailableTools(pi, apiTools, sessionOwner);
46
+ return;
47
+ }
48
+ const activeTools = new Set(pi.getActiveTools());
49
+ setAvailableTools(
50
+ pi,
51
+ FIRECRAWL_TOOL_NAMES.filter((name) => activeTools.has(name)),
52
+ sessionOwner,
53
+ );
64
54
  }
65
55
 
66
56
  export function configureFirecrawlToolExposure(
67
- pi: ExtensionAPI,
68
- availableTools: readonly FirecrawlToolName[],
69
- loadedTools: readonly FirecrawlToolName[] = [],
70
- sessionOwner?: object,
71
- model?: ExtensionContext["model"],
57
+ pi: ExtensionAPI,
58
+ availableTools: readonly FirecrawlToolName[],
59
+ loadedTools: readonly FirecrawlToolName[] = [],
60
+ sessionOwner?: object,
61
+ model?: ExtensionContext["model"],
72
62
  ) {
73
- const available = setAvailableTools(pi, availableTools, sessionOwner);
74
- const lazyExposure = supportsNativeDeferredToolLoading(model);
75
- lazyExposureByApi.set(pi, lazyExposure);
76
- const loaded = new Set(loadedTools);
77
- const exposedTools = lazyExposure
78
- ? FIRECRAWL_TOOL_NAMES.filter((name) => available.has(name) && loaded.has(name))
79
- : FIRECRAWL_TOOL_NAMES.filter((name) => available.has(name));
80
- const nonCapabilityTools = pi
81
- .getActiveTools()
82
- .filter((name) => !FIRECRAWL_TOOL_NAMES.includes(name as FirecrawlToolName));
83
- pi.setActiveTools(unique([...nonCapabilityTools, FIRECRAWL_LOAD_TOOL_NAME, ...exposedTools]));
63
+ const available = setAvailableTools(pi, availableTools, sessionOwner);
64
+ const lazyExposure = supportsNativeDeferredToolLoading(model);
65
+ lazyExposureByApi.set(pi, lazyExposure);
66
+ const loaded = new Set(loadedTools);
67
+ const exposedTools = lazyExposure
68
+ ? FIRECRAWL_TOOL_NAMES.filter((name) => available.has(name) && loaded.has(name))
69
+ : FIRECRAWL_TOOL_NAMES.filter((name) => available.has(name));
70
+ const nonCapabilityTools = pi
71
+ .getActiveTools()
72
+ .filter((name) => !FIRECRAWL_TOOL_NAMES.includes(name as FirecrawlToolName));
73
+ pi.setActiveTools(unique([...nonCapabilityTools, FIRECRAWL_LOAD_TOOL_NAME, ...exposedTools]));
84
74
  }
85
75
 
86
76
  export function requireEagerFirecrawlToolExposure(pi: ExtensionAPI) {
87
- lazyExposureByApi.set(pi, false);
88
- const active = pi.getActiveTools();
89
- const available = availableFirecrawlTools(pi);
90
- pi.setActiveTools(unique([...active, FIRECRAWL_LOAD_TOOL_NAME, ...available]));
77
+ lazyExposureByApi.set(pi, false);
78
+ const active = pi.getActiveTools();
79
+ const available = availableFirecrawlTools(pi);
80
+ pi.setActiveTools(unique([...active, FIRECRAWL_LOAD_TOOL_NAME, ...available]));
91
81
  }
92
82
 
93
83
  export function applyAvailableFirecrawlTools(
94
- pi: ExtensionAPI,
95
- availableTools: readonly FirecrawlToolName[],
96
- sessionOwner?: object,
84
+ pi: ExtensionAPI,
85
+ availableTools: readonly FirecrawlToolName[],
86
+ sessionOwner?: object,
97
87
  ) {
98
- const available = setAvailableTools(pi, availableTools, sessionOwner);
99
- const lazyExposure = lazyExposureByApi.get(pi) === true;
100
- const active = pi
101
- .getActiveTools()
102
- .filter(
103
- (name) =>
104
- !FIRECRAWL_TOOL_NAMES.includes(name as FirecrawlToolName) ||
105
- (lazyExposure && available.has(name as FirecrawlToolName)),
106
- );
107
- const eagerTools = lazyExposure ? [] : FIRECRAWL_TOOL_NAMES.filter((name) => available.has(name));
108
- pi.setActiveTools(unique([...active, FIRECRAWL_LOAD_TOOL_NAME, ...eagerTools]));
88
+ const available = setAvailableTools(pi, availableTools, sessionOwner);
89
+ const lazyExposure = lazyExposureByApi.get(pi) === true;
90
+ const active = pi
91
+ .getActiveTools()
92
+ .filter(
93
+ (name) =>
94
+ !FIRECRAWL_TOOL_NAMES.includes(name as FirecrawlToolName) ||
95
+ (lazyExposure && available.has(name as FirecrawlToolName)),
96
+ );
97
+ const eagerTools = lazyExposure ? [] : FIRECRAWL_TOOL_NAMES.filter((name) => available.has(name));
98
+ pi.setActiveTools(unique([...active, FIRECRAWL_LOAD_TOOL_NAME, ...eagerTools]));
109
99
  }
110
100
 
111
101
  export function firecrawlToolExposureMode(pi: ExtensionAPI) {
112
- return lazyExposureByApi.get(pi) === true ? "native deferred" : "eager";
102
+ return lazyExposureByApi.get(pi) === true ? "native deferred" : "eager";
113
103
  }
114
104
 
115
105
  export function supportsNativeDeferredToolLoading(model: ExtensionContext["model"]): boolean {
116
- if (!model) return false;
117
- if (model.api === "anthropic-messages") {
118
- const configured = compatBoolean(model.compat, "supportsToolReferences");
119
- if (configured !== undefined) return configured;
120
- if (model.provider !== "anthropic" || model.id.includes("haiku")) return false;
121
- const version = model.id.match(/^claude-(?:opus|sonnet|fable)-(\d+)(?:-(\d+))?(?:-|$)/);
122
- if (!version) return false;
123
- const major = Number(version[1]);
124
- const minor = version[2] && version[2].length < 8 ? Number(version[2]) : 0;
125
- return major > 4 || (major === 4 && minor >= 5);
126
- }
127
- if (model.api === "openai-completions") {
128
- return compatString(model.compat, "deferredToolsMode") === "kimi";
129
- }
130
- if (model.api === "openai-responses" || model.api === "openai-codex-responses") {
131
- return (
132
- compatBoolean(model.compat, "supportsAdditionalTools") === true ||
133
- compatBoolean(model.compat, "supportsToolSearch") === true
134
- );
135
- }
136
- return false;
106
+ if (!model) return false;
107
+ if (model.api === "anthropic-messages") {
108
+ // Fireworks Messages requires the canonical ToolSearch/tool_search loader name.
109
+ // firecrawl_load remains package-specific so independently installed loaders cannot collide.
110
+ if (model.provider === "fireworks") return false;
111
+ const configured = compatBoolean(model.compat, "supportsToolReferences");
112
+ if (configured !== undefined) return configured;
113
+ if (model.provider !== "anthropic" || model.id.includes("haiku")) return false;
114
+ const version = model.id.match(/^claude-(?:opus|sonnet|fable)-(\d+)(?:-(\d+))?(?:-|$)/);
115
+ if (!version) return false;
116
+ const major = Number(version[1]);
117
+ const minor = version[2] && version[2].length < 8 ? Number(version[2]) : 0;
118
+ return major > 4 || (major === 4 && minor >= 5);
119
+ }
120
+ if (model.api === "openai-completions") {
121
+ return compatString(model.compat, "deferredToolsMode") === "kimi";
122
+ }
123
+ if (model.api === "openai-responses" || model.api === "openai-codex-responses") {
124
+ return (
125
+ compatBoolean(model.compat, "supportsAdditionalTools") === true ||
126
+ compatBoolean(model.compat, "supportsToolSearch") === true
127
+ );
128
+ }
129
+ return false;
137
130
  }
138
131
 
139
132
  export function availableFirecrawlTools(pi: ExtensionAPI) {
140
- const available = availableToolsByApi.get(pi) ?? new Set();
141
- return FIRECRAWL_TOOL_NAMES.filter((name) => available.has(name));
133
+ const available = availableToolsByApi.get(pi) ?? new Set();
134
+ return FIRECRAWL_TOOL_NAMES.filter((name) => available.has(name));
142
135
  }
143
136
 
144
137
  export function createFirecrawlLoadTool(pi: ExtensionAPI) {
145
- return defineTool({
146
- name: FIRECRAWL_LOAD_TOOL_NAME,
147
- label: "Firecrawl: Load Tools",
148
- description:
149
- "Find and enable Firecrawl tools relevant to a web scraping, crawling, URL discovery, crawl-status, or search task. Loaded tools remain available for the session.",
150
- promptSnippet: "Load Firecrawl web research capabilities on demand",
151
- promptGuidelines: [
152
- "Use firecrawl_load when a task requires Firecrawl web scraping, crawling, URL discovery, crawl status, or search and the needed firecrawl_* capability is not active.",
153
- "If FIRECRAWL_API_KEY is missing, report the configuration error instead of retrying repeatedly.",
154
- ],
155
- parameters: Type.Object({
156
- query: Type.String({
157
- description: "Firecrawl capability or web research task to find tools for.",
158
- maxLength: 500,
159
- }),
160
- limit: Type.Optional(
161
- Type.Integer({
162
- description: "Maximum tools to load. Defaults to 3.",
163
- minimum: 1,
164
- maximum: 5,
165
- }),
166
- ),
167
- }),
168
- async execute(_toolCallId, params, signal) {
169
- signal?.throwIfAborted();
170
- const available = new Set(availableFirecrawlTools(pi));
171
- const matches = matchFirecrawlTools(params.query, params.limit ?? 3, available);
172
- const active = pi.getActiveTools();
173
- const activeSet = new Set(active);
174
- const added = matches.filter((name) => !activeSet.has(name));
175
- if (added.length > 0) pi.setActiveTools(unique([...active, ...added]));
138
+ return defineTool({
139
+ name: FIRECRAWL_LOAD_TOOL_NAME,
140
+ label: "Firecrawl: Load Tools",
141
+ description:
142
+ "Find and enable Firecrawl tools relevant to a web scraping, crawling, URL discovery, crawl-status, or search task. Loaded tools remain available for the session.",
143
+ promptSnippet: "Load Firecrawl web research capabilities on demand",
144
+ promptGuidelines: [
145
+ "Use firecrawl_load when a task requires Firecrawl web scraping, crawling, URL discovery, crawl status, or search and the needed firecrawl_* capability is not active.",
146
+ "If FIRECRAWL_API_KEY is missing, report the configuration error instead of retrying repeatedly.",
147
+ ],
148
+ parameters: Type.Object({
149
+ query: Type.String({
150
+ description: "Firecrawl capability or web research task to find tools for.",
151
+ maxLength: 500,
152
+ }),
153
+ limit: Type.Optional(
154
+ Type.Integer({
155
+ description: "Maximum tools to load. Defaults to 3.",
156
+ minimum: 1,
157
+ maximum: 5,
158
+ }),
159
+ ),
160
+ }),
161
+ async execute(_toolCallId, params, signal) {
162
+ signal?.throwIfAborted();
163
+ const available = new Set(availableFirecrawlTools(pi));
164
+ const matches = matchFirecrawlTools(params.query, params.limit ?? 3, available);
165
+ const active = pi.getActiveTools();
166
+ const activeSet = new Set(active);
167
+ const added = matches.filter((name) => !activeSet.has(name));
168
+ if (added.length > 0) pi.setActiveTools(unique([...active, ...added]));
176
169
 
177
- const text =
178
- matches.length === 0
179
- ? "No available Firecrawl tools matched the query."
180
- : added.length > 0
181
- ? `Loaded Firecrawl tools: ${added.join(", ")}`
182
- : `Matching Firecrawl tools are already loaded: ${matches.join(", ")}`;
183
- return {
184
- content: [{ type: "text" as const, text }],
185
- details: { matches, added },
186
- };
187
- },
188
- });
170
+ const text =
171
+ matches.length === 0
172
+ ? "No available Firecrawl tools matched the query."
173
+ : added.length > 0
174
+ ? `Loaded Firecrawl tools: ${added.join(", ")}`
175
+ : `Matching Firecrawl tools are already loaded: ${matches.join(", ")}`;
176
+ return {
177
+ content: [{ type: "text" as const, text }],
178
+ details: { matches, added },
179
+ };
180
+ },
181
+ });
189
182
  }
190
183
 
191
- function matchFirecrawlTools(
192
- query: string,
193
- limit: number,
194
- available: ReadonlySet<FirecrawlToolName>,
195
- ) {
196
- const terms = [
197
- ...new Set(
198
- query
199
- .toLowerCase()
200
- .split(/[^a-z0-9]+/)
201
- .filter((term) => term.length >= 2),
202
- ),
203
- ];
204
- if (terms.length === 0) return [];
205
- const ranked = FIRECRAWL_TOOL_NAMES.filter((name) => available.has(name))
206
- .map((name, index) => ({
207
- name,
208
- index,
209
- score: terms.reduce(
210
- (score, term) => score + (SEARCH_TEXT[name].split(" ").includes(term) ? 1 : 0),
211
- 0,
212
- ),
213
- }))
214
- .filter((match) => match.score > 0)
215
- .sort((left, right) => right.score - left.score || left.index - right.index);
216
- const bestScore = ranked[0]?.score;
217
- if (bestScore === undefined) return [];
218
- const matches = ranked
219
- .filter((match) => match.score === bestScore)
220
- .slice(0, limit)
221
- .map((match) => match.name);
222
- if (
223
- matches.includes("firecrawl_crawl") &&
224
- available.has("firecrawl_crawl_status") &&
225
- !matches.includes("firecrawl_crawl_status") &&
226
- matches.length < limit
227
- ) {
228
- matches.push("firecrawl_crawl_status");
229
- }
230
- if (
231
- matches.includes("firecrawl_crawl_status") &&
232
- available.has("firecrawl_crawl") &&
233
- !matches.includes("firecrawl_crawl") &&
234
- terms.some((term) => CRAWL_CREATION_TERMS.has(term)) &&
235
- matches.length < limit
236
- ) {
237
- matches.unshift("firecrawl_crawl");
238
- }
239
- return matches;
184
+ function matchFirecrawlTools(query: string, limit: number, available: ReadonlySet<FirecrawlToolName>) {
185
+ const terms = [
186
+ ...new Set(
187
+ query
188
+ .toLowerCase()
189
+ .split(/[^a-z0-9]+/)
190
+ .filter((term) => term.length >= 2),
191
+ ),
192
+ ];
193
+ if (terms.length === 0) return [];
194
+ const ranked = FIRECRAWL_TOOL_NAMES.filter((name) => available.has(name))
195
+ .map((name, index) => ({
196
+ name,
197
+ index,
198
+ score: terms.reduce((score, term) => score + (SEARCH_TEXT[name].split(" ").includes(term) ? 1 : 0), 0),
199
+ }))
200
+ .filter((match) => match.score > 0)
201
+ .sort((left, right) => right.score - left.score || left.index - right.index);
202
+ const bestScore = ranked[0]?.score;
203
+ if (bestScore === undefined) return [];
204
+ const matches = ranked
205
+ .filter((match) => match.score === bestScore)
206
+ .slice(0, limit)
207
+ .map((match) => match.name);
208
+ if (
209
+ matches.includes("firecrawl_crawl") &&
210
+ available.has("firecrawl_crawl_status") &&
211
+ !matches.includes("firecrawl_crawl_status") &&
212
+ matches.length < limit
213
+ ) {
214
+ matches.push("firecrawl_crawl_status");
215
+ }
216
+ if (
217
+ matches.includes("firecrawl_crawl_status") &&
218
+ available.has("firecrawl_crawl") &&
219
+ !matches.includes("firecrawl_crawl") &&
220
+ terms.some((term) => CRAWL_CREATION_TERMS.has(term)) &&
221
+ matches.length < limit
222
+ ) {
223
+ matches.unshift("firecrawl_crawl");
224
+ }
225
+ return matches;
240
226
  }
241
227
 
242
228
  export function loadedFirecrawlToolsFromBranch(
243
- entries: readonly unknown[],
244
- availableTools: readonly FirecrawlToolName[],
229
+ entries: readonly unknown[],
230
+ availableTools: readonly FirecrawlToolName[],
245
231
  ) {
246
- const available = new Set(availableTools);
247
- const loaded = new Set<FirecrawlToolName>();
248
- for (const entry of entries) {
249
- if (!isRecord(entry) || entry.type !== "message" || !isRecord(entry.message)) continue;
250
- const message = entry.message;
251
- if (
252
- message.role !== "toolResult" ||
253
- message.toolName !== FIRECRAWL_LOAD_TOOL_NAME ||
254
- message.isError === true
255
- ) {
256
- continue;
257
- }
258
- const details = isRecord(message.details) ? message.details : undefined;
259
- const recordedNames = [
260
- ...(Array.isArray(message.addedToolNames) ? message.addedToolNames : []),
261
- ...(details && Array.isArray(details.added) ? details.added : []),
262
- ];
263
- for (const name of recordedNames) {
264
- if (isFirecrawlToolName(name) && available.has(name)) loaded.add(name);
265
- }
266
- }
267
- return FIRECRAWL_TOOL_NAMES.filter((name) => loaded.has(name));
232
+ const available = new Set(availableTools);
233
+ const loaded = new Set<FirecrawlToolName>();
234
+ for (const entry of entries) {
235
+ if (!isRecord(entry) || entry.type !== "message" || !isRecord(entry.message)) continue;
236
+ const message = entry.message;
237
+ if (message.role !== "toolResult" || message.toolName !== FIRECRAWL_LOAD_TOOL_NAME || message.isError === true) {
238
+ continue;
239
+ }
240
+ const details = isRecord(message.details) ? message.details : undefined;
241
+ const recordedNames = [
242
+ ...(Array.isArray(message.addedToolNames) ? message.addedToolNames : []),
243
+ ...(details && Array.isArray(details.added) ? details.added : []),
244
+ ];
245
+ for (const name of recordedNames) {
246
+ if (isFirecrawlToolName(name) && available.has(name)) loaded.add(name);
247
+ }
248
+ }
249
+ return FIRECRAWL_TOOL_NAMES.filter((name) => loaded.has(name));
268
250
  }
269
251
 
270
252
  function setAvailableTools(
271
- pi: ExtensionAPI,
272
- availableTools: readonly FirecrawlToolName[] | ReadonlySet<FirecrawlToolName>,
273
- sessionOwner?: object,
253
+ pi: ExtensionAPI,
254
+ availableTools: readonly FirecrawlToolName[] | ReadonlySet<FirecrawlToolName>,
255
+ sessionOwner?: object,
274
256
  ) {
275
- const available = new Set(availableTools);
276
- availableToolsByApi.set(pi, available);
277
- if (sessionOwner) availableToolsBySession.set(sessionOwner, new Set(available));
278
- return available;
257
+ const available = new Set(availableTools);
258
+ availableToolsByApi.set(pi, available);
259
+ if (sessionOwner) availableToolsBySession.set(sessionOwner, new Set(available));
260
+ return available;
279
261
  }
280
262
 
281
263
  function isFirecrawlToolName(value: unknown): value is FirecrawlToolName {
282
- return typeof value === "string" && FIRECRAWL_TOOL_NAMES.includes(value as FirecrawlToolName);
264
+ return typeof value === "string" && FIRECRAWL_TOOL_NAMES.includes(value as FirecrawlToolName);
283
265
  }
284
266
 
285
267
  function isRecord(value: unknown): value is Record<string, unknown> {
286
- return typeof value === "object" && value !== null && !Array.isArray(value);
268
+ return typeof value === "object" && value !== null && !Array.isArray(value);
287
269
  }
288
270
 
289
271
  function compatBoolean(value: unknown, key: string) {
290
- if (!isRecord(value)) return undefined;
291
- return typeof value[key] === "boolean" ? value[key] : undefined;
272
+ if (!isRecord(value)) return undefined;
273
+ return typeof value[key] === "boolean" ? value[key] : undefined;
292
274
  }
293
275
 
294
276
  function compatString(value: unknown, key: string) {
295
- if (!isRecord(value)) return undefined;
296
- return typeof value[key] === "string" ? value[key] : undefined;
277
+ if (!isRecord(value)) return undefined;
278
+ return typeof value[key] === "string" ? value[key] : undefined;
297
279
  }
298
280
 
299
281
  function unique(values: readonly string[]) {
300
- return [...new Set(values)];
282
+ return [...new Set(values)];
301
283
  }