Interface: GraphProcessable<TInput, TOutput>
Defined in: packages/core/src/graph/graph.ts:168
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;
Extends
Processable<TInput,TOutput>
Extended by
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: packages/core/src/types.ts:216
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.
Inherited from
Processable.emitsInvocationEvents
forwardsStepEvents?
readonlyoptionalforwardsStepEvents?:boolean
Defined in: packages/core/src/types.ts:341
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.
Inherited from
Processable.forwardsStepEvents
Methods
describe()
describe():
ProcessableStructure
Defined in: packages/core/src/types.ts:324
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
Inherited from
getGraphNodes()
getGraphNodes():
GraphNodeRecord[]
Defined in: packages/core/src/graph/graph.ts:171
Complete node inspection, including ordinary function steps.
Returns
getId()
getId():
string
Defined in: packages/core/src/types.ts:243
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'
Inherited from
getName()
getName():
string
Defined in: packages/core/src/types.ts:311
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
Inherited from
process()
process(
input,options?):Promise<InferSchemaOutput<TOutput>>
Defined in: packages/core/src/types.ts:221
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>>
Inherited from
run()
run(
input,options?):Promise<RunOutcome<TOutput>>
Defined in: packages/core/src/graph/graph.ts:173
Managed outcome; successful undefined and null remain completed values.
Parameters
input
TInput
options?
Returns
Promise<RunOutcome<TOutput>>
stream()?
optionalstream(input,options?):AsyncGenerator<BaleybotStreamEvent>
Defined in: packages/core/src/types.ts:224
The run's events as an async iterator, instead of onToken callbacks.
Parameters
input
TInput
options?
Omit<ProcessOptions, "onError" | "onToken" | "onComplete">
Returns
AsyncGenerator<BaleybotStreamEvent>
Inherited from
subscribeToAll()
subscribeToAll(
options?):Subscription
Defined in: packages/core/src/types.ts:295
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?
Returns
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
});