@@ -9,20 +9,20 @@ export function useManipulateEditorTool() {
99 const { getEditors } = useJournlAgentAwareness ( ) ;
1010 const tool = createClientTool ( {
1111 execute : async ( toolCall , chat ) => {
12- const editor = getEditors ( ) . get ( toolCall . input . editorId ) ;
12+ try {
13+ const editor = getEditors ( ) . get ( toolCall . input . editorId ) ;
1314
14- if ( ! editor ) {
15- const availableEditors = JSON . stringify (
16- Object . fromEntries ( getEditors ( ) . entries ( ) ) ,
17- ) ;
18- return await chat . addToolResult ( {
19- output : `Editor ${ toolCall . input . editorId } was not found. Please call the tool again with the available editors: ${ availableEditors } ` ,
20- tool : toolCall . toolName ,
21- toolCallId : toolCall . toolCallId ,
22- } ) ;
23- }
15+ if ( ! editor ) {
16+ const availableEditors = JSON . stringify (
17+ Object . fromEntries ( getEditors ( ) . entries ( ) ) ,
18+ ) ;
19+ return await chat . addToolResult ( {
20+ output : `Editor ${ toolCall . input . editorId } was not found. Please call the tool again with the available editors: ${ availableEditors } ` ,
21+ tool : toolCall . toolName ,
22+ toolCallId : toolCall . toolCallId ,
23+ } ) ;
24+ }
2425
25- try {
2626 const aiExtension = getAIExtension ( editor ) ;
2727
2828 const result = await aiExtension . callLLM ( {
@@ -37,15 +37,15 @@ export function useManipulateEditorTool() {
3737
3838 const changes = await result ?. llmResult . streamObjectResult ?. object ;
3939
40- await chat . addToolResult ( {
40+ void chat . addToolResult ( {
4141 output : `The following changes were made to the editor: ${ JSON . stringify (
4242 changes ,
4343 ) } `,
4444 tool : toolCall . toolName ,
4545 toolCallId : toolCall . toolCallId ,
4646 } ) ;
4747 } catch ( error ) {
48- await chat . addToolResult ( {
48+ void chat . addToolResult ( {
4949 output : `Error when calling the tool: ${ error } ` ,
5050 tool : toolCall . toolName ,
5151 toolCallId : toolCall . toolCallId ,
0 commit comments