Skip to main content

Crate harn_vm

Crate harn_vm 

Source

Re-exports§

pub use checkpoint::register_checkpoint_builtins;
pub use llm::register_llm_builtins;
pub use mcp::connect_mcp_server;
pub use mcp::connect_mcp_server_from_json;
pub use mcp::connect_mcp_server_from_spec;
pub use mcp::register_mcp_builtins;
pub use mcp_server::take_mcp_serve_prompts;
pub use mcp_server::take_mcp_serve_registry;
pub use mcp_server::take_mcp_serve_resource_templates;
pub use mcp_server::take_mcp_serve_resources;
pub use mcp_server::tool_registry_to_mcp_tools;
pub use mcp_server::McpServer;
pub use metadata::register_metadata_builtins;
pub use metadata::register_scan_builtins;
pub use stdlib::register_agent_stdlib;
pub use stdlib::register_core_stdlib;
pub use stdlib::register_io_stdlib;
pub use stdlib::register_vm_stdlib;
pub use store::register_store_builtins;
pub use value::*;

Modules§

bridge
JSON-RPC 2.0 bridge for host communication.
checkpoint
Checkpoint system for resilient pipeline execution.
events
Structured event emission for observability.
jsonrpc
Shared JSON-RPC 2.0 message construction helpers.
llm
LLM integration: API calls, streaming, agent loops, tool handling, and tracing.
llm_config
mcp
MCP (Model Context Protocol) client for connecting to external tool servers.
mcp_server
MCP server mode: expose Harn tools, resources, resource templates, and prompts as MCP capabilities over stdio.
metadata
Project metadata store for Harn’s runtime state root.
orchestration
runtime_paths
schema
stdlib
Standard library builtins for the Harn VM.
stdlib_modules
store
Persistent key-value store backed by Harn’s runtime state root.
tracing
Pipeline Observability: structured tracing spans with parent/child relationships.
value
visible_text

Structs§

Chunk
A compiled chunk of bytecode.
CompileError
Compile error.
CompiledFunction
A compiled function (closure body).
Compiler
Compiles an AST into bytecode.
DebugState
Information about current execution state for the debugger.
Vm
The Harn bytecode virtual machine.

Enums§

Constant
A constant value in the constant pool.
DebugAction
Debug action returned by the debug hook.
Op
Bytecode opcodes for the Harn VM.

Functions§

clone_async_builtin_child_vm
Clone the VM at the top of the async-builtin child VM stack, returning a fresh Vm instance that callers own and can use without coordinating with other concurrent users of the stack. This replaces the legacy take/restore pattern: that pattern serialized access because only one consumer could hold the single stack entry at a time, which prevented any form of concurrent tool-handler execution within a single agent_loop iteration. Cloning is cheap — the VM struct shares its heavy state (env, builtins, bridge, module_cache) via Arc/Rc — so multiple concurrent handlers can each have their own execution context.
compile_source
Lex, parse, type-check, and compile source to bytecode in one call. Bails on the first type error. For callers that need diagnostics rather than early exit, use harn_parser::check_source directly and then call Compiler::new().compile(&program).
register_http_builtins
Register HTTP builtins on a VM.
reset_http_state
Reset thread-local HTTP mock state. Call between test runs.
reset_thread_local_state
Reset all thread-local state that can leak between test runs. Call this before each test execution for proper isolation.
restore_async_builtin_child_vmDeprecated
Legacy API — now a no-op because take_async_builtin_child_vm returns a clone rather than popping the stack, so there is nothing to restore. Kept for backward compatibility.
take_async_builtin_child_vmDeprecated
Legacy API preserved for backward compatibility with any out-of-tree callers. New code should use clone_async_builtin_child_vm() instead — take serializes concurrent callers because only one can hold the popped value at a time. Internally this now delegates to a clone so even legacy callers don’t deadlock each other, but the name is kept until external callers migrate.