Interface: ProcessOptions
Defined in: packages/core/src/types.ts:461
Extended by
Properties
conversationHistory?
optionalconversationHistory?:object[]
Defined in: packages/core/src/types.ts:596
Conversation history for multi-turn conversations (uses OpenAI ChatMessage format from providers)
content
content:
string|MessageContentBlock[]
role
role:
"system"|"user"|"assistant"|"tool"
tool_call_id?
optionaltool_call_id?:string
tool_calls?
optionaltool_calls?:object[]
enableCaching?
optionalenableCaching?:boolean
Defined in: packages/core/src/types.ts:477
Enable prompt caching for multi-agent pipelines. When true, each agent's system message gets cache control markers, allowing shared document context to be cached across parallel agent calls.
Especially beneficial for extraction pipelines where multiple agents process the same document simultaneously — cached reads cost only 10% (Anthropic) or 50% (OpenAI) of normal input price.
extraVars?
optionalextraVars?:Record<string,unknown>
Defined in: packages/core/src/types.ts:617
Extra variable bindings injected at process-time (used by BAL map/for iterators).
hooks?
optionalhooks?:ProcessHooks
Defined in: packages/core/src/types.ts:643
Per-step lifecycle hooks. Awaitable — the runner awaits each hook before proceeding, so persistence can land before the next step runs.
For single-step Processables (e.g. a lone Baleybot), hooks fire around the whole invocation. For multi-step Processables (pipeline, graph, ParallelMerge), they fire per step with the appropriate nodeId / nodeLabel.
Zero-cost when unset: the runner skips event construction entirely if hooks is absent AND no subscription is active.
See ProcessHooks in ./graph/types.ts for the full callback shape and
ordering contract.
hooksAreFatal?
optionalhooksAreFatal?:boolean
Defined in: packages/core/src/types.ts:650
If true, a throwing hook rejects the run. Default (false) logs the error and continues execution — observability should not be able to break a pipeline by accident.
maxTokens?
optionalmaxTokens?:number
Defined in: packages/core/src/types.ts:624
Override maxTokens for this call only. Takes precedence over construction-time maxTokens.
model?
optionalmodel?:string|ModelConfig
Defined in: packages/core/src/types.ts:620
Override the model for this call only. Takes precedence over construction-time model.
onApprovalRequired?
optionalonApprovalRequired?: (botName,toolCall,toolDefinition) =>Promise<ToolApprovalResult>
Defined in: packages/core/src/types.ts:590
Request approval for individual tool calls (v6 pattern)
Called when a tool has requiresApproval: true or returns true from
its requiresApproval function. This is called per-tool, not per-batch.
Parameters
botName
string
toolCall
toolDefinition
ZodToolDefinition<ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>, unknown>
Returns
Promise<ToolApprovalResult>
Example
const bot = new Baleybot({
name: 'bot',
goal: 'Help with files',
tools: {
deleteFile: defineZodTool({
name: 'delete_file',
description: 'Delete a file',
inputSchema: z.object({ path: z.string() }),
requiresApproval: true, // Always require approval
execute: async ({ path }) => { ... },
}),
},
});
await bot.process('Delete temp.txt', {
onApprovalRequired: async (botName, toolCall, toolDef) => {
// Show approval UI
const approved = await showApprovalDialog(toolCall);
return approved
? { approved: true }
: { approved: false, reason: 'User cancelled' };
},
});
onComplete?
optionalonComplete?: (botName,result) =>void
Defined in: packages/core/src/types.ts:555
Called when processing completes with final result
Note: You can also get the final result from process() return value.
This callback is provided for convenience when you need both streaming and completion notification.
Parameters
botName
string
result
unknown
Returns
void
onError?
optionalonError?: (botName,error) =>void
Defined in: packages/core/src/types.ts:556
Parameters
botName
string
error
Error
Returns
void
onStart?
optionalonStart?: (botName) =>void
Defined in: packages/core/src/types.ts:479
Parameters
botName
string
Returns
void
onToken?
optionalonToken?:TokenHandlers| ((botName,event) =>void)
Defined in: packages/core/src/types.ts:548
Streaming event handlers - receive events in real-time during execution
You can use BOTH streaming events AND final results together:
- Streaming events: Provide
onTokenhandlers to receive real-time updates via callbacks - Final result: Also available when
process()Promise resolves (see return value)
Accepts either:
- A callback function that receives all events
- An object with specific handlers for each event type (recommended for type safety)
Examples
// Stream events in real-time AND get final result
const result = await bot.process(input, {
onToken: {
// Real-time streaming events
onTextDelta(botName, event) {
process.stdout.write(event.content); // Stream as it generates
},
onToolExecutionStart(botName, event) {
console.log(`🔧 ${event.toolName} starting...`); // Real-time tool status
},
onToolExecutionOutput(botName, event) {
console.log(`✅ Tool result:`, event.result); // Final tool result event
},
onToolExecutionStream(botName, event) {
// Nested streaming from child bots
const nested = event.nestedEvent;
if (nested.type === 'text_delta') {
process.stdout.write(nested.content); // Child bot streaming
}
}
}
});
// Final result available when Promise resolves
console.log('Final response:', result); // Complete parsed response
await bot.process(input, {
onToken: (botName, event) => {
if (event.type === 'text_delta') {
process.stdout.write(event.content);
}
}
});
// Don't await or use return value if you only care about streaming
const result = await bot.process(input);
// No onToken = no streaming, just wait for final result
console.log('Response:', result);
onToken(botName, event) {
if (event.type === 'tool_execution_start') {
console.log(`Starting ${event.toolName}`);
}
}
signal?
optionalsignal?:AbortSignal
Defined in: packages/core/src/types.ts:466
AbortSignal to cancel the request
stopWhen?
optionalstopWhen?:StopCondition
Defined in: packages/core/src/types.ts:626
Override stopWhen for this call only. Takes precedence over construction-time stopWhen.
temperature?
optionaltemperature?:number
Defined in: packages/core/src/types.ts:622
Override temperature for this call only (0–2). Takes precedence over construction-time temperature.
toolCallId?
optionaltoolCallId?:string
Defined in: packages/core/src/types.ts:615
Tool call ID - set by executeTools when invoking a tool. Used by tools that emit streaming events (like spawn_agent) to identify which tool call the events belong to for correct UI routing.
verbose?
optionalverbose?:boolean
Defined in: packages/core/src/types.ts:463
Enable verbose logging for debugging