Skip to content

Data Model

ArchAgent uses Firestore as its primary datastore. All collection paths are centralized in shared/src/paths.ts -- never construct paths as raw strings.

Entity Relationships

Top-Level Collections

config/platform

Platform-wide configuration singleton.

FieldTypeDescription
copilotModelstringModel for instance copilot
agentModelstringDefault model for custom agents
openclawModelstringDefault model for OpenClaw agents
mastraModelstringDefault model for Mastra agents
maxTokensnumberMax tokens per response

users/{id}

User profiles.

FieldTypeDescription
emailstringUser email
subscriptionobjectStripe subscription state
copilotConversationIdsmapConversation ID references
usageobjectUsage tracking

users/{id}/private/secrets

Encrypted user secrets (API keys, channel app tokens, integration tokens).

FieldTypeDescription
apiKeysmapProvider API keys (anthropic, openai, google, ollama)
channelAppsmapChannel bot tokens by platform
integrationAppsmapIntegration tokens (e.g., GitHub PATs)

instances/{id}

Workspace instances. Each maps to a Cloud Run service.

FieldTypeDescription
userIdstringOwner
namestringDisplay name
statusstringprovisioning, running, stopped, error
cloudRunServicestringCloud Run service name
topologyTopologyMulti-agent topology configuration
createdAttimestampCreation time
updatedAttimestampLast update

agents/{id}

Agent definitions. Top-level collection, references instanceId.

FieldTypeDescription
userIdstringOwner
instanceIdstringParent workspace
namestringDisplay name
agentTypestringopenclaw, mastra, or custom
configAgentConfigRuntime configuration (name, personality, model provider, channel, integration)
rolestringAgent role description
goalstringAgent goal
capabilitiesstringAgent capabilities
statusstringrunning, paused, stopped
channelStatusstringconnected, disconnected, error
ocRuntimeobjectOpenClaw-specific runtime state
mastraRuntimeobjectMastra-specific runtime state

OpenClaw Runtime Fields (ocRuntime)

FieldTypeDescription
ocAgentIdstringOpenClaw agent ID
ocVersionstringOC binary version
ocModelstringCurrent model
ocSkillsInstallednumberInstalled skill count
ocSkillsAvailablenumberAvailable skill count
ocThinkingstringThinking level

Mastra Runtime Fields (mastraRuntime)

FieldTypeDescription
threadIdstringConversation thread ID
mcpServersMcpServerConfig[]Configured MCP servers

Instance Subcollections

PathPurposeKey Fields
instances/{id}/sessionsBridge session trackingstartedAt, status
instances/{id}/commandsCopilot-to-bridge command queuecommand, args, status
instances/{id}/activityActivity log (lifecycle, messages, errors)type, severity, message, timestamp
instances/{id}/contextShared context for multi-agent coordinationchannel, authorAgentId, content, type
instances/{id}/approvalsExecution approval requestsstatus, command, agentId
instances/{id}/metrics/aggregateAggregated message metricscounts, timestamps

Context Entry Types

Context entries in instances/{id}/context carry one of four types:

TypePurpose
artifactCode, documents, or other outputs
statusProgress updates
decisionArchitectural or design decisions
handoffWork handoff between pipeline stages

Entries are scoped to channels: all, planning, code, review, status.

Agent Subcollections

PathPurposeKey Fields
agents/{id}/messagesChat messages (status machine)role, content, status, channel, responseContent
agents/{id}/tasksStructured work itemstitle, description, status, assignedBy
agents/{id}/memoryPersistent agent memorytype, key, content, metadata
agents/{id}/private/runtimeAgent secrets (channel token, proxy secret)proxySecret, channelToken
agents/{id}/integrationAuditProxy request decision logmethod, path, allowed, reason

Message Status Machine

Agent messages follow a strict status progression:

pending --> processing --> complete

Messages arrive as pending, the agent loop marks them processing while working, and writes responseContent when marking complete. Channel adapters watch the same doc via waitForReply -- no second query needed.

Memory Types

Agent memory has five categories:

TypePurposeExample Keys
identityWho the agent isrole, personality, skills, constraints
user_relationshipWhat it knows about the userpreferences, goals, communication_style
taskActive work state across sessionscurrent_task, status, blockers, next_steps
knowledgeLearned facts about the domainrepo_structure, architecture, dependencies
team_sharedVisible to all agents in the instanceshared_plan, handoffs, decisions

Firestore Path Reference

All paths are built via shared/src/paths.ts:

typescript
import { paths } from "@archagent/shared";

paths.platformConfig()          // "config/platform"
paths.user(userId)              // "users/{userId}"
paths.userSecrets(userId)       // "users/{userId}/private/secrets"
paths.instance(instanceId)      // "instances/{instanceId}"
paths.agents()                  // "agents"
paths.agent(agentId)            // "agents/{agentId}"
paths.agentMessages(agentId)    // "agents/{agentId}/messages"
paths.agentTasks(agentId)       // "agents/{agentId}/tasks"
paths.agentMemory(agentId)      // "agents/{agentId}/memory"
paths.agentSecrets(agentId)     // "agents/{agentId}/private/runtime"
paths.context(instanceId)       // "instances/{instanceId}/context"
paths.approvals(instanceId)     // "instances/{instanceId}/approvals"
paths.integrationAudit(agentId) // "agents/{agentId}/integrationAudit"