Skip to main content

Module stdlib

Module stdlib 

Source
Expand description

Standard library builtins for the Harn VM.

Every builtin is declared with the #[harn_builtin] proc-macro (crate::stdlib::macros::harn_builtin). Each annotation emits a sibling static <FN>_DEF: VmBuiltinDef carrying the signature, aliases, handler, and metadata, and registers it into the workspace-global macros::ALL_BUILTIN_DEFS distributed slice at link time. The CLI / LSP / lint / serve / dap binaries call force_link to defeat rlib dead-code stripping (linkme issue #36) so every static lands in the slice. Modules still expose a register_<module>_builtins(vm) helper for ordered eager registration (e.g. so clock::timestamp can override process::timestamp). register_vm_stdlib calls those helpers in order and then installs the aggregated signatures into the parser registry.

See CONTRIBUTING.md (“Adding a stdlib builtin”) for the full template.

Modules§

agent_state
asset_paths
Re-export of harn_modules::asset_paths plus a VM-side convenience that anchors the project-root walk at the currently-executing source file (via VM_SOURCE_DIR) and falls back to the existing source-relative resolver when the path is not an @-prefixed asset reference.
host
http_response
HTTP response codec primitives for .harn HTTP handlers.
long_running
macros
Support module referenced by #[harn_builtin]-emitted code.
process
secret_scan
template
Prompt-template engine for .harn.prompt assets and the render / render_prompt builtins.
token_redaction
std/oauth/redaction (OA-06) — OAuth token redaction stdlib.
tracing
workflow_messages

Functions§

all_builtin_defs
Aggregate of every #[harn_builtin]-emitted VmBuiltinDef in the stdlib.
all_builtin_signatures
Driver-facing helper: flatten the macro-emitted BuiltinDefs into a &'static [&'static BuiltinSignature] slice suitable for harn_builtin_registry::install_builtin_signatures.
force_link
Force-link entry point: a pub fn that touches ALL_BUILTIN_DEFS so the linker keeps every #[harn_builtin]-emitted static. Drivers (harn-cli, harn-lsp, etc.) call this once at startup. Doing nothing at runtime is fine — the side effect is purely a link-time signal.
register_agent_stdlib
Register agent builtins (requires network access and async runtime).
register_all_macro_builtins
Register every #[harn_builtin]-emitted def on the given VM. Drivers that build the full stdlib via register_vm_stdlib get this for free — each module’s register_*_builtins walks its MODULE_BUILTINS slice. This helper is exposed for embedders / tests that want a one-call entry.
register_core_stdlib
Register core builtins: pure/deterministic, no I/O.
register_io_stdlib
Register I/O builtins (requires OS access).
register_vm_stdlib
Register all standard builtins on a VM (core + io + agent). Also installs the macro-emitted signature slice into the parser registry (idempotent under repeat calls with the same slice pointer).
reset_stdlib_state
Reset thread-local stdlib state. Call between test runs.
stdlib_builtin_metadata
Return discoverable metadata for registered stdlib builtins.
stdlib_builtin_names
Return the canonical list of all stdlib builtin names. Used by harn-lint and harn-lsp to avoid hardcoded duplicate lists.