cobnox 4.3.1__py3-none-win_amd64.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.
cobnox/__init__.py ADDED
@@ -0,0 +1,228 @@
1
+ """
2
+ Cobnox v4.3.0 — Official Python & Google Colab Package
3
+ ======================================================
4
+ Provides:
5
+ - `cobnox` CLI entry point (wraps the bundled hardened native compiler)
6
+ - `%load_ext cobnox` -> `%%cobnox` cell magic for Google Colab & Jupyter
7
+ - `cobnox.run(code)` Python helper with interactive 3D viewport support
8
+ - Automatic SHA-256 integrity verification of the bundled native binary
9
+ """
10
+
11
+ import hashlib
12
+ import json
13
+ import os
14
+ import re
15
+ import stat
16
+ import subprocess
17
+ import sys
18
+ import tempfile
19
+ import uuid
20
+ from pathlib import Path
21
+
22
+ __version__ = "4.3.1"
23
+
24
+ _BIN_DIR = Path(__file__).resolve().parent / "_bin"
25
+ _BIN_NAME = "cobnox.exe" if sys.platform.startswith("win") else "cobnox"
26
+ _VERIFIED = False
27
+
28
+ FRAME_RE = re.compile(r"\[COBNOX_3D_FRAME:\s*(\{.+\})\s*\]")
29
+
30
+
31
+ def _sha256_file(path: Path) -> str:
32
+ h = hashlib.sha256()
33
+ with path.open("rb") as f:
34
+ for chunk in iter(lambda: f.read(1024 * 1024), b""):
35
+ h.update(chunk)
36
+ return h.hexdigest().lower()
37
+
38
+
39
+ def binary_path(verify: bool = True) -> Path:
40
+ """Return the path to the bundled native Cobnox binary after integrity verification."""
41
+ global _VERIFIED
42
+ exe = _BIN_DIR / _BIN_NAME
43
+ if not exe.is_file():
44
+ raise FileNotFoundError(
45
+ f"Bundled Cobnox binary not found at {exe}. "
46
+ "Reinstall with `pip install --force-reinstall cobnox`."
47
+ )
48
+
49
+ if verify and not _VERIFIED:
50
+ sha_file = _BIN_DIR / "SHA256.txt"
51
+ if sha_file.is_file():
52
+ expected = sha_file.read_text(encoding="utf-8").strip().split()[0].lower()
53
+ actual = _sha256_file(exe)
54
+ if expected and actual != expected:
55
+ raise RuntimeError(
56
+ f"Cobnox binary integrity check FAILED!\n"
57
+ f" Expected SHA-256: {expected}\n"
58
+ f" Actual SHA-256: {actual}\n"
59
+ "Refusing to execute modified binary."
60
+ )
61
+ if not sys.platform.startswith("win"):
62
+ mode = exe.stat().st_mode
63
+ if not (mode & stat.S_IXUSR):
64
+ exe.chmod(mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)
65
+ _VERIFIED = True
66
+ return exe
67
+
68
+
69
+ def _render_3d_frames_html(frames_by_id):
70
+ blocks = []
71
+ for scene_id, frames in frames_by_id.items():
72
+ uid = f"cbx3d_{uuid.uuid4().hex[:10]}"
73
+ payload = json.dumps(frames)
74
+ blocks.append(f"""
75
+ <div id="{uid}" style="background:#0b1120;border:1px solid #334155;border-radius:10px;padding:10px;margin:8px 0;color:#e2e8f0;font-family:monospace;max-width:760px;">
76
+ <div style="display:flex;justify-content:space-between;align-items:center;margin-bottom:6px;gap:8px;flex-wrap:wrap;">
77
+ <strong style="color:#38bdf8;">Cobnox 3D Viewport — {scene_id}</strong>
78
+ <span id="{uid}_hud" style="font-size:12px;color:#94a3b8;">frame 1/{len(frames)}</span>
79
+ <div style="display:flex;gap:6px;align-items:center;">
80
+ <button id="{uid}_play" style="background:#1e293b;color:#e2e8f0;border:1px solid #475569;border-radius:5px;padding:2px 8px;cursor:pointer;">Play</button>
81
+ <button id="{uid}_wire" style="background:#1e293b;color:#e2e8f0;border:1px solid #475569;border-radius:5px;padding:2px 8px;cursor:pointer;">Wireframe</button>
82
+ <input id="{uid}_scrub" type="range" min="0" max="{max(0, len(frames)-1)}" value="0" style="width:120px;">
83
+ </div>
84
+ </div>
85
+ <canvas id="{uid}_cv" width="720" height="400" style="width:100%;background:#020617;border-radius:6px;cursor:grab;"></canvas>
86
+ <script>
87
+ (function() {{
88
+ const frames = {payload};
89
+ const cv = document.getElementById("{uid}_cv");
90
+ const ctx = cv.getContext("2d");
91
+ const hud = document.getElementById("{uid}_hud");
92
+ const scrub = document.getElementById("{uid}_scrub");
93
+ const playBtn = document.getElementById("{uid}_play");
94
+ const wireBtn = document.getElementById("{uid}_wire");
95
+ let yaw = 0.55, pitch = 0.35, dist = 5.2, wire = false, playing = false, idx = 0, dragging = false, lx = 0, ly = 0;
96
+
97
+ function project(p) {{
98
+ const cy = Math.cos(yaw), sy = Math.sin(yaw), cp = Math.cos(pitch), sp = Math.sin(pitch);
99
+ const ex = dist * cp * sy, ey = 0.8 + dist * sp, ez = dist * cp * cy;
100
+ const fx = -ex, fy = 0.8 - ey, fz = -ez;
101
+ const fl = Math.hypot(fx, fy, fz) || 1;
102
+ const f = [fx/fl, fy/fl, fz/fl];
103
+ const rx = f[2], ry = 0, rz = -f[0];
104
+ const rl = Math.hypot(rx, ry, rz) || 1;
105
+ const r = [rx/rl, 0, rz/rl];
106
+ const u = [r[1]*f[2]-r[2]*f[1], r[2]*f[0]-r[0]*f[2], r[0]*f[1]-r[1]*f[0]];
107
+ const dx = p[0]-ex, dy = p[1]-ey, dz = p[2]-ez;
108
+ const z = dx*f[0] + dy*f[1] + dz*f[2];
109
+ if (z <= 0.05) return null;
110
+ const fov = cv.width * 0.7;
111
+ return [cv.width*0.5 + ((dx*r[0]+dy*r[1]+dz*r[2])/z)*fov, cv.height*0.5 - ((dx*u[0]+dy*u[1]+dz*u[2])/z)*fov, z];
112
+ }}
113
+
114
+ function drawLine(a, b, color, w=1.5) {{
115
+ const pa = project(a), pb = project(b);
116
+ if (!pa || !pb) return;
117
+ ctx.strokeStyle = color; ctx.lineWidth = w;
118
+ ctx.beginPath(); ctx.moveTo(pa[0], pa[1]); ctx.lineTo(pb[0], pb[1]); ctx.stroke();
119
+ }}
120
+
121
+ function render() {{
122
+ ctx.fillStyle = "#020617"; ctx.fillRect(0, 0, cv.width, cv.height);
123
+ for (let g = -4; g <= 4; g++) {{
124
+ drawLine([g, 0, -4], [g, 0, 4], "#1e293b", 1);
125
+ drawLine([-4, 0, g], [4, 0, g], "#1e293b", 1);
126
+ }}
127
+ const fr = frames[idx] || {{}};
128
+ hud.textContent = "frame " + (idx+1) + "/" + frames.length + (fr.hud ? " | " + fr.hud : "");
129
+ (fr.bodies || []).forEach(b => {{
130
+ const p = b.p || [0,0,0], s = b.s || [0.2,0.2,0.2], c = b.c || "#38bdf8";
131
+ const pr = project(p); if (!pr) return;
132
+ const rad = Math.max(4, (Math.max(s[0], s[1], s[2]) / pr[2]) * cv.width * 0.65);
133
+ ctx.beginPath(); ctx.arc(pr[0], pr[1], rad, 0, Math.PI*2);
134
+ if (wire) {{ ctx.strokeStyle = c; ctx.lineWidth = 2; ctx.stroke(); }}
135
+ else {{ ctx.fillStyle = c; ctx.fill(); }}
136
+ }});
137
+ (fr.bonds || []).forEach(bd => drawLine(bd.a, bd.b, bd.c || "#cbd5e1", 2.5));
138
+ (fr.atoms || []).forEach(a => {{
139
+ const pr = project(a.p); if (!pr) return;
140
+ const rad = Math.max(5, ((a.r || 0.15) / pr[2]) * cv.width * 0.7);
141
+ ctx.beginPath(); ctx.arc(pr[0], pr[1], rad, 0, Math.PI*2);
142
+ ctx.fillStyle = a.c || "#22c55e"; ctx.fill();
143
+ }});
144
+ (fr.contacts || []).forEach(ct => {{
145
+ const p = ct.p, n = ct.n || [0,1,0];
146
+ drawLine(p, [p[0]+n[0]*0.3, p[1]+n[1]*0.3, p[2]+n[2]*0.3], "#f43f5e", 2.5);
147
+ }});
148
+ }}
149
+
150
+ cv.addEventListener("mousedown", e => {{ dragging = true; lx = e.clientX; ly = e.clientY; }});
151
+ window.addEventListener("mouseup", () => dragging = false);
152
+ window.addEventListener("mousemove", e => {{
153
+ if (!dragging) return;
154
+ yaw += (e.clientX - lx) * 0.01; pitch = Math.max(-1.4, Math.min(1.4, pitch + (e.clientY - ly) * 0.01));
155
+ lx = e.clientX; ly = e.clientY; render();
156
+ }});
157
+ cv.addEventListener("wheel", e => {{ e.preventDefault(); dist = Math.max(1.2, Math.min(20, dist + e.deltaY * 0.005)); render(); }});
158
+ scrub.addEventListener("input", () => {{ idx = parseInt(scrub.value, 10); render(); }});
159
+ wireBtn.addEventListener("click", () => {{ wire = !wire; render(); }});
160
+ playBtn.addEventListener("click", () => {{
161
+ playing = !playing; playBtn.textContent = playing ? "Pause" : "Play";
162
+ if (playing) {{
163
+ const tick = () => {{
164
+ if (!playing) return;
165
+ idx = (idx + 1) % frames.length; scrub.value = idx; render();
166
+ setTimeout(tick, 60);
167
+ }};
168
+ tick();
169
+ }}
170
+ }});
171
+ render();
172
+ }})();
173
+ </script>
174
+ </div>
175
+ """)
176
+ return "\n".join(blocks)
177
+
178
+
179
+ def run(code: str, extra_args=None) -> int:
180
+ """Compile and execute a Cobnox source string using the verified native binary."""
181
+ exe = str(binary_path())
182
+ extra_args = list(extra_args or [])
183
+ with tempfile.NamedTemporaryFile("w", suffix=".cbx", delete=False, encoding="utf-8") as tf:
184
+ tf.write(code)
185
+ src_path = tf.name
186
+ try:
187
+ env = os.environ.copy()
188
+ env["COBNOX_NOTEBOOK_MODE"] = "1"
189
+ proc = subprocess.run(
190
+ [exe, *extra_args, src_path],
191
+ capture_output=True,
192
+ text=True,
193
+ env=env,
194
+ )
195
+ frames_by_id = {}
196
+ for line in proc.stdout.splitlines():
197
+ m = FRAME_RE.search(line)
198
+ if m:
199
+ try:
200
+ fr = json.loads(m.group(1))
201
+ sid = fr.get("id", "scene")
202
+ frames_by_id.setdefault(sid, []).append(fr)
203
+ except Exception:
204
+ print(line)
205
+ else:
206
+ print(line)
207
+ if proc.stderr.strip():
208
+ print(proc.stderr, file=sys.stderr)
209
+ if frames_by_id:
210
+ try:
211
+ from IPython.display import HTML, display
212
+ display(HTML(_render_3d_frames_html(frames_by_id)))
213
+ except ImportError:
214
+ pass
215
+ return proc.returncode
216
+ finally:
217
+ if os.path.exists(src_path):
218
+ os.remove(src_path)
219
+
220
+
221
+ def load_ipython_extension(ipython):
222
+ """Enable `%%cobnox` cell magic via `%load_ext cobnox` in Google Colab / Jupyter."""
223
+ def _cobnox_magic(line, cell):
224
+ args = line.strip().split() if line.strip() else []
225
+ run(cell, extra_args=args)
226
+
227
+ ipython.register_magic_function(_cobnox_magic, magic_kind="cell", magic_name="cobnox")
228
+ print(f"Cobnox v{__version__} %%cobnox magic ready (Verified binary + GPU + 3D Viewport).")
cobnox/_bin/SHA256.txt ADDED
@@ -0,0 +1 @@
1
+ ea02e34e940ca9cf1308cbbbb4f280d3049a7ece9122e38f06bdd5fc0945e46c cobnox.exe
cobnox/_bin/cobnox.exe ADDED
@@ -0,0 +1,4 @@
1
+ [diffend] Oversized file quarantined before diffing.
2
+ name: cobnox/_bin/cobnox.exe
3
+ size: 56197120 bytes
4
+ sha256: ea02e34e940ca9cf1308cbbbb4f280d3049a7ece9122e38f06bdd5fc0945e46c
Binary file
Binary file
Binary file
cobnox/_cli.py ADDED
@@ -0,0 +1,15 @@
1
+ """CLI entry point for `cobnox` installed via `pip install cobnox`."""
2
+
3
+ import subprocess
4
+ import sys
5
+ from . import binary_path
6
+
7
+
8
+ def main() -> int:
9
+ exe = str(binary_path(verify=True))
10
+ completed = subprocess.run([exe, *sys.argv[1:]])
11
+ return completed.returncode
12
+
13
+
14
+ if __name__ == "__main__":
15
+ raise SystemExit(main())
@@ -0,0 +1,42 @@
1
+ Metadata-Version: 2.1
2
+ Name: cobnox
3
+ Version: 4.3.1
4
+ Summary: Cobnox - Sovereign AI, Real Robotics RL & Native MAMC Compiler (Linux, Google Colab & Windows)
5
+ Home-page: https://github.com/aelionyxe/cobnox
6
+ Author: Muhammad Ahmad (Aelionyxe Lab)
7
+ License: Proprietary
8
+ Requires-Python: >=3.8
9
+ Description-Content-Type: text/markdown
10
+
11
+ # Cobnox v4.3.0
12
+
13
+ **Sovereign AI, Real Robotics RL & Native MAMC Compiler** for **Google Colab, Linux x64, and Windows x64**.
14
+
15
+ ## Install via `pip`
16
+ ```bash
17
+ pip install cobnox
18
+ ```
19
+
20
+ ## Google Colab Quick Start
21
+ ```python
22
+ !pip install -q cobnox
23
+ %load_ext cobnox
24
+ ```
25
+
26
+ Then run native Cobnox code directly in any Colab cell (with automatic interactive 3D viewport & NVIDIA GPU support):
27
+ ```cobnox
28
+ %%cobnox
29
+ print("Hello from Cobnox v4.3.0 on Google Colab!")
30
+ ```
31
+
32
+ Or run `.cbx` files from the terminal:
33
+ ```bash
34
+ cobnox --version
35
+ cobnox my_robot.cbx
36
+ ```
37
+
38
+ ## Security & Integrity
39
+ - Native compiler binaries are compiled with Full RELRO, PIE, NX stack, and stripped symbols.
40
+ - All 137 standard library modules are encrypted and embedded inside the native binary (zero plain-text runtime downloads).
41
+ - Every launch verifies the embedded SHA-256 digest of the bundled compiler binary before execution.
42
+ - Official releases are published via GitHub Actions OIDC Trusted Publishing with PyPI PEP 740 cryptographic attestations.
@@ -0,0 +1,11 @@
1
+ cobnox/__init__.py,sha256=PcyOQWSr5mznBVh9i4Y64TxV3WJr2_lVz0S6vDAS-0c,9583
2
+ cobnox/_cli.py,sha256=WExpiPYrJEFq3vSE55e5hQiS3KWfXnQ2UWml0dE_-aA,331
3
+ cobnox/_bin/cobnox.exe,sha256=6gLjTpQMqc8TCMu7tPKA0wSafs6RIuOPBr3V_AlF5Gw,56197120
4
+ cobnox/_bin/SHA256.txt,sha256=GsV602AuQar_egKBYwLKslU7bKEWsLPr_VQ0p_RWFrg,77
5
+ cobnox-4.3.1.dist-info/METADATA,sha256=gynRapz2av9Kn44XfbebMRCzYeTnMHE0umfpR07nxoY,1335
6
+ cobnox-4.3.1.dist-info/WHEEL,sha256=ZNmaYDgKRnQsGe4ZH72qVfNm905167ZAKPdhUkZgk-E,96
7
+ cobnox-4.3.1.dist-info/entry_points.txt,sha256=CTmhFKu0pl_0UwXdiW-1lY_ZQ-dcBcfK4jtS_sfqydM,44
8
+ cobnox/_bin/msvcp140.dll,sha256=3vRqpqj3Lye6-sDEMzRBlIak0dzbbEeajvcDSz4fpMs,553552
9
+ cobnox/_bin/vcruntime140.dll,sha256=GEFGhScnqdtO6gYXhxa-w827EBXJEfaw-RWxhK13dbI,123472
10
+ cobnox/_bin/vcruntime140_1.dll,sha256=5r-zZiq0sZaac0QdvjXJbVFEG2v_jPH-dDC9WyRspgU,47264
11
+ cobnox-4.3.1.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: cobnox-build-wheel
3
+ Root-Is-Purelib: false
4
+ Tag: py3-none-win_amd64
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ cobnox = cobnox._cli:main