The whole hunk
from line 247, old and new numbered
/
lines
from line 247
247247
248248 ```php PHP
249249 use Anthropic\Client;
250 use Anthropic\Messages\TextBlock;
251250 use Anthropic\Messages\ToolUseBlock;
252251
253252 $client = new Client();
from line 1412
14131412 # so reshape each block to the request schema before echoing it back.
14141413 def assistant_content_param(content)
14151414 content.map do |block|
1416 case block.type
1417 when :tool_use
1415 case block
1416 when Anthropic::Models::ToolUseBlock
14181417 input = parse_tool_input(block.input)
14191418 {type: "tool_use", id: block.id, name: block.name, input: input}
1420 when :text
1419 when Anthropic::Models::TextBlock
14211420 {type: "text", text: block.text}
1422 when :thinking
1421 when Anthropic::Models::ThinkingBlock
14231422 {type: "thinking", thinking: block.thinking, signature: block.signature}
1424 when :redacted_thinking then {type: "redacted_thinking", data: block.data}
1423 when Anthropic::Models::RedactedThinkingBlock then {type: "redacted_thinking", data: block.data}
14251424 else
14261425 block.to_h
14271426 end
from line 1468
14691468 for block in response.content:
14701469 if block.type != "tool_use":
14711470 continue
1472 if block.name == "report_findings":
1473 report = json.dumps(block.input, indent=2)
1474 output, is_error = "Findings recorded.", False
1475 elif block.name == "bash":
1476 output, is_error = handle_bash_block(block)
1477 else:
1478 output, is_error = f"unknown tool: {block.name}", True
1471 match block.name:
1472 case "report_findings":
1473 report = json.dumps(block.input, indent=2)
1474 output, is_error = "Findings recorded.", False
1475 case "bash":
1476 output, is_error = handle_bash_block(block)
1477 case _:
1478 output, is_error = f"unknown tool: {block.name}", True
14791479 tool_results.append(
14801480 {
14811481 "type": "tool_result",
from line 1535
15351535 }
15361536 let output: string;
15371537 let isError: boolean;
1538 if (block.name === "report_findings") {
1539 report = JSON.stringify(block.input, null, 2);
1540 output = "Findings recorded.";
1541 isError = false;
1542 } else if (block.name === "bash") {
1543 ({ output, isError } = await handleBashBlock(block));
1544 } else {
1545 output = `unknown tool: ${block.name}`;
1546 isError = true;
1538 switch (block.name) {
1539 case "report_findings":
1540 report = JSON.stringify(block.input, null, 2);
1541 output = "Findings recorded.";
1542 isError = false;
1543 break;
1544 case "bash":
1545 ({ output, isError } = await handleBashBlock(block));
1546 break;
1547 default:
1548 output = `unknown tool: ${block.name}`;
1549 isError = true;
15471550 }
15481551 toolResults.push({
15491552 type: "tool_result",
from line 1835
18321835 }
18331836 }
18341837 foreach ($jsonBuffers as $index => $buffer) {
1835 if ($buffer !== '' && $blocks[$index] instanceof ToolUseBlock) {
1838 if ($buffer !== '' && $blocks[$index] instanceof \Anthropic\Messages\ToolUseBlock) {
18361839 $decoded = json_decode($buffer, true);
18371840 $blocks[$index] = $blocks[$index]->withInput(is_array($decoded) ? $decoded : []);
18381841 }
from line 1872
18691872 if ($stopReason !== 'tool_use') {
18701873 $text = '';
18711874 foreach ($content as $block) {
1872 if ($block instanceof TextBlock) {
1875 if ($block instanceof \Anthropic\Messages\TextBlock) {
18731876 $text .= $block->text;
18741877 }
18751878 }
from line 1884
18811884 $report = null;
18821885 $toolResults = [];
18831886 foreach ($content as $block) {
1884 if (!$block instanceof ToolUseBlock) {
1887 if (!$block instanceof \Anthropic\Messages\ToolUseBlock) {
18851888 continue;
18861889 }
18871890 if ($block->name === 'report_findings') {
from line 3027
30243027 for block in response.content:
30253028 if block.type != "tool_use":
30263029 continue
3027 if block.name == "Workflow":
3028 output, is_error = run_workflow(self.model, block.input.get("subtasks", []))
3029 elif block.name == "bash":
3030 output, is_error = handle_bash_block(block)
3031 else:
3032 output, is_error = f"unknown tool: {block.name}", True
3030 match block.name:
3031 case "Workflow":
3032 output, is_error = run_workflow(self.model, block.input.get("subtasks", []))
3033 case "bash":
3034 output, is_error = handle_bash_block(block)
3035 case _:
3036 output, is_error = f"unknown tool: {block.name}", True
30333037 tool_results.append(
30343038 {
30353039 "type": "tool_result",
from line 3146
31423146 }
31433147 let output: string;
31443148 let isError: boolean;
3145 if (block.name === "Workflow") {
3146 const input = block.input as { subtasks?: unknown };
3147 ({ output, isError } = await runWorkflow(this.model, input.subtasks ?? []));
3148 } else if (block.name === "bash") {
3149 ({ output, isError } = await handleBashBlock(block));
3150 } else {
3151 output = `unknown tool: ${block.name}`;
3152 isError = true;
3149 switch (block.name) {
3150 case "Workflow": {
3151 const input = block.input as { subtasks?: unknown };
3152 ({ output, isError } = await runWorkflow(this.model, input.subtasks ?? []));
3153 break;
3154 }
3155 case "bash":
3156 ({ output, isError } = await handleBashBlock(block));
3157 break;
3158 default:
3159 output = `unknown tool: ${block.name}`;
3160 isError = true;
31533161 }
31543162 toolResults.push({
31553163 type: "tool_result",
from line 3650
36423650 if ($stopReason !== 'tool_use') {
36433651 $text = '';
36443652 foreach ($content as $block) {
3645 if ($block instanceof TextBlock) {
3653 if ($block instanceof \Anthropic\Messages\TextBlock) {
36463654 $text .= $block->text;
36473655 }
36483656 }
from line 3664
36563664
36573665 $toolResults = [];
36583666 foreach ($content as $block) {
3659 if (!$block instanceof ToolUseBlock) {
3667 if (!$block instanceof \Anthropic\Messages\ToolUseBlock) {
36603668 continue;
36613669 }
36623670 if ($block->name === 'Workflow') {