Skip to content

Mock Data Structure

This document outlines the current mock data structure in the Meta Agent Platform demo frontend and provides recommendations for improvements to better support various agent types and protocols.

Current Mock Data Structure

The demo frontend currently uses a basic mock data structure with several key components:

Agent Data Structure

{
  "id": "agent-001",
  "name": "Data Validator",
  "description": "Validates customer data against business rules",
  "type": "text",
  "status": "active",
  "version": "1.2.0",
  "created_at": "2023-03-10T09:15:00Z",
  "last_used": "2023-04-18T14:22:01Z",
  "configuration": {
    "validation_rules": {
      "name": "required|string|min:2",
      "email": "required|email",
      "company": "required|string"
    },
    "api_key": "sk_validator_123456"
  },
  "capabilities": [
    "data_validation",
    "schema_enforcement",
    "format_correction"
  ],
  "input_schema": {
    "type": "object",
    "properties": {
      "customer_data": {
        "type": "object",
        "properties": {
          "name": { "type": "string" },
          "email": { "type": "string" },
          "company": { "type": "string" }
        },
        "required": ["name", "email"]
      },
      "validation_level": {
        "type": "string",
        "enum": ["strict", "moderate", "lenient"],
        "default": "moderate"
      }
    },
    "required": ["customer_data"]
  },
  "output_schema": {
    "type": "object",
    "properties": {
      "valid": { "type": "boolean" },
      "validation_results": {
        "type": "object",
        "additionalProperties": { "type": "string" }
      },
      "corrected_data": {
        "type": "object",
        "additionalProperties": true
      }
    },
    "required": ["valid", "validation_results"]
  }
}

Workflow Data Structure

{
  "id": "wf-001",
  "name": "Customer Onboarding",
  "description": "Process new customer applications",
  "status": "active",
  "created_by": "user-001",
  "created_at": "2023-04-15T10:30:00Z",
  "last_run": "2023-04-18T14:22:00Z",
  "tags": ["customer", "onboarding", "automation"],
  "nodes": [
    {
      "id": "node-001",
      "type": "trigger",
      "subtype": "api",
      "position": { "x": 100, "y": 100 },
      "data": {
        "name": "API Trigger",
        "endpoint": "/api/customers/new"
      }
    },
    {
      "id": "node-002",
      "type": "agent",
      "subtype": "text",
      "position": { "x": 300, "y": 100 },
      "data": {
        "name": "Validate Customer Data",
        "agent_id": "agent-001",
        "parameters": {
          "validation_level": "strict"
        }
      }
    }
  ],
  "edges": [
    {
      "id": "edge-001",
      "source": "node-001",
      "target": "node-002"
    }
  ]
}

Workflow Run Data Structure

{
  "id": "run-001",
  "workflow_id": "wf-001",
  "status": "completed",
  "started_at": "2023-04-18T14:22:00Z",
  "completed_at": "2023-04-18T14:23:30Z",
  "triggered_by": "user-001",
  "trigger_type": "manual",
  "node_runs": [
    {
      "node_id": "node-001",
      "status": "completed",
      "started_at": "2023-04-18T14:22:00Z",
      "completed_at": "2023-04-18T14:22:01Z",
      "input": {},
      "output": {
        "customer_data": {
          "name": "John Doe",
          "email": "john@example.com",
          "company": "Acme Inc."
        }
      }
    }
  ],
  "logs": [
    {
      "timestamp": "2023-04-18T14:22:00.123Z",
      "level": "info",
      "node_id": "node-001",
      "message": "Starting API trigger execution"
    }
  ]
}

HITL Task Data Structure

{
  "id": "task-001",
  "workflow_id": "wf-001",
  "workflow_run_id": "run-001",
  "node_id": "node-004",
  "title": "Manager Approval: Customer Onboarding",
  "description": "Please review and approve this customer application.",
  "status": "completed",
  "priority": "medium",
  "created_at": "2023-04-18T14:22:06Z",
  "completed_at": "2023-04-18T14:23:25Z",
  "assigned_to": "user-002",
  "data": {
    "customer_data": {
      "name": "John Doe",
      "email": "john@example.com",
      "company": "Acme Inc."
    },
    "validation_results": {
      "name": "valid",
      "email": "valid",
      "company": "valid"
    }
  },
  "response": {
    "approved": true,
    "comments": "Customer information looks good."
  },
  "response_options": [
    {
      "id": "approve",
      "label": "Approve",
      "value": true
    },
    {
      "id": "reject",
      "label": "Reject",
      "value": false
    }
  ],
  "additional_fields": [
    {
      "id": "comments",
      "label": "Comments",
      "type": "textarea",
      "required": false
    }
  ]
}

