@clawos-dev/clawd 0.2.649 → 0.2.651

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();
@@ -53627,6 +53677,7 @@ function driveCodexThread(opts) {
53627
53677
  let threadId = ctx.toolSessionId;
53628
53678
  let turnId;
53629
53679
  let turnOpen = false;
53680
+ let activeTrace;
53630
53681
  const firstByte = createFirstByteClock(opts.now);
53631
53682
  const approvalIds = /* @__PURE__ */ new Map();
53632
53683
  const subagents = new CodexSubagentTracker();
@@ -53655,6 +53706,7 @@ function driveCodexThread(opts) {
53655
53706
  if (threadId !== void 0 && ownerThreadId === threadId && method === "turn/started") {
53656
53707
  const id = params?.turn?.id;
53657
53708
  if (id) turnId = id;
53709
+ activeTrace?.("native.turn.started", { threadId, turnId });
53658
53710
  }
53659
53711
  const events = route === "subagent" && ownerThreadId ? subagents.handleChildNotification(ownerThreadId, method, params) : route === "foreground" ? [
53660
53712
  ...subagents.handleParentNotification(method, params),
@@ -53669,6 +53721,8 @@ function driveCodexThread(opts) {
53669
53721
  if (!subagentsRunning) opts.onSubagentsIdle?.();
53670
53722
  }
53671
53723
  if (route === "foreground" && method === "turn/completed") {
53724
+ activeTrace?.("native.turn.completed", { threadId, turnId, status: turnOutcomeOf(params) });
53725
+ activeTrace = void 0;
53672
53726
  turnOpen = false;
53673
53727
  opts.onTurnCompleted?.(turnOutcomeOf(params), firstByte.afterFirstByteMs());
53674
53728
  }
@@ -53714,6 +53768,8 @@ function driveCodexThread(opts) {
53714
53768
  })().catch((e) => sink.onError(`codex app-server init failed: ${e.message}`));
53715
53769
  const session = {
53716
53770
  startTurn(text) {
53771
+ const trace = opts.onTurnTrace?.();
53772
+ trace?.("native.ready.waiting");
53717
53773
  const model = opts.turnModel?.();
53718
53774
  const modelSelected = opts.onTurnModelSelected?.();
53719
53775
  void ready.then(() => {
@@ -53722,8 +53778,10 @@ function driveCodexThread(opts) {
53722
53778
  if (opened) {
53723
53779
  turnOpen = true;
53724
53780
  firstByte.reset();
53781
+ activeTrace = trace;
53725
53782
  opts.onTurnStarting?.();
53726
53783
  }
53784
+ trace?.("native.query.sent", { threadId });
53727
53785
  void client.request("turn/start", {
53728
53786
  threadId,
53729
53787
  input: turnStartInput(text, opts.imageInput),
@@ -53731,9 +53789,11 @@ function driveCodexThread(opts) {
53731
53789
  ...effort ? { effort } : {},
53732
53790
  ...model ? { model } : {}
53733
53791
  }).then(() => {
53792
+ trace?.("native.query.accepted", { threadId });
53734
53793
  if (model) modelSelected?.(model);
53735
53794
  }).catch((e) => {
53736
53795
  if (exited) return;
53796
+ trace?.("native.query.failed", { threadId });
53737
53797
  sink.pushEvents([
53738
53798
  { kind: "error", message: `turn/start failed: ${e.message}` },
53739
53799
  { kind: "turn_end" }
@@ -69429,25 +69489,12 @@ var EXTENSIONS_IMPORT_CORS_HEADERS = {
69429
69489
  "Access-Control-Allow-Headers": "Authorization, Content-Type",
69430
69490
  "Access-Control-Max-Age": "86400"
69431
69491
  };
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
69492
  var UPLOAD_CORS_HEADERS = {
69442
69493
  "Access-Control-Allow-Origin": "*",
69443
69494
  "Access-Control-Allow-Methods": "POST, OPTIONS",
69444
69495
  "Access-Control-Allow-Headers": "Authorization, Content-Type",
69445
69496
  "Access-Control-Max-Age": "86400"
69446
69497
  };
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
69498
  function isValidUploadFileName(fileName) {
69452
69499
  if (fileName.length === 0) return false;
69453
69500
  if (fileName === "." || fileName === "..") return false;
@@ -69728,14 +69775,15 @@ function createHttpRouter(deps) {
69728
69775
  sendUploadJson(400, { code: "INVALID_PARAM", message: "malformed Content-Length" });
69729
69776
  return true;
69730
69777
  }
69731
- if (contentLength > UPLOAD_MAX_BYTES) {
69778
+ if (contentLength > MAX_ATTACHMENT_BYTES) {
69732
69779
  sendUploadJson(413, {
69733
69780
  code: "FILE_TOO_LARGE",
69734
- message: `max ${UPLOAD_MAX_BYTES} bytes`
69781
+ message: `max ${MAX_ATTACHMENT_BYTES} bytes`
69735
69782
  });
69736
69783
  return true;
69737
69784
  }
69738
- if (!isUploadMimeAllowed(mimeType)) {
69785
+ const resolvedMime = resolveAttachmentUploadMime(fileName, mimeType);
69786
+ if (!resolvedMime) {
69739
69787
  sendUploadJson(400, {
69740
69788
  code: "UNSUPPORTED_MIME",
69741
69789
  message: `mime ${mimeType} not allowed`
@@ -69770,7 +69818,7 @@ function createHttpRouter(deps) {
69770
69818
  sessionId,
69771
69819
  scope,
69772
69820
  fileName,
69773
- mimeType,
69821
+ mimeType: resolvedMime,
69774
69822
  contentLength,
69775
69823
  body: req,
69776
69824
  groupFileStore: up.groupFileStore
@@ -74368,7 +74416,7 @@ function computeMethodAccess(args) {
74368
74416
  }
74369
74417
 
74370
74418
  // src/version.ts
74371
- var version = "0.2.649".length > 0 ? "0.2.649" : "dev";
74419
+ var version = "0.2.651".length > 0 ? "0.2.651" : "dev";
74372
74420
 
74373
74421
  // src/cli-probe/probe.ts
74374
74422
  var fs85 = __toESM(require("fs"), 1);