Skip to content

Spaces

Spaces provide isolated workspaces for organizing agent conversations, generated artifacts, and task history. Each space maintains its own context and state.

import { Space } from 'viber';
const space = new Space({
name: 'my-project',
rootPath: './workspaces/my-project',
});
  • Directorymy-project/
    • Directory.viber/
      • config.json
      • Directoryhistory/
      • Directoryartifacts/
    • Directoryoutputs/
const space = new Space({
name: 'research-project',
rootPath: './workspaces/research',
config: {
maxHistoryItems: 100,
autoSaveInterval: 5000,
},
});
OptionTypeDefaultDescription
namestringrequiredSpace identifier
rootPathstringrequiredFilesystem path
maxHistoryItemsnumber1000History retention limit
autoSaveIntervalnumber10000Auto-save interval (ms)
const agent = new Agent({
name: 'Researcher',
model: 'openai:gpt-4o',
space, // Associate with a space
});
// Artifacts are automatically saved to the space
await agent.streamText({
messages: [{ role: 'user', content: 'Research AI trends' }],
});
// List all artifacts
const artifacts = await space.listArtifacts();
// Read a specific artifact
const content = await space.readArtifact('report.md');
// Save an artifact
await space.saveArtifact('summary.txt', 'Key findings...');
// View conversation history
const history = await space.getHistory();
// Clear history
await space.clearHistory();