unaiverse 0.1.6__cp311-cp311-musllinux_1_2_x86_64.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.

Potentially problematic release.


This version of unaiverse might be problematic. Click here for more details.

Files changed (50) hide show
  1. unaiverse/__init__.py +19 -0
  2. unaiverse/agent.py +2008 -0
  3. unaiverse/agent_basics.py +1846 -0
  4. unaiverse/clock.py +191 -0
  5. unaiverse/dataprops.py +1209 -0
  6. unaiverse/hsm.py +1880 -0
  7. unaiverse/modules/__init__.py +18 -0
  8. unaiverse/modules/cnu/__init__.py +17 -0
  9. unaiverse/modules/cnu/cnus.py +536 -0
  10. unaiverse/modules/cnu/layers.py +261 -0
  11. unaiverse/modules/cnu/psi.py +60 -0
  12. unaiverse/modules/hl/__init__.py +15 -0
  13. unaiverse/modules/hl/hl_utils.py +411 -0
  14. unaiverse/modules/networks.py +1509 -0
  15. unaiverse/modules/utils.py +680 -0
  16. unaiverse/networking/__init__.py +16 -0
  17. unaiverse/networking/node/__init__.py +18 -0
  18. unaiverse/networking/node/connpool.py +1261 -0
  19. unaiverse/networking/node/node.py +2223 -0
  20. unaiverse/networking/node/profile.py +446 -0
  21. unaiverse/networking/node/tokens.py +79 -0
  22. unaiverse/networking/p2p/__init__.py +198 -0
  23. unaiverse/networking/p2p/go.mod +127 -0
  24. unaiverse/networking/p2p/go.sum +548 -0
  25. unaiverse/networking/p2p/golibp2p.py +18 -0
  26. unaiverse/networking/p2p/golibp2p.pyi +135 -0
  27. unaiverse/networking/p2p/lib.go +2714 -0
  28. unaiverse/networking/p2p/lib.go.sha256 +1 -0
  29. unaiverse/networking/p2p/lib_types.py +312 -0
  30. unaiverse/networking/p2p/message_pb2.py +63 -0
  31. unaiverse/networking/p2p/messages.py +265 -0
  32. unaiverse/networking/p2p/mylogger.py +77 -0
  33. unaiverse/networking/p2p/p2p.py +929 -0
  34. unaiverse/networking/p2p/proto-go/message.pb.go +616 -0
  35. unaiverse/networking/p2p/unailib.cpython-311-x86_64-linux-musl.so +0 -0
  36. unaiverse/streamlib/__init__.py +15 -0
  37. unaiverse/streamlib/streamlib.py +210 -0
  38. unaiverse/streams.py +770 -0
  39. unaiverse/utils/__init__.py +16 -0
  40. unaiverse/utils/ask_lone_wolf.json +27 -0
  41. unaiverse/utils/lone_wolf.json +19 -0
  42. unaiverse/utils/misc.py +305 -0
  43. unaiverse/utils/sandbox.py +293 -0
  44. unaiverse/utils/server.py +435 -0
  45. unaiverse/world.py +175 -0
  46. unaiverse-0.1.6.dist-info/METADATA +365 -0
  47. unaiverse-0.1.6.dist-info/RECORD +50 -0
  48. unaiverse-0.1.6.dist-info/WHEEL +5 -0
  49. unaiverse-0.1.6.dist-info/licenses/LICENSE +43 -0
  50. unaiverse-0.1.6.dist-info/top_level.txt +1 -0
