Deploy AIOS web (React glide grid + FastAPI slice)
Browse files- Dockerfile +9 -1
- RELEASES.json +1 -1
- VERSION +1 -1
- api/routes_connectors.py +38 -20
- api/test_website_runtime.py +105 -0
- api/website_tools.py +27 -4
- web/public/AIOS_DEPLOY_RECEIPT +1 -1
Dockerfile
CHANGED
|
@@ -42,8 +42,16 @@ COPY web/ ./
|
|
| 42 |
RUN npm run build # -> /web/dist
|
| 43 |
|
| 44 |
# ---- stage 2: python API serving the bundle ----
|
| 45 |
-
FROM python:3.12-slim
|
| 46 |
WORKDIR /app
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
COPY requirements.txt ./
|
| 48 |
# W59-T35, 2026-09-13: pin the locally installed resolver instead of upgrading pip implicitly.
|
| 49 |
# The Space uploader still sends aios-web/requirements.txt with open bounds and excludes the
|
|
|
|
| 42 |
RUN npm run build # -> /web/dist
|
| 43 |
|
| 44 |
# ---- stage 2: python API serving the bundle ----
|
| 45 |
+
FROM python:3.12-slim-trixie
|
| 46 |
WORKDIR /app
|
| 47 |
+
# Chromium's libraries match the reviewed Playwright Debian 13 dependency list.
|
| 48 |
+
RUN apt-get update \
|
| 49 |
+
&& apt-get install -y --no-install-recommends \
|
| 50 |
+
fonts-liberation libasound2t64 libatk-bridge2.0-0t64 libatk1.0-0t64 \
|
| 51 |
+
libatspi2.0-0t64 libcairo2 libcups2t64 libdbus-1-3 libdrm2 libgbm1 \
|
| 52 |
+
libglib2.0-0t64 libnspr4 libnss3 libpango-1.0-0 libx11-6 libxcb1 \
|
| 53 |
+
libxcomposite1 libxdamage1 libxext6 libxfixes3 libxkbcommon0 libxrandr2 \
|
| 54 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 55 |
COPY requirements.txt ./
|
| 56 |
# W59-T35, 2026-09-13: pin the locally installed resolver instead of upgrading pip implicitly.
|
| 57 |
# The Space uploader still sends aios-web/requirements.txt with open bounds and excludes the
|
RELEASES.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
{
|
| 2 |
-
"current": "
|
| 3 |
"releases": []
|
| 4 |
}
|
|
|
|
| 1 |
{
|
| 2 |
+
"current": "c75ec9fa8",
|
| 3 |
"releases": []
|
| 4 |
}
|
VERSION
CHANGED
|
@@ -1 +1 @@
|
|
| 1 |
-
|
|
|
|
| 1 |
+
c75ec9fa8
|
api/routes_connectors.py
CHANGED
|
@@ -2874,27 +2874,41 @@ def odoo_status(connection_id: str = None, session: Session = Depends(require_se
|
|
| 2874 |
"receipt": receipt, "lastSyncAt": last_sync_at}
|
| 2875 |
|
| 2876 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2877 |
def _daily_completed_sync(rt, connector_key):
|
| 2878 |
"""Read completed mirror markers; never create a mirror or contact a provider."""
|
| 2879 |
if connector_key == "amazon_sp":
|
| 2880 |
-
|
| 2881 |
-
try:
|
| 2882 |
-
states = cx.sync_state(rt, rt.key)
|
| 2883 |
-
except cx.AmazonStatusSafetyError as refused:
|
| 2884 |
-
states = dict(getattr(refused, "safe_status", None) or {})
|
| 2885 |
-
except Exception:
|
| 2886 |
-
return None, False
|
| 2887 |
-
if not isinstance(states, dict):
|
| 2888 |
-
return None, False
|
| 2889 |
-
rows = [row for row in states.values() if isinstance(row, dict) and not row.get("declared")]
|
| 2890 |
-
stamps = [_sync_stamp(row.get("lastSuccess")) for row in rows]
|
| 2891 |
-
stamps = [stamp for stamp in stamps if stamp]
|
| 2892 |
-
if stamps:
|
| 2893 |
-
return max(stamps, key=datetime.fromisoformat), True
|
| 2894 |
-
# This is the existing reader's explicit unreadable-mirror outcome, not a never-run fact.
|
| 2895 |
-
unknown = any(str(row.get("unknownCause") or "").startswith(
|
| 2896 |
-
"This container has no readable sync status.") for row in rows)
|
| 2897 |
-
return None, bool(rows) and not unknown
|
| 2898 |
if connector_key == "meta_ads":
|
| 2899 |
from pathlib import Path
|
| 2900 |
from harness import datastore
|
|
@@ -2938,7 +2952,8 @@ def connector_sync_status(connector_key: str, connection_id: str = None,
|
|
| 2938 |
raise err(404, "sync_provider_unknown",
|
| 2939 |
f"{connector_key} is not registered for connector sync")
|
| 2940 |
rt = (_odoo_status_reads(session.runtime) if connector_key == "odoo"
|
| 2941 |
-
else _ConnectorStatusReads(session.runtime)
|
|
|
|
| 2942 |
resolved_connection = (_odoo_connection_slot(rt, connection_id)
|
| 2943 |
if connector_key == "odoo" else connection_id)
|
| 2944 |
jobs = _connection_jobs(rt, connector_key, resolved_connection)
|
|
@@ -2949,7 +2964,10 @@ def connector_sync_status(connector_key: str, connection_id: str = None,
|
|
| 2949 |
receipt = odoo_health_receipt(rt, resolved_connection, jobs=jobs)
|
| 2950 |
answer["lastSyncAt"] = _odoo_last_sync_at(rt, receipt, connection_id)
|
| 2951 |
if connector_key in ("amazon_sp", "meta_ads"):
|
| 2952 |
-
|
|
|
|
|
|
|
|
|
|
| 2953 |
answer.update(schedule="daily", lastCompletedAt=completed, lastSyncAt=completed,
|
| 2954 |
lastCompletedKnown=known, canSync=bool(session.admin))
|
| 2955 |
return _safe_connector_status(connector_key, answer)
|
|
|
|
| 2874 |
"receipt": receipt, "lastSyncAt": last_sync_at}
|
| 2875 |
|
| 2876 |
|
| 2877 |
+
def _amazon_completed_sync(rt):
|
| 2878 |
+
"""Project completion markers without counting business rows or building database detail."""
|
| 2879 |
+
import duckdb
|
| 2880 |
+
from harness import amazon_store as az, datastore
|
| 2881 |
+
|
| 2882 |
+
def read(cursor):
|
| 2883 |
+
rows = cursor.execute("SELECT entity, phase, updated_at FROM _sync_state "
|
| 2884 |
+
"WHERE starts_with(entity, ?)", [az.PREFIX]).fetchall()
|
| 2885 |
+
markers = {str(entity): (phase, _sync_stamp(at)) for entity, phase, at in rows}
|
| 2886 |
+
stamps = []
|
| 2887 |
+
for table in az.TABLES:
|
| 2888 |
+
landed = markers.get(az.entity_key(table), (None, None))
|
| 2889 |
+
watermark = markers.get(az.entity_key(az.WATERMARK_PREFIX + table), (None, None))
|
| 2890 |
+
# A refused pass also closes its tick. Only its saved watermark proves success.
|
| 2891 |
+
candidates = ((watermark,) if landed[0] in ("refused", "failed", "throttled") else
|
| 2892 |
+
(landed, markers.get(az.entity_key("sync_tick_" + table), (None, None)), watermark))
|
| 2893 |
+
stamps.extend(at for phase, at in candidates if phase == "done" and at)
|
| 2894 |
+
return (max(stamps, key=datetime.fromisoformat) if stamps else None), True
|
| 2895 |
+
|
| 2896 |
+
try:
|
| 2897 |
+
path = az._tenant_mirror_path(rt.key, rt=rt)
|
| 2898 |
+
if not path.is_file():
|
| 2899 |
+
return None, False
|
| 2900 |
+
if path.resolve() == Path(datastore.DB_PATH).resolve():
|
| 2901 |
+
return read(datastore.ro_cursor())
|
| 2902 |
+
with duckdb.connect(str(path), read_only=True) as cursor:
|
| 2903 |
+
return read(cursor)
|
| 2904 |
+
except Exception:
|
| 2905 |
+
return None, False
|
| 2906 |
+
|
| 2907 |
+
|
| 2908 |
def _daily_completed_sync(rt, connector_key):
|
| 2909 |
"""Read completed mirror markers; never create a mirror or contact a provider."""
|
| 2910 |
if connector_key == "amazon_sp":
|
| 2911 |
+
return _amazon_completed_sync(rt)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2912 |
if connector_key == "meta_ads":
|
| 2913 |
from pathlib import Path
|
| 2914 |
from harness import datastore
|
|
|
|
| 2952 |
raise err(404, "sync_provider_unknown",
|
| 2953 |
f"{connector_key} is not registered for connector sync")
|
| 2954 |
rt = (_odoo_status_reads(session.runtime) if connector_key == "odoo"
|
| 2955 |
+
else _ConnectorStatusReads(session.runtime, (connector_sync.JOBS_KEY, connector_sync.STATE_KEY)
|
| 2956 |
+
if connector_key == "amazon_sp" else ()))
|
| 2957 |
resolved_connection = (_odoo_connection_slot(rt, connection_id)
|
| 2958 |
if connector_key == "odoo" else connection_id)
|
| 2959 |
jobs = _connection_jobs(rt, connector_key, resolved_connection)
|
|
|
|
| 2964 |
receipt = odoo_health_receipt(rt, resolved_connection, jobs=jobs)
|
| 2965 |
answer["lastSyncAt"] = _odoo_last_sync_at(rt, receipt, connection_id)
|
| 2966 |
if connector_key in ("amazon_sp", "meta_ads"):
|
| 2967 |
+
if connector_key == "amazon_sp" and (str(resolved_connection or "").strip() or "default") != "default":
|
| 2968 |
+
completed, known = None, False
|
| 2969 |
+
else:
|
| 2970 |
+
completed, known = _daily_completed_sync(rt, connector_key)
|
| 2971 |
answer.update(schedule="daily", lastCompletedAt=completed, lastSyncAt=completed,
|
| 2972 |
lastCompletedKnown=known, canSync=bool(session.admin))
|
| 2973 |
return _safe_connector_status(connector_key, answer)
|
api/test_website_runtime.py
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Exercise runtime preparation failures and an optional real data-free browser launch."""
|
| 2 |
+
|
| 3 |
+
import argparse
|
| 4 |
+
import json
|
| 5 |
+
import os
|
| 6 |
+
from pathlib import Path
|
| 7 |
+
import subprocess
|
| 8 |
+
import sys
|
| 9 |
+
import tempfile
|
| 10 |
+
import unittest
|
| 11 |
+
from unittest.mock import patch
|
| 12 |
+
|
| 13 |
+
sys.path.insert(0, str(Path(__file__).resolve().parents[2] / "platform"))
|
| 14 |
+
import website_tools
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
class WebsiteRuntimeTests(unittest.TestCase):
|
| 18 |
+
def setUp(self):
|
| 19 |
+
self.temporary = tempfile.TemporaryDirectory(prefix="website-runtime-fixture-")
|
| 20 |
+
self.addCleanup(self.temporary.cleanup)
|
| 21 |
+
self.root = Path(self.temporary.name)
|
| 22 |
+
self.node = self.root / "node-v24.21.0-linux-x64/bin/node"
|
| 23 |
+
self.node.parent.mkdir(parents=True)
|
| 24 |
+
self.node.touch()
|
| 25 |
+
self.package = self.root / "sdk/node_modules/pomerado"
|
| 26 |
+
self.package.mkdir(parents=True)
|
| 27 |
+
(self.package / "package.json").write_text(
|
| 28 |
+
json.dumps({"version": website_tools._VERSION, "license": "MIT"}), encoding="utf-8")
|
| 29 |
+
self.calls = []
|
| 30 |
+
self.failure = None
|
| 31 |
+
self.proof = b"aios-website-runtime-ok\n"
|
| 32 |
+
|
| 33 |
+
def command(self, argv, **kwargs):
|
| 34 |
+
self.calls.append((argv, kwargs))
|
| 35 |
+
browser = "--input-type=module" in argv
|
| 36 |
+
if browser and self.failure:
|
| 37 |
+
return subprocess.CompletedProcess(argv, 127, b"", self.failure)
|
| 38 |
+
return subprocess.CompletedProcess(argv, 0, self.proof if browser else b"", b"")
|
| 39 |
+
|
| 40 |
+
def prepare(self):
|
| 41 |
+
with patch.object(website_tools.host_platform, "system", return_value="Linux"), \
|
| 42 |
+
patch.object(website_tools.host_platform, "machine", return_value="x86_64"), \
|
| 43 |
+
patch.object(website_tools, "urlopen", side_effect=AssertionError("Unexpected download")), \
|
| 44 |
+
patch.object(website_tools.subprocess, "run", side_effect=self.command):
|
| 45 |
+
return website_tools.prepare_runtime(self.root)
|
| 46 |
+
|
| 47 |
+
def test_missing_library_refuses_until_browser_page_check_succeeds(self):
|
| 48 |
+
self.failure = b"libglib-2.0.so.0: cannot open shared object file. CANARY-private-payload"
|
| 49 |
+
with self.assertLogs("website_tools", level="WARNING") as logs:
|
| 50 |
+
with self.assertRaises(website_tools.deps.HTTPException) as failed:
|
| 51 |
+
self.prepare()
|
| 52 |
+
self.assertEqual(failed.exception.status_code, 503)
|
| 53 |
+
self.assertEqual(failed.exception.detail["error"]["code"], "website_runtime_unavailable")
|
| 54 |
+
self.assertIn("Chromium launch and page check", failed.exception.detail["error"]["message"])
|
| 55 |
+
self.assertNotIn("CANARY-private-payload", str(failed.exception.detail) + str(logs.output))
|
| 56 |
+
self.failure = None
|
| 57 |
+
result = self.prepare()
|
| 58 |
+
self.assertEqual(result["POMERADO_NODE"], str(self.node))
|
| 59 |
+
self.assertEqual(result["POMERADO_PACKAGE_ROOT"], str(self.package))
|
| 60 |
+
|
| 61 |
+
def test_process_success_without_browser_page_proof_is_refused(self):
|
| 62 |
+
self.proof = b""
|
| 63 |
+
with self.assertRaises(website_tools.deps.HTTPException):
|
| 64 |
+
self.prepare()
|
| 65 |
+
|
| 66 |
+
def test_existing_unreviewed_package_is_refused_before_browser(self):
|
| 67 |
+
(self.package / "package.json").write_text(
|
| 68 |
+
json.dumps({"version": "0.0.0", "license": "MIT"}), encoding="utf-8")
|
| 69 |
+
with self.assertRaises(website_tools.deps.HTTPException) as failed:
|
| 70 |
+
self.prepare()
|
| 71 |
+
self.assertIn("Pomerado manifest check", failed.exception.detail["error"]["message"])
|
| 72 |
+
self.assertFalse(any("install" in argv or "--input-type=module" in argv for argv, _ in self.calls))
|
| 73 |
+
|
| 74 |
+
def test_setup_child_cannot_receive_product_credentials_or_global_browser_cache(self):
|
| 75 |
+
with patch.dict(os.environ, {"ODOO_WEB_RI_PASSWORD": "CANARY-password", "HF_TOKEN": "CANARY-token",
|
| 76 |
+
"PLAYWRIGHT_BROWSERS_PATH": "/other/browser-cache",
|
| 77 |
+
"OPENROUTER_API_KEY": "CANARY-provider"}):
|
| 78 |
+
result = self.prepare()
|
| 79 |
+
self.assertEqual(result["POMERADO_BROWSERS_PATH"], str(self.root / "browsers"))
|
| 80 |
+
for _argv, options in self.calls:
|
| 81 |
+
self.assertEqual(options["env"]["PLAYWRIGHT_BROWSERS_PATH"], str(self.root / "browsers"))
|
| 82 |
+
self.assertFalse(any("CANARY-" in value for value in options["env"].values()))
|
| 83 |
+
|
| 84 |
+
def test_browser_install_timeout_is_named_without_subprocess_output(self):
|
| 85 |
+
with patch.object(website_tools.host_platform, "system", return_value="Linux"), \
|
| 86 |
+
patch.object(website_tools.host_platform, "machine", return_value="x86_64"), \
|
| 87 |
+
patch.object(website_tools.subprocess, "run", side_effect=[
|
| 88 |
+
subprocess.CompletedProcess([], 0, b"", b""),
|
| 89 |
+
subprocess.TimeoutExpired("private-command", 1, output=b"CANARY-private-output")]):
|
| 90 |
+
with self.assertRaises(website_tools.deps.HTTPException) as failed:
|
| 91 |
+
website_tools.prepare_runtime(self.root)
|
| 92 |
+
self.assertIn("Chromium installation", failed.exception.detail["error"]["message"])
|
| 93 |
+
self.assertNotIn("CANARY-private-output", str(failed.exception.detail))
|
| 94 |
+
|
| 95 |
+
|
| 96 |
+
if __name__ == "__main__":
|
| 97 |
+
parser = argparse.ArgumentParser(description=__doc__)
|
| 98 |
+
parser.add_argument("--runtime-dir", type=Path, help="Also prepare the reviewed runtime and launch a data-free browser")
|
| 99 |
+
args, remaining = parser.parse_known_args()
|
| 100 |
+
result = unittest.main(argv=[sys.argv[0], *remaining], exit=False)
|
| 101 |
+
if not result.result.wasSuccessful():
|
| 102 |
+
raise SystemExit(1)
|
| 103 |
+
if args.runtime_dir:
|
| 104 |
+
website_tools.prepare_runtime(args.runtime_dir)
|
| 105 |
+
print("Data-free Chromium page check passed.")
|
api/website_tools.py
CHANGED
|
@@ -4,6 +4,7 @@ import copy
|
|
| 4 |
import datetime as dt
|
| 5 |
import hashlib
|
| 6 |
import json
|
|
|
|
| 7 |
import os
|
| 8 |
from pathlib import Path
|
| 9 |
import platform as host_platform
|
|
@@ -546,13 +547,16 @@ def prepare_runtime(directory):
|
|
| 546 |
timeout=min(90, remaining()))
|
| 547 |
if result.returncode != 0:
|
| 548 |
raise ValueError
|
|
|
|
| 549 |
|
|
|
|
| 550 |
try:
|
| 551 |
root.mkdir(mode=0o700, parents=True, exist_ok=True)
|
| 552 |
root = root.resolve()
|
| 553 |
node_dir = root / "node-v24.21.0-linux-x64"
|
| 554 |
node = node_dir / "bin/node"
|
| 555 |
if not node.is_file():
|
|
|
|
| 556 |
with tempfile.TemporaryDirectory(prefix="node-prepare-", dir=root) as temporary:
|
| 557 |
archive = Path(temporary) / "node.tar.xz"
|
| 558 |
digest = hashlib.sha256()
|
|
@@ -569,6 +573,7 @@ def prepare_runtime(directory):
|
|
| 569 |
if digest.hexdigest() != "fd8e59d5a511510f6a298afb548f18c7d2b1be404d8b4a27d94fbe49f56cb2d6":
|
| 570 |
raise ValueError
|
| 571 |
with tarfile.open(archive, "r:xz") as bundle:
|
|
|
|
| 572 |
bundle.extractall(Path(temporary), filter="data")
|
| 573 |
(Path(temporary) / node_dir.name).replace(node_dir)
|
| 574 |
sdk = root / "sdk"
|
|
@@ -580,20 +585,38 @@ def prepare_runtime(directory):
|
|
| 580 |
NPM_CONFIG_USERCONFIG=os.devnull, NPM_CONFIG_CACHE=str(root / "npm-cache"))
|
| 581 |
with tempfile.TemporaryDirectory(prefix="runtime-check-", dir=root) as temporary:
|
| 582 |
env.update(TMPDIR=temporary, TMP=temporary, TEMP=temporary)
|
|
|
|
| 583 |
command([str(node), "-e", "if(process.version !== 'v24.21.0')process.exit(1)"], env, sdk)
|
| 584 |
if not (package / "package.json").is_file():
|
|
|
|
| 585 |
command([str(node), str(node_dir / "lib/node_modules/npm/bin/npm-cli.js"),
|
| 586 |
"install", "--prefix", str(sdk), "--ignore-scripts", "--no-audit", "--no-fund",
|
| 587 |
"--save-exact", "pomerado@" + _VERSION], env, sdk)
|
|
|
|
| 588 |
manifest = json.loads((package / "package.json").read_text(encoding="utf-8"))
|
| 589 |
if manifest.get("version") != _VERSION or manifest.get("license") != "MIT":
|
| 590 |
raise ValueError
|
|
|
|
| 591 |
command([str(node), str(sdk / "node_modules/playwright/cli.js"), "install", "chromium"], env, sdk)
|
| 592 |
-
|
| 593 |
-
|
| 594 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 595 |
return {"POMERADO_NODE": str(node), "POMERADO_PACKAGE_ROOT": str(package),
|
| 596 |
"POMERADO_BROWSERS_PATH": env["PLAYWRIGHT_BROWSERS_PATH"]}
|
| 597 |
except (OSError, ValueError, KeyError, TypeError, tarfile.TarError, subprocess.TimeoutExpired):
|
|
|
|
| 598 |
raise deps.err(503, "website_runtime_unavailable",
|
| 599 |
-
"Website runtime preparation failed
|
|
|
|
|
|
| 4 |
import datetime as dt
|
| 5 |
import hashlib
|
| 6 |
import json
|
| 7 |
+
import logging
|
| 8 |
import os
|
| 9 |
from pathlib import Path
|
| 10 |
import platform as host_platform
|
|
|
|
| 547 |
timeout=min(90, remaining()))
|
| 548 |
if result.returncode != 0:
|
| 549 |
raise ValueError
|
| 550 |
+
return result
|
| 551 |
|
| 552 |
+
stage = "runtime directory"
|
| 553 |
try:
|
| 554 |
root.mkdir(mode=0o700, parents=True, exist_ok=True)
|
| 555 |
root = root.resolve()
|
| 556 |
node_dir = root / "node-v24.21.0-linux-x64"
|
| 557 |
node = node_dir / "bin/node"
|
| 558 |
if not node.is_file():
|
| 559 |
+
stage = "Node download"
|
| 560 |
with tempfile.TemporaryDirectory(prefix="node-prepare-", dir=root) as temporary:
|
| 561 |
archive = Path(temporary) / "node.tar.xz"
|
| 562 |
digest = hashlib.sha256()
|
|
|
|
| 573 |
if digest.hexdigest() != "fd8e59d5a511510f6a298afb548f18c7d2b1be404d8b4a27d94fbe49f56cb2d6":
|
| 574 |
raise ValueError
|
| 575 |
with tarfile.open(archive, "r:xz") as bundle:
|
| 576 |
+
stage = "Node extraction"
|
| 577 |
bundle.extractall(Path(temporary), filter="data")
|
| 578 |
(Path(temporary) / node_dir.name).replace(node_dir)
|
| 579 |
sdk = root / "sdk"
|
|
|
|
| 585 |
NPM_CONFIG_USERCONFIG=os.devnull, NPM_CONFIG_CACHE=str(root / "npm-cache"))
|
| 586 |
with tempfile.TemporaryDirectory(prefix="runtime-check-", dir=root) as temporary:
|
| 587 |
env.update(TMPDIR=temporary, TMP=temporary, TEMP=temporary)
|
| 588 |
+
stage = "Node version check"
|
| 589 |
command([str(node), "-e", "if(process.version !== 'v24.21.0')process.exit(1)"], env, sdk)
|
| 590 |
if not (package / "package.json").is_file():
|
| 591 |
+
stage = "Pomerado installation"
|
| 592 |
command([str(node), str(node_dir / "lib/node_modules/npm/bin/npm-cli.js"),
|
| 593 |
"install", "--prefix", str(sdk), "--ignore-scripts", "--no-audit", "--no-fund",
|
| 594 |
"--save-exact", "pomerado@" + _VERSION], env, sdk)
|
| 595 |
+
stage = "Pomerado manifest check"
|
| 596 |
manifest = json.loads((package / "package.json").read_text(encoding="utf-8"))
|
| 597 |
if manifest.get("version") != _VERSION or manifest.get("license") != "MIT":
|
| 598 |
raise ValueError
|
| 599 |
+
stage = "Chromium installation"
|
| 600 |
command([str(node), str(sdk / "node_modules/playwright/cli.js"), "install", "chromium"], env, sdk)
|
| 601 |
+
stage = "Chromium launch and page check"
|
| 602 |
+
result = command([str(node), "--input-type=module", "-e", """
|
| 603 |
+
import {chromium} from 'playwright';
|
| 604 |
+
const browser = await chromium.launch({headless:true});
|
| 605 |
+
try {
|
| 606 |
+
const page = await browser.newPage();
|
| 607 |
+
await page.setContent('<title>AIOS runtime check</title>');
|
| 608 |
+
if (page.url() !== 'about:blank' || await page.title() !== 'AIOS runtime check') throw new Error('Smoke check failed');
|
| 609 |
+
} finally {
|
| 610 |
+
await browser.close();
|
| 611 |
+
}
|
| 612 |
+
console.log('aios-website-runtime-ok');
|
| 613 |
+
"""], env, sdk)
|
| 614 |
+
if result.stdout.strip() != b"aios-website-runtime-ok":
|
| 615 |
+
raise ValueError
|
| 616 |
return {"POMERADO_NODE": str(node), "POMERADO_PACKAGE_ROOT": str(package),
|
| 617 |
"POMERADO_BROWSERS_PATH": env["PLAYWRIGHT_BROWSERS_PATH"]}
|
| 618 |
except (OSError, ValueError, KeyError, TypeError, tarfile.TarError, subprocess.TimeoutExpired):
|
| 619 |
+
logging.getLogger(__name__).warning("Website runtime preparation failed during %s.", stage)
|
| 620 |
raise deps.err(503, "website_runtime_unavailable",
|
| 621 |
+
f"Website runtime preparation failed during {stage}. "
|
| 622 |
+
"Supply Node 24.21, pinned Pomerado, Chromium and its OS libraries.") from None
|
web/public/AIOS_DEPLOY_RECEIPT
CHANGED
|
@@ -1 +1 @@
|
|
| 1 |
-
|
|
|
|
| 1 |
+
7a87d8ad91771ce4c4847c3d369032f223721845f44f117efab44b966c9505a7
|