Interface: Processable<TInput, TOutput>
Defined in: core/dist/types/types.d.ts:174
What every Baleybots primitive implements, so 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(step1, step2);
const refinement: Processable = loop({ body: bot, condition, maxIterations: 5 });
// With type inference from Zod schema:
const bot = Baleybot.create({
name: 'sentiment',
output: Output.object({ schema: 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;
Type Parameters
TInput
TInput = unknown
TOutput
TOutput = unknown
The output type, or a Zod schema to infer it from
Properties
emitsInvocationEvents?
readonlyoptionalemitsInvocationEvents?:boolean
Defined in: core/dist/types/types.d.ts:178
All events from one process() call reach its own options.onToken callback. Enables isolated step events when the same instance runs concurrently. Subscription-only implementations must not overlap observed invocations.
forwardsStepEvents?
readonlyoptionalforwardsStepEvents?:boolean
Defined in: core/dist/types/types.d.ts:297
True when this processable forwards its children's stream events to
ProcessOptions.hooks.onStepEvent itself.
A composite that intercepts a child's stream — today only graph() —
declares this so an enclosing composite knows not to also capture and
replay the same events off subscribeToAll. Without the declaration,
nesting two interceptors delivers every leaf event once per level: the
inner fires it live with precise attribution, the outer replays its
buffered copy at step end. Declared rather than sniffed (no
instanceof, no structural probe), per ASK-DONT-SNIFF.
Absent means false: the composite passes hooks through (or fires only boundaries) and its enclosing graph captures leaf streams on its behalf.
Methods
describe()
describe():
ProcessableStructure
Defined in: core/dist/types/types.d.ts:281
Everything this node says about itself beyond running: its children, the wiring composition does not imply, and the capabilities it has — where it runs, what it is for a journal, which family it belongs to, what it must release.
The walker (walk()) and every consumer that lays out, addresses, places,
identifies or tears down a composition read this, so a new primitive that
answers it is walked, drawn, started and closed the day it exists, and a
capability is asked for rather than probed for (ASK-DONT-SNIFF).
Returns
ProcessableStructure
getId()
getId():
string
Defined in: core/dist/types/types.d.ts:203
This instance's id, unique within the process for its lifetime and different after a restart.
Returns
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'
getName()
getName():
string
Defined in: core/dist/types/types.d.ts:269
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.
Never returns an empty string: where no name was configured, the primitive reports its kind.
Returns
string
process()
process(
input,options?):Promise<InferSchemaOutput<TOutput>>
Defined in: core/dist/types/types.d.ts:183
Run once and resolve to the final output. Events stream to
options.onToken while it runs; see ProcessOptions.onToken.
Parameters
input
TInput
options?
Returns
Promise<InferSchemaOutput<TOutput>>
stream()?
optionalstream(input,options?):AsyncGenerator<StreamEvent>
Defined in: core/dist/types/types.d.ts:185
The run's events as an async iterator, instead of onToken callbacks.
Parameters
input
TInput
options?
Omit<ProcessOptions, "onToken" | "onComplete" | "onError">
Returns
AsyncGenerator<StreamEvent>
subscribeToAll()
subscribeToAll(
options?):Subscription
Defined in: core/dist/types/types.d.ts:254
Subscribe to categorized events from this processable and all nested processables:
- 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 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')
Callbacks run synchronously inside the run they observe. A callback that
throws fails that run with its error once every subscriber has heard the
notification (see leafEvents).
Parameters
options?
SubscribeAllCallbacks
Returns
Subscription
Examples
Subscribe to all events
const subscription = pipeline.subscribeToAll({
onStreamEvent(botId, botName, event) {
if (event.type === 'text_delta') {
console.log(`[${botId}] ${botName}:`, event.content);
}
},
onProgressUpdate(botId, botName, event) {
if (event.type === 'tool_execution_start') {
console.log(`${botName} (${botId}) executing ${event.toolName}`);
}
},
onComplete(botId, botName, output) {
console.log(`${botName} completed:`, output);
},
onError(botId, botName, event) {
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
});