Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
fix(deps): strip Claude Agent SDK binaries via ignoredOptionalDependencies
Elian Doran09d6089da771
diff --git a/.pnpmfile.cjs b/.pnpmfile.cjsdeleted file mode 100644index 4a2b6be5f5..0000000000--- a/.pnpmfile.cjs+++ /dev/null@@ -1,30 +0,0 @@-/**- * pnpm install hook.- *- * Strips the per-platform native binary packages bundled by agent SDKs whose- * providers run in "bring-your-own-binary" mode. Trilium's Claude Agent- * provider (apps/server) drives the SDK's JS wrapper but points it at the- * user's own installed CLI via `pathToClaudeCodeExecutable`, so the ~250 MB- * bundled binary is never used — and must not be downloaded into every server- * install and Docker layer. The tiny JS wrapper is kept; only the- * `@anthropic-ai/claude-agent-sdk-<platform>` optionalDependencies are removed.- */--/** SDK package name → prefix of the platform-binary optionalDependencies to drop. */-const BYO_BINARY_SDKS = {- "@anthropic-ai/claude-agent-sdk": "@anthropic-ai/claude-agent-sdk-"-};--function readPackage(pkg) {- const prefix = BYO_BINARY_SDKS[pkg.name];- if (prefix && pkg.optionalDependencies) {- for (const dep of Object.keys(pkg.optionalDependencies)) {- if (dep.startsWith(prefix)) {- delete pkg.optionalDependencies[dep];- }- }- }- return pkg;-}--module.exports = { hooks: { readPackage } };diff --git a/apps/server/src/services/llm/providers/claude_agent.ts b/apps/server/src/services/llm/providers/claude_agent.tsindex 696abddfab..e8fd5d893c 100644--- a/apps/server/src/services/llm/providers/claude_agent.ts+++ b/apps/server/src/services/llm/providers/claude_agent.ts@@ -6,7 +6,8 @@* machine running the server), and billing goes to the subscription.** Bring-your-own-binary: the SDK's ~250 MB bundled native binary is stripped at- * install time (root .pnpmfile.cjs); the provider drives the user's own+ * install time (`ignoredOptionalDependencies` in the root pnpm-workspace.yaml);+ * the provider drives the user's own* installed `claude` CLI (see claude_binary.ts), keeping the server lean.** Unlike the AI-SDK providers, the Agent SDK runs its own agentic loop and isdiff --git a/apps/server/src/services/llm/providers/claude_binary.ts b/apps/server/src/services/llm/providers/claude_binary.tsindex c31ccf6539..a5e32d443d 100644--- a/apps/server/src/services/llm/providers/claude_binary.ts+++ b/apps/server/src/services/llm/providers/claude_binary.ts@@ -2,8 +2,9 @@* Resolves the Claude Code CLI binary the Claude Agent provider drives.** The provider runs in "bring-your-own-binary" mode: the ~250 MB native binary- * that the SDK would otherwise bundle is stripped at install time (see the- * root .pnpmfile.cjs), so we point the SDK at the user's own installed CLI via+ * that the SDK would otherwise bundle is stripped at install time (see+ * `ignoredOptionalDependencies` in the root pnpm-workspace.yaml), so we point+ * the SDK at the user's own installed CLI via* `pathToClaudeCodeExecutable`. This keeps the server install lean and lets each* platform provide a binary that actually runs there (e.g. the nixpkgs wrapper* on NixOS, which needs no glibc/nix-ld shim — unlike the SDK's bundled ELF).diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 4969b5caf7..4f0d444870 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -81,8 +81,6 @@ overrides:basic-ftp@=5.2.0: '>=5.2.1'extract-zip>yauzl: 3.4.0-pnpmfileChecksum: sha256-Y+CmGTGmFhNZN6QTL8GJnY/EuBOU2KPY66OgOmzHWqw=-patchedDependencies:'@ckeditor/ckeditor5-code-block': 1530be090e4f5235e197fb6208a8e8230e3355d5633fc7cad2b2e892659e9c04'@ckeditor/ckeditor5-mention': 70377e48a04e2f45abba79aa35f3d5527ec7aa7ffce44056f9957a49a24a4a60@@ -13893,6 +13891,9 @@ packages:resolution: {integrity: sha512-bXE4cR/kVZhKZX/RjPEflHaKVhUVl85noU3v6b8apfQEc1x4A+zBxjZ4lN8LqGd6WZ3dl98pY4o717VFmoPp+A==}+ignoredOptionalDependencies:+ - '@anthropic-ai/claude-agent-sdk-*'+snapshots:'@1natsu/[email protected]':diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yamlindex 81e91bf4eb..f6e6040e57 100644--- a/pnpm-workspace.yaml+++ b/pnpm-workspace.yaml@@ -98,6 +98,17 @@ overrides:# electron/electron#51619). yauzl@>=3.3.1 is the maintainer-recommended fix."extract-zip>yauzl": "3.4.0"+# Trilium's Claude Agent provider (apps/server) runs the SDK in+# "bring-your-own-binary" mode (pathToClaudeCodeExecutable), so the ~250 MB+# bundled per-platform binaries are never used and must not be downloaded into+# every server install and Docker layer. Only the tiny JS wrapper is kept.+# Declarative replacement for the former .pnpmfile.cjs readPackage hook: a+# pnpmfile pins a pnpmfileChecksum into the lockfile, which Renovate's+# --ignore-pnpmfile lockfile updates silently drop, breaking every frozen+# CI install on its PRs (ERR_PNPM_LOCKFILE_CONFIG_MISMATCH).+ignoredOptionalDependencies:+ - "@anthropic-ai/claude-agent-sdk-*"+patchedDependencies:"@ckeditor/ckeditor5-mention": patches/@ckeditor__ckeditor5-mention.patch"@ckeditor/ckeditor5-code-block": patches/@ckeditor__ckeditor5-code-block.patch