firecrawl-sdk 1.17.0 → 1.17.3
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.
- checksums.yaml +4 -4
- data/README.md +20 -0
- data/lib/firecrawl/client.rb +9 -0
- data/lib/firecrawl/models/agent_exchange_options.rb +68 -0
- data/lib/firecrawl/models/agent_exchange_summary.rb +72 -0
- data/lib/firecrawl/models/agent_options.rb +7 -0
- data/lib/firecrawl/models/agent_pending_approval.rb +64 -0
- data/lib/firecrawl/models/agent_response.rb +4 -1
- data/lib/firecrawl/models/agent_status_response.rb +10 -1
- data/lib/firecrawl/models/parse_format.rb +36 -0
- data/lib/firecrawl/version.rb +1 -1
- data/lib/firecrawl.rb +4 -0
- metadata +6 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 02dbea25069649d09dd507af8b1e2fed0010c8c5d454ee04117261d3e8a2dbc0
|
|
4
|
+
data.tar.gz: c0b3d3596a2f68d8d26c976f707db9cbc407da5eda3f3d2b3547ed1affcace6f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c1875f25b8ccebed6d9af7f31a0941f777a9c46ff448cedb428c8440a26b8e25927683d7bd86ad0ad35d81c3a762121c8e7051f83f8bdcf1e85749aa7667650d
|
|
7
|
+
data.tar.gz: 40fef9f8bb7032e9fb3bc55695af46e716b243c885faf7088acd6d6a14834482ba1b070e9f28409d4b0925bc2a7511d34ce3c1341a746aa98467d352c5409de2
|
data/README.md
CHANGED
|
@@ -126,6 +126,15 @@ doc = client.parse(file,
|
|
|
126
126
|
puts doc.markdown
|
|
127
127
|
```
|
|
128
128
|
|
|
129
|
+
List the file formats the parse endpoint accepts. `available` is `false` for
|
|
130
|
+
formats the deployment can't currently handle (e.g. images when OCR is off).
|
|
131
|
+
|
|
132
|
+
```ruby
|
|
133
|
+
client.get_parse_formats.each do |f|
|
|
134
|
+
puts "#{f.format} (#{f.kind}) #{f.extensions.join(", ")} #{f.mime_types.join(", ")} available=#{f.available}"
|
|
135
|
+
end
|
|
136
|
+
```
|
|
137
|
+
|
|
129
138
|
### Crawl
|
|
130
139
|
|
|
131
140
|
```ruby
|
|
@@ -194,6 +203,17 @@ status = client.agent(
|
|
|
194
203
|
urls: ["https://example.com"]
|
|
195
204
|
))
|
|
196
205
|
puts status.data
|
|
206
|
+
|
|
207
|
+
# Use Alexandria data providers connected in the dashboard
|
|
208
|
+
status = client.agent(
|
|
209
|
+
Firecrawl::Models::AgentOptions.new(
|
|
210
|
+
prompt: "Find the work email of the CEO of example.com",
|
|
211
|
+
exchange: Firecrawl::Models::AgentExchangeOptions.new(
|
|
212
|
+
enabled: true,
|
|
213
|
+
toolkits: ["apollo"]
|
|
214
|
+
)
|
|
215
|
+
))
|
|
216
|
+
puts status.exchange&.paid_calls
|
|
197
217
|
```
|
|
198
218
|
|
|
199
219
|
### Usage & Metrics
|
data/lib/firecrawl/client.rb
CHANGED
|
@@ -195,6 +195,15 @@ module Firecrawl
|
|
|
195
195
|
Models::Document.new(data)
|
|
196
196
|
end
|
|
197
197
|
|
|
198
|
+
# Lists the file formats accepted by {#parse} on this deployment.
|
|
199
|
+
#
|
|
200
|
+
# @return [Array<Models::ParseFormat>]
|
|
201
|
+
def get_parse_formats
|
|
202
|
+
raw = @http.get("/v2/parse/formats")
|
|
203
|
+
formats = (raw["data"] || {})["formats"] || []
|
|
204
|
+
formats.map { |f| Models::ParseFormat.new(f) }
|
|
205
|
+
end
|
|
206
|
+
|
|
198
207
|
# ================================================================
|
|
199
208
|
# CRAWL
|
|
200
209
|
# ================================================================
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Firecrawl
|
|
4
|
+
module Models
|
|
5
|
+
# Alexandria (Exchange) options for an agent run, forwarded verbatim; the
|
|
6
|
+
# server owns every default and limit. On a follow-up turn, omitting the
|
|
7
|
+
# exchange options inherits the previous turn's settings.
|
|
8
|
+
#
|
|
9
|
+
# on_terms_required: "skip" or "ask".
|
|
10
|
+
class AgentExchangeOptions
|
|
11
|
+
# Answers the previous turn's pending approval. A "terms" approval is
|
|
12
|
+
# accepted as a whole, so call_ids and always are ignored on it.
|
|
13
|
+
class Approve
|
|
14
|
+
attr_reader :approval_id, :call_ids, :always
|
|
15
|
+
|
|
16
|
+
def initialize(approval_id:, call_ids: nil, always: nil)
|
|
17
|
+
@approval_id = approval_id
|
|
18
|
+
@call_ids = call_ids
|
|
19
|
+
@always = always
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def to_h
|
|
23
|
+
{
|
|
24
|
+
"approvalId" => approval_id,
|
|
25
|
+
"callIds" => call_ids,
|
|
26
|
+
"always" => always,
|
|
27
|
+
}.compact
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# Refuses the previous turn's pending approval.
|
|
32
|
+
class Decline
|
|
33
|
+
attr_reader :approval_id
|
|
34
|
+
|
|
35
|
+
def initialize(approval_id:)
|
|
36
|
+
@approval_id = approval_id
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def to_h
|
|
40
|
+
{ "approvalId" => approval_id }
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
FIELDS = %i[
|
|
45
|
+
enabled toolkits max_calls require_approval approve decline
|
|
46
|
+
on_terms_required
|
|
47
|
+
].freeze
|
|
48
|
+
|
|
49
|
+
attr_reader(*FIELDS)
|
|
50
|
+
|
|
51
|
+
def initialize(**kwargs)
|
|
52
|
+
FIELDS.each { |f| instance_variable_set(:"@#{f}", kwargs[f]) }
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def to_h
|
|
56
|
+
{
|
|
57
|
+
"enabled" => enabled,
|
|
58
|
+
"toolkits" => toolkits,
|
|
59
|
+
"maxCalls" => max_calls,
|
|
60
|
+
"requireApproval" => require_approval,
|
|
61
|
+
"approve" => approve&.to_h,
|
|
62
|
+
"decline" => decline&.to_h,
|
|
63
|
+
"onTermsRequired" => on_terms_required,
|
|
64
|
+
}.compact
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Firecrawl
|
|
4
|
+
module Models
|
|
5
|
+
# What an agent run did with Alexandria (Exchange). toolkits and
|
|
6
|
+
# require_approval are what the run resolved to after thread inheritance.
|
|
7
|
+
class AgentExchangeSummary
|
|
8
|
+
# A provider that needs data terms the team has not accepted, so the run
|
|
9
|
+
# did not use it.
|
|
10
|
+
class SkippedProvider
|
|
11
|
+
attr_reader :provider, :name, :capability, :adds, :reason, :version,
|
|
12
|
+
:terms_url
|
|
13
|
+
|
|
14
|
+
def initialize(data)
|
|
15
|
+
@provider = data["provider"]
|
|
16
|
+
@name = data["name"]
|
|
17
|
+
@capability = data["capability"]
|
|
18
|
+
@adds = data["adds"]
|
|
19
|
+
@reason = data["reason"]
|
|
20
|
+
@version = data["version"]
|
|
21
|
+
@terms_url = data["termsUrl"]
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# The Exchange calls to view and accept providers' terms ("ask" mode).
|
|
26
|
+
# Nothing here runs for you; only call accept after your user agrees.
|
|
27
|
+
class TermsRequiredAction
|
|
28
|
+
# show and accept are the raw Exchange calls ("provider",
|
|
29
|
+
# "capability", "options").
|
|
30
|
+
class Provider
|
|
31
|
+
attr_reader :provider, :name, :capability, :adds, :version, :digest,
|
|
32
|
+
:url, :show, :accept
|
|
33
|
+
|
|
34
|
+
def initialize(data)
|
|
35
|
+
@provider = data["provider"]
|
|
36
|
+
@name = data["name"]
|
|
37
|
+
@capability = data["capability"]
|
|
38
|
+
@adds = data["adds"]
|
|
39
|
+
@version = data["version"]
|
|
40
|
+
@digest = data["digest"]
|
|
41
|
+
@url = data["url"]
|
|
42
|
+
@show = data["show"]
|
|
43
|
+
@accept = data["accept"]
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
attr_reader :type, :approval_id, :providers
|
|
48
|
+
|
|
49
|
+
def initialize(data)
|
|
50
|
+
@type = data["type"]
|
|
51
|
+
@approval_id = data["approvalId"]
|
|
52
|
+
@providers = data["providers"]&.map { |p| Provider.new(p) }
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
attr_reader :enabled, :toolkits, :require_approval, :on_terms_required,
|
|
57
|
+
:paid_calls, :credits_used, :skipped_providers,
|
|
58
|
+
:requires_action
|
|
59
|
+
|
|
60
|
+
def initialize(data)
|
|
61
|
+
@enabled = data["enabled"]
|
|
62
|
+
@toolkits = data["toolkits"]
|
|
63
|
+
@require_approval = data["requireApproval"]
|
|
64
|
+
@on_terms_required = data["onTermsRequired"]
|
|
65
|
+
@paid_calls = data["paidCalls"]
|
|
66
|
+
@credits_used = data["creditsUsed"]
|
|
67
|
+
@skipped_providers = data["skippedProviders"]&.map { |p| SkippedProvider.new(p) }
|
|
68
|
+
@requires_action = data["requiresAction"] && TermsRequiredAction.new(data["requiresAction"])
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|
|
@@ -6,10 +6,14 @@ module Firecrawl
|
|
|
6
6
|
#
|
|
7
7
|
# effort: valid values are "low", "medium", and "high"; sets the reasoning
|
|
8
8
|
# budget for the run (every level runs spark-2).
|
|
9
|
+
#
|
|
10
|
+
# thread_id continues an existing thread as its next turn; omitted starts a
|
|
11
|
+
# new thread. mode: "extract" or "chat".
|
|
9
12
|
class AgentOptions
|
|
10
13
|
FIELDS = %i[
|
|
11
14
|
urls prompt schema integration max_credits
|
|
12
15
|
strict_constrain_to_urls model effort webhook audit_metadata
|
|
16
|
+
thread_id mode exchange
|
|
13
17
|
].freeze
|
|
14
18
|
|
|
15
19
|
attr_reader(*FIELDS)
|
|
@@ -34,6 +38,9 @@ module Firecrawl
|
|
|
34
38
|
"effort" => effort,
|
|
35
39
|
"webhook" => webhook.is_a?(Hash) ? webhook : webhook&.to_h,
|
|
36
40
|
"auditMetadata" => audit_metadata&.to_h,
|
|
41
|
+
"threadId" => thread_id,
|
|
42
|
+
"mode" => mode,
|
|
43
|
+
"exchange" => exchange&.to_h,
|
|
37
44
|
}.compact
|
|
38
45
|
end
|
|
39
46
|
end
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Firecrawl
|
|
4
|
+
module Models
|
|
5
|
+
# A turn that ended waiting for the caller. kind "calls" (or nil on older
|
|
6
|
+
# runs) holds paid calls to allow or refuse; kind "terms" lists providers
|
|
7
|
+
# whose data terms need accepting, with calls empty. Answer it on the next
|
|
8
|
+
# turn of the thread with AgentExchangeOptions approve or decline.
|
|
9
|
+
class AgentPendingApproval
|
|
10
|
+
# input and more are the raw call arguments.
|
|
11
|
+
class Call
|
|
12
|
+
attr_reader :id, :provider, :capability, :input, :more,
|
|
13
|
+
:credits_estimate
|
|
14
|
+
|
|
15
|
+
def initialize(data)
|
|
16
|
+
@id = data["id"]
|
|
17
|
+
@provider = data["provider"]
|
|
18
|
+
@capability = data["capability"]
|
|
19
|
+
@input = data["input"]
|
|
20
|
+
@more = data["more"]
|
|
21
|
+
@credits_estimate = data["creditsEstimate"]
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
class TermsGate
|
|
26
|
+
attr_reader :provider, :name, :logo, :capability, :adds, :version,
|
|
27
|
+
:digest, :url
|
|
28
|
+
|
|
29
|
+
def initialize(data)
|
|
30
|
+
@provider = data["provider"]
|
|
31
|
+
@name = data["name"]
|
|
32
|
+
@logo = data["logo"]
|
|
33
|
+
@capability = data["capability"]
|
|
34
|
+
@adds = data["adds"]
|
|
35
|
+
@version = data["version"]
|
|
36
|
+
@digest = data["digest"]
|
|
37
|
+
@url = data["url"]
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
class Resolution
|
|
42
|
+
attr_reader :approved, :call_ids, :always, :by_run_id
|
|
43
|
+
|
|
44
|
+
def initialize(data)
|
|
45
|
+
@approved = data["approved"]
|
|
46
|
+
@call_ids = data["callIds"]
|
|
47
|
+
@always = data["always"]
|
|
48
|
+
@by_run_id = data["byRunId"]
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
attr_reader :id, :kind, :reason, :calls, :terms, :resolution
|
|
53
|
+
|
|
54
|
+
def initialize(data)
|
|
55
|
+
@id = data["id"]
|
|
56
|
+
@kind = data["kind"]
|
|
57
|
+
@reason = data["reason"]
|
|
58
|
+
@calls = data["calls"]&.map { |c| Call.new(c) }
|
|
59
|
+
@terms = data["terms"]&.map { |t| TermsGate.new(t) }
|
|
60
|
+
@resolution = data["resolution"] && Resolution.new(data["resolution"])
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
@@ -4,12 +4,15 @@ module Firecrawl
|
|
|
4
4
|
module Models
|
|
5
5
|
# Response from starting an agent task.
|
|
6
6
|
class AgentResponse
|
|
7
|
-
attr_reader :success, :id, :error
|
|
7
|
+
attr_reader :success, :id, :error, :thread_id, :thread_turn
|
|
8
8
|
|
|
9
9
|
def initialize(data)
|
|
10
10
|
@success = data["success"]
|
|
11
11
|
@id = data["id"]
|
|
12
12
|
@error = data["error"]
|
|
13
|
+
# Pass thread_id back in AgentOptions to continue the conversation.
|
|
14
|
+
@thread_id = data["threadId"]
|
|
15
|
+
@thread_turn = data["threadTurn"]
|
|
13
16
|
end
|
|
14
17
|
|
|
15
18
|
def to_s
|
|
@@ -4,7 +4,9 @@ module Firecrawl
|
|
|
4
4
|
module Models
|
|
5
5
|
# Status response for monitoring agent tasks.
|
|
6
6
|
class AgentStatusResponse
|
|
7
|
-
attr_reader :status, :data, :credits_used, :expires_at, :effort
|
|
7
|
+
attr_reader :status, :data, :credits_used, :expires_at, :effort,
|
|
8
|
+
:thread_id, :thread_turn, :mode, :message, :pending_approval,
|
|
9
|
+
:exchange
|
|
8
10
|
|
|
9
11
|
def initialize(raw)
|
|
10
12
|
@status = raw["status"]
|
|
@@ -13,6 +15,13 @@ module Firecrawl
|
|
|
13
15
|
@expires_at = raw["expiresAt"]
|
|
14
16
|
# The effort the job ran with; only present for runs that specified it.
|
|
15
17
|
@effort = raw["effort"]
|
|
18
|
+
@thread_id = raw["threadId"]
|
|
19
|
+
@thread_turn = raw["threadTurn"]
|
|
20
|
+
@mode = raw["mode"]
|
|
21
|
+
# Chat-mode runs answer here instead of in data.
|
|
22
|
+
@message = raw["message"]
|
|
23
|
+
@pending_approval = raw["pendingApproval"] && AgentPendingApproval.new(raw["pendingApproval"])
|
|
24
|
+
@exchange = raw["exchange"] && AgentExchangeSummary.new(raw["exchange"])
|
|
16
25
|
end
|
|
17
26
|
|
|
18
27
|
def done?
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Firecrawl
|
|
4
|
+
module Models
|
|
5
|
+
# A file format accepted by the `/v2/parse` endpoint.
|
|
6
|
+
#
|
|
7
|
+
# `kind` is usually one of {KIND_DOCUMENT} or {KIND_IMAGE}, but newer API
|
|
8
|
+
# versions may return other values, which are kept as-is.
|
|
9
|
+
class ParseFormat
|
|
10
|
+
KIND_DOCUMENT = "document"
|
|
11
|
+
KIND_IMAGE = "image"
|
|
12
|
+
|
|
13
|
+
attr_reader :format, :kind, :extensions, :mime_types, :available
|
|
14
|
+
|
|
15
|
+
def initialize(data)
|
|
16
|
+
@format = data["format"]
|
|
17
|
+
@kind = data["kind"]
|
|
18
|
+
@extensions = data["extensions"] || []
|
|
19
|
+
@mime_types = data["mimeTypes"] || []
|
|
20
|
+
@available = data["available"]
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def document?
|
|
24
|
+
kind == KIND_DOCUMENT
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def image?
|
|
28
|
+
kind == KIND_IMAGE
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def to_s
|
|
32
|
+
"ParseFormat{format=#{format}, kind=#{kind}, available=#{available}}"
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
data/lib/firecrawl/version.rb
CHANGED
data/lib/firecrawl.rb
CHANGED
|
@@ -22,9 +22,13 @@ require_relative "firecrawl/models/search_options"
|
|
|
22
22
|
require_relative "firecrawl/models/search_data"
|
|
23
23
|
require_relative "firecrawl/models/parse_file"
|
|
24
24
|
require_relative "firecrawl/models/parse_options"
|
|
25
|
+
require_relative "firecrawl/models/parse_format"
|
|
26
|
+
require_relative "firecrawl/models/agent_exchange_options"
|
|
25
27
|
require_relative "firecrawl/models/agent_options"
|
|
26
28
|
require_relative "firecrawl/models/agent_response"
|
|
27
29
|
require_relative "firecrawl/models/agent_list_response"
|
|
30
|
+
require_relative "firecrawl/models/agent_exchange_summary"
|
|
31
|
+
require_relative "firecrawl/models/agent_pending_approval"
|
|
28
32
|
require_relative "firecrawl/models/agent_status_response"
|
|
29
33
|
require_relative "firecrawl/models/agent_trace_response"
|
|
30
34
|
require_relative "firecrawl/models/agent_snapshot_response"
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: firecrawl-sdk
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.17.
|
|
4
|
+
version: 1.17.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Firecrawl
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-10-06 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: A type-safe Ruby client for the Firecrawl v2 API. Supports scraping,
|
|
14
14
|
crawling, batch scraping, URL mapping, web search, and AI agent operations.
|
|
@@ -24,8 +24,11 @@ files:
|
|
|
24
24
|
- lib/firecrawl/client.rb
|
|
25
25
|
- lib/firecrawl/errors.rb
|
|
26
26
|
- lib/firecrawl/http_client.rb
|
|
27
|
+
- lib/firecrawl/models/agent_exchange_options.rb
|
|
28
|
+
- lib/firecrawl/models/agent_exchange_summary.rb
|
|
27
29
|
- lib/firecrawl/models/agent_list_response.rb
|
|
28
30
|
- lib/firecrawl/models/agent_options.rb
|
|
31
|
+
- lib/firecrawl/models/agent_pending_approval.rb
|
|
29
32
|
- lib/firecrawl/models/agent_response.rb
|
|
30
33
|
- lib/firecrawl/models/agent_snapshot_response.rb
|
|
31
34
|
- lib/firecrawl/models/agent_status_response.rb
|
|
@@ -45,6 +48,7 @@ files:
|
|
|
45
48
|
- lib/firecrawl/models/menu_profile.rb
|
|
46
49
|
- lib/firecrawl/models/monitor.rb
|
|
47
50
|
- lib/firecrawl/models/parse_file.rb
|
|
51
|
+
- lib/firecrawl/models/parse_format.rb
|
|
48
52
|
- lib/firecrawl/models/parse_options.rb
|
|
49
53
|
- lib/firecrawl/models/pdf_parser.rb
|
|
50
54
|
- lib/firecrawl/models/product_profile.rb
|