Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/lib/feedback-hint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,18 @@ export const NO_HINT_TOOLS: ReadonlySet<string> = new Set([
"getAccessibilityAuthConfig",
]);

/**
* Set (as a symbol-keyed property, so it is never serialised to the client) on an error
* result that the user resolves on their own account, such as a plan limit. Asking the
* agent to report those with submitFeedback only sends it the wrong way.
*/
export const NO_FEEDBACK_HINT = Symbol.for("browserstack.mcp.noFeedbackHint");

export function withFeedbackHint<T>(toolName: string, result: T): T {
if (NO_HINT_TOOLS.has(toolName)) return result;
const r = result as { isError?: unknown; content?: unknown } | null;
if (typeof r !== "object" || r === null || r.isError !== true) return result;
if ((r as Record<symbol, unknown>)[NO_FEEDBACK_HINT] === true) return result;
if (!Array.isArray(r.content) || SELF_FIXABLE.test(textOf(r))) return result;
return {
...r,
Expand Down
Loading