@clawos-dev/clawd 0.2.372 → 0.2.374

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
@@ -450,8 +450,8 @@ var init_parseUtil = __esm({
450
450
  init_errors();
451
451
  init_en();
452
452
  makeIssue = (params) => {
453
- const { data, path: path85, errorMaps, issueData } = params;
454
- const fullPath = [...path85, ...issueData.path || []];
453
+ const { data, path: path86, errorMaps, issueData } = params;
454
+ const fullPath = [...path86, ...issueData.path || []];
455
455
  const fullIssue = {
456
456
  ...issueData,
457
457
  path: fullPath
@@ -762,11 +762,11 @@ var init_types = __esm({
762
762
  init_parseUtil();
763
763
  init_util();
764
764
  ParseInputLazyPath = class {
765
- constructor(parent, value, path85, key) {
765
+ constructor(parent, value, path86, key) {
766
766
  this._cachedPath = [];
767
767
  this.parent = parent;
768
768
  this.data = value;
769
- this._path = path85;
769
+ this._path = path86;
770
770
  this._key = key;
771
771
  }
772
772
  get path() {
@@ -9003,8 +9003,8 @@ var require_req = __commonJS({
9003
9003
  if (req.originalUrl) {
9004
9004
  _req.url = req.originalUrl;
9005
9005
  } else {
9006
- const path85 = req.path;
9007
- _req.url = typeof path85 === "string" ? path85 : req.url ? req.url.path || req.url : void 0;
9006
+ const path86 = req.path;
9007
+ _req.url = typeof path86 === "string" ? path86 : req.url ? req.url.path || req.url : void 0;
9008
9008
  }
9009
9009
  if (req.query) {
9010
9010
  _req.query = req.query;
@@ -9169,14 +9169,14 @@ var require_redact = __commonJS({
9169
9169
  }
9170
9170
  return obj;
9171
9171
  }
9172
- function parsePath(path85) {
9172
+ function parsePath(path86) {
9173
9173
  const parts = [];
9174
9174
  let current = "";
9175
9175
  let inBrackets = false;
9176
9176
  let inQuotes = false;
9177
9177
  let quoteChar = "";
9178
- for (let i = 0; i < path85.length; i++) {
9179
- const char = path85[i];
9178
+ for (let i = 0; i < path86.length; i++) {
9179
+ const char = path86[i];
9180
9180
  if (!inBrackets && char === ".") {
9181
9181
  if (current) {
9182
9182
  parts.push(current);
@@ -9307,10 +9307,10 @@ var require_redact = __commonJS({
9307
9307
  return current;
9308
9308
  }
9309
9309
  function redactPaths(obj, paths, censor, remove = false) {
9310
- for (const path85 of paths) {
9311
- const parts = parsePath(path85);
9310
+ for (const path86 of paths) {
9311
+ const parts = parsePath(path86);
9312
9312
  if (parts.includes("*")) {
9313
- redactWildcardPath(obj, parts, censor, path85, remove);
9313
+ redactWildcardPath(obj, parts, censor, path86, remove);
9314
9314
  } else {
9315
9315
  if (remove) {
9316
9316
  removeKey(obj, parts);
@@ -9395,8 +9395,8 @@ var require_redact = __commonJS({
9395
9395
  }
9396
9396
  } else {
9397
9397
  if (afterWildcard.includes("*")) {
9398
- const wrappedCensor = typeof censor === "function" ? (value, path85) => {
9399
- const fullPath = [...pathArray.slice(0, pathLength), ...path85];
9398
+ const wrappedCensor = typeof censor === "function" ? (value, path86) => {
9399
+ const fullPath = [...pathArray.slice(0, pathLength), ...path86];
9400
9400
  return censor(value, fullPath);
9401
9401
  } : censor;
9402
9402
  redactWildcardPath(current, afterWildcard, wrappedCensor, originalPath, remove);
@@ -9431,8 +9431,8 @@ var require_redact = __commonJS({
9431
9431
  return null;
9432
9432
  }
9433
9433
  const pathStructure = /* @__PURE__ */ new Map();
9434
- for (const path85 of pathsToClone) {
9435
- const parts = parsePath(path85);
9434
+ for (const path86 of pathsToClone) {
9435
+ const parts = parsePath(path86);
9436
9436
  let current = pathStructure;
9437
9437
  for (let i = 0; i < parts.length; i++) {
9438
9438
  const part = parts[i];
@@ -9484,24 +9484,24 @@ var require_redact = __commonJS({
9484
9484
  }
9485
9485
  return cloneSelectively(obj, pathStructure);
9486
9486
  }
9487
- function validatePath(path85) {
9488
- if (typeof path85 !== "string") {
9487
+ function validatePath(path86) {
9488
+ if (typeof path86 !== "string") {
9489
9489
  throw new Error("Paths must be (non-empty) strings");
9490
9490
  }
9491
- if (path85 === "") {
9491
+ if (path86 === "") {
9492
9492
  throw new Error("Invalid redaction path ()");
9493
9493
  }
9494
- if (path85.includes("..")) {
9495
- throw new Error(`Invalid redaction path (${path85})`);
9494
+ if (path86.includes("..")) {
9495
+ throw new Error(`Invalid redaction path (${path86})`);
9496
9496
  }
9497
- if (path85.includes(",")) {
9498
- throw new Error(`Invalid redaction path (${path85})`);
9497
+ if (path86.includes(",")) {
9498
+ throw new Error(`Invalid redaction path (${path86})`);
9499
9499
  }
9500
9500
  let bracketCount = 0;
9501
9501
  let inQuotes = false;
9502
9502
  let quoteChar = "";
9503
- for (let i = 0; i < path85.length; i++) {
9504
- const char = path85[i];
9503
+ for (let i = 0; i < path86.length; i++) {
9504
+ const char = path86[i];
9505
9505
  if ((char === '"' || char === "'") && bracketCount > 0) {
9506
9506
  if (!inQuotes) {
9507
9507
  inQuotes = true;
@@ -9515,20 +9515,20 @@ var require_redact = __commonJS({
9515
9515
  } else if (char === "]" && !inQuotes) {
9516
9516
  bracketCount--;
9517
9517
  if (bracketCount < 0) {
9518
- throw new Error(`Invalid redaction path (${path85})`);
9518
+ throw new Error(`Invalid redaction path (${path86})`);
9519
9519
  }
9520
9520
  }
9521
9521
  }
9522
9522
  if (bracketCount !== 0) {
9523
- throw new Error(`Invalid redaction path (${path85})`);
9523
+ throw new Error(`Invalid redaction path (${path86})`);
9524
9524
  }
9525
9525
  }
9526
9526
  function validatePaths(paths) {
9527
9527
  if (!Array.isArray(paths)) {
9528
9528
  throw new TypeError("paths must be an array");
9529
9529
  }
9530
- for (const path85 of paths) {
9531
- validatePath(path85);
9530
+ for (const path86 of paths) {
9531
+ validatePath(path86);
9532
9532
  }
9533
9533
  }
9534
9534
  function slowRedact(options = {}) {
@@ -9696,8 +9696,8 @@ var require_redaction = __commonJS({
9696
9696
  if (shape[k2] === null) {
9697
9697
  o[k2] = (value) => topCensor(value, [k2]);
9698
9698
  } else {
9699
- const wrappedCensor = typeof censor === "function" ? (value, path85) => {
9700
- return censor(value, [k2, ...path85]);
9699
+ const wrappedCensor = typeof censor === "function" ? (value, path86) => {
9700
+ return censor(value, [k2, ...path86]);
9701
9701
  } : censor;
9702
9702
  o[k2] = Redact({
9703
9703
  paths: shape[k2],
@@ -9915,10 +9915,10 @@ var require_atomic_sleep = __commonJS({
9915
9915
  var require_sonic_boom = __commonJS({
9916
9916
  "../node_modules/.pnpm/sonic-boom@4.2.1/node_modules/sonic-boom/index.js"(exports2, module2) {
9917
9917
  "use strict";
9918
- var fs76 = require("fs");
9918
+ var fs77 = require("fs");
9919
9919
  var EventEmitter3 = require("events");
9920
9920
  var inherits = require("util").inherits;
9921
- var path85 = require("path");
9921
+ var path86 = require("path");
9922
9922
  var sleep2 = require_atomic_sleep();
9923
9923
  var assert = require("assert");
9924
9924
  var BUSY_WRITE_TIMEOUT = 100;
@@ -9972,20 +9972,20 @@ var require_sonic_boom = __commonJS({
9972
9972
  const mode = sonic.mode;
9973
9973
  if (sonic.sync) {
9974
9974
  try {
9975
- if (sonic.mkdir) fs76.mkdirSync(path85.dirname(file), { recursive: true });
9976
- const fd = fs76.openSync(file, flags, mode);
9975
+ if (sonic.mkdir) fs77.mkdirSync(path86.dirname(file), { recursive: true });
9976
+ const fd = fs77.openSync(file, flags, mode);
9977
9977
  fileOpened(null, fd);
9978
9978
  } catch (err) {
9979
9979
  fileOpened(err);
9980
9980
  throw err;
9981
9981
  }
9982
9982
  } else if (sonic.mkdir) {
9983
- fs76.mkdir(path85.dirname(file), { recursive: true }, (err) => {
9983
+ fs77.mkdir(path86.dirname(file), { recursive: true }, (err) => {
9984
9984
  if (err) return fileOpened(err);
9985
- fs76.open(file, flags, mode, fileOpened);
9985
+ fs77.open(file, flags, mode, fileOpened);
9986
9986
  });
9987
9987
  } else {
9988
- fs76.open(file, flags, mode, fileOpened);
9988
+ fs77.open(file, flags, mode, fileOpened);
9989
9989
  }
9990
9990
  }
9991
9991
  function SonicBoom(opts) {
@@ -10026,8 +10026,8 @@ var require_sonic_boom = __commonJS({
10026
10026
  this.flush = flushBuffer;
10027
10027
  this.flushSync = flushBufferSync;
10028
10028
  this._actualWrite = actualWriteBuffer;
10029
- fsWriteSync = () => fs76.writeSync(this.fd, this._writingBuf);
10030
- fsWrite = () => fs76.write(this.fd, this._writingBuf, this.release);
10029
+ fsWriteSync = () => fs77.writeSync(this.fd, this._writingBuf);
10030
+ fsWrite = () => fs77.write(this.fd, this._writingBuf, this.release);
10031
10031
  } else if (contentMode === void 0 || contentMode === kContentModeUtf8) {
10032
10032
  this._writingBuf = "";
10033
10033
  this.write = write;
@@ -10036,15 +10036,15 @@ var require_sonic_boom = __commonJS({
10036
10036
  this._actualWrite = actualWrite;
10037
10037
  fsWriteSync = () => {
10038
10038
  if (Buffer.isBuffer(this._writingBuf)) {
10039
- return fs76.writeSync(this.fd, this._writingBuf);
10039
+ return fs77.writeSync(this.fd, this._writingBuf);
10040
10040
  }
10041
- return fs76.writeSync(this.fd, this._writingBuf, "utf8");
10041
+ return fs77.writeSync(this.fd, this._writingBuf, "utf8");
10042
10042
  };
10043
10043
  fsWrite = () => {
10044
10044
  if (Buffer.isBuffer(this._writingBuf)) {
10045
- return fs76.write(this.fd, this._writingBuf, this.release);
10045
+ return fs77.write(this.fd, this._writingBuf, this.release);
10046
10046
  }
10047
- return fs76.write(this.fd, this._writingBuf, "utf8", this.release);
10047
+ return fs77.write(this.fd, this._writingBuf, "utf8", this.release);
10048
10048
  };
10049
10049
  } else {
10050
10050
  throw new Error(`SonicBoom supports "${kContentModeUtf8}" and "${kContentModeBuffer}", but passed ${contentMode}`);
@@ -10101,7 +10101,7 @@ var require_sonic_boom = __commonJS({
10101
10101
  }
10102
10102
  }
10103
10103
  if (this._fsync) {
10104
- fs76.fsyncSync(this.fd);
10104
+ fs77.fsyncSync(this.fd);
10105
10105
  }
10106
10106
  const len = this._len;
10107
10107
  if (this._reopening) {
@@ -10215,7 +10215,7 @@ var require_sonic_boom = __commonJS({
10215
10215
  const onDrain = () => {
10216
10216
  if (!this._fsync) {
10217
10217
  try {
10218
- fs76.fsync(this.fd, (err) => {
10218
+ fs77.fsync(this.fd, (err) => {
10219
10219
  this._flushPending = false;
10220
10220
  cb(err);
10221
10221
  });
@@ -10317,7 +10317,7 @@ var require_sonic_boom = __commonJS({
10317
10317
  const fd = this.fd;
10318
10318
  this.once("ready", () => {
10319
10319
  if (fd !== this.fd) {
10320
- fs76.close(fd, (err) => {
10320
+ fs77.close(fd, (err) => {
10321
10321
  if (err) {
10322
10322
  return this.emit("error", err);
10323
10323
  }
@@ -10366,7 +10366,7 @@ var require_sonic_boom = __commonJS({
10366
10366
  buf = this._bufs[0];
10367
10367
  }
10368
10368
  try {
10369
- const n = Buffer.isBuffer(buf) ? fs76.writeSync(this.fd, buf) : fs76.writeSync(this.fd, buf, "utf8");
10369
+ const n = Buffer.isBuffer(buf) ? fs77.writeSync(this.fd, buf) : fs77.writeSync(this.fd, buf, "utf8");
10370
10370
  const releasedBufObj = releaseWritingBuf(buf, this._len, n);
10371
10371
  buf = releasedBufObj.writingBuf;
10372
10372
  this._len = releasedBufObj.len;
@@ -10382,7 +10382,7 @@ var require_sonic_boom = __commonJS({
10382
10382
  }
10383
10383
  }
10384
10384
  try {
10385
- fs76.fsyncSync(this.fd);
10385
+ fs77.fsyncSync(this.fd);
10386
10386
  } catch {
10387
10387
  }
10388
10388
  }
@@ -10403,7 +10403,7 @@ var require_sonic_boom = __commonJS({
10403
10403
  buf = mergeBuf(this._bufs[0], this._lens[0]);
10404
10404
  }
10405
10405
  try {
10406
- const n = fs76.writeSync(this.fd, buf);
10406
+ const n = fs77.writeSync(this.fd, buf);
10407
10407
  buf = buf.subarray(n);
10408
10408
  this._len = Math.max(this._len - n, 0);
10409
10409
  if (buf.length <= 0) {
@@ -10431,13 +10431,13 @@ var require_sonic_boom = __commonJS({
10431
10431
  this._writingBuf = this._writingBuf.length ? this._writingBuf : this._bufs.shift() || "";
10432
10432
  if (this.sync) {
10433
10433
  try {
10434
- const written = Buffer.isBuffer(this._writingBuf) ? fs76.writeSync(this.fd, this._writingBuf) : fs76.writeSync(this.fd, this._writingBuf, "utf8");
10434
+ const written = Buffer.isBuffer(this._writingBuf) ? fs77.writeSync(this.fd, this._writingBuf) : fs77.writeSync(this.fd, this._writingBuf, "utf8");
10435
10435
  release(null, written);
10436
10436
  } catch (err) {
10437
10437
  release(err);
10438
10438
  }
10439
10439
  } else {
10440
- fs76.write(this.fd, this._writingBuf, release);
10440
+ fs77.write(this.fd, this._writingBuf, release);
10441
10441
  }
10442
10442
  }
10443
10443
  function actualWriteBuffer() {
@@ -10446,7 +10446,7 @@ var require_sonic_boom = __commonJS({
10446
10446
  this._writingBuf = this._writingBuf.length ? this._writingBuf : mergeBuf(this._bufs.shift(), this._lens.shift());
10447
10447
  if (this.sync) {
10448
10448
  try {
10449
- const written = fs76.writeSync(this.fd, this._writingBuf);
10449
+ const written = fs77.writeSync(this.fd, this._writingBuf);
10450
10450
  release(null, written);
10451
10451
  } catch (err) {
10452
10452
  release(err);
@@ -10455,7 +10455,7 @@ var require_sonic_boom = __commonJS({
10455
10455
  if (kCopyBuffer) {
10456
10456
  this._writingBuf = Buffer.from(this._writingBuf);
10457
10457
  }
10458
- fs76.write(this.fd, this._writingBuf, release);
10458
+ fs77.write(this.fd, this._writingBuf, release);
10459
10459
  }
10460
10460
  }
10461
10461
  function actualClose(sonic) {
@@ -10471,12 +10471,12 @@ var require_sonic_boom = __commonJS({
10471
10471
  sonic._lens = [];
10472
10472
  assert(typeof sonic.fd === "number", `sonic.fd must be a number, got ${typeof sonic.fd}`);
10473
10473
  try {
10474
- fs76.fsync(sonic.fd, closeWrapped);
10474
+ fs77.fsync(sonic.fd, closeWrapped);
10475
10475
  } catch {
10476
10476
  }
10477
10477
  function closeWrapped() {
10478
10478
  if (sonic.fd !== 1 && sonic.fd !== 2) {
10479
- fs76.close(sonic.fd, done);
10479
+ fs77.close(sonic.fd, done);
10480
10480
  } else {
10481
10481
  done();
10482
10482
  }
@@ -10733,7 +10733,7 @@ var require_thread_stream = __commonJS({
10733
10733
  var { version: version2 } = require_package();
10734
10734
  var { EventEmitter: EventEmitter3 } = require("events");
10735
10735
  var { Worker } = require("worker_threads");
10736
- var { join: join18 } = require("path");
10736
+ var { join: join19 } = require("path");
10737
10737
  var { pathToFileURL } = require("url");
10738
10738
  var { wait } = require_wait();
10739
10739
  var {
@@ -10769,7 +10769,7 @@ var require_thread_stream = __commonJS({
10769
10769
  function createWorker(stream, opts) {
10770
10770
  const { filename, workerData } = opts;
10771
10771
  const bundlerOverrides = "__bundlerPathsOverrides" in globalThis ? globalThis.__bundlerPathsOverrides : {};
10772
- const toExecute = bundlerOverrides["thread-stream-worker"] || join18(__dirname, "lib", "worker.js");
10772
+ const toExecute = bundlerOverrides["thread-stream-worker"] || join19(__dirname, "lib", "worker.js");
10773
10773
  const worker = new Worker(toExecute, {
10774
10774
  ...opts.workerOpts,
10775
10775
  trackUnmanagedFds: false,
@@ -11155,7 +11155,7 @@ var require_transport = __commonJS({
11155
11155
  "use strict";
11156
11156
  var { createRequire: createRequire2 } = require("module");
11157
11157
  var getCallers = require_caller();
11158
- var { join: join18, isAbsolute: isAbsolute4, sep: sep5 } = require("path");
11158
+ var { join: join19, isAbsolute: isAbsolute4, sep: sep4 } = require("path");
11159
11159
  var sleep2 = require_atomic_sleep();
11160
11160
  var onExit = require_on_exit_leak_free();
11161
11161
  var ThreadStream = require_thread_stream();
@@ -11218,7 +11218,7 @@ var require_transport = __commonJS({
11218
11218
  throw new Error("only one of target or targets can be specified");
11219
11219
  }
11220
11220
  if (targets) {
11221
- target = bundlerOverrides["pino-worker"] || join18(__dirname, "worker.js");
11221
+ target = bundlerOverrides["pino-worker"] || join19(__dirname, "worker.js");
11222
11222
  options.targets = targets.filter((dest) => dest.target).map((dest) => {
11223
11223
  return {
11224
11224
  ...dest,
@@ -11236,7 +11236,7 @@ var require_transport = __commonJS({
11236
11236
  });
11237
11237
  });
11238
11238
  } else if (pipeline3) {
11239
- target = bundlerOverrides["pino-worker"] || join18(__dirname, "worker.js");
11239
+ target = bundlerOverrides["pino-worker"] || join19(__dirname, "worker.js");
11240
11240
  options.pipelines = [pipeline3.map((dest) => {
11241
11241
  return {
11242
11242
  ...dest,
@@ -11258,12 +11258,12 @@ var require_transport = __commonJS({
11258
11258
  return origin;
11259
11259
  }
11260
11260
  if (origin === "pino/file") {
11261
- return join18(__dirname, "..", "file.js");
11261
+ return join19(__dirname, "..", "file.js");
11262
11262
  }
11263
11263
  let fixTarget2;
11264
11264
  for (const filePath of callers) {
11265
11265
  try {
11266
- const context = filePath === "node:repl" ? process.cwd() + sep5 : filePath;
11266
+ const context = filePath === "node:repl" ? process.cwd() + sep4 : filePath;
11267
11267
  fixTarget2 = createRequire2(context).resolve(origin);
11268
11268
  break;
11269
11269
  } catch (err) {
@@ -12248,7 +12248,7 @@ var require_safe_stable_stringify = __commonJS({
12248
12248
  return circularValue;
12249
12249
  }
12250
12250
  let res = "";
12251
- let join18 = ",";
12251
+ let join19 = ",";
12252
12252
  const originalIndentation = indentation;
12253
12253
  if (Array.isArray(value)) {
12254
12254
  if (value.length === 0) {
@@ -12262,7 +12262,7 @@ var require_safe_stable_stringify = __commonJS({
12262
12262
  indentation += spacer;
12263
12263
  res += `
12264
12264
  ${indentation}`;
12265
- join18 = `,
12265
+ join19 = `,
12266
12266
  ${indentation}`;
12267
12267
  }
12268
12268
  const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
@@ -12270,13 +12270,13 @@ ${indentation}`;
12270
12270
  for (; i < maximumValuesToStringify - 1; i++) {
12271
12271
  const tmp2 = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
12272
12272
  res += tmp2 !== void 0 ? tmp2 : "null";
12273
- res += join18;
12273
+ res += join19;
12274
12274
  }
12275
12275
  const tmp = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
12276
12276
  res += tmp !== void 0 ? tmp : "null";
12277
12277
  if (value.length - 1 > maximumBreadth) {
12278
12278
  const removedKeys = value.length - maximumBreadth - 1;
12279
- res += `${join18}"... ${getItemCount(removedKeys)} not stringified"`;
12279
+ res += `${join19}"... ${getItemCount(removedKeys)} not stringified"`;
12280
12280
  }
12281
12281
  if (spacer !== "") {
12282
12282
  res += `
@@ -12297,7 +12297,7 @@ ${originalIndentation}`;
12297
12297
  let separator = "";
12298
12298
  if (spacer !== "") {
12299
12299
  indentation += spacer;
12300
- join18 = `,
12300
+ join19 = `,
12301
12301
  ${indentation}`;
12302
12302
  whitespace = " ";
12303
12303
  }
@@ -12311,13 +12311,13 @@ ${indentation}`;
12311
12311
  const tmp = stringifyFnReplacer(key2, value, stack, replacer, spacer, indentation);
12312
12312
  if (tmp !== void 0) {
12313
12313
  res += `${separator}${strEscape(key2)}:${whitespace}${tmp}`;
12314
- separator = join18;
12314
+ separator = join19;
12315
12315
  }
12316
12316
  }
12317
12317
  if (keyLength > maximumBreadth) {
12318
12318
  const removedKeys = keyLength - maximumBreadth;
12319
12319
  res += `${separator}"...":${whitespace}"${getItemCount(removedKeys)} not stringified"`;
12320
- separator = join18;
12320
+ separator = join19;
12321
12321
  }
12322
12322
  if (spacer !== "" && separator.length > 1) {
12323
12323
  res = `
@@ -12358,7 +12358,7 @@ ${originalIndentation}`;
12358
12358
  }
12359
12359
  const originalIndentation = indentation;
12360
12360
  let res = "";
12361
- let join18 = ",";
12361
+ let join19 = ",";
12362
12362
  if (Array.isArray(value)) {
12363
12363
  if (value.length === 0) {
12364
12364
  return "[]";
@@ -12371,7 +12371,7 @@ ${originalIndentation}`;
12371
12371
  indentation += spacer;
12372
12372
  res += `
12373
12373
  ${indentation}`;
12374
- join18 = `,
12374
+ join19 = `,
12375
12375
  ${indentation}`;
12376
12376
  }
12377
12377
  const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
@@ -12379,13 +12379,13 @@ ${indentation}`;
12379
12379
  for (; i < maximumValuesToStringify - 1; i++) {
12380
12380
  const tmp2 = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
12381
12381
  res += tmp2 !== void 0 ? tmp2 : "null";
12382
- res += join18;
12382
+ res += join19;
12383
12383
  }
12384
12384
  const tmp = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
12385
12385
  res += tmp !== void 0 ? tmp : "null";
12386
12386
  if (value.length - 1 > maximumBreadth) {
12387
12387
  const removedKeys = value.length - maximumBreadth - 1;
12388
- res += `${join18}"... ${getItemCount(removedKeys)} not stringified"`;
12388
+ res += `${join19}"... ${getItemCount(removedKeys)} not stringified"`;
12389
12389
  }
12390
12390
  if (spacer !== "") {
12391
12391
  res += `
@@ -12398,7 +12398,7 @@ ${originalIndentation}`;
12398
12398
  let whitespace = "";
12399
12399
  if (spacer !== "") {
12400
12400
  indentation += spacer;
12401
- join18 = `,
12401
+ join19 = `,
12402
12402
  ${indentation}`;
12403
12403
  whitespace = " ";
12404
12404
  }
@@ -12407,7 +12407,7 @@ ${indentation}`;
12407
12407
  const tmp = stringifyArrayReplacer(key2, value[key2], stack, replacer, spacer, indentation);
12408
12408
  if (tmp !== void 0) {
12409
12409
  res += `${separator}${strEscape(key2)}:${whitespace}${tmp}`;
12410
- separator = join18;
12410
+ separator = join19;
12411
12411
  }
12412
12412
  }
12413
12413
  if (spacer !== "" && separator.length > 1) {
@@ -12465,20 +12465,20 @@ ${originalIndentation}`;
12465
12465
  indentation += spacer;
12466
12466
  let res2 = `
12467
12467
  ${indentation}`;
12468
- const join19 = `,
12468
+ const join20 = `,
12469
12469
  ${indentation}`;
12470
12470
  const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
12471
12471
  let i = 0;
12472
12472
  for (; i < maximumValuesToStringify - 1; i++) {
12473
12473
  const tmp2 = stringifyIndent(String(i), value[i], stack, spacer, indentation);
12474
12474
  res2 += tmp2 !== void 0 ? tmp2 : "null";
12475
- res2 += join19;
12475
+ res2 += join20;
12476
12476
  }
12477
12477
  const tmp = stringifyIndent(String(i), value[i], stack, spacer, indentation);
12478
12478
  res2 += tmp !== void 0 ? tmp : "null";
12479
12479
  if (value.length - 1 > maximumBreadth) {
12480
12480
  const removedKeys = value.length - maximumBreadth - 1;
12481
- res2 += `${join19}"... ${getItemCount(removedKeys)} not stringified"`;
12481
+ res2 += `${join20}"... ${getItemCount(removedKeys)} not stringified"`;
12482
12482
  }
12483
12483
  res2 += `
12484
12484
  ${originalIndentation}`;
@@ -12494,16 +12494,16 @@ ${originalIndentation}`;
12494
12494
  return '"[Object]"';
12495
12495
  }
12496
12496
  indentation += spacer;
12497
- const join18 = `,
12497
+ const join19 = `,
12498
12498
  ${indentation}`;
12499
12499
  let res = "";
12500
12500
  let separator = "";
12501
12501
  let maximumPropertiesToStringify = Math.min(keyLength, maximumBreadth);
12502
12502
  if (isTypedArrayWithEntries(value)) {
12503
- res += stringifyTypedArray(value, join18, maximumBreadth);
12503
+ res += stringifyTypedArray(value, join19, maximumBreadth);
12504
12504
  keys = keys.slice(value.length);
12505
12505
  maximumPropertiesToStringify -= value.length;
12506
- separator = join18;
12506
+ separator = join19;
12507
12507
  }
12508
12508
  if (deterministic) {
12509
12509
  keys = sort(keys, comparator);
@@ -12514,13 +12514,13 @@ ${indentation}`;
12514
12514
  const tmp = stringifyIndent(key2, value[key2], stack, spacer, indentation);
12515
12515
  if (tmp !== void 0) {
12516
12516
  res += `${separator}${strEscape(key2)}: ${tmp}`;
12517
- separator = join18;
12517
+ separator = join19;
12518
12518
  }
12519
12519
  }
12520
12520
  if (keyLength > maximumBreadth) {
12521
12521
  const removedKeys = keyLength - maximumBreadth;
12522
12522
  res += `${separator}"...": "${getItemCount(removedKeys)} not stringified"`;
12523
- separator = join18;
12523
+ separator = join19;
12524
12524
  }
12525
12525
  if (separator !== "") {
12526
12526
  res = `
@@ -13611,11 +13611,11 @@ var init_lib = __esm({
13611
13611
  }
13612
13612
  }
13613
13613
  },
13614
- addToPath: function addToPath(path85, added, removed, oldPosInc, options) {
13615
- var last = path85.lastComponent;
13614
+ addToPath: function addToPath(path86, added, removed, oldPosInc, options) {
13615
+ var last = path86.lastComponent;
13616
13616
  if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) {
13617
13617
  return {
13618
- oldPos: path85.oldPos + oldPosInc,
13618
+ oldPos: path86.oldPos + oldPosInc,
13619
13619
  lastComponent: {
13620
13620
  count: last.count + 1,
13621
13621
  added,
@@ -13625,7 +13625,7 @@ var init_lib = __esm({
13625
13625
  };
13626
13626
  } else {
13627
13627
  return {
13628
- oldPos: path85.oldPos + oldPosInc,
13628
+ oldPos: path86.oldPos + oldPosInc,
13629
13629
  lastComponent: {
13630
13630
  count: 1,
13631
13631
  added,
@@ -14157,10 +14157,10 @@ function attachmentToHistoryMessage(o, ts) {
14157
14157
  const memories = raw.map((m2) => {
14158
14158
  if (!m2 || typeof m2 !== "object") return null;
14159
14159
  const rec4 = m2;
14160
- const path85 = typeof rec4.path === "string" ? rec4.path : null;
14160
+ const path86 = typeof rec4.path === "string" ? rec4.path : null;
14161
14161
  const content = typeof rec4.content === "string" ? rec4.content : null;
14162
- if (!path85 || content == null) return null;
14163
- const entry = { path: path85, content };
14162
+ if (!path86 || content == null) return null;
14163
+ const entry = { path: path86, content };
14164
14164
  if (typeof rec4.mtimeMs === "number") entry.mtimeMs = rec4.mtimeMs;
14165
14165
  return entry;
14166
14166
  }).filter((m2) => m2 !== null);
@@ -15011,10 +15011,10 @@ function parseAttachment(obj) {
15011
15011
  const memories = raw.map((m2) => {
15012
15012
  if (!m2 || typeof m2 !== "object") return null;
15013
15013
  const rec4 = m2;
15014
- const path85 = typeof rec4.path === "string" ? rec4.path : null;
15014
+ const path86 = typeof rec4.path === "string" ? rec4.path : null;
15015
15015
  const content = typeof rec4.content === "string" ? rec4.content : null;
15016
- if (!path85 || content == null) return null;
15017
- const out = { path: path85, content };
15016
+ if (!path86 || content == null) return null;
15017
+ const out = { path: path86, content };
15018
15018
  if (typeof rec4.mtimeMs === "number") out.mtimeMs = rec4.mtimeMs;
15019
15019
  return out;
15020
15020
  }).filter((m2) => m2 !== null);
@@ -29396,8 +29396,8 @@ var require_CronFileParser = __commonJS({
29396
29396
  * @throws If file cannot be read
29397
29397
  */
29398
29398
  static parseFileSync(filePath) {
29399
- const { readFileSync: readFileSync9 } = require("fs");
29400
- const data = readFileSync9(filePath, "utf8");
29399
+ const { readFileSync: readFileSync10 } = require("fs");
29400
+ const data = readFileSync10(filePath, "utf8");
29401
29401
  return _CronFileParser.#parseContent(data);
29402
29402
  }
29403
29403
  /**
@@ -33398,7 +33398,7 @@ var require_BufferList = __commonJS({
33398
33398
  this.head = this.tail = null;
33399
33399
  this.length = 0;
33400
33400
  };
33401
- BufferList.prototype.join = function join18(s) {
33401
+ BufferList.prototype.join = function join19(s) {
33402
33402
  if (this.length === 0) return "";
33403
33403
  var p2 = this.head;
33404
33404
  var ret = "" + p2.data;
@@ -35988,8 +35988,8 @@ var require_utils = __commonJS({
35988
35988
  var result = transform[inputType][outputType](input);
35989
35989
  return result;
35990
35990
  };
35991
- exports2.resolve = function(path85) {
35992
- var parts = path85.split("/");
35991
+ exports2.resolve = function(path86) {
35992
+ var parts = path86.split("/");
35993
35993
  var result = [];
35994
35994
  for (var index = 0; index < parts.length; index++) {
35995
35995
  var part = parts[index];
@@ -41842,18 +41842,18 @@ var require_object = __commonJS({
41842
41842
  var object = new ZipObject(name, zipObjectContent, o);
41843
41843
  this.files[name] = object;
41844
41844
  };
41845
- var parentFolder = function(path85) {
41846
- if (path85.slice(-1) === "/") {
41847
- path85 = path85.substring(0, path85.length - 1);
41845
+ var parentFolder = function(path86) {
41846
+ if (path86.slice(-1) === "/") {
41847
+ path86 = path86.substring(0, path86.length - 1);
41848
41848
  }
41849
- var lastSlash = path85.lastIndexOf("/");
41850
- return lastSlash > 0 ? path85.substring(0, lastSlash) : "";
41849
+ var lastSlash = path86.lastIndexOf("/");
41850
+ return lastSlash > 0 ? path86.substring(0, lastSlash) : "";
41851
41851
  };
41852
- var forceTrailingSlash = function(path85) {
41853
- if (path85.slice(-1) !== "/") {
41854
- path85 += "/";
41852
+ var forceTrailingSlash = function(path86) {
41853
+ if (path86.slice(-1) !== "/") {
41854
+ path86 += "/";
41855
41855
  }
41856
- return path85;
41856
+ return path86;
41857
41857
  };
41858
41858
  var folderAdd = function(name, createFolders) {
41859
41859
  createFolders = typeof createFolders !== "undefined" ? createFolders : defaults.createFolders;
@@ -48218,13 +48218,6 @@ function readCodexProjects(opts) {
48218
48218
  }
48219
48219
 
48220
48220
  // src/projects/store.ts
48221
- var DEFAULT_TMP_ROOTS = () => [
48222
- "/tmp",
48223
- "/private/tmp",
48224
- "/var/folders",
48225
- "/private/var/folders",
48226
- path12.resolve(os5.tmpdir())
48227
- ];
48228
48221
  var ProjectsStore = class {
48229
48222
  constructor(opts) {
48230
48223
  this.opts = opts;
@@ -48262,23 +48255,8 @@ var ProjectsStore = class {
48262
48255
  const insideClawd = !(rel.startsWith("..") || path12.isAbsolute(rel));
48263
48256
  if (insideClawd) return false;
48264
48257
  if (abs === path12.resolve(os5.homedir()) || abs === path12.parse(abs).root) return false;
48265
- for (const root of this.tmpRoots()) {
48266
- if (abs === root || abs.startsWith(root.endsWith(path12.sep) ? root : root + path12.sep)) {
48267
- return false;
48268
- }
48269
- }
48270
48258
  return true;
48271
48259
  }
48272
- /** 层 2 的临时区根(缺省自适应,见构造器 opts.tmpRoots 注释) */
48273
- tmpRoots() {
48274
- if (this.opts.tmpRoots) return this.opts.tmpRoots;
48275
- const defaults = DEFAULT_TMP_ROOTS();
48276
- const clawd = path12.resolve(this.opts.clawdDir);
48277
- const clawdItselfInTmp = defaults.some(
48278
- (r) => clawd === r || clawd.startsWith(r + path12.sep)
48279
- );
48280
- return clawdItselfInTmp ? [] : defaults;
48281
- }
48282
48260
  list() {
48283
48261
  return [...this.entries];
48284
48262
  }
@@ -48302,6 +48280,7 @@ var ProjectsStore = class {
48302
48280
  stateFile: this.opts.codexStateFile,
48303
48281
  logger: this.opts.logger
48304
48282
  })) {
48283
+ if (!c.createdAt) continue;
48305
48284
  const abs = this.normalize(c.path);
48306
48285
  if (!this.isProjectablePath(abs)) continue;
48307
48286
  byPath.set(abs, {
@@ -50229,8 +50208,8 @@ function turnStartInput(text) {
50229
50208
  const items = [];
50230
50209
  let leftover = text;
50231
50210
  for (const m2 of text.matchAll(SKILL_RE)) {
50232
- const [marker, name, path85] = m2;
50233
- items.push({ type: "skill", name, path: path85 });
50211
+ const [marker, name, path86] = m2;
50212
+ items.push({ type: "skill", name, path: path86 });
50234
50213
  leftover = leftover.replace(marker, "");
50235
50214
  }
50236
50215
  for (const m2 of text.matchAll(ATTACHMENT_RE2)) {
@@ -54387,13 +54366,13 @@ function mapSkillsListResponse(res) {
54387
54366
  const r = s ?? {};
54388
54367
  const name = str3(r.name);
54389
54368
  if (!name) continue;
54390
- const path85 = str3(r.path);
54369
+ const path86 = str3(r.path);
54391
54370
  const description = str3(r.description);
54392
54371
  const isPlugin = name.includes(":");
54393
54372
  out.push({
54394
54373
  name,
54395
54374
  source: isPlugin ? "plugin" : "project",
54396
- ...path85 ? { path: path85 } : {},
54375
+ ...path86 ? { path: path86 } : {},
54397
54376
  ...description ? { description } : {},
54398
54377
  ...isPlugin ? { plugin: name.split(":")[0] } : {}
54399
54378
  });
@@ -56495,6 +56474,36 @@ function rmdirIfEmpty(p2) {
56495
56474
  }
56496
56475
  }
56497
56476
 
56477
+ // src/migrations/2026-08-18-drop-seeded-projects.ts
56478
+ var fs44 = __toESM(require("fs"), 1);
56479
+ var path45 = __toESM(require("path"), 1);
56480
+ var DROP_SEEDED_PROJECTS_FLAG = ".projects-seed-dropped.v1.done";
56481
+ function dropSeededProjects(opts) {
56482
+ fs44.mkdirSync(opts.dataDir, { recursive: true });
56483
+ const flag = path45.join(opts.dataDir, DROP_SEEDED_PROJECTS_FLAG);
56484
+ if (fs44.existsSync(flag)) return { skipped: true, dropped: 0, backup: null };
56485
+ const file = path45.join(opts.dataDir, "projects.json");
56486
+ let raw = null;
56487
+ let dropped = 0;
56488
+ try {
56489
+ raw = fs44.readFileSync(file, "utf8");
56490
+ dropped = JSON.parse(raw).projects?.length ?? 0;
56491
+ } catch {
56492
+ }
56493
+ let backup = null;
56494
+ if (raw != null && dropped > 0) {
56495
+ const dir = path45.join(opts.dataDir, "backups");
56496
+ fs44.mkdirSync(dir, { recursive: true });
56497
+ backup = path45.join(dir, `projects.seed-dropped.${(opts.now ?? Date.now)()}.json`);
56498
+ fs44.writeFileSync(backup, raw);
56499
+ }
56500
+ if (raw != null || dropped > 0) {
56501
+ fs44.writeFileSync(file, JSON.stringify({ projects: [] }, null, 2));
56502
+ }
56503
+ fs44.writeFileSync(flag, (/* @__PURE__ */ new Date()).toISOString());
56504
+ return { skipped: false, dropped, backup };
56505
+ }
56506
+
56498
56507
  // src/transport/http-router.ts
56499
56508
  var import_node_fs34 = __toESM(require("fs"), 1);
56500
56509
  var import_node_path38 = __toESM(require("path"), 1);
@@ -58657,9 +58666,9 @@ var CentralClientError = class extends Error {
58657
58666
  code;
58658
58667
  cause;
58659
58668
  };
58660
- async function centralRequest(opts, path85, init) {
58669
+ async function centralRequest(opts, path86, init) {
58661
58670
  const f = opts.fetchImpl ?? globalThis.fetch;
58662
- const url = `${opts.api.replace(/\/+$/, "")}${path85}`;
58671
+ const url = `${opts.api.replace(/\/+$/, "")}${path86}`;
58663
58672
  const ctrl = new AbortController();
58664
58673
  const timer = setTimeout(() => ctrl.abort(), opts.timeoutMs ?? 15e3);
58665
58674
  let res;
@@ -58853,8 +58862,8 @@ function verifyConnectToken(args) {
58853
58862
  }
58854
58863
 
58855
58864
  // src/feishu-auth/server-key.ts
58856
- var fs57 = __toESM(require("fs"), 1);
58857
- var path60 = __toESM(require("path"), 1);
58865
+ var fs58 = __toESM(require("fs"), 1);
58866
+ var path61 = __toESM(require("path"), 1);
58858
58867
  var FILE_NAME2 = "server-signing-key.json";
58859
58868
  var ServerKeyStore = class {
58860
58869
  constructor(dataDir) {
@@ -58862,12 +58871,12 @@ var ServerKeyStore = class {
58862
58871
  }
58863
58872
  dataDir;
58864
58873
  filePath() {
58865
- return path60.join(this.dataDir, FILE_NAME2);
58874
+ return path61.join(this.dataDir, FILE_NAME2);
58866
58875
  }
58867
58876
  /** 读缓存的公钥;无缓存 / 损坏 → null(调用方决定是否触发拉取) */
58868
58877
  read() {
58869
58878
  try {
58870
- const raw = fs57.readFileSync(this.filePath(), "utf8");
58879
+ const raw = fs58.readFileSync(this.filePath(), "utf8");
58871
58880
  const parsed = JSON.parse(raw);
58872
58881
  if (typeof parsed.publicKeyPem === "string" && parsed.publicKeyPem.includes("PUBLIC KEY")) {
58873
58882
  return parsed.publicKeyPem;
@@ -58882,12 +58891,12 @@ var ServerKeyStore = class {
58882
58891
  publicKeyPem,
58883
58892
  fetchedAt: (/* @__PURE__ */ new Date()).toISOString()
58884
58893
  };
58885
- fs57.mkdirSync(this.dataDir, { recursive: true });
58886
- fs57.writeFileSync(this.filePath(), JSON.stringify(content, null, 2), { mode: 384 });
58894
+ fs58.mkdirSync(this.dataDir, { recursive: true });
58895
+ fs58.writeFileSync(this.filePath(), JSON.stringify(content, null, 2), { mode: 384 });
58887
58896
  }
58888
58897
  clear() {
58889
58898
  try {
58890
- fs57.unlinkSync(this.filePath());
58899
+ fs58.unlinkSync(this.filePath());
58891
58900
  } catch {
58892
58901
  }
58893
58902
  }
@@ -59004,23 +59013,6 @@ function toMs(v2) {
59004
59013
  const n = Number(v2 || 0);
59005
59014
  return n > 1e11 ? Math.round(n) : Math.round(n * 1e3);
59006
59015
  }
59007
- function listFiles(dir, depth = 0, maxDepth = 8, out = []) {
59008
- let entries;
59009
- try {
59010
- entries = import_node_fs46.default.readdirSync(dir, { withFileTypes: true });
59011
- } catch {
59012
- return out;
59013
- }
59014
- for (const e of entries) {
59015
- const full = import_node_path51.default.join(dir, e.name);
59016
- if (e.isDirectory()) {
59017
- if (depth < maxDepth) listFiles(full, depth + 1, maxDepth, out);
59018
- } else if (e.isFile()) {
59019
- out.push(full);
59020
- }
59021
- }
59022
- return out;
59023
- }
59024
59016
  async function* jsonLines(file) {
59025
59017
  let raw;
59026
59018
  try {
@@ -59078,6 +59070,7 @@ async function scanClaude(roots) {
59078
59070
  continue;
59079
59071
  }
59080
59072
  let cwd = "";
59073
+ let entrypoint = "";
59081
59074
  let title = "";
59082
59075
  let firstUser = "";
59083
59076
  let turns = 0;
@@ -59086,6 +59079,7 @@ async function scanClaude(roots) {
59086
59079
  let hasMainLine = false;
59087
59080
  for await (const rec4 of jsonLines(file)) {
59088
59081
  if (!cwd && typeof rec4.cwd === "string") cwd = rec4.cwd;
59082
+ if (!entrypoint && typeof rec4.entrypoint === "string") entrypoint = rec4.entrypoint;
59089
59083
  if (typeof rec4.timestamp === "string") {
59090
59084
  const t = Date.parse(rec4.timestamp);
59091
59085
  if (Number.isFinite(t)) {
@@ -59117,7 +59111,7 @@ async function scanClaude(roots) {
59117
59111
  };
59118
59112
  if (!hasMainLine) cand.skip = "subagent \u652F\u7EBF";
59119
59113
  else if (!cwd) cand.skip = "\u65E0 cwd";
59120
- else if (import_node_path51.default.basename(cwd).startsWith(TITLE_GEN_DIR_PREFIX)) cand.skip = "\u6807\u9898\u751F\u6210\u4E34\u65F6\u4F1A\u8BDD";
59114
+ else if (entrypoint !== "cli" && entrypoint !== "claude-desktop") cand.skip = "\u975E\u7528\u6237\u5165\u53E3";
59121
59115
  out.push(cand);
59122
59116
  }
59123
59117
  }
@@ -59138,7 +59132,7 @@ async function countCodexTurns(rolloutPath) {
59138
59132
  return { turns, first };
59139
59133
  }
59140
59134
  function readCodexThreads(db) {
59141
- const COLS = ["id", "cwd", "created_at", "updated_at", "name", "title", "preview", "first_user_message", "archived", "rollout_path"];
59135
+ const COLS = ["id", "cwd", "created_at", "updated_at", "name", "title", "preview", "first_user_message", "archived", "rollout_path", "thread_source"];
59142
59136
  try {
59143
59137
  const { DatabaseSync } = (0, import_node_module.createRequire)(import_meta4.url)("node:sqlite");
59144
59138
  const conn = new DatabaseSync(db, { readOnly: true });
@@ -59146,7 +59140,7 @@ function readCodexThreads(db) {
59146
59140
  const have = new Set(
59147
59141
  conn.prepare("PRAGMA table_info(threads)").all().map((r) => r.name)
59148
59142
  );
59149
- if (!["id", "cwd", "updated_at"].every((c) => have.has(c))) return null;
59143
+ if (!["id", "cwd", "updated_at", "thread_source"].every((c) => have.has(c))) return null;
59150
59144
  const sel = COLS.map((c) => have.has(c) ? c : `NULL AS ${c}`).join(", ");
59151
59145
  return conn.prepare(`SELECT ${sel} FROM threads`).all();
59152
59146
  } finally {
@@ -59160,7 +59154,7 @@ function readCodexThreads(db) {
59160
59154
  const have = new Set(
59161
59155
  info.stdout.split("\n").map((l) => l.split("|")[1]).filter(Boolean)
59162
59156
  );
59163
- if (!["id", "cwd", "updated_at"].every((c) => have.has(c))) return null;
59157
+ if (!["id", "cwd", "updated_at", "thread_source"].every((c) => have.has(c))) return null;
59164
59158
  const sel = COLS.map((c) => have.has(c) ? c : `NULL AS ${c}`).join(", ");
59165
59159
  const res = (0, import_node_child_process12.spawnSync)("sqlite3", ["-json", db, `SELECT ${sel} FROM threads;`], {
59166
59160
  encoding: "utf8",
@@ -59188,58 +59182,22 @@ async function codexFromRows(rows) {
59188
59182
  updatedMs,
59189
59183
  skip: ""
59190
59184
  };
59191
- if (r.archived) cand.skip = "\u5DF2\u5F52\u6863";
59185
+ if (r.thread_source !== "user") cand.skip = "\u975E\u7528\u6237\u65B0\u5EFA";
59186
+ else if (r.archived) cand.skip = "\u5DF2\u5F52\u6863";
59192
59187
  else if (!label) cand.skip = "\u7A7A\u4F1A\u8BDD";
59193
59188
  out.push(cand);
59194
59189
  }
59195
59190
  return out;
59196
59191
  }
59197
- async function scanCodexRollouts(roots) {
59198
- const out = [];
59199
- for (const file of listFiles(import_node_path51.default.join(roots.codexDir, "sessions"))) {
59200
- if (!file.endsWith(".jsonl")) continue;
59201
- let st;
59202
- try {
59203
- st = import_node_fs46.default.statSync(file);
59204
- } catch {
59205
- continue;
59206
- }
59207
- let meta = null;
59208
- for await (const rec4 of jsonLines(file)) {
59209
- if (rec4.type === "session_meta") {
59210
- meta = rec4.payload || {};
59211
- break;
59212
- }
59213
- }
59214
- const tid = meta && (meta.session_id || meta.id);
59215
- if (!tid) continue;
59216
- const { turns, first } = await countCodexTurns(file);
59217
- const cand = {
59218
- tool: "codex",
59219
- toolSessionId: String(tid),
59220
- cwd: String(meta?.cwd || ""),
59221
- label: clipW(first, 56),
59222
- turns,
59223
- createdMs: st.mtimeMs,
59224
- updatedMs: st.mtimeMs,
59225
- skip: ""
59226
- };
59227
- if (!cand.cwd) cand.skip = "\u65E0 cwd";
59228
- out.push(cand);
59229
- }
59230
- return out;
59231
- }
59232
59192
  async function scanCodex(roots) {
59233
59193
  let dbs = [];
59234
59194
  try {
59235
59195
  dbs = import_node_fs46.default.readdirSync(roots.codexDir).filter((n) => /^state_.*\.sqlite$/.test(n)).sort().map((n) => import_node_path51.default.join(roots.codexDir, n));
59236
59196
  } catch {
59237
59197
  }
59238
- if (dbs.length) {
59239
- const rows = readCodexThreads(dbs[dbs.length - 1]);
59240
- if (rows) return codexFromRows(rows);
59241
- }
59242
- return scanCodexRollouts(roots);
59198
+ if (!dbs.length) return [];
59199
+ const rows = readCodexThreads(dbs[dbs.length - 1]);
59200
+ return rows ? codexFromRows(rows) : [];
59243
59201
  }
59244
59202
  async function scanExternalSessions(rootsIn) {
59245
59203
  const roots = { ...defaultRoots(), ...rootsIn };
@@ -59270,14 +59228,19 @@ async function scanExternalSessions(rootsIn) {
59270
59228
  var import_node_fs47 = __toESM(require("fs"), 1);
59271
59229
  var import_node_path52 = __toESM(require("path"), 1);
59272
59230
  var LEDGER_FILENAME = "session-import-ledger.json";
59273
- function appendImportLedger(dataDir, entry) {
59274
- const file = import_node_path52.default.join(dataDir, LEDGER_FILENAME);
59275
- let entries = [];
59231
+ function readImportLedger(dataDir) {
59276
59232
  try {
59277
- const parsed = JSON.parse(import_node_fs47.default.readFileSync(file, "utf8"));
59278
- if (Array.isArray(parsed)) entries = parsed;
59233
+ const parsed = JSON.parse(
59234
+ import_node_fs47.default.readFileSync(import_node_path52.default.join(dataDir, LEDGER_FILENAME), "utf8")
59235
+ );
59236
+ return Array.isArray(parsed) ? parsed : [];
59279
59237
  } catch {
59238
+ return [];
59280
59239
  }
59240
+ }
59241
+ function appendImportLedger(dataDir, entry) {
59242
+ const file = import_node_path52.default.join(dataDir, LEDGER_FILENAME);
59243
+ const entries = readImportLedger(dataDir);
59281
59244
  entries.push(entry);
59282
59245
  import_node_fs47.default.writeFileSync(file, JSON.stringify(entries, null, 2), { encoding: "utf8", mode: 384 });
59283
59246
  }
@@ -59386,6 +59349,9 @@ function buildSessionHandlers(deps) {
59386
59349
  parseArgs2(SessionExternalScanArgs, frame, "session:externalScan args");
59387
59350
  const owned = manager.list().response.sessions;
59388
59351
  const linked = new Set(owned.map((f) => f.toolSessionId).filter(Boolean));
59352
+ if (deps.dataDir) {
59353
+ for (const e of readImportLedger(deps.dataDir)) linked.add(e.toolSessionId);
59354
+ }
59389
59355
  const candidates = (await scanExternalSessions()).filter((c) => !linked.has(c.toolSessionId));
59390
59356
  return { response: { candidates } };
59391
59357
  };
@@ -59779,7 +59745,7 @@ function buildPermissionHandlers(deps) {
59779
59745
  }
59780
59746
 
59781
59747
  // src/handlers/history.ts
59782
- var path65 = __toESM(require("path"), 1);
59748
+ var path66 = __toESM(require("path"), 1);
59783
59749
  init_protocol();
59784
59750
 
59785
59751
  // src/session/recent-dirs.ts
@@ -59797,7 +59763,7 @@ function listRecentDirs(store, limit = 50) {
59797
59763
  }
59798
59764
 
59799
59765
  // src/permission/persona-paths.ts
59800
- var path64 = __toESM(require("path"), 1);
59766
+ var path65 = __toESM(require("path"), 1);
59801
59767
  function getAllowedPersonaIds(grants, action) {
59802
59768
  const ids = /* @__PURE__ */ new Set();
59803
59769
  for (const g2 of grants) {
@@ -59810,42 +59776,42 @@ function getAllowedPersonaIds(grants, action) {
59810
59776
  return ids;
59811
59777
  }
59812
59778
  function isGuestPathAllowed(grants, absPath, personaRoot, action = "read", userWorkDir) {
59813
- const target = path64.resolve(absPath);
59779
+ const target = path65.resolve(absPath);
59814
59780
  if (userWorkDir) {
59815
- const u = path64.resolve(userWorkDir);
59816
- const usep = u.endsWith(path64.sep) ? "" : path64.sep;
59781
+ const u = path65.resolve(userWorkDir);
59782
+ const usep = u.endsWith(path65.sep) ? "" : path65.sep;
59817
59783
  if (target === u || target.startsWith(u + usep)) return true;
59818
59784
  }
59819
- const root = path64.resolve(personaRoot);
59820
- const sep5 = root.endsWith(path64.sep) ? "" : path64.sep;
59821
- if (!target.startsWith(root + sep5)) return false;
59822
- const rel = path64.relative(root, target);
59785
+ const root = path65.resolve(personaRoot);
59786
+ const sep4 = root.endsWith(path65.sep) ? "" : path65.sep;
59787
+ if (!target.startsWith(root + sep4)) return false;
59788
+ const rel = path65.relative(root, target);
59823
59789
  if (!rel || rel.startsWith("..")) return false;
59824
- const personaId2 = rel.split(path64.sep)[0];
59790
+ const personaId2 = rel.split(path65.sep)[0];
59825
59791
  if (!personaId2) return false;
59826
59792
  const allowed = getAllowedPersonaIds(grants, action);
59827
59793
  if (allowed === "*") return true;
59828
59794
  return allowed.has(personaId2);
59829
59795
  }
59830
59796
  function personaIdFromPath(absPath, personaRoot) {
59831
- const root = path64.resolve(personaRoot);
59832
- const target = path64.resolve(absPath);
59833
- const sep5 = root.endsWith(path64.sep) ? "" : path64.sep;
59834
- if (!target.startsWith(root + sep5)) return null;
59835
- const rel = path64.relative(root, target);
59797
+ const root = path65.resolve(personaRoot);
59798
+ const target = path65.resolve(absPath);
59799
+ const sep4 = root.endsWith(path65.sep) ? "" : path65.sep;
59800
+ if (!target.startsWith(root + sep4)) return null;
59801
+ const rel = path65.relative(root, target);
59836
59802
  if (!rel || rel.startsWith("..")) return null;
59837
- const id = rel.split(path64.sep)[0];
59803
+ const id = rel.split(path65.sep)[0];
59838
59804
  return id || null;
59839
59805
  }
59840
59806
  function isPathWithin(dir, absPath) {
59841
- const d = path64.resolve(dir);
59842
- const t = path64.resolve(absPath);
59843
- const sep5 = d.endsWith(path64.sep) ? "" : path64.sep;
59844
- return t === d || t.startsWith(d + sep5);
59807
+ const d = path65.resolve(dir);
59808
+ const t = path65.resolve(absPath);
59809
+ const sep4 = d.endsWith(path65.sep) ? "" : path65.sep;
59810
+ return t === d || t.startsWith(d + sep4);
59845
59811
  }
59846
59812
  function isPathInGuestBoundary(personaRoot, personaId2, userWorkDir, absPath) {
59847
59813
  if (userWorkDir && isPathWithin(userWorkDir, absPath)) return true;
59848
- return personaIdFromPath(path64.resolve(absPath), personaRoot) === personaId2;
59814
+ return personaIdFromPath(path65.resolve(absPath), personaRoot) === personaId2;
59849
59815
  }
59850
59816
 
59851
59817
  // src/handlers/history.ts
@@ -59898,7 +59864,7 @@ function buildHistoryHandlers(deps) {
59898
59864
  if (!pid) return false;
59899
59865
  return isGuestPathAllowed(
59900
59866
  ctx.grants,
59901
- path65.join(personaRoot, pid),
59867
+ path66.join(personaRoot, pid),
59902
59868
  personaRoot,
59903
59869
  "read",
59904
59870
  userWorkDir
@@ -59910,7 +59876,7 @@ function buildHistoryHandlers(deps) {
59910
59876
  };
59911
59877
  const list = async (frame, _client, ctx) => {
59912
59878
  const args = HistoryListArgs.parse(frame);
59913
- assertGuestPath(ctx, path65.resolve(args.projectPath), personaRoot, "history:list", usersRoot);
59879
+ assertGuestPath(ctx, path66.resolve(args.projectPath), personaRoot, "history:list", usersRoot);
59914
59880
  const sessions = await history.listSessions(args);
59915
59881
  return { response: { type: "history:list", sessions } };
59916
59882
  };
@@ -59958,14 +59924,14 @@ function buildHistoryHandlers(deps) {
59958
59924
  };
59959
59925
  const subagents = async (frame, _client, ctx) => {
59960
59926
  const args = HistorySubagentsArgs.parse(frame);
59961
- assertGuestPath(ctx, path65.resolve(args.cwd), personaRoot, "history:subagents", usersRoot);
59927
+ assertGuestPath(ctx, path66.resolve(args.cwd), personaRoot, "history:subagents", usersRoot);
59962
59928
  assertGuestOwnsToolSession(ctx, args.toolSessionId, "history:subagents");
59963
59929
  const subs = await historyReaderForToolSession(args.toolSessionId).listSubagents(args);
59964
59930
  return { response: { type: "history:subagents", subagents: subs } };
59965
59931
  };
59966
59932
  const subagentRead = async (frame, _client, ctx) => {
59967
59933
  const args = HistorySubagentReadArgs.parse(frame);
59968
- assertGuestPath(ctx, path65.resolve(args.cwd), personaRoot, "history:subagent-read", usersRoot);
59934
+ assertGuestPath(ctx, path66.resolve(args.cwd), personaRoot, "history:subagent-read", usersRoot);
59969
59935
  assertGuestOwnsToolSession(ctx, args.toolSessionId, "history:subagent-read");
59970
59936
  const res = await historyReaderForToolSession(args.toolSessionId).readSubagent(args);
59971
59937
  return { response: { type: "history:subagent-read", ...res } };
@@ -59975,7 +59941,7 @@ function buildHistoryHandlers(deps) {
59975
59941
  if (ctx?.principal.kind === "guest" && personaRoot) {
59976
59942
  const userWorkDir = usersRoot ? deriveUserWorkDir(ctx.principal.id, usersRoot) : void 0;
59977
59943
  const filtered = dirs.filter(
59978
- (d) => isGuestPathAllowed(ctx.grants, path65.resolve(d.cwd), personaRoot, "read", userWorkDir)
59944
+ (d) => isGuestPathAllowed(ctx.grants, path66.resolve(d.cwd), personaRoot, "read", userWorkDir)
59979
59945
  );
59980
59946
  return { response: { type: "history:recentDirs", dirs: filtered } };
59981
59947
  }
@@ -59992,17 +59958,17 @@ function buildHistoryHandlers(deps) {
59992
59958
  }
59993
59959
 
59994
59960
  // src/handlers/projects.ts
59995
- var fs61 = __toESM(require("fs"), 1);
59961
+ var fs62 = __toESM(require("fs"), 1);
59996
59962
  var os19 = __toESM(require("os"), 1);
59997
- var path66 = __toESM(require("path"), 1);
59963
+ var path67 = __toESM(require("path"), 1);
59998
59964
  var import_node_child_process13 = require("child_process");
59999
59965
  init_protocol();
60000
- var DEFAULT_PROJECTS_ROOT = path66.join(os19.homedir(), "Documents", "ChatGPT");
59966
+ var DEFAULT_PROJECTS_ROOT = path67.join(os19.homedir(), "Documents", "ChatGPT");
60001
59967
  function allocateDir(root, name) {
60002
- let candidate = path66.join(root, name);
59968
+ let candidate = path67.join(root, name);
60003
59969
  let n = 2;
60004
- while (fs61.existsSync(candidate)) {
60005
- candidate = path66.join(root, `${name} ${n}`);
59970
+ while (fs62.existsSync(candidate)) {
59971
+ candidate = path67.join(root, `${name} ${n}`);
60006
59972
  n += 1;
60007
59973
  }
60008
59974
  return candidate;
@@ -60023,7 +59989,7 @@ function buildProjectHandlers(deps) {
60023
59989
  let target;
60024
59990
  if (args.path) {
60025
59991
  try {
60026
- if (!fs61.statSync(args.path).isDirectory()) throw new Error("not dir");
59992
+ if (!fs62.statSync(args.path).isDirectory()) throw new Error("not dir");
60027
59993
  } catch {
60028
59994
  throw new ClawdError(ERROR_CODES.INVALID_CWD, `not a directory: ${args.path}`);
60029
59995
  }
@@ -60031,15 +59997,15 @@ function buildProjectHandlers(deps) {
60031
59997
  } else {
60032
59998
  const name = args.name;
60033
59999
  try {
60034
- fs61.mkdirSync(root, { recursive: true });
60000
+ fs62.mkdirSync(root, { recursive: true });
60035
60001
  target = allocateDir(root, name);
60036
- fs61.mkdirSync(target);
60002
+ fs62.mkdirSync(target);
60037
60003
  } catch (err) {
60038
60004
  throw new ClawdError(ERROR_CODES.INVALID_CWD, `\u521B\u5EFA\u9879\u76EE\u76EE\u5F55\u5931\u8D25: ${String(err)}`);
60039
60005
  }
60040
60006
  const git = (0, import_node_child_process13.spawnSync)("git", ["init"], { cwd: target, stdio: "ignore" });
60041
60007
  if (git.status !== 0) {
60042
- fs61.rmSync(target, { recursive: true, force: true });
60008
+ fs62.rmSync(target, { recursive: true, force: true });
60043
60009
  throw new ClawdError(
60044
60010
  ERROR_CODES.INVALID_CWD,
60045
60011
  `git init \u5931\u8D25\uFF08${git.error ? String(git.error) : `exit ${git.status}`}\uFF09: ${target}`
@@ -60059,7 +60025,7 @@ function buildProjectHandlers(deps) {
60059
60025
  }
60060
60026
 
60061
60027
  // src/handlers/workspace.ts
60062
- var path67 = __toESM(require("path"), 1);
60028
+ var path68 = __toESM(require("path"), 1);
60063
60029
  var os20 = __toESM(require("os"), 1);
60064
60030
  init_protocol();
60065
60031
  init_protocol();
@@ -60101,22 +60067,22 @@ function buildWorkspaceHandlers(deps) {
60101
60067
  const args = WorkspaceListArgs.parse(frame);
60102
60068
  const isGuest = ctx?.principal.kind === "guest";
60103
60069
  const fallbackCwd = isGuest && personaRoot ? personaRoot : os20.homedir();
60104
- const resolvedCwd = path67.resolve(args.cwd ?? fallbackCwd);
60105
- const target = args.path ? path67.resolve(resolvedCwd, args.path) : resolvedCwd;
60070
+ const resolvedCwd = path68.resolve(args.cwd ?? fallbackCwd);
60071
+ const target = args.path ? path68.resolve(resolvedCwd, args.path) : resolvedCwd;
60106
60072
  assertGuestPath2(ctx, target, personaRoot, "workspace:list", usersRoot);
60107
60073
  const res = workspace.list({ ...args, cwd: resolvedCwd });
60108
60074
  return { response: { type: "workspace:list", ...res } };
60109
60075
  };
60110
60076
  const read = async (frame, _client, ctx) => {
60111
60077
  const args = WorkspaceReadArgs.parse(frame);
60112
- const target = path67.isAbsolute(args.path) ? path67.resolve(args.path) : path67.resolve(args.cwd, args.path);
60078
+ const target = path68.isAbsolute(args.path) ? path68.resolve(args.path) : path68.resolve(args.cwd, args.path);
60113
60079
  assertGuestPath2(ctx, target, personaRoot, "workspace:read", usersRoot);
60114
60080
  const res = workspace.read(args);
60115
60081
  return { response: { type: "workspace:read", ...res } };
60116
60082
  };
60117
60083
  const skillsList = async (frame, _client, ctx) => {
60118
60084
  const args = SkillsListArgs.parse(frame);
60119
- const cwdAbs = path67.resolve(args.cwd);
60085
+ const cwdAbs = path68.resolve(args.cwd);
60120
60086
  assertGuestPath2(ctx, cwdAbs, personaRoot, "skills:list", usersRoot);
60121
60087
  const list2 = await getSkillsForTool(args.tool ?? "claude", cwdAbs);
60122
60088
  if (ctx?.principal.kind === "guest" && personaRoot) {
@@ -60128,7 +60094,7 @@ function buildWorkspaceHandlers(deps) {
60128
60094
  };
60129
60095
  const agentsList = async (frame, _client, ctx) => {
60130
60096
  const args = AgentsListArgs.parse(frame);
60131
- const cwdAbs = path67.resolve(args.cwd);
60097
+ const cwdAbs = path68.resolve(args.cwd);
60132
60098
  assertGuestPath2(ctx, cwdAbs, personaRoot, "agents:list", usersRoot);
60133
60099
  if (args.tool === "codex") {
60134
60100
  return { response: { type: "agents:list", agents: [] } };
@@ -60150,7 +60116,7 @@ function buildWorkspaceHandlers(deps) {
60150
60116
  }
60151
60117
 
60152
60118
  // src/handlers/git.ts
60153
- var path69 = __toESM(require("path"), 1);
60119
+ var path70 = __toESM(require("path"), 1);
60154
60120
  init_protocol();
60155
60121
  init_protocol();
60156
60122
 
@@ -60237,7 +60203,7 @@ async function listGitBranches(cwd) {
60237
60203
  function assertGuestCwd(ctx, cwd, personaRoot, method, usersRoot) {
60238
60204
  if (!ctx || ctx.principal.kind !== "guest" || !personaRoot) return;
60239
60205
  const userWorkDir = usersRoot ? deriveUserWorkDir(ctx.principal.id, usersRoot) : void 0;
60240
- if (!isGuestPathAllowed(ctx.grants, path69.resolve(cwd), personaRoot, "read", userWorkDir)) {
60206
+ if (!isGuestPathAllowed(ctx.grants, path70.resolve(cwd), personaRoot, "read", userWorkDir)) {
60241
60207
  throw new ClawdError(
60242
60208
  ERROR_CODES.UNAUTHORIZED,
60243
60209
  `guest ${ctx.principal.id} cannot ${method} cwd ${cwd}`
@@ -61138,21 +61104,21 @@ function computeMethodAccess(args) {
61138
61104
  }
61139
61105
 
61140
61106
  // src/version.ts
61141
- var version = "0.2.372".length > 0 ? "0.2.372" : "dev";
61107
+ var version = "0.2.374".length > 0 ? "0.2.374" : "dev";
61142
61108
 
61143
61109
  // src/cli-probe/probe.ts
61144
- var fs63 = __toESM(require("fs"), 1);
61145
- var path70 = __toESM(require("path"), 1);
61110
+ var fs64 = __toESM(require("fs"), 1);
61111
+ var path71 = __toESM(require("path"), 1);
61146
61112
  var PKG_NAME = "@clawos-dev/clawd";
61147
61113
  var BIN_NAME = "clawd";
61148
61114
  var MAX_PARENT_HOPS = 5;
61149
61115
  function probeGlobalCli(pathEnv) {
61150
61116
  if (!pathEnv) return null;
61151
- for (const dir of pathEnv.split(path70.delimiter)) {
61117
+ for (const dir of pathEnv.split(path71.delimiter)) {
61152
61118
  if (!dir) continue;
61153
61119
  let real;
61154
61120
  try {
61155
- real = fs63.realpathSync(path70.join(dir, BIN_NAME));
61121
+ real = fs64.realpathSync(path71.join(dir, BIN_NAME));
61156
61122
  } catch {
61157
61123
  continue;
61158
61124
  }
@@ -61162,15 +61128,15 @@ function probeGlobalCli(pathEnv) {
61162
61128
  return null;
61163
61129
  }
61164
61130
  function readOwnPackageVersion(entryPath) {
61165
- let dir = path70.dirname(entryPath);
61131
+ let dir = path71.dirname(entryPath);
61166
61132
  for (let i = 0; i < MAX_PARENT_HOPS; i++) {
61167
61133
  try {
61168
- const raw = fs63.readFileSync(path70.join(dir, "package.json"), "utf8");
61134
+ const raw = fs64.readFileSync(path71.join(dir, "package.json"), "utf8");
61169
61135
  const pkg = JSON.parse(raw);
61170
61136
  if (pkg.name !== PKG_NAME) return null;
61171
61137
  return typeof pkg.version === "string" && pkg.version ? pkg.version : null;
61172
61138
  } catch {
61173
- const parent = path70.dirname(dir);
61139
+ const parent = path71.dirname(dir);
61174
61140
  if (parent === dir) return null;
61175
61141
  dir = parent;
61176
61142
  }
@@ -65062,6 +65028,10 @@ async function startDaemon(config) {
65062
65028
  }
65063
65029
  }
65064
65030
  });
65031
+ const droppedSeed = dropSeededProjects({ dataDir: config.dataDir });
65032
+ if (!droppedSeed.skipped) {
65033
+ logger.info("projects.seed-dropped", { dropped: droppedSeed.dropped, backup: droppedSeed.backup });
65034
+ }
65065
65035
  const projectsStore = new ProjectsStore({
65066
65036
  file: import_node_path68.default.join(config.dataDir, "projects.json"),
65067
65037
  clawdDir: config.dataDir,
@@ -65145,7 +65115,9 @@ async function startDaemon(config) {
65145
65115
  codexHomeFor: (cwd) => resolveCodexHome({
65146
65116
  cwd,
65147
65117
  personaRoot: import_node_path68.default.join(config.dataDir, "personas"),
65148
- projectPaths: projectsStore.list().map((x) => x.path),
65118
+ // 必须用 listMerged(Codex registry ∪ 叠加层):只用本地 list() 的话,用户在
65119
+ // Codex 里建的 project 不在表里,在它下面开的会话会被误判成隔离 → Codex 侧看不到
65120
+ projectPaths: projectsStore.listMerged().map((x) => x.path),
65149
65121
  sharedHome: import_node_path68.default.join(import_node_os24.default.homedir(), ".codex"),
65150
65122
  isolatedHome: codexIsolatedHome
65151
65123
  })