Configuration — for developers
Every key and what it does is documented for users at https://llembas.eu/docs/cli-configuration.html. This page is about the machinery: where configuration comes from, in what order, what a project may and may not set, and what to touch when adding a key.
The files
| File | Scope | Notes |
|---|---|---|
~/.config/lembas/connections.yaml |
global only | 2.0: the login, and nothing else — one type: webui entry naming the LLeMbas server, its key as {file:} to a 0600 file beside it, written by lembas login. Written chmod 600. A project can never define or override it. |
~/.config/lembas/config.yaml |
global | Everything else. |
<project>/.agent/config.yaml |
project | Read only once the directory is trusted. .lembas/ is used instead when .agent/ already belongs to another tool (project/root.ts). |
~/.config/lembas/{agents,commands,skills,memory}/ |
global | Subagents, custom commands, skills, memory. The project's .agent/agents, .agent/commands and .agent/skills count only when trusted. |
~/.local/share/lembas/ |
data | sessions.db, the library, snapshots, worktrees, mcp-auth.json. |
~/.local/state/lembas/ |
state | learned.json, prompt history, the hub socket, the service's status. |
All three roots follow XDG; LEMBAS_HOME roots all three at once, which is what
the tests and the smoke test use (config/paths.ts).
Loading (src/config/load.ts)
- Read the YAML, then translate legacy keys and former names (a mode such as
unrestricted, a renamed permission key) with a note for the user. - Drop a project's global-only keys before validation, so their shape cannot
break the file:
GLOBAL_ONLY=hardline_extra,hardline_disable,voice,update,settings_tool,embedding,remote,library,instructions,personality_custom. Each one dropped is a warning. A repository must not be able to weaken the floor, redirect speech or updates, or write words into the system prompt in the user's voice. - Validate with zod, then substitute.
{env:NAME}and{file:path}are filled after validation (config/substitute.ts); a missing variable or file is an error, never an empty string. A URL field accepts a placeholder and is checked again after substitution.mcp,voice,searchandupdateare filled one entry at a time, so one broken server or service turns off that one thing, not the whole file. A login whose substitution fails (its key file gone) lands inbrokenwith the reason, and no model resolves until it is made again. - Merge: objects key by key, everything else replaced, project over global. Permission rules stack instead (global first, then project), and a project's rule cannot loosen a global one.
- The login is expanded (
lembas/webui.ts): the onewebuientry becomes the server's/v1as it is spoken to (an internalConnection, no longer a schema anyone writes), with the account's models from/v1/models— refreshed at every start, kept from the last good read when the server cannot be reached. The account's personalization replaces the local keys while logged in (lembas/personal.ts). A model's ref is the id the server serves it under (deepseek/deepseek-flash,provider/refs.ts); the older forms (<login>/<id>,<login>/<model>) still resolve, and config.yaml is rewritten from them once (migrations.jsonin the state directory).
Custom connections — removed in 2.0
LLeMbas CLI 2.0 is LLeMbas-server-specific (CLI rule 2). It talks to the server
it is logged in to and uses that server's models, and nothing else; there is one
client, provider/openai-chat.ts. What went with the custom connections:
- the
anthropic,gemini,ollamaandresponsesdialects, context discovery and llama-swap unloading (provider/discover.ts); - a connection's
dialect,base_url,auth,key_cmd,discover,unload_url,unload_method,one_model_at_a_time; a model'sfallback,effort_mapandcache; - several logins at once: a login to another server signs this machine out of the previous one.
Two ways in, one login (lembas/login.ts). login() signs in by device
code; loginWithToken() (lembas login --token-stdin --server <url>) takes a
token another program already holds — Desktop's agent_token from the one
approval — on stdin only, so it never shows in a process list. It is checked
before anything is written (client.ts:checkToken: discovery's protocol, then
GET /api/v1/instance with it, whose scope must include link; a 404 or no
scope is an older server). Both then go through the same store(): the key
file, the webui entry, lembas.json, an earlier login to the same server
replaced and its token signed out naming the new one, any other server signed
out of, voice, search and embedding. --json prints the same done line for
both, so Desktop parses one shape (rule 3: Desktop runs the command and never
writes these files itself).
An entry of any other kind left in connections.yaml from 1.x is read past
with a warning naming it and saying how to log in, so an old file still starts.
Several logins left from 1.x: the one logged in to last is used, and the others
are named. Without a login there is no model: the error (NOT_LOGGED_IN in
provider/index.ts) and the first-run screen say lembas login <address>.
What the server says about a model is what the CLI knows: its context window
(contextWindow, no discovery), its efforts, vision, and its capacity
(capacity.group, single_session — the subagent capacity rule reads only
these). Embeddings go to the server's /v1/embeddings, by an embedding model's
served id. The entry's own models: may still adjust what the server says about
a model; it is rarely needed.
Settings while running (src/config/settings.ts, src/settings.ts)
One list, SETTINGS, is read three ways: /settings, lembas config get|set|list, and the agent's settings tool. Each entry has a kind, the scopes
it may be set at (session, global, project), whether the agent may
change it (with approval; a less strict mode is asked every time), whether it
needs /reload, and what it is when unset. A value is resolved from the session,
then the project's file, then the global file, then the fallback. Writing uses
yaml's parseDocument … setIn, so the user's comments and layout survive.
Not in the list, on purpose: permission rules, the hardline, MCP servers,
the login, the update source and key, and settings_tool itself. Those are
edited by hand, never by the agent.
JSON Schemas
schema/config.schema.json and schema/connections.schema.json are generated
from the zod schemas (config/jsonschema.ts) by bun run schema, and written
beside a user's config by lembas config schema, so an editor with a YAML
language server completes and checks keys. Regenerate them in the same commit as
a schema change; a test compares them.
Adding a key
- Add it to the zod schema in
config/schema.tswith a.describe()— the description is what the JSON Schema and the editor show. - Decide whether a project may set it. If a cloned repository could use it to
weaken a check, redirect traffic or a key, or speak in the user's voice, add
it to
GLOBAL_ONLY. - If it may be changed while running, add it to
SETTINGSwith its scopes, and say whether the agent may change it. The default is no. - Write its reader in the same change, with a test that reads the effect — a key the schema accepts and nothing reads is a promise the program does not keep.
bun run schema, and document it on the website's configuration page.