@danhachuel/thunderbolt 0.4.99 → 0.5.1

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.
@@ -120,11 +120,7 @@ def _safe_metadata(value: Any, *, key: str = "") -> Any:
120
120
 
121
121
 
122
122
  def _history() -> list[dict[str, Any]]:
123
- try:
124
- saved = storage.read_json(NOTIFICATIONS_FILE, [])
125
- except PermissionError:
126
- # Um lock ou ficheiro sem permissões não deve interromper a interface.
127
- return []
123
+ saved = storage.read_json(NOTIFICATIONS_FILE, [])
128
124
  if not isinstance(saved, list):
129
125
  return []
130
126
  return [item for item in saved if isinstance(item, dict)]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@danhachuel/thunderbolt",
3
- "version": "0.4.99",
3
+ "version": "0.5.01",
4
4
  "description": "Thunderbolt — interface local para operação de canais faceless e motor MoneyPrinterTurbo",
5
5
  "license": "MIT",
6
6
  "main": "scripts/cli.mjs",
@@ -16,6 +16,7 @@
16
16
  "integrations/*.py",
17
17
  "integrations/data/*.json",
18
18
  "scripts/*.mjs",
19
+ "scripts/*.py",
19
20
  "seed/prompt_masters/**/*.md",
20
21
  "seed/blueprints/**/*.json",
21
22
  "seed/blueprints/**/*.md",
package/scripts/cli.mjs CHANGED
@@ -25,6 +25,7 @@ const venvDir = process.env.THUNDERBOLT_VENV || process.env.HERMES_VENV || join(
25
25
  const venvPython = platform() === "win32" ? join(venvDir, "Scripts", "python.exe") : join(venvDir, "bin", "python");
26
26
  const python = process.env.THUNDERBOLT_PYTHON || process.env.HERMES_PYTHON || (existsSync(venvPython) ? venvPython : (platform() === "win32" ? "python" : "python3"));
27
27
  const main = resolve(root, "app", "main.py");
28
+ const streamlitBootstrap = resolve(root, "scripts", "streamlit_bootstrap.py");
28
29
  const settingsPath = join(thunderboltHome, "storage", "state", "settings.json");
29
30
  const pythonEnvironment = { ...process.env, PYTHONIOENCODING: "utf-8", PYTHONUTF8: "1", PYTHONLEGACYWINDOWSSTDIO: "1", CLICK_NO_WIN_CONSOLE: "1" };
30
31
 
@@ -265,7 +266,7 @@ let shuttingDown = false;
265
266
  let child;
266
267
 
267
268
  function startStreamlit() {
268
- child = spawn(python, ["-m", "streamlit", "run", main, "--server.port", String(backendPort), "--server.address", "127.0.0.1"], {
269
+ child = spawn(python, [streamlitBootstrap, "run", main, "--server.port", String(backendPort), "--server.address", "127.0.0.1"], {
269
270
  cwd: root,
270
271
  stdio: "inherit",
271
272
  env: { ...runtimeEnv, PYTHONIOENCODING: "utf-8", PYTHONUTF8: "1", PYTHONLEGACYWINDOWSSTDIO: "1", CLICK_NO_WIN_CONSOLE: "1", THUNDERBOLT_LAUNCHER_RESTART: "1" },
@@ -0,0 +1,34 @@
1
+ from __future__ import annotations
2
+
3
+ import io
4
+ import os
5
+ import sys
6
+
7
+ # Este ficheiro é o primeiro módulo Python executado pelo launcher. As
8
+ # variáveis e os streams precisam de ser corrigidos antes de qualquer import
9
+ # de streamlit/click, pois o erro utf-16-le acontece durante essa inicialização.
10
+ os.environ["PYTHONIOENCODING"] = "utf-8"
11
+ os.environ["PYTHONUTF8"] = "1"
12
+ os.environ["PYTHONLEGACYWINDOWSSTDIO"] = "1"
13
+ os.environ["CLICK_NO_WIN_CONSOLE"] = "1"
14
+
15
+
16
+ def _utf8_stream(stream: object) -> object:
17
+ if os.name != "nt":
18
+ return stream
19
+ buffer = getattr(stream, "buffer", None)
20
+ if buffer is None:
21
+ return stream
22
+ try:
23
+ return io.TextIOWrapper(buffer, encoding="utf-8", errors="replace", line_buffering=True)
24
+ except (AttributeError, OSError, ValueError):
25
+ return stream
26
+
27
+
28
+ sys.stdout = _utf8_stream(sys.stdout)
29
+ sys.stderr = _utf8_stream(sys.stderr)
30
+
31
+ from streamlit.web.cli import main # noqa: E402
32
+
33
+ if __name__ == "__main__":
34
+ main()