@langwatch/server 3.1.0-beta.10 → 3.1.0-beta.11
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 +175 -30
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.11",
|
|
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",
|
|
@@ -22490,7 +22490,7 @@ async function ensureAppDir(ctx, bus) {
|
|
|
22490
22490
|
const installed = (0, import_node_fs22.readFileSync)(versionMarker, "utf8").trim();
|
|
22491
22491
|
if (installed === ctx.version) return;
|
|
22492
22492
|
}
|
|
22493
|
-
bus.emit({ type: "starting", service: "app
|
|
22493
|
+
bus.emit({ type: "starting", service: "prepare:app" });
|
|
22494
22494
|
const start = Date.now();
|
|
22495
22495
|
(0, import_node_fs22.mkdirSync)(dst, { recursive: true });
|
|
22496
22496
|
const rsyncProbe = await execa("which", ["rsync"], { reject: false });
|
|
@@ -22512,7 +22512,7 @@ async function ensureAppDir(ctx, bus) {
|
|
|
22512
22512
|
await execa("sh", ["-c", `tar -cf - --exclude=node_modules --exclude=.git -C "${src}" . | tar -xf - -C "${dst}"`]);
|
|
22513
22513
|
}
|
|
22514
22514
|
(0, import_node_fs22.writeFileSync)(versionMarker, ctx.version);
|
|
22515
|
-
bus.emit({ type: "healthy", service: "app
|
|
22515
|
+
bus.emit({ type: "healthy", service: "prepare:app", durationMs: Date.now() - start });
|
|
22516
22516
|
}
|
|
22517
22517
|
function appRoot() {
|
|
22518
22518
|
if ((0, import_node_fs22.existsSync)((0, import_node_path25.join)(paths.app, ".installed-version"))) {
|
|
@@ -22835,33 +22835,41 @@ async function ensureLangwatchDeps(ctx, bus) {
|
|
|
22835
22835
|
if (!langwatchDir) throw new Error("langwatch app dir not found");
|
|
22836
22836
|
const nodeModulesPath = (0, import_node_path28.join)(langwatchDir, "node_modules");
|
|
22837
22837
|
const distPath = (0, import_node_path28.join)(langwatchDir, "dist");
|
|
22838
|
-
|
|
22838
|
+
const prismaClientPath = (0, import_node_path28.join)(nodeModulesPath, ".prisma", "client", "index.js");
|
|
22839
|
+
const lockfilePath = (0, import_node_path28.join)(langwatchDir, "pnpm-lock.yaml");
|
|
22840
|
+
const hashFile = (0, import_node_path28.join)(nodeModulesPath, ".install-hash");
|
|
22841
|
+
const distAlreadyBuilt = (0, import_node_fs26.existsSync)((0, import_node_path28.join)(distPath, "client"));
|
|
22842
|
+
const installKey = computeInstallKey(lockfilePath, (0, import_node_path28.join)(langwatchDir, "package.json"));
|
|
22843
|
+
const topLevelLinksOk = (0, import_node_fs26.existsSync)((0, import_node_path28.join)(nodeModulesPath, ".bin", "prisma"));
|
|
22844
|
+
const cachedHash = (0, import_node_fs26.existsSync)(hashFile) ? (0, import_node_fs26.readFileSync)(hashFile, "utf8").trim() : null;
|
|
22845
|
+
const installFresh = topLevelLinksOk && cachedHash === installKey;
|
|
22846
|
+
if (installFresh && (0, import_node_fs26.existsSync)(prismaClientPath) && distAlreadyBuilt) {
|
|
22839
22847
|
return;
|
|
22840
22848
|
}
|
|
22841
|
-
bus.emit({ type: "starting", service: "
|
|
22849
|
+
bus.emit({ type: "starting", service: "prepare:langwatch" });
|
|
22842
22850
|
const start = Date.now();
|
|
22843
22851
|
const pnpm = await resolvePnpm();
|
|
22844
|
-
|
|
22845
|
-
if (!(0, import_node_fs26.existsSync)(nodeModulesPath)) {
|
|
22852
|
+
if (!installFresh) {
|
|
22846
22853
|
await execAndPipe(
|
|
22847
22854
|
bus,
|
|
22848
|
-
"
|
|
22855
|
+
"prepare:langwatch",
|
|
22849
22856
|
pnpm.command,
|
|
22850
22857
|
[...pnpm.args, "-C", langwatchDir, "install", "--prod=false", "--frozen-lockfile"]
|
|
22851
22858
|
);
|
|
22852
|
-
|
|
22853
|
-
|
|
22854
|
-
|
|
22855
|
-
|
|
22856
|
-
|
|
22857
|
-
|
|
22858
|
-
|
|
22859
|
-
|
|
22859
|
+
(0, import_node_fs26.writeFileSync)(hashFile, installKey);
|
|
22860
|
+
}
|
|
22861
|
+
if (distAlreadyBuilt && !(0, import_node_fs26.existsSync)(prismaClientPath)) {
|
|
22862
|
+
await execAndPipe(
|
|
22863
|
+
bus,
|
|
22864
|
+
"prepare:langwatch",
|
|
22865
|
+
pnpm.command,
|
|
22866
|
+
[...pnpm.args, "-C", langwatchDir, "exec", "prisma", "generate"]
|
|
22867
|
+
);
|
|
22860
22868
|
}
|
|
22861
22869
|
if (!distAlreadyBuilt) {
|
|
22862
22870
|
await execAndPipe(
|
|
22863
22871
|
bus,
|
|
22864
|
-
"
|
|
22872
|
+
"prepare:langwatch",
|
|
22865
22873
|
pnpm.command,
|
|
22866
22874
|
[...pnpm.args, "-C", langwatchDir, "run", "build"],
|
|
22867
22875
|
{
|
|
@@ -22872,7 +22880,15 @@ async function ensureLangwatchDeps(ctx, bus) {
|
|
|
22872
22880
|
}
|
|
22873
22881
|
);
|
|
22874
22882
|
}
|
|
22875
|
-
bus.emit({ type: "healthy", service: "
|
|
22883
|
+
bus.emit({ type: "healthy", service: "prepare:langwatch", durationMs: Date.now() - start });
|
|
22884
|
+
}
|
|
22885
|
+
function computeInstallKey(...files) {
|
|
22886
|
+
const h2 = (0, import_node_crypto5.createHash)("sha256");
|
|
22887
|
+
for (const f2 of files) {
|
|
22888
|
+
if ((0, import_node_fs26.existsSync)(f2)) h2.update((0, import_node_fs26.readFileSync)(f2));
|
|
22889
|
+
h2.update("\n--\n");
|
|
22890
|
+
}
|
|
22891
|
+
return h2.digest("hex");
|
|
22876
22892
|
}
|
|
22877
22893
|
async function resolvePnpm() {
|
|
22878
22894
|
const direct = await execa("pnpm", ["--version"], { reject: false });
|
|
@@ -22885,11 +22901,12 @@ function locateLangwatchDir() {
|
|
|
22885
22901
|
const dir = (0, import_node_path28.join)(appRoot(), "langwatch");
|
|
22886
22902
|
return (0, import_node_fs26.existsSync)((0, import_node_path28.join)(dir, "package.json")) ? dir : null;
|
|
22887
22903
|
}
|
|
22888
|
-
var import_node_fs26, import_node_path28;
|
|
22904
|
+
var import_node_crypto5, import_node_fs26, import_node_path28;
|
|
22889
22905
|
var init_node_deps = __esm({
|
|
22890
22906
|
"src/services/node-deps.ts"() {
|
|
22891
22907
|
"use strict";
|
|
22892
22908
|
init_execa();
|
|
22909
|
+
import_node_crypto5 = require("node:crypto");
|
|
22893
22910
|
import_node_fs26 = require("node:fs");
|
|
22894
22911
|
import_node_path28 = require("node:path");
|
|
22895
22912
|
init_app_dir();
|
|
@@ -23298,12 +23315,12 @@ async function syncVenvs(ctx, bus) {
|
|
|
23298
23315
|
const hashFile = (0, import_node_path33.join)(venvDir, ".lock-hash");
|
|
23299
23316
|
const expected = hashFileSafely(spec.lockFile);
|
|
23300
23317
|
if ((0, import_node_fs31.existsSync)(venvDir) && readFileSafely(hashFile) === expected) return;
|
|
23301
|
-
bus.emit({ type: "starting", service: `
|
|
23318
|
+
bus.emit({ type: "starting", service: `prepare:${spec.name}` });
|
|
23302
23319
|
const start = Date.now();
|
|
23303
23320
|
(0, import_node_fs31.mkdirSync)(venvDir, { recursive: true });
|
|
23304
23321
|
await execAndPipe(
|
|
23305
23322
|
bus,
|
|
23306
|
-
`
|
|
23323
|
+
`prepare:${spec.name}`,
|
|
23307
23324
|
uvBin,
|
|
23308
23325
|
["sync", "--project", spec.projectDir],
|
|
23309
23326
|
{
|
|
@@ -23314,7 +23331,7 @@ async function syncVenvs(ctx, bus) {
|
|
|
23314
23331
|
}
|
|
23315
23332
|
);
|
|
23316
23333
|
(0, import_node_fs31.writeFileSync)(hashFile, expected);
|
|
23317
|
-
bus.emit({ type: "healthy", service: `
|
|
23334
|
+
bus.emit({ type: "healthy", service: `prepare:${spec.name}`, durationMs: Date.now() - start });
|
|
23318
23335
|
})
|
|
23319
23336
|
);
|
|
23320
23337
|
}
|
|
@@ -23335,18 +23352,18 @@ function resolveVenvSpecs() {
|
|
|
23335
23352
|
}
|
|
23336
23353
|
function hashFileSafely(file) {
|
|
23337
23354
|
if (!(0, import_node_fs31.existsSync)(file)) return "missing";
|
|
23338
|
-
return (0,
|
|
23355
|
+
return (0, import_node_crypto6.createHash)("sha256").update((0, import_node_fs31.readFileSync)(file)).digest("hex");
|
|
23339
23356
|
}
|
|
23340
23357
|
function readFileSafely(file) {
|
|
23341
23358
|
if (!(0, import_node_fs31.existsSync)(file)) return null;
|
|
23342
23359
|
return (0, import_node_fs31.readFileSync)(file, "utf8").trim();
|
|
23343
23360
|
}
|
|
23344
|
-
var import_node_fs31,
|
|
23361
|
+
var import_node_fs31, import_node_crypto6, import_node_path33;
|
|
23345
23362
|
var init_venvs = __esm({
|
|
23346
23363
|
"src/services/venvs.ts"() {
|
|
23347
23364
|
"use strict";
|
|
23348
23365
|
import_node_fs31 = require("node:fs");
|
|
23349
|
-
|
|
23366
|
+
import_node_crypto6 = require("node:crypto");
|
|
23350
23367
|
import_node_path33 = require("node:path");
|
|
23351
23368
|
init_app_dir();
|
|
23352
23369
|
init_paths2();
|
|
@@ -24051,9 +24068,15 @@ var COLORS2 = {
|
|
|
24051
24068
|
postgres: source_default.dim,
|
|
24052
24069
|
redis: source_default.dim,
|
|
24053
24070
|
clickhouse: source_default.dim,
|
|
24054
|
-
bullboard: source_default.gray
|
|
24071
|
+
bullboard: source_default.gray,
|
|
24072
|
+
"prepare:app": source_default.blue,
|
|
24073
|
+
"prepare:langwatch": source_default.green,
|
|
24074
|
+
"prepare:langwatch_nlp": source_default.cyan,
|
|
24075
|
+
"prepare:langevals": source_default.magenta,
|
|
24076
|
+
"migrate:prisma": source_default.dim,
|
|
24077
|
+
"migrate:clickhouse": source_default.dim
|
|
24055
24078
|
};
|
|
24056
|
-
var LABEL_WIDTH =
|
|
24079
|
+
var LABEL_WIDTH = 22;
|
|
24057
24080
|
function paint(service) {
|
|
24058
24081
|
const fn2 = COLORS2[service] ?? source_default.white;
|
|
24059
24082
|
return fn2(service.padEnd(LABEL_WIDTH));
|
|
@@ -24074,8 +24097,10 @@ function renderEvent(ev) {
|
|
|
24074
24097
|
return null;
|
|
24075
24098
|
}
|
|
24076
24099
|
}
|
|
24077
|
-
async function streamEventsToTTY(events) {
|
|
24100
|
+
async function streamEventsToTTY(events, options = {}) {
|
|
24101
|
+
const { intercept } = options;
|
|
24078
24102
|
for await (const ev of events) {
|
|
24103
|
+
if (intercept && intercept(ev)) continue;
|
|
24079
24104
|
const line = renderEvent(ev);
|
|
24080
24105
|
if (line) {
|
|
24081
24106
|
process.stdout.write(`${line}
|
|
@@ -25988,6 +26013,113 @@ var Listr = class {
|
|
|
25988
26013
|
}
|
|
25989
26014
|
};
|
|
25990
26015
|
|
|
26016
|
+
// src/animation/install-panels.ts
|
|
26017
|
+
var RING_SIZE = 5;
|
|
26018
|
+
var INSTALL_TASKS = [
|
|
26019
|
+
{ title: "preparing langwatch app", service: "prepare:app" },
|
|
26020
|
+
{ title: "installing langwatch_nlp deps", service: "prepare:langwatch_nlp" },
|
|
26021
|
+
{ title: "installing langevals deps", service: "prepare:langevals" },
|
|
26022
|
+
{ title: "installing langwatch deps", service: "prepare:langwatch" }
|
|
26023
|
+
];
|
|
26024
|
+
var INSTALL_SERVICES = new Set(INSTALL_TASKS.map((t) => t.service));
|
|
26025
|
+
function isInstallEvent(ev) {
|
|
26026
|
+
return INSTALL_SERVICES.has(ev.service);
|
|
26027
|
+
}
|
|
26028
|
+
function makeInstallPanelRouter() {
|
|
26029
|
+
const buffered = /* @__PURE__ */ new Map();
|
|
26030
|
+
const listeners = /* @__PURE__ */ new Map();
|
|
26031
|
+
const finishedListeners = /* @__PURE__ */ new Set();
|
|
26032
|
+
let finished7 = false;
|
|
26033
|
+
return {
|
|
26034
|
+
subscribe(service, fn2) {
|
|
26035
|
+
listeners.set(service, fn2);
|
|
26036
|
+
const queue = buffered.get(service);
|
|
26037
|
+
if (queue) {
|
|
26038
|
+
for (const ev of queue) fn2(ev);
|
|
26039
|
+
buffered.delete(service);
|
|
26040
|
+
}
|
|
26041
|
+
},
|
|
26042
|
+
feed(ev) {
|
|
26043
|
+
if (!INSTALL_SERVICES.has(ev.service)) return;
|
|
26044
|
+
const fn2 = listeners.get(ev.service);
|
|
26045
|
+
if (fn2) {
|
|
26046
|
+
fn2(ev);
|
|
26047
|
+
return;
|
|
26048
|
+
}
|
|
26049
|
+
const queue = buffered.get(ev.service) ?? [];
|
|
26050
|
+
queue.push(ev);
|
|
26051
|
+
buffered.set(ev.service, queue);
|
|
26052
|
+
},
|
|
26053
|
+
installFinished() {
|
|
26054
|
+
if (finished7) return;
|
|
26055
|
+
finished7 = true;
|
|
26056
|
+
for (const fn2 of finishedListeners) fn2();
|
|
26057
|
+
finishedListeners.clear();
|
|
26058
|
+
},
|
|
26059
|
+
// exposed via prototype-style closure: tasks call back through subscribe()
|
|
26060
|
+
// for events, and (separately) await an install-finished signal so cached
|
|
26061
|
+
// steps that never emit can complete.
|
|
26062
|
+
onInstallFinished(fn2) {
|
|
26063
|
+
if (finished7) {
|
|
26064
|
+
fn2();
|
|
26065
|
+
return;
|
|
26066
|
+
}
|
|
26067
|
+
finishedListeners.add(fn2);
|
|
26068
|
+
}
|
|
26069
|
+
};
|
|
26070
|
+
}
|
|
26071
|
+
function renderInstallPanels(router) {
|
|
26072
|
+
const tasks = new Listr(
|
|
26073
|
+
INSTALL_TASKS.map((spec) => ({
|
|
26074
|
+
title: spec.title,
|
|
26075
|
+
task: (_2, task) => new Promise((resolve, reject) => {
|
|
26076
|
+
const ring = [];
|
|
26077
|
+
let started = false;
|
|
26078
|
+
router.subscribe(spec.service, (ev) => {
|
|
26079
|
+
if (ev.type === "starting") {
|
|
26080
|
+
started = true;
|
|
26081
|
+
return;
|
|
26082
|
+
}
|
|
26083
|
+
if (ev.type === "log") {
|
|
26084
|
+
const trimmed = ev.line.replace(/\r/g, "").trim();
|
|
26085
|
+
if (trimmed.length === 0) return;
|
|
26086
|
+
ring.push(trimmed);
|
|
26087
|
+
if (ring.length > RING_SIZE) ring.shift();
|
|
26088
|
+
task.output = ring.join("\n");
|
|
26089
|
+
return;
|
|
26090
|
+
}
|
|
26091
|
+
if (ev.type === "healthy") {
|
|
26092
|
+
resolve();
|
|
26093
|
+
return;
|
|
26094
|
+
}
|
|
26095
|
+
if (ev.type === "crashed") {
|
|
26096
|
+
reject(new Error(`${spec.service} crashed (exit ${ev.code})`));
|
|
26097
|
+
return;
|
|
26098
|
+
}
|
|
26099
|
+
});
|
|
26100
|
+
router.onInstallFinished(
|
|
26101
|
+
() => {
|
|
26102
|
+
if (!started) {
|
|
26103
|
+
task.skip("(cached)");
|
|
26104
|
+
resolve();
|
|
26105
|
+
}
|
|
26106
|
+
}
|
|
26107
|
+
);
|
|
26108
|
+
})
|
|
26109
|
+
})),
|
|
26110
|
+
{
|
|
26111
|
+
concurrent: true,
|
|
26112
|
+
exitOnError: false,
|
|
26113
|
+
collectErrors: "minimal",
|
|
26114
|
+
rendererOptions: { collapseSubtasks: false }
|
|
26115
|
+
}
|
|
26116
|
+
);
|
|
26117
|
+
return tasks.run().then(
|
|
26118
|
+
() => void 0,
|
|
26119
|
+
() => void 0
|
|
26120
|
+
);
|
|
26121
|
+
}
|
|
26122
|
+
|
|
25991
26123
|
// src/predeps/runner.ts
|
|
25992
26124
|
var import_node_fs19 = require("node:fs");
|
|
25993
26125
|
var import_prompts = __toESM(require_prompts3(), 1);
|
|
@@ -26704,7 +26836,7 @@ var placeholderRuntime = {
|
|
|
26704
26836
|
};
|
|
26705
26837
|
|
|
26706
26838
|
// src/cli.ts
|
|
26707
|
-
var VERSION = true ? "3.1.0-beta.
|
|
26839
|
+
var VERSION = true ? "3.1.0-beta.11" : "0.0.0-dev";
|
|
26708
26840
|
async function loadRuntime() {
|
|
26709
26841
|
try {
|
|
26710
26842
|
const real = await Promise.resolve().then(() => (init_runtime(), runtime_exports));
|
|
@@ -26755,8 +26887,21 @@ program2.command("start", { isDefault: true }).description("install missing pred
|
|
|
26755
26887
|
userEnv: captureUserEnv()
|
|
26756
26888
|
};
|
|
26757
26889
|
ensureEnvFile(ctx);
|
|
26758
|
-
const
|
|
26759
|
-
|
|
26890
|
+
const installRouter = makeInstallPanelRouter();
|
|
26891
|
+
const panelsPromise = renderInstallPanels(installRouter);
|
|
26892
|
+
const eventsStream = streamEventsToTTY(runtime2.events(ctx), {
|
|
26893
|
+
intercept: (ev) => {
|
|
26894
|
+
if (!isInstallEvent(ev)) return false;
|
|
26895
|
+
installRouter.feed(ev);
|
|
26896
|
+
return true;
|
|
26897
|
+
}
|
|
26898
|
+
});
|
|
26899
|
+
try {
|
|
26900
|
+
await runtime2.installServices(ctx);
|
|
26901
|
+
} finally {
|
|
26902
|
+
installRouter.installFinished();
|
|
26903
|
+
}
|
|
26904
|
+
await panelsPromise;
|
|
26760
26905
|
const handles = await runtime2.startAll(ctx);
|
|
26761
26906
|
await runtime2.waitForHealth(ctx, { timeoutMs: 6e4 });
|
|
26762
26907
|
const url = `http://localhost:${ports.langwatch}`;
|