@ai-sdk/anthropic 3.0.21 → 3.0.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/index.d.mts +7 -0
  3. package/dist/index.d.ts +7 -0
  4. package/dist/index.js +20 -9
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.mjs +21 -9
  7. package/dist/index.mjs.map +1 -1
  8. package/package.json +9 -5
  9. package/src/anthropic-provider.ts +32 -7
  10. package/src/__fixtures__/anthropic-code-execution-20250825.1.chunks.txt +0 -248
  11. package/src/__fixtures__/anthropic-code-execution-20250825.1.json +0 -70
  12. package/src/__fixtures__/anthropic-code-execution-20250825.2.chunks.txt +0 -984
  13. package/src/__fixtures__/anthropic-code-execution-20250825.2.json +0 -111
  14. package/src/__fixtures__/anthropic-code-execution-20250825.pptx-skill.chunks.txt +0 -691
  15. package/src/__fixtures__/anthropic-code-execution-20250825.pptx-skill.json +0 -1801
  16. package/src/__fixtures__/anthropic-json-other-tool.1.chunks.txt +0 -13
  17. package/src/__fixtures__/anthropic-json-other-tool.1.json +0 -26
  18. package/src/__fixtures__/anthropic-json-output-format.1.chunks.txt +0 -120
  19. package/src/__fixtures__/anthropic-json-output-format.1.json +0 -25
  20. package/src/__fixtures__/anthropic-json-tool.1.chunks.txt +0 -9
  21. package/src/__fixtures__/anthropic-json-tool.1.json +0 -37
  22. package/src/__fixtures__/anthropic-json-tool.2.chunks.txt +0 -14
  23. package/src/__fixtures__/anthropic-mcp.1.chunks.txt +0 -17
  24. package/src/__fixtures__/anthropic-mcp.1.json +0 -39
  25. package/src/__fixtures__/anthropic-memory-20250818.1.json +0 -28
  26. package/src/__fixtures__/anthropic-message-delta-input-tokens.chunks.txt +0 -8
  27. package/src/__fixtures__/anthropic-programmatic-tool-calling.1.chunks.txt +0 -278
  28. package/src/__fixtures__/anthropic-programmatic-tool-calling.1.json +0 -106
  29. package/src/__fixtures__/anthropic-tool-no-args.chunks.txt +0 -13
  30. package/src/__fixtures__/anthropic-tool-no-args.json +0 -31
  31. package/src/__fixtures__/anthropic-tool-search-bm25.1.chunks.txt +0 -47
  32. package/src/__fixtures__/anthropic-tool-search-bm25.1.json +0 -67
  33. package/src/__fixtures__/anthropic-tool-search-deferred-bm25.2.json +0 -65
  34. package/src/__fixtures__/anthropic-tool-search-deferred-bm25.chunks.txt +0 -115
  35. package/src/__fixtures__/anthropic-tool-search-deferred-regex.2.json +0 -69
  36. package/src/__fixtures__/anthropic-tool-search-deferred-regex.chunks.txt +0 -119
  37. package/src/__fixtures__/anthropic-tool-search-regex.1.chunks.txt +0 -51
  38. package/src/__fixtures__/anthropic-tool-search-regex.1.json +0 -65
  39. package/src/__fixtures__/anthropic-web-fetch-tool.1.chunks.txt +0 -64
  40. package/src/__fixtures__/anthropic-web-fetch-tool.1.json +0 -54
  41. package/src/__fixtures__/anthropic-web-fetch-tool.2.json +0 -56
  42. package/src/__fixtures__/anthropic-web-fetch-tool.error.json +0 -46
  43. package/src/__fixtures__/anthropic-web-search-tool.1.chunks.txt +0 -120
  44. package/src/__fixtures__/anthropic-web-search-tool.1.json +0 -181
  45. package/src/__snapshots__/anthropic-messages-language-model.test.ts.snap +0 -16719
  46. package/src/anthropic-error.test.ts +0 -42
  47. package/src/anthropic-messages-language-model.test.ts +0 -7368
  48. package/src/anthropic-prepare-tools.test.ts +0 -1219
  49. package/src/anthropic-provider.test.ts +0 -162
  50. package/src/convert-to-anthropic-messages-prompt.test.ts +0 -2902
