Skip to content
Open
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
5 changes: 5 additions & 0 deletions .changeset/shy-sides-crash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@browserbasehq/stagehand": patch
---

Fix key action mapping in Anthropic CUA
14 changes: 2 additions & 12 deletions packages/core/lib/v3/agent/AnthropicCUAClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { AgentScreenshotProviderError } from "../types/public/sdkErrors";
import Anthropic from "@anthropic-ai/sdk";
import { ToolSet } from "ai";
import { AgentClient } from "./AgentClient";
import { mapKeyToPlaywright } from "./utils/cuaKeyMapping";
import { compressConversationImages } from "./utils/imageCompression";
import { toJsonSchema } from "../zodCompat";
import type { StagehandZodSchema } from "../zodCompat";
Expand Down Expand Up @@ -772,10 +771,10 @@ export class AnthropicCUAClient extends AgentClient {
text: input.text as string,
...input,
};
} else if (action === "keypress") {
} else if (action === "keypress" || action === "key") {
return {
type: "keypress",
keys: input.keys as string[],
keys: [input.text as string],
...input,
};
} else if (action === "double_click" || action === "doubleClick") {
Expand Down Expand Up @@ -865,15 +864,6 @@ export class AnthropicCUAClient extends AgentClient {
type: "wait",
...input,
};
} else if (action === "key") {
const text = input.text as string;
const mappedKey = mapKeyToPlaywright(text);

return {
type: "key",
text: mappedKey,
...input,
};
} else if (action === "left_click") {
// Convert left_click to regular click
const coordinates = input.coordinate as number[] | undefined;
Expand Down