@langchain/anthropic 1.3.26 → 1.4.0-dev-1775763803878

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 (41) hide show
  1. package/dist/chat_models.cjs +39 -1
  2. package/dist/chat_models.cjs.map +1 -1
  3. package/dist/chat_models.d.cts +46 -26
  4. package/dist/chat_models.d.cts.map +1 -1
  5. package/dist/chat_models.d.ts +46 -26
  6. package/dist/chat_models.d.ts.map +1 -1
  7. package/dist/chat_models.js +39 -1
  8. package/dist/chat_models.js.map +1 -1
  9. package/dist/output_parsers.cjs.map +1 -1
  10. package/dist/output_parsers.js.map +1 -1
  11. package/dist/tools/bash.d.cts +2 -12
  12. package/dist/tools/bash.d.cts.map +1 -1
  13. package/dist/tools/bash.d.ts +2 -12
  14. package/dist/tools/bash.d.ts.map +1 -1
  15. package/dist/tools/computer.cjs.map +1 -1
  16. package/dist/tools/computer.d.cts +3 -112
  17. package/dist/tools/computer.d.cts.map +1 -1
  18. package/dist/tools/computer.d.ts +3 -112
  19. package/dist/tools/computer.d.ts.map +1 -1
  20. package/dist/tools/computer.js.map +1 -1
  21. package/dist/tools/memory.d.cts +2 -52
  22. package/dist/tools/memory.d.cts.map +1 -1
  23. package/dist/tools/memory.d.ts +2 -52
  24. package/dist/tools/memory.d.ts.map +1 -1
  25. package/dist/tools/textEditor.d.cts +2 -40
  26. package/dist/tools/textEditor.d.cts.map +1 -1
  27. package/dist/tools/textEditor.d.ts +2 -40
  28. package/dist/tools/textEditor.d.ts.map +1 -1
  29. package/dist/utils/errors.cjs.map +1 -1
  30. package/dist/utils/errors.js.map +1 -1
  31. package/dist/utils/message_inputs.cjs.map +1 -1
  32. package/dist/utils/message_inputs.js.map +1 -1
  33. package/dist/utils/message_outputs.cjs.map +1 -1
  34. package/dist/utils/message_outputs.js.map +1 -1
  35. package/dist/utils/standard.cjs.map +1 -1
  36. package/dist/utils/standard.js.map +1 -1
  37. package/dist/utils/stream_events.cjs +316 -0
  38. package/dist/utils/stream_events.cjs.map +1 -0
  39. package/dist/utils/stream_events.js +316 -0
  40. package/dist/utils/stream_events.js.map +1 -0
  41. package/package.json +8 -17
