Skip to main content

agentSyncService

Workspace API


Workspace API / services/agentSyncService

services/agentSyncService

Interfaces

VoltAgentAgent

Defined in: services/agentSyncService.ts:19

VoltAgent agent from server /agents endpoint

Properties

id

id: string

Defined in: services/agentSyncService.ts:20

name

name: string

Defined in: services/agentSyncService.ts:21

instructions

instructions: string

Defined in: services/agentSyncService.ts:22

model?

optional model: string

Defined in: services/agentSyncService.ts:23

tools?

optional tools: any[]

Defined in: services/agentSyncService.ts:24

metadata?

optional metadata: Record<string, unknown>

Defined in: services/agentSyncService.ts:25


SyncResult

Defined in: services/agentSyncService.ts:31

Sync result

Properties

imported

imported: number

Defined in: services/agentSyncService.ts:32

updated

updated: number

Defined in: services/agentSyncService.ts:33

skipped

skipped: number

Defined in: services/agentSyncService.ts:34

errors

errors: string[]

Defined in: services/agentSyncService.ts:35

details

details: object

Defined in: services/agentSyncService.ts:36

imported

imported: string[]

updated

updated: string[]

skipped

skipped: string[]


AgentChange

Defined in: services/agentSyncService.ts:46

Agent change detected from Console

Properties

agentKey

agentKey: string

Defined in: services/agentSyncService.ts:47

type

type: "new" | "updated"

Defined in: services/agentSyncService.ts:48

consoleAgent

consoleAgent: VoltAgentAgent

Defined in: services/agentSyncService.ts:49

Functions

fetchConsoleAgents()

fetchConsoleAgents(): Promise<VoltAgentAgent[]>

Defined in: services/agentSyncService.ts:60

Fetch all agents from VoltAgent server

Calls GET /agents endpoint to retrieve current agent list.

Returns

Promise<VoltAgentAgent[]>

Array of VoltAgent agents

Throws

Error if server is unreachable or returns invalid response


detectAgentChanges()

detectAgentChanges(consoleAgents, dbAgents, userId, organizationId): Promise<AgentChange[]>

Defined in: services/agentSyncService.ts:125

Detect changes between Console agents and database agents

Compares agent lists to identify new agents and updated agents. For existing agents, compares instructions, model, and tools to detect changes.

Parameters

consoleAgents

VoltAgentAgent[]

Agents from VoltAgent server

dbAgents

Agent[]

Agents from app database (with active version details)

userId

string

organizationId

string

Returns

Promise<AgentChange[]>

Array of detected changes (new or updated)


importAgentFromConsole()

importAgentFromConsole(consoleAgent, organizationId, userId): Promise<{ id: string; agent_key: string; }>

Defined in: services/agentSyncService.ts:233

Import agent from VoltAgent Console to app database

Creates a new agent record with initial version. Logs audit trail with source: 'console'.

Parameters

consoleAgent

VoltAgentAgent

Agent data from VoltAgent Console

organizationId

string

Organization ID to assign ownership

userId

string

User ID performing the import (for audit trail)

Returns

Promise<{ id: string; agent_key: string; }>

Created agent record


syncAgentsFromConsole()

syncAgentsFromConsole(organizationId, userId): Promise<SyncResult>

Defined in: services/agentSyncService.ts:410

Sync agents from VoltAgent Console to app database

Main sync function that:

  1. Fetches agents from VoltAgent server
  2. Compares with database agents
  3. Imports new agents
  4. Updates existing agents (creates new versions)
  5. Logs all changes with source: 'console'

Parameters

organizationId

string

Organization ID for ownership

userId

string

User ID performing the sync (for audit trail)

Returns

Promise<SyncResult>

Sync result with counts and details