@langchain/core 1.0.2 → 1.0.4

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 (47) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/agents.d.ts.map +1 -1
  3. package/dist/errors/index.cjs +1 -1
  4. package/dist/errors/index.cjs.map +1 -1
  5. package/dist/errors/index.js +1 -1
  6. package/dist/errors/index.js.map +1 -1
  7. package/dist/language_models/base.cjs +60 -9
  8. package/dist/language_models/base.cjs.map +1 -1
  9. package/dist/language_models/base.d.cts +11 -0
  10. package/dist/language_models/base.d.cts.map +1 -1
  11. package/dist/language_models/base.d.ts +11 -0
  12. package/dist/language_models/base.d.ts.map +1 -1
  13. package/dist/language_models/base.js +60 -9
  14. package/dist/language_models/base.js.map +1 -1
  15. package/dist/load/import_map.cjs +3 -1
  16. package/dist/load/import_map.cjs.map +1 -1
  17. package/dist/load/import_map.js +3 -1
  18. package/dist/load/import_map.js.map +1 -1
  19. package/dist/tools/index.cjs +17 -4
  20. package/dist/tools/index.cjs.map +1 -1
  21. package/dist/tools/index.d.cts +13 -4
  22. package/dist/tools/index.d.cts.map +1 -1
  23. package/dist/tools/index.d.ts +13 -4
  24. package/dist/tools/index.d.ts.map +1 -1
  25. package/dist/tools/index.js +17 -4
  26. package/dist/tools/index.js.map +1 -1
  27. package/dist/tools/types.cjs.map +1 -1
  28. package/dist/tools/types.d.cts +94 -2
  29. package/dist/tools/types.d.cts.map +1 -1
  30. package/dist/tools/types.d.ts +94 -2
  31. package/dist/tools/types.d.ts.map +1 -1
  32. package/dist/tools/types.js.map +1 -1
  33. package/dist/utils/async_caller.cjs +10 -4
  34. package/dist/utils/async_caller.cjs.map +1 -1
  35. package/dist/utils/async_caller.d.cts.map +1 -1
  36. package/dist/utils/async_caller.d.ts.map +1 -1
  37. package/dist/utils/async_caller.js +10 -4
  38. package/dist/utils/async_caller.js.map +1 -1
  39. package/dist/utils/format.cjs +12 -0
  40. package/dist/utils/format.cjs.map +1 -0
  41. package/dist/utils/format.d.cts +58 -0
  42. package/dist/utils/format.d.cts.map +1 -0
  43. package/dist/utils/format.d.ts +58 -0
  44. package/dist/utils/format.d.ts.map +1 -0
  45. package/dist/utils/format.js +6 -0
  46. package/dist/utils/format.js.map +1 -0
  47. package/package.json +12 -1
