runApp
runApp
The main entry point for a LiveWire application. It prints the ASCII banner, runs
the prewarm function (if defined), creates a JobContext, prints a random tip,
invokes the registered entry function, and starts the underlying SignalWire agent.
This mirrors cli.runApp() from @livekit/agents-js. It is also available as
cli.runApp.
Parameters
options
The agent definition returned by defineAgent(), or an object
with entry and optional prewarm functions.
Returns
void — This function runs the agent lifecycle asynchronously.
Lifecycle
- Prints the LiveWire ASCII banner to stderr.
- If the agent definition has a
prewarmfunction, calls it with a freshJobProcessinstance. Logs an informational message noting that warm process pools are not needed on SignalWire. - Creates a
JobContext. - Prints a random “Did you know?” tip to stderr.
- Calls the
entryfunction with theJobContext. If the entry function is async, it is awaited. - After entry completes, starts the underlying SignalWire agent if one was bound.
Example
defineAgent
Wraps an entry function (and optional prewarm function) into an agent definition
object that can be passed to runApp(). This mirrors defineAgent() from
@livekit/agents-js.
Parameters
entry
The main entry function for the agent. Receives a JobContext and
should create an Agent, an AgentSession, and call session.start().
prewarm
Optional setup function called before the entry function. Receives a
JobProcess whose userData object can be used to share state
with the entry function.
Returns
The same object, for passing to runApp().