@langchain/core 1.1.44 → 1.1.46

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 (52) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/callbacks/base.d.cts.map +1 -1
  3. package/dist/callbacks/base.d.ts.map +1 -1
  4. package/dist/language_models/base.cjs +1 -1
  5. package/dist/language_models/base.js +1 -1
  6. package/dist/load/index.cjs +19 -0
  7. package/dist/load/index.cjs.map +1 -1
  8. package/dist/load/index.d.cts +4 -0
  9. package/dist/load/index.d.cts.map +1 -1
  10. package/dist/load/index.d.ts +4 -0
  11. package/dist/load/index.d.ts.map +1 -1
  12. package/dist/load/index.js +19 -0
  13. package/dist/load/index.js.map +1 -1
  14. package/dist/load/map_keys.cjs +13 -7
  15. package/dist/load/map_keys.cjs.map +1 -1
  16. package/dist/load/map_keys.d.cts.map +1 -1
  17. package/dist/load/map_keys.d.ts.map +1 -1
  18. package/dist/load/map_keys.js +11 -2
  19. package/dist/load/map_keys.js.map +1 -1
  20. package/dist/messages/base.cjs +10 -0
  21. package/dist/messages/base.cjs.map +1 -1
  22. package/dist/messages/base.d.cts.map +1 -1
  23. package/dist/messages/base.d.ts.map +1 -1
  24. package/dist/messages/base.js +10 -0
  25. package/dist/messages/base.js.map +1 -1
  26. package/dist/runnables/base.cjs +3 -0
  27. package/dist/runnables/base.cjs.map +1 -1
  28. package/dist/runnables/base.d.cts +43 -0
  29. package/dist/runnables/base.d.cts.map +1 -1
  30. package/dist/runnables/base.d.ts +43 -0
  31. package/dist/runnables/base.d.ts.map +1 -1
  32. package/dist/runnables/base.js +3 -0
  33. package/dist/runnables/base.js.map +1 -1
  34. package/dist/runnables/history.cjs +3 -0
  35. package/dist/runnables/history.cjs.map +1 -1
  36. package/dist/runnables/history.d.cts +3 -0
  37. package/dist/runnables/history.d.cts.map +1 -1
  38. package/dist/runnables/history.d.ts +3 -0
  39. package/dist/runnables/history.d.ts.map +1 -1
  40. package/dist/runnables/history.js +3 -0
  41. package/dist/runnables/history.js.map +1 -1
  42. package/dist/tracers/console.cjs +30 -4
  43. package/dist/tracers/console.cjs.map +1 -1
  44. package/dist/tracers/console.d.cts.map +1 -1
  45. package/dist/tracers/console.d.ts.map +1 -1
  46. package/dist/tracers/console.js +28 -1
  47. package/dist/tracers/console.js.map +1 -1
  48. package/dist/utils/env.cjs.map +1 -1
  49. package/dist/utils/env.d.cts.map +1 -1
  50. package/dist/utils/env.d.ts.map +1 -1
  51. package/dist/utils/env.js.map +1 -1
  52. package/package.json +1 -5
package/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # @langchain/core
2
2
 
