@clawos-dev/clawd 0.2.649 → 0.2.650

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.
@@ -34364,6 +34364,40 @@ var CloudVolumeGetResultSchema = external_exports.object({
34364
34364
  volume: CloudVolumeUsageSchema.nullable()
34365
34365
  }).strict();
34366
34366
 
34367
+ // ../protocol/src/attachment-upload-policy.ts
34368
+ var MAX_ATTACHMENT_BYTES = 25 * 1024 * 1024;
34369
+ var EXTENSION_MIME = {
34370
+ ".png": "image/png",
34371
+ ".jpg": "image/jpeg",
34372
+ ".jpeg": "image/jpeg",
34373
+ ".gif": "image/gif",
34374
+ ".webp": "image/webp",
34375
+ ".pdf": "application/pdf",
34376
+ ".txt": "text/plain",
34377
+ ".md": "text/plain",
34378
+ ".markdown": "text/plain",
34379
+ ".csv": "text/plain",
34380
+ ".log": "text/plain",
34381
+ ".json": "application/json",
34382
+ ".xml": "application/xml",
34383
+ ".yaml": "application/yaml",
34384
+ ".yml": "application/yaml",
34385
+ ".html": "text/html",
34386
+ ".conf": "text/plain",
34387
+ ".cfg": "text/plain",
34388
+ ".ini": "text/plain",
34389
+ ".toml": "text/plain"
34390
+ };
34391
+ var ACCEPTED_MIME = /* @__PURE__ */ new Set([
34392
+ ...Object.values(EXTENSION_MIME),
34393
+ "application/x-yaml"
34394
+ ]);
34395
+ var CHAT_INPUT_FILE_ACCEPT = [
34396
+ ...ACCEPTED_MIME,
34397
+ "text/*",
34398
+ ...Object.keys(EXTENSION_MIME)
34399
+ ].join(",");
34400
+
34367
34401
  // ../protocol/src/log.ts
34368
34402
  var LOG_SOURCES = ["daemon", "main", "renderer"];
34369
34403
  var LogSourceSchema = external_exports.enum(LOG_SOURCES);
package/dist/cli.cjs CHANGED
@@ -9669,6 +9669,55 @@ var init_persona_mode = __esm({
9669
9669
  }
9670
9670
  });
9671
9671
 
9672
+ // ../protocol/src/attachment-upload-policy.ts
9673
+ function resolveAttachmentUploadMime(fileName, mimeType) {
9674
+ const mime = mimeType.split(";", 1)[0].trim().toLowerCase();
9675
+ if (mime === "" || mime === "application/octet-stream") {
9676
+ const extensionIndex = fileName.lastIndexOf(".");
9677
+ const extension2 = extensionIndex > 0 ? fileName.slice(extensionIndex).toLowerCase() : "";
9678
+ return EXTENSION_MIME[extension2] ?? null;
9679
+ }
9680
+ return ACCEPTED_MIME.has(mime) || mime.startsWith("text/") ? mime : null;
9681
+ }
9682
+ var MAX_ATTACHMENT_BYTES, EXTENSION_MIME, ACCEPTED_MIME, CHAT_INPUT_FILE_ACCEPT;
9683
+ var init_attachment_upload_policy = __esm({
9684
+ "../protocol/src/attachment-upload-policy.ts"() {
9685
+ "use strict";
9686
+ MAX_ATTACHMENT_BYTES = 25 * 1024 * 1024;
9687
+ EXTENSION_MIME = {
9688
+ ".png": "image/png",
9689
+ ".jpg": "image/jpeg",
9690
+ ".jpeg": "image/jpeg",
9691
+ ".gif": "image/gif",
9692
+ ".webp": "image/webp",
9693
+ ".pdf": "application/pdf",
9694
+ ".txt": "text/plain",
9695
+ ".md": "text/plain",
9696
+ ".markdown": "text/plain",
9697
+ ".csv": "text/plain",
9698
+ ".log": "text/plain",
9699
+ ".json": "application/json",
9700
+ ".xml": "application/xml",
9701
+ ".yaml": "application/yaml",
9702
+ ".yml": "application/yaml",
9703
+ ".html": "text/html",
9704
+ ".conf": "text/plain",
9705
+ ".cfg": "text/plain",
9706
+ ".ini": "text/plain",
9707
+ ".toml": "text/plain"
9708
+ };
9709
+ ACCEPTED_MIME = /* @__PURE__ */ new Set([
9710
+ ...Object.values(EXTENSION_MIME),
9711
+ "application/x-yaml"
9712
+ ]);
9713
+ CHAT_INPUT_FILE_ACCEPT = [
9714
+ ...ACCEPTED_MIME,
9715
+ "text/*",
9716
+ ...Object.keys(EXTENSION_MIME)
9717
+ ].join(",");
9718
+ }
9719
+ });
9720
+
9672
9721
  // ../protocol/src/log.ts
