firecrawl 4.41.0 → 4.42.0
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/dist/{chunk-I2DFXQYR.js → chunk-OCJTYRX5.js} +1 -1
- package/dist/index.cjs +15 -9
- package/dist/index.d.cts +131 -12
- package/dist/index.d.ts +131 -12
- package/dist/index.js +16 -10
- package/dist/{package-V72LKFNW.js → package-ECWDBUY3.js} +1 -1
- package/package.json +1 -1
- package/src/__tests__/unit/v2/agent-hints.test.ts +116 -0
- package/src/__tests__/unit/v2/agent-thread.unit.test.ts +122 -0
- package/src/v2/methods/map.ts +2 -1
- package/src/v2/methods/parse.ts +2 -1
- package/src/v2/methods/scrape.ts +2 -1
- package/src/v2/methods/search.ts +2 -1
- package/src/v2/types.ts +136 -11
- package/src/v2/utils/agentHints.ts +7 -0
- package/src/v2/utils/errorHandler.ts +5 -5
|
@@ -12,7 +12,7 @@ var require_package = __commonJS({
|
|
|
12
12
|
"package.json"(exports, module) {
|
|
13
13
|
module.exports = {
|
|
14
14
|
name: "@mendable/firecrawl-js",
|
|
15
|
-
version: "4.
|
|
15
|
+
version: "4.42.0",
|
|
16
16
|
description: "JavaScript SDK for the Firecrawl API: web scraping, crawling, web search, and scientific literature search over a research paper index of PubMed, bioRxiv, medRxiv and arXiv abstracts",
|
|
17
17
|
main: "dist/index.js",
|
|
18
18
|
types: "dist/index.d.ts",
|
package/dist/index.cjs
CHANGED
|
@@ -39,7 +39,7 @@ var require_package = __commonJS({
|
|
|
39
39
|
"package.json"(exports2, module2) {
|
|
40
40
|
module2.exports = {
|
|
41
41
|
name: "@mendable/firecrawl-js",
|
|
42
|
-
version: "4.
|
|
42
|
+
version: "4.42.0",
|
|
43
43
|
description: "JavaScript SDK for the Firecrawl API: web scraping, crawling, web search, and scientific literature search over a research paper index of PubMed, bioRxiv, medRxiv and arXiv abstracts",
|
|
44
44
|
main: "dist/index.js",
|
|
45
45
|
types: "dist/index.d.ts",
|
|
@@ -317,6 +317,12 @@ var JobTimeoutError = class extends SdkError {
|
|
|
317
317
|
}
|
|
318
318
|
};
|
|
319
319
|
|
|
320
|
+
// src/v2/utils/agentHints.ts
|
|
321
|
+
function agentHintMetadata(body) {
|
|
322
|
+
const hints = body?.agent_hints;
|
|
323
|
+
return Array.isArray(hints) && hints.every((hint) => typeof hint === "string") ? { agent_hints: [...hints] } : {};
|
|
324
|
+
}
|
|
325
|
+
|
|
320
326
|
// src/utils/zodSchemaToJson.ts
|
|
321
327
|
var import_zod_to_json_schema = require("zod-to-json-schema");
|
|
322
328
|
function isZodSchema(value) {
|
|
@@ -550,7 +556,7 @@ function throwForBadResponse(resp, action) {
|
|
|
550
556
|
const status = resp.status;
|
|
551
557
|
const body = resp.data || {};
|
|
552
558
|
const msg = body?.error || body?.message || `Request failed (${status}) while trying to ${action}`;
|
|
553
|
-
throw new SdkError(
|
|
559
|
+
throw Object.assign(new SdkError(
|
|
554
560
|
msg,
|
|
555
561
|
status,
|
|
556
562
|
body?.code,
|
|
@@ -558,14 +564,14 @@ function throwForBadResponse(resp, action) {
|
|
|
558
564
|
void 0,
|
|
559
565
|
body?.chargeId,
|
|
560
566
|
parseRequiresAction(body?.requiresAction)
|
|
561
|
-
);
|
|
567
|
+
), agentHintMetadata(body));
|
|
562
568
|
}
|
|
563
569
|
function normalizeAxiosError(err, action) {
|
|
564
570
|
const status = err.response?.status;
|
|
565
571
|
const body = err.response?.data;
|
|
566
572
|
const message = body?.error || err.message || `Request failed${status ? ` (${status})` : ""} while trying to ${action}`;
|
|
567
573
|
const code = body?.code || err.code;
|
|
568
|
-
throw new SdkError(
|
|
574
|
+
throw Object.assign(new SdkError(
|
|
569
575
|
message,
|
|
570
576
|
status,
|
|
571
577
|
code,
|
|
@@ -573,7 +579,7 @@ function normalizeAxiosError(err, action) {
|
|
|
573
579
|
void 0,
|
|
574
580
|
body?.chargeId,
|
|
575
581
|
parseRequiresAction(body?.requiresAction)
|
|
576
|
-
);
|
|
582
|
+
), agentHintMetadata(body));
|
|
577
583
|
}
|
|
578
584
|
function isRetryableError(err) {
|
|
579
585
|
if (err instanceof JobTimeoutError) {
|
|
@@ -641,7 +647,7 @@ async function scrape(http, url, options, deps = {}) {
|
|
|
641
647
|
if (res.status !== 200 || !res.data?.success) {
|
|
642
648
|
throwForBadResponse(res, "scrape");
|
|
643
649
|
}
|
|
644
|
-
return res.data.data
|
|
650
|
+
return { ...res.data.data, ...agentHintMetadata(res.data) };
|
|
645
651
|
} catch (err) {
|
|
646
652
|
const delayMs = autoResume !== false ? processingContinuesDelayMs(err) : void 0;
|
|
647
653
|
if (delayMs !== void 0 && resumes < RESUME_MAX_ATTEMPTS && resumeWaitedMs + delayMs <= RESUME_MAX_TOTAL_WAIT_MS) {
|
|
@@ -758,7 +764,7 @@ async function parse(http, file, options) {
|
|
|
758
764
|
if (res.status !== 200 || !res.data?.success) {
|
|
759
765
|
throwForBadResponse(res, "parse");
|
|
760
766
|
}
|
|
761
|
-
return res.data.data
|
|
767
|
+
return { ...res.data.data, ...agentHintMetadata(res.data) };
|
|
762
768
|
} catch (err) {
|
|
763
769
|
if (err?.isAxiosError) return normalizeAxiosError(err, "parse");
|
|
764
770
|
throw err;
|
|
@@ -832,7 +838,7 @@ async function search(http, request) {
|
|
|
832
838
|
throwForBadResponse(res, "search");
|
|
833
839
|
}
|
|
834
840
|
const data = res.data.data || {};
|
|
835
|
-
const out = {};
|
|
841
|
+
const out = { ...agentHintMetadata(res.data) };
|
|
836
842
|
if (res.data.warning) out.warning = res.data.warning;
|
|
837
843
|
if (data.web) out.web = transformArray(data.web);
|
|
838
844
|
if (data.news) out.news = transformArray(data.news);
|
|
@@ -1037,7 +1043,7 @@ async function map(http, url, options) {
|
|
|
1037
1043
|
description: item.description
|
|
1038
1044
|
});
|
|
1039
1045
|
}
|
|
1040
|
-
return { id: res.data.id, links };
|
|
1046
|
+
return { id: res.data.id, links, ...agentHintMetadata(res.data) };
|
|
1041
1047
|
} catch (err) {
|
|
1042
1048
|
if (err?.isAxiosError) return normalizeAxiosError(err, "map");
|
|
1043
1049
|
throw err;
|
package/dist/index.d.cts
CHANGED
|
@@ -540,6 +540,8 @@ interface DocumentMetadata {
|
|
|
540
540
|
[key: string]: unknown;
|
|
541
541
|
}
|
|
542
542
|
interface Document {
|
|
543
|
+
/** API guidance, separate from extracted page content. */
|
|
544
|
+
agent_hints?: string[];
|
|
543
545
|
markdown?: string;
|
|
544
546
|
html?: string;
|
|
545
547
|
rawHtml?: string;
|
|
@@ -671,6 +673,7 @@ interface SearchResultImages {
|
|
|
671
673
|
position?: number;
|
|
672
674
|
}
|
|
673
675
|
interface SearchData {
|
|
676
|
+
agent_hints?: string[];
|
|
674
677
|
warning?: string;
|
|
675
678
|
web?: Array<SearchResultWeb | Document>;
|
|
676
679
|
news?: Array<SearchResultNews | Document>;
|
|
@@ -917,6 +920,7 @@ interface BatchScrapeJob {
|
|
|
917
920
|
data: Document[];
|
|
918
921
|
}
|
|
919
922
|
interface MapData {
|
|
923
|
+
agent_hints?: string[];
|
|
920
924
|
id?: string;
|
|
921
925
|
links: SearchResultWeb[];
|
|
922
926
|
}
|
|
@@ -1236,7 +1240,11 @@ interface AgentExchangeOptions {
|
|
|
1236
1240
|
toolkits?: string[];
|
|
1237
1241
|
maxCalls?: number;
|
|
1238
1242
|
requireApproval?: boolean;
|
|
1239
|
-
/**
|
|
1243
|
+
/**
|
|
1244
|
+
* Answers a pendingApproval from the previous turn of the thread. A `terms`
|
|
1245
|
+
* approval is accepted or declined as a whole: `callIds` and `always` are
|
|
1246
|
+
* ignored on it.
|
|
1247
|
+
*/
|
|
1240
1248
|
approve?: {
|
|
1241
1249
|
approvalId: string;
|
|
1242
1250
|
callIds?: string[];
|
|
@@ -1245,6 +1253,75 @@ interface AgentExchangeOptions {
|
|
|
1245
1253
|
decline?: {
|
|
1246
1254
|
approvalId: string;
|
|
1247
1255
|
};
|
|
1256
|
+
/**
|
|
1257
|
+
* What to do when a provider the agent would use needs data terms the team
|
|
1258
|
+
* has not accepted. Gated providers are never called in any mode:
|
|
1259
|
+
* - "skip" (server default): answer with accepted providers only and list
|
|
1260
|
+
* the gated ones in `exchange.skippedProviders`.
|
|
1261
|
+
* - "ask": the same, plus `exchange.requiresAction` and a `terms`
|
|
1262
|
+
* pendingApproval. Get your user's explicit consent, call terms/accept,
|
|
1263
|
+
* then continue the thread with `approve: { approvalId }`.
|
|
1264
|
+
* Terms gating is rolling out: until it is on for a thread, none of the
|
|
1265
|
+
* terms fields appear. There is no auto-accept mode. Omitted on a follow-up turn inherits the
|
|
1266
|
+
* previous turn's value.
|
|
1267
|
+
*/
|
|
1268
|
+
onTermsRequired?: AgentOnTermsRequired;
|
|
1269
|
+
}
|
|
1270
|
+
type AgentOnTermsRequired = "skip" | "ask";
|
|
1271
|
+
/** A gated provider the run would have used but did not. */
|
|
1272
|
+
interface AgentSkippedProvider {
|
|
1273
|
+
provider: string;
|
|
1274
|
+
name: string;
|
|
1275
|
+
capability?: string;
|
|
1276
|
+
/** What it would have added, in the agent's words. */
|
|
1277
|
+
adds?: string;
|
|
1278
|
+
reason: "terms_required";
|
|
1279
|
+
/** The gating terms version. */
|
|
1280
|
+
version: string;
|
|
1281
|
+
/** Where a person accepts the terms in the dashboard. */
|
|
1282
|
+
termsUrl: string;
|
|
1283
|
+
}
|
|
1284
|
+
/**
|
|
1285
|
+
* The exact Exchange calls to view and accept a provider's terms. Nothing here
|
|
1286
|
+
* is executed for you, and terms/accept must only be called after the user
|
|
1287
|
+
* has explicitly agreed to that provider's terms.
|
|
1288
|
+
*/
|
|
1289
|
+
interface AgentTermsRequiredAction {
|
|
1290
|
+
type: "accept_terms";
|
|
1291
|
+
/**
|
|
1292
|
+
* The `terms` pendingApproval that answers this. After the user agrees and
|
|
1293
|
+
* terms/accept succeeds, continue the thread with
|
|
1294
|
+
* `exchange.approve: { approvalId }`, or refuse with `decline`.
|
|
1295
|
+
*/
|
|
1296
|
+
approvalId: string;
|
|
1297
|
+
providers: {
|
|
1298
|
+
provider: string;
|
|
1299
|
+
name: string;
|
|
1300
|
+
capability?: string;
|
|
1301
|
+
adds?: string;
|
|
1302
|
+
version: string;
|
|
1303
|
+
/** null when the catalog published no digest; terms/show returns it. */
|
|
1304
|
+
digest: string | null;
|
|
1305
|
+
url: string;
|
|
1306
|
+
show: {
|
|
1307
|
+
provider: "firecrawl";
|
|
1308
|
+
capability: "terms/show";
|
|
1309
|
+
options: {
|
|
1310
|
+
provider: string;
|
|
1311
|
+
};
|
|
1312
|
+
};
|
|
1313
|
+
accept: {
|
|
1314
|
+
provider: "firecrawl";
|
|
1315
|
+
capability: "terms/accept";
|
|
1316
|
+
options: {
|
|
1317
|
+
provider: string;
|
|
1318
|
+
version: string;
|
|
1319
|
+
/** null when the catalog published no digest; terms/show returns it. */
|
|
1320
|
+
digest: string | null;
|
|
1321
|
+
confirmed: true;
|
|
1322
|
+
};
|
|
1323
|
+
};
|
|
1324
|
+
}[];
|
|
1248
1325
|
}
|
|
1249
1326
|
/** Per-run summary reported on a status response. */
|
|
1250
1327
|
interface AgentExchangeSummary {
|
|
@@ -1252,33 +1329,72 @@ interface AgentExchangeSummary {
|
|
|
1252
1329
|
/** What the run resolved to after thread inheritance, not what it requested. */
|
|
1253
1330
|
toolkits?: string[];
|
|
1254
1331
|
requireApproval?: boolean;
|
|
1332
|
+
onTermsRequired?: AgentOnTermsRequired;
|
|
1255
1333
|
paidCalls: number;
|
|
1256
1334
|
creditsUsed: number | null;
|
|
1335
|
+
/** Gated providers that would have helped and were not used. Any mode. */
|
|
1336
|
+
skippedProviders?: AgentSkippedProvider[];
|
|
1337
|
+
/** "ask" mode, when a terms offer ended the turn. */
|
|
1338
|
+
requiresAction?: AgentTermsRequiredAction;
|
|
1339
|
+
}
|
|
1340
|
+
/** A provider in a `terms` pendingApproval. */
|
|
1341
|
+
interface AgentTermsGate {
|
|
1342
|
+
provider: string;
|
|
1343
|
+
name: string;
|
|
1344
|
+
logo?: string;
|
|
1345
|
+
capability?: string;
|
|
1346
|
+
adds?: string;
|
|
1347
|
+
version: string;
|
|
1348
|
+
/** null when the catalog published no digest; terms/show returns it. */
|
|
1349
|
+
digest: string | null;
|
|
1350
|
+
url: string;
|
|
1257
1351
|
}
|
|
1258
1352
|
/** A follow-up the agent offers for the next turn of the thread. */
|
|
1259
1353
|
interface AgentSuggestion {
|
|
1260
1354
|
label: string;
|
|
1261
1355
|
prompt: string;
|
|
1262
1356
|
}
|
|
1263
|
-
/** A
|
|
1264
|
-
interface
|
|
1357
|
+
/** A paid call a `calls` pendingApproval is holding back. */
|
|
1358
|
+
interface PendingApprovalCall {
|
|
1359
|
+
id: string;
|
|
1360
|
+
provider: string;
|
|
1361
|
+
capability: string;
|
|
1362
|
+
input: Record<string, unknown>;
|
|
1363
|
+
more?: Record<string, unknown>[];
|
|
1364
|
+
creditsEstimate: number | null;
|
|
1365
|
+
}
|
|
1366
|
+
interface PendingApprovalBase {
|
|
1265
1367
|
id: string;
|
|
1266
1368
|
reason: string;
|
|
1267
|
-
calls: {
|
|
1268
|
-
id: string;
|
|
1269
|
-
provider: string;
|
|
1270
|
-
capability: string;
|
|
1271
|
-
input: Record<string, unknown>;
|
|
1272
|
-
more?: Record<string, unknown>[];
|
|
1273
|
-
creditsEstimate: number | null;
|
|
1274
|
-
}[];
|
|
1275
1369
|
resolution: null | {
|
|
1276
1370
|
approved: boolean;
|
|
1371
|
+
/** Calls approved. Ignored on terms offers. */
|
|
1277
1372
|
callIds: string[];
|
|
1278
1373
|
always: boolean;
|
|
1279
1374
|
byRunId: string;
|
|
1280
1375
|
};
|
|
1281
1376
|
}
|
|
1377
|
+
/**
|
|
1378
|
+
* A turn that ended waiting for the caller to allow or refuse paid calls.
|
|
1379
|
+
* `kind` is absent on items written before terms offers existed.
|
|
1380
|
+
*/
|
|
1381
|
+
interface PendingCallsApproval extends PendingApprovalBase {
|
|
1382
|
+
kind?: "calls";
|
|
1383
|
+
calls: PendingApprovalCall[];
|
|
1384
|
+
terms?: never;
|
|
1385
|
+
}
|
|
1386
|
+
/**
|
|
1387
|
+
* A turn that ended waiting for the caller to accept providers' data terms
|
|
1388
|
+
* ("ask" mode). `calls` is always empty (typed `never[]` rather
|
|
1389
|
+
* than `[]` so existing `pendingApproval.calls[0]` code still compiles).
|
|
1390
|
+
*/
|
|
1391
|
+
interface PendingTermsApproval extends PendingApprovalBase {
|
|
1392
|
+
kind: "terms";
|
|
1393
|
+
calls: never[];
|
|
1394
|
+
terms: AgentTermsGate[];
|
|
1395
|
+
}
|
|
1396
|
+
/** Narrow on `kind === "terms"`. */
|
|
1397
|
+
type PendingApproval = PendingCallsApproval | PendingTermsApproval;
|
|
1282
1398
|
interface AgentResponse {
|
|
1283
1399
|
success: boolean;
|
|
1284
1400
|
id: string;
|
|
@@ -1588,6 +1704,7 @@ interface RequiresAction {
|
|
|
1588
1704
|
}
|
|
1589
1705
|
declare function parseRequiresAction(value: unknown): RequiresAction | undefined;
|
|
1590
1706
|
declare class SdkError extends Error {
|
|
1707
|
+
agent_hints?: string[];
|
|
1591
1708
|
requestId?: string;
|
|
1592
1709
|
status?: number;
|
|
1593
1710
|
code?: string;
|
|
@@ -1631,10 +1748,12 @@ interface BrowserExecuteResponse {
|
|
|
1631
1748
|
stderr?: string;
|
|
1632
1749
|
exitCode?: number;
|
|
1633
1750
|
killed?: boolean;
|
|
1751
|
+
truncated?: boolean;
|
|
1634
1752
|
error?: string;
|
|
1635
1753
|
}
|
|
1636
1754
|
interface BrowserDeleteResponse {
|
|
1637
1755
|
success: boolean;
|
|
1756
|
+
status?: string;
|
|
1638
1757
|
sessionDurationMs?: number;
|
|
1639
1758
|
creditsBilled?: number;
|
|
1640
1759
|
error?: string;
|
|
@@ -3409,4 +3528,4 @@ declare class Firecrawl extends FirecrawlClient {
|
|
|
3409
3528
|
get v1(): FirecrawlApp;
|
|
3410
3529
|
}
|
|
3411
3530
|
|
|
3412
|
-
export { type ActionOption, type ActiveCrawl, type ActiveCrawlsResponse, type AgentEffort, type AgentExchangeOptions, type AgentExchangeSummary, type AgentListItem, type AgentListOptions, type AgentListResponse, type AgentMode, type AgentOptions$1 as AgentOptions, type AgentResponse, type AgentSnapshotResponse, type AgentStatusResponse, type AgentSuggestion, type AgentThread, type AgentThreadResponse, type AgentThreadRun, type AgentTraceActiveBrowserSession, type AgentTraceAgentFinishedEvent, type AgentTraceAgentIdentity, type AgentTraceAgentRole, type AgentTraceAgentStartedEvent, type AgentTraceArtifactChange, type AgentTraceArtifactUpdatedEvent, type AgentTraceBrowserSessionFinishedEvent, type AgentTraceBrowserSessionStartedEvent, type AgentTraceError, type AgentTraceErrorOccurredEvent, type AgentTraceEvent, type AgentTraceProgressReportedEvent, type AgentTraceReasoningSummaryEvent, type AgentTraceResponse, type AgentTraceRunCancelRequestedEvent, type AgentTraceRunFinishedEvent, type AgentTraceRunStartedEvent, type AgentTraceToolCallFinishedEvent, type AgentTraceToolCallStartedEvent, type AgentWebhookConfig, type AgentWebhookEvent, type AlexandriaCall, type AlexandriaOptions, type AlexandriaScrapeData, type AlexandriaScrapeError, type AlexandriaScrapeRequest, type AlexandriaScrapeResult, type AttributesFormat, type AuditMetadata$1 as AuditMetadata, type BatchScrapeJob, type BatchScrapeOptions, type BatchScrapeResponse$1 as BatchScrapeResponse, type BrandingProfile, type BrowserCreateResponse, type BrowserDeleteResponse, type BrowserExecuteResponse, type BrowserListResponse, type BrowserSession, type CategoryOption, type ChangeTrackingFormat, type ClickAction, type ConcurrencyCheck, type CrawlErrorsResponse$1 as CrawlErrorsResponse, type CrawlJob, type CrawlOptions, type CrawlResponse$1 as CrawlResponse, type CreateMonitorRequest, type CreditUsage, type CreditUsageHistoricalPeriod, type CreditUsageHistoricalResponse, type DeveloperSearchLicenseDisclosure, type DeveloperSearchOptions, type DeveloperSearchPassage, type DeveloperSearchRepoStatus, type DeveloperSearchResponse, type DeveloperSearchResult, type DeveloperSearchSourceStatus, type DeveloperSearchType, type DiscoveredTool, type Document, type DocumentMetadata, type EndpointFeedbackEndpoint, type EndpointFeedbackRequest, type ErrorDetails, type ExecuteJavascriptAction, type ExtractResponse$1 as ExtractResponse, type FeedbackMissingContent, type FeedbackRating, type FeedbackResponse, type FeedbackValuableSource, type FindToolsData, type FindToolsOptions, Firecrawl, FirecrawlApp as FirecrawlAppV1, FirecrawlClient, type FirecrawlClientInput, type FirecrawlClientOptions, type Format, type FormatOption, type FormatString, type GetMonitorCheckOptions, type GetPaperOptions, type GitHubScoreBreakdown, type GitHubSearchItem, type GitHubSearchResponse, type HighlightsFormat, type IdMap, type ImageParser, JobTimeoutError, type JsonFormat, type ListMonitorChecksOptions, type ListMonitorsOptions, type LocationConfig$1 as LocationConfig, type MapData, type MapOptions, type MenuAvailability, type MenuImage, type MenuItem, type MenuItemIdentifiers, type MenuMerchant, type MenuPrice, type MenuProfile, type MenuSection, type Monitor, type MonitorCheck, type MonitorCheckDetail, type MonitorCheckPage, type MonitorCrawlTarget, type MonitorCrawlTargetResult, type MonitorEmailNotification, type MonitorEmailRecipientSubscription, type MonitorJsonFieldDiff, type MonitorNotification, type MonitorPageDiff, type MonitorPageJudgment, type MonitorPageSnapshot, type MonitorSchedule, type MonitorScrapeTarget, type MonitorScrapeTargetResult, type MonitorSearchTarget, type MonitorSearchTargetResult, type MonitorSummary, type MonitorTarget, type MonitorTargetResult, type MonitorWebhookConfig, type PDFAction, type PDFParser, type PaginationConfig, type PaperMetadata, type PaperMetadataResponse, type PaperResult, type PaperSignals, type ParseFile, type ParseFileData, type ParseFormat, type ParseFormatOption, type ParseFormatString, type ParseOptions, type Passage, type PdfBlockConfidence, type PdfBlockItem, type PdfPage, type PdfPageBlocks, type PendingApproval, type PressAction, type ProductAvailability, type ProductImage, type ProductPrice, type ProductProfile, type ProductSale, type ProductVariant, type QueryFormat, type QuestionFormat, type QueueStatusResponse$1 as QueueStatusResponse, type ReadPaperResponse, type RedactPIIEntity, type RedactPIIOptions, type RequiresAction, ResearchClient, type ScrapeAction, type ScrapeBrowserDeleteResponse, type ScrapeExecuteRequest, type ScrapeExecuteResponse, type ScrapeOptions, type ScreenshotAction, type ScreenshotFormat, type ScrollAction, SdkError, type SearchData, type SearchFeedbackRequest, type SearchGithubOptions, type SearchPapersOptions, type SearchPapersResponse, type SearchRequest, type SearchResultImages, type SearchResultNews, type SearchResultWeb, type SimilarPapersOptions, type SimilarPapersResponse, type ThreatProtectionOptions, type TokenUsage, type TokenUsageHistoricalPeriod, type TokenUsageHistoricalResponse, type UpdateMonitorRequest, type Viewport, type WaitAction, Watcher, type WatcherOptions, type WebhookConfig, type WriteAction, Firecrawl as default, parseRequiresAction };
|
|
3531
|
+
export { type ActionOption, type ActiveCrawl, type ActiveCrawlsResponse, type AgentEffort, type AgentExchangeOptions, type AgentExchangeSummary, type AgentListItem, type AgentListOptions, type AgentListResponse, type AgentMode, type AgentOnTermsRequired, type AgentOptions$1 as AgentOptions, type AgentResponse, type AgentSkippedProvider, type AgentSnapshotResponse, type AgentStatusResponse, type AgentSuggestion, type AgentTermsGate, type AgentTermsRequiredAction, type AgentThread, type AgentThreadResponse, type AgentThreadRun, type AgentTraceActiveBrowserSession, type AgentTraceAgentFinishedEvent, type AgentTraceAgentIdentity, type AgentTraceAgentRole, type AgentTraceAgentStartedEvent, type AgentTraceArtifactChange, type AgentTraceArtifactUpdatedEvent, type AgentTraceBrowserSessionFinishedEvent, type AgentTraceBrowserSessionStartedEvent, type AgentTraceError, type AgentTraceErrorOccurredEvent, type AgentTraceEvent, type AgentTraceProgressReportedEvent, type AgentTraceReasoningSummaryEvent, type AgentTraceResponse, type AgentTraceRunCancelRequestedEvent, type AgentTraceRunFinishedEvent, type AgentTraceRunStartedEvent, type AgentTraceToolCallFinishedEvent, type AgentTraceToolCallStartedEvent, type AgentWebhookConfig, type AgentWebhookEvent, type AlexandriaCall, type AlexandriaOptions, type AlexandriaScrapeData, type AlexandriaScrapeError, type AlexandriaScrapeRequest, type AlexandriaScrapeResult, type AttributesFormat, type AuditMetadata$1 as AuditMetadata, type BatchScrapeJob, type BatchScrapeOptions, type BatchScrapeResponse$1 as BatchScrapeResponse, type BrandingProfile, type BrowserCreateResponse, type BrowserDeleteResponse, type BrowserExecuteResponse, type BrowserListResponse, type BrowserSession, type CategoryOption, type ChangeTrackingFormat, type ClickAction, type ConcurrencyCheck, type CrawlErrorsResponse$1 as CrawlErrorsResponse, type CrawlJob, type CrawlOptions, type CrawlResponse$1 as CrawlResponse, type CreateMonitorRequest, type CreditUsage, type CreditUsageHistoricalPeriod, type CreditUsageHistoricalResponse, type DeveloperSearchLicenseDisclosure, type DeveloperSearchOptions, type DeveloperSearchPassage, type DeveloperSearchRepoStatus, type DeveloperSearchResponse, type DeveloperSearchResult, type DeveloperSearchSourceStatus, type DeveloperSearchType, type DiscoveredTool, type Document, type DocumentMetadata, type EndpointFeedbackEndpoint, type EndpointFeedbackRequest, type ErrorDetails, type ExecuteJavascriptAction, type ExtractResponse$1 as ExtractResponse, type FeedbackMissingContent, type FeedbackRating, type FeedbackResponse, type FeedbackValuableSource, type FindToolsData, type FindToolsOptions, Firecrawl, FirecrawlApp as FirecrawlAppV1, FirecrawlClient, type FirecrawlClientInput, type FirecrawlClientOptions, type Format, type FormatOption, type FormatString, type GetMonitorCheckOptions, type GetPaperOptions, type GitHubScoreBreakdown, type GitHubSearchItem, type GitHubSearchResponse, type HighlightsFormat, type IdMap, type ImageParser, JobTimeoutError, type JsonFormat, type ListMonitorChecksOptions, type ListMonitorsOptions, type LocationConfig$1 as LocationConfig, type MapData, type MapOptions, type MenuAvailability, type MenuImage, type MenuItem, type MenuItemIdentifiers, type MenuMerchant, type MenuPrice, type MenuProfile, type MenuSection, type Monitor, type MonitorCheck, type MonitorCheckDetail, type MonitorCheckPage, type MonitorCrawlTarget, type MonitorCrawlTargetResult, type MonitorEmailNotification, type MonitorEmailRecipientSubscription, type MonitorJsonFieldDiff, type MonitorNotification, type MonitorPageDiff, type MonitorPageJudgment, type MonitorPageSnapshot, type MonitorSchedule, type MonitorScrapeTarget, type MonitorScrapeTargetResult, type MonitorSearchTarget, type MonitorSearchTargetResult, type MonitorSummary, type MonitorTarget, type MonitorTargetResult, type MonitorWebhookConfig, type PDFAction, type PDFParser, type PaginationConfig, type PaperMetadata, type PaperMetadataResponse, type PaperResult, type PaperSignals, type ParseFile, type ParseFileData, type ParseFormat, type ParseFormatOption, type ParseFormatString, type ParseOptions, type Passage, type PdfBlockConfidence, type PdfBlockItem, type PdfPage, type PdfPageBlocks, type PendingApproval, type PendingApprovalCall, type PendingCallsApproval, type PendingTermsApproval, type PressAction, type ProductAvailability, type ProductImage, type ProductPrice, type ProductProfile, type ProductSale, type ProductVariant, type QueryFormat, type QuestionFormat, type QueueStatusResponse$1 as QueueStatusResponse, type ReadPaperResponse, type RedactPIIEntity, type RedactPIIOptions, type RequiresAction, ResearchClient, type ScrapeAction, type ScrapeBrowserDeleteResponse, type ScrapeExecuteRequest, type ScrapeExecuteResponse, type ScrapeOptions, type ScreenshotAction, type ScreenshotFormat, type ScrollAction, SdkError, type SearchData, type SearchFeedbackRequest, type SearchGithubOptions, type SearchPapersOptions, type SearchPapersResponse, type SearchRequest, type SearchResultImages, type SearchResultNews, type SearchResultWeb, type SimilarPapersOptions, type SimilarPapersResponse, type ThreatProtectionOptions, type TokenUsage, type TokenUsageHistoricalPeriod, type TokenUsageHistoricalResponse, type UpdateMonitorRequest, type Viewport, type WaitAction, Watcher, type WatcherOptions, type WebhookConfig, type WriteAction, Firecrawl as default, parseRequiresAction };
|
package/dist/index.d.ts
CHANGED
|
@@ -540,6 +540,8 @@ interface DocumentMetadata {
|
|
|
540
540
|
[key: string]: unknown;
|
|
541
541
|
}
|
|
542
542
|
interface Document {
|
|
543
|
+
/** API guidance, separate from extracted page content. */
|
|
544
|
+
agent_hints?: string[];
|
|
543
545
|
markdown?: string;
|
|
544
546
|
html?: string;
|
|
545
547
|
rawHtml?: string;
|
|
@@ -671,6 +673,7 @@ interface SearchResultImages {
|
|
|
671
673
|
position?: number;
|
|
672
674
|
}
|
|
673
675
|
interface SearchData {
|
|
676
|
+
agent_hints?: string[];
|
|
674
677
|
warning?: string;
|
|
675
678
|
web?: Array<SearchResultWeb | Document>;
|
|
676
679
|
news?: Array<SearchResultNews | Document>;
|
|
@@ -917,6 +920,7 @@ interface BatchScrapeJob {
|
|
|
917
920
|
data: Document[];
|
|
918
921
|
}
|
|
919
922
|
interface MapData {
|
|
923
|
+
agent_hints?: string[];
|
|
920
924
|
id?: string;
|
|
921
925
|
links: SearchResultWeb[];
|
|
922
926
|
}
|
|
@@ -1236,7 +1240,11 @@ interface AgentExchangeOptions {
|
|
|
1236
1240
|
toolkits?: string[];
|
|
1237
1241
|
maxCalls?: number;
|
|
1238
1242
|
requireApproval?: boolean;
|
|
1239
|
-
/**
|
|
1243
|
+
/**
|
|
1244
|
+
* Answers a pendingApproval from the previous turn of the thread. A `terms`
|
|
1245
|
+
* approval is accepted or declined as a whole: `callIds` and `always` are
|
|
1246
|
+
* ignored on it.
|
|
1247
|
+
*/
|
|
1240
1248
|
approve?: {
|
|
1241
1249
|
approvalId: string;
|
|
1242
1250
|
callIds?: string[];
|
|
@@ -1245,6 +1253,75 @@ interface AgentExchangeOptions {
|
|
|
1245
1253
|
decline?: {
|
|
1246
1254
|
approvalId: string;
|
|
1247
1255
|
};
|
|
1256
|
+
/**
|
|
1257
|
+
* What to do when a provider the agent would use needs data terms the team
|
|
1258
|
+
* has not accepted. Gated providers are never called in any mode:
|
|
1259
|
+
* - "skip" (server default): answer with accepted providers only and list
|
|
1260
|
+
* the gated ones in `exchange.skippedProviders`.
|
|
1261
|
+
* - "ask": the same, plus `exchange.requiresAction` and a `terms`
|
|
1262
|
+
* pendingApproval. Get your user's explicit consent, call terms/accept,
|
|
1263
|
+
* then continue the thread with `approve: { approvalId }`.
|
|
1264
|
+
* Terms gating is rolling out: until it is on for a thread, none of the
|
|
1265
|
+
* terms fields appear. There is no auto-accept mode. Omitted on a follow-up turn inherits the
|
|
1266
|
+
* previous turn's value.
|
|
1267
|
+
*/
|
|
1268
|
+
onTermsRequired?: AgentOnTermsRequired;
|
|
1269
|
+
}
|
|
1270
|
+
type AgentOnTermsRequired = "skip" | "ask";
|
|
1271
|
+
/** A gated provider the run would have used but did not. */
|
|
1272
|
+
interface AgentSkippedProvider {
|
|
1273
|
+
provider: string;
|
|
1274
|
+
name: string;
|
|
1275
|
+
capability?: string;
|
|
1276
|
+
/** What it would have added, in the agent's words. */
|
|
1277
|
+
adds?: string;
|
|
1278
|
+
reason: "terms_required";
|
|
1279
|
+
/** The gating terms version. */
|
|
1280
|
+
version: string;
|
|
1281
|
+
/** Where a person accepts the terms in the dashboard. */
|
|
1282
|
+
termsUrl: string;
|
|
1283
|
+
}
|
|
1284
|
+
/**
|
|
1285
|
+
* The exact Exchange calls to view and accept a provider's terms. Nothing here
|
|
1286
|
+
* is executed for you, and terms/accept must only be called after the user
|
|
1287
|
+
* has explicitly agreed to that provider's terms.
|
|
1288
|
+
*/
|
|
1289
|
+
interface AgentTermsRequiredAction {
|
|
1290
|
+
type: "accept_terms";
|
|
1291
|
+
/**
|
|
1292
|
+
* The `terms` pendingApproval that answers this. After the user agrees and
|
|
1293
|
+
* terms/accept succeeds, continue the thread with
|
|
1294
|
+
* `exchange.approve: { approvalId }`, or refuse with `decline`.
|
|
1295
|
+
*/
|
|
1296
|
+
approvalId: string;
|
|
1297
|
+
providers: {
|
|
1298
|
+
provider: string;
|
|
1299
|
+
name: string;
|
|
1300
|
+
capability?: string;
|
|
1301
|
+
adds?: string;
|
|
1302
|
+
version: string;
|
|
1303
|
+
/** null when the catalog published no digest; terms/show returns it. */
|
|
1304
|
+
digest: string | null;
|
|
1305
|
+
url: string;
|
|
1306
|
+
show: {
|
|
1307
|
+
provider: "firecrawl";
|
|
1308
|
+
capability: "terms/show";
|
|
1309
|
+
options: {
|
|
1310
|
+
provider: string;
|
|
1311
|
+
};
|
|
1312
|
+
};
|
|
1313
|
+
accept: {
|
|
1314
|
+
provider: "firecrawl";
|
|
1315
|
+
capability: "terms/accept";
|
|
1316
|
+
options: {
|
|
1317
|
+
provider: string;
|
|
1318
|
+
version: string;
|
|
1319
|
+
/** null when the catalog published no digest; terms/show returns it. */
|
|
1320
|
+
digest: string | null;
|
|
1321
|
+
confirmed: true;
|
|
1322
|
+
};
|
|
1323
|
+
};
|
|
1324
|
+
}[];
|
|
1248
1325
|
}
|
|
1249
1326
|
/** Per-run summary reported on a status response. */
|
|
1250
1327
|
interface AgentExchangeSummary {
|
|
@@ -1252,33 +1329,72 @@ interface AgentExchangeSummary {
|
|
|
1252
1329
|
/** What the run resolved to after thread inheritance, not what it requested. */
|
|
1253
1330
|
toolkits?: string[];
|
|
1254
1331
|
requireApproval?: boolean;
|
|
1332
|
+
onTermsRequired?: AgentOnTermsRequired;
|
|
1255
1333
|
paidCalls: number;
|
|
1256
1334
|
creditsUsed: number | null;
|
|
1335
|
+
/** Gated providers that would have helped and were not used. Any mode. */
|
|
1336
|
+
skippedProviders?: AgentSkippedProvider[];
|
|
1337
|
+
/** "ask" mode, when a terms offer ended the turn. */
|
|
1338
|
+
requiresAction?: AgentTermsRequiredAction;
|
|
1339
|
+
}
|
|
1340
|
+
/** A provider in a `terms` pendingApproval. */
|
|
1341
|
+
interface AgentTermsGate {
|
|
1342
|
+
provider: string;
|
|
1343
|
+
name: string;
|
|
1344
|
+
logo?: string;
|
|
1345
|
+
capability?: string;
|
|
1346
|
+
adds?: string;
|
|
1347
|
+
version: string;
|
|
1348
|
+
/** null when the catalog published no digest; terms/show returns it. */
|
|
1349
|
+
digest: string | null;
|
|
1350
|
+
url: string;
|
|
1257
1351
|
}
|
|
1258
1352
|
/** A follow-up the agent offers for the next turn of the thread. */
|
|
1259
1353
|
interface AgentSuggestion {
|
|
1260
1354
|
label: string;
|
|
1261
1355
|
prompt: string;
|
|
1262
1356
|
}
|
|
1263
|
-
/** A
|
|
1264
|
-
interface
|
|
1357
|
+
/** A paid call a `calls` pendingApproval is holding back. */
|
|
1358
|
+
interface PendingApprovalCall {
|
|
1359
|
+
id: string;
|
|
1360
|
+
provider: string;
|
|
1361
|
+
capability: string;
|
|
1362
|
+
input: Record<string, unknown>;
|
|
1363
|
+
more?: Record<string, unknown>[];
|
|
1364
|
+
creditsEstimate: number | null;
|
|
1365
|
+
}
|
|
1366
|
+
interface PendingApprovalBase {
|
|
1265
1367
|
id: string;
|
|
1266
1368
|
reason: string;
|
|
1267
|
-
calls: {
|
|
1268
|
-
id: string;
|
|
1269
|
-
provider: string;
|
|
1270
|
-
capability: string;
|
|
1271
|
-
input: Record<string, unknown>;
|
|
1272
|
-
more?: Record<string, unknown>[];
|
|
1273
|
-
creditsEstimate: number | null;
|
|
1274
|
-
}[];
|
|
1275
1369
|
resolution: null | {
|
|
1276
1370
|
approved: boolean;
|
|
1371
|
+
/** Calls approved. Ignored on terms offers. */
|
|
1277
1372
|
callIds: string[];
|
|
1278
1373
|
always: boolean;
|
|
1279
1374
|
byRunId: string;
|
|
1280
1375
|
};
|
|
1281
1376
|
}
|
|
1377
|
+
/**
|
|
1378
|
+
* A turn that ended waiting for the caller to allow or refuse paid calls.
|
|
1379
|
+
* `kind` is absent on items written before terms offers existed.
|
|
1380
|
+
*/
|
|
1381
|
+
interface PendingCallsApproval extends PendingApprovalBase {
|
|
1382
|
+
kind?: "calls";
|
|
1383
|
+
calls: PendingApprovalCall[];
|
|
1384
|
+
terms?: never;
|
|
1385
|
+
}
|
|
1386
|
+
/**
|
|
1387
|
+
* A turn that ended waiting for the caller to accept providers' data terms
|
|
1388
|
+
* ("ask" mode). `calls` is always empty (typed `never[]` rather
|
|
1389
|
+
* than `[]` so existing `pendingApproval.calls[0]` code still compiles).
|
|
1390
|
+
*/
|
|
1391
|
+
interface PendingTermsApproval extends PendingApprovalBase {
|
|
1392
|
+
kind: "terms";
|
|
1393
|
+
calls: never[];
|
|
1394
|
+
terms: AgentTermsGate[];
|
|
1395
|
+
}
|
|
1396
|
+
/** Narrow on `kind === "terms"`. */
|
|
1397
|
+
type PendingApproval = PendingCallsApproval | PendingTermsApproval;
|
|
1282
1398
|
interface AgentResponse {
|
|
1283
1399
|
success: boolean;
|
|
1284
1400
|
id: string;
|
|
@@ -1588,6 +1704,7 @@ interface RequiresAction {
|
|
|
1588
1704
|
}
|
|
1589
1705
|
declare function parseRequiresAction(value: unknown): RequiresAction | undefined;
|
|
1590
1706
|
declare class SdkError extends Error {
|
|
1707
|
+
agent_hints?: string[];
|
|
1591
1708
|
requestId?: string;
|
|
1592
1709
|
status?: number;
|
|
1593
1710
|
code?: string;
|
|
@@ -1631,10 +1748,12 @@ interface BrowserExecuteResponse {
|
|
|
1631
1748
|
stderr?: string;
|
|
1632
1749
|
exitCode?: number;
|
|
1633
1750
|
killed?: boolean;
|
|
1751
|
+
truncated?: boolean;
|
|
1634
1752
|
error?: string;
|
|
1635
1753
|
}
|
|
1636
1754
|
interface BrowserDeleteResponse {
|
|
1637
1755
|
success: boolean;
|
|
1756
|
+
status?: string;
|
|
1638
1757
|
sessionDurationMs?: number;
|
|
1639
1758
|
creditsBilled?: number;
|
|
1640
1759
|
error?: string;
|
|
@@ -3409,4 +3528,4 @@ declare class Firecrawl extends FirecrawlClient {
|
|
|
3409
3528
|
get v1(): FirecrawlApp;
|
|
3410
3529
|
}
|
|
3411
3530
|
|
|
3412
|
-
export { type ActionOption, type ActiveCrawl, type ActiveCrawlsResponse, type AgentEffort, type AgentExchangeOptions, type AgentExchangeSummary, type AgentListItem, type AgentListOptions, type AgentListResponse, type AgentMode, type AgentOptions$1 as AgentOptions, type AgentResponse, type AgentSnapshotResponse, type AgentStatusResponse, type AgentSuggestion, type AgentThread, type AgentThreadResponse, type AgentThreadRun, type AgentTraceActiveBrowserSession, type AgentTraceAgentFinishedEvent, type AgentTraceAgentIdentity, type AgentTraceAgentRole, type AgentTraceAgentStartedEvent, type AgentTraceArtifactChange, type AgentTraceArtifactUpdatedEvent, type AgentTraceBrowserSessionFinishedEvent, type AgentTraceBrowserSessionStartedEvent, type AgentTraceError, type AgentTraceErrorOccurredEvent, type AgentTraceEvent, type AgentTraceProgressReportedEvent, type AgentTraceReasoningSummaryEvent, type AgentTraceResponse, type AgentTraceRunCancelRequestedEvent, type AgentTraceRunFinishedEvent, type AgentTraceRunStartedEvent, type AgentTraceToolCallFinishedEvent, type AgentTraceToolCallStartedEvent, type AgentWebhookConfig, type AgentWebhookEvent, type AlexandriaCall, type AlexandriaOptions, type AlexandriaScrapeData, type AlexandriaScrapeError, type AlexandriaScrapeRequest, type AlexandriaScrapeResult, type AttributesFormat, type AuditMetadata$1 as AuditMetadata, type BatchScrapeJob, type BatchScrapeOptions, type BatchScrapeResponse$1 as BatchScrapeResponse, type BrandingProfile, type BrowserCreateResponse, type BrowserDeleteResponse, type BrowserExecuteResponse, type BrowserListResponse, type BrowserSession, type CategoryOption, type ChangeTrackingFormat, type ClickAction, type ConcurrencyCheck, type CrawlErrorsResponse$1 as CrawlErrorsResponse, type CrawlJob, type CrawlOptions, type CrawlResponse$1 as CrawlResponse, type CreateMonitorRequest, type CreditUsage, type CreditUsageHistoricalPeriod, type CreditUsageHistoricalResponse, type DeveloperSearchLicenseDisclosure, type DeveloperSearchOptions, type DeveloperSearchPassage, type DeveloperSearchRepoStatus, type DeveloperSearchResponse, type DeveloperSearchResult, type DeveloperSearchSourceStatus, type DeveloperSearchType, type DiscoveredTool, type Document, type DocumentMetadata, type EndpointFeedbackEndpoint, type EndpointFeedbackRequest, type ErrorDetails, type ExecuteJavascriptAction, type ExtractResponse$1 as ExtractResponse, type FeedbackMissingContent, type FeedbackRating, type FeedbackResponse, type FeedbackValuableSource, type FindToolsData, type FindToolsOptions, Firecrawl, FirecrawlApp as FirecrawlAppV1, FirecrawlClient, type FirecrawlClientInput, type FirecrawlClientOptions, type Format, type FormatOption, type FormatString, type GetMonitorCheckOptions, type GetPaperOptions, type GitHubScoreBreakdown, type GitHubSearchItem, type GitHubSearchResponse, type HighlightsFormat, type IdMap, type ImageParser, JobTimeoutError, type JsonFormat, type ListMonitorChecksOptions, type ListMonitorsOptions, type LocationConfig$1 as LocationConfig, type MapData, type MapOptions, type MenuAvailability, type MenuImage, type MenuItem, type MenuItemIdentifiers, type MenuMerchant, type MenuPrice, type MenuProfile, type MenuSection, type Monitor, type MonitorCheck, type MonitorCheckDetail, type MonitorCheckPage, type MonitorCrawlTarget, type MonitorCrawlTargetResult, type MonitorEmailNotification, type MonitorEmailRecipientSubscription, type MonitorJsonFieldDiff, type MonitorNotification, type MonitorPageDiff, type MonitorPageJudgment, type MonitorPageSnapshot, type MonitorSchedule, type MonitorScrapeTarget, type MonitorScrapeTargetResult, type MonitorSearchTarget, type MonitorSearchTargetResult, type MonitorSummary, type MonitorTarget, type MonitorTargetResult, type MonitorWebhookConfig, type PDFAction, type PDFParser, type PaginationConfig, type PaperMetadata, type PaperMetadataResponse, type PaperResult, type PaperSignals, type ParseFile, type ParseFileData, type ParseFormat, type ParseFormatOption, type ParseFormatString, type ParseOptions, type Passage, type PdfBlockConfidence, type PdfBlockItem, type PdfPage, type PdfPageBlocks, type PendingApproval, type PressAction, type ProductAvailability, type ProductImage, type ProductPrice, type ProductProfile, type ProductSale, type ProductVariant, type QueryFormat, type QuestionFormat, type QueueStatusResponse$1 as QueueStatusResponse, type ReadPaperResponse, type RedactPIIEntity, type RedactPIIOptions, type RequiresAction, ResearchClient, type ScrapeAction, type ScrapeBrowserDeleteResponse, type ScrapeExecuteRequest, type ScrapeExecuteResponse, type ScrapeOptions, type ScreenshotAction, type ScreenshotFormat, type ScrollAction, SdkError, type SearchData, type SearchFeedbackRequest, type SearchGithubOptions, type SearchPapersOptions, type SearchPapersResponse, type SearchRequest, type SearchResultImages, type SearchResultNews, type SearchResultWeb, type SimilarPapersOptions, type SimilarPapersResponse, type ThreatProtectionOptions, type TokenUsage, type TokenUsageHistoricalPeriod, type TokenUsageHistoricalResponse, type UpdateMonitorRequest, type Viewport, type WaitAction, Watcher, type WatcherOptions, type WebhookConfig, type WriteAction, Firecrawl as default, parseRequiresAction };
|
|
3531
|
+
export { type ActionOption, type ActiveCrawl, type ActiveCrawlsResponse, type AgentEffort, type AgentExchangeOptions, type AgentExchangeSummary, type AgentListItem, type AgentListOptions, type AgentListResponse, type AgentMode, type AgentOnTermsRequired, type AgentOptions$1 as AgentOptions, type AgentResponse, type AgentSkippedProvider, type AgentSnapshotResponse, type AgentStatusResponse, type AgentSuggestion, type AgentTermsGate, type AgentTermsRequiredAction, type AgentThread, type AgentThreadResponse, type AgentThreadRun, type AgentTraceActiveBrowserSession, type AgentTraceAgentFinishedEvent, type AgentTraceAgentIdentity, type AgentTraceAgentRole, type AgentTraceAgentStartedEvent, type AgentTraceArtifactChange, type AgentTraceArtifactUpdatedEvent, type AgentTraceBrowserSessionFinishedEvent, type AgentTraceBrowserSessionStartedEvent, type AgentTraceError, type AgentTraceErrorOccurredEvent, type AgentTraceEvent, type AgentTraceProgressReportedEvent, type AgentTraceReasoningSummaryEvent, type AgentTraceResponse, type AgentTraceRunCancelRequestedEvent, type AgentTraceRunFinishedEvent, type AgentTraceRunStartedEvent, type AgentTraceToolCallFinishedEvent, type AgentTraceToolCallStartedEvent, type AgentWebhookConfig, type AgentWebhookEvent, type AlexandriaCall, type AlexandriaOptions, type AlexandriaScrapeData, type AlexandriaScrapeError, type AlexandriaScrapeRequest, type AlexandriaScrapeResult, type AttributesFormat, type AuditMetadata$1 as AuditMetadata, type BatchScrapeJob, type BatchScrapeOptions, type BatchScrapeResponse$1 as BatchScrapeResponse, type BrandingProfile, type BrowserCreateResponse, type BrowserDeleteResponse, type BrowserExecuteResponse, type BrowserListResponse, type BrowserSession, type CategoryOption, type ChangeTrackingFormat, type ClickAction, type ConcurrencyCheck, type CrawlErrorsResponse$1 as CrawlErrorsResponse, type CrawlJob, type CrawlOptions, type CrawlResponse$1 as CrawlResponse, type CreateMonitorRequest, type CreditUsage, type CreditUsageHistoricalPeriod, type CreditUsageHistoricalResponse, type DeveloperSearchLicenseDisclosure, type DeveloperSearchOptions, type DeveloperSearchPassage, type DeveloperSearchRepoStatus, type DeveloperSearchResponse, type DeveloperSearchResult, type DeveloperSearchSourceStatus, type DeveloperSearchType, type DiscoveredTool, type Document, type DocumentMetadata, type EndpointFeedbackEndpoint, type EndpointFeedbackRequest, type ErrorDetails, type ExecuteJavascriptAction, type ExtractResponse$1 as ExtractResponse, type FeedbackMissingContent, type FeedbackRating, type FeedbackResponse, type FeedbackValuableSource, type FindToolsData, type FindToolsOptions, Firecrawl, FirecrawlApp as FirecrawlAppV1, FirecrawlClient, type FirecrawlClientInput, type FirecrawlClientOptions, type Format, type FormatOption, type FormatString, type GetMonitorCheckOptions, type GetPaperOptions, type GitHubScoreBreakdown, type GitHubSearchItem, type GitHubSearchResponse, type HighlightsFormat, type IdMap, type ImageParser, JobTimeoutError, type JsonFormat, type ListMonitorChecksOptions, type ListMonitorsOptions, type LocationConfig$1 as LocationConfig, type MapData, type MapOptions, type MenuAvailability, type MenuImage, type MenuItem, type MenuItemIdentifiers, type MenuMerchant, type MenuPrice, type MenuProfile, type MenuSection, type Monitor, type MonitorCheck, type MonitorCheckDetail, type MonitorCheckPage, type MonitorCrawlTarget, type MonitorCrawlTargetResult, type MonitorEmailNotification, type MonitorEmailRecipientSubscription, type MonitorJsonFieldDiff, type MonitorNotification, type MonitorPageDiff, type MonitorPageJudgment, type MonitorPageSnapshot, type MonitorSchedule, type MonitorScrapeTarget, type MonitorScrapeTargetResult, type MonitorSearchTarget, type MonitorSearchTargetResult, type MonitorSummary, type MonitorTarget, type MonitorTargetResult, type MonitorWebhookConfig, type PDFAction, type PDFParser, type PaginationConfig, type PaperMetadata, type PaperMetadataResponse, type PaperResult, type PaperSignals, type ParseFile, type ParseFileData, type ParseFormat, type ParseFormatOption, type ParseFormatString, type ParseOptions, type Passage, type PdfBlockConfidence, type PdfBlockItem, type PdfPage, type PdfPageBlocks, type PendingApproval, type PendingApprovalCall, type PendingCallsApproval, type PendingTermsApproval, type PressAction, type ProductAvailability, type ProductImage, type ProductPrice, type ProductProfile, type ProductSale, type ProductVariant, type QueryFormat, type QuestionFormat, type QueueStatusResponse$1 as QueueStatusResponse, type ReadPaperResponse, type RedactPIIEntity, type RedactPIIOptions, type RequiresAction, ResearchClient, type ScrapeAction, type ScrapeBrowserDeleteResponse, type ScrapeExecuteRequest, type ScrapeExecuteResponse, type ScrapeOptions, type ScreenshotAction, type ScreenshotFormat, type ScrollAction, SdkError, type SearchData, type SearchFeedbackRequest, type SearchGithubOptions, type SearchPapersOptions, type SearchPapersResponse, type SearchRequest, type SearchResultImages, type SearchResultNews, type SearchResultWeb, type SimilarPapersOptions, type SimilarPapersResponse, type ThreatProtectionOptions, type TokenUsage, type TokenUsageHistoricalPeriod, type TokenUsageHistoricalResponse, type UpdateMonitorRequest, type Viewport, type WaitAction, Watcher, type WatcherOptions, type WebhookConfig, type WriteAction, Firecrawl as default, parseRequiresAction };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
require_package
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-OCJTYRX5.js";
|
|
4
4
|
|
|
5
5
|
// src/v2/utils/httpClient.ts
|
|
6
6
|
import axios from "axios";
|
|
@@ -185,6 +185,12 @@ var JobTimeoutError = class extends SdkError {
|
|
|
185
185
|
}
|
|
186
186
|
};
|
|
187
187
|
|
|
188
|
+
// src/v2/utils/agentHints.ts
|
|
189
|
+
function agentHintMetadata(body) {
|
|
190
|
+
const hints = body?.agent_hints;
|
|
191
|
+
return Array.isArray(hints) && hints.every((hint) => typeof hint === "string") ? { agent_hints: [...hints] } : {};
|
|
192
|
+
}
|
|
193
|
+
|
|
188
194
|
// src/utils/zodSchemaToJson.ts
|
|
189
195
|
import { zodToJsonSchema as zodToJsonSchemaLib } from "zod-to-json-schema";
|
|
190
196
|
function isZodSchema(value) {
|
|
@@ -418,7 +424,7 @@ function throwForBadResponse(resp, action) {
|
|
|
418
424
|
const status = resp.status;
|
|
419
425
|
const body = resp.data || {};
|
|
420
426
|
const msg = body?.error || body?.message || `Request failed (${status}) while trying to ${action}`;
|
|
421
|
-
throw new SdkError(
|
|
427
|
+
throw Object.assign(new SdkError(
|
|
422
428
|
msg,
|
|
423
429
|
status,
|
|
424
430
|
body?.code,
|
|
@@ -426,14 +432,14 @@ function throwForBadResponse(resp, action) {
|
|
|
426
432
|
void 0,
|
|
427
433
|
body?.chargeId,
|
|
428
434
|
parseRequiresAction(body?.requiresAction)
|
|
429
|
-
);
|
|
435
|
+
), agentHintMetadata(body));
|
|
430
436
|
}
|
|
431
437
|
function normalizeAxiosError(err, action) {
|
|
432
438
|
const status = err.response?.status;
|
|
433
439
|
const body = err.response?.data;
|
|
434
440
|
const message = body?.error || err.message || `Request failed${status ? ` (${status})` : ""} while trying to ${action}`;
|
|
435
441
|
const code = body?.code || err.code;
|
|
436
|
-
throw new SdkError(
|
|
442
|
+
throw Object.assign(new SdkError(
|
|
437
443
|
message,
|
|
438
444
|
status,
|
|
439
445
|
code,
|
|
@@ -441,7 +447,7 @@ function normalizeAxiosError(err, action) {
|
|
|
441
447
|
void 0,
|
|
442
448
|
body?.chargeId,
|
|
443
449
|
parseRequiresAction(body?.requiresAction)
|
|
444
|
-
);
|
|
450
|
+
), agentHintMetadata(body));
|
|
445
451
|
}
|
|
446
452
|
function isRetryableError(err) {
|
|
447
453
|
if (err instanceof JobTimeoutError) {
|
|
@@ -509,7 +515,7 @@ async function scrape(http, url, options, deps = {}) {
|
|
|
509
515
|
if (res.status !== 200 || !res.data?.success) {
|
|
510
516
|
throwForBadResponse(res, "scrape");
|
|
511
517
|
}
|
|
512
|
-
return res.data.data
|
|
518
|
+
return { ...res.data.data, ...agentHintMetadata(res.data) };
|
|
513
519
|
} catch (err) {
|
|
514
520
|
const delayMs = autoResume !== false ? processingContinuesDelayMs(err) : void 0;
|
|
515
521
|
if (delayMs !== void 0 && resumes < RESUME_MAX_ATTEMPTS && resumeWaitedMs + delayMs <= RESUME_MAX_TOTAL_WAIT_MS) {
|
|
@@ -626,7 +632,7 @@ async function parse(http, file, options) {
|
|
|
626
632
|
if (res.status !== 200 || !res.data?.success) {
|
|
627
633
|
throwForBadResponse(res, "parse");
|
|
628
634
|
}
|
|
629
|
-
return res.data.data
|
|
635
|
+
return { ...res.data.data, ...agentHintMetadata(res.data) };
|
|
630
636
|
} catch (err) {
|
|
631
637
|
if (err?.isAxiosError) return normalizeAxiosError(err, "parse");
|
|
632
638
|
throw err;
|
|
@@ -700,7 +706,7 @@ async function search(http, request) {
|
|
|
700
706
|
throwForBadResponse(res, "search");
|
|
701
707
|
}
|
|
702
708
|
const data = res.data.data || {};
|
|
703
|
-
const out = {};
|
|
709
|
+
const out = { ...agentHintMetadata(res.data) };
|
|
704
710
|
if (res.data.warning) out.warning = res.data.warning;
|
|
705
711
|
if (data.web) out.web = transformArray(data.web);
|
|
706
712
|
if (data.news) out.news = transformArray(data.news);
|
|
@@ -905,7 +911,7 @@ async function map(http, url, options) {
|
|
|
905
911
|
description: item.description
|
|
906
912
|
});
|
|
907
913
|
}
|
|
908
|
-
return { id: res.data.id, links };
|
|
914
|
+
return { id: res.data.id, links, ...agentHintMetadata(res.data) };
|
|
909
915
|
} catch (err) {
|
|
910
916
|
if (err?.isAxiosError) return normalizeAxiosError(err, "map");
|
|
911
917
|
throw err;
|
|
@@ -2667,7 +2673,7 @@ var FirecrawlApp = class {
|
|
|
2667
2673
|
if (typeof process !== "undefined" && process.env && process.env.npm_package_version) {
|
|
2668
2674
|
return process.env.npm_package_version;
|
|
2669
2675
|
}
|
|
2670
|
-
const packageJson = await import("./package-
|
|
2676
|
+
const packageJson = await import("./package-ECWDBUY3.js");
|
|
2671
2677
|
return packageJson.default.version;
|
|
2672
2678
|
} catch (error) {
|
|
2673
2679
|
const isTest = typeof process !== "undefined" && (process.env.JEST_WORKER_ID != null || false);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "firecrawl",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.42.0",
|
|
4
4
|
"description": "JavaScript SDK for the Firecrawl API: web scraping, crawling, web search, and scientific literature search over a research paper index of PubMed, bioRxiv, medRxiv and arXiv abstracts",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { describe, expect, it, jest } from "@jest/globals";
|
|
2
|
+
import { search } from "../../../v2/methods/search";
|
|
3
|
+
import { scrape } from "../../../v2/methods/scrape";
|
|
4
|
+
import { parse } from "../../../v2/methods/parse";
|
|
5
|
+
import { map } from "../../../v2/methods/map";
|
|
6
|
+
import {
|
|
7
|
+
normalizeAxiosError,
|
|
8
|
+
throwForBadResponse,
|
|
9
|
+
} from "../../../v2/utils/errorHandler";
|
|
10
|
+
|
|
11
|
+
const hints = [
|
|
12
|
+
"Scrape a selected search result if you need full page content.",
|
|
13
|
+
"Evaluate this result before submitting feedback.",
|
|
14
|
+
];
|
|
15
|
+
function httpFor(body: object) {
|
|
16
|
+
return {
|
|
17
|
+
post: jest.fn<any>().mockResolvedValue({ status: 200, data: body }),
|
|
18
|
+
postMultipart: jest
|
|
19
|
+
.fn<any>()
|
|
20
|
+
.mockResolvedValue({ status: 200, data: body }),
|
|
21
|
+
} as any;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
describe("agent hints survive SDK response unwrapping", () => {
|
|
25
|
+
it("preserves search hints without adding them to records", async () => {
|
|
26
|
+
const web = [{ url: "https://example.com" }];
|
|
27
|
+
const result = await search(
|
|
28
|
+
httpFor({ success: true, data: { web }, agent_hints: hints }),
|
|
29
|
+
{ query: "test" },
|
|
30
|
+
);
|
|
31
|
+
expect(result.web).toEqual(web);
|
|
32
|
+
expect(result.web[0]).not.toHaveProperty("agent_hints");
|
|
33
|
+
expect(result.agent_hints).toEqual(hints);
|
|
34
|
+
expect(JSON.parse(JSON.stringify(result)).agent_hints).toEqual(hints);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it("keeps existing search output unchanged when hints are absent", async () => {
|
|
38
|
+
const result = await search(httpFor({ success: true, data: { web: [] } }), {
|
|
39
|
+
query: "test",
|
|
40
|
+
});
|
|
41
|
+
expect(Object.keys(result)).toEqual(["web"]);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it.each(["scrape", "parse"])(
|
|
45
|
+
"keeps %s hints separate from document content",
|
|
46
|
+
async (method) => {
|
|
47
|
+
const http = httpFor({
|
|
48
|
+
success: true,
|
|
49
|
+
data: { markdown: "# Page" },
|
|
50
|
+
agent_hints: hints,
|
|
51
|
+
});
|
|
52
|
+
const result =
|
|
53
|
+
method === "scrape"
|
|
54
|
+
? await scrape(http, "https://example.com")
|
|
55
|
+
: await parse(http, { filename: "page.txt", data: "Page" });
|
|
56
|
+
expect(result.markdown).toBe("# Page");
|
|
57
|
+
expect(result.agent_hints).toEqual(hints);
|
|
58
|
+
},
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
it("preserves map metadata alongside normalized links", async () => {
|
|
62
|
+
const result = await map(
|
|
63
|
+
httpFor({
|
|
64
|
+
success: true,
|
|
65
|
+
id: "map-id",
|
|
66
|
+
links: ["https://example.com"],
|
|
67
|
+
agent_hints: hints,
|
|
68
|
+
}),
|
|
69
|
+
"https://example.com",
|
|
70
|
+
);
|
|
71
|
+
expect(result).toEqual({
|
|
72
|
+
id: "map-id",
|
|
73
|
+
links: [{ url: "https://example.com" }],
|
|
74
|
+
agent_hints: hints,
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it.each([null, "unexpected", [123]])(
|
|
79
|
+
"ignores malformed optional hints: %j",
|
|
80
|
+
async (value) => {
|
|
81
|
+
const result = await search(
|
|
82
|
+
httpFor({ success: true, data: {}, agent_hints: value }),
|
|
83
|
+
{ query: "test" },
|
|
84
|
+
);
|
|
85
|
+
expect(result).not.toHaveProperty("agent_hints");
|
|
86
|
+
},
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
it("preserves hints on HTTP and Axios errors without changing their status", () => {
|
|
90
|
+
const response = {
|
|
91
|
+
status: 400,
|
|
92
|
+
data: {
|
|
93
|
+
success: false,
|
|
94
|
+
code: "INVALID",
|
|
95
|
+
error: "Invalid request",
|
|
96
|
+
agent_hints: hints,
|
|
97
|
+
},
|
|
98
|
+
} as any;
|
|
99
|
+
for (const raise of [
|
|
100
|
+
() => throwForBadResponse(response, "search"),
|
|
101
|
+
() =>
|
|
102
|
+
normalizeAxiosError({ response, isAxiosError: true } as any, "search"),
|
|
103
|
+
]) {
|
|
104
|
+
try {
|
|
105
|
+
raise();
|
|
106
|
+
throw new Error("Expected SDK error");
|
|
107
|
+
} catch (error) {
|
|
108
|
+
expect(error).toMatchObject({
|
|
109
|
+
status: 400,
|
|
110
|
+
code: "INVALID",
|
|
111
|
+
agent_hints: hints,
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
});
|
|
@@ -161,4 +161,126 @@ describe("v2.agent threads unit", () => {
|
|
|
161
161
|
"/v2/agent/threads/thread-1?includeData=true",
|
|
162
162
|
);
|
|
163
163
|
});
|
|
164
|
+
test("startAgent forwards exchange.onTermsRequired and a terms approve", async () => {
|
|
165
|
+
const post = okPost();
|
|
166
|
+
const exchange = {
|
|
167
|
+
onTermsRequired: "ask" as const,
|
|
168
|
+
approve: { approvalId: "0199aaaa-0000-7000-8000-000000000000" },
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
await startAgent({ post } as any, {
|
|
172
|
+
prompt: "Continue",
|
|
173
|
+
threadId: "thread-1",
|
|
174
|
+
exchange,
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
expect(post).toHaveBeenCalledWith("/v2/agent", {
|
|
178
|
+
prompt: "Continue",
|
|
179
|
+
threadId: "thread-1",
|
|
180
|
+
exchange,
|
|
181
|
+
});
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
test("startAgent forwards exchange.onTermsRequired skip", async () => {
|
|
185
|
+
const post = okPost();
|
|
186
|
+
|
|
187
|
+
await startAgent({ post } as any, {
|
|
188
|
+
prompt: "Find the key business contact at exa.ai",
|
|
189
|
+
exchange: { onTermsRequired: "skip" },
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
expect(post).toHaveBeenCalledWith("/v2/agent", {
|
|
193
|
+
prompt: "Find the key business contact at exa.ai",
|
|
194
|
+
exchange: { onTermsRequired: "skip" },
|
|
195
|
+
});
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
test("getAgentStatus parses skippedProviders, requiresAction and a terms approval", async () => {
|
|
199
|
+
const approvalId = "0199aaaa-0000-7000-8000-000000000000";
|
|
200
|
+
const get = jest.fn().mockResolvedValue({
|
|
201
|
+
status: 200,
|
|
202
|
+
data: {
|
|
203
|
+
success: true,
|
|
204
|
+
status: "completed",
|
|
205
|
+
data: null,
|
|
206
|
+
model: "spark-2",
|
|
207
|
+
expiresAt: "2026-09-02T00:00:00.000Z",
|
|
208
|
+
exchange: {
|
|
209
|
+
enabled: true,
|
|
210
|
+
onTermsRequired: "ask",
|
|
211
|
+
paidCalls: 0,
|
|
212
|
+
creditsUsed: null,
|
|
213
|
+
skippedProviders: [
|
|
214
|
+
{
|
|
215
|
+
provider: "apollo",
|
|
216
|
+
name: "Apollo",
|
|
217
|
+
capability: "people/search",
|
|
218
|
+
adds: "verified work emails",
|
|
219
|
+
reason: "terms_required",
|
|
220
|
+
version: "F-1.0.0",
|
|
221
|
+
termsUrl: "https://www.firecrawl.dev/app/alexandria/apollo",
|
|
222
|
+
},
|
|
223
|
+
],
|
|
224
|
+
requiresAction: {
|
|
225
|
+
type: "accept_terms",
|
|
226
|
+
approvalId,
|
|
227
|
+
providers: [
|
|
228
|
+
{
|
|
229
|
+
provider: "apollo",
|
|
230
|
+
name: "Apollo",
|
|
231
|
+
version: "F-1.0.0",
|
|
232
|
+
digest: null,
|
|
233
|
+
url: "https://www.firecrawl.dev/app/alexandria/apollo",
|
|
234
|
+
show: {
|
|
235
|
+
provider: "firecrawl",
|
|
236
|
+
capability: "terms/show",
|
|
237
|
+
options: { provider: "apollo" },
|
|
238
|
+
},
|
|
239
|
+
accept: {
|
|
240
|
+
provider: "firecrawl",
|
|
241
|
+
capability: "terms/accept",
|
|
242
|
+
options: {
|
|
243
|
+
provider: "apollo",
|
|
244
|
+
version: "F-1.0.0",
|
|
245
|
+
digest: null,
|
|
246
|
+
confirmed: true,
|
|
247
|
+
},
|
|
248
|
+
},
|
|
249
|
+
},
|
|
250
|
+
],
|
|
251
|
+
},
|
|
252
|
+
},
|
|
253
|
+
pendingApproval: {
|
|
254
|
+
id: approvalId,
|
|
255
|
+
kind: "terms",
|
|
256
|
+
reason: "Apollo could add verified work emails.",
|
|
257
|
+
calls: [],
|
|
258
|
+
terms: [
|
|
259
|
+
{
|
|
260
|
+
provider: "apollo",
|
|
261
|
+
name: "Apollo",
|
|
262
|
+
version: "F-1.0.0",
|
|
263
|
+
digest: null,
|
|
264
|
+
url: "https://www.firecrawl.dev/app/alexandria/apollo",
|
|
265
|
+
},
|
|
266
|
+
],
|
|
267
|
+
resolution: null,
|
|
268
|
+
},
|
|
269
|
+
},
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
const status = await getAgentStatus({ get } as any, "agent-job");
|
|
273
|
+
|
|
274
|
+
expect(status.exchange!.onTermsRequired).toBe("ask");
|
|
275
|
+
expect(status.exchange!.skippedProviders![0].reason).toBe("terms_required");
|
|
276
|
+
const action = status.exchange!.requiresAction!;
|
|
277
|
+
expect(action.approvalId).toBe(approvalId);
|
|
278
|
+
expect(action.providers[0].accept.capability).toBe("terms/accept");
|
|
279
|
+
expect(action.providers[0].accept.options.digest).toBeNull();
|
|
280
|
+
const pending = status.pendingApproval!;
|
|
281
|
+
expect(pending.kind).toBe("terms");
|
|
282
|
+
if (pending.kind !== "terms") throw new Error("expected a terms approval");
|
|
283
|
+
expect(pending.calls).toEqual([]);
|
|
284
|
+
expect(pending.terms[0].provider).toBe("apollo");
|
|
285
|
+
});
|
|
164
286
|
});
|
package/src/v2/methods/map.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type MapData, type MapOptions, type SearchResultWeb } from "../types";
|
|
2
2
|
import { HttpClient } from "../utils/httpClient";
|
|
3
|
+
import { agentHintMetadata } from "../utils/agentHints";
|
|
3
4
|
import {
|
|
4
5
|
throwForBadResponse,
|
|
5
6
|
normalizeAxiosError,
|
|
@@ -65,7 +66,7 @@ export async function map(
|
|
|
65
66
|
description: (item as any).description,
|
|
66
67
|
});
|
|
67
68
|
}
|
|
68
|
-
return { id: res.data.id, links };
|
|
69
|
+
return { id: res.data.id, links, ...agentHintMetadata(res.data) };
|
|
69
70
|
} catch (err: any) {
|
|
70
71
|
if (err?.isAxiosError) return normalizeAxiosError(err, "map");
|
|
71
72
|
throw err;
|
package/src/v2/methods/parse.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type Document, type ParseFile, type ParseOptions } from "../types";
|
|
2
2
|
import { HttpClient } from "../utils/httpClient";
|
|
3
|
+
import { agentHintMetadata } from "../utils/agentHints";
|
|
3
4
|
import { ensureValidParseOptions } from "../utils/validation";
|
|
4
5
|
import {
|
|
5
6
|
throwForBadResponse,
|
|
@@ -88,7 +89,7 @@ export async function parse(
|
|
|
88
89
|
if (res.status !== 200 || !res.data?.success) {
|
|
89
90
|
throwForBadResponse(res, "parse");
|
|
90
91
|
}
|
|
91
|
-
return
|
|
92
|
+
return { ...res.data.data, ...agentHintMetadata(res.data) };
|
|
92
93
|
} catch (err: any) {
|
|
93
94
|
if (err?.isAxiosError) return normalizeAxiosError(err, "parse");
|
|
94
95
|
throw err;
|
package/src/v2/methods/scrape.ts
CHANGED
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
type ScrapeOptions,
|
|
7
7
|
} from "../types";
|
|
8
8
|
import { HttpClient } from "../utils/httpClient";
|
|
9
|
+
import { agentHintMetadata } from "../utils/agentHints";
|
|
9
10
|
import { ensureValidScrapeOptions } from "../utils/validation";
|
|
10
11
|
import {
|
|
11
12
|
throwForBadResponse,
|
|
@@ -131,7 +132,7 @@ export async function scrape(
|
|
|
131
132
|
if (res.status !== 200 || !res.data?.success) {
|
|
132
133
|
throwForBadResponse(res, "scrape");
|
|
133
134
|
}
|
|
134
|
-
return
|
|
135
|
+
return { ...res.data.data, ...agentHintMetadata(res.data) };
|
|
135
136
|
} catch (err: any) {
|
|
136
137
|
const delayMs = autoResume !== false ? processingContinuesDelayMs(err) : undefined;
|
|
137
138
|
if (
|
package/src/v2/methods/search.ts
CHANGED
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
type SearchResultImages,
|
|
9
9
|
} from "../types";
|
|
10
10
|
import { HttpClient } from "../utils/httpClient";
|
|
11
|
+
import { agentHintMetadata } from "../utils/agentHints";
|
|
11
12
|
import { ensureValidScrapeOptions } from "../utils/validation";
|
|
12
13
|
import {
|
|
13
14
|
throwForBadResponse,
|
|
@@ -101,7 +102,7 @@ export async function search(
|
|
|
101
102
|
throwForBadResponse(res, "search");
|
|
102
103
|
}
|
|
103
104
|
const data = (res.data.data || {}) as Record<string, any>;
|
|
104
|
-
const out: SearchData = {};
|
|
105
|
+
const out: SearchData = { ...agentHintMetadata(res.data) };
|
|
105
106
|
if (res.data.warning) out.warning = res.data.warning;
|
|
106
107
|
if (data.web) out.web = transformArray<SearchResultWeb>(data.web);
|
|
107
108
|
if (data.news) out.news = transformArray<SearchResultNews>(data.news);
|
package/src/v2/types.ts
CHANGED
|
@@ -678,6 +678,8 @@ export interface DocumentMetadata {
|
|
|
678
678
|
}
|
|
679
679
|
|
|
680
680
|
export interface Document {
|
|
681
|
+
/** API guidance, separate from extracted page content. */
|
|
682
|
+
agent_hints?: string[];
|
|
681
683
|
markdown?: string;
|
|
682
684
|
html?: string;
|
|
683
685
|
rawHtml?: string;
|
|
@@ -820,6 +822,7 @@ export interface SearchResultImages {
|
|
|
820
822
|
}
|
|
821
823
|
|
|
822
824
|
export interface SearchData {
|
|
825
|
+
agent_hints?: string[];
|
|
823
826
|
warning?: string;
|
|
824
827
|
web?: Array<SearchResultWeb | Document>;
|
|
825
828
|
news?: Array<SearchResultNews | Document>;
|
|
@@ -1086,6 +1089,7 @@ export interface BatchScrapeJob {
|
|
|
1086
1089
|
}
|
|
1087
1090
|
|
|
1088
1091
|
export interface MapData {
|
|
1092
|
+
agent_hints?: string[];
|
|
1089
1093
|
id?: string;
|
|
1090
1094
|
links: SearchResultWeb[];
|
|
1091
1095
|
}
|
|
@@ -1449,9 +1453,83 @@ export interface AgentExchangeOptions {
|
|
|
1449
1453
|
toolkits?: string[];
|
|
1450
1454
|
maxCalls?: number;
|
|
1451
1455
|
requireApproval?: boolean;
|
|
1452
|
-
/**
|
|
1456
|
+
/**
|
|
1457
|
+
* Answers a pendingApproval from the previous turn of the thread. A `terms`
|
|
1458
|
+
* approval is accepted or declined as a whole: `callIds` and `always` are
|
|
1459
|
+
* ignored on it.
|
|
1460
|
+
*/
|
|
1453
1461
|
approve?: { approvalId: string; callIds?: string[]; always?: boolean };
|
|
1454
1462
|
decline?: { approvalId: string };
|
|
1463
|
+
/**
|
|
1464
|
+
* What to do when a provider the agent would use needs data terms the team
|
|
1465
|
+
* has not accepted. Gated providers are never called in any mode:
|
|
1466
|
+
* - "skip" (server default): answer with accepted providers only and list
|
|
1467
|
+
* the gated ones in `exchange.skippedProviders`.
|
|
1468
|
+
* - "ask": the same, plus `exchange.requiresAction` and a `terms`
|
|
1469
|
+
* pendingApproval. Get your user's explicit consent, call terms/accept,
|
|
1470
|
+
* then continue the thread with `approve: { approvalId }`.
|
|
1471
|
+
* Terms gating is rolling out: until it is on for a thread, none of the
|
|
1472
|
+
* terms fields appear. There is no auto-accept mode. Omitted on a follow-up turn inherits the
|
|
1473
|
+
* previous turn's value.
|
|
1474
|
+
*/
|
|
1475
|
+
onTermsRequired?: AgentOnTermsRequired;
|
|
1476
|
+
}
|
|
1477
|
+
|
|
1478
|
+
export type AgentOnTermsRequired = "skip" | "ask";
|
|
1479
|
+
|
|
1480
|
+
/** A gated provider the run would have used but did not. */
|
|
1481
|
+
export interface AgentSkippedProvider {
|
|
1482
|
+
provider: string;
|
|
1483
|
+
name: string;
|
|
1484
|
+
capability?: string;
|
|
1485
|
+
/** What it would have added, in the agent's words. */
|
|
1486
|
+
adds?: string;
|
|
1487
|
+
reason: "terms_required";
|
|
1488
|
+
/** The gating terms version. */
|
|
1489
|
+
version: string;
|
|
1490
|
+
/** Where a person accepts the terms in the dashboard. */
|
|
1491
|
+
termsUrl: string;
|
|
1492
|
+
}
|
|
1493
|
+
|
|
1494
|
+
/**
|
|
1495
|
+
* The exact Exchange calls to view and accept a provider's terms. Nothing here
|
|
1496
|
+
* is executed for you, and terms/accept must only be called after the user
|
|
1497
|
+
* has explicitly agreed to that provider's terms.
|
|
1498
|
+
*/
|
|
1499
|
+
export interface AgentTermsRequiredAction {
|
|
1500
|
+
type: "accept_terms";
|
|
1501
|
+
/**
|
|
1502
|
+
* The `terms` pendingApproval that answers this. After the user agrees and
|
|
1503
|
+
* terms/accept succeeds, continue the thread with
|
|
1504
|
+
* `exchange.approve: { approvalId }`, or refuse with `decline`.
|
|
1505
|
+
*/
|
|
1506
|
+
approvalId: string;
|
|
1507
|
+
providers: {
|
|
1508
|
+
provider: string;
|
|
1509
|
+
name: string;
|
|
1510
|
+
capability?: string;
|
|
1511
|
+
adds?: string;
|
|
1512
|
+
version: string;
|
|
1513
|
+
/** null when the catalog published no digest; terms/show returns it. */
|
|
1514
|
+
digest: string | null;
|
|
1515
|
+
url: string;
|
|
1516
|
+
show: {
|
|
1517
|
+
provider: "firecrawl";
|
|
1518
|
+
capability: "terms/show";
|
|
1519
|
+
options: { provider: string };
|
|
1520
|
+
};
|
|
1521
|
+
accept: {
|
|
1522
|
+
provider: "firecrawl";
|
|
1523
|
+
capability: "terms/accept";
|
|
1524
|
+
options: {
|
|
1525
|
+
provider: string;
|
|
1526
|
+
version: string;
|
|
1527
|
+
/** null when the catalog published no digest; terms/show returns it. */
|
|
1528
|
+
digest: string | null;
|
|
1529
|
+
confirmed: true;
|
|
1530
|
+
};
|
|
1531
|
+
};
|
|
1532
|
+
}[];
|
|
1455
1533
|
}
|
|
1456
1534
|
|
|
1457
1535
|
/** Per-run summary reported on a status response. */
|
|
@@ -1460,8 +1538,26 @@ export interface AgentExchangeSummary {
|
|
|
1460
1538
|
/** What the run resolved to after thread inheritance, not what it requested. */
|
|
1461
1539
|
toolkits?: string[];
|
|
1462
1540
|
requireApproval?: boolean;
|
|
1541
|
+
onTermsRequired?: AgentOnTermsRequired;
|
|
1463
1542
|
paidCalls: number;
|
|
1464
1543
|
creditsUsed: number | null;
|
|
1544
|
+
/** Gated providers that would have helped and were not used. Any mode. */
|
|
1545
|
+
skippedProviders?: AgentSkippedProvider[];
|
|
1546
|
+
/** "ask" mode, when a terms offer ended the turn. */
|
|
1547
|
+
requiresAction?: AgentTermsRequiredAction;
|
|
1548
|
+
}
|
|
1549
|
+
|
|
1550
|
+
/** A provider in a `terms` pendingApproval. */
|
|
1551
|
+
export interface AgentTermsGate {
|
|
1552
|
+
provider: string;
|
|
1553
|
+
name: string;
|
|
1554
|
+
logo?: string;
|
|
1555
|
+
capability?: string;
|
|
1556
|
+
adds?: string;
|
|
1557
|
+
version: string;
|
|
1558
|
+
/** null when the catalog published no digest; terms/show returns it. */
|
|
1559
|
+
digest: string | null;
|
|
1560
|
+
url: string;
|
|
1465
1561
|
}
|
|
1466
1562
|
|
|
1467
1563
|
/** A follow-up the agent offers for the next turn of the thread. */
|
|
@@ -1470,26 +1566,52 @@ export interface AgentSuggestion {
|
|
|
1470
1566
|
prompt: string;
|
|
1471
1567
|
}
|
|
1472
1568
|
|
|
1473
|
-
/** A
|
|
1474
|
-
export interface
|
|
1569
|
+
/** A paid call a `calls` pendingApproval is holding back. */
|
|
1570
|
+
export interface PendingApprovalCall {
|
|
1571
|
+
id: string;
|
|
1572
|
+
provider: string;
|
|
1573
|
+
capability: string;
|
|
1574
|
+
input: Record<string, unknown>;
|
|
1575
|
+
more?: Record<string, unknown>[];
|
|
1576
|
+
creditsEstimate: number | null;
|
|
1577
|
+
}
|
|
1578
|
+
|
|
1579
|
+
interface PendingApprovalBase {
|
|
1475
1580
|
id: string;
|
|
1476
1581
|
reason: string;
|
|
1477
|
-
calls: {
|
|
1478
|
-
id: string;
|
|
1479
|
-
provider: string;
|
|
1480
|
-
capability: string;
|
|
1481
|
-
input: Record<string, unknown>;
|
|
1482
|
-
more?: Record<string, unknown>[];
|
|
1483
|
-
creditsEstimate: number | null;
|
|
1484
|
-
}[];
|
|
1485
1582
|
resolution: null | {
|
|
1486
1583
|
approved: boolean;
|
|
1584
|
+
/** Calls approved. Ignored on terms offers. */
|
|
1487
1585
|
callIds: string[];
|
|
1488
1586
|
always: boolean;
|
|
1489
1587
|
byRunId: string;
|
|
1490
1588
|
};
|
|
1491
1589
|
}
|
|
1492
1590
|
|
|
1591
|
+
/**
|
|
1592
|
+
* A turn that ended waiting for the caller to allow or refuse paid calls.
|
|
1593
|
+
* `kind` is absent on items written before terms offers existed.
|
|
1594
|
+
*/
|
|
1595
|
+
export interface PendingCallsApproval extends PendingApprovalBase {
|
|
1596
|
+
kind?: "calls";
|
|
1597
|
+
calls: PendingApprovalCall[];
|
|
1598
|
+
terms?: never;
|
|
1599
|
+
}
|
|
1600
|
+
|
|
1601
|
+
/**
|
|
1602
|
+
* A turn that ended waiting for the caller to accept providers' data terms
|
|
1603
|
+
* ("ask" mode). `calls` is always empty (typed `never[]` rather
|
|
1604
|
+
* than `[]` so existing `pendingApproval.calls[0]` code still compiles).
|
|
1605
|
+
*/
|
|
1606
|
+
export interface PendingTermsApproval extends PendingApprovalBase {
|
|
1607
|
+
kind: "terms";
|
|
1608
|
+
calls: never[];
|
|
1609
|
+
terms: AgentTermsGate[];
|
|
1610
|
+
}
|
|
1611
|
+
|
|
1612
|
+
/** Narrow on `kind === "terms"`. */
|
|
1613
|
+
export type PendingApproval = PendingCallsApproval | PendingTermsApproval;
|
|
1614
|
+
|
|
1493
1615
|
export interface AgentResponse {
|
|
1494
1616
|
success: boolean;
|
|
1495
1617
|
id: string;
|
|
@@ -1876,6 +1998,7 @@ export function parseRequiresAction(value: unknown): RequiresAction | undefined
|
|
|
1876
1998
|
}
|
|
1877
1999
|
|
|
1878
2000
|
export class SdkError extends Error {
|
|
2001
|
+
declare agent_hints?: string[];
|
|
1879
2002
|
requestId?: string;
|
|
1880
2003
|
status?: number;
|
|
1881
2004
|
code?: string;
|
|
@@ -1956,11 +2079,13 @@ export interface BrowserExecuteResponse {
|
|
|
1956
2079
|
stderr?: string;
|
|
1957
2080
|
exitCode?: number;
|
|
1958
2081
|
killed?: boolean;
|
|
2082
|
+
truncated?: boolean;
|
|
1959
2083
|
error?: string;
|
|
1960
2084
|
}
|
|
1961
2085
|
|
|
1962
2086
|
export interface BrowserDeleteResponse {
|
|
1963
2087
|
success: boolean;
|
|
2088
|
+
status?: string;
|
|
1964
2089
|
sessionDurationMs?: number;
|
|
1965
2090
|
creditsBilled?: number;
|
|
1966
2091
|
error?: string;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Keep response guidance as metadata when convenience methods unwrap data. */
|
|
2
|
+
export function agentHintMetadata(body: unknown): { agent_hints?: string[] } {
|
|
3
|
+
const hints = (body as { agent_hints?: unknown } | null)?.agent_hints;
|
|
4
|
+
return Array.isArray(hints) && hints.every((hint) => typeof hint === "string")
|
|
5
|
+
? { agent_hints: [...hints] }
|
|
6
|
+
: {};
|
|
7
|
+
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { type AxiosError, type AxiosResponse } from "axios";
|
|
2
2
|
import { SdkError, JobTimeoutError, parseRequiresAction } from "../types";
|
|
3
|
+
import { agentHintMetadata } from "./agentHints";
|
|
3
4
|
|
|
4
5
|
export function throwForBadResponse(resp: AxiosResponse, action: string): never {
|
|
5
6
|
const status = resp.status;
|
|
6
7
|
const body = resp.data || {};
|
|
7
8
|
const msg = body?.error || body?.message || `Request failed (${status}) while trying to ${action}`;
|
|
8
|
-
throw new SdkError(
|
|
9
|
+
throw Object.assign(new SdkError(
|
|
9
10
|
msg,
|
|
10
11
|
status,
|
|
11
12
|
body?.code,
|
|
@@ -13,7 +14,7 @@ export function throwForBadResponse(resp: AxiosResponse, action: string): never
|
|
|
13
14
|
undefined,
|
|
14
15
|
body?.chargeId,
|
|
15
16
|
parseRequiresAction(body?.requiresAction),
|
|
16
|
-
);
|
|
17
|
+
), agentHintMetadata(body));
|
|
17
18
|
}
|
|
18
19
|
|
|
19
20
|
export function normalizeAxiosError(err: AxiosError, action: string): never {
|
|
@@ -21,7 +22,7 @@ export function normalizeAxiosError(err: AxiosError, action: string): never {
|
|
|
21
22
|
const body: any = err.response?.data;
|
|
22
23
|
const message = body?.error || err.message || `Request failed${status ? ` (${status})` : ""} while trying to ${action}`;
|
|
23
24
|
const code = (body?.code as string) || err.code;
|
|
24
|
-
throw new SdkError(
|
|
25
|
+
throw Object.assign(new SdkError(
|
|
25
26
|
message,
|
|
26
27
|
status,
|
|
27
28
|
code,
|
|
@@ -29,7 +30,7 @@ export function normalizeAxiosError(err: AxiosError, action: string): never {
|
|
|
29
30
|
undefined,
|
|
30
31
|
body?.chargeId,
|
|
31
32
|
parseRequiresAction(body?.requiresAction),
|
|
32
|
-
);
|
|
33
|
+
), agentHintMetadata(body));
|
|
33
34
|
}
|
|
34
35
|
|
|
35
36
|
export function isRetryableError(err: any): boolean {
|
|
@@ -64,4 +65,3 @@ export function isRetryableError(err: any): boolean {
|
|
|
64
65
|
// Default: retry on unknown errors (safer than not retrying)
|
|
65
66
|
return true;
|
|
66
67
|
}
|
|
67
|
-
|