ahn-client 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.
- ahn_client/__init__.py +21 -0
- ahn_client/_classify.py +92 -0
- ahn_client/_client.py +108 -0
- ahn_client/_hosts.py +82 -0
- ahn_client/_result.py +148 -0
- ahn_client/py.typed +0 -0
- ahn_client-0.1.0.dist-info/METADATA +98 -0
- ahn_client-0.1.0.dist-info/RECORD +10 -0
- ahn_client-0.1.0.dist-info/WHEEL +4 -0
- ahn_client-0.1.0.dist-info/licenses/LICENSE +202 -0
ahn_client/__init__.py
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"""ahn-client: ask Agent Help Network what a host declares and recommends when a web step is blocked.
|
|
2
|
+
|
|
3
|
+
Agent Help Network is an independent project, not an official service of OpenAI, Meta,
|
|
4
|
+
Muse, dots or any site it describes. This client only reads; it never reports.
|
|
5
|
+
|
|
6
|
+
import ahn_client as ahn
|
|
7
|
+
|
|
8
|
+
try:
|
|
9
|
+
page.goto(url)
|
|
10
|
+
except Exception as exc:
|
|
11
|
+
answer = ahn.check(url, *ahn.classify(exc))
|
|
12
|
+
if answer:
|
|
13
|
+
print(answer.summary())
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
from ._classify import classify
|
|
17
|
+
from ._client import check, clear_cache
|
|
18
|
+
from ._result import Result
|
|
19
|
+
|
|
20
|
+
__version__ = "0.1.0"
|
|
21
|
+
__all__ = ["check", "classify", "clear_cache", "Result", "__version__"]
|
ahn_client/_classify.py
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"""Map an exception or an error message to the lookup's error_class and failure_stage.
|
|
2
|
+
|
|
3
|
+
The text rules are those of plugins/claude-code/ahn/hooks/ahn_lookup.py. On top of them
|
|
4
|
+
this module reads exception class names (as strings, so Playwright, httpx, requests and
|
|
5
|
+
aiohttp are never imported) and an HTTP status carried on the exception.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
import re
|
|
11
|
+
from typing import Optional, Tuple
|
|
12
|
+
|
|
13
|
+
from ._hosts import normalize_host
|
|
14
|
+
|
|
15
|
+
URL_IN_TEXT = re.compile(r"https?://[^\s'\"<>()\[\]{}`]+", re.IGNORECASE)
|
|
16
|
+
CLASSES = (
|
|
17
|
+
("human_verification", re.compile(r"captcha|verify (?:that )?you are (?:a )?human|are you a robot|challenge|cloudflare", re.I)),
|
|
18
|
+
("login_auth", re.compile(r"log[ -]?in\b|sign[ -]?in\b|unauthori[sz]ed|\b401\b|\bauthenticat(?:e|ion)\b", re.I)),
|
|
19
|
+
("service_error", re.compile(r"\b5\d\d\b|time ?out|timed ?out|unavailable|reset|bad gateway", re.I)),
|
|
20
|
+
)
|
|
21
|
+
BEFORE_RESPONSE = re.compile(r"connection refused|could not resolve|timed ?out|ENOTFOUND|ECONNREFUSED|getaddrinfo"
|
|
22
|
+
r"|is unable to fetch from"
|
|
23
|
+
# Chromium's net:: errors, as Playwright and Puppeteer report them.
|
|
24
|
+
r"|ERR_NAME_NOT_RESOLVED|ERR_CONNECTION_(?:REFUSED|TIMED_OUT)|ERR_INTERNET_DISCONNECTED",
|
|
25
|
+
re.I)
|
|
26
|
+
# Exception class names that say no connection to the target was made.
|
|
27
|
+
CONNECT_NAMES = frozenset({"connecterror", "connecttimeout", "connecttimeouterror", "connectionerror", "connectionrefusederror",
|
|
28
|
+
"newconnectionerror", "nameresolutionerror", "gaierror", "dnserror", "clientconnectorerror",
|
|
29
|
+
"clientconnectorcertificateerror", "clientconnectordnserror"})
|
|
30
|
+
|
|
31
|
+
ERROR_CLASSES = ("site_access", "login_auth", "human_verification", "service_error")
|
|
32
|
+
FAILURE_STAGES = ("before_target_response", "response_observed", "access_denial_observed", "unknown")
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def without_urls(text: str) -> str:
|
|
36
|
+
"""Replace each URL by its hostname so paths and queries never shape the classification."""
|
|
37
|
+
return URL_IN_TEXT.sub(lambda match: normalize_host(match.group(0)) or "", text)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def classify_text(text: str) -> Tuple[str, Optional[str]]:
|
|
41
|
+
text = without_urls(text or "")
|
|
42
|
+
error_class = next((name for name, pattern in CLASSES if pattern.search(text)), "site_access")
|
|
43
|
+
stage = "before_target_response" if BEFORE_RESPONSE.search(text) else None
|
|
44
|
+
return error_class, stage
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def _status(exc: BaseException) -> Optional[int]:
|
|
48
|
+
"""An HTTP error status (400-599) carried by the exception: httpx/requests .response, aiohttp .status."""
|
|
49
|
+
response = getattr(exc, "response", None)
|
|
50
|
+
for holder, names in ((exc, ("status_code", "status")), (response, ("status_code", "status"))):
|
|
51
|
+
if holder is None:
|
|
52
|
+
continue
|
|
53
|
+
for name in names:
|
|
54
|
+
code = getattr(holder, name, None)
|
|
55
|
+
if isinstance(code, int) and not isinstance(code, bool) and 400 <= code <= 599:
|
|
56
|
+
return code
|
|
57
|
+
return None
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def _chain(exc: BaseException):
|
|
61
|
+
seen = []
|
|
62
|
+
while exc is not None and exc not in seen and len(seen) < 3:
|
|
63
|
+
seen.append(exc)
|
|
64
|
+
exc = exc.__cause__ or exc.__context__
|
|
65
|
+
return seen
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def classify(exc_or_text) -> Tuple[str, Optional[str]]:
|
|
69
|
+
"""``(error_class, failure_stage)`` for an exception object or a message.
|
|
70
|
+
|
|
71
|
+
error_class is one of human_verification, login_auth, service_error, site_access;
|
|
72
|
+
failure_stage is before_target_response, response_observed or None. Only the
|
|
73
|
+
exception's class names, its message and its HTTP status are read. URLs in messages
|
|
74
|
+
are reduced to their hostnames, so a path or query never influences the answer.
|
|
75
|
+
"""
|
|
76
|
+
if isinstance(exc_or_text, BaseException):
|
|
77
|
+
chain = _chain(exc_or_text)
|
|
78
|
+
names = [type(item).__name__ for item in chain]
|
|
79
|
+
status = _status(exc_or_text)
|
|
80
|
+
text = " ".join(names + [str(item) for item in chain])
|
|
81
|
+
if status:
|
|
82
|
+
text += f" HTTP {status}"
|
|
83
|
+
error_class, stage = classify_text(text)
|
|
84
|
+
if stage is None:
|
|
85
|
+
if any(name.lower() in CONNECT_NAMES for name in names):
|
|
86
|
+
stage = "before_target_response"
|
|
87
|
+
elif status:
|
|
88
|
+
stage = "response_observed"
|
|
89
|
+
return error_class, stage
|
|
90
|
+
if isinstance(exc_or_text, bytes):
|
|
91
|
+
exc_or_text = exc_or_text.decode("utf-8", errors="replace")
|
|
92
|
+
return classify_text(exc_or_text if isinstance(exc_or_text, str) else "")
|
ahn_client/_client.py
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"""The lookup call: one GET with a hostname and two enum codes, never an exception."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import json
|
|
6
|
+
import threading
|
|
7
|
+
import time
|
|
8
|
+
import urllib.parse
|
|
9
|
+
import urllib.request
|
|
10
|
+
from typing import Dict, Optional, Tuple
|
|
11
|
+
|
|
12
|
+
from ._classify import ERROR_CLASSES, FAILURE_STAGES
|
|
13
|
+
from ._hosts import eligible_host
|
|
14
|
+
from ._result import Result
|
|
15
|
+
|
|
16
|
+
__all__ = ["check", "clear_cache", "lookup_url"]
|
|
17
|
+
|
|
18
|
+
API_URL = "https://agenthelpnetwork.com/v1/incidents/check"
|
|
19
|
+
USER_AGENT = "ahn-client/0.1 (+https://agenthelpnetwork.com)"
|
|
20
|
+
CACHE_TTL_SECONDS = 600
|
|
21
|
+
FAILURE_TTL_SECONDS = 60
|
|
22
|
+
CACHE_MAX_ENTRIES = 200
|
|
23
|
+
MAX_RESPONSE_BYTES = 262_144
|
|
24
|
+
|
|
25
|
+
_cache: Dict[Tuple[str, Optional[str], Optional[str]], Tuple[float, Optional[Result]]] = {}
|
|
26
|
+
_lock = threading.Lock()
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class _NoRedirect(urllib.request.HTTPRedirectHandler):
|
|
30
|
+
def redirect_request(self, *args, **kwargs):
|
|
31
|
+
return None
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
_opener = urllib.request.build_opener(_NoRedirect)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def _urlopen(request, timeout):
|
|
38
|
+
return _opener.open(request, timeout=timeout)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def clear_cache() -> None:
|
|
42
|
+
"""Forget every cached answer."""
|
|
43
|
+
with _lock:
|
|
44
|
+
_cache.clear()
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def lookup_url(host: str, error_class: Optional[str], failure_stage: Optional[str]) -> str:
|
|
48
|
+
query = {"site_host": host}
|
|
49
|
+
if error_class:
|
|
50
|
+
query["error_class"] = error_class
|
|
51
|
+
if failure_stage:
|
|
52
|
+
query["failure_stage"] = failure_stage
|
|
53
|
+
return API_URL + "?" + urllib.parse.urlencode(query)
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def _fetch(host: str, error_class: Optional[str], failure_stage: Optional[str], timeout: float) -> Optional[Result]:
|
|
57
|
+
url = lookup_url(host, error_class, failure_stage)
|
|
58
|
+
request = urllib.request.Request(url, headers={"User-Agent": USER_AGENT, "Accept": "application/json"})
|
|
59
|
+
try:
|
|
60
|
+
with _urlopen(request, timeout) as response:
|
|
61
|
+
if getattr(response, "status", 200) != 200:
|
|
62
|
+
return None
|
|
63
|
+
body = response.read(MAX_RESPONSE_BYTES + 1)
|
|
64
|
+
if len(body) > MAX_RESPONSE_BYTES:
|
|
65
|
+
return None
|
|
66
|
+
return Result.from_response(host, url, json.loads(body.decode("utf-8")))
|
|
67
|
+
except Exception: # Network, TLS, HTTP status, JSON: all mean "no answer", never an exception for the caller.
|
|
68
|
+
return None
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def check(host_or_url, error_class: Optional[str] = None, failure_stage: Optional[str] = None, *,
|
|
72
|
+
timeout: float = 4.0) -> Optional[Result]:
|
|
73
|
+
"""Ask Agent Help Network about the host of ``host_or_url``; None when there is no answer.
|
|
74
|
+
|
|
75
|
+
Only the bare hostname, ``error_class`` and ``failure_stage`` are sent: scheme,
|
|
76
|
+
credentials, port, path, query and fragment are dropped first. Nothing is requested
|
|
77
|
+
(None comes back) for local, private, special-use, IP-literal, single-label hosts,
|
|
78
|
+
for agenthelpnetwork.com itself, for hosts listed in ``AHN_CLIENT_SKIP_HOSTS``, when
|
|
79
|
+
``AHN_CLIENT_DISABLE=1``, or when ``error_class`` / ``failure_stage`` is not one of
|
|
80
|
+
the service's values. Network errors, timeouts and unreadable answers also give None;
|
|
81
|
+
this function does not raise. Answers are cached in memory for 10 minutes per host,
|
|
82
|
+
error class and stage (a failed lookup for 1 minute).
|
|
83
|
+
"""
|
|
84
|
+
try:
|
|
85
|
+
if error_class is not None and error_class not in ERROR_CLASSES:
|
|
86
|
+
return None
|
|
87
|
+
if failure_stage is not None and failure_stage not in FAILURE_STAGES:
|
|
88
|
+
return None
|
|
89
|
+
host = eligible_host(host_or_url)
|
|
90
|
+
if host is None:
|
|
91
|
+
return None
|
|
92
|
+
key = (host, error_class, failure_stage)
|
|
93
|
+
now = time.monotonic()
|
|
94
|
+
with _lock:
|
|
95
|
+
hit = _cache.get(key)
|
|
96
|
+
if hit and hit[0] > now:
|
|
97
|
+
return hit[1]
|
|
98
|
+
result = _fetch(host, error_class, failure_stage, timeout)
|
|
99
|
+
now = time.monotonic()
|
|
100
|
+
with _lock:
|
|
101
|
+
for stale in [k for k, (expires, _) in _cache.items() if expires <= now]:
|
|
102
|
+
del _cache[stale]
|
|
103
|
+
if len(_cache) >= CACHE_MAX_ENTRIES:
|
|
104
|
+
del _cache[min(_cache, key=lambda k: _cache[k][0])]
|
|
105
|
+
_cache[key] = (now + (CACHE_TTL_SECONDS if result else FAILURE_TTL_SECONDS), result)
|
|
106
|
+
return result
|
|
107
|
+
except Exception:
|
|
108
|
+
return None
|
ahn_client/_hosts.py
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"""Hostname extraction and the list of hosts that are never looked up.
|
|
2
|
+
|
|
3
|
+
Mirrors normalize_host and skip_host in plugins/claude-code/ahn/hooks/ahn_lookup.py;
|
|
4
|
+
tests/test_ahn_client.py checks the two stay in step. Nothing here resolves a name.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
import ipaddress
|
|
10
|
+
import os
|
|
11
|
+
import re
|
|
12
|
+
import urllib.parse
|
|
13
|
+
from typing import Optional
|
|
14
|
+
|
|
15
|
+
OWN_HOST = "agenthelpnetwork.com"
|
|
16
|
+
|
|
17
|
+
HOST_LABEL = re.compile(r"^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$")
|
|
18
|
+
# Special-use and private-network names (RFC 6761/6762/8375, Tor, common LAN suffixes).
|
|
19
|
+
SKIP_TLDS = frozenset({"localhost", "local", "internal", "test", "lan", "arpa", "onion", "invalid", "example",
|
|
20
|
+
"home", "corp", "intranet", "private", "localdomain", "alt"})
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def normalize_host(value: object) -> Optional[str]:
|
|
24
|
+
"""A bare lowercase hostname from a URL or host string; None when there is none.
|
|
25
|
+
|
|
26
|
+
Scheme, userinfo, port, path, query and fragment are dropped, as is one leading
|
|
27
|
+
``www.`` (the service reads declared policy for apex names only).
|
|
28
|
+
"""
|
|
29
|
+
if not isinstance(value, str):
|
|
30
|
+
return None
|
|
31
|
+
value = value.strip()
|
|
32
|
+
if not value:
|
|
33
|
+
return None
|
|
34
|
+
try:
|
|
35
|
+
parts = urllib.parse.urlsplit(value if "://" in value else "//" + value)
|
|
36
|
+
host = parts.hostname
|
|
37
|
+
except ValueError:
|
|
38
|
+
return None
|
|
39
|
+
if not host:
|
|
40
|
+
return None
|
|
41
|
+
host = host.rstrip(".").lower()
|
|
42
|
+
if not host.isascii():
|
|
43
|
+
try:
|
|
44
|
+
host = host.encode("idna").decode("ascii")
|
|
45
|
+
except UnicodeError:
|
|
46
|
+
return None
|
|
47
|
+
labels = host.split(".")
|
|
48
|
+
if not all(HOST_LABEL.fullmatch(label) for label in labels) or len(host) > 253:
|
|
49
|
+
return None
|
|
50
|
+
if len(labels) >= 3 and labels[0] == "www":
|
|
51
|
+
host = ".".join(labels[1:])
|
|
52
|
+
return host
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def skip_host(host: str, extra: str = "") -> bool:
|
|
56
|
+
"""True for local, private, special-use, address-literal, single-label and own hosts."""
|
|
57
|
+
labels = host.split(".")
|
|
58
|
+
if len(labels) < 2:
|
|
59
|
+
return True
|
|
60
|
+
last = labels[-1]
|
|
61
|
+
# Public TLDs are alphabetic or IDN; an all-digit or hex last label is an address
|
|
62
|
+
# literal in inet_aton form (10.0.0.1, 127.1, 0x7f.1).
|
|
63
|
+
if last in SKIP_TLDS or not (last.isalpha() or last.startswith("xn--")):
|
|
64
|
+
return True
|
|
65
|
+
try:
|
|
66
|
+
ipaddress.ip_address(host)
|
|
67
|
+
return True
|
|
68
|
+
except ValueError:
|
|
69
|
+
pass
|
|
70
|
+
suffixes = [OWN_HOST] + [item.strip().lower().lstrip(".") for item in extra.split(",") if item.strip()]
|
|
71
|
+
return any(host == suffix or host.endswith("." + suffix) for suffix in suffixes)
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def eligible_host(value: object, env=None) -> Optional[str]:
|
|
75
|
+
"""The hostname to look up for ``value``, or None when nothing may be sent."""
|
|
76
|
+
env = os.environ if env is None else env
|
|
77
|
+
if env.get("AHN_CLIENT_DISABLE") == "1":
|
|
78
|
+
return None
|
|
79
|
+
host = normalize_host(value)
|
|
80
|
+
if host is None or skip_host(host, env.get("AHN_CLIENT_SKIP_HOSTS", "")):
|
|
81
|
+
return None
|
|
82
|
+
return host
|
ahn_client/_result.py
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
"""The parsed answer of ``GET /v1/incidents/check`` and its one-line summary."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import re
|
|
6
|
+
from dataclasses import dataclass, field
|
|
7
|
+
from typing import Any, Dict, List, Optional, Tuple
|
|
8
|
+
|
|
9
|
+
MAX_SUMMARY = 700
|
|
10
|
+
ACTIONS = ("proceed", "use_official_path", "hand_off_to_human", "wait_provider_incident", "stop_declared_block", "unknown")
|
|
11
|
+
CONFIDENCES = ("high", "medium", "low")
|
|
12
|
+
|
|
13
|
+
CODE = re.compile(r"^[a-z][a-z0-9_]{0,47}$")
|
|
14
|
+
TOKEN = re.compile(r"^[A-Za-z0-9][A-Za-z0-9._-]{0,47}$")
|
|
15
|
+
SAFE_URL = re.compile(r"^https://[A-Za-z0-9.-]+(?:/[A-Za-z0-9._~/%+=&?#-]*)?$")
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def _code(value: Any, default: str = "unknown") -> str:
|
|
19
|
+
return value if isinstance(value, str) and CODE.fullmatch(value) else default
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def _url(value: Any) -> Optional[str]:
|
|
23
|
+
return value if isinstance(value, str) and len(value) <= 200 and SAFE_URL.fullmatch(value) else None
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def _dict(value: Any) -> Optional[Dict[str, Any]]:
|
|
27
|
+
return value if isinstance(value, dict) else None
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def _summary(host: str, data: Dict[str, Any], url: str) -> str:
|
|
31
|
+
"""The same line the Claude Code plugin prints, at most MAX_SUMMARY characters, from validated fields only."""
|
|
32
|
+
rec = _dict(data.get("recommendation")) or {}
|
|
33
|
+
profile = _dict(data.get("access_profile"))
|
|
34
|
+
official = _dict(data.get("official_paths")) or {}
|
|
35
|
+
provider = _dict(data.get("provider_status"))
|
|
36
|
+
checks = data.get("next_checks") if isinstance(data.get("next_checks"), list) else []
|
|
37
|
+
|
|
38
|
+
if profile:
|
|
39
|
+
robots = _code(profile.get("robots_status"))
|
|
40
|
+
rules = _dict(profile.get("robots")) or {}
|
|
41
|
+
listed = rules.get("agents_blocked") if isinstance(rules.get("agents_blocked"), list) else []
|
|
42
|
+
blocked: Optional[List[str]] = [item for item in listed if isinstance(item, str) and TOKEN.fullmatch(item)]
|
|
43
|
+
llms = _code(profile.get("llms_txt_status"))
|
|
44
|
+
else:
|
|
45
|
+
robots, blocked, llms = "not read for this hostname", None, "unknown"
|
|
46
|
+
path = _url(official.get("api_docs")) or _url(official.get("developer_portal"))
|
|
47
|
+
path_listed = bool(official.get("api_docs") or official.get("developer_portal"))
|
|
48
|
+
if provider:
|
|
49
|
+
status = f"{_code(provider.get('indicator'))}/{_code(provider.get('freshness'))}"
|
|
50
|
+
else:
|
|
51
|
+
status = "not connected (official page listed)" if isinstance(data.get("official_status_page"), dict) else "not connected"
|
|
52
|
+
codes = [_code(item.get("code")) for item in checks if isinstance(item, dict)][:2]
|
|
53
|
+
|
|
54
|
+
def render(agent_limit: Optional[int], show_path: bool, show_url: bool) -> str:
|
|
55
|
+
if blocked is None:
|
|
56
|
+
agents = "unknown"
|
|
57
|
+
elif not blocked:
|
|
58
|
+
agents = "none" if robots == "ok" else "unknown"
|
|
59
|
+
elif agent_limit is None or len(blocked) <= agent_limit:
|
|
60
|
+
agents = ", ".join(blocked)
|
|
61
|
+
elif agent_limit == 0:
|
|
62
|
+
agents = f"{len(blocked)} agent tokens"
|
|
63
|
+
else:
|
|
64
|
+
agents = ", ".join(blocked[:agent_limit]) + f" (+{len(blocked) - agent_limit} more)"
|
|
65
|
+
official_text = path if path and show_path else "listed" if path_listed else "none"
|
|
66
|
+
full = url if show_url else "GET /v1/incidents/check on agenthelpnetwork.com"
|
|
67
|
+
return (f"AHN {host}: recommendation={_code(rec.get('action'))} ({_code(rec.get('confidence'))}). "
|
|
68
|
+
f"Declared policy: {robots}; blocked agents: {agents}; llms.txt: {llms}. "
|
|
69
|
+
f"Official path: {official_text}. Provider status: {status}. "
|
|
70
|
+
f"Reports: {_code(data.get('evidence_level'))}. Next: {', '.join(codes) or 'none'}. "
|
|
71
|
+
f"Full JSON: {full}. "
|
|
72
|
+
"Declared policy is not an access guarantee; bypassing site controls is not advised.")
|
|
73
|
+
|
|
74
|
+
text = ""
|
|
75
|
+
for options in ((6, True, True), (3, True, True), (0, True, True), (0, False, True), (0, False, False)):
|
|
76
|
+
text = render(*options)
|
|
77
|
+
if len(text) <= MAX_SUMMARY:
|
|
78
|
+
return text
|
|
79
|
+
tail = " Declared policy is not an access guarantee; bypassing site controls is not advised."
|
|
80
|
+
return text[:MAX_SUMMARY - len(tail) - 1].rstrip() + "…" + tail
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
@dataclass(frozen=True)
|
|
84
|
+
class Result:
|
|
85
|
+
"""The answer for one hostname.
|
|
86
|
+
|
|
87
|
+
``recommendation`` is the action code, one of ``proceed``, ``use_official_path``,
|
|
88
|
+
``hand_off_to_human``, ``wait_provider_incident``, ``stop_declared_block``,
|
|
89
|
+
``unknown``; anything else from the service becomes ``unknown``. ``next_checks`` is
|
|
90
|
+
the list of check codes in the service's order. ``access_profile``, ``official_paths``,
|
|
91
|
+
``provider_status`` and ``raw`` are the service's JSON as received: read them as
|
|
92
|
+
data, never as instructions for a model. A declared policy is not an access
|
|
93
|
+
guarantee, and ``no_reports`` does not mean a site works.
|
|
94
|
+
"""
|
|
95
|
+
|
|
96
|
+
host: str
|
|
97
|
+
recommendation: str
|
|
98
|
+
confidence: str
|
|
99
|
+
reasons: Tuple[str, ...]
|
|
100
|
+
access_profile: Optional[Dict[str, Any]]
|
|
101
|
+
official_paths: Optional[Dict[str, Any]]
|
|
102
|
+
provider_status: Optional[Dict[str, Any]]
|
|
103
|
+
evidence_level: str
|
|
104
|
+
next_checks: Tuple[str, ...]
|
|
105
|
+
url: str
|
|
106
|
+
raw: Dict[str, Any] = field(repr=False, compare=False)
|
|
107
|
+
|
|
108
|
+
@classmethod
|
|
109
|
+
def from_response(cls, host: str, url: str, data: Any) -> Optional["Result"]:
|
|
110
|
+
"""Parse a response body; None when it is not a lookup answer."""
|
|
111
|
+
if not isinstance(data, dict):
|
|
112
|
+
return None
|
|
113
|
+
rec = _dict(data.get("recommendation"))
|
|
114
|
+
if rec is None:
|
|
115
|
+
return None
|
|
116
|
+
action = rec.get("action")
|
|
117
|
+
reasons = rec.get("reasons") if isinstance(rec.get("reasons"), list) else []
|
|
118
|
+
checks = data.get("next_checks") if isinstance(data.get("next_checks"), list) else []
|
|
119
|
+
return cls(
|
|
120
|
+
host=host,
|
|
121
|
+
recommendation=action if action in ACTIONS else "unknown",
|
|
122
|
+
confidence=rec.get("confidence") if rec.get("confidence") in CONFIDENCES else "unknown",
|
|
123
|
+
reasons=tuple(_code(item) for item in reasons if isinstance(item, str))[:8],
|
|
124
|
+
access_profile=_dict(data.get("access_profile")),
|
|
125
|
+
official_paths=_dict(data.get("official_paths")),
|
|
126
|
+
provider_status=_dict(data.get("provider_status")),
|
|
127
|
+
evidence_level=_code(data.get("evidence_level")),
|
|
128
|
+
next_checks=tuple(_code(item.get("code")) for item in checks if isinstance(item, dict))[:12],
|
|
129
|
+
url=url,
|
|
130
|
+
raw=data,
|
|
131
|
+
)
|
|
132
|
+
|
|
133
|
+
@property
|
|
134
|
+
def official_url(self) -> Optional[str]:
|
|
135
|
+
"""The listed official API documentation or developer portal (an https URL), or None."""
|
|
136
|
+
paths = self.official_paths or {}
|
|
137
|
+
return _url(paths.get("api_docs")) or _url(paths.get("developer_portal"))
|
|
138
|
+
|
|
139
|
+
@property
|
|
140
|
+
def blocked_agents(self) -> Tuple[str, ...]:
|
|
141
|
+
"""Agent user-agent tokens the host's robots.txt explicitly blocks at the root."""
|
|
142
|
+
rules = _dict((self.access_profile or {}).get("robots")) or {}
|
|
143
|
+
listed = rules.get("agents_blocked") if isinstance(rules.get("agents_blocked"), list) else []
|
|
144
|
+
return tuple(item for item in listed if isinstance(item, str) and TOKEN.fullmatch(item))
|
|
145
|
+
|
|
146
|
+
def summary(self) -> str:
|
|
147
|
+
"""One line, at most 700 characters, built only from validated fields."""
|
|
148
|
+
return _summary(self.host, self.raw, self.url)
|
ahn_client/py.typed
ADDED
|
File without changes
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: ahn-client
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Ask Agent Help Network what a host declares and recommends when your browser automation is blocked. Read-only, no dependencies.
|
|
5
|
+
Project-URL: Homepage, https://agenthelpnetwork.com
|
|
6
|
+
Project-URL: Documentation, https://agenthelpnetwork.com/en/agents
|
|
7
|
+
Project-URL: Repository, https://github.com/agent-help-network/agent-help-network
|
|
8
|
+
Project-URL: Issues, https://github.com/agent-help-network/agent-help-network/issues
|
|
9
|
+
Author: Agent Help Network
|
|
10
|
+
License-Expression: Apache-2.0
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: agents,browser-automation,browser-use,llms-txt,playwright,robots-txt,web-access
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
22
|
+
Classifier: Typing :: Typed
|
|
23
|
+
Requires-Python: >=3.9
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
|
|
26
|
+
# ahn-client
|
|
27
|
+
|
|
28
|
+
A small Python client for [Agent Help Network](https://agenthelpnetwork.com/en/agents): when your browser automation (Playwright, Browser Use, Stagehand-style scripts, plain HTTP) is blocked, ask what the host **declares** agents may do (its own `robots.txt` and `llms.txt`), where its **official developer path** is, what the provider's **status feed** says, and get one recommended action.
|
|
29
|
+
|
|
30
|
+
**Agent Help Network is an independent project. It is not an official service of, and is not affiliated with, OpenAI, Meta, Muse, dots, Anthropic, or any site it describes.** `ahn-client` is read-only (version 0.1 has no reporting function), has no dependencies beyond the Python standard library, and runs on Python 3.9+.
|
|
31
|
+
|
|
32
|
+
## Install
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
pip install ahn-client
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Use
|
|
39
|
+
|
|
40
|
+
```python
|
|
41
|
+
import ahn_client as ahn
|
|
42
|
+
answer = ahn.check("https://example.com/some/page", *ahn.classify("403 Forbidden"))
|
|
43
|
+
print(answer.summary() if answer else "no answer")
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
In an `except` block:
|
|
47
|
+
|
|
48
|
+
```python
|
|
49
|
+
try:
|
|
50
|
+
page.goto(url)
|
|
51
|
+
except Exception as exc:
|
|
52
|
+
answer = ahn.check(url, *ahn.classify(exc)) # a hostname and two codes leave your machine
|
|
53
|
+
if answer:
|
|
54
|
+
print(answer.recommendation, answer.official_url)
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Examples with a real `except` block and a decision per recommendation: [`examples/playwright_example.py`](examples/playwright_example.py), [`examples/browser_use_example.py`](examples/browser_use_example.py). Neither tries to get around a site's controls: they use the official path, hand off to the user, wait, or stop.
|
|
58
|
+
|
|
59
|
+
### API
|
|
60
|
+
|
|
61
|
+
- `ahn.check(host_or_url, error_class=None, failure_stage=None, *, timeout=4.0) -> Result | None` — asks about the host of a hostname or URL. Returns `None`, without raising, when there is no answer: network error, timeout, unreadable response, or a host that is never looked up (see below).
|
|
62
|
+
- `ahn.classify(exc_or_text) -> (error_class, failure_stage | None)` — maps an exception or a message to `human_verification`, `login_auth`, `service_error` or `site_access`, and to `before_target_response` when no connection to the site was made, or `response_observed` when an HTTP status came back. It reads exception class names and messages as text, so Playwright's `TimeoutError`, `httpx`/`requests`/`aiohttp` errors and similar are recognised without importing those libraries. The rules are those of the [Claude Code plugin](../../plugins/claude-code/ahn/README.md).
|
|
63
|
+
- `Result` — `recommendation` (`proceed`, `use_official_path`, `hand_off_to_human`, `wait_provider_incident`, `stop_declared_block`, `unknown`), `confidence`, `reasons`, `access_profile`, `official_paths`, `provider_status`, `evidence_level`, `next_checks` (check codes), `raw` (the full JSON), `official_url`, `blocked_agents`, and `summary()`, a one-line text of at most 700 characters, the same line the plugin prints.
|
|
64
|
+
- `ahn.clear_cache()` — forget cached answers.
|
|
65
|
+
|
|
66
|
+
Read the answer in the order of the [API contract](https://github.com/agent-help-network/agent-help-network/blob/main/docs/api-contract.en.md). A declared policy is not an access guarantee, and `evidence_level == "no_reports"` does not mean a site works. `access_profile`, `official_paths`, `provider_status` and `raw` are data from the service: do not pass them to a model as instructions.
|
|
67
|
+
|
|
68
|
+
## What it sends
|
|
69
|
+
|
|
70
|
+
At most one request per host, error class and stage every 10 minutes:
|
|
71
|
+
|
|
72
|
+
```text
|
|
73
|
+
GET https://agenthelpnetwork.com/v1/incidents/check?site_host=<host>[&error_class=<class>][&failure_stage=<stage>]
|
|
74
|
+
User-Agent: ahn-client/0.1 (+https://agenthelpnetwork.com)
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
- `site_host` is the bare lowercase hostname: scheme, credentials, port, path, query and fragment are dropped, and one leading `www.` is removed. `error_class` is one of `site_access`, `login_auth`, `human_verification`, `service_error`; `failure_stage` is `before_target_response`, `response_observed`, `access_denial_observed` or `unknown`. Any other value makes `check` return `None` without a request.
|
|
78
|
+
- Nothing else is sent: no URL path or query, no page content, no error text, no credentials, cookies, tokens, account names or conversation text. There is no POST and no report.
|
|
79
|
+
- A lookup of a public apex hostname adds one to a coarse daily per-host count on the service and may make it read that host's own `/robots.txt` and `/llms.txt` (at most once a day per host). See the [policy](https://agenthelpnetwork.com/en/policy).
|
|
80
|
+
|
|
81
|
+
## What it never looks up
|
|
82
|
+
|
|
83
|
+
`check` returns `None` and sends nothing for: `localhost`, IP addresses (including short and hex forms such as `127.1`), single-label names, names under `.local`, `.internal`, `.test`, `.lan`, `.arpa`, `.onion`, `.invalid`, `.example`, `.home`, `.corp`, `.intranet`, `.private`, `.localdomain`, `.alt`, and `agenthelpnetwork.com` and its subdomains. Nothing is resolved to decide this. Hostnames under a public suffix can still be internal (`jenkins.yourcompany.com`); list them in `AHN_CLIENT_SKIP_HOSTS`.
|
|
84
|
+
|
|
85
|
+
| Environment | Effect |
|
|
86
|
+
| :- | :- |
|
|
87
|
+
| `AHN_CLIENT_DISABLE=1` | `check` never sends anything |
|
|
88
|
+
| `AHN_CLIENT_SKIP_HOSTS=corp.example.com,other.example.org` | Never look up these hosts or their subdomains |
|
|
89
|
+
|
|
90
|
+
Answers are cached in memory for 10 minutes (a failed lookup for 1 minute); nothing is written to disk. Redirects from the service are not followed.
|
|
91
|
+
|
|
92
|
+
## Development
|
|
93
|
+
|
|
94
|
+
From the repository root: `python -m pytest tests/test_ahn_client.py -q` (no network). Build with `python -m build clients/python`.
|
|
95
|
+
|
|
96
|
+
## License
|
|
97
|
+
|
|
98
|
+
[Apache-2.0](LICENSE). Source: [agent-help-network/agent-help-network](https://github.com/agent-help-network/agent-help-network), `clients/python/`.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
ahn_client/__init__.py,sha256=rlVQtsszb-fLWVtGEr0JcLQ8iSI4fi6DzBWQyAzld4o,668
|
|
2
|
+
ahn_client/_classify.py,sha256=lVGbrV7KbUKK7dQl4jFEgWFTklNH0ozsswgr0CVipwE,4479
|
|
3
|
+
ahn_client/_client.py,sha256=GSRCDbEPoG4YB4651KoI9DJVNP3moRrneP_PmqEim-E,4154
|
|
4
|
+
ahn_client/_hosts.py,sha256=N6peaB3FDR_0iZeDt9ABnwDJ_o-s820bzS45taZBC58,2971
|
|
5
|
+
ahn_client/_result.py,sha256=vLA6RY4JYN1YvExFHnTr7aP0lHdlNt3gqtYbmHpV4Rc,7198
|
|
6
|
+
ahn_client/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
|
+
ahn_client-0.1.0.dist-info/METADATA,sha256=AhaF2ujZ7lGpMLcEZAS0y5EsEu6XZ9ph5FFzkrKc_cE,6775
|
|
8
|
+
ahn_client-0.1.0.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
|
|
9
|
+
ahn_client-0.1.0.dist-info/licenses/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
|
|
10
|
+
ahn_client-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|