Callback invoked for each pipeline step. Receives the
target tool name, the resolved argument object, and the outer execution
context forwarded from the composite tool's own execute call.
Must return a ToolExecutionResult; a success: false result aborts
the remainder of the pipeline.
Optional options: { Optional builder configuration.
Optional strictWhen true, unresolved reference expressions throw an error instead of falling through as literal strings.
Build an ITool-compatible object from a ComposableToolSpec.
The returned tool can be registered directly with any tool orchestrator that
accepts ITool. Its execute method runs the step pipeline sequentially,
threading outputs through the reference resolution system.
Machine-readable tool name exposed to the LLM (e.g. "research_topic").
Natural language description of what the composite tool does.
JSON Schema describing the arguments the composite tool accepts.
The composable pipeline specification to execute.
A fully-formed ITool instance whose execute method runs the pipeline.
const tool = builder.build(
'fetch_and_summarise',
'Fetch a URL then return a one-paragraph summary.',
{ type: 'object', properties: { url: { type: 'string' } }, required: ['url'] },
spec,
);
Validate a ComposableToolSpec before building.
Performs structural checks only — it does not verify that the referenced tool names are actually registered in any registry. Use this method to give early, actionable feedback before attempting to build a tool.
Checks performed:
spec.steps must be a non-empty array.tool string.The spec to validate.
{ valid: true } when the spec passes all checks, or
{ valid: false, errors: string[] } with one message per failing check.
Optional errors?: string[]const result = builder.validate(spec);
if (!result.valid) {
console.error('Invalid spec:', result.errors);
}
Readonly strictWhen true, unresolved $-prefixed reference expressions throw instead
of silently passing through as literal strings. Useful for development
and testing to catch typos in inputMapping expressions early.
Builds composite
IToolinstances by chaining existing tool invocations.Each invocation is described by a ComposableStep that maps values from a shared pipeline context into the step tool's arguments via a lightweight reference expression syntax:
"$input.foo"args.foofrom the composite tool's own input"$input""$prev.bar"barfrom the previous step's output"$prev""$steps[0].output.data"output.datafrom the first step's output"$steps[0]"Reference expressions nested inside plain objects are resolved recursively, so
{ query: "$input.topic", limit: 10 }becomes{ query: "actual-topic", limit: 10 }.Safe by construction — all tool invocations are delegated to the
executeToolcallback supplied at construction time. The builder never holds a reference to any tool registry.Example