@goonnguyen/human-mcp 2.7.0 → 2.8.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 +784 -486
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -27,6 +27,7 @@ var __export = (target, all) => {
27
27
  set: (newValue) => all[name] = () => newValue
28
28
  });
29
29
  };
30
+ var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
30
31
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
31
32
 
32
33
  // node_modules/uri-js/dist/es5/uri.all.js
@@ -12195,6 +12196,89 @@ var require_lib = __commonJS((exports, module) => {
12195
12196
  module.exports = Sharp;
12196
12197
  });
12197
12198
 
12199
+ // src/utils/logger.ts
12200
+ class Logger {
12201
+ level;
12202
+ constructor() {
12203
+ this.level = process.env.LOG_LEVEL || "info";
12204
+ }
12205
+ shouldLog(level) {
12206
+ const levels = ["debug", "info", "warn", "error"];
12207
+ return levels.indexOf(level) >= levels.indexOf(this.level);
12208
+ }
12209
+ format(level, message, ...args) {
12210
+ const timestamp = new Date().toISOString();
12211
+ const formatted = `[${timestamp}] [${level.toUpperCase()}] ${message}`;
12212
+ if (args.length > 0) {
12213
+ return `${formatted} ${JSON.stringify(args)}`;
12214
+ }
12215
+ return formatted;
12216
+ }
12217
+ debug(message, ...args) {
12218
+ if (this.shouldLog("debug")) {
12219
+ console.error(this.format("debug", message, ...args));
12220
+ }
12221
+ }
12222
+ info(message, ...args) {
12223
+ if (this.shouldLog("info")) {
12224
+ console.error(this.format("info", message, ...args));
12225
+ }
12226
+ }
12227
+ warn(message, ...args) {
12228
+ if (this.shouldLog("warn")) {
12229
+ console.error(this.format("warn", message, ...args));
12230
+ }
12231
+ }
12232
+ error(message, ...args) {
12233
+ if (this.shouldLog("error")) {
12234
+ console.error(this.format("error", message, ...args));
12235
+ }
12236
+ }
12237
+ }
12238
+ var logger2;
12239
+ var init_logger = __esm(() => {
12240
+ logger2 = new Logger;
12241
+ });
12242
+
12243
+ // src/utils/errors.ts
12244
+ function handleError(error) {
12245
+ if (error instanceof HumanMCPError) {
12246
+ return error;
12247
+ }
12248
+ if (error instanceof Error) {
12249
+ return new ProcessingError(error.message);
12250
+ }
12251
+ return new ProcessingError("An unknown error occurred");
12252
+ }
12253
+ var HumanMCPError, ValidationError, ProcessingError, APIError;
12254
+ var init_errors = __esm(() => {
12255
+ HumanMCPError = class HumanMCPError extends Error {
12256
+ code;
12257
+ statusCode;
12258
+ constructor(message, code, statusCode) {
12259
+ super(message);
12260
+ this.code = code;
12261
+ this.statusCode = statusCode;
12262
+ this.name = "HumanMCPError";
12263
+ }
12264
+ };
12265
+ ValidationError = class ValidationError extends HumanMCPError {
12266
+ constructor(message) {
12267
+ super(message, "VALIDATION_ERROR", 400);
12268
+ }
12269
+ };
12270
+ ProcessingError = class ProcessingError extends HumanMCPError {
12271
+ constructor(message) {
12272
+ super(message, "PROCESSING_ERROR", 500);
12273
+ }
12274
+ };
12275
+ APIError = class APIError extends HumanMCPError {
12276
+ constructor(message, statusCode = 500) {
12277
+ super(message, "API_ERROR", statusCode);
12278
+ }
12279
+ };
12280
+ });
12281
+
12198
12282
  // node_modules/@smithy/types/dist-cjs/index.js
