Skip to main content

Function: importAgentFromJSON()

importAgentFromJSON(json, options?): Agent

Defined in: packages/agentos/src/api/agentExport.ts:390

Imports an agent from a JSON string.

Parses the string and delegates to importAgent.

Parameters​

json​

string

JSON string containing an AgentExportConfig.

options?​

ImportAgentOptions

Values for what the export redacted or replaced.

Returns​

Agent

A new Agent instance.

Throws​

If the JSON is malformed.

Throws​

If the parsed config fails validation or holds a value import cannot restore.

Example​

const agent = importAgentFromJSON(fs.readFileSync('agent.json', 'utf-8'));