@langwatch/server 3.1.0-beta.17 → 3.1.0-beta.19
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.
- package/package.json +1 -1
- package/packages/server/dist/cli.cjs +65 -36
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.19",
|
|
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",
|
|
@@ -22132,7 +22132,7 @@ async function killPidGroups(pids) {
|
|
|
22132
22132
|
try {
|
|
22133
22133
|
const { stdout } = await execa("ps", ["-o", "pgid=", "-p", String(pid)], { reject: false });
|
|
22134
22134
|
const pgid = Number.parseInt(stdout.trim(), 10);
|
|
22135
|
-
if (Number.isFinite(pgid)) groups.add(pgid);
|
|
22135
|
+
if (Number.isFinite(pgid) && pgid > 1) groups.add(pgid);
|
|
22136
22136
|
} catch {
|
|
22137
22137
|
}
|
|
22138
22138
|
}
|
|
@@ -22206,11 +22206,14 @@ function buildEnv({ ports, baseHost, overrides = {} }) {
|
|
|
22206
22206
|
return lines.join("\n") + "\n";
|
|
22207
22207
|
}
|
|
22208
22208
|
function scaffoldEnvFile(input) {
|
|
22209
|
+
const secretsPath = (0, import_node_path22.join)((0, import_node_path22.dirname)(input.path), "secrets.json");
|
|
22209
22210
|
if ((0, import_node_fs20.existsSync)(input.path)) {
|
|
22211
|
+
if (!(0, import_node_fs20.existsSync)(secretsPath)) {
|
|
22212
|
+
writePersistedSecrets(secretsPath, (0, import_node_fs20.readFileSync)(input.path, "utf8"));
|
|
22213
|
+
}
|
|
22210
22214
|
return { written: false, path: input.path };
|
|
22211
22215
|
}
|
|
22212
22216
|
(0, import_node_fs20.mkdirSync)((0, import_node_path22.dirname)(input.path), { recursive: true });
|
|
22213
|
-
const secretsPath = (0, import_node_path22.join)((0, import_node_path22.dirname)(input.path), "secrets.json");
|
|
22214
22217
|
const persistedSecrets = readPersistedSecrets(secretsPath);
|
|
22215
22218
|
const overlay = { ...input.overrides, ...persistedSecrets };
|
|
22216
22219
|
const body = buildEnv({ ...input, overrides: overlay });
|
|
@@ -22303,10 +22306,13 @@ async function pollUntilHealthy({
|
|
|
22303
22306
|
return { ok: false, durationMs: Date.now() - start, reason: `timed out: ${lastReason}` };
|
|
22304
22307
|
}
|
|
22305
22308
|
function httpGetCheck(url, opts = {}) {
|
|
22309
|
+
const requestTimeoutMs = opts.requestTimeoutMs ?? 5e3;
|
|
22306
22310
|
return async () => {
|
|
22307
22311
|
const start = Date.now();
|
|
22312
|
+
const ac = new AbortController();
|
|
22313
|
+
const timer = setTimeout(() => ac.abort(), requestTimeoutMs);
|
|
22308
22314
|
try {
|
|
22309
|
-
const res = await fetch(url);
|
|
22315
|
+
const res = await fetch(url, { signal: ac.signal });
|
|
22310
22316
|
const status = res.status;
|
|
22311
22317
|
const expected = opts.expectStatus ?? 200;
|
|
22312
22318
|
if (status !== expected) {
|
|
@@ -22324,7 +22330,10 @@ function httpGetCheck(url, opts = {}) {
|
|
|
22324
22330
|
}
|
|
22325
22331
|
return { ok: true, durationMs: Date.now() - start };
|
|
22326
22332
|
} catch (err) {
|
|
22327
|
-
|
|
22333
|
+
const reason = ac.signal.aborted ? `request timed out after ${requestTimeoutMs}ms` : err.message;
|
|
22334
|
+
return { ok: false, durationMs: Date.now() - start, reason };
|
|
22335
|
+
} finally {
|
|
22336
|
+
clearTimeout(timer);
|
|
22328
22337
|
}
|
|
22329
22338
|
};
|
|
22330
22339
|
}
|
|
@@ -22397,24 +22406,28 @@ function supervise({
|
|
|
22397
22406
|
if (typeof child.pid === "number") {
|
|
22398
22407
|
(0, import_node_fs21.writeFileSync)(pidPath, String(child.pid));
|
|
22399
22408
|
}
|
|
22400
|
-
|
|
22401
|
-
|
|
22409
|
+
const pipesDrained = [
|
|
22410
|
+
pipeLines(child, "stdout", spec.name, logStream, bus),
|
|
22411
|
+
pipeLines(child, "stderr", spec.name, logStream, bus)
|
|
22412
|
+
];
|
|
22402
22413
|
let stopped = false;
|
|
22403
22414
|
let exited = false;
|
|
22404
22415
|
child.on("exit", (code, signal) => {
|
|
22405
22416
|
exited = true;
|
|
22406
|
-
logStream.end();
|
|
22407
22417
|
safeUnlink(pidPath);
|
|
22408
|
-
|
|
22409
|
-
|
|
22410
|
-
|
|
22411
|
-
|
|
22412
|
-
|
|
22413
|
-
|
|
22414
|
-
|
|
22415
|
-
|
|
22416
|
-
|
|
22417
|
-
|
|
22418
|
+
void Promise.all(pipesDrained).then(() => {
|
|
22419
|
+
logStream.end();
|
|
22420
|
+
if (!stopped && (code !== 0 || signal !== null)) {
|
|
22421
|
+
bus.emit({
|
|
22422
|
+
type: "crashed",
|
|
22423
|
+
service: spec.name,
|
|
22424
|
+
code: code ?? -1,
|
|
22425
|
+
signal: signal ?? void 0
|
|
22426
|
+
});
|
|
22427
|
+
} else {
|
|
22428
|
+
bus.emit({ type: "stopped", service: spec.name });
|
|
22429
|
+
}
|
|
22430
|
+
});
|
|
22418
22431
|
});
|
|
22419
22432
|
const stop = async () => {
|
|
22420
22433
|
if (stopped || exited) return;
|
|
@@ -22430,13 +22443,14 @@ function supervise({
|
|
|
22430
22443
|
}
|
|
22431
22444
|
function pipeLines(child, streamName, service, logStream, bus) {
|
|
22432
22445
|
const stream = child[streamName];
|
|
22433
|
-
if (!stream) return;
|
|
22446
|
+
if (!stream) return Promise.resolve();
|
|
22434
22447
|
const rl = (0, import_node_readline.createInterface)({ input: stream });
|
|
22435
22448
|
rl.on("line", (line) => {
|
|
22436
22449
|
logStream.write(`${line}
|
|
22437
22450
|
`);
|
|
22438
22451
|
bus.emit({ type: "log", service, stream: streamName, line });
|
|
22439
22452
|
});
|
|
22453
|
+
return new Promise((resolve) => rl.once("close", () => resolve()));
|
|
22440
22454
|
}
|
|
22441
22455
|
function waitForExit2(child, timeoutMs) {
|
|
22442
22456
|
if (child.exitCode !== null || child.signalCode !== null) return Promise.resolve(true);
|
|
@@ -22872,7 +22886,7 @@ var init_pipe_to_bus = __esm({
|
|
|
22872
22886
|
});
|
|
22873
22887
|
|
|
22874
22888
|
// src/services/node-deps.ts
|
|
22875
|
-
async function ensureLangwatchDeps(
|
|
22889
|
+
async function ensureLangwatchDeps(bus) {
|
|
22876
22890
|
const langwatchDir = locateLangwatchDir();
|
|
22877
22891
|
if (!langwatchDir) throw new Error("langwatch app dir not found");
|
|
22878
22892
|
const nodeModulesPath = (0, import_node_path28.join)(langwatchDir, "node_modules");
|
|
@@ -23518,7 +23532,7 @@ var init_runtime = __esm({
|
|
|
23518
23532
|
await ensureAppDir(ctx, bus);
|
|
23519
23533
|
await Promise.all([
|
|
23520
23534
|
syncVenvs(ctx, bus),
|
|
23521
|
-
ensureLangwatchDeps(
|
|
23535
|
+
ensureLangwatchDeps(bus)
|
|
23522
23536
|
]);
|
|
23523
23537
|
},
|
|
23524
23538
|
async startAll(ctx) {
|
|
@@ -26353,6 +26367,7 @@ function makeAigatewayPredep(version) {
|
|
|
26353
26367
|
init_execa();
|
|
26354
26368
|
var import_node_fs14 = require("node:fs");
|
|
26355
26369
|
var import_node_path17 = require("node:path");
|
|
26370
|
+
init_index_min();
|
|
26356
26371
|
var CH_VERSION = "25.8.22.28";
|
|
26357
26372
|
function downloadSource(platform5) {
|
|
26358
26373
|
const releaseBase = `https://github.com/ClickHouse/ClickHouse/releases/download/v${CH_VERSION}-lts`;
|
|
@@ -26406,11 +26421,10 @@ var clickhousePredep = {
|
|
|
26406
26421
|
if (src.kind === "binary") {
|
|
26407
26422
|
await downloadWithProgress(src.url, out, task, `downloading clickhouse ${CH_VERSION}`);
|
|
26408
26423
|
} else {
|
|
26409
|
-
const tar = await Promise.resolve().then(() => (init_index_min(), index_min_exports));
|
|
26410
26424
|
const tmp = (0, import_node_path17.join)(paths2.bin, `.clickhouse-${CH_VERSION}.tgz`);
|
|
26411
26425
|
await downloadWithProgress(src.url, tmp, task, `downloading clickhouse ${CH_VERSION}`);
|
|
26412
26426
|
task.output = "extracting";
|
|
26413
|
-
|
|
26427
|
+
co({
|
|
26414
26428
|
sync: true,
|
|
26415
26429
|
file: tmp,
|
|
26416
26430
|
cwd: paths2.bin,
|
|
@@ -26596,6 +26610,7 @@ var import_node_crypto3 = require("node:crypto");
|
|
|
26596
26610
|
var import_node_fs17 = require("node:fs");
|
|
26597
26611
|
var import_node_path20 = require("node:path");
|
|
26598
26612
|
var import_promises15 = require("node:stream/promises");
|
|
26613
|
+
init_index_min();
|
|
26599
26614
|
var REDIS_VERSION = embeds_versions_default.redis.version;
|
|
26600
26615
|
var EMBEDS_BASE2 = "https://embeds.langwatch.ai";
|
|
26601
26616
|
function downloadUrl4(platform5) {
|
|
@@ -26635,7 +26650,6 @@ var redisPredep = {
|
|
|
26635
26650
|
async install({ platform: platform5, paths: paths2, task }) {
|
|
26636
26651
|
(0, import_node_fs17.mkdirSync)(paths2.bin, { recursive: true });
|
|
26637
26652
|
const url = downloadUrl4(platform5);
|
|
26638
|
-
const tar = await Promise.resolve().then(() => (init_index_min(), index_min_exports));
|
|
26639
26653
|
const tmp = (0, import_node_path20.join)(paths2.bin, `.redis-${REDIS_VERSION}-${platform5}.tar.gz`);
|
|
26640
26654
|
await downloadWithProgress(url, tmp, task, `downloading redis ${REDIS_VERSION}`);
|
|
26641
26655
|
task.output = "verifying sha256";
|
|
@@ -26651,7 +26665,7 @@ var redisPredep = {
|
|
|
26651
26665
|
);
|
|
26652
26666
|
}
|
|
26653
26667
|
task.output = "extracting";
|
|
26654
|
-
|
|
26668
|
+
co({ sync: true, file: tmp, cwd: paths2.bin });
|
|
26655
26669
|
const serverBin = (0, import_node_path20.join)(paths2.bin, "redis-server");
|
|
26656
26670
|
const cliBin = (0, import_node_path20.join)(paths2.bin, "redis-cli");
|
|
26657
26671
|
if (!(0, import_node_fs17.existsSync)(serverBin) || !(0, import_node_fs17.existsSync)(cliBin)) {
|
|
@@ -26903,8 +26917,16 @@ async function resolvePortConflicts({ base = PORT_BASE_DEFAULT, yes = false } =
|
|
|
26903
26917
|
return { base, report, resolution: "no-conflict" };
|
|
26904
26918
|
}
|
|
26905
26919
|
printConflicts(report);
|
|
26906
|
-
if (yes
|
|
26907
|
-
|
|
26920
|
+
if (yes) {
|
|
26921
|
+
if (report.suggestedBase != null) {
|
|
26922
|
+
return reportShift(report.suggestedBase, report);
|
|
26923
|
+
}
|
|
26924
|
+
console.error(
|
|
26925
|
+
source_default.red(
|
|
26926
|
+
"\u2717 --yes was set but no port shift can free every conflicting slot. Free the ports manually or re-run interactively."
|
|
26927
|
+
)
|
|
26928
|
+
);
|
|
26929
|
+
process.exit(1);
|
|
26908
26930
|
}
|
|
26909
26931
|
const choices = [
|
|
26910
26932
|
...report.suggestedBase != null ? [{ title: `Shift to PORT=${report.suggestedBase}`, value: "shift" }] : [],
|
|
@@ -26966,7 +26988,7 @@ var placeholderRuntime = {
|
|
|
26966
26988
|
};
|
|
26967
26989
|
|
|
26968
26990
|
// src/cli.ts
|
|
26969
|
-
var VERSION = true ? "3.1.0-beta.
|
|
26991
|
+
var VERSION = true ? "3.1.0-beta.19" : "0.0.0-dev";
|
|
26970
26992
|
async function loadRuntime() {
|
|
26971
26993
|
try {
|
|
26972
26994
|
const real = await Promise.resolve().then(() => (init_runtime(), runtime_exports));
|
|
@@ -27026,24 +27048,31 @@ program2.command("start", { isDefault: true }).description("install missing pred
|
|
|
27026
27048
|
return true;
|
|
27027
27049
|
}
|
|
27028
27050
|
});
|
|
27051
|
+
let handles = [];
|
|
27052
|
+
let shuttingDown = false;
|
|
27053
|
+
const onShutdown = async () => {
|
|
27054
|
+
if (shuttingDown) return;
|
|
27055
|
+
shuttingDown = true;
|
|
27056
|
+
console.log(source_default.yellow("\n \u23FB shutting down LangWatch..."));
|
|
27057
|
+
installRouter.installFinished();
|
|
27058
|
+
if (handles.length > 0) {
|
|
27059
|
+
await runtime2.stopAll(handles).catch(() => void 0);
|
|
27060
|
+
}
|
|
27061
|
+
await eventsStream.catch(() => void 0);
|
|
27062
|
+
process.exit(0);
|
|
27063
|
+
};
|
|
27064
|
+
process.on("SIGINT", onShutdown);
|
|
27065
|
+
process.on("SIGTERM", onShutdown);
|
|
27029
27066
|
try {
|
|
27030
27067
|
await runtime2.installServices(ctx);
|
|
27031
27068
|
} finally {
|
|
27032
27069
|
installRouter.installFinished();
|
|
27033
27070
|
}
|
|
27034
27071
|
await panelsPromise;
|
|
27035
|
-
|
|
27072
|
+
handles = await runtime2.startAll(ctx);
|
|
27036
27073
|
await runtime2.waitForHealth(ctx, { timeoutMs: 6e4 });
|
|
27037
27074
|
const url = `http://localhost:${ports.langwatch}`;
|
|
27038
27075
|
if (opts.open !== false && !process.env.CI) await openBrowser(url);
|
|
27039
|
-
const onShutdown = async () => {
|
|
27040
|
-
console.log(source_default.yellow("\n \u23FB shutting down LangWatch..."));
|
|
27041
|
-
await runtime2.stopAll(handles);
|
|
27042
|
-
await eventsStream;
|
|
27043
|
-
process.exit(0);
|
|
27044
|
-
};
|
|
27045
|
-
process.on("SIGINT", onShutdown);
|
|
27046
|
-
process.on("SIGTERM", onShutdown);
|
|
27047
27076
|
await eventsStream;
|
|
27048
27077
|
});
|
|
27049
27078
|
program2.command("doctor").description("check which predeps and services are installed; do not change anything").option("--port-base <n>", "report the resolved ports for this base", String(PORT_BASE_DEFAULT)).action(async (opts) => {
|