@llmops/app 0.3.2-beta.1 → 0.3.2-beta.2

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
@@ -51,11 +51,8 @@ let hono_http_exception = require("hono/http-exception");
51
51
  let __hono_zod_validator = require("@hono/zod-validator");
52
52
  let nunjucks = require("nunjucks");
53
53
  nunjucks = __toESM(nunjucks);
54
- let fs = require("fs");
55
- fs = __toESM(fs);
56
- let path = require("path");
57
- path = __toESM(path);
58
- let url = require("url");
54
+ let __llmops_gateway_plugins_default_manifest_json = require("@llmops/gateway/plugins/default/manifest.json");
55
+ __llmops_gateway_plugins_default_manifest_json = __toESM(__llmops_gateway_plugins_default_manifest_json);
59
56
  let hono_pretty_json = require("hono/pretty-json");
60
57
  let hono_cors = require("hono/cors");
61
58
  let node_crypto = require("node:crypto");
@@ -65,6 +62,8 @@ let node_process = require("node:process");
65
62
  let __llmops_core_db = require("@llmops/core/db");
66
63
  let better_auth = require("better-auth");
67
64
  let hono_serve_static = require("hono/serve-static");
65
+ let url = require("url");
66
+ let path = require("path");
68
67
  let fs_promises = require("fs/promises");
69
68
 
70
69
  //#region src/client/index.tsx?url
@@ -1467,8 +1466,8 @@ const manifest = {
1467
1466
  "names": ["styles.css"]
1468
1467
  }
1469
1468
  };
