@langwatch/server 3.1.0-beta.18 → 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 +61 -35
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
|
}
|
|
@@ -22306,10 +22306,13 @@ async function pollUntilHealthy({
|
|
|
22306
22306
|
return { ok: false, durationMs: Date.now() - start, reason: `timed out: ${lastReason}` };
|
|
22307
22307
|
}
|
|
22308
22308
|
function httpGetCheck(url, opts = {}) {
|
|
22309
|
+
const requestTimeoutMs = opts.requestTimeoutMs ?? 5e3;
|
|
22309
22310
|
return async () => {
|
|
22310
22311
|
const start = Date.now();
|
|
22312
|
+
const ac = new AbortController();
|
|
22313
|
+
const timer = setTimeout(() => ac.abort(), requestTimeoutMs);
|
|
22311
22314
|
try {
|
|
22312
|
-
const res = await fetch(url);
|
|
22315
|
+
const res = await fetch(url, { signal: ac.signal });
|
|
22313
22316
|
const status = res.status;
|
|
22314
22317
|
const expected = opts.expectStatus ?? 200;
|
|
22315
22318
|
if (status !== expected) {
|
|
@@ -22327,7 +22330,10 @@ function httpGetCheck(url, opts = {}) {
|
|
|
22327
22330
|
}
|
|
22328
22331
|
return { ok: true, durationMs: Date.now() - start };
|
|
22329
22332
|
} catch (err) {
|
|
22330
|
-
|
|
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);
|
|
22331
22337
|
}
|
|
22332
22338
|
};
|
|
22333
22339
|
}
|
|
@@ -22400,24 +22406,28 @@ function supervise({
|
|
|
22400
22406
|
if (typeof child.pid === "number") {
|
|
22401
22407
|
(0, import_node_fs21.writeFileSync)(pidPath, String(child.pid));
|
|
22402
22408
|
}
|
|
22403
|
-
|
|
22404
|
-
|
|
22409
|
+
const pipesDrained = [
|
|
22410
|
+
pipeLines(child, "stdout", spec.name, logStream, bus),
|
|
22411
|
+
pipeLines(child, "stderr", spec.name, logStream, bus)
|
|
22412
|
+
];
|
|
22405
22413
|
let stopped = false;
|
|
22406
22414
|
let exited = false;
|
|
22407
22415
|
child.on("exit", (code, signal) => {
|
|
22408
22416
|
exited = true;
|
|
22409
|
-
logStream.end();
|
|
22410
22417
|
safeUnlink(pidPath);
|
|
22411
|
-
|
|
22412
|
-
|
|
22413
|
-
|
|
22414
|
-
|
|
22415
|
-
|
|
22416
|
-
|
|
22417
|
-
|
|
22418
|
-
|
|
22419
|
-
|
|
22420
|
-
|
|
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
|
+
});
|
|
22421
22431
|
});
|
|
22422
22432
|
const stop = async () => {
|
|
22423
22433
|
if (stopped || exited) return;
|
|
@@ -22433,13 +22443,14 @@ function supervise({
|
|
|
22433
22443
|
}
|
|
22434
22444
|
function pipeLines(child, streamName, service, logStream, bus) {
|
|
22435
22445
|
const stream = child[streamName];
|
|
22436
|
-
if (!stream) return;
|
|
22446
|
+
if (!stream) return Promise.resolve();
|
|
22437
22447
|
const rl = (0, import_node_readline.createInterface)({ input: stream });
|
|
22438
22448
|
rl.on("line", (line) => {
|
|
22439
22449
|
logStream.write(`${line}
|
|
22440
22450
|
`);
|
|
22441
22451
|
bus.emit({ type: "log", service, stream: streamName, line });
|
|
22442
22452
|
});
|
|
22453
|
+
return new Promise((resolve) => rl.once("close", () => resolve()));
|
|
22443
22454
|
}
|
|
22444
22455
|
function waitForExit2(child, timeoutMs) {
|
|
22445
22456
|
if (child.exitCode !== null || child.signalCode !== null) return Promise.resolve(true);
|
|
@@ -22875,7 +22886,7 @@ var init_pipe_to_bus = __esm({
|
|
|
22875
22886
|
});
|
|
22876
22887
|
|
|
22877
22888
|
// src/services/node-deps.ts
|
|
22878
|
-
async function ensureLangwatchDeps(
|
|
22889
|
+
async function ensureLangwatchDeps(bus) {
|
|
22879
22890
|
const langwatchDir = locateLangwatchDir();
|
|
22880
22891
|
if (!langwatchDir) throw new Error("langwatch app dir not found");
|
|
22881
22892
|
const nodeModulesPath = (0, import_node_path28.join)(langwatchDir, "node_modules");
|
|
@@ -23521,7 +23532,7 @@ var init_runtime = __esm({
|
|
|
23521
23532
|
await ensureAppDir(ctx, bus);
|
|
23522
23533
|
await Promise.all([
|
|
23523
23534
|
syncVenvs(ctx, bus),
|
|
23524
|
-
ensureLangwatchDeps(
|
|
23535
|
+
ensureLangwatchDeps(bus)
|
|
23525
23536
|
]);
|
|
23526
23537
|
},
|
|
23527
23538
|
async startAll(ctx) {
|
|
@@ -26356,6 +26367,7 @@ function makeAigatewayPredep(version) {
|
|
|
26356
26367
|
init_execa();
|
|
26357
26368
|
var import_node_fs14 = require("node:fs");
|
|
26358
26369
|
var import_node_path17 = require("node:path");
|
|
26370
|
+
init_index_min();
|
|
26359
26371
|
var CH_VERSION = "25.8.22.28";
|
|
26360
26372
|
function downloadSource(platform5) {
|
|
26361
26373
|
const releaseBase = `https://github.com/ClickHouse/ClickHouse/releases/download/v${CH_VERSION}-lts`;
|
|
@@ -26409,11 +26421,10 @@ var clickhousePredep = {
|
|
|
26409
26421
|
if (src.kind === "binary") {
|
|
26410
26422
|
await downloadWithProgress(src.url, out, task, `downloading clickhouse ${CH_VERSION}`);
|
|
26411
26423
|
} else {
|
|
26412
|
-
const tar = await Promise.resolve().then(() => (init_index_min(), index_min_exports));
|
|
26413
26424
|
const tmp = (0, import_node_path17.join)(paths2.bin, `.clickhouse-${CH_VERSION}.tgz`);
|
|
26414
26425
|
await downloadWithProgress(src.url, tmp, task, `downloading clickhouse ${CH_VERSION}`);
|
|
26415
26426
|
task.output = "extracting";
|
|
26416
|
-
|
|
26427
|
+
co({
|
|
26417
26428
|
sync: true,
|
|
26418
26429
|
file: tmp,
|
|
26419
26430
|
cwd: paths2.bin,
|
|
@@ -26599,6 +26610,7 @@ var import_node_crypto3 = require("node:crypto");
|
|
|
26599
26610
|
var import_node_fs17 = require("node:fs");
|
|
26600
26611
|
var import_node_path20 = require("node:path");
|
|
26601
26612
|
var import_promises15 = require("node:stream/promises");
|
|
26613
|
+
init_index_min();
|
|
26602
26614
|
var REDIS_VERSION = embeds_versions_default.redis.version;
|
|
26603
26615
|
var EMBEDS_BASE2 = "https://embeds.langwatch.ai";
|
|
26604
26616
|
function downloadUrl4(platform5) {
|
|
@@ -26638,7 +26650,6 @@ var redisPredep = {
|
|
|
26638
26650
|
async install({ platform: platform5, paths: paths2, task }) {
|
|
26639
26651
|
(0, import_node_fs17.mkdirSync)(paths2.bin, { recursive: true });
|
|
26640
26652
|
const url = downloadUrl4(platform5);
|
|
26641
|
-
const tar = await Promise.resolve().then(() => (init_index_min(), index_min_exports));
|
|
26642
26653
|
const tmp = (0, import_node_path20.join)(paths2.bin, `.redis-${REDIS_VERSION}-${platform5}.tar.gz`);
|
|
26643
26654
|
await downloadWithProgress(url, tmp, task, `downloading redis ${REDIS_VERSION}`);
|
|
26644
26655
|
task.output = "verifying sha256";
|
|
@@ -26654,7 +26665,7 @@ var redisPredep = {
|
|
|
26654
26665
|
);
|
|
26655
26666
|
}
|
|
26656
26667
|
task.output = "extracting";
|
|
26657
|
-
|
|
26668
|
+
co({ sync: true, file: tmp, cwd: paths2.bin });
|
|
26658
26669
|
const serverBin = (0, import_node_path20.join)(paths2.bin, "redis-server");
|
|
26659
26670
|
const cliBin = (0, import_node_path20.join)(paths2.bin, "redis-cli");
|
|
26660
26671
|
if (!(0, import_node_fs17.existsSync)(serverBin) || !(0, import_node_fs17.existsSync)(cliBin)) {
|
|
@@ -26906,8 +26917,16 @@ async function resolvePortConflicts({ base = PORT_BASE_DEFAULT, yes = false } =
|
|
|
26906
26917
|
return { base, report, resolution: "no-conflict" };
|
|
26907
26918
|
}
|
|
26908
26919
|
printConflicts(report);
|
|
26909
|
-
if (yes
|
|
26910
|
-
|
|
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);
|
|
26911
26930
|
}
|
|
26912
26931
|
const choices = [
|
|
26913
26932
|
...report.suggestedBase != null ? [{ title: `Shift to PORT=${report.suggestedBase}`, value: "shift" }] : [],
|
|
@@ -26969,7 +26988,7 @@ var placeholderRuntime = {
|
|
|
26969
26988
|
};
|
|
26970
26989
|
|
|
26971
26990
|
// src/cli.ts
|
|
26972
|
-
var VERSION = true ? "3.1.0-beta.
|
|
26991
|
+
var VERSION = true ? "3.1.0-beta.19" : "0.0.0-dev";
|
|
26973
26992
|
async function loadRuntime() {
|
|
26974
26993
|
try {
|
|
26975
26994
|
const real = await Promise.resolve().then(() => (init_runtime(), runtime_exports));
|
|
@@ -27029,24 +27048,31 @@ program2.command("start", { isDefault: true }).description("install missing pred
|
|
|
27029
27048
|
return true;
|
|
27030
27049
|
}
|
|
27031
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);
|
|
27032
27066
|
try {
|
|
27033
27067
|
await runtime2.installServices(ctx);
|
|
27034
27068
|
} finally {
|
|
27035
27069
|
installRouter.installFinished();
|
|
27036
27070
|
}
|
|
27037
27071
|
await panelsPromise;
|
|
27038
|
-
|
|
27072
|
+
handles = await runtime2.startAll(ctx);
|
|
27039
27073
|
await runtime2.waitForHealth(ctx, { timeoutMs: 6e4 });
|
|
27040
27074
|
const url = `http://localhost:${ports.langwatch}`;
|
|
27041
27075
|
if (opts.open !== false && !process.env.CI) await openBrowser(url);
|
|
27042
|
-
const onShutdown = async () => {
|
|
27043
|
-
console.log(source_default.yellow("\n \u23FB shutting down LangWatch..."));
|
|
27044
|
-
await runtime2.stopAll(handles);
|
|
27045
|
-
await eventsStream;
|
|
27046
|
-
process.exit(0);
|
|
27047
|
-
};
|
|
27048
|
-
process.on("SIGINT", onShutdown);
|
|
27049
|
-
process.on("SIGTERM", onShutdown);
|
|
27050
27076
|
await eventsStream;
|
|
27051
27077
|
});
|
|
27052
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) => {
|