fix(notify): open configured web run pages from ntfy
This commit is contained in:
@@ -25,6 +25,7 @@ import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
from pathlib import Path
|
||||
from urllib.parse import urlsplit
|
||||
|
||||
from zoneinfo import ZoneInfoNotFoundError
|
||||
|
||||
@@ -642,6 +643,16 @@ class Setup:
|
||||
raise ValueError("Invalid API/web bind address; use an IPv4 address such as 0.0.0.0 or 127.0.0.1") from None
|
||||
prefix = self.resolve_prefix()
|
||||
allow_authoring = self.authoring_role(prefix, args.allow_authoring)
|
||||
web_public_url = self.environ.get("PIPELINES_WEB_PUBLIC_URL", "")
|
||||
previous = prefix / MARKER
|
||||
if not web_public_url and previous.is_file() and not previous.is_symlink():
|
||||
web_public_url = json.loads(previous.read_text()).get("opencode_env", {}).get("PIPELINES_WEB_PUBLIC_URL", "")
|
||||
if web_public_url:
|
||||
parsed = urlsplit(web_public_url)
|
||||
if (parsed.scheme not in ("http", "https") or not parsed.hostname or parsed.username is not None
|
||||
or parsed.password is not None or parsed.query or parsed.fragment or parsed.path not in ("", "/")
|
||||
or any(ord(c) < 33 for c in web_public_url)):
|
||||
raise ValueError("PIPELINES_WEB_PUBLIC_URL must be an HTTP(S) web origin without credentials, path, query or fragment")
|
||||
harness = self.harness()
|
||||
service_path = self.service_path()
|
||||
# Reuse an already built ntfy binary and skip the release lookup, so a
|
||||
@@ -684,6 +695,7 @@ class Setup:
|
||||
if self.environ.get(key):
|
||||
opencode_env[key] = self.environ[key]
|
||||
opencode_env["PIPELINES_DEFAULT_MODEL"] = args.model or pipeline_model
|
||||
opencode_env["PIPELINES_WEB_PUBLIC_URL"] = web_public_url or f"http://{lan_ip if args.web_host == '0.0.0.0' else args.web_host}:{args.web_port}"
|
||||
path_value = str(prefix / "bin") + os.pathsep + self.environ.get("PATH", "")
|
||||
manifest = {
|
||||
"format": 1,
|
||||
|
||||
Reference in New Issue
Block a user