Skip to main content

Function: sanitizeAgentWorkspaceId()

sanitizeAgentWorkspaceId(raw): string

Defined in: packages/agentos/src/cognition/marketplace/workspace/AgentWorkspace.ts:95

Sanitize an arbitrary agent identifier into a safe folder name.

  • trims whitespace
  • replaces slashes with '-'
  • collapses non-alphanumerics to '-'
  • limits length to 80 chars
  • names an id that cleans to nothing 'agent'

The cleaned name keeps dots, so it is then held to the rule every name built from data meets: an id whose cleaned name starts or ends with a dot, such as ., .., /.. or .., or whose first 80 characters end with one, is refused. Dots inside a name stay, so a/../b cleans to a-..-b, one folder name.

Parameters​

raw​

string

The agent's id.

Returns​

string

The folder name.

Throws​

InvalidAgentWorkspaceIdError when the cleaned name breaks the rule.