runtime-sdk 0.4.3__tar.gz → 0.4.5__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.3
3
+ Version: 0.4.5
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.3"
3
+ version = "0.4.5"
4
4
  description = "Runtime Python SDK and CLI"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.11"
@@ -1064,6 +1064,7 @@ def _run_terminal_session(ws_url: str) -> int:
1064
1064
  old_settings = termios.tcgetattr(fd)
1065
1065
  stop = threading.Event()
1066
1066
  result: dict[str, Any] = {"code": 0, "error": None}
1067
+ output_state: dict[str, Any] = {"buffer": "", "suppressing_preamble": True}
1067
1068
 
1068
1069
  with websocket_connect(ws_url, open_timeout=DEFAULT_WARMUP_TIMEOUT, close_timeout=1) as ws:
1069
1070
  _send_terminal_resize(ws)
@@ -1081,7 +1082,7 @@ def _run_terminal_session(ws_url: str) -> int:
1081
1082
  if event_type == "ready":
1082
1083
  continue
1083
1084
  if event_type == "output":
1084
- data = str(event.get("data") or "")
1085
+ data = _filter_terminal_output(str(event.get("data") or ""), output_state)
1085
1086
  if data:
1086
1087
  sys.stdout.write(data)
1087
1088
  sys.stdout.flush()
@@ -1134,11 +1135,65 @@ def _run_terminal_session(ws_url: str) -> int:
1134
1135
 
1135
1136
  sys.stdout.write("\n")
1136
1137
  sys.stdout.flush()
1138
+ tail = _flush_terminal_output(output_state)
1139
+ if tail:
1140
+ sys.stdout.write(tail)
1141
+ sys.stdout.flush()
1137
1142
  if result.get("error"):
1138
1143
  _UI.err().print(f"[bold red]✗[/bold red] {result['error']}")
1139
1144
  return int(result.get("code") or 0)
1140
1145
 
1141
1146
 
1147
+ def _filter_terminal_output(chunk: str, state: dict[str, Any]) -> str:
1148
+ if not chunk:
1149
+ return ""
1150
+ if not state.get("suppressing_preamble", False):
1151
+ return _strip_terminal_noise(chunk)
1152
+
1153
+ buffer = str(state.get("buffer") or "") + chunk
1154
+ marker = "\x1b[1;34mruntime@"
1155
+ idx = buffer.find(marker)
1156
+ if idx != -1:
1157
+ state["suppressing_preamble"] = False
1158
+ state["buffer"] = ""
1159
+ return _strip_terminal_noise(buffer[idx:])
1160
+
1161
+ if len(buffer) > 8192:
1162
+ buffer = buffer[-4096:]
1163
+ state["buffer"] = buffer
1164
+ return ""
1165
+
1166
+
1167
+ def _flush_terminal_output(state: dict[str, Any]) -> str:
1168
+ buffer = str(state.get("buffer") or "")
1169
+ state["buffer"] = ""
1170
+ if state.get("suppressing_preamble", False):
1171
+ return ""
1172
+ return _strip_terminal_noise(buffer)
1173
+
1174
+
1175
+ def _strip_terminal_noise(text: str) -> str:
1176
+ if not text:
1177
+ return ""
1178
+
1179
+ lines = text.splitlines(keepends=True)
1180
+ filtered: list[str] = []
1181
+ for line in lines:
1182
+ stripped = line.rstrip("\r\n")
1183
+ if stripped == "Running bootstrap command: export PS1='\\[\\033[1;34m\\]runtime@\\h\\[\\033[0m\\]:\\w\\$ '":
1184
+ continue
1185
+ if stripped == "Connected! Press Ctrl+] to exit.":
1186
+ continue
1187
+ if stripped == "* Image built by SlicerVM (2026)":
1188
+ continue
1189
+ if stripped == "* Website: https://slicervm.com":
1190
+ continue
1191
+ if stripped == "* Docs: https://docs.slicervm.com":
1192
+ continue
1193
+ filtered.append(line)
1194
+ return "".join(filtered)
1195
+
1196
+
1142
1197
  def _send_terminal_resize(ws: Any) -> None:
1143
1198
  size = shutil.get_terminal_size((100, 24))
1144
1199
  ws.send(json.dumps({"type": "resize", "cols": size.columns, "rows": size.lines}))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: runtime-sdk
3
- Version: 0.4.3
3
+ Version: 0.4.5
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