Skip to content

Commit 7073adc

Browse files
committed
Redesign docs presentation
1 parent 9ee0abb commit 7073adc

9 files changed

Lines changed: 636 additions & 41 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ agentproof verify challenge.json response.json
174174

175175
## Demo
176176

177-
A runnable local demo lives in [`demo/`](/home/borislav/VSCode/agentproof/demo).
177+
A runnable local demo lives in [`demo/`](https://github.com/bnovik0v/agentproof/tree/main/demo).
178178

179179
Run it with:
180180

@@ -214,7 +214,7 @@ uv run mkdocs build --strict
214214

215215
- PyPI: https://pypi.org/project/agentproof-ai/
216216
- Docs: https://bnovik0v.github.io/agentproof/
217-
- Demo: [demo/README.md](/home/borislav/VSCode/agentproof/demo/README.md)
217+
- Demo: [demo/README.md](https://github.com/bnovik0v/agentproof/blob/main/demo/README.md)
218218
- Contributing: [CONTRIBUTING.md](CONTRIBUTING.md)
219219

220220
## License

docs/api.md

Lines changed: 72 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,91 @@
11
# API
22

3-
## Public entry points
3+
## Public imports
44

55
```python
66
from agentproof import generate_challenge, solve_challenge, verify_response
77
from agentproof import ChallengeSpec, Challenge, AgentResponse, VerificationResult
88
```
99

10-
## ChallengeSpec
10+
## `ChallengeSpec`
11+
12+
Used to request a challenge.
13+
14+
Fields:
1115

1216
- `challenge_type`
1317
- `ttl_seconds`
1418
- `difficulty`
1519
- `options`
1620

17-
## VerificationResult
21+
Example:
22+
23+
```python
24+
spec = ChallengeSpec(
25+
challenge_type="semantic_math_lock",
26+
ttl_seconds=90,
27+
options={"topic": "security", "word_count": 7},
28+
)
29+
```
30+
31+
## `Challenge`
32+
33+
Represents an issued challenge payload.
34+
35+
Important fields:
36+
37+
- `challenge_id`
38+
- `challenge_type`
39+
- `prompt`
40+
- `issued_at`
41+
- `expires_at`
42+
- `data`
43+
- `version`
44+
45+
## `AgentResponse`
46+
47+
Represents the response returned by a client or reference solver.
48+
49+
Important fields:
50+
51+
- `challenge_id`
52+
- `challenge_type`
53+
- `payload`
54+
55+
## `VerificationResult`
56+
57+
Returned by `verify_response(...)`.
58+
59+
Fields:
1860

1961
- `ok`
2062
- `reason`
2163
- `details`
2264

65+
Common success value:
66+
67+
```json
68+
{
69+
"ok": true,
70+
"reason": "ok",
71+
"details": {
72+
"nonce": "223",
73+
"hash": "00bf9b61..."
74+
}
75+
}
76+
```
77+
78+
Common failure values:
79+
80+
- `challenge_id_mismatch`
81+
- `challenge_type_mismatch`
82+
- `challenge_expired`
83+
- `missing_nonce`
84+
- `missing_hash`
85+
- `hash_mismatch`
86+
- `insufficient_difficulty`
87+
- `missing_text`
88+
- `wrong_word_count`
89+
- `required_word_constraint_failed`
90+
- `initial_sum_mismatch`
91+

docs/concepts.md

Lines changed: 65 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,75 @@
1-
# Concepts
1+
# Challenge Types
22

3-
## Challenge families
3+
`agentproof` currently ships two built-in challenge families.
44

5-
`agentproof` currently ships two built-in challenge families:
5+
## `proof_of_work`
66

7-
- `proof_of_work`
8-
- `semantic_math_lock`
7+
Use this when you want a deterministic compute task with no natural-language component.
98

10-
Each family supports:
9+
What the agent does:
1110

12-
- generation
13-
- solving with the reference implementation
14-
- verification
11+
- reads the payload
12+
- searches for a nonce
13+
- returns a nonce and hash pair
1514

16-
## Determinism
15+
What the server verifies:
1716

18-
Verification logic should be machine-checkable and stable. The library avoids fuzzy scoring.
17+
- challenge ID matches
18+
- response is not expired
19+
- hash recomputes correctly
20+
- hash satisfies the required difficulty
1921

20-
## Extensibility
22+
Typical use cases:
2123

22-
Challenge families implement a shared protocol, which keeps custom handlers isolated from the public API.
24+
- cheap anti-abuse friction
25+
- deterministic smoke tests
26+
- baseline challenge-response verification
27+
28+
## `semantic_math_lock`
29+
30+
Use this when you want a readable challenge that still has exact measurable constraints.
31+
32+
What the agent does:
33+
34+
- reads required words and word-count rules
35+
- produces text that matches all constraints
36+
- returns the text in structured JSON
37+
38+
What the server verifies:
39+
40+
- challenge ID matches
41+
- response is not expired
42+
- exact word count
43+
- required words appear exactly once
44+
- initial-letter ASCII sum matches the target
45+
46+
Typical use cases:
47+
48+
- reverse-CAPTCHA experiments
49+
- structured agent behavior checks
50+
- demos where human-readable prompts matter
51+
52+
## Determinism matters
53+
54+
`agentproof` intentionally avoids fuzzy verification.
55+
56+
Each built-in challenge is designed so the server can produce a clear yes/no result and, when it
57+
fails, a concrete failure reason such as:
58+
59+
- `challenge_expired`
60+
- `hash_mismatch`
61+
- `wrong_word_count`
62+
- `required_word_constraint_failed`
63+
- `initial_sum_mismatch`
64+
65+
## Extending the library
66+
67+
Challenge families implement a shared internal protocol:
68+
69+
- generate
70+
- solve
71+
- verify
72+
73+
That keeps custom challenge logic isolated from the public API while preserving a consistent
74+
library interface.
2375

docs/examples.md

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,19 @@
55
```python
66
from agentproof import ChallengeSpec, generate_challenge, solve_challenge, verify_response
77

8-
challenge = generate_challenge(ChallengeSpec(challenge_type="proof_of_work", difficulty=16))
8+
challenge = generate_challenge(
9+
ChallengeSpec(challenge_type="proof_of_work", difficulty=16, ttl_seconds=120)
10+
)
911
response = solve_challenge(challenge)
1012
result = verify_response(challenge, response)
13+
1114
assert result.ok
1215
```
1316

1417
## Semantic math lock
1518

1619
```python
17-
from agentproof import ChallengeSpec, generate_challenge, solve_challenge
20+
from agentproof import ChallengeSpec, generate_challenge, solve_challenge, verify_response
1821

1922
challenge = generate_challenge(
2023
ChallengeSpec(
@@ -23,5 +26,56 @@ challenge = generate_challenge(
2326
)
2427
)
2528
response = solve_challenge(challenge)
29+
result = verify_response(challenge, response)
30+
31+
assert result.ok
32+
print(response.payload["text"])
33+
```
34+
35+
## Manual verification in a service
36+
37+
```python
38+
from agentproof import AgentResponse, Challenge, verify_response
39+
40+
challenge = Challenge(**challenge_payload_from_storage)
41+
response = AgentResponse(**response_payload_from_client)
42+
result = verify_response(challenge, response)
43+
44+
if result.ok:
45+
allow_request()
46+
else:
47+
reject_request(result.reason)
48+
```
49+
50+
## Failure example
51+
52+
If the client sends the wrong number of words for `semantic_math_lock`, the result looks like:
53+
54+
```json
55+
{
56+
"ok": false,
57+
"reason": "wrong_word_count",
58+
"details": {
59+
"actual": 3,
60+
"expected": 7
61+
}
62+
}
2663
```
2764

65+
## Local demo
66+
67+
The repository ships a runnable local demo in the
68+
[`demo/` directory on GitHub](https://github.com/bnovik0v/agentproof/tree/main/demo).
69+
70+
Run it with:
71+
72+
```bash
73+
uv run python demo/app.py
74+
```
75+
76+
The demo lets you:
77+
78+
- generate challenges
79+
- auto-solve them
80+
- inspect the raw JSON
81+
- tamper with the response and watch verification fail

docs/getting-started.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Getting Started
2+
3+
## Install
4+
5+
```bash
6+
pip install agentproof-ai
7+
```
8+
9+
The published distribution name is `agentproof-ai`, but the import name is `agentproof`.
10+
11+
## Basic roundtrip
12+
13+
```python
14+
from agentproof import ChallengeSpec, generate_challenge, solve_challenge, verify_response
15+
16+
challenge = generate_challenge(
17+
ChallengeSpec(challenge_type="proof_of_work", difficulty=8, ttl_seconds=60)
18+
)
19+
response = solve_challenge(challenge)
20+
result = verify_response(challenge, response)
21+
22+
print(challenge.to_dict())
23+
print(response.to_dict())
24+
print(result.to_dict())
25+
```
26+
27+
## CLI roundtrip
28+
29+
```bash
30+
agentproof generate proof_of_work --difficulty 16 --output challenge.json
31+
agentproof solve challenge.json --output response.json
32+
agentproof verify challenge.json response.json
33+
```
34+
35+
## Service flow
36+
37+
In a real application:
38+
39+
1. Your backend generates a challenge and returns it to the client.
40+
2. The client agent solves it.
41+
3. The client sends the response back.
42+
4. Your backend verifies it before allowing the next step.
43+
44+
## Local demo
45+
46+
Run the demo app from the repository root:
47+
48+
```bash
49+
uv run python demo/app.py
50+
```
51+
52+
Then open:
53+
54+
```text
55+
http://127.0.0.1:8765
56+
```
57+

0 commit comments

Comments
 (0)