@elsium-ai/app 0.9.1 → 0.10.0

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.
Files changed (2) hide show
  1. package/dist/index.js +122 -38
  2. package/package.json +10 -10
package/dist/index.js CHANGED
@@ -2951,9 +2951,9 @@ var log9 = createLogger();
2951
2951
  var log10 = createLogger();
2952
2952
  // ../observe/src/otel.ts
2953
2953
  var log11 = createLogger();
2954
- // ../../node_modules/.bun/@hono+node-server@1.19.10/node_modules/@hono/node-server/dist/index.mjs
2954
+ // ../../node_modules/.bun/@hono+node-server@1.19.14/node_modules/@hono/node-server/dist/index.mjs
2955
2955
  import { createServer as createServerHTTP } from "http";
2956
- import { Http2ServerRequest as Http2ServerRequest2 } from "http2";
2956
+ import { Http2ServerRequest as Http2ServerRequest2, constants as h2constants } from "http2";
2957
2957
  import { Http2ServerRequest } from "http2";
2958
2958
  import { Readable } from "stream";
2959
2959
  import crypto from "crypto";
@@ -3093,6 +3093,17 @@ var requestPrototype = {
3093
3093
  }
3094
3094
  });
3095
3095
  });
3096
+ Object.defineProperty(requestPrototype, Symbol.for("nodejs.util.inspect.custom"), {
3097
+ value: function(depth, options, inspectFn) {
3098
+ const props = {
3099
+ method: this.method,
3100
+ url: this.url,
3101
+ headers: this.headers,
3102
+ nativeRequest: this[requestCache]
3103
+ };
3104
+ return `Request (lightweight) ${inspectFn(props, { ...options, depth: depth == null ? null : depth - 1 })}`;
3105
+ }
3106
+ });
3096
3107
  Object.setPrototypeOf(requestPrototype, Request2.prototype);
3097
3108
  var newRequest = (incoming, defaultHostname) => {
3098
3109
  const req = Object.create(requestPrototype);
@@ -3158,15 +3169,14 @@ var Response2 = class _Response {
3158
3169
  this.#init = init;
3159
3170
  }
3160
3171
  if (typeof body === "string" || typeof body?.getReader !== "undefined" || body instanceof Blob || body instanceof Uint8Array) {
3161
- headers ||= init?.headers || { "content-type": "text/plain; charset=UTF-8" };
3162
- this[cacheKey] = [init?.status || 200, body, headers];
3172
+ this[cacheKey] = [init?.status || 200, body, headers || init?.headers];
3163
3173
  }
3164
3174
  }
3165
3175
  get headers() {
3166
3176
  const cache = this[cacheKey];
3167
3177
  if (cache) {
3168
3178
  if (!(cache[2] instanceof Headers)) {
3169
- cache[2] = new Headers(cache[2]);
3179
+ cache[2] = new Headers(cache[2] || { "content-type": "text/plain; charset=UTF-8" });
3170
3180
  }
3171
3181
  return cache[2];
3172
3182
  }
@@ -3194,6 +3204,17 @@ var Response2 = class _Response {
3194
3204
  }
3195
3205
  });
3196
3206
  });
3207
+ Object.defineProperty(Response2.prototype, Symbol.for("nodejs.util.inspect.custom"), {
3208
+ value: function(depth, options, inspectFn) {
3209
+ const props = {
3210
+ status: this.status,
3211
+ headers: this.headers,
3212
+ ok: this.ok,
3213
+ nativeResponse: this[responseCache]
3214
+ };
3215
+ return `Response (lightweight) ${inspectFn(props, { ...options, depth: depth == null ? null : depth - 1 })}`;
3216
+ }
3217
+ });
3197
3218
  Object.setPrototypeOf(Response2, GlobalResponse);
3198
3219
  Object.setPrototypeOf(Response2.prototype, GlobalResponse.prototype);
