Deployment & Secrets
Packaging to .bxa, and why secrets never live in generated source.
On this page
Deployment & Secrets
Secrets never enter the artifact - they are supplied to the process, at the far right of this chain:
flowchart LR
P["your project"] -->|"bxAgents build"| B[".build/<br/>app/ public/ lib/ runtime/"]
B -->|"bxAgents package"| A["dist/name-version.bxa<br/>+ .sha256 + redacted manifest.json"]
A -->|"bxAgents deploy"| T["a target:<br/>local / ssh / ftp / sftp<br/>docker / digitalocean"]
T --> RUN["boxlang-miniserver runs in the unzipped folder"]
ENV["environment variables<br/>OPENAI_API_KEY, CLAUDE_API_KEY,<br/>every *EnvVar a gateway names"] -->|"read at RUNTIME by bx-ai"| RUN
style A fill:#eaf6ec,stroke:#155724
style ENV fill:#fff3cd,stroke:#856404
Nothing on the left of ENV ever holds a secret value: .env/dotfiles are excluded from the zip unconditionally, and the manifest is redacted on top of never carrying one.
Packaging
bxAgents package zips the built app into a portable .bxa artifact. What is zipped is the packaging set of the ColdBox BoxLang template: app/, lib/, public/, runtime/ (without its logs, class cache and the other files a running server creates in its home), boxlang_modules/ and miniserver.json, all from .build/ (see what is in .build). manifest.json and the build's work folders are not part of it.
bxAgents package --version=1.0.0
produces, in dist/:
{agentName}-{version}.bxa- the zipped app{agentName}-{version}.bxa.sha256- its checksummanifest.json- a redacted copy of the build manifest (see below)
Packaging twice in a row over the same build produces byte-identical zip bytes (deterministic entry order/timestamps) - useful for verifying a CI-built artifact matches a locally-built one.
The .bxa is relocatable: it carries every file the agent reads at runtime (including each agent node's own instructions.md, copied into agent/ at build time), and the generated agent/GeneratedAgentFactory.bx resolves those paths relative to its own location on disk rather than the absolute paths of the machine that built it. So a .bxa built on CI runs unchanged when unzipped anywhere else - which also means a .bxaignore broad enough to match *.md will strip the agent's own instructions out of the artifact.
package requires a prior build (it reads .build/manifest.json) and refuses to run - producing no .bxa - if manifestVersion is unset or malformed.
Excluding files: .bxaignore
An optional .bxaignore at the project root, one glob pattern per line (#-prefixed lines are comments), excludes matching paths from the packaged .bxa. Patterns are matched against paths inside .build (so app/skills/old/, not skills/old/, which is where they were matched before the app and the web root were split): a pattern with no / matches at any depth, one with a / is anchored at the root of .build, a trailing / names a folder and everything under it, and * also crosses /.
# .bxaignore
*.log
scratch/
This is on top of a hard-coded, always-on exclusion of .env/.env.*/dotfiles at the packaging layer - even if .bxaignore doesn't mention them, and even if they somehow ended up inside .build, they never make it into the zip.
Secret redaction
Secrets are never written into manifest.json in the first place - the manifest's agent block only ever contains safe, structural fields (name, description, model, environment). As defense-in-depth, package additionally walks the manifest recursively and replaces any struct key that looks like a secret with [REDACTED]:
(apikey | api_key | token | secret | password)$ (case-insensitive, any prefix)
This guards against a future field - or a caller passing a richer struct into package some other way - accidentally leaking a value, even though today's manifest never puts one there to begin with.
Where real secrets live
BxAgents never resolves, stores, or embeds provider API keys, tokens, or passwords anywhere in a build or package. That's entirely bx-ai's job, at runtime: it reads them from the process environment following its own <PROVIDER>_API_KEY-style convention (e.g. OPENAI_API_KEY, CLAUDE_API_KEY). Set them however you normally manage secrets for a deployed process - an OS environment variable or your platform's secret manager. For local development, BoxLang and boxlang-miniserver both load a .env from the project root themselves, so bxAgents new's .env is the easy place for them; BxAgents never reads, copies or embeds it, and it is never committed (the scaffolded .gitignore covers it) or packaged. A deployed .bxa has no .env, so give that process real environment variables.
export OPENAI_API_KEY=sk-...
bxAgents serve
Variables BxAgents reads itself
None of these holds a provider secret. BXAGENTS_TOKEN is the one credential, and it is only ever read from the environment of the machine you type on.
| Variable | Used by | Effect |
|---|---|---|
BX_AGENTS_ENV | build | The active environment when --environment is not given (default development). See Environments. |
BXAGENTS_DB | the app, chat, token, notes, sessions, stats | The chat database file. serve sets it to the chat.db of the data home (~/.bxagents/<agent name>/chat.db by default). Without it, the app asks the data home for the file, so a deployed app keeps it in its own data home too; database.path is only the fallback for an agent with no name. See the SQLite store. |
BXAGENTS_TOKEN | chat --connect | The token to send, instead of --token. |
BXAGENTS_USER_CONFIG | build, the app at start, chat, extensions | Another file in place of ~/.bxagents/Agent.yml, the person's file for every agent. |
BXAGENTS_SKILLS_URL | skills | Another skills registry, instead of --registry. |
BXAGENTS_BANNER, BXAGENTS_BANNER_THEME | --help, new | off hides the banner; a theme name pins its colors. |
BXAGENTS_ plus a name | deploy | The only prefix a deploy/ entry may name for a password or passphrase (passwordEnvVar, passphraseEnvVar). |
Secrets people hand to a running agent
Environment variables are for what you deploy with. For a key or login that a person hands to a running agent (an API key for Gmail, a ticket system, a customer's own token), use the vault: values are sealed in the chat database, added from the terminal chat, the web page or bxAgents vault, and read by the runtime at the moment a tool or MCP server needs one. They are never part of a build, a package or the manifest. Set BXAGENTS_VAULT_KEY in the environment of the deployed process so the key does not sit beside the database.
A service that asks each person to sign in (connect) seals the tokens it is given with the same key. Set BXAGENTS_PUBLIC_URL to the address people reach the server at (https://agent.example.com), and register <that address>/__bxagents/connect/callback with the provider: that is where the browser comes back after a sign in.
Deploying
bxAgents deploy --destination=/path/to/somewhere # local, flag-only shorthand
bxAgents deploy --name=production # any target, via deploy/production.bx
Six pluggable targets ship out of the box - local (copy the newest .bxa somewhere), ssh (ship it to a bare server), ftp/sftp (ship it via the real bx-ftp module, bundled with BxAgents), docker (build/push a container image), and digitalocean (deploy to a DigitalOcean App Platform app) - see deploy/ for the full config shape of each and CLI Reference for the CLI flags.
No target ever reads a secret from deploy/* config - credentials (registry passwords, SSH keys, the DigitalOcean API token) are always resolved from environment variables at deploy time, the same "secrets stay external" rule as everywhere else in this doc. See deploy/ for the exact env var each target expects.
To run a packaged .bxa somewhere else manually: unzip it into a folder (its path must not hold a space: the boxlang-miniserver launcher script does not quote it), go into that folder, and start the server there with the runtime as its home, setting whatever secret environment variables that deployment needs:
cd /srv/my-agent
BOXLANG_HOME="$PWD/runtime" boxlang-miniserver miniserver.json
miniserver.json names everything by paths relative to the folder it is in (webRoot: public, configPath: runtime/boxlang.json, serverHome: runtime), so the same file serves the app wherever it is unzipped, and only public/ is reachable from outside. It binds 127.0.0.1:8080 as packaged: edit host (and port) for the machine it runs on, or put a reverse proxy in front.