runtime-sdk 0.4.7__tar.gz → 0.4.9__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.
- {runtime_sdk-0.4.7 → runtime_sdk-0.4.9}/PKG-INFO +1 -1
- {runtime_sdk-0.4.7 → runtime_sdk-0.4.9}/pyproject.toml +1 -1
- {runtime_sdk-0.4.7 → runtime_sdk-0.4.9}/scripts/runtime_sdk/cli.py +32 -11
- {runtime_sdk-0.4.7 → runtime_sdk-0.4.9}/scripts/runtime_sdk.egg-info/PKG-INFO +1 -1
- {runtime_sdk-0.4.7 → runtime_sdk-0.4.9}/README.md +0 -0
- {runtime_sdk-0.4.7 → runtime_sdk-0.4.9}/scripts/runtime_sdk/__init__.py +0 -0
- {runtime_sdk-0.4.7 → runtime_sdk-0.4.9}/scripts/runtime_sdk/client.py +0 -0
- {runtime_sdk-0.4.7 → runtime_sdk-0.4.9}/scripts/runtime_sdk/config.py +0 -0
- {runtime_sdk-0.4.7 → runtime_sdk-0.4.9}/scripts/runtime_sdk.egg-info/SOURCES.txt +0 -0
- {runtime_sdk-0.4.7 → runtime_sdk-0.4.9}/scripts/runtime_sdk.egg-info/dependency_links.txt +0 -0
- {runtime_sdk-0.4.7 → runtime_sdk-0.4.9}/scripts/runtime_sdk.egg-info/entry_points.txt +0 -0
- {runtime_sdk-0.4.7 → runtime_sdk-0.4.9}/scripts/runtime_sdk.egg-info/requires.txt +0 -0
- {runtime_sdk-0.4.7 → runtime_sdk-0.4.9}/scripts/runtime_sdk.egg-info/top_level.txt +0 -0
- {runtime_sdk-0.4.7 → runtime_sdk-0.4.9}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: runtime-sdk
|
|
3
|
-
Version: 0.4.
|
|
3
|
+
Version: 0.4.9
|
|
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
|
|
@@ -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__
|
|
@@ -939,7 +939,7 @@ def handle_create(
|
|
|
939
939
|
computer_id = result.get("id") or result.get("slug")
|
|
940
940
|
if not computer_id:
|
|
941
941
|
return code
|
|
942
|
-
return _enter_computer(config, str(computer_id)
|
|
942
|
+
return _enter_computer(config, str(computer_id))
|
|
943
943
|
|
|
944
944
|
|
|
945
945
|
def handle_list(config: RuntimeConfig) -> int:
|
|
@@ -1159,7 +1159,7 @@ def handle_publish(config: RuntimeConfig, computer_id: str | None, port: int | N
|
|
|
1159
1159
|
)
|
|
1160
1160
|
|
|
1161
1161
|
|
|
1162
|
-
def _enter_computer(config: RuntimeConfig, computer_id: str
|
|
1162
|
+
def _enter_computer(config: RuntimeConfig, computer_id: str) -> int:
|
|
1163
1163
|
client = RuntimeClient(base_url=config.base_url, api_key=config.api_key)
|
|
1164
1164
|
ticket_payload = _with_spinner(
|
|
1165
1165
|
f"preparing console for {computer_id}…",
|
|
@@ -1169,16 +1169,13 @@ def _enter_computer(config: RuntimeConfig, computer_id: str, *, announce_created
|
|
|
1169
1169
|
if not ws_url:
|
|
1170
1170
|
return report_error("terminal endpoint did not return a websocket url")
|
|
1171
1171
|
|
|
1172
|
-
|
|
1173
|
-
_UI.console().print("[cyan]●[/cyan] Connecting to console...")
|
|
1174
|
-
else:
|
|
1175
|
-
_UI.console().print("[cyan]●[/cyan] Connecting to console...")
|
|
1172
|
+
_UI.console().print("[cyan]●[/cyan] Connecting to console...")
|
|
1176
1173
|
|
|
1177
1174
|
try:
|
|
1178
1175
|
return _run_terminal_session(ws_url)
|
|
1179
1176
|
except RuntimeAPIError as exc:
|
|
1180
1177
|
return report_error(str(exc), status_code=exc.status_code)
|
|
1181
|
-
except OSError as exc:
|
|
1178
|
+
except (InvalidHandshake, TimeoutError, OSError) as exc:
|
|
1182
1179
|
return report_error(f"terminal failed: {exc}")
|
|
1183
1180
|
|
|
1184
1181
|
|
|
@@ -1241,6 +1238,9 @@ def _run_terminal_session(ws_url: str) -> int:
|
|
|
1241
1238
|
stop.set()
|
|
1242
1239
|
return
|
|
1243
1240
|
except ConnectionClosed:
|
|
1241
|
+
if not stop.is_set() and not result.get("error") and int(result.get("code") or 0) == 0:
|
|
1242
|
+
result["code"] = 1
|
|
1243
|
+
result["error"] = "terminal connection closed unexpectedly"
|
|
1244
1244
|
stop.set()
|
|
1245
1245
|
except Exception as exc: # pragma: no cover - defensive for real TTY sessions
|
|
1246
1246
|
result["code"] = 1
|
|
@@ -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
|
-
|
|
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.
|
|
3
|
+
Version: 0.4.9
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|