@@ -0,0 +1,316 @@
1
+ //#region src/utils/stream_events.ts
2
+ /**
3
+ * Convert an async iterable of raw Anthropic stream events into
4
+ * LangChain `ChatModelStreamEvent`s.
5
+ *
6
+ * @example
7
+ * ```ts
8
+ * const anthropicStream = await client.messages.create({ ..., stream: true });
9
+ * for await (const event of convertAnthropicStream(anthropicStream)) {
10
+ * // event is a ChatModelStreamEvent
11
+ * }
12
+ * ```
13
+ */
14
+ async function* convertAnthropicStream(source, options = {}) {
15
+ const shouldStreamUsage = options.streamUsage ?? true;
16
+ const blockAccumulators = /* @__PURE__ */ new Map();
17
+ let usageSnapshot;
18
+ let stopReason = null;
19
+ for await (const data of source) switch (data.type) {
20
+ case "message_start": {
21
+ const { usage, id, model } = data.message;
22
+ if (usage && shouldStreamUsage) usageSnapshot = buildUsageSnapshot(usage);
23
+ yield {
24
+ type: "message-start",
25
+ id,
26
+ ...usageSnapshot ? { usage: usageSnapshot } : {}
27
+ };
28
+ yield {
29
+ type: "provider",
30
+ provider: "anthropic",
31
+ name: "message_start",
32
+ payload: {
33
+ model,
34
+ id
35
+ }
36
+ };
37
+ break;
38
+ }
39
+ case "message_delta":
40
+ stopReason = data.delta.stop_reason;
41
+ if (shouldStreamUsage && data.usage) {
42
+ if (!usageSnapshot) usageSnapshot = {
43
+ input_tokens: 0,
44
+ output_tokens: data.usage.output_tokens,
45
+ total_tokens: data.usage.output_tokens
46
+ };
47
+ else usageSnapshot = {
48
+ ...usageSnapshot,
49
+ output_tokens: usageSnapshot.output_tokens + data.usage.output_tokens,
50
+ total_tokens: usageSnapshot.input_tokens + usageSnapshot.output_tokens + data.usage.output_tokens
51
+ };
52
+ yield {
53
+ type: "usage",
54
+ usage: usageSnapshot
55
+ };
56
+ }
57
+ if ("context_management" in data.delta && data.delta.context_management) yield {
58
+ type: "provider",
59
+ provider: "anthropic",
60
+ name: "context_management",
61
+ payload: data.delta.context_management
62
+ };
63
+ break;
64
+ case "message_stop":
65
+ yield {
66
+ type: "message-finish",
67
+ reason: mapStopReason(stopReason),
68
+ ...usageSnapshot ? { usage: usageSnapshot } : {},
69
+ responseMetadata: { model_provider: "anthropic" }
70
+ };
71
+ break;
72
+ case "content_block_start": {
73
+ const { index, content_block } = data;
74
+ const mapped = mapBlockToContentBlock(content_block, index);
75
+ blockAccumulators.set(index, {
76
+ accumulated: { ...mapped },
77
+ type: mapped.type
78
+ });
79
+ yield {
80
+ type: "content-block-start",
81
+ index,
82
+ content: mapped
83
+ };
84
+ break;
85
+ }
86
+ case "content_block_delta": {
87
+ const { index, delta } = data;
88
+ const acc = blockAccumulators.get(index);
89
+ if (!acc) break;
90
+ const { accumulated } = applyDelta(acc.accumulated, delta, index);
91
+ acc.accumulated = accumulated;
92
+ yield {
93
+ type: "content-block-delta",
94
+ index,
95
+ content: accumulated
96
+ };
97
+ break;
98
+ }
99
+ case "content_block_stop": {
100
+ const { index } = data;
101
+ const acc = blockAccumulators.get(index);
102
+ if (!acc) break;
103
+ yield {
104
+ type: "content-block-finish",
105
+ index,
106
+ content: finalizeBlock(acc.accumulated)
107
+ };
108
+ blockAccumulators.delete(index);
109
+ break;
110
+ }
111
+ default:
112
+ yield {
113
+ type: "provider",
114
+ provider: "anthropic",
115
+ name: data.type,
116
+ payload: data
117
+ };
118
+ break;
119
+ }
120
+ }
121
+ /**
122
+ * Map Anthropic's stop_reason to the standard FinishReason.
123
+ */
124
+ function mapStopReason(stopReason) {
125
+ switch (stopReason) {
126
+ case "end_turn":
127
+ case "stop_sequence": return "stop";
128
+ case "tool_use": return "tool_use";
129
+ case "max_tokens": return "length";
130
+ default: return "stop";
131
+ }
132
+ }
133
+ /**
134
+ * Build a usage snapshot from Anthropic's usage object.
135
+ * Handles cache token details.
136
+ */
137
+ function buildUsageSnapshot(usage) {
138
+ const cacheCreation = usage.cache_creation_input_tokens ?? 0;
139
+ const cacheRead = usage.cache_read_input_tokens ?? 0;
140
+ const totalInput = usage.input_tokens + cacheCreation + cacheRead;
141
+ return {
142
+ input_tokens: totalInput,
143
+ output_tokens: usage.output_tokens,
144
+ total_tokens: totalInput + usage.output_tokens,
145
+ input_token_details: {
146
+ cache_creation: cacheCreation,
147
+ cache_read: cacheRead
148
+ }
149
+ };
150
+ }
151
+ /**
152
+ * Map an Anthropic content block (from content_block_start) to a
153
+ * LangChain ContentBlock.
154
+ */
155
+ function mapBlockToContentBlock(block, index) {
156
+ switch (block.type) {
157
+ case "text": return {
158
+ type: "text",
159
+ text: block.text ?? "",
160
+ index
161
+ };
162
+ case "thinking": return {
163
+ type: "reasoning",
164
+ reasoning: block.thinking ?? "",
165
+ index
166
+ };
167
+ case "redacted_thinking": return {
168
+ type: "non_standard",
169
+ value: { ...block },
170
+ index
171
+ };
172
+ case "tool_use": return {
173
+ type: "tool_call_chunk",
174
+ id: block.id,
175
+ name: block.name,
176
+ args: "",
177
+ index
178
+ };
179
+ case "server_tool_use": return {
180
+ type: "server_tool_call_chunk",
181
+ id: block.id,
182
+ name: block.name,
183
+ args: "",
184
+ index
185
+ };
186
+ default: return {
187
+ type: "non_standard",
188
+ value: { ...block },
189
+ index
190
+ };
191
+ }
192
+ }
193
+ /**
194
+ * Apply an Anthropic content_block_delta to the accumulated content block.
195
+ * Returns both the incremental delta (as a ContentBlock) and the new
196
+ * accumulated state.
197
+ */
198
+ function applyDelta(accumulated, delta, index) {
199
+ switch (delta.type) {
200
+ case "text_delta": return {
201
+ deltaBlock: {
202
+ type: "text",
203
+ text: delta.text,
204
+ index
205
+ },
206
+ accumulated: {
207
+ ...accumulated,
208
+ text: (accumulated.text ?? "") + delta.text
209
+ }
210
+ };
211
+ case "thinking_delta": return {
212
+ deltaBlock: {
213
+ type: "reasoning",
214
+ reasoning: delta.thinking,
215
+ index
216
+ },
217
+ accumulated: {
218
+ ...accumulated,
219
+ reasoning: (accumulated.reasoning ?? "") + delta.thinking
220
+ }
221
+ };
222
+ case "input_json_delta": return {
223
+ deltaBlock: {
224
+ type: accumulated.type,
225
+ args: delta.partial_json,
226
+ index
227
+ },
228
+ accumulated: {
229
+ ...accumulated,
230
+ args: (accumulated.args ?? "") + delta.partial_json
231
+ }
232
+ };
233
+ case "citations_delta": {
234
+ const newCitation = delta.citation;
235
+ const existingAnnotations = accumulated.annotations ?? [];
236
+ return {
237
+ deltaBlock: {
238
+ type: "text",
239
+ text: "",
240
+ annotations: [newCitation],
241
+ index
242
+ },
243
+ accumulated: {
244
+ ...accumulated,
245
+ annotations: [...existingAnnotations, newCitation]
246
+ }
247
+ };
248
+ }
249
+ case "signature_delta": return {
250
+ deltaBlock: {
251
+ type: "non_standard",
252
+ value: { signature: delta.signature },
253
+ index
254
+ },
255
+ accumulated: {
256
+ ...accumulated,
257
+ signature: delta.signature
258
+ }
259
+ };
260
+ case "compaction_delta": return {
261
+ deltaBlock: {
262
+ type: "non_standard",
263
+ value: { compaction: delta },
264
+ index
265
+ },
266
+ accumulated: {
267
+ ...accumulated,
268
+ value: {
269
+ ...accumulated.value ?? {},
270
+ compaction: delta
271
+ }
272
+ }
273
+ };
274
+ default: return {
275
+ deltaBlock: {
276
+ type: "non_standard",
277
+ value: delta,
278
+ index
279
+ },
280
+ accumulated
281
+ };
282
+ }
283
+ }
284
+ /**
285
+ * Finalize an accumulated content block for the content-block-finish event.
286
+ * For tool calls, parse the accumulated JSON args string.
287
+ */
288
+ function finalizeBlock(accumulated) {
289
+ if (accumulated.type === "tool_call_chunk" || accumulated.type === "server_tool_call_chunk") {
290
+ const finalType = accumulated.type === "tool_call_chunk" ? "tool_call" : "server_tool_call";
291
+ let parsedArgs;
292
+ try {
293
+ parsedArgs = JSON.parse(accumulated.args || "{}");
294
+ } catch {
295
+ return {
296
+ type: "invalid_tool_call",
297
+ id: accumulated.id,
298
+ name: accumulated.name,
299
+ args: accumulated.args,
300
+ error: "Failed to parse tool call arguments as JSON"
301
+ };
302
+ }
303
+ return {
304
+ type: finalType,
305
+ id: accumulated.id,
306
+ name: accumulated.name,
307
+ args: parsedArgs
308
+ };
309
+ }
310
+ const { index: _index, ...rest } = accumulated;
311
+ return rest;
312
+ }
313
+ //#endregion
314
+ export { convertAnthropicStream };
315
+
316
+ //# sourceMappingURL=stream_events.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stream_events.js","names":[],"sources":["../../src/utils/stream_events.ts"],"sourcesContent":["/**\n * Converts a raw Anthropic SSE event stream into LangChain ChatModelStreamEvents.\n *\n * This is a pure converter: it takes an async iterable of native Anthropic\n * `RawMessageStreamEvent`s and yields `ChatModelStreamEvent`s. It handles:\n *\n * - Message lifecycle (`message_start` → `message-start`, `message_stop` → `message-finish`)\n * - Content block lifecycle with fully-qualified accumulated snapshots\n * - Tool call arg accumulation and JSON parsing on finalization\n * - Usage snapshots (input tokens on start, output tokens on delta)\n * - Provider passthrough for unrecognized events\n *\n * @module\n */\n\nimport type Anthropic from \"@anthropic-ai/sdk\";\nimport type {\n ChatModelStreamEvent,\n FinishReason,\n} from \"@langchain/core/language_models/event\";\nimport type { ContentBlock } from \"@langchain/core/messages/content\";\nimport type { UsageMetadata } from \"@langchain/core/messages/metadata\";\nimport type { AnthropicMessageStreamEvent } from \"../types.js\";\n\nexport interface ConvertAnthropicStreamOptions {\n /**\n * Whether to emit usage events.\n * @default true\n */\n streamUsage?: boolean;\n}\n\n/**\n * Convert an async iterable of raw Anthropic stream events into\n * LangChain `ChatModelStreamEvent`s.\n *\n * @example\n * ```ts\n * const anthropicStream = await client.messages.create({ ..., stream: true });\n * for await (const event of convertAnthropicStream(anthropicStream)) {\n * // event is a ChatModelStreamEvent\n * }\n * ```\n */\nexport async function* convertAnthropicStream(\n source: AsyncIterable<AnthropicMessageStreamEvent>,\n options: ConvertAnthropicStreamOptions = {}\n): AsyncGenerator<ChatModelStreamEvent> {\n const shouldStreamUsage = options.streamUsage ?? true;\n\n // Track accumulated state per content block\n const blockAccumulators = new Map<\n number,\n {\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n accumulated: Record<string, any>;\n type: string;\n }\n >();\n let usageSnapshot: UsageMetadata | undefined;\n let stopReason: string | null = null;\n\n for await (const data of source) {\n switch (data.type) {\n case \"message_start\": {\n const { usage, id, model } = data.message;\n if (usage && shouldStreamUsage) {\n usageSnapshot = buildUsageSnapshot(usage);\n }\n yield {\n type: \"message-start\" as const,\n id,\n ...(usageSnapshot ? { usage: usageSnapshot } : {}),\n };\n // Emit response metadata as provider event\n yield {\n type: \"provider\" as const,\n provider: \"anthropic\",\n name: \"message_start\",\n payload: { model, id },\n };\n break;\n }\n\n case \"message_delta\": {\n stopReason = data.delta.stop_reason;\n if (shouldStreamUsage && data.usage) {\n if (!usageSnapshot) {\n usageSnapshot = {\n input_tokens: 0,\n output_tokens: data.usage.output_tokens,\n total_tokens: data.usage.output_tokens,\n };\n } else {\n usageSnapshot = {\n ...usageSnapshot,\n output_tokens:\n usageSnapshot.output_tokens + data.usage.output_tokens,\n total_tokens:\n usageSnapshot.input_tokens +\n usageSnapshot.output_tokens +\n data.usage.output_tokens,\n };\n }\n yield { type: \"usage\" as const, usage: usageSnapshot };\n }\n // Forward context_management as provider event\n if (\n \"context_management\" in data.delta &&\n data.delta.context_management\n ) {\n yield {\n type: \"provider\" as const,\n provider: \"anthropic\",\n name: \"context_management\",\n payload: data.delta.context_management,\n };\n }\n break;\n }\n\n case \"message_stop\": {\n yield {\n type: \"message-finish\" as const,\n reason: mapStopReason(stopReason),\n ...(usageSnapshot ? { usage: usageSnapshot } : {}),\n responseMetadata: { model_provider: \"anthropic\" },\n };\n break;\n }\n\n // ── Content block lifecycle ───────────────────────────\n case \"content_block_start\": {\n const { index, content_block } = data;\n const mapped = mapBlockToContentBlock(content_block, index);\n blockAccumulators.set(index, {\n accumulated: { ...mapped },\n type: mapped.type,\n });\n yield {\n type: \"content-block-start\" as const,\n index,\n content: mapped,\n };\n break;\n }\n\n case \"content_block_delta\": {\n const { index, delta } = data;\n const acc = blockAccumulators.get(index);\n if (!acc) break;\n\n const { accumulated } = applyDelta(acc.accumulated, delta, index);\n acc.accumulated = accumulated;\n\n yield {\n type: \"content-block-delta\" as const,\n index,\n content: accumulated,\n };\n break;\n }\n\n case \"content_block_stop\": {\n const { index } = data;\n const acc = blockAccumulators.get(index);\n if (!acc) break;\n\n const finalized = finalizeBlock(acc.accumulated);\n yield {\n type: \"content-block-finish\" as const,\n index,\n content: finalized,\n };\n blockAccumulators.delete(index);\n break;\n }\n\n // ── Unhandled events → provider passthrough ───────────\n default: {\n yield {\n type: \"provider\" as const,\n provider: \"anthropic\",\n name: data.type,\n payload: data,\n };\n break;\n }\n }\n }\n}\n\n// ─── Internal helpers ───────────────────────────────────────────\n\n/**\n * Map Anthropic's stop_reason to the standard FinishReason.\n */\nfunction mapStopReason(stopReason: string | null | undefined): FinishReason {\n switch (stopReason) {\n case \"end_turn\":\n case \"stop_sequence\":\n return \"stop\";\n case \"tool_use\":\n return \"tool_use\";\n case \"max_tokens\":\n return \"length\";\n default:\n return \"stop\";\n }\n}\n\n/**\n * Build a usage snapshot from Anthropic's usage object.\n * Handles cache token details.\n */\nfunction buildUsageSnapshot(\n usage: Anthropic.Messages.Usage | Record<string, number>\n): UsageMetadata {\n const cacheCreation =\n (usage as Record<string, number>).cache_creation_input_tokens ?? 0;\n const cacheRead =\n (usage as Record<string, number>).cache_read_input_tokens ?? 0;\n const totalInput = usage.input_tokens + cacheCreation + cacheRead;\n return {\n input_tokens: totalInput,\n output_tokens: usage.output_tokens,\n total_tokens: totalInput + usage.output_tokens,\n input_token_details: {\n cache_creation: cacheCreation,\n cache_read: cacheRead,\n },\n };\n}\n\n/**\n * Map an Anthropic content block (from content_block_start) to a\n * LangChain ContentBlock.\n */\nfunction mapBlockToContentBlock(\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n block: any,\n index: number\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n): Record<string, any> {\n switch (block.type) {\n case \"text\":\n return {\n type: \"text\" as const,\n text: block.text ?? \"\",\n index,\n };\n case \"thinking\":\n return {\n type: \"reasoning\" as const,\n reasoning: block.thinking ?? \"\",\n index,\n };\n case \"redacted_thinking\":\n return {\n type: \"non_standard\" as const,\n value: { ...block },\n index,\n };\n case \"tool_use\":\n return {\n type: \"tool_call_chunk\" as const,\n id: block.id,\n name: block.name,\n args: \"\",\n index,\n };\n case \"server_tool_use\":\n return {\n type: \"server_tool_call_chunk\" as const,\n id: block.id,\n name: block.name,\n args: \"\",\n index,\n };\n default:\n // document, web_search_tool_result, compaction, etc.\n return {\n type: \"non_standard\" as const,\n value: { ...block },\n index,\n };\n }\n}\n\n/**\n * Apply an Anthropic content_block_delta to the accumulated content block.\n * Returns both the incremental delta (as a ContentBlock) and the new\n * accumulated state.\n */\nfunction applyDelta(\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n accumulated: Record<string, any>,\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n delta: any,\n index: number\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n): { deltaBlock: Record<string, any>; accumulated: Record<string, any> } {\n switch (delta.type) {\n case \"text_delta\":\n return {\n deltaBlock: { type: \"text\" as const, text: delta.text, index },\n accumulated: {\n ...accumulated,\n text: (accumulated.text ?? \"\") + delta.text,\n },\n };\n\n case \"thinking_delta\":\n return {\n deltaBlock: {\n type: \"reasoning\" as const,\n reasoning: delta.thinking,\n index,\n },\n accumulated: {\n ...accumulated,\n reasoning: (accumulated.reasoning ?? \"\") + delta.thinking,\n },\n };\n\n case \"input_json_delta\":\n return {\n deltaBlock: {\n type: accumulated.type,\n args: delta.partial_json,\n index,\n },\n accumulated: {\n ...accumulated,\n args: (accumulated.args ?? \"\") + delta.partial_json,\n },\n };\n\n case \"citations_delta\": {\n const newCitation = delta.citation;\n const existingAnnotations = accumulated.annotations ?? [];\n return {\n deltaBlock: {\n type: \"text\" as const,\n text: \"\",\n annotations: [newCitation],\n index,\n },\n accumulated: {\n ...accumulated,\n annotations: [...existingAnnotations, newCitation],\n },\n };\n }\n\n case \"signature_delta\":\n return {\n deltaBlock: {\n type: \"non_standard\" as const,\n value: { signature: delta.signature },\n index,\n },\n accumulated: {\n ...accumulated,\n signature: delta.signature,\n },\n };\n\n case \"compaction_delta\":\n return {\n deltaBlock: {\n type: \"non_standard\" as const,\n value: { compaction: delta },\n index,\n },\n accumulated: {\n ...accumulated,\n value: {\n ...(accumulated.value ?? {}),\n compaction: delta,\n },\n },\n };\n\n default:\n return {\n deltaBlock: {\n type: \"non_standard\" as const,\n value: delta,\n index,\n },\n accumulated,\n };\n }\n}\n\n/**\n * Finalize an accumulated content block for the content-block-finish event.\n * For tool calls, parse the accumulated JSON args string.\n */\nfunction finalizeBlock(\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n accumulated: Record<string, any>\n): ContentBlock.Standard {\n if (\n accumulated.type === \"tool_call_chunk\" ||\n accumulated.type === \"server_tool_call_chunk\"\n ) {\n const finalType =\n accumulated.type === \"tool_call_chunk\"\n ? (\"tool_call\" as const)\n : (\"server_tool_call\" as const);\n let parsedArgs: unknown;\n try {\n parsedArgs = JSON.parse(accumulated.args || \"{}\");\n } catch {\n return {\n type: \"invalid_tool_call\" as const,\n id: accumulated.id,\n name: accumulated.name,\n args: accumulated.args,\n error: \"Failed to parse tool call arguments as JSON\",\n } as ContentBlock.Tools.InvalidToolCall;\n }\n return {\n type: finalType,\n id: accumulated.id,\n name: accumulated.name,\n args: parsedArgs,\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n } as any;\n }\n\n // Text and reasoning blocks: strip the index for the finalized form\n const { index: _index, ...rest } = accumulated;\n return rest as ContentBlock.Standard;\n}\n"],"mappings":";;;;;;;;;;;;;AA4CA,gBAAuB,uBACrB,QACA,UAAyC,EAAE,EACL;CACtC,MAAM,oBAAoB,QAAQ,eAAe;CAGjD,MAAM,oCAAoB,IAAI,KAO3B;CACH,IAAI;CACJ,IAAI,aAA4B;AAEhC,YAAW,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;IACD;GACD;GACD;;;;;;;AAQP,SAAS,cAEP,aACuB;AACvB,KACE,YAAY,SAAS,qBACrB,YAAY,SAAS,0BACrB;EACA,MAAM,YACJ,YAAY,SAAS,oBAChB,cACA;EACP,IAAI;AACJ,MAAI;AACF,gBAAa,KAAK,MAAM,YAAY,QAAQ,KAAK;UAC3C;AACN,UAAO;IACL,MAAM;IACN,IAAI,YAAY;IAChB,MAAM,YAAY;IAClB,MAAM,YAAY;IAClB,OAAO;IACR;;AAEH,SAAO;GACL,MAAM;GACN,IAAI,YAAY;GAChB,MAAM,YAAY;GAClB,MAAM;GAEP;;CAIH,MAAM,EAAE,OAAO,QAAQ,GAAG,SAAS;AACnC,QAAO"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@langchain/anthropic",
3
- "version": "1.3.26",
3
+ "version": "1.4.0-dev-1775763803878",
4
4
  "description": "Anthropic integrations for LangChain.js",
