Creates a new ExpressBrick.
The options for the ExpressBrick.
Interface for the options of ExpressBrick. It extends from BrickOptions and adds properties specific to ExpressBrick.
OptionalbuiltinMiddleware?: { json: boolean; urlencoded: boolean }An object specifying whether to use built-in middleware functions.
Whether to use the built-in JSON middleware.
Whether to use the built-in URL-encoded middleware.
Optionaldatabase?: KeyValueStoreThe key-value store of the Brick instance. Defaults to an in-memory store.
Optionalhost?: stringThe host on which the Express server will listen.
Optionalid?: stringThe unique identifier of the Brick instance. If not provided, a random UUID will be generated.
Optionalintelligence?: IntelligenceThe Intelligence of the Brick instance. This is used to manage the AI capabilities of the Brick.
OptionallogJSON?: booleanA boolean indicating whether the logs should be in JSON format.
OptionallogLevel?: LevelThe log level of the Brick instance. This determines the level of detail of the logs.
Optionalmiddleware?: RequestHandler<ParamsDictionary, any, any, ParsedQs, Record<string, any>>[]An array of middleware functions to use in the Express application.
Optionalname?: stringThe name of the Brick instance. If not provided, the id will be used as the name.
OptionalpinoOptions?: LoggerOptions<never>The options for the pino logger used by the Brick instance.
Optionalport?: numberThe port on which the Express server will listen.
Optionalroutes?: { handler: (req: Request, res: Response) => void; method: string; path: string }[]An array of routes that the Express server will handle.
Optionalstructure?: StructureThe parent Structure of the Brick, if any.
Supports all BrickOptions as well as ExpressBrickOptions.
OptionalaiThe intelligence of the Brick instance. This is used to manage the AI capabilities of the Brick.
The key-value store of the Brick instance.
The event emitter of the Brick instance. This is used to emit events that occur in the Brick, such as the running of a program.
The Express application instance.
The unique identifier of the Brick instance.
The logger used by the Brick instance. This is used to log information about the operation of the Brick.
The name of the Brick instance.
OptionalserverThe HTTP server instance.
OptionalstructureThe parent Structure of the Brick instance, if any.
Accumulates token usage/cost across every ask() call on this Brick.
Starts as a .child() of this.ai.usage when an Intelligence is
configured (so totals also roll up there), or standalone otherwise.
Rebound as a .child() of the parent Structure's usage when added
to one via Structure.add().
Returns the private map of programs.
Runs a prompt through this Brick's ai, offering its programs (via
Brick.tools) plus any tools attached via Brick.use.
Optionaloptions: AskOptionsRegisters GET <path> (default /ask/stream) streaming with askStreamRoute.
Defaults to this brick as the target.
Removes a program from the private map of programs by its name.
The name of the program to remove.
Toggles the keep alive flag of the Brick instance, which will prevent the Node process from exiting
A boolean indicating whether to turn the keep alive flag on or off.
Adds a program to the private map of programs.
The program to add.
Runs a program by its name with a given payload.
The name of the program to run.
The payload to pass to the program.
The result of the program.
Schedules a Task to run on a given schedule. This is a wrapper around the cron package.
The Task to schedule.
The scheduled task.
Returns a Task by its name.
Exposes every registered program as a ToolDefinition, each
execute calling this.run(program.name, input).
Every tool this Brick offers: its programs (via Brick.tools) plus anything attached via Brick.use.
Attaches external tool arrays (e.g. MCP-sourced tools) to this Brick,
included whenever ask() builds its tool list.
Class representing a brick that sets up an Express server. It extends from the intellibrix!Brick class.
Access all of Express's functionality through the ExpressBrick.express property.
Example