3199
3220
  async function readWithoutBlocking(readPromise) {
@@ -3264,6 +3285,48 @@ if (typeof global.crypto === "undefined") {
3264
3285
  global.crypto = crypto;
3265
3286
  }
3266
3287
  var outgoingEnded = Symbol("outgoingEnded");
3288
+ var incomingDraining = Symbol("incomingDraining");
3289
+ var DRAIN_TIMEOUT_MS = 500;
3290
+ var MAX_DRAIN_BYTES = 64 * 1024 * 1024;
3291
+ var drainIncoming = (incoming) => {
3292
+ const incomingWithDrainState = incoming;
3293
+ if (incoming.destroyed || incomingWithDrainState[incomingDraining]) {
3294
+ return;
3295
+ }
3296
+ incomingWithDrainState[incomingDraining] = true;
3297
+ if (incoming instanceof Http2ServerRequest2) {
3298
+ try {
3299
+ incoming.stream?.close?.(h2constants.NGHTTP2_NO_ERROR);
3300
+ } catch {}
3301
+ return;
3302
+ }
3303
+ let bytesRead = 0;
3304
+ const cleanup = () => {
3305
+ clearTimeout(timer);
3306
+ incoming.off("data", onData);
3307
+ incoming.off("end", cleanup);
3308
+ incoming.off("error", cleanup);
3309
+ };
3310
+ const forceClose = () => {
3311
+ cleanup();
3312
+ const socket = incoming.socket;
3313
+ if (socket && !socket.destroyed) {
3314
+ socket.destroySoon();
3315
+ }
3316
+ };
3317
+ const timer = setTimeout(forceClose, DRAIN_TIMEOUT_MS);
3318
+ timer.unref?.();
3319
+ const onData = (chunk) => {
3320
+ bytesRead += chunk.length;
3321
+ if (bytesRead > MAX_DRAIN_BYTES) {
3322
+ forceClose();
3323
+ }
3324
+ };
3325
+ incoming.on("data", onData);
3326
+ incoming.on("end", cleanup);
3327
+ incoming.on("error", cleanup);
3328
+ incoming.resume();
3329
+ };
3267
3330
  var handleRequestError = () => new Response(null, {
3268
3331
  status: 400
3269
3332
  });
@@ -3290,15 +3353,32 @@ var flushHeaders = (outgoing) => {
3290
3353
  };
3291
3354
  var responseViaCache = async (res, outgoing) => {
3292
3355
  let [status, body, header] = res[cacheKey];
3293
- if (header instanceof Headers) {
3356
+ let hasContentLength = false;
3357
+ if (!header) {
3358
+ header = { "content-type": "text/plain; charset=UTF-8" };
3359
+ } else if (header instanceof Headers) {
3360
+ hasContentLength = header.has("content-length");
3294
3361
  header = buildOutgoingHttpHeaders(header);
3362
+ } else if (Array.isArray(header)) {
3363
+ const headerObj = new Headers(header);
3364
+ hasContentLength = headerObj.has("content-length");
3365
+ header = buildOutgoingHttpHeaders(headerObj);
3366
+ } else {
3367
+ for (const key in header) {
3368
+ if (key.length === 14 && key.toLowerCase() === "content-length") {
3369
+ hasContentLength = true;
3370
+ break;
3371
+ }
3372
+ }
3295
3373
  }
3296
- if (typeof body === "string") {
3297
- header["Content-Length"] = Buffer.byteLength(body);
3298
- } else if (body instanceof Uint8Array) {
3299
- header["Content-Length"] = body.byteLength;
3300
- } else if (body instanceof Blob) {
3301
- header["Content-Length"] = body.size;
3374
+ if (!hasContentLength) {
3375
+ if (typeof body === "string") {
3376
+ header["Content-Length"] = Buffer.byteLength(body);
3377
+ } else if (body instanceof Uint8Array) {
3378
+ header["Content-Length"] = body.byteLength;
3379
+ } else if (body instanceof Blob) {
3380
+ header["Content-Length"] = body.size;
3381
+ }
3302
3382
  }
3303
3383
  outgoing.writeHead(status, header);
3304
3384
  if (typeof body === "string" || body instanceof Uint8Array) {
@@ -3410,14 +3490,18 @@ var getRequestListener = (fetchCallback, options = {}) => {
3410
3490
  setTimeout(() => {
3411
3491
  if (!incomingEnded) {
3412
3492
  setTimeout(() => {
3413
- incoming.destroy();
3414
- outgoing.destroy();
3493
+ drainIncoming(incoming);
3415
3494
  });
3416
3495
  }
3417
3496
  });
3418
3497
  }
3419
3498
  };
3420
3499
  }
3500
+ outgoing.on("finish", () => {
3501
+ if (!incomingEnded) {
3502
+ drainIncoming(incoming);
3503
+ }
3504
+ });
3421
3505
  }
3422
3506
  outgoing.on("close", () => {
3423
3507
  const abortController = req[abortControllerKey];
@@ -3432,7 +3516,7 @@ var getRequestListener = (fetchCallback, options = {}) => {
3432
3516
  setTimeout(() => {
3433
3517
  if (!incomingEnded) {
3434
3518
  setTimeout(() => {
3435
- incoming.destroy();
3519
+ drainIncoming(incoming);
3436
3520
  });
3437
3521
  }
3438
3522
  });
@@ -3485,7 +3569,7 @@ var serve = (options, listeningListener) => {
3485
3569
  return server;
3486
3570
  };
3487
3571
 
3488
- // ../../node_modules/.bun/hono@4.12.8/node_modules/hono/dist/compose.js
3572
+ // ../../node_modules/.bun/hono@4.12.12/node_modules/hono/dist/compose.js
3489
3573
  var compose = (middleware, onError, onNotFound) => {
3490
3574
  return (context, next) => {
3491
3575
  let index = -1;
@@ -3529,10 +3613,10 @@ var compose = (middleware, onError, onNotFound) => {
3529
3613
  };
3530
3614
  };
3531
3615
 
3532
- // ../../node_modules/.bun/hono@4.12.8/node_modules/hono/dist/request/constants.js
3616
+ // ../../node_modules/.bun/hono@4.12.12/node_modules/hono/dist/request/constants.js
3533
3617
  var GET_MATCH_RESULT = /* @__PURE__ */ Symbol();
3534
3618
 
3535
- // ../../node_modules/.bun/hono@4.12.8/node_modules/hono/dist/utils/body.js
3619
+ // ../../node_modules/.bun/hono@4.12.12/node_modules/hono/dist/utils/body.js
3536
3620
  var parseBody = async (request, options = /* @__PURE__ */ Object.create(null)) => {
3537
3621
  const { all = false, dot = false } = options;
3538
3622
  const headers = request instanceof HonoRequest ? request.raw.headers : request.headers;
@@ -3603,7 +3687,7 @@ var handleParsingNestedValues = (form, key, value) => {
3603
3687
  });
3604
3688
  };
3605
3689
 
3606
- // ../../node_modules/.bun/hono@4.12.8/node_modules/hono/dist/utils/url.js
3690
+ // ../../node_modules/.bun/hono@4.12.12/node_modules/hono/dist/utils/url.js
3607
3691
  var splitPath = (path) => {
3608
3692
  const paths = path.split("/");
3609
3693
  if (paths[0] === "") {
@@ -3803,7 +3887,7 @@ var getQueryParams = (url, key) => {
3803
3887
  };
3804
3888
  var decodeURIComponent_ = decodeURIComponent;
3805
3889
 
3806
- // ../../node_modules/.bun/hono@4.12.8/node_modules/hono/dist/request.js
3890
+ // ../../node_modules/.bun/hono@4.12.12/node_modules/hono/dist/request.js
3807
3891
  var tryDecodeURIComponent = (str) => tryDecode(str, decodeURIComponent_);
3808
3892
  var HonoRequest = class {
3809
3893
  raw;
@@ -3857,7 +3941,7 @@ var HonoRequest = class {
3857
3941
  return headerData;
3858
3942
  }
3859
3943
  async parseBody(options) {
3860
- return this.bodyCache.parsedBody ??= await parseBody(this, options);
3944
+ return parseBody(this, options);
3861
3945
  }
3862
3946
  #cachedBody = (key) => {
3863
3947
  const { bodyCache, raw } = this;
@@ -3914,7 +3998,7 @@ var HonoRequest = class {
3914
3998
  }
3915
3999
  };
3916
4000
 
3917
- // ../../node_modules/.bun/hono@4.12.8/node_modules/hono/dist/utils/html.js
4001
+ // ../../node_modules/.bun/hono@4.12.12/node_modules/hono/dist/utils/html.js
3918
4002
  var HtmlEscapedCallbackPhase = {
3919
4003
  Stringify: 1,
3920
4004
  BeforeStream: 2,
@@ -3952,7 +4036,7 @@ var resolveCallback = async (str, phase, preserveCallbacks, context, buffer) =>
3952
4036
  }
3953
4037
  };
3954
4038
 
3955
- // ../../node_modules/.bun/hono@4.12.8/node_modules/hono/dist/context.js
4039
+ // ../../node_modules/.bun/hono@4.12.12/node_modules/hono/dist/context.js
3956
4040
  var TEXT_PLAIN = "text/plain; charset=UTF-8";
3957
4041
  var setDefaultContentType = (contentType, headers) => {
3958
4042
  return {
@@ -4119,7 +4203,7 @@ var Context = class {
4119
4203
  };
4120
4204
  };
4121
4205
 
4122
- // ../../node_modules/.bun/hono@4.12.8/node_modules/hono/dist/router.js
4206
+ // ../../node_modules/.bun/hono@4.12.12/node_modules/hono/dist/router.js
4123
4207
  var METHOD_NAME_ALL = "ALL";
4124
4208
  var METHOD_NAME_ALL_LOWERCASE = "all";
4125
4209
  var METHODS = ["get", "post", "put", "delete", "options", "patch"];
@@ -4127,10 +4211,10 @@ var MESSAGE_MATCHER_IS_ALREADY_BUILT = "Can not add a route since the matcher is
4127
4211
  var UnsupportedPathError = class extends Error {
4128
4212
  };
4129
4213
 
4130
- // ../../node_modules/.bun/hono@4.12.8/node_modules/hono/dist/utils/constants.js
4214
+ // ../../node_modules/.bun/hono@4.12.12/node_modules/hono/dist/utils/constants.js
4131
4215
  var COMPOSED_HANDLER = "__COMPOSED_HANDLER";
4132
4216
 
4133
- // ../../node_modules/.bun/hono@4.12.8/node_modules/hono/dist/hono-base.js
4217
+ // ../../node_modules/.bun/hono@4.12.12/node_modules/hono/dist/hono-base.js
4134
4218
  var notFoundHandler = (c) => {
4135
4219
  return c.text("404 Not Found", 404);
4136
4220
  };
@@ -4349,7 +4433,7 @@ var Hono = class _Hono {
4349
4433
  };
4350
4434
  };
4351
4435
 
4352
- // ../../node_modules/.bun/hono@4.12.8/node_modules/hono/dist/router/reg-exp-router/matcher.js
4436
+ // ../../node_modules/.bun/hono@4.12.12/node_modules/hono/dist/router/reg-exp-router/matcher.js
4353
4437
  var emptyParam = [];
4354
4438
  function match(method, path) {
4355
4439
  const matchers = this.buildAllMatchers();
@@ -4370,7 +4454,7 @@ function match(method, path) {
4370
4454
  return match2(method, path);
4371
4455
  }
4372
4456
 
4373
- // ../../node_modules/.bun/hono@4.12.8/node_modules/hono/dist/router/reg-exp-router/node.js
4457
+ // ../../node_modules/.bun/hono@4.12.12/node_modules/hono/dist/router/reg-exp-router/node.js
4374
4458
  var LABEL_REG_EXP_STR = "[^/]+";
4375
4459
  var ONLY_WILDCARD_REG_EXP_STR = ".*";
4376
4460
  var TAIL_WILDCARD_REG_EXP_STR = "(?:|/.*)";
@@ -4474,7 +4558,7 @@ var Node = class _Node {
4474
4558
  }
4475
4559
  };
4476
4560
 
4477
- // ../../node_modules/.bun/hono@4.12.8/node_modules/hono/dist/router/reg-exp-router/trie.js
4561
+ // ../../node_modules/.bun/hono@4.12.12/node_modules/hono/dist/router/reg-exp-router/trie.js
4478
4562
  var Trie = class {
4479
4563
  #context = { varIndex: 0 };
4480
4564
  #root = new Node;
@@ -4530,7 +4614,7 @@ var Trie = class {
4530
4614
  }
4531
4615
  };
4532
4616
 
4533
- // ../../node_modules/.bun/hono@4.12.8/node_modules/hono/dist/router/reg-exp-router/router.js
4617
+ // ../../node_modules/.bun/hono@4.12.12/node_modules/hono/dist/router/reg-exp-router/router.js
4534
4618
  var nullMatcher = [/^$/, [], /* @__PURE__ */ Object.create(null)];
4535
4619
  var wildcardRegExpCache = /* @__PURE__ */ Object.create(null);
4536
4620
  function buildWildcardRegExp(path) {
@@ -4695,7 +4779,7 @@ var RegExpRouter = class {
4695
4779
  }
4696
4780
  };
4697
4781
 
4698
- // ../../node_modules/.bun/hono@4.12.8/node_modules/hono/dist/router/reg-exp-router/prepared-router.js
4782
+ // ../../node_modules/.bun/hono@4.12.12/node_modules/hono/dist/router/reg-exp-router/prepared-router.js
4699
4783
  var PreparedRegExpRouter = class {
4700
4784
  name = "PreparedRegExpRouter";
4701
4785
  #matchers;
@@ -4767,7 +4851,7 @@ var PreparedRegExpRouter = class {
4767
4851
  match = match;
4768
4852
  };
4769
4853
 
4770
- // ../../node_modules/.bun/hono@4.12.8/node_modules/hono/dist/router/smart-router/router.js
4854
+ // ../../node_modules/.bun/hono@4.12.12/node_modules/hono/dist/router/smart-router/router.js
4771
4855
  var SmartRouter = class {
4772
4856
  name = "SmartRouter";
4773
4857
  #routers = [];
@@ -4822,7 +4906,7 @@ var SmartRouter = class {
4822
4906
  }
4823
4907
  };
4824
4908
 
4825
- // ../../node_modules/.bun/hono@4.12.8/node_modules/hono/dist/router/trie-router/node.js
4909
+ // ../../node_modules/.bun/hono@4.12.12/node_modules/hono/dist/router/trie-router/node.js
4826
4910
  var emptyParams = /* @__PURE__ */ Object.create(null);
4827
4911
  var hasChildren = (children) => {
4828
4912
  for (const _ in children) {
@@ -4991,7 +5075,7 @@ var Node2 = class _Node2 {
4991
5075
  }
4992
5076
  };
4993
5077
 
4994
- // ../../node_modules/.bun/hono@4.12.8/node_modules/hono/dist/router/trie-router/router.js
5078
+ // ../../node_modules/.bun/hono@4.12.12/node_modules/hono/dist/router/trie-router/router.js
4995
5079
  var TrieRouter = class {
4996
5080
  name = "TrieRouter";
4997
5081
  #node;
@@ -5013,7 +5097,7 @@ var TrieRouter = class {
5013
5097
  }
5014
5098
  };
5015
5099
 
5016
- // ../../node_modules/.bun/hono@4.12.8/node_modules/hono/dist/hono.js
5100
+ // ../../node_modules/.bun/hono@4.12.12/node_modules/hono/dist/hono.js
5017
5101
  var Hono2 = class extends Hono {
5018
5102
  constructor(options = {}) {
5019
5103
  super(options);
@@ -5128,7 +5212,7 @@ function requestLoggerMiddleware(logger) {
5128
5212
  };
5129
5213
  }
5130
5214
 
5131
- // ../../node_modules/.bun/hono@4.12.8/node_modules/hono/dist/utils/stream.js
5215
+ // ../../node_modules/.bun/hono@4.12.12/node_modules/hono/dist/utils/stream.js
5132
5216
  var StreamingApi = class {
5133
5217
  writer;
5134
5218
  encoder;
@@ -5194,7 +5278,7 @@ var StreamingApi = class {
5194
5278
  }
5195
5279
  };
5196
5280
 
5197
- // ../../node_modules/.bun/hono@4.12.8/node_modules/hono/dist/helper/streaming/utils.js
5281
+ // ../../node_modules/.bun/hono@4.12.12/node_modules/hono/dist/helper/streaming/utils.js
5198
5282
  var isOldBunVersion = () => {
5199
5283
  const version = typeof Bun !== "undefined" ? Bun.version : undefined;
5200
5284
  if (version === undefined) {
@@ -5205,7 +5289,7 @@ var isOldBunVersion = () => {
5205
5289
  return result;
5206
5290
  };
5207
5291
 
5208
- // ../../node_modules/.bun/hono@4.12.8/node_modules/hono/dist/helper/streaming/stream.js
5292
+ // ../../node_modules/.bun/hono@4.12.12/node_modules/hono/dist/helper/streaming/stream.js
5209
5293
  var contextStash = /* @__PURE__ */ new WeakMap;
5210
5294
  var stream = (c, cb, onError) => {
5211
5295
  const { readable, writable } = new TransformStream;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elsium-ai/app",
3
- "version": "0.9.1",
3
+ "version": "0.10.0",
4
4
  "description": "App bootstrap, HTTP server, and API routes for ElsiumAI",
5
5
  "license": "MIT",
6
6
  "author": "Eric Utrera <ebutrera9103@gmail.com>",
@@ -26,15 +26,15 @@
26
26
  "dev": "bun --watch src/index.ts"
27
27
  },
28
28
  "dependencies": {
29
- "@elsium-ai/core": "^0.9.1",
30
- "@elsium-ai/gateway": "^0.9.1",
31
- "@elsium-ai/agents": "^0.9.1",
32
- "@elsium-ai/tools": "^0.9.1",
33
- "@elsium-ai/observe": "^0.9.1",
34
- "@elsium-ai/rag": "^0.9.1",
35
- "@elsium-ai/workflows": "^0.9.1",
36
- "@hono/node-server": "^1.19.10",
37
- "hono": "^4.12.4",
29
+ "@elsium-ai/core": "^0.10.0",
30
+ "@elsium-ai/gateway": "^0.10.0",
31
+ "@elsium-ai/agents": "^0.10.0",
32
+ "@elsium-ai/tools": "^0.10.0",
33
+ "@elsium-ai/observe": "^0.10.0",
34
+ "@elsium-ai/rag": "^0.10.0",
35
+ "@elsium-ai/workflows": "^0.10.0",
36
+ "@hono/node-server": "^1.19.14",
37
+ "hono": "^4.12.12",
38
38
  "zod": "^3.24.0"
39
39
  },
40
40
  "devDependencies": {