diff --git a/package-lock.json b/package-lock.json index d63f20ed..79f019da 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1035,17 +1035,6 @@ "react": ">=16.8.0" } }, - "node_modules/@emnapi/runtime": { - "version": "1.7.1", - "resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.7.1.tgz", - "integrity": "sha512-PVtJr5CmLwYAU9PZDMITZoR5iAOShYREoR45EyyLrbntV50mdePTgUn4AmOw90Ifcj+x2kRjdzr1HP3RrNiHGA==", - "license": "MIT", - "optional": true, - "peer": true, - "dependencies": { - "tslib": "^2.4.0" - } - }, "node_modules/@esbuild/aix-ppc64": { "version": "0.25.12", "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.25.12.tgz", @@ -1564,502 +1553,11 @@ }, "node_modules/@hapi/topo": { "version": "5.1.0", - "resolved": "https://registry.npmjs.org/@hapi/topo/-/topo-5.1.0.tgz", - "integrity": "sha512-foQZKJig7Ob0BMAYBfcJk8d77QtOe7Wo4ox7ff1lQYoNNAb6jwcY1ncdoy2e9wQZzvNy7ODZCYJkK8kzmcAnAg==", - "license": "BSD-3-Clause", - "dependencies": { - "@hapi/hoek": "^9.0.0" - } - }, - "node_modules/@img/colour": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/@img/colour/-/colour-1.0.0.tgz", - "integrity": "sha512-A5P/LfWGFSl6nsckYtjw9da+19jB8hkJ6ACTGcDfEJ0aE+l2n2El7dsVM7UVHZQ9s2lmYMWlrS21YLy2IR1LUw==", - "license": "MIT", - "optional": true, - "peer": true, - "engines": { - "node": ">=18" - } - }, - "node_modules/@img/sharp-darwin-arm64": { - "version": "0.34.5", - "resolved": "https://registry.npmjs.org/@img/sharp-darwin-arm64/-/sharp-darwin-arm64-0.34.5.tgz", - "integrity": "sha512-imtQ3WMJXbMY4fxb/Ndp6HBTNVtWCUI0WdobyheGf5+ad6xX8VIDO8u2xE4qc/fr08CKG/7dDseFtn6M6g/r3w==", - "cpu": [ - "arm64" - ], - "license": "Apache-2.0", - "optional": true, - "os": [ - "darwin" - ], - "peer": true, - "engines": { - "node": "^18.17.0 || ^20.3.0 || >=21.0.0" - }, - "funding": { - "url": "https://opencollective.com/libvips" - }, - "optionalDependencies": { - "@img/sharp-libvips-darwin-arm64": "1.2.4" - } - }, - "node_modules/@img/sharp-darwin-x64": { - "version": "0.34.5", - "resolved": "https://registry.npmjs.org/@img/sharp-darwin-x64/-/sharp-darwin-x64-0.34.5.tgz", - "integrity": "sha512-YNEFAF/4KQ/PeW0N+r+aVVsoIY0/qxxikF2SWdp+NRkmMB7y9LBZAVqQ4yhGCm/H3H270OSykqmQMKLBhBJDEw==", - "cpu": [ - "x64" - ], - "license": "Apache-2.0", - "optional": true, - "os": [ - "darwin" - ], - "peer": true, - "engines": { - "node": "^18.17.0 || ^20.3.0 || >=21.0.0" - }, - "funding": { - "url": "https://opencollective.com/libvips" - }, - "optionalDependencies": { - "@img/sharp-libvips-darwin-x64": "1.2.4" - } - }, - "node_modules/@img/sharp-libvips-darwin-arm64": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/@img/sharp-libvips-darwin-arm64/-/sharp-libvips-darwin-arm64-1.2.4.tgz", - "integrity": "sha512-zqjjo7RatFfFoP0MkQ51jfuFZBnVE2pRiaydKJ1G/rHZvnsrHAOcQALIi9sA5co5xenQdTugCvtb1cuf78Vf4g==", - "cpu": [ - "arm64" - ], - "license": "LGPL-3.0-or-later", - "optional": true, - "os": [ - "darwin" - ], - "peer": true, - "funding": { - "url": "https://opencollective.com/libvips" - } - }, - "node_modules/@img/sharp-libvips-darwin-x64": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/@img/sharp-libvips-darwin-x64/-/sharp-libvips-darwin-x64-1.2.4.tgz", - "integrity": "sha512-1IOd5xfVhlGwX+zXv2N93k0yMONvUlANylbJw1eTah8K/Jtpi15KC+WSiaX/nBmbm2HxRM1gZ0nSdjSsrZbGKg==", - "cpu": [ - "x64" - ], - "license": "LGPL-3.0-or-later", - "optional": true, - "os": [ - "darwin" - ], - "peer": true, - "funding": { - "url": "https://opencollective.com/libvips" - } - }, - "node_modules/@img/sharp-libvips-linux-arm": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm/-/sharp-libvips-linux-arm-1.2.4.tgz", - "integrity": "sha512-bFI7xcKFELdiNCVov8e44Ia4u2byA+l3XtsAj+Q8tfCwO6BQ8iDojYdvoPMqsKDkuoOo+X6HZA0s0q11ANMQ8A==", - "cpu": [ - "arm" - ], - "license": "LGPL-3.0-or-later", - "optional": true, - "os": [ - "linux" - ], - "peer": true, - "funding": { - "url": "https://opencollective.com/libvips" - } - }, - "node_modules/@img/sharp-libvips-linux-arm64": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm64/-/sharp-libvips-linux-arm64-1.2.4.tgz", - "integrity": "sha512-excjX8DfsIcJ10x1Kzr4RcWe1edC9PquDRRPx3YVCvQv+U5p7Yin2s32ftzikXojb1PIFc/9Mt28/y+iRklkrw==", - "cpu": [ - "arm64" - ], - "license": "LGPL-3.0-or-later", - "optional": true, - "os": [ - "linux" - ], - "peer": true, - "funding": { - "url": "https://opencollective.com/libvips" - } - }, - "node_modules/@img/sharp-libvips-linux-ppc64": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-ppc64/-/sharp-libvips-linux-ppc64-1.2.4.tgz", - "integrity": "sha512-FMuvGijLDYG6lW+b/UvyilUWu5Ayu+3r2d1S8notiGCIyYU/76eig1UfMmkZ7vwgOrzKzlQbFSuQfgm7GYUPpA==", - "cpu": [ - "ppc64" - ], - "license": "LGPL-3.0-or-later", - "optional": true, - "os": [ - "linux" - ], - "peer": true, - "funding": { - "url": "https://opencollective.com/libvips" - } - }, - "node_modules/@img/sharp-libvips-linux-riscv64": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-riscv64/-/sharp-libvips-linux-riscv64-1.2.4.tgz", - "integrity": "sha512-oVDbcR4zUC0ce82teubSm+x6ETixtKZBh/qbREIOcI3cULzDyb18Sr/Wcyx7NRQeQzOiHTNbZFF1UwPS2scyGA==", - "cpu": [ - "riscv64" - ], - "license": "LGPL-3.0-or-later", - "optional": true, - "os": [ - "linux" - ], - "peer": true, - "funding": { - "url": "https://opencollective.com/libvips" - } - }, - "node_modules/@img/sharp-libvips-linux-s390x": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-s390x/-/sharp-libvips-linux-s390x-1.2.4.tgz", - "integrity": "sha512-qmp9VrzgPgMoGZyPvrQHqk02uyjA0/QrTO26Tqk6l4ZV0MPWIW6LTkqOIov+J1yEu7MbFQaDpwdwJKhbJvuRxQ==", - "cpu": [ - "s390x" - ], - "license": "LGPL-3.0-or-later", - "optional": true, - "os": [ - "linux" - ], - "peer": true, - "funding": { - "url": "https://opencollective.com/libvips" - } - }, - "node_modules/@img/sharp-libvips-linux-x64": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-x64/-/sharp-libvips-linux-x64-1.2.4.tgz", - "integrity": "sha512-tJxiiLsmHc9Ax1bz3oaOYBURTXGIRDODBqhveVHonrHJ9/+k89qbLl0bcJns+e4t4rvaNBxaEZsFtSfAdquPrw==", - "cpu": [ - "x64" - ], - "license": "LGPL-3.0-or-later", - "optional": true, - "os": [ - "linux" - ], - "peer": true, - "funding": { - "url": "https://opencollective.com/libvips" - } - }, - "node_modules/@img/sharp-libvips-linuxmusl-arm64": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-arm64/-/sharp-libvips-linuxmusl-arm64-1.2.4.tgz", - "integrity": "sha512-FVQHuwx1IIuNow9QAbYUzJ+En8KcVm9Lk5+uGUQJHaZmMECZmOlix9HnH7n1TRkXMS0pGxIJokIVB9SuqZGGXw==", - "cpu": [ - "arm64" - ], - "license": "LGPL-3.0-or-later", - "optional": true, - "os": [ - "linux" - ], - "peer": true, - "funding": { - "url": "https://opencollective.com/libvips" - } - }, - "node_modules/@img/sharp-libvips-linuxmusl-x64": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-x64/-/sharp-libvips-linuxmusl-x64-1.2.4.tgz", - "integrity": "sha512-+LpyBk7L44ZIXwz/VYfglaX/okxezESc6UxDSoyo2Ks6Jxc4Y7sGjpgU9s4PMgqgjj1gZCylTieNamqA1MF7Dg==", - "cpu": [ - "x64" - ], - "license": "LGPL-3.0-or-later", - "optional": true, - "os": [ - "linux" - ], - "peer": true, - "funding": { - "url": "https://opencollective.com/libvips" - } - }, - "node_modules/@img/sharp-linux-arm": { - "version": "0.34.5", - "resolved": "https://registry.npmjs.org/@img/sharp-linux-arm/-/sharp-linux-arm-0.34.5.tgz", - "integrity": "sha512-9dLqsvwtg1uuXBGZKsxem9595+ujv0sJ6Vi8wcTANSFpwV/GONat5eCkzQo/1O6zRIkh0m/8+5BjrRr7jDUSZw==", - "cpu": [ - "arm" - ], - "license": "Apache-2.0", - "optional": true, - "os": [ - "linux" - ], - "peer": true, - "engines": { - "node": "^18.17.0 || ^20.3.0 || >=21.0.0" - }, - "funding": { - "url": "https://opencollective.com/libvips" - }, - "optionalDependencies": { - "@img/sharp-libvips-linux-arm": "1.2.4" - } - }, - "node_modules/@img/sharp-linux-arm64": { - "version": "0.34.5", - "resolved": "https://registry.npmjs.org/@img/sharp-linux-arm64/-/sharp-linux-arm64-0.34.5.tgz", - "integrity": "sha512-bKQzaJRY/bkPOXyKx5EVup7qkaojECG6NLYswgktOZjaXecSAeCWiZwwiFf3/Y+O1HrauiE3FVsGxFg8c24rZg==", - "cpu": [ - "arm64" - ], - "license": "Apache-2.0", - "optional": true, - "os": [ - "linux" - ], - "peer": true, - "engines": { - "node": "^18.17.0 || ^20.3.0 || >=21.0.0" - }, - "funding": { - "url": "https://opencollective.com/libvips" - }, - "optionalDependencies": { - "@img/sharp-libvips-linux-arm64": "1.2.4" - } - }, - "node_modules/@img/sharp-linux-ppc64": { - "version": "0.34.5", - "resolved": "https://registry.npmjs.org/@img/sharp-linux-ppc64/-/sharp-linux-ppc64-0.34.5.tgz", - "integrity": "sha512-7zznwNaqW6YtsfrGGDA6BRkISKAAE1Jo0QdpNYXNMHu2+0dTrPflTLNkpc8l7MUP5M16ZJcUvysVWWrMefZquA==", - "cpu": [ - "ppc64" - ], - "license": "Apache-2.0", - "optional": true, - "os": [ - "linux" - ], - "peer": true, - "engines": { - "node": "^18.17.0 || ^20.3.0 || >=21.0.0" - }, - "funding": { - "url": "https://opencollective.com/libvips" - }, - "optionalDependencies": { - "@img/sharp-libvips-linux-ppc64": "1.2.4" - } - }, - "node_modules/@img/sharp-linux-riscv64": { - "version": "0.34.5", - "resolved": "https://registry.npmjs.org/@img/sharp-linux-riscv64/-/sharp-linux-riscv64-0.34.5.tgz", - "integrity": "sha512-51gJuLPTKa7piYPaVs8GmByo7/U7/7TZOq+cnXJIHZKavIRHAP77e3N2HEl3dgiqdD/w0yUfiJnII77PuDDFdw==", - "cpu": [ - "riscv64" - ], - "license": "Apache-2.0", - "optional": true, - "os": [ - "linux" - ], - "peer": true, - "engines": { - "node": "^18.17.0 || ^20.3.0 || >=21.0.0" - }, - "funding": { - "url": "https://opencollective.com/libvips" - }, - "optionalDependencies": { - "@img/sharp-libvips-linux-riscv64": "1.2.4" - } - }, - "node_modules/@img/sharp-linux-s390x": { - "version": "0.34.5", - "resolved": "https://registry.npmjs.org/@img/sharp-linux-s390x/-/sharp-linux-s390x-0.34.5.tgz", - "integrity": "sha512-nQtCk0PdKfho3eC5MrbQoigJ2gd1CgddUMkabUj+rBevs8tZ2cULOx46E7oyX+04WGfABgIwmMC0VqieTiR4jg==", - "cpu": [ - "s390x" - ], - "license": "Apache-2.0", - "optional": true, - "os": [ - "linux" - ], - "peer": true, - "engines": { - "node": "^18.17.0 || ^20.3.0 || >=21.0.0" - }, - "funding": { - "url": "https://opencollective.com/libvips" - }, - "optionalDependencies": { - "@img/sharp-libvips-linux-s390x": "1.2.4" - } - }, - "node_modules/@img/sharp-linux-x64": { - "version": "0.34.5", - "resolved": "https://registry.npmjs.org/@img/sharp-linux-x64/-/sharp-linux-x64-0.34.5.tgz", - "integrity": "sha512-MEzd8HPKxVxVenwAa+JRPwEC7QFjoPWuS5NZnBt6B3pu7EG2Ge0id1oLHZpPJdn3OQK+BQDiw9zStiHBTJQQQQ==", - "cpu": [ - "x64" - ], - "license": "Apache-2.0", - "optional": true, - "os": [ - "linux" - ], - "peer": true, - "engines": { - "node": "^18.17.0 || ^20.3.0 || >=21.0.0" - }, - "funding": { - "url": "https://opencollective.com/libvips" - }, - "optionalDependencies": { - "@img/sharp-libvips-linux-x64": "1.2.4" - } - }, - "node_modules/@img/sharp-linuxmusl-arm64": { - "version": "0.34.5", - "resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-arm64/-/sharp-linuxmusl-arm64-0.34.5.tgz", - "integrity": "sha512-fprJR6GtRsMt6Kyfq44IsChVZeGN97gTD331weR1ex1c1rypDEABN6Tm2xa1wE6lYb5DdEnk03NZPqA7Id21yg==", - "cpu": [ - "arm64" - ], - "license": "Apache-2.0", - "optional": true, - "os": [ - "linux" - ], - "peer": true, - "engines": { - "node": "^18.17.0 || ^20.3.0 || >=21.0.0" - }, - "funding": { - "url": "https://opencollective.com/libvips" - }, - "optionalDependencies": { - "@img/sharp-libvips-linuxmusl-arm64": "1.2.4" - } - }, - "node_modules/@img/sharp-linuxmusl-x64": { - "version": "0.34.5", - "resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-x64/-/sharp-linuxmusl-x64-0.34.5.tgz", - "integrity": "sha512-Jg8wNT1MUzIvhBFxViqrEhWDGzqymo3sV7z7ZsaWbZNDLXRJZoRGrjulp60YYtV4wfY8VIKcWidjojlLcWrd8Q==", - "cpu": [ - "x64" - ], - "license": "Apache-2.0", - "optional": true, - "os": [ - "linux" - ], - "peer": true, - "engines": { - "node": "^18.17.0 || ^20.3.0 || >=21.0.0" - }, - "funding": { - "url": "https://opencollective.com/libvips" - }, - "optionalDependencies": { - "@img/sharp-libvips-linuxmusl-x64": "1.2.4" - } - }, - "node_modules/@img/sharp-wasm32": { - "version": "0.34.5", - "resolved": "https://registry.npmjs.org/@img/sharp-wasm32/-/sharp-wasm32-0.34.5.tgz", - "integrity": "sha512-OdWTEiVkY2PHwqkbBI8frFxQQFekHaSSkUIJkwzclWZe64O1X4UlUjqqqLaPbUpMOQk6FBu/HtlGXNblIs0huw==", - "cpu": [ - "wasm32" - ], - "license": "Apache-2.0 AND LGPL-3.0-or-later AND MIT", - "optional": true, - "peer": true, - "dependencies": { - "@emnapi/runtime": "^1.7.0" - }, - "engines": { - "node": "^18.17.0 || ^20.3.0 || >=21.0.0" - }, - "funding": { - "url": "https://opencollective.com/libvips" - } - }, - "node_modules/@img/sharp-win32-arm64": { - "version": "0.34.5", - "resolved": "https://registry.npmjs.org/@img/sharp-win32-arm64/-/sharp-win32-arm64-0.34.5.tgz", - "integrity": "sha512-WQ3AgWCWYSb2yt+IG8mnC6Jdk9Whs7O0gxphblsLvdhSpSTtmu69ZG1Gkb6NuvxsNACwiPV6cNSZNzt0KPsw7g==", - "cpu": [ - "arm64" - ], - "license": "Apache-2.0 AND LGPL-3.0-or-later", - "optional": true, - "os": [ - "win32" - ], - "peer": true, - "engines": { - "node": "^18.17.0 || ^20.3.0 || >=21.0.0" - }, - "funding": { - "url": "https://opencollective.com/libvips" - } - }, - "node_modules/@img/sharp-win32-ia32": { - "version": "0.34.5", - "resolved": "https://registry.npmjs.org/@img/sharp-win32-ia32/-/sharp-win32-ia32-0.34.5.tgz", - "integrity": "sha512-FV9m/7NmeCmSHDD5j4+4pNI8Cp3aW+JvLoXcTUo0IqyjSfAZJ8dIUmijx1qaJsIiU+Hosw6xM5KijAWRJCSgNg==", - "cpu": [ - "ia32" - ], - "license": "Apache-2.0 AND LGPL-3.0-or-later", - "optional": true, - "os": [ - "win32" - ], - "peer": true, - "engines": { - "node": "^18.17.0 || ^20.3.0 || >=21.0.0" - }, - "funding": { - "url": "https://opencollective.com/libvips" - } - }, - "node_modules/@img/sharp-win32-x64": { - "version": "0.34.5", - "resolved": "https://registry.npmjs.org/@img/sharp-win32-x64/-/sharp-win32-x64-0.34.5.tgz", - "integrity": "sha512-+29YMsqY2/9eFEiW93eqWnuLcWcufowXewwSNIT6UwZdUUCrM3oFjMWH/Z6/TMmb4hlFenmfAVbpWeup2jryCw==", - "cpu": [ - "x64" - ], - "license": "Apache-2.0 AND LGPL-3.0-or-later", - "optional": true, - "os": [ - "win32" - ], - "peer": true, - "engines": { - "node": "^18.17.0 || ^20.3.0 || >=21.0.0" - }, - "funding": { - "url": "https://opencollective.com/libvips" + "resolved": "https://registry.npmjs.org/@hapi/topo/-/topo-5.1.0.tgz", + "integrity": "sha512-foQZKJig7Ob0BMAYBfcJk8d77QtOe7Wo4ox7ff1lQYoNNAb6jwcY1ncdoy2e9wQZzvNy7ODZCYJkK8kzmcAnAg==", + "license": "BSD-3-Clause", + "dependencies": { + "@hapi/hoek": "^9.0.0" } }, "node_modules/@isaacs/cliui": { @@ -2300,270 +1798,6 @@ } } }, - "node_modules/@llamaindex/workflow/node_modules/@next/env": { - "version": "15.5.7", - "resolved": "https://registry.npmjs.org/@next/env/-/env-15.5.7.tgz", - "integrity": "sha512-4h6Y2NyEkIEN7Z8YxkA27pq6zTkS09bUSYC0xjd0NpwFxjnIKeZEeH591o5WECSmjpUhLn3H2QLJcDye3Uzcvg==", - "license": "MIT", - "optional": true, - "peer": true - }, - "node_modules/@llamaindex/workflow/node_modules/@next/swc-darwin-arm64": { - "version": "15.5.7", - "resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-15.5.7.tgz", - "integrity": "sha512-IZwtxCEpI91HVU/rAUOOobWSZv4P2DeTtNaCdHqLcTJU4wdNXgAySvKa/qJCgR5m6KI8UsKDXtO2B31jcaw1Yw==", - "cpu": [ - "arm64" - ], - "license": "MIT", - "optional": true, - "os": [ - "darwin" - ], - "peer": true, - "engines": { - "node": ">= 10" - } - }, - "node_modules/@llamaindex/workflow/node_modules/@next/swc-darwin-x64": { - "version": "15.5.7", - "resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-15.5.7.tgz", - "integrity": "sha512-UP6CaDBcqaCBuiq/gfCEJw7sPEoX1aIjZHnBWN9v9qYHQdMKvCKcAVs4OX1vIjeE+tC5EIuwDTVIoXpUes29lg==", - "cpu": [ - "x64" - ], - "license": "MIT", - "optional": true, - "os": [ - "darwin" - ], - "peer": true, - "engines": { - "node": ">= 10" - } - }, - "node_modules/@llamaindex/workflow/node_modules/@next/swc-linux-arm64-gnu": { - "version": "15.5.7", - "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-15.5.7.tgz", - "integrity": "sha512-NCslw3GrNIw7OgmRBxHtdWFQYhexoUCq+0oS2ccjyYLtcn1SzGzeM54jpTFonIMUjNbHmpKpziXnpxhSWLcmBA==", - "cpu": [ - "arm64" - ], - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "peer": true, - "engines": { - "node": ">= 10" - } - }, - "node_modules/@llamaindex/workflow/node_modules/@next/swc-linux-arm64-musl": { - "version": "15.5.7", - "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-15.5.7.tgz", - "integrity": "sha512-nfymt+SE5cvtTrG9u1wdoxBr9bVB7mtKTcj0ltRn6gkP/2Nu1zM5ei8rwP9qKQP0Y//umK+TtkKgNtfboBxRrw==", - "cpu": [ - "arm64" - ], - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "peer": true, - "engines": { - "node": ">= 10" - } - }, - "node_modules/@llamaindex/workflow/node_modules/@next/swc-linux-x64-gnu": { - "version": "15.5.7", - "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-15.5.7.tgz", - "integrity": "sha512-hvXcZvCaaEbCZcVzcY7E1uXN9xWZfFvkNHwbe/n4OkRhFWrs1J1QV+4U1BN06tXLdaS4DazEGXwgqnu/VMcmqw==", - "cpu": [ - "x64" - ], - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "peer": true, - "engines": { - "node": ">= 10" - } - }, - "node_modules/@llamaindex/workflow/node_modules/@next/swc-linux-x64-musl": { - "version": "15.5.7", - "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-15.5.7.tgz", - "integrity": "sha512-4IUO539b8FmF0odY6/SqANJdgwn1xs1GkPO5doZugwZ3ETF6JUdckk7RGmsfSf7ws8Qb2YB5It33mvNL/0acqA==", - "cpu": [ - "x64" - ], - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "peer": true, - "engines": { - "node": ">= 10" - } - }, - "node_modules/@llamaindex/workflow/node_modules/@next/swc-win32-arm64-msvc": { - "version": "15.5.7", - "resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-15.5.7.tgz", - "integrity": "sha512-CpJVTkYI3ZajQkC5vajM7/ApKJUOlm6uP4BknM3XKvJ7VXAvCqSjSLmM0LKdYzn6nBJVSjdclx8nYJSa3xlTgQ==", - "cpu": [ - "arm64" - ], - "license": "MIT", - "optional": true, - "os": [ - "win32" - ], - "peer": true, - "engines": { - "node": ">= 10" - } - }, - "node_modules/@llamaindex/workflow/node_modules/@next/swc-win32-x64-msvc": { - "version": "15.5.7", - "resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-15.5.7.tgz", - "integrity": "sha512-gMzgBX164I6DN+9/PGA+9dQiwmTkE4TloBNx8Kv9UiGARsr9Nba7IpcBRA1iTV9vwlYnrE3Uy6I7Aj6qLjQuqw==", - "cpu": [ - "x64" - ], - "license": "MIT", - "optional": true, - "os": [ - "win32" - ], - "peer": true, - "engines": { - "node": ">= 10" - } - }, - "node_modules/@llamaindex/workflow/node_modules/@swc/helpers": { - "version": "0.5.15", - "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.15.tgz", - "integrity": "sha512-JQ5TuMi45Owi4/BIMAJBoSQoOJu12oOk/gADqlcUL9JEdHB8vyjUSsxqeNXnmXHjYKMi2WcYtezGEEhqUI/E2g==", - "license": "Apache-2.0", - "optional": true, - "peer": true, - "dependencies": { - "tslib": "^2.8.0" - } - }, - "node_modules/@llamaindex/workflow/node_modules/next": { - "version": "15.5.7", - "resolved": "https://registry.npmjs.org/next/-/next-15.5.7.tgz", - "integrity": "sha512-+t2/0jIJ48kUpGKkdlhgkv+zPTEOoXyr60qXe68eB/pl3CMJaLeIGjzp5D6Oqt25hCBiBTt8wEeeAzfJvUKnPQ==", - "license": "MIT", - "optional": true, - "peer": true, - "dependencies": { - "@next/env": "15.5.7", - "@swc/helpers": "0.5.15", - "caniuse-lite": "^1.0.30001579", - "postcss": "8.4.31", - "styled-jsx": "5.1.6" - }, - "bin": { - "next": "dist/bin/next" - }, - "engines": { - "node": "^18.18.0 || ^19.8.0 || >= 20.0.0" - }, - "optionalDependencies": { - "@next/swc-darwin-arm64": "15.5.7", - "@next/swc-darwin-x64": "15.5.7", - "@next/swc-linux-arm64-gnu": "15.5.7", - "@next/swc-linux-arm64-musl": "15.5.7", - "@next/swc-linux-x64-gnu": "15.5.7", - "@next/swc-linux-x64-musl": "15.5.7", - "@next/swc-win32-arm64-msvc": "15.5.7", - "@next/swc-win32-x64-msvc": "15.5.7", - "sharp": "^0.34.3" - }, - "peerDependencies": { - "@opentelemetry/api": "^1.1.0", - "@playwright/test": "^1.51.1", - "babel-plugin-react-compiler": "*", - "react": "^18.2.0 || 19.0.0-rc-de68d2f4-20241204 || ^19.0.0", - "react-dom": "^18.2.0 || 19.0.0-rc-de68d2f4-20241204 || ^19.0.0", - "sass": "^1.3.0" - }, - "peerDependenciesMeta": { - "@opentelemetry/api": { - "optional": true - }, - "@playwright/test": { - "optional": true - }, - "babel-plugin-react-compiler": { - "optional": true - }, - "sass": { - "optional": true - } - } - }, - "node_modules/@llamaindex/workflow/node_modules/postcss": { - "version": "8.4.31", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.31.tgz", - "integrity": "sha512-PS08Iboia9mts/2ygV3eLpY5ghnUcfLV/EXTOW1E2qYxJKGGBUtNjN76FYHnMs36RmARn41bC0AZmn+rR0OVpQ==", - "funding": [ - { - "type": "opencollective", - "url": "https://opencollective.com/postcss/" - }, - { - "type": "tidelift", - "url": "https://tidelift.com/funding/github/npm/postcss" - }, - { - "type": "github", - "url": "https://github.com/sponsors/ai" - } - ], - "license": "MIT", - "optional": true, - "peer": true, - "dependencies": { - "nanoid": "^3.3.6", - "picocolors": "^1.0.0", - "source-map-js": "^1.0.2" - }, - "engines": { - "node": "^10 || ^12 || >=14" - } - }, - "node_modules/@llamaindex/workflow/node_modules/styled-jsx": { - "version": "5.1.6", - "resolved": "https://registry.npmjs.org/styled-jsx/-/styled-jsx-5.1.6.tgz", - "integrity": "sha512-qSVyDTeMotdvQYoHWLNGwRFJHC+i+ZvdBRYosOFgC+Wg1vx4frN2/RG/NA7SYqqvKNLf39P2LSRA2pu6n0XYZA==", - "license": "MIT", - "optional": true, - "peer": true, - "dependencies": { - "client-only": "0.0.1" - }, - "engines": { - "node": ">= 12.0.0" - }, - "peerDependencies": { - "react": ">= 16.8.0 || 17.x.x || ^18.0.0-0 || ^19.0.0-0" - }, - "peerDependenciesMeta": { - "@babel/core": { - "optional": true - }, - "babel-plugin-macros": { - "optional": true - } - } - }, "node_modules/@neondatabase/serverless": { "version": "0.10.4", "resolved": "https://registry.npmjs.org/@neondatabase/serverless/-/serverless-0.10.4.tgz", @@ -6910,17 +6144,6 @@ "node": ">=6" } }, - "node_modules/detect-libc": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz", - "integrity": "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==", - "license": "Apache-2.0", - "optional": true, - "peer": true, - "engines": { - "node": ">=8" - } - }, "node_modules/detect-node-es": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/detect-node-es/-/detect-node-es-1.1.0.tgz", @@ -10309,66 +9532,6 @@ "url": "https://ko-fi.com/killymxi" } }, - "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", - "optional": true, - "peer": true, - "bin": { - "semver": "bin/semver.js" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/sharp": { - "version": "0.34.5", - "resolved": "https://registry.npmjs.org/sharp/-/sharp-0.34.5.tgz", - "integrity": "sha512-Ou9I5Ft9WNcCbXrU9cMgPBcCK8LiwLqcbywW3t4oDV37n1pzpuNLsYiAV8eODnjbtQlSDwZ2cUEeQz4E54Hltg==", - "hasInstallScript": true, - "license": "Apache-2.0", - "optional": true, - "peer": true, - "dependencies": { - "@img/colour": "^1.0.0", - "detect-libc": "^2.1.2", - "semver": "^7.7.3" - }, - "engines": { - "node": "^18.17.0 || ^20.3.0 || >=21.0.0" - }, - "funding": { - "url": "https://opencollective.com/libvips" - }, - "optionalDependencies": { - "@img/sharp-darwin-arm64": "0.34.5", - "@img/sharp-darwin-x64": "0.34.5", - "@img/sharp-libvips-darwin-arm64": "1.2.4", - "@img/sharp-libvips-darwin-x64": "1.2.4", - "@img/sharp-libvips-linux-arm": "1.2.4", - "@img/sharp-libvips-linux-arm64": "1.2.4", - "@img/sharp-libvips-linux-ppc64": "1.2.4", - "@img/sharp-libvips-linux-riscv64": "1.2.4", - "@img/sharp-libvips-linux-s390x": "1.2.4", - "@img/sharp-libvips-linux-x64": "1.2.4", - "@img/sharp-libvips-linuxmusl-arm64": "1.2.4", - "@img/sharp-libvips-linuxmusl-x64": "1.2.4", - "@img/sharp-linux-arm": "0.34.5", - "@img/sharp-linux-arm64": "0.34.5", - "@img/sharp-linux-ppc64": "0.34.5", - "@img/sharp-linux-riscv64": "0.34.5", - "@img/sharp-linux-s390x": "0.34.5", - "@img/sharp-linux-x64": "0.34.5", - "@img/sharp-linuxmusl-arm64": "0.34.5", - "@img/sharp-linuxmusl-x64": "0.34.5", - "@img/sharp-wasm32": "0.34.5", - "@img/sharp-win32-arm64": "0.34.5", - "@img/sharp-win32-ia32": "0.34.5", - "@img/sharp-win32-x64": "0.34.5" - } - }, "node_modules/shebang-command": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", @@ -11060,7 +10223,6 @@ "cpu": [ "ppc64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -11077,7 +10239,6 @@ "cpu": [ "arm" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -11094,7 +10255,6 @@ "cpu": [ "arm64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -11111,7 +10271,6 @@ "cpu": [ "x64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -11128,7 +10287,6 @@ "cpu": [ "arm64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -11145,7 +10303,6 @@ "cpu": [ "x64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -11162,7 +10319,6 @@ "cpu": [ "arm64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -11179,7 +10335,6 @@ "cpu": [ "x64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -11196,7 +10351,6 @@ "cpu": [ "arm" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -11213,7 +10367,6 @@ "cpu": [ "arm64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -11230,7 +10383,6 @@ "cpu": [ "ia32" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -11247,7 +10399,6 @@ "cpu": [ "loong64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -11264,7 +10415,6 @@ "cpu": [ "mips64el" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -11281,7 +10431,6 @@ "cpu": [ "ppc64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -11298,7 +10447,6 @@ "cpu": [ "riscv64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -11315,7 +10463,6 @@ "cpu": [ "s390x" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -11332,7 +10479,6 @@ "cpu": [ "x64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -11349,7 +10495,6 @@ "cpu": [ "arm64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -11366,7 +10511,6 @@ "cpu": [ "x64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -11383,7 +10527,6 @@ "cpu": [ "arm64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -11400,7 +10543,6 @@ "cpu": [ "x64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -11417,7 +10559,6 @@ "cpu": [ "arm64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -11434,7 +10575,6 @@ "cpu": [ "x64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -11451,7 +10591,6 @@ "cpu": [ "arm64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -11468,7 +10607,6 @@ "cpu": [ "ia32" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -11485,7 +10623,6 @@ "cpu": [ "x64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ diff --git a/src/app/api/builder/route.ts b/src/app/api/builder/route.ts index a2728484..ffb0f857 100644 --- a/src/app/api/builder/route.ts +++ b/src/app/api/builder/route.ts @@ -34,6 +34,7 @@ export async function POST(req: Request) { d.instructions, request.stream ?? false, distinctId, + 'builder_edit_prompt', ); case ApiAction.SummaryOfPrompt: const summaryData = request.data as SummaryOfPromptData; @@ -42,6 +43,7 @@ export async function POST(req: Request) { summaryData.fullPrompt, request.stream ?? false, distinctId, + 'builder_summary_prompt', ); default: @@ -59,6 +61,7 @@ async function createNewPrompt(data: SessionBuilderData, distinctId?: string) { createTemplatePrompt, createPromptContent(data), distinctId, + 'builder_create_prompt', ); console.log('[i] Created new prompt:', fullPrompt); diff --git a/src/app/api/llamaUtils.ts b/src/app/api/llamaUtils.ts index e3769f18..7ae8ef2e 100644 --- a/src/app/api/llamaUtils.ts +++ b/src/app/api/llamaUtils.ts @@ -9,6 +9,7 @@ import { getHostSessionById, updateUserSession, increaseSessionsCount, + getSessionOwner, } from '@/lib/db'; import { initializeCrossPollination } from '@/lib/crossPollination'; import { getLLM } from '@/lib/modelConfig'; @@ -22,6 +23,9 @@ export async function finishedResponse( systemPrompt: string, userPrompt: string, distinctId?: string, + tag?: string, + sessionIds?: string[], + hostIds?: string[], ) { console.log('[i] Generating finished response:', { systemPrompt: systemPrompt?.substring(0, 100) + '...', @@ -44,6 +48,9 @@ export async function finishedResponse( }, ], distinctId, + tag, + sessionIds, + hostIds, }); console.log('[i] Completion response:', JSON.stringify(response)); @@ -78,6 +85,9 @@ export async function finishedResponse( }, ], distinctId, + tag, + sessionIds, + hostIds, }); console.log('[i] Fallback to small model successful:', JSON.stringify(fallbackResponse)); @@ -178,6 +188,9 @@ export async function handleGenerateAnswer( const sessionData = await getHostSessionById(messageData.sessionId); console.log(`[i] Session data:`, sessionData); + // Get session owner (host) for analytics + const hostId = await getSessionOwner(messageData.sessionId); + const basicFacilitationPrompt = await getPromptInstructions( 'BASIC_FACILITATION_PROMPT', ); @@ -208,6 +221,9 @@ ${sessionData?.critical ? `- Key Points: ${sessionData.critical}` : ''}`; const message = await chatEngine.chat({ messages: formattedMessages as ChatMessage[], distinctId, + tag: 'chat', + sessionIds: [messageData.sessionId], + hostIds: hostId ? [hostId] : undefined, }); console.log('[i] Response:', message); @@ -241,9 +257,12 @@ export async function handleResponse( userPrompt: string, stream: boolean, distinctId?: string, + tag?: string, + sessionIds?: string[], + hostIds?: string[], ) { if (stream) { - const streamData = streamResponse(systemPrompt, userPrompt, distinctId); + const streamData = streamResponse(systemPrompt, userPrompt, distinctId, tag, sessionIds, hostIds); return new NextResponse(streamData, { headers: { 'Content-Type': 'text/event-stream', @@ -252,13 +271,20 @@ export async function handleResponse( }, }); } else { - const response = await finishedResponse(systemPrompt, userPrompt, distinctId); + const response = await finishedResponse(systemPrompt, userPrompt, distinctId, tag, sessionIds, hostIds); console.log('response from finishedResponse:', response); return NextResponse.json({ fullPrompt: response }); } } -function streamResponse(systemPrompt: string, userPrompt: string, distinctId?: string) { +function streamResponse( + systemPrompt: string, + userPrompt: string, + distinctId?: string, + tag?: string, + sessionIds?: string[], + hostIds?: string[], +) { const encoder = new TextEncoder(); return new ReadableStream({ @@ -279,6 +305,9 @@ function streamResponse(systemPrompt: string, userPrompt: string, distinctId?: s }, ], distinctId, + tag, + sessionIds, + hostIds, }); if (response) { @@ -317,6 +346,9 @@ function streamResponse(systemPrompt: string, userPrompt: string, distinctId?: s }, ], distinctId, + tag, + sessionIds, + hostIds, }); console.log('[i] Gemini fallback successful in stream'); diff --git a/src/lib/characterGenerator.ts b/src/lib/characterGenerator.ts index 0e0c4cce..e3ce5b50 100644 --- a/src/lib/characterGenerator.ts +++ b/src/lib/characterGenerator.ts @@ -1,5 +1,6 @@ import { getLLM } from '@/lib/modelConfig'; import * as db from '@/lib/db'; +import { getSessionOwner } from '@/lib/db'; export async function generateCharacters(sessionId: string): Promise { // Get session context @@ -15,6 +16,9 @@ export async function generateCharacters(sessionId: string): Promise { throw new Error('Session data not found'); } + // Get session owner (host) for analytics + const hostId = await getSessionOwner(sessionId); + // Set up LLM with SMALL model configuration const llm = getLLM('SMALL', 0.8); @@ -45,6 +49,9 @@ Create authentic characters with diverse perspectives while avoiding assumptions const response = await llm.chat({ messages: [{ role: 'user', content: prompt }], + tag: 'character_generation', + sessionIds: [sessionId], + hostIds: hostId ? [hostId] : undefined, }); return response || ''; diff --git a/src/lib/crossPollinationManager.ts b/src/lib/crossPollinationManager.ts index c37db9bd..eb9ee850 100644 --- a/src/lib/crossPollinationManager.ts +++ b/src/lib/crossPollinationManager.ts @@ -4,6 +4,7 @@ import { getAllChatMessagesInOrder, getAllMessagesForSessionSorted, getHostSessionById, + getSessionOwner, } from '@/lib/db'; import { getPromptInstructions } from './promptsCache'; import { getSession } from '@auth0/nextjs-auth0'; @@ -30,6 +31,7 @@ export class CrossPollinationManager { private lastCrossPollination: number | null = null; private sessionData: any = null; private distinctId: string | undefined; + private hostId: string | null = null; constructor(config: CrossPollinationConfig) { this.config = config; @@ -38,6 +40,13 @@ export class CrossPollinationManager { this.generateEngine = getLLM('LARGE', 0.3); } + private async getHostId(): Promise { + if (this.hostId === null) { + this.hostId = await getSessionOwner(this.config.sessionId); + } + return this.hostId; + } + private async getDistinctId() { if (!this.distinctId) { try { @@ -97,6 +106,7 @@ export class CrossPollinationManager { ); const distinctId = await this.getDistinctId(); + const hostId = await this.getHostId(); // 4. Analyze the current thread to determine if cross-pollination is appropriate const response = await this.analyzeEngine.chat({ @@ -119,6 +129,9 @@ Based on this information, should I introduce cross-pollination now? Answer with }, ], distinctId, + tag: 'cross_pollination_analysis', + sessionIds: [this.config.sessionId], + hostIds: hostId ? [hostId] : undefined, }); const responseText = response.trim().toUpperCase(); @@ -213,6 +226,7 @@ Based on this information, should I introduce cross-pollination now? Answer with await getPromptInstructions('CROSS_POLLINATION'); const distinctId = await this.getDistinctId(); + const hostId = await this.getHostId(); // Make a single LLM call to analyze and generate a question const response = await this.generateEngine.chat({ @@ -252,6 +266,9 @@ Based on this information, should I introduce cross-pollination now? Answer with }, ], distinctId, + tag: 'cross_pollination_question', + sessionIds: [this.config.sessionId], + hostIds: hostId ? [hostId] : undefined, }); const responseText = response.trim(); diff --git a/src/lib/db.ts b/src/lib/db.ts index 272679a0..d03d457a 100644 --- a/src/lib/db.ts +++ b/src/lib/db.ts @@ -1755,3 +1755,73 @@ export async function updateThreadRating( return null; } } + +/** + * Get the owner (host) user ID for a session + * @param sessionId The session ID to look up + * @returns The user_id of the owner, or null if not found + */ +export async function getSessionOwner( + sessionId: string, +): Promise { + console.log('[i] Database Operation: getSessionOwner'); + try { + const db = await dbPromise; + const result = await db + .selectFrom(permissionsTableName) + .select('user_id') + .where('resource_id', '=', sessionId) + .where('resource_type', '=', 'SESSION') + .where('role', '=', 'owner') + .executeTakeFirst(); + + return result?.user_id || null; + } catch (error) { + console.error('Error getting session owner:', error); + return null; + } +} + +/** + * Get owners for multiple sessions at once + * @param sessionIds Array of session IDs to look up + * @returns Map of sessionId -> owner user_id (null if not found) + */ +export async function getSessionOwners( + sessionIds: string[], +): Promise> { + console.log('[i] Database Operation: getSessionOwners'); + const result = new Map(); + + if (!sessionIds.length) return result; + + try { + const db = await dbPromise; + const rows = await db + .selectFrom(permissionsTableName) + .select(['resource_id', 'user_id']) + .where('resource_id', 'in', sessionIds) + .where('resource_type', '=', 'SESSION') + .where('role', '=', 'owner') + .execute(); + + // Initialize all session IDs with null + for (const id of sessionIds) { + result.set(id, null); + } + + // Fill in found owners + for (const row of rows) { + result.set(row.resource_id, row.user_id); + } + + return result; + } catch (error) { + console.error('Error getting session owners:', error); + // Return map with all nulls on error + for (const id of sessionIds) { + result.set(id, null); + } + return result; + } +} diff --git a/src/lib/export/llamaExport.ts b/src/lib/export/llamaExport.ts index 53a80a7a..90f2f00e 100644 --- a/src/lib/export/llamaExport.ts +++ b/src/lib/export/llamaExport.ts @@ -45,6 +45,7 @@ export async function extractDataWithLlama( content: `Here are the conversations to extract data from:\n\n${formattedContext}\n\n${extractUserPrompt}`, }, ], + tag: 'data_export', }); // Clean the response if it includes markdown code blocks diff --git a/src/lib/formAnswerGenerator.ts b/src/lib/formAnswerGenerator.ts index 8cc59e66..170c19c6 100644 --- a/src/lib/formAnswerGenerator.ts +++ b/src/lib/formAnswerGenerator.ts @@ -71,6 +71,7 @@ ${attempts > 0 ? `Previous attempt failed with: ${lastError}\nIMPORTANT: Ensure { role: 'system', content: systemContent }, { role: 'user', content: userContent }, ], + tag: 'form_answer_generation', }); console.log('\n=== LLM Response ==='); diff --git a/src/lib/modelConfig.ts b/src/lib/modelConfig.ts index ea091ff5..acc3387d 100644 --- a/src/lib/modelConfig.ts +++ b/src/lib/modelConfig.ts @@ -98,6 +98,9 @@ export class LLM { async chat(params: { messages: ChatMessage[]; distinctId?: string; + tag?: string; + sessionIds?: string[]; + hostIds?: string[]; }): Promise { const startTime = Date.now(); // All LLMs actually accept the same message format, even though they specify it differently. @@ -189,6 +192,9 @@ export class LLM { $ai_output_tokens: outputTokens, $ai_status: 'success', $ai_trace_id: crypto.randomUUID(), + tag: params.tag, + session_ids: params.sessionIds, + host_ids: params.hostIds, }, }); } @@ -237,6 +243,9 @@ export class LLM { $ai_status: 'error', $ai_error: error instanceof Error ? error.message : String(error), $ai_trace_id: crypto.randomUUID(), + tag: params.tag, + session_ids: params.sessionIds, + host_ids: params.hostIds, }, }); } diff --git a/src/lib/monica/analyzeQueryType.ts b/src/lib/monica/analyzeQueryType.ts index dd09cc51..512bc09d 100644 --- a/src/lib/monica/analyzeQueryType.ts +++ b/src/lib/monica/analyzeQueryType.ts @@ -42,6 +42,7 @@ export async function analyzeQueryType( content: classificationPrompt, }, ], + tag: 'query_type_analysis', }); const queryClassification = JSON.parse(response) as QueryClassification; diff --git a/src/lib/monica/fileAnalysis.ts b/src/lib/monica/fileAnalysis.ts index 6663f57e..a603adae 100644 --- a/src/lib/monica/fileAnalysis.ts +++ b/src/lib/monica/fileAnalysis.ts @@ -38,6 +38,7 @@ ${content.substring(0, 4000)} // Limit content length to avoid token limits content: analysisPrompt, }, ], + tag: 'file_analysis', }); console.log('[i] Raw analysis response:', response); diff --git a/src/lib/monica/monicaMultiSession.ts b/src/lib/monica/monicaMultiSession.ts index 80749ffa..5c598652 100644 --- a/src/lib/monica/monicaMultiSession.ts +++ b/src/lib/monica/monicaMultiSession.ts @@ -3,6 +3,7 @@ import { OpenAIMessage } from '../types'; import { getPromptInstructions } from '../promptsCache'; import { getSessionContent } from './qdrantQuery'; import { getLLM } from '../modelConfig'; +import { getSessionOwners } from '@/lib/db'; export async function generateMultiSessionAnswer( sessionIds: string[], @@ -149,6 +150,10 @@ ${contextData?.critical ? `Key Points: ${contextData?.critical}` : ''}`, const chatEngine = getLLM("LARGE", 0.3); + // Get session owners (hosts) for analytics + const ownersMap = await getSessionOwners(sessionIds); + const hostIds = Array.from(ownersMap.values()).filter((id): id is string => id !== null); + const chatHistoryWithoutInitialWelcoming = chatHistory.slice(1); const chatHistoryForPrompt = chatHistoryWithoutInitialWelcoming.length > 0 @@ -201,6 +206,9 @@ ${qdrantContent?.KNOWLEDGE ? `### Relevant Knowledge Content:\n${qdrantContent.K }, ], distinctId, + tag: 'monica_ai', + sessionIds, + hostIds: hostIds.length > 0 ? hostIds : undefined, }); console.log('[i] Received response: ', response); diff --git a/src/lib/monica/monicaSingleSessionRAG.ts b/src/lib/monica/monicaSingleSessionRAG.ts index 01b2244a..79f43cba 100644 --- a/src/lib/monica/monicaSingleSessionRAG.ts +++ b/src/lib/monica/monicaSingleSessionRAG.ts @@ -4,6 +4,7 @@ import * as db from '@/lib/db'; import { OpenAI, OpenAIEmbedding } from '@llamaindex/openai'; import { SentenceSplitter } from 'llamaindex'; import { getLLM, LLM } from '../modelConfig'; +import { getSessionOwners } from '@/lib/db'; const initialPrompt = ` ### Guidelines: @@ -357,6 +358,10 @@ Total Responses: ${messages.length} const chatEngine: LLM = getLLM("LARGE", 0.3); + // Get session owners (hosts) for analytics + const ownersMap = await getSessionOwners(sessionIds); + const hostIds = Array.from(ownersMap.values()).filter((id): id is string => id !== null); + // Construct the full prompt with context const response = await chatEngine.chat({ messages: [ @@ -364,7 +369,7 @@ Total Responses: ${messages.length} { role: 'user', content: ` -### User Transcripts: +### User Transcripts: ${threadDocuments.map((doc) => doc.text).join('\n')} ### Question: ${query} @@ -373,6 +378,9 @@ Please analyze the above context to answer the question.`, }, ...chatHistory.map((msg: any) => ({ role: msg.role, content: msg.content })), ], + tag: 'monica_ai_rag', + sessionIds, + hostIds: hostIds.length > 0 ? hostIds : undefined, }); console.log('[i] Chat engine response:', response); diff --git a/src/lib/participantAnswerGenerator.ts b/src/lib/participantAnswerGenerator.ts index 13f0357f..4652439e 100644 --- a/src/lib/participantAnswerGenerator.ts +++ b/src/lib/participantAnswerGenerator.ts @@ -79,6 +79,7 @@ export async function generateParticipantAnswer( content: `Here's the conversation so far:\n\n${conversationHistory}\n\nRespond as a creative team member to the most recent message. BE VERY BRIEF (1-2 sentences) and DIRECTLY ADDRESS the content of the last message.`, }, ], + tag: 'simulated_participant', }); const participantResponse = response diff --git a/src/lib/sessionGenerator.ts b/src/lib/sessionGenerator.ts index 9d713726..c7f811e0 100644 --- a/src/lib/sessionGenerator.ts +++ b/src/lib/sessionGenerator.ts @@ -1,4 +1,5 @@ import * as db from '@/lib/db'; +import { getSessionOwner } from '@/lib/db'; import * as llama from '../app/api/llamaUtils'; import { getUserNameFromContext } from '@/lib/clientUtils'; import { generateFormAnswers } from './formAnswerGenerator'; @@ -22,6 +23,8 @@ async function isSessionComplete( lastQuestion: string, sessionData: any, distinctId?: string, + sessionId?: string, + hostId?: string, ): Promise { const llm = getLLM('MAIN', 0.1); // Low temperature for more consistent results @@ -42,6 +45,9 @@ Reply with ONLY "true" if the session should end, or "false" if it should contin const response = await llm.chat({ messages: [{ role: 'user', content: prompt }], distinctId, + tag: 'session_completion_check', + sessionIds: sessionId ? [sessionId] : undefined, + hostIds: hostId ? [hostId] : undefined, }); return response.toLowerCase().includes('true') || false; @@ -67,6 +73,9 @@ export async function generateSession(config: SessionConfig) { throw new Error('Session data not found'); } + // Get session owner (host) for analytics + const hostId = await getSessionOwner(config.sessionId); + // Generate form answers if questions exist let userContextPrompt = ''; if (sessionData.questions) { @@ -112,6 +121,12 @@ export async function generateSession(config: SessionConfig) { }, true, distinctId, + // tag will be passed down to LLM.chat inside handleGenerateAnswer but handleGenerateAnswer doesn't accept tag yet? + // Wait, handleGenerateAnswer calls LLM.chat. We need to update handleGenerateAnswer signature in llamaUtils.ts first or pass it somehow. + // Actually, handleGenerateAnswer is for the AI *question*. We should tag it as 'session_generation_question' + // But handleGenerateAnswer signature in llamaUtils.ts: (messageData, crossPollinationEnabled, distinctId) + // It doesn't take a tag. + // Let's stick to tagging the user response generation below first. ); // Store AI question @@ -127,6 +142,8 @@ export async function generateSession(config: SessionConfig) { questionResponse.content, sessionData, distinctId, + config.sessionId, + hostId || undefined, ); if (shouldEndSession) { @@ -169,6 +186,9 @@ Additional response guidelines: }, ], distinctId, + tag: 'session_user_response', + sessionIds: [config.sessionId], + hostIds: hostId ? [hostId] : undefined, }); lastUserMessage = userResponse || ''; diff --git a/src/lib/summaryMultiSession.ts b/src/lib/summaryMultiSession.ts index 845a0b88..d14d2d95 100644 --- a/src/lib/summaryMultiSession.ts +++ b/src/lib/summaryMultiSession.ts @@ -1,4 +1,5 @@ import * as db from '@/lib/db'; +import { getSessionOwners } from '@/lib/db'; import { getLLM } from '@/lib/modelConfig'; import { getSession } from '@auth0/nextjs-auth0'; @@ -113,6 +114,10 @@ ${sessionsData[sessionIndex]?.critical ? `Key Points: ${sessionsData[sessionInde const chatEngine = getLLM('MAIN', 0.3); + // Get session owners (hosts) for analytics + const ownersMap = await getSessionOwners(sessionIds); + const hostIds = Array.from(ownersMap.values()).filter((id): id is string => id !== null); + const userPrompt = ` ### Historical Messages by Session: ${messagesContent} @@ -127,6 +132,9 @@ ${messagesContent} }, ], distinctId, + tag: 'summary_generation', + sessionIds, + hostIds: hostIds.length > 0 ? hostIds : undefined, }); return response;