3
+ ## 1.1.46
4
+
5
+ ### Patch Changes
6
+
7
+ - [#10847](https://github.com/langchain-ai/langchainjs/pull/10847) [`1659e7d`](https://github.com/langchain-ai/langchainjs/commit/1659e7d36e31e315c890fa98f43db887f7a2d52b) Thanks [@hntrl](https://github.com/hntrl)! - chore(core): reduce transitive dependency exposure and tighten release hygiene
8
+
9
+ Remove direct runtime dependencies on `ansi-styles`, `camelcase`, and `decamelize`
10
+ by inlining equivalent logic in core internals, and enable npm provenance in the
11
+ release workflow.
12
+
13
+ - [#10790](https://github.com/langchain-ai/langchainjs/pull/10790) [`ef78bc6`](https://github.com/langchain-ai/langchainjs/commit/ef78bc6a21f9a8808ba95c98db2023f0a6b51bcc) Thanks [@Genmin](https://github.com/Genmin)! - fix(core): keep different content block types separate when merging chunks
14
+
15
+ ## 1.1.45
16
+
17
+ ### Patch Changes
18
+
19
+ - [#10833](https://github.com/langchain-ai/langchainjs/pull/10833) [`6cf39fe`](https://github.com/langchain-ai/langchainjs/commit/6cf39fe9636804f6280db0b98c4a4c72d5b103a0) Thanks [@colifran](https://github.com/colifran)! - chore(core): deprecate streamLog, streamEvents v1, RunnableWithMessageHistory and improve threat model verbiage for loads
20
+
21
+ - [#10835](https://github.com/langchain-ai/langchainjs/pull/10835) [`0aebe50`](https://github.com/langchain-ai/langchainjs/commit/0aebe5054cfb982f09d9775b017317a731b6576f) Thanks [@colifran](https://github.com/colifran)! - fix(core): deno re-declaration in LangSmith is causing unit test failures
22
+
3
23
  ## 1.1.44
4
24
 
5
25
  ### Patch Changes
@@ -1 +1 @@
1
- {"version":3,"file":"base.d.cts","names":[],"sources":["../../src/callbacks/base.ts"],"mappings":";;;;;;;;;;KAqBK,KAAA;;AAJ6D;;;;UAWjD,wBAAA;EACf,SAAA;EACA,WAAA;EACA,WAAA;EACA,eAAA;EACA,iBAAA;EACA,aAAA;EACA,UAAA;AAAA;;;;;UAOe,eAAA;EACf,MAAA;EACA,UAAA;AAAA;AAAA,KAIU,+BAAA;EACV,KAAA,GAAQ,eAAA,GAAkB,mBAAA;AAAA;;;;;;uBAQb,+BAAA;EARgC;;AAC7C;;EAYA,cAAA,CAAA,CACE,GAAA,EAAK,UAAA,EACL,OAAA,YACA,KAAA,UACA,WAAA,WACA,WAAA,GAAc,MAAA,mBACd,IAAA,aACA,QAAA,GAAW,MAAA,mBACX,OAAA;EAEA,OAAA;EALc;;;EAUhB,iBAAA,CAAA,CACE,KAAA;EAWS;;;;;;;EAJT,GAAA,EAAK,eAAA,EACL,KAAA,UACA,WAAA,WACA,IAAA,aACA,MAAA,GAAS,+BAAA;EAET,OAAA;EAiCc;;;EA5BhB,0BAAA,CAAA,CACE,KAAA,EAAO,oBAAA,EACP,KAAA,UACA,WAAA,WACA,IAAA;EAEA,OAAA;EAqCW;;;EAhCb,cAAA,CAAA,CACE,GAAA,EAAK,KAAA,EACL,KAAA,UACA,WAAA,WACA,IAAA,aACA,WAAA,GAAc,MAAA;EAEd,OAAA;EA2CQ;;;EAtCV,YAAA,CAAA,CACE,MAAA,EAAQ,SAAA,EACR,KAAA,UACA,WAAA,WACA,IAAA,aACA,WAAA,GAAc,MAAA;EAEd,OAAA;EAmDS;;;;EA7CX,oBAAA,CAAA,CACE,GAAA,EAAK,UAAA,EACL,QAAA,EAAU,WAAA,MACV,KAAA,UACA,WA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WAAA,WACO,IAAA;IAGpB,OAAA;IA+EO;AAYX;;;qCApFkB,KAAA,UACD,WAAA,WACO,IAAA;IAGpB,OAAA;8BAGY,KAAA,UACC,WAAA,WACO,IAAA,cAEnB,OAAA;IA+E2C;;;;+BAxEpC,WAAA,EAAW,KAAA,UACN,WAAA,WACO,IAAA,cAEnB,OAAA;IAwE0C;;;;4BAjEnC,WAAA,EAAW,KAAA,UACN,WAAA,WACO,IAAA,cAEnB,OAAA;qCAGU,UAAA,EAAU,KAAA,UACR,KAAA,UACA,WAAA,WACO,IAAA,aACL,QAAA,GACJ,MAAA,mBAAuB,IAAA;IAGlC,OAAA;mCAGW,iBAAA,IAAmB,KAAA,UACjB,WAAA,WACO,IAAA;IAGpB,OAAA;+BAGK,KAAA,EAAK,KAAA,UACG,WAAA,WACO,IAAA;IAGpB,OAAA;0CAGiB,IAAA,OAER,KAAA,UACI,IAAA,aACE,QAAA,GAEJ,MAAA;IAEX,OAAA;;;;OA4DmB,GAAA;IAAA;IAAA;OAIG,GAAA;IAAA;IAAA;OAIH,GAAA;IAAA;IAAA;IA5SR;;;IAAA;eAwUF,gBAAA;;;;;;;;YAmCH,mBAAA;cAME,UAAA;4BAIc,wBAAA;EAAA;AAAA;AAAA,cAiBb,qBAAA,GAAqB,CAAA"}
@@ -139,7 +139,7 @@ var BaseLangChain = class extends require_base.Runnable {
139
139
  this.callbacks = params.callbacks;
140
140
  this.tags = params.tags ?? [];
141
141
  this.metadata = params.metadata ?? {};
142
- this._addVersion("@langchain/core", "1.1.44");
142
+ this._addVersion("@langchain/core", "1.1.46");
143
143
  }
144
144
  _addVersion(pkg, version) {
145
145
  const existing = this.metadata?.versions;
@@ -138,7 +138,7 @@ var BaseLangChain = class extends Runnable {
138
138
  this.callbacks = params.callbacks;
139
139
  this.tags = params.tags ?? [];
140
140
  this.metadata = params.metadata ?? {};
141
- this._addVersion("@langchain/core", "1.1.44");
141
+ this._addVersion("@langchain/core", "1.1.46");
142
142
  }
143
143
  _addVersion(pkg, version) {
144
144
  const existing = this.metadata?.versions;
@@ -25,6 +25,21 @@ const require_import_map = require("./import_map.cjs");
25
25
  *
26
26
  * When deserializing, the class path is validated against supported namespaces.
27
27
  *
28
+ * ## Threat model
29
+ *
30
+ * A serialized LangChain payload crosses a trust boundary because the manifest
31
+ * may contain serialized objects and configuration that affect runtime behavior.
32
+ * For example, a payload can configure a chat model with a custom `base_url`,
33
+ * custom headers, a different model name, or other constructor arguments. These
34
+ * are supported features, but they also mean the payload contents should be
35
+ * treated as executable configuration rather than plain text.
36
+ *
37
+ * Concretely, deserialization instantiates classes, so any constructor on an
38
+ * allowed class will run during `load()`. A crafted payload that is allowed to
39
+ * reach an unintended class — or an intended class with attacker-controlled
40
+ * kwargs — could cause network calls, file operations, or environment-variable
41
+ * access while the object is being built.
42
+ *
28
43
  * ## Security model
29
44
  *
30
45
  * The `secretsFromEnv` parameter controls whether secrets can be loaded from environment
@@ -163,6 +178,10 @@ async function reviver(value) {
163
178
  * instantiates arbitrary allowed classes with attacker-controlled arguments,
164
179
  * potentially causing secret exfiltration, SSRF, or other side effects.
165
180
  *
181
+ * A serialized payload should be treated as executable configuration — it can
182
+ * configure models with custom endpoints, headers, or other constructor kwargs
183
+ * that execute during instantiation.
184
+ *
166
185
  * Only call `load()` on data you have produced yourself or received from a
167
186
  * fully trusted origin (e.g., your own database). **Never deserialize
168
187
  * user-supplied or network-received JSON without independent validation.**
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["isEscapedObject","unescapeValue","getEnvironmentVariable","coreImportMap","defaultOptionalImportEntrypoints","optionalImportEntrypoints","get_lc_unique_name","mapKeys","keyFromJson"],"sources":["../../src/load/index.ts"],"sourcesContent":["/**\n * Load LangChain objects from JSON strings or objects.\n *\n * **WARNING: `load()` deserializes data by instantiating classes and invoking\n * constructors. Never call `load()` on untrusted or user-supplied input.**\n * Doing so can lead to insecure deserialization — including arbitrary class\n * instantiation, secret exfiltration, and server-side request forgery (SSRF).\n * Only deserialize data that originates from a trusted source you control.\n *\n * ## How it works\n *\n * Each `Serializable` LangChain object has a unique identifier (its \"class path\"),\n * which is a list of strings representing the module path and class name. For example:\n *\n * - `AIMessage` -> `[\"langchain_core\", \"messages\", \"ai\", \"AIMessage\"]`\n * - `ChatPromptTemplate` -> `[\"langchain_core\", \"prompts\", \"chat\", \"ChatPromptTemplate\"]`\n *\n * When deserializing, the class path is validated against supported namespaces.\n *\n * ## Security model\n *\n * The `secretsFromEnv` parameter controls whether secrets can be loaded from environment\n * variables:\n *\n * - `false` (default): Secrets must be provided in `secretsMap`. If a secret is not\n * found, `null` is returned instead of loading from environment variables.\n * - `true`: If a secret is not found in `secretsMap`, it will be loaded from\n * environment variables. Use this only in trusted environments.\n *\n * ### Hardening recommendations\n *\n * - **Never enable `secretsFromEnv`** unless the serialized data is fully trusted.\n * A crafted payload can reference arbitrary environment variable names, leaking\n * secrets to an attacker-controlled class constructor.\n * - **Keep `secretsMap` minimal.** Only include the specific secrets the serialized\n * object actually needs.\n * - **Keep `importMap` / `optionalImportsMap` as small and static as possible.**\n * Each entry widens the set of classes an attacker can instantiate. Never\n * populate these maps from user input.\n *\n * ### Injection protection (escape-based)\n *\n * During serialization, plain objects that contain an `'lc'` key are escaped by wrapping\n * them: `{\"__lc_escaped__\": {...}}`. During deserialization, escaped objects are unwrapped\n * and returned as plain objects, NOT instantiated as LC objects.\n *\n * This is an allowlist approach: only objects explicitly produced by\n * `Serializable.toJSON()` (which are NOT escaped) are treated as LC objects;\n * everything else is user data.\n *\n * @module\n */\n\nimport {\n Serializable,\n SerializedConstructor,\n SerializedNotImplemented,\n SerializedSecret,\n get_lc_unique_name,\n} from \"./serializable.js\";\nimport { optionalImportEntrypoints as defaultOptionalImportEntrypoints } from \"./import_constants.js\";\nimport * as coreImportMap from \"./import_map.js\";\nimport type { OptionalImportMap, SecretMap } from \"./import_type.js\";\nimport { type SerializedFields, keyFromJson, mapKeys } from \"./map_keys.js\";\nimport { getEnvironmentVariable } from \"../utils/env.js\";\nimport { isEscapedObject, unescapeValue } from \"./validation.js\";\n\n/**\n * Options for loading serialized LangChain objects.\n *\n * @remarks\n * **Security considerations:**\n *\n * Deserialization can instantiate arbitrary classes from the allowed namespaces.\n * When loading untrusted data, be aware that:\n *\n * 1. **`secretsFromEnv`**: Defaults to `false`. Setting to `true` allows the\n * deserializer to read environment variables, which could leak secrets if\n * the serialized data contains malicious secret references.\n *\n * 2. **`importMap` / `optionalImportsMap`**: These allow extending which classes\n * can be instantiated. Never populate these from user input. Only include\n * modules you explicitly trust.\n *\n * 3. **Class instantiation**: Allowed classes will have their constructors called\n * with the deserialized kwargs. If a class performs side effects in its\n * constructor (network calls, file I/O, etc.), those will execute.\n */\nexport interface LoadOptions {\n /**\n * A map of secrets to load. Keys are secret identifiers, values are the secret values.\n *\n * If a secret is not found in this map and `secretsFromEnv` is `false`, an error is\n * thrown. If `secretsFromEnv` is `true`, the secret will be loaded from environment\n * variables (if not found there either, an error is thrown).\n */\n secretsMap?: SecretMap;\n\n /**\n * Whether to load secrets from environment variables when not found in `secretsMap`.\n *\n * @default false\n *\n * @remarks\n * **Security warning:** Setting this to `true` allows the deserializer to read\n * environment variables, which could be a security risk if the serialized data\n * is not trusted. Only set this to `true` when deserializing data from trusted\n * sources (e.g., your own database, not user input).\n */\n secretsFromEnv?: boolean;\n\n /**\n * A map of optional imports. Keys are namespace paths (e.g., \"langchain_community/llms\"),\n * values are the imported modules.\n *\n * @remarks\n * **Security warning:** This extends which classes can be instantiated during\n * deserialization. Never populate this map with values derived from user input.\n * Only include modules that you explicitly trust and have reviewed.\n *\n * Classes in these modules can be instantiated with attacker-controlled kwargs\n * if the serialized data is untrusted.\n */\n optionalImportsMap?: OptionalImportMap;\n\n /**\n * Additional optional import entrypoints to allow beyond the defaults.\n *\n * @remarks\n * **Security warning:** This extends which namespace paths are considered valid\n * for deserialization. Never populate this array with values derived from user\n * input. Each entrypoint you add expands the attack surface for deserialization.\n */\n optionalImportEntrypoints?: string[];\n\n /**\n * Additional import map for the \"langchain\" namespace.\n *\n * @remarks\n * **Security warning:** This extends which classes can be instantiated during\n * deserialization. Never populate this map with values derived from user input.\n * Only include modules that you explicitly trust and have reviewed.\n *\n * Any class exposed through this map can be instantiated with attacker-controlled\n * kwargs if the serialized data is untrusted.\n */\n importMap?: Record<string, unknown>;\n\n /**\n * Maximum recursion depth allowed during deserialization.\n *\n * @default 50\n *\n * @remarks\n * This limit protects against denial-of-service attacks using deeply nested\n * JSON structures that could cause stack overflow. If your legitimate data\n * requires deeper nesting, you can increase this limit.\n */\n maxDepth?: number;\n}\n\n/**\n * Default maximum recursion depth for deserialization.\n * This provides protection against DoS attacks via deeply nested structures.\n */\nconst DEFAULT_MAX_DEPTH = 50;\n\nfunction combineAliasesAndInvert(constructor: typeof Serializable) {\n const aliases: { [key: string]: string } = {};\n for (\n let current = constructor;\n current && current.prototype;\n current = Object.getPrototypeOf(current)\n ) {\n Object.assign(aliases, Reflect.get(current.prototype, \"lc_aliases\"));\n }\n return Object.entries(aliases).reduce(\n (acc, [key, value]) => {\n acc[value] = key;\n return acc;\n },\n {} as Record<string, string>\n );\n}\n\ninterface ReviverContext {\n optionalImportsMap: OptionalImportMap;\n optionalImportEntrypoints: string[];\n secretsMap: SecretMap;\n secretsFromEnv: boolean;\n importMap: Record<string, unknown>;\n path: string[];\n depth: number;\n maxDepth: number;\n}\n\n/**\n * Recursively revive a value, handling escape markers and LC objects.\n *\n * This function handles:\n * 1. Escaped dicts - unwrapped and returned as plain objects\n * 2. LC secret objects - resolved from secretsMap or env\n * 3. LC constructor objects - instantiated\n * 4. Regular objects/arrays - recursed into\n */\nasync function reviver(this: ReviverContext, value: unknown): Promise<unknown> {\n const {\n optionalImportsMap,\n optionalImportEntrypoints,\n importMap,\n secretsMap,\n secretsFromEnv,\n path,\n depth,\n maxDepth,\n } = this;\n const pathStr = path.join(\".\");\n\n // Check recursion depth to prevent DoS via deeply nested structures\n if (depth > maxDepth) {\n throw new Error(\n `Maximum recursion depth (${maxDepth}) exceeded during deserialization. ` +\n `This may indicate a malicious payload or you may need to increase maxDepth.`\n );\n }\n\n // If not an object, return as-is\n if (typeof value !== \"object\" || value == null) {\n return value;\n }\n\n // Handle arrays - recurse into elements\n if (Array.isArray(value)) {\n return Promise.all(\n value.map((v, i) =>\n reviver.call({ ...this, path: [...path, `${i}`], depth: depth + 1 }, v)\n )\n );\n }\n\n // It's an object - check for escape marker FIRST\n const record = value as Record<string, unknown>;\n if (isEscapedObject(record)) {\n // This is an escaped user object - unwrap and return as-is (no LC processing)\n return unescapeValue(record);\n }\n\n // Check for LC secret object\n if (\n \"lc\" in record &&\n \"type\" in record &&\n \"id\" in record &&\n record.lc === 1 &&\n record.type === \"secret\"\n ) {\n const serialized = record as unknown as SerializedSecret;\n const [key] = serialized.id;\n if (key in secretsMap) {\n return secretsMap[key as keyof SecretMap];\n } else if (secretsFromEnv) {\n const secretValueInEnv = getEnvironmentVariable(key);\n if (secretValueInEnv) {\n return secretValueInEnv;\n }\n }\n throw new Error(`Missing secret \"${key}\" at ${pathStr}`);\n }\n\n // Check for LC not_implemented object\n if (\n \"lc\" in record &&\n \"type\" in record &&\n \"id\" in record &&\n record.lc === 1 &&\n record.type === \"not_implemented\"\n ) {\n const serialized = record as unknown as SerializedNotImplemented;\n const str = JSON.stringify(serialized);\n throw new Error(\n `Trying to load an object that doesn't implement serialization: ${pathStr} -> ${str}`\n );\n }\n\n // Check for LC constructor object\n if (\n \"lc\" in record &&\n \"type\" in record &&\n \"id\" in record &&\n \"kwargs\" in record &&\n record.lc === 1 &&\n record.type === \"constructor\"\n ) {\n const serialized = record as unknown as SerializedConstructor;\n const str = JSON.stringify(serialized);\n const [name, ...namespaceReverse] = serialized.id.slice().reverse();\n const namespace = namespaceReverse.reverse();\n const importMaps = { langchain_core: coreImportMap, langchain: importMap };\n\n let module:\n | (typeof importMaps)[\"langchain_core\"][keyof (typeof importMaps)[\"langchain_core\"]]\n | (typeof importMaps)[\"langchain\"][keyof (typeof importMaps)[\"langchain\"]]\n | OptionalImportMap[keyof OptionalImportMap]\n | null = null;\n\n const optionalImportNamespaceAliases = [namespace.join(\"/\")];\n if (namespace[0] === \"langchain_community\") {\n optionalImportNamespaceAliases.push(\n [\"langchain\", ...namespace.slice(1)].join(\"/\")\n );\n }\n const matchingNamespaceAlias = optionalImportNamespaceAliases.find(\n (alias) => alias in optionalImportsMap\n );\n if (\n defaultOptionalImportEntrypoints\n .concat(optionalImportEntrypoints)\n .includes(namespace.join(\"/\")) ||\n matchingNamespaceAlias\n ) {\n if (matchingNamespaceAlias !== undefined) {\n module =\n await optionalImportsMap[\n matchingNamespaceAlias as keyof typeof optionalImportsMap\n ];\n } else {\n throw new Error(\n `Missing key \"${namespace.join(\n \"/\"\n )}\" for ${pathStr} in load(optionalImportsMap={})`\n );\n }\n } else {\n let finalImportMap:\n | (typeof importMaps)[\"langchain\"]\n | (typeof importMaps)[\"langchain_core\"];\n // Currently, we only support langchain and langchain_core imports.\n if (namespace[0] === \"langchain\" || namespace[0] === \"langchain_core\") {\n finalImportMap = importMaps[namespace[0]];\n namespace.shift();\n } else {\n throw new Error(`Invalid namespace: ${pathStr} -> ${str}`);\n }\n\n // The root namespace \"langchain\" is not a valid import.\n if (namespace.length === 0) {\n throw new Error(`Invalid namespace: ${pathStr} -> ${str}`);\n }\n\n // Find the longest matching namespace.\n let importMapKey: string;\n do {\n importMapKey = namespace.join(\"__\");\n if (importMapKey in finalImportMap) {\n break;\n } else {\n namespace.pop();\n }\n } while (namespace.length > 0);\n\n // If no matching namespace is found, throw an error.\n if (importMapKey in finalImportMap) {\n module = finalImportMap[importMapKey as keyof typeof finalImportMap];\n }\n }\n\n if (typeof module !== \"object\" || module === null) {\n throw new Error(`Invalid namespace: ${pathStr} -> ${str}`);\n }\n\n // Extract the builder from the import map.\n const builder =\n // look for a named export with the same name as the class\n module[name as keyof typeof module] ??\n // look for an export with a lc_name property matching the class name\n // this is necessary for classes that are minified\n Object.values(module).find(\n (v) =>\n typeof v === \"function\" &&\n get_lc_unique_name(v as typeof Serializable) === name\n );\n if (typeof builder !== \"function\") {\n throw new Error(`Invalid identifer: ${pathStr} -> ${str}`);\n }\n\n // Recurse on the arguments, which may be serialized objects themselves\n const kwargs = await reviver.call(\n { ...this, path: [...path, \"kwargs\"], depth: depth + 1 },\n serialized.kwargs\n );\n\n // Construct the object\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n const instance = new (builder as any)(\n mapKeys(\n kwargs as SerializedFields,\n keyFromJson,\n combineAliasesAndInvert(builder)\n )\n );\n\n // Minification in severless/edge runtimes will mange the\n // name of classes presented in traces. As the names in import map\n // are present as-is even with minification, use these names instead\n Object.defineProperty(instance.constructor, \"name\", { value: name });\n\n return instance;\n }\n\n // Regular object - recurse into values\n const result: Record<string, unknown> = {};\n for (const [key, val] of Object.entries(record)) {\n result[key] = await reviver.call(\n { ...this, path: [...path, key], depth: depth + 1 },\n val\n );\n }\n return result;\n}\n\n/**\n * Load a LangChain object from a JSON string.\n *\n * **WARNING — insecure deserialization risk.** This function instantiates\n * classes and invokes constructors based on the contents of `text`. If `text`\n * originates from an untrusted source, an attacker can craft a payload that\n * instantiates arbitrary allowed classes with attacker-controlled arguments,\n * potentially causing secret exfiltration, SSRF, or other side effects.\n *\n * Only call `load()` on data you have produced yourself or received from a\n * fully trusted origin (e.g., your own database). **Never deserialize\n * user-supplied or network-received JSON without independent validation.**\n *\n * @param text - The JSON string to parse and load.\n * @param options - Options for loading. See {@link LoadOptions} for security guidance.\n * @returns The loaded LangChain object.\n *\n * @example\n * ```typescript\n * import { load } from \"@langchain/core/load\";\n * import { AIMessage } from \"@langchain/core/messages\";\n *\n * // Basic usage - secrets must be provided explicitly\n * const msg = await load<AIMessage>(jsonString);\n *\n * // With secrets from a map (preferred over secretsFromEnv)\n * const msg = await load<AIMessage>(jsonString, {\n * secretsMap: { OPENAI_API_KEY: \"sk-...\" }\n * });\n *\n * // Allow loading secrets from environment — ONLY for fully trusted data\n * const msg = await load<AIMessage>(jsonString, {\n * secretsFromEnv: true\n * });\n * ```\n */\nexport async function load<T>(text: string, options?: LoadOptions): Promise<T> {\n const json = JSON.parse(text);\n\n const context: ReviverContext = {\n optionalImportsMap: options?.optionalImportsMap ?? {},\n optionalImportEntrypoints: options?.optionalImportEntrypoints ?? [],\n secretsMap: options?.secretsMap ?? {},\n secretsFromEnv: options?.secretsFromEnv ?? false,\n importMap: options?.importMap ?? {},\n path: [\"$\"],\n depth: 0,\n maxDepth: options?.maxDepth ?? DEFAULT_MAX_DEPTH,\n };\n\n return reviver.call(context, json) as Promise<T>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqKA,MAAM,oBAAoB;AAE1B,SAAS,wBAAwB,aAAkC;CACjE,MAAM,UAAqC,EAAE;AAC7C,MACE,IAAI,UAAU,aACd,WAAW,QAAQ,WACnB,UAAU,OAAO,eAAe,QAAQ,CAExC,QAAO,OAAO,SAAS,QAAQ,IAAI,QAAQ,WAAW,aAAa,CAAC;AAEtE,QAAO,OAAO,QAAQ,QAAQ,CAAC,QAC5B,KAAK,CAAC,KAAK,WAAW;AACrB,MAAI,SAAS;AACb,SAAO;IAET,EAAE,CACH;;;;;;;;;;;AAuBH,eAAe,QAA8B,OAAkC;CAC7E,MAAM,EACJ,oBACA,2BAAA,6BACA,WACA,YACA,gBACA,MACA,OACA,aACE;CACJ,MAAM,UAAU,KAAK,KAAK,IAAI;AAG9B,KAAI,QAAQ,SACV,OAAM,IAAI,MACR,4BAA4B,SAAS,gHAEtC;AAIH,KAAI,OAAO,UAAU,YAAY,SAAS,KACxC,QAAO;AAIT,KAAI,MAAM,QAAQ,MAAM,CACtB,QAAO,QAAQ,IACb,MAAM,KAAK,GAAG,MACZ,QAAQ,KAAK;EAAE,GAAG;EAAM,MAAM,CAAC,GAAG,MAAM,GAAG,IAAI;EAAE,OAAO,QAAQ;EAAG,EAAE,EAAE,CACxE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AAG,EACnD,IACD;AAEH,QAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCT,eAAsB,KAAQ,MAAc,SAAmC;CAC7E,MAAM,OAAO,KAAK,MAAM,KAAK;CAE7B,MAAM,UAA0B;EAC9B,oBAAoB,SAAS,sBAAsB,EAAE;EACrD,2BAA2B,SAAS,6BAA6B,EAAE;EACnE,YAAY,SAAS,cAAc,EAAE;EACrC,gBAAgB,SAAS,kBAAkB;EAC3C,WAAW,SAAS,aAAa,EAAE;EACnC,MAAM,CAAC,IAAI;EACX,OAAO;EACP,UAAU,SAAS,YAAY;EAChC;AAED,QAAO,QAAQ,KAAK,SAAS,KAAK"}
1
+ {"version":3,"file":"index.cjs","names":["isEscapedObject","unescapeValue","getEnvironmentVariable","coreImportMap","defaultOptionalImportEntrypoints","optionalImportEntrypoints","get_lc_unique_name","mapKeys","keyFromJson"],"sources":["../../src/load/index.ts"],"sourcesContent":["/**\n * Load LangChain objects from JSON strings or objects.\n *\n * **WARNING: `load()` deserializes data by instantiating classes and invoking\n * constructors. Never call `load()` on untrusted or user-supplied input.**\n * Doing so can lead to insecure deserialization — including arbitrary class\n * instantiation, secret exfiltration, and server-side request forgery (SSRF).\n * Only deserialize data that originates from a trusted source you control.\n *\n * ## How it works\n *\n * Each `Serializable` LangChain object has a unique identifier (its \"class path\"),\n * which is a list of strings representing the module path and class name. For example:\n *\n * - `AIMessage` -> `[\"langchain_core\", \"messages\", \"ai\", \"AIMessage\"]`\n * - `ChatPromptTemplate` -> `[\"langchain_core\", \"prompts\", \"chat\", \"ChatPromptTemplate\"]`\n *\n * When deserializing, the class path is validated against supported namespaces.\n *\n * ## Threat model\n *\n * A serialized LangChain payload crosses a trust boundary because the manifest\n * may contain serialized objects and configuration that affect runtime behavior.\n * For example, a payload can configure a chat model with a custom `base_url`,\n * custom headers, a different model name, or other constructor arguments. These\n * are supported features, but they also mean the payload contents should be\n * treated as executable configuration rather than plain text.\n *\n * Concretely, deserialization instantiates classes, so any constructor on an\n * allowed class will run during `load()`. A crafted payload that is allowed to\n * reach an unintended class — or an intended class with attacker-controlled\n * kwargs — could cause network calls, file operations, or environment-variable\n * access while the object is being built.\n *\n * ## Security model\n *\n * The `secretsFromEnv` parameter controls whether secrets can be loaded from environment\n * variables:\n *\n * - `false` (default): Secrets must be provided in `secretsMap`. If a secret is not\n * found, `null` is returned instead of loading from environment variables.\n * - `true`: If a secret is not found in `secretsMap`, it will be loaded from\n * environment variables. Use this only in trusted environments.\n *\n * ### Hardening recommendations\n *\n * - **Never enable `secretsFromEnv`** unless the serialized data is fully trusted.\n * A crafted payload can reference arbitrary environment variable names, leaking\n * secrets to an attacker-controlled class constructor.\n * - **Keep `secretsMap` minimal.** Only include the specific secrets the serialized\n * object actually needs.\n * - **Keep `importMap` / `optionalImportsMap` as small and static as possible.**\n * Each entry widens the set of classes an attacker can instantiate. Never\n * populate these maps from user input.\n *\n * ### Injection protection (escape-based)\n *\n * During serialization, plain objects that contain an `'lc'` key are escaped by wrapping\n * them: `{\"__lc_escaped__\": {...}}`. During deserialization, escaped objects are unwrapped\n * and returned as plain objects, NOT instantiated as LC objects.\n *\n * This is an allowlist approach: only objects explicitly produced by\n * `Serializable.toJSON()` (which are NOT escaped) are treated as LC objects;\n * everything else is user data.\n *\n * @module\n */\n\nimport {\n Serializable,\n SerializedConstructor,\n SerializedNotImplemented,\n SerializedSecret,\n get_lc_unique_name,\n} from \"./serializable.js\";\nimport { optionalImportEntrypoints as defaultOptionalImportEntrypoints } from \"./import_constants.js\";\nimport * as coreImportMap from \"./import_map.js\";\nimport type { OptionalImportMap, SecretMap } from \"./import_type.js\";\nimport { type SerializedFields, keyFromJson, mapKeys } from \"./map_keys.js\";\nimport { getEnvironmentVariable } from \"../utils/env.js\";\nimport { isEscapedObject, unescapeValue } from \"./validation.js\";\n\n/**\n * Options for loading serialized LangChain objects.\n *\n * @remarks\n * **Security considerations:**\n *\n * Deserialization can instantiate arbitrary classes from the allowed namespaces.\n * When loading untrusted data, be aware that:\n *\n * 1. **`secretsFromEnv`**: Defaults to `false`. Setting to `true` allows the\n * deserializer to read environment variables, which could leak secrets if\n * the serialized data contains malicious secret references.\n *\n * 2. **`importMap` / `optionalImportsMap`**: These allow extending which classes\n * can be instantiated. Never populate these from user input. Only include\n * modules you explicitly trust.\n *\n * 3. **Class instantiation**: Allowed classes will have their constructors called\n * with the deserialized kwargs. If a class performs side effects in its\n * constructor (network calls, file I/O, etc.), those will execute.\n */\nexport interface LoadOptions {\n /**\n * A map of secrets to load. Keys are secret identifiers, values are the secret values.\n *\n * If a secret is not found in this map and `secretsFromEnv` is `false`, an error is\n * thrown. If `secretsFromEnv` is `true`, the secret will be loaded from environment\n * variables (if not found there either, an error is thrown).\n */\n secretsMap?: SecretMap;\n\n /**\n * Whether to load secrets from environment variables when not found in `secretsMap`.\n *\n * @default false\n *\n * @remarks\n * **Security warning:** Setting this to `true` allows the deserializer to read\n * environment variables, which could be a security risk if the serialized data\n * is not trusted. Only set this to `true` when deserializing data from trusted\n * sources (e.g., your own database, not user input).\n */\n secretsFromEnv?: boolean;\n\n /**\n * A map of optional imports. Keys are namespace paths (e.g., \"langchain_community/llms\"),\n * values are the imported modules.\n *\n * @remarks\n * **Security warning:** This extends which classes can be instantiated during\n * deserialization. Never populate this map with values derived from user input.\n * Only include modules that you explicitly trust and have reviewed.\n *\n * Classes in these modules can be instantiated with attacker-controlled kwargs\n * if the serialized data is untrusted.\n */\n optionalImportsMap?: OptionalImportMap;\n\n /**\n * Additional optional import entrypoints to allow beyond the defaults.\n *\n * @remarks\n * **Security warning:** This extends which namespace paths are considered valid\n * for deserialization. Never populate this array with values derived from user\n * input. Each entrypoint you add expands the attack surface for deserialization.\n */\n optionalImportEntrypoints?: string[];\n\n /**\n * Additional import map for the \"langchain\" namespace.\n *\n * @remarks\n * **Security warning:** This extends which classes can be instantiated during\n * deserialization. Never populate this map with values derived from user input.\n * Only include modules that you explicitly trust and have reviewed.\n *\n * Any class exposed through this map can be instantiated with attacker-controlled\n * kwargs if the serialized data is untrusted.\n */\n importMap?: Record<string, unknown>;\n\n /**\n * Maximum recursion depth allowed during deserialization.\n *\n * @default 50\n *\n * @remarks\n * This limit protects against denial-of-service attacks using deeply nested\n * JSON structures that could cause stack overflow. If your legitimate data\n * requires deeper nesting, you can increase this limit.\n */\n maxDepth?: number;\n}\n\n/**\n * Default maximum recursion depth for deserialization.\n * This provides protection against DoS attacks via deeply nested structures.\n */\nconst DEFAULT_MAX_DEPTH = 50;\n\nfunction combineAliasesAndInvert(constructor: typeof Serializable) {\n const aliases: { [key: string]: string } = {};\n for (\n let current = constructor;\n current && current.prototype;\n current = Object.getPrototypeOf(current)\n ) {\n Object.assign(aliases, Reflect.get(current.prototype, \"lc_aliases\"));\n }\n return Object.entries(aliases).reduce(\n (acc, [key, value]) => {\n acc[value] = key;\n return acc;\n },\n {} as Record<string, string>\n );\n}\n\ninterface ReviverContext {\n optionalImportsMap: OptionalImportMap;\n optionalImportEntrypoints: string[];\n secretsMap: SecretMap;\n secretsFromEnv: boolean;\n importMap: Record<string, unknown>;\n path: string[];\n depth: number;\n maxDepth: number;\n}\n\n/**\n * Recursively revive a value, handling escape markers and LC objects.\n *\n * This function handles:\n * 1. Escaped dicts - unwrapped and returned as plain objects\n * 2. LC secret objects - resolved from secretsMap or env\n * 3. LC constructor objects - instantiated\n * 4. Regular objects/arrays - recursed into\n */\nasync function reviver(this: ReviverContext, value: unknown): Promise<unknown> {\n const {\n optionalImportsMap,\n optionalImportEntrypoints,\n importMap,\n secretsMap,\n secretsFromEnv,\n path,\n depth,\n maxDepth,\n } = this;\n const pathStr = path.join(\".\");\n\n // Check recursion depth to prevent DoS via deeply nested structures\n if (depth > maxDepth) {\n throw new Error(\n `Maximum recursion depth (${maxDepth}) exceeded during deserialization. ` +\n `This may indicate a malicious payload or you may need to increase maxDepth.`\n );\n }\n\n // If not an object, return as-is\n if (typeof value !== \"object\" || value == null) {\n return value;\n }\n\n // Handle arrays - recurse into elements\n if (Array.isArray(value)) {\n return Promise.all(\n value.map((v, i) =>\n reviver.call({ ...this, path: [...path, `${i}`], depth: depth + 1 }, v)\n )\n );\n }\n\n // It's an object - check for escape marker FIRST\n const record = value as Record<string, unknown>;\n if (isEscapedObject(record)) {\n // This is an escaped user object - unwrap and return as-is (no LC processing)\n return unescapeValue(record);\n }\n\n // Check for LC secret object\n if (\n \"lc\" in record &&\n \"type\" in record &&\n \"id\" in record &&\n record.lc === 1 &&\n record.type === \"secret\"\n ) {\n const serialized = record as unknown as SerializedSecret;\n const [key] = serialized.id;\n if (key in secretsMap) {\n return secretsMap[key as keyof SecretMap];\n } else if (secretsFromEnv) {\n const secretValueInEnv = getEnvironmentVariable(key);\n if (secretValueInEnv) {\n return secretValueInEnv;\n }\n }\n throw new Error(`Missing secret \"${key}\" at ${pathStr}`);\n }\n\n // Check for LC not_implemented object\n if (\n \"lc\" in record &&\n \"type\" in record &&\n \"id\" in record &&\n record.lc === 1 &&\n record.type === \"not_implemented\"\n ) {\n const serialized = record as unknown as SerializedNotImplemented;\n const str = JSON.stringify(serialized);\n throw new Error(\n `Trying to load an object that doesn't implement serialization: ${pathStr} -> ${str}`\n );\n }\n\n // Check for LC constructor object\n if (\n \"lc\" in record &&\n \"type\" in record &&\n \"id\" in record &&\n \"kwargs\" in record &&\n record.lc === 1 &&\n record.type === \"constructor\"\n ) {\n const serialized = record as unknown as SerializedConstructor;\n const str = JSON.stringify(serialized);\n const [name, ...namespaceReverse] = serialized.id.slice().reverse();\n const namespace = namespaceReverse.reverse();\n const importMaps = { langchain_core: coreImportMap, langchain: importMap };\n\n let module:\n | (typeof importMaps)[\"langchain_core\"][keyof (typeof importMaps)[\"langchain_core\"]]\n | (typeof importMaps)[\"langchain\"][keyof (typeof importMaps)[\"langchain\"]]\n | OptionalImportMap[keyof OptionalImportMap]\n | null = null;\n\n const optionalImportNamespaceAliases = [namespace.join(\"/\")];\n if (namespace[0] === \"langchain_community\") {\n optionalImportNamespaceAliases.push(\n [\"langchain\", ...namespace.slice(1)].join(\"/\")\n );\n }\n const matchingNamespaceAlias = optionalImportNamespaceAliases.find(\n (alias) => alias in optionalImportsMap\n );\n if (\n defaultOptionalImportEntrypoints\n .concat(optionalImportEntrypoints)\n .includes(namespace.join(\"/\")) ||\n matchingNamespaceAlias\n ) {\n if (matchingNamespaceAlias !== undefined) {\n module =\n await optionalImportsMap[\n matchingNamespaceAlias as keyof typeof optionalImportsMap\n ];\n } else {\n throw new Error(\n `Missing key \"${namespace.join(\n \"/\"\n )}\" for ${pathStr} in load(optionalImportsMap={})`\n );\n }\n } else {\n let finalImportMap:\n | (typeof importMaps)[\"langchain\"]\n | (typeof importMaps)[\"langchain_core\"];\n // Currently, we only support langchain and langchain_core imports.\n if (namespace[0] === \"langchain\" || namespace[0] === \"langchain_core\") {\n finalImportMap = importMaps[namespace[0]];\n namespace.shift();\n } else {\n throw new Error(`Invalid namespace: ${pathStr} -> ${str}`);\n }\n\n // The root namespace \"langchain\" is not a valid import.\n if (namespace.length === 0) {\n throw new Error(`Invalid namespace: ${pathStr} -> ${str}`);\n }\n\n // Find the longest matching namespace.\n let importMapKey: string;\n do {\n importMapKey = namespace.join(\"__\");\n if (importMapKey in finalImportMap) {\n break;\n } else {\n namespace.pop();\n }\n } while (namespace.length > 0);\n\n // If no matching namespace is found, throw an error.\n if (importMapKey in finalImportMap) {\n module = finalImportMap[importMapKey as keyof typeof finalImportMap];\n }\n }\n\n if (typeof module !== \"object\" || module === null) {\n throw new Error(`Invalid namespace: ${pathStr} -> ${str}`);\n }\n\n // Extract the builder from the import map.\n const builder =\n // look for a named export with the same name as the class\n module[name as keyof typeof module] ??\n // look for an export with a lc_name property matching the class name\n // this is necessary for classes that are minified\n Object.values(module).find(\n (v) =>\n typeof v === \"function\" &&\n get_lc_unique_name(v as typeof Serializable) === name\n );\n if (typeof builder !== \"function\") {\n throw new Error(`Invalid identifer: ${pathStr} -> ${str}`);\n }\n\n // Recurse on the arguments, which may be serialized objects themselves\n const kwargs = await reviver.call(\n { ...this, path: [...path, \"kwargs\"], depth: depth + 1 },\n serialized.kwargs\n );\n\n // Construct the object\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n const instance = new (builder as any)(\n mapKeys(\n kwargs as SerializedFields,\n keyFromJson,\n combineAliasesAndInvert(builder)\n )\n );\n\n // Minification in severless/edge runtimes will mange the\n // name of classes presented in traces. As the names in import map\n // are present as-is even with minification, use these names instead\n Object.defineProperty(instance.constructor, \"name\", { value: name });\n\n return instance;\n }\n\n // Regular object - recurse into values\n const result: Record<string, unknown> = {};\n for (const [key, val] of Object.entries(record)) {\n result[key] = await reviver.call(\n { ...this, path: [...path, key], depth: depth + 1 },\n val\n );\n }\n return result;\n}\n\n/**\n * Load a LangChain object from a JSON string.\n *\n * **WARNING — insecure deserialization risk.** This function instantiates\n * classes and invokes constructors based on the contents of `text`. If `text`\n * originates from an untrusted source, an attacker can craft a payload that\n * instantiates arbitrary allowed classes with attacker-controlled arguments,\n * potentially causing secret exfiltration, SSRF, or other side effects.\n *\n * A serialized payload should be treated as executable configuration — it can\n * configure models with custom endpoints, headers, or other constructor kwargs\n * that execute during instantiation.\n *\n * Only call `load()` on data you have produced yourself or received from a\n * fully trusted origin (e.g., your own database). **Never deserialize\n * user-supplied or network-received JSON without independent validation.**\n *\n * @param text - The JSON string to parse and load.\n * @param options - Options for loading. See {@link LoadOptions} for security guidance.\n * @returns The loaded LangChain object.\n *\n * @example\n * ```typescript\n * import { load } from \"@langchain/core/load\";\n * import { AIMessage } from \"@langchain/core/messages\";\n *\n * // Basic usage - secrets must be provided explicitly\n * const msg = await load<AIMessage>(jsonString);\n *\n * // With secrets from a map (preferred over secretsFromEnv)\n * const msg = await load<AIMessage>(jsonString, {\n * secretsMap: { OPENAI_API_KEY: \"sk-...\" }\n * });\n *\n * // Allow loading secrets from environment — ONLY for fully trusted data\n * const msg = await load<AIMessage>(jsonString, {\n * secretsFromEnv: true\n * });\n * ```\n */\nexport async function load<T>(text: string, options?: LoadOptions): Promise<T> {\n const json = JSON.parse(text);\n\n const context: ReviverContext = {\n optionalImportsMap: options?.optionalImportsMap ?? {},\n optionalImportEntrypoints: options?.optionalImportEntrypoints ?? [],\n secretsMap: options?.secretsMap ?? {},\n secretsFromEnv: options?.secretsFromEnv ?? false,\n importMap: options?.importMap ?? {},\n path: [\"$\"],\n depth: 0,\n maxDepth: options?.maxDepth ?? DEFAULT_MAX_DEPTH,\n };\n\n return reviver.call(context, json) as Promise<T>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoLA,MAAM,oBAAoB;AAE1B,SAAS,wBAAwB,aAAkC;CACjE,MAAM,UAAqC,EAAE;AAC7C,MACE,IAAI,UAAU,aACd,WAAW,QAAQ,WACnB,UAAU,OAAO,eAAe,QAAQ,CAExC,QAAO,OAAO,SAAS,QAAQ,IAAI,QAAQ,WAAW,aAAa,CAAC;AAEtE,QAAO,OAAO,QAAQ,QAAQ,CAAC,QAC5B,KAAK,CAAC,KAAK,WAAW;AACrB,MAAI,SAAS;AACb,SAAO;IAET,EAAE,CACH;;;;;;;;;;;AAuBH,eAAe,QAA8B,OAAkC;CAC7E,MAAM,EACJ,oBACA,2BAAA,6BACA,WACA,YACA,gBACA,MACA,OACA,aACE;CACJ,MAAM,UAAU,KAAK,KAAK,IAAI;AAG9B,KAAI,QAAQ,SACV,OAAM,IAAI,MACR,4BAA4B,SAAS,gHAEtC;AAIH,KAAI,OAAO,UAAU,YAAY,SAAS,KACxC,QAAO;AAIT,KAAI,MAAM,QAAQ,MAAM,CACtB,QAAO,QAAQ,IACb,MAAM,KAAK,GAAG,MACZ,QAAQ,KAAK;EAAE,GAAG;EAAM,MAAM,CAAC,GAAG,MAAM,GAAG,IAAI;EAAE,OAAO,QAAQ;EAAG,EAAE,EAAE,CACxE,CACF;CAIH,MAAM,SAAS;AACf,KAAIA,mBAAAA,gBA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;;;;;;;;;;;;;;;;;;;;;;;;AA2CT,eAAsB,KAAQ,MAAc,SAAmC;CAC7E,MAAM,OAAO,KAAK,MAAM,KAAK;CAE7B,MAAM,UAA0B;EAC9B,oBAAoB,SAAS,sBAAsB,EAAE;EACrD,2BAA2B,SAAS,6BAA6B,EAAE;EACnE,YAAY,SAAS,cAAc,EAAE;EACrC,gBAAgB,SAAS,kBAAkB;EAC3C,WAAW,SAAS,aAAa,EAAE;EACnC,MAAM,CAAC,IAAI;EACX,OAAO;EACP,UAAU,SAAS,YAAY;EAChC;AAED,QAAO,QAAQ,KAAK,SAAS,KAAK"}
@@ -98,6 +98,10 @@ interface LoadOptions {
98
98
  * instantiates arbitrary allowed classes with attacker-controlled arguments,
99
99
  * potentially causing secret exfiltration, SSRF, or other side effects.
100
100
  *
101
+ * A serialized payload should be treated as executable configuration — it can
102
+ * configure models with custom endpoints, headers, or other constructor kwargs
103
+ * that execute during instantiation.
104
+ *
101
105
  * Only call `load()` on data you have produced yourself or received from a
102
106
  * fully trusted origin (e.g., your own database). **Never deserialize
103
107
  * user-supplied or network-received JSON without independent validation.**
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../../src/load/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;UAwFiB,WAAA;;;;;;;;EAQf,UAAA,GAAa,SAAA;;;;;;;;;;;;EAab,cAAA;;;;;;;;;;;;;EAcA,kBAAA,GAAqB,iBAAA;;;;;;;;;EAUrB,yBAAA;;;;;;;;;;;;EAaA,SAAA,GAAY,MAAA;;;;;;;;;;;EAYZ,QAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAySoB,IAAA,GAAA,CAAQ,IAAA,UAAc,OAAA,GAAU,WAAA,GAAc,OAAA,CAAQ,CAAA"}
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../../src/load/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;UAuGiB,WAAA;;;;;;;;EAQf,UAAA,GAAa,SAAA;;;;;;;;;;;;EAab,cAAA;;;;;;;;;;;;;EAcA,kBAAA,GAAqB,iBAAA;;;;;;;;;EAUrB,yBAAA;;;;;;;;;;;;EAaA,SAAA,GAAY,MAAA;;;;;;;;;;;EAYZ,QAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA6SoB,IAAA,GAAA,CAAQ,IAAA,UAAc,OAAA,GAAU,WAAA,GAAc,OAAA,CAAQ,CAAA"}
@@ -98,6 +98,10 @@ interface LoadOptions {
98
98
  * instantiates arbitrary allowed classes with attacker-controlled arguments,
99
99
  * potentially causing secret exfiltration, SSRF, or other side effects.
100
100
  *
101
+ * A serialized payload should be treated as executable configuration — it can
102
+ * configure models with custom endpoints, headers, or other constructor kwargs
103
+ * that execute during instantiation.
104
+ *
101
105
  * Only call `load()` on data you have produced yourself or received from a
102
106
  * fully trusted origin (e.g., your own database). **Never deserialize
103
107
  * user-supplied or network-received JSON without independent validation.**
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/load/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;UAwFiB,WAAA;;;;;;;;EAQf,UAAA,GAAa,SAAA;;;;;;;;;;;;EAab,cAAA;;;;;;;;;;;;;EAcA,kBAAA,GAAqB,iBAAA;;;;;;;;;EAUrB,yBAAA;;;;;;;;;;;;EAaA,SAAA,GAAY,MAAA;;;;;;;;;;;EAYZ,QAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAySoB,IAAA,GAAA,CAAQ,IAAA,UAAc,OAAA,GAAU,WAAA,GAAc,OAAA,CAAQ,CAAA"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/load/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;UAuGiB,WAAA;;;;;;;;EAQf,UAAA,GAAa,SAAA;;;;;;;;;;;;EAab,cAAA;;;;;;;;;;;;;EAcA,kBAAA,GAAqB,iBAAA;;;;;;;;;EAUrB,yBAAA;;;;;;;;;;;;EAaA,SAAA,GAAY,MAAA;;;;;;;;;;;EAYZ,QAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA6SoB,IAAA,GAAA,CAAQ,IAAA,UAAc,OAAA,GAAU,WAAA,GAAc,OAAA,CAAQ,CAAA"}
@@ -24,6 +24,21 @@ import { import_map_exports } from "./import_map.js";
24
24
  *
25
25
  * When deserializing, the class path is validated against supported namespaces.
26
26
  *
27
+ * ## Threat model
28
+ *
29
+ * A serialized LangChain payload crosses a trust boundary because the manifest
30
+ * may contain serialized objects and configuration that affect runtime behavior.
31
+ * For example, a payload can configure a chat model with a custom `base_url`,
32
+ * custom headers, a different model name, or other constructor arguments. These
33
+ * are supported features, but they also mean the payload contents should be
34
+ * treated as executable configuration rather than plain text.
35
+ *
36
+ * Concretely, deserialization instantiates classes, so any constructor on an
37
+ * allowed class will run during `load()`. A crafted payload that is allowed to
38
+ * reach an unintended class — or an intended class with attacker-controlled
39
+ * kwargs — could cause network calls, file operations, or environment-variable
40
+ * access while the object is being built.
41
+ *
27
42
  * ## Security model
28
43
  *
29
44
  * The `secretsFromEnv` parameter controls whether secrets can be loaded from environment
@@ -162,6 +177,10 @@ async function reviver(value) {
162
177
  * instantiates arbitrary allowed classes with attacker-controlled arguments,
163
178
  * potentially causing secret exfiltration, SSRF, or other side effects.
164
179
  *
180
+ * A serialized payload should be treated as executable configuration — it can
181
+ * configure models with custom endpoints, headers, or other constructor kwargs
182
+ * that execute during instantiation.
183
+ *
165
184
  * Only call `load()` on data you have produced yourself or received from a
166
185
  * fully trusted origin (e.g., your own database). **Never deserialize
167
186
  * user-supplied or network-received JSON without independent validation.**
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["coreImportMap","defaultOptionalImportEntrypoints","optionalImportEntrypoints"],"sources":["../../src/load/index.ts"],"sourcesContent":["/**\n * Load LangChain objects from JSON strings or objects.\n *\n * **WARNING: `load()` deserializes data by instantiating classes and invoking\n * constructors. Never call `load()` on untrusted or user-supplied input.**\n * Doing so can lead to insecure deserialization — including arbitrary class\n * instantiation, secret exfiltration, and server-side request forgery (SSRF).\n * Only deserialize data that originates from a trusted source you control.\n *\n * ## How it works\n *\n * Each `Serializable` LangChain object has a unique identifier (its \"class path\"),\n * which is a list of strings representing the module path and class name. For example:\n *\n * - `AIMessage` -> `[\"langchain_core\", \"messages\", \"ai\", \"AIMessage\"]`\n * - `ChatPromptTemplate` -> `[\"langchain_core\", \"prompts\", \"chat\", \"ChatPromptTemplate\"]`\n *\n * When deserializing, the class path is validated against supported namespaces.\n *\n * ## Security model\n *\n * The `secretsFromEnv` parameter controls whether secrets can be loaded from environment\n * variables:\n *\n * - `false` (default): Secrets must be provided in `secretsMap`. If a secret is not\n * found, `null` is returned instead of loading from environment variables.\n * - `true`: If a secret is not found in `secretsMap`, it will be loaded from\n * environment variables. Use this only in trusted environments.\n *\n * ### Hardening recommendations\n *\n * - **Never enable `secretsFromEnv`** unless the serialized data is fully trusted.\n * A crafted payload can reference arbitrary environment variable names, leaking\n * secrets to an attacker-controlled class constructor.\n * - **Keep `secretsMap` minimal.** Only include the specific secrets the serialized\n * object actually needs.\n * - **Keep `importMap` / `optionalImportsMap` as small and static as possible.**\n * Each entry widens the set of classes an attacker can instantiate. Never\n * populate these maps from user input.\n *\n * ### Injection protection (escape-based)\n *\n * During serialization, plain objects that contain an `'lc'` key are escaped by wrapping\n * them: `{\"__lc_escaped__\": {...}}`. During deserialization, escaped objects are unwrapped\n * and returned as plain objects, NOT instantiated as LC objects.\n *\n * This is an allowlist approach: only objects explicitly produced by\n * `Serializable.toJSON()` (which are NOT escaped) are treated as LC objects;\n * everything else is user data.\n *\n * @module\n */\n\nimport {\n Serializable,\n SerializedConstructor,\n SerializedNotImplemented,\n SerializedSecret,\n get_lc_unique_name,\n} from \"./serializable.js\";\nimport { optionalImportEntrypoints as defaultOptionalImportEntrypoints } from \"./import_constants.js\";\nimport * as coreImportMap from \"./import_map.js\";\nimport type { OptionalImportMap, SecretMap } from \"./import_type.js\";\nimport { type SerializedFields, keyFromJson, mapKeys } from \"./map_keys.js\";\nimport { getEnvironmentVariable } from \"../utils/env.js\";\nimport { isEscapedObject, unescapeValue } from \"./validation.js\";\n\n/**\n * Options for loading serialized LangChain objects.\n *\n * @remarks\n * **Security considerations:**\n *\n * Deserialization can instantiate arbitrary classes from the allowed namespaces.\n * When loading untrusted data, be aware that:\n *\n * 1. **`secretsFromEnv`**: Defaults to `false`. Setting to `true` allows the\n * deserializer to read environment variables, which could leak secrets if\n * the serialized data contains malicious secret references.\n *\n * 2. **`importMap` / `optionalImportsMap`**: These allow extending which classes\n * can be instantiated. Never populate these from user input. Only include\n * modules you explicitly trust.\n *\n * 3. **Class instantiation**: Allowed classes will have their constructors called\n * with the deserialized kwargs. If a class performs side effects in its\n * constructor (network calls, file I/O, etc.), those will execute.\n */\nexport interface LoadOptions {\n /**\n * A map of secrets to load. Keys are secret identifiers, values are the secret values.\n *\n * If a secret is not found in this map and `secretsFromEnv` is `false`, an error is\n * thrown. If `secretsFromEnv` is `true`, the secret will be loaded from environment\n * variables (if not found there either, an error is thrown).\n */\n secretsMap?: SecretMap;\n\n /**\n * Whether to load secrets from environment variables when not found in `secretsMap`.\n *\n * @default false\n *\n * @remarks\n * **Security warning:** Setting this to `true` allows the deserializer to read\n * environment variables, which could be a security risk if the serialized data\n * is not trusted. Only set this to `true` when deserializing data from trusted\n * sources (e.g., your own database, not user input).\n */\n secretsFromEnv?: boolean;\n\n /**\n * A map of optional imports. Keys are namespace paths (e.g., \"langchain_community/llms\"),\n * values are the imported modules.\n *\n * @remarks\n * **Security warning:** This extends which classes can be instantiated during\n * deserialization. Never populate this map with values derived from user input.\n * Only include modules that you explicitly trust and have reviewed.\n *\n * Classes in these modules can be instantiated with attacker-controlled kwargs\n * if the serialized data is untrusted.\n */\n optionalImportsMap?: OptionalImportMap;\n\n /**\n * Additional optional import entrypoints to allow beyond the defaults.\n *\n * @remarks\n * **Security warning:** This extends which namespace paths are considered valid\n * for deserialization. Never populate this array with values derived from user\n * input. Each entrypoint you add expands the attack surface for deserialization.\n */\n optionalImportEntrypoints?: string[];\n\n /**\n * Additional import map for the \"langchain\" namespace.\n *\n * @remarks\n * **Security warning:** This extends which classes can be instantiated during\n * deserialization. Never populate this map with values derived from user input.\n * Only include modules that you explicitly trust and have reviewed.\n *\n * Any class exposed through this map can be instantiated with attacker-controlled\n * kwargs if the serialized data is untrusted.\n */\n importMap?: Record<string, unknown>;\n\n /**\n * Maximum recursion depth allowed during deserialization.\n *\n * @default 50\n *\n * @remarks\n * This limit protects against denial-of-service attacks using deeply nested\n * JSON structures that could cause stack overflow. If your legitimate data\n * requires deeper nesting, you can increase this limit.\n */\n maxDepth?: number;\n}\n\n/**\n * Default maximum recursion depth for deserialization.\n * This provides protection against DoS attacks via deeply nested structures.\n */\nconst DEFAULT_MAX_DEPTH = 50;\n\nfunction combineAliasesAndInvert(constructor: typeof Serializable) {\n const aliases: { [key: string]: string } = {};\n for (\n let current = constructor;\n current && current.prototype;\n current = Object.getPrototypeOf(current)\n ) {\n Object.assign(aliases, Reflect.get(current.prototype, \"lc_aliases\"));\n }\n return Object.entries(aliases).reduce(\n (acc, [key, value]) => {\n acc[value] = key;\n return acc;\n },\n {} as Record<string, string>\n );\n}\n\ninterface ReviverContext {\n optionalImportsMap: OptionalImportMap;\n optionalImportEntrypoints: string[];\n secretsMap: SecretMap;\n secretsFromEnv: boolean;\n importMap: Record<string, unknown>;\n path: string[];\n depth: number;\n maxDepth: number;\n}\n\n/**\n * Recursively revive a value, handling escape markers and LC objects.\n *\n * This function handles:\n * 1. Escaped dicts - unwrapped and returned as plain objects\n * 2. LC secret objects - resolved from secretsMap or env\n * 3. LC constructor objects - instantiated\n * 4. Regular objects/arrays - recursed into\n */\nasync function reviver(this: ReviverContext, value: unknown): Promise<unknown> {\n const {\n optionalImportsMap,\n optionalImportEntrypoints,\n importMap,\n secretsMap,\n secretsFromEnv,\n path,\n depth,\n maxDepth,\n } = this;\n const pathStr = path.join(\".\");\n\n // Check recursion depth to prevent DoS via deeply nested structures\n if (depth > maxDepth) {\n throw new Error(\n `Maximum recursion depth (${maxDepth}) exceeded during deserialization. ` +\n `This may indicate a malicious payload or you may need to increase maxDepth.`\n );\n }\n\n // If not an object, return as-is\n if (typeof value !== \"object\" || value == null) {\n return value;\n }\n\n // Handle arrays - recurse into elements\n if (Array.isArray(value)) {\n return Promise.all(\n value.map((v, i) =>\n reviver.call({ ...this, path: [...path, `${i}`], depth: depth + 1 }, v)\n )\n );\n }\n\n // It's an object - check for escape marker FIRST\n const record = value as Record<string, unknown>;\n if (isEscapedObject(record)) {\n // This is an escaped user object - unwrap and return as-is (no LC processing)\n return unescapeValue(record);\n }\n\n // Check for LC secret object\n if (\n \"lc\" in record &&\n \"type\" in record &&\n \"id\" in record &&\n record.lc === 1 &&\n record.type === \"secret\"\n ) {\n const serialized = record as unknown as SerializedSecret;\n const [key] = serialized.id;\n if (key in secretsMap) {\n return secretsMap[key as keyof SecretMap];\n } else if (secretsFromEnv) {\n const secretValueInEnv = getEnvironmentVariable(key);\n if (secretValueInEnv) {\n return secretValueInEnv;\n }\n }\n throw new Error(`Missing secret \"${key}\" at ${pathStr}`);\n }\n\n // Check for LC not_implemented object\n if (\n \"lc\" in record &&\n \"type\" in record &&\n \"id\" in record &&\n record.lc === 1 &&\n record.type === \"not_implemented\"\n ) {\n const serialized = record as unknown as SerializedNotImplemented;\n const str = JSON.stringify(serialized);\n throw new Error(\n `Trying to load an object that doesn't implement serialization: ${pathStr} -> ${str}`\n );\n }\n\n // Check for LC constructor object\n if (\n \"lc\" in record &&\n \"type\" in record &&\n \"id\" in record &&\n \"kwargs\" in record &&\n record.lc === 1 &&\n record.type === \"constructor\"\n ) {\n const serialized = record as unknown as SerializedConstructor;\n const str = JSON.stringify(serialized);\n const [name, ...namespaceReverse] = serialized.id.slice().reverse();\n const namespace = namespaceReverse.reverse();\n const importMaps = { langchain_core: coreImportMap, langchain: importMap };\n\n let module:\n | (typeof importMaps)[\"langchain_core\"][keyof (typeof importMaps)[\"langchain_core\"]]\n | (typeof importMaps)[\"langchain\"][keyof (typeof importMaps)[\"langchain\"]]\n | OptionalImportMap[keyof OptionalImportMap]\n | null = null;\n\n const optionalImportNamespaceAliases = [namespace.join(\"/\")];\n if (namespace[0] === \"langchain_community\") {\n optionalImportNamespaceAliases.push(\n [\"langchain\", ...namespace.slice(1)].join(\"/\")\n );\n }\n const matchingNamespaceAlias = optionalImportNamespaceAliases.find(\n (alias) => alias in optionalImportsMap\n );\n if (\n defaultOptionalImportEntrypoints\n .concat(optionalImportEntrypoints)\n .includes(namespace.join(\"/\")) ||\n matchingNamespaceAlias\n ) {\n if (matchingNamespaceAlias !== undefined) {\n module =\n await optionalImportsMap[\n matchingNamespaceAlias as keyof typeof optionalImportsMap\n ];\n } else {\n throw new Error(\n `Missing key \"${namespace.join(\n \"/\"\n )}\" for ${pathStr} in load(optionalImportsMap={})`\n );\n }\n } else {\n let finalImportMap:\n | (typeof importMaps)[\"langchain\"]\n | (typeof importMaps)[\"langchain_core\"];\n // Currently, we only support langchain and langchain_core imports.\n if (namespace[0] === \"langchain\" || namespace[0] === \"langchain_core\") {\n finalImportMap = importMaps[namespace[0]];\n namespace.shift();\n } else {\n throw new Error(`Invalid namespace: ${pathStr} -> ${str}`);\n }\n\n // The root namespace \"langchain\" is not a valid import.\n if (namespace.length === 0) {\n throw new Error(`Invalid namespace: ${pathStr} -> ${str}`);\n }\n\n // Find the longest matching namespace.\n let importMapKey: string;\n do {\n importMapKey = namespace.join(\"__\");\n if (importMapKey in finalImportMap) {\n break;\n } else {\n namespace.pop();\n }\n } while (namespace.length > 0);\n\n // If no matching namespace is found, throw an error.\n if (importMapKey in finalImportMap) {\n module = finalImportMap[importMapKey as keyof typeof finalImportMap];\n }\n }\n\n if (typeof module !== \"object\" || module === null) {\n throw new Error(`Invalid namespace: ${pathStr} -> ${str}`);\n }\n\n // Extract the builder from the import map.\n const builder =\n // look for a named export with the same name as the class\n module[name as keyof typeof module] ??\n // look for an export with a lc_name property matching the class name\n // this is necessary for classes that are minified\n Object.values(module).find(\n (v) =>\n typeof v === \"function\" &&\n get_lc_unique_name(v as typeof Serializable) === name\n );\n if (typeof builder !== \"function\") {\n throw new Error(`Invalid identifer: ${pathStr} -> ${str}`);\n }\n\n // Recurse on the arguments, which may be serialized objects themselves\n const kwargs = await reviver.call(\n { ...this, path: [...path, \"kwargs\"], depth: depth + 1 },\n serialized.kwargs\n );\n\n // Construct the object\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n const instance = new (builder as any)(\n mapKeys(\n kwargs as SerializedFields,\n keyFromJson,\n combineAliasesAndInvert(builder)\n )\n );\n\n // Minification in severless/edge runtimes will mange the\n // name of classes presented in traces. As the names in import map\n // are present as-is even with minification, use these names instead\n Object.defineProperty(instance.constructor, \"name\", { value: name });\n\n return instance;\n }\n\n // Regular object - recurse into values\n const result: Record<string, unknown> = {};\n for (const [key, val] of Object.entries(record)) {\n result[key] = await reviver.call(\n { ...this, path: [...path, key], depth: depth + 1 },\n val\n );\n }\n return result;\n}\n\n/**\n * Load a LangChain object from a JSON string.\n *\n * **WARNING — insecure deserialization risk.** This function instantiates\n * classes and invokes constructors based on the contents of `text`. If `text`\n * originates from an untrusted source, an attacker can craft a payload that\n * instantiates arbitrary allowed classes with attacker-controlled arguments,\n * potentially causing secret exfiltration, SSRF, or other side effects.\n *\n * Only call `load()` on data you have produced yourself or received from a\n * fully trusted origin (e.g., your own database). **Never deserialize\n * user-supplied or network-received JSON without independent validation.**\n *\n * @param text - The JSON string to parse and load.\n * @param options - Options for loading. See {@link LoadOptions} for security guidance.\n * @returns The loaded LangChain object.\n *\n * @example\n * ```typescript\n * import { load } from \"@langchain/core/load\";\n * import { AIMessage } from \"@langchain/core/messages\";\n *\n * // Basic usage - secrets must be provided explicitly\n * const msg = await load<AIMessage>(jsonString);\n *\n * // With secrets from a map (preferred over secretsFromEnv)\n * const msg = await load<AIMessage>(jsonString, {\n * secretsMap: { OPENAI_API_KEY: \"sk-...\" }\n * });\n *\n * // Allow loading secrets from environment — ONLY for fully trusted data\n * const msg = await load<AIMessage>(jsonString, {\n * secretsFromEnv: true\n * });\n * ```\n */\nexport async function load<T>(text: string, options?: LoadOptions): Promise<T> {\n const json = JSON.parse(text);\n\n const context: ReviverContext = {\n optionalImportsMap: options?.optionalImportsMap ?? {},\n optionalImportEntrypoints: options?.optionalImportEntrypoints ?? [],\n secretsMap: options?.secretsMap ?? {},\n secretsFromEnv: options?.secretsFromEnv ?? false,\n importMap: options?.importMap ?? {},\n path: [\"$\"],\n depth: 0,\n maxDepth: options?.maxDepth ?? DEFAULT_MAX_DEPTH,\n };\n\n return reviver.call(context, json) as Promise<T>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqKA,MAAM,oBAAoB;AAE1B,SAAS,wBAAwB,aAAkC;CACjE,MAAM,UAAqC,EAAE;AAC7C,MACE,IAAI,UAAU,aACd,WAAW,QAAQ,WACnB,UAAU,OAAO,eAAe,QAAQ,CAExC,QAAO,OAAO,SAAS,QAAQ,IAAI,QAAQ,WAAW,aAAa,CAAC;AAEtE,QAAO,OAAO,QAAQ,QAAQ,CAAC,QAC5B,KAAK,CAAC,KAAK,WAAW;AACrB,MAAI,SAAS;AACb,SAAO;IAET,EAAE,CACH;;;;;;;;;;;AAuBH,eAAe,QAA8B,OAAkC;CAC7E,MAAM,EACJ,oBACA,2BAAA,6BACA,WACA,YACA,gBACA,MACA,OACA,aACE;CACJ,MAAM,UAAU,KAAK,KAAK,IAAI;AAG9B,KAAI,QAAQ,SACV,OAAM,IAAI,MACR,4BAA4B,SAAS,gHAEtC;AAIH,KAAI,OAAO,UAAU,YAAY,SAAS,KACxC,QAAO;AAIT,KAAI,MAAM,QAAQ,MAAM,CACtB,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,KAC1B;EAAE,GAAG;EAAM,MAAM,CAAC,GAAG,MAAM,IAAI;EAAE,OAAO,QAAQ;EAAG,EACnD,IACD;AAEH,QAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCT,eAAsB,KAAQ,MAAc,SAAmC;CAC7E,MAAM,OAAO,KAAK,MAAM,KAAK;CAE7B,MAAM,UAA0B;EAC9B,oBAAoB,SAAS,sBAAsB,EAAE;EACrD,2BAA2B,SAAS,6BAA6B,EAAE;EACnE,YAAY,SAAS,cAAc,EAAE;EACrC,gBAAgB,SAAS,kBAAkB;EAC3C,WAAW,SAAS,aAAa,EAAE;EACnC,MAAM,CAAC,IAAI;EACX,OAAO;EACP,UAAU,SAAS,YAAY;EAChC;AAED,QAAO,QAAQ,KAAK,SAAS,KAAK"}
1
+ {"version":3,"file":"index.js","names":["coreImportMap","defaultOptionalImportEntrypoints","optionalImportEntrypoints"],"sources":["../../src/load/index.ts"],"sourcesContent":["/**\n * Load LangChain objects from JSON strings or objects.\n *\n * **WARNING: `load()` deserializes data by instantiating classes and invoking\n * constructors. Never call `load()` on untrusted or user-supplied input.**\n * Doing so can lead to insecure deserialization — including arbitrary class\n * instantiation, secret exfiltration, and server-side request forgery (SSRF).\n * Only deserialize data that originates from a trusted source you control.\n *\n * ## How it works\n *\n * Each `Serializable` LangChain object has a unique identifier (its \"class path\"),\n * which is a list of strings representing the module path and class name. For example:\n *\n * - `AIMessage` -> `[\"langchain_core\", \"messages\", \"ai\", \"AIMessage\"]`\n * - `ChatPromptTemplate` -> `[\"langchain_core\", \"prompts\", \"chat\", \"ChatPromptTemplate\"]`\n *\n * When deserializing, the class path is validated against supported namespaces.\n *\n * ## Threat model\n *\n * A serialized LangChain payload crosses a trust boundary because the manifest\n * may contain serialized objects and configuration that affect runtime behavior.\n * For example, a payload can configure a chat model with a custom `base_url`,\n * custom headers, a different model name, or other constructor arguments. These\n * are supported features, but they also mean the payload contents should be\n * treated as executable configuration rather than plain text.\n *\n * Concretely, deserialization instantiates classes, so any constructor on an\n * allowed class will run during `load()`. A crafted payload that is allowed to\n * reach an unintended class — or an intended class with attacker-controlled\n * kwargs — could cause network calls, file operations, or environment-variable\n * access while the object is being built.\n *\n * ## Security model\n *\n * The `secretsFromEnv` parameter controls whether secrets can be loaded from environment\n * variables:\n *\n * - `false` (default): Secrets must be provided in `secretsMap`. If a secret is not\n * found, `null` is returned instead of loading from environment variables.\n * - `true`: If a secret is not found in `secretsMap`, it will be loaded from\n * environment variables. Use this only in trusted environments.\n *\n * ### Hardening recommendations\n *\n * - **Never enable `secretsFromEnv`** unless the serialized data is fully trusted.\n * A crafted payload can reference arbitrary environment variable names, leaking\n * secrets to an attacker-controlled class constructor.\n * - **Keep `secretsMap` minimal.** Only include the specific secrets the serialized\n * object actually needs.\n * - **Keep `importMap` / `optionalImportsMap` as small and static as possible.**\n * Each entry widens the set of classes an attacker can instantiate. Never\n * populate these maps from user input.\n *\n * ### Injection protection (escape-based)\n *\n * During serialization, plain objects that contain an `'lc'` key are escaped by wrapping\n * them: `{\"__lc_escaped__\": {...}}`. During deserialization, escaped objects are unwrapped\n * and returned as plain objects, NOT instantiated as LC objects.\n *\n * This is an allowlist approach: only objects explicitly produced by\n * `Serializable.toJSON()` (which are NOT escaped) are treated as LC objects;\n * everything else is user data.\n *\n * @module\n */\n\nimport {\n Serializable,\n SerializedConstructor,\n SerializedNotImplemented,\n SerializedSecret,\n get_lc_unique_name,\n} from \"./serializable.js\";\nimport { optionalImportEntrypoints as defaultOptionalImportEntrypoints } from \"./import_constants.js\";\nimport * as coreImportMap from \"./import_map.js\";\nimport type { OptionalImportMap, SecretMap } from \"./import_type.js\";\nimport { type SerializedFields, keyFromJson, mapKeys } from \"./map_keys.js\";\nimport { getEnvironmentVariable } from \"../utils/env.js\";\nimport { isEscapedObject, unescapeValue } from \"./validation.js\";\n\n/**\n * Options for loading serialized LangChain objects.\n *\n * @remarks\n * **Security considerations:**\n *\n * Deserialization can instantiate arbitrary classes from the allowed namespaces.\n * When loading untrusted data, be aware that:\n *\n * 1. **`secretsFromEnv`**: Defaults to `false`. Setting to `true` allows the\n * deserializer to read environment variables, which could leak secrets if\n * the serialized data contains malicious secret references.\n *\n * 2. **`importMap` / `optionalImportsMap`**: These allow extending which classes\n * can be instantiated. Never populate these from user input. Only include\n * modules you explicitly trust.\n *\n * 3. **Class instantiation**: Allowed classes will have their constructors called\n * with the deserialized kwargs. If a class performs side effects in its\n * constructor (network calls, file I/O, etc.), those will execute.\n */\nexport interface LoadOptions {\n /**\n * A map of secrets to load. Keys are secret identifiers, values are the secret values.\n *\n * If a secret is not found in this map and `secretsFromEnv` is `false`, an error is\n * thrown. If `secretsFromEnv` is `true`, the secret will be loaded from environment\n * variables (if not found there either, an error is thrown).\n */\n secretsMap?: SecretMap;\n\n /**\n * Whether to load secrets from environment variables when not found in `secretsMap`.\n *\n * @default false\n *\n * @remarks\n * **Security warning:** Setting this to `true` allows the deserializer to read\n * environment variables, which could be a security risk if the serialized data\n * is not trusted. Only set this to `true` when deserializing data from trusted\n * sources (e.g., your own database, not user input).\n */\n secretsFromEnv?: boolean;\n\n /**\n * A map of optional imports. Keys are namespace paths (e.g., \"langchain_community/llms\"),\n * values are the imported modules.\n *\n * @remarks\n * **Security warning:** This extends which classes can be instantiated during\n * deserialization. Never populate this map with values derived from user input.\n * Only include modules that you explicitly trust and have reviewed.\n *\n * Classes in these modules can be instantiated with attacker-controlled kwargs\n * if the serialized data is untrusted.\n */\n optionalImportsMap?: OptionalImportMap;\n\n /**\n * Additional optional import entrypoints to allow beyond the defaults.\n *\n * @remarks\n * **Security warning:** This extends which namespace paths are considered valid\n * for deserialization. Never populate this array with values derived from user\n * input. Each entrypoint you add expands the attack surface for deserialization.\n */\n optionalImportEntrypoints?: string[];\n\n /**\n * Additional import map for the \"langchain\" namespace.\n *\n * @remarks\n * **Security warning:** This extends which classes can be instantiated during\n * deserialization. Never populate this map with values derived from user input.\n * Only include modules that you explicitly trust and have reviewed.\n *\n * Any class exposed through this map can be instantiated with attacker-controlled\n * kwargs if the serialized data is untrusted.\n */\n importMap?: Record<string, unknown>;\n\n /**\n * Maximum recursion depth allowed during deserialization.\n *\n * @default 50\n *\n * @remarks\n * This limit protects against denial-of-service attacks using deeply nested\n * JSON structures that could cause stack overflow. If your legitimate data\n * requires deeper nesting, you can increase this limit.\n */\n maxDepth?: number;\n}\n\n/**\n * Default maximum recursion depth for deserialization.\n * This provides protection against DoS attacks via deeply nested structures.\n */\nconst DEFAULT_MAX_DEPTH = 50;\n\nfunction combineAliasesAndInvert(constructor: typeof Serializable) {\n const aliases: { [key: string]: string } = {};\n for (\n let current = constructor;\n current && current.prototype;\n current = Object.getPrototypeOf(current)\n ) {\n Object.assign(aliases, Reflect.get(current.prototype, \"lc_aliases\"));\n }\n return Object.entries(aliases).reduce(\n (acc, [key, value]) => {\n acc[value] = key;\n return acc;\n },\n {} as Record<string, string>\n );\n}\n\ninterface ReviverContext {\n optionalImportsMap: OptionalImportMap;\n optionalImportEntrypoints: string[];\n secretsMap: SecretMap;\n secretsFromEnv: boolean;\n importMap: Record<string, unknown>;\n path: string[];\n depth: number;\n maxDepth: number;\n}\n\n/**\n * Recursively revive a value, handling escape markers and LC objects.\n *\n * This function handles:\n * 1. Escaped dicts - unwrapped and returned as plain objects\n * 2. LC secret objects - resolved from secretsMap or env\n * 3. LC constructor objects - instantiated\n * 4. Regular objects/arrays - recursed into\n */\nasync function reviver(this: ReviverContext, value: unknown): Promise<unknown> {\n const {\n optionalImportsMap,\n optionalImportEntrypoints,\n importMap,\n secretsMap,\n secretsFromEnv,\n path,\n depth,\n maxDepth,\n } = this;\n const pathStr = path.join(\".\");\n\n // Check recursion depth to prevent DoS via deeply nested structures\n if (depth > maxDepth) {\n throw new Error(\n `Maximum recursion depth (${maxDepth}) exceeded during deserialization. ` +\n `This may indicate a malicious payload or you may need to increase maxDepth.`\n );\n }\n\n // If not an object, return as-is\n if (typeof value !== \"object\" || value == null) {\n return value;\n }\n\n // Handle arrays - recurse into elements\n if (Array.isArray(value)) {\n return Promise.all(\n value.map((v, i) =>\n reviver.call({ ...this, path: [...path, `${i}`], depth: depth + 1 }, v)\n )\n );\n }\n\n // It's an object - check for escape marker FIRST\n const record = value as Record<string, unknown>;\n if (isEscapedObject(record)) {\n // This is an escaped user object - unwrap and return as-is (no LC processing)\n return unescapeValue(record);\n }\n\n // Check for LC secret object\n if (\n \"lc\" in record &&\n \"type\" in record &&\n \"id\" in record &&\n record.lc === 1 &&\n record.type === \"secret\"\n ) {\n const serialized = record as unknown as SerializedSecret;\n const [key] = serialized.id;\n if (key in secretsMap) {\n return secretsMap[key as keyof SecretMap];\n } else if (secretsFromEnv) {\n const secretValueInEnv = getEnvironmentVariable(key);\n if (secretValueInEnv) {\n return secretValueInEnv;\n }\n }\n throw new Error(`Missing secret \"${key}\" at ${pathStr}`);\n }\n\n // Check for LC not_implemented object\n if (\n \"lc\" in record &&\n \"type\" in record &&\n \"id\" in record &&\n record.lc === 1 &&\n record.type === \"not_implemented\"\n ) {\n const serialized = record as unknown as SerializedNotImplemented;\n const str = JSON.stringify(serialized);\n throw new Error(\n `Trying to load an object that doesn't implement serialization: ${pathStr} -> ${str}`\n );\n }\n\n // Check for LC constructor object\n if (\n \"lc\" in record &&\n \"type\" in record &&\n \"id\" in record &&\n \"kwargs\" in record &&\n record.lc === 1 &&\n record.type === \"constructor\"\n ) {\n const serialized = record as unknown as SerializedConstructor;\n const str = JSON.stringify(serialized);\n const [name, ...namespaceReverse] = serialized.id.slice().reverse();\n const namespace = namespaceReverse.reverse();\n const importMaps = { langchain_core: coreImportMap, langchain: importMap };\n\n let module:\n | (typeof importMaps)[\"langchain_core\"][keyof (typeof importMaps)[\"langchain_core\"]]\n | (typeof importMaps)[\"langchain\"][keyof (typeof importMaps)[\"langchain\"]]\n | OptionalImportMap[keyof OptionalImportMap]\n | null = null;\n\n const optionalImportNamespaceAliases = [namespace.join(\"/\")];\n if (namespace[0] === \"langchain_community\") {\n optionalImportNamespaceAliases.push(\n [\"langchain\", ...namespace.slice(1)].join(\"/\")\n );\n }\n const matchingNamespaceAlias = optionalImportNamespaceAliases.find(\n (alias) => alias in optionalImportsMap\n );\n if (\n defaultOptionalImportEntrypoints\n .concat(optionalImportEntrypoints)\n .includes(namespace.join(\"/\")) ||\n matchingNamespaceAlias\n ) {\n if (matchingNamespaceAlias !== undefined) {\n module =\n await optionalImportsMap[\n matchingNamespaceAlias as keyof typeof optionalImportsMap\n ];\n } else {\n throw new Error(\n `Missing key \"${namespace.join(\n \"/\"\n )}\" for ${pathStr} in load(optionalImportsMap={})`\n );\n }\n } else {\n let finalImportMap:\n | (typeof importMaps)[\"langchain\"]\n | (typeof importMaps)[\"langchain_core\"];\n // Currently, we only support langchain and langchain_core imports.\n if (namespace[0] === \"langchain\" || namespace[0] === \"langchain_core\") {\n finalImportMap = importMaps[namespace[0]];\n namespace.shift();\n } else {\n throw new Error(`Invalid namespace: ${pathStr} -> ${str}`);\n }\n\n // The root namespace \"langchain\" is not a valid import.\n if (namespace.length === 0) {\n throw new Error(`Invalid namespace: ${pathStr} -> ${str}`);\n }\n\n // Find the longest matching namespace.\n let importMapKey: string;\n do {\n importMapKey = namespace.join(\"__\");\n if (importMapKey in finalImportMap) {\n break;\n } else {\n namespace.pop();\n }\n } while (namespace.length > 0);\n\n // If no matching namespace is found, throw an error.\n if (importMapKey in finalImportMap) {\n module = finalImportMap[importMapKey as keyof typeof finalImportMap];\n }\n }\n\n if (typeof module !== \"object\" || module === null) {\n throw new Error(`Invalid namespace: ${pathStr} -> ${str}`);\n }\n\n // Extract the builder from the import map.\n const builder =\n // look for a named export with the same name as the class\n module[name as keyof typeof module] ??\n // look for an export with a lc_name property matching the class name\n // this is necessary for classes that are minified\n Object.values(module).find(\n (v) =>\n typeof v === \"function\" &&\n get_lc_unique_name(v as typeof Serializable) === name\n );\n if (typeof builder !== \"function\") {\n throw new Error(`Invalid identifer: ${pathStr} -> ${str}`);\n }\n\n // Recurse on the arguments, which may be serialized objects themselves\n const kwargs = await reviver.call(\n { ...this, path: [...path, \"kwargs\"], depth: depth + 1 },\n serialized.kwargs\n );\n\n // Construct the object\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n const instance = new (builder as any)(\n mapKeys(\n kwargs as SerializedFields,\n keyFromJson,\n combineAliasesAndInvert(builder)\n )\n );\n\n // Minification in severless/edge runtimes will mange the\n // name of classes presented in traces. As the names in import map\n // are present as-is even with minification, use these names instead\n Object.defineProperty(instance.constructor, \"name\", { value: name });\n\n return instance;\n }\n\n // Regular object - recurse into values\n const result: Record<string, unknown> = {};\n for (const [key, val] of Object.entries(record)) {\n result[key] = await reviver.call(\n { ...this, path: [...path, key], depth: depth + 1 },\n val\n );\n }\n return result;\n}\n\n/**\n * Load a LangChain object from a JSON string.\n *\n * **WARNING — insecure deserialization risk.** This function instantiates\n * classes and invokes constructors based on the contents of `text`. If `text`\n * originates from an untrusted source, an attacker can craft a payload that\n * instantiates arbitrary allowed classes with attacker-controlled arguments,\n * potentially causing secret exfiltration, SSRF, or other side effects.\n *\n * A serialized payload should be treated as executable configuration — it can\n * configure models with custom endpoints, headers, or other constructor kwargs\n * that execute during instantiation.\n *\n * Only call `load()` on data you have produced yourself or received from a\n * fully trusted origin (e.g., your own database). **Never deserialize\n * user-supplied or network-received JSON without independent validation.**\n *\n * @param text - The JSON string to parse and load.\n * @param options - Options for loading. See {@link LoadOptions} for security guidance.\n * @returns The loaded LangChain object.\n *\n * @example\n * ```typescript\n * import { load } from \"@langchain/core/load\";\n * import { AIMessage } from \"@langchain/core/messages\";\n *\n * // Basic usage - secrets must be provided explicitly\n * const msg = await load<AIMessage>(jsonString);\n *\n * // With secrets from a map (preferred over secretsFromEnv)\n * const msg = await load<AIMessage>(jsonString, {\n * secretsMap: { OPENAI_API_KEY: \"sk-...\" }\n * });\n *\n * // Allow loading secrets from environment — ONLY for fully trusted data\n * const msg = await load<AIMessage>(jsonString, {\n * secretsFromEnv: true\n * });\n * ```\n */\nexport async function load<T>(text: string, options?: LoadOptions): Promise<T> {\n const json = JSON.parse(text);\n\n const context: ReviverContext = {\n optionalImportsMap: options?.optionalImportsMap ?? {},\n optionalImportEntrypoints: options?.optionalImportEntrypoints ?? [],\n secretsMap: options?.secretsMap ?? {},\n secretsFromEnv: options?.secretsFromEnv ?? false,\n importMap: options?.importMap ?? {},\n path: [\"$\"],\n depth: 0,\n maxDepth: options?.maxDepth ?? DEFAULT_MAX_DEPTH,\n };\n\n return reviver.call(context, json) as Promise<T>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoLA,MAAM,oBAAoB;AAE1B,SAAS,wBAAwB,aAAkC;CACjE,MAAM,UAAqC,EAAE;AAC7C,MACE,IAAI,UAAU,aACd,WAAW,QAAQ,WACnB,UAAU,OAAO,eAAe,QAAQ,CAExC,QAAO,OAAO,SAAS,QAAQ,IAAI,QAAQ,WAAW,aAAa,CAAC;AAEtE,QAAO,OAAO,QAAQ,QAAQ,CAAC,QAC5B,KAAK,CAAC,KAAK,WAAW;AACrB,MAAI,SAAS;AACb,SAAO;IAET,EAAE,CACH;;;;;;;;;;;AAuBH,eAAe,QAA8B,OAAkC;CAC7E,MAAM,EACJ,oBACA,2BAAA,6BACA,WACA,YACA,gBACA,MACA,OACA,aACE;CACJ,MAAM,UAAU,KAAK,KAAK,IAAI;AAG9B,KAAI,QAAQ,SACV,OAAM,IAAI,MACR,4BAA4B,SAAS,gHAEtC;AAIH,KAAI,OAAO,UAAU,YAAY,SAAS,KACxC,QAAO;AAIT,KAAI,MAAM,QAAQ,MAAM,CACtB,QAAO,QAAQ,IACb,MAAM,KAAK,GAAG,MACZ,QAAQ,KAAK;EAAE,GAAG;EAAM,MAAM,CAAC,GAAG,MAAM,GAAG,IAAI;EAAE,OAAO,QAAQ;EAAG,EAAE,EAAE,CACxE,CACF;CAIH,MAAM,SAAS;AACf,KAAI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mC;CAC7E,MAAM,OAAO,KAAK,MAAM,KAAK;CAE7B,MAAM,UAA0B;EAC9B,oBAAoB,SAAS,sBAAsB,EAAE;EACrD,2BAA2B,SAAS,6BAA6B,EAAE;EACnE,YAAY,SAAS,cAAc,EAAE;EACrC,gBAAgB,SAAS,kBAAkB;EAC3C,WAAW,SAAS,aAAa,EAAE;EACnC,MAAM,CAAC,IAAI;EACX,OAAO;EACP,UAAU,SAAS,YAAY;EAChC;AAED,QAAO,QAAQ,KAAK,SAAS,KAAK"}
@@ -1,14 +1,20 @@
1
- const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
2
- let decamelize = require("decamelize");
3
- decamelize = require_runtime.__toESM(decamelize, 1);
4
- let camelcase = require("camelcase");
5
- camelcase = require_runtime.__toESM(camelcase, 1);
6
1
  //#region src/load/map_keys.ts
2
+ const UPPER_TO_WORD_BOUNDARY = /([A-Z]+)([A-Z][a-z0-9]+)/g;
3
+ const LOWER_TO_UPPER_BOUNDARY = /([a-z0-9])([A-Z])/g;
4
+ const SEPARATORS = /[-_\s]+/g;
5
+ function snakeCase(key) {
6
+ return key.replace(UPPER_TO_WORD_BOUNDARY, "$1_$2").replace(LOWER_TO_UPPER_BOUNDARY, "$1_$2").replace(SEPARATORS, "_").toLowerCase();
7
+ }
8
+ function camelCase(key) {
9
+ const trimmed = key.trim();
10
+ if (!/[-_\s]/.test(trimmed)) return trimmed;
11
+ return trimmed.replace(SEPARATORS, "_").toLowerCase().replace(/_+([a-z0-9])/g, (_, char) => char.toUpperCase());
12
+ }
7
13
  function keyToJson(key, map) {
8
- return map?.[key] || (0, decamelize.default)(key);
14
+ return map?.[key] || snakeCase(key);
9
15
  }
10
16
  function keyFromJson(key, map) {
11
- return map?.[key] || (0, camelcase.default)(key);
17
+ return map?.[key] || camelCase(key);
12
18
  }
13
19
  function mapKeys(fields, mapper, map) {
14
20
  const mapped = {};
@@ -1 +1 @@
1
- {"version":3,"file":"map_keys.cjs","names":[],"sources":["../../src/load/map_keys.ts"],"sourcesContent":["import snakeCase from \"decamelize\";\nimport camelCase from \"camelcase\";\n\nexport interface SerializedFields {\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n [key: string]: any;\n}\n\nexport interface SerializedKeyAlias {\n [key: string]: string;\n}\n\nexport function keyToJson(key: string, map?: SerializedKeyAlias): string {\n return map?.[key] || snakeCase(key);\n}\n\nexport function keyFromJson(key: string, map?: SerializedKeyAlias): string {\n return map?.[key] || camelCase(key);\n}\n\nexport function mapKeys(\n fields: SerializedFields,\n mapper: typeof keyToJson,\n map?: SerializedKeyAlias\n): SerializedFields {\n const mapped: SerializedFields = {};\n\n for (const key in fields) {\n if (Object.hasOwn(fields, key)) {\n mapped[mapper(key, map)] = fields[key];\n }\n }\n\n return mapped;\n}\n"],"mappings":";;;;;;AAYA,SAAgB,UAAU,KAAa,KAAkC;AACvE,QAAO,MAAM,SAAA,GAAA,WAAA,SAAkB,IAAI;;AAGrC,SAAgB,YAAY,KAAa,KAAkC;AACzE,QAAO,MAAM,SAAA,GAAA,UAAA,SAAkB,IAAI;;AAGrC,SAAgB,QACd,QACA,QACA,KACkB;CAClB,MAAM,SAA2B,EAAE;AAEnC,MAAK,MAAM,OAAO,OAChB,KAAI,OAAO,OAAO,QAAQ,IAAI,CAC5B,QAAO,OAAO,KAAK,IAAI,IAAI,OAAO;AAItC,QAAO"}
1
+ {"version":3,"file":"map_keys.cjs","names":[],"sources":["../../src/load/map_keys.ts"],"sourcesContent":["const UPPER_TO_WORD_BOUNDARY = /([A-Z]+)([A-Z][a-z0-9]+)/g;\nconst LOWER_TO_UPPER_BOUNDARY = /([a-z0-9])([A-Z])/g;\nconst SEPARATORS = /[-_\\s]+/g;\n\nfunction snakeCase(key: string): string {\n return key\n .replace(UPPER_TO_WORD_BOUNDARY, \"$1_$2\")\n .replace(LOWER_TO_UPPER_BOUNDARY, \"$1_$2\")\n .replace(SEPARATORS, \"_\")\n .toLowerCase();\n}\n\nfunction camelCase(key: string): string {\n const trimmed = key.trim();\n if (!/[-_\\s]/.test(trimmed)) {\n return trimmed;\n }\n return trimmed\n .replace(SEPARATORS, \"_\")\n .toLowerCase()\n .replace(/_+([a-z0-9])/g, (_, char: string) => char.toUpperCase());\n}\n\nexport interface SerializedFields {\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n [key: string]: any;\n}\n\nexport interface SerializedKeyAlias {\n [key: string]: string;\n}\n\nexport function keyToJson(key: string, map?: SerializedKeyAlias): string {\n return map?.[key] || snakeCase(key);\n}\n\nexport function keyFromJson(key: string, map?: SerializedKeyAlias): string {\n return map?.[key] || camelCase(key);\n}\n\nexport function mapKeys(\n fields: SerializedFields,\n mapper: typeof keyToJson,\n map?: SerializedKeyAlias\n): SerializedFields {\n const mapped: SerializedFields = {};\n\n for (const key in fields) {\n if (Object.hasOwn(fields, key)) {\n mapped[mapper(key, map)] = fields[key];\n }\n }\n\n return mapped;\n}\n"],"mappings":";AAAA,MAAM,yBAAyB;AAC/B,MAAM,0BAA0B;AAChC,MAAM,aAAa;AAEnB,SAAS,UAAU,KAAqB;AACtC,QAAO,IACJ,QAAQ,wBAAwB,QAAQ,CACxC,QAAQ,yBAAyB,QAAQ,CACzC,QAAQ,YAAY,IAAI,CACxB,aAAa;;AAGlB,SAAS,UAAU,KAAqB;CACtC,MAAM,UAAU,IAAI,MAAM;AAC1B,KAAI,CAAC,SAAS,KAAK,QAAQ,CACzB,QAAO;AAET,QAAO,QACJ,QAAQ,YAAY,IAAI,CACxB,aAAa,CACb,QAAQ,kBAAkB,GAAG,SAAiB,KAAK,aAAa,CAAC;;AAYtE,SAAgB,UAAU,KAAa,KAAkC;AACvE,QAAO,MAAM,QAAQ,UAAU,IAAI;;AAGrC,SAAgB,YAAY,KAAa,KAAkC;AACzE,QAAO,MAAM,QAAQ,UAAU,IAAI;;AAGrC,SAAgB,QACd,QACA,QACA,KACkB;CAClB,MAAM,SAA2B,EAAE;AAEnC,MAAK,MAAM,OAAO,OAChB,KAAI,OAAO,OAAO,QAAQ,IAAI,CAC5B,QAAO,OAAO,KAAK,IAAI,IAAI,OAAO;AAItC,QAAO"}
@@ -1 +1 @@
1
- {"version":3,"file":"map_keys.d.cts","names":[],"sources":["../../src/load/map_keys.ts"],"mappings":";UAGiB,gBAAA;EAAA,CAEd,GAAA;AAAA"}
1
+ {"version":3,"file":"map_keys.d.cts","names":[],"sources":["../../src/load/map_keys.ts"],"mappings":";UAuBiB,gBAAA;EAAA,CAEd,GAAA;AAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"map_keys.d.ts","names":[],"sources":["../../src/load/map_keys.ts"],"mappings":";UAGiB,gBAAA;EAAA,CAEd,GAAA;AAAA"}
1
+ {"version":3,"file":"map_keys.d.ts","names":[],"sources":["../../src/load/map_keys.ts"],"mappings":";UAuBiB,gBAAA;EAAA,CAEd,GAAA;AAAA"}
@@ -1,6 +1,15 @@
1
- import snakeCase from "decamelize";
2
- import camelCase from "camelcase";
3
1
  //#region src/load/map_keys.ts
2
+ const UPPER_TO_WORD_BOUNDARY = /([A-Z]+)([A-Z][a-z0-9]+)/g;
3
+ const LOWER_TO_UPPER_BOUNDARY = /([a-z0-9])([A-Z])/g;
4
+ const SEPARATORS = /[-_\s]+/g;
5
+ function snakeCase(key) {
6
+ return key.replace(UPPER_TO_WORD_BOUNDARY, "$1_$2").replace(LOWER_TO_UPPER_BOUNDARY, "$1_$2").replace(SEPARATORS, "_").toLowerCase();
7
+ }
8
+ function camelCase(key) {
9
+ const trimmed = key.trim();
10
+ if (!/[-_\s]/.test(trimmed)) return trimmed;
11
+ return trimmed.replace(SEPARATORS, "_").toLowerCase().replace(/_+([a-z0-9])/g, (_, char) => char.toUpperCase());
12
+ }
4
13
  function keyToJson(key, map) {
5
14
  return map?.[key] || snakeCase(key);
6
15
  }
@@ -1 +1 @@
1
- {"version":3,"file":"map_keys.js","names":[],"sources":["../../src/load/map_keys.ts"],"sourcesContent":["import snakeCase from \"decamelize\";\nimport camelCase from \"camelcase\";\n\nexport interface SerializedFields {\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n [key: string]: any;\n}\n\nexport interface SerializedKeyAlias {\n [key: string]: string;\n}\n\nexport function keyToJson(key: string, map?: SerializedKeyAlias): string {\n return map?.[key] || snakeCase(key);\n}\n\nexport function keyFromJson(key: string, map?: SerializedKeyAlias): string {\n return map?.[key] || camelCase(key);\n}\n\nexport function mapKeys(\n fields: SerializedFields,\n mapper: typeof keyToJson,\n map?: SerializedKeyAlias\n): SerializedFields {\n const mapped: SerializedFields = {};\n\n for (const key in fields) {\n if (Object.hasOwn(fields, key)) {\n mapped[mapper(key, map)] = fields[key];\n }\n }\n\n return mapped;\n}\n"],"mappings":";;;AAYA,SAAgB,UAAU,KAAa,KAAkC;AACvE,QAAO,MAAM,QAAQ,UAAU,IAAI;;AAGrC,SAAgB,YAAY,KAAa,KAAkC;AACzE,QAAO,MAAM,QAAQ,UAAU,IAAI;;AAGrC,SAAgB,QACd,QACA,QACA,KACkB;CAClB,MAAM,SAA2B,EAAE;AAEnC,MAAK,MAAM,OAAO,OAChB,KAAI,OAAO,OAAO,QAAQ,IAAI,CAC5B,QAAO,OAAO,KAAK,IAAI,IAAI,OAAO;AAItC,QAAO"}
1
+ {"version":3,"file":"map_keys.js","names":[],"sources":["../../src/load/map_keys.ts"],"sourcesContent":["const UPPER_TO_WORD_BOUNDARY = /([A-Z]+)([A-Z][a-z0-9]+)/g;\nconst LOWER_TO_UPPER_BOUNDARY = /([a-z0-9])([A-Z])/g;\nconst SEPARATORS = /[-_\\s]+/g;\n\nfunction snakeCase(key: string): string {\n return key\n .replace(UPPER_TO_WORD_BOUNDARY, \"$1_$2\")\n .replace(LOWER_TO_UPPER_BOUNDARY, \"$1_$2\")\n .replace(SEPARATORS, \"_\")\n .toLowerCase();\n}\n\nfunction camelCase(key: string): string {\n const trimmed = key.trim();\n if (!/[-_\\s]/.test(trimmed)) {\n return trimmed;\n }\n return trimmed\n .replace(SEPARATORS, \"_\")\n .toLowerCase()\n .replace(/_+([a-z0-9])/g, (_, char: string) => char.toUpperCase());\n}\n\nexport interface SerializedFields {\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n [key: string]: any;\n}\n\nexport interface SerializedKeyAlias {\n [key: string]: string;\n}\n\nexport function keyToJson(key: string, map?: SerializedKeyAlias): string {\n return map?.[key] || snakeCase(key);\n}\n\nexport function keyFromJson(key: string, map?: SerializedKeyAlias): string {\n return map?.[key] || camelCase(key);\n}\n\nexport function mapKeys(\n fields: SerializedFields,\n mapper: typeof keyToJson,\n map?: SerializedKeyAlias\n): SerializedFields {\n const mapped: SerializedFields = {};\n\n for (const key in fields) {\n if (Object.hasOwn(fields, key)) {\n mapped[mapper(key, map)] = fields[key];\n }\n }\n\n return mapped;\n}\n"],"mappings":";AAAA,MAAM,yBAAyB;AAC/B,MAAM,0BAA0B;AAChC,MAAM,aAAa;AAEnB,SAAS,UAAU,KAAqB;AACtC,QAAO,IACJ,QAAQ,wBAAwB,QAAQ,CACxC,QAAQ,yBAAyB,QAAQ,CACzC,QAAQ,YAAY,IAAI,CACxB,aAAa;;AAGlB,SAAS,UAAU,KAAqB;CACtC,MAAM,UAAU,IAAI,MAAM;AAC1B,KAAI,CAAC,SAAS,KAAK,QAAQ,CACzB,QAAO;AAET,QAAO,QACJ,QAAQ,YAAY,IAAI,CACxB,aAAa,CACb,QAAQ,kBAAkB,GAAG,SAAiB,KAAK,aAAa,CAAC;;AAYtE,SAAgB,UAAU,KAAa,KAAkC;AACvE,QAAO,MAAM,QAAQ,UAAU,IAAI;;AAGrC,SAAgB,YAAY,KAAa,KAAkC;AACzE,QAAO,MAAM,QAAQ,UAAU,IAAI;;AAGrC,SAAgB,QACd,QACA,QACA,KACkB;CAClB,MAAM,SAA2B,EAAE;AAEnC,MAAK,MAAM,OAAO,OAChB,KAAI,OAAO,OAAO,QAAQ,IAAI,CAC5B,QAAO,OAAO,KAAK,IAAI,IAAI,OAAO;AAItC,QAAO"}
@@ -254,6 +254,15 @@ function hasMergeableId(value) {
254
254
  const id = value.id;
255
255
  return id != null && id !== "";
256
256
  }
257
+ function getMergeableTypeBase(type) {
258
+ return type.endsWith("_delta") ? type.slice(0, -6) : type;
259
+ }
260
+ function hasMismatchedMergeableType(left, right) {
261
+ if (typeof left !== "object" || left === null) return false;
262
+ if (typeof right !== "object" || right === null) return false;
263
+ if (!("type" in left) || !("type" in right)) return false;
264
+ return typeof left.type === "string" && typeof right.type === "string" && getMergeableTypeBase(left.type) !== getMergeableTypeBase(right.type);
265
+ }
257
266
  /**
258
267
  * Find the index of an existing item in `merged` that should be merged with
259
268
  * `item`, based on index and/or id matching.
@@ -272,6 +281,7 @@ function _findMergeTarget(merged, item) {
272
281
  const leftHasId = hasMergeableId(leftItem);
273
282
  if (itemHasIndex && leftHasIndex) {
274
283
  if (!(leftItem.index === item.index)) return false;
284
+ if (hasMismatchedMergeableType(leftItem, item)) return false;
275
285
  if (leftHasId && itemHasId) return leftItem.id === item.id;
276
286
  return true;
277
287
  }