Expand description
Lua scripted profile runtime.
Loads .lua profile scripts at startup, extracts their metadata (name,
description, tools, arguments), and provides runtime resolution with a
context bridge back into the Rust core (search, get, sources).
§Architecture
Profile scripts follow the same sandboxed Lua VM model as connectors and
tools, reusing all host APIs from crate::lua_runtime. In addition,
profiles receive a context table identical to tools:
context.search(query, opts?)— search the knowledge basecontext.get(id)— retrieve a document by UUIDcontext.sources()— list connector status
The profile-specific config from ctx.toml is passed as the second
argument to profile.resolve(args, config, context).
§Script Interface
Every profile script defines a global profile table. The historical
agent global remains accepted for compatibility:
profile = {
name = "my-profile",
description = "Helps with tasks",
tools = { "search", "get" },
arguments = {
{ name = "topic", description = "Focus area", required = false },
},
}
function profile.resolve(args, config, context)
return {
system = "You are a helpful assistant.",
messages = {},
}
end§Configuration
[profiles.script.my_profile]
path = "profiles/my-profile.lua"
timeout = 30
search_limit = 5See the profiles documentation for the full specification.
Structs§
- LuaProfile
Adapter - Adapter that wraps a Lua
ProfileDefinitionas aProfiletrait object. - Profile
Definition - Metadata extracted from a loaded Lua profile script.
Functions§
- doc_
response_ 🔒to_ lua - Convert a document response to a Lua table.
- extract_
arguments 🔒 - Extract argument definitions from a Lua
profile.argumentstable. - extract_
string_ 🔒list - Extract a list of strings from a Lua table field.
- get_
profile_ 🔒table - Return the canonical
profiletable, falling back to the legacyagentglobal so existing scripts continue to work unchanged. - list_
profiles - List all configured profiles and print their info.
- load_
profile_ definitions - Load all profile scripts from config and extract their definitions.
- load_
single_ profile - Load a single profile script and extract its definition.
- lua_
result_ 🔒to_ profile_ prompt - Convert the Lua
profile.resolve()return value to aProfilePrompt. - register_
profile_ 🔒context_ bridge - Register the
contexttable in the Lua VM for profile scripts. - resolve_
profile - Resolve a profile script’s prompt.
- run_
lua_ 🔒profile - Run the Lua profile synchronously on a blocking thread.
- scaffold_
profile - Scaffold a new profile script from a template.
- search_
results_ 🔒to_ lua - Convert search results to a Lua array table.
- sources_
to_ 🔒lua - Convert source statuses to a Lua array table.
- test_
profile - Test a profile script by resolving its prompt.
- truncate 🔒
- Truncate a string to fit in a column.