Skip to main content

skillAgentMapper

Workspace API


Workspace API / services/skillAgentMapper

services/skillAgentMapper

Functions

getAgentKeyForSkill()

getAgentKeyForSkill(skillKey, orgId): Promise<string | null>

Defined in: services/skillAgentMapper.ts:59

Get agent key for a skill

Lookup priority:

  1. Cache (if available)
  2. Database lookup (skills_agents table by skill_key or agent_key)
  3. Skill metadata (agent_key field)
  4. Fallback to skill_key as agent_key

Parameters

skillKey

string

Skill key to map

orgId

string

Organization ID for RLS context

Returns

Promise<string | null>

Agent key or null if no mapping found


getAgentKeyForSkillVersion()

getAgentKeyForSkillVersion(skillVersion, orgId): Promise<string>

Defined in: services/skillAgentMapper.ts:148

Get agent key from skill version with full fallback chain

Lookup priority:

  1. Cache (if available)
  2. Database lookup (skills_agents table)
  3. Skill version metadata.agent_key
  4. Fallback to skill_key

Parameters

skillVersion

SkillVersion

Skill version to get agent key for

orgId

string

Organization ID for RLS context

Returns

Promise<string>

Agent key


ensureAgentExists()

ensureAgentExists(skillVersion, orgId): Promise<string>

Defined in: services/skillAgentMapper.ts:194

Ensure an agent exists for a skill version

If no agent exists in database and this is a VoltAgent skill, this will need to be created via the agent creation API.

For now, this is a validation check that returns the agent key and logs warnings if mapping is missing.

Parameters

skillVersion

SkillVersion

Skill version to ensure agent for

orgId

string

Organization ID

Returns

Promise<string>

Agent key (may be fallback)


clearMappingCache()

clearMappingCache(skillKey, orgId): void

Defined in: services/skillAgentMapper.ts:239

Clear cache entry for a skill

Used when agent mappings change (e.g., after agent publish/update)

Parameters

skillKey

string

orgId

string

Returns

void


clearAllMappingCache()

clearAllMappingCache(): void

Defined in: services/skillAgentMapper.ts:250

Clear entire mapping cache

Used for bulk operations or testing

Returns

void


getCacheStats()

getCacheStats(): object

Defined in: services/skillAgentMapper.ts:258

Get cache statistics (for monitoring)

Returns

object

size

size: number

maxSize

maxSize: number

ttlMs

ttlMs: number