Skip to content

feat(deps): migrate LangChain 0.3 → 1.x (backend npm audit: 10 → 0)#140

Merged
recabasic merged 4 commits into
CaviraOSS:mainfrom
tongshu2023:feat/langchain-1x-migration
Jun 10, 2026
Merged

feat(deps): migrate LangChain 0.3 → 1.x (backend npm audit: 10 → 0)#140
recabasic merged 4 commits into
CaviraOSS:mainfrom
tongshu2023:feat/langchain-1x-migration

Conversation

@tongshu2023

Copy link
Copy Markdown
Contributor

Summary

The LangChain 0.3 → 1.x migration promised in #139 — this clears all remaining backend npm audit advisories: 10 → 0 (33 before #139), including the langsmith highs (SSRF, prototype pollution, deserialization).

Stacked on #139 (branched from it, includes its commits). Merge #139 first, then this — or merge this alone and it carries both.

Why the diff is small

The backend's LangChain API surface is narrow, and almost all of it is source-compatible in 1.x:

Usage 0.3 → 1.x
ChatAnthropic / ChatGoogleGenerativeAI / ChatOllama / ChatOpenAI + embeddings unchanged
Document, EmbeddingsInterface (@langchain/core) unchanged
Chroma (@langchain/community/vectorstores/chroma) unchanged
StateGraph + Annotation.Root (@langchain/langgraph) unchanged (Annotation API retained in 1.x)
RecursiveCharacterTextSplitter from langchain/text_splitter @langchain/textsplitters
MemoryVectorStore from langchain/vectorstores/memory @langchain/classic/vectorstores/memory

Two import lines changed; everything else is package.json/lockfile.

Verification

  • npm auditfound 0 vulnerabilities
  • npm run build (tsc) → clean
  • npm test → 15 passed / 3 skipped (the skipped ones are integration tests requiring live API keys)

Note: the chat-model code paths (model factories, examlab langgraph flows) are covered by the unit suite; a quick smoke of a live provider call after merge would be a reasonable extra check since I can't exercise live keys from here.

…->0)

Addresses the automated security audit issues (CaviraOSS#138 and earlier).

Backend (npm audit fix --legacy-peer-deps):
- Clears the critical protobufjs advisory and 4 highs
  (fast-xml-parser/builder, @xmldom/xmldom, underscore chains)
- 33 -> 22 vulnerabilities; tsc build verified clean

Frontend (pnpm update within semver + concurrently 9->10 devDep):
- Clears all 40 advisories including the critical shell-quote one
  (concurrently 9.x pins shell-quote 1.8.3; v10 ships 1.8.4)
- 40 -> 0 vulnerabilities; vite build verified clean

The 22 remaining backend advisories all require maintainer decisions:
- 9 come through @keyv/sqlite -> sqlite3 -> node-gyp/tar (install-time
  toolchain of an unmaintained package)
- 13 require the langchain 0.3 -> 1.x major migration
Plain `npm install` fails with ERESOLVE on the pre-existing openai@6 vs
@browserbasehq/stagehand (peer openai@^4) conflict, which is why the CI
pipeline fails intermittently on main. This makes installs deterministic
for CI and contributors until the conflict is resolved upstream.
…rides

sqlite3@5.1.7 (final release, unmaintained) pulls node-gyp 8.x with
vulnerable tar/cacache/make-fetch-happen. Pinning the toolchain to
current patched versions clears 6 of the 7 remaining high advisories.
tsc build verified; sqlite3 installs via prebuilt binaries so the
node-gyp bump only affects the source-build fallback path.

The last high (langsmith) plus 9 moderates all sit behind the
langchain 0.3 -> 1.x migration and are left for a dedicated PR.
…end advisories

Code changes are minimal because the API surface in use is narrow:
- RecursiveCharacterTextSplitter: langchain/text_splitter -> @langchain/textsplitters
- MemoryVectorStore: langchain/vectorstores/memory -> @langchain/classic/vectorstores/memory
- ChatX constructors, Document, EmbeddingsInterface, Chroma, and
  langgraph StateGraph/Annotation.Root are source-compatible in 1.x

npm audit: 0 vulnerabilities (was 10 after the first round of fixes,
33 originally). tsc build clean; vitest 15 passed / 3 skipped
(integration tests that need API keys).
@recabasic recabasic merged commit ad8f9ae into CaviraOSS:main Jun 10, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants