From adf39b7c57c1ced6022cc4ce2f8a34055d29ea24 Mon Sep 17 00:00:00 2001 From: "anthropic-code-agent[bot]" <242468646+Claude@users.noreply.github.com> Date: Wed, 15 Apr 2026 02:05:15 +0000 Subject: [PATCH 1/8] feat: configure dual-driver setup for Vercel - Turso for sys namespace, Memory for apps Agent-Logs-Url: https://github.com/objectstack-ai/framework/sessions/b0cabda0-dbb2-41c2-8ae6-47f8e3e6cabc Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com> --- apps/server/server/index.ts | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/apps/server/server/index.ts b/apps/server/server/index.ts index 9d080cfa9..6ac94d1c3 100644 --- a/apps/server/server/index.ts +++ b/apps/server/server/index.ts @@ -13,6 +13,7 @@ import { ObjectKernel, DriverPlugin, AppPlugin } from '@objectstack/runtime'; import { ObjectQLPlugin } from '@objectstack/objectql'; import { TursoDriver } from '@objectstack/driver-turso'; +import { InMemoryDriver } from '@objectstack/driver-memory'; import { createHonoApp } from '@objectstack/hono'; import { AuthPlugin } from '@objectstack/plugin-auth'; import { SecurityPlugin } from '@objectstack/plugin-security'; @@ -62,7 +63,11 @@ async function ensureKernel(): Promise { // Register ObjectQL engine await kernel.use(new ObjectQLPlugin()); - // Database driver - Turso (remote mode for Vercel) + // Register Memory driver (default for CRM, Todo, BI apps) + const memoryDriver = new InMemoryDriver(); + await kernel.use(new DriverPlugin(memoryDriver, 'memory')); + + // Register Turso driver (for sys namespace) const tursoUrl = process.env.TURSO_DATABASE_URL; const tursoToken = process.env.TURSO_AUTH_TOKEN; @@ -76,7 +81,19 @@ async function ensureKernel(): Promise { // Remote mode - no local sync needed for Vercel }); - await kernel.use(new DriverPlugin(tursoDriver)); + await kernel.use(new DriverPlugin(tursoDriver, 'turso')); + + // Configure datasource mapping: sys namespace → Turso, everything else → Memory + const ql = kernel.getService('objectql'); + if (ql && typeof ql.setDatasourceMapping === 'function') { + ql.setDatasourceMapping([ + // System objects (sys namespace) use Turso for persistent storage + { namespace: 'sys', datasource: 'turso' }, + // All other objects use Memory driver as default + { default: true, datasource: 'memory' }, + ]); + console.log('[Vercel] Datasource mapping configured: sys → turso, default → memory'); + } // Load app manifests (BEFORE plugins that need object schemas) await kernel.use(new AppPlugin(CrmApp)); From 71e99b65b2022cf3aae0c4fbeda1789c81c6eda4 Mon Sep 17 00:00:00 2001 From: "anthropic-code-agent[bot]" <242468646+Claude@users.noreply.github.com> Date: Wed, 15 Apr 2026 02:20:17 +0000 Subject: [PATCH 2/8] fix: add pino logging dependencies for Vercel deployment Agent-Logs-Url: https://github.com/objectstack-ai/framework/sessions/386f4e43-c30c-4e81-bebf-d47cbf07430f Co-authored-by: xuyushun441-sys <255036401+xuyushun441-sys@users.noreply.github.com> --- apps/server/package.json | 4 +++- apps/server/scripts/bundle-api.mjs | 3 +++ apps/server/vercel.json | 3 ++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/apps/server/package.json b/apps/server/package.json index 1d5e8900c..a6dfd0710 100644 --- a/apps/server/package.json +++ b/apps/server/package.json @@ -35,7 +35,9 @@ "@objectstack/service-automation": "workspace:*", "@objectstack/service-feed": "workspace:*", "@objectstack/spec": "workspace:*", - "hono": "^4.12.12" + "hono": "^4.12.12", + "pino": "^10.3.1", + "pino-pretty": "^13.1.3" }, "devDependencies": { "@objectstack/cli": "workspace:*", diff --git a/apps/server/scripts/bundle-api.mjs b/apps/server/scripts/bundle-api.mjs index 57700c855..410c9c63a 100644 --- a/apps/server/scripts/bundle-api.mjs +++ b/apps/server/scripts/bundle-api.mjs @@ -27,6 +27,9 @@ const EXTERNAL = [ 'tedious', // macOS-only native file watcher 'fsevents', + // Logging libraries - use dynamic require, must be external + 'pino', + 'pino-pretty', ]; await build({ diff --git a/apps/server/vercel.json b/apps/server/vercel.json index fdaa07ceb..791d98823 100644 --- a/apps/server/vercel.json +++ b/apps/server/vercel.json @@ -12,7 +12,8 @@ "functions": { "api/**/*.js": { "memory": 1024, - "maxDuration": 60 + "maxDuration": 60, + "includeFiles": "node_modules/{pino,pino-pretty}/**" } }, "headers": [ From 61a4b20805a11376c5a56ffad947b94d8c8552bc Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 15 Apr 2026 03:41:37 +0000 Subject: [PATCH 3/8] fix: update pnpm-lock.yaml for pino dependencies Agent-Logs-Url: https://github.com/objectstack-ai/framework/sessions/1ae5e6a3-687f-481e-9cf6-9361c11db750 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 813ca2db3..0ebff6dcc 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -193,6 +193,12 @@ importers: hono: specifier: ^4.12.12 version: 4.12.12 + pino: + specifier: ^10.3.1 + version: 10.3.1 + pino-pretty: + specifier: ^13.1.3 + version: 13.1.3 devDependencies: '@objectstack/cli': specifier: workspace:* From 84ee318d353b6ff72a34d55ad78f6c1b1f7f871e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 15 Apr 2026 03:54:27 +0000 Subject: [PATCH 4/8] fix: resolve pnpm symlinks for Vercel serverless function packaging Install external dependencies (pino, pino-pretty, @libsql/client) via npm into api/node_modules/ during the build step. This creates real directories (no symlinks) that Vercel can properly package for the serverless function. - Updated build-vercel.sh to install external deps in api/node_modules/ - Updated vercel.json includeFiles to api/node_modules/** - Added @libsql/client to esbuild EXTERNAL list - Added api/node_modules/ and public/ to .gitignore Agent-Logs-Url: https://github.com/objectstack-ai/framework/sessions/a2378bd5-dff3-42d5-bf08-1dff787cf351 Co-authored-by: xuyushun441-sys <255036401+xuyushun441-sys@users.noreply.github.com> --- apps/server/.gitignore | 2 ++ apps/server/scripts/build-vercel.sh | 24 ++++++++++++++++++++++++ apps/server/scripts/bundle-api.mjs | 2 ++ apps/server/vercel.json | 2 +- 4 files changed, 29 insertions(+), 1 deletion(-) diff --git a/apps/server/.gitignore b/apps/server/.gitignore index 7b9ccd07e..b79cbf941 100644 --- a/apps/server/.gitignore +++ b/apps/server/.gitignore @@ -1,10 +1,12 @@ # Build artifacts dist/ .turbo/ +public/ # Bundled API handler (generated during Vercel build) api/_handler.js api/_handler.js.map +api/node_modules/ # Node modules node_modules/ diff --git a/apps/server/scripts/build-vercel.sh b/apps/server/scripts/build-vercel.sh index 20b624f59..f0b059f22 100755 --- a/apps/server/scripts/build-vercel.sh +++ b/apps/server/scripts/build-vercel.sh @@ -8,11 +8,13 @@ set -euo pipefail # - esbuild bundles server/index.ts → api/_handler.js (self-contained bundle) # - The committed .js wrapper re-exports from _handler.js at runtime # - Studio SPA is built and copied to public/ for serving the UI +# - External dependencies installed in api/node_modules/ (no symlinks) # # Steps: # 1. Build the project with turbo (includes studio) # 2. Bundle the API serverless function (→ api/_handler.js) # 3. Copy studio dist files to public/ for UI serving +# 4. Install external deps in api/node_modules/ (resolve pnpm symlinks) echo "[build-vercel] Starting server build..." @@ -36,4 +38,26 @@ else echo "[build-vercel] ⚠ Studio dist not found (skipped)" fi +# 4. Install external dependencies in api/node_modules/ (no symlinks) +# pnpm uses symlinks in node_modules/, which Vercel's serverless function +# packaging cannot handle ("invalid deployment package" error). +# We use npm to install external packages as real files next to the handler. +echo "[build-vercel] Installing external dependencies for serverless function..." +cat > api/_package.json << 'DEPS' +{ + "private": true, + "dependencies": { + "@libsql/client": "0.14.0", + "pino": "10.3.1", + "pino-pretty": "13.1.3" + } +} +DEPS +cd api +mv _package.json package.json +npm install --production --no-package-lock --ignore-scripts 2>&1 | tail -3 +rm package.json +cd .. +echo "[build-vercel] ✓ External dependencies installed in api/node_modules/" + echo "[build-vercel] Done. Static files in public/, serverless function in api/[[...route]].js → api/_handler.js" diff --git a/apps/server/scripts/bundle-api.mjs b/apps/server/scripts/bundle-api.mjs index 410c9c63a..9103a5d71 100644 --- a/apps/server/scripts/bundle-api.mjs +++ b/apps/server/scripts/bundle-api.mjs @@ -27,6 +27,8 @@ const EXTERNAL = [ 'tedious', // macOS-only native file watcher 'fsevents', + // LibSQL client — has native bindings, must remain external for Vercel + '@libsql/client', // Logging libraries - use dynamic require, must be external 'pino', 'pino-pretty', diff --git a/apps/server/vercel.json b/apps/server/vercel.json index 791d98823..d32d142fa 100644 --- a/apps/server/vercel.json +++ b/apps/server/vercel.json @@ -13,7 +13,7 @@ "api/**/*.js": { "memory": 1024, "maxDuration": 60, - "includeFiles": "node_modules/{pino,pino-pretty}/**" + "includeFiles": "api/node_modules/**" } }, "headers": [ From 8a021fadc8b3a0ede810b2ff8431dc7e0cf65ab7 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 15 Apr 2026 03:55:21 +0000 Subject: [PATCH 5/8] fix: improve npm install error visibility in build-vercel.sh Agent-Logs-Url: https://github.com/objectstack-ai/framework/sessions/a2378bd5-dff3-42d5-bf08-1dff787cf351 Co-authored-by: xuyushun441-sys <255036401+xuyushun441-sys@users.noreply.github.com> --- apps/server/scripts/build-vercel.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/server/scripts/build-vercel.sh b/apps/server/scripts/build-vercel.sh index f0b059f22..64754b48d 100755 --- a/apps/server/scripts/build-vercel.sh +++ b/apps/server/scripts/build-vercel.sh @@ -55,7 +55,7 @@ cat > api/_package.json << 'DEPS' DEPS cd api mv _package.json package.json -npm install --production --no-package-lock --ignore-scripts 2>&1 | tail -3 +npm install --production --no-package-lock --ignore-scripts --loglevel error rm package.json cd .. echo "[build-vercel] ✓ External dependencies installed in api/node_modules/" From b0e743f2bed83bd02e006ba51e61b689c931f0cb Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 15 Apr 2026 04:00:39 +0000 Subject: [PATCH 6/8] fix: use getServiceAsync for objectql service and remove ignored memory setting Agent-Logs-Url: https://github.com/objectstack-ai/framework/sessions/3e1b55e8-5330-4645-b7d8-61e8e032fa00 Co-authored-by: xuyushun441-sys <255036401+xuyushun441-sys@users.noreply.github.com> --- apps/server/server/index.ts | 3 +-- apps/server/vercel.json | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/apps/server/server/index.ts b/apps/server/server/index.ts index 6ac94d1c3..adbcf8ae2 100644 --- a/apps/server/server/index.ts +++ b/apps/server/server/index.ts @@ -84,7 +84,7 @@ async function ensureKernel(): Promise { await kernel.use(new DriverPlugin(tursoDriver, 'turso')); // Configure datasource mapping: sys namespace → Turso, everything else → Memory - const ql = kernel.getService('objectql'); + const ql = await kernel.getServiceAsync('objectql'); if (ql && typeof ql.setDatasourceMapping === 'function') { ql.setDatasourceMapping([ // System objects (sys namespace) use Turso for persistent storage @@ -266,6 +266,5 @@ export default getRequestListener(async (request, env) => { * Vercel per-function configuration. */ export const config = { - memory: 1024, maxDuration: 60, }; diff --git a/apps/server/vercel.json b/apps/server/vercel.json index d32d142fa..84811d0b0 100644 --- a/apps/server/vercel.json +++ b/apps/server/vercel.json @@ -11,7 +11,6 @@ }, "functions": { "api/**/*.js": { - "memory": 1024, "maxDuration": 60, "includeFiles": "api/node_modules/**" } From 434139f21a8fc426b976f57691c28816ddc40b7e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 15 Apr 2026 04:01:22 +0000 Subject: [PATCH 7/8] refactor: use proper ObjectQL type instead of any for getServiceAsync Agent-Logs-Url: https://github.com/objectstack-ai/framework/sessions/3e1b55e8-5330-4645-b7d8-61e8e032fa00 Co-authored-by: xuyushun441-sys <255036401+xuyushun441-sys@users.noreply.github.com> --- apps/server/server/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/server/server/index.ts b/apps/server/server/index.ts index adbcf8ae2..2719771f3 100644 --- a/apps/server/server/index.ts +++ b/apps/server/server/index.ts @@ -11,7 +11,7 @@ */ import { ObjectKernel, DriverPlugin, AppPlugin } from '@objectstack/runtime'; -import { ObjectQLPlugin } from '@objectstack/objectql'; +import { ObjectQLPlugin, ObjectQL } from '@objectstack/objectql'; import { TursoDriver } from '@objectstack/driver-turso'; import { InMemoryDriver } from '@objectstack/driver-memory'; import { createHonoApp } from '@objectstack/hono'; @@ -84,7 +84,7 @@ async function ensureKernel(): Promise { await kernel.use(new DriverPlugin(tursoDriver, 'turso')); // Configure datasource mapping: sys namespace → Turso, everything else → Memory - const ql = await kernel.getServiceAsync('objectql'); + const ql = await kernel.getServiceAsync('objectql'); if (ql && typeof ql.setDatasourceMapping === 'function') { ql.setDatasourceMapping([ // System objects (sys namespace) use Turso for persistent storage From cce964d40d73c9f0f605f439952c03b2a263182e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 15 Apr 2026 04:05:10 +0000 Subject: [PATCH 8/8] fix: move datasource mapping after bootstrap() to resolve 'objectql' not found Agent-Logs-Url: https://github.com/objectstack-ai/framework/sessions/a1cc1f6c-d9ba-459d-b0cb-fb6ba8dace02 Co-authored-by: xuyushun441-sys <255036401+xuyushun441-sys@users.noreply.github.com> --- apps/server/server/index.ts | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/apps/server/server/index.ts b/apps/server/server/index.ts index 2719771f3..f3bbc577c 100644 --- a/apps/server/server/index.ts +++ b/apps/server/server/index.ts @@ -83,18 +83,6 @@ async function ensureKernel(): Promise { await kernel.use(new DriverPlugin(tursoDriver, 'turso')); - // Configure datasource mapping: sys namespace → Turso, everything else → Memory - const ql = await kernel.getServiceAsync('objectql'); - if (ql && typeof ql.setDatasourceMapping === 'function') { - ql.setDatasourceMapping([ - // System objects (sys namespace) use Turso for persistent storage - { namespace: 'sys', datasource: 'turso' }, - // All other objects use Memory driver as default - { default: true, datasource: 'memory' }, - ]); - console.log('[Vercel] Datasource mapping configured: sys → turso, default → memory'); - } - // Load app manifests (BEFORE plugins that need object schemas) await kernel.use(new AppPlugin(CrmApp)); await kernel.use(new AppPlugin(TodoApp)); @@ -129,6 +117,18 @@ async function ensureKernel(): Promise { await kernel.bootstrap(); + // Configure datasource mapping AFTER bootstrap (ObjectQL service is registered during init) + const ql = await kernel.getServiceAsync('objectql'); + if (ql && typeof ql.setDatasourceMapping === 'function') { + ql.setDatasourceMapping([ + // System objects (sys namespace) use Turso for persistent storage + { namespace: 'sys', datasource: 'turso' }, + // All other objects use Memory driver as default + { default: true, datasource: 'memory' }, + ]); + console.log('[Vercel] Datasource mapping configured: sys → turso, default → memory'); + } + _kernel = kernel; console.log('[Vercel] Kernel ready.'); return kernel;