Skip to content

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 });
new CapabilityHost(): CapabilityHost;

CapabilityHost

get capabilityCount(): number;

Number of registered capabilities.

number


get needsReconfigure(): boolean;

True if tools or prompt changed since last markConfigured() call.

boolean

addTools(tools): this;

Add regular tools not managed by any capability.

Parameter Type

tools

ToolDeclaration<unknown, unknown>[]

this


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.

ToolDeclaration<unknown, unknown>[]


getSystemPrompt(basePrompt?): string;

Build complete system prompt from base prompt + all capability sections. Sections are ordered by role priority.

Parameter Type

basePrompt?

string

string


markConfigured(): void;

Mark the current state as “seen” for reconfigure detection.

void


notifyChanged(): void;

Bump version to signal that tools or prompt have changed.

void


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

Parameter Type

toolName

string

args

unknown

result

unknown

CapabilityAction


use(capability): this;

Add a capability (flow, triage, extraction, etc.).

Parameter Type

capability

Capability

this