@langchain/anthropic 1.3.17 → 1.3.18

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 (126) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/dist/_virtual/{rolldown_runtime.cjs → _rolldown/runtime.cjs} +11 -7
  3. package/dist/chat_models.cjs +56 -70
  4. package/dist/chat_models.cjs.map +1 -1
  5. package/dist/chat_models.d.cts +0 -1
  6. package/dist/chat_models.d.cts.map +1 -1
  7. package/dist/chat_models.d.ts +0 -1
  8. package/dist/chat_models.d.ts.map +1 -1
  9. package/dist/chat_models.js +28 -42
  10. package/dist/chat_models.js.map +1 -1
  11. package/dist/index.cjs +1 -0
  12. package/dist/output_parsers.cjs +9 -11
  13. package/dist/output_parsers.cjs.map +1 -1
  14. package/dist/output_parsers.js +2 -4
  15. package/dist/output_parsers.js.map +1 -1
  16. package/dist/profiles.cjs +96 -29
  17. package/dist/profiles.cjs.map +1 -1
  18. package/dist/profiles.js +96 -29
  19. package/dist/profiles.js.map +1 -1
  20. package/dist/tools/bash.cjs +3 -3
  21. package/dist/tools/bash.cjs.map +1 -1
  22. package/dist/tools/bash.d.cts +7 -7
  23. package/dist/tools/bash.d.cts.map +1 -1
  24. package/dist/tools/bash.d.ts +7 -7
  25. package/dist/tools/bash.d.ts.map +1 -1
  26. package/dist/tools/bash.js.map +1 -1
  27. package/dist/tools/codeExecution.cjs.map +1 -1
  28. package/dist/tools/codeExecution.d.cts +0 -1
  29. package/dist/tools/codeExecution.d.cts.map +1 -1
  30. package/dist/tools/codeExecution.d.ts +0 -1
  31. package/dist/tools/codeExecution.d.ts.map +1 -1
  32. package/dist/tools/codeExecution.js.map +1 -1
  33. package/dist/tools/computer.cjs +4 -4
  34. package/dist/tools/computer.cjs.map +1 -1
  35. package/dist/tools/computer.d.cts +101 -101
  36. package/dist/tools/computer.d.cts.map +1 -1
  37. package/dist/tools/computer.d.ts +101 -101
  38. package/dist/tools/computer.d.ts.map +1 -1
  39. package/dist/tools/computer.js.map +1 -1
  40. package/dist/tools/index.cjs.map +1 -1
  41. package/dist/tools/index.d.cts.map +1 -1
  42. package/dist/tools/index.d.ts.map +1 -1
  43. package/dist/tools/index.js.map +1 -1
  44. package/dist/tools/mcpToolset.cjs.map +1 -1
  45. package/dist/tools/mcpToolset.d.cts +0 -1
  46. package/dist/tools/mcpToolset.d.cts.map +1 -1
  47. package/dist/tools/mcpToolset.d.ts +0 -1
  48. package/dist/tools/mcpToolset.d.ts.map +1 -1
  49. package/dist/tools/mcpToolset.js.map +1 -1
  50. package/dist/tools/memory.cjs +3 -3
  51. package/dist/tools/memory.cjs.map +1 -1
  52. package/dist/tools/memory.d.cts +27 -28
  53. package/dist/tools/memory.d.cts.map +1 -1
  54. package/dist/tools/memory.d.ts +25 -26
  55. package/dist/tools/memory.d.ts.map +1 -1
  56. package/dist/tools/memory.js.map +1 -1
  57. package/dist/tools/textEditor.cjs +3 -3
  58. package/dist/tools/textEditor.cjs.map +1 -1
  59. package/dist/tools/textEditor.d.cts +19 -19
  60. package/dist/tools/textEditor.d.cts.map +1 -1
  61. package/dist/tools/textEditor.d.ts +21 -21
  62. package/dist/tools/textEditor.d.ts.map +1 -1
  63. package/dist/tools/textEditor.js.map +1 -1
  64. package/dist/tools/toolSearch.cjs.map +1 -1
  65. package/dist/tools/toolSearch.d.cts +0 -1
  66. package/dist/tools/toolSearch.d.cts.map +1 -1
  67. package/dist/tools/toolSearch.d.ts +0 -1
  68. package/dist/tools/toolSearch.d.ts.map +1 -1
  69. package/dist/tools/toolSearch.js.map +1 -1
  70. package/dist/tools/types.cjs +2 -2
  71. package/dist/tools/types.cjs.map +1 -1
  72. package/dist/tools/types.d.cts +0 -1
  73. package/dist/tools/types.d.cts.map +1 -1
  74. package/dist/tools/types.d.ts +0 -1
  75. package/dist/tools/types.d.ts.map +1 -1
  76. package/dist/tools/types.js.map +1 -1
  77. package/dist/tools/webFetch.cjs.map +1 -1
  78. package/dist/tools/webFetch.d.cts +0 -1
  79. package/dist/tools/webFetch.d.cts.map +1 -1
  80. package/dist/tools/webFetch.d.ts +0 -1
  81. package/dist/tools/webFetch.d.ts.map +1 -1
  82. package/dist/tools/webFetch.js.map +1 -1
  83. package/dist/tools/webSearch.cjs.map +1 -1
  84. package/dist/tools/webSearch.d.cts +0 -1
  85. package/dist/tools/webSearch.d.cts.map +1 -1
  86. package/dist/tools/webSearch.d.ts +0 -1
  87. package/dist/tools/webSearch.d.ts.map +1 -1
  88. package/dist/tools/webSearch.js.map +1 -1
  89. package/dist/types.d.cts +0 -1
  90. package/dist/types.d.cts.map +1 -1
  91. package/dist/types.d.ts +0 -1
  92. package/dist/types.d.ts.map +1 -1
  93. package/dist/utils/content.cjs +3 -3
  94. package/dist/utils/content.cjs.map +1 -1
  95. package/dist/utils/content.js.map +1 -1
  96. package/dist/utils/errors.cjs +4 -1
  97. package/dist/utils/errors.cjs.map +1 -1
  98. package/dist/utils/errors.js +4 -1
  99. package/dist/utils/errors.js.map +1 -1
  100. package/dist/utils/index.cjs.map +1 -1
  101. package/dist/utils/index.js.map +1 -1
  102. package/dist/utils/message_inputs.cjs +79 -100
  103. package/dist/utils/message_inputs.cjs.map +1 -1
  104. package/dist/utils/message_inputs.js +73 -94
  105. package/dist/utils/message_inputs.js.map +1 -1
  106. package/dist/utils/message_outputs.cjs +28 -32
  107. package/dist/utils/message_outputs.cjs.map +1 -1
  108. package/dist/utils/message_outputs.js +13 -17
  109. package/dist/utils/message_outputs.js.map +1 -1
  110. package/dist/utils/prompts.cjs +1 -2
  111. package/dist/utils/prompts.cjs.map +1 -1
  112. package/dist/utils/prompts.d.cts +0 -1
  113. package/dist/utils/prompts.d.cts.map +1 -1
  114. package/dist/utils/prompts.d.ts +0 -1
  115. package/dist/utils/prompts.d.ts.map +1 -1
  116. package/dist/utils/prompts.js +1 -2
  117. package/dist/utils/prompts.js.map +1 -1
  118. package/dist/utils/standard.cjs +2 -4
  119. package/dist/utils/standard.cjs.map +1 -1
  120. package/dist/utils/standard.js +2 -4
  121. package/dist/utils/standard.js.map +1 -1
  122. package/dist/utils/tools.cjs +4 -3
  123. package/dist/utils/tools.cjs.map +1 -1
  124. package/dist/utils/tools.js +1 -1
  125. package/dist/utils/tools.js.map +1 -1
  126. package/package.json +4 -4
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../../src/tools/types.ts"],"sourcesContent":["import Anthropic from \"@anthropic-ai/sdk\";\nimport { z } from \"zod/v4\";\n\n/**\n * Memory tool command types as defined by Anthropic's memory tool API.\n * @beta\n * @see https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/memory-tool\n */\n\n// Zod schemas for memory commands\nexport const Memory20250818ViewCommandSchema = z.object({\n command: z.literal(\"view\"),\n path: z.string(),\n});\n\nexport const Memory20250818CreateCommandSchema = z.object({\n command: z.literal(\"create\"),\n path: z.string(),\n file_text: z.string(),\n});\n\nexport const Memory20250818StrReplaceCommandSchema = z.object({\n command: z.literal(\"str_replace\"),\n path: z.string(),\n old_str: z.string(),\n new_str: z.string(),\n});\n\nexport const Memory20250818InsertCommandSchema = z.object({\n command: z.literal(\"insert\"),\n path: z.string(),\n insert_line: z.number(),\n insert_text: z.string(),\n});\n\nexport const Memory20250818DeleteCommandSchema = z.object({\n command: z.literal(\"delete\"),\n path: z.string(),\n});\n\nexport const Memory20250818RenameCommandSchema = z.object({\n command: z.literal(\"rename\"),\n old_path: z.string(),\n new_path: z.string(),\n});\n\n// Discriminated union schema for all memory commands\nexport const Memory20250818CommandSchema = z.discriminatedUnion(\"command\", [\n Memory20250818ViewCommandSchema,\n Memory20250818CreateCommandSchema,\n Memory20250818StrReplaceCommandSchema,\n Memory20250818InsertCommandSchema,\n Memory20250818DeleteCommandSchema,\n Memory20250818RenameCommandSchema,\n]);\n\n// TypeScript types derived from Zod schemas\nexport type Memory20250818ViewCommand = z.infer<\n typeof Memory20250818ViewCommandSchema\n>;\nexport type Memory20250818CreateCommand = z.infer<\n typeof Memory20250818CreateCommandSchema\n>;\nexport type Memory20250818StrReplaceCommand = z.infer<\n typeof Memory20250818StrReplaceCommandSchema\n>;\nexport type Memory20250818InsertCommand = z.infer<\n typeof Memory20250818InsertCommandSchema\n>;\nexport type Memory20250818DeleteCommand = z.infer<\n typeof Memory20250818DeleteCommandSchema\n>;\nexport type Memory20250818RenameCommand = z.infer<\n typeof Memory20250818RenameCommandSchema\n>;\n\nexport type Memory20250818Command = z.infer<typeof Memory20250818CommandSchema>;\n\n/**\n * Options for creating a memory tool.\n */\nexport interface MemoryTool20250818Options {\n /**\n * Optional execute function that handles memory command execution.\n * In LangChain, this is typically handled separately when processing tool calls,\n * but this option is provided for compatibility with the AI SDK pattern.\n * Note: This option is currently unused but reserved for future use.\n */\n execute: (action: Memory20250818Command) => Promise<string> | string;\n}\n\n/**\n * Memory tool type definition.\n */\nexport type MemoryTool20250818 = Anthropic.Beta.BetaMemoryTool20250818;\n\n/**\n * Text editor tool command types for Claude 4.x models.\n * @see https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/text-editor-tool\n */\n\n// Zod schemas for text editor commands\nexport const TextEditor20250728ViewCommandSchema = z.object({\n command: z.literal(\"view\"),\n path: z.string(),\n view_range: z.tuple([z.number(), z.number()]).optional(),\n});\n\nexport const TextEditor20250728StrReplaceCommandSchema = z.object({\n command: z.literal(\"str_replace\"),\n path: z.string(),\n old_str: z.string(),\n new_str: z.string(),\n});\n\nexport const TextEditor20250728CreateCommandSchema = z.object({\n command: z.literal(\"create\"),\n path: z.string(),\n file_text: z.string(),\n});\n\nexport const TextEditor20250728InsertCommandSchema = z.object({\n command: z.literal(\"insert\"),\n path: z.string(),\n insert_line: z.number(),\n new_str: z.string(),\n});\n\n// Discriminated union schema for all text editor commands\nexport const TextEditor20250728CommandSchema = z.discriminatedUnion(\"command\", [\n TextEditor20250728ViewCommandSchema,\n TextEditor20250728StrReplaceCommandSchema,\n TextEditor20250728CreateCommandSchema,\n TextEditor20250728InsertCommandSchema,\n]);\n\n// TypeScript types derived from Zod schemas\nexport type TextEditor20250728ViewCommand = z.infer<\n typeof TextEditor20250728ViewCommandSchema\n>;\nexport type TextEditor20250728StrReplaceCommand = z.infer<\n typeof TextEditor20250728StrReplaceCommandSchema\n>;\nexport type TextEditor20250728CreateCommand = z.infer<\n typeof TextEditor20250728CreateCommandSchema\n>;\nexport type TextEditor20250728InsertCommand = z.infer<\n typeof TextEditor20250728InsertCommandSchema\n>;\nexport type TextEditor20250728Command = z.infer<\n typeof TextEditor20250728CommandSchema\n>;\n\n/**\n * Computer use tool action types for Claude Opus 4.5.\n * Includes zoom action which is not available in earlier versions.\n * @see https://platform.claude.com/docs/en/agents-and-tools/tool-use/computer-use-tool\n */\nexport type Computer20251124Action =\n | Computer20250124Action\n | ComputerZoomAction;\n\n/**\n * Computer use tool action types for Claude Sonnet 4.5, Haiku 4.5, Opus 4.1, Sonnet 4, Opus 4, and Sonnet 3.7 versions.\n * @see https://platform.claude.com/docs/en/agents-and-tools/tool-use/computer-use-tool\n */\nexport type Computer20250124Action =\n | ComputerScreenshotAction\n | ComputerLeftClickAction\n | ComputerRightClickAction\n | ComputerMiddleClickAction\n | ComputerDoubleClickAction\n | ComputerTripleClickAction\n | ComputerLeftClickDragAction\n | ComputerLeftMouseDownAction\n | ComputerLeftMouseUpAction\n | ComputerScrollAction\n | ComputerTypeAction\n | ComputerKeyAction\n | ComputerMouseMoveAction\n | ComputerHoldKeyAction\n | ComputerWaitAction;\n\n// Zod schemas for computer actions\nconst coordinateSchema = z.tuple([z.number(), z.number()]);\n\nexport const ComputerScreenshotActionSchema = z.object({\n action: z.literal(\"screenshot\"),\n});\n\nexport const ComputerLeftClickActionSchema = z.object({\n action: z.literal(\"left_click\"),\n coordinate: coordinateSchema,\n});\n\nexport const ComputerRightClickActionSchema = z.object({\n action: z.literal(\"right_click\"),\n coordinate: coordinateSchema,\n});\n\nexport const ComputerMiddleClickActionSchema = z.object({\n action: z.literal(\"middle_click\"),\n coordinate: coordinateSchema,\n});\n\nexport const ComputerDoubleClickActionSchema = z.object({\n action: z.literal(\"double_click\"),\n coordinate: coordinateSchema,\n});\n\nexport const ComputerTripleClickActionSchema = z.object({\n action: z.literal(\"triple_click\"),\n coordinate: coordinateSchema,\n});\n\nexport const ComputerLeftClickDragActionSchema = z.object({\n action: z.literal(\"left_click_drag\"),\n start_coordinate: coordinateSchema,\n end_coordinate: coordinateSchema,\n});\n\nexport const ComputerLeftMouseDownActionSchema = z.object({\n action: z.literal(\"left_mouse_down\"),\n coordinate: coordinateSchema,\n});\n\nexport const ComputerLeftMouseUpActionSchema = z.object({\n action: z.literal(\"left_mouse_up\"),\n coordinate: coordinateSchema,\n});\n\nexport const ComputerScrollActionSchema = z.object({\n action: z.literal(\"scroll\"),\n coordinate: coordinateSchema,\n scroll_direction: z.enum([\"up\", \"down\", \"left\", \"right\"]),\n scroll_amount: z.number(),\n});\n\nexport const ComputerTypeActionSchema = z.object({\n action: z.literal(\"type\"),\n text: z.string(),\n});\n\nexport const ComputerKeyActionSchema = z.object({\n action: z.literal(\"key\"),\n key: z.string(),\n});\n\nexport const ComputerMouseMoveActionSchema = z.object({\n action: z.literal(\"mouse_move\"),\n coordinate: coordinateSchema,\n});\n\nexport const ComputerHoldKeyActionSchema = z.object({\n action: z.literal(\"hold_key\"),\n key: z.string(),\n});\n\nexport const ComputerWaitActionSchema = z.object({\n action: z.literal(\"wait\"),\n duration: z.number().optional(),\n});\n\nexport const ComputerZoomActionSchema = z.object({\n action: z.literal(\"zoom\"),\n region: z.tuple([z.number(), z.number(), z.number(), z.number()]),\n});\n\n// Discriminated union schemas\nexport const Computer20250124ActionSchema = z.discriminatedUnion(\"action\", [\n ComputerScreenshotActionSchema,\n ComputerLeftClickActionSchema,\n ComputerRightClickActionSchema,\n ComputerMiddleClickActionSchema,\n ComputerDoubleClickActionSchema,\n ComputerTripleClickActionSchema,\n ComputerLeftClickDragActionSchema,\n ComputerLeftMouseDownActionSchema,\n ComputerLeftMouseUpActionSchema,\n ComputerScrollActionSchema,\n ComputerTypeActionSchema,\n ComputerKeyActionSchema,\n ComputerMouseMoveActionSchema,\n ComputerHoldKeyActionSchema,\n ComputerWaitActionSchema,\n]);\n\nexport const Computer20251124ActionSchema = z.discriminatedUnion(\"action\", [\n ComputerScreenshotActionSchema,\n ComputerLeftClickActionSchema,\n ComputerRightClickActionSchema,\n ComputerMiddleClickActionSchema,\n ComputerDoubleClickActionSchema,\n ComputerTripleClickActionSchema,\n ComputerLeftClickDragActionSchema,\n ComputerLeftMouseDownActionSchema,\n ComputerLeftMouseUpActionSchema,\n ComputerScrollActionSchema,\n ComputerTypeActionSchema,\n ComputerKeyActionSchema,\n ComputerMouseMoveActionSchema,\n ComputerHoldKeyActionSchema,\n ComputerWaitActionSchema,\n ComputerZoomActionSchema,\n]);\n\n// TypeScript types derived from Zod schemas\nexport type ComputerScreenshotAction = z.infer<\n typeof ComputerScreenshotActionSchema\n>;\n\nexport type ComputerLeftClickAction = z.infer<\n typeof ComputerLeftClickActionSchema\n>;\n\nexport type ComputerRightClickAction = z.infer<\n typeof ComputerRightClickActionSchema\n>;\n\nexport type ComputerMiddleClickAction = z.infer<\n typeof ComputerMiddleClickActionSchema\n>;\n\nexport type ComputerDoubleClickAction = z.infer<\n typeof ComputerDoubleClickActionSchema\n>;\n\nexport type ComputerTripleClickAction = z.infer<\n typeof ComputerTripleClickActionSchema\n>;\n\nexport type ComputerLeftClickDragAction = z.infer<\n typeof ComputerLeftClickDragActionSchema\n>;\n\nexport type ComputerLeftMouseDownAction = z.infer<\n typeof ComputerLeftMouseDownActionSchema\n>;\n\nexport type ComputerLeftMouseUpAction = z.infer<\n typeof ComputerLeftMouseUpActionSchema\n>;\n\nexport type ComputerScrollAction = z.infer<typeof ComputerScrollActionSchema>;\n\nexport type ComputerTypeAction = z.infer<typeof ComputerTypeActionSchema>;\n\nexport type ComputerKeyAction = z.infer<typeof ComputerKeyActionSchema>;\n\nexport type ComputerMouseMoveAction = z.infer<\n typeof ComputerMouseMoveActionSchema\n>;\n\nexport type ComputerHoldKeyAction = z.infer<typeof ComputerHoldKeyActionSchema>;\n\nexport type ComputerWaitAction = z.infer<typeof ComputerWaitActionSchema>;\n\nexport type ComputerZoomAction = z.infer<typeof ComputerZoomActionSchema>;\n\n/**\n * Bash tool command types for Claude 4 models and Claude 3.7.\n * @see https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/bash-tool\n */\n\n// Zod schemas for bash commands\nexport const Bash20250124ExecuteCommandSchema = z.object({\n command: z.string().describe(\"The bash command to run\"),\n});\n\nexport const Bash20250124RestartCommandSchema = z.object({\n restart: z.literal(true).describe(\"Set to true to restart the bash session\"),\n});\n\n// Union schema for all bash commands\nexport const Bash20250124CommandSchema = z.union([\n Bash20250124ExecuteCommandSchema,\n Bash20250124RestartCommandSchema,\n]);\n\n// TypeScript types derived from Zod schemas\nexport type Bash20250124ExecuteCommand = z.infer<\n typeof Bash20250124ExecuteCommandSchema\n>;\nexport type Bash20250124RestartCommand = z.infer<\n typeof Bash20250124RestartCommandSchema\n>;\nexport type Bash20250124Command = z.infer<typeof Bash20250124CommandSchema>;\n"],"mappings":";;;;;;;;AAUA,MAAa,kCAAkC,EAAE,OAAO;CACtD,SAAS,EAAE,QAAQ,OAAO;CAC1B,MAAM,EAAE,QAAQ;AACjB,EAAC;AAEF,MAAa,oCAAoC,EAAE,OAAO;CACxD,SAAS,EAAE,QAAQ,SAAS;CAC5B,MAAM,EAAE,QAAQ;CAChB,WAAW,EAAE,QAAQ;AACtB,EAAC;AAEF,MAAa,wCAAwC,EAAE,OAAO;CAC5D,SAAS,EAAE,QAAQ,cAAc;CACjC,MAAM,EAAE,QAAQ;CAChB,SAAS,EAAE,QAAQ;CACnB,SAAS,EAAE,QAAQ;AACpB,EAAC;AAEF,MAAa,oCAAoC,EAAE,OAAO;CACxD,SAAS,EAAE,QAAQ,SAAS;CAC5B,MAAM,EAAE,QAAQ;CAChB,aAAa,EAAE,QAAQ;CACvB,aAAa,EAAE,QAAQ;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AC7B,KAAK,EAAE,QAAQ;AAChB,EAAC;AAEF,MAAa,2BAA2B,EAAE,OAAO;CAC/C,QAAQ,EAAE,QAAQ,OAAO;CACzB,UAAU,EAAE,QAAQ,CAAC,UAAU;AAChC,EAAC;AAEF,MAAa,2BAA2B,EAAE,OAAO;CAC/C,QAAQ,EAAE,QAAQ,OAAO;CACzB,QAAQ,EAAE,MAAM;EAAC,EAAE,QAAQ;EAAE,EAAE,QAAQ;EAAE,EAAE,QAAQ;EAAE,EAAE,QAAQ;CAAC,EAAC;AAClE,EAAC;AAGF,MAAa,+BAA+B,EAAE,mBAAmB,UAAU;CACzE;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACD,EAAC;AAEF,MAAa,+BAA+B,EAAE,mBAAmB,UAAU;CACzE;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACD,EAAC;;;;;AA6DF,MAAa,mCAAmC,EAAE,OAAO,EACvD,SAAS,EAAE,QAAQ,CAAC,SAAS,0BAA0B,CACxD,EAAC;AAEF,MAAa,mCAAmC,EAAE,OAAO,EACvD,SAAS,EAAE,QAAQ,KAAK,CAAC,SAAS,0CAA0C,CAC7E,EAAC;AAGF,MAAa,4BAA4B,EAAE,MAAM,CAC/C,kCACA,gCACD,EAAC"}
1
+ {"version":3,"file":"types.js","names":[],"sources":["../../src/tools/types.ts"],"sourcesContent":["import Anthropic from \"@anthropic-ai/sdk\";\nimport { z } from \"zod/v4\";\n\n/**\n * Memory tool command types as defined by Anthropic's memory tool API.\n * @beta\n * @see https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/memory-tool\n */\n\n// Zod schemas for memory commands\nexport const Memory20250818ViewCommandSchema = z.object({\n command: z.literal(\"view\"),\n path: z.string(),\n});\n\nexport const Memory20250818CreateCommandSchema = z.object({\n command: z.literal(\"create\"),\n path: z.string(),\n file_text: z.string(),\n});\n\nexport const Memory20250818StrReplaceCommandSchema = z.object({\n command: z.literal(\"str_replace\"),\n path: z.string(),\n old_str: z.string(),\n new_str: z.string(),\n});\n\nexport const Memory20250818InsertCommandSchema = z.object({\n command: z.literal(\"insert\"),\n path: z.string(),\n insert_line: z.number(),\n insert_text: z.string(),\n});\n\nexport const Memory20250818DeleteCommandSchema = z.object({\n command: z.literal(\"delete\"),\n path: z.string(),\n});\n\nexport const Memory20250818RenameCommandSchema = z.object({\n command: z.literal(\"rename\"),\n old_path: z.string(),\n new_path: z.string(),\n});\n\n// Discriminated union schema for all memory commands\nexport const Memory20250818CommandSchema = z.discriminatedUnion(\"command\", [\n Memory20250818ViewCommandSchema,\n Memory20250818CreateCommandSchema,\n Memory20250818StrReplaceCommandSchema,\n Memory20250818InsertCommandSchema,\n Memory20250818DeleteCommandSchema,\n Memory20250818RenameCommandSchema,\n]);\n\n// TypeScript types derived from Zod schemas\nexport type Memory20250818ViewCommand = z.infer<\n typeof Memory20250818ViewCommandSchema\n>;\nexport type Memory20250818CreateCommand = z.infer<\n typeof Memory20250818CreateCommandSchema\n>;\nexport type Memory20250818StrReplaceCommand = z.infer<\n typeof Memory20250818StrReplaceCommandSchema\n>;\nexport type Memory20250818InsertCommand = z.infer<\n typeof Memory20250818InsertCommandSchema\n>;\nexport type Memory20250818DeleteCommand = z.infer<\n typeof Memory20250818DeleteCommandSchema\n>;\nexport type Memory20250818RenameCommand = z.infer<\n typeof Memory20250818RenameCommandSchema\n>;\n\nexport type Memory20250818Command = z.infer<typeof Memory20250818CommandSchema>;\n\n/**\n * Options for creating a memory tool.\n */\nexport interface MemoryTool20250818Options {\n /**\n * Optional execute function that handles memory command execution.\n * In LangChain, this is typically handled separately when processing tool calls,\n * but this option is provided for compatibility with the AI SDK pattern.\n * Note: This option is currently unused but reserved for future use.\n */\n execute: (action: Memory20250818Command) => Promise<string> | string;\n}\n\n/**\n * Memory tool type definition.\n */\nexport type MemoryTool20250818 = Anthropic.Beta.BetaMemoryTool20250818;\n\n/**\n * Text editor tool command types for Claude 4.x models.\n * @see https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/text-editor-tool\n */\n\n// Zod schemas for text editor commands\nexport const TextEditor20250728ViewCommandSchema = z.object({\n command: z.literal(\"view\"),\n path: z.string(),\n view_range: z.tuple([z.number(), z.number()]).optional(),\n});\n\nexport const TextEditor20250728StrReplaceCommandSchema = z.object({\n command: z.literal(\"str_replace\"),\n path: z.string(),\n old_str: z.string(),\n new_str: z.string(),\n});\n\nexport const TextEditor20250728CreateCommandSchema = z.object({\n command: z.literal(\"create\"),\n path: z.string(),\n file_text: z.string(),\n});\n\nexport const TextEditor20250728InsertCommandSchema = z.object({\n command: z.literal(\"insert\"),\n path: z.string(),\n insert_line: z.number(),\n new_str: z.string(),\n});\n\n// Discriminated union schema for all text editor commands\nexport const TextEditor20250728CommandSchema = z.discriminatedUnion(\"command\", [\n TextEditor20250728ViewCommandSchema,\n TextEditor20250728StrReplaceCommandSchema,\n TextEditor20250728CreateCommandSchema,\n TextEditor20250728InsertCommandSchema,\n]);\n\n// TypeScript types derived from Zod schemas\nexport type TextEditor20250728ViewCommand = z.infer<\n typeof TextEditor20250728ViewCommandSchema\n>;\nexport type TextEditor20250728StrReplaceCommand = z.infer<\n typeof TextEditor20250728StrReplaceCommandSchema\n>;\nexport type TextEditor20250728CreateCommand = z.infer<\n typeof TextEditor20250728CreateCommandSchema\n>;\nexport type TextEditor20250728InsertCommand = z.infer<\n typeof TextEditor20250728InsertCommandSchema\n>;\nexport type TextEditor20250728Command = z.infer<\n typeof TextEditor20250728CommandSchema\n>;\n\n/**\n * Computer use tool action types for Claude Opus 4.5.\n * Includes zoom action which is not available in earlier versions.\n * @see https://platform.claude.com/docs/en/agents-and-tools/tool-use/computer-use-tool\n */\nexport type Computer20251124Action =\n | Computer20250124Action\n | ComputerZoomAction;\n\n/**\n * Computer use tool action types for Claude Sonnet 4.5, Haiku 4.5, Opus 4.1, Sonnet 4, Opus 4, and Sonnet 3.7 versions.\n * @see https://platform.claude.com/docs/en/agents-and-tools/tool-use/computer-use-tool\n */\nexport type Computer20250124Action =\n | ComputerScreenshotAction\n | ComputerLeftClickAction\n | ComputerRightClickAction\n | ComputerMiddleClickAction\n | ComputerDoubleClickAction\n | ComputerTripleClickAction\n | ComputerLeftClickDragAction\n | ComputerLeftMouseDownAction\n | ComputerLeftMouseUpAction\n | ComputerScrollAction\n | ComputerTypeAction\n | ComputerKeyAction\n | ComputerMouseMoveAction\n | ComputerHoldKeyAction\n | ComputerWaitAction;\n\n// Zod schemas for computer actions\nconst coordinateSchema = z.tuple([z.number(), z.number()]);\n\nexport const ComputerScreenshotActionSchema = z.object({\n action: z.literal(\"screenshot\"),\n});\n\nexport const ComputerLeftClickActionSchema = z.object({\n action: z.literal(\"left_click\"),\n coordinate: coordinateSchema,\n});\n\nexport const ComputerRightClickActionSchema = z.object({\n action: z.literal(\"right_click\"),\n coordinate: coordinateSchema,\n});\n\nexport const ComputerMiddleClickActionSchema = z.object({\n action: z.literal(\"middle_click\"),\n coordinate: coordinateSchema,\n});\n\nexport const ComputerDoubleClickActionSchema = z.object({\n action: z.literal(\"double_click\"),\n coordinate: coordinateSchema,\n});\n\nexport const ComputerTripleClickActionSchema = z.object({\n action: z.literal(\"triple_click\"),\n coordinate: coordinateSchema,\n});\n\nexport const ComputerLeftClickDragActionSchema = z.object({\n action: z.literal(\"left_click_drag\"),\n start_coordinate: coordinateSchema,\n end_coordinate: coordinateSchema,\n});\n\nexport const ComputerLeftMouseDownActionSchema = z.object({\n action: z.literal(\"left_mouse_down\"),\n coordinate: coordinateSchema,\n});\n\nexport const ComputerLeftMouseUpActionSchema = z.object({\n action: z.literal(\"left_mouse_up\"),\n coordinate: coordinateSchema,\n});\n\nexport const ComputerScrollActionSchema = z.object({\n action: z.literal(\"scroll\"),\n coordinate: coordinateSchema,\n scroll_direction: z.enum([\"up\", \"down\", \"left\", \"right\"]),\n scroll_amount: z.number(),\n});\n\nexport const ComputerTypeActionSchema = z.object({\n action: z.literal(\"type\"),\n text: z.string(),\n});\n\nexport const ComputerKeyActionSchema = z.object({\n action: z.literal(\"key\"),\n key: z.string(),\n});\n\nexport const ComputerMouseMoveActionSchema = z.object({\n action: z.literal(\"mouse_move\"),\n coordinate: coordinateSchema,\n});\n\nexport const ComputerHoldKeyActionSchema = z.object({\n action: z.literal(\"hold_key\"),\n key: z.string(),\n});\n\nexport const ComputerWaitActionSchema = z.object({\n action: z.literal(\"wait\"),\n duration: z.number().optional(),\n});\n\nexport const ComputerZoomActionSchema = z.object({\n action: z.literal(\"zoom\"),\n region: z.tuple([z.number(), z.number(), z.number(), z.number()]),\n});\n\n// Discriminated union schemas\nexport const Computer20250124ActionSchema = z.discriminatedUnion(\"action\", [\n ComputerScreenshotActionSchema,\n ComputerLeftClickActionSchema,\n ComputerRightClickActionSchema,\n ComputerMiddleClickActionSchema,\n ComputerDoubleClickActionSchema,\n ComputerTripleClickActionSchema,\n ComputerLeftClickDragActionSchema,\n ComputerLeftMouseDownActionSchema,\n ComputerLeftMouseUpActionSchema,\n ComputerScrollActionSchema,\n ComputerTypeActionSchema,\n ComputerKeyActionSchema,\n ComputerMouseMoveActionSchema,\n ComputerHoldKeyActionSchema,\n ComputerWaitActionSchema,\n]);\n\nexport const Computer20251124ActionSchema = z.discriminatedUnion(\"action\", [\n ComputerScreenshotActionSchema,\n ComputerLeftClickActionSchema,\n ComputerRightClickActionSchema,\n ComputerMiddleClickActionSchema,\n ComputerDoubleClickActionSchema,\n ComputerTripleClickActionSchema,\n ComputerLeftClickDragActionSchema,\n ComputerLeftMouseDownActionSchema,\n ComputerLeftMouseUpActionSchema,\n ComputerScrollActionSchema,\n ComputerTypeActionSchema,\n ComputerKeyActionSchema,\n ComputerMouseMoveActionSchema,\n ComputerHoldKeyActionSchema,\n ComputerWaitActionSchema,\n ComputerZoomActionSchema,\n]);\n\n// TypeScript types derived from Zod schemas\nexport type ComputerScreenshotAction = z.infer<\n typeof ComputerScreenshotActionSchema\n>;\n\nexport type ComputerLeftClickAction = z.infer<\n typeof ComputerLeftClickActionSchema\n>;\n\nexport type ComputerRightClickAction = z.infer<\n typeof ComputerRightClickActionSchema\n>;\n\nexport type ComputerMiddleClickAction = z.infer<\n typeof ComputerMiddleClickActionSchema\n>;\n\nexport type ComputerDoubleClickAction = z.infer<\n typeof ComputerDoubleClickActionSchema\n>;\n\nexport type ComputerTripleClickAction = z.infer<\n typeof ComputerTripleClickActionSchema\n>;\n\nexport type ComputerLeftClickDragAction = z.infer<\n typeof ComputerLeftClickDragActionSchema\n>;\n\nexport type ComputerLeftMouseDownAction = z.infer<\n typeof ComputerLeftMouseDownActionSchema\n>;\n\nexport type ComputerLeftMouseUpAction = z.infer<\n typeof ComputerLeftMouseUpActionSchema\n>;\n\nexport type ComputerScrollAction = z.infer<typeof ComputerScrollActionSchema>;\n\nexport type ComputerTypeAction = z.infer<typeof ComputerTypeActionSchema>;\n\nexport type ComputerKeyAction = z.infer<typeof ComputerKeyActionSchema>;\n\nexport type ComputerMouseMoveAction = z.infer<\n typeof ComputerMouseMoveActionSchema\n>;\n\nexport type ComputerHoldKeyAction = z.infer<typeof ComputerHoldKeyActionSchema>;\n\nexport type ComputerWaitAction = z.infer<typeof ComputerWaitActionSchema>;\n\nexport type ComputerZoomAction = z.infer<typeof ComputerZoomActionSchema>;\n\n/**\n * Bash tool command types for Claude 4 models and Claude 3.7.\n * @see https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/bash-tool\n */\n\n// Zod schemas for bash commands\nexport const Bash20250124ExecuteCommandSchema = z.object({\n command: z.string().describe(\"The bash command to run\"),\n});\n\nexport const Bash20250124RestartCommandSchema = z.object({\n restart: z.literal(true).describe(\"Set to true to restart the bash session\"),\n});\n\n// Union schema for all bash commands\nexport const Bash20250124CommandSchema = z.union([\n Bash20250124ExecuteCommandSchema,\n Bash20250124RestartCommandSchema,\n]);\n\n// TypeScript types derived from Zod schemas\nexport type Bash20250124ExecuteCommand = z.infer<\n typeof Bash20250124ExecuteCommandSchema\n>;\nexport type Bash20250124RestartCommand = z.infer<\n typeof Bash20250124RestartCommandSchema\n>;\nexport type Bash20250124Command = z.infer<typeof Bash20250124CommandSchema>;\n"],"mappings":";;;;;;;;AAUA,MAAa,kCAAkC,EAAE,OAAO;CACtD,SAAS,EAAE,QAAQ,OAAO;CAC1B,MAAM,EAAE,QAAQ;CACjB,CAAC;AAEF,MAAa,oCAAoC,EAAE,OAAO;CACxD,SAAS,EAAE,QAAQ,SAAS;CAC5B,MAAM,EAAE,QAAQ;CAChB,WAAW,EAAE,QAAQ;CACtB,CAAC;AAEF,MAAa,wCAAwC,EAAE,OAAO;CAC5D,SAAS,EAAE,QAAQ,cAAc;CACjC,MAAM,EAAE,QAAQ;CAChB,SAAS,EAAE,QAAQ;CACnB,SAAS,EAAE,QAAQ;CACpB,CAAC;AAEF,MAAa,oCAAoC,EAAE,OAAO;CACxD,SAAS,EAAE,QAAQ,SAAS;CAC5B,MAAM,EAAE,QAAQ;CAChB,aAAa,EAAE,QAAQ;CACvB,aAAa,EAAE,QAAQ;CACxB,CAAC;AAEF,MAAa,oCAAoC,EAAE,OAAO;CACxD,SAAS,EAAE,QAAQ,SAAS;CAC5B,MAAM,EAAE,QAAQ;CACjB,CAAC;AAEF,MAAa,oCAAoC,EAAE,OAAO;CACxD,SAAS,EAAE,QAAQ,SAAS;CAC5B,UAAU,EAAE,QAAQ;CACpB,UAAU,EAAE,QAAQ;CACrB,CAAC;AAGF,MAAa,8BAA8B,EAAE,mBAAmB,WAAW;CACzE;CACA;CACA;CACA;CACA;CACA;CACD,CAAC;;;;;AAgDF,MAAa,sCAAsC,EAAE,OAAO;CAC1D,SAAS,EAAE,QAAQ,OAAO;CAC1B,MAAM,EAAE,QAAQ;CAChB,YAAY,EAAE,MAAM,CAAC,EAAE,QAAQ,EAAE,EAAE,QAAQ,CAAC,CAAC,CAAC,UAAU;CACzD,CAAC;AAEF,MAAa,4CAA4C,EAAE,OAAO;CAChE,SAAS,EAAE,QAAQ,c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;CACA;CACA;CACD,CAAC;;;;;AA6DF,MAAa,mCAAmC,EAAE,OAAO,EACvD,SAAS,EAAE,QAAQ,CAAC,SAAS,0BAA0B,EACxD,CAAC;AAEF,MAAa,mCAAmC,EAAE,OAAO,EACvD,SAAS,EAAE,QAAQ,KAAK,CAAC,SAAS,0CAA0C,EAC7E,CAAC;AAGF,MAAa,4BAA4B,EAAE,MAAM,CAC/C,kCACA,iCACD,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"webFetch.cjs","names":["options?: WebFetch20250910Options"],"sources":["../../src/tools/webFetch.ts"],"sourcesContent":["import Anthropic from \"@anthropic-ai/sdk\";\nimport { type ServerTool } from \"@langchain/core/tools\";\n\n/**\n * Options for the web fetch tool.\n */\nexport interface WebFetch20250910Options {\n /**\n * Maximum number of times the tool can be used in the API request.\n */\n maxUses?: number;\n /**\n * If provided, only these domains will be fetched. Cannot be used\n * alongside `blockedDomains`.\n */\n allowedDomains?: string[];\n /**\n * If provided, these domains will never be fetched. Cannot be used\n * alongside `allowedDomains`.\n */\n blockedDomains?: string[];\n /**\n * Create a cache control breakpoint at this content block.\n */\n cacheControl?: Anthropic.Beta.BetaCacheControlEphemeral;\n /**\n * Enable citations for fetched content. Unlike web search where citations\n * are always enabled, citations are optional for web fetch.\n */\n citations?: {\n enabled: boolean;\n };\n /**\n * Maximum content length in tokens. If the fetched content exceeds this limit,\n * it will be truncated. This helps control token usage when fetching large documents.\n */\n maxContentTokens?: number;\n}\n\n/**\n * Creates a web fetch tool that allows Claude to retrieve full content from specified\n * web pages and PDF documents. Claude can only fetch URLs that have been explicitly\n * provided by the user or that come from previous web search or web fetch results.\n *\n * @warning Enabling the web fetch tool in environments where Claude processes untrusted\n * input alongside sensitive data poses data exfiltration risks. We recommend only using\n * this tool in trusted environments or when handling non-sensitive data.\n *\n * @see {@link https://docs.anthropic.com/en/docs/build-with-claude/tool-use/web-fetch-tool | Anthropic Web Fetch Documentation}\n * @param options - Configuration options for the web fetch tool\n * @returns A web fetch tool definition to be passed to the Anthropic API\n *\n * @example\n * ```typescript\n * import { ChatAnthropic, tools } from \"@langchain/anthropic\";\n *\n * const model = new ChatAnthropic({\n * model: \"claude-sonnet-4-5-20250929\",\n * });\n *\n * // Basic usage - fetch content from a URL\n * const response = await model.invoke(\n * \"Please analyze the content at https://example.com/article\",\n * { tools: [tools.webFetch_20250910()] }\n * );\n *\n * // With options\n * const responseWithOptions = await model.invoke(\n * \"Summarize this research paper: https://arxiv.org/abs/2024.12345\",\n * {\n * tools: [tools.webFetch_20250910({\n * maxUses: 5,\n * allowedDomains: [\"arxiv.org\", \"example.com\"],\n * citations: { enabled: true },\n * maxContentTokens: 50000,\n * })],\n * }\n * );\n *\n * // Combined with web search for comprehensive information gathering\n * const combinedResponse = await model.invoke(\n * \"Find recent articles about quantum computing and analyze the most relevant one\",\n * {\n * tools: [\n * tools.webSearch_20250305({ maxUses: 3 }),\n * tools.webFetch_20250910({ maxUses: 5, citations: { enabled: true } }),\n * ],\n * }\n * );\n * ```\n */\nexport function webFetch_20250910(\n options?: WebFetch20250910Options\n): ServerTool {\n return {\n type: \"web_fetch_20250910\",\n name: \"web_fetch\",\n max_uses: options?.maxUses,\n allowed_domains: options?.allowedDomains,\n blocked_domains: options?.blockedDomains,\n cache_control: options?.cacheControl,\n citations: options?.citations,\n max_content_tokens: options?.maxContentTokens,\n } satisfies Anthropic.Beta.BetaWebFetchTool20250910;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2FA,SAAgB,kBACdA,SACY;AACZ,QAAO;EACL,MAAM;EACN,MAAM;EACN,UAAU,SAAS;EACnB,iBAAiB,SAAS;EAC1B,iBAAiB,SAAS;EAC1B,eAAe,SAAS;EACxB,WAAW,SAAS;EACpB,oBAAoB,SAAS;CAC9B;AACF"}
1
+ {"version":3,"file":"webFetch.cjs","names":[],"sources":["../../src/tools/webFetch.ts"],"sourcesContent":["import Anthropic from \"@anthropic-ai/sdk\";\nimport { type ServerTool } from \"@langchain/core/tools\";\n\n/**\n * Options for the web fetch tool.\n */\nexport interface WebFetch20250910Options {\n /**\n * Maximum number of times the tool can be used in the API request.\n */\n maxUses?: number;\n /**\n * If provided, only these domains will be fetched. Cannot be used\n * alongside `blockedDomains`.\n */\n allowedDomains?: string[];\n /**\n * If provided, these domains will never be fetched. Cannot be used\n * alongside `allowedDomains`.\n */\n blockedDomains?: string[];\n /**\n * Create a cache control breakpoint at this content block.\n */\n cacheControl?: Anthropic.Beta.BetaCacheControlEphemeral;\n /**\n * Enable citations for fetched content. Unlike web search where citations\n * are always enabled, citations are optional for web fetch.\n */\n citations?: {\n enabled: boolean;\n };\n /**\n * Maximum content length in tokens. If the fetched content exceeds this limit,\n * it will be truncated. This helps control token usage when fetching large documents.\n */\n maxContentTokens?: number;\n}\n\n/**\n * Creates a web fetch tool that allows Claude to retrieve full content from specified\n * web pages and PDF documents. Claude can only fetch URLs that have been explicitly\n * provided by the user or that come from previous web search or web fetch results.\n *\n * @warning Enabling the web fetch tool in environments where Claude processes untrusted\n * input alongside sensitive data poses data exfiltration risks. We recommend only using\n * this tool in trusted environments or when handling non-sensitive data.\n *\n * @see {@link https://docs.anthropic.com/en/docs/build-with-claude/tool-use/web-fetch-tool | Anthropic Web Fetch Documentation}\n * @param options - Configuration options for the web fetch tool\n * @returns A web fetch tool definition to be passed to the Anthropic API\n *\n * @example\n * ```typescript\n * import { ChatAnthropic, tools } from \"@langchain/anthropic\";\n *\n * const model = new ChatAnthropic({\n * model: \"claude-sonnet-4-5-20250929\",\n * });\n *\n * // Basic usage - fetch content from a URL\n * const response = await model.invoke(\n * \"Please analyze the content at https://example.com/article\",\n * { tools: [tools.webFetch_20250910()] }\n * );\n *\n * // With options\n * const responseWithOptions = await model.invoke(\n * \"Summarize this research paper: https://arxiv.org/abs/2024.12345\",\n * {\n * tools: [tools.webFetch_20250910({\n * maxUses: 5,\n * allowedDomains: [\"arxiv.org\", \"example.com\"],\n * citations: { enabled: true },\n * maxContentTokens: 50000,\n * })],\n * }\n * );\n *\n * // Combined with web search for comprehensive information gathering\n * const combinedResponse = await model.invoke(\n * \"Find recent articles about quantum computing and analyze the most relevant one\",\n * {\n * tools: [\n * tools.webSearch_20250305({ maxUses: 3 }),\n * tools.webFetch_20250910({ maxUses: 5, citations: { enabled: true } }),\n * ],\n * }\n * );\n * ```\n */\nexport function webFetch_20250910(\n options?: WebFetch20250910Options\n): ServerTool {\n return {\n type: \"web_fetch_20250910\",\n name: \"web_fetch\",\n max_uses: options?.maxUses,\n allowed_domains: options?.allowedDomains,\n blocked_domains: options?.blockedDomains,\n cache_control: options?.cacheControl,\n citations: options?.citations,\n max_content_tokens: options?.maxContentTokens,\n } satisfies Anthropic.Beta.BetaWebFetchTool20250910;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2FA,SAAgB,kBACd,SACY;AACZ,QAAO;EACL,MAAM;EACN,MAAM;EACN,UAAU,SAAS;EACnB,iBAAiB,SAAS;EAC1B,iBAAiB,SAAS;EAC1B,eAAe,SAAS;EACxB,WAAW,SAAS;EACpB,oBAAoB,SAAS;EAC9B"}
@@ -2,7 +2,6 @@ import Anthropic from "@anthropic-ai/sdk";
2
2
  import { ServerTool } from "@langchain/core/tools";
3
3
 
4
4
  //#region src/tools/webFetch.d.ts
5
-
6
5
  /**
7
6
  * Options for the web fetch tool.
8
7
  */
@@ -1 +1 @@
1
- {"version":3,"file":"webFetch.d.cts","names":["Anthropic","ServerTool","WebFetch20250910Options","Beta","BetaCacheControlEphemeral","webFetch_20250910"],"sources":["../../src/tools/webFetch.d.ts"],"sourcesContent":["import Anthropic from \"@anthropic-ai/sdk\";\nimport { type ServerTool } from \"@langchain/core/tools\";\n/**\n * Options for the web fetch tool.\n */\nexport interface WebFetch20250910Options {\n /**\n * Maximum number of times the tool can be used in the API request.\n */\n maxUses?: number;\n /**\n * If provided, only these domains will be fetched. Cannot be used\n * alongside `blockedDomains`.\n */\n allowedDomains?: string[];\n /**\n * If provided, these domains will never be fetched. Cannot be used\n * alongside `allowedDomains`.\n */\n blockedDomains?: string[];\n /**\n * Create a cache control breakpoint at this content block.\n */\n cacheControl?: Anthropic.Beta.BetaCacheControlEphemeral;\n /**\n * Enable citations for fetched content. Unlike web search where citations\n * are always enabled, citations are optional for web fetch.\n */\n citations?: {\n enabled: boolean;\n };\n /**\n * Maximum content length in tokens. If the fetched content exceeds this limit,\n * it will be truncated. This helps control token usage when fetching large documents.\n */\n maxContentTokens?: number;\n}\n/**\n * Creates a web fetch tool that allows Claude to retrieve full content from specified\n * web pages and PDF documents. Claude can only fetch URLs that have been explicitly\n * provided by the user or that come from previous web search or web fetch results.\n *\n * @warning Enabling the web fetch tool in environments where Claude processes untrusted\n * input alongside sensitive data poses data exfiltration risks. We recommend only using\n * this tool in trusted environments or when handling non-sensitive data.\n *\n * @see {@link https://docs.anthropic.com/en/docs/build-with-claude/tool-use/web-fetch-tool | Anthropic Web Fetch Documentation}\n * @param options - Configuration options for the web fetch tool\n * @returns A web fetch tool definition to be passed to the Anthropic API\n *\n * @example\n * ```typescript\n * import { ChatAnthropic, tools } from \"@langchain/anthropic\";\n *\n * const model = new ChatAnthropic({\n * model: \"claude-sonnet-4-5-20250929\",\n * });\n *\n * // Basic usage - fetch content from a URL\n * const response = await model.invoke(\n * \"Please analyze the content at https://example.com/article\",\n * { tools: [tools.webFetch_20250910()] }\n * );\n *\n * // With options\n * const responseWithOptions = await model.invoke(\n * \"Summarize this research paper: https://arxiv.org/abs/2024.12345\",\n * {\n * tools: [tools.webFetch_20250910({\n * maxUses: 5,\n * allowedDomains: [\"arxiv.org\", \"example.com\"],\n * citations: { enabled: true },\n * maxContentTokens: 50000,\n * })],\n * }\n * );\n *\n * // Combined with web search for comprehensive information gathering\n * const combinedResponse = await model.invoke(\n * \"Find recent articles about quantum computing and analyze the most relevant one\",\n * {\n * tools: [\n * tools.webSearch_20250305({ maxUses: 3 }),\n * tools.webFetch_20250910({ maxUses: 5, citations: { enabled: true } }),\n * ],\n * }\n * );\n * ```\n */\nexport declare function webFetch_20250910(options?: WebFetch20250910Options): ServerTool;\n//# sourceMappingURL=webFetch.d.ts.map"],"mappings":";;;;;;;AAKA;AAoFwBK,UApFPH,uBAAAA,CAoFmCA;;;;;;;;;;;;;;;;;;iBAlEjCF,SAAAA,CAAUG,IAAAA,CAAKC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAkEVC,iBAAAA,WAA4BH,0BAA0BD"}
1
+ {"version":3,"file":"webFetch.d.cts","names":[],"sources":["../../src/tools/webFetch.ts"],"mappings":";;;;;;AAMA;UAAiB,uBAAA;;;;EAIf,OAAA;EAUA;;;;EALA,cAAA;EAcA;;;;EATA,cAAA;EAuEc;;;EAnEd,YAAA,GAAe,SAAA,CAAU,IAAA,CAAK,yBAAA;EAoEpB;;;;EA/DV,SAAA;IACE,OAAA;EAAA;;;;;EAMF,gBAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAuDc,iBAAA,CACd,OAAA,GAAU,uBAAA,GACT,UAAA"}
@@ -2,7 +2,6 @@ import Anthropic from "@anthropic-ai/sdk";
2
2
  import { ServerTool } from "@langchain/core/tools";
3
3
 
4
4
  //#region src/tools/webFetch.d.ts
5
-
6
5
  /**
7
6
  * Options for the web fetch tool.
8
7
  */
@@ -1 +1 @@
1
- {"version":3,"file":"webFetch.d.ts","names":["Anthropic","ServerTool","WebFetch20250910Options","Beta","BetaCacheControlEphemeral","webFetch_20250910"],"sources":["../../src/tools/webFetch.d.ts"],"sourcesContent":["import Anthropic from \"@anthropic-ai/sdk\";\nimport { type ServerTool } from \"@langchain/core/tools\";\n/**\n * Options for the web fetch tool.\n */\nexport interface WebFetch20250910Options {\n /**\n * Maximum number of times the tool can be used in the API request.\n */\n maxUses?: number;\n /**\n * If provided, only these domains will be fetched. Cannot be used\n * alongside `blockedDomains`.\n */\n allowedDomains?: string[];\n /**\n * If provided, these domains will never be fetched. Cannot be used\n * alongside `allowedDomains`.\n */\n blockedDomains?: string[];\n /**\n * Create a cache control breakpoint at this content block.\n */\n cacheControl?: Anthropic.Beta.BetaCacheControlEphemeral;\n /**\n * Enable citations for fetched content. Unlike web search where citations\n * are always enabled, citations are optional for web fetch.\n */\n citations?: {\n enabled: boolean;\n };\n /**\n * Maximum content length in tokens. If the fetched content exceeds this limit,\n * it will be truncated. This helps control token usage when fetching large documents.\n */\n maxContentTokens?: number;\n}\n/**\n * Creates a web fetch tool that allows Claude to retrieve full content from specified\n * web pages and PDF documents. Claude can only fetch URLs that have been explicitly\n * provided by the user or that come from previous web search or web fetch results.\n *\n * @warning Enabling the web fetch tool in environments where Claude processes untrusted\n * input alongside sensitive data poses data exfiltration risks. We recommend only using\n * this tool in trusted environments or when handling non-sensitive data.\n *\n * @see {@link https://docs.anthropic.com/en/docs/build-with-claude/tool-use/web-fetch-tool | Anthropic Web Fetch Documentation}\n * @param options - Configuration options for the web fetch tool\n * @returns A web fetch tool definition to be passed to the Anthropic API\n *\n * @example\n * ```typescript\n * import { ChatAnthropic, tools } from \"@langchain/anthropic\";\n *\n * const model = new ChatAnthropic({\n * model: \"claude-sonnet-4-5-20250929\",\n * });\n *\n * // Basic usage - fetch content from a URL\n * const response = await model.invoke(\n * \"Please analyze the content at https://example.com/article\",\n * { tools: [tools.webFetch_20250910()] }\n * );\n *\n * // With options\n * const responseWithOptions = await model.invoke(\n * \"Summarize this research paper: https://arxiv.org/abs/2024.12345\",\n * {\n * tools: [tools.webFetch_20250910({\n * maxUses: 5,\n * allowedDomains: [\"arxiv.org\", \"example.com\"],\n * citations: { enabled: true },\n * maxContentTokens: 50000,\n * })],\n * }\n * );\n *\n * // Combined with web search for comprehensive information gathering\n * const combinedResponse = await model.invoke(\n * \"Find recent articles about quantum computing and analyze the most relevant one\",\n * {\n * tools: [\n * tools.webSearch_20250305({ maxUses: 3 }),\n * tools.webFetch_20250910({ maxUses: 5, citations: { enabled: true } }),\n * ],\n * }\n * );\n * ```\n */\nexport declare function webFetch_20250910(options?: WebFetch20250910Options): ServerTool;\n//# sourceMappingURL=webFetch.d.ts.map"],"mappings":";;;;;;;AAKA;AAoFwBK,UApFPH,uBAAAA,CAoFmCA;;;;;;;;;;;;;;;;;;iBAlEjCF,SAAAA,CAAUG,IAAAA,CAAKC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAkEVC,iBAAAA,WAA4BH,0BAA0BD"}
1
+ {"version":3,"file":"webFetch.d.ts","names":[],"sources":["../../src/tools/webFetch.ts"],"mappings":";;;;;;AAMA;UAAiB,uBAAA;;;;EAIf,OAAA;EAUA;;;;EALA,cAAA;EAcA;;;;EATA,cAAA;EAuEc;;;EAnEd,YAAA,GAAe,SAAA,CAAU,IAAA,CAAK,yBAAA;EAoEpB;;;;EA/DV,SAAA;IACE,OAAA;EAAA;;;;;EAMF,gBAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAuDc,iBAAA,CACd,OAAA,GAAU,uBAAA,GACT,UAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"webFetch.js","names":["options?: WebFetch20250910Options"],"sources":["../../src/tools/webFetch.ts"],"sourcesContent":["import Anthropic from \"@anthropic-ai/sdk\";\nimport { type ServerTool } from \"@langchain/core/tools\";\n\n/**\n * Options for the web fetch tool.\n */\nexport interface WebFetch20250910Options {\n /**\n * Maximum number of times the tool can be used in the API request.\n */\n maxUses?: number;\n /**\n * If provided, only these domains will be fetched. Cannot be used\n * alongside `blockedDomains`.\n */\n allowedDomains?: string[];\n /**\n * If provided, these domains will never be fetched. Cannot be used\n * alongside `allowedDomains`.\n */\n blockedDomains?: string[];\n /**\n * Create a cache control breakpoint at this content block.\n */\n cacheControl?: Anthropic.Beta.BetaCacheControlEphemeral;\n /**\n * Enable citations for fetched content. Unlike web search where citations\n * are always enabled, citations are optional for web fetch.\n */\n citations?: {\n enabled: boolean;\n };\n /**\n * Maximum content length in tokens. If the fetched content exceeds this limit,\n * it will be truncated. This helps control token usage when fetching large documents.\n */\n maxContentTokens?: number;\n}\n\n/**\n * Creates a web fetch tool that allows Claude to retrieve full content from specified\n * web pages and PDF documents. Claude can only fetch URLs that have been explicitly\n * provided by the user or that come from previous web search or web fetch results.\n *\n * @warning Enabling the web fetch tool in environments where Claude processes untrusted\n * input alongside sensitive data poses data exfiltration risks. We recommend only using\n * this tool in trusted environments or when handling non-sensitive data.\n *\n * @see {@link https://docs.anthropic.com/en/docs/build-with-claude/tool-use/web-fetch-tool | Anthropic Web Fetch Documentation}\n * @param options - Configuration options for the web fetch tool\n * @returns A web fetch tool definition to be passed to the Anthropic API\n *\n * @example\n * ```typescript\n * import { ChatAnthropic, tools } from \"@langchain/anthropic\";\n *\n * const model = new ChatAnthropic({\n * model: \"claude-sonnet-4-5-20250929\",\n * });\n *\n * // Basic usage - fetch content from a URL\n * const response = await model.invoke(\n * \"Please analyze the content at https://example.com/article\",\n * { tools: [tools.webFetch_20250910()] }\n * );\n *\n * // With options\n * const responseWithOptions = await model.invoke(\n * \"Summarize this research paper: https://arxiv.org/abs/2024.12345\",\n * {\n * tools: [tools.webFetch_20250910({\n * maxUses: 5,\n * allowedDomains: [\"arxiv.org\", \"example.com\"],\n * citations: { enabled: true },\n * maxContentTokens: 50000,\n * })],\n * }\n * );\n *\n * // Combined with web search for comprehensive information gathering\n * const combinedResponse = await model.invoke(\n * \"Find recent articles about quantum computing and analyze the most relevant one\",\n * {\n * tools: [\n * tools.webSearch_20250305({ maxUses: 3 }),\n * tools.webFetch_20250910({ maxUses: 5, citations: { enabled: true } }),\n * ],\n * }\n * );\n * ```\n */\nexport function webFetch_20250910(\n options?: WebFetch20250910Options\n): ServerTool {\n return {\n type: \"web_fetch_20250910\",\n name: \"web_fetch\",\n max_uses: options?.maxUses,\n allowed_domains: options?.allowedDomains,\n blocked_domains: options?.blockedDomains,\n cache_control: options?.cacheControl,\n citations: options?.citations,\n max_content_tokens: options?.maxContentTokens,\n } satisfies Anthropic.Beta.BetaWebFetchTool20250910;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2FA,SAAgB,kBACdA,SACY;AACZ,QAAO;EACL,MAAM;EACN,MAAM;EACN,UAAU,SAAS;EACnB,iBAAiB,SAAS;EAC1B,iBAAiB,SAAS;EAC1B,eAAe,SAAS;EACxB,WAAW,SAAS;EACpB,oBAAoB,SAAS;CAC9B;AACF"}
1
+ {"version":3,"file":"webFetch.js","names":[],"sources":["../../src/tools/webFetch.ts"],"sourcesContent":["import Anthropic from \"@anthropic-ai/sdk\";\nimport { type ServerTool } from \"@langchain/core/tools\";\n\n/**\n * Options for the web fetch tool.\n */\nexport interface WebFetch20250910Options {\n /**\n * Maximum number of times the tool can be used in the API request.\n */\n maxUses?: number;\n /**\n * If provided, only these domains will be fetched. Cannot be used\n * alongside `blockedDomains`.\n */\n allowedDomains?: string[];\n /**\n * If provided, these domains will never be fetched. Cannot be used\n * alongside `allowedDomains`.\n */\n blockedDomains?: string[];\n /**\n * Create a cache control breakpoint at this content block.\n */\n cacheControl?: Anthropic.Beta.BetaCacheControlEphemeral;\n /**\n * Enable citations for fetched content. Unlike web search where citations\n * are always enabled, citations are optional for web fetch.\n */\n citations?: {\n enabled: boolean;\n };\n /**\n * Maximum content length in tokens. If the fetched content exceeds this limit,\n * it will be truncated. This helps control token usage when fetching large documents.\n */\n maxContentTokens?: number;\n}\n\n/**\n * Creates a web fetch tool that allows Claude to retrieve full content from specified\n * web pages and PDF documents. Claude can only fetch URLs that have been explicitly\n * provided by the user or that come from previous web search or web fetch results.\n *\n * @warning Enabling the web fetch tool in environments where Claude processes untrusted\n * input alongside sensitive data poses data exfiltration risks. We recommend only using\n * this tool in trusted environments or when handling non-sensitive data.\n *\n * @see {@link https://docs.anthropic.com/en/docs/build-with-claude/tool-use/web-fetch-tool | Anthropic Web Fetch Documentation}\n * @param options - Configuration options for the web fetch tool\n * @returns A web fetch tool definition to be passed to the Anthropic API\n *\n * @example\n * ```typescript\n * import { ChatAnthropic, tools } from \"@langchain/anthropic\";\n *\n * const model = new ChatAnthropic({\n * model: \"claude-sonnet-4-5-20250929\",\n * });\n *\n * // Basic usage - fetch content from a URL\n * const response = await model.invoke(\n * \"Please analyze the content at https://example.com/article\",\n * { tools: [tools.webFetch_20250910()] }\n * );\n *\n * // With options\n * const responseWithOptions = await model.invoke(\n * \"Summarize this research paper: https://arxiv.org/abs/2024.12345\",\n * {\n * tools: [tools.webFetch_20250910({\n * maxUses: 5,\n * allowedDomains: [\"arxiv.org\", \"example.com\"],\n * citations: { enabled: true },\n * maxContentTokens: 50000,\n * })],\n * }\n * );\n *\n * // Combined with web search for comprehensive information gathering\n * const combinedResponse = await model.invoke(\n * \"Find recent articles about quantum computing and analyze the most relevant one\",\n * {\n * tools: [\n * tools.webSearch_20250305({ maxUses: 3 }),\n * tools.webFetch_20250910({ maxUses: 5, citations: { enabled: true } }),\n * ],\n * }\n * );\n * ```\n */\nexport function webFetch_20250910(\n options?: WebFetch20250910Options\n): ServerTool {\n return {\n type: \"web_fetch_20250910\",\n name: \"web_fetch\",\n max_uses: options?.maxUses,\n allowed_domains: options?.allowedDomains,\n blocked_domains: options?.blockedDomains,\n cache_control: options?.cacheControl,\n citations: options?.citations,\n max_content_tokens: options?.maxContentTokens,\n } satisfies Anthropic.Beta.BetaWebFetchTool20250910;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2FA,SAAgB,kBACd,SACY;AACZ,QAAO;EACL,MAAM;EACN,MAAM;EACN,UAAU,SAAS;EACnB,iBAAiB,SAAS;EAC1B,iBAAiB,SAAS;EAC1B,eAAe,SAAS;EACxB,WAAW,SAAS;EACpB,oBAAoB,SAAS;EAC9B"}
@@ -1 +1 @@
1
- {"version":3,"file":"webSearch.cjs","names":["options?: WebSearch20250305Options"],"sources":["../../src/tools/webSearch.ts"],"sourcesContent":["import Anthropic from \"@anthropic-ai/sdk\";\nimport { type ServerTool } from \"@langchain/core/tools\";\n\n/**\n * Options for the web search tool.\n */\nexport interface WebSearch20250305Options {\n /**\n * Maximum number of times the tool can be used in the API request.\n */\n maxUses?: number;\n /**\n * If provided, only these domains will be included in results. Cannot be used\n * alongside `blocked_domains`.\n */\n allowedDomains?: string[];\n /**\n * If provided, these domains will never appear in results. Cannot be used\n * alongside `allowed_domains`.\n */\n blockedDomains?: string[];\n /**\n * Create a cache control breakpoint at this content block.\n */\n cacheControl?: Anthropic.Beta.BetaCacheControlEphemeral;\n /**\n * Parameters for the user's location. Used to provide more relevant search\n * results.\n */\n userLocation?: Anthropic.Beta.BetaWebSearchTool20250305.UserLocation;\n /**\n * If true, tool will not be included in initial system prompt. Only loaded when\n * returned via tool_reference from tool search.\n */\n deferLoading?: boolean;\n /**\n * If true, tool will only return results from the allowed domains.\n */\n strict?: boolean;\n}\n\n/**\n * Creates a web search tool that gives Claude direct access to real-time web content,\n * allowing it to answer questions with up-to-date information beyond its knowledge cutoff.\n * Claude automatically cites sources from search results as part of its answer.\n *\n * @see {@link https://docs.anthropic.com/en/docs/build-with-claude/tool-use/web-search-tool | Anthropic Web Search Documentation}\n * @param options - Configuration options for the web search tool\n * @returns A web search tool definition to be passed to the Anthropic API\n *\n * @example\n * ```typescript\n * import { ChatAnthropic, tools } from \"@langchain/anthropic\";\n *\n * const model = new ChatAnthropic({\n * model: \"claude-sonnet-4-5-20250929\",\n * });\n *\n * // Basic usage\n * const response = await model.invoke(\"What is the weather in NYC?\", {\n * tools: [tools.webSearch_20250305()],\n * });\n *\n * // With options\n * const responseWithOptions = await model.invoke(\"Latest news about AI?\", {\n * tools: [tools.webSearch_20250305({\n * maxUses: 5,\n * allowedDomains: [\"reuters.com\", \"bbc.com\"],\n * userLocation: {\n * type: \"approximate\",\n * city: \"San Francisco\",\n * region: \"California\",\n * country: \"US\",\n * timezone: \"America/Los_Angeles\",\n * },\n * })],\n * });\n * ```\n */\nexport function webSearch_20250305(\n options?: WebSearch20250305Options\n): ServerTool {\n return {\n type: \"web_search_20250305\",\n name: \"web_search\",\n max_uses: options?.maxUses,\n allowed_domains: options?.allowedDomains,\n blocked_domains: options?.blockedDomains,\n cache_control: options?.cacheControl,\n defer_loading: options?.deferLoading,\n strict: options?.strict,\n user_location: options?.userLocation,\n } satisfies Anthropic.Beta.BetaWebSearchTool20250305;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+EA,SAAgB,mBACdA,SACY;AACZ,QAAO;EACL,MAAM;EACN,MAAM;EACN,UAAU,SAAS;EACnB,iBAAiB,SAAS;EAC1B,iBAAiB,SAAS;EAC1B,eAAe,SAAS;EACxB,eAAe,SAAS;EACxB,QAAQ,SAAS;EACjB,eAAe,SAAS;CACzB;AACF"}
1
+ {"version":3,"file":"webSearch.cjs","names":[],"sources":["../../src/tools/webSearch.ts"],"sourcesContent":["import Anthropic from \"@anthropic-ai/sdk\";\nimport { type ServerTool } from \"@langchain/core/tools\";\n\n/**\n * Options for the web search tool.\n */\nexport interface WebSearch20250305Options {\n /**\n * Maximum number of times the tool can be used in the API request.\n */\n maxUses?: number;\n /**\n * If provided, only these domains will be included in results. Cannot be used\n * alongside `blocked_domains`.\n */\n allowedDomains?: string[];\n /**\n * If provided, these domains will never appear in results. Cannot be used\n * alongside `allowed_domains`.\n */\n blockedDomains?: string[];\n /**\n * Create a cache control breakpoint at this content block.\n */\n cacheControl?: Anthropic.Beta.BetaCacheControlEphemeral;\n /**\n * Parameters for the user's location. Used to provide more relevant search\n * results.\n */\n userLocation?: Anthropic.Beta.BetaWebSearchTool20250305.UserLocation;\n /**\n * If true, tool will not be included in initial system prompt. Only loaded when\n * returned via tool_reference from tool search.\n */\n deferLoading?: boolean;\n /**\n * If true, tool will only return results from the allowed domains.\n */\n strict?: boolean;\n}\n\n/**\n * Creates a web search tool that gives Claude direct access to real-time web content,\n * allowing it to answer questions with up-to-date information beyond its knowledge cutoff.\n * Claude automatically cites sources from search results as part of its answer.\n *\n * @see {@link https://docs.anthropic.com/en/docs/build-with-claude/tool-use/web-search-tool | Anthropic Web Search Documentation}\n * @param options - Configuration options for the web search tool\n * @returns A web search tool definition to be passed to the Anthropic API\n *\n * @example\n * ```typescript\n * import { ChatAnthropic, tools } from \"@langchain/anthropic\";\n *\n * const model = new ChatAnthropic({\n * model: \"claude-sonnet-4-5-20250929\",\n * });\n *\n * // Basic usage\n * const response = await model.invoke(\"What is the weather in NYC?\", {\n * tools: [tools.webSearch_20250305()],\n * });\n *\n * // With options\n * const responseWithOptions = await model.invoke(\"Latest news about AI?\", {\n * tools: [tools.webSearch_20250305({\n * maxUses: 5,\n * allowedDomains: [\"reuters.com\", \"bbc.com\"],\n * userLocation: {\n * type: \"approximate\",\n * city: \"San Francisco\",\n * region: \"California\",\n * country: \"US\",\n * timezone: \"America/Los_Angeles\",\n * },\n * })],\n * });\n * ```\n */\nexport function webSearch_20250305(\n options?: WebSearch20250305Options\n): ServerTool {\n return {\n type: \"web_search_20250305\",\n name: \"web_search\",\n max_uses: options?.maxUses,\n allowed_domains: options?.allowedDomains,\n blocked_domains: options?.blockedDomains,\n cache_control: options?.cacheControl,\n defer_loading: options?.deferLoading,\n strict: options?.strict,\n user_location: options?.userLocation,\n } satisfies Anthropic.Beta.BetaWebSearchTool20250305;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+EA,SAAgB,mBACd,SACY;AACZ,QAAO;EACL,MAAM;EACN,MAAM;EACN,UAAU,SAAS;EACnB,iBAAiB,SAAS;EAC1B,iBAAiB,SAAS;EAC1B,eAAe,SAAS;EACxB,eAAe,SAAS;EACxB,QAAQ,SAAS;EACjB,eAAe,SAAS;EACzB"}
@@ -2,7 +2,6 @@ import Anthropic from "@anthropic-ai/sdk";
2
2
  import { ServerTool } from "@langchain/core/tools";
3
3
 
4
4
  //#region src/tools/webSearch.d.ts
5
-
6
5
  /**
7
6
  * Options for the web search tool.
8
7
  */
@@ -1 +1 @@
1
- {"version":3,"file":"webSearch.d.cts","names":["Anthropic","ServerTool","WebSearch20250305Options","Beta","BetaCacheControlEphemeral","BetaWebSearchTool20250305","UserLocation","webSearch_20250305"],"sources":["../../src/tools/webSearch.d.ts"],"sourcesContent":["import Anthropic from \"@anthropic-ai/sdk\";\nimport { type ServerTool } from \"@langchain/core/tools\";\n/**\n * Options for the web search tool.\n */\nexport interface WebSearch20250305Options {\n /**\n * Maximum number of times the tool can be used in the API request.\n */\n maxUses?: number;\n /**\n * If provided, only these domains will be included in results. Cannot be used\n * alongside `blocked_domains`.\n */\n allowedDomains?: string[];\n /**\n * If provided, these domains will never appear in results. Cannot be used\n * alongside `allowed_domains`.\n */\n blockedDomains?: string[];\n /**\n * Create a cache control breakpoint at this content block.\n */\n cacheControl?: Anthropic.Beta.BetaCacheControlEphemeral;\n /**\n * Parameters for the user's location. Used to provide more relevant search\n * results.\n */\n userLocation?: Anthropic.Beta.BetaWebSearchTool20250305.UserLocation;\n /**\n * If true, tool will not be included in initial system prompt. Only loaded when\n * returned via tool_reference from tool search.\n */\n deferLoading?: boolean;\n /**\n * If true, tool will only return results from the allowed domains.\n */\n strict?: boolean;\n}\n/**\n * Creates a web search tool that gives Claude direct access to real-time web content,\n * allowing it to answer questions with up-to-date information beyond its knowledge cutoff.\n * Claude automatically cites sources from search results as part of its answer.\n *\n * @see {@link https://docs.anthropic.com/en/docs/build-with-claude/tool-use/web-search-tool | Anthropic Web Search Documentation}\n * @param options - Configuration options for the web search tool\n * @returns A web search tool definition to be passed to the Anthropic API\n *\n * @example\n * ```typescript\n * import { ChatAnthropic, tools } from \"@langchain/anthropic\";\n *\n * const model = new ChatAnthropic({\n * model: \"claude-sonnet-4-5-20250929\",\n * });\n *\n * // Basic usage\n * const response = await model.invoke(\"What is the weather in NYC?\", {\n * tools: [tools.webSearch_20250305()],\n * });\n *\n * // With options\n * const responseWithOptions = await model.invoke(\"Latest news about AI?\", {\n * tools: [tools.webSearch_20250305({\n * maxUses: 5,\n * allowedDomains: [\"reuters.com\", \"bbc.com\"],\n * userLocation: {\n * type: \"approximate\",\n * city: \"San Francisco\",\n * region: \"California\",\n * country: \"US\",\n * timezone: \"America/Los_Angeles\",\n * },\n * })],\n * });\n * ```\n */\nexport declare function webSearch_20250305(options?: WebSearch20250305Options): ServerTool;\n//# sourceMappingURL=webSearch.d.ts.map"],"mappings":";;;;;;;AAKA;AAwEwBO,UAxEPL,wBAAAA,CAwEoCA;;;;;;;;;;;;;;;;;;iBAtDlCF,SAAAA,CAAUG,IAAAA,CAAKC;;;;;iBAKfJ,SAAAA,CAAUG,IAAAA,CAAKE,yBAAAA,CAA0BC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAiDpCC,kBAAAA,WAA6BL,2BAA2BD"}
1
+ {"version":3,"file":"webSearch.d.cts","names":[],"sources":["../../src/tools/webSearch.ts"],"mappings":";;;;;;AAMA;UAAiB,wBAAA;;;;EAIf,OAAA;EAUA;;;;EALA,cAAA;EAcA;;;;EATA,cAAA;EAcA;;;EAVA,YAAA,GAAe,SAAA,CAAU,IAAA,CAAK,yBAAA;EAuDhB;;;;EAlDd,YAAA,GAAe,SAAA,CAAU,IAAA,CAAK,yBAAA,CAA0B,YAAA;EAmDxD;;;;EA9CA,YAAA;;;;EAIA,MAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAyCc,kBAAA,CACd,OAAA,GAAU,wBAAA,GACT,UAAA"}
@@ -2,7 +2,6 @@ import Anthropic from "@anthropic-ai/sdk";
2
2
  import { ServerTool } from "@langchain/core/tools";
3
3
 
4
4
  //#region src/tools/webSearch.d.ts
5
-
6
5
  /**
7
6
  * Options for the web search tool.
8
7
  */
@@ -1 +1 @@
1
- {"version":3,"file":"webSearch.d.ts","names":["Anthropic","ServerTool","WebSearch20250305Options","Beta","BetaCacheControlEphemeral","BetaWebSearchTool20250305","UserLocation","webSearch_20250305"],"sources":["../../src/tools/webSearch.d.ts"],"sourcesContent":["import Anthropic from \"@anthropic-ai/sdk\";\nimport { type ServerTool } from \"@langchain/core/tools\";\n/**\n * Options for the web search tool.\n */\nexport interface WebSearch20250305Options {\n /**\n * Maximum number of times the tool can be used in the API request.\n */\n maxUses?: number;\n /**\n * If provided, only these domains will be included in results. Cannot be used\n * alongside `blocked_domains`.\n */\n allowedDomains?: string[];\n /**\n * If provided, these domains will never appear in results. Cannot be used\n * alongside `allowed_domains`.\n */\n blockedDomains?: string[];\n /**\n * Create a cache control breakpoint at this content block.\n */\n cacheControl?: Anthropic.Beta.BetaCacheControlEphemeral;\n /**\n * Parameters for the user's location. Used to provide more relevant search\n * results.\n */\n userLocation?: Anthropic.Beta.BetaWebSearchTool20250305.UserLocation;\n /**\n * If true, tool will not be included in initial system prompt. Only loaded when\n * returned via tool_reference from tool search.\n */\n deferLoading?: boolean;\n /**\n * If true, tool will only return results from the allowed domains.\n */\n strict?: boolean;\n}\n/**\n * Creates a web search tool that gives Claude direct access to real-time web content,\n * allowing it to answer questions with up-to-date information beyond its knowledge cutoff.\n * Claude automatically cites sources from search results as part of its answer.\n *\n * @see {@link https://docs.anthropic.com/en/docs/build-with-claude/tool-use/web-search-tool | Anthropic Web Search Documentation}\n * @param options - Configuration options for the web search tool\n * @returns A web search tool definition to be passed to the Anthropic API\n *\n * @example\n * ```typescript\n * import { ChatAnthropic, tools } from \"@langchain/anthropic\";\n *\n * const model = new ChatAnthropic({\n * model: \"claude-sonnet-4-5-20250929\",\n * });\n *\n * // Basic usage\n * const response = await model.invoke(\"What is the weather in NYC?\", {\n * tools: [tools.webSearch_20250305()],\n * });\n *\n * // With options\n * const responseWithOptions = await model.invoke(\"Latest news about AI?\", {\n * tools: [tools.webSearch_20250305({\n * maxUses: 5,\n * allowedDomains: [\"reuters.com\", \"bbc.com\"],\n * userLocation: {\n * type: \"approximate\",\n * city: \"San Francisco\",\n * region: \"California\",\n * country: \"US\",\n * timezone: \"America/Los_Angeles\",\n * },\n * })],\n * });\n * ```\n */\nexport declare function webSearch_20250305(options?: WebSearch20250305Options): ServerTool;\n//# sourceMappingURL=webSearch.d.ts.map"],"mappings":";;;;;;;AAKA;AAwEwBO,UAxEPL,wBAAAA,CAwEoCA;;;;;;;;;;;;;;;;;;iBAtDlCF,SAAAA,CAAUG,IAAAA,CAAKC;;;;;iBAKfJ,SAAAA,CAAUG,IAAAA,CAAKE,yBAAAA,CAA0BC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAiDpCC,kBAAAA,WAA6BL,2BAA2BD"}
1
+ {"version":3,"file":"webSearch.d.ts","names":[],"sources":["../../src/tools/webSearch.ts"],"mappings":";;;;;;AAMA;UAAiB,wBAAA;;;;EAIf,OAAA;EAUA;;;;EALA,cAAA;EAcA;;;;EATA,cAAA;EAcA;;;EAVA,YAAA,GAAe,SAAA,CAAU,IAAA,CAAK,yBAAA;EAuDhB;;;;EAlDd,YAAA,GAAe,SAAA,CAAU,IAAA,CAAK,yBAAA,CAA0B,YAAA;EAmDxD;;;;EA9CA,YAAA;;;;EAIA,MAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAyCc,kBAAA,CACd,OAAA,GAAU,wBAAA,GACT,UAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"webSearch.js","names":["options?: WebSearch20250305Options"],"sources":["../../src/tools/webSearch.ts"],"sourcesContent":["import Anthropic from \"@anthropic-ai/sdk\";\nimport { type ServerTool } from \"@langchain/core/tools\";\n\n/**\n * Options for the web search tool.\n */\nexport interface WebSearch20250305Options {\n /**\n * Maximum number of times the tool can be used in the API request.\n */\n maxUses?: number;\n /**\n * If provided, only these domains will be included in results. Cannot be used\n * alongside `blocked_domains`.\n */\n allowedDomains?: string[];\n /**\n * If provided, these domains will never appear in results. Cannot be used\n * alongside `allowed_domains`.\n */\n blockedDomains?: string[];\n /**\n * Create a cache control breakpoint at this content block.\n */\n cacheControl?: Anthropic.Beta.BetaCacheControlEphemeral;\n /**\n * Parameters for the user's location. Used to provide more relevant search\n * results.\n */\n userLocation?: Anthropic.Beta.BetaWebSearchTool20250305.UserLocation;\n /**\n * If true, tool will not be included in initial system prompt. Only loaded when\n * returned via tool_reference from tool search.\n */\n deferLoading?: boolean;\n /**\n * If true, tool will only return results from the allowed domains.\n */\n strict?: boolean;\n}\n\n/**\n * Creates a web search tool that gives Claude direct access to real-time web content,\n * allowing it to answer questions with up-to-date information beyond its knowledge cutoff.\n * Claude automatically cites sources from search results as part of its answer.\n *\n * @see {@link https://docs.anthropic.com/en/docs/build-with-claude/tool-use/web-search-tool | Anthropic Web Search Documentation}\n * @param options - Configuration options for the web search tool\n * @returns A web search tool definition to be passed to the Anthropic API\n *\n * @example\n * ```typescript\n * import { ChatAnthropic, tools } from \"@langchain/anthropic\";\n *\n * const model = new ChatAnthropic({\n * model: \"claude-sonnet-4-5-20250929\",\n * });\n *\n * // Basic usage\n * const response = await model.invoke(\"What is the weather in NYC?\", {\n * tools: [tools.webSearch_20250305()],\n * });\n *\n * // With options\n * const responseWithOptions = await model.invoke(\"Latest news about AI?\", {\n * tools: [tools.webSearch_20250305({\n * maxUses: 5,\n * allowedDomains: [\"reuters.com\", \"bbc.com\"],\n * userLocation: {\n * type: \"approximate\",\n * city: \"San Francisco\",\n * region: \"California\",\n * country: \"US\",\n * timezone: \"America/Los_Angeles\",\n * },\n * })],\n * });\n * ```\n */\nexport function webSearch_20250305(\n options?: WebSearch20250305Options\n): ServerTool {\n return {\n type: \"web_search_20250305\",\n name: \"web_search\",\n max_uses: options?.maxUses,\n allowed_domains: options?.allowedDomains,\n blocked_domains: options?.blockedDomains,\n cache_control: options?.cacheControl,\n defer_loading: options?.deferLoading,\n strict: options?.strict,\n user_location: options?.userLocation,\n } satisfies Anthropic.Beta.BetaWebSearchTool20250305;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+EA,SAAgB,mBACdA,SACY;AACZ,QAAO;EACL,MAAM;EACN,MAAM;EACN,UAAU,SAAS;EACnB,iBAAiB,SAAS;EAC1B,iBAAiB,SAAS;EAC1B,eAAe,SAAS;EACxB,eAAe,SAAS;EACxB,QAAQ,SAAS;EACjB,eAAe,SAAS;CACzB;AACF"}
1
+ {"version":3,"file":"webSearch.js","names":[],"sources":["../../src/tools/webSearch.ts"],"sourcesContent":["import Anthropic from \"@anthropic-ai/sdk\";\nimport { type ServerTool } from \"@langchain/core/tools\";\n\n/**\n * Options for the web search tool.\n */\nexport interface WebSearch20250305Options {\n /**\n * Maximum number of times the tool can be used in the API request.\n */\n maxUses?: number;\n /**\n * If provided, only these domains will be included in results. Cannot be used\n * alongside `blocked_domains`.\n */\n allowedDomains?: string[];\n /**\n * If provided, these domains will never appear in results. Cannot be used\n * alongside `allowed_domains`.\n */\n blockedDomains?: string[];\n /**\n * Create a cache control breakpoint at this content block.\n */\n cacheControl?: Anthropic.Beta.BetaCacheControlEphemeral;\n /**\n * Parameters for the user's location. Used to provide more relevant search\n * results.\n */\n userLocation?: Anthropic.Beta.BetaWebSearchTool20250305.UserLocation;\n /**\n * If true, tool will not be included in initial system prompt. Only loaded when\n * returned via tool_reference from tool search.\n */\n deferLoading?: boolean;\n /**\n * If true, tool will only return results from the allowed domains.\n */\n strict?: boolean;\n}\n\n/**\n * Creates a web search tool that gives Claude direct access to real-time web content,\n * allowing it to answer questions with up-to-date information beyond its knowledge cutoff.\n * Claude automatically cites sources from search results as part of its answer.\n *\n * @see {@link https://docs.anthropic.com/en/docs/build-with-claude/tool-use/web-search-tool | Anthropic Web Search Documentation}\n * @param options - Configuration options for the web search tool\n * @returns A web search tool definition to be passed to the Anthropic API\n *\n * @example\n * ```typescript\n * import { ChatAnthropic, tools } from \"@langchain/anthropic\";\n *\n * const model = new ChatAnthropic({\n * model: \"claude-sonnet-4-5-20250929\",\n * });\n *\n * // Basic usage\n * const response = await model.invoke(\"What is the weather in NYC?\", {\n * tools: [tools.webSearch_20250305()],\n * });\n *\n * // With options\n * const responseWithOptions = await model.invoke(\"Latest news about AI?\", {\n * tools: [tools.webSearch_20250305({\n * maxUses: 5,\n * allowedDomains: [\"reuters.com\", \"bbc.com\"],\n * userLocation: {\n * type: \"approximate\",\n * city: \"San Francisco\",\n * region: \"California\",\n * country: \"US\",\n * timezone: \"America/Los_Angeles\",\n * },\n * })],\n * });\n * ```\n */\nexport function webSearch_20250305(\n options?: WebSearch20250305Options\n): ServerTool {\n return {\n type: \"web_search_20250305\",\n name: \"web_search\",\n max_uses: options?.maxUses,\n allowed_domains: options?.allowedDomains,\n blocked_domains: options?.blockedDomains,\n cache_control: options?.cacheControl,\n defer_loading: options?.deferLoading,\n strict: options?.strict,\n user_location: options?.userLocation,\n } satisfies Anthropic.Beta.BetaWebSearchTool20250305;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+EA,SAAgB,mBACd,SACY;AACZ,QAAO;EACL,MAAM;EACN,MAAM;EACN,UAAU,SAAS;EACnB,iBAAiB,SAAS;EAC1B,iBAAiB,SAAS;EAC1B,eAAe,SAAS;EACxB,eAAe,SAAS;EACxB,QAAQ,SAAS;EACjB,eAAe,SAAS;EACzB"}
package/dist/types.d.cts CHANGED
@@ -2,7 +2,6 @@ import Anthropic from "@anthropic-ai/sdk";
2
2
  import { BindToolsInput } from "@langchain/core/language_models/chat_models";
3
3
 
4
4
  //#region src/types.d.ts
5
-
6
5
  type AnthropicMessageCreateParams = Anthropic.MessageCreateParamsNonStreaming;
7
6
  type AnthropicStreamingMessageCreateParams = Anthropic.MessageCreateParamsStreaming;
8
7
  type AnthropicThinkingConfigParam = Anthropic.ThinkingConfigParam;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.cts","names":["Anthropic","BindToolsInput","AnthropicToolResponse","Record","AnthropicMessageParam","MessageParam","AnthropicMessageResponse","ContentBlock","AnthropicMessageCreateParams","MessageCreateParamsNonStreaming","AnthropicStreamingMessageCreateParams","MessageCreateParamsStreaming","AnthropicThinkingConfigParam","ThinkingConfigParam","AnthropicContextManagementConfigParam","Beta","BetaContextManagementConfig","AnthropicMessageStreamEvent","MessageStreamEvent","AnthropicRequestOptions","RequestOptions","AnthropicToolChoice","ChatAnthropicToolType","Messages","Tool","ChatAnthropicOutputFormat","JSONOutputFormat","AnthropicOutputConfig","OutputConfig","AnthropicTextBlockParam","TextBlockParam","AnthropicImageBlockParam","ImageBlockParam","AnthropicToolUseBlockParam","ToolUseBlockParam","AnthropicToolResultBlockParam","ToolResultBlockParam","AnthropicDocumentBlockParam","DocumentBlockParam","AnthropicThinkingBlockParam","ThinkingBlockParam","AnthropicRedactedThinkingBlockParam","RedactedThinkingBlockParam","AnthropicServerToolUseBlockParam","ServerToolUseBlockParam","AnthropicWebSearchToolResultBlockParam","WebSearchToolResultBlockParam","AnthropicWebSearchResultBlockParam","WebSearchResultBlockParam","AnthropicSearchResultBlockParam","SearchResultBlockParam","AnthropicContainerUploadBlockParam","BetaContainerUploadBlockParam","AnthropicCompactionBlockParam","BetaCompactionBlockParam","AnthropicMCPServerURLDefinition","BetaRequestMCPServerURLDefinition","ChatAnthropicContentBlock","isAnthropicImageBlockParam","AnthropicBuiltInToolUnion","ToolUnion","Exclude","Kwargs","AnthropicInvocationParams","Omit"],"sources":["../src/types.d.ts"],"sourcesContent":["import Anthropic from \"@anthropic-ai/sdk\";\nimport { BindToolsInput } from \"@langchain/core/language_models/chat_models\";\nexport type AnthropicToolResponse = {\n type: \"tool_use\";\n id: string;\n name: string;\n input: Record<string, any>;\n};\nexport type AnthropicMessageParam = Anthropic.MessageParam;\nexport type AnthropicMessageResponse = Anthropic.ContentBlock | AnthropicToolResponse;\nexport type AnthropicMessageCreateParams = Anthropic.MessageCreateParamsNonStreaming;\nexport type AnthropicStreamingMessageCreateParams = Anthropic.MessageCreateParamsStreaming;\nexport type AnthropicThinkingConfigParam = Anthropic.ThinkingConfigParam;\nexport type AnthropicContextManagementConfigParam = Anthropic.Beta.BetaContextManagementConfig;\nexport type AnthropicMessageStreamEvent = Anthropic.MessageStreamEvent;\nexport type AnthropicRequestOptions = Anthropic.RequestOptions;\nexport type AnthropicToolChoice = {\n type: \"tool\";\n name: string;\n} | \"any\" | \"auto\" | \"none\" | string;\nexport type ChatAnthropicToolType = Anthropic.Messages.Tool | BindToolsInput;\nexport type ChatAnthropicOutputFormat = Anthropic.Messages.JSONOutputFormat;\nexport type AnthropicOutputConfig = Anthropic.Messages.OutputConfig;\nexport type AnthropicTextBlockParam = Anthropic.Messages.TextBlockParam;\nexport type AnthropicImageBlockParam = Anthropic.Messages.ImageBlockParam;\nexport type AnthropicToolUseBlockParam = Anthropic.Messages.ToolUseBlockParam;\nexport type AnthropicToolResultBlockParam = Anthropic.Messages.ToolResultBlockParam;\nexport type AnthropicDocumentBlockParam = Anthropic.Messages.DocumentBlockParam;\nexport type AnthropicThinkingBlockParam = Anthropic.Messages.ThinkingBlockParam;\nexport type AnthropicRedactedThinkingBlockParam = Anthropic.Messages.RedactedThinkingBlockParam;\nexport type AnthropicServerToolUseBlockParam = Anthropic.Messages.ServerToolUseBlockParam;\nexport type AnthropicWebSearchToolResultBlockParam = Anthropic.Messages.WebSearchToolResultBlockParam;\nexport type AnthropicWebSearchResultBlockParam = Anthropic.Messages.WebSearchResultBlockParam;\nexport type AnthropicSearchResultBlockParam = Anthropic.SearchResultBlockParam;\nexport type AnthropicContainerUploadBlockParam = Anthropic.Beta.BetaContainerUploadBlockParam;\nexport type AnthropicCompactionBlockParam = Anthropic.Beta.BetaCompactionBlockParam;\nexport type AnthropicMCPServerURLDefinition = Anthropic.Beta.Messages.BetaRequestMCPServerURLDefinition;\nexport type ChatAnthropicContentBlock = AnthropicTextBlockParam | AnthropicImageBlockParam | AnthropicToolUseBlockParam | AnthropicToolResultBlockParam | AnthropicDocumentBlockParam | AnthropicThinkingBlockParam | AnthropicRedactedThinkingBlockParam | AnthropicServerToolUseBlockParam | AnthropicWebSearchToolResultBlockParam | AnthropicWebSearchResultBlockParam | AnthropicSearchResultBlockParam | AnthropicContainerUploadBlockParam | AnthropicCompactionBlockParam;\nexport declare function isAnthropicImageBlockParam(block: unknown): block is AnthropicImageBlockParam;\nexport type AnthropicBuiltInToolUnion = Exclude<Anthropic.Messages.ToolUnion, Anthropic.Messages.Tool>;\n/**\n * A type representing additional parameters that can be passed to the\n * Anthropic API.\n */\nexport type Kwargs = Record<string, any>;\nexport type AnthropicInvocationParams = Omit<AnthropicMessageCreateParams | AnthropicStreamingMessageCreateParams, \"messages\"> & Kwargs;\n//# sourceMappingURL=types.d.ts.map"],"mappings":";;;;;AAgBYqB,KANAb,4BAAAA,GAA+BR,SAAAA,CAAUS,+BAMtB;AAInBa,KATAZ,qCAAAA,GAAwCV,SAAAA,CAAUW,4BASc;AAChEc,KATAb,4BAAAA,GAA+BZ,SAAAA,CAAUa,mBASMa;AAC/CC,KATAb,qCAAAA,GAAwCd,SAAAA,CAAUe,IAAAA,CAAKC,2BASA;AACvDa,KATAZ,2BAAAA,GAA8BjB,SAAAA,CAAUkB,kBASKY;AAC7CC,KATAZ,uBAAAA,GAA0BnB,SAAAA,CAAUoB,cASUY;AAC9CC,KATAZ,mBAAAA,GAS0B;EAC1Bc,IAAAA,EAAAA,MAAAA;EACAE,IAAAA,EAAAA,MAAAA;AACZ,CAAA,GAAYE,KAAAA,GAAAA,MAAAA,GAAAA,MAAAA,GAAAA,MAA2B;AAC3BE,KATAnB,qBAAAA,GAAwBtB,SAAAA,CAAUuB,QAAAA,CAASC,IASLxB,GATYC,cASOyC;AACzDC,KATAlB,yBAAAA,GAA4BzB,SAAAA,CAAUuB,QAAAA,CAASG,gBASOkB;AACtDC,KATAlB,qBAAAA,GAAwB3B,SAA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AAS,0BAAA;AAAA,KACT,gCAAA,GACV,SAAA,CAAU,QAAA,CAAS,uBAAA;AAAA,KACT,sCAAA,GACV,SAAA,CAAU,QAAA,CAAS,6BAAA;AAAA,KACT,kCAAA,GACV,SAAA,CAAU,QAAA,CAAS,yBAAA;AAAA,KACT,+BAAA,GAAkC,SAAA,CAAU,sBAAA;AAAA,KAC5C,kCAAA,GACV,SAAA,CAAU,IAAA,CAAK,6BAAA;AAAA,KACL,6BAAA,GACV,SAAA,CAAU,IAAA,CAAK,wBAAA;AAAA,KACL,+BAAA,GACV,SAAA,CAAU,IAAA,CAAK,QAAA,CAAS,iCAAA;AAAA,KAGd,yBAAA,GACR,uBAAA,GACA,wBAAA,GACA,0BAAA,GACA,6BAAA,GACA,2BAAA,GACA,2BAAA,GACA,mCAAA,GACA,gCAAA,GACA,sCAAA,GACA,kCAAA,GACA,+BAAA,GACA,kCAAA,GACA,6BAAA;;;;AAzCJ;KAkHY,MAAA,GAAS,MAAA;AAAA,KAET,yBAAA,GAA4B,IAAA,CACtC,4BAAA,GAA+B,qCAAA,gBAG/B,MAAA"}
package/dist/types.d.ts CHANGED
@@ -2,7 +2,6 @@ import Anthropic from "@anthropic-ai/sdk";
2
2
  import { BindToolsInput } from "@langchain/core/language_models/chat_models";
3
3
 
4
4
  //#region src/types.d.ts
5
-
6
5
  type AnthropicMessageCreateParams = Anthropic.MessageCreateParamsNonStreaming;
7
6
  type AnthropicStreamingMessageCreateParams = Anthropic.MessageCreateParamsStreaming;
8
7
  type AnthropicThinkingConfigParam = Anthropic.ThinkingConfigParam;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","names":["Anthropic","BindToolsInput","AnthropicToolResponse","Record","AnthropicMessageParam","MessageParam","AnthropicMessageResponse","ContentBlock","AnthropicMessageCreateParams","MessageCreateParamsNonStreaming","AnthropicStreamingMessageCreateParams","MessageCreateParamsStreaming","AnthropicThinkingConfigParam","ThinkingConfigParam","AnthropicContextManagementConfigParam","Beta","BetaContextManagementConfig","AnthropicMessageStreamEvent","MessageStreamEvent","AnthropicRequestOptions","RequestOptions","AnthropicToolChoice","ChatAnthropicToolType","Messages","Tool","ChatAnthropicOutputFormat","JSONOutputFormat","AnthropicOutputConfig","OutputConfig","AnthropicTextBlockParam","TextBlockParam","AnthropicImageBlockParam","ImageBlockParam","AnthropicToolUseBlockParam","ToolUseBlockParam","AnthropicToolResultBlockParam","ToolResultBlockParam","AnthropicDocumentBlockParam","DocumentBlockParam","AnthropicThinkingBlockParam","ThinkingBlockParam","AnthropicRedactedThinkingBlockParam","RedactedThinkingBlockParam","AnthropicServerToolUseBlockParam","ServerToolUseBlockParam","AnthropicWebSearchToolResultBlockParam","WebSearchToolResultBlockParam","AnthropicWebSearchResultBlockParam","WebSearchResultBlockParam","AnthropicSearchResultBlockParam","SearchResultBlockParam","AnthropicContainerUploadBlockParam","BetaContainerUploadBlockParam","AnthropicCompactionBlockParam","BetaCompactionBlockParam","AnthropicMCPServerURLDefinition","BetaRequestMCPServerURLDefinition","ChatAnthropicContentBlock","isAnthropicImageBlockParam","AnthropicBuiltInToolUnion","ToolUnion","Exclude","Kwargs","AnthropicInvocationParams","Omit"],"sources":["../src/types.d.ts"],"sourcesContent":["import Anthropic from \"@anthropic-ai/sdk\";\nimport { BindToolsInput } from \"@langchain/core/language_models/chat_models\";\nexport type AnthropicToolResponse = {\n type: \"tool_use\";\n id: string;\n name: string;\n input: Record<string, any>;\n};\nexport type AnthropicMessageParam = Anthropic.MessageParam;\nexport type AnthropicMessageResponse = Anthropic.ContentBlock | AnthropicToolResponse;\nexport type AnthropicMessageCreateParams = Anthropic.MessageCreateParamsNonStreaming;\nexport type AnthropicStreamingMessageCreateParams = Anthropic.MessageCreateParamsStreaming;\nexport type AnthropicThinkingConfigParam = Anthropic.ThinkingConfigParam;\nexport type AnthropicContextManagementConfigParam = Anthropic.Beta.BetaContextManagementConfig;\nexport type AnthropicMessageStreamEvent = Anthropic.MessageStreamEvent;\nexport type AnthropicRequestOptions = Anthropic.RequestOptions;\nexport type AnthropicToolChoice = {\n type: \"tool\";\n name: string;\n} | \"any\" | \"auto\" | \"none\" | string;\nexport type ChatAnthropicToolType = Anthropic.Messages.Tool | BindToolsInput;\nexport type ChatAnthropicOutputFormat = Anthropic.Messages.JSONOutputFormat;\nexport type AnthropicOutputConfig = Anthropic.Messages.OutputConfig;\nexport type AnthropicTextBlockParam = Anthropic.Messages.TextBlockParam;\nexport type AnthropicImageBlockParam = Anthropic.Messages.ImageBlockParam;\nexport type AnthropicToolUseBlockParam = Anthropic.Messages.ToolUseBlockParam;\nexport type AnthropicToolResultBlockParam = Anthropic.Messages.ToolResultBlockParam;\nexport type AnthropicDocumentBlockParam = Anthropic.Messages.DocumentBlockParam;\nexport type AnthropicThinkingBlockParam = Anthropic.Messages.ThinkingBlockParam;\nexport type AnthropicRedactedThinkingBlockParam = Anthropic.Messages.RedactedThinkingBlockParam;\nexport type AnthropicServerToolUseBlockParam = Anthropic.Messages.ServerToolUseBlockParam;\nexport type AnthropicWebSearchToolResultBlockParam = Anthropic.Messages.WebSearchToolResultBlockParam;\nexport type AnthropicWebSearchResultBlockParam = Anthropic.Messages.WebSearchResultBlockParam;\nexport type AnthropicSearchResultBlockParam = Anthropic.SearchResultBlockParam;\nexport type AnthropicContainerUploadBlockParam = Anthropic.Beta.BetaContainerUploadBlockParam;\nexport type AnthropicCompactionBlockParam = Anthropic.Beta.BetaCompactionBlockParam;\nexport type AnthropicMCPServerURLDefinition = Anthropic.Beta.Messages.BetaRequestMCPServerURLDefinition;\nexport type ChatAnthropicContentBlock = AnthropicTextBlockParam | AnthropicImageBlockParam | AnthropicToolUseBlockParam | AnthropicToolResultBlockParam | AnthropicDocumentBlockParam | AnthropicThinkingBlockParam | AnthropicRedactedThinkingBlockParam | AnthropicServerToolUseBlockParam | AnthropicWebSearchToolResultBlockParam | AnthropicWebSearchResultBlockParam | AnthropicSearchResultBlockParam | AnthropicContainerUploadBlockParam | AnthropicCompactionBlockParam;\nexport declare function isAnthropicImageBlockParam(block: unknown): block is AnthropicImageBlockParam;\nexport type AnthropicBuiltInToolUnion = Exclude<Anthropic.Messages.ToolUnion, Anthropic.Messages.Tool>;\n/**\n * A type representing additional parameters that can be passed to the\n * Anthropic API.\n */\nexport type Kwargs = Record<string, any>;\nexport type AnthropicInvocationParams = Omit<AnthropicMessageCreateParams | AnthropicStreamingMessageCreateParams, \"messages\"> & Kwargs;\n//# sourceMappingURL=types.d.ts.map"],"mappings":";;;;;AAgBYqB,KANAb,4BAAAA,GAA+BR,SAAAA,CAAUS,+BAMtB;AAInBa,KATAZ,qCAAAA,GAAwCV,SAAAA,CAAUW,4BASc;AAChEc,KATAb,4BAAAA,GAA+BZ,SAAAA,CAAUa,mBASMa;AAC/CC,KATAb,qCAAAA,GAAwCd,SAAAA,CAAUe,IAAAA,CAAKC,2BASA;AACvDa,KATAZ,2BAAAA,GAA8BjB,SAAAA,CAAUkB,kBASKY;AAC7CC,KATAZ,uBAAAA,GAA0BnB,SAAAA,CAAUoB,cASUY;AAC9CC,KATAZ,mBAAAA,GAS0B;EAC1Bc,IAAAA,EAAAA,MAAAA;EACAE,IAAAA,EAAAA,MAAAA;AACZ,CAAA,GAAYE,KAAAA,GAAAA,MAAAA,GAAAA,MAAAA,GAAAA,MAA2B;AAC3BE,KATAnB,qBAAAA,GAAwBtB,SAAAA,CAAUuB,QAAAA,CAASC,IASLxB,GATYC,cASOyC;AACzDC,KATAlB,yBAAAA,GAA4BzB,SAAAA,CAAUuB,QAAAA,CAASG,gBASOkB;AACtDC,KATAlB,qBAAAA,GAAwB3B,SAAAA,CAAUuB,QAAAA,CAASK,YASQL;AACnDwB,KATAlB,uBAAAA,GAA0B7B,SAAAA,CAAUuB,QAAAA,CAASO,cASEP;AAC/C0B,KATAlB,wBAAAA,GAA2B/B,SAAAA,CAAUuB,QAAAA,CAASS,eASFkB;AAC5CC,KATAlB,0BAAAA,GAA6BjC,SAAAA,CAAUuB,QAAAA,CAASW,iBASIkB;AACp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AAA,CAAU,IAAA,CAAK,6BAAA;AAAA,KACL,6BAAA,GACV,SAAA,CAAU,IAAA,CAAK,wBAAA;AAAA,KACL,+BAAA,GACV,SAAA,CAAU,IAAA,CAAK,QAAA,CAAS,iCAAA;AAAA,KAGd,yBAAA,GACR,uBAAA,GACA,wBAAA,GACA,0BAAA,GACA,6BAAA,GACA,2BAAA,GACA,2BAAA,GACA,mCAAA,GACA,gCAAA,GACA,sCAAA,GACA,kCAAA,GACA,+BAAA,GACA,kCAAA,GACA,6BAAA;;;;AAzCJ;KAkHY,MAAA,GAAS,MAAA;AAAA,KAET,yBAAA,GAA4B,IAAA,CACtC,4BAAA,GAA+B,qCAAA,gBAG/B,MAAA"}
@@ -1,5 +1,5 @@
1
- const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
- const __langchain_core_messages = require_rolldown_runtime.__toESM(require("@langchain/core/messages"));
1
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
2
+ let _langchain_core_messages = require("@langchain/core/messages");
3
3
 
4
4
  //#region src/utils/content.ts
5
5
  function _isAnthropicThinkingBlock(block) {
@@ -45,7 +45,7 @@ const standardContentBlockConverter = {
45
45
  },
46
46
  fromStandardImageBlock(block) {
47
47
  if (block.source_type === "url") {
48
- const data = (0, __langchain_core_messages.parseBase64DataUrl)({
48
+ const data = (0, _langchain_core_messages.parseBase64DataUrl)({
49
49
  dataUrl: block.url,
50
50
  asTypedArray: false
51
51
  });
@@ -1 +1 @@
1
- {"version":3,"file":"content.cjs","names":["block: unknown","standardContentBlockConverter: StandardContentBlockConverter<{\n text: Anthropic.Messages.TextBlockParam;\n image: Anthropic.Messages.ImageBlockParam;\n file: Anthropic.Messages.DocumentBlockParam;\n}>"],"sources":["../../src/utils/content.ts"],"sourcesContent":["import type Anthropic from \"@anthropic-ai/sdk\";\nimport {\n parseBase64DataUrl,\n type StandardContentBlockConverter,\n} from \"@langchain/core/messages\";\n\nexport function _isAnthropicThinkingBlock(\n block: unknown\n): block is Anthropic.Messages.ThinkingBlockParam {\n return (\n typeof block === \"object\" &&\n block !== null &&\n \"type\" in block &&\n block.type === \"thinking\"\n );\n}\n\nexport function _isAnthropicRedactedThinkingBlock(\n block: unknown\n): block is Anthropic.Messages.RedactedThinkingBlockParam {\n return (\n typeof block === \"object\" &&\n block !== null &&\n \"type\" in block &&\n block.type === \"redacted_thinking\"\n );\n}\n\nexport function _isAnthropicCompactionBlock(\n block: unknown\n): block is Anthropic.Beta.BetaCompactionBlockParam {\n return (\n typeof block === \"object\" &&\n block !== null &&\n \"type\" in block &&\n block.type === \"compaction\"\n );\n}\n\nexport function _isAnthropicSearchResultBlock(\n block: unknown\n): block is Anthropic.Beta.BetaSearchResultBlockParam {\n return (\n typeof block === \"object\" &&\n block !== null &&\n \"type\" in block &&\n block.type === \"search_result\"\n );\n}\n\nexport function _isAnthropicImageBlockParam(\n block: unknown\n): block is Anthropic.Messages.ImageBlockParam {\n if (typeof block !== \"object\" || block == null) {\n return false;\n }\n if (!(\"type\" in block) || block.type !== \"image\") {\n return false;\n }\n\n if (\n !(\"source\" in block) ||\n typeof block.source !== \"object\" ||\n block.source == null\n ) {\n return false;\n }\n\n if (!(\"type\" in block.source)) {\n return false;\n }\n\n if (block.source.type === \"base64\") {\n if (!(\"media_type\" in block.source)) {\n return false;\n }\n\n if (typeof block.source.media_type !== \"string\") {\n return false;\n }\n\n if (!(\"data\" in block.source)) {\n return false;\n }\n\n if (typeof block.source.data !== \"string\") {\n return false;\n }\n\n return true;\n }\n\n if (block.source.type === \"url\") {\n if (!(\"url\" in block.source)) {\n return false;\n }\n\n if (typeof block.source.url !== \"string\") {\n return false;\n }\n\n return true;\n }\n\n return false;\n}\n\nexport const standardContentBlockConverter: StandardContentBlockConverter<{\n text: Anthropic.Messages.TextBlockParam;\n image: Anthropic.Messages.ImageBlockParam;\n file: Anthropic.Messages.DocumentBlockParam;\n}> = {\n providerName: \"anthropic\",\n\n fromStandardTextBlock(block): Anthropic.Messages.TextBlockParam {\n return {\n type: \"text\",\n text: block.text,\n ...(\"citations\" in (block.metadata ?? {})\n ? { citations: block.metadata!.citations }\n : {}),\n ...(\"cache_control\" in (block.metadata ?? {})\n ? { cache_control: block.metadata!.cache_control }\n : {}),\n } as Anthropic.Messages.TextBlockParam;\n },\n\n fromStandardImageBlock(block): Anthropic.Messages.ImageBlockParam {\n if (block.source_type === \"url\") {\n const data = parseBase64DataUrl({\n dataUrl: block.url,\n asTypedArray: false,\n });\n if (data) {\n return {\n type: \"image\",\n source: {\n type: \"base64\",\n data: data.data,\n media_type: data.mime_type,\n },\n ...(\"cache_control\" in (block.metadata ?? {})\n ? { cache_control: block.metadata!.cache_control }\n : {}),\n } as Anthropic.Messages.ImageBlockParam;\n } else {\n return {\n type: \"image\",\n source: {\n type: \"url\",\n url: block.url,\n },\n ...(\"cache_control\" in (block.metadata ?? {})\n ? { cache_control: block.metadata!.cache_control }\n : {}),\n } as Anthropic.Messages.ImageBlockParam;\n }\n } else {\n if (block.source_type === \"base64\") {\n return {\n type: \"image\",\n source: {\n type: \"base64\",\n data: block.data,\n media_type: block.mime_type ?? \"\",\n },\n ...(\"cache_control\" in (block.metadata ?? {})\n ? { cache_control: block.metadata!.cache_control }\n : {}),\n } as Anthropic.Messages.ImageBlockParam;\n } else {\n throw new Error(`Unsupported image source type: ${block.source_type}`);\n }\n }\n },\n\n fromStandardFileBlock(block): Anthropic.Messages.DocumentBlockParam {\n const mime_type = (block.mime_type ?? \"\").split(\";\")[0];\n\n if (block.source_type === \"url\") {\n if (mime_type === \"application/pdf\" || mime_type === \"\") {\n return {\n type: \"document\",\n source: {\n type: \"url\",\n url: block.url,\n },\n ...(\"cache_control\" in (block.metadata ?? {})\n ? { cache_control: block.metadata!.cache_control }\n : {}),\n ...(\"citations\" in (block.metadata ?? {})\n ? { citations: block.metadata!.citations }\n : {}),\n ...(\"context\" in (block.metadata ?? {})\n ? { context: block.metadata!.context }\n : {}),\n ...(\"title\" in (block.metadata ?? {})\n ? { title: block.metadata!.title }\n : {}),\n } as Anthropic.Messages.DocumentBlockParam;\n }\n throw new Error(\n `Unsupported file mime type for file url source: ${block.mime_type}`\n );\n } else if (block.source_type === \"text\") {\n if (mime_type === \"text/plain\" || mime_type === \"\") {\n return {\n type: \"document\",\n source: {\n type: \"text\",\n data: block.text,\n media_type: block.mime_type ?? \"\",\n },\n ...(\"cache_control\" in (block.metadata ?? {})\n ? { cache_control: block.metadata!.cache_control }\n : {}),\n ...(\"citations\" in (block.metadata ?? {})\n ? { citations: block.metadata!.citations }\n : {}),\n ...(\"context\" in (block.metadata ?? {})\n ? { context: block.metadata!.context }\n : {}),\n ...(\"title\" in (block.metadata ?? {})\n ? { title: block.metadata!.title }\n : {}),\n } as Anthropic.Messages.DocumentBlockParam;\n } else {\n throw new Error(\n `Unsupported file mime type for file text source: ${block.mime_type}`\n );\n }\n } else if (block.source_type === \"base64\") {\n if (mime_type === \"application/pdf\" || mime_type === \"\") {\n return {\n type: \"document\",\n source: {\n type: \"base64\",\n data: block.data,\n media_type: \"application/pdf\",\n },\n ...(\"cache_control\" in (block.metadata ?? {})\n ? { cache_control: block.metadata!.cache_control }\n : {}),\n ...(\"citations\" in (block.metadata ?? {})\n ? { citations: block.metadata!.citations }\n : {}),\n ...(\"context\" in (block.metadata ?? {})\n ? { context: block.metadata!.context }\n : {}),\n ...(\"title\" in (block.metadata ?? {})\n ? { title: block.metadata!.title }\n : {}),\n } as Anthropic.Messages.DocumentBlockParam;\n } else if (\n [\"image/jpeg\", \"image/png\", \"image/gif\", \"image/webp\"].includes(\n mime_type\n )\n ) {\n return {\n type: \"document\",\n source: {\n type: \"content\",\n content: [\n {\n type: \"image\",\n source: {\n type: \"base64\",\n data: block.data,\n media_type: mime_type as\n | \"image/jpeg\"\n | \"image/png\"\n | \"image/gif\"\n | \"image/webp\",\n },\n },\n ],\n },\n ...(\"cache_control\" in (block.metadata ?? {})\n ? { cache_control: block.metadata!.cache_control }\n : {}),\n ...(\"citations\" in (block.metadata ?? {})\n ? { citations: block.metadata!.citations }\n : {}),\n ...(\"context\" in (block.metadata ?? {})\n ? { context: block.metadata!.context }\n : {}),\n ...(\"title\" in (block.metadata ?? {})\n ? { title: block.metadata!.title }\n : {}),\n } as Anthropic.Messages.DocumentBlockParam;\n } else {\n throw new Error(\n `Unsupported file mime type for file base64 source: ${block.mime_type}`\n );\n }\n } else {\n throw new Error(`Unsupported file source type: ${block.source_type}`);\n }\n },\n};\n"],"mappings":";;;;AAMA,SAAgB,0BACdA,OACgD;AAChD,QACE,OAAO,UAAU,YACjB,UAAU,QACV,UAAU,SACV,MAAM,SAAS;AAElB;AAED,SAAgB,kCACdA,OACwD;AACxD,QACE,OAAO,UAAU,YACjB,UAAU,QACV,UAAU,SACV,MAAM,SAAS;AAElB;AAED,SAAgB,4BACdA,OACkD;AAClD,QACE,OAAO,UAAU,YACjB,UAAU,QACV,UAAU,SACV,MAAM,SAAS;AAElB;AAED,SAAgB,8BACdA,OACoD;AACpD,QACE,OAAO,UAAU,YACjB,UAAU,QACV,UAAU,SACV,MAAM,SAAS;AAElB;AAED,SAAgB,4BACdA,OAC6C;AAC7C,KAAI,OAAO,UAAU,YAAY,SAAS,KACxC,QAAO;AAET,KAAI,EAAE,UAAU,UAAU,MAAM,SAAS,QACvC,QAAO;AAGT,KACE,EAAE,YAAY,UACd,OAAO,MAAM,WAAW,YACxB,MAAM,UAAU,KAEhB,QAAO;AAGT,KAAI,EAAE,UAAU,MAAM,QACpB,QAAO;AAGT,KAAI,MAAM,OAAO,SAAS,UAAU;AAClC,MAAI,EAAE,gBAAgB,MAAM,QAC1B,QAAO;AAGT,MAAI,OAAO,MAAM,OAAO,eAAe,SACrC,QAAO;AAGT,MAAI,EAAE,UAAU,MAAM,QACpB,QAAO;AAGT,MAAI,OAAO,MAAM,OAAO,SAAS,SAC/B,QAAO;AAGT,SAAO;CACR;AAED,KAAI,MAAM,OAAO,SAAS,OAAO;AAC/B,MAAI,EAAE,SAAS,MAAM,QACnB,QAAO;AAG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N,GAAI,gBAAgB,MAAM,YAAY,CAAE,KACpC,EAAE,WAAW,MAAM,SAAU,UAAW,IACxC,CAAE;GACN,GAAI,cAAc,MAAM,YAAY,CAAE,KAClC,EAAE,SAAS,MAAM,SAAU,QAAS,IACpC,CAAE;GACN,GAAI,YAAY,MAAM,YAAY,CAAE,KAChC,EAAE,OAAO,MAAM,SAAU,MAAO,IAChC,CAAE;EACP;WAED;GAAC;GAAc;GAAa;GAAa;EAAa,EAAC,SACrD,UACD,CAED,QAAO;GACL,MAAM;GACN,QAAQ;IACN,MAAM;IACN,SAAS,CACP;KACE,MAAM;KACN,QAAQ;MACN,MAAM;MACN,MAAM,MAAM;MACZ,YAAY;KAKb;IACF,CACF;GACF;GACD,GAAI,oBAAoB,MAAM,YAAY,CAAE,KACxC,EAAE,eAAe,MAAM,SAAU,cAAe,IAChD,CAAE;GACN,GAAI,gBAAgB,MAAM,YAAY,CAAE,KACpC,EAAE,WAAW,MAAM,SAAU,UAAW,IACxC,CAAE;GACN,GAAI,cAAc,MAAM,YAAY,CAAE,KAClC,EAAE,SAAS,MAAM,SAAU,QAAS,IACpC,CAAE;GACN,GAAI,YAAY,MAAM,YAAY,CAAE,KAChC,EAAE,OAAO,MAAM,SAAU,MAAO,IAChC,CAAE;EACP;MAED,OAAM,IAAI,MACR,CAAC,mDAAmD,EAAE,MAAM,WAAW;MAI3E,OAAM,IAAI,MAAM,CAAC,8BAA8B,EAAE,MAAM,aAAa;CAEvE;AACF"}
1
+ {"version":3,"file":"content.cjs","names":[],"sources":["../../src/utils/content.ts"],"sourcesContent":["import type Anthropic from \"@anthropic-ai/sdk\";\nimport {\n parseBase64DataUrl,\n type StandardContentBlockConverter,\n} from \"@langchain/core/messages\";\n\nexport function _isAnthropicThinkingBlock(\n block: unknown\n): block is Anthropic.Messages.ThinkingBlockParam {\n return (\n typeof block === \"object\" &&\n block !== null &&\n \"type\" in block &&\n block.type === \"thinking\"\n );\n}\n\nexport function _isAnthropicRedactedThinkingBlock(\n block: unknown\n): block is Anthropic.Messages.RedactedThinkingBlockParam {\n return (\n typeof block === \"object\" &&\n block !== null &&\n \"type\" in block &&\n block.type === \"redacted_thinking\"\n );\n}\n\nexport function _isAnthropicCompactionBlock(\n block: unknown\n): block is Anthropic.Beta.BetaCompactionBlockParam {\n return (\n typeof block === \"object\" &&\n block !== null &&\n \"type\" in block &&\n block.type === \"compaction\"\n );\n}\n\nexport function _isAnthropicSearchResultBlock(\n block: unknown\n): block is Anthropic.Beta.BetaSearchResultBlockParam {\n return (\n typeof block === \"object\" &&\n block !== null &&\n \"type\" in block &&\n block.type === \"search_result\"\n );\n}\n\nexport function _isAnthropicImageBlockParam(\n block: unknown\n): block is Anthropic.Messages.ImageBlockParam {\n if (typeof block !== \"object\" || block == null) {\n return false;\n }\n if (!(\"type\" in block) || block.type !== \"image\") {\n return false;\n }\n\n if (\n !(\"source\" in block) ||\n typeof block.source !== \"object\" ||\n block.source == null\n ) {\n return false;\n }\n\n if (!(\"type\" in block.source)) {\n return false;\n }\n\n if (block.source.type === \"base64\") {\n if (!(\"media_type\" in block.source)) {\n return false;\n }\n\n if (typeof block.source.media_type !== \"string\") {\n return false;\n }\n\n if (!(\"data\" in block.source)) {\n return false;\n }\n\n if (typeof block.source.data !== \"string\") {\n return false;\n }\n\n return true;\n }\n\n if (block.source.type === \"url\") {\n if (!(\"url\" in block.source)) {\n return false;\n }\n\n if (typeof block.source.url !== \"string\") {\n return false;\n }\n\n return true;\n }\n\n return false;\n}\n\nexport const standardContentBlockConverter: StandardContentBlockConverter<{\n text: Anthropic.Messages.TextBlockParam;\n image: Anthropic.Messages.ImageBlockParam;\n file: Anthropic.Messages.DocumentBlockParam;\n}> = {\n providerName: \"anthropic\",\n\n fromStandardTextBlock(block): Anthropic.Messages.TextBlockParam {\n return {\n type: \"text\",\n text: block.text,\n ...(\"citations\" in (block.metadata ?? {})\n ? { citations: block.metadata!.citations }\n : {}),\n ...(\"cache_control\" in (block.metadata ?? {})\n ? { cache_control: block.metadata!.cache_control }\n : {}),\n } as Anthropic.Messages.TextBlockParam;\n },\n\n fromStandardImageBlock(block): Anthropic.Messages.ImageBlockParam {\n if (block.source_type === \"url\") {\n const data = parseBase64DataUrl({\n dataUrl: block.url,\n asTypedArray: false,\n });\n if (data) {\n return {\n type: \"image\",\n source: {\n type: \"base64\",\n data: data.data,\n media_type: data.mime_type,\n },\n ...(\"cache_control\" in (block.metadata ?? {})\n ? { cache_control: block.metadata!.cache_control }\n : {}),\n } as Anthropic.Messages.ImageBlockParam;\n } else {\n return {\n type: \"image\",\n source: {\n type: \"url\",\n url: block.url,\n },\n ...(\"cache_control\" in (block.metadata ?? {})\n ? { cache_control: block.metadata!.cache_control }\n : {}),\n } as Anthropic.Messages.ImageBlockParam;\n }\n } else {\n if (block.source_type === \"base64\") {\n return {\n type: \"image\",\n source: {\n type: \"base64\",\n data: block.data,\n media_type: block.mime_type ?? \"\",\n },\n ...(\"cache_control\" in (block.metadata ?? {})\n ? { cache_control: block.metadata!.cache_control }\n : {}),\n } as Anthropic.Messages.ImageBlockParam;\n } else {\n throw new Error(`Unsupported image source type: ${block.source_type}`);\n }\n }\n },\n\n fromStandardFileBlock(block): Anthropic.Messages.DocumentBlockParam {\n const mime_type = (block.mime_type ?? \"\").split(\";\")[0];\n\n if (block.source_type === \"url\") {\n if (mime_type === \"application/pdf\" || mime_type === \"\") {\n return {\n type: \"document\",\n source: {\n type: \"url\",\n url: block.url,\n },\n ...(\"cache_control\" in (block.metadata ?? {})\n ? { cache_control: block.metadata!.cache_control }\n : {}),\n ...(\"citations\" in (block.metadata ?? {})\n ? { citations: block.metadata!.citations }\n : {}),\n ...(\"context\" in (block.metadata ?? {})\n ? { context: block.metadata!.context }\n : {}),\n ...(\"title\" in (block.metadata ?? {})\n ? { title: block.metadata!.title }\n : {}),\n } as Anthropic.Messages.DocumentBlockParam;\n }\n throw new Error(\n `Unsupported file mime type for file url source: ${block.mime_type}`\n );\n } else if (block.source_type === \"text\") {\n if (mime_type === \"text/plain\" || mime_type === \"\") {\n return {\n type: \"document\",\n source: {\n type: \"text\",\n data: block.text,\n media_type: block.mime_type ?? \"\",\n },\n ...(\"cache_control\" in (block.metadata ?? {})\n ? { cache_control: block.metadata!.cache_control }\n : {}),\n ...(\"citations\" in (block.metadata ?? {})\n ? { citations: block.metadata!.citations }\n : {}),\n ...(\"context\" in (block.metadata ?? {})\n ? { context: block.metadata!.context }\n : {}),\n ...(\"title\" in (block.metadata ?? {})\n ? { title: block.metadata!.title }\n : {}),\n } as Anthropic.Messages.DocumentBlockParam;\n } else {\n throw new Error(\n `Unsupported file mime type for file text source: ${block.mime_type}`\n );\n }\n } else if (block.source_type === \"base64\") {\n if (mime_type === \"application/pdf\" || mime_type === \"\") {\n return {\n type: \"document\",\n source: {\n type: \"base64\",\n data: block.data,\n media_type: \"application/pdf\",\n },\n ...(\"cache_control\" in (block.metadata ?? {})\n ? { cache_control: block.metadata!.cache_control }\n : {}),\n ...(\"citations\" in (block.metadata ?? {})\n ? { citations: block.metadata!.citations }\n : {}),\n ...(\"context\" in (block.metadata ?? {})\n ? { context: block.metadata!.context }\n : {}),\n ...(\"title\" in (block.metadata ?? {})\n ? { title: block.metadata!.title }\n : {}),\n } as Anthropic.Messages.DocumentBlockParam;\n } else if (\n [\"image/jpeg\", \"image/png\", \"image/gif\", \"image/webp\"].includes(\n mime_type\n )\n ) {\n return {\n type: \"document\",\n source: {\n type: \"content\",\n content: [\n {\n type: \"image\",\n source: {\n type: \"base64\",\n data: block.data,\n media_type: mime_type as\n | \"image/jpeg\"\n | \"image/png\"\n | \"image/gif\"\n | \"image/webp\",\n },\n },\n ],\n },\n ...(\"cache_control\" in (block.metadata ?? {})\n ? { cache_control: block.metadata!.cache_control }\n : {}),\n ...(\"citations\" in (block.metadata ?? {})\n ? { citations: block.metadata!.citations }\n : {}),\n ...(\"context\" in (block.metadata ?? {})\n ? { context: block.metadata!.context }\n : {}),\n ...(\"title\" in (block.metadata ?? {})\n ? { title: block.metadata!.title }\n : {}),\n } as Anthropic.Messages.DocumentBlockParam;\n } else {\n throw new Error(\n `Unsupported file mime type for file base64 source: ${block.mime_type}`\n );\n }\n } else {\n throw new Error(`Unsupported file source type: ${block.source_type}`);\n }\n },\n};\n"],"mappings":";;;;AAMA,SAAgB,0BACd,OACgD;AAChD,QACE,OAAO,UAAU,YACjB,UAAU,QACV,UAAU,SACV,MAAM,SAAS;;AAInB,SAAgB,kCACd,OACwD;AACxD,QACE,OAAO,UAAU,YACjB,UAAU,QACV,UAAU,SACV,MAAM,SAAS;;AAInB,SAAgB,4BACd,OACkD;AAClD,QACE,OAAO,UAAU,YACjB,UAAU,QACV,UAAU,SACV,MAAM,SAAS;;AAInB,SAAgB,8BACd,OACoD;AACpD,QACE,OAAO,UAAU,YACjB,UAAU,QACV,UAAU,SACV,MAAM,SAAS;;AAInB,SAAgB,4BACd,OAC6C;AAC7C,KAAI,OAAO,UAAU,YAAY,SAAS,KACxC,QAAO;AAET,KAAI,EAAE,UAAU,UAAU,MAAM,SAAS,QACvC,QAAO;AAGT,KACE,EAAE,YAAY,UACd,OAAO,MAAM,WAAW,YACxB,MAAM,UAAU,KAEhB,QAAO;AAGT,KAAI,EAAE,UAAU,MAAM,QACpB,QAAO;AAGT,KAAI,MAAM,OAAO,SAAS,UAAU;AAClC,MAAI,EAAE,gBAAgB,MAAM,QAC1B,QAAO;AAGT,MAAI,OAAO,MAAM,OAAO,eAAe,SACrC,QAAO;AAGT,MAAI,EAAE,UAAU,MAAM,QACpB,QAAO;AAGT,MAAI,OAAO,MAAM,OAAO,SAAS,SAC/B,QAAO;AAGT,SAAO;;AAGT,KAAI,MAAM,OAAO,SAAS,OAAO;AAC/B,MAAI,EAAE,SAAS,MAAM,QACnB,QAAO;AAGT,MAAI,OAAO,MAAM,OAAO,QAAQ,SAC9B,QAAO;AAGT,SAAO;;AAGT,QAAO;;AAGT,MAAa,gCAIR;CACH,cAAc;CAEd,sBAAsB,OAA0C;AAC9D,SAAO;GACL,MAA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EAAE,OAAO,MAAM,SAAU,OAAO,GAChC,EAAE;GACP;WAED;GAAC;GAAc;GAAa;GAAa;GAAa,CAAC,SACrD,UACD,CAED,QAAO;GACL,MAAM;GACN,QAAQ;IACN,MAAM;IACN,SAAS,CACP;KACE,MAAM;KACN,QAAQ;MACN,MAAM;MACN,MAAM,MAAM;MACZ,YAAY;MAKb;KACF,CACF;IACF;GACD,GAAI,oBAAoB,MAAM,YAAY,EAAE,IACxC,EAAE,eAAe,MAAM,SAAU,eAAe,GAChD,EAAE;GACN,GAAI,gBAAgB,MAAM,YAAY,EAAE,IACpC,EAAE,WAAW,MAAM,SAAU,WAAW,GACxC,EAAE;GACN,GAAI,cAAc,MAAM,YAAY,EAAE,IAClC,EAAE,SAAS,MAAM,SAAU,SAAS,GACpC,EAAE;GACN,GAAI,YAAY,MAAM,YAAY,EAAE,IAChC,EAAE,OAAO,MAAM,SAAU,OAAO,GAChC,EAAE;GACP;MAED,OAAM,IAAI,MACR,sDAAsD,MAAM,YAC7D;MAGH,OAAM,IAAI,MAAM,iCAAiC,MAAM,cAAc;;CAG1E"}
@@ -1 +1 @@
1
- {"version":3,"file":"content.js","names":["block: unknown","standardContentBlockConverter: StandardContentBlockConverter<{\n text: Anthropic.Messages.TextBlockParam;\n image: Anthropic.Messages.ImageBlockParam;\n file: Anthropic.Messages.DocumentBlockParam;\n}>"],"sources":["../../src/utils/content.ts"],"sourcesContent":["import type Anthropic from \"@anthropic-ai/sdk\";\nimport {\n parseBase64DataUrl,\n type StandardContentBlockConverter,\n} from \"@langchain/core/messages\";\n\nexport function _isAnthropicThinkingBlock(\n block: unknown\n): block is Anthropic.Messages.ThinkingBlockParam {\n return (\n typeof block === \"object\" &&\n block !== null &&\n \"type\" in block &&\n block.type === \"thinking\"\n );\n}\n\nexport function _isAnthropicRedactedThinkingBlock(\n block: unknown\n): block is Anthropic.Messages.RedactedThinkingBlockParam {\n return (\n typeof block === \"object\" &&\n block !== null &&\n \"type\" in block &&\n block.type === \"redacted_thinking\"\n );\n}\n\nexport function _isAnthropicCompactionBlock(\n block: unknown\n): block is Anthropic.Beta.BetaCompactionBlockParam {\n return (\n typeof block === \"object\" &&\n block !== null &&\n \"type\" in block &&\n block.type === \"compaction\"\n );\n}\n\nexport function _isAnthropicSearchResultBlock(\n block: unknown\n): block is Anthropic.Beta.BetaSearchResultBlockParam {\n return (\n typeof block === \"object\" &&\n block !== null &&\n \"type\" in block &&\n block.type === \"search_result\"\n );\n}\n\nexport function _isAnthropicImageBlockParam(\n block: unknown\n): block is Anthropic.Messages.ImageBlockParam {\n if (typeof block !== \"object\" || block == null) {\n return false;\n }\n if (!(\"type\" in block) || block.type !== \"image\") {\n return false;\n }\n\n if (\n !(\"source\" in block) ||\n typeof block.source !== \"object\" ||\n block.source == null\n ) {\n return false;\n }\n\n if (!(\"type\" in block.source)) {\n return false;\n }\n\n if (block.source.type === \"base64\") {\n if (!(\"media_type\" in block.source)) {\n return false;\n }\n\n if (typeof block.source.media_type !== \"string\") {\n return false;\n }\n\n if (!(\"data\" in block.source)) {\n return false;\n }\n\n if (typeof block.source.data !== \"string\") {\n return false;\n }\n\n return true;\n }\n\n if (block.source.type === \"url\") {\n if (!(\"url\" in block.source)) {\n return false;\n }\n\n if (typeof block.source.url !== \"string\") {\n return false;\n }\n\n return true;\n }\n\n return false;\n}\n\nexport const standardContentBlockConverter: StandardContentBlockConverter<{\n text: Anthropic.Messages.TextBlockParam;\n image: Anthropic.Messages.ImageBlockParam;\n file: Anthropic.Messages.DocumentBlockParam;\n}> = {\n providerName: \"anthropic\",\n\n fromStandardTextBlock(block): Anthropic.Messages.TextBlockParam {\n return {\n type: \"text\",\n text: block.text,\n ...(\"citations\" in (block.metadata ?? {})\n ? { citations: block.metadata!.citations }\n : {}),\n ...(\"cache_control\" in (block.metadata ?? {})\n ? { cache_control: block.metadata!.cache_control }\n : {}),\n } as Anthropic.Messages.TextBlockParam;\n },\n\n fromStandardImageBlock(block): Anthropic.Messages.ImageBlockParam {\n if (block.source_type === \"url\") {\n const data = parseBase64DataUrl({\n dataUrl: block.url,\n asTypedArray: false,\n });\n if (data) {\n return {\n type: \"image\",\n source: {\n type: \"base64\",\n data: data.data,\n media_type: data.mime_type,\n },\n ...(\"cache_control\" in (block.metadata ?? {})\n ? { cache_control: block.metadata!.cache_control }\n : {}),\n } as Anthropic.Messages.ImageBlockParam;\n } else {\n return {\n type: \"image\",\n source: {\n type: \"url\",\n url: block.url,\n },\n ...(\"cache_control\" in (block.metadata ?? {})\n ? { cache_control: block.metadata!.cache_control }\n : {}),\n } as Anthropic.Messages.ImageBlockParam;\n }\n } else {\n if (block.source_type === \"base64\") {\n return {\n type: \"image\",\n source: {\n type: \"base64\",\n data: block.data,\n media_type: block.mime_type ?? \"\",\n },\n ...(\"cache_control\" in (block.metadata ?? {})\n ? { cache_control: block.metadata!.cache_control }\n : {}),\n } as Anthropic.Messages.ImageBlockParam;\n } else {\n throw new Error(`Unsupported image source type: ${block.source_type}`);\n }\n }\n },\n\n fromStandardFileBlock(block): Anthropic.Messages.DocumentBlockParam {\n const mime_type = (block.mime_type ?? \"\").split(\";\")[0];\n\n if (block.source_type === \"url\") {\n if (mime_type === \"application/pdf\" || mime_type === \"\") {\n return {\n type: \"document\",\n source: {\n type: \"url\",\n url: block.url,\n },\n ...(\"cache_control\" in (block.metadata ?? {})\n ? { cache_control: block.metadata!.cache_control }\n : {}),\n ...(\"citations\" in (block.metadata ?? {})\n ? { citations: block.metadata!.citations }\n : {}),\n ...(\"context\" in (block.metadata ?? {})\n ? { context: block.metadata!.context }\n : {}),\n ...(\"title\" in (block.metadata ?? {})\n ? { title: block.metadata!.title }\n : {}),\n } as Anthropic.Messages.DocumentBlockParam;\n }\n throw new Error(\n `Unsupported file mime type for file url source: ${block.mime_type}`\n );\n } else if (block.source_type === \"text\") {\n if (mime_type === \"text/plain\" || mime_type === \"\") {\n return {\n type: \"document\",\n source: {\n type: \"text\",\n data: block.text,\n media_type: block.mime_type ?? \"\",\n },\n ...(\"cache_control\" in (block.metadata ?? {})\n ? { cache_control: block.metadata!.cache_control }\n : {}),\n ...(\"citations\" in (block.metadata ?? {})\n ? { citations: block.metadata!.citations }\n : {}),\n ...(\"context\" in (block.metadata ?? {})\n ? { context: block.metadata!.context }\n : {}),\n ...(\"title\" in (block.metadata ?? {})\n ? { title: block.metadata!.title }\n : {}),\n } as Anthropic.Messages.DocumentBlockParam;\n } else {\n throw new Error(\n `Unsupported file mime type for file text source: ${block.mime_type}`\n );\n }\n } else if (block.source_type === \"base64\") {\n if (mime_type === \"application/pdf\" || mime_type === \"\") {\n return {\n type: \"document\",\n source: {\n type: \"base64\",\n data: block.data,\n media_type: \"application/pdf\",\n },\n ...(\"cache_control\" in (block.metadata ?? {})\n ? { cache_control: block.metadata!.cache_control }\n : {}),\n ...(\"citations\" in (block.metadata ?? {})\n ? { citations: block.metadata!.citations }\n : {}),\n ...(\"context\" in (block.metadata ?? {})\n ? { context: block.metadata!.context }\n : {}),\n ...(\"title\" in (block.metadata ?? {})\n ? { title: block.metadata!.title }\n : {}),\n } as Anthropic.Messages.DocumentBlockParam;\n } else if (\n [\"image/jpeg\", \"image/png\", \"image/gif\", \"image/webp\"].includes(\n mime_type\n )\n ) {\n return {\n type: \"document\",\n source: {\n type: \"content\",\n content: [\n {\n type: \"image\",\n source: {\n type: \"base64\",\n data: block.data,\n media_type: mime_type as\n | \"image/jpeg\"\n | \"image/png\"\n | \"image/gif\"\n | \"image/webp\",\n },\n },\n ],\n },\n ...(\"cache_control\" in (block.metadata ?? {})\n ? { cache_control: block.metadata!.cache_control }\n : {}),\n ...(\"citations\" in (block.metadata ?? {})\n ? { citations: block.metadata!.citations }\n : {}),\n ...(\"context\" in (block.metadata ?? {})\n ? { context: block.metadata!.context }\n : {}),\n ...(\"title\" in (block.metadata ?? {})\n ? { title: block.metadata!.title }\n : {}),\n } as Anthropic.Messages.DocumentBlockParam;\n } else {\n throw new Error(\n `Unsupported file mime type for file base64 source: ${block.mime_type}`\n );\n }\n } else {\n throw new Error(`Unsupported file source type: ${block.source_type}`);\n }\n },\n};\n"],"mappings":";;;AAMA,SAAgB,0BACdA,OACgD;AAChD,QACE,OAAO,UAAU,YACjB,UAAU,QACV,UAAU,SACV,MAAM,SAAS;AAElB;AAED,SAAgB,kCACdA,OACwD;AACxD,QACE,OAAO,UAAU,YACjB,UAAU,QACV,UAAU,SACV,MAAM,SAAS;AAElB;AAED,SAAgB,4BACdA,OACkD;AAClD,QACE,OAAO,UAAU,YACjB,UAAU,QACV,UAAU,SACV,MAAM,SAAS;AAElB;AAED,SAAgB,8BACdA,OACoD;AACpD,QACE,OAAO,UAAU,YACjB,UAAU,QACV,UAAU,SACV,MAAM,SAAS;AAElB;AAED,SAAgB,4BACdA,OAC6C;AAC7C,KAAI,OAAO,UAAU,YAAY,SAAS,KACxC,QAAO;AAET,KAAI,EAAE,UAAU,UAAU,MAAM,SAAS,QACvC,QAAO;AAGT,KACE,EAAE,YAAY,UACd,OAAO,MAAM,WAAW,YACxB,MAAM,UAAU,KAEhB,QAAO;AAGT,KAAI,EAAE,UAAU,MAAM,QACpB,QAAO;AAGT,KAAI,MAAM,OAAO,SAAS,UAAU;AAClC,MAAI,EAAE,gBAAgB,MAAM,QAC1B,QAAO;AAGT,MAAI,OAAO,MAAM,OAAO,eAAe,SACrC,QAAO;AAGT,MAAI,EAAE,UAAU,MAAM,QACpB,QAAO;AAGT,MAAI,OAAO,MAAM,OAAO,SAAS,SAC/B,QAAO;AAGT,SAAO;CACR;AAED,KAAI,MAAM,OAAO,SAAS,OAAO;AAC/B,MAAI,EAAE,SAAS,MAAM,QACnB,QAAO;AAGT,MAAI,OAAO,MAAM,OAAO,QAAQ,SAC9B,QAAO;AAGT,SAAO;CACR;AAED,QAAO;AACR;AAED,MAAaC,gCAIR;CACH,cAAc;CAEd,sBAAsB,OAA0C;AAC9D,SAAO;GACL,MAAM;GACN,MAAM,MAAM;GACZ,GAAI,gBAAgB,MAAM,YAAY,CAAE,KACpC,EAAE,W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,MAAM,SAAU,MAAO,IAChC,CAAE;EACP;WAED;GAAC;GAAc;GAAa;GAAa;EAAa,EAAC,SACrD,UACD,CAED,QAAO;GACL,MAAM;GACN,QAAQ;IACN,MAAM;IACN,SAAS,CACP;KACE,MAAM;KACN,QAAQ;MACN,MAAM;MACN,MAAM,MAAM;MACZ,YAAY;KAKb;IACF,CACF;GACF;GACD,GAAI,oBAAoB,MAAM,YAAY,CAAE,KACxC,EAAE,eAAe,MAAM,SAAU,cAAe,IAChD,CAAE;GACN,GAAI,gBAAgB,MAAM,YAAY,CAAE,KACpC,EAAE,WAAW,MAAM,SAAU,UAAW,IACxC,CAAE;GACN,GAAI,cAAc,MAAM,YAAY,CAAE,KAClC,EAAE,SAAS,MAAM,SAAU,QAAS,IACpC,CAAE;GACN,GAAI,YAAY,MAAM,YAAY,CAAE,KAChC,EAAE,OAAO,MAAM,SAAU,MAAO,IAChC,CAAE;EACP;MAED,OAAM,IAAI,MACR,CAAC,mDAAmD,EAAE,MAAM,WAAW;MAI3E,OAAM,IAAI,MAAM,CAAC,8BAA8B,EAAE,MAAM,aAAa;CAEvE;AACF"}
1
+ {"version":3,"file":"content.js","names":[],"sources":["../../src/utils/content.ts"],"sourcesContent":["import type Anthropic from \"@anthropic-ai/sdk\";\nimport {\n parseBase64DataUrl,\n type StandardContentBlockConverter,\n} from \"@langchain/core/messages\";\n\nexport function _isAnthropicThinkingBlock(\n block: unknown\n): block is Anthropic.Messages.ThinkingBlockParam {\n return (\n typeof block === \"object\" &&\n block !== null &&\n \"type\" in block &&\n block.type === \"thinking\"\n );\n}\n\nexport function _isAnthropicRedactedThinkingBlock(\n block: unknown\n): block is Anthropic.Messages.RedactedThinkingBlockParam {\n return (\n typeof block === \"object\" &&\n block !== null &&\n \"type\" in block &&\n block.type === \"redacted_thinking\"\n );\n}\n\nexport function _isAnthropicCompactionBlock(\n block: unknown\n): block is Anthropic.Beta.BetaCompactionBlockParam {\n return (\n typeof block === \"object\" &&\n block !== null &&\n \"type\" in block &&\n block.type === \"compaction\"\n );\n}\n\nexport function _isAnthropicSearchResultBlock(\n block: unknown\n): block is Anthropic.Beta.BetaSearchResultBlockParam {\n return (\n typeof block === \"object\" &&\n block !== null &&\n \"type\" in block &&\n block.type === \"search_result\"\n );\n}\n\nexport function _isAnthropicImageBlockParam(\n block: unknown\n): block is Anthropic.Messages.ImageBlockParam {\n if (typeof block !== \"object\" || block == null) {\n return false;\n }\n if (!(\"type\" in block) || block.type !== \"image\") {\n return false;\n }\n\n if (\n !(\"source\" in block) ||\n typeof block.source !== \"object\" ||\n block.source == null\n ) {\n return false;\n }\n\n if (!(\"type\" in block.source)) {\n return false;\n }\n\n if (block.source.type === \"base64\") {\n if (!(\"media_type\" in block.source)) {\n return false;\n }\n\n if (typeof block.source.media_type !== \"string\") {\n return false;\n }\n\n if (!(\"data\" in block.source)) {\n return false;\n }\n\n if (typeof block.source.data !== \"string\") {\n return false;\n }\n\n return true;\n }\n\n if (block.source.type === \"url\") {\n if (!(\"url\" in block.source)) {\n return false;\n }\n\n if (typeof block.source.url !== \"string\") {\n return false;\n }\n\n return true;\n }\n\n return false;\n}\n\nexport const standardContentBlockConverter: StandardContentBlockConverter<{\n text: Anthropic.Messages.TextBlockParam;\n image: Anthropic.Messages.ImageBlockParam;\n file: Anthropic.Messages.DocumentBlockParam;\n}> = {\n providerName: \"anthropic\",\n\n fromStandardTextBlock(block): Anthropic.Messages.TextBlockParam {\n return {\n type: \"text\",\n text: block.text,\n ...(\"citations\" in (block.metadata ?? {})\n ? { citations: block.metadata!.citations }\n : {}),\n ...(\"cache_control\" in (block.metadata ?? {})\n ? { cache_control: block.metadata!.cache_control }\n : {}),\n } as Anthropic.Messages.TextBlockParam;\n },\n\n fromStandardImageBlock(block): Anthropic.Messages.ImageBlockParam {\n if (block.source_type === \"url\") {\n const data = parseBase64DataUrl({\n dataUrl: block.url,\n asTypedArray: false,\n });\n if (data) {\n return {\n type: \"image\",\n source: {\n type: \"base64\",\n data: data.data,\n media_type: data.mime_type,\n },\n ...(\"cache_control\" in (block.metadata ?? {})\n ? { cache_control: block.metadata!.cache_control }\n : {}),\n } as Anthropic.Messages.ImageBlockParam;\n } else {\n return {\n type: \"image\",\n source: {\n type: \"url\",\n url: block.url,\n },\n ...(\"cache_control\" in (block.metadata ?? {})\n ? { cache_control: block.metadata!.cache_control }\n : {}),\n } as Anthropic.Messages.ImageBlockParam;\n }\n } else {\n if (block.source_type === \"base64\") {\n return {\n type: \"image\",\n source: {\n type: \"base64\",\n data: block.data,\n media_type: block.mime_type ?? \"\",\n },\n ...(\"cache_control\" in (block.metadata ?? {})\n ? { cache_control: block.metadata!.cache_control }\n : {}),\n } as Anthropic.Messages.ImageBlockParam;\n } else {\n throw new Error(`Unsupported image source type: ${block.source_type}`);\n }\n }\n },\n\n fromStandardFileBlock(block): Anthropic.Messages.DocumentBlockParam {\n const mime_type = (block.mime_type ?? \"\").split(\";\")[0];\n\n if (block.source_type === \"url\") {\n if (mime_type === \"application/pdf\" || mime_type === \"\") {\n return {\n type: \"document\",\n source: {\n type: \"url\",\n url: block.url,\n },\n ...(\"cache_control\" in (block.metadata ?? {})\n ? { cache_control: block.metadata!.cache_control }\n : {}),\n ...(\"citations\" in (block.metadata ?? {})\n ? { citations: block.metadata!.citations }\n : {}),\n ...(\"context\" in (block.metadata ?? {})\n ? { context: block.metadata!.context }\n : {}),\n ...(\"title\" in (block.metadata ?? {})\n ? { title: block.metadata!.title }\n : {}),\n } as Anthropic.Messages.DocumentBlockParam;\n }\n throw new Error(\n `Unsupported file mime type for file url source: ${block.mime_type}`\n );\n } else if (block.source_type === \"text\") {\n if (mime_type === \"text/plain\" || mime_type === \"\") {\n return {\n type: \"document\",\n source: {\n type: \"text\",\n data: block.text,\n media_type: block.mime_type ?? \"\",\n },\n ...(\"cache_control\" in (block.metadata ?? {})\n ? { cache_control: block.metadata!.cache_control }\n : {}),\n ...(\"citations\" in (block.metadata ?? {})\n ? { citations: block.metadata!.citations }\n : {}),\n ...(\"context\" in (block.metadata ?? {})\n ? { context: block.metadata!.context }\n : {}),\n ...(\"title\" in (block.metadata ?? {})\n ? { title: block.metadata!.title }\n : {}),\n } as Anthropic.Messages.DocumentBlockParam;\n } else {\n throw new Error(\n `Unsupported file mime type for file text source: ${block.mime_type}`\n );\n }\n } else if (block.source_type === \"base64\") {\n if (mime_type === \"application/pdf\" || mime_type === \"\") {\n return {\n type: \"document\",\n source: {\n type: \"base64\",\n data: block.data,\n media_type: \"application/pdf\",\n },\n ...(\"cache_control\" in (block.metadata ?? {})\n ? { cache_control: block.metadata!.cache_control }\n : {}),\n ...(\"citations\" in (block.metadata ?? {})\n ? { citations: block.metadata!.citations }\n : {}),\n ...(\"context\" in (block.metadata ?? {})\n ? { context: block.metadata!.context }\n : {}),\n ...(\"title\" in (block.metadata ?? {})\n ? { title: block.metadata!.title }\n : {}),\n } as Anthropic.Messages.DocumentBlockParam;\n } else if (\n [\"image/jpeg\", \"image/png\", \"image/gif\", \"image/webp\"].includes(\n mime_type\n )\n ) {\n return {\n type: \"document\",\n source: {\n type: \"content\",\n content: [\n {\n type: \"image\",\n source: {\n type: \"base64\",\n data: block.data,\n media_type: mime_type as\n | \"image/jpeg\"\n | \"image/png\"\n | \"image/gif\"\n | \"image/webp\",\n },\n },\n ],\n },\n ...(\"cache_control\" in (block.metadata ?? {})\n ? { cache_control: block.metadata!.cache_control }\n : {}),\n ...(\"citations\" in (block.metadata ?? {})\n ? { citations: block.metadata!.citations }\n : {}),\n ...(\"context\" in (block.metadata ?? {})\n ? { context: block.metadata!.context }\n : {}),\n ...(\"title\" in (block.metadata ?? {})\n ? { title: block.metadata!.title }\n : {}),\n } as Anthropic.Messages.DocumentBlockParam;\n } else {\n throw new Error(\n `Unsupported file mime type for file base64 source: ${block.mime_type}`\n );\n }\n } else {\n throw new Error(`Unsupported file source type: ${block.source_type}`);\n }\n },\n};\n"],"mappings":";;;AAMA,SAAgB,0BACd,OACgD;AAChD,QACE,OAAO,UAAU,YACjB,UAA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YAAY;MAKb;KACF,CACF;IACF;GACD,GAAI,oBAAoB,MAAM,YAAY,EAAE,IACxC,EAAE,eAAe,MAAM,SAAU,eAAe,GAChD,EAAE;GACN,GAAI,gBAAgB,MAAM,YAAY,EAAE,IACpC,EAAE,WAAW,MAAM,SAAU,WAAW,GACxC,EAAE;GACN,GAAI,cAAc,MAAM,YAAY,EAAE,IAClC,EAAE,SAAS,MAAM,SAAU,SAAS,GACpC,EAAE;GACN,GAAI,YAAY,MAAM,YAAY,EAAE,IAChC,EAAE,OAAO,MAAM,SAAU,OAAO,GAChC,EAAE;GACP;MAED,OAAM,IAAI,MACR,sDAAsD,MAAM,YAC7D;MAGH,OAAM,IAAI,MAAM,iCAAiC,MAAM,cAAc;;CAG1E"}
@@ -1,3 +1,5 @@
1
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
2
+ let _langchain_core_errors = require("@langchain/core/errors");
1
3
 
2
4
  //#region src/utils/errors.ts
3
5
  function addLangChainErrorFields(error, lc_error_code) {
@@ -7,7 +9,8 @@ function addLangChainErrorFields(error, lc_error_code) {
7
9
  }
8
10
  function wrapAnthropicClientError(e) {
9
11
  let error;
10
- if (e.status === 400 && e.message.includes("tool")) error = addLangChainErrorFields(e, "INVALID_TOOL_RESULTS");
12
+ if (e.status === 400 && typeof e.message === "string" && e.message.includes("prompt is too long")) error = _langchain_core_errors.ContextOverflowError.fromError(e);
13
+ else if (e.status === 400 && e.message.includes("tool")) error = addLangChainErrorFields(e, "INVALID_TOOL_RESULTS");
11
14
  else if (e.status === 401) error = addLangChainErrorFields(e, "MODEL_AUTHENTICATION");
12
15
  else if (e.status === 404) error = addLangChainErrorFields(e, "MODEL_NOT_FOUND");
13
16
  else if (e.status === 429) error = addLangChainErrorFields(e, "MODEL_RATE_LIMIT");
@@ -1 +1 @@
1
- {"version":3,"file":"errors.cjs","names":["error: any","lc_error_code: LangChainErrorCodes","e: any"],"sources":["../../src/utils/errors.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable no-param-reassign */\n\n// Duplicate of core\n// TODO: Remove once we stop supporting 0.2.x core versions\nexport type LangChainErrorCodes =\n | \"INVALID_PROMPT_INPUT\"\n | \"INVALID_TOOL_RESULTS\"\n | \"MESSAGE_COERCION_FAILURE\"\n | \"MODEL_AUTHENTICATION\"\n | \"MODEL_NOT_FOUND\"\n | \"MODEL_RATE_LIMIT\"\n | \"OUTPUT_PARSING_FAILURE\";\n\nexport function addLangChainErrorFields(\n error: any,\n lc_error_code: LangChainErrorCodes\n) {\n (error as any).lc_error_code = lc_error_code;\n error.message = `${error.message}\\n\\nTroubleshooting URL: https://docs.langchain.com/oss/javascript/langchain/errors/${lc_error_code}/\\n`;\n return error;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function wrapAnthropicClientError(e: any) {\n let error;\n if (e.status === 400 && e.message.includes(\"tool\")) {\n error = addLangChainErrorFields(e, \"INVALID_TOOL_RESULTS\");\n } else if (e.status === 401) {\n error = addLangChainErrorFields(e, \"MODEL_AUTHENTICATION\");\n } else if (e.status === 404) {\n error = addLangChainErrorFields(e, \"MODEL_NOT_FOUND\");\n } else if (e.status === 429) {\n error = addLangChainErrorFields(e, \"MODEL_RATE_LIMIT\");\n } else {\n error = e;\n }\n return error;\n}\n"],"mappings":";;AAcA,SAAgB,wBACdA,OACAC,eACA;CACC,MAAc,gBAAgB;CAC/B,MAAM,UAAU,GAAG,MAAM,QAAQ,oFAAoF,EAAE,cAAc,GAAG,CAAC;AACzI,QAAO;AACR;AAGD,SAAgB,yBAAyBC,GAAQ;CAC/C,IAAI;AACJ,KAAI,EAAE,WAAW,OAAO,EAAE,QAAQ,SAAS,OAAO,EAChD,QAAQ,wBAAwB,GAAG,uBAAuB;UACjD,EAAE,WAAW,KACtB,QAAQ,wBAAwB,GAAG,uBAAuB;UACjD,EAAE,WAAW,KACtB,QAAQ,wBAAwB,GAAG,kBAAkB;UAC5C,EAAE,WAAW,KACtB,QAAQ,wBAAwB,GAAG,mBAAmB;MAEtD,QAAQ;AAEV,QAAO;AACR"}
1
+ {"version":3,"file":"errors.cjs","names":["ContextOverflowError"],"sources":["../../src/utils/errors.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable no-param-reassign */\n\nimport { ContextOverflowError } from \"@langchain/core/errors\";\n\n// Duplicate of core\n// TODO: Remove once we stop supporting 0.2.x core versions\nexport type LangChainErrorCodes =\n | \"CONTEXT_OVERFLOW\"\n | \"INVALID_PROMPT_INPUT\"\n | \"INVALID_TOOL_RESULTS\"\n | \"MESSAGE_COERCION_FAILURE\"\n | \"MODEL_AUTHENTICATION\"\n | \"MODEL_NOT_FOUND\"\n | \"MODEL_RATE_LIMIT\"\n | \"OUTPUT_PARSING_FAILURE\";\n\nexport function addLangChainErrorFields(\n error: any,\n lc_error_code: LangChainErrorCodes\n) {\n (error as any).lc_error_code = lc_error_code;\n error.message = `${error.message}\\n\\nTroubleshooting URL: https://docs.langchain.com/oss/javascript/langchain/errors/${lc_error_code}/\\n`;\n return error;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function wrapAnthropicClientError(e: any) {\n let error;\n if (\n e.status === 400 &&\n typeof e.message === \"string\" &&\n e.message.includes(\"prompt is too long\")\n ) {\n error = ContextOverflowError.fromError(e);\n } else if (e.status === 400 && e.message.includes(\"tool\")) {\n error = addLangChainErrorFields(e, \"INVALID_TOOL_RESULTS\");\n } else if (e.status === 401) {\n error = addLangChainErrorFields(e, \"MODEL_AUTHENTICATION\");\n } else if (e.status === 404) {\n error = addLangChainErrorFields(e, \"MODEL_NOT_FOUND\");\n } else if (e.status === 429) {\n error = addLangChainErrorFields(e, \"MODEL_RATE_LIMIT\");\n } else {\n error = e;\n }\n return error;\n}\n"],"mappings":";;;;AAiBA,SAAgB,wBACd,OACA,eACA;AACA,CAAC,MAAc,gBAAgB;AAC/B,OAAM,UAAU,GAAG,MAAM,QAAQ,sFAAsF,cAAc;AACrI,QAAO;;AAIT,SAAgB,yBAAyB,GAAQ;CAC/C,IAAI;AACJ,KACE,EAAE,WAAW,OACb,OAAO,EAAE,YAAY,YACrB,EAAE,QAAQ,SAAS,qBAAqB,CAExC,SAAQA,4CAAqB,UAAU,EAAE;UAChC,EAAE,WAAW,OAAO,EAAE,QAAQ,SAAS,OAAO,CACvD,SAAQ,wBAAwB,GAAG,uBAAuB;UACjD,EAAE,WAAW,IACtB,SAAQ,wBAAwB,GAAG,uBAAuB;UACjD,EAAE,WAAW,IACtB,SAAQ,wBAAwB,GAAG,kBAAkB;UAC5C,EAAE,WAAW,IACtB,SAAQ,wBAAwB,GAAG,mBAAmB;KAEtD,SAAQ;AAEV,QAAO"}
@@ -1,3 +1,5 @@
1
+ import { ContextOverflowError } from "@langchain/core/errors";
2
+
1
3
  //#region src/utils/errors.ts
2
4
  function addLangChainErrorFields(error, lc_error_code) {
3
5
  error.lc_error_code = lc_error_code;
@@ -6,7 +8,8 @@ function addLangChainErrorFields(error, lc_error_code) {
6
8
  }
7
9
  function wrapAnthropicClientError(e) {
8
10
  let error;
9
- if (e.status === 400 && e.message.includes("tool")) error = addLangChainErrorFields(e, "INVALID_TOOL_RESULTS");
11
+ if (e.status === 400 && typeof e.message === "string" && e.message.includes("prompt is too long")) error = ContextOverflowError.fromError(e);
12
+ else if (e.status === 400 && e.message.includes("tool")) error = addLangChainErrorFields(e, "INVALID_TOOL_RESULTS");
10
13
  else if (e.status === 401) error = addLangChainErrorFields(e, "MODEL_AUTHENTICATION");
11
14
  else if (e.status === 404) error = addLangChainErrorFields(e, "MODEL_NOT_FOUND");
12
15
  else if (e.status === 429) error = addLangChainErrorFields(e, "MODEL_RATE_LIMIT");
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","names":["error: any","lc_error_code: LangChainErrorCodes","e: any"],"sources":["../../src/utils/errors.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable no-param-reassign */\n\n// Duplicate of core\n// TODO: Remove once we stop supporting 0.2.x core versions\nexport type LangChainErrorCodes =\n | \"INVALID_PROMPT_INPUT\"\n | \"INVALID_TOOL_RESULTS\"\n | \"MESSAGE_COERCION_FAILURE\"\n | \"MODEL_AUTHENTICATION\"\n | \"MODEL_NOT_FOUND\"\n | \"MODEL_RATE_LIMIT\"\n | \"OUTPUT_PARSING_FAILURE\";\n\nexport function addLangChainErrorFields(\n error: any,\n lc_error_code: LangChainErrorCodes\n) {\n (error as any).lc_error_code = lc_error_code;\n error.message = `${error.message}\\n\\nTroubleshooting URL: https://docs.langchain.com/oss/javascript/langchain/errors/${lc_error_code}/\\n`;\n return error;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function wrapAnthropicClientError(e: any) {\n let error;\n if (e.status === 400 && e.message.includes(\"tool\")) {\n error = addLangChainErrorFields(e, \"INVALID_TOOL_RESULTS\");\n } else if (e.status === 401) {\n error = addLangChainErrorFields(e, \"MODEL_AUTHENTICATION\");\n } else if (e.status === 404) {\n error = addLangChainErrorFields(e, \"MODEL_NOT_FOUND\");\n } else if (e.status === 429) {\n error = addLangChainErrorFields(e, \"MODEL_RATE_LIMIT\");\n } else {\n error = e;\n }\n return error;\n}\n"],"mappings":";AAcA,SAAgB,wBACdA,OACAC,eACA;CACC,MAAc,gBAAgB;CAC/B,MAAM,UAAU,GAAG,MAAM,QAAQ,oFAAoF,EAAE,cAAc,GAAG,CAAC;AACzI,QAAO;AACR;AAGD,SAAgB,yBAAyBC,GAAQ;CAC/C,IAAI;AACJ,KAAI,EAAE,WAAW,OAAO,EAAE,QAAQ,SAAS,OAAO,EAChD,QAAQ,wBAAwB,GAAG,uBAAuB;UACjD,EAAE,WAAW,KACtB,QAAQ,wBAAwB,GAAG,uBAAuB;UACjD,EAAE,WAAW,KACtB,QAAQ,wBAAwB,GAAG,kBAAkB;UAC5C,EAAE,WAAW,KACtB,QAAQ,wBAAwB,GAAG,mBAAmB;MAEtD,QAAQ;AAEV,QAAO;AACR"}
1
+ {"version":3,"file":"errors.js","names":[],"sources":["../../src/utils/errors.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable no-param-reassign */\n\nimport { ContextOverflowError } from \"@langchain/core/errors\";\n\n// Duplicate of core\n// TODO: Remove once we stop supporting 0.2.x core versions\nexport type LangChainErrorCodes =\n | \"CONTEXT_OVERFLOW\"\n | \"INVALID_PROMPT_INPUT\"\n | \"INVALID_TOOL_RESULTS\"\n | \"MESSAGE_COERCION_FAILURE\"\n | \"MODEL_AUTHENTICATION\"\n | \"MODEL_NOT_FOUND\"\n | \"MODEL_RATE_LIMIT\"\n | \"OUTPUT_PARSING_FAILURE\";\n\nexport function addLangChainErrorFields(\n error: any,\n lc_error_code: LangChainErrorCodes\n) {\n (error as any).lc_error_code = lc_error_code;\n error.message = `${error.message}\\n\\nTroubleshooting URL: https://docs.langchain.com/oss/javascript/langchain/errors/${lc_error_code}/\\n`;\n return error;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function wrapAnthropicClientError(e: any) {\n let error;\n if (\n e.status === 400 &&\n typeof e.message === \"string\" &&\n e.message.includes(\"prompt is too long\")\n ) {\n error = ContextOverflowError.fromError(e);\n } else if (e.status === 400 && e.message.includes(\"tool\")) {\n error = addLangChainErrorFields(e, \"INVALID_TOOL_RESULTS\");\n } else if (e.status === 401) {\n error = addLangChainErrorFields(e, \"MODEL_AUTHENTICATION\");\n } else if (e.status === 404) {\n error = addLangChainErrorFields(e, \"MODEL_NOT_FOUND\");\n } else if (e.status === 429) {\n error = addLangChainErrorFields(e, \"MODEL_RATE_LIMIT\");\n } else {\n error = e;\n }\n return error;\n}\n"],"mappings":";;;AAiBA,SAAgB,wBACd,OACA,eACA;AACA,CAAC,MAAc,gBAAgB;AAC/B,OAAM,UAAU,GAAG,MAAM,QAAQ,sFAAsF,cAAc;AACrI,QAAO;;AAIT,SAAgB,yBAAyB,GAAQ;CAC/C,IAAI;AACJ,KACE,EAAE,WAAW,OACb,OAAO,EAAE,YAAY,YACrB,EAAE,QAAQ,SAAS,qBAAqB,CAExC,SAAQ,qBAAqB,UAAU,EAAE;UAChC,EAAE,WAAW,OAAO,EAAE,QAAQ,SAAS,OAAO,CACvD,SAAQ,wBAAwB,GAAG,uBAAuB;UACjD,EAAE,WAAW,IACtB,SAAQ,wBAAwB,GAAG,uBAAuB;UACjD,EAAE,WAAW,IACtB,SAAQ,wBAAwB,GAAG,kBAAkB;UAC5C,EAAE,WAAW,IACtB,SAAQ,wBAAwB,GAAG,mBAAmB;KAEtD,SAAQ;AAEV,QAAO"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["fn: () => T"],"sources":["../../src/utils/index.ts"],"sourcesContent":["export const iife = <T>(fn: () => T) => fn();\n\nexport const safeParseJson = <T>(json: string): T | object => {\n try {\n return JSON.parse(json);\n } catch {\n return {};\n }\n};\n"],"mappings":";;AAAA,MAAa,OAAO,CAAIA,OAAgB,IAAI"}
1
+ {"version":3,"file":"index.cjs","names":[],"sources":["../../src/utils/index.ts"],"sourcesContent":["export const iife = <T>(fn: () => T) => fn();\n\nexport const safeParseJson = <T>(json: string): T | object => {\n try {\n return JSON.parse(json);\n } catch {\n return {};\n }\n};\n"],"mappings":";;AAAA,MAAa,QAAW,OAAgB,IAAI"}