runtime-sdk 0.4.22__tar.gz → 0.4.24__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.22
3
+ Version: 0.4.24
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.22"
3
+ version = "0.4.24"
4
4
  description = "Runtime Python SDK and CLI"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.11"
@@ -325,6 +325,9 @@ def build_parser() -> argparse.ArgumentParser:
325
325
  )
326
326
  completion_cmd.add_argument("shell", choices=["bash", "zsh", "fish"], help="Target shell")
327
327
 
328
+ # Hidden helper used by shell completion to list slugs, one per line.
329
+ subparsers.add_parser("_slugs", help=argparse.SUPPRESS)
330
+
328
331
  parser.format_help = lambda: _format_top_help() # type: ignore[assignment]
329
332
  return parser
330
333
 
@@ -571,6 +574,8 @@ def main(argv: list[str] | None = None) -> int:
571
574
  return handle_help(args.topic)
572
575
  if args.command == "completion":
573
576
  return handle_completion(args.shell)
577
+ if args.command == "_slugs":
578
+ return handle_slugs(config)
574
579
  if args.command == "_proxy_agent":
575
580
  return run_proxy_agent(
576
581
  args.base_url,
@@ -1256,14 +1261,16 @@ def _render_computer_table(computers: list[dict[str, Any]], *, title: str | None
1256
1261
 
1257
1262
 
1258
1263
  def _select_prompt(message: str, choices: list[Any], *, instruction: str | None = None) -> Any:
1264
+ # questionary rejects use_jk_keys together with use_search_filter because
1265
+ # j/k would be swallowed by the search prefix. We pick search over vim keys.
1259
1266
  return _UI.q().select(
1260
1267
  message,
1261
1268
  choices=choices,
1262
1269
  qmark="●",
1263
1270
  pointer="❯",
1264
- instruction=instruction or "↑↓ navigate · / search · enter select · esc cancel",
1271
+ instruction=instruction or "↑↓ navigate · type to search · enter · esc cancel",
1265
1272
  use_indicator=True,
1266
- use_jk_keys=True,
1273
+ use_jk_keys=False,
1267
1274
  use_search_filter=True,
1268
1275
  style=_UI.style(),
1269
1276
  )
@@ -3056,7 +3063,7 @@ def _vm_detail_menu(client: RuntimeClient, vm: dict[str, Any]) -> str:
3056
3063
  choices,
3057
3064
  ).unsafe_ask()
3058
3065
 
3059
- if action == "__back__":
3066
+ if action is None or action == "__back__":
3060
3067
  return "__back__"
3061
3068
  if action == "__quit__":
3062
3069
  return "__quit__"
@@ -3268,9 +3275,9 @@ _runtime_complete() {
3268
3275
  fi
3269
3276
  sub="${COMP_WORDS[1]}"
3270
3277
  case "$sub" in
3271
- info|url|start|enter|run|publish|delete|rm|share|startup|service)
3278
+ info|url|start|enter|run|publish|delete|rm|startup|service)
3272
3279
  local ids
3273
- ids=$(runtime ls 2>/dev/null | python3 -c 'import sys,json;print("\n".join(c["slug"] for c in json.load(sys.stdin).get("computers",[]) if c.get("slug")))' 2>/dev/null)
3280
+ ids=$(runtime _slugs 2>/dev/null)
3274
3281
  COMPREPLY=( $(compgen -W "$ids" -- "$cur") )
3275
3282
  ;;
3276
3283
  completion)
@@ -3279,6 +3286,10 @@ _runtime_complete() {
3279
3286
  share)
3280
3287
  if [[ ${COMP_CWORD} -eq 2 ]]; then
3281
3288
  COMPREPLY=( $(compgen -W "public private" -- "$cur") )
3289
+ else
3290
+ local ids
3291
+ ids=$(runtime _slugs 2>/dev/null)
3292
+ COMPREPLY=( $(compgen -W "$ids" -- "$cur") )
3282
3293
  fi
3283
3294
  ;;
3284
3295
  esac
@@ -3329,11 +3340,17 @@ _runtime() {
3329
3340
  case ${words[1]} in
3330
3341
  info|url|start|enter|run|publish|delete|rm|startup|service)
3331
3342
  local -a ids
3332
- ids=(${(f)"$(runtime ls 2>/dev/null | python3 -c 'import sys,json;print(\"\\n\".join(c[\"slug\"] for c in json.load(sys.stdin).get(\"computers\",[]) if c.get(\"slug\")))' 2>/dev/null)"})
3343
+ ids=(${(f)"$(runtime _slugs 2>/dev/null)"})
3333
3344
  _describe -t slugs 'computer' ids
3334
3345
  ;;
3335
3346
  share)
3336
- _values 'visibility' public private
3347
+ if (( CURRENT == 2 )); then
3348
+ _values 'visibility' public private
3349
+ else
3350
+ local -a ids
3351
+ ids=(${(f)"$(runtime _slugs 2>/dev/null)"})
3352
+ _describe -t slugs 'computer' ids
3353
+ fi
3337
3354
  ;;
3338
3355
  completion)
3339
3356
  _values 'shell' bash zsh fish
@@ -3348,7 +3365,7 @@ _runtime "$@"
3348
3365
 
3349
3366
  _COMPLETION_FISH = r"""# fish completion for runtime
3350
3367
  function __runtime_slugs
3351
- runtime ls 2>/dev/null | python3 -c 'import sys,json;print("\n".join(c["slug"] for c in json.load(sys.stdin).get("computers",[]) if c.get("slug")))' 2>/dev/null
3368
+ runtime _slugs 2>/dev/null
3352
3369
  end
3353
3370
 
3354
3371
  complete -c runtime -f
@@ -3385,5 +3402,25 @@ def handle_completion(shell: str) -> int:
3385
3402
  return 0
3386
3403
 
3387
3404
 
3405
+ def handle_slugs(config: RuntimeConfig) -> int:
3406
+ """Print one slug per line. Used by shell completion scripts. Silent on errors."""
3407
+ if not config.api_key:
3408
+ return 0
3409
+ try:
3410
+ client = RuntimeClient(base_url=config.base_url, api_key=config.api_key)
3411
+ payload = client.list_computers()
3412
+ except Exception:
3413
+ return 0
3414
+ computers = payload.get("computers") or []
3415
+ if not isinstance(computers, list):
3416
+ return 0
3417
+ for c in computers:
3418
+ if isinstance(c, dict):
3419
+ slug = str(c.get("slug") or "").strip()
3420
+ if slug:
3421
+ sys.stdout.write(slug + "\n")
3422
+ return 0
3423
+
3424
+
3388
3425
  if __name__ == "__main__":
3389
3426
  raise SystemExit(main())
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: runtime-sdk
3
- Version: 0.4.22
3
+ Version: 0.4.24
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