From 0dacbda9da8d988189a608a486f97e8dce3d96b8 Mon Sep 17 00:00:00 2001 From: Simon <10131203+gaomeng1900@users.noreply.github.com> Date: Thu, 5 Mar 2026 16:54:41 +0800 Subject: [PATCH] chore: improve logging --- packages/core/src/utils/autoFixer.ts | 16 ++++++++-------- packages/core/src/utils/index.ts | 2 +- packages/llms/src/utils.ts | 4 +--- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/packages/core/src/utils/autoFixer.ts b/packages/core/src/utils/autoFixer.ts index bbde7aa..732189a 100644 --- a/packages/core/src/utils/autoFixer.ts +++ b/packages/core/src/utils/autoFixer.ts @@ -4,6 +4,8 @@ import * as z from 'zod' import type { PageAgentTool } from '../tools' +const log = console.log.bind(console, chalk.yellow('[autoFixer]')) + /** * Normalize LLM response and fix common format issues. * @@ -34,7 +36,7 @@ export function normalizeResponse(response: any, tools?: Map): any { (k) => !(schema.shape as Record)[k].safeParse(undefined).success ) if (requiredKey) { - console.log( - chalk.yellow(`[normalizeResponse] coercing primitive action input for "${toolName}"`) - ) + log(`coercing primitive action input for "${toolName}"`) value = { [requiredKey]: value } } } diff --git a/packages/core/src/utils/index.ts b/packages/core/src/utils/index.ts index e62d819..3da5340 100644 --- a/packages/core/src/utils/index.ts +++ b/packages/core/src/utils/index.ts @@ -1,6 +1,6 @@ import chalk from 'chalk' -export { normalizeResponse } from './autoFixer' +export * from './autoFixer' export async function waitFor(seconds: number): Promise { await new Promise((resolve) => setTimeout(resolve, seconds * 1000)) diff --git a/packages/llms/src/utils.ts b/packages/llms/src/utils.ts index cbc08d8..4320e7a 100644 --- a/packages/llms/src/utils.ts +++ b/packages/llms/src/utils.ts @@ -6,9 +6,7 @@ import * as z from 'zod' import type { Tool } from './types' -function debug(message: string) { - console.debug(chalk.gray('[LLM]'), message) -} +const debug = console.debug.bind(console, chalk.gray('[LLM]')) /** * Convert Zod schema to OpenAI tool format