@@ -1,111 +0,0 @@
1
- {
2
- "model": "claude-sonnet-4-5-20250929",
3
- "id": "msg_01SoDD6rHi4QCh3PxHKK2oZW",
4
- "type": "message",
5
- "role": "assistant",
6
- "content": [
7
- {
8
- "type": "text",
9
- "text": "I'll help you create a Python script to calculate Fibonacci numbers, execute it to find the 10th Fibonacci number, and output the results to an Excel file. Let me break this down into steps:\n\n1. First, I'll create the Python script\n2. Execute it to find the 10th Fibonacci number\n3. Save the results to an Excel file\n4. Export both the Excel file and the Python code"
10
- },
11
- {
12
- "type": "server_tool_use",
13
- "id": "srvtoolu_01PitdyEfvwhjVp11SJarVsT",
14
- "name": "text_editor_code_execution",
15
- "input": {
16
- "command": "create",
17
- "path": "/tmp/fibonacci_calculator.py",
18
- "file_text": "import pandas as pd\nimport os\n\ndef fibonacci(n):\n \"\"\"\n Calculate the nth Fibonacci number using iterative approach.\n \n Args:\n n (int): The position in the Fibonacci sequence (1-indexed)\n \n Returns:\n int: The nth Fibonacci number\n \"\"\"\n if n <= 0:\n return 0\n elif n == 1:\n return 0\n elif n == 2:\n return 1\n else:\n a, b = 0, 1\n for _ in range(2, n):\n a, b = b, a + b\n return b\n\ndef generate_fibonacci_sequence(n):\n \"\"\"\n Generate Fibonacci sequence up to the nth number.\n \n Args:\n n (int): Number of Fibonacci numbers to generate\n \n Returns:\n list: List of tuples containing (position, fibonacci_number)\n \"\"\"\n sequence = []\n for i in range(1, n + 1):\n fib_num = fibonacci(i)\n sequence.append((i, fib_num))\n return sequence\n\ndef save_to_excel(data, filename):\n \"\"\"\n Save Fibonacci sequence data to an Excel file.\n \n Args:\n data (list): List of tuples containing (position, fibonacci_number)\n filename (str): Output filename\n \"\"\"\n # Create a DataFrame\n df = pd.DataFrame(data, columns=['Position', 'Fibonacci Number'])\n \n # Save to Excel\n output_dir = os.environ.get('OUTPUT_DIR', '/tmp')\n filepath = os.path.join(output_dir, filename)\n df.to_excel(filepath, index=False, sheet_name='Fibonacci Sequence')\n \n print(f\"Excel file saved to: {filepath}\")\n return df\n\ndef main():\n # Calculate the 10th Fibonacci number\n n = 10\n print(f\"Calculating Fibonacci sequence up to position {n}...\")\n print()\n \n # Generate the sequence\n fibonacci_sequence = generate_fibonacci_sequence(n)\n \n # Display results\n print(\"Fibonacci Sequence:\")\n print(\"-\" * 40)\n for pos, fib_num in fibonacci_sequence:\n print(f\"Position {pos:2d}: {fib_num}\")\n print(\"-\" * 40)\n print()\n \n # Highlight the 10th Fibonacci number\n tenth_fib = fibonacci(n)\n print(f\"The 10th Fibonacci number is: {tenth_fib}\")\n print()\n \n # Save to Excel file\n df = save_to_excel(fibonacci_sequence, 'fibonacci_results.xlsx')\n print()\n print(\"DataFrame preview:\")\n print(df)\n \n return tenth_fib\n\nif __name__ == \"__main__\":\n result = main()\n"
19
- }
20
- },
21
- {
22
- "type": "text_editor_code_execution_tool_result",
23
- "tool_use_id": "srvtoolu_01PitdyEfvwhjVp11SJarVsT",
24
- "content": {
25
- "type": "text_editor_code_execution_create_result",
26
- "is_file_update": false
27
- }
28
- },
29
- {
30
- "type": "text",
31
- "text": "Now let's execute the script to calculate the 10th Fibonacci number and generate the Excel file:"
32
- },
33
- {
34
- "type": "server_tool_use",
35
- "id": "srvtoolu_01Lk4vvHmfk7ik3iw5LUUVPm",
36
- "name": "bash_code_execution",
37
- "input": {
38
- "command": "cd /tmp && python fibonacci_calculator.py"
39
- }
40
- },
41
- {
42
- "type": "bash_code_execution_tool_result",
43
- "tool_use_id": "srvtoolu_01Lk4vvHmfk7ik3iw5LUUVPm",
44
- "content": {
45
- "type": "bash_code_execution_result",
46
- "stdout": "Calculating Fibonacci sequence up to position 10...\n\nFibonacci Sequence:\n----------------------------------------\nPosition 1: 0\nPosition 2: 1\nPosition 3: 1\nPosition 4: 2\nPosition 5: 3\nPosition 6: 5\nPosition 7: 8\nPosition 8: 13\nPosition 9: 21\nPosition 10: 34\n----------------------------------------\n\nThe 10th Fibonacci number is: 34\n\nExcel file saved to: /files/output/8f1f10526994b0a8/fibonacci_results.xlsx\n\nDataFrame preview:\n Position Fibonacci Number\n0 1 0\n1 2 1\n2 3 1\n3 4 2\n4 5 3\n5 6 5\n6 7 8\n7 8 13\n8 9 21\n9 10 34\n",
47
- "stderr": "",
48
- "return_code": 0,
49
- "content": [
50
- {
51
- "type": "bash_code_execution_output",
52
- "file_id": "file_011CUJascj5v5AsQ2KybX48e"
53
- }
54
- ]
55
- }
56
- },
57
- {
58
- "type": "text",
59
- "text": "Perfect! Now let's export the Python script as well:"
60
- },
61
- {
62
- "type": "server_tool_use",
63
- "id": "srvtoolu_016dr2it9y5xkvQVq2sRfnSX",
64
- "name": "bash_code_execution",
65
- "input": {
66
- "command": "cp /tmp/fibonacci_calculator.py $OUTPUT_DIR/fibonacci_calculator.py"
67
- }
68
- },
69
- {
70
- "type": "bash_code_execution_tool_result",
71
- "tool_use_id": "srvtoolu_016dr2it9y5xkvQVq2sRfnSX",
72
- "content": {
73
- "type": "bash_code_execution_result",
74
- "stdout": "",
75
- "stderr": "",
76
- "return_code": 0,
77
- "content": [
78
- {
79
- "type": "bash_code_execution_output",
80
- "file_id": "file_011CUJat24HHw4F65QJuLjhv"
81
- }
82
- ]
83
- }
84
- },
85
- {
86
- "type": "text",
87
- "text": "Excellent! I've successfully completed all the tasks:\n\n## Summary\n\n✅ **Python Script Created**: `fibonacci_calculator.py`\n- Implements a Fibonacci number calculator using an efficient iterative approach\n- Generates a complete Fibonacci sequence up to the nth position\n- Includes proper documentation and functions\n\n✅ **Execution Results**:\n- The **10th Fibonacci number is: 34**\n- The complete sequence from positions 1-10: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34\n\n✅ **Files Exported**:\n1. **fibonacci_results.xlsx** - Excel file containing:\n - Column 1: Position (1-10)\n - Column 2: Fibonacci Number (0-34)\n \n2. **fibonacci_calculator.py** - The complete Python source code\n\n## Features of the Script:\n- **fibonacci(n)**: Calculates the nth Fibonacci number\n- **generate_fibonacci_sequence(n)**: Creates a sequence up to position n\n- **save_to_excel()**: Exports data to Excel format using pandas\n- Clean output with formatted display of results\n- Professional code structure with docstrings\n\nBoth files have been exported and are ready for download!"
88
- }
89
- ],
90
- "container": {
91
- "id": "container_011CUJar2mdkMcv7daEVAQw2",
92
- "expires_at": "2025-10-20T15:10:44.950231Z"
93
- },
94
- "stop_reason": "end_turn",
95
- "stop_sequence": null,
96
- "usage": {
97
- "input_tokens": 12546,
98
- "cache_creation_input_tokens": 0,
99
- "cache_read_input_tokens": 0,
100
- "cache_creation": {
101
- "ephemeral_5m_input_tokens": 0,
102
- "ephemeral_1h_input_tokens": 0
103
- },
104
- "output_tokens": 1359,
105
- "service_tier": "standard",
106
- "server_tool_use": {
107
- "web_search_requests": 0,
108
- "web_fetch_requests": 0
109
- }
110
- }
111
- }