@@ -0,0 +1,58 @@
1
+ //#region src/utils/format.d.ts
2
+ /**
3
+ * A function that converts data from one format to another.
4
+ *
5
+ * This is commonly used for transforming message content blocks between different
6
+ * provider-specific formats and standardized internal representations.
7
+ *
8
+ * @template T - The input type to convert from
9
+ * @template U - The output type to convert to
10
+ *
11
+ * @param input - The data to convert
12
+ * @returns The converted data in the target format
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * // Convert from OpenAI format to standard format
17
+ * const converter: Converter<OpenAIBlock, ContentBlock.Standard> = (block) => {
18
+ * return { type: "text", text: block.text };
19
+ * };
20
+ * ```
21
+ */
22
+ type Converter<T, U> = (input: T) => U;
23
+ /**
24
+ * A pair of bidirectional conversion functions for transforming data between two formats.
25
+ *
26
+ * This type is used throughout the message system to enable conversion between
27
+ * provider-specific message formats (like OpenAI, Anthropic, Google, etc.) and
28
+ * standardized internal content block representations. The `encode` function
29
+ * typically converts from a standard format to a provider-specific format, while
30
+ * `decode` converts from a provider-specific format back to the standard format.
31
+ *
32
+ * @template T - The first format (typically the standard/internal format)
33
+ * @template U - The second format (typically the provider-specific format)
34
+ *
35
+ * @property encode - Converts from format T to format U
36
+ * @property decode - Converts from format U back to format T
37
+ *
38
+ * @example
39
+ * ```typescript
40
+ * // Converter pair for OpenAI message blocks
41
+ * const openAIConverter: ConverterPair<ContentBlock.Standard, OpenAIBlock> = {
42
+ * encode: (standard) => ({ text: standard.text }),
43
+ * decode: (openai) => ({ type: "text", text: openai.text })
44
+ * };
45
+ *
46
+ * // Usage
47
+ * const standardBlock = { type: "text", text: "Hello" };
48
+ * const openaiBlock = openAIConverter.encode(standardBlock);
49
+ * const backToStandard = openAIConverter.decode(openaiBlock);
50
+ * ```
51
+ */
52
+ type ConverterPair<T, U> = {
53
+ encode: Converter<T, U>;
54
+ decode: Converter<U, T>;
55
+ };
56
+ //#endregion
57
+ export { Converter, ConverterPair };
58
+ //# sourceMappingURL=format.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format.d.cts","names":["Converter","T","U","ConverterPair"],"sources":["../../src/utils/format.d.ts"],"sourcesContent":["/**\n * A function that converts data from one format to another.\n *\n * This is commonly used for transforming message content blocks between different\n * provider-specific formats and standardized internal representations.\n *\n * @template T - The input type to convert from\n * @template U - The output type to convert to\n *\n * @param input - The data to convert\n * @returns The converted data in the target format\n *\n * @example\n * ```typescript\n * // Convert from OpenAI format to standard format\n * const converter: Converter<OpenAIBlock, ContentBlock.Standard> = (block) => {\n * return { type: \"text\", text: block.text };\n * };\n * ```\n */\nexport type Converter<T, U> = (input: T) => U;\n/**\n * A pair of bidirectional conversion functions for transforming data between two formats.\n *\n * This type is used throughout the message system to enable conversion between\n * provider-specific message formats (like OpenAI, Anthropic, Google, etc.) and\n * standardized internal content block representations. The `encode` function\n * typically converts from a standard format to a provider-specific format, while\n * `decode` converts from a provider-specific format back to the standard format.\n *\n * @template T - The first format (typically the standard/internal format)\n * @template U - The second format (typically the provider-specific format)\n *\n * @property encode - Converts from format T to format U\n * @property decode - Converts from format U back to format T\n *\n * @example\n * ```typescript\n * // Converter pair for OpenAI message blocks\n * const openAIConverter: ConverterPair<ContentBlock.Standard, OpenAIBlock> = {\n * encode: (standard) => ({ text: standard.text }),\n * decode: (openai) => ({ type: \"text\", text: openai.text })\n * };\n *\n * // Usage\n * const standardBlock = { type: \"text\", text: \"Hello\" };\n * const openaiBlock = openAIConverter.encode(standardBlock);\n * const backToStandard = openAIConverter.decode(openaiBlock);\n * ```\n */\nexport type ConverterPair<T, U> = {\n encode: Converter<T, U>;\n decode: Converter<U, T>;\n};\n"],"mappings":";;AAoBA;;;;AAA6C;AA8B7C;;;;;;;;AAEqB;;;;;;KAhCTA,0BAA0BC,MAAMC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA8BhCC;UACAH,UAAUC,GAAGC;UACbF,UAAUE,GAAGD"}
@@ -0,0 +1,58 @@
1
+ //#region src/utils/format.d.ts
2
+ /**
3
+ * A function that converts data from one format to another.
4
+ *
5
+ * This is commonly used for transforming message content blocks between different
6
+ * provider-specific formats and standardized internal representations.
7
+ *
8
+ * @template T - The input type to convert from
9
+ * @template U - The output type to convert to
10
+ *
11
+ * @param input - The data to convert
12
+ * @returns The converted data in the target format
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * // Convert from OpenAI format to standard format
17
+ * const converter: Converter<OpenAIBlock, ContentBlock.Standard> = (block) => {
18
+ * return { type: "text", text: block.text };
19
+ * };
20
+ * ```
21
+ */
22
+ type Converter<T, U> = (input: T) => U;
23
+ /**
24
+ * A pair of bidirectional conversion functions for transforming data between two formats.
25
+ *
26
+ * This type is used throughout the message system to enable conversion between
27
+ * provider-specific message formats (like OpenAI, Anthropic, Google, etc.) and
28
+ * standardized internal content block representations. The `encode` function
29
+ * typically converts from a standard format to a provider-specific format, while
30
+ * `decode` converts from a provider-specific format back to the standard format.
31
+ *
32
+ * @template T - The first format (typically the standard/internal format)
33
+ * @template U - The second format (typically the provider-specific format)
34
+ *
35
+ * @property encode - Converts from format T to format U
36
+ * @property decode - Converts from format U back to format T
37
+ *
38
+ * @example
39
+ * ```typescript
40
+ * // Converter pair for OpenAI message blocks
41
+ * const openAIConverter: ConverterPair<ContentBlock.Standard, OpenAIBlock> = {
42
+ * encode: (standard) => ({ text: standard.text }),
43
+ * decode: (openai) => ({ type: "text", text: openai.text })
44
+ * };
45
+ *
46
+ * // Usage
47
+ * const standardBlock = { type: "text", text: "Hello" };
48
+ * const openaiBlock = openAIConverter.encode(standardBlock);
49
+ * const backToStandard = openAIConverter.decode(openaiBlock);
50
+ * ```
51
+ */
52
+ type ConverterPair<T, U> = {
53
+ encode: Converter<T, U>;
54
+ decode: Converter<U, T>;
55
+ };
56
+ //#endregion
57
+ export { Converter, ConverterPair };
58
+ //# sourceMappingURL=format.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format.d.ts","names":["Converter","T","U","ConverterPair"],"sources":["../../src/utils/format.d.ts"],"sourcesContent":["/**\n * A function that converts data from one format to another.\n *\n * This is commonly used for transforming message content blocks between different\n * provider-specific formats and standardized internal representations.\n *\n * @template T - The input type to convert from\n * @template U - The output type to convert to\n *\n * @param input - The data to convert\n * @returns The converted data in the target format\n *\n * @example\n * ```typescript\n * // Convert from OpenAI format to standard format\n * const converter: Converter<OpenAIBlock, ContentBlock.Standard> = (block) => {\n * return { type: \"text\", text: block.text };\n * };\n * ```\n */\nexport type Converter<T, U> = (input: T) => U;\n/**\n * A pair of bidirectional conversion functions for transforming data between two formats.\n *\n * This type is used throughout the message system to enable conversion between\n * provider-specific message formats (like OpenAI, Anthropic, Google, etc.) and\n * standardized internal content block representations. The `encode` function\n * typically converts from a standard format to a provider-specific format, while\n * `decode` converts from a provider-specific format back to the standard format.\n *\n * @template T - The first format (typically the standard/internal format)\n * @template U - The second format (typically the provider-specific format)\n *\n * @property encode - Converts from format T to format U\n * @property decode - Converts from format U back to format T\n *\n * @example\n * ```typescript\n * // Converter pair for OpenAI message blocks\n * const openAIConverter: ConverterPair<ContentBlock.Standard, OpenAIBlock> = {\n * encode: (standard) => ({ text: standard.text }),\n * decode: (openai) => ({ type: \"text\", text: openai.text })\n * };\n *\n * // Usage\n * const standardBlock = { type: \"text\", text: \"Hello\" };\n * const openaiBlock = openAIConverter.encode(standardBlock);\n * const backToStandard = openAIConverter.decode(openaiBlock);\n * ```\n */\nexport type ConverterPair<T, U> = {\n encode: Converter<T, U>;\n decode: Converter<U, T>;\n};\n"],"mappings":";;AAoBA;;;;AAA6C;AA8B7C;;;;;;;;AAEqB;;;;;;KAhCTA,0BAA0BC,MAAMC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA8BhCC;UACAH,UAAUC,GAAGC;UACbF,UAAUE,GAAGD"}
@@ -0,0 +1,6 @@
1
+ //#region src/utils/format.ts
2
+ var format_exports = {};
3
+
4
+ //#endregion
5
+ export { format_exports };
6
+ //# sourceMappingURL=format.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format.js","names":[],"sources":["../../src/utils/format.ts"],"sourcesContent":["/**\n * A function that converts data from one format to another.\n *\n * This is commonly used for transforming message content blocks between different\n * provider-specific formats and standardized internal representations.\n *\n * @template T - The input type to convert from\n * @template U - The output type to convert to\n *\n * @param input - The data to convert\n * @returns The converted data in the target format\n *\n * @example\n * ```typescript\n * // Convert from OpenAI format to standard format\n * const converter: Converter<OpenAIBlock, ContentBlock.Standard> = (block) => {\n * return { type: \"text\", text: block.text };\n * };\n * ```\n */\nexport type Converter<T, U> = (input: T) => U;\n\n/**\n * A pair of bidirectional conversion functions for transforming data between two formats.\n *\n * This type is used throughout the message system to enable conversion between\n * provider-specific message formats (like OpenAI, Anthropic, Google, etc.) and\n * standardized internal content block representations. The `encode` function\n * typically converts from a standard format to a provider-specific format, while\n * `decode` converts from a provider-specific format back to the standard format.\n *\n * @template T - The first format (typically the standard/internal format)\n * @template U - The second format (typically the provider-specific format)\n *\n * @property encode - Converts from format T to format U\n * @property decode - Converts from format U back to format T\n *\n * @example\n * ```typescript\n * // Converter pair for OpenAI message blocks\n * const openAIConverter: ConverterPair<ContentBlock.Standard, OpenAIBlock> = {\n * encode: (standard) => ({ text: standard.text }),\n * decode: (openai) => ({ type: \"text\", text: openai.text })\n * };\n *\n * // Usage\n * const standardBlock = { type: \"text\", text: \"Hello\" };\n * const openaiBlock = openAIConverter.encode(standardBlock);\n * const backToStandard = openAIConverter.decode(openaiBlock);\n * ```\n */\nexport type ConverterPair<T, U> = {\n encode: Converter<T, U>;\n decode: Converter<U, T>;\n};\n"],"mappings":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@langchain/core",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "Core LangChain.js abstractions and schemas",
5
5
  "type": "module",
6
6
  "engines": {
@@ -589,6 +589,17 @@
589
589
  "default": "./dist/utils/event_source_parse.js"
590
590
  }
591
591
  },
592
+ "./utils/format": {
593
+ "input": "./src/utils/format.ts",
594
+ "require": {
595
+ "types": "./dist/utils/format.d.cts",
596
+ "default": "./dist/utils/format.cjs"
597
+ },
598
+ "import": {
599
+ "types": "./dist/utils/format.d.ts",
600
+ "default": "./dist/utils/format.js"
601
+ }
602
+ },
592
603
  "./utils/function_calling": {
593
604
  "input": "./src/utils/function_calling.ts",
594
605
  "require": {