Mission Lifecycle & Artifact Evolution
Unlike task-oriented frameworks with a simple “start → execute → end” lifecycle, Viber provides persistent Spaces where work evolves over time through continuous collaboration.
Core Concepts Hierarchy
Section titled “Core Concepts Hierarchy”Space (persistent container) └── Mission (user's substantial intent) └── Plan (strategy, evolves) └── Task[] (individual work items)- Space: A persistent container that never ends—like a project folder
- Mission: A substantial goal with a lifecycle (e.g., “Write my thesis”)
- Plan: The strategy for achieving a Mission, can evolve
- Task: Individual work items within a Plan
Note: Our “Task” is different from AI SDK’s “steps” (multi-turn tool execution loops). Viber Tasks are higher-level work items.
Understanding Spaces vs Missions
Section titled “Understanding Spaces vs Missions”A Space is a persistent container—it doesn’t have a lifecycle with start/end. Think of it like a project workspace that always exists once created.
A Mission within a Space has a lifecycle: it’s created, worked on, and eventually completed or abandoned. Missions represent substantial goals that require multiple Tasks.
Session States (Not Space Lifecycle)
Section titled “Session States (Not Space Lifecycle)”While Spaces persist indefinitely, user sessions within a Space have states:
stateDiagram-v2 [*] --> Created: XAgent.start() Created --> Active: First message Active --> Active: Conversation continues Active --> Paused: User leaves Paused --> Active: XAgent.resume() Active --> Archived: User archives Archived --> Active: User restoresNote: These are session states, not Space states. The Space itself persists through all of these—only the user’s active connection changes.
Phase 1: Mission Creation
Section titled “Phase 1: Mission Creation”When a user starts a new project, XAgent creates a Space and begins the first Mission:
// User initiatesconst space = await XAgent.start("Write my thesis on climate change");// Creates: Space + Mission("Write my thesis on climate change")What happens internally:
sequenceDiagram actor User participant XAgent participant Space participant Mission participant Storage
User->>XAgent: start("Write my thesis...") XAgent->>Space: Create new Space Space->>Mission: Create Mission with goal Mission->>Mission: Initialize Plan Space->>Storage: Persist initial state XAgent->>XAgent: Attach to Space XAgent-->>User: Space readyCreated State:
- Empty artifact list
- Fresh conversation history
- Mission with initial Plan
- XAgent attached and ready
Phase 2: Active Collaboration
Section titled “Phase 2: Active Collaboration”The core of Viber—continuous iteration on artifacts through conversation.
The Conversation-Artifact Loop
Section titled “The Conversation-Artifact Loop”sequenceDiagram actor User participant XAgent participant Mission participant Task participant Artifact
loop Continuous Collaboration User->>XAgent: "Write the introduction" XAgent->>Mission: Get current Task XAgent->>XAgent: Generate content XAgent->>Artifact: Create/Update Artifact->>Artifact: Version++ XAgent->>Task: Mark complete XAgent-->>User: "Here's the introduction..."
User->>XAgent: "Make it more concise" XAgent->>Artifact: Read current version XAgent->>XAgent: Edit content XAgent->>Artifact: Update (new version) XAgent-->>User: "I've made it more concise..." endArtifact Versioning
Section titled “Artifact Versioning”Every modification creates a new version:
interface ArtifactVersion { version: number; content: Buffer | string; createdAt: Date; createdBy: string; // Agent or user message?: string; // Commit message relatedMessageId?: string; // The message that triggered this change}Example evolution:
thesis.md├── v1: Initial draft (by XAgent, "Write the introduction")├── v2: More concise (by XAgent, "Make it more concise")├── v3: Added citations (by Researcher agent)└── v4: Final polish (by Editor agent)Phase 3: Session Pause & Resume
Section titled “Phase 3: Session Pause & Resume”Users can leave and return at any time. The Space preserves everything.
Leaving a Session
Section titled “Leaving a Session”When the user closes the browser or explicitly pauses:
// Automatic on disconnect, or explicitawait space.pause();What’s preserved:
- Complete conversation history
- All artifact versions
- Current Mission and Plan state
- Agent configurations
- User preferences
Resuming a Session
Section titled “Resuming a Session”// Next day, next week, next month...const space = await XAgent.resume("space_abc123");What happens:
sequenceDiagram actor User participant XAgent participant Storage participant Space participant Mission
User->>XAgent: resume(spaceId) XAgent->>Storage: Load Space data Storage-->>XAgent: Space, Mission, History, Artifacts XAgent->>Space: Reconstruct state XAgent->>Mission: Get current Task XAgent->>XAgent: Attach to Space XAgent-->>User: "Welcome back! We were working on..."
Note over XAgent: XAgent has full context User->>XAgent: "Continue with chapter 2" XAgent->>XAgent: Uses accumulated contextMission Lifecycle States
Section titled “Mission Lifecycle States”stateDiagram-v2 [*] --> Active: Mission created Active --> Active: Tasks progress Active --> Paused: User pauses Paused --> Active: User resumes Active --> Completed: All Tasks done Active --> Abandoned: User gives up Completed --> [*] Abandoned --> [*]Artifact Evolution Patterns
Section titled “Artifact Evolution Patterns”Pattern 1: Single Document Refinement
Section titled “Pattern 1: Single Document Refinement”// Session 1: Draftawait xAgent.chat("Write a blog post about AI");// Creates: blog-post.md v1
// Session 2: Improveawait xAgent.chat("Add more technical details");// Updates: blog-post.md v2
// Session 3: Polishawait xAgent.chat("Make it more engaging");// Updates: blog-post.md v3Pattern 2: Multi-Artifact Project
Section titled “Pattern 2: Multi-Artifact Project”// Session 1: Researchawait xAgent.chat("Research renewable energy trends");// Creates: sources.md, notes.md
// Session 2: Outlineawait xAgent.chat("Create an outline for a report");// Creates: outline.md// References: sources.md, notes.md
// Session 3: Writeawait xAgent.chat("Write the full report");// Creates: report.md// Uses: outline.md, sources.md, notes.mdPattern 3: Collaborative Editing
Section titled “Pattern 3: Collaborative Editing”// User uploads existing documentawait space.uploadArtifact("proposal.docx", content);
// Iterative refinementawait xAgent.chat("Review and suggest improvements");// XAgent reads proposal.docx, provides feedback
await xAgent.chat("Apply the suggestions");// Updates: proposal.docx v2
await xAgent.chat("Now focus on the budget section");// Updates: proposal.docx v3Plan Adaptation
Section titled “Plan Adaptation”Unlike static workflows, Viber Plans adapt based on conversation:
sequenceDiagram actor User participant XAgent participant Mission participant Plan
User->>XAgent: "Write a research paper" XAgent->>Mission: Create Mission Mission->>Plan: Generate initial Plan Note over Plan: Tasks:<br/>1. Research<br/>2. Outline<br/>3. Draft<br/>4. Review
User->>XAgent: "Actually, focus on methodology first" XAgent->>Plan: Adapt Plan Note over Plan: Tasks:<br/>1. Methodology<br/>2. Research<br/>3. Draft<br/>4. Review
User->>XAgent: "Skip the outline, I have one" XAgent->>Plan: Adapt Plan Note over Plan: Tasks:<br/>1. Methodology<br/>2. Research<br/>3. Draft (use existing)<br/>4. ReviewContext Accumulation
Section titled “Context Accumulation”A key feature of Space-oriented design is context accumulation:
// Traditional: Each call is independentagent.run("Research X"); // Context: just "Research X"agent.run("Write about X"); // Context: just "Write about X"
// Viber: Context accumulatesawait xAgent.chat("Research climate change");// Context: research request
await xAgent.chat("Focus on agriculture impacts");// Context: research + agriculture focus
await xAgent.chat("Write a summary");// Context: research + agriculture + all findings// XAgent knows everything discussedContext Window Management
Section titled “Context Window Management”For long-running Spaces, context is managed intelligently:
interface ContextManager { // Get relevant context for current request getRelevantContext( query: string, tokenLimit: number ): Promise<XMessage[]>;
// Summarize old context summarizeOldMessages(): Promise<void>;
// Retrieve by artifact getContextForArtifact(artifactId: string): XMessage[];}Execution Engine Integration
Section titled “Execution Engine Integration”For complex multi-step operations, XAgent can invoke the internal Execution Engine:
sequenceDiagram actor User participant XAgent participant Mission participant Engine participant Agents
User->>XAgent: "Analyze this dataset and create a report" XAgent->>Mission: Get current Task XAgent->>Engine: Execute Task workflow
loop Task Execution Engine->>Agents: Invoke specialist Agents-->>Engine: Result Engine->>Engine: Update context end
Engine-->>XAgent: Task complete XAgent->>Mission: Update Plan progress XAgent-->>User: "Report ready..."Human-in-the-Loop
Section titled “Human-in-the-Loop”Execution can pause for user input:
// Execution node{ type: "human_input", prompt: "Please review this draft and provide feedback", artifactId: "draft.md"}When reached:
- Engine pauses
- User notified
- User provides feedback
- Engine resumes with feedback in context
Space Archival
Section titled “Space Archival”When a project is complete:
await space.archive();Archived Spaces:
- Remain fully accessible
- Can be restored to active state
- Serve as reference for future work
- Can be cloned as templates
Summary: The Viber Model
Section titled “Summary: The Viber Model”┌─────────────────────────────────────────────────────────────┐│ PERSISTENT SPACE │├─────────────────────────────────────────────────────────────┤│ ││ MISSIONS: Mission1 ──► Mission2 ──► ... ││ │ ││ ▼ ││ ┌──────────┐ ││ │ Plan │ ││ │ ┌──────┐ │ ││ │ │Task 1│ │ ││ │ │Task 2│ │ ││ │ │Task 3│ │ ││ │ └──────┘ │ ││ └──────────┘ ││ │ ││ ▼ ││ ┌──────────────────────────────────┐ ││ │ Artifacts │ ││ │ v1 → v2 → v3 → v4 → ... │ ││ │ (evolve across missions) │ ││ └──────────────────────────────────┘ ││ │ ││ ▼ ││ ┌──────────────────────────────────┐ ││ │ History │ ││ │ (persisted across sessions) │ ││ └──────────────────────────────────┘ ││ ││ SESSIONS: Connect ──► Work ──► Disconnect ──► Reconnect ││ (Space persists through all sessions) ││ │└─────────────────────────────────────────────────────────────┘Key Insights:
- Spaces persist forever - Your workspace is always there
- Missions have lifecycles - Substantial goals that can be completed
- Plans evolve - Strategy adapts based on feedback
- Tasks are work items - Individual steps within a Plan
- Artifacts evolve - Content improves over time
- Context is never lost - Everything is preserved