shariq-pi-extensions 0.3.4 → 0.3.6
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.
|
@@ -156,13 +156,11 @@ export function buildDeveloperSearchBody(params: DeveloperSearchParams): Record<
|
|
|
156
156
|
|
|
157
157
|
const k = clampInteger(params.limit, 5, 1, 20);
|
|
158
158
|
const passages = clampInteger(params.passages, 1, 1, 5);
|
|
159
|
-
const timeout = clampInteger(params.timeout_seconds, 60, 5, 120) * 1_000;
|
|
160
159
|
|
|
161
160
|
return {
|
|
162
161
|
query,
|
|
163
162
|
k,
|
|
164
163
|
passages,
|
|
165
|
-
timeout,
|
|
166
164
|
...(types?.length ? { types } : {}),
|
|
167
165
|
...(repos?.length ? { repos } : {}),
|
|
168
166
|
...(sources?.length ? { sources } : {}),
|
|
@@ -240,8 +238,9 @@ export async function firecrawlRequest(
|
|
|
240
238
|
config: FirecrawlConfig,
|
|
241
239
|
signal?: AbortSignal,
|
|
242
240
|
fetchImpl: FetchLike = fetch,
|
|
241
|
+
options?: { timeoutMs?: number },
|
|
243
242
|
): Promise<Record<string, unknown>> {
|
|
244
|
-
const timeoutMs = Number(body.timeout) || 60_000;
|
|
243
|
+
const timeoutMs = options?.timeoutMs || Number(body.timeout) || 60_000;
|
|
245
244
|
let lastError: unknown;
|
|
246
245
|
|
|
247
246
|
for (let attempt = 0; attempt <= RETRY_DELAYS_MS.length; attempt++) {
|
|
@@ -121,7 +121,8 @@ export default function firecrawlWebExtension(pi: ExtensionAPI) {
|
|
|
121
121
|
const config = resolveFirecrawlConfig();
|
|
122
122
|
onUpdate?.({ content: [{ type: "text", text: `Searching Developer Index for: ${params.query}` }], details: {} });
|
|
123
123
|
const body = buildDeveloperSearchBody(params);
|
|
124
|
-
const
|
|
124
|
+
const timeoutMs = typeof params.timeout_seconds === "number" ? Math.max(5, Math.min(120, params.timeout_seconds)) * 1_000 : 60_000;
|
|
125
|
+
const payload = await firecrawlRequest("search/developer", body, config, signal, fetch, { timeoutMs });
|
|
125
126
|
return {
|
|
126
127
|
content: [{ type: "text", text: await formatDeveloperSearchOutput(payload) }],
|
|
127
128
|
details: {
|
|
@@ -137,12 +137,13 @@ export async function formatDeveloperSearchOutput(payload: Record<string, unknow
|
|
|
137
137
|
|
|
138
138
|
for (const [index, rawResult] of results.entries()) {
|
|
139
139
|
const item = record(rawResult);
|
|
140
|
-
const type = valueText(item.type) ?? "artifact";
|
|
141
|
-
const title = valueText(item.title) ?? valueText(item.id) ?? valueText(item.url) ?? "Untitled";
|
|
142
|
-
const url = valueText(item.url);
|
|
143
140
|
const id = valueText(item.id);
|
|
141
|
+
const idKind = id ? id.match(/^([a-z_]+):/i)?.[1]?.replace(/_/g, " ") : undefined;
|
|
142
|
+
const type = (valueText(item.type) ?? idKind ?? "artifact").toUpperCase();
|
|
143
|
+
const title = valueText(item.title) ?? id ?? valueText(item.url) ?? "Untitled";
|
|
144
|
+
const url = valueText(item.url);
|
|
144
145
|
|
|
145
|
-
lines.push("", `### ${index + 1}. [${type
|
|
146
|
+
lines.push("", `### ${index + 1}. [${type}] ${title}`);
|
|
146
147
|
if (url) lines.push(`URL: ${url}`);
|
|
147
148
|
if (id && id !== title) lines.push(`ID: ${id}`);
|
|
148
149
|
|