Skip to main content

Class: BaleybotConditional

Defined in: packages/core/src/conditional.ts:47

BaleybotConditional - Boolean decision-making primitive

A specialized Baleybot that returns true/false decisions. Useful for filtering, validation, gates, and conditional logic.

Example

const isSpam = BaleybotConditional.create({
name: 'spam-filter',
analysisGoal: 'Determine if the email is spam',
includeReasoning: true
});

// Simple boolean result
const result = await isSpam.process(email);
// result: true or false

// With reasoning
const detailed = await isSpam.processWithReasoning(email);
// detailed: { result: true, reasoning: "Contains phishing links" }

Implements

Methods

getBot()

getBot(): Baleybot<ConditionalResult>

Defined in: packages/core/src/conditional.ts:123

Get the underlying Baleybot (for advanced usage)

Returns

Baleybot<ConditionalResult>


getBotNames()

getBotNames(): string[]

Defined in: packages/core/src/conditional.ts:137

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

Processable.getBotNames


getId()

getId(): string

Defined in: packages/core/src/conditional.ts:109

Get the unique ID of this conditional

Returns

string

Implementation of

Processable.getId


getName()

getName(): string

Defined in: packages/core/src/conditional.ts:116

Get the name of this conditional

Returns

string


process()

process<TInput>(input, options?): Promise<boolean>

Defined in: packages/core/src/conditional.ts:83

Process input and return structured output

You can use BOTH streaming events AND final result together:

  • Streaming events: Provide options.onToken to receive real-time events during execution
  • Final result: Returned when Promise resolves (complete parsed response)

Both work simultaneously - streaming events fire in real-time, then final result is returned.

Type Parameters

TInput

TInput = unknown

Parameters

input

TInput

Input data (typed for safety)

options?

ProcessOptions

Optional callbacks for streaming, completion, errors

Returns

Promise<boolean>

Promise resolving to structured output (inferred from TOutput if it's a Zod schema)

Implementation of

Processable.process


processWithReasoning()

processWithReasoning<TInput>(input, options?): Promise<ConditionalResult>

Defined in: packages/core/src/conditional.ts:97

Process input and return decision with reasoning

Type Parameters

TInput

TInput = unknown

Parameters

input

TInput

Input to evaluate

options?

ProcessOptions

Process options (streaming, callbacks)

Returns

Promise<ConditionalResult>

Object with result and optional reasoning


subscribeToAll()

subscribeToAll(options?): Subscription

Defined in: packages/core/src/conditional.ts:127

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')

Parameters

options?

Optional categorized callbacks and bot filter

omit?

string[]

onComplete?

(botId, botName, output) => void

onError?

(botId, botName, event) => void

onProgressUpdate?

(botId, botName, event) => void

onStreamEvent?

(botId, botName, event) => void

Returns

Subscription

Subscription object with unsubscribe method

Examples

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();
const subscription = pipeline.subscribeToAll({
onStreamEvent(botId, botName, event) {
console.log(`${botName}:`, event);
},
omit: ['chat-step', 'processor-42-8a3f91'] // Filter by name or ID
});

Implementation of

Processable.subscribeToAll


create()

static create(config): BaleybotConditional

Defined in: packages/core/src/conditional.ts:74

Create a new conditional decision bot

Parameters

config

BaleybotConditionalConfig

Returns

BaleybotConditional