@@ -122,17 +122,14 @@ export const Agents: React.FC = () => {
122122 try {
123123 const selected = await openDialog ( {
124124 filters : [
125- { name : 'JSON Files ' , extensions : [ 'json' ] } ,
125+ { name : 'opcode Agent ' , extensions : [ 'opcode.json' , 'json' ] } ,
126126 { name : 'All Files' , extensions : [ '*' ] }
127127 ] ,
128128 multiple : false ,
129129 } ) ;
130130
131131 if ( selected ) {
132- const fileContent = await invoke < string > ( 'read_text_file' , { path : selected } ) ;
133- const agentData = JSON . parse ( fileContent ) ;
134-
135- const importedAgent = await api . importAgent ( JSON . stringify ( agentData ) ) ;
132+ const importedAgent = await api . importAgentFromFile ( selected as string ) ;
136133 setToast ( { message : `Imported agent: ${ importedAgent . name } ` , type : 'success' } ) ;
137134 loadAgents ( ) ;
138135 }
@@ -145,18 +142,14 @@ export const Agents: React.FC = () => {
145142 const handleExportAgent = async ( agent : Agent ) => {
146143 try {
147144 const path = await save ( {
148- defaultPath : `${ agent . name } .json` ,
145+ defaultPath : `${ agent . name . toLowerCase ( ) . replace ( / \s + / g , '-' ) } .opcode .json` ,
149146 filters : [
150- { name : 'JSON Files ' , extensions : [ 'json' ] }
147+ { name : 'opcode Agent ' , extensions : [ 'opcode. json' ] }
151148 ]
152149 } ) ;
153150
154151 if ( path && agent . id ) {
155- const agentData = await api . exportAgent ( agent . id ) ;
156- await invoke ( 'write_text_file' , {
157- path,
158- contents : agentData
159- } ) ;
152+ await invoke ( 'export_agent_to_file' , { id : agent . id , filePath : path } ) ;
160153 setToast ( { message : `Exported agent: ${ agent . name } ` , type : 'success' } ) ;
161154 }
162155 } catch ( error ) {
@@ -461,4 +454,4 @@ export const Agents: React.FC = () => {
461454 </ div >
462455 </ div >
463456 ) ;
464- } ;
457+ } ;
0 commit comments