Skip to content

armgit / cua

Public Imported from GitHub
0

Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.

Clean up lume_stop

f-trycuaf18ca5f555c6
diff --git a/libs/lumier/src/lib/utils.sh b/libs/lumier/src/lib/utils.sh
index 8a9937548f..079ca047fa 100755
--- a/libs/lumier/src/lib/utils.sh
+++ b/libs/lumier/src/lib/utils.sh
@@ -134,13 +134,35 @@ EOF
extract_json_field() {
local field_name=$1
local input=$2
- local result
- result=$(echo "$input" | grep -oP '"'"$field_name"'"\s*:\s*"\K[^"]+')
- if [[ $? -ne 0 ]]; then
- echo ""
- else
+ local result=""
+
+ # First attempt with jq if available (most reliable JSON parsing)
+ if command -v jq &> /dev/null; then
+ # Use jq for reliable JSON parsing
+ result=$(echo "$input" | jq -r ".$field_name // empty" 2>/dev/null)
+ if [[ -n "$result" ]]; then
+ echo "$result"
+ return 0
+ fi
+ fi
+
+ # Fallback to grep-based approach with improvements
+ # First try for quoted string values
+ result=$(echo "$input" | tr -d '\n' | grep -o "\"$field_name\"\s*:\s*\"[^\"]*\"" | sed -E 's/.*":\s*"(.*)"$/\1/')
+ if [[ -n "$result" ]]; then
echo "$result"
+ return 0
fi
+
+ # Try for non-quoted values (numbers, true, false, null)
+ result=$(echo "$input" | tr -d '\n' | grep -o "\"$field_name\"\s*:\s*[^,}]*" | sed -E 's/.*":\s*(.*)$/\1/')
+ if [[ -n "$result" ]]; then
+ echo "$result"
+ return 0
+ fi
+
+ # Return empty string if field not found
+ echo ""
}
extract_json_field_from_file() {
diff --git a/libs/lumier/src/lib/vm.sh b/libs/lumier/src/lib/vm.sh
index 5437976701..b2bd10d7e7 100755
--- a/libs/lumier/src/lib/vm.sh
+++ b/libs/lumier/src/lib/vm.sh
@@ -233,7 +233,7 @@ stop_vm() {
# still attempt a stop just in case.
echo "VM status is unknown ('$vm_status') or VM not found during cleanup. Attempting stop anyway."
lume_stop "$VM_NAME" "$STORAGE_PATH"
- sleep 5000
+ sleep 5
echo "VM '$VM_NAME' stop command issued as a precaution."
else
echo "VM status is unknown ('$vm_status') or VM not found. Not attempting stop."