@@ -0,0 +1,198 @@
1
+ """
2
+ █████ █████ ██████ █████ █████ █████ █████ ██████████ ███████████ █████████ ██████████
3
+ ░░███ ░░███ ░░██████ ░░███ ░░███ ░░███ ░░███ ░░███░░░░░█░░███░░░░░███ ███░░░░░███░░███░░░░░█
4
+ ░███ ░███ ░███░███ ░███ ██████ ░███ ░███ ░███ ░███ █ ░ ░███ ░███ ░███ ░░░ ░███ █ ░
5
+ ░███ ░███ ░███░░███░███ ░░░░░███ ░███ ░███ ░███ ░██████ ░██████████ ░░█████████ ░██████
6
+ ░███ ░███ ░███ ░░██████ ███████ ░███ ░░███ ███ ░███░░█ ░███░░░░░███ ░░░░░░░░███ ░███░░█
7
+ ░███ ░███ ░███ ░░█████ ███░░███ ░███ ░░░█████░ ░███ ░ █ ░███ ░███ ███ ░███ ░███ ░ █
8
+ ░░████████ █████ ░░█████░░████████ █████ ░░███ ██████████ █████ █████░░█████████ ██████████
9
+ ░░░░░░░░ ░░░░░ ░░░░░ ░░░░░░░░ ░░░░░ ░░░ ░░░░░░░░░░ ░░░░░ ░░░░░ ░░░░░░░░░ ░░░░░░░░░░
10
+ A Collectionless AI Project (https://collectionless.ai)
11
+ Registration/Login: https://unaiverse.io
12
+ Code Repositories: https://github.com/collectionlessai/
13
+ Main Developers: Stefano Melacci (Project Leader), Christian Di Maio, Tommaso Guidi
14
+ """
15
+ from . import messages
16
+ from . import p2p
17
+ from . import golibp2p
18
+ from . import lib_types
19
+ import os
20
+ import sys
21
+ import glob
22
+ import json
23
+ import ctypes
24
+ import hashlib
25
+ import platform
26
+ import warnings
27
+ from typing import cast
28
+ from .messages import Msg
29
+ from .p2p import P2P, P2PError
30
+ from .golibp2p import GoLibP2P # Your stub interface definition
31
+ from .lib_types import TypeInterface # Assuming TypeInterface handles the void* results
32
+
33
+
34
+ # --- Helper Functions ---
35
+ def _get_lib_filename():
36
+ """Determines the correct shared library filename based on the OS."""
37
+ system = platform.system()
38
+ if system == 'Linux':
39
+ return 'unailib*.so'
40
+ elif system == 'Darwin':
41
+ return 'unailib*.dylib'
42
+ elif system == 'Windows':
43
+ return 'unailib*.pyd'
44
+ # This error should ideally never be reached if setup.py ran correctly.
45
+ raise ImportError(f"Unsupported operating system for shared library: {system}")
46
+
47
+ def _get_file_hash(filepath):
48
+ """Calculates the SHA256 hash of a file, returning None if it doesn't exist."""
49
+ if not os.path.exists(filepath):
50
+ return None
51
+ sha256_hash = hashlib.sha256()
52
+ with open(filepath, "rb") as f:
53
+ for byte_block in iter(lambda: f.read(4096), b""):
54
+ sha256_hash.update(byte_block)
55
+ return sha256_hash.hexdigest()
56
+
57
+ def _developer_source_check():
58
+ """
59
+ If source files are present (i.e., in a dev environment), check if the
60
+ compiled library is in sync with the source code.
61
+ """
62
+ go_source_file = os.path.join(_lib_dir, 'lib.go')
63
+ hash_file = go_source_file + '.sha256'
64
+
65
+ # This check only runs if all dev files are present. For users who
66
+ # installed from a wheel, these files won't exist, and this is skipped.
67
+ if os.path.exists(go_source_file) and os.path.exists(hash_file):
68
+ current_source_hash = _get_file_hash(go_source_file)
69
+
70
+ stored_build_hash = None
71
+ with open(hash_file, 'r') as f:
72
+ stored_build_hash = f.read().strip()
73
+
74
+ if current_source_hash != stored_build_hash:
75
+ # Use warnings.warn for a standard, non-intrusive developer warning.
76
+ warnings.warn(
77
+ "\n" + "="*80 +
78
+ "\nWARNING: The Go source file (lib.go) has been modified since the shared\n"
79
+ "library was last compiled. Your running code may not reflect recent changes.\n\n"
80
+ "To fix this, run: pip install -e .\n" +
81
+ "="*80,
82
+ UserWarning
83
+ )
84
+
85
+ # --- Main Library Loading ---
86
+ # The shared library is guaranteed by the build process to be in this directory.
87
+ _lib_dir = os.path.dirname(os.path.abspath(__file__))
88
+ _shared_lib = None
89
+
90
+ try:
91
+ _results = glob.glob(os.path.join(_lib_dir, _get_lib_filename()))
92
+ _lib_path = os.path.join(_lib_dir, _results[0])
93
+ _shared_lib = ctypes.CDLL(_lib_path)
94
+ except OSError as e:
95
+ print(
96
+ f"FATAL: Could not load the required p2p shared library from {_lib_path}.\n"
97
+ "This indicates a corrupted or missing installation. "
98
+ "Please try reinstalling the 'unaiverse' package.\n"
99
+ f"Underlying error: {e}",
100
+ file=sys.stderr
101
+ )
102
+ raise ImportError("Failed to load the UNaIVERSE p2p shared library.") from e
103
+
104
+ # Run the check after successfully loading the library.
105
+ if _shared_lib is not None:
106
+ _developer_source_check()
107
+ print(f"UNaIVERSE: Successfully loaded p2p library from {_lib_path}")
108
+
109
+ # --- Function Prototypes (argtypes and restype) ---
110
+ # Using void* for returned C strings, requiring TypeInterface for conversion/freeing.
111
+
112
+ # Define argtypes for the Go init function here
113
+ _shared_lib.InitializeLibrary.argtypes = [ctypes.c_int, ctypes.c_int, ctypes.c_int, ctypes.c_int, ctypes.c_int]
114
+ _shared_lib.InitializeLibrary.restype = None
115
+
116
+ # Node Lifecycle & Info
117
+ _shared_lib.CreateNode.argtypes = [ctypes.c_int, ctypes.c_char_p, ctypes.c_int, ctypes.c_char_p, ctypes.c_int, ctypes.c_int,
118
+ ctypes.c_int, ctypes.c_int, ctypes.c_int, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_char_p]
119
+ _shared_lib.CreateNode.restype = ctypes.c_void_p # Treat returned *C.char as opaque pointer
120
+
121
+ _shared_lib.CloseNode.argtypes = [ctypes.c_int]
122
+ _shared_lib.CloseNode.restype = ctypes.c_void_p # Treat returned *C.char as opaque pointer
123
+
124
+ _shared_lib.GetNodeAddresses.argtypes = [ctypes.c_int, ctypes.c_char_p] # Input is still a Python string -> C string
125
+ _shared_lib.GetNodeAddresses.restype = ctypes.c_void_p # Treat returned *C.char as opaque pointer
126
+
127
+ _shared_lib.GetConnectedPeers.argtypes = [ctypes.c_int]
128
+ _shared_lib.GetConnectedPeers.restype = ctypes.c_void_p # Treat returned *C.char as opaque pointer
129
+
130
+ _shared_lib.GetRendezvousPeers.argtypes = [ctypes.c_int]
131
+ _shared_lib.GetRendezvousPeers.restype = ctypes.c_void_p # Treat returned *C.char as opaque pointer
132
+
133
+ # Peer Connection
134
+ _shared_lib.ConnectTo.argtypes = [ctypes.c_int, ctypes.c_char_p]
135
+ _shared_lib.ConnectTo.restype = ctypes.c_void_p # Treat returned *C.char as opaque pointer
136
+
137
+ _shared_lib.DisconnectFrom.argtypes = [ctypes.c_int, ctypes.c_char_p]
138
+ _shared_lib.DisconnectFrom.restype = ctypes.c_void_p # Treat returned *C.char as opaque pointer
139
+
140
+ # Direct Messaging
141
+ _shared_lib.SendMessageToPeer.argtypes = [ctypes.c_int, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_int]
142
+ _shared_lib.SendMessageToPeer.restype = ctypes.c_void_p # Returns status code, not pointer
143
+
144
+ # Message Queue
145
+ _shared_lib.MessageQueueLength.argtypes = [ctypes.c_int]
146
+ _shared_lib.MessageQueueLength.restype = ctypes.c_int # Returns length, not pointer
147
+
148
+ _shared_lib.PopMessages.argtypes = [ctypes.c_int]
149
+ _shared_lib.PopMessages.restype = ctypes.c_void_p # Treat returned *C.char as opaque pointer
150
+
151
+ # PubSub
152
+ _shared_lib.SubscribeToTopic.argtypes = [ctypes.c_int, ctypes.c_char_p]
153
+ _shared_lib.SubscribeToTopic.restype = ctypes.c_void_p # Treat returned *C.char as opaque pointer
154
+
155
+ _shared_lib.UnsubscribeFromTopic.argtypes = [ctypes.c_int, ctypes.c_char_p]
156
+ _shared_lib.UnsubscribeFromTopic.restype = ctypes.c_void_p # Treat returned *C.char as opaque pointer
157
+
158
+ # Relay Client
159
+ _shared_lib.ReserveOnRelay.argtypes = [ctypes.c_int, ctypes.c_char_p]
160
+ _shared_lib.ReserveOnRelay.restype = ctypes.c_void_p # Treat returned *C.char as opaque pointer
161
+
162
+ # Memory Management
163
+ # FreeString now accepts the opaque pointer directly
164
+ _shared_lib.FreeString.argtypes = [ctypes.c_void_p]
165
+ _shared_lib.FreeString.restype = None # Void return
166
+
167
+ _shared_lib.FreeInt.argtypes = [ctypes.POINTER(ctypes.c_int)] # Still expects a pointer to int
168
+ _shared_lib.FreeInt.restype = None # Void return
169
+
170
+ # --- Python Interface Setup ---
171
+
172
+ # Import necessary components
173
+ # IMPORTANT: TypeInterface (or equivalent logic) MUST now handle converting
174
+ # the c_char_p results back to strings/JSON before freeing.
175
+ # Ensure TypeInterface methods like from_go_string_to_json are adapted for this.
176
+
177
+ # Import the stub type for type checking
178
+ try:
179
+ from .golibp2p import GoLibP2P # Your stub interface definition
180
+ except ImportError:
181
+ print("Warning: GoLibP2P stub not found. Type checking will be limited.", file=sys.stderr)
182
+ GoLibP2P = ctypes.CDLL
183
+
184
+ # Cast the loaded library object to the stub type
185
+ _shared_lib_typed = cast(GoLibP2P, _shared_lib)
186
+
187
+ # Attach the typed shared library object to the P2P class
188
+ P2P.libp2p = _shared_lib_typed
189
+ TypeInterface.libp2p = _shared_lib_typed # Attach to TypeInterface if needed
190
+
191
+ # Attach the typed shared library object to the P2PError class
192
+
193
+ # Define the public API of this package
194
+ __all__ = [
195
+ "P2P",
196
+ "P2PError",
197
+ "TypeInterface" # Expose TypeInterface if users need its conversion helpers directly
198
+ ]
@@ -0,0 +1,127 @@
1
+ module unaiverse/networking/p2p/lib
2
+
3
+ go 1.24.5
4
+
5
+ require (
6
+ github.com/caddyserver/certmagic v0.25.0
7
+ github.com/ipfs/go-log/v2 v2.8.0
8
+ github.com/ipshipyard/p2p-forge v0.6.1
9
+ github.com/libp2p/go-libp2p v0.43.0
10
+ github.com/libp2p/go-libp2p-kad-dht v0.34.0
11
+ github.com/libp2p/go-libp2p-pubsub v0.15.0
12
+ github.com/multiformats/go-multiaddr v0.16.1
13
+ google.golang.org/protobuf v1.36.9
14
+ )
15
+
16
+ require (
17
+ github.com/benbjohnson/clock v1.3.5 // indirect
18
+ github.com/beorn7/perks v1.0.1 // indirect
19
+ github.com/caddyserver/zerossl v0.1.3 // indirect
20
+ github.com/cespare/xxhash/v2 v2.3.0 // indirect
21
+ github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c // indirect
22
+ github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.0 // indirect
23
+ github.com/filecoin-project/go-clock v0.1.0 // indirect
24
+ github.com/flynn/noise v1.1.0 // indirect
25
+ github.com/francoispqt/gojay v1.2.13 // indirect
26
+ github.com/go-logr/logr v1.4.3 // indirect
27
+ github.com/go-logr/stdr v1.2.2 // indirect
28
+ github.com/gogo/protobuf v1.3.2 // indirect
29
+ github.com/google/gopacket v1.1.19 // indirect
30
+ github.com/google/uuid v1.6.0 // indirect
31
+ github.com/gorilla/websocket v1.5.3 // indirect
32
+ github.com/hashicorp/golang-lru v1.0.2 // indirect
33
+ github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
34
+ github.com/huin/goupnp v1.3.0 // indirect
35
+ github.com/ipfs/boxo v0.33.1 // indirect
36
+ github.com/ipfs/go-cid v0.5.0 // indirect
37
+ github.com/ipfs/go-datastore v0.8.2 // indirect
38
+ github.com/ipld/go-ipld-prime v0.21.0 // indirect
39
+ github.com/jackpal/go-nat-pmp v1.0.2 // indirect
40
+ github.com/jbenet/go-temp-err-catcher v0.1.0 // indirect
41
+ github.com/klauspost/compress v1.18.0 // indirect
42
+ github.com/klauspost/cpuid/v2 v2.3.0 // indirect
43
+ github.com/koron/go-ssdp v0.0.6 // indirect
44
+ github.com/libdns/libdns v1.1.1 // indirect
45
+ github.com/libp2p/go-buffer-pool v0.1.0 // indirect
46
+ github.com/libp2p/go-cidranger v1.1.0 // indirect
47
+ github.com/libp2p/go-flow-metrics v0.3.0 // indirect
48
+ github.com/libp2p/go-libp2p-asn-util v0.4.1 // indirect
49
+ github.com/libp2p/go-libp2p-kbucket v0.7.0 // indirect
50
+ github.com/libp2p/go-libp2p-record v0.3.1 // indirect
51
+ github.com/libp2p/go-libp2p-routing-helpers v0.7.5 // indirect
52
+ github.com/libp2p/go-msgio v0.3.0 // indirect
53
+ github.com/libp2p/go-netroute v0.2.2 // indirect
54
+ github.com/libp2p/go-reuseport v0.4.0 // indirect
55
+ github.com/libp2p/go-yamux/v5 v5.0.1 // indirect
56
+ github.com/marten-seemann/tcp v0.0.0-20210406111302-dfbc87cc63fd // indirect
57
+ github.com/mattn/go-isatty v0.0.20 // indirect
58
+ github.com/mholt/acmez/v3 v3.1.3 // indirect
59
+ github.com/miekg/dns v1.1.68 // indirect
60
+ github.com/mikioh/tcpinfo v0.0.0-20190314235526-30a79bb1804b // indirect
61
+ github.com/mikioh/tcpopt v0.0.0-20190314235656-172688c1accc // indirect
62
+ github.com/minio/sha256-simd v1.0.1 // indirect
63
+ github.com/mr-tron/base58 v1.2.0 // indirect
64
+ github.com/multiformats/go-base32 v0.1.0 // indirect
65
+ github.com/multiformats/go-base36 v0.2.0 // indirect
66
+ github.com/multiformats/go-multiaddr-dns v0.4.1 // indirect
67
+ github.com/multiformats/go-multiaddr-fmt v0.1.0 // indirect
68
+ github.com/multiformats/go-multibase v0.2.0 // indirect
69
+ github.com/multiformats/go-multicodec v0.9.2 // indirect
70
+ github.com/multiformats/go-multihash v0.2.3 // indirect
71
+ github.com/multiformats/go-multistream v0.6.1 // indirect
72
+ github.com/multiformats/go-varint v0.0.7 // indirect
73
+ github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
74
+ github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 // indirect
75
+ github.com/pion/datachannel v1.5.10 // indirect
76
+ github.com/pion/dtls/v2 v2.2.12 // indirect
77
+ github.com/pion/dtls/v3 v3.0.6 // indirect
78
+ github.com/pion/ice/v4 v4.0.10 // indirect
79
+ github.com/pion/interceptor v0.1.40 // indirect
80
+ github.com/pion/logging v0.2.3 // indirect
81
+ github.com/pion/mdns/v2 v2.0.7 // indirect
82
+ github.com/pion/randutil v0.1.0 // indirect
83
+ github.com/pion/rtcp v1.2.15 // indirect
84
+ github.com/pion/rtp v1.8.19 // indirect
85
+ github.com/pion/sctp v1.8.39 // indirect
86
+ github.com/pion/sdp/v3 v3.0.13 // indirect
87
+ github.com/pion/srtp/v3 v3.0.6 // indirect
88
+ github.com/pion/stun v0.6.1 // indirect
89
+ github.com/pion/stun/v3 v3.0.0 // indirect
90
+ github.com/pion/transport/v2 v2.2.10 // indirect
91
+ github.com/pion/transport/v3 v3.0.7 // indirect
92
+ github.com/pion/turn/v4 v4.0.2 // indirect
93
+ github.com/pion/webrtc/v4 v4.1.2 // indirect
94
+ github.com/polydawn/refmt v0.89.0 // indirect
95
+ github.com/prometheus/client_golang v1.23.0 // indirect
96
+ github.com/prometheus/client_model v0.6.2 // indirect
97
+ github.com/prometheus/common v0.65.0 // indirect
98
+ github.com/prometheus/procfs v0.17.0 // indirect
99
+ github.com/quic-go/qpack v0.5.1 // indirect
100
+ github.com/quic-go/quic-go v0.54.0 // indirect
101
+ github.com/quic-go/webtransport-go v0.9.0 // indirect
102
+ github.com/spaolacci/murmur3 v1.1.0 // indirect
103
+ github.com/whyrusleeping/go-keyspace v0.0.0-20160322163242-5b898ac5add1 // indirect
104
+ github.com/wlynxg/anet v0.0.5 // indirect
105
+ github.com/zeebo/blake3 v0.2.4 // indirect
106
+ go.opentelemetry.io/auto/sdk v1.1.0 // indirect
107
+ go.opentelemetry.io/otel v1.37.0 // indirect
108
+ go.opentelemetry.io/otel/metric v1.37.0 // indirect
109
+ go.opentelemetry.io/otel/trace v1.37.0 // indirect
110
+ go.uber.org/dig v1.19.0 // indirect
111
+ go.uber.org/fx v1.24.0 // indirect
112
+ go.uber.org/mock v0.5.2 // indirect
113
+ go.uber.org/multierr v1.11.0 // indirect
114
+ go.uber.org/zap v1.27.0 // indirect
115
+ go.uber.org/zap/exp v0.3.0 // indirect
116
+ golang.org/x/crypto v0.41.0 // indirect
117
+ golang.org/x/exp v0.0.0-20250811191247-51f88131bc50 // indirect
118
+ golang.org/x/mod v0.27.0 // indirect
119
+ golang.org/x/net v0.43.0 // indirect
120
+ golang.org/x/sync v0.16.0 // indirect
121
+ golang.org/x/sys v0.35.0 // indirect
122
+ golang.org/x/text v0.28.0 // indirect
123
+ golang.org/x/time v0.12.0 // indirect
124
+ golang.org/x/tools v0.36.0 // indirect
125
+ gonum.org/v1/gonum v0.16.0 // indirect
126
+ lukechampine.com/blake3 v1.4.1 // indirect
127
+ )