5
5
  "author": "LangChain",
6
6
  "license": "MIT",
@@ -14,29 +14,26 @@
14
14
  },
15
15
  "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/providers/langchain-anthropic/",
16
16
  "dependencies": {
17
- "@anthropic-ai/sdk": "^0.74.0",
17
+ "@anthropic-ai/sdk": "^0.82.0",
18
18
  "zod": "^3.25.76 || ^4"
19
19
  },
20
20
  "peerDependencies": {
21
- "@langchain/core": "^1.1.38"
21
+ "@langchain/core": "^1.2.0-dev-1775763803878"
22
22
  },
23
23
  "devDependencies": {
24
24
  "@anthropic-ai/vertex-sdk": "^0.14.4",
25
25
  "@cfworker/json-schema": "^4.1.1",
26
26
  "@tsconfig/recommended": "^1.0.10",
27
27
  "@vitest/coverage-v8": "^3.2.4",
28
- "dotenv": "^17.2.1",
28
+ "dotenv": "^17.4.0",
29
29
  "dpdm": "^3.14.0",
30
- "eslint": "^9.34.0",
31
- "prettier": "^3.5.0",
32
30
  "rimraf": "^6.1.3",
33
31
  "typescript": "~5.8.3",
34
32
  "uuid": "^13.0.0",
35
- "vitest": "^3.2.4",
36
- "@langchain/core": "^1.1.38",
37
- "@langchain/eslint": "0.1.1",
38
- "@langchain/standard-tests": "0.0.23",
39
- "@langchain/tsconfig": "0.0.1"
33
+ "vitest": "^4.1.2",
34
+ "@langchain/core": "^1.2.0-dev-1775763803878",
35
+ "@langchain/tsconfig": "0.0.1",
36
+ "@langchain/standard-tests": "0.0.23"
40
37
  },
