@exulu/backend source. For constructor options, see Configuration.
Constructor
generateSync()
Runs a complete, non-streaming generation — waits for the full response before returning. Used for background jobs, evals, API-triggered runs, and agent-as-tool execution. Internally uses the AI-SDKgenerateText function.
A single-turn prompt string. Mutually exclusive with
inputMessages — passing both throws.Multi-turn message array. Mutually exclusive with
prompt. When a session is also provided, IMP loads and prepends the session’s stored history.The Vercel AI-SDK
LanguageModel instance to call. Obtain it by calling provider.config.model.create({ apiKey }) with the resolved API key from resolveModel().The calling user. Used for memory retrieval, access control, personalization (first name, last name, email in the system prompt), and token statistics.
Session ID. When set, IMP loads the full ordered message history from the
agent_messages table, runs context-budget occupancy checks, and applies compaction checkpointing before calling the model.The database agent record. When
agent.memory is set to a context ID, IMP performs a hybrid search over that context and injects the top results as pre-fetched context in the system prompt.System prompt override. When omitted, defaults to a generic helpful-assistant prompt. IMP always appends its generic context (date, time, user personalization, session file info) after your instructions.
Express request object — forwarded to tool-conversion utilities that need the raw request (for example, for request-scoped tool configs).
Tools available to the agent for this run. Converted to AI-SDK format via the internal
convertExuluToolsToAiSdkTools pipeline, which also injects framework tools (agentic context search, session item tools).Skills available to the agent. Listed in the system prompt so the model knows which skill folders to read from the session filesystem.
Tool call IDs pre-approved for this run — used when resuming from a user-approval step.
The full registered tool set. Required by tool-conversion utilities that need to resolve agent-as-tool wiring.
Admin-set tool configuration values for this agent — the runtime values for the
config params declared on each ExuluTool.Resolved API key for the provider. Passed directly to tool-conversion utilities; the
languageModel you provide already has the key baked in.Context instances available for memory retrieval and context-search tools.
The app’s
ExuluConfig. Needed for storage access inside tools and processors called during this run.Maximum AI-SDK agentic steps (tool-call turns). When omitted, IMP derives a step budget from the agent record’s configured step limit.
({ inputTokens, outputTokens }) => Promise<void> | void — callback invoked after the run completes with the total token usage. Useful for billing hooks.Context-window size override in tokens. Used by the context-budget guard and the retrieval-budget guard. When omitted, falls back to
provider.maxContextLength.Tool IDs to suppress for this run, in addition to any admin-level disabling.
Optional usage-statistics attribution recorded with the run — an object with
label and trigger strings used in analytics.The model’s text response as a string, or a structured object when the call produced a structured output.
generateStream()
Runs a streaming generation, returning the AI-SDK stream object alongside the reconstructed message arrays. Used by the platform’s chat endpoint — call this when you need to pipe a response to the client in real time. Internally uses the AI-SDKstreamText function.
The new user message to process.
generateStream appends it to the loaded session history before calling the model.Pre-loaded message history from the client side, used when
session is not provided.generateSync — see above for their descriptions.
The AI-SDK
streamText result. Pipe stream.toDataStreamResponse() to the HTTP response for the standard chat streaming protocol.The full validated message array that was sent to the model, after history loading, deduplication, stale-approval reconciliation, and file-part processing.
The history that was loaded before appending the new message — useful for persisting the session after the stream completes.
tool()
Exports the provider as anExuluTool that an orchestrating agent can call. The generated tool accepts a prompt (the question to ask the sub-agent) and an information field (summary of relevant session context), then runs generateSync and returns the text response.
Database ID (UUID) of the agent record to load. The method resolves the agent via
exuluApp.get().agent(instance) and returns null when not found.All registered providers — used when resolving the sub-agent’s model and enabled tools.
All registered contexts — used for tool enablement and memory retrieval inside the sub-agent’s run.
An
ExuluTool of type "agent" that the orchestrating agent can call, or null when the agent record was not found.tool() requires the multi-agent-tooling entitlement in your EXULU_ENTERPRISE_LICENSE. Without it, the method logs a warning and continues — but the returned tool, if non-null, will fail at call time because the sub-agent model resolution will lack a valid key. Set the license before wiring multi-agent flows.Getters
providerName
this.provider (the string you passed to the constructor) when config.model.create is defined; returns an empty string otherwise.
modelName
this.config.name when config.model.create is defined; returns an empty string otherwise.