@clawos-dev/clawd 0.2.326 → 0.2.327

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.cjs CHANGED
@@ -9585,10 +9585,10 @@ var require_redaction = __commonJS({
9585
9585
  var strict = false;
9586
9586
  function redaction(opts, serialize) {
9587
9587
  const { paths, censor, remove } = handle(opts);
9588
- const shape = paths.reduce((o, str4) => {
9588
+ const shape = paths.reduce((o, str5) => {
9589
9589
  rx.lastIndex = 0;
9590
- const first = rx.exec(str4);
9591
- const next = rx.exec(str4);
9590
+ const first = rx.exec(str5);
9591
+ const next = rx.exec(str5);
9592
9592
  let ns = first[1] !== void 0 ? first[1].replace(/^(?:"|'|`)(.*)(?:"|'|`)$/, "$1") : first[0];
9593
9593
  if (ns === "*") {
9594
9594
  ns = wildcardFirstSym;
@@ -9601,7 +9601,7 @@ var require_redaction = __commonJS({
9601
9601
  return o;
9602
9602
  }
9603
9603
  const { index } = next;
9604
- const nextPath = `${str4.substr(index, str4.length - 1)}`;
9604
+ const nextPath = `${str5.substr(index, str5.length - 1)}`;
9605
9605
  o[ns] = o[ns] || [];
9606
9606
  if (ns !== wildcardFirstSym && o[ns].length === 0) {
9607
9607
  o[ns].push(...o[wildcardFirstSym] || []);
@@ -9717,7 +9717,7 @@ var require_quick_format_unescaped = __commonJS({
9717
9717
  }
9718
9718
  var argLen = args.length;
9719
9719
  if (argLen === 0) return f;
9720
- var str4 = "";
9720
+ var str5 = "";
9721
9721
  var a = 1 - offset;
9722
9722
  var lastPos = -1;
9723
9723
  var flen = f && f.length || 0;
@@ -9732,8 +9732,8 @@ var require_quick_format_unescaped = __commonJS({
9732
9732
  break;
9733
9733
  if (args[a] == null) break;
9734
9734
  if (lastPos < i)
9735
- str4 += f.slice(lastPos, i);
9736
- str4 += Number(args[a]);
9735
+ str5 += f.slice(lastPos, i);
9736
+ str5 += Number(args[a]);
9737
9737
  lastPos = i + 2;
9738
9738
  i++;
9739
9739
  break;
@@ -9742,8 +9742,8 @@ var require_quick_format_unescaped = __commonJS({
9742
9742
  break;
9743
9743
  if (args[a] == null) break;
9744
9744
  if (lastPos < i)
9745
- str4 += f.slice(lastPos, i);
9746
- str4 += Math.floor(Number(args[a]));
9745
+ str5 += f.slice(lastPos, i);
9746
+ str5 += Math.floor(Number(args[a]));
9747
9747
  lastPos = i + 2;
9748
9748
  i++;
9749
9749
  break;
@@ -9756,21 +9756,21 @@ var require_quick_format_unescaped = __commonJS({
9756
9756
  break;
9757
9757
  if (args[a] === void 0) break;
9758
9758
  if (lastPos < i)
9759
- str4 += f.slice(lastPos, i);
9759
+ str5 += f.slice(lastPos, i);
9760
9760
  var type = typeof args[a];
9761
9761
  if (type === "string") {
9762
- str4 += "'" + args[a] + "'";
9762
+ str5 += "'" + args[a] + "'";
9763
9763
  lastPos = i + 2;
9764
9764
  i++;
9765
9765
  break;
9766
9766
  }
9767
9767
  if (type === "function") {
9768
- str4 += args[a].name || "<anonymous>";
9768
+ str5 += args[a].name || "<anonymous>";
9769
9769
  lastPos = i + 2;
9770
9770
  i++;
9771
9771
  break;
9772
9772
  }
9773
- str4 += ss(args[a]);
9773
+ str5 += ss(args[a]);
9774
9774
  lastPos = i + 2;
9775
9775
  i++;
9776
9776
  break;
@@ -9778,15 +9778,15 @@ var require_quick_format_unescaped = __commonJS({
9778
9778
  if (a >= argLen)
9779
9779
  break;
9780
9780
  if (lastPos < i)
9781
- str4 += f.slice(lastPos, i);
9782
- str4 += String(args[a]);
9781
+ str5 += f.slice(lastPos, i);
9782
+ str5 += String(args[a]);
9783
9783
  lastPos = i + 2;
9784
9784
  i++;
9785
9785
  break;
9786
9786
  case 37:
9787
9787
  if (lastPos < i)
9788
- str4 += f.slice(lastPos, i);
9789
- str4 += "%";
9788
+ str5 += f.slice(lastPos, i);
9789
+ str5 += "%";
9790
9790
  lastPos = i + 2;
9791
9791
  i++;
9792
9792
  a--;
@@ -9799,9 +9799,9 @@ var require_quick_format_unescaped = __commonJS({
9799
9799
  if (lastPos === -1)
9800
9800
  return f;
9801
9801
  else if (lastPos < flen) {
9802
- str4 += f.slice(lastPos);
9802
+ str5 += f.slice(lastPos);
9803
9803
  }
9804
- return str4;
9804
+ return str5;
9805
9805
  }
9806
9806
  }
9807
9807
  });
@@ -9845,7 +9845,7 @@ var require_atomic_sleep = __commonJS({
9845
9845
  var require_sonic_boom = __commonJS({
9846
9846
  "../node_modules/.pnpm/sonic-boom@4.2.1/node_modules/sonic-boom/index.js"(exports2, module2) {
9847
9847
  "use strict";
9848
- var fs71 = require("fs");
9848
+ var fs72 = require("fs");
9849
9849
  var EventEmitter3 = require("events");
9850
9850
  var inherits = require("util").inherits;
9851
9851
  var path81 = require("path");
@@ -9902,20 +9902,20 @@ var require_sonic_boom = __commonJS({
9902
9902
  const mode = sonic.mode;
9903
9903
  if (sonic.sync) {
9904
9904
  try {
9905
- if (sonic.mkdir) fs71.mkdirSync(path81.dirname(file), { recursive: true });
9906
- const fd = fs71.openSync(file, flags, mode);
9905
+ if (sonic.mkdir) fs72.mkdirSync(path81.dirname(file), { recursive: true });
9906
+ const fd = fs72.openSync(file, flags, mode);
9907
9907
  fileOpened(null, fd);
9908
9908
  } catch (err) {
9909
9909
  fileOpened(err);
9910
9910
  throw err;
9911
9911
  }
9912
9912
  } else if (sonic.mkdir) {
9913
- fs71.mkdir(path81.dirname(file), { recursive: true }, (err) => {
9913
+ fs72.mkdir(path81.dirname(file), { recursive: true }, (err) => {
9914
9914
  if (err) return fileOpened(err);
9915
- fs71.open(file, flags, mode, fileOpened);
9915
+ fs72.open(file, flags, mode, fileOpened);
9916
9916
  });
9917
9917
  } else {
9918
- fs71.open(file, flags, mode, fileOpened);
9918
+ fs72.open(file, flags, mode, fileOpened);
9919
9919
  }
9920
9920
  }
9921
9921
  function SonicBoom(opts) {
@@ -9956,8 +9956,8 @@ var require_sonic_boom = __commonJS({
9956
9956
  this.flush = flushBuffer;
9957
9957
  this.flushSync = flushBufferSync;
9958
9958
  this._actualWrite = actualWriteBuffer;
9959
- fsWriteSync = () => fs71.writeSync(this.fd, this._writingBuf);
9960
- fsWrite = () => fs71.write(this.fd, this._writingBuf, this.release);
9959
+ fsWriteSync = () => fs72.writeSync(this.fd, this._writingBuf);
9960
+ fsWrite = () => fs72.write(this.fd, this._writingBuf, this.release);
9961
9961
  } else if (contentMode === void 0 || contentMode === kContentModeUtf8) {
9962
9962
  this._writingBuf = "";
9963
9963
  this.write = write;
@@ -9966,15 +9966,15 @@ var require_sonic_boom = __commonJS({
9966
9966
  this._actualWrite = actualWrite;
9967
9967
  fsWriteSync = () => {
9968
9968
  if (Buffer.isBuffer(this._writingBuf)) {
9969
- return fs71.writeSync(this.fd, this._writingBuf);
9969
+ return fs72.writeSync(this.fd, this._writingBuf);
9970
9970
  }
9971
- return fs71.writeSync(this.fd, this._writingBuf, "utf8");
9971
+ return fs72.writeSync(this.fd, this._writingBuf, "utf8");
9972
9972
  };
9973
9973
  fsWrite = () => {
9974
9974
  if (Buffer.isBuffer(this._writingBuf)) {
9975
- return fs71.write(this.fd, this._writingBuf, this.release);
9975
+ return fs72.write(this.fd, this._writingBuf, this.release);
9976
9976
  }
9977
- return fs71.write(this.fd, this._writingBuf, "utf8", this.release);
9977
+ return fs72.write(this.fd, this._writingBuf, "utf8", this.release);
9978
9978
  };
9979
9979
  } else {
9980
9980
  throw new Error(`SonicBoom supports "${kContentModeUtf8}" and "${kContentModeBuffer}", but passed ${contentMode}`);
@@ -10031,7 +10031,7 @@ var require_sonic_boom = __commonJS({
10031
10031
  }
10032
10032
  }
10033
10033
  if (this._fsync) {
10034
- fs71.fsyncSync(this.fd);
10034
+ fs72.fsyncSync(this.fd);
10035
10035
  }
10036
10036
  const len = this._len;
10037
10037
  if (this._reopening) {
@@ -10145,7 +10145,7 @@ var require_sonic_boom = __commonJS({
10145
10145
  const onDrain = () => {
10146
10146
  if (!this._fsync) {
10147
10147
  try {
10148
- fs71.fsync(this.fd, (err) => {
10148
+ fs72.fsync(this.fd, (err) => {
10149
10149
  this._flushPending = false;
10150
10150
  cb(err);
10151
10151
  });
@@ -10247,7 +10247,7 @@ var require_sonic_boom = __commonJS({
10247
10247
  const fd = this.fd;
10248
10248
  this.once("ready", () => {
10249
10249
  if (fd !== this.fd) {
10250
- fs71.close(fd, (err) => {
10250
+ fs72.close(fd, (err) => {
10251
10251
  if (err) {
10252
10252
  return this.emit("error", err);
10253
10253
  }
@@ -10296,7 +10296,7 @@ var require_sonic_boom = __commonJS({
10296
10296
  buf = this._bufs[0];
10297
10297
  }
10298
10298
  try {
10299
- const n = Buffer.isBuffer(buf) ? fs71.writeSync(this.fd, buf) : fs71.writeSync(this.fd, buf, "utf8");
10299
+ const n = Buffer.isBuffer(buf) ? fs72.writeSync(this.fd, buf) : fs72.writeSync(this.fd, buf, "utf8");
10300
10300
  const releasedBufObj = releaseWritingBuf(buf, this._len, n);
10301
10301
  buf = releasedBufObj.writingBuf;
10302
10302
  this._len = releasedBufObj.len;
@@ -10312,7 +10312,7 @@ var require_sonic_boom = __commonJS({
10312
10312
  }
10313
10313
  }
10314
10314
  try {
10315
- fs71.fsyncSync(this.fd);
10315
+ fs72.fsyncSync(this.fd);
10316
10316
  } catch {
10317
10317
  }
10318
10318
  }
@@ -10333,7 +10333,7 @@ var require_sonic_boom = __commonJS({
10333
10333
  buf = mergeBuf(this._bufs[0], this._lens[0]);
10334
10334
  }
10335
10335
  try {
10336
- const n = fs71.writeSync(this.fd, buf);
10336
+ const n = fs72.writeSync(this.fd, buf);
10337
10337
  buf = buf.subarray(n);
10338
10338
  this._len = Math.max(this._len - n, 0);
10339
10339
  if (buf.length <= 0) {
@@ -10361,13 +10361,13 @@ var require_sonic_boom = __commonJS({
10361
10361
  this._writingBuf = this._writingBuf.length ? this._writingBuf : this._bufs.shift() || "";
10362
10362
  if (this.sync) {
10363
10363
  try {
10364
- const written = Buffer.isBuffer(this._writingBuf) ? fs71.writeSync(this.fd, this._writingBuf) : fs71.writeSync(this.fd, this._writingBuf, "utf8");
10364
+ const written = Buffer.isBuffer(this._writingBuf) ? fs72.writeSync(this.fd, this._writingBuf) : fs72.writeSync(this.fd, this._writingBuf, "utf8");
10365
10365
  release(null, written);
10366
10366
  } catch (err) {
10367
10367
  release(err);
10368
10368
  }
10369
10369
  } else {
10370
- fs71.write(this.fd, this._writingBuf, release);
10370
+ fs72.write(this.fd, this._writingBuf, release);
10371
10371
  }
10372
10372
  }
10373
10373
  function actualWriteBuffer() {
@@ -10376,7 +10376,7 @@ var require_sonic_boom = __commonJS({
10376
10376
  this._writingBuf = this._writingBuf.length ? this._writingBuf : mergeBuf(this._bufs.shift(), this._lens.shift());
10377
10377
  if (this.sync) {
10378
10378
  try {
10379
- const written = fs71.writeSync(this.fd, this._writingBuf);
10379
+ const written = fs72.writeSync(this.fd, this._writingBuf);
10380
10380
  release(null, written);
10381
10381
  } catch (err) {
10382
10382
  release(err);
@@ -10385,7 +10385,7 @@ var require_sonic_boom = __commonJS({
10385
10385
  if (kCopyBuffer) {
10386
10386
  this._writingBuf = Buffer.from(this._writingBuf);
10387
10387
  }
10388
- fs71.write(this.fd, this._writingBuf, release);
10388
+ fs72.write(this.fd, this._writingBuf, release);
10389
10389
  }
10390
10390
  }
10391
10391
  function actualClose(sonic) {
@@ -10401,12 +10401,12 @@ var require_sonic_boom = __commonJS({
10401
10401
  sonic._lens = [];
10402
10402
  assert(typeof sonic.fd === "number", `sonic.fd must be a number, got ${typeof sonic.fd}`);
10403
10403
  try {
10404
- fs71.fsync(sonic.fd, closeWrapped);
10404
+ fs72.fsync(sonic.fd, closeWrapped);
10405
10405
  } catch {
10406
10406
  }
10407
10407
  function closeWrapped() {
10408
10408
  if (sonic.fd !== 1 && sonic.fd !== 2) {
10409
- fs71.close(sonic.fd, done);
10409
+ fs72.close(sonic.fd, done);
10410
10410
  } else {
10411
10411
  done();
10412
10412
  }
@@ -11287,29 +11287,29 @@ var require_tools = __commonJS({
11287
11287
  }
11288
11288
  }
11289
11289
  }
11290
- function asString(str4) {
11290
+ function asString(str5) {
11291
11291
  let result = "";
11292
11292
  let last = 0;
11293
11293
  let found = false;
11294
11294
  let point = 255;
11295
- const l = str4.length;
11295
+ const l = str5.length;
11296
11296
  if (l > 100) {
11297
- return JSON.stringify(str4);
11297
+ return JSON.stringify(str5);
11298
11298
  }
11299
11299
  for (var i = 0; i < l && point >= 32; i++) {
11300
- point = str4.charCodeAt(i);
11300
+ point = str5.charCodeAt(i);
11301
11301
  if (point === 34 || point === 92) {
11302
- result += str4.slice(last, i) + "\\";
11302
+ result += str5.slice(last, i) + "\\";
11303
11303
  last = i;
11304
11304
  found = true;
11305
11305
  }
11306
11306
  }
11307
11307
  if (!found) {
11308
- result = str4;
11308
+ result = str5;
11309
11309
  } else {
11310
- result += str4.slice(last);
11310
+ result += str5.slice(last);
11311
11311
  }
11312
- return point < 32 ? JSON.stringify(str4) : '"' + result + '"';
11312
+ return point < 32 ? JSON.stringify(str5) : '"' + result + '"';
11313
11313
  }
11314
11314
  function asJson(obj, msg, num3, time) {
11315
11315
  if (asJsonChan.hasSubscribers === false) {
@@ -12015,11 +12015,11 @@ var require_safe_stable_stringify = __commonJS({
12015
12015
  exports2.configure = configure;
12016
12016
  module2.exports = stringify;
12017
12017
  var strEscapeSequencesRegExp = /[\u0000-\u001f\u0022\u005c\ud800-\udfff]/;
12018
- function strEscape(str4) {
12019
- if (str4.length < 5e3 && !strEscapeSequencesRegExp.test(str4)) {
12020
- return `"${str4}"`;
12018
+ function strEscape(str5) {
12019
+ if (str5.length < 5e3 && !strEscapeSequencesRegExp.test(str5)) {
12020
+ return `"${str5}"`;
12021
12021
  }
12022
- return JSON.stringify(str4);
12022
+ return JSON.stringify(str5);
12023
12023
  }
12024
12024
  function sort(array, comparator) {
12025
12025
  if (array.length > 200 || comparator) {
@@ -14063,12 +14063,12 @@ function attachmentToHistoryMessage(o, ts) {
14063
14063
  const raw = Array.isArray(a.memories) ? a.memories : [];
14064
14064
  const memories = raw.map((m2) => {
14065
14065
  if (!m2 || typeof m2 !== "object") return null;
14066
- const rec3 = m2;
14067
- const path81 = typeof rec3.path === "string" ? rec3.path : null;
14068
- const content = typeof rec3.content === "string" ? rec3.content : null;
14066
+ const rec4 = m2;
14067
+ const path81 = typeof rec4.path === "string" ? rec4.path : null;
14068
+ const content = typeof rec4.content === "string" ? rec4.content : null;
14069
14069
  if (!path81 || content == null) return null;
14070
14070
  const entry = { path: path81, content };
14071
- if (typeof rec3.mtimeMs === "number") entry.mtimeMs = rec3.mtimeMs;
14071
+ if (typeof rec4.mtimeMs === "number") entry.mtimeMs = rec4.mtimeMs;
14072
14072
  return entry;
14073
14073
  }).filter((m2) => m2 !== null);
14074
14074
  if (memories.length === 0) return null;
@@ -14887,12 +14887,12 @@ function parseAttachment(obj) {
14887
14887
  const raw = Array.isArray(a.memories) ? a.memories : [];
14888
14888
  const memories = raw.map((m2) => {
14889
14889
  if (!m2 || typeof m2 !== "object") return null;
14890
- const rec3 = m2;
14891
- const path81 = typeof rec3.path === "string" ? rec3.path : null;
14892
- const content = typeof rec3.content === "string" ? rec3.content : null;
14890
+ const rec4 = m2;
14891
+ const path81 = typeof rec4.path === "string" ? rec4.path : null;
14892
+ const content = typeof rec4.content === "string" ? rec4.content : null;
14893
14893
  if (!path81 || content == null) return null;
14894
14894
  const out = { path: path81, content };
14895
- if (typeof rec3.mtimeMs === "number") out.mtimeMs = rec3.mtimeMs;
14895
+ if (typeof rec4.mtimeMs === "number") out.mtimeMs = rec4.mtimeMs;
14896
14896
  return out;
14897
14897
  }).filter((m2) => m2 !== null);
14898
14898
  if (memories.length === 0) return null;
@@ -21811,14 +21811,14 @@ var require_luxon = __commonJS({
21811
21811
  tibt: [3872, 3881]
21812
21812
  };
21813
21813
  var hanidecChars = numberingSystems.hanidec.replace(/[\[|\]]/g, "").split("");
21814
- function parseDigits(str4) {
21815
- let value = parseInt(str4, 10);
21814
+ function parseDigits(str5) {
21815
+ let value = parseInt(str5, 10);
21816
21816
  if (isNaN(value)) {
21817
21817
  value = "";
21818
- for (let i = 0; i < str4.length; i++) {
21819
- const code = str4.charCodeAt(i);
21820
- if (str4[i].search(numberingSystems.hanidec) !== -1) {
21821
- value += hanidecChars.indexOf(str4[i]);
21818
+ for (let i = 0; i < str5.length; i++) {
21819
+ const code = str5.charCodeAt(i);
21820
+ if (str5[i].search(numberingSystems.hanidec) !== -1) {
21821
+ value += hanidecChars.indexOf(str5[i]);
21822
21822
  } else {
21823
21823
  for (const key in numberingSystemsUTF16) {
21824
21824
  const [min, max] = numberingSystemsUTF16[key];
@@ -28817,10 +28817,10 @@ var require_random = __commonJS({
28817
28817
  "use strict";
28818
28818
  Object.defineProperty(exports2, "__esModule", { value: true });
28819
28819
  exports2.seededRandom = seededRandom;
28820
- function xfnv1a(str4) {
28820
+ function xfnv1a(str5) {
28821
28821
  let h = 2166136261 >>> 0;
28822
- for (let i = 0; i < str4.length; i++) {
28823
- h ^= str4.charCodeAt(i);
28822
+ for (let i = 0; i < str5.length; i++) {
28823
+ h ^= str5.charCodeAt(i);
28824
28824
  h = Math.imul(h, 16777619);
28825
28825
  }
28826
28826
  return () => h >>> 0;
@@ -28833,8 +28833,8 @@ var require_random = __commonJS({
28833
28833
  return ((t ^ t >>> 14) >>> 0) / 4294967296;
28834
28834
  };
28835
28835
  }
28836
- function seededRandom(str4) {
28837
- const seed = str4 ? xfnv1a(str4)() : Math.floor(Math.random() * 1e10);
28836
+ function seededRandom(str5) {
28837
+ const seed = str5 ? xfnv1a(str5)() : Math.floor(Math.random() * 1e10);
28838
28838
  return mulberry32(seed);
28839
28839
  }
28840
28840
  }
@@ -34751,19 +34751,19 @@ var require_stream_readable = __commonJS({
34751
34751
  var ret = p2.data;
34752
34752
  n -= ret.length;
34753
34753
  while (p2 = p2.next) {
34754
- var str4 = p2.data;
34755
- var nb = n > str4.length ? str4.length : n;
34756
- if (nb === str4.length) ret += str4;
34757
- else ret += str4.slice(0, n);
34754
+ var str5 = p2.data;
34755
+ var nb = n > str5.length ? str5.length : n;
34756
+ if (nb === str5.length) ret += str5;
34757
+ else ret += str5.slice(0, n);
34758
34758
  n -= nb;
34759
34759
  if (n === 0) {
34760
- if (nb === str4.length) {
34760
+ if (nb === str5.length) {
34761
34761
  ++c;
34762
34762
  if (p2.next) list.head = p2.next;
34763
34763
  else list.head = list.tail = null;
34764
34764
  } else {
34765
34765
  list.head = p2;
34766
- p2.data = str4.slice(nb);
34766
+ p2.data = str5.slice(nb);
34767
34767
  }
34768
34768
  break;
34769
34769
  }
@@ -35659,14 +35659,14 @@ var require_utils = __commonJS({
35659
35659
  var nodejsUtils = require_nodejsUtils();
35660
35660
  var external = require_external();
35661
35661
  require_setImmediate();
35662
- function string2binary(str4) {
35662
+ function string2binary(str5) {
35663
35663
  var result = null;
35664
35664
  if (support.uint8array) {
35665
- result = new Uint8Array(str4.length);
35665
+ result = new Uint8Array(str5.length);
35666
35666
  } else {
35667
- result = new Array(str4.length);
35667
+ result = new Array(str5.length);
35668
35668
  }
35669
- return stringToArrayLike(str4, result);
35669
+ return stringToArrayLike(str5, result);
35670
35670
  }
35671
35671
  exports2.newBlob = function(part, type) {
35672
35672
  exports2.checkSupport("blob");
@@ -35688,9 +35688,9 @@ var require_utils = __commonJS({
35688
35688
  function identity(input) {
35689
35689
  return input;
35690
35690
  }
35691
- function stringToArrayLike(str4, array) {
35692
- for (var i = 0; i < str4.length; ++i) {
35693
- array[i] = str4.charCodeAt(i) & 255;
35691
+ function stringToArrayLike(str5, array) {
35692
+ for (var i = 0; i < str5.length; ++i) {
35693
+ array[i] = str5.charCodeAt(i) & 255;
35694
35694
  }
35695
35695
  return array;
35696
35696
  }
@@ -35903,10 +35903,10 @@ var require_utils = __commonJS({
35903
35903
  };
35904
35904
  exports2.MAX_VALUE_16BITS = 65535;
35905
35905
  exports2.MAX_VALUE_32BITS = -1;
35906
- exports2.pretty = function(str4) {
35906
+ exports2.pretty = function(str5) {
35907
35907
  var res = "", code, i;
35908
- for (i = 0; i < (str4 || "").length; i++) {
35909
- code = str4.charCodeAt(i);
35908
+ for (i = 0; i < (str5 || "").length; i++) {
35909
+ code = str5.charCodeAt(i);
35910
35910
  res += "\\x" + (code < 16 ? "0" : "") + code.toString(16).toUpperCase();
35911
35911
  }
35912
35912
  return res;
@@ -36216,12 +36216,12 @@ var require_utf8 = __commonJS({
36216
36216
  }
36217
36217
  var i;
36218
36218
  _utf8len[254] = _utf8len[254] = 1;
36219
- var string2buf = function(str4) {
36220
- var buf, c, c2, m_pos, i2, str_len = str4.length, buf_len = 0;
36219
+ var string2buf = function(str5) {
36220
+ var buf, c, c2, m_pos, i2, str_len = str5.length, buf_len = 0;
36221
36221
  for (m_pos = 0; m_pos < str_len; m_pos++) {
36222
- c = str4.charCodeAt(m_pos);
36222
+ c = str5.charCodeAt(m_pos);
36223
36223
  if ((c & 64512) === 55296 && m_pos + 1 < str_len) {
36224
- c2 = str4.charCodeAt(m_pos + 1);
36224
+ c2 = str5.charCodeAt(m_pos + 1);
36225
36225
  if ((c2 & 64512) === 56320) {
36226
36226
  c = 65536 + (c - 55296 << 10) + (c2 - 56320);
36227
36227
  m_pos++;
@@ -36235,9 +36235,9 @@ var require_utf8 = __commonJS({
36235
36235
  buf = new Array(buf_len);
36236
36236
  }
36237
36237
  for (i2 = 0, m_pos = 0; i2 < buf_len; m_pos++) {
36238
- c = str4.charCodeAt(m_pos);
36238
+ c = str5.charCodeAt(m_pos);
36239
36239
  if ((c & 64512) === 55296 && m_pos + 1 < str_len) {
36240
- c2 = str4.charCodeAt(m_pos + 1);
36240
+ c2 = str5.charCodeAt(m_pos + 1);
36241
36241
  if ((c2 & 64512) === 56320) {
36242
36242
  c = 65536 + (c - 55296 << 10) + (c2 - 56320);
36243
36243
  m_pos++;
@@ -36321,11 +36321,11 @@ var require_utf8 = __commonJS({
36321
36321
  }
36322
36322
  return utils.applyFromCharCode(utf16buf);
36323
36323
  };
36324
- exports2.utf8encode = function utf8encode(str4) {
36324
+ exports2.utf8encode = function utf8encode(str5) {
36325
36325
  if (support.nodebuffer) {
36326
- return nodejsUtils.newBufferFrom(str4, "utf-8");
36326
+ return nodejsUtils.newBufferFrom(str5, "utf-8");
36327
36327
  }
36328
- return string2buf(str4);
36328
+ return string2buf(str5);
36329
36329
  };
36330
36330
  exports2.utf8decode = function utf8decode(buf) {
36331
36331
  if (support.nodebuffer) {
@@ -36734,11 +36734,11 @@ var require_crc32 = __commonJS({
36734
36734
  }
36735
36735
  return crc ^ -1;
36736
36736
  }
36737
- function crc32str(crc, str4, len, pos) {
36737
+ function crc32str(crc, str5, len, pos) {
36738
36738
  var t = crcTable, end = pos + len;
36739
36739
  crc = crc ^ -1;
36740
36740
  for (var i = pos; i < end; i++) {
36741
- crc = crc >>> 8 ^ t[(crc ^ str4.charCodeAt(i)) & 255];
36741
+ crc = crc >>> 8 ^ t[(crc ^ str5.charCodeAt(i)) & 255];
36742
36742
  }
36743
36743
  return crc ^ -1;
36744
36744
  }
@@ -37935,7 +37935,7 @@ var require_deflate = __commonJS({
37935
37935
  }
37936
37936
  function fill_window(s) {
37937
37937
  var _w_size = s.w_size;
37938
- var p2, n, m2, more, str4;
37938
+ var p2, n, m2, more, str5;
37939
37939
  do {
37940
37940
  more = s.window_size - s.lookahead - s.strstart;
37941
37941
  if (s.strstart >= _w_size + (_w_size - MIN_LOOKAHEAD)) {
@@ -37963,14 +37963,14 @@ var require_deflate = __commonJS({
37963
37963
  n = read_buf(s.strm, s.window, s.strstart + s.lookahead, more);
37964
37964
  s.lookahead += n;
37965
37965
  if (s.lookahead + s.insert >= MIN_MATCH) {
37966
- str4 = s.strstart - s.insert;
37967
- s.ins_h = s.window[str4];
37968
- s.ins_h = (s.ins_h << s.hash_shift ^ s.window[str4 + 1]) & s.hash_mask;
37966
+ str5 = s.strstart - s.insert;
37967
+ s.ins_h = s.window[str5];
37968
+ s.ins_h = (s.ins_h << s.hash_shift ^ s.window[str5 + 1]) & s.hash_mask;
37969
37969
  while (s.insert) {
37970
- s.ins_h = (s.ins_h << s.hash_shift ^ s.window[str4 + MIN_MATCH - 1]) & s.hash_mask;
37971
- s.prev[str4 & s.w_mask] = s.head[s.ins_h];
37972
- s.head[s.ins_h] = str4;
37973
- str4++;
37970
+ s.ins_h = (s.ins_h << s.hash_shift ^ s.window[str5 + MIN_MATCH - 1]) & s.hash_mask;
37971
+ s.prev[str5 & s.w_mask] = s.head[s.ins_h];
37972
+ s.head[s.ins_h] = str5;
37973
+ str5++;
37974
37974
  s.insert--;
37975
37975
  if (s.lookahead + s.insert < MIN_MATCH) {
37976
37976
  break;
@@ -38746,7 +38746,7 @@ var require_deflate = __commonJS({
38746
38746
  function deflateSetDictionary(strm, dictionary) {
38747
38747
  var dictLength = dictionary.length;
38748
38748
  var s;
38749
- var str4, n;
38749
+ var str5, n;
38750
38750
  var wrap2;
38751
38751
  var avail;
38752
38752
  var next;
@@ -38784,15 +38784,15 @@ var require_deflate = __commonJS({
38784
38784
  strm.input = dictionary;
38785
38785
  fill_window(s);
38786
38786
  while (s.lookahead >= MIN_MATCH) {
38787
- str4 = s.strstart;
38787
+ str5 = s.strstart;
38788
38788
  n = s.lookahead - (MIN_MATCH - 1);
38789
38789
  do {
38790
- s.ins_h = (s.ins_h << s.hash_shift ^ s.window[str4 + MIN_MATCH - 1]) & s.hash_mask;
38791
- s.prev[str4 & s.w_mask] = s.head[s.ins_h];
38792
- s.head[s.ins_h] = str4;
38793
- str4++;
38790
+ s.ins_h = (s.ins_h << s.hash_shift ^ s.window[str5 + MIN_MATCH - 1]) & s.hash_mask;
38791
+ s.prev[str5 & s.w_mask] = s.head[s.ins_h];
38792
+ s.head[s.ins_h] = str5;
38793
+ str5++;
38794
38794
  } while (--n);
38795
- s.strstart = str4;
38795
+ s.strstart = str5;
38796
38796
  s.lookahead = MIN_MATCH - 1;
38797
38797
  fill_window(s);
38798
38798
  }
@@ -38843,12 +38843,12 @@ var require_strings = __commonJS({
38843
38843
  }
38844
38844
  var q;
38845
38845
  _utf8len[254] = _utf8len[254] = 1;
38846
- exports2.string2buf = function(str4) {
38847
- var buf, c, c2, m_pos, i, str_len = str4.length, buf_len = 0;
38846
+ exports2.string2buf = function(str5) {
38847
+ var buf, c, c2, m_pos, i, str_len = str5.length, buf_len = 0;
38848
38848
  for (m_pos = 0; m_pos < str_len; m_pos++) {
38849
- c = str4.charCodeAt(m_pos);
38849
+ c = str5.charCodeAt(m_pos);
38850
38850
  if ((c & 64512) === 55296 && m_pos + 1 < str_len) {
38851
- c2 = str4.charCodeAt(m_pos + 1);
38851
+ c2 = str5.charCodeAt(m_pos + 1);
38852
38852
  if ((c2 & 64512) === 56320) {
38853
38853
  c = 65536 + (c - 55296 << 10) + (c2 - 56320);
38854
38854
  m_pos++;
@@ -38858,9 +38858,9 @@ var require_strings = __commonJS({
38858
38858
  }
38859
38859
  buf = new utils.Buf8(buf_len);
38860
38860
  for (i = 0, m_pos = 0; i < buf_len; m_pos++) {
38861
- c = str4.charCodeAt(m_pos);
38861
+ c = str5.charCodeAt(m_pos);
38862
38862
  if ((c & 64512) === 55296 && m_pos + 1 < str_len) {
38863
- c2 = str4.charCodeAt(m_pos + 1);
38863
+ c2 = str5.charCodeAt(m_pos + 1);
38864
38864
  if ((c2 & 64512) === 56320) {
38865
38865
  c = 65536 + (c - 55296 << 10) + (c2 - 56320);
38866
38866
  m_pos++;
@@ -38899,10 +38899,10 @@ var require_strings = __commonJS({
38899
38899
  exports2.buf2binstring = function(buf) {
38900
38900
  return buf2binstring(buf, buf.length);
38901
38901
  };
38902
- exports2.binstring2buf = function(str4) {
38903
- var buf = new utils.Buf8(str4.length);
38902
+ exports2.binstring2buf = function(str5) {
38903
+ var buf = new utils.Buf8(str5.length);
38904
38904
  for (var i = 0, len = buf.length; i < len; i++) {
38905
- buf[i] = str4.charCodeAt(i);
38905
+ buf[i] = str5.charCodeAt(i);
38906
38906
  }
38907
38907
  return buf;
38908
38908
  };
@@ -43609,9 +43609,9 @@ async function sendBatch(deps, batch) {
43609
43609
  }
43610
43610
  return { sent: 0, failed: batch.records.length };
43611
43611
  }
43612
- function stringifyRecord(rec3) {
43612
+ function stringifyRecord(rec4) {
43613
43613
  const out = {};
43614
- for (const [k2, v2] of Object.entries(rec3)) {
43614
+ for (const [k2, v2] of Object.entries(rec4)) {
43615
43615
  if (v2 == null) continue;
43616
43616
  out[k2] = typeof v2 === "string" ? v2 : String(v2);
43617
43617
  }
@@ -46551,6 +46551,27 @@ var SessionManager = class {
46551
46551
  if (!existing || existing.cwd === cwd) return;
46552
46552
  this.writeOwned({ ...existing, cwd, updatedAt: nowIso2(this.deps) });
46553
46553
  }
46554
+ /**
46555
+ * 外部探测来的会话元信息回填入口(当前唯一消费方:codex 会话打开时从 rollout 读到的
46556
+ * 实际 model / effort,见 tools/codex-turn-context.ts)。走 reducer 的 meta_update 通道 →
46557
+ * persist-file + session:info,与 CC 侧 `parseLine` 抽出来的 meta_update 完全同路。
46558
+ *
46559
+ * 与 `feedObserverEvents` 的区别:这不是 observer 回灌——不带 uuid、不参与 turn 判定,
46560
+ * 也不受那条 SDK 模式的 procAlive 守卫(守卫是为"daemon 自己在消费 stdout,observer 读到的
46561
+ * 是同一帧副本"设的;主动探测来的 meta 没有重复源,被吞掉就永远补不上)。
46562
+ *
46563
+ * 无 runner 时先 ensureSession(只建 state 容器不 spawn,同 session:observe 的前置),
46564
+ * 否则 meta_update 无处可落。幂等由 reducer 的 shallowEqMeta 保证;session 不存在静默返回。
46565
+ */
46566
+ applyResolvedMeta(sessionId, patch) {
46567
+ let runner = this.runners.get(sessionId);
46568
+ if (!runner) {
46569
+ const file = this.findOwnedSession(sessionId);
46570
+ if (!file) return;
46571
+ runner = this.ensureSession(file);
46572
+ }
46573
+ runner.input({ kind: "inject-events", events: [{ kind: "meta_update", patch }] });
46574
+ }
46554
46575
  /**
46555
46576
  * 启动清扫:删除所有磁盘残留的 ephemeral(快速问答临时)session。
46556
46577
  * 客户端崩溃 / 没关抽屉会留下永久不可见的孤儿(ephemeral 被 sidebar 过滤,用户自己也删不掉)。
@@ -51347,7 +51368,7 @@ function createDispatchStore(deps) {
51347
51368
  return records.find((r) => r.dispatchId === dispatchId);
51348
51369
  }
51349
51370
  function add(input) {
51350
- const rec3 = {
51371
+ const rec4 = {
51351
51372
  dispatchId: input.dispatchId,
51352
51373
  sourceSessionId: input.sourceSessionId,
51353
51374
  ...input.sourcePersonaId ? { sourcePersonaId: input.sourcePersonaId } : {},
@@ -51357,9 +51378,9 @@ function createDispatchStore(deps) {
51357
51378
  ...input.meta ? { meta: input.meta } : {},
51358
51379
  createdAt: new Date(deps.now()).toISOString()
51359
51380
  };
51360
- records.push(rec3);
51381
+ records.push(rec4);
51361
51382
  scheduleFlush();
51362
- return rec3;
51383
+ return rec4;
51363
51384
  }
51364
51385
  function update(dispatchId, patch) {
51365
51386
  const idx = records.findIndex((r) => r.dispatchId === dispatchId);
@@ -52451,11 +52472,11 @@ function createLarkBotCloudClient(opts) {
52451
52472
  const json = await request("POST", "/api/lark-bot/events/claim?v=2");
52452
52473
  const items = json.items ?? [];
52453
52474
  return items.map((it) => {
52454
- const rec3 = it;
52455
- if (rec3 && typeof rec3 === "object" && "payload" in rec3) {
52475
+ const rec4 = it;
52476
+ if (rec4 && typeof rec4 === "object" && "payload" in rec4) {
52456
52477
  return {
52457
- status: rec3.status === "forwarded" ? "forwarded" : "received",
52458
- payload: rec3.payload
52478
+ status: rec4.status === "forwarded" ? "forwarded" : "received",
52479
+ payload: rec4.payload
52459
52480
  };
52460
52481
  }
52461
52482
  return { status: "received", payload: it };
@@ -52927,20 +52948,20 @@ function buildPersonaDispatchHandlers(deps) {
52927
52948
  "follow-up dispatch cannot be initiated by a guest"
52928
52949
  );
52929
52950
  }
52930
- const rec3 = deps.store.get(args.dispatchId);
52931
- if (!rec3) {
52951
+ const rec4 = deps.store.get(args.dispatchId);
52952
+ if (!rec4) {
52932
52953
  throw new ClawdError(ERROR_CODES.INVALID_PARAM, `dispatch not found: ${args.dispatchId}`);
52933
52954
  }
52934
- if (!rec3.workerSessionId) {
52955
+ if (!rec4.workerSessionId) {
52935
52956
  throw new ClawdError(
52936
52957
  ERROR_CODES.INVALID_PARAM,
52937
52958
  `dispatch ${args.dispatchId} has no worker session and cannot be continued (cross-device or spawn incomplete)`
52938
52959
  );
52939
52960
  }
52940
- if (args.targetPersona && args.targetPersona !== rec3.targetPersonaId) {
52961
+ if (args.targetPersona && args.targetPersona !== rec4.targetPersonaId) {
52941
52962
  throw new ClawdError(
52942
52963
  ERROR_CODES.INVALID_PARAM,
52943
- `targetPersona mismatch: dispatch ${args.dispatchId} belongs to ${rec3.targetPersonaId}`
52964
+ `targetPersona mismatch: dispatch ${args.dispatchId} belongs to ${rec4.targetPersonaId}`
52944
52965
  );
52945
52966
  }
52946
52967
  if (!deps.sendFollowUp) {
@@ -52955,16 +52976,16 @@ function buildPersonaDispatchHandlers(deps) {
52955
52976
  });
52956
52977
  mgr.reopen(args.dispatchId, {
52957
52978
  sourceSessionId,
52958
- targetPersona: rec3.targetPersonaId,
52959
- workerSessionId: rec3.workerSessionId
52979
+ targetPersona: rec4.targetPersonaId,
52980
+ workerSessionId: rec4.workerSessionId
52960
52981
  });
52961
52982
  logger?.info("dispatch.run.follow-up", {
52962
52983
  dispatchId: args.dispatchId,
52963
- workerSessionId: rec3.workerSessionId,
52984
+ workerSessionId: rec4.workerSessionId,
52964
52985
  promptLen: args.prompt.length
52965
52986
  });
52966
52987
  const ok = deps.sendFollowUp(
52967
- rec3.workerSessionId,
52988
+ rec4.workerSessionId,
52968
52989
  buildFollowUpTaskPack(args.dispatchId, args.prompt)
52969
52990
  );
52970
52991
  if (!ok) {
@@ -53111,16 +53132,16 @@ function buildPersonaDispatchHandlers(deps) {
53111
53132
  const get = async (frame, _client, ctx) => {
53112
53133
  const { type: _t, requestId: _r, ...rest } = frame;
53113
53134
  const args = DispatchGetArgsSchema.parse(rest);
53114
- const rec3 = deps.store.get(args.dispatchId);
53115
- const denied = ctx?.principal.kind === "guest" && rec3?.sourceSessionId !== ctx.principal.id;
53116
- if (!rec3 || denied) {
53135
+ const rec4 = deps.store.get(args.dispatchId);
53136
+ const denied = ctx?.principal.kind === "guest" && rec4?.sourceSessionId !== ctx.principal.id;
53137
+ if (!rec4 || denied) {
53117
53138
  throw new ClawdError(ERROR_CODES.DISPATCH_NOT_FOUND, `unknown dispatchId: ${args.dispatchId}`);
53118
53139
  }
53119
53140
  return {
53120
53141
  response: {
53121
53142
  type: "personaDispatch:get:ok",
53122
- status: rec3.status,
53123
- ...rec3.outcome ? { outcome: rec3.outcome } : {}
53143
+ status: rec4.status,
53144
+ ...rec4.outcome ? { outcome: rec4.outcome } : {}
53124
53145
  }
53125
53146
  };
53126
53147
  };
@@ -53497,6 +53518,84 @@ async function listCodexSkills(cwd, deps = {}) {
53497
53518
  return mapSkillsListResponse(res);
53498
53519
  }
53499
53520
 
53521
+ // src/tools/codex-turn-context.ts
53522
+ var import_promises3 = __toESM(require("fs/promises"), 1);
53523
+ function parseTurnContextFromRollout(raw) {
53524
+ const lines = raw.split("\n");
53525
+ for (let i = lines.length - 1; i >= 0; i--) {
53526
+ const line = lines[i];
53527
+ if (!line || !line.includes('"turn_context"')) continue;
53528
+ let obj;
53529
+ try {
53530
+ obj = JSON.parse(line);
53531
+ } catch {
53532
+ continue;
53533
+ }
53534
+ const o = rec3(obj);
53535
+ if (o?.type !== "turn_context") continue;
53536
+ const payload = rec3(o.payload);
53537
+ if (!payload) continue;
53538
+ const out = {};
53539
+ if (typeof payload.model === "string" && payload.model) out.model = payload.model;
53540
+ if (typeof payload.effort === "string" && payload.effort) out.effort = payload.effort;
53541
+ if (!out.model && !out.effort) continue;
53542
+ return out;
53543
+ }
53544
+ return null;
53545
+ }
53546
+ async function readCodexTurnContext(args, deps = {}) {
53547
+ const res = rec3(
53548
+ await queryCodexAppServer(
53549
+ args.cwd,
53550
+ "thread/read",
53551
+ { threadId: args.threadId, includeTurns: false },
53552
+ deps
53553
+ )
53554
+ );
53555
+ const rolloutPath = str4(rec3(res?.thread)?.path);
53556
+ if (!rolloutPath) return null;
53557
+ return parseTurnContextFromRollout(await import_promises3.default.readFile(rolloutPath, "utf8"));
53558
+ }
53559
+ function createCodexResolvedMetaHydrator(deps) {
53560
+ const fetchedThreadIds = /* @__PURE__ */ new Set();
53561
+ return async (sessionId) => {
53562
+ const target = deps.getSession(sessionId);
53563
+ if (!target) return;
53564
+ if ((target.tool ?? "claude") !== "codex") return;
53565
+ const threadId = target.toolSessionId;
53566
+ if (!threadId) return;
53567
+ if (target.resolvedModel && target.resolvedEffort) return;
53568
+ if (fetchedThreadIds.has(threadId)) return;
53569
+ fetchedThreadIds.add(threadId);
53570
+ try {
53571
+ const ctx = await deps.readTurnContext({ cwd: target.cwd, threadId });
53572
+ if (!ctx) {
53573
+ deps.logger?.debug("codex turn_context not found", { sessionId, threadId });
53574
+ return;
53575
+ }
53576
+ const patch = {};
53577
+ if (ctx.model) patch.resolvedModel = ctx.model;
53578
+ if (ctx.effort) patch.resolvedEffort = ctx.effort;
53579
+ if (Object.keys(patch).length === 0) return;
53580
+ deps.applyMeta(sessionId, patch);
53581
+ deps.logger?.debug("codex resolved meta hydrated", { sessionId, threadId, ...patch });
53582
+ } catch (err) {
53583
+ fetchedThreadIds.delete(threadId);
53584
+ deps.logger?.warn("codex resolved meta hydrate failed", {
53585
+ sessionId,
53586
+ threadId,
53587
+ error: err.message
53588
+ });
53589
+ }
53590
+ };
53591
+ }
53592
+ function rec3(v2) {
53593
+ return typeof v2 === "object" && v2 !== null ? v2 : void 0;
53594
+ }
53595
+ function str4(v2) {
53596
+ return typeof v2 === "string" && v2 ? v2 : void 0;
53597
+ }
53598
+
53500
53599
  // src/workspace/browser.ts
53501
53600
  var import_node_fs28 = __toESM(require("fs"), 1);
53502
53601
  var import_node_os8 = __toESM(require("os"), 1);
@@ -54841,7 +54940,7 @@ async function authenticate(token, deps) {
54841
54940
  }
54842
54941
 
54843
54942
  // src/legacy-cleanup.ts
54844
- var fs36 = __toESM(require("fs/promises"), 1);
54943
+ var fs37 = __toESM(require("fs/promises"), 1);
54845
54944
  var path38 = __toESM(require("path"), 1);
54846
54945
  var LEGACY_FILES = [
54847
54946
  "personal-capability.json",
@@ -54853,7 +54952,7 @@ async function cleanupLegacyCapabilityFiles(dataDir, logger) {
54853
54952
  for (const name of LEGACY_FILES) {
54854
54953
  const p2 = path38.join(dataDir, name);
54855
54954
  try {
54856
- await fs36.unlink(p2);
54955
+ await fs37.unlink(p2);
54857
54956
  removed.push(name);
54858
54957
  logger.debug("legacy capability file removed", { file: name });
54859
54958
  } catch (err) {
@@ -54865,13 +54964,13 @@ async function cleanupLegacyCapabilityFiles(dataDir, logger) {
54865
54964
  }
54866
54965
 
54867
54966
  // src/inbox/inbox-store.ts
54868
- var fs37 = __toESM(require("fs"), 1);
54967
+ var fs38 = __toESM(require("fs"), 1);
54869
54968
  var path39 = __toESM(require("path"), 1);
54870
54969
  var INBOX_SUBDIR = "inbox";
54871
54970
  var InboxStore = class {
54872
54971
  constructor(dataDir) {
54873
54972
  this.dataDir = dataDir;
54874
- fs37.mkdirSync(this.dirPath(), { recursive: true });
54973
+ fs38.mkdirSync(this.dirPath(), { recursive: true });
54875
54974
  }
54876
54975
  dataDir;
54877
54976
  /**
@@ -54883,7 +54982,7 @@ var InboxStore = class {
54883
54982
  const file = this.filePath(peerDeviceId);
54884
54983
  let raw;
54885
54984
  try {
54886
- raw = fs37.readFileSync(file, "utf8");
54985
+ raw = fs38.readFileSync(file, "utf8");
54887
54986
  } catch (err) {
54888
54987
  if (err?.code === "ENOENT") return [];
54889
54988
  return [];
@@ -54899,7 +54998,7 @@ var InboxStore = class {
54899
54998
  const dir = this.dirPath();
54900
54999
  let entries;
54901
55000
  try {
54902
- entries = fs37.readdirSync(dir);
55001
+ entries = fs38.readdirSync(dir);
54903
55002
  } catch (err) {
54904
55003
  if (err?.code === "ENOENT") return [];
54905
55004
  return [];
@@ -54915,9 +55014,9 @@ var InboxStore = class {
54915
55014
  if (existing.some((m2) => m2.id === message.id)) return;
54916
55015
  const file = this.filePath(message.peerDeviceId);
54917
55016
  const line = JSON.stringify(message) + "\n";
54918
- fs37.appendFileSync(file, line, { mode: 384 });
55017
+ fs38.appendFileSync(file, line, { mode: 384 });
54919
55018
  try {
54920
- fs37.chmodSync(file, 384);
55019
+ fs38.chmodSync(file, 384);
54921
55020
  } catch {
54922
55021
  }
54923
55022
  }
@@ -54947,7 +55046,7 @@ var InboxStore = class {
54947
55046
  removeByPeerDeviceId(peerDeviceId) {
54948
55047
  const file = this.filePath(peerDeviceId);
54949
55048
  try {
54950
- fs37.unlinkSync(file);
55049
+ fs38.unlinkSync(file);
54951
55050
  } catch (err) {
54952
55051
  if (err?.code === "ENOENT") return;
54953
55052
  }
@@ -54956,10 +55055,10 @@ var InboxStore = class {
54956
55055
  const file = this.filePath(peerDeviceId);
54957
55056
  const tmp = `${file}.tmp-${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2)}`;
54958
55057
  const content = messages.map((m2) => JSON.stringify(m2)).join("\n") + (messages.length > 0 ? "\n" : "");
54959
- fs37.writeFileSync(tmp, content, { mode: 384 });
54960
- fs37.renameSync(tmp, file);
55058
+ fs38.writeFileSync(tmp, content, { mode: 384 });
55059
+ fs38.renameSync(tmp, file);
54961
55060
  try {
54962
- fs37.chmodSync(file, 384);
55061
+ fs38.chmodSync(file, 384);
54963
55062
  } catch {
54964
55063
  }
54965
55064
  }
@@ -55055,7 +55154,7 @@ var InboxManager = class {
55055
55154
  };
55056
55155
 
55057
55156
  // src/state/contact-store.ts
55058
- var fs38 = __toESM(require("fs"), 1);
55157
+ var fs39 = __toESM(require("fs"), 1);
55059
55158
  var path40 = __toESM(require("path"), 1);
55060
55159
  var FILE_NAME = "contacts.json";
55061
55160
  var ContactStore = class {
@@ -55069,7 +55168,7 @@ var ContactStore = class {
55069
55168
  const file = path40.join(this.dataDir, FILE_NAME);
55070
55169
  let raw;
55071
55170
  try {
55072
- raw = fs38.readFileSync(file, "utf8");
55171
+ raw = fs39.readFileSync(file, "utf8");
55073
55172
  } catch (err) {
55074
55173
  if (err?.code !== "ENOENT") this.renameBak(file);
55075
55174
  return;
@@ -55145,13 +55244,13 @@ var ContactStore = class {
55145
55244
  null,
55146
55245
  2
55147
55246
  );
55148
- fs38.mkdirSync(this.dataDir, { recursive: true });
55149
- fs38.writeFileSync(tmp, content, { mode: 384 });
55150
- fs38.renameSync(tmp, file);
55247
+ fs39.mkdirSync(this.dataDir, { recursive: true });
55248
+ fs39.writeFileSync(tmp, content, { mode: 384 });
55249
+ fs39.renameSync(tmp, file);
55151
55250
  }
55152
55251
  renameBak(file) {
55153
55252
  try {
55154
- fs38.renameSync(file, `${file}.bak`);
55253
+ fs39.renameSync(file, `${file}.bak`);
55155
55254
  } catch {
55156
55255
  }
55157
55256
  }
@@ -55259,7 +55358,7 @@ async function connectRemote(args) {
55259
55358
  }
55260
55359
 
55261
55360
  // src/migrations/2026-05-20-flatten-sessions.ts
55262
- var fs39 = __toESM(require("fs"), 1);
55361
+ var fs40 = __toESM(require("fs"), 1);
55263
55362
  var path41 = __toESM(require("path"), 1);
55264
55363
  var MIGRATION_FLAG_NAME = ".migration.v1.done";
55265
55364
  function migrateFlattenSessions(opts) {
@@ -55279,7 +55378,7 @@ function migrateFlattenSessions(opts) {
55279
55378
  if (!entry.endsWith(".json")) continue;
55280
55379
  const src = path41.join(defaultDir, entry);
55281
55380
  const dst = path41.join(sessionsDir, entry);
55282
- fs39.renameSync(src, dst);
55381
+ fs40.renameSync(src, dst);
55283
55382
  movedBare += 1;
55284
55383
  }
55285
55384
  rmdirIfEmpty(defaultDir);
@@ -55291,10 +55390,10 @@ function migrateFlattenSessions(opts) {
55291
55390
  const ownerSrc = path41.join(personaDir, "owner");
55292
55391
  if (existsSync3(ownerSrc) && isDir(ownerSrc)) {
55293
55392
  const ownerDst = path41.join(dataDir, "personas", pid, ".clawd", "sessions", "owner");
55294
- fs39.mkdirSync(ownerDst, { recursive: true });
55393
+ fs40.mkdirSync(ownerDst, { recursive: true });
55295
55394
  for (const file of readdirSafe(ownerSrc)) {
55296
55395
  if (!file.endsWith(".json")) continue;
55297
- fs39.renameSync(path41.join(ownerSrc, file), path41.join(ownerDst, file));
55396
+ fs40.renameSync(path41.join(ownerSrc, file), path41.join(ownerDst, file));
55298
55397
  movedVmOwner += 1;
55299
55398
  }
55300
55399
  rmdirIfEmpty(ownerSrc);
@@ -55302,18 +55401,18 @@ function migrateFlattenSessions(opts) {
55302
55401
  const listenerSrc = path41.join(personaDir, "listener");
55303
55402
  if (existsSync3(listenerSrc) && isDir(listenerSrc)) {
55304
55403
  const archiveDst = path41.join(dataDir, ".legacy", `listener-${pid}`);
55305
- fs39.mkdirSync(archiveDst, { recursive: true });
55404
+ fs40.mkdirSync(archiveDst, { recursive: true });
55306
55405
  for (const file of readdirSafe(listenerSrc)) {
55307
55406
  if (!file.endsWith(".json")) continue;
55308
- fs39.renameSync(path41.join(listenerSrc, file), path41.join(archiveDst, file));
55407
+ fs40.renameSync(path41.join(listenerSrc, file), path41.join(archiveDst, file));
55309
55408
  archivedListener += 1;
55310
55409
  }
55311
55410
  rmdirIfEmpty(listenerSrc);
55312
55411
  }
55313
55412
  rmdirIfEmpty(personaDir);
55314
55413
  }
55315
- fs39.mkdirSync(sessionsDir, { recursive: true });
55316
- fs39.writeFileSync(flagPath, JSON.stringify({ migratedAt: now() }, null, 2));
55414
+ fs40.mkdirSync(sessionsDir, { recursive: true });
55415
+ fs40.writeFileSync(flagPath, JSON.stringify({ migratedAt: now() }, null, 2));
55317
55416
  return {
55318
55417
  skipped: false,
55319
55418
  flagWritten: true,
@@ -55324,7 +55423,7 @@ function migrateFlattenSessions(opts) {
55324
55423
  }
55325
55424
  function existsSync3(p2) {
55326
55425
  try {
55327
- fs39.statSync(p2);
55426
+ fs40.statSync(p2);
55328
55427
  return true;
55329
55428
  } catch {
55330
55429
  return false;
@@ -55332,21 +55431,21 @@ function existsSync3(p2) {
55332
55431
  }
55333
55432
  function isDir(p2) {
55334
55433
  try {
55335
- return fs39.statSync(p2).isDirectory();
55434
+ return fs40.statSync(p2).isDirectory();
55336
55435
  } catch {
55337
55436
  return false;
55338
55437
  }
55339
55438
  }
55340
55439
  function readdirSafe(p2) {
55341
55440
  try {
55342
- return fs39.readdirSync(p2);
55441
+ return fs40.readdirSync(p2);
55343
55442
  } catch {
55344
55443
  return [];
55345
55444
  }
55346
55445
  }
55347
55446
  function rmdirIfEmpty(p2) {
55348
55447
  try {
55349
- fs39.rmdirSync(p2);
55448
+ fs40.rmdirSync(p2);
55350
55449
  } catch {
55351
55450
  }
55352
55451
  }
@@ -55536,7 +55635,7 @@ function verifySignedUrl(secret, absPath, eRaw, s, now = Date.now) {
55536
55635
  var import_node_fs32 = __toESM(require("fs"), 1);
55537
55636
  var import_node_path35 = __toESM(require("path"), 1);
55538
55637
  var import_node_crypto8 = __toESM(require("crypto"), 1);
55539
- var import_promises3 = require("stream/promises");
55638
+ var import_promises4 = require("stream/promises");
55540
55639
  var UploadError = class extends Error {
55541
55640
  constructor(code, message) {
55542
55641
  super(message);
@@ -55566,7 +55665,7 @@ async function writeUploadedAttachment(args) {
55566
55665
  `.upload-${process.pid}-${Date.now()}-${import_node_crypto8.default.randomBytes(4).toString("hex")}`
55567
55666
  );
55568
55667
  try {
55569
- await (0, import_promises3.pipeline)(
55668
+ await (0, import_promises4.pipeline)(
55570
55669
  args.body,
55571
55670
  async function* (source) {
55572
55671
  for await (const chunk of source) {
@@ -55637,7 +55736,7 @@ async function writeUploadedAttachment(args) {
55637
55736
  }
55638
55737
 
55639
55738
  // src/extension/import.ts
55640
- var import_promises4 = __toESM(require("fs/promises"), 1);
55739
+ var import_promises5 = __toESM(require("fs/promises"), 1);
55641
55740
  var import_node_path36 = __toESM(require("path"), 1);
55642
55741
  var import_node_os12 = __toESM(require("os"), 1);
55643
55742
  var import_jszip = __toESM(require_lib3(), 1);
@@ -55692,30 +55791,30 @@ async function importZip(buf, root) {
55692
55791
  const destDir = import_node_path36.default.join(root, manifest.id);
55693
55792
  let destExists = false;
55694
55793
  try {
55695
- await import_promises4.default.access(destDir);
55794
+ await import_promises5.default.access(destDir);
55696
55795
  destExists = true;
55697
55796
  } catch {
55698
55797
  }
55699
55798
  if (destExists) {
55700
55799
  throw new ImportError("ALREADY_EXISTS", `extension ${manifest.id} already installed`);
55701
55800
  }
55702
- const stage = await import_promises4.default.mkdtemp(import_node_path36.default.join(import_node_os12.default.tmpdir(), `clawd-ext-stage-${manifest.id}-`));
55801
+ const stage = await import_promises5.default.mkdtemp(import_node_path36.default.join(import_node_os12.default.tmpdir(), `clawd-ext-stage-${manifest.id}-`));
55703
55802
  try {
55704
55803
  for (const [name, entry] of Object.entries(zip.files)) {
55705
55804
  const dest = import_node_path36.default.join(stage, name);
55706
55805
  if (entry.dir) {
55707
- await import_promises4.default.mkdir(dest, { recursive: true });
55806
+ await import_promises5.default.mkdir(dest, { recursive: true });
55708
55807
  continue;
55709
55808
  }
55710
- await import_promises4.default.mkdir(import_node_path36.default.dirname(dest), { recursive: true });
55809
+ await import_promises5.default.mkdir(import_node_path36.default.dirname(dest), { recursive: true });
55711
55810
  const content = await entry.async("nodebuffer");
55712
- await import_promises4.default.writeFile(dest, content);
55811
+ await import_promises5.default.writeFile(dest, content);
55713
55812
  }
55714
- await import_promises4.default.mkdir(root, { recursive: true });
55715
- await import_promises4.default.rename(stage, destDir);
55813
+ await import_promises5.default.mkdir(root, { recursive: true });
55814
+ await import_promises5.default.rename(stage, destDir);
55716
55815
  return { extId: manifest.id };
55717
55816
  } catch (e) {
55718
- await import_promises4.default.rm(stage, { recursive: true, force: true }).catch(() => {
55817
+ await import_promises5.default.rm(stage, { recursive: true, force: true }).catch(() => {
55719
55818
  });
55720
55819
  throw e;
55721
55820
  }
@@ -56745,7 +56844,7 @@ var import_node_os13 = __toESM(require("os"), 1);
56745
56844
  var import_node_path42 = __toESM(require("path"), 1);
56746
56845
  var import_node_child_process8 = require("child_process");
56747
56846
  var import_node_stream3 = require("stream");
56748
- var import_promises5 = require("stream/promises");
56847
+ var import_promises6 = require("stream/promises");
56749
56848
  var FRPC_VERSION = "0.68.0";
56750
56849
  var UnsupportedPlatformError = class extends Error {
56751
56850
  constructor(platform, arch) {
@@ -56836,7 +56935,7 @@ async function downloadToFile(url, dest, fetchImpl) {
56836
56935
  }
56837
56936
  const out = import_node_fs38.default.createWriteStream(dest);
56838
56937
  const nodeStream = import_node_stream3.Readable.fromWeb(res.body);
56839
- await (0, import_promises5.pipeline)(nodeStream, out);
56938
+ await (0, import_promises6.pipeline)(nodeStream, out);
56840
56939
  }
56841
56940
  async function extractFrpcFromTarball(tarball, binDir, version2, platform, destBin) {
56842
56941
  const work = import_node_path42.default.join(binDir, `extract-${process.pid}-${Date.now()}`);
@@ -57709,7 +57808,7 @@ function verifyConnectToken(args) {
57709
57808
  }
57710
57809
 
57711
57810
  // src/feishu-auth/server-key.ts
57712
- var fs53 = __toESM(require("fs"), 1);
57811
+ var fs54 = __toESM(require("fs"), 1);
57713
57812
  var path57 = __toESM(require("path"), 1);
57714
57813
  var FILE_NAME2 = "server-signing-key.json";
57715
57814
  var ServerKeyStore = class {
@@ -57723,7 +57822,7 @@ var ServerKeyStore = class {
57723
57822
  /** 读缓存的公钥;无缓存 / 损坏 → null(调用方决定是否触发拉取) */
57724
57823
  read() {
57725
57824
  try {
57726
- const raw = fs53.readFileSync(this.filePath(), "utf8");
57825
+ const raw = fs54.readFileSync(this.filePath(), "utf8");
57727
57826
  const parsed = JSON.parse(raw);
57728
57827
  if (typeof parsed.publicKeyPem === "string" && parsed.publicKeyPem.includes("PUBLIC KEY")) {
57729
57828
  return parsed.publicKeyPem;
@@ -57738,12 +57837,12 @@ var ServerKeyStore = class {
57738
57837
  publicKeyPem,
57739
57838
  fetchedAt: (/* @__PURE__ */ new Date()).toISOString()
57740
57839
  };
57741
- fs53.mkdirSync(this.dataDir, { recursive: true });
57742
- fs53.writeFileSync(this.filePath(), JSON.stringify(content, null, 2), { mode: 384 });
57840
+ fs54.mkdirSync(this.dataDir, { recursive: true });
57841
+ fs54.writeFileSync(this.filePath(), JSON.stringify(content, null, 2), { mode: 384 });
57743
57842
  }
57744
57843
  clear() {
57745
57844
  try {
57746
- fs53.unlinkSync(this.filePath());
57845
+ fs54.unlinkSync(this.filePath());
57747
57846
  } catch {
57748
57847
  }
57749
57848
  }
@@ -57824,7 +57923,7 @@ function forkSession(input) {
57824
57923
 
57825
57924
  // src/session/external-scan.ts
57826
57925
  var import_node_fs45 = __toESM(require("fs"), 1);
57827
- var import_promises6 = __toESM(require("fs/promises"), 1);
57926
+ var import_promises7 = __toESM(require("fs/promises"), 1);
57828
57927
  var import_node_os17 = __toESM(require("os"), 1);
57829
57928
  var import_node_path50 = __toESM(require("path"), 1);
57830
57929
  var import_node_module = require("module");
@@ -57880,7 +57979,7 @@ function listFiles(dir, depth = 0, maxDepth = 8, out = []) {
57880
57979
  async function* jsonLines(file) {
57881
57980
  let raw;
57882
57981
  try {
57883
- raw = await import_promises6.default.readFile(file, "utf8");
57982
+ raw = await import_promises7.default.readFile(file, "utf8");
57884
57983
  } catch {
57885
57984
  return;
57886
57985
  }
@@ -57940,23 +58039,23 @@ async function scanClaude(roots) {
57940
58039
  let firstTs = 0;
57941
58040
  let lastTs = 0;
57942
58041
  let hasMainLine = false;
57943
- for await (const rec3 of jsonLines(file)) {
57944
- if (!cwd && typeof rec3.cwd === "string") cwd = rec3.cwd;
57945
- if (typeof rec3.timestamp === "string") {
57946
- const t = Date.parse(rec3.timestamp);
58042
+ for await (const rec4 of jsonLines(file)) {
58043
+ if (!cwd && typeof rec4.cwd === "string") cwd = rec4.cwd;
58044
+ if (typeof rec4.timestamp === "string") {
58045
+ const t = Date.parse(rec4.timestamp);
57947
58046
  if (Number.isFinite(t)) {
57948
58047
  firstTs ||= t;
57949
58048
  lastTs = t;
57950
58049
  }
57951
58050
  }
57952
- if (rec3.type === "ai-title" && rec3.aiTitle) {
57953
- title = String(rec3.aiTitle);
58051
+ if (rec4.type === "ai-title" && rec4.aiTitle) {
58052
+ title = String(rec4.aiTitle);
57954
58053
  continue;
57955
58054
  }
57956
- if (rec3.type !== "user" && rec3.type !== "assistant") continue;
57957
- if (!rec3.isSidechain) hasMainLine = true;
57958
- if (rec3.type !== "user" || rec3.isSidechain || rec3.isMeta) continue;
57959
- const text = userText(rec3.message || {});
58055
+ if (rec4.type !== "user" && rec4.type !== "assistant") continue;
58056
+ if (!rec4.isSidechain) hasMainLine = true;
58057
+ if (rec4.type !== "user" || rec4.isSidechain || rec4.isMeta) continue;
58058
+ const text = userText(rec4.message || {});
57960
58059
  if (!text.trim() || text.trimStart().startsWith("<")) continue;
57961
58060
  turns += 1;
57962
58061
  firstUser ||= text;
@@ -57982,8 +58081,8 @@ async function countCodexTurns(rolloutPath) {
57982
58081
  if (!rolloutPath || !import_node_fs45.default.existsSync(rolloutPath)) return { turns: 0, first: "" };
57983
58082
  let turns = 0;
57984
58083
  let first = "";
57985
- for await (const rec3 of jsonLines(rolloutPath)) {
57986
- const p2 = rec3.payload || {};
58084
+ for await (const rec4 of jsonLines(rolloutPath)) {
58085
+ const p2 = rec4.payload || {};
57987
58086
  if (p2.type !== "message" || p2.role !== "user") continue;
57988
58087
  const text = (p2.content || []).map((b2) => String(b2 && b2.text || "")).join("");
57989
58088
  if (!text.trim() || text.trimStart().startsWith("<")) continue;
@@ -58060,9 +58159,9 @@ async function scanCodexRollouts(roots) {
58060
58159
  continue;
58061
58160
  }
58062
58161
  let meta = null;
58063
- for await (const rec3 of jsonLines(file)) {
58064
- if (rec3.type === "session_meta") {
58065
- meta = rec3.payload || {};
58162
+ for await (const rec4 of jsonLines(file)) {
58163
+ if (rec4.type === "session_meta") {
58164
+ meta = rec4.payload || {};
58066
58165
  break;
58067
58166
  }
58068
58167
  }
@@ -58447,6 +58546,7 @@ function buildSessionHandlers(deps) {
58447
58546
  if (args.sessionId !== void 0) {
58448
58547
  ensureSessionAccess(ctx, args.sessionId, "read");
58449
58548
  addSubscription(client, args.sessionId);
58549
+ void deps.hydrateCodexResolvedMeta?.(args.sessionId);
58450
58550
  }
58451
58551
  return {
58452
58552
  response: { type: "subscribed", sessionId: args.sessionId }
@@ -59890,10 +59990,10 @@ function computeMethodAccess(args) {
59890
59990
  }
59891
59991
 
59892
59992
  // src/version.ts
59893
- var version = "0.2.326".length > 0 ? "0.2.326" : "dev";
59993
+ var version = "0.2.327".length > 0 ? "0.2.327" : "dev";
59894
59994
 
59895
59995
  // src/cli-probe/probe.ts
59896
- var fs58 = __toESM(require("fs"), 1);
59996
+ var fs59 = __toESM(require("fs"), 1);
59897
59997
  var path66 = __toESM(require("path"), 1);
59898
59998
  var PKG_NAME = "@clawos-dev/clawd";
59899
59999
  var BIN_NAME = "clawd";
@@ -59904,7 +60004,7 @@ function probeGlobalCli(pathEnv) {
59904
60004
  if (!dir) continue;
59905
60005
  let real;
59906
60006
  try {
59907
- real = fs58.realpathSync(path66.join(dir, BIN_NAME));
60007
+ real = fs59.realpathSync(path66.join(dir, BIN_NAME));
59908
60008
  } catch {
59909
60009
  continue;
59910
60010
  }
@@ -59917,7 +60017,7 @@ function readOwnPackageVersion(entryPath) {
59917
60017
  let dir = path66.dirname(entryPath);
59918
60018
  for (let i = 0; i < MAX_PARENT_HOPS; i++) {
59919
60019
  try {
59920
- const raw = fs58.readFileSync(path66.join(dir, "package.json"), "utf8");
60020
+ const raw = fs59.readFileSync(path66.join(dir, "package.json"), "utf8");
59921
60021
  const pkg = JSON.parse(raw);
59922
60022
  if (pkg.name !== PKG_NAME) return null;
59923
60023
  return typeof pkg.version === "string" && pkg.version ? pkg.version : null;
@@ -60266,12 +60366,12 @@ function buildAttachmentHandlers(deps) {
60266
60366
  }
60267
60367
 
60268
60368
  // src/handlers/extension.ts
60269
- var import_promises10 = __toESM(require("fs/promises"), 1);
60369
+ var import_promises11 = __toESM(require("fs/promises"), 1);
60270
60370
  var import_node_path58 = __toESM(require("path"), 1);
60271
60371
  init_protocol();
60272
60372
 
60273
60373
  // src/extension/bundle-zip.ts
60274
- var import_promises7 = __toESM(require("fs/promises"), 1);
60374
+ var import_promises8 = __toESM(require("fs/promises"), 1);
60275
60375
  var import_node_path54 = __toESM(require("path"), 1);
60276
60376
  var import_node_crypto14 = __toESM(require("crypto"), 1);
60277
60377
  var import_jszip2 = __toESM(require_lib3(), 1);
@@ -60280,7 +60380,7 @@ async function bundleExtensionDir(dir) {
60280
60380
  const zip = new import_jszip2.default();
60281
60381
  for (const rel of entries) {
60282
60382
  const abs = import_node_path54.default.join(dir, rel);
60283
- const content = await import_promises7.default.readFile(abs);
60383
+ const content = await import_promises8.default.readFile(abs);
60284
60384
  zip.file(rel, content, { date: FIXED_DATE });
60285
60385
  }
60286
60386
  const buffer = await zip.generateAsync({
@@ -60301,7 +60401,7 @@ async function listFilesSorted(rootDir) {
60301
60401
  }
60302
60402
  async function walk(absRoot, relPrefix, out) {
60303
60403
  const dirAbs = import_node_path54.default.join(absRoot, relPrefix);
60304
- const entries = await import_promises7.default.readdir(dirAbs, { withFileTypes: true });
60404
+ const entries = await import_promises8.default.readdir(dirAbs, { withFileTypes: true });
60305
60405
  for (const e of entries) {
60306
60406
  if (IGNORE_BASENAMES.has(e.name)) continue;
60307
60407
  const rel = relPrefix ? `${relPrefix}/${e.name}` : e.name;
@@ -60353,7 +60453,7 @@ function computePublishCheck(args) {
60353
60453
  }
60354
60454
 
60355
60455
  // src/extension/install-flow.ts
60356
- var import_promises8 = __toESM(require("fs/promises"), 1);
60456
+ var import_promises9 = __toESM(require("fs/promises"), 1);
60357
60457
  var import_node_path56 = __toESM(require("path"), 1);
60358
60458
  var import_node_os20 = __toESM(require("os"), 1);
60359
60459
  var import_node_crypto15 = __toESM(require("crypto"), 1);
@@ -60434,7 +60534,7 @@ async function installFromChannel(args, deps) {
60434
60534
  const destDir = import_node_path56.default.join(deps.extensionsRoot, localExtId);
60435
60535
  let destExists = false;
60436
60536
  try {
60437
- await import_promises8.default.access(destDir);
60537
+ await import_promises9.default.access(destDir);
60438
60538
  destExists = true;
60439
60539
  } catch {
60440
60540
  }
@@ -60444,28 +60544,28 @@ async function installFromChannel(args, deps) {
60444
60544
  `extension ${localExtId} already installed locally (from owner ${channelRef.ownerPrincipalId})`
60445
60545
  );
60446
60546
  }
60447
- const stage = await import_promises8.default.mkdtemp(
60547
+ const stage = await import_promises9.default.mkdtemp(
60448
60548
  import_node_path56.default.join(import_node_os20.default.tmpdir(), `clawd-ext-install-${localExtId}-`)
60449
60549
  );
60450
60550
  try {
60451
60551
  for (const [name, entry] of Object.entries(zip.files)) {
60452
60552
  const dest = import_node_path56.default.join(stage, name);
60453
60553
  if (entry.dir) {
60454
- await import_promises8.default.mkdir(dest, { recursive: true });
60554
+ await import_promises9.default.mkdir(dest, { recursive: true });
60455
60555
  continue;
60456
60556
  }
60457
- await import_promises8.default.mkdir(import_node_path56.default.dirname(dest), { recursive: true });
60557
+ await import_promises9.default.mkdir(import_node_path56.default.dirname(dest), { recursive: true });
60458
60558
  if (name === "manifest.json") {
60459
60559
  const rewritten = { ...parsed.data, id: localExtId };
60460
- await import_promises8.default.writeFile(dest, JSON.stringify(rewritten, null, 2));
60560
+ await import_promises9.default.writeFile(dest, JSON.stringify(rewritten, null, 2));
60461
60561
  } else {
60462
- await import_promises8.default.writeFile(dest, await entry.async("nodebuffer"));
60562
+ await import_promises9.default.writeFile(dest, await entry.async("nodebuffer"));
60463
60563
  }
60464
60564
  }
60465
- await import_promises8.default.mkdir(deps.extensionsRoot, { recursive: true });
60466
- await import_promises8.default.rename(stage, destDir);
60565
+ await import_promises9.default.mkdir(deps.extensionsRoot, { recursive: true });
60566
+ await import_promises9.default.rename(stage, destDir);
60467
60567
  } catch (e) {
60468
- await import_promises8.default.rm(stage, { recursive: true, force: true }).catch(() => {
60568
+ await import_promises9.default.rm(stage, { recursive: true, force: true }).catch(() => {
60469
60569
  });
60470
60570
  throw e;
60471
60571
  }
@@ -60474,7 +60574,7 @@ async function installFromChannel(args, deps) {
60474
60574
  }
60475
60575
 
60476
60576
  // src/extension/update-flow.ts
60477
- var import_promises9 = __toESM(require("fs/promises"), 1);
60577
+ var import_promises10 = __toESM(require("fs/promises"), 1);
60478
60578
  var import_node_path57 = __toESM(require("path"), 1);
60479
60579
  var import_node_os21 = __toESM(require("os"), 1);
60480
60580
  var import_node_crypto16 = __toESM(require("crypto"), 1);
@@ -60496,7 +60596,7 @@ async function updateFromChannel(args, deps) {
60496
60596
  const prevDir = `${liveDir}.prev`;
60497
60597
  let existingVersion;
60498
60598
  try {
60499
- const raw = await import_promises9.default.readFile(import_node_path57.default.join(liveDir, "manifest.json"), "utf8");
60599
+ const raw = await import_promises10.default.readFile(import_node_path57.default.join(liveDir, "manifest.json"), "utf8");
60500
60600
  const parsed2 = ExtensionManifestSchema.safeParse(JSON.parse(raw));
60501
60601
  if (!parsed2.success) {
60502
60602
  throw new UpdateError(
@@ -60561,31 +60661,31 @@ async function updateFromChannel(args, deps) {
60561
60661
  );
60562
60662
  }
60563
60663
  await deps.runtime.close(localExtId);
60564
- await import_promises9.default.rm(prevDir, { recursive: true, force: true });
60565
- await import_promises9.default.rename(liveDir, prevDir);
60566
- const stage = await import_promises9.default.mkdtemp(
60664
+ await import_promises10.default.rm(prevDir, { recursive: true, force: true });
60665
+ await import_promises10.default.rename(liveDir, prevDir);
60666
+ const stage = await import_promises10.default.mkdtemp(
60567
60667
  import_node_path57.default.join(import_node_os21.default.tmpdir(), `clawd-ext-update-${localExtId}-`)
60568
60668
  );
60569
60669
  try {
60570
60670
  for (const [name, entry] of Object.entries(zip.files)) {
60571
60671
  const dest = import_node_path57.default.join(stage, name);
60572
60672
  if (entry.dir) {
60573
- await import_promises9.default.mkdir(dest, { recursive: true });
60673
+ await import_promises10.default.mkdir(dest, { recursive: true });
60574
60674
  continue;
60575
60675
  }
60576
- await import_promises9.default.mkdir(import_node_path57.default.dirname(dest), { recursive: true });
60676
+ await import_promises10.default.mkdir(import_node_path57.default.dirname(dest), { recursive: true });
60577
60677
  if (name === "manifest.json") {
60578
60678
  const rewritten = { ...parsed.data, id: localExtId };
60579
- await import_promises9.default.writeFile(dest, JSON.stringify(rewritten, null, 2));
60679
+ await import_promises10.default.writeFile(dest, JSON.stringify(rewritten, null, 2));
60580
60680
  } else {
60581
- await import_promises9.default.writeFile(dest, await entry.async("nodebuffer"));
60681
+ await import_promises10.default.writeFile(dest, await entry.async("nodebuffer"));
60582
60682
  }
60583
60683
  }
60584
- await import_promises9.default.rename(stage, liveDir);
60684
+ await import_promises10.default.rename(stage, liveDir);
60585
60685
  } catch (e) {
60586
- await import_promises9.default.rm(stage, { recursive: true, force: true }).catch(() => {
60686
+ await import_promises10.default.rm(stage, { recursive: true, force: true }).catch(() => {
60587
60687
  });
60588
- await import_promises9.default.rename(prevDir, liveDir).catch(() => {
60688
+ await import_promises10.default.rename(prevDir, liveDir).catch(() => {
60589
60689
  });
60590
60690
  await deps.runtime.open(localExtId).catch(() => {
60591
60691
  });
@@ -60607,7 +60707,7 @@ async function updateFromChannel(args, deps) {
60607
60707
  reason: e.message
60608
60708
  };
60609
60709
  }
60610
- await import_promises9.default.rm(prevDir, { recursive: true, force: true });
60710
+ await import_promises10.default.rm(prevDir, { recursive: true, force: true });
60611
60711
  return {
60612
60712
  kind: "updated",
60613
60713
  extId: localExtId,
@@ -60615,9 +60715,9 @@ async function updateFromChannel(args, deps) {
60615
60715
  };
60616
60716
  }
60617
60717
  async function rollback(deps, localExtId, liveDir, prevDir) {
60618
- await import_promises9.default.rm(liveDir, { recursive: true, force: true }).catch(() => {
60718
+ await import_promises10.default.rm(liveDir, { recursive: true, force: true }).catch(() => {
60619
60719
  });
60620
- await import_promises9.default.rename(prevDir, liveDir).catch(() => {
60720
+ await import_promises10.default.rename(prevDir, liveDir).catch(() => {
60621
60721
  });
60622
60722
  await deps.runtime.open(localExtId).catch(() => {
60623
60723
  });
@@ -60644,14 +60744,14 @@ async function rewriteManifestVersion(root, extId, newVersion, previousPublished
60644
60744
  const manifest = await readManifest(root, extId);
60645
60745
  const next = { ...manifest, version: newVersion };
60646
60746
  const tmp = `${manifestPath}.tmp`;
60647
- await import_promises10.default.writeFile(tmp, JSON.stringify(next, null, 2));
60648
- await import_promises10.default.rename(tmp, manifestPath);
60747
+ await import_promises11.default.writeFile(tmp, JSON.stringify(next, null, 2));
60748
+ await import_promises11.default.rename(tmp, manifestPath);
60649
60749
  }
60650
60750
  async function readManifest(root, extId) {
60651
60751
  const file = import_node_path58.default.join(root, extId, "manifest.json");
60652
60752
  let raw;
60653
60753
  try {
60654
- raw = await import_promises10.default.readFile(file, "utf8");
60754
+ raw = await import_promises11.default.readFile(file, "utf8");
60655
60755
  } catch (e) {
60656
60756
  if (e.code === "ENOENT") {
60657
60757
  throw new ClawdError(ERROR_CODES.INVALID_PARAM, `extension ${extId} not installed`);
@@ -60681,22 +60781,22 @@ function assertOwner(ctx) {
60681
60781
  throw new ClawdError(ERROR_CODES.FORBIDDEN, "owner only");
60682
60782
  }
60683
60783
  }
60684
- function composeState(rec3, running, crashed, getPort) {
60685
- if (rec3.state === "invalid") return rec3;
60686
- if (manifestMode(rec3.manifest) === "hosted") {
60784
+ function composeState(rec4, running, crashed, getPort) {
60785
+ if (rec4.state === "invalid") return rec4;
60786
+ if (manifestMode(rec4.manifest) === "hosted") {
60687
60787
  return {
60688
- ...rec3,
60788
+ ...rec4,
60689
60789
  state: "running",
60690
- target: { kind: "hosted", url: rec3.manifest.entry.url }
60790
+ target: { kind: "hosted", url: rec4.manifest.entry.url }
60691
60791
  };
60692
60792
  }
60693
- if (running.has(rec3.extId)) {
60694
- const port = getPort(rec3.extId);
60695
- if (port == null) return rec3;
60696
- return { ...rec3, state: "running", target: { kind: "local", port } };
60793
+ if (running.has(rec4.extId)) {
60794
+ const port = getPort(rec4.extId);
60795
+ if (port == null) return rec4;
60796
+ return { ...rec4, state: "running", target: { kind: "local", port } };
60697
60797
  }
60698
- if (crashed.has(rec3.extId)) return { ...rec3, state: "crashed" };
60699
- return rec3;
60798
+ if (crashed.has(rec4.extId)) return { ...rec4, state: "crashed" };
60799
+ return rec4;
60700
60800
  }
60701
60801
  function buildExtensionHandlers(deps) {
60702
60802
  const list = async (_frame, _client, ctx) => {
@@ -62300,12 +62400,12 @@ function buildVisitorHandlers(deps) {
62300
62400
  }
62301
62401
 
62302
62402
  // src/extension/registry.ts
62303
- var import_promises11 = __toESM(require("fs/promises"), 1);
62403
+ var import_promises12 = __toESM(require("fs/promises"), 1);
62304
62404
  var import_node_path62 = __toESM(require("path"), 1);
62305
62405
  async function loadAll(root) {
62306
62406
  let entries;
62307
62407
  try {
62308
- entries = await import_promises11.default.readdir(root, { withFileTypes: true });
62408
+ entries = await import_promises12.default.readdir(root, { withFileTypes: true });
62309
62409
  } catch (e) {
62310
62410
  if (e.code === "ENOENT") return [];
62311
62411
  throw e;
@@ -62323,7 +62423,7 @@ async function loadOne(dir, dirName) {
62323
62423
  const manifestPath = import_node_path62.default.join(dir, "manifest.json");
62324
62424
  let raw;
62325
62425
  try {
62326
- raw = await import_promises11.default.readFile(manifestPath, "utf8");
62426
+ raw = await import_promises12.default.readFile(manifestPath, "utf8");
62327
62427
  } catch {
62328
62428
  return {
62329
62429
  extId: dirName,
@@ -62364,7 +62464,7 @@ async function loadOne(dir, dirName) {
62364
62464
  }
62365
62465
 
62366
62466
  // src/extension/uninstall.ts
62367
- var import_promises12 = __toESM(require("fs/promises"), 1);
62467
+ var import_promises13 = __toESM(require("fs/promises"), 1);
62368
62468
  var import_node_path63 = __toESM(require("path"), 1);
62369
62469
  var UninstallError = class extends Error {
62370
62470
  constructor(code, message) {
@@ -62376,12 +62476,12 @@ var UninstallError = class extends Error {
62376
62476
  async function uninstall(deps) {
62377
62477
  const dir = import_node_path63.default.join(deps.root, deps.extId);
62378
62478
  try {
62379
- await import_promises12.default.access(dir);
62479
+ await import_promises13.default.access(dir);
62380
62480
  } catch {
62381
62481
  throw new UninstallError("NOT_FOUND", `extension ${deps.extId} not installed`);
62382
62482
  }
62383
62483
  await deps.runtime.close(deps.extId);
62384
- await import_promises12.default.rm(dir, { recursive: true, force: true });
62484
+ await import_promises13.default.rm(dir, { recursive: true, force: true });
62385
62485
  }
62386
62486
 
62387
62487
  // src/handlers/index.ts
@@ -63027,7 +63127,7 @@ async function dispatchRpc(method, frame, client, ctx, deps) {
63027
63127
  // src/extension/runtime.ts
63028
63128
  var import_node_child_process19 = require("child_process");
63029
63129
  var import_node_path64 = __toESM(require("path"), 1);
63030
- var import_promises13 = require("timers/promises");
63130
+ var import_promises14 = require("timers/promises");
63031
63131
 
63032
63132
  // src/extension/port-allocator.ts
63033
63133
  var import_node_net2 = __toESM(require("net"), 1);
@@ -63112,17 +63212,17 @@ var Runtime = class {
63112
63212
  const existing = this.handles.get(extId);
63113
63213
  if (existing) return { kind: "local", port: existing.port };
63114
63214
  const records = await loadAll(this.root);
63115
- const rec3 = records.find((r) => r.extId === extId);
63116
- if (!rec3) throw new RuntimeError("NOT_FOUND", `extension ${extId} not installed`);
63117
- if (rec3.state === "invalid")
63118
- throw new RuntimeError("INVALID_MANIFEST", rec3.invalidReason);
63119
- if (manifestMode(rec3.manifest) === "hosted") {
63120
- return { kind: "hosted", url: rec3.manifest.entry.url };
63215
+ const rec4 = records.find((r) => r.extId === extId);
63216
+ if (!rec4) throw new RuntimeError("NOT_FOUND", `extension ${extId} not installed`);
63217
+ if (rec4.state === "invalid")
63218
+ throw new RuntimeError("INVALID_MANIFEST", rec4.invalidReason);
63219
+ if (manifestMode(rec4.manifest) === "hosted") {
63220
+ return { kind: "hosted", url: rec4.manifest.entry.url };
63121
63221
  }
63122
63222
  const port = await this.allocator.allocate().catch(() => {
63123
63223
  throw new RuntimeError("PORT_EXHAUSTED", "no free port in configured range");
63124
63224
  });
63125
- const startCommand = rec3.manifest.runtime.startCommand;
63225
+ const startCommand = rec4.manifest.runtime.startCommand;
63126
63226
  const cmd = startCommand.replace(
63127
63227
  /\$CLAWOS_EXT_PORT/g,
63128
63228
  String(port)
@@ -63203,7 +63303,7 @@ ${handle.stderrTail}`
63203
63303
  if (res.ok) return;
63204
63304
  } catch {
63205
63305
  }
63206
- await (0, import_promises13.setTimeout)(this.healthzIntervalMs);
63306
+ await (0, import_promises14.setTimeout)(this.healthzIntervalMs);
63207
63307
  }
63208
63308
  throw new RuntimeError(
63209
63309
  "HEALTHZ_FAILED",
@@ -63228,7 +63328,7 @@ ${handle.stderrTail}`
63228
63328
  };
63229
63329
  killGroup("SIGTERM");
63230
63330
  const exited = new Promise((resolve6) => child.once("exit", () => resolve6()));
63231
- const timed = (0, import_promises13.setTimeout)(5e3).then(() => "timeout");
63331
+ const timed = (0, import_promises14.setTimeout)(5e3).then(() => "timeout");
63232
63332
  const winner = await Promise.race([exited.then(() => "exited"), timed]);
63233
63333
  if (winner === "timeout" && child.exitCode === null) {
63234
63334
  killGroup("SIGKILL");
@@ -63238,7 +63338,7 @@ ${handle.stderrTail}`
63238
63338
  };
63239
63339
 
63240
63340
  // src/extension/published-channels.ts
63241
- var import_promises14 = __toESM(require("fs/promises"), 1);
63341
+ var import_promises15 = __toESM(require("fs/promises"), 1);
63242
63342
  var import_node_path65 = __toESM(require("path"), 1);
63243
63343
  init_zod();
63244
63344
  var PublishedChannelsError = class extends Error {
@@ -63269,7 +63369,7 @@ var PublishedChannelStore = class {
63269
63369
  this.channels.clear();
63270
63370
  let raw;
63271
63371
  try {
63272
- raw = await import_promises14.default.readFile(this.filePath, "utf8");
63372
+ raw = await import_promises15.default.readFile(this.filePath, "utf8");
63273
63373
  } catch (e) {
63274
63374
  if (e.code === "ENOENT") {
63275
63375
  this.loaded = true;
@@ -63338,14 +63438,14 @@ var PublishedChannelStore = class {
63338
63438
  )
63339
63439
  };
63340
63440
  const tmp = `${this.filePath}.tmp`;
63341
- await import_promises14.default.mkdir(import_node_path65.default.dirname(this.filePath), { recursive: true });
63342
- await import_promises14.default.writeFile(tmp, JSON.stringify(data, null, 2), { mode: 384 });
63343
- await import_promises14.default.rename(tmp, this.filePath);
63441
+ await import_promises15.default.mkdir(import_node_path65.default.dirname(this.filePath), { recursive: true });
63442
+ await import_promises15.default.writeFile(tmp, JSON.stringify(data, null, 2), { mode: 384 });
63443
+ await import_promises15.default.rename(tmp, this.filePath);
63344
63444
  }
63345
63445
  };
63346
63446
 
63347
63447
  // src/extension/bundle-cache.ts
63348
- var import_promises15 = __toESM(require("fs/promises"), 1);
63448
+ var import_promises16 = __toESM(require("fs/promises"), 1);
63349
63449
  var import_node_path66 = __toESM(require("path"), 1);
63350
63450
  var BundleCache = class {
63351
63451
  constructor(rootDir) {
@@ -63354,17 +63454,17 @@ var BundleCache = class {
63354
63454
  rootDir;
63355
63455
  /** Atomic write: stage tmp → rename. Caller passes the hex sha256. */
63356
63456
  async write(snapshotHash, buffer) {
63357
- await import_promises15.default.mkdir(this.rootDir, { recursive: true });
63457
+ await import_promises16.default.mkdir(this.rootDir, { recursive: true });
63358
63458
  const file = import_node_path66.default.join(this.rootDir, `${snapshotHash}.zip`);
63359
63459
  const tmp = `${file}.tmp`;
63360
- await import_promises15.default.writeFile(tmp, buffer, { mode: 384 });
63361
- await import_promises15.default.rename(tmp, file);
63460
+ await import_promises16.default.writeFile(tmp, buffer, { mode: 384 });
63461
+ await import_promises16.default.rename(tmp, file);
63362
63462
  }
63363
63463
  /** Returns the bundle bytes, or null when the file doesn't exist. */
63364
63464
  async read(snapshotHash) {
63365
63465
  const file = import_node_path66.default.join(this.rootDir, `${snapshotHash}.zip`);
63366
63466
  try {
63367
- return await import_promises15.default.readFile(file);
63467
+ return await import_promises16.default.readFile(file);
63368
63468
  } catch (e) {
63369
63469
  if (e.code === "ENOENT") return null;
63370
63470
  throw e;
@@ -63373,7 +63473,7 @@ var BundleCache = class {
63373
63473
  /** Idempotent — missing file is not an error. */
63374
63474
  async delete(snapshotHash) {
63375
63475
  const file = import_node_path66.default.join(this.rootDir, `${snapshotHash}.zip`);
63376
- await import_promises15.default.rm(file, { force: true });
63476
+ await import_promises16.default.rm(file, { force: true });
63377
63477
  }
63378
63478
  };
63379
63479
 
@@ -63981,6 +64081,12 @@ async function startDaemon(config) {
63981
64081
  provider: ownerProvider,
63982
64082
  feishuUnionId: ownerFeishuUnionId
63983
64083
  });
64084
+ const hydrateCodexResolvedMeta = createCodexResolvedMetaHydrator({
64085
+ getSession: (sessionId) => manager.findOwnedSession(sessionId),
64086
+ readTurnContext: (args) => readCodexTurnContext(args),
64087
+ applyMeta: (sessionId, patch) => manager.applyResolvedMeta(sessionId, patch),
64088
+ logger
64089
+ });
63984
64090
  const handlers = {
63985
64091
  ...buildMethodHandlers({
63986
64092
  // meta:methods 自省:飞书 gate getter + 最终 handler 表(下面还会 spread 进
@@ -63998,6 +64104,7 @@ async function startDaemon(config) {
63998
64104
  history,
63999
64105
  // history:read 按 session.tool 路由:codex → adapter.historyReader(CodexHistoryReader);缺省 claude。
64000
64106
  getHistoryReader: (tool) => getAdapter(tool).historyReader ?? history,
64107
+ hydrateCodexResolvedMeta,
64001
64108
  observer,
64002
64109
  getAdapter,
64003
64110
  store,
@@ -64315,11 +64422,11 @@ async function startDaemon(config) {
64315
64422
  dataDir: config.dataDir,
64316
64423
  // 现读(登录/登出热切换);unionId 缺失时回落 ownerId(老登录记录无 unionId)
64317
64424
  getOwnerIdentity: () => {
64318
- const rec3 = ownerIdentityStore.read();
64319
- if (!rec3) return null;
64425
+ const rec4 = ownerIdentityStore.read();
64426
+ if (!rec4) return null;
64320
64427
  return {
64321
- unionId: rec3.identity.unionId ?? rec3.identity.ownerId,
64322
- displayName: rec3.identity.displayName
64428
+ unionId: rec4.identity.unionId ?? rec4.identity.ownerId,
64429
+ displayName: rec4.identity.displayName
64323
64430
  };
64324
64431
  },
64325
64432
  apiUrl: config.clawosApi ?? DEFAULT_CLAWOS_API,