x402check-langchain 0.1.0__tar.gz

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,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 x402check
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the Software), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,39 @@
1
+ Metadata-Version: 2.4
2
+ Name: x402check-langchain
3
+ Version: 0.1.0
4
+ Summary: LangChain tools for x402check — preflight x402 seller endpoints (ok|caution|avoid) before an agent pays.
5
+ Author: x402check
6
+ License: MIT
7
+ Project-URL: Homepage, https://x402check.dev
8
+ Project-URL: Documentation, https://x402check.dev/llms.txt
9
+ Project-URL: Repository, https://github.com/nwilliams005/x402check
10
+ Keywords: x402,x402check,langchain,ai-agent,preflight,payto,base,usdc
11
+ Requires-Python: >=3.10
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Requires-Dist: httpx>=0.27
15
+ Requires-Dist: langchain-core>=0.3
16
+ Dynamic: license-file
17
+
18
+ # x402check-langchain (Python)
19
+
20
+ LangChain tools for [x402check](https://x402check.dev) — trust-check an x402 seller **before any payment**.
21
+
22
+ ```bash
23
+ pip install x402check-langchain
24
+ ```
25
+
26
+ ```python
27
+ from x402check_langchain import create_x402check_tools
28
+ import os
29
+ os.environ["X402CHECK_URL"] = "https://x402check.dev"
30
+ tools = create_x402check_tools()
31
+ ```
32
+
33
+ Tools: `preflight_check`, `verify_payto`, `compare_tools`.
34
+
35
+ Paid **$0.002 USDC Exact per tool URL** on Base. See https://x402check.dev/llms.txt
36
+
37
+ ## Note
38
+
39
+ This package is prepared for PyPI. Publishing requires a PyPI API token (not present in this environment).
@@ -0,0 +1,22 @@
1
+ # x402check-langchain (Python)
2
+
3
+ LangChain tools for [x402check](https://x402check.dev) — trust-check an x402 seller **before any payment**.
4
+
5
+ ```bash
6
+ pip install x402check-langchain
7
+ ```
8
+
9
+ ```python
10
+ from x402check_langchain import create_x402check_tools
11
+ import os
12
+ os.environ["X402CHECK_URL"] = "https://x402check.dev"
13
+ tools = create_x402check_tools()
14
+ ```
15
+
16
+ Tools: `preflight_check`, `verify_payto`, `compare_tools`.
17
+
18
+ Paid **$0.002 USDC Exact per tool URL** on Base. See https://x402check.dev/llms.txt
19
+
20
+ ## Note
21
+
22
+ This package is prepared for PyPI. Publishing requires a PyPI API token (not present in this environment).
@@ -0,0 +1,25 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "x402check-langchain"
7
+ version = "0.1.0"
8
+ description = "LangChain tools for x402check — preflight x402 seller endpoints (ok|caution|avoid) before an agent pays."
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ license = { text = "MIT" }
12
+ authors = [{ name = "x402check" }]
13
+ keywords = ["x402", "x402check", "langchain", "ai-agent", "preflight", "payto", "base", "usdc"]
14
+ dependencies = [
15
+ "httpx>=0.27",
16
+ "langchain-core>=0.3",
17
+ ]
18
+
19
+ [project.urls]
20
+ Homepage = "https://x402check.dev"
21
+ Documentation = "https://x402check.dev/llms.txt"
22
+ Repository = "https://github.com/nwilliams005/x402check"
23
+
24
+ [tool.setuptools.packages.find]
25
+ include = ["x402check_langchain*"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,129 @@
1
+ """LangChain tools for x402check (https://x402check.dev)."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import json
6
+ import os
7
+ from typing import Any, Optional, Sequence
8
+
9
+ import httpx
10
+ from langchain_core.tools import StructuredTool
11
+ from pydantic import BaseModel, Field
12
+
13
+ DEFAULT_BASE = "https://x402check.dev"
14
+
15
+
16
+ class PreflightInput(BaseModel):
17
+ url: str = Field(..., description="Absolute https URL of the x402 seller endpoint")
18
+ fresh: bool = Field(False, description="Force a live probe; ignore cache")
19
+
20
+
21
+ class CompareInput(BaseModel):
22
+ urls: list[str] = Field(..., description="Candidate seller URLs (max 25)")
23
+ fresh: bool = Field(False, description="Force a live probe")
24
+
25
+
26
+ def _base(base_url: Optional[str] = None) -> str:
27
+ return (base_url or os.environ.get("X402CHECK_URL") or DEFAULT_BASE).rstrip("/")
28
+
29
+
30
+ def preflight(
31
+ url: str,
32
+ *,
33
+ base_url: Optional[str] = None,
34
+ fresh: bool = False,
35
+ payment_headers: Optional[dict[str, str]] = None,
36
+ ) -> dict[str, Any]:
37
+ if os.environ.get("X402CHECK_SKIP") == "1":
38
+ return {"url": url, "verdict": "ok", "reasonCodes": ["preflight_skipped"], "history": {"checks": 0}}
39
+ params = {"url": url}
40
+ if fresh:
41
+ params["fresh"] = "1"
42
+ headers = {"accept": "application/json", **(payment_headers or {})}
43
+ with httpx.Client(timeout=30.0) as client:
44
+ res = client.get(f"{_base(base_url)}/preflight", params=params, headers=headers)
45
+ if res.status_code == 402:
46
+ raise RuntimeError("preflight_payment_required")
47
+ res.raise_for_status()
48
+ return res.json()
49
+
50
+
51
+ def preflight_batch(
52
+ urls: Sequence[str],
53
+ *,
54
+ base_url: Optional[str] = None,
55
+ fresh: bool = False,
56
+ payment_headers: Optional[dict[str, str]] = None,
57
+ ) -> dict[str, Any]:
58
+ headers = {
59
+ "accept": "application/json",
60
+ "content-type": "application/json",
61
+ **(payment_headers or {}),
62
+ }
63
+ with httpx.Client(timeout=60.0) as client:
64
+ res = client.post(
65
+ f"{_base(base_url)}/preflight",
66
+ headers=headers,
67
+ json={"urls": list(urls), "fresh": fresh},
68
+ )
69
+ if res.status_code == 402:
70
+ raise RuntimeError("preflight_payment_required")
71
+ res.raise_for_status()
72
+ return res.json()
73
+
74
+
75
+ def create_x402check_tools(
76
+ *,
77
+ base_url: Optional[str] = None,
78
+ payment_headers: Optional[dict[str, str]] = None,
79
+ ) -> list[StructuredTool]:
80
+ """Return LangChain StructuredTools: preflight_check, verify_payto, compare_tools."""
81
+
82
+ def _preflight(url: str, fresh: bool = False) -> str:
83
+ return json.dumps(preflight(url, base_url=base_url, fresh=fresh, payment_headers=payment_headers))
84
+
85
+ def _verify(url: str, fresh: bool = False) -> str:
86
+ check = preflight(url, base_url=base_url, fresh=fresh, payment_headers=payment_headers)
87
+ slim = {
88
+ "url": check.get("url"),
89
+ "verdict": check.get("verdict"),
90
+ "payTo": check.get("payTo"),
91
+ "priceUsd": check.get("priceUsd"),
92
+ "network": check.get("network"),
93
+ "reasonCodes": check.get("reasonCodes", []),
94
+ "payToChanges": (check.get("history") or {}).get("payToChanges", []),
95
+ "priceChanges": (check.get("history") or {}).get("priceChanges", []),
96
+ }
97
+ return json.dumps(slim)
98
+
99
+ def _compare(urls: list[str], fresh: bool = False) -> str:
100
+ return json.dumps(
101
+ preflight_batch(urls, base_url=base_url, fresh=fresh, payment_headers=payment_headers)
102
+ )
103
+
104
+ return [
105
+ StructuredTool.from_function(
106
+ func=_preflight,
107
+ name="preflight_check",
108
+ description=(
109
+ "Mandatory trust preflight before paying any x402 endpoint. "
110
+ "Returns verdict ok|caution|avoid plus history. Do not pay if avoid."
111
+ ),
112
+ args_schema=PreflightInput,
113
+ ),
114
+ StructuredTool.from_function(
115
+ func=_verify,
116
+ name="verify_payto",
117
+ description="Verify the payTo / receiving wallet an x402 seller demands before signing USDC on Base.",
118
+ args_schema=PreflightInput,
119
+ ),
120
+ StructuredTool.from_function(
121
+ func=_compare,
122
+ name="compare_tools",
123
+ description="Compare several x402 seller URLs before choosing which to pay.",
124
+ args_schema=CompareInput,
125
+ ),
126
+ ]
127
+
128
+
129
+ __all__ = ["preflight", "preflight_batch", "create_x402check_tools"]
@@ -0,0 +1,39 @@
1
+ Metadata-Version: 2.4
2
+ Name: x402check-langchain
3
+ Version: 0.1.0
4
+ Summary: LangChain tools for x402check — preflight x402 seller endpoints (ok|caution|avoid) before an agent pays.
5
+ Author: x402check
6
+ License: MIT
7
+ Project-URL: Homepage, https://x402check.dev
8
+ Project-URL: Documentation, https://x402check.dev/llms.txt
9
+ Project-URL: Repository, https://github.com/nwilliams005/x402check
10
+ Keywords: x402,x402check,langchain,ai-agent,preflight,payto,base,usdc
11
+ Requires-Python: >=3.10
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Requires-Dist: httpx>=0.27
15
+ Requires-Dist: langchain-core>=0.3
16
+ Dynamic: license-file
17
+
18
+ # x402check-langchain (Python)
19
+
20
+ LangChain tools for [x402check](https://x402check.dev) — trust-check an x402 seller **before any payment**.
21
+
22
+ ```bash
23
+ pip install x402check-langchain
24
+ ```
25
+
26
+ ```python
27
+ from x402check_langchain import create_x402check_tools
28
+ import os
29
+ os.environ["X402CHECK_URL"] = "https://x402check.dev"
30
+ tools = create_x402check_tools()
31
+ ```
32
+
33
+ Tools: `preflight_check`, `verify_payto`, `compare_tools`.
34
+
35
+ Paid **$0.002 USDC Exact per tool URL** on Base. See https://x402check.dev/llms.txt
36
+
37
+ ## Note
38
+
39
+ This package is prepared for PyPI. Publishing requires a PyPI API token (not present in this environment).
@@ -0,0 +1,9 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ x402check_langchain/__init__.py
5
+ x402check_langchain.egg-info/PKG-INFO
6
+ x402check_langchain.egg-info/SOURCES.txt
7
+ x402check_langchain.egg-info/dependency_links.txt
8
+ x402check_langchain.egg-info/requires.txt
9
+ x402check_langchain.egg-info/top_level.txt
@@ -0,0 +1,2 @@
1
+ httpx>=0.27
2
+ langchain-core>=0.3
@@ -0,0 +1 @@
1
+ x402check_langchain