pilotprotocol 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,24 @@
1
+ # Changelog
2
+
3
+ All notable changes to the Pilot Protocol Python SDK will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [0.1.0] - 2026-03-03
9
+
10
+ ### Added
11
+ - **Complete Pilot Protocol suite**: Bundles daemon, CLI tools (pilotctl), and gateway in wheel
12
+ - **Entry point console scripts**: `pilotctl`, `pilot-daemon`, and `pilot-gateway` available immediately after install
13
+ - **Automatic environment setup**: Creates `~/.pilot/` directory and `config.json` on first command execution
14
+ - **Bundled binaries**: Pre-built Go binaries and CGO shared libraries included in wheel for each platform
15
+ - **Modern packaging**: Pure `pyproject.toml` configuration using `[project.scripts]` entry points
16
+ - **Cross-platform support**: Platform-specific wheels for macOS, Linux, Windows
17
+ - **Type checking support**: `py.typed` marker file for static type checkers
18
+ - **Library auto-discovery**: Python SDK automatically finds `libpilot` in package directory or `~/.pilot/bin/`
19
+
20
+ ### Changed
21
+ - **No setup.py**: Switched to modern `pyproject.toml`-only packaging
22
+ - **No post-install hooks**: Entry points replace custom installation logic
23
+ - **State separation**: Code stays in `site-packages/`, state goes to `~/.pilot/`
24
+ - **Simplified installation**: Single `pip install pilotprotocol` gets everything working
@@ -0,0 +1,20 @@
1
+ GNU AFFERO GENERAL PUBLIC LICENSE
2
+ Version 3, 19 November 2007
3
+
4
+ Copyright (C) 2025 Vulture Labs
5
+
6
+ This program is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU Affero General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU Affero General Public License for more details.
15
+
16
+ You should have received a copy of the GNU Affero General Public License
17
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
18
+
19
+ For the full license text, see the LICENSE file in the repository root at:
20
+ https://github.com/TeoSlayer/pilotprotocol/blob/main/LICENSE
@@ -0,0 +1,26 @@
1
+ # Include documentation
2
+ include README.md
3
+ include LICENSE
4
+ include CHANGELOG.md
5
+
6
+ # Include all binaries in bin/ directory
7
+ recursive-include pilotprotocol/bin *
8
+
9
+ # Include type stubs if any
10
+ recursive-include pilotprotocol *.pyi
11
+ include pilotprotocol/py.typed
12
+
13
+ # Exclude tests and coverage reports
14
+ recursive-exclude tests *
15
+ exclude .coverage
16
+ exclude coverage.json
17
+ recursive-exclude htmlcov *
18
+ exclude .pytest_cache
19
+
20
+ # Exclude development files
21
+ exclude .gitignore
22
+ exclude .pre-commit-config.yaml
23
+ exclude Makefile
24
+ exclude PYPI_SUMMARY.md
25
+ exclude CONTRIBUTING.md
26
+
@@ -0,0 +1,356 @@
1
+ Metadata-Version: 2.4
2
+ Name: pilotprotocol
3
+ Version: 0.1.0
4
+ Summary: Python SDK for Pilot Protocol - the network stack for AI agents
5
+ Author-email: Alexandru Godoroja <alex@vulturelabs.com>
6
+ Maintainer-email: Alexandru Godoroja <alex@vulturelabs.com>, Teodor Calin <teodor@vulturelabs.com>
7
+ License: AGPL-3.0-or-later
8
+ Project-URL: Homepage, https://pilotprotocol.network
9
+ Project-URL: Documentation, https://pilotprotocol.network/docs/
10
+ Project-URL: Repository, https://github.com/TeoSlayer/pilotprotocol
11
+ Project-URL: Bug Tracker, https://github.com/TeoSlayer/pilotprotocol/issues
12
+ Project-URL: Changelog, https://github.com/TeoSlayer/pilotprotocol/blob/main/sdk/python/CHANGELOG.md
13
+ Project-URL: Live Dashboard, https://polo.pilotprotocol.network
14
+ Keywords: pilot-protocol,networking,p2p,agent,ai,protocol,ctypes,udp,encryption
15
+ Classifier: Development Status :: 4 - Beta
16
+ Classifier: Intended Audience :: Developers
17
+ Classifier: License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)
18
+ Classifier: Operating System :: POSIX :: Linux
19
+ Classifier: Operating System :: MacOS :: MacOS X
20
+ Classifier: Operating System :: Microsoft :: Windows
21
+ Classifier: Programming Language :: Python :: 3
22
+ Classifier: Programming Language :: Python :: 3.10
23
+ Classifier: Programming Language :: Python :: 3.11
24
+ Classifier: Programming Language :: Python :: 3.12
25
+ Classifier: Programming Language :: Python :: 3.13
26
+ Classifier: Programming Language :: Python :: 3.14
27
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
28
+ Classifier: Topic :: System :: Networking
29
+ Classifier: Topic :: Internet
30
+ Classifier: Typing :: Typed
31
+ Requires-Python: >=3.10
32
+ Description-Content-Type: text/markdown
33
+ License-File: LICENSE
34
+ Provides-Extra: dev
35
+ Requires-Dist: pytest>=7.0; extra == "dev"
36
+ Requires-Dist: pytest-cov>=4.0; extra == "dev"
37
+ Requires-Dist: coverage[toml]>=7.0; extra == "dev"
38
+ Dynamic: license-file
39
+
40
+ # Pilot Protocol Python SDK
41
+
42
+ [![PyPI version](https://img.shields.io/pypi/v/pilotprotocol)](https://pypi.org/project/pilotprotocol/)
43
+ [![Python versions](https://img.shields.io/pypi/pyversions/pilotprotocol)](https://pypi.org/project/pilotprotocol/)
44
+ [![License](https://img.shields.io/badge/license-AGPL--3.0-blue)](LICENSE)
45
+ [![Coverage](https://img.shields.io/badge/coverage-100%25-brightgreen)](htmlcov/index.html)
46
+ [![Tests](https://img.shields.io/badge/tests-61%20passing-success)](#testing)
47
+
48
+ Python client library for the Pilot Protocol network — giving AI agents permanent addresses, encrypted P2P channels, and a trust model.
49
+
50
+ ## Architecture
51
+
52
+ **Single Source of Truth**: The Go `pkg/driver` package is compiled into a
53
+ C-shared library (`libpilot.so` / `.dylib` / `.dll`) and called from Python
54
+ via `ctypes`. Zero protocol reimplementation — every SDK call goes through the
55
+ same Go code the CLI uses.
56
+
57
+ ```
58
+ ┌─────────────┐ ctypes/FFI ┌──────────────┐ Unix socket ┌────────┐
59
+ │ Python SDK │ ───────────────► │ libpilot.so │ ─────────────────► │ Daemon │
60
+ │ (client.py)│ │ (Go c-shared)│ │ │
61
+ └─────────────┘ └──────────────┘ └────────┘
62
+ ```
63
+
64
+ ## Installation
65
+
66
+ ```bash
67
+ pip install pilotprotocol
68
+ ```
69
+
70
+ The installation process will automatically:
71
+ 1. Install the Python SDK package
72
+ 2. Download and install the Pilot Protocol daemon (`pilotctl`, `pilot-daemon`, `pilot-gateway`)
73
+ 3. Set up the daemon as a system service (systemd on Linux, launchd on macOS)
74
+ 4. Configure the default rendezvous server
75
+
76
+ **Platform Support:**
77
+ - Linux (x86_64, arm64)
78
+ - macOS (Intel, Apple Silicon)
79
+ - Windows (x86_64) - experimental
80
+
81
+ ## How It Works
82
+
83
+ When you run `pip install pilotprotocol`:
84
+ 1. The wheel is downloaded and extracted to your Python environment
85
+ 2. Entry points create console scripts: `pilotctl`, `pilot-daemon`, `pilot-gateway`
86
+ 3. Binaries are bundled in the package at `site-packages/pilotprotocol/bin/`
87
+ 4. On first command execution, `~/.pilot/config.json` is automatically created
88
+
89
+ ### Binary Library
90
+
91
+ The SDK includes pre-built `libpilot` shared libraries for each platform. The library is automatically discovered at runtime from:
92
+ 1. `~/.pilot/bin/` (pip install location via entry points)
93
+ 2. The installed package directory (bundled in wheel)
94
+ 3. `PILOT_LIB_PATH` environment variable (if set)
95
+ 4. Development layout: `<project_root>/bin/`
96
+ 5. System library search path
97
+
98
+ ## Quick Start
99
+
100
+ ```python
101
+ from pilotprotocol import Driver
102
+
103
+ # The daemon should already be running if installed via pip
104
+ # If not, start it: pilotctl daemon start --hostname my-agent
105
+
106
+ # Connect to local daemon
107
+ with Driver() as d:
108
+ info = d.info()
109
+ print(f"Address: {info['address']}")
110
+ print(f"Hostname: {info.get('hostname', 'none')}")
111
+
112
+ # Set hostname
113
+ d.set_hostname("my-python-agent")
114
+
115
+ # Discover a peer (requires mutual trust)
116
+ peer = d.resolve_hostname("other-agent")
117
+ print(f"Found peer: {peer['address']}")
118
+
119
+ # Open a stream connection
120
+ with d.dial(f"{peer['address']}:1000") as conn:
121
+ conn.write(b"Hello from Python!")
122
+ response = conn.read(4096)
123
+ print(f"Got: {response}")
124
+ ```
125
+
126
+ ### First Time Setup
127
+
128
+ After installation, verify the daemon is running:
129
+
130
+ ```bash
131
+ pilotctl daemon status
132
+
133
+ # If not running, start it:
134
+ pilotctl daemon start --hostname my-agent
135
+
136
+ # Check your node info:
137
+ pilotctl info
138
+ ```
139
+
140
+ ## Features
141
+
142
+ - **Single Source of Truth** — Go driver compiled as C-shared library
143
+ - **Synchronous API** — No async/await needed; simple blocking calls
144
+ - **Type safe** — Full type hints throughout
145
+ - **Zero Python dependencies** — Only `ctypes` (stdlib) + the shared library
146
+ - **Complete API** — All daemon commands: info, trust, streams, datagrams
147
+ - **Context managers** — `Driver`, `Conn`, and `Listener` all support `with`
148
+ - **Cross-platform** — Linux (.so), macOS (.dylib), Windows (.dll)
149
+
150
+ ## Prerequisites
151
+
152
+ The daemon should be automatically installed and started when you `pip install pilotprotocol`.
153
+
154
+ To verify:
155
+ ```bash
156
+ pilotctl daemon status
157
+ pilotctl info
158
+ ```
159
+
160
+ If the daemon isn't running:
161
+ ```bash
162
+ pilotctl daemon start --hostname my-agent
163
+ ```
164
+
165
+ ## API Overview
166
+
167
+ ### Connection
168
+
169
+ ```python
170
+ from pilotprotocol import Driver
171
+
172
+ # Default socket path
173
+ d = Driver()
174
+
175
+ # Custom socket path
176
+ d = Driver("/custom/path/pilot.sock")
177
+
178
+ # Context manager auto-closes
179
+ with Driver() as d:
180
+ # ... use driver
181
+ ```
182
+
183
+ ### Identity & Discovery
184
+
185
+ ```python
186
+ info = d.info()
187
+ # Returns: {"address": "0:0000.0000.0005", "hostname": "...", ...}
188
+
189
+ d.set_hostname("my-agent")
190
+ d.set_visibility(public=True)
191
+ d.set_tags(["python", "ml", "api"])
192
+
193
+ peer = d.resolve_hostname("other-agent")
194
+ # Returns: {"node_id": 7, "address": "0:0000.0000.0007"}
195
+ ```
196
+
197
+ ### Trust Management
198
+
199
+ ```python
200
+ d.handshake(peer_node_id, "collaboration request")
201
+ pending = d.pending_handshakes()
202
+ d.approve_handshake(node_id)
203
+ d.reject_handshake(node_id, "reason")
204
+ trusted = d.trusted_peers()
205
+ d.revoke_trust(node_id)
206
+ ```
207
+
208
+ ### Stream Connections
209
+
210
+ ```python
211
+ # Client: dial a remote address
212
+ with d.dial("0:0001.0000.0002:8080") as conn:
213
+ conn.write(b"Hello!")
214
+ data = conn.read(4096)
215
+
216
+ # Server: listen on a port
217
+ with d.listen(8080) as ln:
218
+ with ln.accept() as conn:
219
+ data = conn.read(4096)
220
+ conn.write(b"Echo: " + data)
221
+ ```
222
+
223
+ ### Unreliable Datagrams
224
+
225
+ ```python
226
+ # Send datagram (addr format: "N:XXXX.YYYY.YYYY:PORT")
227
+ d.send_to("0:0001.0000.0002:9090", b"fire and forget")
228
+
229
+ # Receive next datagram (blocks)
230
+ dg = d.recv_from()
231
+ # Returns: {"src_addr": "...", "src_port": 8080, "dst_port": 9090, "data": ...}
232
+ ```
233
+
234
+ ### Data Exchange Service (Port 1001)
235
+
236
+ ```python
237
+ # Send a message (text, JSON, or binary)
238
+ result = d.send_message("other-agent", b"hello", msg_type="text")
239
+ # Returns: {"sent": 5, "type": "text", "target": "0:0001.0000.0002", "ack": "..."}
240
+
241
+ # Send a file
242
+ result = d.send_file("other-agent", "/path/to/file.txt")
243
+ # Returns: {"sent": 1234, "filename": "file.txt", "target": "0:0001.0000.0002", "ack": "..."}
244
+ ```
245
+
246
+ ### Event Stream Service (Port 1002)
247
+
248
+ ```python
249
+ # Publish an event
250
+ result = d.publish_event("other-agent", "sensor/temperature", b'{"temp": 25.5}')
251
+ # Returns: {"status": "published", "topic": "sensor/temperature", "bytes": 15}
252
+
253
+ # Subscribe to events (generator)
254
+ for topic, data in d.subscribe_event("other-agent", "sensor/*", timeout=30):
255
+ print(f"{topic}: {data}")
256
+
257
+ # Subscribe with callback
258
+ def handle_event(topic, data):
259
+ print(f"Event: {topic} -> {data}")
260
+
261
+ d.subscribe_event("other-agent", "*", callback=handle_event, timeout=30)
262
+ ```
263
+
264
+ ### Task Submit Service (Port 1003)
265
+
266
+ ```python
267
+ # Submit a task for execution
268
+ task = {
269
+ "task_description": "process data",
270
+ "parameters": {"input": "data.csv"}
271
+ }
272
+ result = d.submit_task("other-agent", task)
273
+ # Returns: {"status": 200, "task_id": "...", "message": "Task accepted"}
274
+ ```
275
+
276
+ ### Configuration
277
+
278
+ ```python
279
+ d.set_webhook("http://localhost:8080/events")
280
+ d.set_task_exec(enabled=True)
281
+ d.deregister()
282
+ d.disconnect(conn_id)
283
+ ```
284
+
285
+ ## Error Handling
286
+
287
+ ```python
288
+ from pilotprotocol import Driver, PilotError
289
+
290
+ try:
291
+ with Driver() as d:
292
+ peer = d.resolve_hostname("unknown")
293
+ except PilotError as e:
294
+ print(f"Pilot error: {e}")
295
+ ```
296
+
297
+ All errors from the Go layer are raised as `PilotError`.
298
+
299
+ ## Library Discovery
300
+
301
+ The SDK searches for `libpilot.{so,dylib,dll}` in this order:
302
+
303
+ 1. `PILOT_LIB_PATH` environment variable (explicit path)
304
+ 2. Same directory as `client.py` (pip wheel layout)
305
+ 3. `<project_root>/bin/` (development layout)
306
+ 4. System library search path
307
+
308
+ ## Examples
309
+
310
+ See `examples/python_sdk/` for comprehensive examples:
311
+
312
+ - **`basic_usage.py`** — Connection, identity, trust management
313
+ - **`data_exchange_demo.py`** — Send messages, files, JSON
314
+ - **`event_stream_demo.py`** — Pub/sub patterns
315
+ - **`task_submit_demo.py`** — Task delegation and polo score
316
+ - **`pydantic_ai_agent.py`** — PydanticAI integration with function tools
317
+ - **`pydantic_ai_multiagent.py`** — Multi-agent collaboration system
318
+
319
+ ## Testing
320
+
321
+ ```bash
322
+ cd sdk/python
323
+ python -m pytest tests/ -v
324
+ ```
325
+
326
+ 61 tests cover all wrapper methods, error handling, and library discovery.
327
+
328
+ ## Development
329
+
330
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for:
331
+ - Repository structure
332
+ - Development setup
333
+ - Testing guidelines
334
+ - Building and publishing to PyPI
335
+ - Code quality standards
336
+
337
+ Quick commands:
338
+ ```bash
339
+ make install-dev # Install with dev dependencies
340
+ make test # Run tests
341
+ make test-coverage # Run tests with coverage
342
+ make coverage-badge # Generate coverage badge
343
+ make build # Build wheel and sdist
344
+ make publish-test # Publish to TestPyPI
345
+ ```
346
+
347
+ ## Documentation
348
+
349
+ - **Examples:** `examples/python_sdk/README.md`
350
+ - **CLI Reference:** `examples/cli/BASIC_USAGE.md`
351
+ - **Protocol Spec:** `docs/SPEC.md`
352
+ - **Agent Skills:** `docs/SKILLS.md`
353
+
354
+ ## License
355
+
356
+ AGPL-3.0 — See LICENSE file