Core Exports
import {
Viber,
Agent,
streamText,
generateText,
} from "openviber"; Viber
The primary class for running agents with context injection.
Constructor
new Viber(config: AgentConfig, options?: ViberOptions) ViberOptions
| Property | Type | Description |
|---|---|---|
model | string | Override model |
agentId | string | Agent identifier |
config | Partial<AgentConfig> | Config overrides |
Methods
streamText(options)
Stream a text response with context injection.
const result = await viber.streamText({
messages: Message[],
plan?: string, // Plan context (markdown)
memory?: string, // Memory excerpt
artifacts?: ArtifactRef[], // Artifact references
metadata?: Record<string, any>,
}); generateText(options)
Generate a complete text response (non-streaming).
const result = await viber.generateText({
messages: Message[],
plan?: string,
memory?: string,
artifacts?: ArtifactRef[],
}); getAgent()
Get the underlying Agent instance.
const agent = viber.getAgent(); getSummary()
Get agent summary information.
const summary = viber.getSummary();
// { id, name, description, tools, llmModel, agentId } Agent
The core agent class for LLM interaction.
Constructor
new Agent(config: AgentConfig) AgentConfig
| Property | Type | Required | Description |
|---|---|---|---|
name | string | ✓ | Agent identifier |
description | string | ✓ | Agent description |
provider | string | ✓ | LLM provider |
model | string | ✓ | Model identifier |
systemPrompt | string | Agent instructions | |
tools | string[] | Available tools | |
skills | string[] | Loaded skills | |
temperature | number | Creativity (0-1) | |
maxTokens | number | Response limit |
Methods
streamText(options)
Stream a text response.
const result = await agent.streamText({
messages: ViberMessage[],
system?: string,
spaceId?: string,
metadata?: Record<string, any>,
});
for await (const chunk of result.textStream) {
process.stdout.write(chunk);
} generateText(options)
Generate a complete text response.
const result = await agent.generateText({
messages: ViberMessage[],
system?: string,
}); Message Types
ViberMessage
interface ViberMessage {
role: "user" | "assistant" | "system";
content: string | ContentPart[];
metadata?: Record<string, any>;
} ArtifactRef
interface ArtifactRef {
id: string;
title?: string;
type?: string; // "file" | "screenshot" | "log"
ref?: string; // Path or URL
} Daemon Runtime
runTask
Execute a task through the daemon runtime.
import { runTask } from "openviber";
const { streamResult, agent } = await runTask(
"Build a landing page",
{
taskId: "task-123",
singleAgentId: "developer",
model: "anthropic/claude-sonnet-4-20250514",
},
messages
); loadAgentConfig
Load agent configuration from file.
import { loadAgentConfig } from "openviber";
const config = await loadAgentConfig("developer");
// Loads from ~/.openviber/agents/developer.yaml AI SDK Re-exports
OpenViber re-exports key Vercel AI SDK functions:
import { streamText, generateText } from "openviber";
// Use directly
const result = await streamText({
model: openai("gpt-4o"),
messages: [{ role: "user", content: "Hello" }],
});