use fusabi_host::{ExecutionContext, Result, Value, Error};
use std::collections::HashMap;
pub fn list_devices(_args: &[Value], _ctx: &ExecutionContext) -> Result<Value> {
tracing::debug!("gpu.list_devices: returning mock data");
let mut device = HashMap::new();
device.insert("id".to_string(), Value::Int(0));
device.insert("name".to_string(), Value::String("Mock GPU".to_string()));
device.insert("uuid".to_string(), Value::String("GPU-00000000-0000-0000-0000-000000000000".to_string()));
Ok(Value::List(vec![Value::Map(device)]))
}
pub fn utilization(args: &[Value], _ctx: &ExecutionContext) -> Result<Value> {
let device_id = args
.first()
.and_then(|v| v.as_int())
.ok_or_else(|| Error::host_function("gpu.utilization: missing device_id argument"))?;
tracing::debug!("gpu.utilization: device_id={}, returning mock data", device_id);
Ok(Value::Float(42.5))
}
pub fn memory_info(args: &[Value], _ctx: &ExecutionContext) -> Result<Value> {
let device_id = args
.first()
.and_then(|v| v.as_int())
.ok_or_else(|| Error::host_function("gpu.memory_info: missing device_id argument"))?;
tracing::debug!("gpu.memory_info: device_id={}, returning mock data", device_id);
let total = 17179869184i64; let used = 8589934592i64; let free = total - used;
let mut info = HashMap::new();
info.insert("total".to_string(), Value::Int(total));
info.insert("used".to_string(), Value::Int(used));
info.insert("free".to_string(), Value::Int(free));
Ok(Value::Map(info))
}
pub fn temperature(args: &[Value], _ctx: &ExecutionContext) -> Result<Value> {
let device_id = args
.first()
.and_then(|v| v.as_int())
.ok_or_else(|| Error::host_function("gpu.temperature: missing device_id argument"))?;
tracing::debug!("gpu.temperature: device_id={}, returning mock data", device_id);
Ok(Value::Float(65.0))
}
pub fn power_usage(args: &[Value], _ctx: &ExecutionContext) -> Result<Value> {
let device_id = args
.first()
.and_then(|v| v.as_int())
.ok_or_else(|| Error::host_function("gpu.power_usage: missing device_id argument"))?;
tracing::debug!("gpu.power_usage: device_id={}, returning mock data", device_id);
Ok(Value::Float(250.0))
}
pub fn clock_speeds(args: &[Value], _ctx: &ExecutionContext) -> Result<Value> {
let device_id = args
.first()
.and_then(|v| v.as_int())
.ok_or_else(|| Error::host_function("gpu.clock_speeds: missing device_id argument"))?;
tracing::debug!("gpu.clock_speeds: device_id={}, returning mock data", device_id);
let mut clocks = HashMap::new();
clocks.insert("graphics".to_string(), Value::Int(1500));
clocks.insert("memory".to_string(), Value::Int(7000));
clocks.insert("sm".to_string(), Value::Int(1500));
Ok(Value::Map(clocks))
}