mirror of
https://github.com/Tencent/BrowserSkill.git
synced 2026-09-10 13:01:23 +08:00
fix(dsh-plugin-browserskill): include the bsk error hint in the thrown message
The daemon's JSON error envelope carries an actionable hint (e.g. 'choose an input, textarea, or contenteditable element from the latest snapshot'), but the thrown BskError only embedded the message field, so the model-facing error text never showed the hint. Append it.
This commit is contained in:
@@ -177,7 +177,10 @@ export function parseBskJson(result: BskRunResult, commandLabel: string): unknow
|
||||
}
|
||||
const message =
|
||||
parsed?.message ?? (result.stderr.trim() || body || `bsk ${commandLabel} failed`);
|
||||
throw new BskError(`bsk ${commandLabel} failed: ${message}`, {
|
||||
// Surface the envelope's actionable hint in the model-facing message; a
|
||||
// hint the model cannot see cannot be followed.
|
||||
const withHint = parsed?.hint !== undefined ? `${message} (hint: ${parsed.hint})` : message;
|
||||
throw new BskError(`bsk ${commandLabel} failed: ${withHint}`, {
|
||||
code: parsed?.code,
|
||||
hint: parsed?.hint,
|
||||
exitCode: result.code,
|
||||
|
||||
@@ -109,6 +109,7 @@ describe("parseBskJson", () => {
|
||||
exitCode: 3,
|
||||
});
|
||||
expect((error as Error).message).toContain("no browser connected");
|
||||
expect((error as Error).message).toContain("hint: open Chrome");
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user