osf-agentkit 0.1.0__py3-none-any.whl

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.
@@ -0,0 +1,234 @@
1
+ """OSF (Open Source Filings) action provider for Coinbase AgentKit.
2
+
3
+ Provenance-stamped "ground truth" tools for AI agents, each paid per call over
4
+ x402 (USDC on Base mainnet) using the agent's own EVM wallet:
5
+
6
+ * lookup_entity - resolve a company/person against authoritative public
7
+ registries (CMS NPI, GLEIF LEI, FDIC, SEC EDGAR)
8
+ * screen_entity - sanctions/watchlist screening by name (OFAC SDN, EU, UK)
9
+ * check_cve_exploited - is a CVE actively exploited (CISA KEV / EPSS / CVSS)
10
+
11
+ Every result carries a provenance URL to the authoritative primary source (and,
12
+ for sanctions, an audit receipt). Payment is automatic: on a 402 the x402 client
13
+ signs and settles the micropayment with the agent's wallet, then retries. Each
14
+ action is bounded by a per-call spend ceiling.
15
+
16
+ This is a single-file build of the osf-agentkit package.
17
+ """
18
+
19
+ from __future__ import annotations
20
+
21
+ import json
22
+ from typing import Any
23
+ from urllib.parse import quote
24
+
25
+ from pydantic import BaseModel, Field
26
+
27
+ from x402.clients.base import decode_x_payment_response
28
+ from x402.clients.requests import x402_requests
29
+
30
+ from coinbase_agentkit.action_providers.action_provider import ActionProvider
31
+ from coinbase_agentkit.action_providers.action_decorator import create_action
32
+ from coinbase_agentkit.network import Network
33
+ from coinbase_agentkit.wallet_providers.evm_wallet_provider import EvmWalletProvider
34
+
35
+
36
+ class LookupEntitySchema(BaseModel):
37
+ """Resolve a company or person against authoritative public registries."""
38
+
39
+ query: str = Field(
40
+ ...,
41
+ description=(
42
+ "An entity identifier for an exact match, OR a company/person name for "
43
+ "candidate matches. Accepted identifiers: US healthcare provider NPI "
44
+ "(10 digits), GLEIF LEI (20 chars), FDIC certificate number, or SEC EDGAR "
45
+ "CIK. Examples: 'Apple Inc', '254900XAWYYH4QOUWQ70' (LEI), '1174150262' (NPI)."
46
+ ),
47
+ )
48
+
49
+
50
+ class ScreenEntitySchema(BaseModel):
51
+ """Sanctions/watchlist screening of a single name."""
52
+
53
+ name: str = Field(
54
+ ...,
55
+ description=(
56
+ "Full name of the person or entity to screen against the OFAC SDN, EU "
57
+ "consolidated, and UK OFSI sanctions lists. Example: 'Vladimir Putin'."
58
+ ),
59
+ )
60
+
61
+
62
+ class CheckCveExploitedSchema(BaseModel):
63
+ """Check whether a CVE is actively exploited."""
64
+
65
+ cve_id: str = Field(
66
+ ...,
67
+ description=(
68
+ "A CVE identifier in canonical form 'CVE-YYYY-NNNN' (4+ digits in the "
69
+ "sequence number). Example: 'CVE-2021-44228' (Log4Shell)."
70
+ ),
71
+ )
72
+
73
+
74
+ # OSF settles on Base mainnet only.
75
+ SUPPORTED_NETWORKS = ["base-mainnet"]
76
+
77
+ DEFAULT_BASE_URL = "https://api.osf-master-server.com/x402"
78
+
79
+ # Per-action spend ceilings in atomic USDC (6 decimals: 1_000_000 = $1.00).
80
+ # Headroom over OSF's live prices (entity $0.01, sanctions $0.05, cve $0.02) so a
81
+ # modest price change does not break calls, while capping runaway spend. The
82
+ # x402 client refuses to pay more than this for the call.
83
+ _MAX_ENTITY_ATOMIC = 50_000 # $0.05 ceiling
84
+ _MAX_SCREEN_ATOMIC = 150_000 # $0.15 ceiling
85
+ _MAX_CVE_ATOMIC = 100_000 # $0.10 ceiling
86
+
87
+ _TIMEOUT_SECONDS = 30
88
+
89
+
90
+ class OSF(ActionProvider[EvmWalletProvider]):
91
+ """Paid access to OSF provenance-stamped government and scientific data.
92
+
93
+ Note: AgentKit derives each agent-facing action name as ``{ClassName}_{method}``,
94
+ so this class is named ``OSF`` to yield clean tool names like ``OSF_lookup_entity``.
95
+ """
96
+
97
+ def __init__(self, base_url: str = DEFAULT_BASE_URL) -> None:
98
+ super().__init__("osf", [])
99
+ self._base_url = base_url.rstrip("/")
100
+
101
+ def supports_network(self, network: Network) -> bool:
102
+ """OSF endpoints settle on Base mainnet."""
103
+ return network.network_id in SUPPORTED_NETWORKS
104
+
105
+ # ------------------------------------------------------------------ #
106
+ # internal: a single paid GET with automatic x402 settlement
107
+ # ------------------------------------------------------------------ #
108
+ def _paid_get(
109
+ self,
110
+ wallet_provider: EvmWalletProvider,
111
+ path: str,
112
+ max_value_atomic: int,
113
+ ) -> str:
114
+ try:
115
+ account = wallet_provider.to_signer()
116
+ session = x402_requests(account, max_value=max_value_atomic)
117
+ url = f"{self._base_url}{path}"
118
+ response = session.request(url=url, method="GET", timeout=_TIMEOUT_SECONDS)
119
+
120
+ payment = None
121
+ if "x-payment-response" in response.headers:
122
+ try:
123
+ proof = decode_x_payment_response(response.headers["x-payment-response"])
124
+ payment = {
125
+ "transaction": proof.get("transaction"),
126
+ "network": proof.get("network"),
127
+ "payer": proof.get("payer"),
128
+ }
129
+ except Exception:
130
+ payment = None
131
+
132
+ is_json = "application/json" in response.headers.get("content-type", "")
133
+ data = response.json() if is_json else response.text
134
+
135
+ out: dict[str, Any] = {
136
+ "success": response.status_code == 200,
137
+ "status": response.status_code,
138
+ "data": data,
139
+ }
140
+ if payment:
141
+ out["payment"] = payment
142
+ return json.dumps(out, indent=2)
143
+
144
+ except Exception as error: # noqa: BLE001 - surface a clean message to the agent
145
+ return json.dumps(
146
+ {
147
+ "success": False,
148
+ "error": str(error),
149
+ "hint": (
150
+ "Check the agent wallet holds USDC on Base mainnet and that "
151
+ "the per-call spend ceiling is high enough for the endpoint price."
152
+ ),
153
+ },
154
+ indent=2,
155
+ )
156
+
157
+ # ------------------------------------------------------------------ #
158
+ # actions
159
+ # ------------------------------------------------------------------ #
160
+ @create_action(
161
+ name="lookup_entity",
162
+ description=(
163
+ "Resolve and verify a company or person against authoritative public "
164
+ "registries: US healthcare providers (CMS NPI), global legal entities "
165
+ "(GLEIF LEI), US banks (FDIC), and SEC filers / public companies (EDGAR "
166
+ "CIK). Pass an identifier (NPI, LEI, FDIC cert, or CIK) for an exact "
167
+ "match, or a name for candidate matches. Returns legal name, status, "
168
+ "type, jurisdiction, key identifiers, and a provenance URL to the official "
169
+ "source. Use for KYC, KYB, counterparty due-diligence, provider "
170
+ "verification, and onboarding. Costs a small USDC micropayment per call "
171
+ "(paid automatically via x402 on Base)."
172
+ ),
173
+ schema=LookupEntitySchema,
174
+ )
175
+ def lookup_entity(self, wallet_provider: EvmWalletProvider, args: dict[str, Any]) -> str:
176
+ """Resolve an entity by identifier or name against public registries."""
177
+ q = quote(str(args["query"]), safe="")
178
+ return self._paid_get(wallet_provider, f"/identity/entity/{q}", _MAX_ENTITY_ATOMIC)
179
+
180
+ @create_action(
181
+ name="screen_entity",
182
+ description=(
183
+ "Sanctions and compliance screening of a single name against the OFAC SDN, "
184
+ "EU consolidated, and UK OFSI sanctions lists. Returns hit or no-hit, the "
185
+ "matched list, a provenance URL, and an audit receipt. Use for AML, KYC, "
186
+ "watchlist, and OFAC compliance checks before moving money or onboarding a "
187
+ "counterparty. Costs a small USDC micropayment per call (paid automatically "
188
+ "via x402 on Base)."
189
+ ),
190
+ schema=ScreenEntitySchema,
191
+ )
192
+ def screen_entity(self, wallet_provider: EvmWalletProvider, args: dict[str, Any]) -> str:
193
+ """Screen a name against OFAC/EU/UK sanctions lists."""
194
+ n = quote(str(args["name"]), safe="")
195
+ return self._paid_get(wallet_provider, f"/screen/sanctions/{n}", _MAX_SCREEN_ATOMIC)
196
+
197
+ @create_action(
198
+ name="check_cve_exploited",
199
+ description=(
200
+ "Check whether a CVE is being actively exploited in the wild. Returns its "
201
+ "presence on the US CISA Known Exploited Vulnerabilities (KEV) catalog, its "
202
+ "EPSS exploit-probability score, and its CVSS severity, each with a "
203
+ "provenance URL to the authoritative US government source. Use for "
204
+ "vulnerability management, patch prioritization, threat intelligence, and "
205
+ "DevSecOps triage. Costs a small USDC micropayment per call (paid "
206
+ "automatically via x402 on Base)."
207
+ ),
208
+ schema=CheckCveExploitedSchema,
209
+ )
210
+ def check_cve_exploited(self, wallet_provider: EvmWalletProvider, args: dict[str, Any]) -> str:
211
+ """Check whether a CVE is on CISA KEV / its EPSS + CVSS scores."""
212
+ c = quote(str(args["cve_id"]), safe="")
213
+ return self._paid_get(wallet_provider, f"/security/cve/{c}", _MAX_CVE_ATOMIC)
214
+
215
+
216
+ def osf_action_provider(base_url: str = DEFAULT_BASE_URL) -> "OSF":
217
+ """Create an OSF action provider (AgentKit factory convention).
218
+
219
+ Args:
220
+ base_url: Override the OSF base URL (defaults to the public mainnet API).
221
+
222
+ Returns:
223
+ An OSF provider exposing lookup_entity, screen_entity, and
224
+ check_cve_exploited (surfaced to the agent as OSF_lookup_entity, etc.).
225
+ """
226
+ return OSF(base_url=base_url)
227
+
228
+
229
+ # Backward-compatible alias.
230
+ OsfActionProvider = OSF
231
+
232
+
233
+ __all__ = ["OSF", "OsfActionProvider", "osf_action_provider"]
234
+ __version__ = "0.1.0"
@@ -0,0 +1,57 @@
1
+ Metadata-Version: 2.4
2
+ Name: osf-agentkit
3
+ Version: 0.1.0
4
+ Summary: Coinbase AgentKit action provider for OSF (Open Source Filings): provenance-stamped sanctions, entity, and CVE data for AI agents, paid per call over x402 (USDC on Base).
5
+ Project-URL: Homepage, https://api.osf-master-server.com
6
+ Project-URL: Source, https://github.com/onefreeman1337/osf-agentkit
7
+ Author: Corey Gallant
8
+ License: MIT
9
+ Keywords: agentkit,ai-agents,coinbase,cve,entity-resolution,kyb,kyc,ofac,provenance,sanctions,x402
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
18
+ Requires-Python: >=3.10
19
+ Requires-Dist: coinbase-agentkit>=0.7.0
20
+ Requires-Dist: x402<2.0.0,>=1.0.0
21
+ Description-Content-Type: text/markdown
22
+
23
+ # osf-agentkit
24
+
25
+ A [Coinbase AgentKit](https://github.com/coinbase/agentkit) action provider for **OSF (Open Source Filings)**: provenance-stamped, public-domain U.S. government and scientific data for AI agents, paid per call over **x402** (USDC on Base mainnet).
26
+
27
+ Three tools, each returning structured JSON with a provenance URL to the authoritative primary source:
28
+
29
+ - **OSF_lookup_entity** ($0.01) - resolve/verify a company or person against public registries (CMS NPI, GLEIF LEI, FDIC, SEC EDGAR). For KYC, KYB, counterparty due-diligence.
30
+ - **OSF_screen_entity** ($0.05) - sanctions screening against OFAC SDN, EU, and UK OFSI lists. Returns hit/no-hit, matched list, and an audit receipt. For AML/KYC.
31
+ - **OSF_check_cve_exploited** ($0.02) - is a CVE actively exploited (CISA KEV), plus EPSS probability and CVSS severity. For vulnerability management and DevSecOps.
32
+
33
+ Payment is automatic: on an HTTP 402 the x402 client signs and settles the USDC micropayment with the agent's own EVM wallet, then retries. Each action enforces a per-call spend ceiling.
34
+
35
+ ## Install
36
+
37
+ ```
38
+ pip install osf-agentkit
39
+ ```
40
+
41
+ ## Use
42
+
43
+ ```python
44
+ from coinbase_agentkit import AgentKit, AgentKitConfig
45
+ from osf_agentkit import osf_action_provider
46
+
47
+ agent_kit = AgentKit(AgentKitConfig(
48
+ wallet_provider=your_evm_wallet_provider,
49
+ action_providers=[osf_action_provider()],
50
+ ))
51
+ ```
52
+
53
+ The agent's wallet must hold USDC on Base mainnet. Learn more at the [OSF data marketplace](https://api.osf-master-server.com/mcp).
54
+
55
+ ## License
56
+
57
+ MIT
@@ -0,0 +1,4 @@
1
+ osf_agentkit/__init__.py,sha256=dULct-sDCqtA2V8YCQTdx25QIhqyXx3qGtDLSHkcdfk,9728
2
+ osf_agentkit-0.1.0.dist-info/METADATA,sha256=2_y8aVL9ykO5dmxW2dHyvcMMUvBgif407ApEvzGzFWk,2560
3
+ osf_agentkit-0.1.0.dist-info/WHEEL,sha256=mffPy8wBnZQn2VnJUU5jE99KsxaSfiyMHV9Yt0aLVxs,87
4
+ osf_agentkit-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.30.1
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any