1470
- const getAsset = (path$2) => {
1471
- return embeddedAssets[path$2];
1469
+ const getAsset = (path$1) => {
1470
+ return embeddedAssets[path$1];
1472
1471
  };
1473
1472
  const decodeAsset = (asset) => {
1474
1473
  return Buffer.from(asset.content, "base64");
@@ -1985,9 +1984,9 @@ function mergeDefs(...defs) {
1985
1984
  function cloneDef(schema) {
1986
1985
  return mergeDefs(schema._zod.def);
1987
1986
  }
1988
- function getElementAtPath(obj, path$2) {
1989
- if (!path$2) return obj;
1990
- return path$2.reduce((acc, key) => acc?.[key], obj);
1987
+ function getElementAtPath(obj, path$1) {
1988
+ if (!path$1) return obj;
1989
+ return path$1.reduce((acc, key) => acc?.[key], obj);
1991
1990
  }
1992
1991
  function promiseAllObject(promisesObj) {
1993
1992
  const keys = Object.keys(promisesObj);
@@ -2284,11 +2283,11 @@ function aborted(x, startIndex = 0) {
2284
2283
  for (let i = startIndex; i < x.issues.length; i++) if (x.issues[i]?.continue !== true) return true;
2285
2284
  return false;
2286
2285
  }
2287
- function prefixIssues(path$2, issues) {
2286
+ function prefixIssues(path$1, issues) {
2288
2287
  return issues.map((iss) => {
2289
2288
  var _a$1;
2290
2289
  (_a$1 = iss).path ?? (_a$1.path = []);
2291
- iss.path.unshift(path$2);
2290
+ iss.path.unshift(path$1);
2292
2291
  return iss;
2293
2292
  });
2294
2293
  }
@@ -2436,13 +2435,13 @@ function formatError(error$47, mapper = (issue$1) => issue$1.message) {
2436
2435
  }
2437
2436
  function treeifyError(error$47, mapper = (issue$1) => issue$1.message) {
2438
2437
  const result = { errors: [] };
2439
- const processError = (error$48, path$2 = []) => {
2438
+ const processError = (error$48, path$1 = []) => {
2440
2439
  var _a$1, _b;
2441
2440
  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));
2442
2441
  else if (issue$1.code === "invalid_key") processError({ issues: issue$1.issues }, issue$1.path);
2443
2442
  else if (issue$1.code === "invalid_element") processError({ issues: issue$1.issues }, issue$1.path);
2444
2443
  else {
2445
- const fullpath = [...path$2, ...issue$1.path];
2444
+ const fullpath = [...path$1, ...issue$1.path];
2446
2445
  if (fullpath.length === 0) {
2447
2446
  result.errors.push(mapper(issue$1));
2448
2447
  continue;
@@ -2503,8 +2502,8 @@ function treeifyError(error$47, mapper = (issue$1) => issue$1.message) {
2503
2502
  */
2504
2503
  function toDotPath(_path) {
2505
2504
  const segs = [];
2506
- const path$2 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
2507
- for (const seg of path$2) if (typeof seg === "number") segs.push(`[${seg}]`);
2505
+ const path$1 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
2506
+ for (const seg of path$1) if (typeof seg === "number") segs.push(`[${seg}]`);
2508
2507
  else if (typeof seg === "symbol") segs.push(`[${JSON.stringify(String(seg))}]`);
2509
2508
  else if (/[^\w$]/.test(seg)) segs.push(`[${JSON.stringify(seg)}]`);
2510
2509
  else {
@@ -14100,11 +14099,11 @@ function detectVersion(schema, defaultTarget) {
14100
14099
  }
14101
14100
  function resolveRef(ref, ctx) {
14102
14101
  if (!ref.startsWith("#")) throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
14103
- const path$2 = ref.slice(1).split("/").filter(Boolean);
14104
- if (path$2.length === 0) return ctx.rootSchema;
14102
+ const path$1 = ref.slice(1).split("/").filter(Boolean);
14103
+ if (path$1.length === 0) return ctx.rootSchema;
14105
14104
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
14106
- if (path$2[0] === defsKey) {
14107
- const key = path$2[1];
14105
+ if (path$1[0] === defsKey) {
14106
+ const key = path$1[1];
14108
14107
  if (!key || !ctx.defs[key]) throw new Error(`Reference not found: ${ref}`);
14109
14108
  return ctx.defs[key];
14110
14109
  }
@@ -15320,31 +15319,8 @@ var environments_default = app$10;
15320
15319
 
15321
15320
  //#endregion
15322
15321
  //#region src/server/handlers/guardrails/index.ts
15323
- const __filename$1 = (0, url.fileURLToPath)(require("url").pathToFileURL(__filename).href);
15324
- const __dirname$2 = path.default.dirname(__filename$1);
15325
- let cachedManifest = null;
15326
15322
  function getDefaultManifest() {
15327
- if (cachedManifest) return cachedManifest;
15328
- const possiblePaths = [
15329
- path.default.resolve(__dirname$2, "../../../../gateway/plugins/default/manifest.json"),
15330
- path.default.resolve(process.cwd(), "packages/gateway/plugins/default/manifest.json"),
15331
- path.default.resolve(__dirname$2, "../../../../../gateway/plugins/default/manifest.json")
15332
- ];
15333
- for (const manifestPath$1 of possiblePaths) try {
15334
- if (fs.default.existsSync(manifestPath$1)) {
15335
- const content = fs.default.readFileSync(manifestPath$1, "utf-8");
15336
- cachedManifest = JSON.parse(content);
15337
- return cachedManifest;
15338
- }
15339
- } catch {}
15340
- console.warn("Could not find default guardrails manifest");
15341
- return {
15342
- id: "default",
15343
- name: "Default",
15344
- description: "Default guardrails",
15345
- credentials: [],
15346
- functions: []
15347
- };
15323
+ return __llmops_gateway_plugins_default_manifest_json.default;
15348
15324
  }
15349
15325
  const app$9 = new hono.Hono().get("/available", async (c) => {
15350
15326
  try {
@@ -16494,10 +16470,10 @@ const createGatewayAdapterMiddleware = () => {
16494
16470
  const envSec = c.get("envSec");
16495
16471
  const db = c.var.db;
16496
16472
  const kyselyDb = c.var.kyselyDb;
16497
- const path$2 = c.req.path;
16473
+ const path$1 = c.req.path;
16498
16474
  const method = c.req.method;
16499
16475
  const contentType = c.req.header("content-type")?.split(";")[0];
16500
- const isChatRequest = method === "POST" && contentType === "application/json" && (path$2.endsWith("/chat/completions") || path$2.endsWith("/completions"));
16476
+ const isChatRequest = method === "POST" && contentType === "application/json" && (path$1.endsWith("/chat/completions") || path$1.endsWith("/completions"));
16501
16477
  if (!configId && isChatRequest) {
16502
16478
  try {
16503
16479
  const body = await c.req.json();
@@ -16936,8 +16912,8 @@ function createCostTrackingMiddleware(config$1 = {}) {
16936
16912
  const log = debug ? (msg) => __llmops_core.logger.debug(`[CostTracking] ${msg}`) : () => {};
16937
16913
  return async (c, next) => {
16938
16914
  if (!enabled) return next();
16939
- const path$2 = c.req.path;
16940
- if (!path$2.endsWith("/chat/completions") && !path$2.endsWith("/completions")) return next();
16915
+ const path$1 = c.req.path;
16916
+ if (!path$1.endsWith("/chat/completions") && !path$1.endsWith("/completions")) return next();
16941
16917
  const requestId = (0, node_crypto.randomUUID)();
16942
16918
  const startTime = Date.now();
16943
16919
  c.header("x-llmops-request-id", requestId);
@@ -16971,7 +16947,7 @@ function createCostTrackingMiddleware(config$1 = {}) {
16971
16947
  provider: "",
16972
16948
  model: body.model || "",
16973
16949
  configId: c.get("configId"),
16974
- endpoint: path$2,
16950
+ endpoint: path$1,
16975
16951
  isStreaming
16976
16952
  };
16977
16953
  c.set("__costTrackingContext", context);
@@ -17361,8 +17337,8 @@ const hasEmbeddedAssets = Object.keys(embeddedAssets).length > 0;
17361
17337
  */
17362
17338
  const createStaticAssetMiddleware = () => {
17363
17339
  if (hasEmbeddedAssets) return async (c) => {
17364
- const path$2 = c.req.path;
17365
- const asset = getAsset(path$2);
17340
+ const path$1 = c.req.path;
17341
+ const asset = getAsset(path$1);
17366
17342
  if (!asset) return c.notFound();
17367
17343
  const buffer = decodeAsset(asset);
17368
17344
  return new Response(new Uint8Array(buffer), { headers: {
@@ -17372,9 +17348,9 @@ const createStaticAssetMiddleware = () => {
17372
17348
  };
17373
17349
  return (0, hono_serve_static.serveStatic)({
17374
17350
  root: "./",
17375
- getContent: async (path$2) => {
17351
+ getContent: async (path$1) => {
17376
17352
  try {
17377
- return await (0, fs_promises.readFile)((0, path.join)(__dirname$1, "..", path$2));
17353
+ return await (0, fs_promises.readFile)((0, path.join)(__dirname$1, "..", path$1));
17378
17354
  } catch {
17379
17355
  return null;
17380
17356
  }
package/dist/index.mjs CHANGED
@@ -8,9 +8,7 @@ import { existsSync, readFileSync } from "node:fs";
8
8
  import { HTTPException } from "hono/http-exception";
9
9
  import { zValidator } from "@hono/zod-validator";
10
10
  import nunjucks from "nunjucks";
11
- import fs from "fs";
12
- import path, { dirname as dirname$1, join as join$1 } from "path";
13
- import { fileURLToPath as fileURLToPath$1 } from "url";
11
+ import defaultManifest from "@llmops/gateway/plugins/default/manifest.json";
14
12
  import { prettyJSON } from "hono/pretty-json";
15
13
  import { cors } from "hono/cors";
16
14
  import { randomUUID } from "node:crypto";
@@ -19,6 +17,8 @@ import { env } from "node:process";
19
17
  import { createDatabaseFromConnection, detectDatabaseType } from "@llmops/core/db";
20
18
  import { betterAuth } from "better-auth";
21
19
  import { serveStatic } from "hono/serve-static";
20
+ import { fileURLToPath as fileURLToPath$1 } from "url";
21
+ import { dirname as dirname$1, join as join$1 } from "path";
22
22
  import { readFile } from "fs/promises";
23
23
 
24
24
  //#region rolldown:runtime
@@ -1438,8 +1438,8 @@ const manifest = {
1438
1438
  "names": ["styles.css"]
1439
1439
  }
1440
1440
  };
1441
- const getAsset = (path$1) => {
1442
- return embeddedAssets[path$1];
1441
+ const getAsset = (path) => {
1442
+ return embeddedAssets[path];
1443
1443
  };
1444
1444
  const decodeAsset = (asset) => {
1445
1445
  return Buffer.from(asset.content, "base64");
@@ -1956,9 +1956,9 @@ function mergeDefs(...defs) {
1956
1956
  function cloneDef(schema) {
1957
1957
  return mergeDefs(schema._zod.def);
1958
1958
  }
1959
- function getElementAtPath(obj, path$1) {
1960
- if (!path$1) return obj;
1961
- return path$1.reduce((acc, key) => acc?.[key], obj);
1959
+ function getElementAtPath(obj, path) {
1960
+ if (!path) return obj;
1961
+ return path.reduce((acc, key) => acc?.[key], obj);
1962
1962
  }
1963
1963
  function promiseAllObject(promisesObj) {
1964
1964
  const keys = Object.keys(promisesObj);
@@ -2255,11 +2255,11 @@ function aborted(x, startIndex = 0) {
2255
2255
  for (let i = startIndex; i < x.issues.length; i++) if (x.issues[i]?.continue !== true) return true;
2256
2256
  return false;
2257
2257
  }
2258
- function prefixIssues(path$1, issues) {
2258
+ function prefixIssues(path, issues) {
2259
2259
  return issues.map((iss) => {
2260
2260
  var _a$1;
2261
2261
  (_a$1 = iss).path ?? (_a$1.path = []);
2262
- iss.path.unshift(path$1);
2262
+ iss.path.unshift(path);
2263
2263
  return iss;
2264
2264
  });
2265
2265
  }
@@ -2407,13 +2407,13 @@ function formatError(error$47, mapper = (issue$1) => issue$1.message) {
2407
2407
  }
2408
2408
  function treeifyError(error$47, mapper = (issue$1) => issue$1.message) {
2409
2409
  const result = { errors: [] };
2410
- const processError = (error$48, path$1 = []) => {
2410
+ const processError = (error$48, path = []) => {
2411
2411
  var _a$1, _b;
2412
2412
  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));
2413
2413
  else if (issue$1.code === "invalid_key") processError({ issues: issue$1.issues }, issue$1.path);
2414
2414
  else if (issue$1.code === "invalid_element") processError({ issues: issue$1.issues }, issue$1.path);
2415
2415
  else {
2416
- const fullpath = [...path$1, ...issue$1.path];
2416
+ const fullpath = [...path, ...issue$1.path];
2417
2417
  if (fullpath.length === 0) {
2418
2418
  result.errors.push(mapper(issue$1));
2419
2419
  continue;
@@ -2474,8 +2474,8 @@ function treeifyError(error$47, mapper = (issue$1) => issue$1.message) {
2474
2474
  */
2475
2475
  function toDotPath(_path) {
2476
2476
  const segs = [];
2477
- const path$1 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
2478
- for (const seg of path$1) if (typeof seg === "number") segs.push(`[${seg}]`);
2477
+ const path = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
2478
+ for (const seg of path) if (typeof seg === "number") segs.push(`[${seg}]`);
2479
2479
  else if (typeof seg === "symbol") segs.push(`[${JSON.stringify(String(seg))}]`);
2480
2480
  else if (/[^\w$]/.test(seg)) segs.push(`[${JSON.stringify(seg)}]`);
2481
2481
  else {
@@ -14071,11 +14071,11 @@ function detectVersion(schema, defaultTarget) {
14071
14071
  }
14072
14072
  function resolveRef(ref, ctx) {
14073
14073
  if (!ref.startsWith("#")) throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
14074
- const path$1 = ref.slice(1).split("/").filter(Boolean);
14075
- if (path$1.length === 0) return ctx.rootSchema;
14074
+ const path = ref.slice(1).split("/").filter(Boolean);
14075
+ if (path.length === 0) return ctx.rootSchema;
14076
14076
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
14077
- if (path$1[0] === defsKey) {
14078
- const key = path$1[1];
14077
+ if (path[0] === defsKey) {
14078
+ const key = path[1];
14079
14079
  if (!key || !ctx.defs[key]) throw new Error(`Reference not found: ${ref}`);
14080
14080
  return ctx.defs[key];
14081
14081
  }
@@ -15291,31 +15291,8 @@ var environments_default = app$10;
15291
15291
 
15292
15292
  //#endregion
15293
15293
  //#region src/server/handlers/guardrails/index.ts
15294
- const __filename = fileURLToPath$1(import.meta.url);
15295
- const __dirname$1 = path.dirname(__filename);
15296
- let cachedManifest = null;
15297
15294
  function getDefaultManifest() {
15298
- if (cachedManifest) return cachedManifest;
15299
- const possiblePaths = [
15300
- path.resolve(__dirname$1, "../../../../gateway/plugins/default/manifest.json"),
15301
- path.resolve(process.cwd(), "packages/gateway/plugins/default/manifest.json"),
15302
- path.resolve(__dirname$1, "../../../../../gateway/plugins/default/manifest.json")
15303
- ];
15304
- for (const manifestPath$1 of possiblePaths) try {
15305
- if (fs.existsSync(manifestPath$1)) {
15306
- const content = fs.readFileSync(manifestPath$1, "utf-8");
15307
- cachedManifest = JSON.parse(content);
15308
- return cachedManifest;
15309
- }
15310
- } catch {}
15311
- console.warn("Could not find default guardrails manifest");
15312
- return {
15313
- id: "default",
15314
- name: "Default",
15315
- description: "Default guardrails",
15316
- credentials: [],
15317
- functions: []
15318
- };
15295
+ return defaultManifest;
15319
15296
  }
15320
15297
  const app$9 = new Hono().get("/available", async (c) => {
15321
15298
  try {
@@ -16465,10 +16442,10 @@ const createGatewayAdapterMiddleware = () => {
16465
16442
  const envSec = c.get("envSec");
16466
16443
  const db = c.var.db;
16467
16444
  const kyselyDb = c.var.kyselyDb;
16468
- const path$1 = c.req.path;
16445
+ const path = c.req.path;
16469
16446
  const method = c.req.method;
16470
16447
  const contentType = c.req.header("content-type")?.split(";")[0];
16471
- const isChatRequest = method === "POST" && contentType === "application/json" && (path$1.endsWith("/chat/completions") || path$1.endsWith("/completions"));
16448
+ const isChatRequest = method === "POST" && contentType === "application/json" && (path.endsWith("/chat/completions") || path.endsWith("/completions"));
16472
16449
  if (!configId && isChatRequest) {
16473
16450
  try {
16474
16451
  const body = await c.req.json();
@@ -16907,8 +16884,8 @@ function createCostTrackingMiddleware(config$1 = {}) {
16907
16884
  const log = debug ? (msg) => logger.debug(`[CostTracking] ${msg}`) : () => {};
16908
16885
  return async (c, next) => {
16909
16886
  if (!enabled) return next();
16910
- const path$1 = c.req.path;
16911
- if (!path$1.endsWith("/chat/completions") && !path$1.endsWith("/completions")) return next();
16887
+ const path = c.req.path;
16888
+ if (!path.endsWith("/chat/completions") && !path.endsWith("/completions")) return next();
16912
16889
  const requestId = randomUUID();
16913
16890
  const startTime = Date.now();
16914
16891
  c.header("x-llmops-request-id", requestId);
@@ -16942,7 +16919,7 @@ function createCostTrackingMiddleware(config$1 = {}) {
16942
16919
  provider: "",
16943
16920
  model: body.model || "",
16944
16921
  configId: c.get("configId"),
16945
- endpoint: path$1,
16922
+ endpoint: path,
16946
16923
  isStreaming
16947
16924
  };
16948
16925
  c.set("__costTrackingContext", context);
@@ -17332,8 +17309,8 @@ const hasEmbeddedAssets = Object.keys(embeddedAssets).length > 0;
17332
17309
  */
17333
17310
  const createStaticAssetMiddleware = () => {
17334
17311
  if (hasEmbeddedAssets) return async (c) => {
17335
- const path$1 = c.req.path;
17336
- const asset = getAsset(path$1);
17312
+ const path = c.req.path;
17313
+ const asset = getAsset(path);
17337
17314
  if (!asset) return c.notFound();
17338
17315
  const buffer = decodeAsset(asset);
17339
17316
  return new Response(new Uint8Array(buffer), { headers: {
@@ -17343,9 +17320,9 @@ const createStaticAssetMiddleware = () => {
17343
17320
  };
17344
17321
  return serveStatic({
17345
17322
  root: "./",
17346
- getContent: async (path$1) => {
17323
+ getContent: async (path) => {
17347
17324
  try {
17348
- return await readFile(join$1(__dirname, "..", path$1));
17325
+ return await readFile(join$1(__dirname, "..", path));
17349
17326
  } catch {
17350
17327
  return null;
17351
17328
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@llmops/app",
3
- "version": "0.3.2-beta.1",
3
+ "version": "0.3.2-beta.2",
4
4
  "description": "LLMOps application with server and client",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -67,8 +67,8 @@
67
67
  "react-aria-components": "^1.13.0",
68
68
  "react-hook-form": "^7.68.0",
69
69
  "recharts": "^3.6.0",
70
- "@llmops/core": "^0.3.2-beta.1",
71
- "@llmops/gateway": "^0.3.2-beta.1"
70
+ "@llmops/core": "^0.3.2-beta.2",
71
+ "@llmops/gateway": "^0.3.2-beta.2"
72
72
  },
73
73
  "peerDependencies": {
74
74
  "react": "^19.2.1",