runtime-sdk 0.4.7__tar.gz → 0.4.8__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: runtime-sdk
3
- Version: 0.4.7
3
+ Version: 0.4.8
4
4
  Summary: Runtime Python SDK and CLI
5
5
  Project-URL: Repository, https://github.com/The-Money-Company-Limited/runtimevm
6
6
  Project-URL: Issues, https://github.com/The-Money-Company-Limited/runtimevm/issues
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "runtime-sdk"
3
- version = "0.4.7"
3
+ version = "0.4.8"
4
4
  description = "Runtime Python SDK and CLI"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.11"
@@ -14,7 +14,7 @@ from datetime import datetime, timezone
14
14
  from typing import Any, Callable
15
15
  from urllib.parse import urljoin, urlparse
16
16
 
17
- from websockets.exceptions import ConnectionClosed
17
+ from websockets.exceptions import ConnectionClosed, InvalidHandshake
18
18
  from websockets.sync.client import connect as websocket_connect
19
19
 
20
20
  from runtime_sdk import __version__
@@ -1178,7 +1178,7 @@ def _enter_computer(config: RuntimeConfig, computer_id: str, *, announce_created
1178
1178
  return _run_terminal_session(ws_url)
1179
1179
  except RuntimeAPIError as exc:
1180
1180
  return report_error(str(exc), status_code=exc.status_code)
1181
- except OSError as exc:
1181
+ except (InvalidHandshake, TimeoutError, OSError) as exc:
1182
1182
  return report_error(f"terminal failed: {exc}")
1183
1183
 
1184
1184
 
@@ -1299,17 +1299,38 @@ def _filter_terminal_output(chunk: str, state: dict[str, Any]) -> str:
1299
1299
  state["buffer"] = ""
1300
1300
  return _strip_terminal_noise(buffer[idx:])
1301
1301
 
1302
+ cleaned = _strip_terminal_noise(buffer)
1303
+ if cleaned and _should_release_terminal_output(cleaned):
1304
+ state["suppressing_preamble"] = False
1305
+ state["buffer"] = ""
1306
+ return cleaned
1307
+
1302
1308
  if len(buffer) > 8192:
1303
- buffer = buffer[-4096:]
1309
+ state["suppressing_preamble"] = False
1310
+ state["buffer"] = ""
1311
+ return _strip_terminal_noise(buffer)
1312
+
1304
1313
  state["buffer"] = buffer
1305
1314
  return ""
1306
1315
 
1307
1316
 
1317
+
1318
+ def _should_release_terminal_output(text: str) -> bool:
1319
+ if not text:
1320
+ return False
1321
+ if "\n" in text or "\r" in text:
1322
+ return True
1323
+ if len(text) >= 256:
1324
+ return True
1325
+
1326
+ stripped = text.rstrip()
1327
+ return text.endswith(("$ ", "# ", "% ", "> ")) or stripped.endswith(("$", "#", "%", ">"))
1328
+
1329
+
1330
+
1308
1331
  def _flush_terminal_output(state: dict[str, Any]) -> str:
1309
1332
  buffer = str(state.get("buffer") or "")
1310
1333
  state["buffer"] = ""
1311
- if state.get("suppressing_preamble", False):
1312
- return ""
1313
1334
  return _strip_terminal_noise(buffer)
1314
1335
 
1315
1336
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: runtime-sdk
3
- Version: 0.4.7
3
+ Version: 0.4.8
4
4
  Summary: Runtime Python SDK and CLI
5
5
  Project-URL: Repository, https://github.com/The-Money-Company-Limited/runtimevm
6
6
  Project-URL: Issues, https://github.com/The-Money-Company-Limited/runtimevm/issues
File without changes
File without changes