@llmops/app 1.0.0-beta.11 → 1.0.0-beta.12

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/dist/index.cjs CHANGED
@@ -43,9 +43,6 @@ let hono = require("hono");
43
43
  let __llmops_core = require("@llmops/core");
44
44
  let nunjucks = require("nunjucks");
45
45
  nunjucks = __toESM(nunjucks);
46
- let node_url = require("node:url");
47
- let node_path = require("node:path");
48
- let node_fs = require("node:fs");
49
46
  let __hono_zod_validator = require("@hono/zod-validator");
50
47
  let __llmops_sdk = require("@llmops/sdk");
51
48
  let hono_pretty_json = require("hono/pretty-json");
@@ -57,10 +54,6 @@ __llmops_gateway = __toESM(__llmops_gateway);
57
54
  let protobufjs = require("protobufjs");
58
55
  protobufjs = __toESM(protobufjs);
59
56
  let node_process = require("node:process");
60
- let hono_serve_static = require("hono/serve-static");
61
- let url = require("url");
62
- let path = require("path");
63
- let fs_promises = require("fs/promises");
64
57
 
65
58
  //#region src/client/index.tsx?url
66
59
  var client_default = "/assets/index-silDa7sW.js";
@@ -408,8 +401,8 @@ const manifest = {
408
401
  "names": ["styles.css"]
409
402
  }
410
403
  };
