Guides / Spaces

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

const space = new Space({
  name: "my-project",
  rootPath: "./workspaces/my-project",
});

Space Structure

my-project/
  .viber/
    config.json
    history/
    artifacts/
  outputs/

Configuration

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)

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 space
await agent.streamText({
  messages: [{ role: "user", content: "Research AI trends" }],
});

Accessing Artifacts

// 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...");

Tip

Spaces persist across sessions, enabling agents to resume work where they left off.

Task History

// View conversation history
const history = await space.getHistory();

// Clear history
await space.clearHistory();