mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-11-16 13:00:55 +00:00
* 🎒 feat: Carry Project Context Across Conversations
* fix: fail a project attach whose upload hold cannot be released and keep file deletes independent of project cleanup
- Attaching a project file now fails, with nothing attached, when the file's
temporary upload hold cannot be released, instead of attaching a file that
can still expire.
- A failed project cleanup after a file delete is logged rather than failing a
delete that already happened, and a user-wide delete clears that user's
project references without reading every file first.
- Both resize handles share the orientation-aware grip, so a primary handle in
a vertical group renders a rotated grip like the alternate one.
* fix: treat an empty tenant id as no tenant in the project file picker
* fix: attach nothing when a project file is deleted while the attach is in flight
* fix: localize project file association failures instead of showing server text
* test: expect a localized reason for a rejected project file association
* fix: scope project file listing to the caller's tenant and name the file limit when attaching an existing file
- Listing a project's attached files now returns not found when the project
belongs to another tenant, matching the available-file listing and the
chat context resolver.
- Choosing an existing file for a full project now names the project file
limit instead of the generic attach error, like the upload path.
* fix: treat an empty tenant id as no tenant in every project tenant check
A caller whose tenant id is an empty string was refused its own tenantless
project when listing attached or available files, because the handlers
compared '' with null. The project handlers and the chat context resolver now
share one comparison that treats an empty tenant id as no tenant, the rule the
project file queries already follow.
* test: wait for the workspace layout swap and the mobile drawer before acting in the long-metadata spec
The desktop title was measured while the phone layout could still be the one
rendered, and the sidebar row menu was opened before the mobile drawer
committed its open state, which closes a menu opened ahead of it. The spec
now waits for the workspace's phone-only sidebar toggle to leave and for the
drawer to drop inert, the same drawer signal the agents helpers use.
* fix: keep the agent context fingerprint of a turn outside any project unchanged
Every turn now passes a project context key into the agent context
fingerprint, and a turn outside any project passed the no-project sentinel,
which changed the digest of every existing no-project checkpoint. An agent
event conversation written before this change then cold-started and reloaded
its history on its next event. The fingerprint now hashes the no-project key
as absent, so those checkpoints keep matching.
* test: load the long-metadata spec at phone width before driving the mobile drawer
The spec crossed back from desktop to phone width without a reload, which
leaves the drawer on the desktop toggle path whose delayed focus handoff to
the close button dismissed the row menu roughly 200ms after it opened. The
spec now reloads at phone width, as a phone arrives, and waits for the
drawer's own focus handoff before opening the menu.
(cherry picked from commit 4062bc3c00)
Original-PR: https://github.com/LibreChat-AI/LibreChat/pull/15684
181 lines
5.7 KiB
TypeScript
181 lines
5.7 KiB
TypeScript
import crypto from 'crypto';
|
|
import path from 'path';
|
|
|
|
const DEFAULT_BASE_URL = 'http://localhost:3080';
|
|
const DEFAULT_MONGO_URI = 'mongodb://127.0.0.1:27017/LibreChat-e2e';
|
|
const DEFAULT_RUNTIME_ENV_PATH = path.resolve(__dirname, '../specs/.test-results/runtime-env.json');
|
|
const GENERATED_CREDS_KEY = crypto.randomBytes(32).toString('hex');
|
|
const GENERATED_CREDS_IV = crypto.randomBytes(16).toString('hex');
|
|
const GENERATED_JWT_SECRET = crypto.randomBytes(32).toString('hex');
|
|
const GENERATED_JWT_REFRESH_SECRET = crypto.randomBytes(32).toString('hex');
|
|
const DEFAULT_REDIS_URI = 'redis://127.0.0.1:6379/15';
|
|
const DEFAULT_REDIS_CLUSTER_URI = [7001, 7002, 7003]
|
|
.map((port) => `redis://127.0.0.1:${port}`)
|
|
.join(',');
|
|
const DEFAULT_REDIS_KEY_PREFIX = 'LibreChatE2E';
|
|
const PASSTHROUGH_ENV_KEYS = [
|
|
'APPDATA',
|
|
'CI',
|
|
'FORCE_COLOR',
|
|
'HOME',
|
|
'LOCALAPPDATA',
|
|
'NO_COLOR',
|
|
'NO_PROXY',
|
|
'NODE_OPTIONS',
|
|
'PATH',
|
|
'PLAYWRIGHT_BROWSERS_PATH',
|
|
'SHELL',
|
|
'TEMP',
|
|
'TMP',
|
|
'TMPDIR',
|
|
'USER',
|
|
'USERNAME',
|
|
'http_proxy',
|
|
'https_proxy',
|
|
'no_proxy',
|
|
'HTTP_PROXY',
|
|
'HTTPS_PROXY',
|
|
];
|
|
|
|
export function getE2EBaseURL() {
|
|
return process.env.E2E_BASE_URL ?? DEFAULT_BASE_URL;
|
|
}
|
|
|
|
export function getE2EServerAddress(baseURL = getE2EBaseURL()) {
|
|
const url = new URL(baseURL);
|
|
const host = url.hostname.replace(/^\[(.*)\]$/, '$1');
|
|
const port = url.port || (url.protocol === 'https:' ? '443' : '80');
|
|
|
|
return { host, port };
|
|
}
|
|
|
|
export function getRuntimeEnvPath() {
|
|
return process.env.E2E_RUNTIME_ENV_PATH ?? DEFAULT_RUNTIME_ENV_PATH;
|
|
}
|
|
|
|
function getPassthroughEnv(): Record<string, string> {
|
|
const env: Record<string, string> = {};
|
|
const passthroughKeys = [
|
|
...PASSTHROUGH_ENV_KEYS,
|
|
...(process.env.E2E_PASSTHROUGH_ENV?.split(',') ?? []),
|
|
];
|
|
|
|
for (const key of passthroughKeys) {
|
|
const value = process.env[key.trim()];
|
|
if (value != null) {
|
|
env[key.trim()] = value;
|
|
}
|
|
}
|
|
|
|
for (const [key, value] of Object.entries(process.env)) {
|
|
if (key.startsWith('MONGOMS_') && value != null) {
|
|
env[key] = value;
|
|
}
|
|
}
|
|
|
|
return env;
|
|
}
|
|
|
|
function getStreamStoreEnv(): Record<string, string> {
|
|
const streamStore = process.env.E2E_STREAM_STORE ?? 'memory';
|
|
if (streamStore === 'memory') {
|
|
return {
|
|
E2E_REQUIRE_REDIS_STREAMS: 'false',
|
|
USE_REDIS: 'false',
|
|
USE_REDIS_STREAMS: 'false',
|
|
USE_REDIS_CLUSTER: 'false',
|
|
REDIS_KEY_PREFIX: '',
|
|
REDIS_KEY_PREFIX_VAR: '',
|
|
};
|
|
}
|
|
if (streamStore === 'redis') {
|
|
return {
|
|
E2E_REQUIRE_REDIS_STREAMS: 'true',
|
|
USE_REDIS: 'true',
|
|
USE_REDIS_STREAMS: 'true',
|
|
USE_REDIS_CLUSTER: 'false',
|
|
REDIS_URI: process.env.REDIS_URI ?? DEFAULT_REDIS_URI,
|
|
REDIS_KEY_PREFIX: process.env.E2E_REDIS_KEY_PREFIX ?? DEFAULT_REDIS_KEY_PREFIX,
|
|
REDIS_KEY_PREFIX_VAR: '',
|
|
};
|
|
}
|
|
if (streamStore === 'redis-cluster') {
|
|
return {
|
|
E2E_REQUIRE_REDIS_STREAMS: 'true',
|
|
USE_REDIS: 'true',
|
|
USE_REDIS_STREAMS: 'true',
|
|
USE_REDIS_CLUSTER: 'true',
|
|
REDIS_URI: process.env.REDIS_URI ?? DEFAULT_REDIS_CLUSTER_URI,
|
|
REDIS_KEY_PREFIX: process.env.E2E_REDIS_KEY_PREFIX ?? DEFAULT_REDIS_KEY_PREFIX,
|
|
REDIS_KEY_PREFIX_VAR: '',
|
|
};
|
|
}
|
|
throw new Error(`Unsupported E2E_STREAM_STORE "${streamStore}"`);
|
|
}
|
|
|
|
export function getBaseE2EEnv(): Record<string, string> {
|
|
const baseURL = getE2EBaseURL();
|
|
const { host, port } = getE2EServerAddress(baseURL);
|
|
|
|
return {
|
|
...getPassthroughEnv(),
|
|
NODE_ENV: 'CI',
|
|
HOST: process.env.E2E_HOST ?? host,
|
|
PORT: process.env.E2E_PORT ?? port,
|
|
MONGO_URI: process.env.MONGO_URI ?? DEFAULT_MONGO_URI,
|
|
DOMAIN_CLIENT: process.env.E2E_DOMAIN_CLIENT ?? baseURL,
|
|
DOMAIN_SERVER: process.env.E2E_DOMAIN_SERVER ?? baseURL,
|
|
E2E_RUNTIME_ENV_PATH: getRuntimeEnvPath(),
|
|
E2E_USE_MEMORY_MONGO: process.env.E2E_USE_MEMORY_MONGO ?? 'auto',
|
|
NO_INDEX: process.env.NO_INDEX ?? 'true',
|
|
OPENAI_API_KEY: process.env.OPENAI_API_KEY ?? 'user_provided',
|
|
CREDS_KEY: process.env.CREDS_KEY ?? GENERATED_CREDS_KEY,
|
|
CREDS_IV: process.env.CREDS_IV ?? GENERATED_CREDS_IV,
|
|
JWT_SECRET: process.env.JWT_SECRET ?? GENERATED_JWT_SECRET,
|
|
JWT_REFRESH_SECRET: process.env.JWT_REFRESH_SECRET ?? GENERATED_JWT_REFRESH_SECRET,
|
|
EMAIL_HOST: '',
|
|
SEARCH: 'false',
|
|
SESSION_EXPIRY: process.env.SESSION_EXPIRY ?? '3600000',
|
|
ALLOW_REGISTRATION: 'true',
|
|
REFRESH_TOKEN_EXPIRY: process.env.REFRESH_TOKEN_EXPIRY ?? '3600000',
|
|
...getStreamStoreEnv(),
|
|
};
|
|
}
|
|
|
|
export function getLocalE2EEnv(): Record<string, string> {
|
|
return {
|
|
...getBaseE2EEnv(),
|
|
TITLE_CONVO: 'false',
|
|
LOGIN_VIOLATION_SCORE: '0',
|
|
REGISTRATION_VIOLATION_SCORE: '0',
|
|
CONCURRENT_VIOLATION_SCORE: '0',
|
|
MESSAGE_VIOLATION_SCORE: '0',
|
|
NON_BROWSER_VIOLATION_SCORE: '0',
|
|
FORK_VIOLATION_SCORE: '0',
|
|
IMPORT_VIOLATION_SCORE: '0',
|
|
TTS_VIOLATION_SCORE: '0',
|
|
STT_VIOLATION_SCORE: '0',
|
|
FILE_UPLOAD_VIOLATION_SCORE: '0',
|
|
RESET_PASSWORD_VIOLATION_SCORE: '0',
|
|
VERIFY_EMAIL_VIOLATION_SCORE: '0',
|
|
TOOL_CALL_VIOLATION_SCORE: '0',
|
|
CONVO_ACCESS_VIOLATION_SCORE: '0',
|
|
ILLEGAL_MODEL_REQ_SCORE: '0',
|
|
/** The suite authenticates far more often than a person does: a spec that
|
|
* exercises a second account logs in once per Playwright project, and the
|
|
* admin-config specs log in per test. 20 per minute throttles those runs
|
|
* into flakes; no spec asserts login or registration throttling. */
|
|
LOGIN_MAX: '200',
|
|
LOGIN_WINDOW: '1',
|
|
REGISTER_MAX: '200',
|
|
REGISTER_WINDOW: '1',
|
|
LIMIT_CONCURRENT_MESSAGES: 'false',
|
|
CONCURRENT_MESSAGE_MAX: '20',
|
|
LIMIT_MESSAGE_IP: 'false',
|
|
MESSAGE_IP_MAX: '100',
|
|
MESSAGE_IP_WINDOW: '1',
|
|
LIMIT_MESSAGE_USER: 'false',
|
|
MESSAGE_USER_MAX: '100',
|
|
MESSAGE_USER_WINDOW: '1',
|
|
};
|
|
}
|