To better support various agent types and protocols, the following improvements are recommended:

1. Enhanced Agent Data Structure

{
  "id": "agent-001",
  "name": "Data Validator",
  "description": "Validates customer data against business rules",
  "type": "text",
  "execution_type": "docker",  // Add execution_type: docker, api, a2a, edge
  "status": "active",
  "version": "1.2.0",
  "created_at": "2023-03-10T09:15:00Z",
  "last_used": "2023-04-18T14:22:01Z",
  "configuration": {
    // Docker-specific configuration
    "container": {
      "image": "registry.example.com/agents/data-validator:1.2.0",
      "pull_policy": "IfNotPresent",
      "command": ["python", "/app/run.py"],
      "working_dir": "/app",
      "user": "agent"
    },
    // OR API-specific configuration
    "api": {
      "endpoint": "https://api.example.com/validate",
      "method": "POST",
      "headers": {
        "Authorization": "Bearer ${API_KEY}"
      }
    },
    // OR A2A-specific configuration
    "a2a": {
      "endpoint": "https://a2a.example.com",
      "protocol_version": "1.0",
      "features": ["streaming", "thread_management"]
    }
  },
  "resources": {
    "memory": "512Mi",
    "memory_limit": "1Gi",
    "cpu": "0.5",
    "cpu_limit": "1.0"
  },
  "capabilities": [
    "data_validation",
    "schema_enforcement",
    "format_correction"
  ],
  "input_schema": {
    "type": "object",
    "properties": { ... },
    "required": ["customer_data"]
  },
  "output_schema": {
    "type": "object",
    "properties": { ... },
    "required": ["valid", "validation_results"]
  },
  "modalities": ["text"],  // Add supported modalities
  "security": {
    "read_only_fs": true,
    "no_new_privileges": true,
    "allow_network": false
  }
}

2. Enhanced Workflow Data Structure

{
  "id": "wf-001",
  "name": "Customer Onboarding",
  "description": "Process new customer applications",
  "status": "active",
  "version": 1,
  "created_by": "user-001",
  "created_at": "2023-04-15T10:30:00Z",
  "updated_at": "2023-04-16T11:20:00Z",
  "last_run": "2023-04-18T14:22:00Z",
  "tags": ["customer", "onboarding", "automation"],
  "nodes": [
    {
      "id": "node-001",
      "type": "trigger",
      "subtype": "api",
      "position": { "x": 100, "y": 100 },
      "data": {
        "name": "API Trigger",
        "endpoint": "/api/customers/new",
        "method": "POST",
        "schema": {
          "type": "object",
          "properties": { ... }
        }
      }
    },
    {
      "id": "node-002",
      "type": "agent",
      "subtype": "text",
      "position": { "x": 300, "y": 100 },
      "data": {
        "name": "Validate Customer Data",
        "agent_id": "agent-001",
        "execution_type": "docker",
        "input_mapping": {
          "customer_data": "$.trigger.body"
        },
        "parameters": {
          "validation_level": "strict"
        },
        "retry": {
          "max_attempts": 3,
          "backoff": "exponential",
          "initial_delay": 1.0
        }
      }
    }
  ],
  "edges": [ ... ],
  "variables": {
    "global": {
      "company_name": "Acme Inc.",
      "support_email": "support@acme.com"
    }
  },
  "error_handling": {
    "default": "stop",
    "custom": [
      {
        "node_id": "node-002",
        "action": "retry",
        "max_retries": 3
      }
    ]
  }
}

3. Enhanced Workflow Run Data Structure

