Qwen3.8-Flash-Next on any consumer hardware: one-click install for Windows / Linux. Strata inference engine, OpenAI/Anthropic API on localhost, optional image input.
C++
Portable monitor bundle: carries consoleinfo.py and overview.py (manifest schema 6), the plain Monitor runs when launch is not bundled, smokes accept the Overview's /metrics read, test derives the bundle's import closure
Niko12213fa1b524d770
diff --git a/docs/TERMINAL.md b/docs/TERMINAL.mdindex 0165615a9..abdc75be3 100644--- a/docs/TERMINAL.md+++ b/docs/TERMINAL.md@@ -184,7 +184,7 @@ python dist/strata-monitor.pyz monitor --url https://HOST --once --jsonpython dist/strata-monitor.pyz logs --url https://HOST --output json```-The `.pyz` contains only the bounded telemetry client, connection store, renderers for the Overview and five detail pages, optional TUI module, the same status/monitor/logs command implementation used by `strata`, and Strata's MIT license notice. It has no server, engine, model, setup code or bundled framework. One-shot status, request activity and saved connections work with Python's standard library alone; interactive mode needs an explicit `python -m pip install textual==8.2.8` in that Python environment. The adjacent version-4 `.manifest.json` records a SHA-256 checksum, exact bundle members, Python 3.10 minimum and telemetry schema 1 compatibility. The verifier still accepts older version-1 through version-3 source bundles so a local update can retain and roll back to one. The manifest has no publisher signature, so it is a source-run artifact, not a signed release component. A remote URL still requires HTTPS or a local SSH tunnel; credentials come from an environment variable through `--credential-env` or a saved reference.+The `.pyz` contains only the bounded telemetry client, connection store, renderers for the Overview and five detail pages, optional TUI module, the same status/monitor/logs command implementation used by `strata`, and Strata's MIT license notice. It has no server, engine, model, setup code or bundled framework. One-shot status, request activity and saved connections work with Python's standard library alone; interactive mode needs an explicit `python -m pip install textual==8.2.8` in that Python environment. The adjacent version-6 `.manifest.json` records a SHA-256 checksum, exact bundle members, Python 3.10 minimum and telemetry schema 1 compatibility. The verifier still accepts older version-1 through version-5 source bundles so a local update can retain and roll back to one. The manifest has no publisher signature, so it is a source-run artifact, not a signed release component. A remote URL still requires HTTPS or a local SSH tunnel; credentials come from an environment variable through `--credential-env` or a saved reference.Before distributing a candidate to an operator, run its standard-library smoke on each target Python and OS:diff --git a/packaging/monitor_bundle.py b/packaging/monitor_bundle.pyindex f79419af2..1c27c2c7e 100644--- a/packaging/monitor_bundle.py+++ b/packaging/monitor_bundle.py@@ -31,14 +31,18 @@ SOURCES_V2 = ()SOURCES_V3 = (*SOURCES_V2, "strata_cli/dashboard.py")SOURCES_V4 = (*SOURCES_V3, "strata_cli/detail_dashboard.py")-SOURCES = (*SOURCES_V4, "strata_cli/nav.py") # schema 5: the view tabs every screen shares (strata_cli/nav.py)+SOURCES_V5 = (*SOURCES_V4, "strata_cli/nav.py") # schema 5: the view tabs every screen shares (strata_cli/nav.py)+# schema 6: the two modules the interactive Monitor imports at run time (strata_cli/monitor.py, render.py) that earlier lists missed.+# tests/terminal/test_monitor_bundle.py derives the import closure of the bundle's entry point and fails if this list falls behind.+SOURCES = (*SOURCES_V5, "strata_cli/consoleinfo.py", "strata_cli/overview.py")BOOTSTRAP = b"from strata_cli.monitor_commands import main\nraise SystemExit(main())\n"MEMBERS_V1 = ("__main__.py", *SOURCES_V2)LICENSE_NOTICE = "LICENSE"MEMBERS_V2 = (*MEMBERS_V1, LICENSE_NOTICE)MEMBERS_V3 = (*MEMBERS_V2, "strata_cli/dashboard.py")MEMBERS_V4 = (*MEMBERS_V3, "strata_cli/detail_dashboard.py")-MEMBERS = (*MEMBERS_V4, "strata_cli/nav.py")+MEMBERS_V5 = (*MEMBERS_V4, "strata_cli/nav.py")+MEMBERS = (*MEMBERS_V5, "strata_cli/consoleinfo.py", "strata_cli/overview.py")COMPATIBILITY = {"python_min": "3.10", "telemetry_schema": [1]}MAX_BUNDLE_BYTES = 1024 * 1024MAX_MANIFEST_BYTES = 64 * 1024@@ -74,7 +78,7 @@ def build(bundle: Path) -> dict:if set(names) != set((*MEMBERS, "strata_cli/")) or len(names) != len(MEMBERS) + 1:raise ValueError("bundle member list changed during build")files = {name: digest(archive.read(name)) for name in MEMBERS}- report = {"schema_version": 5, "kind": "strata-monitor-bundle",+ report = {"schema_version": 6, "kind": "strata-monitor-bundle","bundle": bundle.name, "sha256": digest(temp_bundle.read_bytes()),"files": files, "interactive_dependency": "textual==8.2.8","compatibility": COMPATIBILITY, "license": "MIT", "license_file": LICENSE_NOTICE,@@ -96,13 +100,13 @@ def verify(bundle: Path) -> dict:raise ValueError("bundle and manifest must be bounded regular files")report = json.loads(manifest_path(bundle).read_text())if (not isinstance(report, dict) or type(report.get("schema_version")) is not int or- report["schema_version"] not in (1, 2, 3, 4, 5) or+ report["schema_version"] not in (1, 2, 3, 4, 5, 6) orreport.get("kind") != "strata-monitor-bundle" orreport.get("publisher_signature") is not None orreport.get("bundle") != bundle.name or report.get("sha256") != digest(bundle.read_bytes())):raise ValueError("bundle manifest or SHA-256 mismatch")members = {1: MEMBERS_V1, 2: MEMBERS_V2, 3: MEMBERS_V3, 4: MEMBERS_V4,- 5: MEMBERS}[report["schema_version"]]+ 5: MEMBERS_V5, 6: MEMBERS}[report["schema_version"]]if report["schema_version"] >= 2:if (report.get("compatibility") != COMPATIBILITY or report.get("license") != "MIT" orreport.get("license_file") != LICENSE_NOTICE):diff --git a/strata_cli/monitor_commands.py b/strata_cli/monitor_commands.pyindex b3bef9f41..6414eeaac 100644--- a/strata_cli/monitor_commands.py+++ b/strata_cli/monitor_commands.py@@ -192,7 +192,14 @@ def run(a: argparse.Namespace) -> int:try:from strata_cli.launch.monitor_ext import LaunchMonitorexcept ImportError:- return _error("monitor component missing; install the optional terminal UI dependency", 5, machine)+ # the portable monitor bundle carries the read-only client only (no launch/Connect view): run the plain Monitor+ try:+ from strata_cli.monitor import MonitorApp+ except ImportError:+ return _error("monitor component missing; install the optional terminal UI dependency", 5, machine)+ MonitorApp(endpoint, None, interval=a.interval, requests=a.requests,+ theme=a.theme, color=a.color, glyphs=a.glyphs).run()+ return 0# the one monitor, with the same seven views as the one `strata launch` opens (Connect is key 7 and works against this --url# server); q just detaches here: nothing was started by this command, so there is nothing to stopLaunchMonitor(endpoint, None, info={"url": endpoint.base_url, "urls": [endpoint.base_url], "key": endpoint.credential or "", "model": "",diff --git a/tests/terminal/test_monitor_bundle.py b/tests/terminal/test_monitor_bundle.pyindex 1bcdb44e0..312fb7a87 100644--- a/tests/terminal/test_monitor_bundle.py+++ b/tests/terminal/test_monitor_bundle.py@@ -65,7 +65,7 @@ class MonitorBundleTests(unittest.TestCase):build(bundle)with zipfile.ZipFile(bundle) as archive:self.assertIn(b"MIT License\r\n", archive.read("LICENSE"))- self.assertEqual(verify(bundle)["schema_version"], 5)+ self.assertEqual(verify(bundle)["schema_version"], 6)def test_update_rollback_and_commit_keep_one_verified_previous_copy(self):with tempfile.TemporaryDirectory() as directory:@@ -282,6 +282,38 @@ class MonitorBundleTests(unittest.TestCase):with self.assertRaisesRegex(ValueError, "manifest or SHA-256"):verify(bundle)+ def test_bundle_carries_every_module_its_entry_point_imports(self):+ """The import closure of strata_cli.monitor_commands (lazy imports included) minus the launch package must be in the bundle."""+ import ast+ needed, todo = set(), ["strata_cli/monitor_commands.py"]+ while todo:+ name = todo.pop()+ if name in needed:+ continue+ needed.add(name)+ for node in ast.walk(ast.parse((ROOT / name).read_text(encoding="utf-8"))):+ if isinstance(node, ast.ImportFrom) and node.module and node.module.split(".")[0] == "strata_cli":+ names = [node.module] + [node.module + "." + a.name for a in node.names]+ elif isinstance(node, ast.Import):+ names = [a.name for a in node.names]+ else:+ continue+ for module in names:+ path = module.replace(".", "/") + ".py"+ if module.startswith("strata_cli") and (ROOT / path).is_file() and "/launch/" not in path:+ todo.append(path)+ self.assertLessEqual(needed, set(BUILDER_MODULE.SOURCES))++ def test_plain_monitor_runs_when_the_launch_package_is_not_bundled(self):+ """The pyz has no strata_cli.launch: interactive `monitor` must fall back to the plain Monitor, not fail."""+ from strata_cli import monitor as monitor_module+ from strata_cli import monitor_commands+ ran = []+ blocked = {"strata_cli.launch.monitor_ext": None} # None in sys.modules makes the import raise ImportError+ with mock.patch.dict(sys.modules, blocked), mock.patch.object(monitor_module.MonitorApp, "run", lambda self: ran.append(self.endpoint.base_url)), mock.patch.object(sys.stdout, "isatty", return_value=True):+ code = monitor_commands.main(["monitor", "--url", "http://127.0.0.1:9"])+ self.assertEqual((code, ran), (0, ["http://127.0.0.1:9"]))+def test_versioned_manifest_keeps_legacy_update_and_rollback_available(self):with tempfile.TemporaryDirectory() as directory:root = Path(directory)@@ -293,7 +325,8 @@ class MonitorBundleTests(unittest.TestCase):for old_bundle, version in ((current, 1), (previous, 2), (old_visual, 3)):with zipfile.ZipFile(modern) as source, zipfile.ZipFile(old_bundle, "w", zipfile.ZIP_DEFLATED) as legacy:for item in source.infolist():- if item.filename not in ("strata_cli/detail_dashboard.py", "strata_cli/nav.py") and \+ if item.filename not in ("strata_cli/detail_dashboard.py", "strata_cli/nav.py",+ "strata_cli/consoleinfo.py", "strata_cli/overview.py") and \(version >= 3 or item.filename != "strata_cli/dashboard.py") and \(version != 1 or item.filename != "LICENSE"):legacy.writestr(item, source.read(item.filename))@@ -303,6 +336,8 @@ class MonitorBundleTests(unittest.TestCase):report["sha256"] = hashlib.sha256(old_bundle.read_bytes()).hexdigest()del report["files"]["strata_cli/detail_dashboard.py"]del report["files"]["strata_cli/nav.py"]+ del report["files"]["strata_cli/consoleinfo.py"]+ del report["files"]["strata_cli/overview.py"]if version < 3:del report["files"]["strata_cli/dashboard.py"]if version == 1:@@ -313,7 +348,7 @@ class MonitorBundleTests(unittest.TestCase):self.assertEqual(verify(current)["schema_version"], 1)self.assertEqual(verify(previous)["schema_version"], 2)self.assertEqual(verify(old_visual)["schema_version"], 3)- self.assertEqual(verify(modern)["schema_version"], 5)+ self.assertEqual(verify(modern)["schema_version"], 6)with zipfile.ZipFile(modern) as archive:self.assertIn(b"MIT License", archive.read("LICENSE"))self.assertIn(b"render_dashboard", archive.read("strata_cli/dashboard.py"))@@ -324,7 +359,7 @@ class MonitorBundleTests(unittest.TestCase):self.assertTrue(preview["would_update"])self.assertTrue(update(modern, target, if_current_sha256=preview["current_sha256"],if_candidate_sha256=preview["candidate_sha256"])["updated"])- self.assertEqual(verify(target / modern.name)["schema_version"], 5)+ self.assertEqual(verify(target / modern.name)["schema_version"], 6)self.assertEqual(verify(root / "optional-monitor.previous" / current.name)["schema_version"], 1)planned = rollback(target, plan=True)self.assertTrue(rollback(target, if_active_sha256=planned["active_sha256"],@@ -336,7 +371,7 @@ class MonitorBundleTests(unittest.TestCase):self.assertTrue(update(modern, second_target,if_current_sha256=preview["current_sha256"],if_candidate_sha256=preview["candidate_sha256"])["updated"])- self.assertEqual(verify(second_target / modern.name)["schema_version"], 5)+ self.assertEqual(verify(second_target / modern.name)["schema_version"], 6)planned = rollback(second_target, plan=True)self.assertTrue(rollback(second_target, if_active_sha256=planned["active_sha256"],if_rollback_sha256=planned["rollback_sha256"])["rolled_back"])@@ -401,7 +436,7 @@ class MonitorBundleTests(unittest.TestCase):capture_output=True, text=True)subprocess.run([sys.executable, str(BUILDER), "verify", str(bundle)], check=True,capture_output=True, text=True)- self.assertLess(bundle.stat().st_size, 64 * 1024)+ self.assertLess(bundle.stat().st_size, 96 * 1024)with zipfile.ZipFile(bundle) as archive:self.assertIn(b"MIT License", archive.read("LICENSE"))self.assertIn("strata_cli/dashboard.py", archive.namelist())diff --git a/tools/portable_monitor_pty_smoke.py b/tools/portable_monitor_pty_smoke.pyindex a814c974d..840b08adf 100644--- a/tools/portable_monitor_pty_smoke.py+++ b/tools/portable_monitor_pty_smoke.py@@ -97,7 +97,7 @@ def smoke(bundle: Path) -> dict:server.shutdown()server.server_close()worker.join(timeout=3)- if not server_alive or any(path != "GET /v1/telemetry" for path in paths):+ if not server_alive or any(path not in ("GET /v1/telemetry", "GET /metrics") for path in paths):raise RuntimeError("Monitor detach changed or stopped the telemetry server")return {"schema_version": 1, "scope": "portable_monitor_posix_pty_smoke","bundle_sha256": hashlib.sha256(bundle.read_bytes()).hexdigest(),diff --git a/tools/portable_monitor_smoke.py b/tools/portable_monitor_smoke.pyindex fc72bd2e7..49315d1c7 100644--- a/tools/portable_monitor_smoke.py+++ b/tools/portable_monitor_smoke.py@@ -217,7 +217,7 @@ def smoke(bundle: Path, *, interactive: bool = False) -> dict:worker.join(timeout=5)if (paths[:2] != ["GET /v1/telemetry", "GET /v1/telemetry"] or- any(path != "GET /v1/telemetry" for path in paths) or+ any(path not in ("GET /v1/telemetry", "GET /metrics") for path in paths) or # the interactive Overview also reads /metrics (404 here: it keeps the earlier Overview)(interactive and len(paths) < 4) or (not interactive and len(paths) != 3)):raise RuntimeError(f"unexpected client HTTP operations: {paths}")report = {"schema_version": 1, "scope": "portable_monitor_stdlib_smoke",