41
38
  "publishConfig": {
42
39
  "access": "public"
@@ -81,10 +78,6 @@
81
78
  "scripts": {
82
79
  "build": "turbo build:compile --filter @langchain/anthropic --output-logs new-only",
83
80
  "build:compile": "tsdown",
84
- "lint:eslint": "eslint --cache src/",
85
- "lint:dpdm": "dpdm --skip-dynamic-imports circular --exit-code circular:1 --no-warning --no-tree src/*.ts src/**/*.ts",
86
- "lint": "pnpm lint:eslint && pnpm lint:dpdm",
87
- "lint:fix": "pnpm lint:eslint --fix && pnpm lint:dpdm",
88
81
  "clean": "rm -rf .turbo dist/",
89
82
  "test": "vitest run",
90
83
  "test:watch": "vitest",
@@ -92,8 +85,6 @@
92
85
  "test:standard:unit": "vitest run --mode standard-unit",
93
86
  "test:standard:int": "vitest run --mode standard-int",
94
87
  "test:standard": "pnpm test:standard:unit && pnpm test:standard:int",
95
- "format": "prettier --write \"src\"",
96
- "format:check": "prettier --check \"src\"",
97
88
  "typegen": "pnpm run typegen:profiles",
98
89
  "typegen:profiles": "pnpm --filter @langchain/model-profiles make --config profiles.toml"
99
90
  }