{
  "id": "run-001",
  "workflow_id": "wf-001",
  "workflow_version": 1,
  "status": "completed",
  "started_at": "2023-04-18T14:22:00Z",
  "completed_at": "2023-04-18T14:23:30Z",
  "duration_ms": 90000,
  "triggered_by": "user-001",
  "trigger_type": "manual",
  "trigger_data": { ... },
  "node_runs": [
    {
      "node_id": "node-001",
      "status": "completed",
      "started_at": "2023-04-18T14:22:00Z",
      "completed_at": "2023-04-18T14:22:01Z",
      "duration_ms": 1000,
      "input": { ... },
      "output": { ... },
      "error": null,
      "retries": 0,
      "metrics": {
        "memory_usage_mb": 120,
        "cpu_usage_percent": 15
      }
    }
  ],
  "logs": [
    {
      "timestamp": "2023-04-18T14:22:00.123Z",
      "level": "info",
      "node_id": "node-001",
      "message": "Starting API trigger execution",
      "context": { ... }
    }
  ],
  "variables": { ... },
  "a2a_threads": [
    {
      "thread_id": "thread-001",
      "agent_id": "agent-003",
      "created_at": "2023-04-18T14:22:05Z"
    }
  ]
}

4. API-Based Agent Examples

Dify Agent Configuration

{
  "id": "agent-dify-001",
  "name": "Customer Support Assistant",
  "description": "Handles customer inquiries using Dify",
  "type": "text",
  "execution_type": "api",
  "platform": "dify",
  "status": "active",
  "version": "1.0.0",
  "configuration": {
    "endpoint": "https://api.dify.ai/v1/chat-messages",
    "method": "POST",
    "authentication": {
      "type": "api_key",
      "header_name": "Authorization",
      "key": "${DIFY_API_KEY}"
    },
    "headers": {
      "Content-Type": "application/json"
    },
    "timeout": 30,
    "retry": {
      "max_attempts": 3,
      "initial_delay": 1,
      "backoff": "exponential"
    }
  },
  "input_schema": {
    "type": "object",
    "properties": {
      "query": {
        "type": "string",
        "description": "User query"
      },
      "user_id": {
        "type": "string",
        "description": "User identifier"
      }
    },
    "required": ["query"]
  },
  "output_schema": {
    "type": "object",
    "properties": {
      "result": {
        "type": "string",
        "description": "Agent response"
      },
      "conversation_id": {
        "type": "string",
        "description": "Conversation identifier"
      },
      "sources": {
        "type": "array",
        "description": "Reference sources"
      }
    },
    "required": ["result"]
  }
}

Flowise Agent Configuration

{
  "id": "agent-flowise-001",
  "name": "Document Processor",
  "description": "Processes and extracts information from documents",
  "type": "text",
  "execution_type": "api",
  "platform": "flowise",
  "status": "active",
  "version": "1.0.0",
  "configuration": {
    "endpoint": "https://flowise.example.com/api/v1/prediction/flow/123456",
    "method": "POST",
    "authentication": {
      "type": "api_key",
      "header_name": "x-api-key",
      "key": "${FLOWISE_API_KEY}"
    },
    "timeout": 60
  },
  "input_schema": {
    "type": "object",
    "properties": {
      "document_url": {
        "type": "string",
        "description": "URL of the document to process"
      },
      "extraction_type": {
        "type": "string",
        "enum": ["full", "summary", "entities"],
        "default": "full"
      }
    },
    "required": ["document_url"]
  },
  "output_schema": {
    "type": "object",
    "properties": {
      "text": {
        "type": "string",
        "description": "Extracted text"
      },
      "summary": {
        "type": "string",
        "description": "Document summary"
      },
      "key_points": {
        "type": "array",
        "description": "Key points from the document"
      }
    },
    "required": ["text"]
  }
}

5. Framework-Based Agent Examples

LangChain Agent Configuration

