superbrain-server 1.0.2-beta.3 → 1.0.4

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/bin/superbrain.js CHANGED
@@ -170,8 +170,12 @@ if (userArgs.length > 0) {
170
170
  superbrain-server -> Starts the backend engine
171
171
  superbrain-server reset -> Open Reset Menu
172
172
  superbrain-server reset --all -> Force complete wipe
173
+ superbrain-server status -> Show QR Code and Server Info
173
174
  `);
174
175
  process.exit(0);
176
+ } else if (cmd === 'status' || cmd === 'update') {
177
+ targetScript = 'start.py';
178
+ finalArgs = ['--status'];
175
179
  }
176
180
  }
177
181
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "superbrain-server",
3
- "version": "1.0.2-beta.3",
3
+ "version": "1.0.4",
4
4
  "description": "1-Line Auto-Installer and Server Execution wrapper for SuperBrain",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -22,4 +22,4 @@
22
22
  "bin/",
23
23
  "payload/"
24
24
  ]
25
- }
25
+ }
package/payload/api.py CHANGED
@@ -1152,6 +1152,7 @@ async def get_retry_queue(token: str = Depends(verify_token)):
1152
1152
  async def flush_retry_queue(token: str = Depends(verify_token)):
1153
1153
  """Immediately promote all retry-ready items to the active queue"""
1154
1154
  try:
1155
+ db = get_db()
1155
1156
  ready = db.get_retry_ready()
1156
1157
  for item in ready:
1157
1158
  db.add_to_queue(item['shortcode'], item['url'])
@@ -1164,6 +1165,17 @@ async def flush_retry_queue(token: str = Depends(verify_token)):
1164
1165
  logger.error(f"Error flushing retry queue: {e}")
1165
1166
  raise HTTPException(status_code=500, detail=str(e))
1166
1167
 
1168
+ @app.delete("/queue/{shortcode}")
1169
+ async def delete_queue_item(shortcode: str, token: str = Depends(verify_token)):
1170
+ """Remove an item from the processing or retry queue"""
1171
+ try:
1172
+ db = get_db()
1173
+ db.remove_from_queue(shortcode)
1174
+ return {"success": True, "message": f"Removed {shortcode} from queue"}
1175
+ except Exception as e:
1176
+ logger.error(f"Error removing {shortcode} from queue: {e}")
1177
+ raise HTTPException(status_code=500, detail=str(e))
1178
+
1167
1179
 
1168
1180
  # ─────────────────────────────────────────────────────────────────
1169
1181
  # Reset endpoints (admin only)
package/payload/fix.py ADDED
@@ -0,0 +1,66 @@
1
+ import sys, shutil
2
+ path1 = 'D:/superbrain/backend/start.py'
3
+ path2 = 'D:/superbrain/superbrain-cli/payload/start.py'
4
+
5
+ status_code = '''
6
+ def launch_backend_status():
7
+ h1("SuperBrain Server Status")
8
+ PORT = 5000
9
+ token = TOKEN_FILE.read_text().strip() if TOKEN_FILE.exists() else "�"
10
+ local_ip = _detect_local_ip()
11
+
12
+ localtunnel_enabled = bool(shutil.which("npx") or shutil.which("npx.cmd"))
13
+ localtunnel_url: str | None = None
14
+ if localtunnel_enabled:
15
+ localtunnel_url = _find_localtunnel_url_from_log()
16
+
17
+ if localtunnel_url:
18
+ tunnel_line = f" Public URL ? {GREEN}{BOLD}{localtunnel_url}{RESET} {DIM}(localtunnel){RESET}"
19
+ tunnel_hint = f" � public ? {GREEN}{localtunnel_url}{RESET}"
20
+ elif localtunnel_enabled:
21
+ tunnel_line = f" Public URL ? {YELLOW}(running � URL in localtunnel.log){RESET}"
22
+ tunnel_hint = f" � public ? run: {DIM}npx localtunnel --port {PORT}{RESET}"
23
+ else:
24
+ tunnel_line = ""
25
+ tunnel_hint = f" � public ? install Node.js first, then run: {DIM}npx localtunnel --port {PORT}{RESET}"
26
+
27
+ qr_url = localtunnel_url if localtunnel_url else f"http://{local_ip}:{PORT}"
28
+ _display_connect_qr(qr_url, token)
29
+
30
+ print(f\"\"\"
31
+ {GREEN}{BOLD}Server Status{RESET}
32
+
33
+ Local URL ? {CYAN}http://127.0.0.1:{PORT}{RESET}
34
+ Network URL ? {CYAN}http://{local_ip}:{PORT}{RESET}
35
+ {(tunnel_line + chr(10)) if tunnel_line else ''} API docs ? {CYAN}http://127.0.0.1:{PORT}/docs{RESET}
36
+ Access Token ? {BOLD}{MAGENTA}{token}{RESET}
37
+
38
+ {YELLOW}Mobile app setup:{RESET}
39
+ {BOLD}Option A � Scan QR code:{RESET}
40
+ 1. Open the app ? Settings ? tap the {BOLD}QR icon{RESET} ??
41
+ 2. Scan the QR code shown above
42
+
43
+ {BOLD}Option B � Manual setup:{RESET}
44
+ 1. Go to app ? ? settings
45
+ 2. Set {BOLD}Server URL{RESET} to:
46
+ {tunnel_hint}
47
+ � Same WiFi ? http://{local_ip}:{PORT}
48
+ 3. Set {BOLD}Access Token{RESET} to: {BOLD}{MAGENTA}{token}{RESET}
49
+ \"\"\")
50
+ sys.exit(0)
51
+
52
+ '''
53
+
54
+ for path in [path1, path2]:
55
+ with open(path, 'r', encoding='utf-8') as f:
56
+ content = f.read()
57
+
58
+ if 'def launch_backend_status()' not in content:
59
+ content = content.replace('def main():', status_code + 'def main():')
60
+
61
+ if 'status_mode = "--status" in sys.argv' not in content:
62
+ content = content.replace(' reset_mode = "--reset" in sys.argv', ' status_mode = "--status" in sys.argv\\n if status_mode:\\n launch_backend_status()\\n return\\n\\n reset_mode = "--reset" in sys.argv')
63
+
64
+ with open(path, 'w', encoding='utf-8') as f:
65
+ f.write(content)
66
+ print("Done fixing start.py!")
@@ -0,0 +1,63 @@
1
+ import sys, shutil
2
+ path1 = 'D:/superbrain/backend/start.py'
3
+ path2 = 'D:/superbrain/superbrain-cli/payload/start.py'
4
+
5
+ status_code = '''
6
+ def launch_backend_status():
7
+ h1("SuperBrain Server Status")
8
+ PORT = 5000
9
+ token = TOKEN_FILE.read_text().strip() if TOKEN_FILE.exists() else "�"
10
+ local_ip = _detect_local_ip()
11
+
12
+ localtunnel_enabled = bool(shutil.which("npx") or shutil.which("npx.cmd"))
13
+ localtunnel_url: str | None = None
14
+ if localtunnel_enabled:
15
+ localtunnel_url = _find_localtunnel_url_from_log()
16
+
17
+ if localtunnel_url:
18
+ tunnel_line = f" Public URL ? {GREEN}{BOLD}{localtunnel_url}{RESET} {DIM}(localtunnel){RESET}"
19
+ tunnel_hint = f" � public ? {GREEN}{localtunnel_url}{RESET}"
20
+ elif localtunnel_enabled:
21
+ tunnel_line = f" Public URL ? {YELLOW}(running � URL in localtunnel.log){RESET}"
22
+ tunnel_hint = f" � public ? run: {DIM}npx localtunnel --port {PORT}{RESET}"
23
+ else:
24
+ tunnel_line = ""
25
+ tunnel_hint = f" � public ? install Node.js first, then run: {DIM}npx localtunnel --port {PORT}{RESET}"
26
+
27
+ qr_url = localtunnel_url if localtunnel_url else f"http://{local_ip}:{PORT}"
28
+ _display_connect_qr(qr_url, token)
29
+
30
+ print(f\"\"\"
31
+ {GREEN}{BOLD}Server Status{RESET}
32
+
33
+ Local URL ? {CYAN}http://127.0.0.1:{PORT}{RESET}
34
+ Network URL ? {CYAN}http://{local_ip}:{PORT}{RESET}
35
+ {(tunnel_line + chr(10)) if tunnel_line else ''} API docs ? {CYAN}http://127.0.0.1:{PORT}/docs{RESET}
36
+ Access Token ? {BOLD}{MAGENTA}{token}{RESET}
37
+
38
+ {YELLOW}Mobile app setup:{RESET}
39
+ {BOLD}Option A � Scan QR code:{RESET}
40
+ 1. Open the app ? Settings ? tap the {BOLD}QR icon{RESET} ??
41
+ 2. Scan the QR code shown above
42
+
43
+ {BOLD}Option B � Manual setup:{RESET}
44
+ 1. Go to app ? ? settings
45
+ 2. Set {BOLD}Server URL{RESET} to:
46
+ {tunnel_hint}
47
+ � Same WiFi ? http://{local_ip}:{PORT}
48
+ 3. Set {BOLD}Access Token{RESET} to: {BOLD}{MAGENTA}{token}{RESET}
49
+ \"\"\")
50
+ sys.exit(0)
51
+
52
+ '''
53
+
54
+ for path in [path1, path2]:
55
+ with open(path, 'r', encoding='utf-8') as f:
56
+ content = f.read()
57
+
58
+ if 'def launch_backend_status()' not in content:
59
+ content = content.replace('def main():', status_code + 'def main():')
60
+
61
+ with open(path, 'w', encoding='utf-8') as f:
62
+ f.write(content)
63
+ print("Done fixing start.py again!")
package/payload/start.py CHANGED
@@ -1266,10 +1266,50 @@ def launch_backend():
1266
1266
  # ══════════════════════════════════════════════════════════════════════════════
1267
1267
  # Main
1268
1268
  # ══════════════════════════════════════════════════════════════════════════════
1269
+
1270
+ def launch_backend_status():
1271
+ h1("SuperBrain Status")
1272
+
1273
+ token = "UNKNOWN"
1274
+ if TOKEN_FILE.exists():
1275
+ token = TOKEN_FILE.read_text(encoding="utf-8").strip()
1276
+
1277
+ url = "NOT_FOUND"
1278
+ log_file = BACKEND_DIR / "config" / "localtunnel.log"
1279
+ if log_file.exists():
1280
+ match = re.search(r"your url is: (https://[^\s]+)", log_file.read_text(encoding="utf-8"))
1281
+ if match:
1282
+ url = match.group(1)
1283
+
1284
+ if url == "NOT_FOUND":
1285
+ warn("Could not find a running localtunnel URL in config/localtunnel.log.")
1286
+ nl()
1287
+ print(" Wait 5 seconds, or run 'superbrain-server' to start the server.")
1288
+ return
1289
+
1290
+ _display_connect_qr(url, token)
1291
+
1292
+ local_url = "http://127.0.0.1:5000"
1293
+ local_ip = _detect_local_ip()
1294
+ network_url = f"http://{local_ip}:5000"
1295
+
1296
+ nl()
1297
+ print(f" Local URL ? {CYAN}{local_url}{RESET}")
1298
+ print(f" Network URL ? {CYAN}{network_url}{RESET}")
1299
+ print(f" Public URL ? {CYAN}{url}{RESET} (localtunnel)")
1300
+ print(f" API docs ? {CYAN}{local_url}/docs{RESET}")
1301
+ print(f" Access Token ? {BOLD}{MAGENTA}{token}{RESET}")
1302
+ nl()
1303
+
1269
1304
  def main():
1270
1305
  os.chdir(BASE_DIR)
1271
1306
  banner()
1272
1307
 
1308
+ status_mode = "--status" in sys.argv
1309
+ if status_mode:
1310
+ launch_backend_status()
1311
+ return
1312
+
1273
1313
  reset_mode = "--reset" in sys.argv
1274
1314
 
1275
1315
  if SETUP_DONE.exists() and not reset_mode: