Modules enable code reuse through imports and exports. Registry provides public sharing.
Importing
Registry modules:
import { @sortBy, @unique } from @mlld/array
import @corp/utils as @corp
>> With version
import { @helper } from @alice/utils@1.0.0
import { @helper } from @alice/utils@beta >> a tag
The first import of a registry module that is not in your local cache (~/.llm/cache) fetches it from the registry, checks it against the hash the registry published, caches it, and pins it in your project's mlld-lock.json. mlld notes each fetch on stderr. Later runs load it from the cache without the network, and must match the pin.
A module your project has not pinned (one another project already cached, say) follows the registry instead, and mlld says on stderr that it is unpinned. Without a version, the import loads the registry's latest version, checking for a newer one at most once an hour; if the registry cannot be reached, the cached copy loads and the note says so. With a version or tag, it loads that version, and does not pin it. To fix a module at one version, pin it with mlld module install @author/name@1.0.0.
A version range such as @^1.0.0 is refused, naming the versions that exist; name an exact version or a tag instead. mlld module install @author/name fetches a module ahead of time the same way.
Letting a registry module apply approval labels:
An approval label is a grant class (a class declared with effect: "grant") or an attestation label. It says something has been checked or approved, so it can unlock operations a policy would otherwise stop. A registry or remote module may not apply one on its own. The import has to name each label it allows with using { attests: [...] }:
class .reviewed = { kind: "data", effect: "grant", description: "A person checked this" }
record @approved [
body: string [ accepts .reviewed ]
]
import { @review } from @someone/reviewer using { attests: [.reviewed] }
The label has to be declared, as every label your program uses must be, and a grant class needs a record field that accepts it (see labels-classes). The permission covers only that module and only the labels named. A label in the list that is not an approval label is an error. Your project's own files need no permission: they may apply approval labels already, and naming attests on a local import only prints a warning that it changes nothing.
Importing Local Files
Local files (selected exports):
import { @helper } from "./utils.mld"
import { @config } from "@root/config.mld"
import { @prompt } from "../prompts/main.mld"
import {
@renderHeader,
@renderBody
} from "./templates.mld"
Local files (namespace import):
import "./utils.mld" as @utils
show @utils.helper("report")
Path resolution:
./and../paths resolve from the importing file's directory, not the shell cwd."@root/..."resolves from the project root (the folder holdingmlld-config.json).- Write paths with
/separators.
A path known only when the program runs:
policy @dynamic = { * { capabilities: { dynamic_imports: true } } }
import { @tools } from @modulePath
import { @prompts } from @repo.promptsModule
import { @rebuild } from `@root/${@repoDir}/llm/agents/griffin.mld`
import @modulePath as @mod
An import can take its path from a variable, a field of one, or a backtick template. The path is worked out when the import line runs and then imported as if it had been written out, so it reaches the same files: a local file, or an @root/… path that only descends from the project root. A URL, a registry module (@author/module) or a resolver prefix cannot come from a variable; write those out in the source. A namespace import from a variable needs a name (as @mod). A name in { … } that the module does not export is an error when the line runs.
These imports are off unless a policy switches them on with capabilities.dynamic_imports: true, because the code they load is chosen while the program runs, possibly from data. Only your program's own policy directives and the project's mlld-config.json policy can switch them on. A policy in an imported module, import policy, a union() of a policy value and a using { policy } clause all leave them off, so a dependency cannot switch them on for you. The switch restricts nothing else: a policy whose only setting is the switch behaves like no policy for everything other than these imports.
Without the switch, the import stops with "Imports whose path comes from a variable are off by default". mlld validate lists such an import with "unresolved": true and does not try to follow it.
Containing an import:
const @agentModule = policy {
* { capabilities: { deny: ["cmd", "sh", "js", "node", "py"] } }
}
import untrusted { @tools, @prompts } from @repoModule using { contain: @agentModule }
using { contain: @ceiling } loads a contained module, for code you did not write, such as another repository's module. A contained module:
- runs its load, and every later call to a function it defines, under your policy narrowed by the ceiling. This holds wherever the function is called: from your code, from inside an object or list, passed to another function, or handed to an agent as a tool. A function you pass into it runs under the ceiling too, for the length of that call.
- keeps its own
policy, guards, hooks and label classes to itself. They apply inside its own calls, where its policy can only narrow further, and never to your program's operations; a grant its policy makes (aself_attestationrecord, adangeropt-in) applies to its load only. Importing a guard from a contained module is an error, and so is a contained module that declares a privilegedguard!or a guard or class with the same name as one your program already declared.import policycannot be contained. - is evaluated on its own. It does not reuse an earlier ordinary import of the same file, and a later ordinary import does not reuse it. The modules it imports are part of it.
The ceiling is a policy value that can only narrow, under the same limits as using { policy } on a call: it cannot grant a capability, switch on sh or dynamic_imports, or carry an allow! exception. contain: {} adds no restriction but keeps the module's rules to itself. contain applies to imported module files; it is an error on a built-in library such as @mlld/lang.
A policy deny list stops the commands and code blocks the module runs, but it is not a wall around the programs those start (see policy-capabilities), and it does not stop the module starting an MCP server with import tools from mcp, which command rules never gate (see mcp-import). To contain processes as well, run the calls in a kernel box. A contained module can still read run inputs such as @input; no ceiling denies them.
Labelling what an import brings in:
import untrusted { @tools } from "./tools.mld" puts the label on every value the import binds, and on the result of every call to a function it binds, so your policy's rules for untrusted data apply to them. Containment adds no label by itself. An import can only add labels that restrict: import trusted { … } is an error, and so is a label whose class your program declares with effect: "grant".
Restricting an import:
import { @helper } from "./utils.mld" using {
policy: { deny: ["fs:r:/private/**"] }
}
The attached policy restricts reading and evaluating the module, including its nested imports. It can narrow the current policy, never relax it. The temporary restriction ends when the import finishes or fails; it does not follow an exported function into later calls. Policies declared by the imported module keep their normal effect after the import.
The same clause works on namespace imports and import policy, and it can sit beside attests in one using (see modules-importing-registry). Writing the policy as with { policy: … } on an import is an error; mlld migrate rewrites it. Import pipelines, section-renaming tails, and invocation authorizations inside an import policy remain unsupported. with keys do nothing on an import: labels and unknown keys print a warning, and trust is an error. An import has no callee to receive them.
A module evaluates once per run:
A module's top-level directives execute the first time the module is imported in a run. Importing the same file again — from the same file, a different file, or through a namespace import — reuses that first evaluation instead of running the module again. A top-level side effect (a file write, an append, a handle mint) therefore happens once per run, no matter how many imports reach the module. A module that should run its setup per import cannot: there is no per-import execution. (Trace output marks the reuse with import.cache_hit.)
A module reads only its own names:
A module resolves names in its own file: its top level, and the parameters and bindings of its functions. It cannot read a name the importing file defines; a reference to one is an error naming the variable. Run inputs such as @input are the exception, because they belong to the run rather than to any file.
A diagnostic the module raises while it evaluates — a warning, for example — is delivered to the author of the file whose import triggered it, attributed to that import's spelling of the module path. A later import of the same module reuses the evaluation and so raises nothing: a lazy data literal that warns when it evaluates warns on the import that forced it, not on imports that receive the already-evaluated value.
Namespace Imports
Namespace imports:
import "./alice-utils.mld" as @alice
import "./bob-utils.mld" as @bob
const @data = { title: "Report" }
show @alice.format(@data)
show @bob.format(@data) >> no collision
Each module's exports sit under its own name, so two modules can both export @format. Registry modules import the same way: import @alice/utils as @alice.
Directory Imports
Importing a directory (import "./agents" as @agents) is not available in mlld 2.2.0. Import the directory's entry file directly instead:
import { @helper } from "./agents/index.mld"
A namespace import of the entry file gives you one object holding its exports:
import "./agents/index.mld" as @agents
show @agents.helper
Relative paths resolve from the importing file's directory, not the shell cwd.
An import through a LOCAL resolver prefix finds the entry file on its own: import { @helper } from @lib/agents loads the index.mld inside agents under the prefix's basePath when there is no agents.mld. See resolvers.
Template Collections
Template collections import an entire directory of template files, both .att (${@var} dialect) and .mtt ({{var}} dialect), as a callable namespace:
import templates from "@root/agents" as @agents(message, context)
const @msg = "Where is my order?"
const @ctx = "order #123"
>> Access templates by name (bracket or dot notation)
show @agents["alice"](@msg, @ctx) >> agents/alice.att
show @agents.support["helper"](@msg, @ctx) >> agents/support/helper.att
The parameters name the values the templates read: agents/alice.att can use ${@message} and ${@context}.
@root/agents is the agents directory at the project root, so the import reads the same from any file in the project. A path relative to the importing file ("./agents") works too, as does a prefix mapped to the LOCAL resolver, such as @local/ (see local-development).
Directory structure example:
agents/
alice.att >> @agents["alice"](msg, ctx)
bob.att >> @agents["bob"](msg, ctx)
support/
helper.att >> @agents.support["helper"](msg, ctx)
escalate.att >> @agents.support["escalate"](msg, ctx)
Key rules:
- All templates in a collection share the same parameter signature
- Hyphens in filenames are preserved:
json-pretty.att→@tpl["json-pretty"] - Other files in the directory (anything that is not
.attor.mtt) are skipped - Calls are positional:
@agents.alice(@msg, @ctx) - Use dot notation for directories, brackets for template names
- Collections require parameters in the
as @name(params)clause
When to use collections:
- Multiple templates with the same interface (agent prompts, formatters)
- Dynamic template selection based on runtime values
- Organizing related templates by category
Single templates:
For one template, load the file as an executable:
exe @alice(message, context) = template "agents/alice.att"
exe @helper(message, context) = template "agents/support/helper.att"
show @alice("Where is my order?", "order #123")
Paths resolve from the file that declares the executable. To pick one of a few single templates by a runtime value, route with match:
exe @alice(message, context) = template "agents/alice.att"
exe @helper(message, context) = template "agents/support/helper.att"
exe @reply(agent, message, context) = match @agent [
"alice" => @alice(@message, @context)
* => @helper(@message, @context)
]
show @reply("alice", "Where is my order?", "order #123")
Importing Node Modules
Importing a node package (
import … from node @pkg) is not available in mlld 2.2.0.
Call the package from a node { … } block instead:
exe @basename(p) = node { return require("path").basename(p) }
show @basename("/tmp/file.txt")
Basic node imports:
import { basename } from node @path
const @name = @basename("/tmp/file.txt")
show @name
Namespace imports:
import { posix } from node @path
const @dir = @posix.dirname("/tmp/file.txt")
show @dir
Constructor expressions:
import { URL } from node @url
const @site = new @URL("https://example.com/path?x=1")
show @site.hostname
show @site.pathname
Automatic wrapping:
- Functions are wrapped to accept and return mlld values
- Method binding is preserved (correct
thiscontext) - Classes support
new @Constructor()syntax - Construction runs under the
nodecapability: a policy that deniesnode(or an allow-list that omits it) refusesnew @Constructor(...)withPOLICY_CAPABILITY_DENIED, exactly as it refuses a node function call - Async iterables are wrapped as streams
- Promises work transparently
- Callback-style functions trigger warnings
Module resolution:
- Uses Node.js module resolution from the importing file's directory
- Supports both CommonJS and ES modules
- Built-in modules:
node @path,node @fs,node @url, etc. - NPM packages: Use package name without leading
@(e.g.,node @chalk)
Import Types
| Type | Behavior | Use Case |
|---|---|---|
module |
Content-addressed cache | Registry modules (default) |
static |
Embedded at parse time | Prompts, templates |
live |
Fetched on every import | Status APIs |
cached(TTL) |
Accepted; fetched on every import, like live |
Feeds, configs |
local |
A module under the @local/ prefix (see local-development) |
Development |
templates |
Directory of .att and .mtt files, each callable (see import-templates) |
Template collections |
import module { @api } from @corp/tools
import static { @prompt } from "./prompts.mld"
import live <https://status.io> as @status
import cached(1h) <https://feed.xml> as @feed
import local { @dev } from @local/experimental
A declared type that does not fit its source is an error, whatever the source: module needs a registry module, cached a URL, local an @local/ path, static a local file or an @root/ path, live a URL, a resolver path or @input, and templates a directory: a local path, an @root/ path, or a path under a prefix mapped to the LOCAL resolver such as @local/. import cached(5m) "./feed.mld" fails with Import type 'cached' requires an absolute URL source. Leave the type out to let mlld pick it from the source.
Custom Resolvers
Built-in:
@author/module→ Registry@root/file→ Project root./file.mld→ Local (with fuzzy extension matching)
Custom prefixes (mlld-config.json):
{
"resolvers": {
"prefixes": [
{
"prefix": "@lib/",
"resolver": "LOCAL",
"config": { "basePath": "./src/lib" }
},
{
"prefix": "@company/",
"resolver": "GITHUB",
"config": {
"repository": "company/private-modules",
"branch": "main"
}
}
]
}
}
A custom prefix works in import (import { @h } from @lib/x). For a LOCAL prefix, @lib/x names x, then x.mld, then x.md, then the index.mld inside an x directory, under the basePath; the first that exists wins, so a file beats a directory of the same name. A file load does not resolve it: <@lib/notes.md> is refused. mlld reads resolvers.prefixes for resolver mappings. It also reads top-level resolverPrefixes when present, and CLI writers persist the nested resolvers.prefixes shape.
Quick setup: mlld init writes mlld-config.json; add each prefix to its resolvers.prefixes list in the shape above.
mlld init
mlld module aliasandmlld setup, which wrote these entries for you, are not available in mlld 2.2.0. Editmlld-config.jsondirectly.
Lock File
When you install a module, or import a registry module that is not yet in your local cache, mlld creates mlld-lock.json to ensure reproducible imports. This file tracks exact versions and content hashes. Once a module is in the lock, later imports must match its pinned hash: content that differs is refused and the lock is left unchanged.
{
"lockfileVersion": 1,
"modules": {
"@alice/utils": {
"version": "1.0.0",
"resolved": "abc123def456...",
"source": "registry://@alice/utils@1.0.0",
"integrity": "sha256:abc123def456...",
"fetchedAt": "2026-01-15T10:00:00.000Z",
"registryVersion": "1.0.0",
"sourceUrl": "https://raw.githubusercontent.com/alice/utils/0123abc.../utils.mld"
}
}
}
Lock entry fields:
- version - The version you asked for: an exact version such as
"1.0.0", or"latest"when you named none - resolved - Content hash used for cache lookup (SHA256)
- source - The registry module and the version that was fetched, as
registry://@author/name@version - sourceUrl - Address the content was downloaded from
- integrity - Content hash for verification (sha256:...) — computed over text-normalized module content (line endings and unicode form normalized), so a module checks out identically across checkout styles.
- fetchedAt - Timestamp when module was installed
- registryVersion - The exact version the registry served (only for registry modules)
Behavior:
- Auto-generated - Created and updated by
mlld module install, and by the first import of a registry module missing from your cache - Version control - Commit to git for reproducible builds
- Never edit manually - Change a pin with
mlld module install(seemodules-updating) - Registry-only validation - Lock file only enforces version matches for registry modules
- Pins hold until you reinstall - Whether
versionreads"latest"or an exact version, imports keep loading the pinned content; onlymlld module installwith a version or--forcemoves a pin - A failed install fails the command -
mlld module installexits 1 when any module fails to install, a pin it refuses included, so a CI step running it fails; the modules that did install keep their lock entries - A corrupt lock is never silent - a lock file that exists but is not valid JSON (a mid-merge conflict marker is the classic case) warns loudly whenever mlld resolves a module, and its pins are ignored — fix or delete the file. Under sig enforce mode, module resolution refuses while the lock is unparseable: a corrupt lock and a tampered one are indistinguishable, so enforce treats corruption as tampering.
Module Philosophy
Module-first design: keep .mld files readable; move complexity into focused modules. Avoid "kitchen sink" modules or side effects on import.
Creating Modules
---
name: text-utils
author: alice
version: 1.0.0
about: String helpers
license: CC0
---
needs {
js: []
}
exe @toUpper(s) = js { return s.toUpperCase() }
exe @trimEnds(s) = js { return s.trim() }
export { @toUpper, @trimEnds }
Frontmatter fields:
name- Module name (required for registry)author- Your username (required for registry)version- Semver versionabout- Brief descriptionlicense- License (CC0 recommended)
Exporting from Modules
Modules only expose items listed in export { }. Unexported items stay private.
exe @greet(name) = `Hello, ${@name}!`
exe @farewell(name) = `Goodbye, ${@name}!`
const @_helper = "internal"
>> Only @greet and @farewell are visible to importers
export { @greet, @farewell }
Why explicit exports: Encapsulation. Importers see a clean API surface. Internal helpers, intermediate variables, and implementation details stay hidden. Rename or remove internals without breaking callers.
Wildcard export: Export everything (same as no export directive):
export { * }
Aliasing an export: An export entry may carry an as alias. The @-form is
the canonical spelling on both the name and the alias (a bare alias is also
accepted and normalized):
export { @greet as @sayHello }
Importers select @sayHello; @greet stays private unless it is also listed in
the export manifest. List both names to expose both:
export { @greet, @greet as @sayHello }
Aliases work in selected and namespace imports and preserve the exported
value's labels and a function's module scope. Reserved names cannot be export
aliases. Repeating the same source and alias is harmless; assigning two sources
to the same exported name is an error.
Re-exporting (barrel modules): export { * } forwards everything visible at the module level — including bindings the module itself imported from elsewhere. So a barrel module can import names once and re-expose them without re-listing each one:
>> barrel.mld — re-exposes names imported from another module
import { @greet, @farewell } from "./greetings.mld"
export { * }
A consumer can then import the re-exported names straight from the barrel:
import { @greet } from "./barrel.mld"
show @greet("World")
Omitting the export directive does the same thing — every module-level item, imported or not, is auto-exported.
There is no dedicated re-export form. export { @greet } from "./greetings.mld" and export * from "./greetings.mld" are both parse errors. To re-export from another module, import the names first, then list them in export { } (or use export { * }).
A module declares the credentials its functions use with the secret directive. The declaration travels with the functions, so an importer's call uses it without declaring anything:
secret @claude = { from: "keychain:mlld-box-{projectname}/claude-dev", as: "ANTHROPIC_API_KEY" }
exe @spawn(prompt) using secret:claude = run cmd { claude -p "$prompt" }
export { @spawn }
In the project's own modules that is the whole story. A module installed from the registry, a URL or GitHub reads the keychain only when the importer allows it: the importer names the secret in its own policy (* { secrets: { claude: "ANTHROPIC_API_KEY" } }), which replaces the module's declaration, or grants danger: ["@keychain"]. Without either, the module gets the environment variable named by as. A module's own policy secrets stay inside the module and do not reach its functions when they are called from an importer. See policy-auth.
Notes:
- Reading an item the module did not export, through a namespace import (
@g._helper), givesnull - Exported executables do not expose captured module internals through field access
- Guards can be exported alongside variables, so an importer can bind them in its own policy (
.secret+.op:cmd { before: @noSecretCmd }). A module's own policy binds cross the import: a guard the module binds fires on matching operations in the importing file, even if you only imported other names from the module. A guard that is exported but bound nowhere does nothing until someone binds it. Seesecurity-guards-basicsfor guards and binds. - Without an
exportdirective, all module-level items are auto-exported - Exported tool collections preserve their surfaced tool metadata when imported elsewhere; treat them as values, not as objects to spread
- Object spread over an exported value materializes plain data and drops wrapper metadata/identity
Module Structure
mlld newis not available in mlld 2.2.0.
Modules are directories with an entry point, manifest, and optional supporting files.
<metadata_sources>
Directory modules use two metadata sources:
| Source | Lives In | Used For |
|---|---|---|
| Frontmatter | Entry .mld file (--- ... ---) |
Runtime metadata (@fm, imported namespace .__meta__) |
module.yml |
Module directory root | Packaging metadata (type, publish/install metadata) |
Keep shared identity fields (name, author, version, about) aligned between frontmatter and module.yml.
</metadata_sources>
<module_types>
| Type | Purpose | Local Path | Global Path |
|---|---|---|---|
| library | Importable code | llm/lib/{name}/ | ~/.llm/lib/{name}/ |
| app | Runnable scripts | llm/run/{name}/ | ~/.llm/run/{name}/ |
| command | Claude slash cmd | .claude/commands/{name}/ | ~/.claude/commands/{name}/ |
| skill | Claude skill | .claude/skills/{name}/ | ~/.claude/skills/{name}/ |
| </module_types> |
<scaffold_commands>
Create the directory at the path its type takes, with an index.mld entry point:
mkdir -p llm/run/myapp && touch llm/run/myapp/index.mld # an app
mkdir -p llm/lib/utils && touch llm/lib/utils/index.mld # a library
</scaffold_commands>
<run_apps>
mlld run myapp # Runs llm/run/myapp/index.mld
mlld run # Lists available scripts including apps
Use index.mld as the module entry point convention.
</run_apps>
mlld module publish takes this standard module format.
Module Patterns
Module patterns:
>> Library module (wraps a core exe with shortcuts)
import { @agent } from @mlld/multi-harness
>> Model names differ per tool, so a shortcut that picks a model also picks the tool
llm @fast(prompt) = @agent(@prompt, { harness: "claude", model: "haiku" })
llm @strong(prompt) = @agent(@prompt, { harness: "claude", model: "sonnet" })
export { @fast, @strong }
>> Config/agent module (reads its own frontmatter, so the file needs a --- block)
const @meta = { id: @fm.id, name: @fm.name }
const @agentPrompts = { primary: <prompts/primary.md>, review: <prompts/review.md> }
export { @meta, @agentPrompts }
>> Gate module
exe @gate(answer, instruction, message) = @agent(@instruction)
export { @gate }
Local Development Modules
Keep modules you are still working on in a folder of your project, and map the @local/ prefix to it in mlld-config.json:
llm/modules/
├── my-utils.mld
└── helpers.mld
{
"resolvers": {
"prefixes": [
{ "prefix": "@local/", "resolver": "LOCAL", "config": { "basePath": "./llm/modules" } }
]
}
}
import local { @helper } from @local/my-utils
@local/my-utils names the file my-utils.mld in llm/modules/. When there is no such file, it names the index.mld inside a my-utils directory; when both exist, my-utils.mld wins. Without the @local/ prefix in mlld-config.json, mlld treats @local/my-utils as a registry module and the import fails. See resolvers for other prefixes.
Publishing
Publishing Public Modules
Publishing adds your module to the public registry at mlld-lang/registry on GitHub. mlld module publish checks the module, works out the exact registry files, and opens a pull request that adds them. The module becomes available once a maintainer merges it.
Before you publish
- mlld installed (
mlld howto quickstart). - Signed in to GitHub:
mlld auth login. The login asks for thegistandpublic_reposcopes;public_repois what lets mlld fork the registry and open the pull request for you. - A public GitHub repository holding the module. The module file must be committed, and the commit pushed to the
originremote on github.com. The registry serves your module from that exact commit, so there is nothing to upload.
Module metadata
A single-file module declares its metadata in frontmatter:
---
name: my-tool # lowercase letters, digits and hyphens
about: Brief description
version: 1.0.0
needs: [] # runtimes it uses: js, node, py, sh
license: CC0 # CC0 or MIT; CC0 when absent
author: yourname # optional; your GitHub login when absent
keywords: [utils, strings]
---
name, about, version and needs are required. The version must be a semantic version (1.2.3, optionally with -beta.1 or +build.5). A directory module keeps the same fields in module.yml, module.yaml or module.json.
See the pull request first
--dry-run runs every check and prints the pull request without sending anything:
mlld module publish my-tool.mld --dry-run
Dry run: would add @tester/greet@1.0.0
Branch: add-tester-greet-1790000000000
Pull request: Add @tester/greet
=== modules/tester/greet/1.0.0.json
{
"version": "1.0.0",
...
}
=== modules/tester/greet/metadata.json
...
=== modules/tester/greet/tags.json
{
"latest": "1.0.0",
"stable": "1.0.0"
}
Nothing was written.
A new module adds three files; an update adds the version file and changes tags.json, and the dry run shows that change as a diff. mlld howto registry-metadata describes each file. --json prints the same result as one JSON object.
Publish
mlld module publish my-tool.mld
The command prints the same summary, then asks:
Open a pull request against mlld-lang/registry? [y/N]
Only y or yes goes ahead. --yes answers for you, for scripts. Without a terminal and without --yes, the command refuses before doing anything:
error: publishing opens a pull request on your behalf and there is no terminal to confirm it; pass --yes, or --dry-run to only print it
Once you confirm, mlld:
- checks again that the version was not published in the meantime, and that you have no open pull request for this module already;
- uses your fork of
mlld-lang/registry, creating it if you have none and waiting up to 30 seconds for it to be ready; - creates a branch on the fork, named
add-<author>-<name>-<time>orupdate-<author>-<name>-<time>; - commits each registry file to that branch;
- opens the pull request and prints its address.
If writing a file fails partway, nothing more is sent and no pull request is opened. The error names the branch left on your fork, for example:
error: could not write modules/tester/greet/metadata.json: GitHub answered 422: Invalid request; the branch tester:add-tester-greet-1790000000000 was left on your fork and no pull request was opened; delete it at https://github.com/tester/registry/branches
Delete that branch and publish again.
Tags
Every publish points latest at the new version. stable follows too, unless it was pinned somewhere other than the previous latest. --tag adds a tag of your own:
mlld module publish my-tool.mld --tag beta
A tag is 2-50 lowercase letters, digits and hyphens; latest and stable are set for you and cannot be passed. See mlld howto versioning.
What is checked
- Metadata: the required fields, the name's shape, the license, and the
needsvalues. - Syntax and exports: the module parses, no name it defines is one mlld refuses to bind (such as
@now,@debugor@mx— a module defining one fails when it is imported), and it declares its API withexport { ... }naming things it defines (notexport { * }). Aconst,exe,llm,record,state,policyor namedguardcan be exported. - Imports: registry imports must come from the module's author, from you, or from
@mlld(so@mlld/multi-harnessis fine), whether the source is written@author/moduleor"@author/module". An import through a resolver prefix your project configures (resolvers.prefixesinmlld-config.json) is a resolver import instead. Local imports (including@root/…), network and resolver imports, and dependency findings, are warnings and do not stop a publish. - Author: you may publish as yourself, or as an organization you are an active member of on GitHub. Only the mlld maintainers may publish as
mlld. - Repository: a github.com
origin, nothing uncommitted under the module, and the current commit pushed. - Served content: each file is fetched from the address the registry will record and must match the committed file byte for byte. Its fingerprint (
contentHash) is taken from what was served. - Registry: the version must not already be published.
Common refusals, and what to do:
| Refusal | Fix |
|---|---|
you are not signed in to GitHub |
mlld auth login |
the module has uncommitted changes |
commit and push |
commit … is not on the \origin` remote` |
push |
… is already published; bump the version |
raise version |
… is not an active member of the … organization |
publish under your own name, or join the organization |
unknown flag: … |
see mlld module publish --help |
After the pull request
Registry maintainers review the pull request and merge it; the module is available from then on. Every publish, first or update, goes through a pull request. mlld howto ownership-permissions covers who may publish under which name.
Publishing Private Modules
For private or internal modules, use local imports or custom resolvers instead of the public registry.
Local Filesystem
Distribute modules via git or file sharing:
import { @helper } from "./shared/utils.mld"
import "./lib/internal/index.mld" as @internal
Custom Resolvers
Configure custom @ prefixes for private registries or internal repos:
{
"resolvers": {
"prefixes": [
{ "prefix": "@company/", "resolver": "LOCAL", "config": { "basePath": "./vendor/company-modules" } }
]
}
}
import { @auth } from @company/auth-utils
@company/auth-utils then loads auth-utils.mld from vendor/company-modules/.
See mlld howto resolvers for resolver configuration.
Development Modules
Map the @local/ prefix to a folder such as llm/modules/ (see local-development), then import by file name:
import local { @tool } from @local/dev-module
These resolve from that folder without a registry lookup.
Updating Modules
mlld module ls,mlld module updateandmlld registryare not available in mlld 2.2.0. Update a module by installing it again, as below.
Check module info:
mlld module info @alice/utils # show module details from the registry
Move to a specific version:
mlld module install @alice/utils@2.0.0 # fetch 2.0.0 and pin it
Move to the newest version:
mlld module install @alice/utils --force # fetch the newest version and pin it
Without --force or a version, a module the lock pins stays at its pin, whether or not it is in your cache. On a machine without it cached, such as a fresh clone or CI, install fetches the pinned version. A pin whose version reads "latest" names only content, so install fetches the newest version and refuses it, leaving the lock unchanged, unless it matches the pinned content.
Reinstall the project's modules:
mlld module install # modules mlld-config.json declares
With no module named, mlld module install installs the modules mlld-config.json declares. Only when it declares none does it install the modules mlld-lock.json pins.
Version pinning:
The lock file (mlld-lock.json) records each pin (see lockfile). An import always loads the pinned content, whether the entry's version reads "latest" or an exact version; only mlld module install with a version or --force moves a pin.
A module the lock does not pin updates by itself: an import without a version picks up a newly published version, checking the registry at most once an hour, and an import naming a version (@alice/utils@2.0.0) loads that version. Pin a module to keep it where it is.
After updating:
Run your script to confirm the new exports load. mlld validate your-file.mld checks the file itself but does not check that its imports resolve.
Versioning
Semantic Versioning
Follow semver (major.minor.patch):
- 1.0.0 - Initial release
- 1.0.1 - Bug fix (backward compatible)
- 1.1.0 - New feature (backward compatible)
- 2.0.0 - Breaking change
Version Tags
Publish with tags:
mlld module publish --tag beta my-tool.mld
Import via tag:
import { @helper } from @alice/my-tool@beta
Common tags:
latest- Most recent stable (default)stable- Recommended versionbeta- Beta testingalpha- Alpha testing
Version Ranges
Specify ranges in mlld-config.json:
{
"dependencies": {
"@alice/my-tool": "^1.0.0",
"@bob/utils": "~1.2.0",
"@eve/lib": ">=1.0.0 <2.0.0"
}
}
Lock file pins exact versions. A range is not resolved when a module is fetched: mlld module install and a first import both refuse one, naming the available versions, so name an exact version or a tag.
Version Resolution in Imports
| Import | Version |
|---|---|
import ... from @alice/utils |
latest |
import ... from @alice/utils@1.0.0 |
exact |
import ... from @alice/utils@^1.0.0 |
refused: name an exact version or tag |
import ... from @alice/utils@beta |
tag |
Registry Metadata
Registry Structure
Modules are stored with version history:
registry/
└── modules/
└── alice/
└── my-tool/
├── metadata.json # Core info, owners
├── 1.0.0.json # Version 1.0.0
├── 1.0.1.json # Version 1.0.1
└── tags.json # latest, stable, etc.
metadata.json
Written once, by the pull request that adds the module:
{
"name": "my-tool",
"author": "alice",
"about": "Brief description",
"owners": ["alice"],
"maintainers": [],
"created": "2026-09-30T00:00:00.000Z",
"createdBy": 12345,
"firstPublishPR": null
}
{version}.json
One per published version:
{
"version": "1.0.0",
"needs": ["js", "sh"],
"license": "CC0",
"source": {
"type": "github",
"url": "https://raw.githubusercontent.com/alice/repo/3be6424…/my-tool.mld",
"contentHash": "6a42f7226eccbefaa06be2092c7e7c103500c4e53e0aa48ed8cc2e734a084aee",
"repository": {
"type": "git",
"url": "https://github.com/alice/repo",
"commit": "3be6424…",
"path": "my-tool.mld"
}
},
"dependencies": {},
"keywords": ["utility", "automation"],
"repo": "https://github.com/alice/repo",
"bugs": "https://github.com/alice/repo/issues",
"publishedAt": "2026-09-30T00:00:00.000Z",
"publishedBy": 12345
}
Key fields:
- source.type -
githubfor a single file, served fromurl;directoryfor a directory module, served frombaseUrlwith itsfileslisted and itsentryPointnamed. - source.contentHash - the SHA-256 fingerprint mlld checks the downloaded content against. For a directory it covers every listed file, in the listed order.
- source.repository - the repository, commit and path the content was published from.
- mlldVersion - present when the module declares one.
- publishedBy - GitHub user ID of the publisher (numeric ID, not username).
- publishedAt - when this version was published.
A directory module's source:
{
"type": "directory",
"baseUrl": "https://raw.githubusercontent.com/alice/repo/3be6424…/my-tool",
"files": ["index.mld", "module.yml", "README.md"],
"entryPoint": "index.mld",
"contentHash": "…",
"repository": { "type": "git", "url": "https://github.com/alice/repo", "commit": "3be6424…", "path": "my-tool" }
}
tags.json
{
"latest": "1.0.1",
"stable": "1.0.1",
"beta": "2.0.0-beta.1"
}
mlld module publish writes all of these; see mlld howto publishing-public.
Ownership and Permissions
Who may publish under a name
A module is published as @<author>/<name>. mlld module publish lets you use an author name that is:
- your own GitHub login (the default when
authoris absent); - an organization you are an active member or admin of on GitHub, checked when you publish;
mlld, only for the mlld maintainers.
Anything else is refused before any pull request is prepared.
Organization modules
---
author: company
name: auth-tool
---
Publishing this needs an active membership of the company organization on GitHub.
Every publish is a pull request
The first version and every update each open a pull request against mlld-lang/registry, and registry maintainers merge it. There is no direct publish.
Owners and maintainers
metadata.json records owners (the author, when the module is added) and maintainers:
{
"owners": ["alice"],
"maintainers": ["bob", "eve"]
}
These are registry records for the people reviewing pull requests. mlld module publish does not read them: whether you may publish an update is decided by the author rule above, and the pull request review decides the rest.
LLM Modules
LLM modules follow a (prompt, config) calling convention. The first argument is always the prompt text. The second is an optional config object that controls model selection, tool access, streaming, and other behavior.
import { @agent } from @mlld/multi-harness
>> Simple — no config
show @agent("What is REST?")
>> Full control — config object
const @review = @agent("Review the auth module", {
harness: "claude",
model: "opus",
tools: ["Read", "Grep"],
stream: true
})
The config object
@agent from @mlld/multi-harness is the module to call models with. It runs the prompt on one of four coding-agent CLIs, each wrapped by its own module: @mlld/claude, @mlld/codex, @mlld/pi and @mlld/opencode. It defines these config fields:
| Field | Type | Default | Purpose |
|---|---|---|---|
harness |
string | "auto" |
"claude", "codex", "pi" or "opencode"; "auto" uses the first one installed and signed in |
model |
string | the tool's own | Model name, in the chosen tool's own naming |
dir |
string | @root |
Working directory for tool operations |
tools |
array | — | Tool access list (see below) |
stream |
boolean | — | Enable token streaming |
system |
string | — | Appended system prompt |
sessionId |
string | — | Name a conversation; naming it again in the run continues it |
Model names differ per tool (haiku for claude, gpt-5.4 for codex), so set harness whenever you set model. Keys only one tool understands pass through to that tool's module; the @mlld/multi-harness README lists them.
When a tool-using agent needs to return structured output, give it the Write tool and an explicit output path, instruct it in the prompt to write its JSON there, then read the file back with <@outPath>? after the call — don't parse the agent's final message.
Convention, not schema: The runtime recognizes tools and dir from the config object (see next section). Everything else — model, system, stream — is handled by the module implementation, not the runtime. Module authors can add their own fields.
Runtime support for bridge calls
When an llm executable is invoked with a config object containing a tools property, the runtime automatically:
- Detects the second argument as a config object (plain object with a
toolskey) - Normalizes the tools array (strings for built-in tools, tool collections for mlld functions)
- Reads
config.dirif present, to set the working directory for bridge operations - Creates MCP bridges — temporary servers that expose the requested tools
- Populates
@mx.llmwith bridge metadata for the exe body to consume
exe @claudeCli(prompt, allowed) with { stdin: @prompt } = cmd {
claude -p --model sonnet --allowedTools "$allowed"
}
llm @myAgent(prompt, config) = [
>> These are set automatically by the runtime:
>> @mx.llm.config — path to generated MCP config file used for explicit tool isolation
>> @mx.llm.allowed — unified tool name list for --allowedTools
>> @mx.llm.native — native tool names CSV (empty when no native tools requested)
>> @mx.llm.inBox — true when inside a box with active VFS bridge
>> @mx.llm.hasTools — true when config.tools was specified
let @answer = @claudeCli(@prompt, @mx.llm.allowed)
=> @answer
]
The command runs in a small helper exe because values reach a cmd body as environment variables: each parameter of the helper is a shell variable ($allowed), and with { stdin: @prompt } sends the prompt on standard input. The shell expands the variable, so a value is never read as command text.
This is why llm executables don't need to manually construct --mcp-config flags or manage bridge lifecycles — the runtime handles it.
If the LLM client closes the bridge socket, such as after a harness timeout, the function bridge cancels active and queued function-tool tools/call work instead of letting it run after the client is gone. Nested imported MCP calls receive the same cancellation signal.
Session state attaches to a call with using { session, seed } (see Call-scoped session state). It does not open a bridge on its own: @mx.llm.sessionId is null inside a call that declares no tools.
Session metadata
@mx.llm.sessionId identifies the in-flight bridge call inside the executing llm body. Reading provider session metadata from a returned value (@value.mx.sessionId, @value.mx.sessions.<name>) is not available in mlld 2.2.0.
This provider or bridge session id is separate from session state: state session @planner = { ... } is state mlld keeps for one call it is attached to.
Resume and retry
A long-running provider call (a coding harness, an agent loop) can be resumed instead of started fresh. mlld carries the provider's resume token for you through a small envelope convention, so a wrapper can retry a blank or failed turn without re-running the whole conversation.
The outbound envelope
An llm executable tells the runtime a call is resumable by returning an envelope instead of a bare value:
llm @resumableLLM(prompt, config) = js {
// ... call the provider, capture its session token ...
return {
value: theAnswerText,
_mlld: { sessionId: providerSessionId, provider: "myharness" }
};
}
The runtime strips the _mlld envelope after the call returns. The plain value flows on as the result, and the sessionId/provider metadata is recorded as resume state. Any provider can opt in by following this { value, _mlld: { sessionId, provider } } shape.
The inbound contract
When a guard resumes a call (see Triggering a resume below), the runtime writes the conversation to continue into the config before the implementation runs:
config._mlld.resume = { sessionId, provider, continue: true }
On a fresh call there is no config._mlld at all, so read it defensively and treat a missing value as "start a new conversation":
const resume = config && config._mlld && config._mlld.resume;
if (resume && resume.continue) {
// hand the provider resume.sessionId
}
A program may also write _mlld.resume into the config by hand, to continue a provider conversation it has a session id for; the runtime passes it through. A call whose config says continue: true (a guard resume or a hand-written one) gets no mlld tools: the runtime serves it none of the config's tools. A guard that names tools for its retry (resume "…" with { tools }, see guard-resume) is the one exception, and gives the continuation exactly the tools it lists. A hand-written config cannot grant tools that way. What the provider's own built-in tools do depends on whether the config has a tools key:
- With a
toolskey, eventools: []or a list of tools, the continuation gets no tools at all: the list is not granted, and it closes the provider's built-in tools as well. - With no
toolskey, the provider keeps its built-in tools, as on any call that names none.
So to stop a hand-written continuation from calling any tool, give it tools: []. A hand-written one is also checked more cautiously: the earlier turns are unknown to the runtime, so URLs in the model's output are checked as the worst case (see security-url-exfiltration). A guard resume carries the earlier attempt forward instead.
A continued conversation carries its labels. mlld records, for the length of a run, everything each provider call was given: the prompt and config, what the llm body reads, and what its tools return. Influence through sessions is run-wide: once any call on a session has been given untrusted text, every later call in the run that continues a session is .influenced, and a call that names no session stays clean. mlld cannot tell reliably which conversation a call reaches (a module may store a session under another id, and an answer's own report of its session can be shaped by the model), so it does not try: a call that names a session in sessionId, resumes one with resume or _mlld.resume, or is answered on one carries everything every session in the run was given, and what calls running at the same time are handing their providers. What a call on no session read joins no session, so to keep a model call clean after a session has seen untrusted text, make it without a session.
Continue a session within a run by naming it again; continue one across runs with resume, which counts as untrusted.
sessionId: "S"names a session. NamingSagain later in the run continues it.resume: "X"and_mlld.resume.sessionId: "X"resume a session by the id the provider holds. If this run has not recorded a session under exactly that id, the call is treated as having seen untrusted content even in a run that read nothing untrusted: an id from another run, one typed by hand, another provider's, or the stored id of a session this run started under a name (a module may store a named session under a different id, as the bundledpimodule does). Resuming a named session counts as untrusted; to continue it in the same run, name it again.
A session is keyed by its provider for that check: the config's _mlld.resume.provider, else its provider, else its harness, else the llm executable itself (its name and the module that defines it). A provider module may report the session it used on its answer, in the _mlld envelope ({ value, _mlld: { sessionId, provider } }, see Resume and retry below); the bundled pi module reports its stored session name under provider pi. What mlld cannot see is a provider that continues a conversation the call neither names nor reports, such as a harness that always continues its most recent session; a module wrapping such a provider must report the session on its answers. See labels-influenced.
A provider module must keep naming and resuming apart: sessionId names a session of this run, and continuing a conversation that already exists, such as one from an earlier run, goes through resume or _mlld.resume. A module that lets sessionId continue an existing conversation hides that conversation's earlier turns from mlld. The bundled pi module scopes sessionId to the run: the session pi stores is named <run id>-<sessionId> (the run id is @mx.tape.run_id, or an id made once per run when the run records no tape), so reusing a sessionId in a later run starts a new session. To continue an earlier run's session, pass the stored name as resume; mlld treats that call as having seen untrusted content. A run resumed from a checkpoint (--resume) is a new run with a new run id, so a sessionId call it makes starts a new pi session too; to continue the interrupted run's session, pass its stored name as resume.
Resume eligibility propagates structurally: when an llm call is wrapped inside a plain (non-llm) exe, the envelope still rides along so the outer wrapper stays resume-eligible even though it never saw the raw _mlld field.
Triggering a resume
The runtime resumes a call when a guard that policy binds with after: asks it to; the caller does not. A guard inspects the output and issues resume "<hint>" to continue the same conversation with a correction message — no tools re-fire. See Guard Resume for the full mechanism. From inside an llm body or a guard, read @mx.llm.resume to see the in-flight resume state (null outside a resumed call, otherwise { sessionId, provider, continuationOf, attempt }).
Loading the generated config natively
@mx.llm.config is a path to a temporary MCP config file the runtime generates for tool isolation. Load and inspect it natively with the alligator reader plus @parse — no shelling out:
const @bridgeConfig = <@mx.llm.config>? | @parse
show @bridgeConfig.mcpServers
The ? makes the read tolerant when the field is absent (an unbridged call). @parse turns the JSON text into a structured object you can read with field access.
Multi-harness dispatch
@agent routes a prompt to one of several provider modules: config.harness picks claude, codex, pi or opencode, each its own llm executable following the (prompt, config) convention. A plain (non-llm) exe that wraps it stays resumable, because resume eligibility propagates structurally through the wrapper even though the wrapper itself is not declared with llm:
import { @agent } from @mlld/multi-harness
>> The wrapper is a plain exe; the call it makes is still resumable.
exe @dispatch(prompt, harness) = @agent(@prompt, { harness: @harness })
const @diffReview = @dispatch("Review the diff", "opencode")
show @diffReview
Blank-recovery recipe
When a provider returns an empty turn, retry against the same wrapper and provider — never silently fall back to a different provider, because a fallback can change the security and tool surface a guard authorized. Pass harness explicitly: with "auto" the pick is made again on each call, so a retry could land on a different tool. The recovery stays harness-agnostic by routing through @dispatch rather than naming a provider directly:
exe @askRecover(prompt, harness) = [
let @first = @dispatch(@prompt, @harness)
=> match [
@first != "" => @first
* => @dispatch(@prompt, @harness)
]
]
const @report = @askRecover("Summarize the report", "opencode")
show @report
The first branch keeps a good answer without calling again; the fallthrough retries the identical call — same wrapper, same provider, no provider swap.
For output repair (the model replied but the answer is malformed), prefer a guard resume over a caller-side retry: resume continues the same conversation so the model sees its prior turn and tool results, and tools do not re-fire. The blank-turn retry above is the right tool only when there is nothing to continue. See Guard Resume.
Tool types in the array
The tools array accepts a mix of string names and tool collections:
import { @agent } from @mlld/multi-harness
exe @summarize(text) = `Summary: ${@text}`
tools @helpers = { summarize: { call: @summarize } }
const @analysis = @agent("Analyze this codebase", {
tools: ["Read", "Grep", @helpers]
})
| Entry type | What happens |
|---|---|
String ("Read") |
Passed to the model as a native tool name. |
Tool collection (@helpers) |
Each entry is served as an MCP tool through a function bridge. The runtime generates a JSON schema from the function signature. |
A bare executable in the array (tools: [@summarize]) is refused; put it in a tools collection.
Empty tools
Passing an empty array signals "no tools" — the runtime sets @mx.llm.hasTools = true, keeps @mx.llm.allowed empty, and still provides an empty strict MCP config so modules can disable built-ins and block ambient MCP connectors:
const @plain = @agent("Pure text generation", { tools: [] })
Call-scoped session state
Attach session state to an LLM call, not to its executable definition:
state session @counter = {
count: number?
}
llm @countingAgent(prompt, config) = `${@counter.count}`
show @countingAgent("hello", {}) using {
session: @counter,
seed: { count: 0 }
}
A wrapper can attach the session and seed to an actual inner call inside its body. It cannot attach a default session on its definition: session belongs to a call, and writing it on a definition is a parse error. See Session state for a wrapper that accepts caller-chosen initial state.
Box interaction
Tool routing changes based on whether the call happens inside a box:
Outside a box: String tools pass through as native names. The child process uses them directly.
Inside a box: String tools are refused (The builtin tool 'Read' is not served inside a box), because passing the name on would hand the model the host's tool instead of the box's files. Tool collections work in both places, and a tool the box's tools: list does not allow refuses by name.
Network hosts each harness needs
A box whose network is a list of hosts lets its processes reach the network only through a local proxy mlld runs for the box (see "Host lists" in Box configuration). The table lists the hosts each harness contacted for a one-line prompt through that proxy, measured on macOS on 2026-10-09. The harness modules do not declare these hosts yet, so a box running a harness must list them in its own net.
| Harness (version) | Works through the proxy | Hosts contacted | Signs in with |
|---|---|---|---|
| claude (2.1.286) | sends every request through it; a full run was not measured, because the test machine's login had expired | api.anthropic.com, api.github.com, registry.npmjs.org, http-intake.logs.us5.datadoghq.com (seen before the login failure) |
the macOS keychain, which a box cannot reach; pass an API key instead |
| codex (0.154.0) | yes | chatgpt.com, auth.openai.com, ab.chatgpt.com, *.oaiusercontent.com |
a file in ~/.codex |
| pi (0.84.4) | yes | the configured provider's host only (openrouter.ai in the measured setup; chatgpt.com was also contacted) |
a file in ~/.pi/agent |
| opencode (dev build) | no: every connection is refused, because its TLS library hides the server name (encrypted ClientHello), which the proxy does not let through | openrouter.ai, models.dev (attempted) |
a file in ~/.local/share/opencode |
Every harness failed rather than connecting directly when given the wrong proxy credentials, so none of them goes around the proxy. pi and opencode talk to many model providers: a box that uses a provider other than the module's default must allow that provider's host.
The @mx.llm.native field tells module implementations which native tools are active. When config.tools is explicit, modules should also use @mx.llm.config as a strict MCP config even if it only contains an empty server set. This prevents the child LLM from inheriting ambient MCP connectors while still allowing modules to pass --tools "" or an equivalent empty native allowlist when native is empty.
Streaming
Streaming is wired on the executable's definition with with { stream, stream_format }, written between the signature and =:
llm @streamingLLM(prompt, config) with { stream: @config.stream, stream_format: "claude-code" } = [
let @answer = @prompt | cmd { claude -p --model sonnet --output-format stream-json --verbose }
=> @answer
]
The modules @agent calls do this internally — when you pass stream: true in config, the underlying executable's with clause turns streaming on. You don't need to configure this when using @agent:
show @agent("Explain TCP/IP", { stream: true })
See stream for format adapters and streaming details.
Writing your own LLM module
An LLM module follows this pattern:
>> 1. Declare with llm so the runtime processes config.tools
>> 2. Accept (prompt, config) as the calling convention
>> 3. Read @mx.llm for bridge metadata set by the runtime
>> 4. Hand values to the CLI as helper parameters (shell variables)
exe @cliWithNative(prompt, model, mcpConfig, tools) with { stdin: @prompt } = cmd {
my-llm-cli --model "$model" --mcp-config "$mcpConfig" --tools "$tools"
}
exe @cliMcpOnly(prompt, model, mcpConfig, tools) with { stdin: @prompt } = cmd {
my-llm-cli --model "$model" --disable-builtin-tools --mcp-config "$mcpConfig" --tools "$tools"
}
exe @cliPlain(prompt, model) with { stdin: @prompt } = cmd {
my-llm-cli --model "$model"
}
llm @myLLM(prompt, config) = [
let @settings = @config ? @config : {}
let @model = @settings.model ? @settings.model : "sonnet"
=> match [
@mx.llm && @mx.llm.config && @mx.llm.native => @cliWithNative(@prompt, @model, @mx.llm.config, @mx.llm.allowed)
@mx.llm && @mx.llm.config => @cliMcpOnly(@prompt, @model, @mx.llm.config, @mx.llm.allowed)
* => @cliPlain(@prompt, @model)
]
]
>> Model shortcuts
llm @fast(prompt) = @myLLM(@prompt, { model: "fast" })
llm @smart(prompt) = @myLLM(@prompt, { model: "smart" })
export { @myLLM, @fast, @smart }
Key points:
- Declaring with
llm(notexe) is required — without it, the runtime won't processconfig.toolsor populate@mx.llm - Always default missing config:
let @settings = @config ? @config : {} - Branch on
@mx.llm.configand@mx.llm.nativeto handle bridged, exe-ref-only, and unbridged invocations - Shortcuts should delegate to the core exe, not duplicate the implementation
- The runtime cleans up bridge temp files automatically when the exe scope exits