12199
12283
  var require_dist_cjs = __commonJS((exports, module) => {
12200
12284
  var __defProp2 = Object.defineProperty;
@@ -33814,7 +33898,7 @@ var require_dist_cjs59 = __commonJS((exports, module) => {
33814
33898
  var __getOwnPropNames2 = Object.getOwnPropertyNames;
33815
33899
  var __hasOwnProp2 = Object.prototype.hasOwnProperty;
33816
33900
  var __name = (target, value) => __defProp2(target, "name", { value, configurable: true });
33817
- var __esm = (fn, res) => function __init() {
33901
+ var __esm2 = (fn, res) => function __init() {
33818
33902
  return fn && (res = (0, fn[__getOwnPropNames2(fn)[0]])(fn = 0)), res;
33819
33903
  };
33820
33904
  var __export2 = (target, all) => {
@@ -33836,7 +33920,7 @@ var require_dist_cjs59 = __commonJS((exports, module) => {
33836
33920
  SSOClient: () => import_client_sso.SSOClient
33837
33921
  });
33838
33922
  var import_client_sso;
33839
- var init_loadSso = __esm({
33923
+ var init_loadSso = __esm2({
33840
33924
  "src/loadSso.ts"() {
33841
33925
  import_client_sso = require_dist_cjs57();
33842
33926
  }
@@ -48483,6 +48567,80 @@ var require_dist_cjs72 = __commonJS((exports, module) => {
48483
48567
  }, "waitUntilObjectNotExists");
48484
48568
  });
48485
48569
 
48570
+ // node_modules/uuid/dist-node/stringify.js
48571
+ function unsafeStringify(arr, offset = 0) {
48572
+ return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();
48573
+ }
48574
+ var byteToHex;
48575
+ var init_stringify = __esm(() => {
48576
+ byteToHex = [];
48577
+ for (let i = 0;i < 256; ++i) {
48578
+ byteToHex.push((i + 256).toString(16).slice(1));
48579
+ }
48580
+ });
48581
+
48582
+ // node_modules/uuid/dist-node/rng.js
48583
+ import { randomFillSync } from "node:crypto";
48584
+ function rng() {
48585
+ if (poolPtr > rnds8Pool.length - 16) {
48586
+ randomFillSync(rnds8Pool);
48587
+ poolPtr = 0;
48588
+ }
48589
+ return rnds8Pool.slice(poolPtr, poolPtr += 16);
48590
+ }
48591
+ var rnds8Pool, poolPtr;
48592
+ var init_rng = __esm(() => {
48593
+ rnds8Pool = new Uint8Array(256);
48594
+ poolPtr = rnds8Pool.length;
48595
+ });
48596
+
48597
+ // node_modules/uuid/dist-node/native.js
48598
+ import { randomUUID } from "node:crypto";
48599
+ var native_default;
48600
+ var init_native = __esm(() => {
48601
+ native_default = { randomUUID };
48602
+ });
48603
+
48604
+ // node_modules/uuid/dist-node/v4.js
48605
+ function _v4(options, buf, offset) {
48606
+ options = options || {};
48607
+ const rnds = options.random ?? options.rng?.() ?? rng();
48608
+ if (rnds.length < 16) {
48609
+ throw new Error("Random bytes length must be >= 16");
48610
+ }
48611
+ rnds[6] = rnds[6] & 15 | 64;
48612
+ rnds[8] = rnds[8] & 63 | 128;
48613
+ if (buf) {
48614
+ offset = offset || 0;
48615
+ if (offset < 0 || offset + 16 > buf.length) {
48616
+ throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`);
48617
+ }
48618
+ for (let i = 0;i < 16; ++i) {
48619
+ buf[offset + i] = rnds[i];
48620
+ }
48621
+ return buf;
48622
+ }
48623
+ return unsafeStringify(rnds);
48624
+ }
48625
+ function v4(options, buf, offset) {
48626
+ if (native_default.randomUUID && !buf && !options) {
48627
+ return native_default.randomUUID();
48628
+ }
48629
+ return _v4(options, buf, offset);
48630
+ }
48631
+ var v4_default;
48632
+ var init_v4 = __esm(() => {
48633
+ init_native();
48634
+ init_rng();
48635
+ init_stringify();
48636
+ v4_default = v4;
48637
+ });
48638
+
48639
+ // node_modules/uuid/dist-node/index.js
48640
+ var init_dist_node = __esm(() => {
48641
+ init_v4();
48642
+ });
48643
+
48486
48644
  // node_modules/mime-db/db.json
48487
48645
  var require_db = __commonJS((exports, module) => {
48488
48646
  module.exports = {
@@ -57980,6 +58138,100 @@ var require_mime_types = __commonJS((exports) => {
57980
58138
  }
57981
58139
  });
57982
58140
 
58141
+ // src/utils/cloudflare-r2.ts
58142
+ class CloudflareR2Client {
58143
+ s3Client;
58144
+ bucketName;
58145
+ baseUrl;
58146
+ constructor() {
58147
+ const requiredVars = [
58148
+ "CLOUDFLARE_CDN_ACCESS_KEY",
58149
+ "CLOUDFLARE_CDN_SECRET_KEY",
58150
+ "CLOUDFLARE_CDN_ENDPOINT_URL",
58151
+ "CLOUDFLARE_CDN_BUCKET_NAME",
58152
+ "CLOUDFLARE_CDN_BASE_URL"
58153
+ ];
58154
+ const missing = requiredVars.filter((varName) => !process.env[varName]);
58155
+ if (missing.length > 0) {
58156
+ throw new Error(`Missing required Cloudflare R2 environment variables: ${missing.join(", ")}`);
58157
+ }
58158
+ const config = {
58159
+ region: "auto",
58160
+ endpoint: process.env.CLOUDFLARE_CDN_ENDPOINT_URL,
58161
+ credentials: {
58162
+ accessKeyId: process.env.CLOUDFLARE_CDN_ACCESS_KEY,
58163
+ secretAccessKey: process.env.CLOUDFLARE_CDN_SECRET_KEY
58164
+ }
58165
+ };
58166
+ this.s3Client = new import_client_s3.S3Client(config);
58167
+ this.bucketName = process.env.CLOUDFLARE_CDN_BUCKET_NAME;
58168
+ this.baseUrl = process.env.CLOUDFLARE_CDN_BASE_URL;
58169
+ }
58170
+ async uploadFile(buffer, originalName) {
58171
+ try {
58172
+ const fileExtension = originalName.split(".").pop() || "bin";
58173
+ const mimeType = import_mime_types.default.lookup(originalName) || "application/octet-stream";
58174
+ const key = `human-mcp/${v4_default()}.${fileExtension}`;
58175
+ const command = new import_client_s3.PutObjectCommand({
58176
+ Bucket: this.bucketName,
58177
+ Key: key,
58178
+ Body: buffer,
58179
+ ContentType: mimeType,
58180
+ Metadata: {
58181
+ originalName,
58182
+ uploadedAt: new Date().toISOString(),
58183
+ source: "human-mcp-http-transport"
58184
+ }
58185
+ });
58186
+ await this.s3Client.send(command);
58187
+ const publicUrl = `${this.baseUrl}/${key}`;
58188
+ logger2.info(`File uploaded to Cloudflare R2: ${publicUrl}`);
58189
+ return publicUrl;
58190
+ } catch (error) {
58191
+ logger2.error("Failed to upload to Cloudflare R2:", error);
58192
+ throw new Error(`Failed to upload file: ${error instanceof Error ? error.message : "Unknown error"}`);
58193
+ }
58194
+ }
58195
+ async uploadBase64(base64Data, mimeType, originalName) {
58196
+ const buffer = Buffer.from(base64Data, "base64");
58197
+ const extension = mimeType.split("/")[1] || "bin";
58198
+ const fileName = originalName || `upload-${Date.now()}.${extension}`;
58199
+ return this.uploadFile(buffer, fileName);
58200
+ }
58201
+ isConfigured() {
58202
+ try {
58203
+ const requiredVars = [
58204
+ "CLOUDFLARE_CDN_ACCESS_KEY",
58205
+ "CLOUDFLARE_CDN_SECRET_KEY",
58206
+ "CLOUDFLARE_CDN_ENDPOINT_URL",
58207
+ "CLOUDFLARE_CDN_BUCKET_NAME",
58208
+ "CLOUDFLARE_CDN_BASE_URL"
58209
+ ];
58210
+ return requiredVars.every((varName) => process.env[varName]);
58211
+ } catch {
58212
+ return false;
58213
+ }
58214
+ }
58215
+ }
58216
+ function getCloudflareR2() {
58217
+ if (!cloudflareR2Instance) {
58218
+ try {
58219
+ cloudflareR2Instance = new CloudflareR2Client;
58220
+ } catch (error) {
58221
+ logger2.warn("Cloudflare R2 not configured:", error instanceof Error ? error.message : "Unknown error");
58222
+ return null;
58223
+ }
58224
+ }
58225
+ return cloudflareR2Instance;
58226
+ }
58227
+ var import_client_s3, import_mime_types, cloudflareR2Instance = null;
58228
+ var init_cloudflare_r2 = __esm(() => {
58229
+ init_dist_node();
58230
+ init_logger();
58231
+ import_client_s3 = __toESM(require_dist_cjs72(), 1);
58232
+ import_mime_types = __toESM(require_mime_types(), 1);
58233
+ });
58234
+
57983
58235
  // node_modules/isexe/windows.js
57984
58236
  var require_windows = __commonJS((exports, module) => {
57985
58237
  module.exports = isexe;
@@ -120843,6 +121095,219 @@ var require_xlsx = __commonJS((exports, module) => {
120843
121095
  } catch (e) {}
120844
121096
  });
120845
121097
 
121098
+ // src/utils/image-loader.ts
121099
+ var exports_image_loader = {};
121100
+ __export(exports_image_loader, {
121101
+ loadImageForProcessing: () => loadImageForProcessing,
121102
+ isUrl: () => isUrl,
121103
+ isFilePath: () => isFilePath,
121104
+ isDataUri: () => isDataUri
121105
+ });
121106
+ import fs5 from "fs/promises";
121107
+ import path4 from "path";
121108
+ async function loadImageForProcessing(source, options) {
121109
+ const {
121110
+ fetchTimeout = 30000,
121111
+ maxWidth = 1024,
121112
+ maxHeight = 1024,
121113
+ quality = 85
121114
+ } = options || {};
121115
+ try {
121116
+ if (source.match(/^\[Image #\d+\]$/)) {
121117
+ throw new ProcessingError(`Virtual image reference "${source}" cannot be processed directly.
121118
+
121119
+ ` + `Solutions:
121120
+ ` + `1. Use a direct file path (e.g., "/path/to/image.png")
121121
+ ` + `2. Use a public URL (e.g., "https://example.com/image.png")
121122
+ ` + `3. Convert to base64 data URI format`);
121123
+ }
121124
+ if (source.startsWith("/mnt/user-data/") || source.startsWith("/mnt/")) {
121125
+ logger2.info(`Detected Claude Desktop virtual path: ${source}`);
121126
+ const filename = source.split("/").pop() || "upload.jpg";
121127
+ const tempPath = `/tmp/mcp-uploads/${filename}`;
121128
+ try {
121129
+ if (await fs5.access(tempPath).then(() => true).catch(() => false)) {
121130
+ const buffer = await fs5.readFile(tempPath);
121131
+ const cloudflare = getCloudflareR2();
121132
+ if (cloudflare) {
121133
+ const publicUrl = await cloudflare.uploadFile(buffer, filename);
121134
+ await fs5.unlink(tempPath).catch(() => {});
121135
+ return loadImageForProcessing(publicUrl, options);
121136
+ }
121137
+ }
121138
+ } catch (error) {
121139
+ logger2.warn(`Could not process temp file: ${error instanceof Error ? error.message : "Unknown error"}`);
121140
+ }
121141
+ throw new ProcessingError(`Local file access not supported via HTTP transport.
121142
+ ` + `Solutions:
121143
+ ` + `1. Upload to Cloudflare R2 using /mcp/upload endpoint
121144
+ ` + `2. Use a public URL
121145
+ ` + `3. Convert to base64 data URI
121146
+ ` + `4. Use stdio transport for local file access`);
121147
+ }
121148
+ if (source.startsWith("data:image/")) {
121149
+ const [header, data] = source.split(",");
121150
+ if (!header || !data) {
121151
+ throw new ProcessingError("Invalid base64 data URI format");
121152
+ }
121153
+ const mimeMatch = header.match(/data:(image\/[^;]+)/);
121154
+ if (!mimeMatch || !mimeMatch[1]) {
121155
+ throw new ProcessingError("Invalid MIME type in data URI");
121156
+ }
121157
+ const cloudflare = getCloudflareR2();
121158
+ if (process.env.TRANSPORT_TYPE === "http" && cloudflare && data.length > 1024 * 1024) {
121159
+ logger2.info("Large base64 image detected, uploading to Cloudflare R2");
121160
+ try {
121161
+ const publicUrl = await cloudflare.uploadBase64(data, mimeMatch[1]);
121162
+ return loadImageForProcessing(publicUrl, options);
121163
+ } catch (error) {
121164
+ logger2.warn("Failed to upload to Cloudflare R2:", error);
121165
+ }
121166
+ }
121167
+ return {
121168
+ data,
121169
+ mimeType: mimeMatch[1]
121170
+ };
121171
+ }
121172
+ if (source.startsWith("http://") || source.startsWith("https://")) {
121173
+ const controller = new AbortController;
121174
+ const timeoutId = setTimeout(() => controller.abort(), fetchTimeout);
121175
+ try {
121176
+ logger2.debug(`Fetching image from URL: ${source.substring(0, 100)}...`);
121177
+ const response = await fetch(source, { signal: controller.signal });
121178
+ clearTimeout(timeoutId);
121179
+ if (!response.ok) {
121180
+ throw new ProcessingError(`Failed to fetch image: ${response.status} ${response.statusText}`);
121181
+ }
121182
+ const buffer = await response.arrayBuffer();
121183
+ const uint8Array = new Uint8Array(buffer);
121184
+ const processedImage = await import_sharp4.default(uint8Array).resize(maxWidth, maxHeight, { fit: "inside", withoutEnlargement: true }).jpeg({ quality }).toBuffer();
121185
+ return {
121186
+ data: processedImage.toString("base64"),
121187
+ mimeType: "image/jpeg"
121188
+ };
121189
+ } catch (error) {
121190
+ clearTimeout(timeoutId);
121191
+ if (error instanceof Error && error.name === "AbortError") {
121192
+ throw new ProcessingError(`Fetch timeout: Failed to download image from ${source}`);
121193
+ }
121194
+ throw new ProcessingError(`Failed to fetch image: ${error instanceof Error ? error.message : "Unknown error"}`);
121195
+ }
121196
+ }
121197
+ try {
121198
+ validateFilePath(source);
121199
+ await validateFileSize(source);
121200
+ logger2.debug(`Loading local image file: ${source}`);
121201
+ const cloudflare = getCloudflareR2();
121202
+ if (process.env.TRANSPORT_TYPE === "http" && cloudflare) {
121203
+ logger2.info(`HTTP transport detected, uploading local file to Cloudflare R2: ${source}`);
121204
+ try {
121205
+ const buffer2 = await fs5.readFile(source);
121206
+ const filename = source.split("/").pop() || "upload.jpg";
121207
+ const publicUrl = await cloudflare.uploadFile(buffer2, filename);
121208
+ return loadImageForProcessing(publicUrl, options);
121209
+ } catch (error) {
121210
+ logger2.warn(`Failed to upload to Cloudflare R2: ${error instanceof Error ? error.message : "Unknown error"}`);
121211
+ }
121212
+ }
121213
+ const buffer = await fs5.readFile(source);
121214
+ const processedImage = await import_sharp4.default(buffer).resize(maxWidth, maxHeight, { fit: "inside", withoutEnlargement: true }).jpeg({ quality }).toBuffer();
121215
+ return {
121216
+ data: processedImage.toString("base64"),
121217
+ mimeType: "image/jpeg"
121218
+ };
121219
+ } catch (error) {
121220
+ if (error instanceof Error && error.message.includes("ENOENT")) {
121221
+ logger2.debug("File not found, attempting to parse as raw base64");
121222
+ try {
121223
+ if (!/^[A-Za-z0-9+/=]+$/.test(source.substring(0, 100))) {
121224
+ throw new Error("Not valid base64");
121225
+ }
121226
+ return {
121227
+ data: source,
121228
+ mimeType: "image/jpeg"
121229
+ };
121230
+ } catch {
121231
+ throw new ProcessingError(`Failed to load image from source: ${source.substring(0, 50)}...
121232
+ ` + `Source must be a valid file path, URL, or base64 data URI.`);
121233
+ }
121234
+ }
121235
+ throw new ProcessingError(`Failed to load image: ${error instanceof Error ? error.message : "Unknown error"}`);
121236
+ }
121237
+ } catch (error) {
121238
+ if (error instanceof ProcessingError) {
121239
+ throw error;
121240
+ }
121241
+ throw new ProcessingError(`Image loading failed: ${error instanceof Error ? error.message : "Unknown error"}`);
121242
+ }
121243
+ }
121244
+ function validateFilePath(filePath) {
121245
+ const resolvedPath2 = path4.resolve(filePath);
121246
+ if (filePath.includes("\x00")) {
121247
+ throw new ProcessingError("Invalid file path: null bytes detected");
121248
+ }
121249
+ const ext = path4.extname(resolvedPath2).toLowerCase();
121250
+ if (!ALLOWED_EXTENSIONS.includes(ext)) {
121251
+ throw new ProcessingError(`Invalid file extension: ${ext}. Allowed extensions: ${ALLOWED_EXTENSIONS.join(", ")}`);
121252
+ }
121253
+ const cwd = process.cwd();
121254
+ if (!resolvedPath2.startsWith(cwd) && !path4.isAbsolute(filePath)) {
121255
+ throw new ProcessingError("Invalid file path: relative paths must be within project directory");
121256
+ }
121257
+ const sensitivePatterns = [
121258
+ "/etc/",
121259
+ "/sys/",
121260
+ "/proc/",
121261
+ "/dev/",
121262
+ "/.ssh/",
121263
+ "/.env"
121264
+ ];
121265
+ for (const pattern of sensitivePatterns) {
121266
+ if (resolvedPath2.includes(pattern)) {
121267
+ throw new ProcessingError("Invalid file path: access to sensitive system files is not allowed");
121268
+ }
121269
+ }
121270
+ }
121271
+ async function validateFileSize(filePath) {
121272
+ try {
121273
+ const stats = await fs5.stat(filePath);
121274
+ if (!stats.isFile()) {
121275
+ throw new ProcessingError(`Path is not a file: ${filePath}`);
121276
+ }
121277
+ if (stats.size > MAX_FILE_SIZE) {
121278
+ const sizeMB = (stats.size / (1024 * 1024)).toFixed(2);
121279
+ const maxMB = (MAX_FILE_SIZE / (1024 * 1024)).toFixed(2);
121280
+ throw new ProcessingError(`File too large: ${sizeMB}MB exceeds maximum allowed size of ${maxMB}MB`);
121281
+ }
121282
+ } catch (error) {
121283
+ if (error instanceof ProcessingError) {
121284
+ throw error;
121285
+ }
121286
+ if (error instanceof Error && error.message.includes("ENOENT")) {
121287
+ throw new ProcessingError(`File not found: ${filePath}`);
121288
+ }
121289
+ throw new ProcessingError(`Failed to validate file: ${error instanceof Error ? error.message : "Unknown error"}`);
121290
+ }
121291
+ }
121292
+ function isFilePath(source) {
121293
+ return (source.startsWith("/") || source.startsWith("./") || source.startsWith("../")) && !source.startsWith("http://") && !source.startsWith("https://") && !source.startsWith("data:");
121294
+ }
121295
+ function isUrl(source) {
121296
+ return source.startsWith("http://") || source.startsWith("https://");
121297
+ }
121298
+ function isDataUri(source) {
121299
+ return source.startsWith("data:image/");
121300
+ }
121301
+ var import_sharp4, MAX_FILE_SIZE, ALLOWED_EXTENSIONS;
121302
+ var init_image_loader = __esm(() => {
121303
+ init_logger();
121304
+ init_errors();
121305
+ init_cloudflare_r2();
121306
+ import_sharp4 = __toESM(require_lib(), 1);
121307
+ MAX_FILE_SIZE = 10 * 1024 * 1024;
121308
+ ALLOWED_EXTENSIONS = [".png", ".jpg", ".jpeg", ".webp", ".gif", ".bmp", ".tiff"];
121309
+ });
121310
+
120846
121311
  // node_modules/stream-parser/node_modules/debug/node_modules/ms/index.js
120847
121312
  var require_ms = __commonJS((exports, module) => {
120848
121313
  var s = 1000;
@@ -121214,8 +121679,8 @@ var require_node2 = __commonJS((exports, module) => {
121214
121679
  }
121215
121680
  break;
121216
121681
  case "FILE":
121217
- var fs5 = __require("fs");
121218
- stream2 = new fs5.SyncWriteStream(fd2, { autoClose: false });
121682
+ var fs6 = __require("fs");
121683
+ stream2 = new fs6.SyncWriteStream(fd2, { autoClose: false });
121219
121684
  stream2._type = "fs";
121220
121685
  break;
121221
121686
  case "PIPE":
@@ -122974,8 +123439,8 @@ var require_node3 = __commonJS((exports, module) => {
122974
123439
  }
122975
123440
  break;
122976
123441
  case "FILE":
122977
- var fs5 = __require("fs");
122978
- stream2 = new fs5.SyncWriteStream(fd2, { autoClose: false });
123442
+ var fs6 = __require("fs");
123443
+ stream2 = new fs6.SyncWriteStream(fd2, { autoClose: false });
122979
123444
  stream2._type = "fs";
122980
123445
  break;
122981
123446
  case "PIPE":
@@ -123474,16 +123939,16 @@ var require_writer2 = __commonJS((exports, module) => {
123474
123939
 
123475
123940
  // node_modules/wav/lib/file-writer.js
123476
123941
  var require_file_writer = __commonJS((exports, module) => {
123477
- var fs5 = __require("fs");
123942
+ var fs6 = __require("fs");
123478
123943
  var Writer = require_writer2();
123479
123944
  var inherits = __require("util").inherits;
123480
123945
  module.exports = FileWriter;
123481
- function FileWriter(path4, opts) {
123946
+ function FileWriter(path5, opts) {
123482
123947
  if (!(this instanceof FileWriter))
123483
- return new FileWriter(path4, opts);
123948
+ return new FileWriter(path5, opts);
123484
123949
  Writer.call(this, opts);
123485
- this.path = path4;
123486
- this.file = fs5.createWriteStream(path4, opts);
123950
+ this.path = path5;
123951
+ this.file = fs6.createWriteStream(path5, opts);
123487
123952
  this.pipe(this.file);
123488
123953
  this.on("header", this._onHeader);
123489
123954
  }
@@ -123495,7 +123960,7 @@ var require_file_writer = __commonJS((exports, module) => {
123495
123960
  if (err)
123496
123961
  return self2.emit("error", err);
123497
123962
  fd = f;
123498
- fs5.write(fd, header, 0, header.length, 0, onWrite);
123963
+ fs6.write(fd, header, 0, header.length, 0, onWrite);
123499
123964
  }
123500
123965
  function onWrite(err, bytesWritten) {
123501
123966
  if (err)
@@ -123503,14 +123968,14 @@ var require_file_writer = __commonJS((exports, module) => {
123503
123968
  if (bytesWritten !== header.length) {
123504
123969
  return self2.emit("error", new Error('problem writing "header" data'));
123505
123970
  }
123506
- fs5.close(fd, onClose);
123971
+ fs6.close(fd, onClose);
123507
123972
  }
123508
123973
  function onClose(err) {
123509
123974
  if (err)
123510
123975
  return self2.emit("error", err);
123511
123976
  self2.emit("done");
123512
123977
  }
123513
- fs5.open(self2.path, "r+", onOpen);
123978
+ fs6.open(self2.path, "r+", onOpen);
123514
123979
  };
123515
123980
  });
123516
123981
 
@@ -132384,13 +132849,13 @@ var require_view = __commonJS((exports, module) => {
132384
132849
  * MIT Licensed
132385
132850
  */
132386
132851
  var debug = require_src3()("express:view");
132387
- var path5 = __require("node:path");
132388
- var fs5 = __require("node:fs");
132389
- var dirname2 = path5.dirname;
132390
- var basename = path5.basename;
132391
- var extname2 = path5.extname;
132392
- var join2 = path5.join;
132393
- var resolve = path5.resolve;
132852
+ var path6 = __require("node:path");
132853
+ var fs6 = __require("node:fs");
132854
+ var dirname2 = path6.dirname;
132855
+ var basename = path6.basename;
132856
+ var extname2 = path6.extname;
132857
+ var join2 = path6.join;
132858
+ var resolve = path6.resolve;
132394
132859
  module.exports = View;
132395
132860
  function View(name, options) {
132396
132861
  var opts = options || {};
@@ -132419,17 +132884,17 @@ var require_view = __commonJS((exports, module) => {
132419
132884
  this.path = this.lookup(fileName);
132420
132885
  }
132421
132886
  View.prototype.lookup = function lookup(name) {
132422
- var path6;
132887
+ var path7;
132423
132888
  var roots = [].concat(this.root);
132424
132889
  debug('lookup "%s"', name);
132425
- for (var i = 0;i < roots.length && !path6; i++) {
132890
+ for (var i = 0;i < roots.length && !path7; i++) {
132426
132891
  var root = roots[i];
132427
132892
  var loc = resolve(root, name);
132428
132893
  var dir = dirname2(loc);
132429
132894
  var file = basename(loc);
132430
- path6 = this.resolve(dir, file);
132895
+ path7 = this.resolve(dir, file);
132431
132896
  }
132432
- return path6;
132897
+ return path7;
132433
132898
  };
132434
132899
  View.prototype.render = function render(options, callback) {
132435
132900
  var sync = true;
@@ -132451,21 +132916,21 @@ var require_view = __commonJS((exports, module) => {
132451
132916
  };
132452
132917
  View.prototype.resolve = function resolve(dir, file) {
132453
132918
  var ext = this.ext;
132454
- var path6 = join2(dir, file);
132455
- var stat = tryStat(path6);
132919
+ var path7 = join2(dir, file);
132920
+ var stat = tryStat(path7);
132456
132921
  if (stat && stat.isFile()) {
132457
- return path6;
132922
+ return path7;
132458
132923
  }
132459
- path6 = join2(dir, basename(file, ext), "index" + ext);
132460
- stat = tryStat(path6);
132924
+ path7 = join2(dir, basename(file, ext), "index" + ext);
132925
+ stat = tryStat(path7);
132461
132926
  if (stat && stat.isFile()) {
132462
- return path6;
132927
+ return path7;
132463
132928
  }
132464
132929
  };
132465
- function tryStat(path6) {
132466
- debug('stat "%s"', path6);
132930
+ function tryStat(path7) {
132931
+ debug('stat "%s"', path7);
132467
132932
  try {
132468
- return fs5.statSync(path6);
132933
+ return fs6.statSync(path7);
132469
132934
  } catch (e) {
132470
132935
  return;
132471
132936
  }
@@ -133692,9 +134157,9 @@ var require_dist5 = __commonJS((exports) => {
133692
134157
  function consume(endType) {
133693
134158
  const tokens2 = [];
133694
134159
  while (true) {
133695
- const path5 = it.text();
133696
- if (path5)
133697
- tokens2.push({ type: "text", value: encodePath(path5) });
134160
+ const path6 = it.text();
134161
+ if (path6)
134162
+ tokens2.push({ type: "text", value: encodePath(path6) });
133698
134163
  const param = it.tryConsume("PARAM");
133699
134164
  if (param) {
133700
134165
  tokens2.push({
@@ -133726,16 +134191,16 @@ var require_dist5 = __commonJS((exports) => {
133726
134191
  const tokens = consume("END");
133727
134192
  return new TokenData(tokens);
133728
134193
  }
133729
- function compile(path5, options = {}) {
134194
+ function compile(path6, options = {}) {
133730
134195
  const { encode = encodeURIComponent, delimiter = DEFAULT_DELIMITER } = options;
133731
- const data = path5 instanceof TokenData ? path5 : parse(path5, options);
134196
+ const data = path6 instanceof TokenData ? path6 : parse(path6, options);
133732
134197
  const fn = tokensToFunction(data.tokens, delimiter, encode);
133733
134198
  return function path(data2 = {}) {
133734
- const [path6, ...missing] = fn(data2);
134199
+ const [path7, ...missing] = fn(data2);
133735
134200
  if (missing.length) {
133736
134201
  throw new TypeError(`Missing parameters: ${missing.join(", ")}`);
133737
134202
  }
133738
- return path6;
134203
+ return path7;
133739
134204
  };
133740
134205
  }
133741
134206
  function tokensToFunction(tokens, delimiter, encode) {
@@ -133791,9 +134256,9 @@ var require_dist5 = __commonJS((exports) => {
133791
134256
  return [encodeValue(value)];
133792
134257
  };
133793
134258
  }
133794
- function match(path5, options = {}) {
134259
+ function match(path6, options = {}) {
133795
134260
  const { decode = decodeURIComponent, delimiter = DEFAULT_DELIMITER } = options;
133796
- const { regexp, keys } = pathToRegexp(path5, options);
134261
+ const { regexp, keys } = pathToRegexp(path6, options);
133797
134262
  const decoders = keys.map((key) => {
133798
134263
  if (decode === false)
133799
134264
  return NOOP_VALUE;
@@ -133805,7 +134270,7 @@ var require_dist5 = __commonJS((exports) => {
133805
134270
  const m = regexp.exec(input);
133806
134271
  if (!m)
133807
134272
  return false;
133808
- const path6 = m[0];
134273
+ const path7 = m[0];
133809
134274
  const params = Object.create(null);
133810
134275
  for (let i = 1;i < m.length; i++) {
133811
134276
  if (m[i] === undefined)
@@ -133814,16 +134279,16 @@ var require_dist5 = __commonJS((exports) => {
133814
134279
  const decoder = decoders[i - 1];
133815
134280
  params[key.name] = decoder(m[i]);
133816
134281
  }
133817
- return { path: path6, params };
134282
+ return { path: path7, params };
133818
134283
  };
133819
134284
  }
133820
- function pathToRegexp(path5, options = {}) {
134285
+ function pathToRegexp(path6, options = {}) {
133821
134286
  const { delimiter = DEFAULT_DELIMITER, end = true, sensitive = false, trailing = true } = options;
133822
134287
  const keys = [];
133823
134288
  const sources = [];
133824
134289
  const flags = sensitive ? "" : "i";
133825
- const paths = Array.isArray(path5) ? path5 : [path5];
133826
- const items = paths.map((path6) => path6 instanceof TokenData ? path6 : parse(path6, options));
134290
+ const paths = Array.isArray(path6) ? path6 : [path6];
134291
+ const items = paths.map((path7) => path7 instanceof TokenData ? path7 : parse(path7, options));
133827
134292
  for (const { tokens } of items) {
133828
134293
  for (const seq of flatten(tokens, 0, [])) {
133829
134294
  const regexp2 = sequenceToRegExp(seq, delimiter, keys);
@@ -133936,18 +134401,18 @@ var require_layer = __commonJS((exports, module) => {
133936
134401
  var TRAILING_SLASH_REGEXP = /\/+$/;
133937
134402
  var MATCHING_GROUP_REGEXP = /\((?:\?<(.*?)>)?(?!\?)/g;
133938
134403
  module.exports = Layer;
133939
- function Layer(path5, options, fn) {
134404
+ function Layer(path6, options, fn) {
133940
134405
  if (!(this instanceof Layer)) {
133941
- return new Layer(path5, options, fn);
134406
+ return new Layer(path6, options, fn);
133942
134407
  }
133943
- debug("new %o", path5);
134408
+ debug("new %o", path6);
133944
134409
  const opts = options || {};
133945
134410
  this.handle = fn;
133946
134411
  this.keys = [];
133947
134412
  this.name = fn.name || "<anonymous>";
133948
134413
  this.params = undefined;
133949
134414
  this.path = undefined;
133950
- this.slash = path5 === "/" && opts.end === false;
134415
+ this.slash = path6 === "/" && opts.end === false;
133951
134416
  function matcher(_path) {
133952
134417
  if (_path instanceof RegExp) {
133953
134418
  const keys = [];
@@ -133986,7 +134451,7 @@ var require_layer = __commonJS((exports, module) => {
133986
134451
  decode: decodeParam
133987
134452
  });
133988
134453
  }
133989
- this.matchers = Array.isArray(path5) ? path5.map(matcher) : [matcher(path5)];
134454
+ this.matchers = Array.isArray(path6) ? path6.map(matcher) : [matcher(path6)];
133990
134455
  }
133991
134456
  Layer.prototype.handleError = function handleError(error, req, res, next) {
133992
134457
  const fn = this.handle;
@@ -134026,9 +134491,9 @@ var require_layer = __commonJS((exports, module) => {
134026
134491
  next(err);
134027
134492
  }
134028
134493
  };
134029
- Layer.prototype.match = function match(path5) {
134494
+ Layer.prototype.match = function match(path6) {
134030
134495
  let match;
134031
- if (path5 != null) {
134496
+ if (path6 != null) {
134032
134497
  if (this.slash) {
134033
134498
  this.params = {};
134034
134499
  this.path = "";
@@ -134036,7 +134501,7 @@ var require_layer = __commonJS((exports, module) => {
134036
134501
  }
134037
134502
  let i = 0;
134038
134503
  while (!match && i < this.matchers.length) {
134039
- match = this.matchers[i](path5);
134504
+ match = this.matchers[i](path6);
134040
134505
  i++;
134041
134506
  }
134042
134507
  }
@@ -134064,13 +134529,13 @@ var require_layer = __commonJS((exports, module) => {
134064
134529
  throw err;
134065
134530
  }
134066
134531
  }
134067
- function loosen(path5) {
134068
- if (path5 instanceof RegExp || path5 === "/") {
134069
- return path5;
134532
+ function loosen(path6) {
134533
+ if (path6 instanceof RegExp || path6 === "/") {
134534
+ return path6;
134070
134535
  }
134071
- return Array.isArray(path5) ? path5.map(function(p) {
134536
+ return Array.isArray(path6) ? path6.map(function(p) {
134072
134537
  return loosen(p);
134073
- }) : String(path5).replace(TRAILING_SLASH_REGEXP, "");
134538
+ }) : String(path6).replace(TRAILING_SLASH_REGEXP, "");
134074
134539
  }
134075
134540
  });
134076
134541
 
@@ -134089,9 +134554,9 @@ var require_route2 = __commonJS((exports, module) => {
134089
134554
  var flatten = Array.prototype.flat;
134090
134555
  var methods = METHODS.map((method) => method.toLowerCase());
134091
134556
  module.exports = Route;
134092
- function Route(path5) {
134093
- debug("new %o", path5);
134094
- this.path = path5;
134557
+ function Route(path6) {
134558
+ debug("new %o", path6);
134559
+ this.path = path6;
134095
134560
  this.stack = [];
134096
134561
  this.methods = Object.create(null);
134097
134562
  }
@@ -134301,8 +134766,8 @@ var require_router = __commonJS((exports, module) => {
134301
134766
  if (++sync > 100) {
134302
134767
  return setImmediate(next, err);
134303
134768
  }
134304
- const path5 = getPathname(req);
134305
- if (path5 == null) {
134769
+ const path6 = getPathname(req);
134770
+ if (path6 == null) {
134306
134771
  return done(layerError);
134307
134772
  }
134308
134773
  let layer;
@@ -134310,7 +134775,7 @@ var require_router = __commonJS((exports, module) => {
134310
134775
  let route;
134311
134776
  while (match !== true && idx < stack.length) {
134312
134777
  layer = stack[idx++];
134313
- match = matchLayer(layer, path5);
134778
+ match = matchLayer(layer, path6);
134314
134779
  route = layer.route;
134315
134780
  if (typeof match !== "boolean") {
134316
134781
  layerError = layerError || match;
@@ -134348,18 +134813,18 @@ var require_router = __commonJS((exports, module) => {
134348
134813
  } else if (route) {
134349
134814
  layer.handleRequest(req, res, next);
134350
134815
  } else {
134351
- trimPrefix(layer, layerError, layerPath, path5);
134816
+ trimPrefix(layer, layerError, layerPath, path6);
134352
134817
  }
134353
134818
  sync = 0;
134354
134819
  });
134355
134820
  }
134356
- function trimPrefix(layer, layerError, layerPath, path5) {
134821
+ function trimPrefix(layer, layerError, layerPath, path6) {
134357
134822
  if (layerPath.length !== 0) {
134358
- if (layerPath !== path5.substring(0, layerPath.length)) {
134823
+ if (layerPath !== path6.substring(0, layerPath.length)) {
134359
134824
  next(layerError);
134360
134825
  return;
134361
134826
  }
134362
- const c = path5[layerPath.length];
134827
+ const c = path6[layerPath.length];
134363
134828
  if (c && c !== "/") {
134364
134829
  next(layerError);
134365
134830
  return;
@@ -134383,7 +134848,7 @@ var require_router = __commonJS((exports, module) => {
134383
134848
  };
134384
134849
  Router.prototype.use = function use(handler) {
134385
134850
  let offset = 0;
134386
- let path5 = "/";
134851
+ let path6 = "/";
134387
134852
  if (typeof handler !== "function") {
134388
134853
  let arg = handler;
134389
134854
  while (Array.isArray(arg) && arg.length !== 0) {
@@ -134391,7 +134856,7 @@ var require_router = __commonJS((exports, module) => {
134391
134856
  }
134392
134857
  if (typeof arg !== "function") {
134393
134858
  offset = 1;
134394
- path5 = handler;
134859
+ path6 = handler;
134395
134860
  }
134396
134861
  }
134397
134862
  const callbacks = flatten.call(slice.call(arguments, offset), Infinity);
@@ -134403,8 +134868,8 @@ var require_router = __commonJS((exports, module) => {
134403
134868
  if (typeof fn !== "function") {
134404
134869
  throw new TypeError("argument handler must be a function");
134405
134870
  }
134406
- debug("use %o %s", path5, fn.name || "<anonymous>");
134407
- const layer = new Layer(path5, {
134871
+ debug("use %o %s", path6, fn.name || "<anonymous>");
134872
+ const layer = new Layer(path6, {
134408
134873
  sensitive: this.caseSensitive,
134409
134874
  strict: false,
134410
134875
  end: false
@@ -134414,9 +134879,9 @@ var require_router = __commonJS((exports, module) => {
134414
134879
  }
134415
134880
  return this;
134416
134881
  };
134417
- Router.prototype.route = function route(path5) {
134418
- const route = new Route(path5);
134419
- const layer = new Layer(path5, {
134882
+ Router.prototype.route = function route(path6) {
134883
+ const route = new Route(path6);
134884
+ const layer = new Layer(path6, {
134420
134885
  sensitive: this.caseSensitive,
134421
134886
  strict: this.strict,
134422
134887
  end: true
@@ -134429,8 +134894,8 @@ var require_router = __commonJS((exports, module) => {
134429
134894
  return route;
134430
134895
  };
134431
134896
  methods.concat("all").forEach(function(method) {
134432
- Router.prototype[method] = function(path5) {
134433
- const route = this.route(path5);
134897
+ Router.prototype[method] = function(path6) {
134898
+ const route = this.route(path6);
134434
134899
  route[method].apply(route, slice.call(arguments, 1));
134435
134900
  return this;
134436
134901
  };
@@ -134459,9 +134924,9 @@ var require_router = __commonJS((exports, module) => {
134459
134924
  const fqdnIndex = url.substring(0, pathLength).indexOf("://");
134460
134925
  return fqdnIndex !== -1 ? url.substring(0, url.indexOf("/", 3 + fqdnIndex)) : undefined;
134461
134926
  }
134462
- function matchLayer(layer, path5) {
134927
+ function matchLayer(layer, path6) {
134463
134928
  try {
134464
- return layer.match(path5);
134929
+ return layer.match(path6);
134465
134930
  } catch (err) {
134466
134931
  return err;
134467
134932
  }
@@ -134694,7 +135159,7 @@ var require_application = __commonJS((exports, module) => {
134694
135159
  };
134695
135160
  app.use = function use(fn) {
134696
135161
  var offset = 0;
134697
- var path5 = "/";
135162
+ var path6 = "/";
134698
135163
  if (typeof fn !== "function") {
134699
135164
  var arg = fn;
134700
135165
  while (Array.isArray(arg) && arg.length !== 0) {
@@ -134702,7 +135167,7 @@ var require_application = __commonJS((exports, module) => {
134702
135167
  }
134703
135168
  if (typeof arg !== "function") {
134704
135169
  offset = 1;
134705
- path5 = fn;
135170
+ path6 = fn;
134706
135171
  }
134707
135172
  }
134708
135173
  var fns = flatten.call(slice.call(arguments, offset), Infinity);
@@ -134712,12 +135177,12 @@ var require_application = __commonJS((exports, module) => {
134712
135177
  var router = this.router;
134713
135178
  fns.forEach(function(fn2) {
134714
135179
  if (!fn2 || !fn2.handle || !fn2.set) {
134715
- return router.use(path5, fn2);
135180
+ return router.use(path6, fn2);
134716
135181
  }
134717
- debug(".use app under %s", path5);
134718
- fn2.mountpath = path5;
135182
+ debug(".use app under %s", path6);
135183
+ fn2.mountpath = path6;
134719
135184
  fn2.parent = this;
134720
- router.use(path5, function mounted_app(req, res, next) {
135185
+ router.use(path6, function mounted_app(req, res, next) {
134721
135186
  var orig = req.app;
134722
135187
  fn2.handle(req, res, function(err) {
134723
135188
  Object.setPrototypeOf(req, orig.request);
@@ -134729,8 +135194,8 @@ var require_application = __commonJS((exports, module) => {
134729
135194
  }, this);
134730
135195
  return this;
134731
135196
  };
134732
- app.route = function route(path5) {
134733
- return this.router.route(path5);
135197
+ app.route = function route(path6) {
135198
+ return this.router.route(path6);
134734
135199
  };
134735
135200
  app.engine = function engine(ext, fn) {
134736
135201
  if (typeof fn !== "function") {
@@ -134789,17 +135254,17 @@ var require_application = __commonJS((exports, module) => {
134789
135254
  return this.set(setting, false);
134790
135255
  };
134791
135256
  methods.forEach(function(method) {
134792
- app[method] = function(path5) {
135257
+ app[method] = function(path6) {
134793
135258
  if (method === "get" && arguments.length === 1) {
134794
- return this.set(path5);
135259
+ return this.set(path6);
134795
135260
  }
134796
- var route = this.route(path5);
135261
+ var route = this.route(path6);
134797
135262
  route[method].apply(route, slice.call(arguments, 1));
134798
135263
  return this;
134799
135264
  };
134800
135265
  });
134801
- app.all = function all(path5) {
134802
- var route = this.route(path5);
135266
+ app.all = function all(path6) {
135267
+ var route = this.route(path6);
134803
135268
  var args = slice.call(arguments, 1);
134804
135269
  for (var i = 0;i < methods.length; i++) {
134805
135270
  route[methods[i]].apply(route, args);
@@ -136207,32 +136672,32 @@ var require_send = __commonJS((exports, module) => {
136207
136672
  var escapeHtml = require_escape_html();
136208
136673
  var etag = require_etag();
136209
136674
  var fresh = require_fresh();
136210
- var fs5 = __require("fs");
136675
+ var fs6 = __require("fs");
136211
136676
  var mime2 = require_mime_types();
136212
136677
  var ms = require_ms3();
136213
136678
  var onFinished = require_on_finished();
136214
136679
  var parseRange = require_range_parser();
136215
- var path5 = __require("path");
136680
+ var path6 = __require("path");
136216
136681
  var statuses = require_statuses2();
136217
136682
  var Stream = __require("stream");
136218
136683
  var util3 = __require("util");
136219
- var extname2 = path5.extname;
136220
- var join2 = path5.join;
136221
- var normalize = path5.normalize;
136222
- var resolve = path5.resolve;
136223
- var sep = path5.sep;
136684
+ var extname2 = path6.extname;
136685
+ var join2 = path6.join;
136686
+ var normalize = path6.normalize;
136687
+ var resolve = path6.resolve;
136688
+ var sep = path6.sep;
136224
136689
  var BYTES_RANGE_REGEXP = /^ *bytes=/;
136225
136690
  var MAX_MAXAGE = 60 * 60 * 24 * 365 * 1000;
136226
136691
  var UP_PATH_REGEXP = /(?:^|[\\/])\.\.(?:[\\/]|$)/;
136227
136692
  module.exports = send;
136228
- function send(req, path6, options) {
136229
- return new SendStream(req, path6, options);
136693
+ function send(req, path7, options) {
136694
+ return new SendStream(req, path7, options);
136230
136695
  }
136231
- function SendStream(req, path6, options) {
136696
+ function SendStream(req, path7, options) {
136232
136697
  Stream.call(this);
136233
136698
  var opts = options || {};
136234
136699
  this.options = opts;
136235
- this.path = path6;
136700
+ this.path = path7;
136236
136701
  this.req = req;
136237
136702
  this._acceptRanges = opts.acceptRanges !== undefined ? Boolean(opts.acceptRanges) : true;
136238
136703
  this._cacheControl = opts.cacheControl !== undefined ? Boolean(opts.cacheControl) : true;
@@ -136346,10 +136811,10 @@ var require_send = __commonJS((exports, module) => {
136346
136811
  var lastModified = this.res.getHeader("Last-Modified");
136347
136812
  return parseHttpDate(lastModified) <= parseHttpDate(ifRange);
136348
136813
  };
136349
- SendStream.prototype.redirect = function redirect(path6) {
136814
+ SendStream.prototype.redirect = function redirect(path7) {
136350
136815
  var res = this.res;
136351
136816
  if (hasListeners(this, "directory")) {
136352
- this.emit("directory", res, path6);
136817
+ this.emit("directory", res, path7);
136353
136818
  return;
136354
136819
  }
136355
136820
  if (this.hasTrailingSlash()) {
@@ -136369,38 +136834,38 @@ var require_send = __commonJS((exports, module) => {
136369
136834
  SendStream.prototype.pipe = function pipe(res) {
136370
136835
  var root = this._root;
136371
136836
  this.res = res;
136372
- var path6 = decode(this.path);
136373
- if (path6 === -1) {
136837
+ var path7 = decode(this.path);
136838
+ if (path7 === -1) {
136374
136839
  this.error(400);
136375
136840
  return res;
136376
136841
  }
136377
- if (~path6.indexOf("\x00")) {
136842
+ if (~path7.indexOf("\x00")) {
136378
136843
  this.error(400);
136379
136844
  return res;
136380
136845
  }
136381
136846
  var parts;
136382
136847
  if (root !== null) {
136383
- if (path6) {
136384
- path6 = normalize("." + sep + path6);
136848
+ if (path7) {
136849
+ path7 = normalize("." + sep + path7);
136385
136850
  }
136386
- if (UP_PATH_REGEXP.test(path6)) {
136387
- debug('malicious path "%s"', path6);
136851
+ if (UP_PATH_REGEXP.test(path7)) {
136852
+ debug('malicious path "%s"', path7);
136388
136853
  this.error(403);
136389
136854
  return res;
136390
136855
  }
136391
- parts = path6.split(sep);
136392
- path6 = normalize(join2(root, path6));
136856
+ parts = path7.split(sep);
136857
+ path7 = normalize(join2(root, path7));
136393
136858
  } else {
136394
- if (UP_PATH_REGEXP.test(path6)) {
136395
- debug('malicious path "%s"', path6);
136859
+ if (UP_PATH_REGEXP.test(path7)) {
136860
+ debug('malicious path "%s"', path7);
136396
136861
  this.error(403);
136397
136862
  return res;
136398
136863
  }
136399
- parts = normalize(path6).split(sep);
136400
- path6 = resolve(path6);
136864
+ parts = normalize(path7).split(sep);
136865
+ path7 = resolve(path7);
136401
136866
  }
136402
136867
  if (containsDotFile(parts)) {
136403
- debug('%s dotfile "%s"', this._dotfiles, path6);
136868
+ debug('%s dotfile "%s"', this._dotfiles, path7);
136404
136869
  switch (this._dotfiles) {
136405
136870
  case "allow":
136406
136871
  break;
@@ -136414,13 +136879,13 @@ var require_send = __commonJS((exports, module) => {
136414
136879
  }
136415
136880
  }
136416
136881
  if (this._index.length && this.hasTrailingSlash()) {
136417
- this.sendIndex(path6);
136882
+ this.sendIndex(path7);
136418
136883
  return res;
136419
136884
  }
136420
- this.sendFile(path6);
136885
+ this.sendFile(path7);
136421
136886
  return res;
136422
136887
  };
136423
- SendStream.prototype.send = function send(path6, stat) {
136888
+ SendStream.prototype.send = function send(path7, stat) {
136424
136889
  var len = stat.size;
136425
136890
  var options = this.options;
136426
136891
  var opts = {};
@@ -136432,9 +136897,9 @@ var require_send = __commonJS((exports, module) => {
136432
136897
  this.headersAlreadySent();
136433
136898
  return;
136434
136899
  }
136435
- debug('pipe "%s"', path6);
136436
- this.setHeader(path6, stat);
136437
- this.type(path6);
136900
+ debug('pipe "%s"', path7);
136901
+ this.setHeader(path7, stat);
136902
+ this.type(path7);
136438
136903
  if (this.isConditionalGET()) {
136439
136904
  if (this.isPreconditionFailure()) {
136440
136905
  this.error(412);
@@ -136484,33 +136949,33 @@ var require_send = __commonJS((exports, module) => {
136484
136949
  res.end();
136485
136950
  return;
136486
136951
  }
136487
- this.stream(path6, opts);
136952
+ this.stream(path7, opts);
136488
136953
  };
136489
- SendStream.prototype.sendFile = function sendFile(path6) {
136954
+ SendStream.prototype.sendFile = function sendFile(path7) {
136490
136955
  var i = 0;
136491
136956
  var self2 = this;
136492
- debug('stat "%s"', path6);
136493
- fs5.stat(path6, function onstat(err, stat) {
136494
- var pathEndsWithSep = path6[path6.length - 1] === sep;
136495
- if (err && err.code === "ENOENT" && !extname2(path6) && !pathEndsWithSep) {
136957
+ debug('stat "%s"', path7);
136958
+ fs6.stat(path7, function onstat(err, stat) {
136959
+ var pathEndsWithSep = path7[path7.length - 1] === sep;
136960
+ if (err && err.code === "ENOENT" && !extname2(path7) && !pathEndsWithSep) {
136496
136961
  return next(err);
136497
136962
  }
136498
136963
  if (err)
136499
136964
  return self2.onStatError(err);
136500
136965
  if (stat.isDirectory())
136501
- return self2.redirect(path6);
136966
+ return self2.redirect(path7);
136502
136967
  if (pathEndsWithSep)
136503
136968
  return self2.error(404);
136504
- self2.emit("file", path6, stat);
136505
- self2.send(path6, stat);
136969
+ self2.emit("file", path7, stat);
136970
+ self2.send(path7, stat);
136506
136971
  });
136507
136972
  function next(err) {
136508
136973
  if (self2._extensions.length <= i) {
136509
136974
  return err ? self2.onStatError(err) : self2.error(404);
136510
136975
  }
136511
- var p = path6 + "." + self2._extensions[i++];
136976
+ var p = path7 + "." + self2._extensions[i++];
136512
136977
  debug('stat "%s"', p);
136513
- fs5.stat(p, function(err2, stat) {
136978
+ fs6.stat(p, function(err2, stat) {
136514
136979
  if (err2)
136515
136980
  return next(err2);
136516
136981
  if (stat.isDirectory())
@@ -136520,7 +136985,7 @@ var require_send = __commonJS((exports, module) => {
136520
136985
  });
136521
136986
  }
136522
136987
  };
136523
- SendStream.prototype.sendIndex = function sendIndex(path6) {
136988
+ SendStream.prototype.sendIndex = function sendIndex(path7) {
136524
136989
  var i = -1;
136525
136990
  var self2 = this;
136526
136991
  function next(err) {
@@ -136529,9 +136994,9 @@ var require_send = __commonJS((exports, module) => {
136529
136994
  return self2.onStatError(err);
136530
136995
  return self2.error(404);
136531
136996
  }
136532
- var p = join2(path6, self2._index[i]);
136997
+ var p = join2(path7, self2._index[i]);
136533
136998
  debug('stat "%s"', p);
136534
- fs5.stat(p, function(err2, stat) {
136999
+ fs6.stat(p, function(err2, stat) {
136535
137000
  if (err2)
136536
137001
  return next(err2);
136537
137002
  if (stat.isDirectory())
@@ -136542,10 +137007,10 @@ var require_send = __commonJS((exports, module) => {
136542
137007
  }
136543
137008
  next();
136544
137009
  };
136545
- SendStream.prototype.stream = function stream(path6, options) {
137010
+ SendStream.prototype.stream = function stream(path7, options) {
136546
137011
  var self2 = this;
136547
137012
  var res = this.res;
136548
- var stream = fs5.createReadStream(path6, options);
137013
+ var stream = fs6.createReadStream(path7, options);
136549
137014
  this.emit("stream", stream);
136550
137015
  stream.pipe(res);
136551
137016
  function cleanup() {
@@ -136560,18 +137025,18 @@ var require_send = __commonJS((exports, module) => {
136560
137025
  self2.emit("end");
136561
137026
  });
136562
137027
  };
136563
- SendStream.prototype.type = function type(path6) {
137028
+ SendStream.prototype.type = function type(path7) {
136564
137029
  var res = this.res;
136565
137030
  if (res.getHeader("Content-Type"))
136566
137031
  return;
136567
- var ext = extname2(path6);
137032
+ var ext = extname2(path7);
136568
137033
  var type = mime2.contentType(ext) || "application/octet-stream";
136569
137034
  debug("content-type %s", type);
136570
137035
  res.setHeader("Content-Type", type);
136571
137036
  };
136572
- SendStream.prototype.setHeader = function setHeader(path6, stat) {
137037
+ SendStream.prototype.setHeader = function setHeader(path7, stat) {
136573
137038
  var res = this.res;
136574
- this.emit("headers", res, path6, stat);
137039
+ this.emit("headers", res, path7, stat);
136575
137040
  if (this._acceptRanges && !res.getHeader("Accept-Ranges")) {
136576
137041
  debug("accept ranges");
136577
137042
  res.setHeader("Accept-Ranges", "bytes");
@@ -136639,9 +137104,9 @@ var require_send = __commonJS((exports, module) => {
136639
137104
  }
136640
137105
  return err instanceof Error ? createError(status, err, { expose: false }) : createError(status, err);
136641
137106
  }
136642
- function decode(path6) {
137107
+ function decode(path7) {
136643
137108
  try {
136644
- return decodeURIComponent(path6);
137109
+ return decodeURIComponent(path7);
136645
137110
  } catch (err) {
136646
137111
  return -1;
136647
137112
  }
@@ -136789,7 +137254,7 @@ var require_response = __commonJS((exports, module) => {
136789
137254
  var http = __require("node:http");
136790
137255
  var onFinished = require_on_finished();
136791
137256
  var mime2 = require_mime_types();
136792
- var path5 = __require("node:path");
137257
+ var path6 = __require("node:path");
136793
137258
  var pathIsAbsolute = __require("node:path").isAbsolute;
136794
137259
  var statuses = require_statuses2();
136795
137260
  var sign = require_cookie_signature().sign;
@@ -136798,8 +137263,8 @@ var require_response = __commonJS((exports, module) => {
136798
137263
  var setCharset = require_utils5().setCharset;
136799
137264
  var cookie = require_cookie();
136800
137265
  var send = require_send();
136801
- var extname2 = path5.extname;
136802
- var resolve = path5.resolve;
137266
+ var extname2 = path6.extname;
137267
+ var resolve = path6.resolve;
136803
137268
  var vary = require_vary();
136804
137269
  var res = Object.create(http.ServerResponse.prototype);
136805
137270
  module.exports = res;
@@ -136945,26 +137410,26 @@ var require_response = __commonJS((exports, module) => {
136945
137410
  this.type("txt");
136946
137411
  return this.send(body);
136947
137412
  };
136948
- res.sendFile = function sendFile(path6, options, callback) {
137413
+ res.sendFile = function sendFile(path7, options, callback) {
136949
137414
  var done = callback;
136950
137415
  var req = this.req;
136951
137416
  var res2 = this;
136952
137417
  var next = req.next;
136953
137418
  var opts = options || {};
136954
- if (!path6) {
137419
+ if (!path7) {
136955
137420
  throw new TypeError("path argument is required to res.sendFile");
136956
137421
  }
136957
- if (typeof path6 !== "string") {
137422
+ if (typeof path7 !== "string") {
136958
137423
  throw new TypeError("path must be a string to res.sendFile");
136959
137424
  }
136960
137425
  if (typeof options === "function") {
136961
137426
  done = options;
136962
137427
  opts = {};
136963
137428
  }
136964
- if (!opts.root && !pathIsAbsolute(path6)) {
137429
+ if (!opts.root && !pathIsAbsolute(path7)) {
136965
137430
  throw new TypeError("path must be absolute or specify root to res.sendFile");
136966
137431
  }
136967
- var pathname = encodeURI(path6);
137432
+ var pathname = encodeURI(path7);
136968
137433
  opts.etag = this.app.enabled("etag");
136969
137434
  var file = send(req, pathname, opts);
136970
137435
  sendfile(res2, file, opts, function(err) {
@@ -136977,7 +137442,7 @@ var require_response = __commonJS((exports, module) => {
136977
137442
  }
136978
137443
  });
136979
137444
  };
136980
- res.download = function download(path6, filename, options, callback) {
137445
+ res.download = function download(path7, filename, options, callback) {
136981
137446
  var done = callback;
136982
137447
  var name = filename;
136983
137448
  var opts = options || null;
@@ -136994,7 +137459,7 @@ var require_response = __commonJS((exports, module) => {
136994
137459
  opts = filename;
136995
137460
  }
136996
137461
  var headers = {
136997
- "Content-Disposition": contentDisposition(name || path6)
137462
+ "Content-Disposition": contentDisposition(name || path7)
136998
137463
  };
136999
137464
  if (opts && opts.headers) {
137000
137465
  var keys = Object.keys(opts.headers);
@@ -137007,7 +137472,7 @@ var require_response = __commonJS((exports, module) => {
137007
137472
  }
137008
137473
  opts = Object.create(opts);
137009
137474
  opts.headers = headers;
137010
- var fullPath = !opts.root ? resolve(path6) : path6;
137475
+ var fullPath = !opts.root ? resolve(path7) : path7;
137011
137476
  return this.sendFile(fullPath, opts, done);
137012
137477
  };
137013
137478
  res.contentType = res.type = function contentType(type) {
@@ -137293,11 +137758,11 @@ var require_serve_static = __commonJS((exports, module) => {
137293
137758
  }
137294
137759
  var forwardError = !fallthrough;
137295
137760
  var originalUrl = parseUrl.original(req);
137296
- var path5 = parseUrl(req).pathname;
137297
- if (path5 === "/" && originalUrl.pathname.substr(-1) !== "/") {
137298
- path5 = "";
137761
+ var path6 = parseUrl(req).pathname;
137762
+ if (path6 === "/" && originalUrl.pathname.substr(-1) !== "/") {
137763
+ path6 = "";
137299
137764
  }
137300
- var stream = send(req, path5, opts);
137765
+ var stream = send(req, path6, opts);
137301
137766
  stream.on("directory", onDirectory);
137302
137767
  if (setHeaders) {
137303
137768
  stream.on("headers", setHeaders);
@@ -138602,8 +139067,8 @@ var require_node5 = __commonJS((exports, module) => {
138602
139067
  }
138603
139068
  break;
138604
139069
  case "FILE":
138605
- var fs5 = __require("fs");
138606
- stream2 = new fs5.SyncWriteStream(fd2, { autoClose: false });
139070
+ var fs6 = __require("fs");
139071
+ stream2 = new fs6.SyncWriteStream(fd2, { autoClose: false });
138607
139072
  stream2._type = "fs";
138608
139073
  break;
138609
139074
  case "PIPE":
@@ -147645,11 +148110,11 @@ var require_mime_types2 = __commonJS((exports) => {
147645
148110
  }
147646
148111
  return exts[0];
147647
148112
  }
147648
- function lookup(path5) {
147649
- if (!path5 || typeof path5 !== "string") {
148113
+ function lookup(path6) {
148114
+ if (!path6 || typeof path6 !== "string") {
147650
148115
  return false;
147651
148116
  }
147652
- var extension2 = extname2("x." + path5).toLowerCase().substr(1);
148117
+ var extension2 = extname2("x." + path6).toLowerCase().substr(1);
147653
148118
  if (!extension2) {
147654
148119
  return false;
147655
148120
  }
@@ -148156,18 +148621,18 @@ var require_utils6 = __commonJS((exports, module) => {
148156
148621
  if (decode)
148157
148622
  return decode(data, hint);
148158
148623
  }
148159
- function basename(path5) {
148160
- if (typeof path5 !== "string")
148624
+ function basename(path6) {
148625
+ if (typeof path6 !== "string")
148161
148626
  return "";
148162
- for (let i = path5.length - 1;i >= 0; --i) {
148163
- switch (path5.charCodeAt(i)) {
148627
+ for (let i = path6.length - 1;i >= 0; --i) {
148628
+ switch (path6.charCodeAt(i)) {
148164
148629
  case 47:
148165
148630
  case 92:
148166
- path5 = path5.slice(i + 1);
148167
- return path5 === ".." || path5 === "." ? "" : path5;
148631
+ path6 = path6.slice(i + 1);
148632
+ return path6 === ".." || path6 === "." ? "" : path6;
148168
148633
  }
148169
148634
  }
148170
- return path5 === ".." || path5 === "." ? "" : path5;
148635
+ return path6 === ".." || path6 === "." ? "" : path6;
148171
148636
  }
148172
148637
  var TOKEN = [
148173
148638
  0,
@@ -151944,8 +152409,8 @@ var require_make_middleware = __commonJS((exports, module) => {
151944
152409
 
151945
152410
  // node_modules/mkdirp/index.js
151946
152411
  var require_mkdirp = __commonJS((exports, module) => {
151947
- var path5 = __require("path");
151948
- var fs5 = __require("fs");
152412
+ var path6 = __require("path");
152413
+ var fs6 = __require("fs");
151949
152414
  var _0777 = parseInt("0777", 8);
151950
152415
  module.exports = mkdirP.mkdirp = mkdirP.mkdirP = mkdirP;
151951
152416
  function mkdirP(p, opts, f, made) {
@@ -151956,14 +152421,14 @@ var require_mkdirp = __commonJS((exports, module) => {
151956
152421
  opts = { mode: opts };
151957
152422
  }
151958
152423
  var mode = opts.mode;
151959
- var xfs = opts.fs || fs5;
152424
+ var xfs = opts.fs || fs6;
151960
152425
  if (mode === undefined) {
151961
152426
  mode = _0777;
151962
152427
  }
151963
152428
  if (!made)
151964
152429
  made = null;
151965
152430
  var cb = f || function() {};
151966
- p = path5.resolve(p);
152431
+ p = path6.resolve(p);
151967
152432
  xfs.mkdir(p, mode, function(er) {
151968
152433
  if (!er) {
151969
152434
  made = made || p;
@@ -151971,9 +152436,9 @@ var require_mkdirp = __commonJS((exports, module) => {
151971
152436
  }
151972
152437
  switch (er.code) {
151973
152438
  case "ENOENT":
151974
- if (path5.dirname(p) === p)
152439
+ if (path6.dirname(p) === p)
151975
152440
  return cb(er);
151976
- mkdirP(path5.dirname(p), opts, function(er2, made2) {
152441
+ mkdirP(path6.dirname(p), opts, function(er2, made2) {
151977
152442
  if (er2)
151978
152443
  cb(er2, made2);
151979
152444
  else
@@ -151996,20 +152461,20 @@ var require_mkdirp = __commonJS((exports, module) => {
151996
152461
  opts = { mode: opts };
151997
152462
  }
151998
152463
  var mode = opts.mode;
151999
- var xfs = opts.fs || fs5;
152464
+ var xfs = opts.fs || fs6;
152000
152465
  if (mode === undefined) {
152001
152466
  mode = _0777;
152002
152467
  }
152003
152468
  if (!made)
152004
152469
  made = null;
152005
- p = path5.resolve(p);
152470
+ p = path6.resolve(p);
152006
152471
  try {
152007
152472
  xfs.mkdirSync(p, mode);
152008
152473
  made = made || p;
152009
152474
  } catch (err0) {
152010
152475
  switch (err0.code) {
152011
152476
  case "ENOENT":
152012
- made = sync(path5.dirname(p), opts, made);
152477
+ made = sync(path6.dirname(p), opts, made);
152013
152478
  sync(p, opts, made);
152014
152479
  break;
152015
152480
  default:
@@ -152030,9 +152495,9 @@ var require_mkdirp = __commonJS((exports, module) => {
152030
152495
 
152031
152496
  // node_modules/multer/storage/disk.js
152032
152497
  var require_disk = __commonJS((exports, module) => {
152033
- var fs5 = __require("fs");
152498
+ var fs6 = __require("fs");
152034
152499
  var os2 = __require("os");
152035
- var path5 = __require("path");
152500
+ var path6 = __require("path");
152036
152501
  var crypto = __require("crypto");
152037
152502
  var mkdirp = require_mkdirp();
152038
152503
  function getFilename(req, file, cb) {
@@ -152062,8 +152527,8 @@ var require_disk = __commonJS((exports, module) => {
152062
152527
  that.getFilename(req, file, function(err2, filename) {
152063
152528
  if (err2)
152064
152529
  return cb(err2);
152065
- var finalPath = path5.join(destination, filename);
152066
- var outStream = fs5.createWriteStream(finalPath);
152530
+ var finalPath = path6.join(destination, filename);
152531
+ var outStream = fs6.createWriteStream(finalPath);
152067
152532
  file.stream.pipe(outStream);
152068
152533
  outStream.on("error", cb);
152069
152534
  outStream.on("finish", function() {
@@ -152078,11 +152543,11 @@ var require_disk = __commonJS((exports, module) => {
152078
152543
  });
152079
152544
  };
152080
152545
  DiskStorage.prototype._removeFile = function _removeFile(req, file, cb) {
152081
- var path6 = file.path;
152546
+ var path7 = file.path;
152082
152547
  delete file.destination;
152083
152548
  delete file.filename;
152084
152549
  delete file.path;
152085
- fs5.unlink(path6, cb);
152550
+ fs6.unlink(path7, cb);
152086
152551
  };
152087
152552
  module.exports = function(opts) {
152088
152553
  return new DiskStorage(opts);
@@ -162725,232 +163190,10 @@ function extractElementType(line) {
162725
163190
  return "element";
162726
163191
  }
162727
163192
 
162728
- // src/utils/logger.ts
162729
- class Logger {
162730
- level;
162731
- constructor() {
162732
- this.level = process.env.LOG_LEVEL || "info";
162733
- }
162734
- shouldLog(level) {
162735
- const levels = ["debug", "info", "warn", "error"];
162736
- return levels.indexOf(level) >= levels.indexOf(this.level);
162737
- }
162738
- format(level, message, ...args) {
162739
- const timestamp = new Date().toISOString();
162740
- const formatted = `[${timestamp}] [${level.toUpperCase()}] ${message}`;
162741
- if (args.length > 0) {
162742
- return `${formatted} ${JSON.stringify(args)}`;
162743
- }
162744
- return formatted;
162745
- }
162746
- debug(message, ...args) {
162747
- if (this.shouldLog("debug")) {
162748
- console.error(this.format("debug", message, ...args));
162749
- }
162750
- }
162751
- info(message, ...args) {
162752
- if (this.shouldLog("info")) {
162753
- console.error(this.format("info", message, ...args));
162754
- }
162755
- }
162756
- warn(message, ...args) {
162757
- if (this.shouldLog("warn")) {
162758
- console.error(this.format("warn", message, ...args));
162759
- }
162760
- }
162761
- error(message, ...args) {
162762
- if (this.shouldLog("error")) {
162763
- console.error(this.format("error", message, ...args));
162764
- }
162765
- }
162766
- }
162767
- var logger2 = new Logger;
162768
-
162769
- // src/utils/errors.ts
162770
- class HumanMCPError extends Error {
162771
- code;
162772
- statusCode;
162773
- constructor(message, code, statusCode) {
162774
- super(message);
162775
- this.code = code;
162776
- this.statusCode = statusCode;
162777
- this.name = "HumanMCPError";
162778
- }
162779
- }
162780
-
162781
- class ValidationError extends HumanMCPError {
162782
- constructor(message) {
162783
- super(message, "VALIDATION_ERROR", 400);
162784
- }
162785
- }
162786
-
162787
- class ProcessingError extends HumanMCPError {
162788
- constructor(message) {
162789
- super(message, "PROCESSING_ERROR", 500);
162790
- }
162791
- }
162792
-
162793
- class APIError extends HumanMCPError {
162794
- constructor(message, statusCode = 500) {
162795
- super(message, "API_ERROR", statusCode);
162796
- }
162797
- }
162798
- function handleError(error) {
162799
- if (error instanceof HumanMCPError) {
162800
- return error;
162801
- }
162802
- if (error instanceof Error) {
162803
- return new ProcessingError(error.message);
162804
- }
162805
- return new ProcessingError("An unknown error occurred");
162806
- }
162807
-
162808
- // src/utils/cloudflare-r2.ts
162809
- var import_client_s3 = __toESM(require_dist_cjs72(), 1);
162810
-
162811
- // node_modules/uuid/dist-node/stringify.js
162812
- var byteToHex = [];
162813
- for (let i = 0;i < 256; ++i) {
162814
- byteToHex.push((i + 256).toString(16).slice(1));
162815
- }
162816
- function unsafeStringify(arr, offset = 0) {
162817
- return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();
162818
- }
162819
-
162820
- // node_modules/uuid/dist-node/rng.js
162821
- import { randomFillSync } from "node:crypto";
162822
- var rnds8Pool = new Uint8Array(256);
162823
- var poolPtr = rnds8Pool.length;
162824
- function rng() {
162825
- if (poolPtr > rnds8Pool.length - 16) {
162826
- randomFillSync(rnds8Pool);
162827
- poolPtr = 0;
162828
- }
162829
- return rnds8Pool.slice(poolPtr, poolPtr += 16);
162830
- }
162831
-
162832
- // node_modules/uuid/dist-node/native.js
162833
- import { randomUUID } from "node:crypto";
162834
- var native_default = { randomUUID };
162835
-
162836
- // node_modules/uuid/dist-node/v4.js
162837
- function _v4(options, buf, offset) {
162838
- options = options || {};
162839
- const rnds = options.random ?? options.rng?.() ?? rng();
162840
- if (rnds.length < 16) {
162841
- throw new Error("Random bytes length must be >= 16");
162842
- }
162843
- rnds[6] = rnds[6] & 15 | 64;
162844
- rnds[8] = rnds[8] & 63 | 128;
162845
- if (buf) {
162846
- offset = offset || 0;
162847
- if (offset < 0 || offset + 16 > buf.length) {
162848
- throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`);
162849
- }
162850
- for (let i = 0;i < 16; ++i) {
162851
- buf[offset + i] = rnds[i];
162852
- }
162853
- return buf;
162854
- }
162855
- return unsafeStringify(rnds);
162856
- }
162857
- function v4(options, buf, offset) {
162858
- if (native_default.randomUUID && !buf && !options) {
162859
- return native_default.randomUUID();
162860
- }
162861
- return _v4(options, buf, offset);
162862
- }
162863
- var v4_default = v4;
162864
- // src/utils/cloudflare-r2.ts
162865
- var import_mime_types = __toESM(require_mime_types(), 1);
162866
- class CloudflareR2Client {
162867
- s3Client;
162868
- bucketName;
162869
- baseUrl;
162870
- constructor() {
162871
- const requiredVars = [
162872
- "CLOUDFLARE_CDN_ACCESS_KEY",
162873
- "CLOUDFLARE_CDN_SECRET_KEY",
162874
- "CLOUDFLARE_CDN_ENDPOINT_URL",
162875
- "CLOUDFLARE_CDN_BUCKET_NAME",
162876
- "CLOUDFLARE_CDN_BASE_URL"
162877
- ];
162878
- const missing = requiredVars.filter((varName) => !process.env[varName]);
162879
- if (missing.length > 0) {
162880
- throw new Error(`Missing required Cloudflare R2 environment variables: ${missing.join(", ")}`);
162881
- }
162882
- const config = {
162883
- region: "auto",
162884
- endpoint: process.env.CLOUDFLARE_CDN_ENDPOINT_URL,
162885
- credentials: {
162886
- accessKeyId: process.env.CLOUDFLARE_CDN_ACCESS_KEY,
162887
- secretAccessKey: process.env.CLOUDFLARE_CDN_SECRET_KEY
162888
- }
162889
- };
162890
- this.s3Client = new import_client_s3.S3Client(config);
162891
- this.bucketName = process.env.CLOUDFLARE_CDN_BUCKET_NAME;
162892
- this.baseUrl = process.env.CLOUDFLARE_CDN_BASE_URL;
162893
- }
162894
- async uploadFile(buffer, originalName) {
162895
- try {
162896
- const fileExtension = originalName.split(".").pop() || "bin";
162897
- const mimeType = import_mime_types.default.lookup(originalName) || "application/octet-stream";
162898
- const key = `human-mcp/${v4_default()}.${fileExtension}`;
162899
- const command = new import_client_s3.PutObjectCommand({
162900
- Bucket: this.bucketName,
162901
- Key: key,
162902
- Body: buffer,
162903
- ContentType: mimeType,
162904
- Metadata: {
162905
- originalName,
162906
- uploadedAt: new Date().toISOString(),
162907
- source: "human-mcp-http-transport"
162908
- }
162909
- });
162910
- await this.s3Client.send(command);
162911
- const publicUrl = `${this.baseUrl}/${key}`;
162912
- logger2.info(`File uploaded to Cloudflare R2: ${publicUrl}`);
162913
- return publicUrl;
162914
- } catch (error) {
162915
- logger2.error("Failed to upload to Cloudflare R2:", error);
162916
- throw new Error(`Failed to upload file: ${error instanceof Error ? error.message : "Unknown error"}`);
162917
- }
162918
- }
162919
- async uploadBase64(base64Data, mimeType, originalName) {
162920
- const buffer = Buffer.from(base64Data, "base64");
162921
- const extension = mimeType.split("/")[1] || "bin";
162922
- const fileName = originalName || `upload-${Date.now()}.${extension}`;
162923
- return this.uploadFile(buffer, fileName);
162924
- }
162925
- isConfigured() {
162926
- try {
162927
- const requiredVars = [
162928
- "CLOUDFLARE_CDN_ACCESS_KEY",
162929
- "CLOUDFLARE_CDN_SECRET_KEY",
162930
- "CLOUDFLARE_CDN_ENDPOINT_URL",
162931
- "CLOUDFLARE_CDN_BUCKET_NAME",
162932
- "CLOUDFLARE_CDN_BASE_URL"
162933
- ];
162934
- return requiredVars.every((varName) => process.env[varName]);
162935
- } catch {
162936
- return false;
162937
- }
162938
- }
162939
- }
162940
- var cloudflareR2Instance = null;
162941
- function getCloudflareR2() {
162942
- if (!cloudflareR2Instance) {
162943
- try {
162944
- cloudflareR2Instance = new CloudflareR2Client;
162945
- } catch (error) {
162946
- logger2.warn("Cloudflare R2 not configured:", error instanceof Error ? error.message : "Unknown error");
162947
- return null;
162948
- }
162949
- }
162950
- return cloudflareR2Instance;
162951
- }
162952
-
162953
163193
  // src/tools/eyes/processors/image.ts
163194
+ init_logger();
163195
+ init_errors();
163196
+ init_cloudflare_r2();
162954
163197
  async function processImage(model, source, options) {
162955
163198
  const startTime = Date.now();
162956
163199
  const maxRetries = 3;
@@ -163173,6 +163416,8 @@ var import_sharp2 = __toESM(require_lib(), 1);
163173
163416
  import fs2 from "fs/promises";
163174
163417
  import path from "path";
163175
163418
  import os from "os";
163419
+ init_logger();
163420
+ init_errors();
163176
163421
  async function processVideo(model, source, options) {
163177
163422
  const startTime = Date.now();
163178
163423
  const maxFrames = options.max_frames || 32;
@@ -163266,6 +163511,8 @@ async function extractFrames(videoSource, outputDir, maxFrames, sampleRate) {
163266
163511
  // src/tools/eyes/processors/gif.ts
163267
163512
  var import_sharp3 = __toESM(require_lib(), 1);
163268
163513
  import fs3 from "fs/promises";
163514
+ init_logger();
163515
+ init_errors();
163269
163516
  async function processGif(model, source, options) {
163270
163517
  const startTime = Date.now();
163271
163518
  try {
@@ -163366,6 +163613,8 @@ async function extractGifFrames(gifBuffer) {
163366
163613
  }
163367
163614
 
163368
163615
  // src/tools/eyes/processors/document.ts
163616
+ init_logger();
163617
+ init_errors();
163369
163618
  import { promises as fs4 } from "fs";
163370
163619
  import path2 from "path";
163371
163620
 
@@ -163497,6 +163746,9 @@ class DocumentProcessor {
163497
163746
  }
163498
163747
 
163499
163748
  // src/tools/eyes/processors/pdf.ts
163749
+ init_logger();
163750
+ init_errors();
163751
+
163500
163752
  class PDFProcessor extends DocumentProcessor {
163501
163753
  constructor(geminiClient) {
163502
163754
  super(geminiClient, ["pdf"]);
@@ -163629,6 +163881,8 @@ class PDFProcessor extends DocumentProcessor {
163629
163881
  }
163630
163882
 
163631
163883
  // src/tools/eyes/processors/word.ts
163884
+ init_logger();
163885
+ init_errors();
163632
163886
  var import_mammoth = __toESM(require_lib7(), 1);
163633
163887
 
163634
163888
  class WordProcessor extends DocumentProcessor {
@@ -163821,6 +164075,8 @@ class WordProcessor extends DocumentProcessor {
163821
164075
  }
163822
164076
 
163823
164077
  // src/tools/eyes/processors/excel.ts
164078
+ init_logger();
164079
+ init_errors();
163824
164080
  var import_xlsx = __toESM(require_xlsx(), 1);
163825
164081
 
163826
164082
  class ExcelProcessor extends DocumentProcessor {
@@ -164100,6 +164356,9 @@ class ExcelProcessor extends DocumentProcessor {
164100
164356
  }
164101
164357
 
164102
164358
  // src/tools/eyes/processors/powerpoint.ts
164359
+ init_logger();
164360
+ init_errors();
164361
+
164103
164362
  class PowerPointProcessor extends DocumentProcessor {
164104
164363
  constructor(geminiClient) {
164105
164364
  super(geminiClient, ["pptx"]);
@@ -164198,6 +164457,8 @@ class PowerPointProcessor extends DocumentProcessor {
164198
164457
  }
164199
164458
 
164200
164459
  // src/tools/eyes/processors/text.ts
164460
+ init_logger();
164461
+ init_errors();
164201
164462
  import path3 from "path";
164202
164463
 
164203
164464
  class TextProcessor extends DocumentProcessor {
@@ -164592,6 +164853,9 @@ Headers: ${headers.join(", ")}
164592
164853
  }
164593
164854
 
164594
164855
  // src/tools/eyes/processors/factory.ts
164856
+ init_logger();
164857
+ init_errors();
164858
+
164595
164859
  class DocumentProcessorFactory {
164596
164860
  static processors = new Map;
164597
164861
  static registerProcessors(geminiClient) {
@@ -165653,6 +165917,9 @@ class GoogleGenerativeAI {
165653
165917
  }
165654
165918
 
165655
165919
  // src/tools/eyes/utils/gemini-client.ts
165920
+ init_logger();
165921
+ init_errors();
165922
+
165656
165923
  class GeminiClient {
165657
165924
  config;
165658
165925
  genAI;
@@ -166792,18 +167059,17 @@ Include key insights and main conclusions from the document.`;
166792
167059
  logger2.info(`Enhanced video prompt: "${enhancedPrompt}"`);
166793
167060
  const parts = [{ text: enhancedPrompt }];
166794
167061
  if (imageInput) {
166795
- if (imageInput.startsWith("data:image/")) {
166796
- const matches = imageInput.match(/data:image\/([^;]+);base64,(.+)/);
166797
- if (matches) {
166798
- const mimeType = `image/${matches[1]}`;
166799
- const data = matches[2];
166800
- parts.push({
166801
- inlineData: {
166802
- mimeType,
166803
- data
166804
- }
166805
- });
166806
- }
167062
+ try {
167063
+ const { loadImageForProcessing: loadImageForProcessing2 } = await Promise.resolve().then(() => (init_image_loader(), exports_image_loader));
167064
+ const { data, mimeType } = await loadImageForProcessing2(imageInput);
167065
+ parts.push({
167066
+ inlineData: {
167067
+ mimeType,
167068
+ data
167069
+ }
167070
+ });
167071
+ } catch (error) {
167072
+ logger2.warn(`Failed to load image input: ${error instanceof Error ? error.message : "Unknown error"}`);
166807
167073
  }
166808
167074
  }
166809
167075
  const response = await videoModel.generateContent(parts);
@@ -166879,6 +167145,8 @@ Include key insights and main conclusions from the document.`;
166879
167145
  }
166880
167146
 
166881
167147
  // src/tools/eyes/index.ts
167148
+ init_logger();
167149
+ init_errors();
166882
167150
  async function registerEyesTool(server, config) {
166883
167151
  const geminiClient = new GeminiClient(config);
166884
167152
  logger2.info("Registering optimized Eyes tools...");
@@ -167182,8 +167450,8 @@ async function loadImageForComparison(source) {
167182
167450
  mimeType: response.headers.get("content-type") || "image/jpeg"
167183
167451
  };
167184
167452
  }
167185
- const fs5 = await import("fs/promises");
167186
- const buffer = await fs5.readFile(source);
167453
+ const fs6 = await import("fs/promises");
167454
+ const buffer = await fs6.readFile(source);
167187
167455
  return {
167188
167456
  data: buffer.toString("base64"),
167189
167457
  mimeType: "image/jpeg"
@@ -167208,8 +167476,8 @@ async function loadDocumentForDetection(source) {
167208
167476
  }
167209
167477
  return Buffer.from(arrayBuffer);
167210
167478
  }
167211
- const fs5 = await import("fs/promises");
167212
- return await fs5.readFile(source);
167479
+ const fs6 = await import("fs/promises");
167480
+ return await fs6.readFile(source);
167213
167481
  }
167214
167482
 
167215
167483
  // src/tools/hands/schemas.ts
@@ -167229,7 +167497,7 @@ var VideoGenerationInputSchema = exports_external.object({
167229
167497
  output_format: exports_external.enum(["mp4", "webm"]).optional().default("mp4"),
167230
167498
  aspect_ratio: exports_external.enum(["1:1", "16:9", "9:16", "4:3", "3:4"]).optional().default("16:9"),
167231
167499
  fps: exports_external.number().int().min(1).max(60).optional().default(24),
167232
- image_input: exports_external.string().optional().describe("Base64 encoded image or image URL to use as starting frame"),
167500
+ image_input: exports_external.string().optional().describe("Starting frame image - supports file paths, URLs, or base64 data URIs"),
167233
167501
  style: exports_external.enum(["realistic", "cinematic", "artistic", "cartoon", "animation"]).optional(),
167234
167502
  camera_movement: exports_external.enum(["static", "pan_left", "pan_right", "zoom_in", "zoom_out", "dolly_forward", "dolly_backward"]).optional(),
167235
167503
  seed: exports_external.number().int().min(0).optional()
@@ -167242,18 +167510,18 @@ var ImageEditingInputSchema = exports_external.object({
167242
167510
  "object_manipulation",
167243
167511
  "multi_image_compose"
167244
167512
  ]).describe("Type of image editing operation to perform"),
167245
- input_image: exports_external.string().describe("Base64 encoded image or file path to the input image"),
167513
+ input_image: exports_external.string().describe("Input image - supports file paths, URLs, or base64 data URIs (e.g., '/path/to/image.png', 'https://example.com/image.jpg', or 'data:image/png;base64,...')"),
167246
167514
  prompt: exports_external.string().min(1, "Prompt cannot be empty").describe("Text description of the desired edit"),
167247
- mask_image: exports_external.string().optional().describe("Base64 encoded mask image for inpainting (white = edit area, black = keep)"),
167515
+ mask_image: exports_external.string().optional().describe("Mask image for inpainting - supports file paths, URLs, or base64 data URIs (white = edit area, black = keep)"),
167248
167516
  mask_prompt: exports_external.string().optional().describe("Text description of the area to mask for editing"),
167249
167517
  expand_direction: exports_external.enum(["all", "left", "right", "top", "bottom", "horizontal", "vertical"]).optional().describe("Direction to expand the image"),
167250
167518
  expansion_ratio: exports_external.number().min(0.1).max(3).optional().default(1.5).describe("How much to expand the image (1.0 = no expansion)"),
167251
- style_image: exports_external.string().optional().describe("Base64 encoded reference image for style transfer"),
167519
+ style_image: exports_external.string().optional().describe("Style reference image - supports file paths, URLs, or base64 data URIs"),
167252
167520
  style_strength: exports_external.number().min(0.1).max(1).optional().default(0.7).describe("Strength of style application"),
167253
167521
  target_object: exports_external.string().optional().describe("Description of the object to manipulate"),
167254
167522
  manipulation_type: exports_external.enum(["move", "resize", "remove", "replace", "duplicate"]).optional().describe("Type of object manipulation"),
167255
167523
  target_position: exports_external.string().optional().describe("New position for the object (e.g., 'center', 'top-left')"),
167256
- secondary_images: exports_external.array(exports_external.string()).optional().describe("Array of base64 encoded images for composition"),
167524
+ secondary_images: exports_external.array(exports_external.string()).optional().describe("Array of secondary images - each supports file paths, URLs, or base64 data URIs"),
167257
167525
  composition_layout: exports_external.enum(["blend", "collage", "overlay", "side_by_side"]).optional().describe("How to combine multiple images"),
167258
167526
  blend_mode: exports_external.enum(["normal", "multiply", "screen", "overlay", "soft_light"]).optional().describe("Blending mode for image composition"),
167259
167527
  negative_prompt: exports_external.string().optional().describe("What to avoid in the edited image"),
@@ -167264,7 +167532,11 @@ var ImageEditingInputSchema = exports_external.object({
167264
167532
  quality: exports_external.enum(["draft", "standard", "high"]).optional().default("standard").describe("Quality level of the editing")
167265
167533
  });
167266
167534
 
167535
+ // src/tools/hands/processors/image-generator.ts
167536
+ init_logger();
167537
+
167267
167538
  // src/utils/file-storage.ts
167539
+ init_logger();
167268
167540
  import { writeFileSync, mkdirSync } from "fs";
167269
167541
  import { join, dirname } from "path";
167270
167542
  import { randomUUID as randomUUID2 } from "crypto";
@@ -167502,6 +167774,7 @@ function estimateImageSize(base64Data) {
167502
167774
  }
167503
167775
 
167504
167776
  // src/tools/hands/processors/video-generator.ts
167777
+ init_logger();
167505
167778
  async function generateVideo(geminiClient, options, config) {
167506
167779
  const startTime = Date.now();
167507
167780
  try {
@@ -167640,16 +167913,8 @@ function estimateVideoSize(duration, aspectRatio) {
167640
167913
  }
167641
167914
 
167642
167915
  // src/tools/hands/processors/image-editor.ts
167643
- function processImageDataUri(dataUri) {
167644
- const matches = dataUri.match(/^data:([^;]+);base64,(.+)$/);
167645
- if (!matches || !matches[1] || !matches[2]) {
167646
- throw new Error("Invalid data URI format");
167647
- }
167648
- return {
167649
- mimeType: matches[1],
167650
- data: matches[2]
167651
- };
167652
- }
167916
+ init_logger();
167917
+ init_image_loader();
167653
167918
  async function editImage(geminiClient, options, config) {
167654
167919
  const startTime = Date.now();
167655
167920
  try {
@@ -167763,19 +168028,15 @@ async function editImage(geminiClient, options, config) {
167763
168028
  }
167764
168029
  async function processImageForEditing(inputImage) {
167765
168030
  try {
167766
- if (inputImage.startsWith("data:")) {
167767
- const result = processImageDataUri(inputImage);
167768
- return {
167769
- data: result.data,
167770
- mimeType: result.mimeType
167771
- };
167772
- }
167773
- if (inputImage.startsWith("/") || inputImage.startsWith("./")) {
167774
- throw new Error("File path input not yet implemented. Please use base64 data URI format.");
167775
- }
168031
+ const result = await loadImageForProcessing(inputImage, {
168032
+ fetchTimeout: 30000,
168033
+ maxWidth: 1024,
168034
+ maxHeight: 1024,
168035
+ quality: 85
168036
+ });
167776
168037
  return {
167777
- data: inputImage,
167778
- mimeType: "image/jpeg"
168038
+ data: result.data,
168039
+ mimeType: result.mimeType
167779
168040
  };
167780
168041
  } catch (error) {
167781
168042
  throw new Error(`Failed to process input image: ${error instanceof Error ? error.message : error}`);
@@ -167898,6 +168159,8 @@ function estimateImageSize2(base64Data) {
167898
168159
  }
167899
168160
 
167900
168161
  // src/tools/hands/index.ts
168162
+ init_logger();
168163
+ init_errors();
167901
168164
  async function registerHandsTool(server, config) {
167902
168165
  const geminiClient = new GeminiClient(config);
167903
168166
  server.registerTool("gemini_gen_image", {
@@ -168583,19 +168846,25 @@ var VoiceCustomizationInputSchema = exports_external.object({
168583
168846
  compare_voices: exports_external.array(exports_external.enum(VoiceNames)).optional().describe("Additional voices to compare with the main voice")
168584
168847
  });
168585
168848
 
168849
+ // src/tools/mouth/processors/speech-synthesis.ts
168850
+ init_logger();
168851
+ init_errors();
168852
+
168586
168853
  // src/tools/mouth/utils/audio-storage.ts
168854
+ init_logger();
168855
+ init_errors();
168587
168856
  var import_wav = __toESM(require_wav(), 1);
168588
- import path4 from "path";
168857
+ import path5 from "path";
168589
168858
  import { fileURLToPath } from "url";
168590
168859
  var __filename2 = fileURLToPath(import.meta.url);
168591
- var __dirname2 = path4.dirname(__filename2);
168860
+ var __dirname2 = path5.dirname(__filename2);
168592
168861
 
168593
168862
  class AudioStorage {
168594
168863
  config;
168595
168864
  localStoragePath;
168596
168865
  constructor(config) {
168597
168866
  this.config = config;
168598
- this.localStoragePath = path4.resolve(process.cwd(), "audio-outputs");
168867
+ this.localStoragePath = path5.resolve(process.cwd(), "audio-outputs");
168599
168868
  }
168600
168869
  async convertPcmToWav(pcmData, filePath) {
168601
168870
  return new Promise((resolve, reject) => {
@@ -168653,7 +168922,7 @@ class AudioStorage {
168653
168922
  }
168654
168923
  result.size = Math.floor(base64Data.length * 3 / 4);
168655
168924
  try {
168656
- const localPath = path4.join(this.localStoragePath, finalFilename);
168925
+ const localPath = path5.join(this.localStoragePath, finalFilename);
168657
168926
  const pcmBuffer = Buffer.from(base64Data, "base64");
168658
168927
  await this.convertPcmToWav(pcmBuffer, localPath);
168659
168928
  result.localPath = localPath;
@@ -168689,11 +168958,11 @@ class AudioStorage {
168689
168958
  }
168690
168959
  async ensureStorageDirectory() {
168691
168960
  try {
168692
- const fs5 = await import("fs/promises");
168961
+ const fs6 = await import("fs/promises");
168693
168962
  try {
168694
- await fs5.access(this.localStoragePath);
168963
+ await fs6.access(this.localStoragePath);
168695
168964
  } catch {
168696
- await fs5.mkdir(this.localStoragePath, { recursive: true });
168965
+ await fs6.mkdir(this.localStoragePath, { recursive: true });
168697
168966
  logger2.info(`Created audio storage directory: ${this.localStoragePath}`);
168698
168967
  }
168699
168968
  } catch (error) {
@@ -168753,18 +169022,18 @@ class AudioStorage {
168753
169022
  }
168754
169023
  async cleanupOldFiles(maxAge = 86400000) {
168755
169024
  try {
168756
- const fs5 = await import("fs/promises");
169025
+ const fs6 = await import("fs/promises");
168757
169026
  let deletedCount = 0;
168758
169027
  const errors2 = [];
168759
169028
  try {
168760
- const files = await fs5.readdir(this.localStoragePath);
169029
+ const files = await fs6.readdir(this.localStoragePath);
168761
169030
  const now = Date.now();
168762
169031
  for (const file of files) {
168763
169032
  try {
168764
- const filePath = path4.join(this.localStoragePath, file);
168765
- const stats = await fs5.stat(filePath);
169033
+ const filePath = path5.join(this.localStoragePath, file);
169034
+ const stats = await fs6.stat(filePath);
168766
169035
  if (now - stats.mtime.getTime() > maxAge) {
168767
- await fs5.unlink(filePath);
169036
+ await fs6.unlink(filePath);
168768
169037
  deletedCount++;
168769
169038
  logger2.debug(`Deleted old audio file: ${file}`);
168770
169039
  }
@@ -168786,7 +169055,7 @@ class AudioStorage {
168786
169055
  }
168787
169056
  async getStorageStats() {
168788
169057
  try {
168789
- const fs5 = await import("fs/promises");
169058
+ const fs6 = await import("fs/promises");
168790
169059
  const stats = {
168791
169060
  localPath: this.localStoragePath,
168792
169061
  localFiles: 0,
@@ -168796,13 +169065,13 @@ class AudioStorage {
168796
169065
  cloudConfigured: this.isCloudflareConfigured()
168797
169066
  };
168798
169067
  try {
168799
- const files = await fs5.readdir(this.localStoragePath);
169068
+ const files = await fs6.readdir(this.localStoragePath);
168800
169069
  let oldestTime = Infinity;
168801
169070
  let newestTime = 0;
168802
169071
  for (const file of files) {
168803
169072
  try {
168804
- const filePath = path4.join(this.localStoragePath, file);
168805
- const fileStat = await fs5.stat(filePath);
169073
+ const filePath = path5.join(this.localStoragePath, file);
169074
+ const fileStat = await fs6.stat(filePath);
168806
169075
  stats.localFiles++;
168807
169076
  stats.totalSize += fileStat.size;
168808
169077
  if (fileStat.mtime.getTime() < oldestTime) {
@@ -168920,6 +169189,8 @@ async function generateSpeech(geminiClient, options) {
168920
169189
  }
168921
169190
 
168922
169191
  // src/tools/mouth/processors/narration.ts
169192
+ init_logger();
169193
+ init_errors();
168923
169194
  async function generateNarration(geminiClient, options) {
168924
169195
  const startTime = Date.now();
168925
169196
  try {
@@ -169038,6 +169309,8 @@ function isChapterBreak(chunk, index) {
169038
169309
  }
169039
169310
 
169040
169311
  // src/tools/mouth/processors/code-explanation.ts
169312
+ init_logger();
169313
+ init_errors();
169041
169314
  async function generateCodeExplanation(geminiClient, options) {
169042
169315
  const startTime = Date.now();
169043
169316
  try {
@@ -169211,6 +169484,8 @@ function createTechnicalStylePrompt(explanationLevel) {
169211
169484
  }
169212
169485
 
169213
169486
  // src/tools/mouth/processors/voice-customization.ts
169487
+ init_logger();
169488
+ init_errors();
169214
169489
  async function generateVoiceCustomization(geminiClient, options) {
169215
169490
  const startTime = Date.now();
169216
169491
  try {
@@ -169363,6 +169638,8 @@ The recommendation should be practical and focused on the best user experience f
169363
169638
  }
169364
169639
 
169365
169640
  // src/tools/mouth/index.ts
169641
+ init_logger();
169642
+ init_errors();
169366
169643
  async function registerMouthTool(server, config) {
169367
169644
  const geminiClient = new GeminiClient(config);
169368
169645
  server.registerTool("mouth_speak", {
@@ -169758,7 +170035,14 @@ async function handleVoiceCustomization(geminiClient, args, config) {
169758
170035
  };
169759
170036
  }
169760
170037
 
170038
+ // src/tools/brain/index.ts
170039
+ init_logger();
170040
+ init_errors();
170041
+
169761
170042
  // src/tools/brain/native/sequential-thinking.ts
170043
+ init_logger();
170044
+ init_errors();
170045
+
169762
170046
  class SequentialThinkingManager {
169763
170047
  sessions = new Map;
169764
170048
  createSession(problem) {
@@ -169937,6 +170221,8 @@ ${session.finalAnswer}
169937
170221
  }
169938
170222
 
169939
170223
  // src/tools/brain/native/simple-reasoning.ts
170224
+ init_logger();
170225
+ init_errors();
169940
170226
  var REASONING_PATTERNS = {
169941
170227
  problem_solving: {
169942
170228
  name: "Problem Solving",
@@ -170369,6 +170655,9 @@ function getUseCase(pattern) {
170369
170655
  }
170370
170656
 
170371
170657
  // src/tools/brain/processors/reflection.ts
170658
+ init_logger();
170659
+ init_errors();
170660
+
170372
170661
  class ReflectionProcessor {
170373
170662
  geminiClient;
170374
170663
  constructor(geminiClient) {
@@ -170972,6 +171261,7 @@ Use the eyes.compare tool with comparison_type="structural".`
170972
171261
  ];
170973
171262
 
170974
171263
  // src/prompts/index.ts
171264
+ init_logger();
170975
171265
  async function registerPrompts(server) {
170976
171266
  for (const prompt of debuggingPrompts) {
170977
171267
  const argsSchema = {};
@@ -171329,6 +171619,7 @@ These examples demonstrate the practical application of Human MCP for common deb
171329
171619
  `;
171330
171620
 
171331
171621
  // src/resources/index.ts
171622
+ init_logger();
171332
171623
  async function registerResources(server) {
171333
171624
  server.registerResource("api-docs", "humanmcp://docs/api", {
171334
171625
  title: "Human MCP API Documentation",
@@ -171360,6 +171651,9 @@ async function registerResources(server) {
171360
171651
  });
171361
171652
  }
171362
171653
 
171654
+ // src/server.ts
171655
+ init_logger();
171656
+
171363
171657
  // src/utils/config.ts
171364
171658
  var ConfigSchema = exports_external.object({
171365
171659
  gemini: exports_external.object({
@@ -172550,6 +172844,8 @@ class StreamableHTTPServerTransport {
172550
172844
  }
172551
172845
 
172552
172846
  // src/transports/http/routes.ts
172847
+ init_cloudflare_r2();
172848
+ init_logger();
172553
172849
  var import_multer = __toESM(require_multer(), 1);
172554
172850
  function createRoutes(mcpServer, sessionManager, config, sseSessionChecker) {
172555
172851
  const router = import_express.Router();
@@ -173154,8 +173450,10 @@ function createSecurityMiddleware(config) {
173154
173450
  }
173155
173451
 
173156
173452
  // src/transports/http/file-interceptor.ts
173157
- import fs5 from "fs/promises";
173158
- import path5 from "path";
173453
+ init_cloudflare_r2();
173454
+ init_logger();
173455
+ import fs6 from "fs/promises";
173456
+ import path6 from "path";
173159
173457
  async function fileInterceptorMiddleware(req, res, next) {
173160
173458
  if (req.body?.method === "tools/call" && req.body?.params?.arguments) {
173161
173459
  const args = req.body.params.arguments;
@@ -173166,15 +173464,15 @@ async function fileInterceptorMiddleware(req, res, next) {
173166
173464
  if (filePath.startsWith("/mnt/user-data/") || filePath.startsWith("/mnt/")) {
173167
173465
  logger2.info(`Intercepting Claude Desktop virtual path: ${filePath}`);
173168
173466
  try {
173169
- const filename = path5.basename(filePath);
173170
- const tempPath = path5.join("/tmp/claude-uploads", filename);
173171
- if (await fs5.access(tempPath).then(() => true).catch(() => false)) {
173467
+ const filename = path6.basename(filePath);
173468
+ const tempPath = path6.join("/tmp/claude-uploads", filename);
173469
+ if (await fs6.access(tempPath).then(() => true).catch(() => false)) {
173172
173470
  const cloudflare = getCloudflareR2();
173173
173471
  if (cloudflare) {
173174
- const buffer = await fs5.readFile(tempPath);
173472
+ const buffer = await fs6.readFile(tempPath);
173175
173473
  const publicUrl = await cloudflare.uploadFile(buffer, filename);
173176
173474
  args[field] = publicUrl;
173177
- await fs5.unlink(tempPath).catch(() => {});
173475
+ await fs6.unlink(tempPath).catch(() => {});
173178
173476
  logger2.info(`Replaced virtual path with CDN URL: ${publicUrl}`);
173179
173477
  }
173180
173478
  } else {
@@ -173224,9 +173522,9 @@ async function fileInterceptorMiddleware(req, res, next) {
173224
173522
  const cloudflare = getCloudflareR2();
173225
173523
  if (cloudflare) {
173226
173524
  try {
173227
- await fs5.access(filePath);
173228
- const buffer = await fs5.readFile(filePath);
173229
- const filename = path5.basename(filePath);
173525
+ await fs6.access(filePath);
173526
+ const buffer = await fs6.readFile(filePath);
173527
+ const filename = path6.basename(filePath);
173230
173528
  const publicUrl = await cloudflare.uploadFile(buffer, filename);
173231
173529
  args[field] = publicUrl;
173232
173530
  logger2.info(`Auto-uploaded local file to CDN: ${publicUrl}`);