9673
9722
  var LOG_SOURCES, LogSourceSchema, LOG_LEVELS, LogLevelSchema, LogRecordSchema;
9674
9723
  var init_log = __esm({
@@ -9825,6 +9874,7 @@ var init_runtime = __esm({
9825
9874
  init_persona_schemas();
9826
9875
  init_persona_mode();
9827
9876
  init_attachment_schemas();
9877
+ init_attachment_upload_policy();
9828
9878
  init_principal();
9829
9879
  init_capability();
9830
9880
  init_inbox();
@@ -69429,25 +69479,12 @@ var EXTENSIONS_IMPORT_CORS_HEADERS = {
69429
69479
  "Access-Control-Allow-Headers": "Authorization, Content-Type",
69430
69480
  "Access-Control-Max-Age": "86400"
69431
69481
  };
69432
- var UPLOAD_MIME_ALLOW = /* @__PURE__ */ new Set([
69433
- "image/png",
69434
- "image/jpeg",
69435
- "image/gif",
69436
- "image/webp",
69437
- "application/pdf"
69438
- ]);
69439
- var UPLOAD_MIME_ALLOW_PREFIX = ["text/"];
69440
- var UPLOAD_MAX_BYTES = 25 * 1024 * 1024;
69441
69482
  var UPLOAD_CORS_HEADERS = {
69442
69483
  "Access-Control-Allow-Origin": "*",
69443
69484
  "Access-Control-Allow-Methods": "POST, OPTIONS",
69444
69485
  "Access-Control-Allow-Headers": "Authorization, Content-Type",
69445
69486
  "Access-Control-Max-Age": "86400"
69446
69487
  };
69447
- function isUploadMimeAllowed(mime) {
69448
- if (UPLOAD_MIME_ALLOW.has(mime)) return true;
69449
- return UPLOAD_MIME_ALLOW_PREFIX.some((p3) => mime.startsWith(p3));
69450
- }
69451
69488
  function isValidUploadFileName(fileName) {
69452
69489
  if (fileName.length === 0) return false;
69453
69490
  if (fileName === "." || fileName === "..") return false;
@@ -69728,14 +69765,15 @@ function createHttpRouter(deps) {
69728
69765
  sendUploadJson(400, { code: "INVALID_PARAM", message: "malformed Content-Length" });
69729
69766
  return true;
69730
69767
  }
69731
- if (contentLength > UPLOAD_MAX_BYTES) {
69768
+ if (contentLength > MAX_ATTACHMENT_BYTES) {
69732
69769
  sendUploadJson(413, {
69733
69770
  code: "FILE_TOO_LARGE",
69734
- message: `max ${UPLOAD_MAX_BYTES} bytes`
69771
+ message: `max ${MAX_ATTACHMENT_BYTES} bytes`
69735
69772
  });
69736
69773
  return true;
69737
69774
  }
69738
- if (!isUploadMimeAllowed(mimeType)) {
69775
+ const resolvedMime = resolveAttachmentUploadMime(fileName, mimeType);
69776
+ if (!resolvedMime) {
69739
69777
  sendUploadJson(400, {
69740
69778
  code: "UNSUPPORTED_MIME",
69741
69779
  message: `mime ${mimeType} not allowed`
@@ -69770,7 +69808,7 @@ function createHttpRouter(deps) {
69770
69808
  sessionId,
69771
69809
  scope,
69772
69810
  fileName,
69773
- mimeType,
69811
+ mimeType: resolvedMime,
69774
69812
  contentLength,
69775
69813
  body: req,
69776
69814
  groupFileStore: up.groupFileStore
@@ -74368,7 +74406,7 @@ function computeMethodAccess(args) {
74368
74406
  }
74369
74407
 
74370
74408
  // src/version.ts
74371
- var version = "0.2.649".length > 0 ? "0.2.649" : "dev";
74409
+ var version = "0.2.650".length > 0 ? "0.2.650" : "dev";
74372
74410
 
74373
74411
  // src/cli-probe/probe.ts
74374
74412
  var fs85 = __toESM(require("fs"), 1);