The whole hunk
from line 929, old and new numbered
/
lines
from line 929
929929
930930
931931 def handle_computer_action(name, tool_input):
932 if name == "screenshot":
933 return capture_screenshot()
934 elif name == "left_click":
935 # coordinate is optional; without it, click where the cursor already is
936 return click(tool_input.get("coordinate"))
937 elif name == "type":
938 return type_text(tool_input["text"])
932 match name:
933 case "screenshot":
934 return capture_screenshot()
935 case "left_click":
936 # coordinate is optional; without it, click where the cursor already is
937 return click(tool_input.get("coordinate"))
938 case "type":
939 return type_text(tool_input["text"])
939940 # Handle other actions as needed
940941 raise ValueError(f"Unknown or unimplemented member: {name}")
941942 ```
from line 977
976977 ): string | Anthropic.ImageBlockParam[] {
977978 const params: object =
978979 typeof input === "object" && input !== null ? input : {};
979 if (action === "screenshot") {
980 return captureScreenshot();
981 } else if (action === "left_click") {
982 // coordinate is optional on the toolset; without one, click at the cursor
983 if ("coordinate" in params && Array.isArray(params.coordinate)) {
984 const [x, y] = params.coordinate;
985 return clickAt(x, y);
986 }
987 return clickAtCursor();
988 } else if (action === "type" && "text" in params) {
989 return typeText(String(params.text));
980 switch (action) {
981 case "screenshot":
982 return captureScreenshot();
983 case "left_click":
984 // coordinate is optional on the toolset; without one, click at the cursor
985 if ("coordinate" in params && Array.isArray(params.coordinate)) {
986 const [x, y] = params.coordinate;
987 return clickAt(x, y);
988 }
989 return clickAtCursor();
990 case "type":
991 if ("text" in params) {
992 return typeText(String(params.text));
993 }
994 break;
990995 }
991996 // Handle other actions as needed
992997 throw new Error(`Unknown or unimplemented member: ${action}`);
from line 1500
14951500 $failed = false;
14961501 foreach ($response->content as $block) {
14971502 // This example declares only the computer toolset; route other tools here if you add them.
1498 if (!($block instanceof ToolUseBlock) || $block->toolsetName !== 'computer') {
1503 if (!($block instanceof \Anthropic\Messages\ToolUseBlock) || $block->toolsetName !== 'computer') {
14991504 continue;
15001505 }
15011506 $result = ['type' => 'tool_result', 'tool_use_id' => $block->id, 'toolset_name' => 'computer'];