@clawos-dev/clawd 0.2.325 → 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
@@ -6924,6 +6924,10 @@ var init_schemas = __esm({
6924
6924
  sessionMetaShape = {
6925
6925
  gitBranch: external_exports.string().optional(),
6926
6926
  resolvedModel: external_exports.string().optional(),
6927
+ // CC 每条 assistant 记录的顶层 `effort`(实测 2.1.228)——即本轮真正生效的推理强度。
6928
+ // 与 resolvedModel 对称:session.effort 是「用户选的」('' = 没选),这个是「实际用的」。
6929
+ // 没选时 UI 拿它显示确切值,而不是「由 CC 决定」这种占位。
6930
+ resolvedEffort: external_exports.string().optional(),
6927
6931
  contextUsage: ContextUsageSchema.optional(),
6928
6932
  contextWindowSize: external_exports.number().int().positive().optional()
6929
6933
  };
@@ -9581,10 +9585,10 @@ var require_redaction = __commonJS({
9581
9585
  var strict = false;
9582
9586
  function redaction(opts, serialize) {
9583
9587
  const { paths, censor, remove } = handle(opts);
9584
- const shape = paths.reduce((o, str4) => {
9588
+ const shape = paths.reduce((o, str5) => {
9585
9589
  rx.lastIndex = 0;
9586
- const first = rx.exec(str4);
9587
- const next = rx.exec(str4);
9590
+ const first = rx.exec(str5);
9591
+ const next = rx.exec(str5);
9588
9592
  let ns = first[1] !== void 0 ? first[1].replace(/^(?:"|'|`)(.*)(?:"|'|`)$/, "$1") : first[0];
9589
9593
  if (ns === "*") {
9590
9594
  ns = wildcardFirstSym;
@@ -9597,7 +9601,7 @@ var require_redaction = __commonJS({
9597
9601
  return o;
9598
9602
  }
9599
9603
  const { index } = next;
9600
- const nextPath = `${str4.substr(index, str4.length - 1)}`;
9604
+ const nextPath = `${str5.substr(index, str5.length - 1)}`;
9601
9605
  o[ns] = o[ns] || [];
9602
9606
  if (ns !== wildcardFirstSym && o[ns].length === 0) {
9603
9607
  o[ns].push(...o[wildcardFirstSym] || []);
@@ -9713,7 +9717,7 @@ var require_quick_format_unescaped = __commonJS({
9713
9717
  }
9714
9718
  var argLen = args.length;
9715
9719
  if (argLen === 0) return f;
9716
- var str4 = "";
9720
+ var str5 = "";
9717
9721
  var a = 1 - offset;
9718
9722
  var lastPos = -1;
9719
9723
  var flen = f && f.length || 0;
@@ -9728,8 +9732,8 @@ var require_quick_format_unescaped = __commonJS({
9728
9732
  break;
9729
9733
  if (args[a] == null) break;
9730
9734
  if (lastPos < i)
9731
- str4 += f.slice(lastPos, i);
9732
- str4 += Number(args[a]);
9735
+ str5 += f.slice(lastPos, i);
9736
+ str5 += Number(args[a]);
9733
9737
  lastPos = i + 2;
9734
9738
  i++;
9735
9739
  break;
@@ -9738,8 +9742,8 @@ var require_quick_format_unescaped = __commonJS({
9738
9742
  break;
9739
9743
  if (args[a] == null) break;
9740
9744
  if (lastPos < i)
9741
- str4 += f.slice(lastPos, i);
9742
- str4 += Math.floor(Number(args[a]));
9745
+ str5 += f.slice(lastPos, i);
9746
+ str5 += Math.floor(Number(args[a]));
9743
9747
  lastPos = i + 2;
9744
9748
  i++;
9745
9749
  break;
@@ -9752,21 +9756,21 @@ var require_quick_format_unescaped = __commonJS({
9752
9756
  break;
9753
9757
  if (args[a] === void 0) break;
9754
9758
  if (lastPos < i)
9755
- str4 += f.slice(lastPos, i);
9759
+ str5 += f.slice(lastPos, i);
9756
9760
  var type = typeof args[a];
9757
9761
  if (type === "string") {
9758
- str4 += "'" + args[a] + "'";
9762
+ str5 += "'" + args[a] + "'";
9759
9763
  lastPos = i + 2;
9760
9764
  i++;
9761
9765
  break;
9762
9766
  }
9763
9767
  if (type === "function") {
9764
- str4 += args[a].name || "<anonymous>";
9768
+ str5 += args[a].name || "<anonymous>";
9765
9769
  lastPos = i + 2;
9766
9770
  i++;
9767
9771
  break;
9768
9772
  }
9769
- str4 += ss(args[a]);
9773
+ str5 += ss(args[a]);
9770
9774
  lastPos = i + 2;
9771
9775
  i++;
9772
9776
  break;
@@ -9774,15 +9778,15 @@ var require_quick_format_unescaped = __commonJS({
9774
9778
  if (a >= argLen)
9775
9779
  break;
9776
9780
  if (lastPos < i)
9777
- str4 += f.slice(lastPos, i);
9778
- str4 += String(args[a]);
9781
+ str5 += f.slice(lastPos, i);
9782
+ str5 += String(args[a]);
9779
9783
  lastPos = i + 2;
9780
9784
  i++;
9781
9785
  break;
9782
9786
  case 37:
9783
9787
  if (lastPos < i)
9784
- str4 += f.slice(lastPos, i);
9785
- str4 += "%";
9788
+ str5 += f.slice(lastPos, i);
9789
+ str5 += "%";
9786
9790
  lastPos = i + 2;
9787
9791
  i++;
9788
9792
  a--;
@@ -9795,9 +9799,9 @@ var require_quick_format_unescaped = __commonJS({
9795
9799
  if (lastPos === -1)
9796
9800
  return f;
9797
9801
  else if (lastPos < flen) {
9798
- str4 += f.slice(lastPos);
9802
+ str5 += f.slice(lastPos);
9799
9803
  }
9800
- return str4;
9804
+ return str5;
9801
9805
  }
9802
9806
  }
9803
9807
  });
@@ -9841,7 +9845,7 @@ var require_atomic_sleep = __commonJS({
9841
9845
  var require_sonic_boom = __commonJS({
9842
9846
  "../node_modules/.pnpm/sonic-boom@4.2.1/node_modules/sonic-boom/index.js"(exports2, module2) {
9843
9847
  "use strict";
9844
- var fs71 = require("fs");
9848
+ var fs72 = require("fs");
9845
9849
  var EventEmitter3 = require("events");
9846
9850
  var inherits = require("util").inherits;
9847
9851
  var path81 = require("path");
@@ -9898,20 +9902,20 @@ var require_sonic_boom = __commonJS({
9898
9902
  const mode = sonic.mode;
9899
9903
  if (sonic.sync) {
9900
9904
  try {
9901
- if (sonic.mkdir) fs71.mkdirSync(path81.dirname(file), { recursive: true });
9902
- 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);
9903
9907
  fileOpened(null, fd);
9904
9908
  } catch (err) {
9905
9909
  fileOpened(err);
9906
9910
  throw err;
9907
9911
  }
9908
9912
  } else if (sonic.mkdir) {
9909
- fs71.mkdir(path81.dirname(file), { recursive: true }, (err) => {
9913
+ fs72.mkdir(path81.dirname(file), { recursive: true }, (err) => {
9910
9914
  if (err) return fileOpened(err);
9911
- fs71.open(file, flags, mode, fileOpened);
9915
+ fs72.open(file, flags, mode, fileOpened);
9912
9916
  });
9913
9917
  } else {
9914
- fs71.open(file, flags, mode, fileOpened);
9918
+ fs72.open(file, flags, mode, fileOpened);
9915
9919
  }
9916
9920
  }
9917
9921
  function SonicBoom(opts) {
@@ -9952,8 +9956,8 @@ var require_sonic_boom = __commonJS({
9952
9956
  this.flush = flushBuffer;
9953
9957
  this.flushSync = flushBufferSync;
9954
9958
  this._actualWrite = actualWriteBuffer;
9955
- fsWriteSync = () => fs71.writeSync(this.fd, this._writingBuf);
9956
- 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);
9957
9961
  } else if (contentMode === void 0 || contentMode === kContentModeUtf8) {
9958
9962
  this._writingBuf = "";
9959
9963
  this.write = write;
@@ -9962,15 +9966,15 @@ var require_sonic_boom = __commonJS({
9962
9966
  this._actualWrite = actualWrite;
9963
9967
  fsWriteSync = () => {
9964
9968
  if (Buffer.isBuffer(this._writingBuf)) {
9965
- return fs71.writeSync(this.fd, this._writingBuf);
9969
+ return fs72.writeSync(this.fd, this._writingBuf);
9966
9970
  }
9967
- return fs71.writeSync(this.fd, this._writingBuf, "utf8");
9971
+ return fs72.writeSync(this.fd, this._writingBuf, "utf8");
9968
9972
  };
9969
9973
  fsWrite = () => {
9970
9974
  if (Buffer.isBuffer(this._writingBuf)) {
9971
- return fs71.write(this.fd, this._writingBuf, this.release);
9975
+ return fs72.write(this.fd, this._writingBuf, this.release);
9972
9976
  }
9973
- return fs71.write(this.fd, this._writingBuf, "utf8", this.release);
9977
+ return fs72.write(this.fd, this._writingBuf, "utf8", this.release);
9974
9978
  };
9975
9979
  } else {
9976
9980
  throw new Error(`SonicBoom supports "${kContentModeUtf8}" and "${kContentModeBuffer}", but passed ${contentMode}`);
@@ -10027,7 +10031,7 @@ var require_sonic_boom = __commonJS({
10027
10031
  }
10028
10032
  }
10029
10033
  if (this._fsync) {
10030
- fs71.fsyncSync(this.fd);
10034
+ fs72.fsyncSync(this.fd);
10031
10035
  }
10032
10036
  const len = this._len;
10033
10037
  if (this._reopening) {
@@ -10141,7 +10145,7 @@ var require_sonic_boom = __commonJS({
10141
10145
  const onDrain = () => {
10142
10146
  if (!this._fsync) {
10143
10147
  try {
10144
- fs71.fsync(this.fd, (err) => {
10148
+ fs72.fsync(this.fd, (err) => {
10145
10149
  this._flushPending = false;
10146
10150
  cb(err);
10147
10151
  });
@@ -10243,7 +10247,7 @@ var require_sonic_boom = __commonJS({
10243
10247
  const fd = this.fd;
10244
10248
  this.once("ready", () => {
10245
10249
  if (fd !== this.fd) {
10246
- fs71.close(fd, (err) => {
10250
+ fs72.close(fd, (err) => {
10247
10251
  if (err) {
10248
10252
  return this.emit("error", err);
10249
10253
  }
@@ -10292,7 +10296,7 @@ var require_sonic_boom = __commonJS({
10292
10296
  buf = this._bufs[0];
10293
10297
  }
10294
10298
  try {
10295
- 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");
10296
10300
  const releasedBufObj = releaseWritingBuf(buf, this._len, n);
10297
10301
  buf = releasedBufObj.writingBuf;
10298
10302
  this._len = releasedBufObj.len;
@@ -10308,7 +10312,7 @@ var require_sonic_boom = __commonJS({
10308
10312
  }
10309
10313
  }
10310
10314
  try {
10311
- fs71.fsyncSync(this.fd);
10315
+ fs72.fsyncSync(this.fd);
10312
10316
  } catch {
10313
10317
  }
10314
10318
  }
@@ -10329,7 +10333,7 @@ var require_sonic_boom = __commonJS({
10329
10333
  buf = mergeBuf(this._bufs[0], this._lens[0]);
10330
10334
  }
10331
10335
  try {
10332
- const n = fs71.writeSync(this.fd, buf);
10336
+ const n = fs72.writeSync(this.fd, buf);
10333
10337
  buf = buf.subarray(n);
10334
10338
  this._len = Math.max(this._len - n, 0);
10335
10339
  if (buf.length <= 0) {
@@ -10357,13 +10361,13 @@ var require_sonic_boom = __commonJS({
10357
10361
  this._writingBuf = this._writingBuf.length ? this._writingBuf : this._bufs.shift() || "";
10358
10362
  if (this.sync) {
10359
10363
  try {
10360
- 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");
10361
10365
  release(null, written);
10362
10366
  } catch (err) {
10363
10367
  release(err);
10364
10368
  }
10365
10369
  } else {
10366
- fs71.write(this.fd, this._writingBuf, release);
10370
+ fs72.write(this.fd, this._writingBuf, release);
10367
10371
  }
10368
10372
  }
10369
10373
  function actualWriteBuffer() {
@@ -10372,7 +10376,7 @@ var require_sonic_boom = __commonJS({
10372
10376
  this._writingBuf = this._writingBuf.length ? this._writingBuf : mergeBuf(this._bufs.shift(), this._lens.shift());
10373
10377
  if (this.sync) {
10374
10378
  try {
10375
- const written = fs71.writeSync(this.fd, this._writingBuf);
10379
+ const written = fs72.writeSync(this.fd, this._writingBuf);
10376
10380
  release(null, written);
10377
10381
  } catch (err) {
10378
10382
  release(err);
@@ -10381,7 +10385,7 @@ var require_sonic_boom = __commonJS({
10381
10385
  if (kCopyBuffer) {
10382
10386
  this._writingBuf = Buffer.from(this._writingBuf);
10383
10387
  }
10384
- fs71.write(this.fd, this._writingBuf, release);
10388
+ fs72.write(this.fd, this._writingBuf, release);
10385
10389
  }
10386
10390
  }
10387
10391
  function actualClose(sonic) {
@@ -10397,12 +10401,12 @@ var require_sonic_boom = __commonJS({
10397
10401
  sonic._lens = [];
10398
10402
  assert(typeof sonic.fd === "number", `sonic.fd must be a number, got ${typeof sonic.fd}`);
10399
10403
  try {
10400
- fs71.fsync(sonic.fd, closeWrapped);
10404
+ fs72.fsync(sonic.fd, closeWrapped);
10401
10405
  } catch {
10402
10406
  }
10403
10407
  function closeWrapped() {
10404
10408
  if (sonic.fd !== 1 && sonic.fd !== 2) {
10405
- fs71.close(sonic.fd, done);
10409
+ fs72.close(sonic.fd, done);
10406
10410
  } else {
10407
10411
  done();
10408
10412
  }
@@ -11283,29 +11287,29 @@ var require_tools = __commonJS({
11283
11287
  }
11284
11288
  }
11285
11289
  }
11286
- function asString(str4) {
11290
+ function asString(str5) {
11287
11291
  let result = "";
11288
11292
  let last = 0;
11289
11293
  let found = false;
11290
11294
  let point = 255;
11291
- const l = str4.length;
11295
+ const l = str5.length;
11292
11296
  if (l > 100) {
11293
- return JSON.stringify(str4);
11297
+ return JSON.stringify(str5);
11294
11298
  }
11295
11299
  for (var i = 0; i < l && point >= 32; i++) {
11296
- point = str4.charCodeAt(i);
11300
+ point = str5.charCodeAt(i);
11297
11301
  if (point === 34 || point === 92) {
11298
- result += str4.slice(last, i) + "\\";
11302
+ result += str5.slice(last, i) + "\\";
11299
11303
  last = i;
11300
11304
  found = true;
11301
11305
  }
11302
11306
  }
11303
11307
  if (!found) {
11304
- result = str4;
11308
+ result = str5;
11305
11309
  } else {
11306
- result += str4.slice(last);
11310
+ result += str5.slice(last);
11307
11311
  }
11308
- return point < 32 ? JSON.stringify(str4) : '"' + result + '"';
11312
+ return point < 32 ? JSON.stringify(str5) : '"' + result + '"';
11309
11313
  }
11310
11314
  function asJson(obj, msg, num3, time) {
11311
11315
  if (asJsonChan.hasSubscribers === false) {
@@ -12011,11 +12015,11 @@ var require_safe_stable_stringify = __commonJS({
12011
12015
  exports2.configure = configure;
12012
12016
  module2.exports = stringify;
12013
12017
  var strEscapeSequencesRegExp = /[\u0000-\u001f\u0022\u005c\ud800-\udfff]/;
12014
- function strEscape(str4) {
12015
- if (str4.length < 5e3 && !strEscapeSequencesRegExp.test(str4)) {
12016
- return `"${str4}"`;
12018
+ function strEscape(str5) {
12019
+ if (str5.length < 5e3 && !strEscapeSequencesRegExp.test(str5)) {
12020
+ return `"${str5}"`;
12017
12021
  }
12018
- return JSON.stringify(str4);
12022
+ return JSON.stringify(str5);
12019
12023
  }
12020
12024
  function sort(array, comparator) {
12021
12025
  if (array.length > 200 || comparator) {
@@ -14059,12 +14063,12 @@ function attachmentToHistoryMessage(o, ts) {
14059
14063
  const raw = Array.isArray(a.memories) ? a.memories : [];
14060
14064
  const memories = raw.map((m2) => {
14061
14065
  if (!m2 || typeof m2 !== "object") return null;
14062
- const rec3 = m2;
14063
- const path81 = typeof rec3.path === "string" ? rec3.path : null;
14064
- 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;
14065
14069
  if (!path81 || content == null) return null;
14066
14070
  const entry = { path: path81, content };
14067
- if (typeof rec3.mtimeMs === "number") entry.mtimeMs = rec3.mtimeMs;
14071
+ if (typeof rec4.mtimeMs === "number") entry.mtimeMs = rec4.mtimeMs;
14068
14072
  return entry;
14069
14073
  }).filter((m2) => m2 !== null);
14070
14074
  if (memories.length === 0) return null;
@@ -14644,6 +14648,10 @@ function parseClaudeObjectInner(obj) {
14644
14648
  if (typeof branch === "string" && branch.length > 0) {
14645
14649
  events.push({ kind: "meta_update", patch: { gitBranch: branch } });
14646
14650
  }
14651
+ const effort = obj.effort;
14652
+ if (typeof effort === "string" && effort.length > 0) {
14653
+ events.push({ kind: "meta_update", patch: { resolvedEffort: effort } });
14654
+ }
14647
14655
  if (type === "system" && subtype === "init") {
14648
14656
  const sid = obj.session_id;
14649
14657
  const model = obj.model;
@@ -14879,12 +14887,12 @@ function parseAttachment(obj) {
14879
14887
  const raw = Array.isArray(a.memories) ? a.memories : [];
14880
14888
  const memories = raw.map((m2) => {
14881
14889
  if (!m2 || typeof m2 !== "object") return null;
14882
- const rec3 = m2;
14883
- const path81 = typeof rec3.path === "string" ? rec3.path : null;
14884
- 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;
14885
14893
  if (!path81 || content == null) return null;
14886
14894
  const out = { path: path81, content };
14887
- if (typeof rec3.mtimeMs === "number") out.mtimeMs = rec3.mtimeMs;
14895
+ if (typeof rec4.mtimeMs === "number") out.mtimeMs = rec4.mtimeMs;
14888
14896
  return out;
14889
14897
  }).filter((m2) => m2 !== null);
14890
14898
  if (memories.length === 0) return null;
@@ -21803,14 +21811,14 @@ var require_luxon = __commonJS({
21803
21811
  tibt: [3872, 3881]
21804
21812
  };
21805
21813
  var hanidecChars = numberingSystems.hanidec.replace(/[\[|\]]/g, "").split("");
21806
- function parseDigits(str4) {
21807
- let value = parseInt(str4, 10);
21814
+ function parseDigits(str5) {
21815
+ let value = parseInt(str5, 10);
21808
21816
  if (isNaN(value)) {
21809
21817
  value = "";
21810
- for (let i = 0; i < str4.length; i++) {
21811
- const code = str4.charCodeAt(i);
21812
- if (str4[i].search(numberingSystems.hanidec) !== -1) {
21813
- 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]);
21814
21822
  } else {
21815
21823
  for (const key in numberingSystemsUTF16) {
21816
21824
  const [min, max] = numberingSystemsUTF16[key];
@@ -28809,10 +28817,10 @@ var require_random = __commonJS({
28809
28817
  "use strict";
28810
28818
  Object.defineProperty(exports2, "__esModule", { value: true });
28811
28819
  exports2.seededRandom = seededRandom;
28812
- function xfnv1a(str4) {
28820
+ function xfnv1a(str5) {
28813
28821
  let h = 2166136261 >>> 0;
28814
- for (let i = 0; i < str4.length; i++) {
28815
- h ^= str4.charCodeAt(i);
28822
+ for (let i = 0; i < str5.length; i++) {
28823
+ h ^= str5.charCodeAt(i);
28816
28824
  h = Math.imul(h, 16777619);
28817
28825
  }
28818
28826
  return () => h >>> 0;
@@ -28825,8 +28833,8 @@ var require_random = __commonJS({
28825
28833
  return ((t ^ t >>> 14) >>> 0) / 4294967296;
28826
28834
  };
28827
28835
  }
28828
- function seededRandom(str4) {
28829
- 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);
28830
28838
  return mulberry32(seed);
28831
28839
  }
28832
28840
  }
@@ -34743,19 +34751,19 @@ var require_stream_readable = __commonJS({
34743
34751
  var ret = p2.data;
34744
34752
  n -= ret.length;
34745
34753
  while (p2 = p2.next) {
34746
- var str4 = p2.data;
34747
- var nb = n > str4.length ? str4.length : n;
34748
- if (nb === str4.length) ret += str4;
34749
- 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);
34750
34758
  n -= nb;
34751
34759
  if (n === 0) {
34752
- if (nb === str4.length) {
34760
+ if (nb === str5.length) {
34753
34761
  ++c;
34754
34762
  if (p2.next) list.head = p2.next;
34755
34763
  else list.head = list.tail = null;
34756
34764
  } else {
34757
34765
  list.head = p2;
34758
- p2.data = str4.slice(nb);
34766
+ p2.data = str5.slice(nb);
34759
34767
  }
34760
34768
  break;
34761
34769
  }
@@ -35651,14 +35659,14 @@ var require_utils = __commonJS({
35651
35659
  var nodejsUtils = require_nodejsUtils();
35652
35660
  var external = require_external();
35653
35661
  require_setImmediate();
35654
- function string2binary(str4) {
35662
+ function string2binary(str5) {
35655
35663
  var result = null;
35656
35664
  if (support.uint8array) {
35657
- result = new Uint8Array(str4.length);
35665
+ result = new Uint8Array(str5.length);
35658
35666
  } else {
35659
- result = new Array(str4.length);
35667
+ result = new Array(str5.length);
35660
35668
  }
35661
- return stringToArrayLike(str4, result);
35669
+ return stringToArrayLike(str5, result);
35662
35670
  }
35663
35671
  exports2.newBlob = function(part, type) {
35664
35672
  exports2.checkSupport("blob");
@@ -35680,9 +35688,9 @@ var require_utils = __commonJS({
35680
35688
  function identity(input) {
35681
35689
  return input;
35682
35690
  }
35683
- function stringToArrayLike(str4, array) {
35684
- for (var i = 0; i < str4.length; ++i) {
35685
- 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;
35686
35694
  }
35687
35695
  return array;
35688
35696
  }
@@ -35895,10 +35903,10 @@ var require_utils = __commonJS({
35895
35903
  };
35896
35904
  exports2.MAX_VALUE_16BITS = 65535;
35897
35905
  exports2.MAX_VALUE_32BITS = -1;
35898
- exports2.pretty = function(str4) {
35906
+ exports2.pretty = function(str5) {
35899
35907
  var res = "", code, i;
35900
- for (i = 0; i < (str4 || "").length; i++) {
35901
- code = str4.charCodeAt(i);
35908
+ for (i = 0; i < (str5 || "").length; i++) {
35909
+ code = str5.charCodeAt(i);
35902
35910
  res += "\\x" + (code < 16 ? "0" : "") + code.toString(16).toUpperCase();
35903
35911
  }
35904
35912
  return res;
@@ -36208,12 +36216,12 @@ var require_utf8 = __commonJS({
36208
36216
  }
36209
36217
  var i;
36210
36218
  _utf8len[254] = _utf8len[254] = 1;
36211
- var string2buf = function(str4) {
36212
- 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;
36213
36221
  for (m_pos = 0; m_pos < str_len; m_pos++) {
36214
- c = str4.charCodeAt(m_pos);
36222
+ c = str5.charCodeAt(m_pos);
36215
36223
  if ((c & 64512) === 55296 && m_pos + 1 < str_len) {
36216
- c2 = str4.charCodeAt(m_pos + 1);
36224
+ c2 = str5.charCodeAt(m_pos + 1);
36217
36225
  if ((c2 & 64512) === 56320) {
36218
36226
  c = 65536 + (c - 55296 << 10) + (c2 - 56320);
36219
36227
  m_pos++;
@@ -36227,9 +36235,9 @@ var require_utf8 = __commonJS({
36227
36235
  buf = new Array(buf_len);
36228
36236
  }
36229
36237
  for (i2 = 0, m_pos = 0; i2 < buf_len; m_pos++) {
36230
- c = str4.charCodeAt(m_pos);
36238
+ c = str5.charCodeAt(m_pos);
36231
36239
  if ((c & 64512) === 55296 && m_pos + 1 < str_len) {
36232
- c2 = str4.charCodeAt(m_pos + 1);
36240
+ c2 = str5.charCodeAt(m_pos + 1);
36233
36241
  if ((c2 & 64512) === 56320) {
36234
36242
  c = 65536 + (c - 55296 << 10) + (c2 - 56320);
36235
36243
  m_pos++;
@@ -36313,11 +36321,11 @@ var require_utf8 = __commonJS({
36313
36321
  }
36314
36322
  return utils.applyFromCharCode(utf16buf);
36315
36323
  };
36316
- exports2.utf8encode = function utf8encode(str4) {
36324
+ exports2.utf8encode = function utf8encode(str5) {
36317
36325
  if (support.nodebuffer) {
36318
- return nodejsUtils.newBufferFrom(str4, "utf-8");
36326
+ return nodejsUtils.newBufferFrom(str5, "utf-8");
36319
36327
  }
36320
- return string2buf(str4);
36328
+ return string2buf(str5);
36321
36329
  };
36322
36330
  exports2.utf8decode = function utf8decode(buf) {
36323
36331
  if (support.nodebuffer) {
@@ -36726,11 +36734,11 @@ var require_crc32 = __commonJS({
36726
36734
  }
36727
36735
  return crc ^ -1;
36728
36736
  }
36729
- function crc32str(crc, str4, len, pos) {
36737
+ function crc32str(crc, str5, len, pos) {
36730
36738
  var t = crcTable, end = pos + len;
36731
36739
  crc = crc ^ -1;
36732
36740
  for (var i = pos; i < end; i++) {
36733
- crc = crc >>> 8 ^ t[(crc ^ str4.charCodeAt(i)) & 255];
36741
+ crc = crc >>> 8 ^ t[(crc ^ str5.charCodeAt(i)) & 255];
36734
36742
  }
36735
36743
  return crc ^ -1;
36736
36744
  }
@@ -37927,7 +37935,7 @@ var require_deflate = __commonJS({
37927
37935
  }
37928
37936
  function fill_window(s) {
37929
37937
  var _w_size = s.w_size;
37930
- var p2, n, m2, more, str4;
37938
+ var p2, n, m2, more, str5;
37931
37939
  do {
37932
37940
  more = s.window_size - s.lookahead - s.strstart;
37933
37941
  if (s.strstart >= _w_size + (_w_size - MIN_LOOKAHEAD)) {
@@ -37955,14 +37963,14 @@ var require_deflate = __commonJS({
37955
37963
  n = read_buf(s.strm, s.window, s.strstart + s.lookahead, more);
37956
37964
  s.lookahead += n;
37957
37965
  if (s.lookahead + s.insert >= MIN_MATCH) {
37958
- str4 = s.strstart - s.insert;
37959
- s.ins_h = s.window[str4];
37960
- 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;
37961
37969
  while (s.insert) {
37962
- s.ins_h = (s.ins_h << s.hash_shift ^ s.window[str4 + MIN_MATCH - 1]) & s.hash_mask;
37963
- s.prev[str4 & s.w_mask] = s.head[s.ins_h];
37964
- s.head[s.ins_h] = str4;
37965
- 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++;
37966
37974
  s.insert--;
37967
37975
  if (s.lookahead + s.insert < MIN_MATCH) {
37968
37976
  break;
@@ -38738,7 +38746,7 @@ var require_deflate = __commonJS({
38738
38746
  function deflateSetDictionary(strm, dictionary) {
38739
38747
  var dictLength = dictionary.length;
38740
38748
  var s;
38741
- var str4, n;
38749
+ var str5, n;
38742
38750
  var wrap2;
38743
38751
  var avail;
38744
38752
  var next;
@@ -38776,15 +38784,15 @@ var require_deflate = __commonJS({
38776
38784
  strm.input = dictionary;
38777
38785
  fill_window(s);
38778
38786
  while (s.lookahead >= MIN_MATCH) {
38779
- str4 = s.strstart;
38787
+ str5 = s.strstart;
38780
38788
  n = s.lookahead - (MIN_MATCH - 1);
38781
38789
  do {
38782
- s.ins_h = (s.ins_h << s.hash_shift ^ s.window[str4 + MIN_MATCH - 1]) & s.hash_mask;
38783
- s.prev[str4 & s.w_mask] = s.head[s.ins_h];
38784
- s.head[s.ins_h] = str4;
38785
- 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++;
38786
38794
  } while (--n);
38787
- s.strstart = str4;
38795
+ s.strstart = str5;
38788
38796
  s.lookahead = MIN_MATCH - 1;
38789
38797
  fill_window(s);
38790
38798
  }
@@ -38835,12 +38843,12 @@ var require_strings = __commonJS({
38835
38843
  }
38836
38844
  var q;
38837
38845
  _utf8len[254] = _utf8len[254] = 1;
38838
- exports2.string2buf = function(str4) {
38839
- 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;
38840
38848
  for (m_pos = 0; m_pos < str_len; m_pos++) {
38841
- c = str4.charCodeAt(m_pos);
38849
+ c = str5.charCodeAt(m_pos);
38842
38850
  if ((c & 64512) === 55296 && m_pos + 1 < str_len) {
38843
- c2 = str4.charCodeAt(m_pos + 1);
38851
+ c2 = str5.charCodeAt(m_pos + 1);
38844
38852
  if ((c2 & 64512) === 56320) {
38845
38853
  c = 65536 + (c - 55296 << 10) + (c2 - 56320);
38846
38854
  m_pos++;
@@ -38850,9 +38858,9 @@ var require_strings = __commonJS({
38850
38858
  }
38851
38859
  buf = new utils.Buf8(buf_len);
38852
38860
  for (i = 0, m_pos = 0; i < buf_len; m_pos++) {
38853
- c = str4.charCodeAt(m_pos);
38861
+ c = str5.charCodeAt(m_pos);
38854
38862
  if ((c & 64512) === 55296 && m_pos + 1 < str_len) {
38855
- c2 = str4.charCodeAt(m_pos + 1);
38863
+ c2 = str5.charCodeAt(m_pos + 1);
38856
38864
  if ((c2 & 64512) === 56320) {
38857
38865
  c = 65536 + (c - 55296 << 10) + (c2 - 56320);
38858
38866
  m_pos++;
@@ -38891,10 +38899,10 @@ var require_strings = __commonJS({
38891
38899
  exports2.buf2binstring = function(buf) {
38892
38900
  return buf2binstring(buf, buf.length);
38893
38901
  };
38894
- exports2.binstring2buf = function(str4) {
38895
- var buf = new utils.Buf8(str4.length);
38902
+ exports2.binstring2buf = function(str5) {
38903
+ var buf = new utils.Buf8(str5.length);
38896
38904
  for (var i = 0, len = buf.length; i < len; i++) {
38897
- buf[i] = str4.charCodeAt(i);
38905
+ buf[i] = str5.charCodeAt(i);
38898
38906
  }
38899
38907
  return buf;
38900
38908
  };
@@ -43601,9 +43609,9 @@ async function sendBatch(deps, batch) {
43601
43609
  }
43602
43610
  return { sent: 0, failed: batch.records.length };
43603
43611
  }
43604
- function stringifyRecord(rec3) {
43612
+ function stringifyRecord(rec4) {
43605
43613
  const out = {};
43606
- for (const [k2, v2] of Object.entries(rec3)) {
43614
+ for (const [k2, v2] of Object.entries(rec4)) {
43607
43615
  if (v2 == null) continue;
43608
43616
  out[k2] = typeof v2 === "string" ? v2 : String(v2);
43609
43617
  }
@@ -44519,7 +44527,7 @@ function eqContextUsage(a, b2) {
44519
44527
  return a.inputTokens === b2.inputTokens && a.outputTokens === b2.outputTokens && a.cacheReadTokens === b2.cacheReadTokens && a.cacheCreateTokens === b2.cacheCreateTokens;
44520
44528
  }
44521
44529
  function shallowEqMeta(a, b2) {
44522
- return a.gitBranch === b2.gitBranch && a.resolvedModel === b2.resolvedModel && a.contextWindowSize === b2.contextWindowSize && eqContextUsage(a.contextUsage, b2.contextUsage);
44530
+ return a.gitBranch === b2.gitBranch && a.resolvedModel === b2.resolvedModel && a.resolvedEffort === b2.resolvedEffort && a.contextWindowSize === b2.contextWindowSize && eqContextUsage(a.contextUsage, b2.contextUsage);
44523
44531
  }
44524
44532
  function applyMetaUpdate(state, patch, deps) {
44525
44533
  const next = cloneState(state);
@@ -46543,6 +46551,27 @@ var SessionManager = class {
46543
46551
  if (!existing || existing.cwd === cwd) return;
46544
46552
  this.writeOwned({ ...existing, cwd, updatedAt: nowIso2(this.deps) });
46545
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
+ }
46546
46575
  /**
46547
46576
  * 启动清扫:删除所有磁盘残留的 ephemeral(快速问答临时)session。
46548
46577
  * 客户端崩溃 / 没关抽屉会留下永久不可见的孤儿(ephemeral 被 sidebar 过滤,用户自己也删不掉)。
@@ -51339,7 +51368,7 @@ function createDispatchStore(deps) {
51339
51368
  return records.find((r) => r.dispatchId === dispatchId);
51340
51369
  }
51341
51370
  function add(input) {
51342
- const rec3 = {
51371
+ const rec4 = {
51343
51372
  dispatchId: input.dispatchId,
51344
51373
  sourceSessionId: input.sourceSessionId,
51345
51374
  ...input.sourcePersonaId ? { sourcePersonaId: input.sourcePersonaId } : {},
@@ -51349,9 +51378,9 @@ function createDispatchStore(deps) {
51349
51378
  ...input.meta ? { meta: input.meta } : {},
51350
51379
  createdAt: new Date(deps.now()).toISOString()
51351
51380
  };
51352
- records.push(rec3);
51381
+ records.push(rec4);
51353
51382
  scheduleFlush();
51354
- return rec3;
51383
+ return rec4;
51355
51384
  }
51356
51385
  function update(dispatchId, patch) {
51357
51386
  const idx = records.findIndex((r) => r.dispatchId === dispatchId);
@@ -52443,11 +52472,11 @@ function createLarkBotCloudClient(opts) {
52443
52472
  const json = await request("POST", "/api/lark-bot/events/claim?v=2");
52444
52473
  const items = json.items ?? [];
52445
52474
  return items.map((it) => {
52446
- const rec3 = it;
52447
- if (rec3 && typeof rec3 === "object" && "payload" in rec3) {
52475
+ const rec4 = it;
52476
+ if (rec4 && typeof rec4 === "object" && "payload" in rec4) {
52448
52477
  return {
52449
- status: rec3.status === "forwarded" ? "forwarded" : "received",
52450
- payload: rec3.payload
52478
+ status: rec4.status === "forwarded" ? "forwarded" : "received",
52479
+ payload: rec4.payload
52451
52480
  };
52452
52481
  }
52453
52482
  return { status: "received", payload: it };
@@ -52919,20 +52948,20 @@ function buildPersonaDispatchHandlers(deps) {
52919
52948
  "follow-up dispatch cannot be initiated by a guest"
52920
52949
  );
52921
52950
  }
52922
- const rec3 = deps.store.get(args.dispatchId);
52923
- if (!rec3) {
52951
+ const rec4 = deps.store.get(args.dispatchId);
52952
+ if (!rec4) {
52924
52953
  throw new ClawdError(ERROR_CODES.INVALID_PARAM, `dispatch not found: ${args.dispatchId}`);
52925
52954
  }
52926
- if (!rec3.workerSessionId) {
52955
+ if (!rec4.workerSessionId) {
52927
52956
  throw new ClawdError(
52928
52957
  ERROR_CODES.INVALID_PARAM,
52929
52958
  `dispatch ${args.dispatchId} has no worker session and cannot be continued (cross-device or spawn incomplete)`
52930
52959
  );
52931
52960
  }
52932
- if (args.targetPersona && args.targetPersona !== rec3.targetPersonaId) {
52961
+ if (args.targetPersona && args.targetPersona !== rec4.targetPersonaId) {
52933
52962
  throw new ClawdError(
52934
52963
  ERROR_CODES.INVALID_PARAM,
52935
- `targetPersona mismatch: dispatch ${args.dispatchId} belongs to ${rec3.targetPersonaId}`
52964
+ `targetPersona mismatch: dispatch ${args.dispatchId} belongs to ${rec4.targetPersonaId}`
52936
52965
  );
52937
52966
  }
52938
52967
  if (!deps.sendFollowUp) {
@@ -52947,16 +52976,16 @@ function buildPersonaDispatchHandlers(deps) {
52947
52976
  });
52948
52977
  mgr.reopen(args.dispatchId, {
52949
52978
  sourceSessionId,
52950
- targetPersona: rec3.targetPersonaId,
52951
- workerSessionId: rec3.workerSessionId
52979
+ targetPersona: rec4.targetPersonaId,
52980
+ workerSessionId: rec4.workerSessionId
52952
52981
  });
52953
52982
  logger?.info("dispatch.run.follow-up", {
52954
52983
  dispatchId: args.dispatchId,
52955
- workerSessionId: rec3.workerSessionId,
52984
+ workerSessionId: rec4.workerSessionId,
52956
52985
  promptLen: args.prompt.length
52957
52986
  });
52958
52987
  const ok = deps.sendFollowUp(
52959
- rec3.workerSessionId,
52988
+ rec4.workerSessionId,
52960
52989
  buildFollowUpTaskPack(args.dispatchId, args.prompt)
52961
52990
  );
52962
52991
  if (!ok) {
@@ -53103,16 +53132,16 @@ function buildPersonaDispatchHandlers(deps) {
53103
53132
  const get = async (frame, _client, ctx) => {
53104
53133
  const { type: _t, requestId: _r, ...rest } = frame;
53105
53134
  const args = DispatchGetArgsSchema.parse(rest);
53106
- const rec3 = deps.store.get(args.dispatchId);
53107
- const denied = ctx?.principal.kind === "guest" && rec3?.sourceSessionId !== ctx.principal.id;
53108
- 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) {
53109
53138
  throw new ClawdError(ERROR_CODES.DISPATCH_NOT_FOUND, `unknown dispatchId: ${args.dispatchId}`);
53110
53139
  }
53111
53140
  return {
53112
53141
  response: {
53113
53142
  type: "personaDispatch:get:ok",
53114
- status: rec3.status,
53115
- ...rec3.outcome ? { outcome: rec3.outcome } : {}
53143
+ status: rec4.status,
53144
+ ...rec4.outcome ? { outcome: rec4.outcome } : {}
53116
53145
  }
53117
53146
  };
53118
53147
  };
@@ -53489,6 +53518,84 @@ async function listCodexSkills(cwd, deps = {}) {
53489
53518
  return mapSkillsListResponse(res);
53490
53519
  }
53491
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
+
53492
53599
  // src/workspace/browser.ts
53493
53600
  var import_node_fs28 = __toESM(require("fs"), 1);
53494
53601
  var import_node_os8 = __toESM(require("os"), 1);
@@ -54833,7 +54940,7 @@ async function authenticate(token, deps) {
54833
54940
  }
54834
54941
 
54835
54942
  // src/legacy-cleanup.ts
54836
- var fs36 = __toESM(require("fs/promises"), 1);
54943
+ var fs37 = __toESM(require("fs/promises"), 1);
54837
54944
  var path38 = __toESM(require("path"), 1);
54838
54945
  var LEGACY_FILES = [
54839
54946
  "personal-capability.json",
@@ -54845,7 +54952,7 @@ async function cleanupLegacyCapabilityFiles(dataDir, logger) {
54845
54952
  for (const name of LEGACY_FILES) {
54846
54953
  const p2 = path38.join(dataDir, name);
54847
54954
  try {
54848
- await fs36.unlink(p2);
54955
+ await fs37.unlink(p2);
54849
54956
  removed.push(name);
54850
54957
  logger.debug("legacy capability file removed", { file: name });
54851
54958
  } catch (err) {
@@ -54857,13 +54964,13 @@ async function cleanupLegacyCapabilityFiles(dataDir, logger) {
54857
54964
  }
54858
54965
 
54859
54966
  // src/inbox/inbox-store.ts
54860
- var fs37 = __toESM(require("fs"), 1);
54967
+ var fs38 = __toESM(require("fs"), 1);
54861
54968
  var path39 = __toESM(require("path"), 1);
54862
54969
  var INBOX_SUBDIR = "inbox";
54863
54970
  var InboxStore = class {
54864
54971
  constructor(dataDir) {
54865
54972
  this.dataDir = dataDir;
54866
- fs37.mkdirSync(this.dirPath(), { recursive: true });
54973
+ fs38.mkdirSync(this.dirPath(), { recursive: true });
54867
54974
  }
54868
54975
  dataDir;
54869
54976
  /**
@@ -54875,7 +54982,7 @@ var InboxStore = class {
54875
54982
  const file = this.filePath(peerDeviceId);
54876
54983
  let raw;
54877
54984
  try {
54878
- raw = fs37.readFileSync(file, "utf8");
54985
+ raw = fs38.readFileSync(file, "utf8");
54879
54986
  } catch (err) {
54880
54987
  if (err?.code === "ENOENT") return [];
54881
54988
  return [];
@@ -54891,7 +54998,7 @@ var InboxStore = class {
54891
54998
  const dir = this.dirPath();
54892
54999
  let entries;
54893
55000
  try {
54894
- entries = fs37.readdirSync(dir);
55001
+ entries = fs38.readdirSync(dir);
54895
55002
  } catch (err) {
54896
55003
  if (err?.code === "ENOENT") return [];
54897
55004
  return [];
@@ -54907,9 +55014,9 @@ var InboxStore = class {
54907
55014
  if (existing.some((m2) => m2.id === message.id)) return;
54908
55015
  const file = this.filePath(message.peerDeviceId);
54909
55016
  const line = JSON.stringify(message) + "\n";
54910
- fs37.appendFileSync(file, line, { mode: 384 });
55017
+ fs38.appendFileSync(file, line, { mode: 384 });
54911
55018
  try {
54912
- fs37.chmodSync(file, 384);
55019
+ fs38.chmodSync(file, 384);
54913
55020
  } catch {
54914
55021
  }
54915
55022
  }
@@ -54939,7 +55046,7 @@ var InboxStore = class {
54939
55046
  removeByPeerDeviceId(peerDeviceId) {
54940
55047
  const file = this.filePath(peerDeviceId);
54941
55048
  try {
54942
- fs37.unlinkSync(file);
55049
+ fs38.unlinkSync(file);
54943
55050
  } catch (err) {
54944
55051
  if (err?.code === "ENOENT") return;
54945
55052
  }
@@ -54948,10 +55055,10 @@ var InboxStore = class {
54948
55055
  const file = this.filePath(peerDeviceId);
54949
55056
  const tmp = `${file}.tmp-${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2)}`;
54950
55057
  const content = messages.map((m2) => JSON.stringify(m2)).join("\n") + (messages.length > 0 ? "\n" : "");
54951
- fs37.writeFileSync(tmp, content, { mode: 384 });
54952
- fs37.renameSync(tmp, file);
55058
+ fs38.writeFileSync(tmp, content, { mode: 384 });
55059
+ fs38.renameSync(tmp, file);
54953
55060
  try {
54954
- fs37.chmodSync(file, 384);
55061
+ fs38.chmodSync(file, 384);
54955
55062
  } catch {
54956
55063
  }
54957
55064
  }
@@ -55047,7 +55154,7 @@ var InboxManager = class {
55047
55154
  };
55048
55155
 
55049
55156
  // src/state/contact-store.ts
55050
- var fs38 = __toESM(require("fs"), 1);
55157
+ var fs39 = __toESM(require("fs"), 1);
55051
55158
  var path40 = __toESM(require("path"), 1);
55052
55159
  var FILE_NAME = "contacts.json";
55053
55160
  var ContactStore = class {
@@ -55061,7 +55168,7 @@ var ContactStore = class {
55061
55168
  const file = path40.join(this.dataDir, FILE_NAME);
55062
55169
  let raw;
55063
55170
  try {
55064
- raw = fs38.readFileSync(file, "utf8");
55171
+ raw = fs39.readFileSync(file, "utf8");
55065
55172
  } catch (err) {
55066
55173
  if (err?.code !== "ENOENT") this.renameBak(file);
55067
55174
  return;
@@ -55137,13 +55244,13 @@ var ContactStore = class {
55137
55244
  null,
55138
55245
  2
55139
55246
  );
55140
- fs38.mkdirSync(this.dataDir, { recursive: true });
55141
- fs38.writeFileSync(tmp, content, { mode: 384 });
55142
- fs38.renameSync(tmp, file);
55247
+ fs39.mkdirSync(this.dataDir, { recursive: true });
55248
+ fs39.writeFileSync(tmp, content, { mode: 384 });
55249
+ fs39.renameSync(tmp, file);
55143
55250
  }
55144
55251
  renameBak(file) {
55145
55252
  try {
55146
- fs38.renameSync(file, `${file}.bak`);
55253
+ fs39.renameSync(file, `${file}.bak`);
55147
55254
  } catch {
55148
55255
  }
55149
55256
  }
@@ -55251,7 +55358,7 @@ async function connectRemote(args) {
55251
55358
  }
55252
55359
 
55253
55360
  // src/migrations/2026-05-20-flatten-sessions.ts
55254
- var fs39 = __toESM(require("fs"), 1);
55361
+ var fs40 = __toESM(require("fs"), 1);
55255
55362
  var path41 = __toESM(require("path"), 1);
55256
55363
  var MIGRATION_FLAG_NAME = ".migration.v1.done";
55257
55364
  function migrateFlattenSessions(opts) {
@@ -55271,7 +55378,7 @@ function migrateFlattenSessions(opts) {
55271
55378
  if (!entry.endsWith(".json")) continue;
55272
55379
  const src = path41.join(defaultDir, entry);
55273
55380
  const dst = path41.join(sessionsDir, entry);
55274
- fs39.renameSync(src, dst);
55381
+ fs40.renameSync(src, dst);
55275
55382
  movedBare += 1;
55276
55383
  }
55277
55384
  rmdirIfEmpty(defaultDir);
@@ -55283,10 +55390,10 @@ function migrateFlattenSessions(opts) {
55283
55390
  const ownerSrc = path41.join(personaDir, "owner");
55284
55391
  if (existsSync3(ownerSrc) && isDir(ownerSrc)) {
55285
55392
  const ownerDst = path41.join(dataDir, "personas", pid, ".clawd", "sessions", "owner");
55286
- fs39.mkdirSync(ownerDst, { recursive: true });
55393
+ fs40.mkdirSync(ownerDst, { recursive: true });
55287
55394
  for (const file of readdirSafe(ownerSrc)) {
55288
55395
  if (!file.endsWith(".json")) continue;
55289
- fs39.renameSync(path41.join(ownerSrc, file), path41.join(ownerDst, file));
55396
+ fs40.renameSync(path41.join(ownerSrc, file), path41.join(ownerDst, file));
55290
55397
  movedVmOwner += 1;
55291
55398
  }
55292
55399
  rmdirIfEmpty(ownerSrc);
@@ -55294,18 +55401,18 @@ function migrateFlattenSessions(opts) {
55294
55401
  const listenerSrc = path41.join(personaDir, "listener");
55295
55402
  if (existsSync3(listenerSrc) && isDir(listenerSrc)) {
55296
55403
  const archiveDst = path41.join(dataDir, ".legacy", `listener-${pid}`);
55297
- fs39.mkdirSync(archiveDst, { recursive: true });
55404
+ fs40.mkdirSync(archiveDst, { recursive: true });
55298
55405
  for (const file of readdirSafe(listenerSrc)) {
55299
55406
  if (!file.endsWith(".json")) continue;
55300
- fs39.renameSync(path41.join(listenerSrc, file), path41.join(archiveDst, file));
55407
+ fs40.renameSync(path41.join(listenerSrc, file), path41.join(archiveDst, file));
55301
55408
  archivedListener += 1;
55302
55409
  }
55303
55410
  rmdirIfEmpty(listenerSrc);
55304
55411
  }
55305
55412
  rmdirIfEmpty(personaDir);
55306
55413
  }
55307
- fs39.mkdirSync(sessionsDir, { recursive: true });
55308
- 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));
55309
55416
  return {
55310
55417
  skipped: false,
55311
55418
  flagWritten: true,
@@ -55316,7 +55423,7 @@ function migrateFlattenSessions(opts) {
55316
55423
  }
55317
55424
  function existsSync3(p2) {
55318
55425
  try {
55319
- fs39.statSync(p2);
55426
+ fs40.statSync(p2);
55320
55427
  return true;
55321
55428
  } catch {
55322
55429
  return false;
@@ -55324,21 +55431,21 @@ function existsSync3(p2) {
55324
55431
  }
55325
55432
  function isDir(p2) {
55326
55433
  try {
55327
- return fs39.statSync(p2).isDirectory();
55434
+ return fs40.statSync(p2).isDirectory();
55328
55435
  } catch {
55329
55436
  return false;
55330
55437
  }
55331
55438
  }
55332
55439
  function readdirSafe(p2) {
55333
55440
  try {
55334
- return fs39.readdirSync(p2);
55441
+ return fs40.readdirSync(p2);
55335
55442
  } catch {
55336
55443
  return [];
55337
55444
  }
55338
55445
  }
55339
55446
  function rmdirIfEmpty(p2) {
55340
55447
  try {
55341
- fs39.rmdirSync(p2);
55448
+ fs40.rmdirSync(p2);
55342
55449
  } catch {
55343
55450
  }
55344
55451
  }
@@ -55528,7 +55635,7 @@ function verifySignedUrl(secret, absPath, eRaw, s, now = Date.now) {
55528
55635
  var import_node_fs32 = __toESM(require("fs"), 1);
55529
55636
  var import_node_path35 = __toESM(require("path"), 1);
55530
55637
  var import_node_crypto8 = __toESM(require("crypto"), 1);
55531
- var import_promises3 = require("stream/promises");
55638
+ var import_promises4 = require("stream/promises");
55532
55639
  var UploadError = class extends Error {
55533
55640
  constructor(code, message) {
55534
55641
  super(message);
@@ -55558,7 +55665,7 @@ async function writeUploadedAttachment(args) {
55558
55665
  `.upload-${process.pid}-${Date.now()}-${import_node_crypto8.default.randomBytes(4).toString("hex")}`
55559
55666
  );
55560
55667
  try {
55561
- await (0, import_promises3.pipeline)(
55668
+ await (0, import_promises4.pipeline)(
55562
55669
  args.body,
55563
55670
  async function* (source) {
55564
55671
  for await (const chunk of source) {
@@ -55629,7 +55736,7 @@ async function writeUploadedAttachment(args) {
55629
55736
  }
55630
55737
 
55631
55738
  // src/extension/import.ts
55632
- var import_promises4 = __toESM(require("fs/promises"), 1);
55739
+ var import_promises5 = __toESM(require("fs/promises"), 1);
55633
55740
  var import_node_path36 = __toESM(require("path"), 1);
55634
55741
  var import_node_os12 = __toESM(require("os"), 1);
55635
55742
  var import_jszip = __toESM(require_lib3(), 1);
@@ -55684,30 +55791,30 @@ async function importZip(buf, root) {
55684
55791
  const destDir = import_node_path36.default.join(root, manifest.id);
55685
55792
  let destExists = false;
55686
55793
  try {
55687
- await import_promises4.default.access(destDir);
55794
+ await import_promises5.default.access(destDir);
55688
55795
  destExists = true;
55689
55796
  } catch {
55690
55797
  }
55691
55798
  if (destExists) {
55692
55799
  throw new ImportError("ALREADY_EXISTS", `extension ${manifest.id} already installed`);
55693
55800
  }
55694
- 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}-`));
55695
55802
  try {
55696
55803
  for (const [name, entry] of Object.entries(zip.files)) {
55697
55804
  const dest = import_node_path36.default.join(stage, name);
55698
55805
  if (entry.dir) {
55699
- await import_promises4.default.mkdir(dest, { recursive: true });
55806
+ await import_promises5.default.mkdir(dest, { recursive: true });
55700
55807
  continue;
55701
55808
  }
55702
- 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 });
55703
55810
  const content = await entry.async("nodebuffer");
55704
- await import_promises4.default.writeFile(dest, content);
55811
+ await import_promises5.default.writeFile(dest, content);
55705
55812
  }
55706
- await import_promises4.default.mkdir(root, { recursive: true });
55707
- await import_promises4.default.rename(stage, destDir);
55813
+ await import_promises5.default.mkdir(root, { recursive: true });
55814
+ await import_promises5.default.rename(stage, destDir);
55708
55815
  return { extId: manifest.id };
55709
55816
  } catch (e) {
55710
- await import_promises4.default.rm(stage, { recursive: true, force: true }).catch(() => {
55817
+ await import_promises5.default.rm(stage, { recursive: true, force: true }).catch(() => {
55711
55818
  });
55712
55819
  throw e;
55713
55820
  }
@@ -56737,7 +56844,7 @@ var import_node_os13 = __toESM(require("os"), 1);
56737
56844
  var import_node_path42 = __toESM(require("path"), 1);
56738
56845
  var import_node_child_process8 = require("child_process");
56739
56846
  var import_node_stream3 = require("stream");
56740
- var import_promises5 = require("stream/promises");
56847
+ var import_promises6 = require("stream/promises");
56741
56848
  var FRPC_VERSION = "0.68.0";
56742
56849
  var UnsupportedPlatformError = class extends Error {
56743
56850
  constructor(platform, arch) {
@@ -56828,7 +56935,7 @@ async function downloadToFile(url, dest, fetchImpl) {
56828
56935
  }
56829
56936
  const out = import_node_fs38.default.createWriteStream(dest);
56830
56937
  const nodeStream = import_node_stream3.Readable.fromWeb(res.body);
56831
- await (0, import_promises5.pipeline)(nodeStream, out);
56938
+ await (0, import_promises6.pipeline)(nodeStream, out);
56832
56939
  }
56833
56940
  async function extractFrpcFromTarball(tarball, binDir, version2, platform, destBin) {
56834
56941
  const work = import_node_path42.default.join(binDir, `extract-${process.pid}-${Date.now()}`);
@@ -57701,7 +57808,7 @@ function verifyConnectToken(args) {
57701
57808
  }
57702
57809
 
57703
57810
  // src/feishu-auth/server-key.ts
57704
- var fs53 = __toESM(require("fs"), 1);
57811
+ var fs54 = __toESM(require("fs"), 1);
57705
57812
  var path57 = __toESM(require("path"), 1);
57706
57813
  var FILE_NAME2 = "server-signing-key.json";
57707
57814
  var ServerKeyStore = class {
@@ -57715,7 +57822,7 @@ var ServerKeyStore = class {
57715
57822
  /** 读缓存的公钥;无缓存 / 损坏 → null(调用方决定是否触发拉取) */
57716
57823
  read() {
57717
57824
  try {
57718
- const raw = fs53.readFileSync(this.filePath(), "utf8");
57825
+ const raw = fs54.readFileSync(this.filePath(), "utf8");
57719
57826
  const parsed = JSON.parse(raw);
57720
57827
  if (typeof parsed.publicKeyPem === "string" && parsed.publicKeyPem.includes("PUBLIC KEY")) {
57721
57828
  return parsed.publicKeyPem;
@@ -57730,12 +57837,12 @@ var ServerKeyStore = class {
57730
57837
  publicKeyPem,
57731
57838
  fetchedAt: (/* @__PURE__ */ new Date()).toISOString()
57732
57839
  };
57733
- fs53.mkdirSync(this.dataDir, { recursive: true });
57734
- 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 });
57735
57842
  }
57736
57843
  clear() {
57737
57844
  try {
57738
- fs53.unlinkSync(this.filePath());
57845
+ fs54.unlinkSync(this.filePath());
57739
57846
  } catch {
57740
57847
  }
57741
57848
  }
@@ -57816,7 +57923,7 @@ function forkSession(input) {
57816
57923
 
57817
57924
  // src/session/external-scan.ts
57818
57925
  var import_node_fs45 = __toESM(require("fs"), 1);
57819
- var import_promises6 = __toESM(require("fs/promises"), 1);
57926
+ var import_promises7 = __toESM(require("fs/promises"), 1);
57820
57927
  var import_node_os17 = __toESM(require("os"), 1);
57821
57928
  var import_node_path50 = __toESM(require("path"), 1);
57822
57929
  var import_node_module = require("module");
@@ -57872,7 +57979,7 @@ function listFiles(dir, depth = 0, maxDepth = 8, out = []) {
57872
57979
  async function* jsonLines(file) {
57873
57980
  let raw;
57874
57981
  try {
57875
- raw = await import_promises6.default.readFile(file, "utf8");
57982
+ raw = await import_promises7.default.readFile(file, "utf8");
57876
57983
  } catch {
57877
57984
  return;
57878
57985
  }
@@ -57932,23 +58039,23 @@ async function scanClaude(roots) {
57932
58039
  let firstTs = 0;
57933
58040
  let lastTs = 0;
57934
58041
  let hasMainLine = false;
57935
- for await (const rec3 of jsonLines(file)) {
57936
- if (!cwd && typeof rec3.cwd === "string") cwd = rec3.cwd;
57937
- if (typeof rec3.timestamp === "string") {
57938
- 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);
57939
58046
  if (Number.isFinite(t)) {
57940
58047
  firstTs ||= t;
57941
58048
  lastTs = t;
57942
58049
  }
57943
58050
  }
57944
- if (rec3.type === "ai-title" && rec3.aiTitle) {
57945
- title = String(rec3.aiTitle);
58051
+ if (rec4.type === "ai-title" && rec4.aiTitle) {
58052
+ title = String(rec4.aiTitle);
57946
58053
  continue;
57947
58054
  }
57948
- if (rec3.type !== "user" && rec3.type !== "assistant") continue;
57949
- if (!rec3.isSidechain) hasMainLine = true;
57950
- if (rec3.type !== "user" || rec3.isSidechain || rec3.isMeta) continue;
57951
- 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 || {});
57952
58059
  if (!text.trim() || text.trimStart().startsWith("<")) continue;
57953
58060
  turns += 1;
57954
58061
  firstUser ||= text;
@@ -57974,8 +58081,8 @@ async function countCodexTurns(rolloutPath) {
57974
58081
  if (!rolloutPath || !import_node_fs45.default.existsSync(rolloutPath)) return { turns: 0, first: "" };
57975
58082
  let turns = 0;
57976
58083
  let first = "";
57977
- for await (const rec3 of jsonLines(rolloutPath)) {
57978
- const p2 = rec3.payload || {};
58084
+ for await (const rec4 of jsonLines(rolloutPath)) {
58085
+ const p2 = rec4.payload || {};
57979
58086
  if (p2.type !== "message" || p2.role !== "user") continue;
57980
58087
  const text = (p2.content || []).map((b2) => String(b2 && b2.text || "")).join("");
57981
58088
  if (!text.trim() || text.trimStart().startsWith("<")) continue;
@@ -58052,9 +58159,9 @@ async function scanCodexRollouts(roots) {
58052
58159
  continue;
58053
58160
  }
58054
58161
  let meta = null;
58055
- for await (const rec3 of jsonLines(file)) {
58056
- if (rec3.type === "session_meta") {
58057
- meta = rec3.payload || {};
58162
+ for await (const rec4 of jsonLines(file)) {
58163
+ if (rec4.type === "session_meta") {
58164
+ meta = rec4.payload || {};
58058
58165
  break;
58059
58166
  }
58060
58167
  }
@@ -58439,6 +58546,7 @@ function buildSessionHandlers(deps) {
58439
58546
  if (args.sessionId !== void 0) {
58440
58547
  ensureSessionAccess(ctx, args.sessionId, "read");
58441
58548
  addSubscription(client, args.sessionId);
58549
+ void deps.hydrateCodexResolvedMeta?.(args.sessionId);
58442
58550
  }
58443
58551
  return {
58444
58552
  response: { type: "subscribed", sessionId: args.sessionId }
@@ -59882,10 +59990,10 @@ function computeMethodAccess(args) {
59882
59990
  }
59883
59991
 
59884
59992
  // src/version.ts
59885
- var version = "0.2.325".length > 0 ? "0.2.325" : "dev";
59993
+ var version = "0.2.327".length > 0 ? "0.2.327" : "dev";
59886
59994
 
59887
59995
  // src/cli-probe/probe.ts
59888
- var fs58 = __toESM(require("fs"), 1);
59996
+ var fs59 = __toESM(require("fs"), 1);
59889
59997
  var path66 = __toESM(require("path"), 1);
59890
59998
  var PKG_NAME = "@clawos-dev/clawd";
59891
59999
  var BIN_NAME = "clawd";
@@ -59896,7 +60004,7 @@ function probeGlobalCli(pathEnv) {
59896
60004
  if (!dir) continue;
59897
60005
  let real;
59898
60006
  try {
59899
- real = fs58.realpathSync(path66.join(dir, BIN_NAME));
60007
+ real = fs59.realpathSync(path66.join(dir, BIN_NAME));
59900
60008
  } catch {
59901
60009
  continue;
59902
60010
  }
@@ -59909,7 +60017,7 @@ function readOwnPackageVersion(entryPath) {
59909
60017
  let dir = path66.dirname(entryPath);
59910
60018
  for (let i = 0; i < MAX_PARENT_HOPS; i++) {
59911
60019
  try {
59912
- const raw = fs58.readFileSync(path66.join(dir, "package.json"), "utf8");
60020
+ const raw = fs59.readFileSync(path66.join(dir, "package.json"), "utf8");
59913
60021
  const pkg = JSON.parse(raw);
59914
60022
  if (pkg.name !== PKG_NAME) return null;
59915
60023
  return typeof pkg.version === "string" && pkg.version ? pkg.version : null;
@@ -60258,12 +60366,12 @@ function buildAttachmentHandlers(deps) {
60258
60366
  }
60259
60367
 
60260
60368
  // src/handlers/extension.ts
60261
- var import_promises10 = __toESM(require("fs/promises"), 1);
60369
+ var import_promises11 = __toESM(require("fs/promises"), 1);
60262
60370
  var import_node_path58 = __toESM(require("path"), 1);
60263
60371
  init_protocol();
60264
60372
 
60265
60373
  // src/extension/bundle-zip.ts
60266
- var import_promises7 = __toESM(require("fs/promises"), 1);
60374
+ var import_promises8 = __toESM(require("fs/promises"), 1);
60267
60375
  var import_node_path54 = __toESM(require("path"), 1);
60268
60376
  var import_node_crypto14 = __toESM(require("crypto"), 1);
60269
60377
  var import_jszip2 = __toESM(require_lib3(), 1);
@@ -60272,7 +60380,7 @@ async function bundleExtensionDir(dir) {
60272
60380
  const zip = new import_jszip2.default();
60273
60381
  for (const rel of entries) {
60274
60382
  const abs = import_node_path54.default.join(dir, rel);
60275
- const content = await import_promises7.default.readFile(abs);
60383
+ const content = await import_promises8.default.readFile(abs);
60276
60384
  zip.file(rel, content, { date: FIXED_DATE });
60277
60385
  }
60278
60386
  const buffer = await zip.generateAsync({
@@ -60293,7 +60401,7 @@ async function listFilesSorted(rootDir) {
60293
60401
  }
60294
60402
  async function walk(absRoot, relPrefix, out) {
60295
60403
  const dirAbs = import_node_path54.default.join(absRoot, relPrefix);
60296
- const entries = await import_promises7.default.readdir(dirAbs, { withFileTypes: true });
60404
+ const entries = await import_promises8.default.readdir(dirAbs, { withFileTypes: true });
60297
60405
  for (const e of entries) {
60298
60406
  if (IGNORE_BASENAMES.has(e.name)) continue;
60299
60407
  const rel = relPrefix ? `${relPrefix}/${e.name}` : e.name;
@@ -60345,7 +60453,7 @@ function computePublishCheck(args) {
60345
60453
  }
60346
60454
 
60347
60455
  // src/extension/install-flow.ts
60348
- var import_promises8 = __toESM(require("fs/promises"), 1);
60456
+ var import_promises9 = __toESM(require("fs/promises"), 1);
60349
60457
  var import_node_path56 = __toESM(require("path"), 1);
60350
60458
  var import_node_os20 = __toESM(require("os"), 1);
60351
60459
  var import_node_crypto15 = __toESM(require("crypto"), 1);
@@ -60426,7 +60534,7 @@ async function installFromChannel(args, deps) {
60426
60534
  const destDir = import_node_path56.default.join(deps.extensionsRoot, localExtId);
60427
60535
  let destExists = false;
60428
60536
  try {
60429
- await import_promises8.default.access(destDir);
60537
+ await import_promises9.default.access(destDir);
60430
60538
  destExists = true;
60431
60539
  } catch {
60432
60540
  }
@@ -60436,28 +60544,28 @@ async function installFromChannel(args, deps) {
60436
60544
  `extension ${localExtId} already installed locally (from owner ${channelRef.ownerPrincipalId})`
60437
60545
  );
60438
60546
  }
60439
- const stage = await import_promises8.default.mkdtemp(
60547
+ const stage = await import_promises9.default.mkdtemp(
60440
60548
  import_node_path56.default.join(import_node_os20.default.tmpdir(), `clawd-ext-install-${localExtId}-`)
60441
60549
  );
60442
60550
  try {
60443
60551
  for (const [name, entry] of Object.entries(zip.files)) {
60444
60552
  const dest = import_node_path56.default.join(stage, name);
60445
60553
  if (entry.dir) {
60446
- await import_promises8.default.mkdir(dest, { recursive: true });
60554
+ await import_promises9.default.mkdir(dest, { recursive: true });
60447
60555
  continue;
60448
60556
  }
60449
- 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 });
60450
60558
  if (name === "manifest.json") {
60451
60559
  const rewritten = { ...parsed.data, id: localExtId };
60452
- await import_promises8.default.writeFile(dest, JSON.stringify(rewritten, null, 2));
60560
+ await import_promises9.default.writeFile(dest, JSON.stringify(rewritten, null, 2));
60453
60561
  } else {
60454
- await import_promises8.default.writeFile(dest, await entry.async("nodebuffer"));
60562
+ await import_promises9.default.writeFile(dest, await entry.async("nodebuffer"));
60455
60563
  }
60456
60564
  }
60457
- await import_promises8.default.mkdir(deps.extensionsRoot, { recursive: true });
60458
- 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);
60459
60567
  } catch (e) {
60460
- await import_promises8.default.rm(stage, { recursive: true, force: true }).catch(() => {
60568
+ await import_promises9.default.rm(stage, { recursive: true, force: true }).catch(() => {
60461
60569
  });
60462
60570
  throw e;
60463
60571
  }
@@ -60466,7 +60574,7 @@ async function installFromChannel(args, deps) {
60466
60574
  }
60467
60575
 
60468
60576
  // src/extension/update-flow.ts
60469
- var import_promises9 = __toESM(require("fs/promises"), 1);
60577
+ var import_promises10 = __toESM(require("fs/promises"), 1);
60470
60578
  var import_node_path57 = __toESM(require("path"), 1);
60471
60579
  var import_node_os21 = __toESM(require("os"), 1);
60472
60580
  var import_node_crypto16 = __toESM(require("crypto"), 1);
@@ -60488,7 +60596,7 @@ async function updateFromChannel(args, deps) {
60488
60596
  const prevDir = `${liveDir}.prev`;
60489
60597
  let existingVersion;
60490
60598
  try {
60491
- 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");
60492
60600
  const parsed2 = ExtensionManifestSchema.safeParse(JSON.parse(raw));
60493
60601
  if (!parsed2.success) {
60494
60602
  throw new UpdateError(
@@ -60553,31 +60661,31 @@ async function updateFromChannel(args, deps) {
60553
60661
  );
60554
60662
  }
60555
60663
  await deps.runtime.close(localExtId);
60556
- await import_promises9.default.rm(prevDir, { recursive: true, force: true });
60557
- await import_promises9.default.rename(liveDir, prevDir);
60558
- 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(
60559
60667
  import_node_path57.default.join(import_node_os21.default.tmpdir(), `clawd-ext-update-${localExtId}-`)
60560
60668
  );
60561
60669
  try {
60562
60670
  for (const [name, entry] of Object.entries(zip.files)) {
60563
60671
  const dest = import_node_path57.default.join(stage, name);
60564
60672
  if (entry.dir) {
60565
- await import_promises9.default.mkdir(dest, { recursive: true });
60673
+ await import_promises10.default.mkdir(dest, { recursive: true });
60566
60674
  continue;
60567
60675
  }
60568
- 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 });
60569
60677
  if (name === "manifest.json") {
60570
60678
  const rewritten = { ...parsed.data, id: localExtId };
60571
- await import_promises9.default.writeFile(dest, JSON.stringify(rewritten, null, 2));
60679
+ await import_promises10.default.writeFile(dest, JSON.stringify(rewritten, null, 2));
60572
60680
  } else {
60573
- await import_promises9.default.writeFile(dest, await entry.async("nodebuffer"));
60681
+ await import_promises10.default.writeFile(dest, await entry.async("nodebuffer"));
60574
60682
  }
60575
60683
  }
60576
- await import_promises9.default.rename(stage, liveDir);
60684
+ await import_promises10.default.rename(stage, liveDir);
60577
60685
  } catch (e) {
60578
- await import_promises9.default.rm(stage, { recursive: true, force: true }).catch(() => {
60686
+ await import_promises10.default.rm(stage, { recursive: true, force: true }).catch(() => {
60579
60687
  });
60580
- await import_promises9.default.rename(prevDir, liveDir).catch(() => {
60688
+ await import_promises10.default.rename(prevDir, liveDir).catch(() => {
60581
60689
  });
60582
60690
  await deps.runtime.open(localExtId).catch(() => {
60583
60691
  });
@@ -60599,7 +60707,7 @@ async function updateFromChannel(args, deps) {
60599
60707
  reason: e.message
60600
60708
  };
60601
60709
  }
60602
- await import_promises9.default.rm(prevDir, { recursive: true, force: true });
60710
+ await import_promises10.default.rm(prevDir, { recursive: true, force: true });
60603
60711
  return {
60604
60712
  kind: "updated",
60605
60713
  extId: localExtId,
@@ -60607,9 +60715,9 @@ async function updateFromChannel(args, deps) {
60607
60715
  };
60608
60716
  }
60609
60717
  async function rollback(deps, localExtId, liveDir, prevDir) {
60610
- await import_promises9.default.rm(liveDir, { recursive: true, force: true }).catch(() => {
60718
+ await import_promises10.default.rm(liveDir, { recursive: true, force: true }).catch(() => {
60611
60719
  });
60612
- await import_promises9.default.rename(prevDir, liveDir).catch(() => {
60720
+ await import_promises10.default.rename(prevDir, liveDir).catch(() => {
60613
60721
  });
60614
60722
  await deps.runtime.open(localExtId).catch(() => {
60615
60723
  });
@@ -60636,14 +60744,14 @@ async function rewriteManifestVersion(root, extId, newVersion, previousPublished
60636
60744
  const manifest = await readManifest(root, extId);
60637
60745
  const next = { ...manifest, version: newVersion };
60638
60746
  const tmp = `${manifestPath}.tmp`;
60639
- await import_promises10.default.writeFile(tmp, JSON.stringify(next, null, 2));
60640
- 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);
60641
60749
  }
60642
60750
  async function readManifest(root, extId) {
60643
60751
  const file = import_node_path58.default.join(root, extId, "manifest.json");
60644
60752
  let raw;
60645
60753
  try {
60646
- raw = await import_promises10.default.readFile(file, "utf8");
60754
+ raw = await import_promises11.default.readFile(file, "utf8");
60647
60755
  } catch (e) {
60648
60756
  if (e.code === "ENOENT") {
60649
60757
  throw new ClawdError(ERROR_CODES.INVALID_PARAM, `extension ${extId} not installed`);
@@ -60673,22 +60781,22 @@ function assertOwner(ctx) {
60673
60781
  throw new ClawdError(ERROR_CODES.FORBIDDEN, "owner only");
60674
60782
  }
60675
60783
  }
60676
- function composeState(rec3, running, crashed, getPort) {
60677
- if (rec3.state === "invalid") return rec3;
60678
- 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") {
60679
60787
  return {
60680
- ...rec3,
60788
+ ...rec4,
60681
60789
  state: "running",
60682
- target: { kind: "hosted", url: rec3.manifest.entry.url }
60790
+ target: { kind: "hosted", url: rec4.manifest.entry.url }
60683
60791
  };
60684
60792
  }
60685
- if (running.has(rec3.extId)) {
60686
- const port = getPort(rec3.extId);
60687
- if (port == null) return rec3;
60688
- 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 } };
60689
60797
  }
60690
- if (crashed.has(rec3.extId)) return { ...rec3, state: "crashed" };
60691
- return rec3;
60798
+ if (crashed.has(rec4.extId)) return { ...rec4, state: "crashed" };
60799
+ return rec4;
60692
60800
  }
60693
60801
  function buildExtensionHandlers(deps) {
60694
60802
  const list = async (_frame, _client, ctx) => {
@@ -62292,12 +62400,12 @@ function buildVisitorHandlers(deps) {
62292
62400
  }
62293
62401
 
62294
62402
  // src/extension/registry.ts
62295
- var import_promises11 = __toESM(require("fs/promises"), 1);
62403
+ var import_promises12 = __toESM(require("fs/promises"), 1);
62296
62404
  var import_node_path62 = __toESM(require("path"), 1);
62297
62405
  async function loadAll(root) {
62298
62406
  let entries;
62299
62407
  try {
62300
- entries = await import_promises11.default.readdir(root, { withFileTypes: true });
62408
+ entries = await import_promises12.default.readdir(root, { withFileTypes: true });
62301
62409
  } catch (e) {
62302
62410
  if (e.code === "ENOENT") return [];
62303
62411
  throw e;
@@ -62315,7 +62423,7 @@ async function loadOne(dir, dirName) {
62315
62423
  const manifestPath = import_node_path62.default.join(dir, "manifest.json");
62316
62424
  let raw;
62317
62425
  try {
62318
- raw = await import_promises11.default.readFile(manifestPath, "utf8");
62426
+ raw = await import_promises12.default.readFile(manifestPath, "utf8");
62319
62427
  } catch {
62320
62428
  return {
62321
62429
  extId: dirName,
@@ -62356,7 +62464,7 @@ async function loadOne(dir, dirName) {
62356
62464
  }
62357
62465
 
62358
62466
  // src/extension/uninstall.ts
62359
- var import_promises12 = __toESM(require("fs/promises"), 1);
62467
+ var import_promises13 = __toESM(require("fs/promises"), 1);
62360
62468
  var import_node_path63 = __toESM(require("path"), 1);
62361
62469
  var UninstallError = class extends Error {
62362
62470
  constructor(code, message) {
@@ -62368,12 +62476,12 @@ var UninstallError = class extends Error {
62368
62476
  async function uninstall(deps) {
62369
62477
  const dir = import_node_path63.default.join(deps.root, deps.extId);
62370
62478
  try {
62371
- await import_promises12.default.access(dir);
62479
+ await import_promises13.default.access(dir);
62372
62480
  } catch {
62373
62481
  throw new UninstallError("NOT_FOUND", `extension ${deps.extId} not installed`);
62374
62482
  }
62375
62483
  await deps.runtime.close(deps.extId);
62376
- await import_promises12.default.rm(dir, { recursive: true, force: true });
62484
+ await import_promises13.default.rm(dir, { recursive: true, force: true });
62377
62485
  }
62378
62486
 
62379
62487
  // src/handlers/index.ts
@@ -63019,7 +63127,7 @@ async function dispatchRpc(method, frame, client, ctx, deps) {
63019
63127
  // src/extension/runtime.ts
63020
63128
  var import_node_child_process19 = require("child_process");
63021
63129
  var import_node_path64 = __toESM(require("path"), 1);
63022
- var import_promises13 = require("timers/promises");
63130
+ var import_promises14 = require("timers/promises");
63023
63131
 
63024
63132
  // src/extension/port-allocator.ts
63025
63133
  var import_node_net2 = __toESM(require("net"), 1);
@@ -63104,17 +63212,17 @@ var Runtime = class {
63104
63212
  const existing = this.handles.get(extId);
63105
63213
  if (existing) return { kind: "local", port: existing.port };
63106
63214
  const records = await loadAll(this.root);
63107
- const rec3 = records.find((r) => r.extId === extId);
63108
- if (!rec3) throw new RuntimeError("NOT_FOUND", `extension ${extId} not installed`);
63109
- if (rec3.state === "invalid")
63110
- throw new RuntimeError("INVALID_MANIFEST", rec3.invalidReason);
63111
- if (manifestMode(rec3.manifest) === "hosted") {
63112
- 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 };
63113
63221
  }
63114
63222
  const port = await this.allocator.allocate().catch(() => {
63115
63223
  throw new RuntimeError("PORT_EXHAUSTED", "no free port in configured range");
63116
63224
  });
63117
- const startCommand = rec3.manifest.runtime.startCommand;
63225
+ const startCommand = rec4.manifest.runtime.startCommand;
63118
63226
  const cmd = startCommand.replace(
63119
63227
  /\$CLAWOS_EXT_PORT/g,
63120
63228
  String(port)
@@ -63195,7 +63303,7 @@ ${handle.stderrTail}`
63195
63303
  if (res.ok) return;
63196
63304
  } catch {
63197
63305
  }
63198
- await (0, import_promises13.setTimeout)(this.healthzIntervalMs);
63306
+ await (0, import_promises14.setTimeout)(this.healthzIntervalMs);
63199
63307
  }
63200
63308
  throw new RuntimeError(
63201
63309
  "HEALTHZ_FAILED",
@@ -63220,7 +63328,7 @@ ${handle.stderrTail}`
63220
63328
  };
63221
63329
  killGroup("SIGTERM");
63222
63330
  const exited = new Promise((resolve6) => child.once("exit", () => resolve6()));
63223
- const timed = (0, import_promises13.setTimeout)(5e3).then(() => "timeout");
63331
+ const timed = (0, import_promises14.setTimeout)(5e3).then(() => "timeout");
63224
63332
  const winner = await Promise.race([exited.then(() => "exited"), timed]);
63225
63333
  if (winner === "timeout" && child.exitCode === null) {
63226
63334
  killGroup("SIGKILL");
@@ -63230,7 +63338,7 @@ ${handle.stderrTail}`
63230
63338
  };
63231
63339
 
63232
63340
  // src/extension/published-channels.ts
63233
- var import_promises14 = __toESM(require("fs/promises"), 1);
63341
+ var import_promises15 = __toESM(require("fs/promises"), 1);
63234
63342
  var import_node_path65 = __toESM(require("path"), 1);
63235
63343
  init_zod();
63236
63344
  var PublishedChannelsError = class extends Error {
@@ -63261,7 +63369,7 @@ var PublishedChannelStore = class {
63261
63369
  this.channels.clear();
63262
63370
  let raw;
63263
63371
  try {
63264
- raw = await import_promises14.default.readFile(this.filePath, "utf8");
63372
+ raw = await import_promises15.default.readFile(this.filePath, "utf8");
63265
63373
  } catch (e) {
63266
63374
  if (e.code === "ENOENT") {
63267
63375
  this.loaded = true;
@@ -63330,14 +63438,14 @@ var PublishedChannelStore = class {
63330
63438
  )
63331
63439
  };
63332
63440
  const tmp = `${this.filePath}.tmp`;
63333
- await import_promises14.default.mkdir(import_node_path65.default.dirname(this.filePath), { recursive: true });
63334
- await import_promises14.default.writeFile(tmp, JSON.stringify(data, null, 2), { mode: 384 });
63335
- 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);
63336
63444
  }
63337
63445
  };
63338
63446
 
63339
63447
  // src/extension/bundle-cache.ts
63340
- var import_promises15 = __toESM(require("fs/promises"), 1);
63448
+ var import_promises16 = __toESM(require("fs/promises"), 1);
63341
63449
  var import_node_path66 = __toESM(require("path"), 1);
63342
63450
  var BundleCache = class {
63343
63451
  constructor(rootDir) {
@@ -63346,17 +63454,17 @@ var BundleCache = class {
63346
63454
  rootDir;
63347
63455
  /** Atomic write: stage tmp → rename. Caller passes the hex sha256. */
63348
63456
  async write(snapshotHash, buffer) {
63349
- await import_promises15.default.mkdir(this.rootDir, { recursive: true });
63457
+ await import_promises16.default.mkdir(this.rootDir, { recursive: true });
63350
63458
  const file = import_node_path66.default.join(this.rootDir, `${snapshotHash}.zip`);
63351
63459
  const tmp = `${file}.tmp`;
63352
- await import_promises15.default.writeFile(tmp, buffer, { mode: 384 });
63353
- 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);
63354
63462
  }
63355
63463
  /** Returns the bundle bytes, or null when the file doesn't exist. */
63356
63464
  async read(snapshotHash) {
63357
63465
  const file = import_node_path66.default.join(this.rootDir, `${snapshotHash}.zip`);
63358
63466
  try {
63359
- return await import_promises15.default.readFile(file);
63467
+ return await import_promises16.default.readFile(file);
63360
63468
  } catch (e) {
63361
63469
  if (e.code === "ENOENT") return null;
63362
63470
  throw e;
@@ -63365,7 +63473,7 @@ var BundleCache = class {
63365
63473
  /** Idempotent — missing file is not an error. */
63366
63474
  async delete(snapshotHash) {
63367
63475
  const file = import_node_path66.default.join(this.rootDir, `${snapshotHash}.zip`);
63368
- await import_promises15.default.rm(file, { force: true });
63476
+ await import_promises16.default.rm(file, { force: true });
63369
63477
  }
63370
63478
  };
63371
63479
 
@@ -63973,6 +64081,12 @@ async function startDaemon(config) {
63973
64081
  provider: ownerProvider,
63974
64082
  feishuUnionId: ownerFeishuUnionId
63975
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
+ });
63976
64090
  const handlers = {
63977
64091
  ...buildMethodHandlers({
63978
64092
  // meta:methods 自省:飞书 gate getter + 最终 handler 表(下面还会 spread 进
@@ -63990,6 +64104,7 @@ async function startDaemon(config) {
63990
64104
  history,
63991
64105
  // history:read 按 session.tool 路由:codex → adapter.historyReader(CodexHistoryReader);缺省 claude。
63992
64106
  getHistoryReader: (tool) => getAdapter(tool).historyReader ?? history,
64107
+ hydrateCodexResolvedMeta,
63993
64108
  observer,
63994
64109
  getAdapter,
63995
64110
  store,
@@ -64307,11 +64422,11 @@ async function startDaemon(config) {
64307
64422
  dataDir: config.dataDir,
64308
64423
  // 现读(登录/登出热切换);unionId 缺失时回落 ownerId(老登录记录无 unionId)
64309
64424
  getOwnerIdentity: () => {
64310
- const rec3 = ownerIdentityStore.read();
64311
- if (!rec3) return null;
64425
+ const rec4 = ownerIdentityStore.read();
64426
+ if (!rec4) return null;
64312
64427
  return {
64313
- unionId: rec3.identity.unionId ?? rec3.identity.ownerId,
64314
- displayName: rec3.identity.displayName
64428
+ unionId: rec4.identity.unionId ?? rec4.identity.ownerId,
64429
+ displayName: rec4.identity.displayName
64315
64430
  };
64316
64431
  },
64317
64432
  apiUrl: config.clawosApi ?? DEFAULT_CLAWOS_API,