From 3f8a348de45270be2ca284d966bad30c05ece58a Mon Sep 17 00:00:00 2001 From: "anthropic-code-agent[bot]" <242468646+Claude@users.noreply.github.com> Date: Mon, 13 Apr 2026 02:12:46 +0000 Subject: [PATCH 1/7] Fix RemoteTransport HttpClient2 bundling error - Mark @libsql/client as external in bundle-api.mjs - Add @libsql/client to vercel.json includeFiles - Prevents esbuild from bundling @libsql/client which breaks HttpClient2 constructor Agent-Logs-Url: https://github.com/objectstack-ai/framework/sessions/bba47546-4868-4fbb-94cc-909dd5f6757d Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com> --- apps/studio/scripts/bundle-api.mjs | 5 ++--- apps/studio/vercel.json | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/apps/studio/scripts/bundle-api.mjs b/apps/studio/scripts/bundle-api.mjs index 9f1d8fc81..1dc897e69 100644 --- a/apps/studio/scripts/bundle-api.mjs +++ b/apps/studio/scripts/bundle-api.mjs @@ -16,9 +16,8 @@ import { build } from 'esbuild'; // Packages that cannot be bundled (native bindings / optional drivers) const EXTERNAL = [ - // @libsql/client is now bundled (pure JS, no native bindings) - // Bundling it solves Vercel deployment issues where external packages - // aren't properly included in the serverless function despite includeFiles config + // @libsql/client must be external — bundling breaks internal HttpClient2 class constructor + '@libsql/client', 'better-sqlite3', // AI SDK provider packages — dynamically imported based on env vars '@ai-sdk/anthropic', diff --git a/apps/studio/vercel.json b/apps/studio/vercel.json index 96e8daf72..eb63e91d8 100644 --- a/apps/studio/vercel.json +++ b/apps/studio/vercel.json @@ -13,7 +13,7 @@ "api/**/*.js": { "memory": 1024, "maxDuration": 300, - "includeFiles": "node_modules/{better-sqlite3,@ai-sdk}/**" + "includeFiles": "node_modules/{@libsql/client,better-sqlite3,@ai-sdk}/**" } }, "headers": [ From b630c46c63529586e9ecbdf02c5e54886f6f0632 Mon Sep 17 00:00:00 2001 From: "anthropic-code-agent[bot]" <242468646+Claude@users.noreply.github.com> Date: Mon, 13 Apr 2026 02:13:06 +0000 Subject: [PATCH 2/7] Add @libsql/client to build-vercel.sh copy logic - Update build-vercel.sh to copy @libsql/client to local node_modules - Remove outdated comment about @libsql/client being bundled - Ensures @libsql/client is available in Vercel serverless function Agent-Logs-Url: https://github.com/objectstack-ai/framework/sessions/bba47546-4868-4fbb-94cc-909dd5f6757d Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com> --- apps/studio/scripts/build-vercel.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/apps/studio/scripts/build-vercel.sh b/apps/studio/scripts/build-vercel.sh index 10a5507f4..437f5bf69 100755 --- a/apps/studio/scripts/build-vercel.sh +++ b/apps/studio/scripts/build-vercel.sh @@ -38,10 +38,8 @@ node scripts/bundle-api.mjs # The vercel.json includeFiles pattern references node_modules/ relative to # apps/studio/, so we must copy the actual module files here for Vercel to # include them in the serverless function's deployment package. -# -# Note: @libsql/client is now bundled by esbuild, so we no longer copy it. echo "[build-vercel] Copying external native modules to local node_modules..." -for mod in better-sqlite3; do +for mod in better-sqlite3 @libsql/client; do src="../../node_modules/$mod" if [ -e "$src" ]; then dest="node_modules/$mod" From 044ae75534d16211f51de14f109b63b630befb45 Mon Sep 17 00:00:00 2001 From: "anthropic-code-agent[bot]" <242468646+Claude@users.noreply.github.com> Date: Mon, 13 Apr 2026 07:34:54 +0000 Subject: [PATCH 3/7] Add @libsql/client and better-sqlite3 to studio dependencies Agent-Logs-Url: https://github.com/objectstack-ai/framework/sessions/553ba115-2f78-433a-96c4-a8088eb6ebe3 Co-authored-by: xuyushun441-sys <255036401+xuyushun441-sys@users.noreply.github.com> --- apps/studio/package.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/apps/studio/package.json b/apps/studio/package.json index 25fbeb5a7..c8b28f452 100644 --- a/apps/studio/package.json +++ b/apps/studio/package.json @@ -23,6 +23,7 @@ "@ai-sdk/openai": "^3.0.0", "@ai-sdk/react": "^3.0.148", "@hono/node-server": "^1.19.12", + "@libsql/client": "^0.17.2", "@objectstack/client": "workspace:*", "@objectstack/client-react": "workspace:*", "@objectstack/driver-memory": "workspace:*", @@ -57,6 +58,7 @@ "@radix-ui/react-toast": "^1.2.15", "@radix-ui/react-tooltip": "^1.2.8", "ai": "^6.0.146", + "better-sqlite3": "^12.8.0", "class-variance-authority": "^0.7.1", "clsx": "^2.1.1", "hono": "^4.12.10", From df3efb4de2434e4514d9a5261908b96d83b948a9 Mon Sep 17 00:00:00 2001 From: "anthropic-code-agent[bot]" <242468646+Claude@users.noreply.github.com> Date: Mon, 13 Apr 2026 07:52:37 +0000 Subject: [PATCH 4/7] Update pnpm-lock.yaml for studio dependencies - Add @libsql/client and better-sqlite3 to lockfile - Fixes CI "frozen-lockfile" error after adding dependencies to apps/studio/package.json Agent-Logs-Url: https://github.com/objectstack-ai/framework/sessions/01213e25-6e79-4f4e-b29e-c08da6842337 Co-authored-by: xuyushun441-sys <255036401+xuyushun441-sys@users.noreply.github.com> --- pnpm-lock.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0afe906c4..c475ab1b3 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -145,6 +145,9 @@ importers: '@hono/node-server': specifier: ^1.19.12 version: 1.19.12(hono@4.12.11) + '@libsql/client': + specifier: ^0.17.2 + version: 0.17.2 '@objectstack/client': specifier: workspace:* version: link:../../packages/client @@ -247,6 +250,9 @@ importers: ai: specifier: ^6.0.146 version: 6.0.149(zod@4.3.6) + better-sqlite3: + specifier: ^12.8.0 + version: 12.8.0 class-variance-authority: specifier: ^0.7.1 version: 0.7.1 From 466e08555535a2d03a18fe4dafb994d2fa792037 Mon Sep 17 00:00:00 2001 From: "anthropic-code-agent[bot]" <242468646+Claude@users.noreply.github.com> Date: Mon, 13 Apr 2026 08:01:42 +0000 Subject: [PATCH 5/7] Remove redundant package copying from build-vercel.sh - Remove better-sqlite3 and @libsql/client from copy loop - These are now direct dependencies installed by pnpm automatically - Prevents infinite recursion error during Vercel build - Keep only @ai-sdk copying logic for workspace dependencies Agent-Logs-Url: https://github.com/objectstack-ai/framework/sessions/d15f5cb9-a33c-458c-aca4-417104e23d66 Co-authored-by: xuyushun441-sys <255036401+xuyushun441-sys@users.noreply.github.com> --- apps/studio/scripts/build-vercel.sh | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/apps/studio/scripts/build-vercel.sh b/apps/studio/scripts/build-vercel.sh index 437f5bf69..8a9caf4e1 100755 --- a/apps/studio/scripts/build-vercel.sh +++ b/apps/studio/scripts/build-vercel.sh @@ -28,28 +28,16 @@ cd apps/studio # 2. Bundle API serverless function node scripts/bundle-api.mjs -# 3. Copy native/external modules into local node_modules for Vercel packaging. +# 3. Copy @ai-sdk packages into local node_modules for Vercel packaging. # -# Unlike hotcrm (which uses shamefully-hoist=true), this monorepo uses pnpm's -# default strict node_modules structure. Transitive native dependencies like -# better-sqlite3 only exist in the monorepo root's node_modules/.pnpm/ virtual -# store — they're NOT symlinked into apps/studio/node_modules/. +# The @ai-sdk packages are workspace dependencies that need to be copied from +# the monorepo root. @libsql/client and better-sqlite3 are now direct dependencies +# in apps/studio/package.json, so pnpm installs them automatically. # # The vercel.json includeFiles pattern references node_modules/ relative to -# apps/studio/, so we must copy the actual module files here for Vercel to -# include them in the serverless function's deployment package. -echo "[build-vercel] Copying external native modules to local node_modules..." -for mod in better-sqlite3 @libsql/client; do - src="../../node_modules/$mod" - if [ -e "$src" ]; then - dest="node_modules/$mod" - mkdir -p "$(dirname "$dest")" - cp -rL "$src" "$dest" - echo "[build-vercel] ✓ Copied $mod" - else - echo "[build-vercel] ⚠ $mod not found at $src (skipped)" - fi -done +# apps/studio/, so we must copy @ai-sdk packages here for Vercel to include +# them in the serverless function's deployment package. +echo "[build-vercel] Copying external modules to local node_modules..." # Copy the @ai-sdk scope (dynamically loaded provider packages) if [ -d "../../node_modules/@ai-sdk" ]; then mkdir -p "node_modules/@ai-sdk" From e5d5c8df06a9f672de2ca48e0094eb9ccef47f86 Mon Sep 17 00:00:00 2001 From: "anthropic-code-agent[bot]" <242468646+Claude@users.noreply.github.com> Date: Mon, 13 Apr 2026 08:08:40 +0000 Subject: [PATCH 6/7] Dereference pnpm symlinks for Vercel deployment - Replace symlinked packages with real files in node_modules - Vercel doesn't support symlinked directories in serverless functions - Use readlink to get real path, then copy with cp -rL - Prevents "invalid deployment package" error from Vercel - Applies to better-sqlite3, @libsql/client, and @ai-sdk packages Agent-Logs-Url: https://github.com/objectstack-ai/framework/sessions/131c9b60-a3c7-43b6-a080-0de180a91db0 Co-authored-by: xuyushun441-sys <255036401+xuyushun441-sys@users.noreply.github.com> --- apps/studio/scripts/build-vercel.sh | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/apps/studio/scripts/build-vercel.sh b/apps/studio/scripts/build-vercel.sh index 8a9caf4e1..ae0d5fc3c 100755 --- a/apps/studio/scripts/build-vercel.sh +++ b/apps/studio/scripts/build-vercel.sh @@ -28,16 +28,27 @@ cd apps/studio # 2. Bundle API serverless function node scripts/bundle-api.mjs -# 3. Copy @ai-sdk packages into local node_modules for Vercel packaging. +# 3. Dereference symlinks in node_modules for Vercel packaging. # -# The @ai-sdk packages are workspace dependencies that need to be copied from -# the monorepo root. @libsql/client and better-sqlite3 are now direct dependencies -# in apps/studio/package.json, so pnpm installs them automatically. +# pnpm creates symlinks in node_modules/ by default. Vercel's serverless function +# packaging doesn't support symlinked directories, so we need to replace symlinks +# with actual file copies. # # The vercel.json includeFiles pattern references node_modules/ relative to -# apps/studio/, so we must copy @ai-sdk packages here for Vercel to include -# them in the serverless function's deployment package. -echo "[build-vercel] Copying external modules to local node_modules..." +# apps/studio/, so we must ensure these directories contain real files, not symlinks. +echo "[build-vercel] Dereferencing symlinks in node_modules..." +for mod in better-sqlite3 @libsql/client; do + if [ -L "node_modules/$mod" ] || [ -d "node_modules/$mod" ]; then + # Get the real path that the symlink points to + real_path=$(readlink -f "node_modules/$mod" 2>/dev/null || echo "") + if [ -n "$real_path" ] && [ -d "$real_path" ]; then + echo "[build-vercel] Dereferencing $mod..." + rm -rf "node_modules/$mod" + cp -rL "$real_path" "node_modules/$mod" + echo "[build-vercel] ✓ Dereferenced $mod" + fi + fi +done # Copy the @ai-sdk scope (dynamically loaded provider packages) if [ -d "../../node_modules/@ai-sdk" ]; then mkdir -p "node_modules/@ai-sdk" From 1fa5437879c3cb22b0471b933e7b797ee6205e03 Mon Sep 17 00:00:00 2001 From: "anthropic-code-agent[bot]" <242468646+Claude@users.noreply.github.com> Date: Mon, 13 Apr 2026 08:52:52 +0000 Subject: [PATCH 7/7] Use pnpm hoisted node-linker for Vercel deployment - Add .npmrc with node-linker=hoisted to apps/studio - Prevents pnpm from creating symlinks in node_modules - Vercel requires real files, not symlinks, in serverless functions - Simplify build-vercel.sh by removing symlink dereferencing logic - @libsql/client and better-sqlite3 will be installed as real directories Agent-Logs-Url: https://github.com/objectstack-ai/framework/sessions/500e4ff3-8d32-4122-bb49-7ab36dbba0d8 Co-authored-by: xuyushun441-sys <255036401+xuyushun441-sys@users.noreply.github.com> --- apps/studio/.npmrc | 3 +++ apps/studio/scripts/build-vercel.sh | 27 +++++++-------------------- 2 files changed, 10 insertions(+), 20 deletions(-) create mode 100644 apps/studio/.npmrc diff --git a/apps/studio/.npmrc b/apps/studio/.npmrc new file mode 100644 index 000000000..94558d3bc --- /dev/null +++ b/apps/studio/.npmrc @@ -0,0 +1,3 @@ +# Vercel doesn't support symlinked directories in serverless functions. +# Use hoisted node-linker to create a flat node_modules structure without symlinks. +node-linker=hoisted diff --git a/apps/studio/scripts/build-vercel.sh b/apps/studio/scripts/build-vercel.sh index ae0d5fc3c..00571fc20 100755 --- a/apps/studio/scripts/build-vercel.sh +++ b/apps/studio/scripts/build-vercel.sh @@ -28,28 +28,15 @@ cd apps/studio # 2. Bundle API serverless function node scripts/bundle-api.mjs -# 3. Dereference symlinks in node_modules for Vercel packaging. +# 3. Copy @ai-sdk packages from monorepo root. # -# pnpm creates symlinks in node_modules/ by default. Vercel's serverless function -# packaging doesn't support symlinked directories, so we need to replace symlinks -# with actual file copies. +# The @ai-sdk packages are workspace dependencies that pnpm doesn't hoist into +# apps/studio/node_modules by default. We copy them here so Vercel's includeFiles +# pattern can find them. # -# The vercel.json includeFiles pattern references node_modules/ relative to -# apps/studio/, so we must ensure these directories contain real files, not symlinks. -echo "[build-vercel] Dereferencing symlinks in node_modules..." -for mod in better-sqlite3 @libsql/client; do - if [ -L "node_modules/$mod" ] || [ -d "node_modules/$mod" ]; then - # Get the real path that the symlink points to - real_path=$(readlink -f "node_modules/$mod" 2>/dev/null || echo "") - if [ -n "$real_path" ] && [ -d "$real_path" ]; then - echo "[build-vercel] Dereferencing $mod..." - rm -rf "node_modules/$mod" - cp -rL "$real_path" "node_modules/$mod" - echo "[build-vercel] ✓ Dereferenced $mod" - fi - fi -done -# Copy the @ai-sdk scope (dynamically loaded provider packages) +# Note: .npmrc configures node-linker=hoisted to prevent pnpm from creating symlinks, +# which Vercel's serverless function packaging doesn't support. +echo "[build-vercel] Copying @ai-sdk packages..." if [ -d "../../node_modules/@ai-sdk" ]; then mkdir -p "node_modules/@ai-sdk" for pkg in ../../node_modules/@ai-sdk/*/; do