CapabilityHost
Collects capabilities and exposes a unified interface for any LLM backend.
Usage:
const host = new CapabilityHost() .use(new ExtractionCapability({ ... })) .use(new ExtractionCapability({ schema })) .use(new GuardrailCapability(policies));
// For Gemini Live:const tools = toGeminiDeclarations(host.getAllTools());const prompt = host.getSystemPrompt(basePrompt);
// For AI SDK:const tools = toAISDKTools(host.getAllTools());streamText({ system: prompt, tools });Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new CapabilityHost(): CapabilityHost;Returns
Section titled “Returns”CapabilityHost
Accessors
Section titled “Accessors”capabilityCount
Section titled “capabilityCount”Get Signature
Section titled “Get Signature”get capabilityCount(): number;Number of registered capabilities.
Returns
Section titled “Returns”number
needsReconfigure
Section titled “needsReconfigure”Get Signature
Section titled “Get Signature”get needsReconfigure(): boolean;True if tools or prompt changed since last markConfigured() call.
Returns
Section titled “Returns”boolean
Methods
Section titled “Methods”addTools()
Section titled “addTools()”addTools(tools): this;Add regular tools not managed by any capability.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
|
Returns
Section titled “Returns”this
getAllTools()
Section titled “getAllTools()”getAllTools(): ToolDeclaration<unknown, unknown>[];Collect all tools from all capabilities + regular tools.
Deduplicates by name — capability-provided tools take priority over regular (agent-level) tools. This prevents duplicate function declarations that providers like Gemini Live reject.
Returns
Section titled “Returns”ToolDeclaration<unknown, unknown>[]
getSystemPrompt()
Section titled “getSystemPrompt()”getSystemPrompt(basePrompt?): string;Build complete system prompt from base prompt + all capability sections. Sections are ordered by role priority.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
|
Returns
Section titled “Returns”string
markConfigured()
Section titled “markConfigured()”markConfigured(): void;Mark the current state as “seen” for reconfigure detection.
Returns
Section titled “Returns”void
notifyChanged()
Section titled “notifyChanged()”notifyChanged(): void;Bump version to signal that tools or prompt have changed.
Returns
Section titled “Returns”void
processToolResult()
Section titled “processToolResult()”processToolResult( toolName, args, result): CapabilityAction;Route a tool result through capabilities. First capability to claim it wins.
If no capability claims it, returns { type: 'continue' } (regular tool).
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
|
|
|
|
|
|
|
Returns
Section titled “Returns”use(capability): this;Add a capability (flow, triage, extraction, etc.).
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
Returns
Section titled “Returns”this