{
  "id": "agent-langchain-001",
  "name": "Research Assistant",
  "description": "Performs web research using LangChain",
  "type": "text",
  "execution_type": "framework",
  "framework": "langchain",
  "status": "active",
  "version": "1.0.0",
  "configuration": {
    "module_name": "research_agent",
    "class_name": "ResearchAgent",
    "parameters": {
      "model": "gpt-4-turbo",
      "temperature": 0.7,
      "tools": ["web_search", "web_browser", "calculator"],
      "memory_type": "conversation_buffer",
      "verbose": true
    }
  },
  "input_schema": {
    "type": "object",
    "properties": {
      "query": {
        "type": "string",
        "description": "Research question"
      },
      "depth": {
        "type": "integer",
        "description": "Research depth (1-5)",
        "default": 3
      }
    },
    "required": ["query"]
  },
  "output_schema": {
    "type": "object",
    "properties": {
      "result": {
        "type": "string",
        "description": "Research findings"
      },
      "sources": {
        "type": "array",
        "description": "Source URLs"
      }
    },
    "required": ["result"]
  }
}

CrewAI Agent Configuration

{
  "id": "agent-crewai-001",
  "name": "Market Analysis Team",
  "description": "Performs market analysis using a team of specialized agents",
  "type": "text",
  "execution_type": "framework",
  "framework": "crewai",
  "status": "active",
  "version": "1.0.0",
  "configuration": {
    "module_name": "market_analysis_crew",
    "class_name": "MarketAnalysisCrew",
    "parameters": {
      "agents": [
        {
          "role": "Market Researcher",
          "goal": "Find comprehensive market data",
          "backstory": "Expert in gathering market intelligence",
          "tools": ["web_search", "data_analysis"]
        },
        {
          "role": "Financial Analyst",
          "goal": "Analyze financial implications",
          "backstory": "Experienced financial professional",
          "tools": ["calculator", "financial_data"]
        },
        {
          "role": "Report Writer",
          "goal": "Create concise, actionable reports",
          "backstory": "Professional business writer",
          "tools": ["text_summarization"]
        }
      ],
      "tasks": [
        {
          "description": "Research the market",
          "agent": "Market Researcher",
          "expected_output": "Comprehensive market data"
        },
        {
          "description": "Analyze financial implications",
          "agent": "Financial Analyst",
          "expected_output": "Financial analysis"
        },
        {
          "description": "Write final report",
          "agent": "Report Writer",
          "expected_output": "Final report"
        }
      ]
    }
  },
  "input_schema": {
    "type": "object",
    "properties": {
      "market": {
        "type": "string",
        "description": "Market to analyze"
      },
      "timeframe": {
        "type": "string",
        "description": "Timeframe for analysis",
        "default": "6 months"
      }
    },
    "required": ["market"]
  },
  "output_schema": {
    "type": "object",
    "properties": {
      "report": {
        "type": "string",
        "description": "Final market analysis report"
      },
      "key_findings": {
        "type": "array",
        "description": "Key findings from the analysis"
      },
      "recommendations": {
        "type": "array",
        "description": "Strategic recommendations"
      }
    },
    "required": ["report"]
  }
}

Implementation Strategy

To implement these improved mock data structures:

  1. Create JSON Files: Update the existing JSON files in the $lib/data/ directory with the enhanced structures.

  2. Update TypeScript Interfaces: Modify the TypeScript interfaces in the store files to match the new data structures.

  3. Extend Store Functions: Update the store functions to handle the new data fields and agent types.

  4. Add Sample Data: Create sample data for different agent types (Docker, API, Framework) to demonstrate the platform's capabilities.

  5. Update UI Components: Modify UI components to display and interact with the new data structures.

Benefits of Improved Mock Data

The improved mock data structure provides several benefits:

  1. Better Representation: More accurately represents the actual data structures that will be used in the production system.

  2. Protocol Support: Explicitly supports different agent execution types and protocols.

  3. Realistic Configuration: Includes realistic configuration options for different agent types.

  4. Resource Management: Adds resource constraints and security settings for Docker-based agents.

  5. Enhanced Workflow Features: Adds support for input/output mapping, retries, and error handling in workflows.

  6. Performance Metrics: Includes performance metrics and detailed logs for better observability.

Conclusion

By implementing these improved mock data structures, the Meta Agent Platform demo frontend will better represent the capabilities of the platform and provide a more realistic user experience. These enhancements will also make it easier to transition from mock data to real API calls when the backend is implemented.


Last updated: 2024-05-20