Class: UserInput
Defined in: chat/src/user-input.ts:24
Processable Interface
The fundamental interface that all Baleybots primitives and patterns implement. This is what enables universal composability - any Processable can be used anywhere a Baleybot is expected.
Example
// All of these implement Processable:
const bot: Processable = Baleybot.create({ ... });
const chain: Processable = Pipeline.from().chain([...]).build();
const refinement: Processable = loop({ body: bot, condition, maxIterations: 5 });
// With type inference from Zod schema:
const bot = Baleybot.create({
finalResponseSchema: z.object({ sentiment: z.string() })
});
const result = await bot.process('text'); // result is typed as { sentiment: string }
// With input/output type constraints:
const typedBot: Processable<string, { sentiment: string }> = bot;
Implements
Processable<unknown,UserMessage>
Constructors
Constructor
new UserInput():
UserInput
Defined in: chat/src/user-input.ts:29
Returns
UserInput
Methods
getBotNames()
getBotNames():
string[]
Defined in: chat/src/user-input.ts:77
Get all bot names in this processable (including nested processables)
Returns
string[]
Array of bot names that can emit events
Example
const pipeline = pipeline()
.step(chatBot)
.parallel({ sentiment: sentimentBot, tone: toneBot })
.build();
const botNames = pipeline.getBotNames();
// ['assistant', 'sentiment', 'tone']
Implementation of
getChildren()
getChildren():
ProcessableChild[]
Defined in: chat/src/user-input.ts:89
A leaf — the turn boundary where a person supplies the next message, with nothing composed beneath it.
Returns
ProcessableChild[]
Implementation of
getId()
getId():
string
Defined in: chat/src/user-input.ts:64
Get the unique ID of this processable instance
Each processable has a unique ID that persists for its lifetime. IDs are useful for:
- Filtering specific instances in subscriptions
- Tracking performance metrics per instance
- Debugging nested compositions
Returns
string
Unique ID string
Example
const bot1 = Baleybot.create({ name: 'analyzer' });
const bot2 = Baleybot.create({ name: 'analyzer' });
bot1.getId(); // 'baleybot-1-a3f891'
bot2.getId(); // 'baleybot-2-b4c2d3'
// Same semantic name, different IDs
bot1.getName(); // 'analyzer'
bot2.getName(); // 'analyzer'
Implementation of
getName()
getName():
string
Defined in: chat/src/user-input.ts:81
What this processable is called. A label, not a key.
Stable across runs, which getId() is not — an id embeds a timestamp
and changes on every restart. That is what makes a name safe to print in
a log, show on a node, or hand to a merge function.
Not unique. Two bots may both be called 'analyzer', and every
unnamed loop() reports 'loop'. Anything that must address exactly one
instance uses getId(), or an address — never this. An earlier version
of this contract promised uniqueness and had unnamed primitives return
their instance id to deliver it; that put generated ids into
ParallelMergeInput.botNames and graph node labels, where a name was
wanted, and made both change on every restart.
Never returns an empty string: where no name was configured, the primitive reports its kind.
Returns
string
Implementation of
process()
process(
_context?,_options?):Promise<UserMessage>
Defined in: chat/src/user-input.ts:37
Process - blocks until send() provides a message
Parameters
_context?
unknown
_options?
ProcessOptions
Returns
Promise<UserMessage>
Implementation of
send()
send(
message):void
Defined in: chat/src/user-input.ts:55
Send a message - unblocks process() or queues for next call. Accepts plain text or multimodal input (files, images, etc.).
Parameters
message
UserMessage
Returns
void
subscribeToAll()
subscribeToAll():
Subscription
Defined in: chat/src/user-input.ts:68
Subscribe to categorized events from this processable and all nested processables
Provides fine-grained control over event handling with categorized callbacks:
- onStreamEvent: Real-time content streaming (text_delta, structured_output_delta, tool_call_arguments_delta)
- onProgressUpdate: Status updates (tool_execution_start, tool_call_stream_start, tool_call_stream_complete, reasoning)
- onComplete: Emitted when each bot finishes processing with final output
- onError: Error events (error, tool_validation_error)
Callbacks now receive both bot ID and name for precise identification:
- botId: Unique instance identifier (e.g., 'baleybot-1-a3f891')
- botName: Semantic name (e.g., 'analyzer', 'router', 'processor')
Returns
Subscription
Subscription object with unsubscribe method
Examples
Subscribe to all events
const subscription = pipeline.subscribeToAll({
onStreamEvent(botId, botName, event) {
// Real-time streaming content
if (event.type === 'text_delta') {
console.log(`[${botId}] ${botName}:`, event.content);
}
},
onProgressUpdate(botId, botName, event) {
// Status updates
if (event.type === 'tool_execution_start') {
console.log(`${botName} (${botId}) executing ${event.toolName}`);
}
},
onComplete(botId, botName, output) {
// Bot finished processing
console.log(`${botName} completed:`, output);
},
onError(botId, botName, event) {
// Errors
console.error(`${botName} error:`, event);
}
});
await pipeline.process('input');
subscription.unsubscribe();
Filter specific bots by name or ID
const subscription = pipeline.subscribeToAll({
onStreamEvent(botId, botName, event) {
console.log(`${botName}:`, event);
},
omit: ['chat-step', 'processor-42-8a3f91'] // Filter by name or ID
});