The Build Pipeline
The fixed phase sequence that turns a project into a ColdBox application.
On this page
The Build Pipeline
bxAgents build runs a fixed sequence of phases, once, producing a plain ColdBox application laid out like the ColdBox BoxLang application template: the code in .build/app, the web root in .build/public. Nothing here runs again at request time - that's the whole point of build-time assembly. This page walks the phases in the exact order BuildPipeline.bx runs them.
What is in .build, and what is served
.build/
miniserver.json how boxlang-miniserver finds everything below (paths relative to .build)
manifest.json the internal manifest (not served, not packaged)
app/ the generated code: handlers, config, agent/, tools/, skills/, models/, interceptors/, modules/bxagentsui/ ...
Application.bx the template's guard: `abort;`
public/ the web root, and the ONLY folder that is served
Application.bx the app's Application.bx (see conventions/application-bx.md)
index.bxm the front controller every request is rewritten to
robots.txt favicon.ico
includes/ images/, i18n/, bxagentsui/build/assets/ (the web page's scripts and styles)
lib/ coldbox/, modules/ (qb, cbsecurity, cbauth, cbmailservices), java/
runtime/ the BoxLang home
boxlang.json the template's engine config
modules/bx-agents/ a copy of the bxagents module, under its installed folder name: the ONLY module the served app loads
global/ lib/ logs/
boxlang_modules/ the project's own installed BoxLang modules
bxAgents serve starts boxlang-miniserver in .build with BOXLANG_HOME=.build/runtime, using .build/miniserver.json:
{ "port": 8080, "host": "127.0.0.1", "webRoot": "public", "configPath": "runtime/boxlang.json",
"serverHome": "runtime", "rewrites": true, "rewriteFileName": "index.bxm", "healthCheck": true,
"passPredicate": "regex( '^/index\\.bxm(/.*)?$' )" }
- Only
public/is a web root. Nothing inapp/,lib/,runtime/orboxlang_modules/can be fetched by its address:/config/agent-settings.json,/project/Agent.yml,/agent/instructions.mdand a listing of/config/were all downloadable without a token before this layout, and answer 404 now. An address nothing routes is a small JSON404, not an error page. - Only
index.bxmruns. The server's default runs any.bxor.bxmunder the web root as a request; thepassPredicatelimits that to the front controller, so a class underapp/is not callable by address. - Only the
bxagentsmodule loads. The module is copied intoruntime/modulesas it is installed, folder name included (bx-module install bx-agentsand a dev build both usebx-agents), with the BoxLang modules bundled inside it. The internal BoxLang mapping remainsbxagents. Any other folder there is removed, andruntime/is the BoxLang home, so the machine's own~/.boxlang/modulesis never read. The copy is skipped while a stamp (the module'sbox.jsonand the hash of its jars) is unchanged. - The paths are relative, so a copy of
.buildanywhere (a packaged.bxaunzipped on another machine) is served by starting the server in it. A folder name with a space in it does not work: theboxlang-miniserverlauncher script does not quoteBOXLANG_HOME. public/includes/shows its file names (the server lists a folder that has no index file, andminiserver.jsonhas no switch for it); it holds only what the browser is meant to load.
The template is carried inside the module as a pinned snapshot (src/main/bx/templates/coldbox-boxlang, its VERSION names the version and the exact commit), so a build never reads the network. Its public/ files (index.bxm, robots.txt, favicon.ico, includes/), runtime/boxlang.json and app/Application.bx are laid out unchanged, apart from two settings in runtime/boxlang.json: whitespace compression is off, and clearClassFilesOnStartup is off so repeated starts can reuse the runtime's compiled classes. public/Application.bx is derived from the template's and changed (a thin class extending the generated base, see Application.bx). On BoxLang 1.19.0 a native SSE() stream is unaffected by the whitespace setting (14 frames with it on or off); only a hand-written writeOutput event stream loses its blank lines when it is on, so that line is a safety net.
flowchart TD
A["1 Β· Resolve config<br/><small>AgentConfigResolver</small>"] --> B["2 Β· Discover<br/><small>ProjectDiscoverer</small>"]
B --> C{"3 Β· Validate<br/><small>ProjectValidator</small>"}
C -->|"any error"| X["Build throws.<br/>.build/app is never written or touched"]
C -->|"clean<br/><small>warnings never block</small>"| D["4 Β· Generate"]
D --> D1["1 Interceptors"] --> D2["2 Gateways"] --> D3["3 MCP"] --> D4["4 Router"]
D4 --> D5["5 Agent API"] --> D6["6 Web UI"] --> D7["7 Extensions"] --> D8["8 Core app skeleton"] --> D9["9 Tools/skills copy"]
D9 --> D10["10 Project modules"] --> D11["11 Runtime libraries"] --> D12["12 Scheduler"]
D12 --> E["5 Β· Normalize + write<br/><small>ManifestNormalizer</small>"]
E --> F[".build/manifest.json<br/>+ .build/app and .build/public - a plain ColdBox application"]
style C fill:#fff3cd,stroke:#856404
style X fill:#f8d7da,stroke:#721c24
style F fill:#d4edda,stroke:#155724
Before phase 1, build restores any skill that .agents/skills.lock.json lists and the disk lacks, and any extension that extensions.lock.json lists and the disk lacks; a failed restore stops the build.
Validation is the gate: it collects every error rather than failing fast, and nothing is generated until it comes back clean.
(Packaging into a .bxa is a deliberately separate step - see Deployment & Secrets - so a fast build β inspect β build again loop never pays a packaging cost it doesn't need.)
1. Resolve config
AgentConfigResolver loads the agent definition (Agent.yml, or the class-based Agent.bx), applies the active environment's overrides (the environments: block of an Agent.yml, or the override method and configure() of an Agent.bx), then deep-merges in boxlang.json/boxlang-{env}.json/miniserver.json/miniserver-{env}.json if present. The person's own files then go over the result for the root agent: ~/.bxagents/Agent.yml and the agent's own Agent.yml in its data home (layered settings). Produces the single resolved config struct every later phase reads from.
2. Discover
ProjectDiscoverer walks the project root and enumerates every convention folder (tools/, skills/ and the registry's .agents/skills/, subagents/, gateways/, mcp/, interceptors/, modules/) into raw { name, path, type } entries. schedules/*.bx are listed the same way, one entry per BoxLang scheduler file. Pure discovery - no interpretation of file contents happens yet.
3. Validate
ProjectValidator runs every validator and collects every error (never fail-fast) plus any warnings: duplicate tool/skill/model/subagent names, duplicate agent names across the whole subagent tree (see subagents/), circular subagent/module references, the two gateway entry shapes, remote MCP config completeness, and model/provider validity. If any errors were collected, the build throws immediately here - no .build/app is written or touched. Warnings (e.g. a schedules/ folder with no Scheduler.bx in it) never block the build.
4. Generate
Only reached once validation is clean. Any .build/app from an earlier build is deleted first, then the template is laid out: its public/ (replacing the old one), its runtime/boxlang.json, app/Application.bx and the empty folders its conventions name. In order:
- Interceptors -
InterceptorSplittercopiesagent-scope interceptors into.build/app/interceptors,runtime-scope ones into a separate.build/runtime-interceptorsdirectory, outside the app (BxAgents does not register those for you). - Gateways -
GatewayGeneratoremitsaiGatewayRegistry().register(...)statements for channel-adapter entries, and writes a small.build/app/handlers/*.bxwebhook handler for eachwhatsapp-cloud,teams,twilioorgithubentry. If any entry is a push-style gateway (e.g.type: "telegram"), it also produces the start-up statement that builds a single bx-aiGatewaySession(bundling every push-style gateway) bound to the project's root agent. - MCP -
McpGeneratorcopies localmcp/*servers into.build/app/mcpand emits theirmcpServer(...).registerTool(...)registration statements. - Router -
RouterGeneratorwrites.build/app/config/Router.bx: the reserved/__bxagentsagent API (atagentApi.path, unlessagentApi.enabledisfalse), the same four turn routes under the path of eachexposes: "agent"entry, oneroute(path).toMCP(...)perexposes: "mcp"entry, the cbSecurity middleware foragentApi.allowedIPsandagentApi.rateLimitwhen set, a singleroute("/gateways").toAiGateway()if the project has any channel-adapter gateway, and one webhook route perwhatsapp-cloud(GET+POST),teams,twilioorgithubpush-style gateway present. - Agent API -
AgentApiGeneratorwrites.build/app/handlers/AgentApi.bx, every action of the agent API (invoke,stream,batch,info, and the run-control, conversation, notes, command and token actions such asevents,cancel,steer,resume,sessionsandcommand), all served by the one handler. Skipped whenagentApi.enabledisfalse. - Web UI -
WebUiGeneratorruns for anyexposes: "webui"entry, installing the web app module at<appDir>/modules/bxagentsuiwith its settings inconfig/bxagentsui.json(mounted at the entry'spath, a client of the agent API, so no handler of its own),models/ChatDb.bx(the sign-in accounts and the store's forward-only migrations, built at boot by a start-up statement rather than on whichever request touches the database first) and the user models (User,UserService,PasswordHasher).apiKeyEnvVarbecomes the agent API's shared secret. Whenusersare declared it also writes the account seeder, the sign-in form (config/bxagentsui-login.html, served at<path>/login.html),interceptors/WebUiLoginGate.bxandhandlers/ChatAuth.bx. It returns the resolved database config, which the next step needs. - Extensions -
ExtensionsGeneratorcopies the project'sextensions/folder to.build/app/extensionsand writesconfig/extensions.jsonfrom theextensions:block ofAgent.yml, so the served agent loads them. Skipped when there is noextensions/folder. - Core app skeleton -
ColdBoxAppGeneratorwrites the generated baseapp/bxagents/Application.bx(see Application.bx),public/Application.bx(derived from the template's own file, and ending as a thin class that extends the base: what is derived and what is changed),app/bxagents/Scheduler.bx,config/Coldbox.bx,config/WireBox.bx,handlers/NotFound.bxandagent/GeneratedAgentFactory.bx, threading in every statement gathered above (gateway registrations, theGatewaySessionstart, MCP registrations, the web UI's store warm-up and account seeding, and - iftools/has any files - a bareaiToolRegistry().scan("app.tools")call: bx-ai expands the dotted path against a mapping,/apphere, so it must be a mapping path and not one relative to the app) into the base'safter(), whichonApplicationStart()calls once ColdBox has loaded. Class paths in generated code go through the template's/appmapping (app.schedules.Nightly,app.agent.GeneratedAgentFactory,app.interceptors.AuditLogger). Interceptors are registered there too, onegetInterceptorService().register(...)per agent-scope interceptor and web UI gate: the generated config declares nointerceptorsarray and registers them this way, which works (the note onconfig/Coldbox.bxbelow says why the array's old failure was measured against a file ColdBox never loaded). Every generated agent also now always receives a checkpointer (withCheckpointer(...), defaulting to acache-backedaiMemory()if the project declares nocheckpointerconfig and the class set none of its own) - without one, human-in-the-loop approval flows through any gateway other thanclifail outright.config/WireBox.bxmaps every agent in the tree (root + every subagent) under its own declaredname, not just the fixed root"GeneratedAgent"alias - see schedules/. Each agent node'sinstructions.mdis copied into the app as part of this step, mirroring the source layout underagent/- the root project's to.build/app/agent/instructions.md, each subagent's to.build/app/agent/subagents/<name>/instructions.md- so every node keeps its own and the built app carries the file it reads at runtime. The factory reads all three of its runtime paths (instructions.md, its owntools/, and any class-based agent's copiedAgent.bx) through a small generatedresolveAppPath()helper that resolves them relative to the factory's own location on disk, falling back to the build-time absolute path if that self-location doesn't resolve - which is what makes a packaged.bxagenuinely relocatable rather than runnable only on the machine that built it. For a project with awebuiexposure it also turns session management on, registers the SQLite datasource (naming it as the app default viathis.datasource), creates the database's parent directory inonApplicationStart()- SQLite creates the file but never the folder holding it - and pins qb's grammar inconfig/Coldbox.bx. That file is calledColdbox.bx(ColdBox's convention) and assignsvariables.coldboxandvariables.moduleSettings: it used to be calledColdBox.bx, which ColdBox never loads on a case-sensitive file system, with unscoped assignments that are local toconfigure()in BoxLang, so the generated app name and qb grammar never applied before. It also setsmodulesExternalLocationto/modules(ColdBox finds its modules in.build/lib/modules) anddefaultEventandinvalidEventHandlerto the generatedNotFound.index, the JSON 404. - Tools/skills copy -
ToolsSkillsCopierwipes and rewrites.build/app/toolsand.build/app/skillsverbatim from your project's own folders, adding the registry skills from.agents/skills/to the app'sskills/. - Project modules -
BoxLangModulesCopiercopies the BoxLang modules installed in the project'sboxlang_modules/into.build/boxlang_modules, leaving out any thatbox.jsonlists only as a development dependency. Skipped when there is noboxlang_modules/folder. - Runtime libraries -
RuntimeLibsCopiercopies the ColdBox runtime bundled inside BxAgents into.build/lib:coldbox/plusmodules/qb,modules/cbsecurity,modules/cbauth,modules/cbmailservicesand their dependencies. Alib/folder in your project (same layout) is copied afterwards and wins, which is how you add or override a library. The bundled copy exists only in an installed or built module, so a source checkout skips this step with a warning. - Schedulers -
SchedulerGeneratorcopies eachschedules/*.bxto.build/app/schedules/<Name>.bx, addingextends="app.bxagents.Scheduler"to a class that names no parent (bxagents.Scheduler, the name the docs use, means the same class). The base already lists them inthis.schedulers, so BoxLang starts them with the app. - The bxagents module and the server config -
ModuleCopiercopies the installedbx-agentsmodule into.build/runtime/modules/bx-agents(to a work folder, then renamed, so an interrupted copy never carries the stamp; skipped while the stamp is unchanged), andMiniServerJsonwrites.build/miniserver.json(port 8080 on127.0.0.1;serverewrites it with the port and host asked for). A source checkout has no installed module: the build says so, andBXAGENTS_MODULE_DIRnames the built one (build/modules/bx-agents).
5. Normalize + write the manifest
ManifestNormalizer produces the canonical, hash-stamped internal manifest from the discovery + resolved-config data, and the pipeline writes it to .build/manifest.json.
Idempotency
Rebuilding an unchanged project produces byte-identical output, down to the manifest's per-file content hashes - the entire point of paying the assembly cost once, at build time, rather than deferring any of this work into request handling.