rbek 0.2.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.
rbek-0.2.0/PKG-INFO ADDED
@@ -0,0 +1,210 @@
1
+ Metadata-Version: 2.4
2
+ Name: rbek
3
+ Version: 0.2.0
4
+ Summary: Official bootstrap CLI for RBEK governed execution.
5
+ Author: RBEK Platform
6
+ Project-URL: Homepage, https://rbekplatform.com
7
+ Project-URL: Repository, https://github.com/rbekplatform/rbek
8
+ Keywords: ai-agents,ai-governance,execution-governance,policy-enforcement,workflow-automation
9
+ Classifier: Development Status :: 3 - Alpha
10
+ Classifier: Environment :: Console
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
17
+ Classifier: Topic :: Security
18
+ Requires-Python: >=3.10
19
+ Description-Content-Type: text/markdown
20
+
21
+ # RBEK
22
+
23
+ **Governed execution for AI agents, workflows and software.**
24
+
25
+ [![Deterministic Execution Verified](https://github.com/rbekplatform/rbek/actions/workflows/real-governed-agent.yml/badge.svg)](https://github.com/rbekplatform/rbek/actions/workflows/real-governed-agent.yml)
26
+ [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/rbekplatform/rbek?quickstart=1)
27
+
28
+ RBEK separates what an agent **wants to do** from what it is **authorized to execute**.
29
+
30
+ ## See RBEK govern an action in 10 seconds
31
+
32
+ ```bash
33
+ curl -fsSL https://raw.githubusercontent.com/rbekplatform/rbek/main/examples/real-governed-agent/demo.sh | bash
34
+ ```
35
+
36
+ **No API key. No prior RBEK installation. No configuration.**
37
+
38
+ The demo installs and validates the public RBEK CLI when needed, then runs an
39
+ offline governed proof:
40
+
41
+ ```text
42
+ Agent requests an action
43
+ |
44
+ +-- unauthorized -> DENY -> executed: NO
45
+ |
46
+ +-- authorized -> ALLOW -> governed dry-run -> AUTHORIZED
47
+ |
48
+ +-- evidence
49
+ ```
50
+
51
+ What you see in the terminal:
52
+
53
+ ```text
54
+ Unauthorized action ............ DENIED
55
+ Denied action executed ......... NO
56
+ Authorized action .............. ALLOWED
57
+ Governed dry-run ............... PASS
58
+ Gate authorization ............. AUTHORIZED
59
+ RBEK policy enforcement ........ REAL
60
+ RBEK evidence .................. REAL
61
+ ```
62
+
63
+ The default proof performs **no external network action**. Policy enforcement
64
+ and evidence generation are real RBEK behavior.
65
+
66
+ The public GitHub Actions workflow executes the proof twice and verifies that
67
+ the deterministic evidence summary is identical across both runs.
68
+
69
+ ### Prefer zero-install in the browser?
70
+
71
+ Use **Open in GitHub Codespaces** above, then run:
72
+
73
+ ```bash
74
+ cd examples/real-governed-agent
75
+ ./demo.sh
76
+ ```
77
+
78
+ ### Want the real AI + Internet path?
79
+
80
+ ```bash
81
+ cd examples/real-governed-agent
82
+ export OPENAI_API_KEY="your-key"
83
+ ./demo.sh --live
84
+ ```
85
+
86
+ Live mode performs real model inference and a real Open-Meteo external action
87
+ through the RBEK governed execution boundary.
88
+
89
+ ## Why RBEK?
90
+
91
+ AI agents can decide what they want to do. Production systems still need a
92
+ controlled boundary for what is actually allowed to execute.
93
+
94
+ RBEK puts that boundary between application logic and real external actions:
95
+
96
+ ```text
97
+ agent / workflow
98
+
99
+ execution request
100
+
101
+ RBEK policy admission
102
+ ↙ ↘
103
+ DENY ALLOW
104
+
105
+ execute
106
+
107
+ evidence
108
+ ```
109
+
110
+ This keeps execution governance separate from the agent framework, model
111
+ provider or workflow engine.
112
+
113
+ ## Install
114
+
115
+ ```bash
116
+ curl -fsSL https://releases.rbekplatform.com/cli/stable/install.sh | bash
117
+ ```
118
+
119
+ Verify:
120
+
121
+ ```bash
122
+ rbek-cli --version
123
+ ```
124
+
125
+ Current public stable:
126
+
127
+ ```text
128
+ RBEK 0.2.0
129
+ ```
130
+
131
+ ## 5-minute quickstart
132
+
133
+ Create and run a minimal local RBEK project:
134
+
135
+ ```bash
136
+ rbek-cli init ./rbek-demo
137
+ rbek-cli run ./rbek-demo
138
+ ```
139
+
140
+ Or run the repository example:
141
+
142
+ ```bash
143
+ bash examples/5-minute-quickstart/run.sh
144
+ ```
145
+
146
+ The goal of the first five minutes is simple: install RBEK, create a governed
147
+ local project and execute it through the RBEK CLI.
148
+
149
+ See [QUICKSTART.md](QUICKSTART.md) for the complete first-run walkthrough.
150
+
151
+ ## Run the live AI + Internet version
152
+
153
+ After the zero-key proof, you can run the real agent path:
154
+
155
+ ```bash
156
+ cd examples/real-governed-agent
157
+ export OPENAI_API_KEY="your-key"
158
+ ./demo.sh --live
159
+ ```
160
+
161
+ In live mode:
162
+
163
+ ```text
164
+ OpenAI agent
165
+
166
+ weather.current
167
+
168
+ RBEK policy admission
169
+
170
+ controlled external execution
171
+
172
+ Open-Meteo
173
+
174
+ receipt + certification
175
+ ```
176
+
177
+ The agent does not call Open-Meteo directly. The external action goes through
178
+ the RBEK governed execution boundary.
179
+
180
+ See
181
+ [examples/real-governed-agent/README.md](examples/real-governed-agent/README.md)
182
+ for details.
183
+
184
+ ## Developer
185
+
186
+ Developer is the public CLI entry point for local development, evaluation and
187
+ integration.
188
+
189
+ It does not require a paid commercial entitlement.
190
+
191
+ Team and Enterprise commercial access are handled separately.
192
+
193
+ ## Repository role
194
+
195
+ This repository contains Developer documentation, examples and installation
196
+ guidance.
197
+
198
+ The RBEK runtime is distributed through the official release host:
199
+
200
+ `https://releases.rbekplatform.com`
201
+
202
+ The complete runtime source is not published in this repository.
203
+
204
+ ## Website
205
+
206
+ `https://rbekplatform.com`
207
+
208
+ ## Security
209
+
210
+ See [SECURITY.md](SECURITY.md).
rbek-0.2.0/README.md ADDED
@@ -0,0 +1,190 @@
1
+ # RBEK
2
+
3
+ **Governed execution for AI agents, workflows and software.**
4
+
5
+ [![Deterministic Execution Verified](https://github.com/rbekplatform/rbek/actions/workflows/real-governed-agent.yml/badge.svg)](https://github.com/rbekplatform/rbek/actions/workflows/real-governed-agent.yml)
6
+ [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/rbekplatform/rbek?quickstart=1)
7
+
8
+ RBEK separates what an agent **wants to do** from what it is **authorized to execute**.
9
+
10
+ ## See RBEK govern an action in 10 seconds
11
+
12
+ ```bash
13
+ curl -fsSL https://raw.githubusercontent.com/rbekplatform/rbek/main/examples/real-governed-agent/demo.sh | bash
14
+ ```
15
+
16
+ **No API key. No prior RBEK installation. No configuration.**
17
+
18
+ The demo installs and validates the public RBEK CLI when needed, then runs an
19
+ offline governed proof:
20
+
21
+ ```text
22
+ Agent requests an action
23
+ |
24
+ +-- unauthorized -> DENY -> executed: NO
25
+ |
26
+ +-- authorized -> ALLOW -> governed dry-run -> AUTHORIZED
27
+ |
28
+ +-- evidence
29
+ ```
30
+
31
+ What you see in the terminal:
32
+
33
+ ```text
34
+ Unauthorized action ............ DENIED
35
+ Denied action executed ......... NO
36
+ Authorized action .............. ALLOWED
37
+ Governed dry-run ............... PASS
38
+ Gate authorization ............. AUTHORIZED
39
+ RBEK policy enforcement ........ REAL
40
+ RBEK evidence .................. REAL
41
+ ```
42
+
43
+ The default proof performs **no external network action**. Policy enforcement
44
+ and evidence generation are real RBEK behavior.
45
+
46
+ The public GitHub Actions workflow executes the proof twice and verifies that
47
+ the deterministic evidence summary is identical across both runs.
48
+
49
+ ### Prefer zero-install in the browser?
50
+
51
+ Use **Open in GitHub Codespaces** above, then run:
52
+
53
+ ```bash
54
+ cd examples/real-governed-agent
55
+ ./demo.sh
56
+ ```
57
+
58
+ ### Want the real AI + Internet path?
59
+
60
+ ```bash
61
+ cd examples/real-governed-agent
62
+ export OPENAI_API_KEY="your-key"
63
+ ./demo.sh --live
64
+ ```
65
+
66
+ Live mode performs real model inference and a real Open-Meteo external action
67
+ through the RBEK governed execution boundary.
68
+
69
+ ## Why RBEK?
70
+
71
+ AI agents can decide what they want to do. Production systems still need a
72
+ controlled boundary for what is actually allowed to execute.
73
+
74
+ RBEK puts that boundary between application logic and real external actions:
75
+
76
+ ```text
77
+ agent / workflow
78
+
79
+ execution request
80
+
81
+ RBEK policy admission
82
+ ↙ ↘
83
+ DENY ALLOW
84
+
85
+ execute
86
+
87
+ evidence
88
+ ```
89
+
90
+ This keeps execution governance separate from the agent framework, model
91
+ provider or workflow engine.
92
+
93
+ ## Install
94
+
95
+ ```bash
96
+ curl -fsSL https://releases.rbekplatform.com/cli/stable/install.sh | bash
97
+ ```
98
+
99
+ Verify:
100
+
101
+ ```bash
102
+ rbek-cli --version
103
+ ```
104
+
105
+ Current public stable:
106
+
107
+ ```text
108
+ RBEK 0.2.0
109
+ ```
110
+
111
+ ## 5-minute quickstart
112
+
113
+ Create and run a minimal local RBEK project:
114
+
115
+ ```bash
116
+ rbek-cli init ./rbek-demo
117
+ rbek-cli run ./rbek-demo
118
+ ```
119
+
120
+ Or run the repository example:
121
+
122
+ ```bash
123
+ bash examples/5-minute-quickstart/run.sh
124
+ ```
125
+
126
+ The goal of the first five minutes is simple: install RBEK, create a governed
127
+ local project and execute it through the RBEK CLI.
128
+
129
+ See [QUICKSTART.md](QUICKSTART.md) for the complete first-run walkthrough.
130
+
131
+ ## Run the live AI + Internet version
132
+
133
+ After the zero-key proof, you can run the real agent path:
134
+
135
+ ```bash
136
+ cd examples/real-governed-agent
137
+ export OPENAI_API_KEY="your-key"
138
+ ./demo.sh --live
139
+ ```
140
+
141
+ In live mode:
142
+
143
+ ```text
144
+ OpenAI agent
145
+
146
+ weather.current
147
+
148
+ RBEK policy admission
149
+
150
+ controlled external execution
151
+
152
+ Open-Meteo
153
+
154
+ receipt + certification
155
+ ```
156
+
157
+ The agent does not call Open-Meteo directly. The external action goes through
158
+ the RBEK governed execution boundary.
159
+
160
+ See
161
+ [examples/real-governed-agent/README.md](examples/real-governed-agent/README.md)
162
+ for details.
163
+
164
+ ## Developer
165
+
166
+ Developer is the public CLI entry point for local development, evaluation and
167
+ integration.
168
+
169
+ It does not require a paid commercial entitlement.
170
+
171
+ Team and Enterprise commercial access are handled separately.
172
+
173
+ ## Repository role
174
+
175
+ This repository contains Developer documentation, examples and installation
176
+ guidance.
177
+
178
+ The RBEK runtime is distributed through the official release host:
179
+
180
+ `https://releases.rbekplatform.com`
181
+
182
+ The complete runtime source is not published in this repository.
183
+
184
+ ## Website
185
+
186
+ `https://rbekplatform.com`
187
+
188
+ ## Security
189
+
190
+ See [SECURITY.md](SECURITY.md).
@@ -0,0 +1,44 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "rbek"
7
+ version = "0.2.0"
8
+ description = "Official bootstrap CLI for RBEK governed execution."
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ authors = [
12
+ { name = "RBEK Platform" }
13
+ ]
14
+ keywords = [
15
+ "ai-agents",
16
+ "ai-governance",
17
+ "execution-governance",
18
+ "policy-enforcement",
19
+ "workflow-automation"
20
+ ]
21
+ classifiers = [
22
+ "Development Status :: 3 - Alpha",
23
+ "Environment :: Console",
24
+ "Intended Audience :: Developers",
25
+ "Programming Language :: Python :: 3",
26
+ "Programming Language :: Python :: 3.10",
27
+ "Programming Language :: Python :: 3.11",
28
+ "Programming Language :: Python :: 3.12",
29
+ "Topic :: Software Development :: Libraries :: Application Frameworks",
30
+ "Topic :: Security"
31
+ ]
32
+
33
+ [project.urls]
34
+ Homepage = "https://rbekplatform.com"
35
+ Repository = "https://github.com/rbekplatform/rbek"
36
+
37
+ [project.scripts]
38
+ rbek = "rbek_pypi.cli:main"
39
+
40
+ [tool.setuptools]
41
+ package-dir = {"" = "src"}
42
+
43
+ [tool.setuptools.packages.find]
44
+ where = ["src"]
rbek-0.2.0/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,210 @@
1
+ Metadata-Version: 2.4
2
+ Name: rbek
3
+ Version: 0.2.0
4
+ Summary: Official bootstrap CLI for RBEK governed execution.
5
+ Author: RBEK Platform
6
+ Project-URL: Homepage, https://rbekplatform.com
7
+ Project-URL: Repository, https://github.com/rbekplatform/rbek
8
+ Keywords: ai-agents,ai-governance,execution-governance,policy-enforcement,workflow-automation
9
+ Classifier: Development Status :: 3 - Alpha
10
+ Classifier: Environment :: Console
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
17
+ Classifier: Topic :: Security
18
+ Requires-Python: >=3.10
19
+ Description-Content-Type: text/markdown
20
+
21
+ # RBEK
22
+
23
+ **Governed execution for AI agents, workflows and software.**
24
+
25
+ [![Deterministic Execution Verified](https://github.com/rbekplatform/rbek/actions/workflows/real-governed-agent.yml/badge.svg)](https://github.com/rbekplatform/rbek/actions/workflows/real-governed-agent.yml)
26
+ [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/rbekplatform/rbek?quickstart=1)
27
+
28
+ RBEK separates what an agent **wants to do** from what it is **authorized to execute**.
29
+
30
+ ## See RBEK govern an action in 10 seconds
31
+
32
+ ```bash
33
+ curl -fsSL https://raw.githubusercontent.com/rbekplatform/rbek/main/examples/real-governed-agent/demo.sh | bash
34
+ ```
35
+
36
+ **No API key. No prior RBEK installation. No configuration.**
37
+
38
+ The demo installs and validates the public RBEK CLI when needed, then runs an
39
+ offline governed proof:
40
+
41
+ ```text
42
+ Agent requests an action
43
+ |
44
+ +-- unauthorized -> DENY -> executed: NO
45
+ |
46
+ +-- authorized -> ALLOW -> governed dry-run -> AUTHORIZED
47
+ |
48
+ +-- evidence
49
+ ```
50
+
51
+ What you see in the terminal:
52
+
53
+ ```text
54
+ Unauthorized action ............ DENIED
55
+ Denied action executed ......... NO
56
+ Authorized action .............. ALLOWED
57
+ Governed dry-run ............... PASS
58
+ Gate authorization ............. AUTHORIZED
59
+ RBEK policy enforcement ........ REAL
60
+ RBEK evidence .................. REAL
61
+ ```
62
+
63
+ The default proof performs **no external network action**. Policy enforcement
64
+ and evidence generation are real RBEK behavior.
65
+
66
+ The public GitHub Actions workflow executes the proof twice and verifies that
67
+ the deterministic evidence summary is identical across both runs.
68
+
69
+ ### Prefer zero-install in the browser?
70
+
71
+ Use **Open in GitHub Codespaces** above, then run:
72
+
73
+ ```bash
74
+ cd examples/real-governed-agent
75
+ ./demo.sh
76
+ ```
77
+
78
+ ### Want the real AI + Internet path?
79
+
80
+ ```bash
81
+ cd examples/real-governed-agent
82
+ export OPENAI_API_KEY="your-key"
83
+ ./demo.sh --live
84
+ ```
85
+
86
+ Live mode performs real model inference and a real Open-Meteo external action
87
+ through the RBEK governed execution boundary.
88
+
89
+ ## Why RBEK?
90
+
91
+ AI agents can decide what they want to do. Production systems still need a
92
+ controlled boundary for what is actually allowed to execute.
93
+
94
+ RBEK puts that boundary between application logic and real external actions:
95
+
96
+ ```text
97
+ agent / workflow
98
+
99
+ execution request
100
+
101
+ RBEK policy admission
102
+ ↙ ↘
103
+ DENY ALLOW
104
+
105
+ execute
106
+
107
+ evidence
108
+ ```
109
+
110
+ This keeps execution governance separate from the agent framework, model
111
+ provider or workflow engine.
112
+
113
+ ## Install
114
+
115
+ ```bash
116
+ curl -fsSL https://releases.rbekplatform.com/cli/stable/install.sh | bash
117
+ ```
118
+
119
+ Verify:
120
+
121
+ ```bash
122
+ rbek-cli --version
123
+ ```
124
+
125
+ Current public stable:
126
+
127
+ ```text
128
+ RBEK 0.2.0
129
+ ```
130
+
131
+ ## 5-minute quickstart
132
+
133
+ Create and run a minimal local RBEK project:
134
+
135
+ ```bash
136
+ rbek-cli init ./rbek-demo
137
+ rbek-cli run ./rbek-demo
138
+ ```
139
+
140
+ Or run the repository example:
141
+
142
+ ```bash
143
+ bash examples/5-minute-quickstart/run.sh
144
+ ```
145
+
146
+ The goal of the first five minutes is simple: install RBEK, create a governed
147
+ local project and execute it through the RBEK CLI.
148
+
149
+ See [QUICKSTART.md](QUICKSTART.md) for the complete first-run walkthrough.
150
+
151
+ ## Run the live AI + Internet version
152
+
153
+ After the zero-key proof, you can run the real agent path:
154
+
155
+ ```bash
156
+ cd examples/real-governed-agent
157
+ export OPENAI_API_KEY="your-key"
158
+ ./demo.sh --live
159
+ ```
160
+
161
+ In live mode:
162
+
163
+ ```text
164
+ OpenAI agent
165
+
166
+ weather.current
167
+
168
+ RBEK policy admission
169
+
170
+ controlled external execution
171
+
172
+ Open-Meteo
173
+
174
+ receipt + certification
175
+ ```
176
+
177
+ The agent does not call Open-Meteo directly. The external action goes through
178
+ the RBEK governed execution boundary.
179
+
180
+ See
181
+ [examples/real-governed-agent/README.md](examples/real-governed-agent/README.md)
182
+ for details.
183
+
184
+ ## Developer
185
+
186
+ Developer is the public CLI entry point for local development, evaluation and
187
+ integration.
188
+
189
+ It does not require a paid commercial entitlement.
190
+
191
+ Team and Enterprise commercial access are handled separately.
192
+
193
+ ## Repository role
194
+
195
+ This repository contains Developer documentation, examples and installation
196
+ guidance.
197
+
198
+ The RBEK runtime is distributed through the official release host:
199
+
200
+ `https://releases.rbekplatform.com`
201
+
202
+ The complete runtime source is not published in this repository.
203
+
204
+ ## Website
205
+
206
+ `https://rbekplatform.com`
207
+
208
+ ## Security
209
+
210
+ See [SECURITY.md](SECURITY.md).
@@ -0,0 +1,9 @@
1
+ README.md
2
+ pyproject.toml
3
+ src/rbek.egg-info/PKG-INFO
4
+ src/rbek.egg-info/SOURCES.txt
5
+ src/rbek.egg-info/dependency_links.txt
6
+ src/rbek.egg-info/entry_points.txt
7
+ src/rbek.egg-info/top_level.txt
8
+ src/rbek_pypi/__init__.py
9
+ src/rbek_pypi/cli.py
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ rbek = rbek_pypi.cli:main
@@ -0,0 +1 @@
1
+ rbek_pypi
@@ -0,0 +1,3 @@
1
+ """Public PyPI bootstrap package for RBEK."""
2
+
3
+ __version__ = "0.2.0"
@@ -0,0 +1,167 @@
1
+ from __future__ import annotations
2
+
3
+ import hashlib
4
+ import os
5
+ import pathlib
6
+ import shutil
7
+ import subprocess
8
+ import sys
9
+ import tempfile
10
+ import urllib.request
11
+
12
+ EXPECTED_RUNTIME_VERSION = "0.2.0"
13
+ EXPECTED_RUNTIME_VERSION_OUTPUT = f"RBEK {EXPECTED_RUNTIME_VERSION}"
14
+
15
+ INSTALLER_URL = "https://releases.rbekplatform.com/cli/stable/install.sh"
16
+ INSTALLER_SHA256 = "0a3fabcad4c114c133b96cb71e1406d25279c2c05fa3b37f95a8e446a10b7c86"
17
+
18
+ DEMO_URL = (
19
+ "https://raw.githubusercontent.com/"
20
+ "rbekplatform/rbek/main/examples/real-governed-agent/demo.sh"
21
+ )
22
+ DEMO_SHA256 = "17d299b02a38aec3f722ead47153a82e0f28be2c208d6a099590984e978df2d6"
23
+
24
+ RUNTIME_COMMAND = "rbek-cli"
25
+
26
+
27
+ class RbekBootstrapError(RuntimeError):
28
+ pass
29
+
30
+
31
+ def _sha256(data: bytes) -> str:
32
+ return hashlib.sha256(data).hexdigest()
33
+
34
+
35
+ def _download_verified(url: str, expected_sha256: str) -> bytes:
36
+ request = urllib.request.Request(
37
+ url,
38
+ headers={"User-Agent": "rbek-pypi-bootstrap/0.2.0"},
39
+ )
40
+
41
+ with urllib.request.urlopen(request, timeout=30) as response:
42
+ data = response.read()
43
+
44
+ actual = _sha256(data)
45
+
46
+ if actual != expected_sha256:
47
+ raise RbekBootstrapError(
48
+ "Downloaded RBEK artifact failed SHA256 validation: "
49
+ f"expected={expected_sha256} actual={actual}"
50
+ )
51
+
52
+ return data
53
+
54
+
55
+ def _runtime_path() -> str | None:
56
+ return shutil.which(RUNTIME_COMMAND)
57
+
58
+
59
+ def _runtime_version(runtime: str) -> str:
60
+ completed = subprocess.run(
61
+ [runtime, "--version"],
62
+ check=True,
63
+ capture_output=True,
64
+ text=True,
65
+ )
66
+ return completed.stdout.strip()
67
+
68
+
69
+ def _validate_runtime(runtime: str) -> None:
70
+ actual = _runtime_version(runtime)
71
+
72
+ if actual != EXPECTED_RUNTIME_VERSION_OUTPUT:
73
+ raise RbekBootstrapError(
74
+ "RBEK runtime version mismatch: "
75
+ f"expected={EXPECTED_RUNTIME_VERSION_OUTPUT!r} "
76
+ f"actual={actual!r}"
77
+ )
78
+
79
+
80
+ def _install_runtime() -> str:
81
+ installer = _download_verified(
82
+ INSTALLER_URL,
83
+ INSTALLER_SHA256,
84
+ )
85
+
86
+ with tempfile.TemporaryDirectory(prefix="rbek-pypi-install-") as tmp:
87
+ path = pathlib.Path(tmp) / "install.sh"
88
+ path.write_bytes(installer)
89
+ path.chmod(0o700)
90
+
91
+ subprocess.run(
92
+ ["bash", str(path)],
93
+ check=True,
94
+ stdout=sys.stderr,
95
+ stderr=sys.stderr,
96
+ )
97
+
98
+ runtime = _runtime_path()
99
+
100
+ if runtime is None:
101
+ raise RbekBootstrapError(
102
+ "RBEK installer completed but rbek-cli was not found in PATH."
103
+ )
104
+
105
+ _validate_runtime(runtime)
106
+ return runtime
107
+
108
+
109
+ def ensure_runtime() -> str:
110
+ runtime = _runtime_path()
111
+
112
+ if runtime is None:
113
+ runtime = _install_runtime()
114
+ else:
115
+ _validate_runtime(runtime)
116
+
117
+ return runtime
118
+
119
+
120
+ def run_demo() -> int:
121
+ demo = _download_verified(
122
+ DEMO_URL,
123
+ DEMO_SHA256,
124
+ )
125
+
126
+ with tempfile.TemporaryDirectory(prefix="rbek-pypi-demo-") as tmp:
127
+ path = pathlib.Path(tmp) / "demo.sh"
128
+ path.write_bytes(demo)
129
+ path.chmod(0o700)
130
+
131
+ completed = subprocess.run(
132
+ ["bash", str(path)],
133
+ check=False,
134
+ )
135
+
136
+ return int(completed.returncode)
137
+
138
+
139
+ def _delegate(runtime: str, args: list[str]) -> int:
140
+ completed = subprocess.run(
141
+ [runtime, *args],
142
+ check=False,
143
+ )
144
+ return int(completed.returncode)
145
+
146
+
147
+ def main() -> None:
148
+ args = sys.argv[1:]
149
+
150
+ try:
151
+ if args == ["demo"]:
152
+ ensure_runtime()
153
+ raise SystemExit(run_demo())
154
+
155
+ runtime = ensure_runtime()
156
+ raise SystemExit(_delegate(runtime, args))
157
+
158
+ except KeyboardInterrupt:
159
+ raise SystemExit(130)
160
+
161
+ except RbekBootstrapError as exc:
162
+ print(f"RBEK bootstrap error: {exc}", file=sys.stderr)
163
+ raise SystemExit(2)
164
+
165
+ except (OSError, subprocess.SubprocessError) as exc:
166
+ print(f"RBEK bootstrap failure: {exc}", file=sys.stderr)
167
+ raise SystemExit(3)