(args: z.infer<typeof ConsoleArgs>, _ctx: ToolContext)
| 220 | argsSchema = ConsoleArgs; |
| 221 | |
| 222 | async execute(args: z.infer<typeof ConsoleArgs>, _ctx: ToolContext): Promise<ToolResult> { |
| 223 | const s = await getSession(); |
| 224 | const level = args.level ?? 'all'; |
| 225 | const limit = args.limit ?? 50; |
| 226 | const filtered = level === 'all' |
| 227 | ? s.consoleBuffer |
| 228 | : s.consoleBuffer.filter(m => m.type === level); |
| 229 | const slice = filtered.slice(-limit); |
| 230 | const consoleLines = slice.length === 0 |
| 231 | ? ' (no messages)' |
| 232 | : slice.map(m => ` [${m.type}] ${m.text}${m.location ? ` (${m.location})` : ''}`).join('\n'); |
| 233 | const errors = s.errorBuffer.length === 0 |
| 234 | ? ' (no page errors)' |
| 235 | : s.errorBuffer.map(e => ` ${e.message}`).join('\n'); |
| 236 | return { |
| 237 | content: `Console (${slice.length}/${filtered.length} ${level} message(s)):\n${consoleLines}\n\nPage errors (${s.errorBuffer.length}):\n${errors}`, |
| 238 | }; |
| 239 | } |
| 240 | } |
| 241 | |
| 242 | const EvaluateArgs = z.object({ |
nothing calls this directly
no test coverage detected