Class: ComposableToolBuilder
Defined in: packages/agentos/src/cognition/emergent/ComposableToolBuilder.ts:94
Builds composite ITool instances 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:
| Expression | Resolves to |
|---|---|
"$input.foo" | args.foo from the composite tool's own input |
"$input" | the whole input object |
"$prev.bar" | bar from the previous step's output |
"$prev" | the previous step's full output |
"$steps[0].output.data" | output.data from the first step's output |
"$steps[0]" | the first step's full output |
| anything else | used as a literal value without transformation |
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 executeTool
callback supplied at construction time. The builder never holds a reference to
any tool registry.
Example
const builder = new ComposableToolBuilder(async (toolName, args, ctx) => {
const tool = registry.get(toolName);
return tool.execute(args, ctx);
});
const spec: ComposableToolSpec = {
mode: 'compose',
steps: [
{ name: 'search', tool: 'web_search', inputMapping: { query: '$input.topic' } },
{ name: 'summarise', tool: 'summarise_text', inputMapping: { text: '$prev.snippet' } },
],
};
const tool = builder.build('research', 'Search then summarise a topic', schema, spec);
const result = await tool.execute({ topic: 'quantum computing' }, ctx);
Constructors
Constructor
new ComposableToolBuilder(
executeTool,options?):ComposableToolBuilder
Defined in: packages/agentos/src/cognition/emergent/ComposableToolBuilder.ts:112