harn-vm 0.10.130

Async bytecode virtual machine for the Harn programming language
Documentation
use super::*;

// The two type blocks are pure literal text and together push this file past
// the source file-length cap, so they live beside it rather than in it.
mod swift_types;
mod typescript_types;

use swift_types::SWIFT_TYPES;
use typescript_types::TYPESCRIPT_TYPES;

pub fn typescript_declarations() -> String {
    typescript_type_block("typescript declarations")
}

fn typescript_type_block(language: &str) -> String {
    format!("{}{}", generated_header("//", language), TYPESCRIPT_TYPES)
}

pub fn swift_binding() -> Result<String, serde_json::Error> {
    Ok(swift_binding_body())
}

/// Hermetic counterpart of [`swift_binding`] for generating the checked-in
/// `HarnProviderCatalog.swift` artifact. See [`artifact_embedded`].
pub fn swift_binding_embedded(
    _explicit_overlay: Option<&crate::llm_config::ProvidersConfig>,
    _explicit_capabilities: Option<&crate::llm::capabilities::CapabilitiesFile>,
) -> Result<String, serde_json::Error> {
    Ok(swift_binding_body())
}

fn swift_binding_body() -> String {
    format!("{}{}", generated_header("//", "swift"), SWIFT_TYPES)
}

fn generated_header(comment: &str, language: &str) -> String {
    format!(
        "{comment} GENERATED by `{PROVIDER_CATALOG_GENERATOR}` - do not edit by hand.\n{comment} Source: Harn runtime provider catalog schema v{PROVIDER_CATALOG_SCHEMA_VERSION}.\n{comment} Language: {language}.\n\n"
    )
}