Skip to content

Commit a004248

Browse files
author
ClawNet Sync Bot
committed
snapshot from ClawNet@8870e02
1 parent 4088d86 commit a004248

23 files changed

Lines changed: 2525 additions & 1 deletion
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
name: Bug report
3+
about: Something is broken in the anet Python SDK
4+
title: "[bug] "
5+
labels: bug
6+
assignees: ''
7+
---
8+
9+
## Describe the bug
10+
A clear and concise description of what the bug is.
11+
12+
## To reproduce
13+
Minimal Python snippet that triggers the bug. Please show the smallest possible
14+
example — ideally something we can copy-paste and run.
15+
16+
```python
17+
from anet.svc import SvcClient
18+
# ...
19+
```
20+
21+
## Expected behaviour
22+
What you expected to happen.
23+
24+
## Actual behaviour
25+
What actually happened. Paste the full traceback if any.
26+
27+
```
28+
Traceback (most recent call last):
29+
...
30+
```
31+
32+
## Environment
33+
- SDK version: `python -c "import anet; print(getattr(anet, '__version__', 'unknown'))"` or `pip show agentnetwork | grep Version`
34+
- Python version: `python --version`
35+
- OS: e.g. macOS 14.5 / Ubuntu 22.04
36+
- `anet daemon` version: `anet --version` (if relevant)
37+
- Daemon running locally? yes / no
38+
39+
## Additional context
40+
Add any other context about the problem here.

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
blank_issues_enabled: false
2+
contact_links:
3+
- name: AgentNetwork docs / SKILL.md
4+
url: https://agentnetwork.org.cn/SKILL.md
5+
about: Read the canonical agent skill before opening an issue.
6+
- name: AgentNetwork community
7+
url: https://agentnetwork.org.cn
8+
about: Project home, news, and contact.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
name: Feature request
3+
about: Suggest a new endpoint, helper, or improvement
4+
title: "[feat] "
5+
labels: enhancement
6+
assignees: ''
7+
---
8+
9+
## What problem are you trying to solve?
10+
Describe the use case. What are you trying to build with the SDK?
11+
12+
## Proposed API
13+
If you have a concrete API shape in mind, sketch it here.
14+
15+
```python
16+
# e.g.
17+
svc.something_new(...)
18+
```
19+
20+
## Alternatives considered
21+
Any workarounds you've already tried?
22+
23+
## Additional context
24+
Anything else relevant — links to AgentNetwork SKILL.md sections, daemon
25+
endpoints, existing SDK modules, etc.

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
## What does this PR do?
2+
Brief description.
3+
4+
## Why?
5+
Link to the issue, discussion, or use case.
6+
7+
## How was it tested?
8+
- [ ] `pytest -q tests/test_svc.py` passes locally
9+
- [ ] Tested against a running `anet daemon` (describe scenario)
10+
- [ ] N/A — docs / typing / pure refactor
11+
12+
## Notes for maintainers
13+
- This repo is a one-way mirror of the upstream closed-source tree. Once
14+
reviewed, the change will be applied internally and re-landed via the
15+
next sync. See [CONTRIBUTING.md](../CONTRIBUTING.md).

