feat: add JSON import functionality for CC agents

This commit is contained in:
Vivek R
2025-06-23 15:35:14 +05:30
parent ad035036e8
commit bec8cea1e7
4 changed files with 193 additions and 12 deletions

View File

@@ -747,6 +747,34 @@ export const api = {
}
},
/**
* Imports an agent from JSON data
* @param jsonData - The JSON string containing the agent export
* @returns Promise resolving to the imported agent
*/
async importAgent(jsonData: string): Promise<Agent> {
try {
return await invoke<Agent>('import_agent', { jsonData });
} catch (error) {
console.error("Failed to import agent:", error);
throw error;
}
},
/**
* Imports an agent from a file
* @param filePath - The path to the JSON file
* @returns Promise resolving to the imported agent
*/
async importAgentFromFile(filePath: string): Promise<Agent> {
try {
return await invoke<Agent>('import_agent_from_file', { filePath });
} catch (error) {
console.error("Failed to import agent from file:", error);
throw error;
}
},
/**
* Executes an agent
* @param agentId - The agent ID to execute