@narumitw/pi-firecrawl 0.4.0 → 0.4.2
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/package.json +2 -2
- package/src/firecrawl.ts +11 -11
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@narumitw/pi-firecrawl",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.2",
|
|
4
4
|
"description": "Pi extension that exposes Firecrawl web scraping and crawling tools.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@biomejs/biome": "2.4.14",
|
|
36
|
-
"@
|
|
36
|
+
"@earendil-works/pi-coding-agent": "0.74.0",
|
|
37
37
|
"typescript": "6.0.3"
|
|
38
38
|
},
|
|
39
39
|
"repository": {
|
package/src/firecrawl.ts
CHANGED
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
defineTool,
|
|
6
6
|
type ExtensionAPI,
|
|
7
7
|
type ExtensionCommandContext,
|
|
8
|
-
} from "@
|
|
8
|
+
} from "@earendil-works/pi-coding-agent";
|
|
9
9
|
import { Type } from "typebox";
|
|
10
10
|
|
|
11
11
|
const DEFAULT_API_URL = "https://api.firecrawl.dev/v1";
|
|
@@ -348,7 +348,7 @@ async function showMenu(pi: ExtensionAPI, ctx: CommandContext) {
|
|
|
348
348
|
}
|
|
349
349
|
}
|
|
350
350
|
|
|
351
|
-
function parseCommand(args: string): CommandAction | "unknown" {
|
|
351
|
+
export function parseCommand(args: string): CommandAction | "unknown" {
|
|
352
352
|
const command = args.trim().toLowerCase();
|
|
353
353
|
if (!command) return "menu";
|
|
354
354
|
if (command === "help") return "help";
|
|
@@ -361,7 +361,7 @@ function parseCommand(args: string): CommandAction | "unknown" {
|
|
|
361
361
|
return "unknown";
|
|
362
362
|
}
|
|
363
363
|
|
|
364
|
-
function commandCompletions(prefix: string) {
|
|
364
|
+
export function commandCompletions(prefix: string) {
|
|
365
365
|
const normalized = prefix.trim().toLowerCase();
|
|
366
366
|
if (normalized.includes(" ")) return null;
|
|
367
367
|
|
|
@@ -625,7 +625,7 @@ function allFirecrawlTools() {
|
|
|
625
625
|
return [...FIRECRAWL_TOOL_NAMES];
|
|
626
626
|
}
|
|
627
627
|
|
|
628
|
-
function orderedFirecrawlTools(selectedTools: ReadonlySet<FirecrawlToolName>) {
|
|
628
|
+
export function orderedFirecrawlTools(selectedTools: ReadonlySet<FirecrawlToolName>) {
|
|
629
629
|
return FIRECRAWL_TOOL_NAMES.filter((toolName) => selectedTools.has(toolName));
|
|
630
630
|
}
|
|
631
631
|
|
|
@@ -642,7 +642,7 @@ async function persistedSettingLabel() {
|
|
|
642
642
|
return "none; current active-tool policy preserved";
|
|
643
643
|
}
|
|
644
644
|
|
|
645
|
-
function formatPersistedSelection(tools: readonly FirecrawlToolName[]) {
|
|
645
|
+
export function formatPersistedSelection(tools: readonly FirecrawlToolName[]) {
|
|
646
646
|
if (tools.length === FIRECRAWL_TOOL_NAMES.length) {
|
|
647
647
|
return `all enabled (${tools.length}/${FIRECRAWL_TOOL_NAMES.length} selected)`;
|
|
648
648
|
}
|
|
@@ -684,7 +684,7 @@ async function loadSettings(): Promise<
|
|
|
684
684
|
}
|
|
685
685
|
}
|
|
686
686
|
|
|
687
|
-
function normalizeFirecrawlSettings(value: unknown): FirecrawlSettings | undefined {
|
|
687
|
+
export function normalizeFirecrawlSettings(value: unknown): FirecrawlSettings | undefined {
|
|
688
688
|
if (!value || typeof value !== "object") return undefined;
|
|
689
689
|
const settings = value as { tools?: unknown; updatedAt?: unknown };
|
|
690
690
|
if (typeof settings.updatedAt !== "number") return undefined;
|
|
@@ -770,11 +770,11 @@ function hasApiKey() {
|
|
|
770
770
|
return Boolean(process.env.FIRECRAWL_API_KEY?.trim());
|
|
771
771
|
}
|
|
772
772
|
|
|
773
|
-
function normalizeApiUrl(apiUrl: string | undefined) {
|
|
773
|
+
export function normalizeApiUrl(apiUrl: string | undefined) {
|
|
774
774
|
return (apiUrl?.trim() || DEFAULT_API_URL).replace(/\/+$/, "");
|
|
775
775
|
}
|
|
776
776
|
|
|
777
|
-
function parseResponseBody(responseText: string) {
|
|
777
|
+
export function parseResponseBody(responseText: string) {
|
|
778
778
|
if (!responseText) return null;
|
|
779
779
|
|
|
780
780
|
try {
|
|
@@ -784,12 +784,12 @@ function parseResponseBody(responseText: string) {
|
|
|
784
784
|
}
|
|
785
785
|
}
|
|
786
786
|
|
|
787
|
-
function formatPayload(payload: unknown) {
|
|
787
|
+
export function formatPayload(payload: unknown) {
|
|
788
788
|
if (typeof payload === "string") return payload;
|
|
789
789
|
return JSON.stringify(payload);
|
|
790
790
|
}
|
|
791
791
|
|
|
792
|
-
function jsonResult(payload: unknown) {
|
|
792
|
+
export function jsonResult(payload: unknown) {
|
|
793
793
|
return {
|
|
794
794
|
content: [{ type: "text" as const, text: JSON.stringify(payload, null, 2) }],
|
|
795
795
|
details: payload,
|
|
@@ -805,7 +805,7 @@ async function withStatus<T>(ctx: StatusContext, status: string, callback: () =>
|
|
|
805
805
|
}
|
|
806
806
|
}
|
|
807
807
|
|
|
808
|
-
function cleanObject<T>(value: T): T {
|
|
808
|
+
export function cleanObject<T>(value: T): T {
|
|
809
809
|
if (Array.isArray(value)) {
|
|
810
810
|
return value.map((item) => cleanObject(item)) as T;
|
|
811
811
|
}
|