Spaces
Overview
Section titled “Overview”Spaces provide isolated workspaces for organizing agent conversations, generated artifacts, and task history. Each space maintains its own context and state.
Creating a Space
Section titled “Creating a Space”import { Space } from 'viber';
const space = new Space({ name: 'my-project', rootPath: './workspaces/my-project',});Space Structure
Section titled “Space Structure”Directorymy-project/
Directory.viber/
- config.json
Directoryhistory/
- …
Directoryartifacts/
- …
Directoryoutputs/
- …
Configuration
Section titled “Configuration”const space = new Space({ name: 'research-project', rootPath: './workspaces/research', config: { maxHistoryItems: 100, autoSaveInterval: 5000, },});| Option | Type | Default | Description |
|---|---|---|---|
name | string | required | Space identifier |
rootPath | string | required | Filesystem path |
maxHistoryItems | number | 1000 | History retention limit |
autoSaveInterval | number | 10000 | Auto-save interval (ms) |
Using Spaces with Agents
Section titled “Using Spaces with Agents”const agent = new Agent({ name: 'Researcher', model: 'openai:gpt-4o', space, // Associate with a space});
// Artifacts are automatically saved to the spaceawait agent.streamText({ messages: [{ role: 'user', content: 'Research AI trends' }],});Accessing Artifacts
Section titled “Accessing Artifacts”// List all artifactsconst artifacts = await space.listArtifacts();
// Read a specific artifactconst content = await space.readArtifact('report.md');
// Save an artifactawait space.saveArtifact('summary.txt', 'Key findings...');Task History
Section titled “Task History”// View conversation historyconst history = await space.getHistory();
// Clear historyawait space.clearHistory();