Merge branch 'worktree-agent-ac54c8919e940163a'
# Conflicts: # scripts/setup-native.py
This commit is contained in:
+30
-9
@@ -44,6 +44,7 @@ lan = module("lan_address", "lan-address.py")
|
||||
release_lookup = module("resolve_releases", "resolve-releases.py")
|
||||
tokens = module("save_ntfy_token", "save-ntfy-token.py")
|
||||
app_build = module("app_build", "app_build.py")
|
||||
web_access = module("web_access", "web_access.py")
|
||||
|
||||
DEFAULT_PREFIX = Path.home() / ".local/share/pipelines"
|
||||
MARKER = "pipelines-install.json"
|
||||
@@ -310,10 +311,12 @@ class Setup:
|
||||
saved = {"port": existing.get("server_port"),
|
||||
"ntfy_port": existing.get("ntfy_port"),
|
||||
"bind_address": existing.get("bind_address"),
|
||||
"web_port": web.get("port"), "web_host": web.get("host")}
|
||||
"web_port": web.get("port"), "web_host": web.get("host"),
|
||||
"web_lan": web.get("lan"), "web_lan_plain_login": web.get("lan_plain_login")}
|
||||
supplied = {argument.split("=", 1)[0] for argument in args.argv}
|
||||
for name, value in saved.items():
|
||||
if value is not None and "--" + name.replace("_", "-") not in supplied:
|
||||
flag = name.replace("_", "-")
|
||||
if value is not None and not {"--" + flag, "--no-" + flag} & supplied:
|
||||
setattr(args, name, value)
|
||||
|
||||
# --- prefix layout ---------------------------------------------------
|
||||
@@ -368,6 +371,7 @@ class Setup:
|
||||
return {"node": node, "script": str(target / "serve.mjs"),
|
||||
"auth_file": str(auth), "host": args.web_host, "port": args.web_port,
|
||||
"server_token_file": str(server_token),
|
||||
"lan": args.web_lan, "lan_plain_login": args.web_lan_plain_login,
|
||||
"root": self.install_app_web(prefix, args, web_build), "updates": str(updates)}
|
||||
|
||||
def ensure_server_token(self, path):
|
||||
@@ -416,7 +420,8 @@ class Setup:
|
||||
raise ValueError("Docker is not running, so the web app cannot be built. The server is never "
|
||||
"installed without it; start Docker and rerun ./install.")
|
||||
try:
|
||||
built = app_build.build("web", runner=self.runner)
|
||||
built = app_build.build("web", runner=self.runner,
|
||||
arguments=app_build.update_signing.dart_defines(self.environ))
|
||||
except RuntimeError as error:
|
||||
raise ValueError(f"The web app build failed ({error}); nothing was installed") from None
|
||||
if not (Path(built) / "index.html").is_file():
|
||||
@@ -822,9 +827,11 @@ class Setup:
|
||||
raise ValueError("Web port must be between 1024 and 65535 and differ from server/ntfy ports")
|
||||
try:
|
||||
ipaddress.IPv4Address(args.bind_address)
|
||||
ipaddress.IPv4Address(args.web_host)
|
||||
except ValueError:
|
||||
raise ValueError("Invalid API/web bind address; use an IPv4 address such as 0.0.0.0 or 127.0.0.1") from None
|
||||
raise ValueError("Invalid API bind address; use an IPv4 address such as 127.0.0.1") from None
|
||||
listen, web_warnings = web_access.resolve(args.web_host, args.web_lan, args.web_lan_plain_login,
|
||||
{argument.split("=", 1)[0] for argument in args.argv})
|
||||
args.web_host, args.web_lan, args.web_lan_plain_login = listen["host"], listen["lan"], listen["lan_plain_login"]
|
||||
allow_authoring = self.authoring_role(prefix, args.allow_authoring)
|
||||
web_public_url = self.environ.get("PIPELINES_WEB_PUBLIC_URL", "")
|
||||
previous = prefix / MARKER
|
||||
@@ -886,7 +893,8 @@ 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}"
|
||||
web_url = f"http://{web_access.default_url_host(web, lan_ip, web_access.tailnet_ipv4(self.runner))}:{args.web_port}"
|
||||
opencode_env["PIPELINES_WEB_PUBLIC_URL"] = web_public_url or web_url
|
||||
path_value = str(prefix / "bin") + os.pathsep + self.environ.get("PATH", "")
|
||||
manifest = {
|
||||
"format": 1,
|
||||
@@ -943,8 +951,13 @@ class Setup:
|
||||
self.serve_on_tailnet(opencode_env["PIPELINES_WEB_PUBLIC_URL"], args.web_port)
|
||||
print(f"ntfy is configured for {base_url}; server, web proxy and ntfy have login autostart ({service_path}).")
|
||||
print("Phone notifications: subscribe to the 'pipelines' topic as phone-reader with the web password.")
|
||||
print(f"Web: http://{lan_ip if args.web_host == '0.0.0.0' else args.web_host}:{args.web_port}/ "
|
||||
f"(sign-in password in {web['auth_file']}; existing credentials retained).")
|
||||
print(f"Web: {web_url}/ (sign-in password in {web['auth_file']}; existing credentials retained).")
|
||||
print("Web proxy access: " + ("loopback + tailnet" + (" + LAN" if args.web_lan else "")
|
||||
if args.web_host == web_access.TAILNET else f"bound to {args.web_host}"))
|
||||
for note in (*web_warnings, web_access.public_url_warning(opencode_env["PIPELINES_WEB_PUBLIC_URL"], web),
|
||||
web_access.firewall_note(self.runner)):
|
||||
if note:
|
||||
print(note)
|
||||
print("Login autostart is already enabled. To enable/start it again, run:\n "
|
||||
+ shlex.join([str(prefix / "bin/pipelines"), "service", "enable"]))
|
||||
print("Android app (optional, slower): ./install --apk builds it in Docker and offers it at "
|
||||
@@ -968,7 +981,15 @@ def arguments(argv=None):
|
||||
parser.add_argument("--timezone", help="Override the detected timezone (fallback: UTC)")
|
||||
parser.add_argument("--port", type=int, default=DEFAULT_SERVER_PORT, help="Pipelines server port")
|
||||
parser.add_argument("--web-port", type=int, default=8082, help="Authenticated web proxy port (default 8082)")
|
||||
parser.add_argument("--web-host", default="0.0.0.0", help="Web proxy bind address (default 0.0.0.0)")
|
||||
parser.add_argument("--web-host", help="Web proxy access: 'tailnet' (default for new installs: loopback and "
|
||||
"this machine's Tailscale addresses only) or an IPv4 bind address such as 0.0.0.0 "
|
||||
"(plain HTTP on every interface); reinstalls keep the saved value")
|
||||
parser.add_argument("--web-lan", action=argparse.BooleanOptionalAction, default=None,
|
||||
help="Also accept plain-HTTP connections from the LAN (with --web-host tailnet); "
|
||||
"sign-in over them still needs --web-lan-plain-login")
|
||||
parser.add_argument("--web-lan-plain-login", action=argparse.BooleanOptionalAction, default=None,
|
||||
help="Allow the password and signed-in pages over plain-HTTP LAN connections "
|
||||
"(unencrypted; only on a trusted network)")
|
||||
parser.add_argument("--bind-address", default=DEFAULT_BIND_ADDRESS,
|
||||
help="Unauthenticated server bind address (default 127.0.0.1; expose only the web proxy)")
|
||||
parser.add_argument("--ntfy-port", type=int, default=DEFAULT_NTFY_PORT, help="ntfy listen port")
|
||||
|
||||
Reference in New Issue
Block a user