@ai-sdk/anthropic 2.0.12 → 2.0.14

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.
package/dist/index.mjs CHANGED
@@ -554,7 +554,14 @@ async function convertToAnthropicMessagesPrompt({
554
554
  }
555
555
  }
556
556
  }
557
- messages.push({ role: "user", content: anthropicContent });
557
+ const toolResultParts = anthropicContent.filter(
558
+ (part) => part.type === "tool_result"
559
+ );
560
+ const otherParts = anthropicContent.filter(
561
+ (part) => part.type !== "tool_result"
562
+ );
563
+ const reorderedContent = toolResultParts.length > 0 ? [...toolResultParts, ...otherParts] : anthropicContent;
564
+ messages.push({ role: "user", content: reorderedContent });
558
565
  break;
559
566
  }
560
567
  case "assistant": {
@@ -1980,69 +1987,97 @@ var textEditor_20250429 = createProviderDefinedToolFactory7({
1980
1987
  // src/anthropic-tools.ts
1981
1988
  var anthropicTools = {
1982
1989
  /**
1983
- * Creates a tool for running a bash command. Must have name "bash".
1990
+ * The bash tool enables Claude to execute shell commands in a persistent bash session,
1991
+ * allowing system operations, script execution, and command-line automation.
1984
1992
  *
1985
1993
  * Image results are supported.
1986
1994
  *
1987
- * @param execute - The function to execute the tool. Optional.
1995
+ * Tool name must be `bash`.
1988
1996
  */
1989
1997
  bash_20241022,
1990
1998
  /**
1991
- * Creates a tool for running a bash command. Must have name "bash".
1999
+ * The bash tool enables Claude to execute shell commands in a persistent bash session,
2000
+ * allowing system operations, script execution, and command-line automation.
1992
2001
  *
1993
2002
  * Image results are supported.
1994
2003
  *
1995
- * @param execute - The function to execute the tool. Optional.
2004
+ * Tool name must be `bash`.
1996
2005
  */
1997
2006
  bash_20250124,
1998
2007
  /**
1999
- * Creates a tool for editing text. Must have name "str_replace_editor".
2000
- */
2001
- textEditor_20241022,
2002
- /**
2003
- * Creates a tool for editing text. Must have name "str_replace_editor".
2004
- */
2005
- textEditor_20250124,
2006
- /**
2007
- * Creates a tool for editing text. Must have name "str_replace_based_edit_tool".
2008
- * Note: This version does not support the "undo_edit" command.
2008
+ * Claude can analyze data, create visualizations, perform complex calculations,
2009
+ * run system commands, create and edit files, and process uploaded files directly within
2010
+ * the API conversation.
2011
+ *
2012
+ * The code execution tool allows Claude to run Bash commands and manipulate files,
2013
+ * including writing code, in a secure, sandboxed environment.
2014
+ *
2015
+ * Tool name must be `code_execution`.
2009
2016
  */
2010
- textEditor_20250429,
2017
+ codeExecution_20250522,
2011
2018
  /**
2012
- * Creates a tool for executing actions on a computer. Must have name "computer".
2019
+ * Claude can interact with computer environments through the computer use tool, which
2020
+ * provides screenshot capabilities and mouse/keyboard control for autonomous desktop interaction.
2013
2021
  *
2014
2022
  * Image results are supported.
2015
2023
  *
2024
+ * Tool name must be `computer`.
2025
+ *
2016
2026
  * @param displayWidthPx - The width of the display being controlled by the model in pixels.
2017
2027
  * @param displayHeightPx - The height of the display being controlled by the model in pixels.
2018
2028
  * @param displayNumber - The display number to control (only relevant for X11 environments). If specified, the tool will be provided a display number in the tool definition.
2019
2029
  */
2020
2030
  computer_20241022,
2021
2031
  /**
2022
- * Creates a tool for executing actions on a computer. Must have name "computer".
2032
+ * Claude can interact with computer environments through the computer use tool, which
2033
+ * provides screenshot capabilities and mouse/keyboard control for autonomous desktop interaction.
2023
2034
  *
2024
2035
  * Image results are supported.
2025
2036
  *
2037
+ * Tool name must be `computer`.
2038
+ *
2026
2039
  * @param displayWidthPx - The width of the display being controlled by the model in pixels.
2027
2040
  * @param displayHeightPx - The height of the display being controlled by the model in pixels.
2028
2041
  * @param displayNumber - The display number to control (only relevant for X11 environments). If specified, the tool will be provided a display number in the tool definition.
2029
- * @param execute - The function to execute the tool. Optional.
2030
2042
  */
2031
2043
  computer_20250124,
2044
+ /**
2045
+ * Claude can use an Anthropic-defined text editor tool to view and modify text files,
2046
+ * helping you debug, fix, and improve your code or other text documents. This allows Claude
2047
+ * to directly interact with your files, providing hands-on assistance rather than just suggesting changes.
2048
+ *
2049
+ * Tool name must be `str_replace_editor`.
2050
+ */
2051
+ textEditor_20241022,
2052
+ /**
2053
+ * Claude can use an Anthropic-defined text editor tool to view and modify text files,
2054
+ * helping you debug, fix, and improve your code or other text documents. This allows Claude
2055
+ * to directly interact with your files, providing hands-on assistance rather than just suggesting changes.
2056
+ *
2057
+ * Tool name must be `str_replace_editor`.
2058
+ */
2059
+ textEditor_20250124,
2060
+ /**
2061
+ * Claude can use an Anthropic-defined text editor tool to view and modify text files,
2062
+ * helping you debug, fix, and improve your code or other text documents. This allows Claude
2063
+ * to directly interact with your files, providing hands-on assistance rather than just suggesting changes.
2064
+ *
2065
+ * Note: This version does not support the "undo_edit" command.
2066
+ *
2067
+ * Tool name must be `str_replace_based_edit_tool`.
2068
+ */
2069
+ textEditor_20250429,
2032
2070
  /**
2033
2071
  * Creates a web search tool that gives Claude direct access to real-time web content.
2034
- * Must have name "web_search".
2072
+ *
2073
+ * Tool name must be `web_search`.
2035
2074
  *
2036
2075
  * @param maxUses - Maximum number of web searches Claude can perform during the conversation.
2037
2076
  * @param allowedDomains - Optional list of domains that Claude is allowed to search.
2038
2077
  * @param blockedDomains - Optional list of domains that Claude should avoid when searching.
2039
2078
  * @param userLocation - Optional user location information to provide geographically relevant search results.
2040
2079
  */
2041
- webSearch_20250305,
2042
- /**
2043
- * Creates a tool for executing Python code. Must have name "code_execution".
2044
- */
2045
- codeExecution_20250522
2080
+ webSearch_20250305
2046
2081
  };
2047
2082
 
2048
2083
  // src/anthropic-provider.ts