@llmops/gateway 1.0.0-beta.1 → 1.0.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/dist/index.cjs CHANGED
@@ -31,8 +31,6 @@ let hono_pretty_json = require("hono/pretty-json");
31
31
  let hono_http_exception = require("hono/http-exception");
32
32
  let hono_compress = require("hono/compress");
33
33
  let hono_adapter = require("hono/adapter");
34
- let path = require("path");
35
- path = __toESM(path);
36
34
  let __cfworker_json_schema = require("@cfworker/json-schema");
37
35
  let __aws_crypto_sha256_js = require("@aws-crypto/sha256-js");
38
36
  let __smithy_signature_v4 = require("@smithy/signature-v4");
@@ -42,6 +40,8 @@ let async_retry = require("async-retry");
42
40
  async_retry = __toESM(async_retry);
43
41
  let fs_promises = require("fs/promises");
44
42
  fs_promises = __toESM(fs_promises);
43
+ let path = require("path");
44
+ path = __toESM(path);
45
45
  let ioredis = require("ioredis");
46
46
  ioredis = __toESM(ioredis);
47
47
 
@@ -650,11 +650,11 @@ function aborted(x, startIndex = 0) {
650
650
  for (let i = startIndex; i < x.issues.length; i++) if (x.issues[i]?.continue !== true) return true;
651
651
  return false;
652
652
  }
