mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-10 15:49:29 +08:00
- Add session-based user data persistence using Electron partitions - Implement multi-tab support with tab management operations - Add new tools: create_tab, list_tabs, close_tab, switch_tab - Update existing tools (open, execute, fetch, reset) to support tabId parameter - Refactor controller to manage sessions with multiple tabs - Add comprehensive documentation in README.md - Add TypeScript interfaces for SessionInfo and TabInfo BREAKING CHANGE: Controller now manages sessions with tabs instead of single windows per session
44 lines
1.4 KiB
TypeScript
44 lines
1.4 KiB
TypeScript
import * as z from 'zod'
|
|
|
|
import type { CdpBrowserController } from '../controller'
|
|
import { logger } from '../types'
|
|
import { errorResponse, successResponse } from './utils'
|
|
|
|
export const ResetSchema = z.object({
|
|
privateMode: z.boolean().optional().describe('true=private window, false=normal window, omit=all windows'),
|
|
tabId: z.string().optional().describe('Close specific tab only (requires privateMode)')
|
|
})
|
|
|
|
export const resetToolDefinition = {
|
|
name: 'reset',
|
|
description:
|
|
'Close browser windows and clear state. Call when done browsing to free resources. Omit all parameters to close everything.',
|
|
inputSchema: {
|
|
type: 'object',
|
|
properties: {
|
|
privateMode: {
|
|
type: 'boolean',
|
|
description: 'true=reset private window only, false=reset normal window only, omit=reset all'
|
|
},
|
|
tabId: {
|
|
type: 'string',
|
|
description: 'Close specific tab only (requires privateMode to be set)'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
export async function handleReset(controller: CdpBrowserController, args: unknown) {
|
|
try {
|
|
const { privateMode, tabId } = ResetSchema.parse(args)
|
|
await controller.reset(privateMode, tabId)
|
|
return successResponse('reset')
|
|
} catch (error) {
|
|
logger.error('Reset failed', {
|
|
error,
|
|
privateMode: args && typeof args === 'object' && 'privateMode' in args ? args.privateMode : undefined
|
|
})
|
|
return errorResponse(error instanceof Error ? error : String(error))
|
|
}
|
|
}
|