Core Exports
The main viber package exports the following:
Agent
The primary class for creating AI agents.
Constructor
new Agent(config: AgentConfig) AgentConfig
| Property | Type | Required | Description |
|---|---|---|---|
name | string | ✓ | Agent identifier |
model | string | ✓ | LLM model (e.g., openai:gpt-4o) |
systemPrompt | string | Agent instructions | |
tools | Tool[] | Available tools | |
temperature | number | Creativity (0-1) | |
maxTokens | number | Response limit |
Methods
streamText(options)
Stream a text response.
const result = await agent.streamText({
messages: Message[],
onToolCall?: (call) => void,
}); generateText(options)
Generate a complete text response (non-streaming).
const result = await agent.generateText({
messages: Message[],
}); Space
Workspace management for organizing artifacts and history.
Constructor
new Space(config: SpaceConfig) Methods
| Method | Returns | Description |
|---|---|---|
saveArtifact(name, content) | Promise<void> | Save an artifact |
readArtifact(name) | Promise<string> | Read an artifact |
listArtifacts() | Promise<string[]> | List all artifacts |
getHistory() | Promise<Message[]> | Get conversation history |
clearHistory() | Promise<void> | Clear history |
tool()
Define a tool for agents.
const myTool = tool({
name: string,
description: string,
parameters: ZodSchema,
execute: (params) => Promise<any>,
}); Framework Adapters
React (viber/react)
Svelte (viber/svelte)
Server (viber/server)