.github/workflows/ci.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: ci
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
workflow_dispatch:
9+
10+
permissions:
11+
contents: read
12+
13+
jobs:
14+
test:
15+
name: pytest (offline)
16+
runs-on: ${{ matrix.os }}
17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
os: [ubuntu-latest, macos-latest]
21+
python-version: ["3.9", "3.10", "3.11", "3.12"]
22+
steps:
23+
- uses: actions/checkout@v4
24+
- uses: actions/setup-python@v5
25+
with:
26+
python-version: ${{ matrix.python-version }}
27+
- name: Install
28+
run: |
29+
python -m pip install --upgrade pip
30+
python -m pip install -e ".[dev]"
31+
- name: Run offline tests
32+
run: pytest -q tests/test_svc.py
33+
34+
build-check:
35+
name: build + twine check
36+
runs-on: ubuntu-latest
37+
needs: test
38+
steps:
39+
- uses: actions/checkout@v4
40+
- uses: actions/setup-python@v5
41+
with:
42+
python-version: "3.11"
43+
- name: Install build tooling
44+
run: |
45+
python -m pip install --upgrade pip
46+
python -m pip install build twine
47+
- name: Build
48+
run: python -m build
49+
- name: Twine check
50+
run: python -m twine check dist/*

.github/workflows/publish-pypi.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: publish-pypi
2+
3+
# Publishes a tagged build to **PyPI** via OIDC Trusted Publishing.
4+
#
5+
# Triggered by tags matching v* (semver, no -test / -rc suffix).
6+
#
7+
# IMPORTANT: This workflow is **disabled** by default (`if: false`). After
8+
# the TestPyPI release looks good, flip the guard to `if: true` (or remove
9+
# the line) and tag a release as v1.1.0 to ship to production PyPI.
10+
#
11+
# Requires (one-time, Web UI):
12+
# PyPI → Account Settings → Publishing → Add a pending publisher
13+
# Owner / Repo: ChatChatTech / anet-python-sdk
14+
# Workflow file: publish-pypi.yml
15+
# Environment: pypi
16+
17+
on:
18+
push:
19+
tags:
20+
- "v[0-9]+.[0-9]+.[0-9]+"
21+
workflow_dispatch:
22+
23+
permissions:
24+
contents: read
25+
26+
jobs:
27+
build:
28+
name: Build sdist + wheel
29+
if: false # <-- enable AFTER TestPyPI verification is green
30+
runs-on: ubuntu-latest
31+
steps:
32+
- uses: actions/checkout@v4
33+
- uses: actions/setup-python@v5
34+
with:
35+
python-version: "3.11"
36+
- name: Install build tooling
37+
run: |
38+
python -m pip install --upgrade pip
39+
python -m pip install build twine pytest httpx
40+
- name: Run offline unit tests
41+
run: pytest -q tests/test_svc.py
42+
- name: Build distributions
43+
run: python -m build
44+
- name: Twine check
45+
run: python -m twine check dist/*
46+
- name: Upload dist artifacts
47+
uses: actions/upload-artifact@v4
48+
with:
49+
name: dist
50+
path: dist/
51+
52+
publish-pypi:
53+
name: Publish to PyPI
54+
if: false # <-- enable AFTER TestPyPI verification is green
55+
needs: build
56+
runs-on: ubuntu-latest
57+
environment:
58+
name: pypi
59+
url: https://pypi.org/project/agentnetwork/
60+
permissions:
61+
id-token: write
62+
steps:
63+
- name: Download dist artifacts
64+
uses: actions/download-artifact@v4
65+
with:
66+
name: dist
67+
path: dist/
68+
- name: Publish to PyPI
69+
uses: pypa/gh-action-pypi-publish@release/v1
70+
with:
71+
packages-dir: dist/
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: publish-testpypi
2+
3+
# Publishes a tagged build to **TestPyPI** via OIDC Trusted Publishing.
4+
# Triggered by:
5+
# - Tags matching v*-test* or v*-rc* (e.g. v1.1.0-test1, v1.1.0-rc2)
6+
# - Manual workflow_dispatch
7+
#
8+
# Requires (one-time, Web UI):
9+
# TestPyPI → Account Settings → Publishing → Add a pending publisher
10+
# Owner / Repo: ChatChatTech / anet-python-sdk
11+
# Workflow file: publish-testpypi.yml
12+
# Environment: testpypi
13+
14+
on:
15+
push:
16+
tags:
17+
- "v*-test*"
18+
- "v*-rc*"
19+
workflow_dispatch:
20+
21+
permissions:
22+
contents: read
23+
24+
jobs:
25+
build:
26+
name: Build sdist + wheel
27+
runs-on: ubuntu-latest
28+
steps:
29+
- uses: actions/checkout@v4
30+
- uses: actions/setup-python@v5
31+
with:
32+
python-version: "3.11"
33+
- name: Install build tooling
34+
run: |
35+
python -m pip install --upgrade pip
36+
python -m pip install build twine pytest httpx
37+
- name: Run offline unit tests
38+
run: pytest -q tests/test_svc.py
39+
- name: Build distributions
40+
run: python -m build
41+
- name: Twine check
42+
run: python -m twine check dist/*
43+
- name: Upload dist artifacts
44+
uses: actions/upload-artifact@v4
45+
with:
46+
name: dist
47+
path: dist/
48+
49+
publish-testpypi:
50+
name: Publish to TestPyPI
51+
needs: build
52+
runs-on: ubuntu-latest
53+
environment:
54+
name: testpypi
55+
url: https://test.pypi.org/project/agentnetwork/
56+
permissions:
57+
id-token: write # Required for OIDC Trusted Publishing
58+
steps:
59+
- name: Download dist artifacts
60+
uses: actions/download-artifact@v4
61+
with:
62+
name: dist
63+
path: dist/
64+
- name: Publish to TestPyPI
65+
uses: pypa/gh-action-pypi-publish@release/v1
66+
with:
67+
repository-url: https://test.pypi.org/legacy/
68+
packages-dir: dist/
69+
skip-existing: true

.gitignore

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Byte-compiled / optimized
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
*.so
6+
7+
# Distribution / packaging
8+
.Python
9+
build/
10+
dist/
11+
sdist/
12+
wheels/
13+
share/python-wheels/
14+
*.egg-info/
15+
*.egg
16+
MANIFEST
17+
18+
# PyInstaller / installer logs
19+
*.manifest
20+
*.spec
21+
pip-log.txt
22+
pip-delete-this-directory.txt
23+
24+
# Unit test / coverage
25+
.pytest_cache/
26+
.coverage
27+
.coverage.*
28+
.cache
29+
nosetests.xml
30+
coverage.xml
31+
*.cover
32+
.hypothesis/
33+
.tox/
34+
htmlcov/
35+
36+
# Virtual envs
37+
.venv/
38+
venv/
39+
env/
40+
ENV/
41+
42+
# Editor / OS
43+
.idea/
44+
.vscode/
45+
*.swp
46+
*.swo
47+
.DS_Store
48+
49+
# Type checkers
50+
.mypy_cache/
51+
.pyre/
52+
.pytype/
53+
54+
# Local dev artifacts
55+
*.log
56+
.env
57+
.env.local

CHANGELOG.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Changelog
2+
3+
All notable changes to **anet** (PyPI: `agentnetwork`) are recorded here.
4+
The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
5+
and the project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6+
7+
## [1.1.0] — 2026-04-30
8+
9+
First public release on PyPI.
10+
11+
### Added
12+
- **`anet.AgentNetwork`** — synchronous REST client covering the daemon's
13+
`/api/{status,peers,credits,tasks,ans,discover,dm,reputation,knowledge,topics,adp,traces,metrics}`
14+
surface (30+ verbs). Single dependency: `httpx`.
15+
- **`anet.lifecycle.Lifecycle`** — frozen 5-verb stable surface
16+
(`claim → evidence_post → bundle_json → submit → accept`) mirroring the
17+
CLI's `STABLE-v1` contract. Auto token resolution from
18+
`$ANET_TOKEN` / `$HOME/.anet/api_token`. POR-CID stash compatible with
19+
the Go CLI so SDK and CLI are interchangeable mid-workflow.
20+
- **`anet.svc.SvcClient`** — full Python client for the P2P **service
21+
gateway** (`/api/svc/*`, 11 endpoints): `register`, `unregister`, `list`,
22+
`show`, `discover`, `call`, `stream` (SSE), `ws_url`, `health`, `meta`,
23+
`audit`. Supports all 5 transport modes (`rr`, `server-stream`, `chunked`,
24+
`bidi-ws`, `bidi-mcp-stdio`). `passthrough_status` for HTTP-status-aware
25+
callers. Body auto-encoding for dict / bytes / str.
26+
- **`anet.examples.ex01-03`** — runnable demos for register / discover-and-call /
27+
stream-consume, all importable as `python -m anet.examples.ex0X_*`.
28+
- Offline unit tests under [`tests/test_svc.py`](tests/test_svc.py) using
29+
`httpx.MockTransport` — no daemon required.
30+
31+
### Tested against
32+
- `anet` daemon **v1.1.10** (P2P Service Gateway closed-in-this-release).
33+
- CPython 3.9, 3.10, 3.11, 3.12 on macOS and Linux.
34+
35+
[1.1.0]: https://github.com/ChatChatTech/anet-python-sdk/releases/tag/v1.1.0

0 commit comments

Comments
 (0)