411
- const getAsset = (path$1) => {
412
- return embeddedAssets[path$1];
404
+ const getAsset = (path) => {
405
+ return embeddedAssets[path];
413
406
  };
414
407
  const decodeAsset = (asset) => {
415
408
  return Buffer.from(asset.content, "base64");
@@ -417,8 +410,7 @@ const decodeAsset = (asset) => {
417
410
 
418
411
  //#endregion
419
412
  //#region src/server/ssr/renderer.ts
420
- const manifestPath = (0, node_path.join)((0, node_path.dirname)((0, node_url.fileURLToPath)(require("url").pathToFileURL(__filename).href)), "./.vite/manifest.json");
421
- const manifest$1 = Object.keys(manifest).length > 0 ? manifest : (0, node_fs.existsSync)(manifestPath) ? JSON.parse((0, node_fs.readFileSync)(manifestPath, "utf-8")) : {};
413
+ const manifest$1 = Object.keys(manifest).length > 0 ? manifest : {};
422
414
  const env$2 = new nunjucks.default.Environment(null, { autoescape: false });
423
415
  const htmlTemplate = `<!DOCTYPE html>
424
416
  <html lang="en" class="">
@@ -907,9 +899,9 @@ function mergeDefs(...defs) {
907
899
  function cloneDef(schema) {
908
900
  return mergeDefs(schema._zod.def);
909
901
  }
910
- function getElementAtPath(obj, path$1) {
911
- if (!path$1) return obj;
912
- return path$1.reduce((acc, key) => acc?.[key], obj);
902
+ function getElementAtPath(obj, path) {
903
+ if (!path) return obj;
904
+ return path.reduce((acc, key) => acc?.[key], obj);
913
905
  }
914
906
  function promiseAllObject(promisesObj) {
915
907
  const keys = Object.keys(promisesObj);
@@ -1206,11 +1198,11 @@ function aborted(x, startIndex = 0) {
1206
1198
  for (let i = startIndex; i < x.issues.length; i++) if (x.issues[i]?.continue !== true) return true;
1207
1199
  return false;
1208
1200
  }
1209
- function prefixIssues(path$1, issues) {
1201
+ function prefixIssues(path, issues) {
1210
1202
  return issues.map((iss) => {
1211
1203
  var _a$1;
1212
1204
  (_a$1 = iss).path ?? (_a$1.path = []);
1213
- iss.path.unshift(path$1);
1205
+ iss.path.unshift(path);
1214
1206
  return iss;
1215
1207
  });
1216
1208
  }
@@ -1358,13 +1350,13 @@ function formatError(error$47, mapper = (issue$1) => issue$1.message) {
1358
1350
  }
1359
1351
  function treeifyError(error$47, mapper = (issue$1) => issue$1.message) {
1360
1352
  const result = { errors: [] };
1361
- const processError = (error$48, path$1 = []) => {
1353
+ const processError = (error$48, path = []) => {
1362
1354
  var _a$1, _b;
1363
1355
  for (const issue$1 of error$48.issues) if (issue$1.code === "invalid_union" && issue$1.errors.length) issue$1.errors.map((issues) => processError({ issues }, issue$1.path));
1364
1356
  else if (issue$1.code === "invalid_key") processError({ issues: issue$1.issues }, issue$1.path);
1365
1357
  else if (issue$1.code === "invalid_element") processError({ issues: issue$1.issues }, issue$1.path);
1366
1358
  else {
1367
- const fullpath = [...path$1, ...issue$1.path];
1359
+ const fullpath = [...path, ...issue$1.path];
1368
1360
  if (fullpath.length === 0) {
1369
1361
  result.errors.push(mapper(issue$1));
1370
1362
  continue;
@@ -1425,8 +1417,8 @@ function treeifyError(error$47, mapper = (issue$1) => issue$1.message) {
1425
1417
  */
1426
1418
  function toDotPath(_path) {
1427
1419
  const segs = [];
1428
- const path$1 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
1429
- for (const seg of path$1) if (typeof seg === "number") segs.push(`[${seg}]`);
1420
+ const path = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
1421
+ for (const seg of path) if (typeof seg === "number") segs.push(`[${seg}]`);
1430
1422
  else if (typeof seg === "symbol") segs.push(`[${JSON.stringify(String(seg))}]`);
1431
1423
  else if (/[^\w$]/.test(seg)) segs.push(`[${JSON.stringify(seg)}]`);
1432
1424
  else {
@@ -2399,10 +2391,10 @@ const $ZodURL = /* @__PURE__ */ $constructor("$ZodURL", (inst, def) => {
2399
2391
  inst._zod.check = (payload) => {
2400
2392
  try {
2401
2393
  const trimmed = payload.value.trim();
2402
- const url$2 = new URL(trimmed);
2394
+ const url$1 = new URL(trimmed);
2403
2395
  if (def.hostname) {
2404
2396
  def.hostname.lastIndex = 0;
2405
- if (!def.hostname.test(url$2.hostname)) payload.issues.push({
2397
+ if (!def.hostname.test(url$1.hostname)) payload.issues.push({
2406
2398
  code: "invalid_format",
2407
2399
  format: "url",
2408
2400
  note: "Invalid hostname",
@@ -2414,7 +2406,7 @@ const $ZodURL = /* @__PURE__ */ $constructor("$ZodURL", (inst, def) => {
2414
2406
  }
2415
2407
  if (def.protocol) {
2416
2408
  def.protocol.lastIndex = 0;
2417
- if (!def.protocol.test(url$2.protocol.endsWith(":") ? url$2.protocol.slice(0, -1) : url$2.protocol)) payload.issues.push({
2409
+ if (!def.protocol.test(url$1.protocol.endsWith(":") ? url$1.protocol.slice(0, -1) : url$1.protocol)) payload.issues.push({
2418
2410
  code: "invalid_format",
2419
2411
  format: "url",
2420
2412
  note: "Invalid protocol",
@@ -2424,7 +2416,7 @@ const $ZodURL = /* @__PURE__ */ $constructor("$ZodURL", (inst, def) => {
2424
2416
  continue: !def.abort
2425
2417
  });
2426
2418
  }
2427
- if (def.normalize) payload.value = url$2.href;
2419
+ if (def.normalize) payload.value = url$1.href;
2428
2420
  else payload.value = trimmed;
2429
2421
  return;
2430
2422
  } catch (_) {
@@ -11835,7 +11827,7 @@ var schemas_exports = /* @__PURE__ */ __export({
11835
11827
  undefined: () => _undefined,
11836
11828
  union: () => union,
11837
11829
  unknown: () => unknown,
11838
- url: () => url$1,
11830
+ url: () => url,
11839
11831
  uuid: () => uuid,
11840
11832
  uuidv4: () => uuidv4,
11841
11833
  uuidv6: () => uuidv6,
@@ -12017,7 +12009,7 @@ const ZodURL = /* @__PURE__ */ $constructor("ZodURL", (inst, def) => {
12017
12009
  $ZodURL.init(inst, def);
12018
12010
  ZodStringFormat.init(inst, def);
12019
12011
  });
12020
- function url$1(params) {
12012
+ function url(params) {
12021
12013
  return _url(ZodURL, params);
12022
12014
  }
12023
12015
  function httpUrl(params) {
@@ -13022,11 +13014,11 @@ function detectVersion(schema, defaultTarget) {
13022
13014
  }
13023
13015
  function resolveRef(ref, ctx) {
13024
13016
  if (!ref.startsWith("#")) throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
13025
- const path$1 = ref.slice(1).split("/").filter(Boolean);
13026
- if (path$1.length === 0) return ctx.rootSchema;
13017
+ const path = ref.slice(1).split("/").filter(Boolean);
13018
+ if (path.length === 0) return ctx.rootSchema;
13027
13019
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
13028
- if (path$1[0] === defsKey) {
13029
- const key = path$1[1];
13020
+ if (path[0] === defsKey) {
13021
+ const key = path[1];
13030
13022
  if (!key || !ctx.defs[key]) throw new Error(`Reference not found: ${ref}`);
13031
13023
  return ctx.defs[key];
13032
13024
  }
@@ -13527,7 +13519,7 @@ var external_exports = /* @__PURE__ */ __export({
13527
13519
  union: () => union,
13528
13520
  unknown: () => unknown,
13529
13521
  uppercase: () => _uppercase,
13530
- url: () => url$1,
13522
+ url: () => url,
13531
13523
  util: () => util_exports,
13532
13524
  uuid: () => uuid,
13533
13525
  uuidv4: () => uuidv4,
@@ -14710,7 +14702,7 @@ function createCostTrackingMiddleware(config$1 = {}) {
14710
14702
  const log = debug ? (msg) => __llmops_core.logger.debug(`[CostTracking] ${msg}`) : () => {};
14711
14703
  return async (c, next) => {
14712
14704
  if (!enabled) return next();
14713
- const path$1 = c.req.path;
14705
+ const path = c.req.path;
14714
14706
  if (![
14715
14707
  "/chat/completions",
14716
14708
  "/completions",
@@ -14722,7 +14714,7 @@ function createCostTrackingMiddleware(config$1 = {}) {
14722
14714
  "/audio/transcriptions",
14723
14715
  "/audio/translations",
14724
14716
  "/messages"
14725
- ].some((endpoint) => path$1.endsWith(endpoint) || endpoint === "/responses" && path$1.match(/\/responses\/[^/]+$/))) return next();
14717
+ ].some((endpoint) => path.endsWith(endpoint) || endpoint === "/responses" && path.match(/\/responses\/[^/]+$/))) return next();
14726
14718
  const requestId = (0, node_crypto.randomUUID)();
14727
14719
  const startTime = Date.now();
14728
14720
  c.header(__llmops_core.LLMOPS_REQUEST_ID_HEADER, requestId);
@@ -14732,7 +14724,7 @@ function createCostTrackingMiddleware(config$1 = {}) {
14732
14724
  body = await c.req.raw.clone().json();
14733
14725
  isStreaming = body.stream === true;
14734
14726
  __llmops_core.logger.debug({
14735
- endpoint: path$1,
14727
+ endpoint: path,
14736
14728
  isStreaming,
14737
14729
  streamValue: body.stream,
14738
14730
  model: body.model
@@ -14767,7 +14759,7 @@ function createCostTrackingMiddleware(config$1 = {}) {
14767
14759
  provider: "",
14768
14760
  model: body.model || "",
14769
14761
  configId: c.get("configId"),
14770
- endpoint: path$1,
14762
+ endpoint: path,
14771
14763
  isStreaming
14772
14764
  };
14773
14765
  c.set("__costTrackingContext", context);
@@ -15919,17 +15911,16 @@ const createMigrationMiddleware = (config$1) => {
15919
15911
 
15920
15912
  //#endregion
15921
15913
  //#region src/server/middlewares/static-assets.ts
15922
- const __dirname$1 = (0, path.dirname)((0, url.fileURLToPath)(require("url").pathToFileURL(__filename).href));
15923
15914
  const hasEmbeddedAssets = Object.keys(embeddedAssets).length > 0;
15924
15915
  /**
15925
15916
  * Creates a middleware for serving static assets.
15926
15917
  * In production (single-file mode), serves from embedded base64 assets.
15927
- * In development, serves from the filesystem.
15918
+ * In development, serves from the filesystem via dynamic import().
15928
15919
  */
15929
15920
  const createStaticAssetMiddleware = () => {
15930
15921
  if (hasEmbeddedAssets) return async (c) => {
15931
- const path$1 = c.req.path;
15932
- const asset = getAsset(path$1);
15922
+ const path = c.req.path;
15923
+ const asset = getAsset(path);
15933
15924
  if (!asset) return c.notFound();
15934
15925
  const buffer = decodeAsset(asset);
15935
15926
  return new Response(new Uint8Array(buffer), { headers: {
@@ -15937,16 +15928,39 @@ const createStaticAssetMiddleware = () => {
15937
15928
  "Cache-Control": "public, max-age=31536000, immutable"
15938
15929
  } });
15939
15930
  };
15940
- return (0, hono_serve_static.serveStatic)({
15941
- root: "./",
15942
- getContent: async (path$1) => {
15943
- try {
15944
- return await (0, fs_promises.readFile)((0, path.join)(__dirname$1, "..", path$1));
15945
- } catch {
15946
- return null;
15947
- }
15931
+ let devServe = null;
15932
+ return async (c) => {
15933
+ if (!devServe) {
15934
+ const { fileURLToPath } = await import("node:url");
15935
+ const { dirname, join } = await import("node:path");
15936
+ const { readFile } = await import("node:fs/promises");
15937
+ const currentDir = dirname(fileURLToPath(require("url").pathToFileURL(__filename).href));
15938
+ devServe = async (ctx) => {
15939
+ const path = ctx.req.path;
15940
+ try {
15941
+ const file$1 = await readFile(join(currentDir, "..", path));
15942
+ const ext = path.split(".").pop() || "";
15943
+ const mimeTypes = {
15944
+ js: "application/javascript",
15945
+ mjs: "application/javascript",
15946
+ css: "text/css",
15947
+ svg: "image/svg+xml",
15948
+ png: "image/png",
15949
+ jpg: "image/jpeg",
15950
+ ico: "image/x-icon",
15951
+ woff: "font/woff",
15952
+ woff2: "font/woff2"
15953
+ };
15954
+ return new Response(file$1, { headers: { "Content-Type": mimeTypes[ext] || "application/octet-stream" } });
15955
+ } catch {
15956
+ return;
15957
+ }
15958
+ };
15948
15959
  }
15949
- });
15960
+ const response = await devServe(c);
15961
+ if (response) return response;
15962
+ return c.notFound();
15963
+ };
15950
15964
  };
15951
15965
 
15952
15966
  //#endregion
package/dist/index.mjs CHANGED
@@ -1,9 +1,6 @@
1
1
  import { Hono } from "hono";
2
2
  import { LLMOPS_REQUEST_ID_HEADER, LLMOPS_SESSION_ID_HEADER, LLMOPS_SPAN_ID_HEADER, LLMOPS_SPAN_NAME_HEADER, LLMOPS_TRACE_ID_HEADER, LLMOPS_TRACE_NAME_HEADER, LLMOPS_USER_ID_HEADER, SupportedProviders, calculateCacheAwareCost, getDefaultPricingProvider, logger, validateLLMOpsConfig } from "@llmops/core";
3
3
  import nunjucks from "nunjucks";
4
- import { fileURLToPath } from "node:url";
5
- import { dirname, join } from "node:path";
6
- import { existsSync, readFileSync } from "node:fs";
7
4
  import { zValidator } from "@hono/zod-validator";
8
5
  import { COST_SUMMARY_GROUP_BY } from "@llmops/sdk";
9
6
  import { prettyJSON } from "hono/pretty-json";
@@ -13,10 +10,6 @@ import { randomBytes, randomUUID } from "node:crypto";
13
10
  import gateway from "@llmops/gateway";
14
11
  import protobuf from "protobufjs";
15
12
  import { env } from "node:process";
16
- import { serveStatic } from "hono/serve-static";
17
- import { fileURLToPath as fileURLToPath$1 } from "url";
18
- import { dirname as dirname$1, join as join$1 } from "path";
19
- import { readFile } from "fs/promises";
20
13
 
21
14
  //#region rolldown:runtime
22
15
  var __defProp = Object.defineProperty;
@@ -390,8 +383,7 @@ const decodeAsset = (asset) => {
390
383
 
391
384
  //#endregion
392
385
  //#region src/server/ssr/renderer.ts
393
- const manifestPath = join(dirname(fileURLToPath(import.meta.url)), "./.vite/manifest.json");
394
- const manifest$1 = Object.keys(manifest).length > 0 ? manifest : existsSync(manifestPath) ? JSON.parse(readFileSync(manifestPath, "utf-8")) : {};
386
+ const manifest$1 = Object.keys(manifest).length > 0 ? manifest : {};
395
387
  const env$1 = new nunjucks.Environment(null, { autoescape: false });
396
388
  const htmlTemplate = `<!DOCTYPE html>
397
389
  <html lang="en" class="">
@@ -15892,12 +15884,11 @@ const createMigrationMiddleware = (config$1) => {
15892
15884
 
15893
15885
  //#endregion
15894
15886
  //#region src/server/middlewares/static-assets.ts
15895
- const __dirname = dirname$1(fileURLToPath$1(import.meta.url));
15896
15887
  const hasEmbeddedAssets = Object.keys(embeddedAssets).length > 0;
15897
15888
  /**
15898
15889
  * Creates a middleware for serving static assets.
15899
15890
  * In production (single-file mode), serves from embedded base64 assets.
15900
- * In development, serves from the filesystem.
15891
+ * In development, serves from the filesystem via dynamic import().
15901
15892
  */
15902
15893
  const createStaticAssetMiddleware = () => {
15903
15894
  if (hasEmbeddedAssets) return async (c) => {
@@ -15910,16 +15901,39 @@ const createStaticAssetMiddleware = () => {
15910
15901
  "Cache-Control": "public, max-age=31536000, immutable"
15911
15902
  } });
15912
15903
  };
15913
- return serveStatic({
15914
- root: "./",
15915
- getContent: async (path) => {
15916
- try {
15917
- return await readFile(join$1(__dirname, "..", path));
15918
- } catch {
15919
- return null;
15920
- }
15904
+ let devServe = null;
15905
+ return async (c) => {
15906
+ if (!devServe) {
15907
+ const { fileURLToPath } = await import("node:url");
15908
+ const { dirname, join } = await import("node:path");
15909
+ const { readFile } = await import("node:fs/promises");
15910
+ const currentDir = dirname(fileURLToPath(import.meta.url));
15911
+ devServe = async (ctx) => {
15912
+ const path = ctx.req.path;
15913
+ try {
15914
+ const file$1 = await readFile(join(currentDir, "..", path));
15915
+ const ext = path.split(".").pop() || "";
15916
+ const mimeTypes = {
15917
+ js: "application/javascript",
15918
+ mjs: "application/javascript",
15919
+ css: "text/css",
15920
+ svg: "image/svg+xml",
15921
+ png: "image/png",
15922
+ jpg: "image/jpeg",
15923
+ ico: "image/x-icon",
15924
+ woff: "font/woff",
15925
+ woff2: "font/woff2"
15926
+ };
15927
+ return new Response(file$1, { headers: { "Content-Type": mimeTypes[ext] || "application/octet-stream" } });
15928
+ } catch {
15929
+ return;
15930
+ }
15931
+ };
15921
15932
  }
15922
- });
15933
+ const response = await devServe(c);
15934
+ if (response) return response;
15935
+ return c.notFound();
15936
+ };
15923
15937
  };
15924
15938
 
15925
15939
  //#endregion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@llmops/app",
3
- "version": "1.0.0-beta.11",
3
+ "version": "1.0.0-beta.12",
4
4
  "description": "LLMOps application with server and client",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -76,9 +76,9 @@
76
76
  "react-hook-form": "^7.68.0",
77
77
  "recharts": "^3.6.0",
78
78
  "uuid": "^13.0.0",
79
- "@llmops/core": "^1.0.0-beta.11",
80
- "@llmops/sdk": "^1.0.0-beta.11",
81
- "@llmops/gateway": "^1.0.0-beta.11"
79
+ "@llmops/core": "^1.0.0-beta.12",
80
+ "@llmops/sdk": "^1.0.0-beta.12",
81
+ "@llmops/gateway": "^1.0.0-beta.12"
82
82
  },
83
83
  "peerDependencies": {
84
84
  "react": "^19.2.1",