@danhachuel/thunderbolt 0.2.95 → 0.2.97

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/app/main.py CHANGED
@@ -244,6 +244,14 @@ _OPTION_TRANSLATED_STREAMLIT_METHODS = {"selectbox", "radio", "multiselect", "se
244
244
  _STREAMLIT_I18N_INSTALLED = False
245
245
 
246
246
 
247
+ def _translated_option_label(value: Any, selected_language: str, formatter: Any = None) -> str:
248
+ """Return a valid Streamlit display label without changing the stored option value."""
249
+ formatted = formatter(value) if formatter is not None else value
250
+ if isinstance(formatted, str):
251
+ return ui_text(formatted, selected_language)
252
+ return str(formatted)
253
+
254
+
247
255
  def _translate_streamlit_arguments(method_name: str, args: tuple[Any, ...], kwargs: dict[str, Any]) -> tuple[tuple[Any, ...], dict[str, Any]]:
248
256
  if not args and "label" not in kwargs:
249
257
  return args, kwargs
@@ -256,12 +264,13 @@ def _translate_streamlit_arguments(method_name: str, args: tuple[Any, ...], kwar
256
264
  for keyword in ("placeholder", "help"):
257
265
  if isinstance(kwargs.get(keyword), str):
258
266
  kwargs[keyword] = ui_text(kwargs[keyword], selected_language)
259
- if method_name in _OPTION_TRANSLATED_STREAMLIT_METHODS and len(translated_args) >= 2:
267
+ has_options = len(translated_args) >= 2 or "options" in kwargs
268
+ if method_name in _OPTION_TRANSLATED_STREAMLIT_METHODS and has_options:
260
269
  existing_format_func = kwargs.get("format_func")
261
270
  if existing_format_func is None:
262
- kwargs["format_func"] = lambda value: ui_text(value, selected_language) if isinstance(value, str) else value
271
+ kwargs["format_func"] = lambda value, language=selected_language: _translated_option_label(value, language)
263
272
  else:
264
- kwargs["format_func"] = lambda value, formatter=existing_format_func: ui_text(formatter(value), selected_language) if isinstance(formatter(value), str) else formatter(value)
273
+ kwargs["format_func"] = lambda value, formatter=existing_format_func, language=selected_language: _translated_option_label(value, language, formatter)
265
274
  return tuple(translated_args), kwargs
266
275
 
267
276
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@danhachuel/thunderbolt",
3
- "version": "0.2.95",
3
+ "version": "0.2.97",
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",
package/scripts/cli.mjs CHANGED
@@ -153,7 +153,15 @@ if (args[0] === "pipeline-worker" || args.includes("--pipeline-worker")) {
153
153
 
154
154
  const port = process.env.THUNDERBOLT_PORT || process.env.HERMES_PORT || "3030";
155
155
  const publicPort = Number.parseInt(String(port), 10);
156
- const backendPort = Number.isFinite(publicPort) ? publicPort + 1 : 3031;
156
+ const backendPort = await new Promise((resolve, reject) => {
157
+ const reservation = net.createServer();
158
+ reservation.once("error", reject);
159
+ reservation.listen(0, "127.0.0.1", () => {
160
+ const address = reservation.address();
161
+ const selectedPort = address && typeof address === "object" ? address.port : 0;
162
+ reservation.close((error) => error ? reject(error) : resolve(selectedPort));
163
+ });
164
+ });
157
165
  const supportedLanguages = new Set(["en", "zh", "de", "vi", "tr", "pt", "ru", "es", "id", "it"]);
158
166
 
159
167
  const proxy = http.createServer((request, response) => {
@@ -196,7 +204,9 @@ proxy.on("upgrade", (request, clientSocket, head) => {
196
204
  upstreamSocket.on("error", () => clientSocket.destroy());
197
205
  });
198
206
 
199
- proxy.listen(publicPort, "127.0.0.1");
207
+ proxy.listen(publicPort, "127.0.0.1", () => {
208
+ console.log(`Thunderbolt: interface disponível em http://localhost:${publicPort}/`);
209
+ });
200
210
  const worker = spawn(python, ["-m", "hermes_ui.automation_worker"], {
201
211
  cwd: root,
202
212
  stdio: "inherit",
@@ -211,7 +221,7 @@ const pipelineWorker = spawn(python, ["-m", "hermes_ui.pipeline_worker"], {
211
221
  });
212
222
  const child = spawn(python, ["-m", "streamlit", "run", main, "--server.port", String(backendPort), "--server.address", "127.0.0.1"], {
213
223
  cwd: root,
214
- stdio: "inherit",
224
+ stdio: "ignore",
215
225
  env: runtimeEnv,
216
226
  windowsHide: false,
217
227
  });