superbrain-server 1.0.20 → 1.0.22
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.
- package/package.json +1 -1
- package/payload/start.py +24 -13
package/package.json
CHANGED
package/payload/start.py
CHANGED
|
@@ -399,7 +399,7 @@ def setup_api_keys():
|
|
|
399
399
|
f"INSTAGRAM_USERNAME={ig_user}\n",
|
|
400
400
|
f"INSTAGRAM_PASSWORD={ig_pass}\n",
|
|
401
401
|
]
|
|
402
|
-
API_KEYS.write_text("".join(lines))
|
|
402
|
+
API_KEYS.write_text(encoding='utf-8', errors='replace', data="".join(lines))
|
|
403
403
|
ok(f"Keys saved to {API_KEYS}")
|
|
404
404
|
|
|
405
405
|
# ══════════════════════════════════════════════════════════════════════════════
|
|
@@ -647,7 +647,7 @@ def setup_whisper():
|
|
|
647
647
|
# ── Save model choice to config ─────────────────────────────────────────
|
|
648
648
|
whisper_cfg = BASE_DIR / "config" / "whisper_model.txt"
|
|
649
649
|
(BASE_DIR / "config").mkdir(exist_ok=True)
|
|
650
|
-
whisper_cfg.write_text(model)
|
|
650
|
+
whisper_cfg.write_text(encoding='utf-8', errors='replace', data=model)
|
|
651
651
|
ok(f"Whisper model set to '{model}' (saved to config/whisper_model.txt)")
|
|
652
652
|
|
|
653
653
|
h2(f"Pre-downloading Whisper '{model}' model …")
|
|
@@ -689,16 +689,16 @@ def setup_remote_access():
|
|
|
689
689
|
|
|
690
690
|
ok("ngrok auto-start enabled")
|
|
691
691
|
NGROK_ENABLED.parent.mkdir(parents=True, exist_ok=True)
|
|
692
|
-
NGROK_ENABLED.write_text("enabled")
|
|
692
|
+
NGROK_ENABLED.write_text(encoding='utf-8', errors='replace', data="enabled")
|
|
693
693
|
|
|
694
|
-
existing_token = NGROK_TOKEN.read_text().strip() if NGROK_TOKEN.exists() else ""
|
|
694
|
+
existing_token = NGROK_TOKEN.read_text(encoding='utf-8', errors='ignore').strip() if NGROK_TOKEN.exists() else ""
|
|
695
695
|
print(f"\n {YELLOW}Please paste your ngrok Authtoken.{RESET}")
|
|
696
696
|
if existing_token:
|
|
697
697
|
print(f" {DIM}(Leave blank to keep existing token){RESET}")
|
|
698
698
|
|
|
699
699
|
auth_token = ask("Authtoken", default=existing_token, paste=True)
|
|
700
700
|
if auth_token.strip():
|
|
701
|
-
NGROK_TOKEN.write_text(auth_token.strip())
|
|
701
|
+
NGROK_TOKEN.write_text(encoding='utf-8', errors='replace', data=auth_token.strip())
|
|
702
702
|
ok("ngrok token saved.")
|
|
703
703
|
else:
|
|
704
704
|
warn("No ngrok token provided. ngrok may disconnect. To fix, re-run setup.")
|
|
@@ -711,7 +711,7 @@ def setup_token_and_db():
|
|
|
711
711
|
|
|
712
712
|
# Token
|
|
713
713
|
if TOKEN_FILE.exists():
|
|
714
|
-
token = TOKEN_FILE.read_text().strip()
|
|
714
|
+
token = TOKEN_FILE.read_text(encoding='utf-8', errors='ignore').strip()
|
|
715
715
|
if token and len(token) == 8 and token.isalnum():
|
|
716
716
|
ok(f"Access Token already exists: {BOLD}{token}{RESET}")
|
|
717
717
|
if not ask_yn("Generate a new Access Token?", default=False):
|
|
@@ -723,7 +723,7 @@ def setup_token_and_db():
|
|
|
723
723
|
|
|
724
724
|
alphabet = string.ascii_uppercase + string.digits
|
|
725
725
|
new_token = ''.join(secrets.choice(alphabet) for _ in range(8))
|
|
726
|
-
TOKEN_FILE.write_text(new_token)
|
|
726
|
+
TOKEN_FILE.write_text(encoding='utf-8', errors='replace', data=new_token)
|
|
727
727
|
ok(f"Access Token saved: {BOLD}{GREEN}{new_token}{RESET}")
|
|
728
728
|
nl()
|
|
729
729
|
print(f" {YELLOW}Copy this token into the mobile app → Settings → Access Token.{RESET}")
|
|
@@ -738,10 +738,21 @@ def setup_token_and_db():
|
|
|
738
738
|
# ══════════════════════════════════════════════════════════════════════════════
|
|
739
739
|
def _start_ngrok(port: int) -> str | None:
|
|
740
740
|
try:
|
|
741
|
+
# Dynamically inject the venv site-packages to import pyngrok since start.py is run by global python
|
|
742
|
+
import sys
|
|
743
|
+
if IS_WINDOWS:
|
|
744
|
+
sp = VENV_DIR / "Lib" / "site-packages"
|
|
745
|
+
else:
|
|
746
|
+
sp_list = list(VENV_DIR.glob("lib/python*/site-packages"))
|
|
747
|
+
sp = sp_list[0] if sp_list else VENV_DIR / "lib" / "python3" / "site-packages"
|
|
748
|
+
|
|
749
|
+
if str(sp) not in sys.path:
|
|
750
|
+
sys.path.insert(0, str(sp))
|
|
751
|
+
|
|
741
752
|
import pyngrok
|
|
742
753
|
from pyngrok import ngrok
|
|
743
754
|
|
|
744
|
-
token = NGROK_TOKEN.read_text().strip() if NGROK_TOKEN.exists() else None
|
|
755
|
+
token = NGROK_TOKEN.read_text(encoding='utf-8', errors='ignore').strip() if NGROK_TOKEN.exists() else None
|
|
745
756
|
if token:
|
|
746
757
|
ngrok.set_auth_token(token)
|
|
747
758
|
|
|
@@ -791,7 +802,7 @@ def _start_localtunnel(port: int, timeout: int = 25) -> str | None:
|
|
|
791
802
|
info("Starting localtunnel in background...")
|
|
792
803
|
try:
|
|
793
804
|
LOCALTUNNEL_LOG.parent.mkdir(parents=True, exist_ok=True)
|
|
794
|
-
LOCALTUNNEL_LOG.write_text("")
|
|
805
|
+
LOCALTUNNEL_LOG.write_text(encoding='utf-8', errors='replace', data="")
|
|
795
806
|
log_handle = open(LOCALTUNNEL_LOG, "a", encoding="utf-8", buffering=1)
|
|
796
807
|
kwargs = {
|
|
797
808
|
"start_new_session": True,
|
|
@@ -856,7 +867,7 @@ def _start_localtunnel(port: int, timeout: int = 25) -> str | None:
|
|
|
856
867
|
info("Starting localtunnel in background...")
|
|
857
868
|
try:
|
|
858
869
|
LOCALTUNNEL_LOG.parent.mkdir(parents=True, exist_ok=True)
|
|
859
|
-
LOCALTUNNEL_LOG.write_text("")
|
|
870
|
+
LOCALTUNNEL_LOG.write_text(encoding='utf-8', errors='replace', data="")
|
|
860
871
|
log_handle = open(LOCALTUNNEL_LOG, "a", encoding="utf-8", buffering=1)
|
|
861
872
|
kwargs = {
|
|
862
873
|
"start_new_session": True,
|
|
@@ -1245,7 +1256,7 @@ def launch_backend():
|
|
|
1245
1256
|
info(f"Try manually: kill -9 {pid}")
|
|
1246
1257
|
sys.exit(1)
|
|
1247
1258
|
|
|
1248
|
-
token = TOKEN_FILE.read_text().strip() if TOKEN_FILE.exists() else "—"
|
|
1259
|
+
token = TOKEN_FILE.read_text(encoding='utf-8', errors='ignore').strip() if TOKEN_FILE.exists() else "—"
|
|
1249
1260
|
local_ip = _detect_local_ip()
|
|
1250
1261
|
|
|
1251
1262
|
# tunnel startup
|
|
@@ -1253,7 +1264,7 @@ def launch_backend():
|
|
|
1253
1264
|
tunnel_type: str = ""
|
|
1254
1265
|
|
|
1255
1266
|
if NGROK_ENABLED.exists():
|
|
1256
|
-
token_txt = NGROK_TOKEN.read_text().strip() if NGROK_TOKEN.exists() else ""
|
|
1267
|
+
token_txt = NGROK_TOKEN.read_text(encoding='utf-8', errors='ignore').strip() if NGROK_TOKEN.exists() else ""
|
|
1257
1268
|
if not token_txt:
|
|
1258
1269
|
warn("Ngrok is enabled but no Authtoken was found.")
|
|
1259
1270
|
setup_remote_access()
|
|
@@ -1428,7 +1439,7 @@ def main():
|
|
|
1428
1439
|
sys.exit(1)
|
|
1429
1440
|
|
|
1430
1441
|
# Mark setup done
|
|
1431
|
-
SETUP_DONE.write_text("ok")
|
|
1442
|
+
SETUP_DONE.write_text(encoding='utf-8', errors='replace', data="ok")
|
|
1432
1443
|
|
|
1433
1444
|
nl()
|
|
1434
1445
|
print(f" {GREEN}{BOLD}{'═'*60}{RESET}")
|