diff --git a/apps/rag-knowledge-agent/README.md b/apps/rag-knowledge-agent/README.md index 8fcb243..710a5e4 100644 --- a/apps/rag-knowledge-agent/README.md +++ b/apps/rag-knowledge-agent/README.md @@ -220,7 +220,7 @@ This architecture provides several key advantages for building document AI appli - **Real-time Updates**: Webhook integration keeps documents synchronized #### **🛡️ Production Ready** -- **Multi-tenant Security**: Row-level security ensures data isolation between users +- **Multi-tenant Security**: Every query is scoped to the signed-in user, and row-level security keeps the tables closed to direct database API access - **Error Handling**: Comprehensive error management and retry logic - **Monitoring**: Built-in logging and performance tracking @@ -289,7 +289,7 @@ Requires `@stackone/ai` and `STACKONE_API_KEY`. The agent uses the first linked 1. In [StackOne Webhooks](https://app.stackone.com/webhooks), add a webhook and set the URL to your app (e.g. `https://your-ngrok-url.ngrok.io/api/stackone/webhook` for local dev). 2. Subscribe to **Documents > Files**: `documents_files.updated`, `documents_files.deleted` (and any account events you need). The app does not handle `documents_files.created`—users select which files to sync via the file picker. -3. Copy the **Signing secret** and set `STACKONE_WEBHOOK_SECRET` in `.env.local` so the app can verify `x-stackone-signature`. +3. Copy the **Signing secret** and set `STACKONE_WEBHOOK_SECRET` in `.env.local` so the app can verify `x-stackone-signature`. Without it the endpoint rejects every event. For local development, use [ngrok](https://ngrok.com) (e.g. `ngrok http 3000`) and use the ngrok URL as the webhook URL in StackOne. diff --git a/apps/rag-knowledge-agent/docker-compose.yml b/apps/rag-knowledge-agent/docker-compose.yml index e56ea45..f4b5075 100644 --- a/apps/rag-knowledge-agent/docker-compose.yml +++ b/apps/rag-knowledge-agent/docker-compose.yml @@ -6,7 +6,7 @@ services: POSTGRES_PASSWORD: postgres POSTGRES_DB: rag_agent ports: - - "5433:5432" # host:container (use 5433 if 5432 is already in use) + - "127.0.0.1:5433:5432" # host:container (use 5433 if 5432 is already in use) volumes: - postgres_data:/var/lib/postgresql/data diff --git a/apps/rag-knowledge-agent/env.example b/apps/rag-knowledge-agent/env.example index 0d2ef7a..21e10b8 100644 --- a/apps/rag-knowledge-agent/env.example +++ b/apps/rag-knowledge-agent/env.example @@ -56,7 +56,8 @@ STACKONE_API_KEY=your_stackone_api_key # STACKONE_BASE_URL=https://api.stackone.com # Webhook signing secret from StackOne dashboard (Webhooks > your webhook > Signing secret). -# If set, the app verifies x-stackone-signature (HMAC SHA256 base64url of body). +# Required for webhooks: without it the webhook endpoint rejects every event. The app +# verifies x-stackone-signature (HMAC SHA256 base64url of body). # For local testing with ngrok: use the secret from StackOne and point the webhook URL to # your ngrok URL, e.g. https://your-subdomain.ngrok.io/api/stackone/webhook STACKONE_WEBHOOK_SECRET= @@ -64,8 +65,8 @@ STACKONE_WEBHOOK_SECRET= # ============================================================================= # NEXT.JS / NEXT-AUTH CONFIGURATION # ============================================================================= -# Generate a random secret for NextAuth -NEXTAUTH_SECRET=your_nextauth_secret_here +# Required. Generate one per installation: openssl rand -base64 32 +NEXTAUTH_SECRET= NEXTAUTH_URL=http://localhost:3000 APP_URL=http://localhost:3000 diff --git a/apps/rag-knowledge-agent/next.config.ts b/apps/rag-knowledge-agent/next.config.ts index a54f900..314d669 100644 --- a/apps/rag-knowledge-agent/next.config.ts +++ b/apps/rag-knowledge-agent/next.config.ts @@ -21,10 +21,6 @@ const nextConfig: NextConfig = { exclude: ['error', 'warn'] } : false, }, - // Temporarily ignore TypeScript errors for build - typescript: { - ignoreBuildErrors: true, - }, }; export default nextConfig; diff --git a/apps/rag-knowledge-agent/package-lock.json b/apps/rag-knowledge-agent/package-lock.json index 8bb88af..aa2cdb6 100644 --- a/apps/rag-knowledge-agent/package-lock.json +++ b/apps/rag-knowledge-agent/package-lock.json @@ -11,8 +11,8 @@ "@ai-sdk/openai": "^3.0.115", "@ant-design/icons": "^5.6.1", "@ant-design/v5-patch-for-react-19": "^1.0.3", - "@langchain/core": "^0.3.72", - "@langchain/textsplitters": "^0.1.0", + "@langchain/core": "^1.5.0", + "@langchain/textsplitters": "^1.0.2", "@llamaindex/chat-ui": "^0.6.1", "@llamaindex/core": "0.6.22", "@llamaindex/env": "0.1.30", @@ -528,9 +528,9 @@ } }, "node_modules/@cfworker/json-schema": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/@cfworker/json-schema/-/json-schema-4.1.1.tgz", - "integrity": "sha512-gAmrUZSGtKc3AiBL71iNWxDsyUC5uMaKKGdvzYsBoTW/xi42JQHl7eKV2OYzCUqvc+D2RCcf7EXY2iCyFIk6og==", + "version": "4.1.6", + "resolved": "https://registry.npmjs.org/@cfworker/json-schema/-/json-schema-4.1.6.tgz", + "integrity": "sha512-YzVGTHXf4bzlyAL5KAvHYCdNbbt6zM5cYkAgxqxQPDQM6aZ4ShIIN5yJ+6q7YeonnevxT8k/LmD2tJi/jOiKkg==", "license": "MIT" }, "node_modules/@codemirror/autocomplete": { @@ -1453,9 +1453,6 @@ "cpu": [ "arm" ], - "libc": [ - "glibc" - ], "license": "LGPL-3.0-or-later", "optional": true, "os": [ @@ -1472,9 +1469,6 @@ "cpu": [ "arm64" ], - "libc": [ - "glibc" - ], "license": "LGPL-3.0-or-later", "optional": true, "os": [ @@ -1491,9 +1485,6 @@ "cpu": [ "ppc64" ], - "libc": [ - "glibc" - ], "license": "LGPL-3.0-or-later", "optional": true, "os": [ @@ -1510,9 +1501,6 @@ "cpu": [ "riscv64" ], - "libc": [ - "glibc" - ], "license": "LGPL-3.0-or-later", "optional": true, "os": [ @@ -1529,9 +1517,6 @@ "cpu": [ "s390x" ], - "libc": [ - "glibc" - ], "license": "LGPL-3.0-or-later", "optional": true, "os": [ @@ -1548,9 +1533,6 @@ "cpu": [ "x64" ], - "libc": [ - "glibc" - ], "license": "LGPL-3.0-or-later", "optional": true, "os": [ @@ -1567,9 +1549,6 @@ "cpu": [ "arm64" ], - "libc": [ - "musl" - ], "license": "LGPL-3.0-or-later", "optional": true, "os": [ @@ -1586,9 +1565,6 @@ "cpu": [ "x64" ], - "libc": [ - "musl" - ], "license": "LGPL-3.0-or-later", "optional": true, "os": [ @@ -1605,9 +1581,6 @@ "cpu": [ "arm" ], - "libc": [ - "glibc" - ], "license": "Apache-2.0", "optional": true, "os": [ @@ -1630,9 +1603,6 @@ "cpu": [ "arm64" ], - "libc": [ - "glibc" - ], "license": "Apache-2.0", "optional": true, "os": [ @@ -1655,9 +1625,6 @@ "cpu": [ "ppc64" ], - "libc": [ - "glibc" - ], "license": "Apache-2.0", "optional": true, "os": [ @@ -1680,9 +1647,6 @@ "cpu": [ "riscv64" ], - "libc": [ - "glibc" - ], "license": "Apache-2.0", "optional": true, "os": [ @@ -1705,9 +1669,6 @@ "cpu": [ "s390x" ], - "libc": [ - "glibc" - ], "license": "Apache-2.0", "optional": true, "os": [ @@ -1730,9 +1691,6 @@ "cpu": [ "x64" ], - "libc": [ - "glibc" - ], "license": "Apache-2.0", "optional": true, "os": [ @@ -1755,9 +1713,6 @@ "cpu": [ "arm64" ], - "libc": [ - "musl" - ], "license": "Apache-2.0", "optional": true, "os": [ @@ -1780,9 +1735,6 @@ "cpu": [ "x64" ], - "libc": [ - "musl" - ], "license": "Apache-2.0", "optional": true, "os": [ @@ -1941,63 +1893,36 @@ } }, "node_modules/@langchain/core": { - "version": "0.3.80", - "resolved": "https://registry.npmjs.org/@langchain/core/-/core-0.3.80.tgz", - "integrity": "sha512-vcJDV2vk1AlCwSh3aBm/urQ1ZrlXFFBocv11bz/NBUfLWD5/UDNMzwPdaAd2dKvNmTWa9FM2lirLU3+JCf4cRA==", + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/@langchain/core/-/core-1.5.1.tgz", + "integrity": "sha512-vPtTZGYxzpJBDJ4BHkPJZpC4+ceAFl+Fs1YCXy2VQiUsPRvNEJmXIE/sJLza5MroKRltPLMfJ/qIsSPHqUBr1w==", "license": "MIT", "dependencies": { - "@cfworker/json-schema": "^4.0.2", - "ansi-styles": "^5.0.0", - "camelcase": "6", - "decamelize": "1.2.0", + "@cfworker/json-schema": "^4.1.4", + "@standard-schema/spec": "^1.1.0", "js-tiktoken": "^1.0.12", - "langsmith": "^0.3.67", + "langsmith": ">=0.11.0 <1.0.0", "mustache": "^4.2.0", "p-queue": "^6.6.2", - "p-retry": "4", - "uuid": "^10.0.0", - "zod": "^3.25.32", - "zod-to-json-schema": "^3.22.3" + "zod": "^4.6.6" }, "engines": { - "node": ">=18" - } - }, - "node_modules/@langchain/core/node_modules/uuid": { - "version": "10.0.0", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-10.0.0.tgz", - "integrity": "sha512-8XkAphELsDnEGrDxUOHB3RGvXz6TeuYSGEZBOjtTtPm2lwhGBjLgOzLHB63IUWfBpNucQjND6d3AOudO+H3RWQ==", - "funding": [ - "https://github.com/sponsors/broofa", - "https://github.com/sponsors/ctavan" - ], - "license": "MIT", - "bin": { - "uuid": "dist/bin/uuid" - } - }, - "node_modules/@langchain/core/node_modules/zod": { - "version": "3.25.76", - "resolved": "https://registry.npmjs.org/zod/-/zod-3.25.76.tgz", - "integrity": "sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ==", - "license": "MIT", - "funding": { - "url": "https://github.com/sponsors/colinhacks" + "node": ">=20" } }, "node_modules/@langchain/textsplitters": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/@langchain/textsplitters/-/textsplitters-0.1.0.tgz", - "integrity": "sha512-djI4uw9rlkAb5iMhtLED+xJebDdAG935AdP4eRTB02R7OB/act55Bj9wsskhZsvuyQRpO4O1wQOp85s6T6GWmw==", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@langchain/textsplitters/-/textsplitters-1.0.2.tgz", + "integrity": "sha512-UNCmlyFIRlRfVxqpmcRsp1jQrscnIVVqRKrrjFF2wHHq+VGTv+VDkGZLyEVUopJfHIdaiXfOKlSrROQui7VLFA==", "license": "MIT", "dependencies": { "js-tiktoken": "^1.0.12" }, "engines": { - "node": ">=18" + "node": ">=20" }, "peerDependencies": { - "@langchain/core": ">=0.2.21 <0.4.0" + "@langchain/core": "^1.0.0" } }, "node_modules/@lexical/clipboard": { @@ -3531,9 +3456,9 @@ } }, "node_modules/@modelcontextprotocol/sdk/node_modules/ajv": { - "version": "8.18.0", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.18.0.tgz", - "integrity": "sha512-PlXPeEWMXMZ7sPYOHqmDyCJzcfNrUr3fGNKtezX14ykXOEIvyK81d+qydx89KY5O71FKMPaQ2vBfBFI5NHR63A==", + "version": "8.20.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.20.0.tgz", + "integrity": "sha512-Thbli+OlOj+iMPYFBVBfJ3OmCAnaSyNn4M1vz9T6Gka5Jt9ba/HIR56joy65tY6kx/FCF5VXNB819Y7/GUrBGA==", "license": "MIT", "dependencies": { "fast-deep-equal": "^3.1.3", @@ -3620,9 +3545,6 @@ "cpu": [ "arm64" ], - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -3639,9 +3561,6 @@ "cpu": [ "arm64" ], - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -3658,9 +3577,6 @@ "cpu": [ "x64" ], - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -3677,9 +3593,6 @@ "cpu": [ "x64" ], - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -5654,12 +5567,6 @@ "@types/react": "^19.2.0" } }, - "node_modules/@types/retry": { - "version": "0.12.0", - "resolved": "https://registry.npmjs.org/@types/retry/-/retry-0.12.0.tgz", - "integrity": "sha512-wWKOClTTiizcZhXnPY4wikVAwmdYHp8q6DmC+EJUzAMsycb7HB32Kh9RN4+0gExjmPmZSAQjgURXIGATPegAvA==", - "license": "MIT" - }, "node_modules/@types/unist": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.3.tgz", @@ -6026,9 +5933,9 @@ } }, "node_modules/@ungap/structured-clone": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/@ungap/structured-clone/-/structured-clone-1.3.0.tgz", - "integrity": "sha512-WmoN8qaIAo7WTYWbAZuG8PYEhn5fkz7dZrqTBZ7dtt//lL2Gwms1IcnQ5yHqjDfX8Ft5j4YzDM23f87zBfDe9g==", + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/@ungap/structured-clone/-/structured-clone-1.4.0.tgz", + "integrity": "sha512-1mEZtMKPM09vDmQt5y7YvmN2+DFTP7Tg0EWXdic8/C6VRnpb33e4ghisCIE3WZjsE2N8mf+QV1Zqh7ZFYLWInQ==", "license": "ISC" }, "node_modules/@unrs/resolver-binding-android-arm-eabi": { @@ -6401,9 +6308,9 @@ } }, "node_modules/ajv": { - "version": "6.14.0", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.14.0.tgz", - "integrity": "sha512-IWrosm/yrn43eiKqkfkHis7QioDleaXQHdDVPKg0FSwwd/DuvyX79TZnFOnYpB7dcsFAMmtFztZuXPDvSePkFw==", + "version": "6.15.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.15.0.tgz", + "integrity": "sha512-fgFx7Hfoq60ytK2c7DhnF8jIvzYgOMxfugjLOSMHjLIPgenqa7S7oaagATUq99mV6IYvN2tRmC0wnTYX6iPbMw==", "dev": true, "license": "MIT", "dependencies": { @@ -6435,9 +6342,9 @@ } }, "node_modules/ajv-formats/node_modules/ajv": { - "version": "8.18.0", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.18.0.tgz", - "integrity": "sha512-PlXPeEWMXMZ7sPYOHqmDyCJzcfNrUr3fGNKtezX14ykXOEIvyK81d+qydx89KY5O71FKMPaQ2vBfBFI5NHR63A==", + "version": "8.20.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.20.0.tgz", + "integrity": "sha512-Thbli+OlOj+iMPYFBVBfJ3OmCAnaSyNn4M1vz9T6Gka5Jt9ba/HIR56joy65tY6kx/FCF5VXNB819Y7/GUrBGA==", "license": "MIT", "dependencies": { "fast-deep-equal": "^3.1.3", @@ -6462,18 +6369,6 @@ "integrity": "sha512-vcZjxvvVoxTeR5XBNJB38oTu/7eDCZlwdz32N1eNgpyPF7j/Z7Idf+CUwQOkKKpJ7RJyjxgLHCM7vdIK0iCNMQ==", "license": "MIT" }, - "node_modules/ansi-styles": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-5.2.0.tgz", - "integrity": "sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==", - "license": "MIT", - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, "node_modules/antd": { "version": "5.29.3", "resolved": "https://registry.npmjs.org/antd/-/antd-5.29.3.tgz", @@ -7102,18 +6997,6 @@ "node": ">=6" } }, - "node_modules/camelcase": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.3.0.tgz", - "integrity": "sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==", - "license": "MIT", - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/caniuse-lite": { "version": "1.0.30001828", "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001828.tgz", @@ -7163,6 +7046,7 @@ "version": "4.1.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, "license": "MIT", "dependencies": { "ansi-styles": "^4.1.0", @@ -7179,6 +7063,7 @@ "version": "4.3.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, "license": "MIT", "dependencies": { "color-convert": "^2.0.1" @@ -7307,6 +7192,7 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, "license": "MIT", "dependencies": { "color-name": "~1.1.4" @@ -7319,6 +7205,7 @@ "version": "1.1.4", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true, "license": "MIT" }, "node_modules/combined-stream": { @@ -7365,15 +7252,6 @@ "dev": true, "license": "MIT" }, - "node_modules/console-table-printer": { - "version": "2.15.0", - "resolved": "https://registry.npmjs.org/console-table-printer/-/console-table-printer-2.15.0.tgz", - "integrity": "sha512-SrhBq4hYVjLCkBVOWaTzceJalvn5K1Zq5aQA6wXC/cYjI3frKWNPEMK3sZsJfNNQApvCQmgBcc13ZKmFj8qExw==", - "license": "MIT", - "dependencies": { - "simple-wcswidth": "^1.1.2" - } - }, "node_modules/content-disposition": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-1.0.1.tgz", @@ -7570,15 +7448,6 @@ } } }, - "node_modules/decamelize": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", - "integrity": "sha512-z2S+W9X73hAUUki+N+9Za2lBlun89zigOyGrsax+KUQ6wKW4ZoWpEYBkGhQjwAjjDCkWxhY0VKEhk8wzY7F5cA==", - "license": "MIT", - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/decode-named-character-reference": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/decode-named-character-reference/-/decode-named-character-reference-1.3.0.tgz", @@ -7827,14 +7696,14 @@ } }, "node_modules/enhanced-resolve": { - "version": "5.19.0", - "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.19.0.tgz", - "integrity": "sha512-phv3E1Xl4tQOShqSte26C7Fl84EwUdZsyOuSSk9qtAGyyQs2s3jJzComh+Abf4g187lUUAvH+H26omrqia2aGg==", + "version": "5.27.0", + "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.27.0.tgz", + "integrity": "sha512-Do6BB2xzlcc/odFg+XEYyneAx4T/WfywO71yw9ePS2tVfRsf7JVR4mUeELadIeHzixkzbG5DpluiEFPi2WGfYQ==", "dev": true, "license": "MIT", "dependencies": { "graceful-fs": "^4.2.4", - "tapable": "^2.3.0" + "tapable": "^2.3.3" }, "engines": { "node": ">=10.13.0" @@ -9234,6 +9103,7 @@ "version": "4.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, "license": "MIT", "engines": { "node": ">=8" @@ -9493,9 +9363,9 @@ } }, "node_modules/highlight.js": { - "version": "11.11.1", - "resolved": "https://registry.npmjs.org/highlight.js/-/highlight.js-11.11.1.tgz", - "integrity": "sha512-Xwwo44whKBVCYoliBQwaPvtd/2tYFkRQtXDWj1nackaV2JPXx3L0+Jvd8/qCJ2p+ML0/XVkJ2q+Mr+UVdpJK5w==", + "version": "11.12.0", + "resolved": "https://registry.npmjs.org/highlight.js/-/highlight.js-11.12.0.tgz", + "integrity": "sha512-nbfWpyRMcMrPMmDwJB+dhX/eiaPKtc2RB+0QZskqJ3WjRA/FDS0e9hZrx8EC/lbEv8gXy98FcDbNa/dspAaJMg==", "license": "BSD-3-Clause", "engines": { "node": ">=12.0.0" @@ -10223,9 +10093,9 @@ } }, "node_modules/jose": { - "version": "6.1.3", - "resolved": "https://registry.npmjs.org/jose/-/jose-6.1.3.tgz", - "integrity": "sha512-0TpaTfihd4QMNwrz/ob2Bp7X04yuxJkjRGi4aKmOqwhov54i6u79oCv7T+C7lo70MKH6BesI3vscD1yb/yzKXQ==", + "version": "6.2.18", + "resolved": "https://registry.npmjs.org/jose/-/jose-6.2.18.tgz", + "integrity": "sha512-doV4thUwgkrycJH4yLeqwTGIIZphHl+pk7CPReuMIhYhncmgzdko85MaCG4YQFTxqMFr1/oEH32tZuKKovcDEg==", "license": "MIT", "funding": { "url": "https://github.com/sponsors/panva" @@ -10247,9 +10117,19 @@ "license": "MIT" }, "node_modules/js-yaml": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.1.tgz", - "integrity": "sha512-qQKT4zQxXl8lLwBtHMWwaTcGfFOZviOJet3Oy/xmGk2gZH677CJM9EvtfdSkgWcATZhj/55JZ0rmy3myCT5lsA==", + "version": "4.3.2", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.3.2.tgz", + "integrity": "sha512-SFNOvSJ+Dgf/9An904Yx+CgSlIPCkIpao4qo51lpee25TIRejdH3rhR4EZMGoNx3/TP3O+wzWuiTFl4sqbltzA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/puzrin" + }, + { + "type": "github", + "url": "https://github.com/sponsors/nodeca" + } + ], "license": "MIT", "dependencies": { "argparse": "^2.0.1" @@ -10378,23 +10258,19 @@ } }, "node_modules/langsmith": { - "version": "0.3.87", - "resolved": "https://registry.npmjs.org/langsmith/-/langsmith-0.3.87.tgz", - "integrity": "sha512-XXR1+9INH8YX96FKWc5tie0QixWz6tOqAsAKfcJyPkE0xPep+NDz0IQLR32q4bn10QK3LqD2HN6T3n6z1YLW7Q==", + "version": "0.14.0", + "resolved": "https://registry.npmjs.org/langsmith/-/langsmith-0.14.0.tgz", + "integrity": "sha512-GpOpjx2rfsfKD6A4nnWfG9kxYbLlx9//catR1eCUwW/nMQxj4Mq2OQL7NJO9MQ5ZcGnvgsnUZdxBZLd2JJC1qA==", "license": "MIT", "dependencies": { - "@types/uuid": "^10.0.0", - "chalk": "^4.1.2", - "console-table-printer": "^2.12.1", - "p-queue": "^6.6.2", - "semver": "^7.6.3", - "uuid": "^10.0.0" + "p-queue": "6.6.2" }, "peerDependencies": { "@opentelemetry/api": "*", "@opentelemetry/exporter-trace-otlp-proto": "*", "@opentelemetry/sdk-trace-base": "*", - "openai": "*" + "openai": "*", + "ws": ">=7" }, "peerDependenciesMeta": { "@opentelemetry/api": { @@ -10408,34 +10284,12 @@ }, "openai": { "optional": true + }, + "ws": { + "optional": true } } }, - "node_modules/langsmith/node_modules/semver": { - "version": "7.7.3", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.3.tgz", - "integrity": "sha512-SdsKMrI9TdgjdweUSR9MweHA4EJ8YxHn8DFaDisvhVlUOe4BF1tLD7GAj0lIqWVl+dPb/rExr0Btby5loQm20Q==", - "license": "ISC", - "bin": { - "semver": "bin/semver.js" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/langsmith/node_modules/uuid": { - "version": "10.0.0", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-10.0.0.tgz", - "integrity": "sha512-8XkAphELsDnEGrDxUOHB3RGvXz6TeuYSGEZBOjtTtPm2lwhGBjLgOzLHB63IUWfBpNucQjND6d3AOudO+H3RWQ==", - "funding": [ - "https://github.com/sponsors/broofa", - "https://github.com/sponsors/ctavan" - ], - "license": "MIT", - "bin": { - "uuid": "dist/bin/uuid" - } - }, "node_modules/language-subtag-registry": { "version": "0.3.23", "resolved": "https://registry.npmjs.org/language-subtag-registry/-/language-subtag-registry-0.3.23.tgz", @@ -14743,19 +14597,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/p-retry": { - "version": "4.6.2", - "resolved": "https://registry.npmjs.org/p-retry/-/p-retry-4.6.2.tgz", - "integrity": "sha512-312Id396EbJdvRONlngUx0NydfrIQ5lsYu0znKVUzVvArzEIt08V1qhtyESbGVd1FGX7UKtiFp5uwKZdM8wIuQ==", - "license": "MIT", - "dependencies": { - "@types/retry": "0.12.0", - "retry": "^0.13.1" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/p-timeout": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/p-timeout/-/p-timeout-3.2.0.tgz", @@ -14893,14 +14734,14 @@ } }, "node_modules/pg": { - "version": "8.18.0", - "resolved": "https://registry.npmjs.org/pg/-/pg-8.18.0.tgz", - "integrity": "sha512-xqrUDL1b9MbkydY/s+VZ6v+xiMUmOUk7SS9d/1kpyQxoJ6U9AO1oIJyUWVZojbfe5Cc/oluutcgFG4L9RDP1iQ==", + "version": "8.23.1", + "resolved": "https://registry.npmjs.org/pg/-/pg-8.23.1.tgz", + "integrity": "sha512-aL96AHANtWjPLDOLqnhx+ngp9+UK7ETEU8VJrDCGvsSSi/mGLcWYsS6Herg7lmaBJe4uwrfqsa7gTEFaSizDoQ==", "license": "MIT", "dependencies": { - "pg-connection-string": "^2.11.0", - "pg-pool": "^3.11.0", - "pg-protocol": "^1.11.0", + "pg-connection-string": "^2.14.1", + "pg-pool": "^3.14.0", + "pg-protocol": "^1.16.1", "pg-types": "2.2.0", "pgpass": "1.0.5" }, @@ -14908,7 +14749,7 @@ "node": ">= 16.0.0" }, "optionalDependencies": { - "pg-cloudflare": "^1.3.0" + "pg-cloudflare": "^1.4.1" }, "peerDependencies": { "pg-native": ">=3.0.1" @@ -14920,16 +14761,16 @@ } }, "node_modules/pg-cloudflare": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/pg-cloudflare/-/pg-cloudflare-1.3.0.tgz", - "integrity": "sha512-6lswVVSztmHiRtD6I8hw4qP/nDm1EJbKMRhf3HCYaqud7frGysPv7FYJ5noZQdhQtN2xJnimfMtvQq21pdbzyQ==", + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/pg-cloudflare/-/pg-cloudflare-1.4.1.tgz", + "integrity": "sha512-6PQbsFWZcp9EmJEwy5cGQ2La+AMWpP46lgbb8X+U/XsHIUweYDNCpeuKck5RxL2MdVFi7krbbEi5nX4Zh7JhrQ==", "license": "MIT", "optional": true }, "node_modules/pg-connection-string": { - "version": "2.11.0", - "resolved": "https://registry.npmjs.org/pg-connection-string/-/pg-connection-string-2.11.0.tgz", - "integrity": "sha512-kecgoJwhOpxYU21rZjULrmrBJ698U2RxXofKVzOn5UDj61BPj/qMb7diYUR1nLScCDbrztQFl1TaQZT0t1EtzQ==", + "version": "2.14.1", + "resolved": "https://registry.npmjs.org/pg-connection-string/-/pg-connection-string-2.14.1.tgz", + "integrity": "sha512-qR3kGNPBLpCNtz0evbKA0Y/MRFXwSSdT+pTJvYp/bXTcReZbvX1kzF0IyTc1QnxqF7AZbOeBhNL8R5mYQZV/MA==", "license": "MIT" }, "node_modules/pg-int8": { @@ -14942,18 +14783,18 @@ } }, "node_modules/pg-pool": { - "version": "3.11.0", - "resolved": "https://registry.npmjs.org/pg-pool/-/pg-pool-3.11.0.tgz", - "integrity": "sha512-MJYfvHwtGp870aeusDh+hg9apvOe2zmpZJpyt+BMtzUWlVqbhFmMK6bOBXLBUPd7iRtIF9fZplDc7KrPN3PN7w==", + "version": "3.14.0", + "resolved": "https://registry.npmjs.org/pg-pool/-/pg-pool-3.14.0.tgz", + "integrity": "sha512-gKtPkFdQPU3DksooVLi9LsjZxrsBUZIpa+7aVx+LV5pNh0KzP4Zleud2po+ConrxbuXGBJ6Hfer6hdgpIBpBaw==", "license": "MIT", "peerDependencies": { "pg": ">=8.0" } }, "node_modules/pg-protocol": { - "version": "1.11.0", - "resolved": "https://registry.npmjs.org/pg-protocol/-/pg-protocol-1.11.0.tgz", - "integrity": "sha512-pfsxk2M9M3BuGgDOfuy37VNRRX3jmKgMjcvAcWqNDpZSf4cUmv8HSOl5ViRQFsfARFn0KuUQTgLxVMbNq5NW3g==", + "version": "1.16.1", + "resolved": "https://registry.npmjs.org/pg-protocol/-/pg-protocol-1.16.1.tgz", + "integrity": "sha512-p9VOFMiHB/ZbJATetbg+99PxssTVSQRnyuPSQ67mN1+1KBOjZaZ83ZQzltnxPhJwSsC3nwVjJ10DVJlerbFzLg==", "license": "MIT" }, "node_modules/pg-types": { @@ -14997,9 +14838,9 @@ "license": "ISC" }, "node_modules/picomatch": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", - "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.2.tgz", + "integrity": "sha512-V7+vQEJ06Z+c5tSye8S+nHUfI51xoXIXjHQ99cQtKUkQqqO1kO/KCJUfZXuB47h/YBlDhah2H3hdUGXn8ie0oA==", "dev": true, "license": "MIT", "engines": { @@ -15980,9 +15821,9 @@ } }, "node_modules/react-hook-form": { - "version": "7.71.1", - "resolved": "https://registry.npmjs.org/react-hook-form/-/react-hook-form-7.71.1.tgz", - "integrity": "sha512-9SUJKCGKo8HUSsCO+y0CtqkqI5nNuaDqTxyqPsZPqIwudpj4rCrAz/jZV+jn57bx5gtZKOh3neQu94DXMc+w5w==", + "version": "7.92.0", + "resolved": "https://registry.npmjs.org/react-hook-form/-/react-hook-form-7.92.0.tgz", + "integrity": "sha512-O5ILyY5fYHN7N13Pfxpe55KboyNFsJdM03BHpshQkClJd8raugiAUGY7VjifITrfhVxyx81ko25azXCoayhf1w==", "license": "MIT", "engines": { "node": ">=18.0.0" @@ -15992,7 +15833,13 @@ "url": "https://opencollective.com/react-hook-form" }, "peerDependencies": { + "@types/react": "*", "react": "^16.8.0 || ^17 || ^18 || ^19" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } } }, "node_modules/react-intersection-observer": { @@ -16608,15 +16455,6 @@ "url": "https://github.com/privatenumber/resolve-pkg-maps?sponsor=1" } }, - "node_modules/retry": { - "version": "0.13.1", - "resolved": "https://registry.npmjs.org/retry/-/retry-0.13.1.tgz", - "integrity": "sha512-XQBQ3I8W1Cge0Seh+6gjj03LbmRFWuoszgK9ooCpwYIrhhoO80pfq4cUkU5DkknwfOfFteRwlZ56PYOGYyFWdg==", - "license": "MIT", - "engines": { - "node": ">= 4" - } - }, "node_modules/reusify": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.1.0.tgz", @@ -17096,12 +16934,6 @@ "simple-concat": "^1.0.0" } }, - "node_modules/simple-wcswidth": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/simple-wcswidth/-/simple-wcswidth-1.1.2.tgz", - "integrity": "sha512-j7piyCjAeTDSjzTSQ7DokZtMNwNlEAyxqSZeCS+CXH7fJ4jx3FuJ/mTW3mE+6JLs4VJBbcll0Kjn+KXI5t21Iw==", - "license": "MIT" - }, "node_modules/source-map-js": { "version": "1.2.4", "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.4.tgz", @@ -17425,6 +17257,7 @@ "version": "7.2.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, "license": "MIT", "dependencies": { "has-flag": "^4.0.0" @@ -17470,9 +17303,9 @@ "license": "MIT" }, "node_modules/tapable": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/tapable/-/tapable-2.3.0.tgz", - "integrity": "sha512-g9ljZiwki/LfxmQADO3dEY1CbpmXT5Hm2fJ+QaGKwSXUylMybePR7/67YW7jOrrvjEgL1Fmz5kzyAjWVWLlucg==", + "version": "2.3.4", + "resolved": "https://registry.npmjs.org/tapable/-/tapable-2.3.4.tgz", + "integrity": "sha512-NHFiWnAbMJxNNpBwiO7jJVGDuqMxT9/oV8v57RR+fgBQShkJil5inGD8/xWy0hjLyHQyX1tu27QANhlz3KBqCg==", "dev": true, "license": "MIT", "engines": { @@ -17484,9 +17317,9 @@ } }, "node_modules/tar-fs": { - "version": "2.1.4", - "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-2.1.4.tgz", - "integrity": "sha512-mDAjwmZdh7LTT6pNleZ05Yt65HC3E+NiQzl672vQG38jIrehtJk/J3mNwIg+vShQPcLF/LV7CMnDW6vjj6sfYQ==", + "version": "2.1.6", + "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-2.1.6.tgz", + "integrity": "sha512-vsdruOmnweDIXJXWpfc5aszWMVOj6qFI+dXxNuprh6Kt+WrGJh1MQL/2xYUEzI3EX86o9b2Rop8ziIF5Ol/UoQ==", "license": "MIT", "optional": true, "dependencies": { @@ -17546,9 +17379,9 @@ } }, "node_modules/tinyglobby/node_modules/picomatch": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz", - "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", + "version": "4.0.7", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.7.tgz", + "integrity": "sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA==", "dev": true, "license": "MIT", "engines": { diff --git a/apps/rag-knowledge-agent/package.json b/apps/rag-knowledge-agent/package.json index 0a520b6..42c5890 100644 --- a/apps/rag-knowledge-agent/package.json +++ b/apps/rag-knowledge-agent/package.json @@ -7,14 +7,16 @@ "dev:webpack": "NODE_OPTIONS='--no-warnings' next dev --webpack", "build": "NODE_OPTIONS='--no-warnings' next build --webpack", "start": "NODE_OPTIONS='--no-warnings' next start", - "lint": "eslint" + "lint": "eslint", + "typecheck": "tsc --noEmit", + "test": "node --test 'src/**/*.test.ts'" }, "dependencies": { "@ai-sdk/openai": "^3.0.115", "@ant-design/icons": "^5.6.1", "@ant-design/v5-patch-for-react-19": "^1.0.3", - "@langchain/core": "^0.3.72", - "@langchain/textsplitters": "^0.1.0", + "@langchain/core": "^1.5.0", + "@langchain/textsplitters": "^1.0.2", "@llamaindex/chat-ui": "^0.6.1", "@llamaindex/core": "0.6.22", "@llamaindex/env": "0.1.30", @@ -53,5 +55,10 @@ "eslint-config-next": "^16.1.0", "tailwindcss": "^4", "typescript": "^5" + }, + "overrides": { + "@mdxeditor/editor": { + "js-yaml": "^4.3.2" + } } } diff --git a/apps/rag-knowledge-agent/postgres-schema.sql b/apps/rag-knowledge-agent/postgres-schema.sql index ffcdd6d..9c55bb5 100644 --- a/apps/rag-knowledge-agent/postgres-schema.sql +++ b/apps/rag-knowledge-agent/postgres-schema.sql @@ -163,6 +163,19 @@ CREATE INDEX IF NOT EXISTS idx_chat_messages_thread_id ON public.chat_messages(t CREATE INDEX IF NOT EXISTS idx_chat_messages_user_id ON public.chat_messages(user_id); CREATE INDEX IF NOT EXISTS idx_chat_messages_created_at ON public.chat_messages(created_at); +-- The app connects as the table owner, which row-level security does not restrict. With RLS on +-- and no policies, every other role (such as Supabase's Data API roles) is denied. +ALTER TABLE public.users ENABLE ROW LEVEL SECURITY; +ALTER TABLE public.integrations ENABLE ROW LEVEL SECURITY; +ALTER TABLE public.connector_metadata ENABLE ROW LEVEL SECURITY; +ALTER TABLE public.documents ENABLE ROW LEVEL SECURITY; +ALTER TABLE public.document_chunks ENABLE ROW LEVEL SECURITY; +ALTER TABLE public.agents ENABLE ROW LEVEL SECURITY; +ALTER TABLE public.agent_integrations ENABLE ROW LEVEL SECURITY; +ALTER TABLE public.agent_documents ENABLE ROW LEVEL SECURITY; +ALTER TABLE public.threads ENABLE ROW LEVEL SECURITY; +ALTER TABLE public.chat_messages ENABLE ROW LEVEL SECURITY; + -- Timestamp trigger CREATE OR REPLACE FUNCTION update_updated_at_column() RETURNS TRIGGER AS $$ diff --git a/apps/rag-knowledge-agent/src/app/agents/[id]/edit/page.tsx b/apps/rag-knowledge-agent/src/app/agents/[id]/edit/page.tsx index f10f068..abf8dce 100644 --- a/apps/rag-knowledge-agent/src/app/agents/[id]/edit/page.tsx +++ b/apps/rag-knowledge-agent/src/app/agents/[id]/edit/page.tsx @@ -278,7 +278,10 @@ export default function EditAgentPage() { } // Start document processing for any new files - if (Object.keys(agentIntegrations).length > 0) { + const selectedAgentIntegrations = Object.fromEntries( + selectedIntegrations.map(integrationId => [integrationId, agentIntegrations[integrationId] || []]) + ) + if (selectedIntegrations.length > 0) { try { const response = await fetch('/api/agents/process', { method: 'POST', @@ -287,7 +290,7 @@ export default function EditAgentPage() { }, body: JSON.stringify({ agentId: agentId, - agentIntegrations: agentIntegrations + agentIntegrations: selectedAgentIntegrations }), }) diff --git a/apps/rag-knowledge-agent/src/app/api/agents/[id]/integrations/route.ts b/apps/rag-knowledge-agent/src/app/api/agents/[id]/integrations/route.ts index 2002814..130ce70 100644 --- a/apps/rag-knowledge-agent/src/app/api/agents/[id]/integrations/route.ts +++ b/apps/rag-knowledge-agent/src/app/api/agents/[id]/integrations/route.ts @@ -62,8 +62,9 @@ export async function PUT( typeof f === 'string' ? f : JSON.stringify(f) ) as string[] await query( - `INSERT INTO agent_integrations (agent_id, integration_id, file_ids) VALUES ($1, $2, $3)`, - [agentId, integration_id, fileIdsArray] + `INSERT INTO agent_integrations (agent_id, integration_id, file_ids) + SELECT $1, id, $3 FROM integrations WHERE id = $2 AND user_id = $4`, + [agentId, integration_id, fileIdsArray, user.id] ) } diff --git a/apps/rag-knowledge-agent/src/app/api/agents/process/route.ts b/apps/rag-knowledge-agent/src/app/api/agents/process/route.ts index 9d16bf8..06b1c88 100644 --- a/apps/rag-knowledge-agent/src/app/api/agents/process/route.ts +++ b/apps/rag-knowledge-agent/src/app/api/agents/process/route.ts @@ -32,8 +32,8 @@ export async function POST(request: NextRequest) { const integrationIds = Object.keys(agentIntegrations) as string[] const integrations = await query<{ id: string; stackone_account_id: string }>( - `SELECT id, stackone_account_id FROM integrations WHERE id = ANY($1::uuid[])`, - [integrationIds] + `SELECT id, stackone_account_id FROM integrations WHERE id = ANY($1::uuid[]) AND user_id = $2`, + [integrationIds, user.id] ) if (integrations.length === 0) { return NextResponse.json({ error: 'Integrations not found' }, { status: 404 }) diff --git a/apps/rag-knowledge-agent/src/app/api/chat/route.ts b/apps/rag-knowledge-agent/src/app/api/chat/route.ts index 1520b41..735131a 100644 --- a/apps/rag-knowledge-agent/src/app/api/chat/route.ts +++ b/apps/rag-knowledge-agent/src/app/api/chat/route.ts @@ -42,8 +42,9 @@ export async function POST(request: NextRequest) { const integrations = integrationIds.length > 0 ? await query<{ id: string; stackone_account_id: string }>( - `SELECT id, stackone_account_id FROM integrations WHERE id = ANY($1::uuid[])`, - [integrationIds] + `SELECT id, stackone_account_id FROM integrations + WHERE id = ANY($1::uuid[]) AND user_id = $2`, + [integrationIds, user.id] ) : [] @@ -138,7 +139,6 @@ export async function POST(request: NextRequest) { integrationIdsFromAgent: integrationIds.length, integrationsFound: integrations.length, accountIds: accountIds.length, - accountIdPreviews: accountIds.map(id => id.slice(0, 12) + '...'), documentIds: documentIds.length, documentContext: documentContext.length, hasStackOneApiKey: !!process.env.STACKONE_API_KEY, diff --git a/apps/rag-knowledge-agent/src/app/api/documents/ingest/route.ts b/apps/rag-knowledge-agent/src/app/api/documents/ingest/route.ts index 97fb435..fb7ddb8 100644 --- a/apps/rag-knowledge-agent/src/app/api/documents/ingest/route.ts +++ b/apps/rag-knowledge-agent/src/app/api/documents/ingest/route.ts @@ -85,7 +85,7 @@ export async function GET(request: NextRequest) { export async function DELETE(request: NextRequest) { try { - await requireUser() + const user = await requireUser() const { fileIds } = await request.json() if (!fileIds || !Array.isArray(fileIds) || fileIds.length === 0) { @@ -94,7 +94,7 @@ export async function DELETE(request: NextRequest) { // Initialize RAG service and delete documents const ragService = new RAGService() - await ragService.deleteDocuments(fileIds) + await ragService.deleteDocuments(fileIds, user.id) return NextResponse.json({ success: true, diff --git a/apps/rag-knowledge-agent/src/app/api/health/route.ts b/apps/rag-knowledge-agent/src/app/api/health/route.ts index 145d286..966f98b 100644 --- a/apps/rag-knowledge-agent/src/app/api/health/route.ts +++ b/apps/rag-knowledge-agent/src/app/api/health/route.ts @@ -1,7 +1,15 @@ import { NextResponse } from 'next/server' import { RAGService } from '@/lib/llamaindex/rag-service' +import { requireUser } from '@/lib/auth-server' +// Signed-in only: each call spends an embeddings request on the app's OpenAI key. export async function GET() { + try { + await requireUser() + } catch { + return NextResponse.json({ error: 'Unauthorized' }, { status: 401 }) + } + const health = { status: 'ok', timestamp: new Date().toISOString(), diff --git a/apps/rag-knowledge-agent/src/app/api/integrations/route.ts b/apps/rag-knowledge-agent/src/app/api/integrations/route.ts index 4537a49..bcd95d0 100644 --- a/apps/rag-knowledge-agent/src/app/api/integrations/route.ts +++ b/apps/rag-knowledge-agent/src/app/api/integrations/route.ts @@ -1,6 +1,7 @@ import { NextRequest, NextResponse } from 'next/server' import { query, queryOne } from '@/lib/db' import { requireUser } from '@/lib/auth-server' +import { getAccountOwnerId } from '@/lib/stackone/api' import { logger } from '@/utils/logger' /** GET /api/integrations - list current user's integrations */ @@ -63,18 +64,26 @@ export async function POST(request: NextRequest) { const user = await requireUser() const body = await request.json() const { provider, stackone_account_id, account_name } = body - if (!provider || !stackone_account_id) { + if (!provider || typeof stackone_account_id !== 'string' || !stackone_account_id) { return NextResponse.json({ error: 'provider and stackone_account_id required' }, { status: 400 }) } + const apiKey = process.env.STACKONE_API_KEY + if (!apiKey) { + return NextResponse.json({ error: 'StackOne API key not configured' }, { status: 500 }) + } + if ((await getAccountOwnerId(apiKey, stackone_account_id)) !== user.id) { + return NextResponse.json({ error: 'Account is not linked to this user' }, { status: 403 }) + } const rows = await query( `INSERT INTO integrations (user_id, provider, stackone_account_id, account_name, status) VALUES ($1, $2, $3, $4, 'active') ON CONFLICT (stackone_account_id) DO UPDATE SET status = 'active', account_name = COALESCE(EXCLUDED.account_name, integrations.account_name), updated_at = NOW() + WHERE integrations.user_id = EXCLUDED.user_id RETURNING *`, [user.id, provider, stackone_account_id, account_name ?? 'Connected account'] ) const integration = rows[0] - if (!integration) return NextResponse.json({ error: 'Failed to create integration' }, { status: 500 }) + if (!integration) return NextResponse.json({ error: 'Account is linked to another user' }, { status: 409 }) return NextResponse.json({ integration }) } catch (err) { if ((err as Error).message === 'Unauthorized') { diff --git a/apps/rag-knowledge-agent/src/app/api/stackone/connect-session/route.ts b/apps/rag-knowledge-agent/src/app/api/stackone/connect-session/route.ts index cdc5f00..b2b6caf 100644 --- a/apps/rag-knowledge-agent/src/app/api/stackone/connect-session/route.ts +++ b/apps/rag-knowledge-agent/src/app/api/stackone/connect-session/route.ts @@ -1,5 +1,6 @@ import { NextRequest, NextResponse } from 'next/server' import { requireUser } from '@/lib/auth-server' +import { queryOne } from '@/lib/db' import { logger } from '@/utils/logger' /** Parse AVAILABLE_INTEGRATION_VERSIONS env (format: googledrive:1.0,googlesheets:1.0) into provider -> version map */ @@ -23,7 +24,17 @@ function getIntegrationVersionsByProvider(): Record { export async function POST(request: NextRequest) { try { const user = await requireUser() - const { origin_owner_id, origin_owner_name, provider, account_id, multiple } = await request.json() + const { provider, account_id, multiple } = await request.json() + + if (account_id) { + const owned = await queryOne<{ id: string }>( + `SELECT id FROM integrations WHERE stackone_account_id = $1 AND user_id = $2`, + [account_id, user.id] + ) + if (!owned) { + return NextResponse.json({ error: 'Account not found' }, { status: 404 }) + } + } const STACKONE_API_KEY = process.env.STACKONE_API_KEY if (!STACKONE_API_KEY) { @@ -49,8 +60,8 @@ export async function POST(request: NextRequest) { const payload: Record = { expires_in: 1800, // 30 minutes multiple: multiple || false, - origin_owner_id: origin_owner_id || user.id, - origin_owner_name: origin_owner_name || user.email || user.id, + origin_owner_id: user.id, + origin_owner_name: user.email || user.id, account_id: account_id || undefined, metadata, } diff --git a/apps/rag-knowledge-agent/src/app/api/stackone/delete-account/route.ts b/apps/rag-knowledge-agent/src/app/api/stackone/delete-account/route.ts index 26cca74..870a1ce 100644 --- a/apps/rag-knowledge-agent/src/app/api/stackone/delete-account/route.ts +++ b/apps/rag-knowledge-agent/src/app/api/stackone/delete-account/route.ts @@ -1,17 +1,26 @@ import { NextRequest, NextResponse } from 'next/server' import { requireUser } from '@/lib/auth-server' +import { queryOne } from '@/lib/db' import { logger } from '@/utils/logger' import { deleteAccount } from '@/lib/stackone/api' export async function DELETE(request: NextRequest) { try { - await requireUser() + const user = await requireUser() const { accountId } = await request.json() if (!accountId) { return NextResponse.json({ error: 'Account ID is required' }, { status: 400 }) } + const owned = await queryOne<{ id: string }>( + `SELECT id FROM integrations WHERE stackone_account_id = $1 AND user_id = $2`, + [accountId, user.id] + ) + if (!owned) { + return NextResponse.json({ error: 'Account not found' }, { status: 404 }) + } + // Get StackOne API key from environment const apiKey = process.env.STACKONE_API_KEY if (!apiKey) { diff --git a/apps/rag-knowledge-agent/src/app/api/stackone/webhook/route.ts b/apps/rag-knowledge-agent/src/app/api/stackone/webhook/route.ts index 6c358cb..ac0e07a 100644 --- a/apps/rag-knowledge-agent/src/app/api/stackone/webhook/route.ts +++ b/apps/rag-knowledge-agent/src/app/api/stackone/webhook/route.ts @@ -1,5 +1,5 @@ import { NextRequest, NextResponse } from 'next/server' -import { createHmac } from 'crypto' +import { createHmac, timingSafeEqual } from 'crypto' import { query, queryOne } from '@/lib/db' import { downloadFile, getDocumentContent } from '@/lib/stackone/api' import { processDocument } from '@/lib/llamaindex/rag-service' @@ -35,8 +35,9 @@ interface StackOneWebhookPayload { function isSignatureValid(signature: string | null, payload: string, secret: string): boolean { if (!signature || !secret) return false - const hash = createHmac('sha256', secret).update(payload).digest('base64url') - return hash === signature + const expected = Buffer.from(createHmac('sha256', secret).update(payload).digest('base64url')) + const received = Buffer.from(signature) + return expected.length === received.length && timingSafeEqual(expected, received) } export async function POST(request: NextRequest) { @@ -58,12 +59,14 @@ export async function POST(request: NextRequest) { }) const secret = process.env.STACKONE_WEBHOOK_SECRET - if (secret) { - const signature = request.headers.get('x-stackone-signature') - if (!isSignatureValid(signature, rawBody, secret)) { - logger.warn('[Webhook] Signature verification failed', { event, account_id: accountId }) - return NextResponse.json({ error: 'Invalid signature' }, { status: 401 }) - } + if (!secret) { + logger.error('[Webhook] STACKONE_WEBHOOK_SECRET is not set; refusing unsigned events') + return NextResponse.json({ error: 'Webhook signing secret not configured' }, { status: 503 }) + } + const signature = request.headers.get('x-stackone-signature') + if (!isSignatureValid(signature, rawBody, secret)) { + logger.warn('[Webhook] Signature verification failed', { event, account_id: accountId }) + return NextResponse.json({ error: 'Invalid signature' }, { status: 401 }) } logger.log('[Webhook] Event received', { diff --git a/apps/rag-knowledge-agent/src/app/login/page.tsx b/apps/rag-knowledge-agent/src/app/login/page.tsx index bfe6e84..593f469 100644 --- a/apps/rag-knowledge-agent/src/app/login/page.tsx +++ b/apps/rag-knowledge-agent/src/app/login/page.tsx @@ -38,6 +38,7 @@ import { handleAdditionalLinkMouseEnter, handleAdditionalLinkMouseLeave } from './loginUtils' +import { sameOriginPath } from './sameOriginPath' const TypographyTitle = Typography.Title as any const TypographyText = Typography.Text as any @@ -51,7 +52,7 @@ export default function LoginPage() { const [isForgotPasswordMode, setIsForgotPasswordMode] = useState(false) const searchParams = useSearchParams() const messageParam = searchParams.get('message') - const redirectTo = searchParams.get('redirectTo') + const redirectTo = sameOriginPath(searchParams.get('redirectTo')) const router = useRouter() const { data: session, status } = useSession() diff --git a/apps/rag-knowledge-agent/src/app/login/sameOriginPath.test.ts b/apps/rag-knowledge-agent/src/app/login/sameOriginPath.test.ts new file mode 100644 index 0000000..4da26a5 --- /dev/null +++ b/apps/rag-knowledge-agent/src/app/login/sameOriginPath.test.ts @@ -0,0 +1,28 @@ +import { test } from 'node:test' +import assert from 'node:assert/strict' +import { sameOriginPath } from './sameOriginPath.ts' + +test('keeps paths on this origin', () => { + assert.equal(sameOriginPath('/dashboard'), '/dashboard') + assert.equal(sameOriginPath('/agents/1/chat?x=1#h'), '/agents/1/chat?x=1#h') + assert.equal(sameOriginPath('/%2F%2Fevil.com'), '/%2F%2Fevil.com') +}) + +test('rejects targets a browser would send to another origin', () => { + for (const value of [ + '//evil.com', + '/\\evil.com', + '/.//evil.com', + '/a/..//evil.com', + '/%2e//evil.com', + '/./\\evil.com', + '/\t/evil.com', + 'https://evil.com', + 'javascript:alert(1)', + 'dashboard', + '', + null, + ]) { + assert.equal(sameOriginPath(value), null, JSON.stringify(value)) + } +}) diff --git a/apps/rag-knowledge-agent/src/app/login/sameOriginPath.ts b/apps/rag-knowledge-agent/src/app/login/sameOriginPath.ts new file mode 100644 index 0000000..adfd607 --- /dev/null +++ b/apps/rag-knowledge-agent/src/app/login/sameOriginPath.ts @@ -0,0 +1,12 @@ +const PLACEHOLDER_ORIGIN = 'http://same-origin.invalid' + +// Browsers read a leading "//" or "/\" as another host, also once dot segments resolve ("/.//x"). +const PROTOCOL_RELATIVE = /^\/[/\\]/ + +export const sameOriginPath = (value: string | null): string | null => { + if (!value || !value.startsWith('/') || PROTOCOL_RELATIVE.test(value)) return null + if (!URL.canParse(value, PLACEHOLDER_ORIGIN)) return null + const url = new URL(value, PLACEHOLDER_ORIGIN) + if (url.origin !== PLACEHOLDER_ORIGIN || PROTOCOL_RELATIVE.test(url.pathname)) return null + return url.pathname + url.search + url.hash +} diff --git a/apps/rag-knowledge-agent/src/components/IntegrationActions.tsx b/apps/rag-knowledge-agent/src/components/IntegrationActions.tsx index bcd194d..25c9032 100644 --- a/apps/rag-knowledge-agent/src/components/IntegrationActions.tsx +++ b/apps/rag-knowledge-agent/src/components/IntegrationActions.tsx @@ -161,7 +161,7 @@ export function ConnectProvider({ provider, onSuccess }: ConnectProviderProps) { const [isSettingUp, setIsSettingUp] = useState(false) const [error, setError] = useState(null) - const handleConnectSuccess = async (account: Account) => { + const handleConnectSuccess = async (account: Account & { name?: string }) => { logger.log('Connect success:', account) setIsSettingUp(true) setError(null) diff --git a/apps/rag-knowledge-agent/src/components/StackOneHub.tsx b/apps/rag-knowledge-agent/src/components/StackOneHub.tsx index e2efa63..76eb6cf 100644 --- a/apps/rag-knowledge-agent/src/components/StackOneHub.tsx +++ b/apps/rag-knowledge-agent/src/components/StackOneHub.tsx @@ -3,7 +3,7 @@ import { useCallback, useEffect, useRef } from 'react' import { useStackOneHub } from '@stackone/react-hub' import { Account } from '@stackone/react-hub/dist/entities/Account' -import { getSessionTokenForUser } from '@/utils/sessionUtils' +import { getSessionToken } from '@/utils/sessionUtils' import { logger } from '@/utils/logger' interface StackOneHubProps { @@ -37,7 +37,7 @@ export function StackOneHub({ 'https://stackone.com' ] - if (!allowedOrigins.some(origin => event.origin.startsWith(origin))) { + if (!allowedOrigins.includes(event.origin)) { return } @@ -99,7 +99,7 @@ export function StackOneHub({ const startFlow = useCallback(async () => { try { - const sessionToken = await getSessionTokenForUser(provider, accountId, multiple) + const sessionToken = await getSessionToken({ provider, account_id: accountId, multiple }) const connectOptions = { sessionToken: sessionToken.token, diff --git a/apps/rag-knowledge-agent/src/lib/llamaindex/rag-service.ts b/apps/rag-knowledge-agent/src/lib/llamaindex/rag-service.ts index 59e7437..2534c29 100644 --- a/apps/rag-knowledge-agent/src/lib/llamaindex/rag-service.ts +++ b/apps/rag-knowledge-agent/src/lib/llamaindex/rag-service.ts @@ -293,12 +293,12 @@ Guidelines: return Math.min(avgSimilarity + chunkBonus, 1.0) } - async deleteDocuments(documentIds: string[]): Promise { + async deleteDocuments(documentIds: string[], userId: string): Promise { try { if (documentIds.length === 0) return await query( - `DELETE FROM document_chunks WHERE document_id = ANY($1::uuid[])`, - [documentIds] + `DELETE FROM document_chunks WHERE document_id = ANY($1::uuid[]) AND user_id = $2`, + [documentIds, userId] ) } catch (error) { logger.error('Error deleting documents:', error) diff --git a/apps/rag-knowledge-agent/src/lib/stackone/api.ts b/apps/rag-knowledge-agent/src/lib/stackone/api.ts index fd155ab..a517302 100644 --- a/apps/rag-knowledge-agent/src/lib/stackone/api.ts +++ b/apps/rag-knowledge-agent/src/lib/stackone/api.ts @@ -21,6 +21,12 @@ function getStackOneHeaders(apiKey: string, includeContentType: boolean = true): return headers } +/** One URL path segment; "." and ".." would be resolved away by the URL parser. */ +function pathSegment(id: string): string { + if (id === '.' || id === '..') throw new Error(`Invalid StackOne ID: ${id}`) + return encodeURIComponent(id) +} + export interface StackOneDocument { id: string; name: string; @@ -100,9 +106,19 @@ export async function listUserAccounts(apiKey: string): Promise { + const response = await fetch(`${STACKONE_API_BASE}/accounts/${pathSegment(accountId)}`, { + headers: getStackOneHeaders(apiKey), + }) + if (!response.ok) return null + const account = (await response.json()) as { origin_owner_id?: string } + return account.origin_owner_id ?? null +} + export async function getAccountMetaInformation(apiKey: string, accountId: string): Promise { try { - const response = await fetch(`${STACKONE_API_BASE}/accounts/${accountId}/meta`, { + const response = await fetch(`${STACKONE_API_BASE}/accounts/${pathSegment(accountId)}/meta`, { headers: getStackOneHeaders(apiKey), }) @@ -230,7 +246,7 @@ export async function downloadFile(apiKey: string, fileId: string, accountId?: s // Check if this is a Google Workspace document that needs export const exportFormat = getExportFormat(fileMetadata.mime_type, fileMetadata.export_formats) - let url = `${STACKONE_API_BASE}/unified/documents/files/${fileId}/download` + let url = `${STACKONE_API_BASE}/unified/documents/files/${pathSegment(fileId)}/download` // If it's a Google Workspace document, add export format parameter if (exportFormat) { @@ -280,7 +296,7 @@ export async function downloadFile(apiKey: string, fileId: string, accountId?: s export async function getFileMetadata(apiKey: string, fileId: string, accountId?: string): Promise { try { - const url = `${STACKONE_API_BASE}/unified/documents/files/${fileId}` + const url = `${STACKONE_API_BASE}/unified/documents/files/${pathSegment(fileId)}` logger.log(`Getting file metadata from URL: ${url}`) logger.log(`File ID: ${fileId}`) logger.log(`Account ID: ${accountId}`) @@ -353,7 +369,7 @@ export async function getFileMetadata(apiKey: string, fileId: string, accountId? export async function getDocumentContent(apiKey: string, fileId: string, accountId?: string): Promise { try { // Try to get document content using the correct StackOne API - const url = `${STACKONE_API_BASE}/unified/documents/files/${fileId}` + const url = `${STACKONE_API_BASE}/unified/documents/files/${pathSegment(fileId)}` logger.log(`Trying to get document content from URL: ${url}`) logger.log(`File ID: ${fileId}`) logger.log(`Account ID: ${accountId}`) @@ -425,7 +441,7 @@ export async function createSessionToken( export async function deleteAccount(apiKey: string, accountId: string): Promise { try { - const response = await fetch(`${STACKONE_API_BASE}/accounts/${accountId}`, { + const response = await fetch(`${STACKONE_API_BASE}/accounts/${pathSegment(accountId)}`, { method: 'DELETE', headers: getStackOneHeaders(apiKey), }) diff --git a/apps/rag-knowledge-agent/src/lib/stackone/meta-tools.ts b/apps/rag-knowledge-agent/src/lib/stackone/meta-tools.ts index c5fb226..5737c10 100644 --- a/apps/rag-knowledge-agent/src/lib/stackone/meta-tools.ts +++ b/apps/rag-knowledge-agent/src/lib/stackone/meta-tools.ts @@ -247,9 +247,10 @@ async function getToolsForAccounts(accountIds: string[]) { const toolset = new StackOneToolSet({ baseUrl }) const tools = await toolset.fetchTools({ accountIds }) - const accountIdsForLog = accountIds.map((id) => id.slice(0, 12) + '...') - const toolCount = tools.toArray().length - console.log('[StackOne tools] fetchTools result:', { accountIdsForLog, toolCount }) + console.log('[StackOne tools] fetchTools result:', { + accountCount: accountIds.length, + toolCount: tools.toArray().length, + }) return tools } diff --git a/apps/rag-knowledge-agent/src/types/jsx.d.ts b/apps/rag-knowledge-agent/src/types/jsx.d.ts index 9c40ad1..88af319 100644 --- a/apps/rag-knowledge-agent/src/types/jsx.d.ts +++ b/apps/rag-knowledge-agent/src/types/jsx.d.ts @@ -1,104 +1,17 @@ -/// +import type React from 'react' +// React 19 types drop the global JSX namespace; @llamaindex/chat-ui ships an +// older react-markdown whose .ts sources still reference it. declare global { namespace JSX { - interface IntrinsicElements { - // eslint-disable-next-line @typescript-eslint/no-explicit-any - [elemName: string]: any; - } + type ElementType = React.JSX.ElementType + type Element = React.JSX.Element + type ElementClass = React.JSX.ElementClass + type ElementAttributesProperty = React.JSX.ElementAttributesProperty + type ElementChildrenAttribute = React.JSX.ElementChildrenAttribute + type LibraryManagedAttributes = React.JSX.LibraryManagedAttributes + type IntrinsicAttributes = React.JSX.IntrinsicAttributes + type IntrinsicClassAttributes = React.JSX.IntrinsicClassAttributes + type IntrinsicElements = React.JSX.IntrinsicElements } - - namespace React { - type FC = import('react').FC; - } - - const React: { - FC: typeof import('react').FC; - }; -} - -// Fix React type compatibility issues with Ant Design -declare module 'react' { - namespace JSX { - interface Element extends React.ReactElement {} - interface ElementClass extends React.Component {} - interface ElementAttributesProperty { - props: {}; - } - interface ElementChildrenAttribute { - children: {}; - } - } - - // Re-export React hooks and components - export const useEffect: typeof import('react').useEffect; - export const useState: typeof import('react').useState; - export const useCallback: typeof import('react').useCallback; - export const useRef: typeof import('react').useRef; - export const Component: typeof import('react').Component; - export const ReactElement: typeof import('react').ReactElement; - export const ReactNode: typeof import('react').ReactNode; - export const FC: typeof import('react').FC; - - // Re-export React types - export type ReactNode = import('react').ReactNode; -} - -// Fix Ant Design component types -declare module 'antd' { - export interface CardInterface { - (props: any): React.ReactElement; - } - - export interface CompoundedComponent { - (props: any): React.ReactElement; - } - - export interface TagType { - (props: any): React.ReactElement; - } - - export interface ForwardRefExoticComponent { - (props: T): React.ReactElement; - } - - // Export Ant Design components - export const Button: CompoundedComponent; - export const Card: CardInterface; - export const Space: CompoundedComponent; - export const Typography: { - Text: ForwardRefExoticComponent; - Title: ForwardRefExoticComponent; - Link: ForwardRefExoticComponent; - }; - export const Tag: TagType; - export const Tooltip: CompoundedComponent; - export const Row: CompoundedComponent; - export const Col: CompoundedComponent; - export const Avatar: ForwardRefExoticComponent; - export const Checkbox: CompoundedComponent; - export const Empty: CompoundedComponent; - export const ConfigProvider: CompoundedComponent; - export const theme: any; - export const Input: CompoundedComponent & { - TextArea: CompoundedComponent; - Search: CompoundedComponent; - Password: CompoundedComponent; - }; - export const Drawer: CompoundedComponent; - export const List: CompoundedComponent; - export const Modal: CompoundedComponent; - export const App: CompoundedComponent & { - useApp: () => any; - }; - export const Layout: CompoundedComponent & { - Sider: CompoundedComponent; - }; - export const Menu: CompoundedComponent; - export const Dropdown: CompoundedComponent; - export const Divider: CompoundedComponent; - export const Form: CompoundedComponent & { - Item: CompoundedComponent; - }; - export const Alert: CompoundedComponent; } diff --git a/apps/rag-knowledge-agent/src/utils/sessionUtils.ts b/apps/rag-knowledge-agent/src/utils/sessionUtils.ts index 878f436..264e2ac 100644 --- a/apps/rag-knowledge-agent/src/utils/sessionUtils.ts +++ b/apps/rag-knowledge-agent/src/utils/sessionUtils.ts @@ -1,9 +1,6 @@ -import { getSession } from 'next-auth/react' import { logger } from '@/utils/logger' export interface SessionTokenParams { - origin_owner_id: string - origin_owner_name: string provider?: string account_id?: string multiple?: boolean @@ -15,7 +12,7 @@ export interface SessionTokenResponse { /** * Retrieves a session token from the StackOne API via our backend. - * Call from client; backend enforces auth via session cookie. + * The backend sets the account owner to the signed-in user. */ export const getSessionToken = async (params: SessionTokenParams): Promise => { try { @@ -23,8 +20,6 @@ export const getSessionToken = async (params: SessionTokenParams): Promise => { - try { - const session = await getSession() - const user = session?.user - if (!user?.id) { - throw new Error('User not authenticated') - } - - return getSessionToken({ - origin_owner_id: user.id, - origin_owner_name: (user.email ?? user.name) || user.id, - provider, - account_id: accountId, - multiple, - }) - } catch (error) { - logger.error('Error retrieving session token for user:', error) - throw error - } -} diff --git a/apps/rag-knowledge-agent/tsconfig.json b/apps/rag-knowledge-agent/tsconfig.json index 79506b3..ace2ea6 100644 --- a/apps/rag-knowledge-agent/tsconfig.json +++ b/apps/rag-knowledge-agent/tsconfig.json @@ -12,6 +12,7 @@ "noImplicitAny": false, "strict": false, "noEmit": true, + "allowImportingTsExtensions": true, "esModuleInterop": true, "module": "esnext", "moduleResolution": "bundler", diff --git a/apps/rag-knowledge-agent/vercel.json b/apps/rag-knowledge-agent/vercel.json index 9764433..88cdca9 100644 --- a/apps/rag-knowledge-agent/vercel.json +++ b/apps/rag-knowledge-agent/vercel.json @@ -1,4 +1,5 @@ { + "installCommand": "npm ci --prefix .", "functions": { "src/app/api/chat/route.ts": { "maxDuration": 60