fix(ext): fix multi-thread logic; extensive logging and error handling

This commit is contained in:
Simon
2026-02-11 19:51:19 +08:00
parent fcb9ec4e57
commit 7c87c90258
9 changed files with 268 additions and 116 deletions

View File

@@ -31,8 +31,11 @@ export function createTabTools(tabsController: TabsController): Record<string, T
}),
execute: async (input: unknown) => {
const { url } = input as { url: string }
const result = await tabsController.openNewTab(url)
return result.message
try {
return await tabsController.openNewTab(url)
} catch (error) {
return `❌ Failed: ${error instanceof Error ? error.message : String(error)}`
}
},
},
@@ -44,7 +47,11 @@ export function createTabTools(tabsController: TabsController): Record<string, T
}),
execute: async (input: unknown) => {
const { tab_id } = input as { tab_id: number }
return (await tabsController.switchToTab(tab_id)).message
try {
return await tabsController.switchToTab(tab_id)
} catch (error) {
return `❌ Failed: ${error instanceof Error ? error.message : String(error)}`
}
},
},
@@ -56,7 +63,11 @@ export function createTabTools(tabsController: TabsController): Record<string, T
}),
execute: async (input: unknown) => {
const { tab_id } = input as { tab_id: number }
return (await tabsController.closeTab(tab_id)).message
try {
return await tabsController.closeTab(tab_id)
} catch (error) {
return `❌ Failed: ${error instanceof Error ? error.message : String(error)}`
}
},
},
}