harn-vm 0.10.170

Async bytecode virtual machine for the Harn programming language
use crate::value::{DictMap, VmDictExt, VmError, VmValue};
use harn_builtin_macros::harn_builtin;
use harn_vm_core::builtin_support::VmBuiltinDef;

pub(super) const OPTION_REGISTRY_DEFS: &[&VmBuiltinDef] = &[&LLM_CALL_OPTION_REGISTRY_BUILTIN_DEF];

/// Expose the canonical `llm_call` option registry to Harn so stdlib
/// projection and removed-key diagnostics cannot drift from the runtime.
#[harn_builtin(
    exposure = "pure",
    effects = [],
    sig = "__llm_call_option_registry() -> dict", category = "llm.config"
)]
fn llm_call_option_registry_builtin(
    _args: &[VmValue],
    _out: &mut String,
) -> Result<VmValue, VmError> {
    let keys = harn_builtin_meta::llm_options::LLM_CALL_OPTION_FIELDS
        .iter()
        .map(|field| VmValue::String(field.name.into()))
        .collect();
    let wrapper_only = harn_builtin_meta::llm_options::LLM_WRAPPER_ONLY_KEYS
        .iter()
        .map(|key| VmValue::String((*key).into()))
        .collect();
    let mut removed = DictMap::new();
    for entry in harn_builtin_meta::llm_options::LLM_REMOVED_OPTIONS {
        removed.put_str(entry.key, entry.fix);
    }
    let mut registry = DictMap::new();
    registry.put("keys", VmValue::list(keys));
    registry.put("wrapper_only", VmValue::list(wrapper_only));
    registry.put("removed", VmValue::dict(removed));
    Ok(VmValue::dict(registry))
}