@@ -122,17 +122,14 @@ export const Agents: React.FC = () => {
122
122
try {
123
123
const selected = await openDialog ( {
124
124
filters : [
125
- { name : 'JSON Files ' , extensions : [ 'json' ] } ,
125
+ { name : 'opcode Agent ' , extensions : [ 'opcode.json' , 'json' ] } ,
126
126
{ name : 'All Files' , extensions : [ '*' ] }
127
127
] ,
128
128
multiple : false ,
129
129
} ) ;
130
130
131
131
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 ) ;
136
133
setToast ( { message : `Imported agent: ${ importedAgent . name } ` , type : 'success' } ) ;
137
134
loadAgents ( ) ;
138
135
}
@@ -145,18 +142,14 @@ export const Agents: React.FC = () => {
145
142
const handleExportAgent = async ( agent : Agent ) => {
146
143
try {
147
144
const path = await save ( {
148
- defaultPath : `${ agent . name } .json` ,
145
+ defaultPath : `${ agent . name . toLowerCase ( ) . replace ( / \s + / g , '-' ) } .opcode .json` ,
149
146
filters : [
150
- { name : 'JSON Files ' , extensions : [ 'json' ] }
147
+ { name : 'opcode Agent ' , extensions : [ 'opcode. json' ] }
151
148
]
152
149
} ) ;
153
150
154
151
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 } ) ;
160
153
setToast ( { message : `Exported agent: ${ agent . name } ` , type : 'success' } ) ;
161
154
}
162
155
} catch ( error ) {
@@ -461,4 +454,4 @@ export const Agents: React.FC = () => {
461
454
</ div >
462
455
</ div >
463
456
) ;
464
- } ;
457
+ } ;
0 commit comments