@langwatch/server 3.1.0-beta.16 → 3.1.0-beta.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -257,7 +257,13 @@ export class ModelProviderRepository {
|
|
|
257
257
|
* Decrypts customKeys after reading from the database.
|
|
258
258
|
* Handles the migration transition where some rows may still have plaintext JSON objects.
|
|
259
259
|
*
|
|
260
|
-
* @returns Decrypted object, or null if input is null/undefined.
|
|
260
|
+
* @returns Decrypted object, or null if input is null/undefined or undecryptable.
|
|
261
|
+
*
|
|
262
|
+
* Undecryptable rows (typically: CREDENTIALS_SECRET rotated since the row
|
|
263
|
+
* was written) used to throw and crash the whole `getAllForProject` query —
|
|
264
|
+
* blocking the entire UI behind a 500 response. We now log a warning and
|
|
265
|
+
* return null so the provider is treated as keyless, the user can re-enter
|
|
266
|
+
* keys, and the rest of the providers list still loads.
|
|
261
267
|
*/
|
|
262
268
|
private decryptCustomKeys(
|
|
263
269
|
customKeys: unknown,
|
|
@@ -271,8 +277,16 @@ export class ModelProviderRepository {
|
|
|
271
277
|
|
|
272
278
|
// Encrypted string: decrypt and parse
|
|
273
279
|
if (typeof customKeys === "string") {
|
|
274
|
-
|
|
275
|
-
|
|
280
|
+
try {
|
|
281
|
+
const decrypted = decrypt(customKeys);
|
|
282
|
+
return JSON.parse(decrypted) as Record<string, unknown>;
|
|
283
|
+
} catch (err) {
|
|
284
|
+
console.warn(
|
|
285
|
+
"[ModelProviderRepository] dropping unreadable customKeys (likely CREDENTIALS_SECRET rotated since row was written):",
|
|
286
|
+
err instanceof Error ? err.message : String(err),
|
|
287
|
+
);
|
|
288
|
+
return null;
|
|
289
|
+
}
|
|
276
290
|
}
|
|
277
291
|
|
|
278
292
|
return null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@langwatch/server",
|
|
3
|
-
"version": "3.1.0-beta.
|
|
3
|
+
"version": "3.1.0-beta.17",
|
|
4
4
|
"description": "Run LangWatch locally with one command — `npx @langwatch/server`. Bundles the Next.js control plane, Python NLP service, evaluators, and the Go AI gateway with embedded postgres, redis, and clickhouse.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://langwatch.ai",
|
|
@@ -22210,9 +22210,42 @@ function scaffoldEnvFile(input) {
|
|
|
22210
22210
|
return { written: false, path: input.path };
|
|
22211
22211
|
}
|
|
22212
22212
|
(0, import_node_fs20.mkdirSync)((0, import_node_path22.dirname)(input.path), { recursive: true });
|
|
22213
|
-
(0,
|
|
22213
|
+
const secretsPath = (0, import_node_path22.join)((0, import_node_path22.dirname)(input.path), "secrets.json");
|
|
22214
|
+
const persistedSecrets = readPersistedSecrets(secretsPath);
|
|
22215
|
+
const overlay = { ...input.overrides, ...persistedSecrets };
|
|
22216
|
+
const body = buildEnv({ ...input, overrides: overlay });
|
|
22217
|
+
(0, import_node_fs20.writeFileSync)(input.path, body, { mode: 384 });
|
|
22218
|
+
writePersistedSecrets(secretsPath, body);
|
|
22214
22219
|
return { written: true, path: input.path };
|
|
22215
22220
|
}
|
|
22221
|
+
function readPersistedSecrets(path6) {
|
|
22222
|
+
if (!(0, import_node_fs20.existsSync)(path6)) return {};
|
|
22223
|
+
try {
|
|
22224
|
+
const raw = (0, import_node_fs20.readFileSync)(path6, "utf8");
|
|
22225
|
+
const parsed = JSON.parse(raw);
|
|
22226
|
+
const out = {};
|
|
22227
|
+
for (const key of PERSISTENT_SECRET_KEYS) {
|
|
22228
|
+
const v2 = parsed[key];
|
|
22229
|
+
if (typeof v2 === "string" && v2.length > 0) out[key] = v2;
|
|
22230
|
+
}
|
|
22231
|
+
return out;
|
|
22232
|
+
} catch {
|
|
22233
|
+
return {};
|
|
22234
|
+
}
|
|
22235
|
+
}
|
|
22236
|
+
function writePersistedSecrets(path6, envBody) {
|
|
22237
|
+
const found = {};
|
|
22238
|
+
for (const line of envBody.split("\n")) {
|
|
22239
|
+
const m2 = line.match(/^([^=]+)=(.*)$/);
|
|
22240
|
+
if (!m2) continue;
|
|
22241
|
+
const [, key, value] = m2;
|
|
22242
|
+
if (PERSISTENT_SECRET_KEYS.includes(key)) {
|
|
22243
|
+
found[key] = value;
|
|
22244
|
+
}
|
|
22245
|
+
}
|
|
22246
|
+
if (Object.keys(found).length === 0) return;
|
|
22247
|
+
(0, import_node_fs20.writeFileSync)(path6, JSON.stringify(found, null, 2), { mode: 384 });
|
|
22248
|
+
}
|
|
22216
22249
|
function captureUserEnv(env3 = process.env) {
|
|
22217
22250
|
const out = {};
|
|
22218
22251
|
for (const key of PASSTHROUGH_ENV_KEYS) {
|
|
@@ -22221,13 +22254,21 @@ function captureUserEnv(env3 = process.env) {
|
|
|
22221
22254
|
}
|
|
22222
22255
|
return out;
|
|
22223
22256
|
}
|
|
22224
|
-
var import_node_crypto4, import_node_fs20, import_node_path22, hex, b64, PASSTHROUGH_ENV_KEYS;
|
|
22257
|
+
var import_node_crypto4, import_node_fs20, import_node_path22, PERSISTENT_SECRET_KEYS, hex, b64, PASSTHROUGH_ENV_KEYS;
|
|
22225
22258
|
var init_env = __esm({
|
|
22226
22259
|
"src/shared/env.ts"() {
|
|
22227
22260
|
"use strict";
|
|
22228
22261
|
import_node_crypto4 = require("node:crypto");
|
|
22229
22262
|
import_node_fs20 = require("node:fs");
|
|
22230
22263
|
import_node_path22 = require("node:path");
|
|
22264
|
+
PERSISTENT_SECRET_KEYS = [
|
|
22265
|
+
"NEXTAUTH_SECRET",
|
|
22266
|
+
"CREDENTIALS_SECRET",
|
|
22267
|
+
"API_TOKEN_JWT_SECRET",
|
|
22268
|
+
"LW_VIRTUAL_KEY_PEPPER",
|
|
22269
|
+
"LW_GATEWAY_INTERNAL_SECRET",
|
|
22270
|
+
"LW_GATEWAY_JWT_SECRET"
|
|
22271
|
+
];
|
|
22231
22272
|
hex = (bytes) => (0, import_node_crypto4.randomBytes)(bytes).toString("hex");
|
|
22232
22273
|
b64 = (bytes) => (0, import_node_crypto4.randomBytes)(bytes).toString("base64");
|
|
22233
22274
|
PASSTHROUGH_ENV_KEYS = [
|
|
@@ -23350,16 +23391,17 @@ async function syncVenvs(ctx, bus) {
|
|
|
23350
23391
|
specs.map(async (spec) => {
|
|
23351
23392
|
const venvDir = sp.venv(spec.name);
|
|
23352
23393
|
const hashFile = (0, import_node_path33.join)(venvDir, ".lock-hash");
|
|
23353
|
-
const expected = hashFileSafely(spec.lockFile)
|
|
23394
|
+
const expected = `${hashFileSafely(spec.lockFile)}|extras=${(spec.extras ?? []).slice().sort().join(",")}`;
|
|
23354
23395
|
if ((0, import_node_fs31.existsSync)(venvDir) && readFileSafely(hashFile) === expected) return;
|
|
23355
23396
|
bus.emit({ type: "starting", service: `prepare:${spec.name}` });
|
|
23356
23397
|
const start = Date.now();
|
|
23357
23398
|
(0, import_node_fs31.mkdirSync)(venvDir, { recursive: true });
|
|
23399
|
+
const extraArgs = (spec.extras ?? []).flatMap((e) => ["--extra", e]);
|
|
23358
23400
|
await execAndPipe(
|
|
23359
23401
|
bus,
|
|
23360
23402
|
`prepare:${spec.name}`,
|
|
23361
23403
|
uvBin,
|
|
23362
|
-
["sync", "--project", spec.projectDir],
|
|
23404
|
+
["sync", "--project", spec.projectDir, ...extraArgs],
|
|
23363
23405
|
{
|
|
23364
23406
|
env: {
|
|
23365
23407
|
...process.env,
|
|
@@ -23383,7 +23425,22 @@ function resolveVenvSpecs() {
|
|
|
23383
23425
|
{
|
|
23384
23426
|
name: "langevals",
|
|
23385
23427
|
projectDir: (0, import_node_path33.join)(root2, "langevals"),
|
|
23386
|
-
lockFile: (0, import_node_path33.join)(root2, "langevals", "uv.lock")
|
|
23428
|
+
lockFile: (0, import_node_path33.join)(root2, "langevals", "uv.lock"),
|
|
23429
|
+
// langevals's evaluator routes (ROUGE Score, exact match, llm-as-judge,
|
|
23430
|
+
// etc.) live in subpackages declared as optional dependencies in
|
|
23431
|
+
// langevals/pyproject.toml: langevals-ragas, langevals-openai,
|
|
23432
|
+
// langevals-langevals, langevals-azure, langevals-lingua,
|
|
23433
|
+
// langevals-presidio, langevals-legacy. Each is a separate `langevals_*`
|
|
23434
|
+
// distribution; server.py auto-registers FastAPI routes for any
|
|
23435
|
+
// `langevals_*` package found via importlib.metadata.distributions().
|
|
23436
|
+
// Without --extra all, only langevals + langevals-core get installed
|
|
23437
|
+
// and `/openapi.json` reports just `/healthcheck` and `/` — every
|
|
23438
|
+
// evaluator request 404s, langwatch app's runEvaluation throws
|
|
23439
|
+
// `404 {"detail":"Not Found"}`, and the experiments workbench column
|
|
23440
|
+
// shows 'Internal error' for every row. We install all extras so the
|
|
23441
|
+
// evaluator dispatch from langwatch_nlp + the legacy-eval REST route
|
|
23442
|
+
// can reach a real evaluator implementation.
|
|
23443
|
+
extras: ["all"]
|
|
23387
23444
|
}
|
|
23388
23445
|
];
|
|
23389
23446
|
}
|
|
@@ -26909,7 +26966,7 @@ var placeholderRuntime = {
|
|
|
26909
26966
|
};
|
|
26910
26967
|
|
|
26911
26968
|
// src/cli.ts
|
|
26912
|
-
var VERSION = true ? "3.1.0-beta.
|
|
26969
|
+
var VERSION = true ? "3.1.0-beta.17" : "0.0.0-dev";
|
|
26913
26970
|
async function loadRuntime() {
|
|
26914
26971
|
try {
|
|
26915
26972
|
const real = await Promise.resolve().then(() => (init_runtime(), runtime_exports));
|