653
- function prefixIssues(path$2, issues) {
653
+ function prefixIssues(path$1, issues) {
654
654
  return issues.map((iss) => {
655
655
  var _a$1;
656
656
  (_a$1 = iss).path ?? (_a$1.path = []);
657
- iss.path.unshift(path$2);
657
+ iss.path.unshift(path$1);
658
658
  return iss;
659
659
  });
660
660
  }
@@ -4434,18 +4434,18 @@ const configSchema = object({
4434
4434
  //#endregion
4435
4435
  //#region src/utils/env.ts
4436
4436
  const isNodeInstance = (0, hono_adapter.getRuntimeKey)() == "node";
4437
- let path$1;
4438
- let fs;
4439
- if (isNodeInstance) {
4440
- path$1 = require("path");
4441
- fs = require("fs");
4442
- }
4437
+ let nodeFs = null;
4438
+ let nodePath = null;
4439
+ isNodeInstance ? Promise.all([import("node:path"), import("node:fs")]).then(([p, f]) => {
4440
+ nodePath = p;
4441
+ nodeFs = f;
4442
+ }) : Promise.resolve();
4443
4443
  function getValueOrFileContents(value, ignore) {
4444
4444
  if (!value || ignore) return value;
4445
4445
  try {
4446
- if (value.startsWith("/") || value.startsWith("./") || value.startsWith("../")) {
4447
- const resolvedPath = path$1.resolve(value);
4448
- if (fs.existsSync(resolvedPath)) return fs.readFileSync(resolvedPath, "utf8").trim();
4446
+ if (nodePath && nodeFs && (value.startsWith("/") || value.startsWith("./") || value.startsWith("../"))) {
4447
+ const resolvedPath = nodePath.resolve(value);
4448
+ if (nodeFs.existsSync(resolvedPath)) return nodeFs.readFileSync(resolvedPath, "utf8").trim();
4449
4449
  }
4450
4450
  return value;
4451
4451
  } catch (error) {
@@ -4453,7 +4453,7 @@ function getValueOrFileContents(value, ignore) {
4453
4453
  return value;
4454
4454
  }
4455
4455
  }
4456
- const nodeEnv = {
4456
+ const nodeEnv = isNodeInstance ? {
4457
4457
  NODE_ENV: getValueOrFileContents(process.env.NODE_ENV, true),
4458
4458
  PORT: getValueOrFileContents(process.env.PORT) || 8787,
4459
4459
  TLS_KEY_PATH: getValueOrFileContents(process.env.TLS_KEY_PATH, true),
@@ -4496,7 +4496,7 @@ const nodeEnv = {
4496
4496
  HTTPS_PROXY: getValueOrFileContents(process.env.HTTPS_PROXY),
4497
4497
  APM_LOGGER: getValueOrFileContents(process.env.APM_LOGGER),
4498
4498
  TRUSTED_CUSTOM_HOSTS: getValueOrFileContents(process.env.TRUSTED_CUSTOM_HOSTS)
4499
- };
4499
+ } : {};
4500
4500
  const Environment = (c) => {
4501
4501
  if (isNodeInstance) return nodeEnv;
4502
4502
  if (c) return (0, hono_adapter.env)(c);
@@ -10375,7 +10375,7 @@ const retryRequest = async (url, options, retryCount, statusCodesToRetry, timeou
10375
10375
 
10376
10376
  //#endregion
10377
10377
  //#region package.json
10378
- var version = "1.0.0-beta.1";
10378
+ var version = "1.0.0-beta.11";
10379
10379
 
10380
10380
  //#endregion
10381
10381
  //#region src/providers/bytez/api.ts
@@ -17192,8 +17192,8 @@ const BedrockFinetuneResponseTransform = (response, responseStatus) => {
17192
17192
  * @param path - The dot-separated path to the property.
17193
17193
  * @param value - The value to set the property to.
17194
17194
  */
17195
- function setNestedProperty(obj, path$2, value) {
17196
- const parts = path$2.split(".");
17195
+ function setNestedProperty(obj, path$1, value) {
17196
+ const parts = path$1.split(".");
17197
17197
  let current = obj;
17198
17198
  for (let i = 0; i < parts.length - 1; i++) {
17199
17199
  if (!current[parts[i]]) current[parts[i]] = {};
@@ -18745,7 +18745,7 @@ const CohereGetBatchOutputHandler = async ({ c, providerOptions, requestURL }) =
18745
18745
  headers
18746
18746
  })).arrayBuffer();
18747
18747
  const buf = Buffer.from(arrayBuffer);
18748
- const avro = require("avsc");
18748
+ const avro = await import("avsc");
18749
18749
  const decoder$1 = new avro.streams.BlockDecoder({ parseHook: (schema) => {
18750
18750
  return avro.Type.forSchema(schema, { wrapUnions: true });
18751
18751
  } });
@@ -26712,7 +26712,7 @@ const AzureAIInferenceAPI = {
26712
26712
  const isAnthropicModel = azureFoundryUrl?.includes("anthropic") || urlToFetch?.includes("anthropic");
26713
26713
  let mappedFn = fn;
26714
26714
  const urlObj = new URL(gatewayRequestURL);
26715
- const path$2 = urlObj.pathname.replace("/v1", "");
26715
+ const path$1 = urlObj.pathname.replace("/v1", "");
26716
26716
  const searchParams = urlObj.searchParams;
26717
26717
  if (azureApiVersion) searchParams.set("api-version", azureApiVersion);
26718
26718
  const deploymentName = deploymentId || azureDeploymentName;
@@ -26728,20 +26728,20 @@ const AzureAIInferenceAPI = {
26728
26728
  createSpeech: "/audio/speech",
26729
26729
  createTranscription: "/audio/transcriptions",
26730
26730
  createTranslation: "/audio/translations",
26731
- uploadFile: path$2,
26732
- retrieveFile: path$2,
26733
- listFiles: path$2,
26734
- deleteFile: path$2,
26735
- retrieveFileContent: path$2,
26736
- listBatches: path$2,
26737
- retrieveBatch: path$2,
26738
- cancelBatch: path$2,
26739
- getBatchOutput: path$2,
26740
- createBatch: path$2,
26731
+ uploadFile: path$1,
26732
+ retrieveFile: path$1,
26733
+ listFiles: path$1,
26734
+ deleteFile: path$1,
26735
+ retrieveFileContent: path$1,
26736
+ listBatches: path$1,
26737
+ retrieveBatch: path$1,
26738
+ cancelBatch: path$1,
26739
+ getBatchOutput: path$1,
26740
+ createBatch: path$1,
26741
26741
  createModelResponse: "/responses",
26742
- getModelResponse: path$2,
26743
- deleteModelResponse: path$2,
26744
- listResponseInputItems: path$2
26742
+ getModelResponse: path$1,
26743
+ deleteModelResponse: path$1,
26744
+ listResponseInputItems: path$1
26745
26745
  };
26746
26746
  const isGithub = providerOptions.provider === GITHUB;
26747
26747
  if (fn === "proxy" && urlToFetch) {
@@ -29371,14 +29371,14 @@ var OCIRequestSigner = class {
29371
29371
  */
29372
29372
  async signRequest(method, url, body, additionalHeaders) {
29373
29373
  let host;
29374
- let path$2;
29374
+ let path$1;
29375
29375
  if (url.startsWith("http://") || url.startsWith("https://")) {
29376
29376
  const urlObj = new URL(url);
29377
29377
  host = urlObj.host;
29378
- path$2 = urlObj.pathname + urlObj.search;
29378
+ path$1 = urlObj.pathname + urlObj.search;
29379
29379
  } else {
29380
29380
  host = `iaas.${this.config.region}.oraclecloud.com`;
29381
- path$2 = url;
29381
+ path$1 = url;
29382
29382
  }
29383
29383
  const date$3 = (/* @__PURE__ */ new Date()).toUTCString();
29384
29384
  const headers = {
@@ -29392,7 +29392,7 @@ var OCIRequestSigner = class {
29392
29392
  "host"
29393
29393
  ];
29394
29394
  const signingStringParts = [];
29395
- const escapedTarget = encodeURI(path$2);
29395
+ const escapedTarget = encodeURI(path$1);
29396
29396
  signingStringParts.push(`(request-target): ${method.toLowerCase()} ${escapedTarget}`);
29397
29397
  signingStringParts.push(`date: ${date$3}`);
29398
29398
  signingStringParts.push(`host: ${host}`);
package/dist/index.mjs CHANGED
@@ -1,10 +1,8 @@
1
- import { createRequire } from "node:module";
2
1
  import { Hono } from "hono";
3
2
  import { prettyJSON } from "hono/pretty-json";
4
3
  import { HTTPException } from "hono/http-exception";
5
4
  import { compress } from "hono/compress";
6
5
  import { env, getRuntimeKey } from "hono/adapter";
7
- import * as path from "path";
8
6
  import { Validator } from "@cfworker/json-schema";
9
7
  import { Sha256 } from "@aws-crypto/sha256-js";
10
8
  import { SignatureV4 } from "@smithy/signature-v4";
@@ -12,12 +10,9 @@ import { Agent } from "https";
12
10
  import { importJWK, jwtVerify } from "jose";
13
11
  import retry from "async-retry";
14
12
  import * as fs from "fs/promises";
13
+ import * as path from "path";
15
14
  import Redis from "ioredis";
16
15
 
17
- //#region rolldown:runtime
18
- var __require = /* @__PURE__ */ createRequire(import.meta.url);
19
-
20
- //#endregion
21
16
  //#region src/globals.ts
22
17
  const POWERED_BY = "llmops";
23
18
  const MAX_RETRY_LIMIT_MS = 60 * 1e3;
@@ -623,11 +618,11 @@ function aborted(x, startIndex = 0) {
623
618
  for (let i = startIndex; i < x.issues.length; i++) if (x.issues[i]?.continue !== true) return true;
624
619
  return false;
625
620
  }
626
- function prefixIssues(path$2, issues) {
621
+ function prefixIssues(path$1, issues) {
627
622
  return issues.map((iss) => {
628
623
  var _a$1;
629
624
  (_a$1 = iss).path ?? (_a$1.path = []);
630
- iss.path.unshift(path$2);
625
+ iss.path.unshift(path$1);
631
626
  return iss;
632
627
  });
633
628
  }
@@ -4407,18 +4402,18 @@ const configSchema = object({
4407
4402
  //#endregion
4408
4403
  //#region src/utils/env.ts
4409
4404
  const isNodeInstance = getRuntimeKey() == "node";
4410
- let path$1;
4411
- let fs$1;
4412
- if (isNodeInstance) {
4413
- path$1 = __require("path");
4414
- fs$1 = __require("fs");
4415
- }
4405
+ let nodeFs = null;
4406
+ let nodePath = null;
4407
+ isNodeInstance ? Promise.all([import("node:path"), import("node:fs")]).then(([p, f]) => {
4408
+ nodePath = p;
4409
+ nodeFs = f;
4410
+ }) : Promise.resolve();
4416
4411
  function getValueOrFileContents(value, ignore) {
4417
4412
  if (!value || ignore) return value;
4418
4413
  try {
4419
- if (value.startsWith("/") || value.startsWith("./") || value.startsWith("../")) {
4420
- const resolvedPath = path$1.resolve(value);
4421
- if (fs$1.existsSync(resolvedPath)) return fs$1.readFileSync(resolvedPath, "utf8").trim();
4414
+ if (nodePath && nodeFs && (value.startsWith("/") || value.startsWith("./") || value.startsWith("../"))) {
4415
+ const resolvedPath = nodePath.resolve(value);
4416
+ if (nodeFs.existsSync(resolvedPath)) return nodeFs.readFileSync(resolvedPath, "utf8").trim();
4422
4417
  }
4423
4418
  return value;
4424
4419
  } catch (error) {
@@ -4426,7 +4421,7 @@ function getValueOrFileContents(value, ignore) {
4426
4421
  return value;
4427
4422
  }
4428
4423
  }
4429
- const nodeEnv = {
4424
+ const nodeEnv = isNodeInstance ? {
4430
4425
  NODE_ENV: getValueOrFileContents(process.env.NODE_ENV, true),
4431
4426
  PORT: getValueOrFileContents(process.env.PORT) || 8787,
4432
4427
  TLS_KEY_PATH: getValueOrFileContents(process.env.TLS_KEY_PATH, true),
@@ -4469,7 +4464,7 @@ const nodeEnv = {
4469
4464
  HTTPS_PROXY: getValueOrFileContents(process.env.HTTPS_PROXY),
4470
4465
  APM_LOGGER: getValueOrFileContents(process.env.APM_LOGGER),
4471
4466
  TRUSTED_CUSTOM_HOSTS: getValueOrFileContents(process.env.TRUSTED_CUSTOM_HOSTS)
4472
- };
4467
+ } : {};
4473
4468
  const Environment = (c) => {
4474
4469
  if (isNodeInstance) return nodeEnv;
4475
4470
  if (c) return env(c);
@@ -10348,7 +10343,7 @@ const retryRequest = async (url, options, retryCount, statusCodesToRetry, timeou
10348
10343
 
10349
10344
  //#endregion
10350
10345
  //#region package.json
10351
- var version = "1.0.0-beta.1";
10346
+ var version = "1.0.0-beta.11";
10352
10347
 
10353
10348
  //#endregion
10354
10349
  //#region src/providers/bytez/api.ts
@@ -17165,8 +17160,8 @@ const BedrockFinetuneResponseTransform = (response, responseStatus) => {
17165
17160
  * @param path - The dot-separated path to the property.
17166
17161
  * @param value - The value to set the property to.
17167
17162
  */
17168
- function setNestedProperty(obj, path$2, value) {
17169
- const parts = path$2.split(".");
17163
+ function setNestedProperty(obj, path$1, value) {
17164
+ const parts = path$1.split(".");
17170
17165
  let current = obj;
17171
17166
  for (let i = 0; i < parts.length - 1; i++) {
17172
17167
  if (!current[parts[i]]) current[parts[i]] = {};
@@ -18718,7 +18713,7 @@ const CohereGetBatchOutputHandler = async ({ c, providerOptions, requestURL }) =
18718
18713
  headers
18719
18714
  })).arrayBuffer();
18720
18715
  const buf = Buffer.from(arrayBuffer);
18721
- const avro = __require("avsc");
18716
+ const avro = await import("avsc");
18722
18717
  const decoder$1 = new avro.streams.BlockDecoder({ parseHook: (schema) => {
18723
18718
  return avro.Type.forSchema(schema, { wrapUnions: true });
18724
18719
  } });
@@ -26685,7 +26680,7 @@ const AzureAIInferenceAPI = {
26685
26680
  const isAnthropicModel = azureFoundryUrl?.includes("anthropic") || urlToFetch?.includes("anthropic");
26686
26681
  let mappedFn = fn;
26687
26682
  const urlObj = new URL(gatewayRequestURL);
26688
- const path$2 = urlObj.pathname.replace("/v1", "");
26683
+ const path$1 = urlObj.pathname.replace("/v1", "");
26689
26684
  const searchParams = urlObj.searchParams;
26690
26685
  if (azureApiVersion) searchParams.set("api-version", azureApiVersion);
26691
26686
  const deploymentName = deploymentId || azureDeploymentName;
@@ -26701,20 +26696,20 @@ const AzureAIInferenceAPI = {
26701
26696
  createSpeech: "/audio/speech",
26702
26697
  createTranscription: "/audio/transcriptions",
26703
26698
  createTranslation: "/audio/translations",
26704
- uploadFile: path$2,
26705
- retrieveFile: path$2,
26706
- listFiles: path$2,
26707
- deleteFile: path$2,
26708
- retrieveFileContent: path$2,
26709
- listBatches: path$2,
26710
- retrieveBatch: path$2,
26711
- cancelBatch: path$2,
26712
- getBatchOutput: path$2,
26713
- createBatch: path$2,
26699
+ uploadFile: path$1,
26700
+ retrieveFile: path$1,
26701
+ listFiles: path$1,
26702
+ deleteFile: path$1,
26703
+ retrieveFileContent: path$1,
26704
+ listBatches: path$1,
26705
+ retrieveBatch: path$1,
26706
+ cancelBatch: path$1,
26707
+ getBatchOutput: path$1,
26708
+ createBatch: path$1,
26714
26709
  createModelResponse: "/responses",
26715
- getModelResponse: path$2,
26716
- deleteModelResponse: path$2,
26717
- listResponseInputItems: path$2
26710
+ getModelResponse: path$1,
26711
+ deleteModelResponse: path$1,
26712
+ listResponseInputItems: path$1
26718
26713
  };
26719
26714
  const isGithub = providerOptions.provider === GITHUB;
26720
26715
  if (fn === "proxy" && urlToFetch) {
@@ -29344,14 +29339,14 @@ var OCIRequestSigner = class {
29344
29339
  */
29345
29340
  async signRequest(method, url, body, additionalHeaders) {
29346
29341
  let host;
29347
- let path$2;
29342
+ let path$1;
29348
29343
  if (url.startsWith("http://") || url.startsWith("https://")) {
29349
29344
  const urlObj = new URL(url);
29350
29345
  host = urlObj.host;
29351
- path$2 = urlObj.pathname + urlObj.search;
29346
+ path$1 = urlObj.pathname + urlObj.search;
29352
29347
  } else {
29353
29348
  host = `iaas.${this.config.region}.oraclecloud.com`;
29354
- path$2 = url;
29349
+ path$1 = url;
29355
29350
  }
29356
29351
  const date$3 = (/* @__PURE__ */ new Date()).toUTCString();
29357
29352
  const headers = {
@@ -29365,7 +29360,7 @@ var OCIRequestSigner = class {
29365
29360
  "host"
29366
29361
  ];
29367
29362
  const signingStringParts = [];
29368
- const escapedTarget = encodeURI(path$2);
29363
+ const escapedTarget = encodeURI(path$1);
29369
29364
  signingStringParts.push(`(request-target): ${method.toLowerCase()} ${escapedTarget}`);
29370
29365
  signingStringParts.push(`date: ${date$3}`);
29371
29366
  signingStringParts.push(`host: ${host}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@llmops/gateway",
3
- "version": "1.0.0-beta.1",
3
+ "version": "1.0.0-beta.11",
4
4
  "description": "AI gateway for LLMOps (forked from Portkey)",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",