@elsium-ai/app 0.9.1 → 0.11.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.
- package/dist/index.js +140 -54
- package/package.json +10 -10
package/dist/index.js
CHANGED
|
@@ -2945,15 +2945,17 @@ var log8 = createLogger();
|
|
|
2945
2945
|
|
|
2946
2946
|
// ../observe/src/audit.ts
|
|
2947
2947
|
var ZERO_HASH = "0".repeat(64);
|
|
2948
|
-
// ../observe/src/
|
|
2948
|
+
// ../observe/src/audit-sink-jsonl.ts
|
|
2949
2949
|
var log9 = createLogger();
|
|
2950
|
-
// ../observe/src/
|
|
2950
|
+
// ../observe/src/experiment.ts
|
|
2951
2951
|
var log10 = createLogger();
|
|
2952
|
-
// ../observe/src/
|
|
2952
|
+
// ../observe/src/studio-exporter.ts
|
|
2953
2953
|
var log11 = createLogger();
|
|
2954
|
-
//
|
|
2954
|
+
// ../observe/src/otel.ts
|
|
2955
|
+
var log12 = createLogger();
|
|
2956
|
+
// ../../node_modules/.bun/@hono+node-server@1.19.14/node_modules/@hono/node-server/dist/index.mjs
|
|
2955
2957
|
import { createServer as createServerHTTP } from "http";
|
|
2956
|
-
import { Http2ServerRequest as Http2ServerRequest2 } from "http2";
|
|
2958
|
+
import { Http2ServerRequest as Http2ServerRequest2, constants as h2constants } from "http2";
|
|
2957
2959
|
import { Http2ServerRequest } from "http2";
|
|
2958
2960
|
import { Readable } from "stream";
|
|
2959
2961
|
import crypto from "crypto";
|
|
@@ -3093,6 +3095,17 @@ var requestPrototype = {
|
|
|
3093
3095
|
}
|
|
3094
3096
|
});
|
|
3095
3097
|
});
|
|
3098
|
+
Object.defineProperty(requestPrototype, Symbol.for("nodejs.util.inspect.custom"), {
|
|
3099
|
+
value: function(depth, options, inspectFn) {
|
|
3100
|
+
const props = {
|
|
3101
|
+
method: this.method,
|
|
3102
|
+
url: this.url,
|
|
3103
|
+
headers: this.headers,
|
|
3104
|
+
nativeRequest: this[requestCache]
|
|
3105
|
+
};
|
|
3106
|
+
return `Request (lightweight) ${inspectFn(props, { ...options, depth: depth == null ? null : depth - 1 })}`;
|
|
3107
|
+
}
|
|
3108
|
+
});
|
|
3096
3109
|
Object.setPrototypeOf(requestPrototype, Request2.prototype);
|
|
3097
3110
|
var newRequest = (incoming, defaultHostname) => {
|
|
3098
3111
|
const req = Object.create(requestPrototype);
|
|
@@ -3158,15 +3171,14 @@ var Response2 = class _Response {
|
|
|
3158
3171
|
this.#init = init;
|
|
3159
3172
|
}
|
|
3160
3173
|
if (typeof body === "string" || typeof body?.getReader !== "undefined" || body instanceof Blob || body instanceof Uint8Array) {
|
|
3161
|
-
|
|
3162
|
-
this[cacheKey] = [init?.status || 200, body, headers];
|
|
3174
|
+
this[cacheKey] = [init?.status || 200, body, headers || init?.headers];
|
|
3163
3175
|
}
|
|
3164
3176
|
}
|
|
3165
3177
|
get headers() {
|
|
3166
3178
|
const cache = this[cacheKey];
|
|
3167
3179
|
if (cache) {
|
|
3168
3180
|
if (!(cache[2] instanceof Headers)) {
|
|
3169
|
-
cache[2] = new Headers(cache[2]);
|
|
3181
|
+
cache[2] = new Headers(cache[2] || { "content-type": "text/plain; charset=UTF-8" });
|
|
3170
3182
|
}
|
|
3171
3183
|
return cache[2];
|
|
3172
3184
|
}
|
|
@@ -3194,6 +3206,17 @@ var Response2 = class _Response {
|
|
|
3194
3206
|
}
|
|
3195
3207
|
});
|
|
3196
3208
|
});
|
|
3209
|
+
Object.defineProperty(Response2.prototype, Symbol.for("nodejs.util.inspect.custom"), {
|
|
3210
|
+
value: function(depth, options, inspectFn) {
|
|
3211
|
+
const props = {
|
|
3212
|
+
status: this.status,
|
|
3213
|
+
headers: this.headers,
|
|
3214
|
+
ok: this.ok,
|
|
3215
|
+
nativeResponse: this[responseCache]
|
|
3216
|
+
};
|
|
3217
|
+
return `Response (lightweight) ${inspectFn(props, { ...options, depth: depth == null ? null : depth - 1 })}`;
|
|
3218
|
+
}
|
|
3219
|
+
});
|
|
3197
3220
|
Object.setPrototypeOf(Response2, GlobalResponse);
|
|
3198
3221
|
Object.setPrototypeOf(Response2.prototype, GlobalResponse.prototype);
|
|
3199
3222
|
async function readWithoutBlocking(readPromise) {
|
|
@@ -3264,6 +3287,48 @@ if (typeof global.crypto === "undefined") {
|
|
|
3264
3287
|
global.crypto = crypto;
|
|
3265
3288
|
}
|
|
3266
3289
|
var outgoingEnded = Symbol("outgoingEnded");
|
|
3290
|
+
var incomingDraining = Symbol("incomingDraining");
|
|
3291
|
+
var DRAIN_TIMEOUT_MS = 500;
|
|
3292
|
+
var MAX_DRAIN_BYTES = 64 * 1024 * 1024;
|
|
3293
|
+
var drainIncoming = (incoming) => {
|
|
3294
|
+
const incomingWithDrainState = incoming;
|
|
3295
|
+
if (incoming.destroyed || incomingWithDrainState[incomingDraining]) {
|
|
3296
|
+
return;
|
|
3297
|
+
}
|
|
3298
|
+
incomingWithDrainState[incomingDraining] = true;
|
|
3299
|
+
if (incoming instanceof Http2ServerRequest2) {
|
|
3300
|
+
try {
|
|
3301
|
+
incoming.stream?.close?.(h2constants.NGHTTP2_NO_ERROR);
|
|
3302
|
+
} catch {}
|
|
3303
|
+
return;
|
|
3304
|
+
}
|
|
3305
|
+
let bytesRead = 0;
|
|
3306
|
+
const cleanup = () => {
|
|
3307
|
+
clearTimeout(timer);
|
|
3308
|
+
incoming.off("data", onData);
|
|
3309
|
+
incoming.off("end", cleanup);
|
|
3310
|
+
incoming.off("error", cleanup);
|
|
3311
|
+
};
|
|
3312
|
+
const forceClose = () => {
|
|
3313
|
+
cleanup();
|
|
3314
|
+
const socket = incoming.socket;
|
|
3315
|
+
if (socket && !socket.destroyed) {
|
|
3316
|
+
socket.destroySoon();
|
|
3317
|
+
}
|
|
3318
|
+
};
|
|
3319
|
+
const timer = setTimeout(forceClose, DRAIN_TIMEOUT_MS);
|
|
3320
|
+
timer.unref?.();
|
|
3321
|
+
const onData = (chunk) => {
|
|
3322
|
+
bytesRead += chunk.length;
|
|
3323
|
+
if (bytesRead > MAX_DRAIN_BYTES) {
|
|
3324
|
+
forceClose();
|
|
3325
|
+
}
|
|
3326
|
+
};
|
|
3327
|
+
incoming.on("data", onData);
|
|
3328
|
+
incoming.on("end", cleanup);
|
|
3329
|
+
incoming.on("error", cleanup);
|
|
3330
|
+
incoming.resume();
|
|
3331
|
+
};
|
|
3267
3332
|
var handleRequestError = () => new Response(null, {
|
|
3268
3333
|
status: 400
|
|
3269
3334
|
});
|
|
@@ -3290,15 +3355,32 @@ var flushHeaders = (outgoing) => {
|
|
|
3290
3355
|
};
|
|
3291
3356
|
var responseViaCache = async (res, outgoing) => {
|
|
3292
3357
|
let [status, body, header] = res[cacheKey];
|
|
3293
|
-
|
|
3358
|
+
let hasContentLength = false;
|
|
3359
|
+
if (!header) {
|
|
3360
|
+
header = { "content-type": "text/plain; charset=UTF-8" };
|
|
3361
|
+
} else if (header instanceof Headers) {
|
|
3362
|
+
hasContentLength = header.has("content-length");
|
|
3294
3363
|
header = buildOutgoingHttpHeaders(header);
|
|
3364
|
+
} else if (Array.isArray(header)) {
|
|
3365
|
+
const headerObj = new Headers(header);
|
|
3366
|
+
hasContentLength = headerObj.has("content-length");
|
|
3367
|
+
header = buildOutgoingHttpHeaders(headerObj);
|
|
3368
|
+
} else {
|
|
3369
|
+
for (const key in header) {
|
|
3370
|
+
if (key.length === 14 && key.toLowerCase() === "content-length") {
|
|
3371
|
+
hasContentLength = true;
|
|
3372
|
+
break;
|
|
3373
|
+
}
|
|
3374
|
+
}
|
|
3295
3375
|
}
|
|
3296
|
-
if (
|
|
3297
|
-
|
|
3298
|
-
|
|
3299
|
-
|
|
3300
|
-
|
|
3301
|
-
|
|
3376
|
+
if (!hasContentLength) {
|
|
3377
|
+
if (typeof body === "string") {
|
|
3378
|
+
header["Content-Length"] = Buffer.byteLength(body);
|
|
3379
|
+
} else if (body instanceof Uint8Array) {
|
|
3380
|
+
header["Content-Length"] = body.byteLength;
|
|
3381
|
+
} else if (body instanceof Blob) {
|
|
3382
|
+
header["Content-Length"] = body.size;
|
|
3383
|
+
}
|
|
3302
3384
|
}
|
|
3303
3385
|
outgoing.writeHead(status, header);
|
|
3304
3386
|
if (typeof body === "string" || body instanceof Uint8Array) {
|
|
@@ -3410,14 +3492,18 @@ var getRequestListener = (fetchCallback, options = {}) => {
|
|
|
3410
3492
|
setTimeout(() => {
|
|
3411
3493
|
if (!incomingEnded) {
|
|
3412
3494
|
setTimeout(() => {
|
|
3413
|
-
incoming
|
|
3414
|
-
outgoing.destroy();
|
|
3495
|
+
drainIncoming(incoming);
|
|
3415
3496
|
});
|
|
3416
3497
|
}
|
|
3417
3498
|
});
|
|
3418
3499
|
}
|
|
3419
3500
|
};
|
|
3420
3501
|
}
|
|
3502
|
+
outgoing.on("finish", () => {
|
|
3503
|
+
if (!incomingEnded) {
|
|
3504
|
+
drainIncoming(incoming);
|
|
3505
|
+
}
|
|
3506
|
+
});
|
|
3421
3507
|
}
|
|
3422
3508
|
outgoing.on("close", () => {
|
|
3423
3509
|
const abortController = req[abortControllerKey];
|
|
@@ -3432,7 +3518,7 @@ var getRequestListener = (fetchCallback, options = {}) => {
|
|
|
3432
3518
|
setTimeout(() => {
|
|
3433
3519
|
if (!incomingEnded) {
|
|
3434
3520
|
setTimeout(() => {
|
|
3435
|
-
incoming
|
|
3521
|
+
drainIncoming(incoming);
|
|
3436
3522
|
});
|
|
3437
3523
|
}
|
|
3438
3524
|
});
|
|
@@ -3485,7 +3571,7 @@ var serve = (options, listeningListener) => {
|
|
|
3485
3571
|
return server;
|
|
3486
3572
|
};
|
|
3487
3573
|
|
|
3488
|
-
// ../../node_modules/.bun/hono@4.12.
|
|
3574
|
+
// ../../node_modules/.bun/hono@4.12.18/node_modules/hono/dist/compose.js
|
|
3489
3575
|
var compose = (middleware, onError, onNotFound) => {
|
|
3490
3576
|
return (context, next) => {
|
|
3491
3577
|
let index = -1;
|
|
@@ -3529,10 +3615,10 @@ var compose = (middleware, onError, onNotFound) => {
|
|
|
3529
3615
|
};
|
|
3530
3616
|
};
|
|
3531
3617
|
|
|
3532
|
-
// ../../node_modules/.bun/hono@4.12.
|
|
3618
|
+
// ../../node_modules/.bun/hono@4.12.18/node_modules/hono/dist/request/constants.js
|
|
3533
3619
|
var GET_MATCH_RESULT = /* @__PURE__ */ Symbol();
|
|
3534
3620
|
|
|
3535
|
-
// ../../node_modules/.bun/hono@4.12.
|
|
3621
|
+
// ../../node_modules/.bun/hono@4.12.18/node_modules/hono/dist/utils/body.js
|
|
3536
3622
|
var parseBody = async (request, options = /* @__PURE__ */ Object.create(null)) => {
|
|
3537
3623
|
const { all = false, dot = false } = options;
|
|
3538
3624
|
const headers = request instanceof HonoRequest ? request.raw.headers : request.headers;
|
|
@@ -3603,7 +3689,7 @@ var handleParsingNestedValues = (form, key, value) => {
|
|
|
3603
3689
|
});
|
|
3604
3690
|
};
|
|
3605
3691
|
|
|
3606
|
-
// ../../node_modules/.bun/hono@4.12.
|
|
3692
|
+
// ../../node_modules/.bun/hono@4.12.18/node_modules/hono/dist/utils/url.js
|
|
3607
3693
|
var splitPath = (path) => {
|
|
3608
3694
|
const paths = path.split("/");
|
|
3609
3695
|
if (paths[0] === "") {
|
|
@@ -3803,7 +3889,7 @@ var getQueryParams = (url, key) => {
|
|
|
3803
3889
|
};
|
|
3804
3890
|
var decodeURIComponent_ = decodeURIComponent;
|
|
3805
3891
|
|
|
3806
|
-
// ../../node_modules/.bun/hono@4.12.
|
|
3892
|
+
// ../../node_modules/.bun/hono@4.12.18/node_modules/hono/dist/request.js
|
|
3807
3893
|
var tryDecodeURIComponent = (str) => tryDecode(str, decodeURIComponent_);
|
|
3808
3894
|
var HonoRequest = class {
|
|
3809
3895
|
raw;
|
|
@@ -3857,7 +3943,7 @@ var HonoRequest = class {
|
|
|
3857
3943
|
return headerData;
|
|
3858
3944
|
}
|
|
3859
3945
|
async parseBody(options) {
|
|
3860
|
-
return
|
|
3946
|
+
return parseBody(this, options);
|
|
3861
3947
|
}
|
|
3862
3948
|
#cachedBody = (key) => {
|
|
3863
3949
|
const { bodyCache, raw } = this;
|
|
@@ -3914,7 +4000,7 @@ var HonoRequest = class {
|
|
|
3914
4000
|
}
|
|
3915
4001
|
};
|
|
3916
4002
|
|
|
3917
|
-
// ../../node_modules/.bun/hono@4.12.
|
|
4003
|
+
// ../../node_modules/.bun/hono@4.12.18/node_modules/hono/dist/utils/html.js
|
|
3918
4004
|
var HtmlEscapedCallbackPhase = {
|
|
3919
4005
|
Stringify: 1,
|
|
3920
4006
|
BeforeStream: 2,
|
|
@@ -3952,7 +4038,7 @@ var resolveCallback = async (str, phase, preserveCallbacks, context, buffer) =>
|
|
|
3952
4038
|
}
|
|
3953
4039
|
};
|
|
3954
4040
|
|
|
3955
|
-
// ../../node_modules/.bun/hono@4.12.
|
|
4041
|
+
// ../../node_modules/.bun/hono@4.12.18/node_modules/hono/dist/context.js
|
|
3956
4042
|
var TEXT_PLAIN = "text/plain; charset=UTF-8";
|
|
3957
4043
|
var setDefaultContentType = (contentType, headers) => {
|
|
3958
4044
|
return {
|
|
@@ -4119,7 +4205,7 @@ var Context = class {
|
|
|
4119
4205
|
};
|
|
4120
4206
|
};
|
|
4121
4207
|
|
|
4122
|
-
// ../../node_modules/.bun/hono@4.12.
|
|
4208
|
+
// ../../node_modules/.bun/hono@4.12.18/node_modules/hono/dist/router.js
|
|
4123
4209
|
var METHOD_NAME_ALL = "ALL";
|
|
4124
4210
|
var METHOD_NAME_ALL_LOWERCASE = "all";
|
|
4125
4211
|
var METHODS = ["get", "post", "put", "delete", "options", "patch"];
|
|
@@ -4127,10 +4213,10 @@ var MESSAGE_MATCHER_IS_ALREADY_BUILT = "Can not add a route since the matcher is
|
|
|
4127
4213
|
var UnsupportedPathError = class extends Error {
|
|
4128
4214
|
};
|
|
4129
4215
|
|
|
4130
|
-
// ../../node_modules/.bun/hono@4.12.
|
|
4216
|
+
// ../../node_modules/.bun/hono@4.12.18/node_modules/hono/dist/utils/constants.js
|
|
4131
4217
|
var COMPOSED_HANDLER = "__COMPOSED_HANDLER";
|
|
4132
4218
|
|
|
4133
|
-
// ../../node_modules/.bun/hono@4.12.
|
|
4219
|
+
// ../../node_modules/.bun/hono@4.12.18/node_modules/hono/dist/hono-base.js
|
|
4134
4220
|
var notFoundHandler = (c) => {
|
|
4135
4221
|
return c.text("404 Not Found", 404);
|
|
4136
4222
|
};
|
|
@@ -4349,7 +4435,7 @@ var Hono = class _Hono {
|
|
|
4349
4435
|
};
|
|
4350
4436
|
};
|
|
4351
4437
|
|
|
4352
|
-
// ../../node_modules/.bun/hono@4.12.
|
|
4438
|
+
// ../../node_modules/.bun/hono@4.12.18/node_modules/hono/dist/router/reg-exp-router/matcher.js
|
|
4353
4439
|
var emptyParam = [];
|
|
4354
4440
|
function match(method, path) {
|
|
4355
4441
|
const matchers = this.buildAllMatchers();
|
|
@@ -4370,7 +4456,7 @@ function match(method, path) {
|
|
|
4370
4456
|
return match2(method, path);
|
|
4371
4457
|
}
|
|
4372
4458
|
|
|
4373
|
-
// ../../node_modules/.bun/hono@4.12.
|
|
4459
|
+
// ../../node_modules/.bun/hono@4.12.18/node_modules/hono/dist/router/reg-exp-router/node.js
|
|
4374
4460
|
var LABEL_REG_EXP_STR = "[^/]+";
|
|
4375
4461
|
var ONLY_WILDCARD_REG_EXP_STR = ".*";
|
|
4376
4462
|
var TAIL_WILDCARD_REG_EXP_STR = "(?:|/.*)";
|
|
@@ -4474,7 +4560,7 @@ var Node = class _Node {
|
|
|
4474
4560
|
}
|
|
4475
4561
|
};
|
|
4476
4562
|
|
|
4477
|
-
// ../../node_modules/.bun/hono@4.12.
|
|
4563
|
+
// ../../node_modules/.bun/hono@4.12.18/node_modules/hono/dist/router/reg-exp-router/trie.js
|
|
4478
4564
|
var Trie = class {
|
|
4479
4565
|
#context = { varIndex: 0 };
|
|
4480
4566
|
#root = new Node;
|
|
@@ -4530,7 +4616,7 @@ var Trie = class {
|
|
|
4530
4616
|
}
|
|
4531
4617
|
};
|
|
4532
4618
|
|
|
4533
|
-
// ../../node_modules/.bun/hono@4.12.
|
|
4619
|
+
// ../../node_modules/.bun/hono@4.12.18/node_modules/hono/dist/router/reg-exp-router/router.js
|
|
4534
4620
|
var nullMatcher = [/^$/, [], /* @__PURE__ */ Object.create(null)];
|
|
4535
4621
|
var wildcardRegExpCache = /* @__PURE__ */ Object.create(null);
|
|
4536
4622
|
function buildWildcardRegExp(path) {
|
|
@@ -4695,7 +4781,7 @@ var RegExpRouter = class {
|
|
|
4695
4781
|
}
|
|
4696
4782
|
};
|
|
4697
4783
|
|
|
4698
|
-
// ../../node_modules/.bun/hono@4.12.
|
|
4784
|
+
// ../../node_modules/.bun/hono@4.12.18/node_modules/hono/dist/router/reg-exp-router/prepared-router.js
|
|
4699
4785
|
var PreparedRegExpRouter = class {
|
|
4700
4786
|
name = "PreparedRegExpRouter";
|
|
4701
4787
|
#matchers;
|
|
@@ -4767,7 +4853,7 @@ var PreparedRegExpRouter = class {
|
|
|
4767
4853
|
match = match;
|
|
4768
4854
|
};
|
|
4769
4855
|
|
|
4770
|
-
// ../../node_modules/.bun/hono@4.12.
|
|
4856
|
+
// ../../node_modules/.bun/hono@4.12.18/node_modules/hono/dist/router/smart-router/router.js
|
|
4771
4857
|
var SmartRouter = class {
|
|
4772
4858
|
name = "SmartRouter";
|
|
4773
4859
|
#routers = [];
|
|
@@ -4822,7 +4908,7 @@ var SmartRouter = class {
|
|
|
4822
4908
|
}
|
|
4823
4909
|
};
|
|
4824
4910
|
|
|
4825
|
-
// ../../node_modules/.bun/hono@4.12.
|
|
4911
|
+
// ../../node_modules/.bun/hono@4.12.18/node_modules/hono/dist/router/trie-router/node.js
|
|
4826
4912
|
var emptyParams = /* @__PURE__ */ Object.create(null);
|
|
4827
4913
|
var hasChildren = (children) => {
|
|
4828
4914
|
for (const _ in children) {
|
|
@@ -4991,7 +5077,7 @@ var Node2 = class _Node2 {
|
|
|
4991
5077
|
}
|
|
4992
5078
|
};
|
|
4993
5079
|
|
|
4994
|
-
// ../../node_modules/.bun/hono@4.12.
|
|
5080
|
+
// ../../node_modules/.bun/hono@4.12.18/node_modules/hono/dist/router/trie-router/router.js
|
|
4995
5081
|
var TrieRouter = class {
|
|
4996
5082
|
name = "TrieRouter";
|
|
4997
5083
|
#node;
|
|
@@ -5013,7 +5099,7 @@ var TrieRouter = class {
|
|
|
5013
5099
|
}
|
|
5014
5100
|
};
|
|
5015
5101
|
|
|
5016
|
-
// ../../node_modules/.bun/hono@4.12.
|
|
5102
|
+
// ../../node_modules/.bun/hono@4.12.18/node_modules/hono/dist/hono.js
|
|
5017
5103
|
var Hono2 = class extends Hono {
|
|
5018
5104
|
constructor(options = {}) {
|
|
5019
5105
|
super(options);
|
|
@@ -5113,12 +5199,12 @@ function requestIdMiddleware() {
|
|
|
5113
5199
|
};
|
|
5114
5200
|
}
|
|
5115
5201
|
function requestLoggerMiddleware(logger) {
|
|
5116
|
-
const
|
|
5202
|
+
const log13 = logger ?? createLogger();
|
|
5117
5203
|
return async (c, next) => {
|
|
5118
5204
|
const start = Date.now();
|
|
5119
5205
|
await next();
|
|
5120
5206
|
const duration = Date.now() - start;
|
|
5121
|
-
|
|
5207
|
+
log13.info(`${c.req.method} ${c.req.path}`, {
|
|
5122
5208
|
method: c.req.method,
|
|
5123
5209
|
path: c.req.path,
|
|
5124
5210
|
status: c.res.status,
|
|
@@ -5128,7 +5214,7 @@ function requestLoggerMiddleware(logger) {
|
|
|
5128
5214
|
};
|
|
5129
5215
|
}
|
|
5130
5216
|
|
|
5131
|
-
// ../../node_modules/.bun/hono@4.12.
|
|
5217
|
+
// ../../node_modules/.bun/hono@4.12.18/node_modules/hono/dist/utils/stream.js
|
|
5132
5218
|
var StreamingApi = class {
|
|
5133
5219
|
writer;
|
|
5134
5220
|
encoder;
|
|
@@ -5194,7 +5280,7 @@ var StreamingApi = class {
|
|
|
5194
5280
|
}
|
|
5195
5281
|
};
|
|
5196
5282
|
|
|
5197
|
-
// ../../node_modules/.bun/hono@4.12.
|
|
5283
|
+
// ../../node_modules/.bun/hono@4.12.18/node_modules/hono/dist/helper/streaming/utils.js
|
|
5198
5284
|
var isOldBunVersion = () => {
|
|
5199
5285
|
const version = typeof Bun !== "undefined" ? Bun.version : undefined;
|
|
5200
5286
|
if (version === undefined) {
|
|
@@ -5205,7 +5291,7 @@ var isOldBunVersion = () => {
|
|
|
5205
5291
|
return result;
|
|
5206
5292
|
};
|
|
5207
5293
|
|
|
5208
|
-
// ../../node_modules/.bun/hono@4.12.
|
|
5294
|
+
// ../../node_modules/.bun/hono@4.12.18/node_modules/hono/dist/helper/streaming/stream.js
|
|
5209
5295
|
var contextStash = /* @__PURE__ */ new WeakMap;
|
|
5210
5296
|
var stream = (c, cb, onError) => {
|
|
5211
5297
|
const { readable, writable } = new TransformStream;
|
|
@@ -5461,13 +5547,13 @@ function createRoutes(deps) {
|
|
|
5461
5547
|
}
|
|
5462
5548
|
|
|
5463
5549
|
// src/app.ts
|
|
5464
|
-
var
|
|
5550
|
+
var log13 = createLogger();
|
|
5465
5551
|
function createApp(config) {
|
|
5466
5552
|
const app = new Hono2;
|
|
5467
5553
|
app.onError((err2, c) => {
|
|
5468
5554
|
const statusCode = err2 instanceof ElsiumError ? err2.statusCode ?? 500 : 500;
|
|
5469
5555
|
const code = err2 instanceof ElsiumError ? err2.code : "UNKNOWN";
|
|
5470
|
-
|
|
5556
|
+
log13.error("Unhandled error", { error: err2.message, code, path: c.req.path });
|
|
5471
5557
|
return c.json({ error: err2.message, code }, statusCode);
|
|
5472
5558
|
});
|
|
5473
5559
|
app.notFound((c) => {
|
|
@@ -5513,7 +5599,7 @@ function createApp(config) {
|
|
|
5513
5599
|
});
|
|
5514
5600
|
const serverConfig = config.server ?? {};
|
|
5515
5601
|
app.use("*", requestIdMiddleware());
|
|
5516
|
-
app.use("*", requestLoggerMiddleware(
|
|
5602
|
+
app.use("*", requestLoggerMiddleware(log13));
|
|
5517
5603
|
if (serverConfig.cors) {
|
|
5518
5604
|
app.use("*", corsMiddleware(serverConfig.cors));
|
|
5519
5605
|
}
|
|
@@ -5559,11 +5645,11 @@ function createApp(config) {
|
|
|
5559
5645
|
const drainTimeoutMs = typeof serverConfig.gracefulShutdown === "object" ? serverConfig.gracefulShutdown.drainTimeoutMs : undefined;
|
|
5560
5646
|
shutdownManager = createShutdownManager({
|
|
5561
5647
|
drainTimeoutMs,
|
|
5562
|
-
onDrainStart: () =>
|
|
5563
|
-
onDrainComplete: () =>
|
|
5648
|
+
onDrainStart: () => log13.info("Draining connections..."),
|
|
5649
|
+
onDrainComplete: () => log13.info("Drain complete")
|
|
5564
5650
|
});
|
|
5565
5651
|
}
|
|
5566
|
-
|
|
5652
|
+
log13.info("ElsiumAI server started", {
|
|
5567
5653
|
url: `http://${hostname}:${listenPort}`,
|
|
5568
5654
|
routes: ["POST /chat", "POST /complete", "GET /health", "GET /metrics", "GET /agents"]
|
|
5569
5655
|
});
|
|
@@ -5580,7 +5666,7 @@ function createApp(config) {
|
|
|
5580
5666
|
};
|
|
5581
5667
|
}
|
|
5582
5668
|
// src/rbac.ts
|
|
5583
|
-
var
|
|
5669
|
+
var log14 = createLogger();
|
|
5584
5670
|
var BUILT_IN_ROLES = [
|
|
5585
5671
|
{
|
|
5586
5672
|
name: "admin",
|
|
@@ -5618,7 +5704,7 @@ function matchPermission(granted, required) {
|
|
|
5618
5704
|
}
|
|
5619
5705
|
function createRBAC(config) {
|
|
5620
5706
|
if (config.trustRoleHeader === true) {
|
|
5621
|
-
|
|
5707
|
+
log14.warn("RBAC: trustRoleHeader is enabled — any client can self-assign roles via the X-Role header. Only use this in development or behind a trusted reverse proxy.");
|
|
5622
5708
|
}
|
|
5623
5709
|
const roleMap = new Map;
|
|
5624
5710
|
for (const role of BUILT_IN_ROLES) {
|
|
@@ -5675,7 +5761,7 @@ function createRBAC(config) {
|
|
|
5675
5761
|
};
|
|
5676
5762
|
}
|
|
5677
5763
|
// src/tenant.ts
|
|
5678
|
-
var
|
|
5764
|
+
var log15 = createLogger();
|
|
5679
5765
|
var tenantUsage = new Map;
|
|
5680
5766
|
function tenantMiddleware(config) {
|
|
5681
5767
|
const { extractTenant, onUnknownTenant = "reject", defaultTenant } = config;
|
|
@@ -5684,13 +5770,13 @@ function tenantMiddleware(config) {
|
|
|
5684
5770
|
if (!tenant) {
|
|
5685
5771
|
if (onUnknownTenant === "default" && defaultTenant) {
|
|
5686
5772
|
c.set("tenant", defaultTenant);
|
|
5687
|
-
|
|
5773
|
+
log15.debug("Using default tenant", { tenantId: defaultTenant.tenantId });
|
|
5688
5774
|
} else {
|
|
5689
5775
|
return c.json({ error: "Tenant identification required" }, 401);
|
|
5690
5776
|
}
|
|
5691
5777
|
} else {
|
|
5692
5778
|
c.set("tenant", tenant);
|
|
5693
|
-
|
|
5779
|
+
log15.debug("Tenant identified", { tenantId: tenant.tenantId });
|
|
5694
5780
|
}
|
|
5695
5781
|
await next();
|
|
5696
5782
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elsium-ai/app",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.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.
|
|
30
|
-
"@elsium-ai/gateway": "^0.
|
|
31
|
-
"@elsium-ai/agents": "^0.
|
|
32
|
-
"@elsium-ai/tools": "^0.
|
|
33
|
-
"@elsium-ai/observe": "^0.
|
|
34
|
-
"@elsium-ai/rag": "^0.
|
|
35
|
-
"@elsium-ai/workflows": "^0.
|
|
36
|
-
"@hono/node-server": "^1.19.
|
|
37
|
-
"hono": "^4.12.
|
|
29
|
+
"@elsium-ai/core": "^0.11.0",
|
|
30
|
+
"@elsium-ai/gateway": "^0.11.0",
|
|
31
|
+
"@elsium-ai/agents": "^0.11.0",
|
|
32
|
+
"@elsium-ai/tools": "^0.11.0",
|
|
33
|
+
"@elsium-ai/observe": "^0.11.0",
|
|
34
|
+
"@elsium-ai/rag": "^0.11.0",
|
|
35
|
+
"@elsium-ai/workflows": "^0.11.0",
|
|
36
|
+
"@hono/node-server": "^1.19.14",
|
|
37
|
+
"hono": "^4.12.18",
|
|
38
38
|
"zod": "^3.24.0"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|