@clawos-dev/clawd 0.2.371 → 0.2.373

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.
Files changed (2) hide show
  1. package/dist/cli.cjs +322 -183
  2. package/package.json +1 -1
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: sep5 } = 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,7 +11258,7 @@ 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) {
@@ -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;
@@ -50229,8 +50229,8 @@ function turnStartInput(text) {
50229
50229
  const items = [];
50230
50230
  let leftover = text;
50231
50231
  for (const m2 of text.matchAll(SKILL_RE)) {
50232
- const [marker, name, path85] = m2;
50233
- items.push({ type: "skill", name, path: path85 });
50232
+ const [marker, name, path86] = m2;
50233
+ items.push({ type: "skill", name, path: path86 });
50234
50234
  leftover = leftover.replace(marker, "");
50235
50235
  }
50236
50236
  for (const m2 of text.matchAll(ATTACHMENT_RE2)) {
@@ -50493,7 +50493,7 @@ function stringValue2(value) {
50493
50493
  // src/tools/codex-app-server-query.ts
50494
50494
  var import_node_child_process5 = require("child_process");
50495
50495
  var DEFAULT_CODEX_QUERY_TIMEOUT_MS = 8e3;
50496
- async function queryCodexAppServer(cwd, method, params, deps = {}) {
50496
+ async function withCodexAppServerClient(cwd, operation, run, deps = {}) {
50497
50497
  const cmd = process.env.CODEX_BIN ?? "codex";
50498
50498
  const args = ["app-server", "--listen", "stdio://"];
50499
50499
  const proc = deps.spawnOverride ? deps.spawnOverride(cmd, args, cwd) : (0, import_node_child_process5.spawn)(cmd, args, { cwd, env: process.env, stdio: ["pipe", "pipe", "pipe"] });
@@ -50502,7 +50502,7 @@ async function queryCodexAppServer(cwd, method, params, deps = {}) {
50502
50502
  let timer;
50503
50503
  const timeout = new Promise((_2, reject) => {
50504
50504
  timer = setTimeout(
50505
- () => reject(new Error(`codex app-server ${method} timed out after ${timeoutMs}ms`)),
50505
+ () => reject(new Error(`codex app-server ${operation} timed out after ${timeoutMs}ms`)),
50506
50506
  timeoutMs
50507
50507
  );
50508
50508
  proc.on(
@@ -50522,12 +50522,20 @@ async function queryCodexAppServer(cwd, method, params, deps = {}) {
50522
50522
  timeout
50523
50523
  ]);
50524
50524
  deps.beforeRequest?.(client);
50525
- return await Promise.race([client.request(method, params), timeout]);
50525
+ return await Promise.race([run(client), timeout]);
50526
50526
  } finally {
50527
50527
  if (timer) clearTimeout(timer);
50528
50528
  if (proc.exitCode === null && proc.signalCode === null) proc.kill("SIGTERM");
50529
50529
  }
50530
50530
  }
50531
+ async function queryCodexAppServer(cwd, method, params, deps = {}) {
50532
+ return withCodexAppServerClient(
50533
+ cwd,
50534
+ method,
50535
+ (client) => client.request(method, params),
50536
+ deps
50537
+ );
50538
+ }
50531
50539
 
50532
50540
  // src/tools/codex-model-list.ts
50533
50541
  var CODEX_CONTEXT_WINDOW = 258400;
@@ -54097,11 +54105,73 @@ function threadItems(thread) {
54097
54105
  }
54098
54106
  return items;
54099
54107
  }
54100
- function threadMessages(thread) {
54108
+ function threadMessages(thread, subagentResults = /* @__PURE__ */ new Map()) {
54101
54109
  const messages = [];
54102
- for (const item of threadItems(thread)) messages.push(...threadItemToHistoryMessages(item));
54110
+ for (const item of threadItems(thread)) {
54111
+ messages.push(...threadItemToHistoryMessages(item));
54112
+ const value = rec2(item);
54113
+ const started = value && nativeSubagentStart(value);
54114
+ const result = started && subagentResults.get(started.toolUseId);
54115
+ if (result) messages.push(result);
54116
+ }
54103
54117
  return messages;
54104
54118
  }
54119
+ function threadFromReadResponse(value, threadId) {
54120
+ const res = rec2(value);
54121
+ const thread = res && rec2(res.thread);
54122
+ if (!thread) throw new Error(`Codex thread/read returned no thread for ${threadId}`);
54123
+ return thread;
54124
+ }
54125
+ async function readThreadWithClient(client, threadId, timeoutMs) {
54126
+ const request = client.request("thread/read", { threadId, includeTurns: true });
54127
+ let timer;
54128
+ const response = timeoutMs === void 0 ? await request : await Promise.race([
54129
+ request,
54130
+ new Promise((_2, reject) => {
54131
+ timer = setTimeout(
54132
+ () => reject(
54133
+ new Error(
54134
+ `Codex child thread/read ${threadId} timed out after ${timeoutMs}ms`
54135
+ )
54136
+ ),
54137
+ timeoutMs
54138
+ );
54139
+ })
54140
+ ]).finally(() => {
54141
+ if (timer) clearTimeout(timer);
54142
+ });
54143
+ return threadFromReadResponse(response, threadId);
54144
+ }
54145
+ function terminalSubagentResult(started, child, parentThreadId) {
54146
+ const actualId = str2(child.id);
54147
+ const actualParentThreadId = str2(child.parentThreadId);
54148
+ if (actualId !== started.agentId || actualParentThreadId !== parentThreadId) {
54149
+ throw new Error(
54150
+ `Codex subagent thread ${started.agentId} does not belong to parent thread ${parentThreadId} (returned id ${actualId ?? "missing"}, parent ${actualParentThreadId ?? "missing"})`
54151
+ );
54152
+ }
54153
+ const turns = Array.isArray(child.turns) ? child.turns : [];
54154
+ for (const value of turns) {
54155
+ const turn = rec2(value);
54156
+ const status = str2(turn?.status);
54157
+ if (status === "completed") {
54158
+ return {
54159
+ kind: "tool_result",
54160
+ toolUseId: started.toolUseId
54161
+ };
54162
+ }
54163
+ if (status === "failed" || status === "interrupted") {
54164
+ const rawError = turn?.error;
54165
+ const error = str2(rawError) ?? str2(rec2(rawError)?.message);
54166
+ return {
54167
+ kind: "tool_result",
54168
+ toolUseId: started.toolUseId,
54169
+ error: error ?? `Codex subagent ${status}`
54170
+ };
54171
+ }
54172
+ }
54173
+ return void 0;
54174
+ }
54105
54175
  function userInputText(content) {
54106
54176
  if (!Array.isArray(content)) return "";
54107
54177
  return content.map((c) => {
@@ -54211,8 +54281,43 @@ var CodexHistoryReader = class {
54211
54281
  return out;
54212
54282
  }
54213
54283
  async read(args) {
54214
- const thread = await this.readThread(args.cwd, args.toolSessionId);
54215
- const messages = threadMessages(thread);
54284
+ const queryTimeoutMs = this.deps.timeoutMs ?? DEFAULT_CODEX_QUERY_TIMEOUT_MS;
54285
+ const queryStartedAt = Date.now();
54286
+ const messages = await withCodexAppServerClient(
54287
+ args.cwd,
54288
+ "history/read",
54289
+ async (client) => {
54290
+ const parent = await readThreadWithClient(client, args.toolSessionId);
54291
+ const starts = threadItems(parent).map((item) => {
54292
+ const value = rec2(item);
54293
+ return value && nativeSubagentStart(value);
54294
+ }).filter((value) => value !== void 0);
54295
+ const results = /* @__PURE__ */ new Map();
54296
+ const childTimeoutMs = Math.floor(
54297
+ (queryTimeoutMs - (Date.now() - queryStartedAt)) / 2
54298
+ );
54299
+ await Promise.all(
54300
+ starts.map(async (started) => {
54301
+ try {
54302
+ if (childTimeoutMs <= 0) {
54303
+ throw new Error(`Codex child thread/read ${started.agentId} timed out before request`);
54304
+ }
54305
+ const child = await readThreadWithClient(client, started.agentId, childTimeoutMs);
54306
+ const result = terminalSubagentResult(started, child, args.toolSessionId);
54307
+ if (result) results.set(started.toolUseId, result);
54308
+ } catch (error) {
54309
+ this.deps.logger?.warn("codex subagent history terminal unavailable", {
54310
+ parentThreadId: args.toolSessionId,
54311
+ childThreadId: started.agentId,
54312
+ message: error.message
54313
+ });
54314
+ }
54315
+ })
54316
+ );
54317
+ return threadMessages(parent, results);
54318
+ },
54319
+ this.deps
54320
+ );
54216
54321
  const total = messages.length;
54217
54322
  const limit = args.limit ?? total;
54218
54323
  const offset = typeof args.offset === "number" ? Math.min(Math.max(0, args.offset), total) : Math.max(0, total - limit);
@@ -54254,17 +54359,15 @@ var CodexHistoryReader = class {
54254
54359
  return [];
54255
54360
  }
54256
54361
  async readThread(cwd, threadId) {
54257
- const res = rec2(
54362
+ return threadFromReadResponse(
54258
54363
  await queryCodexAppServer(
54259
54364
  cwd,
54260
54365
  "thread/read",
54261
54366
  { threadId, includeTurns: true },
54262
54367
  this.deps
54263
- )
54368
+ ),
54369
+ threadId
54264
54370
  );
54265
- const thread = res && rec2(res.thread);
54266
- if (!thread) throw new Error(`Codex thread/read returned no thread for ${threadId}`);
54267
- return thread;
54268
54371
  }
54269
54372
  };
54270
54373
 
@@ -54284,13 +54387,13 @@ function mapSkillsListResponse(res) {
54284
54387
  const r = s ?? {};
54285
54388
  const name = str3(r.name);
54286
54389
  if (!name) continue;
54287
- const path85 = str3(r.path);
54390
+ const path86 = str3(r.path);
54288
54391
  const description = str3(r.description);
54289
54392
  const isPlugin = name.includes(":");
54290
54393
  out.push({
54291
54394
  name,
54292
54395
  source: isPlugin ? "plugin" : "project",
54293
- ...path85 ? { path: path85 } : {},
54396
+ ...path86 ? { path: path86 } : {},
54294
54397
  ...description ? { description } : {},
54295
54398
  ...isPlugin ? { plugin: name.split(":")[0] } : {}
54296
54399
  });
@@ -56392,6 +56495,36 @@ function rmdirIfEmpty(p2) {
56392
56495
  }
56393
56496
  }
56394
56497
 
56498
+ // src/migrations/2026-08-18-drop-seeded-projects.ts
56499
+ var fs44 = __toESM(require("fs"), 1);
56500
+ var path45 = __toESM(require("path"), 1);
56501
+ var DROP_SEEDED_PROJECTS_FLAG = ".projects-seed-dropped.v1.done";
56502
+ function dropSeededProjects(opts) {
56503
+ fs44.mkdirSync(opts.dataDir, { recursive: true });
56504
+ const flag = path45.join(opts.dataDir, DROP_SEEDED_PROJECTS_FLAG);
56505
+ if (fs44.existsSync(flag)) return { skipped: true, dropped: 0, backup: null };
56506
+ const file = path45.join(opts.dataDir, "projects.json");
56507
+ let raw = null;
56508
+ let dropped = 0;
56509
+ try {
56510
+ raw = fs44.readFileSync(file, "utf8");
56511
+ dropped = JSON.parse(raw).projects?.length ?? 0;
56512
+ } catch {
56513
+ }
56514
+ let backup = null;
56515
+ if (raw != null && dropped > 0) {
56516
+ const dir = path45.join(opts.dataDir, "backups");
56517
+ fs44.mkdirSync(dir, { recursive: true });
56518
+ backup = path45.join(dir, `projects.seed-dropped.${(opts.now ?? Date.now)()}.json`);
56519
+ fs44.writeFileSync(backup, raw);
56520
+ }
56521
+ if (raw != null || dropped > 0) {
56522
+ fs44.writeFileSync(file, JSON.stringify({ projects: [] }, null, 2));
56523
+ }
56524
+ fs44.writeFileSync(flag, (/* @__PURE__ */ new Date()).toISOString());
56525
+ return { skipped: false, dropped, backup };
56526
+ }
56527
+
56395
56528
  // src/transport/http-router.ts
56396
56529
  var import_node_fs34 = __toESM(require("fs"), 1);
56397
56530
  var import_node_path38 = __toESM(require("path"), 1);
@@ -58554,9 +58687,9 @@ var CentralClientError = class extends Error {
58554
58687
  code;
58555
58688
  cause;
58556
58689
  };
58557
- async function centralRequest(opts, path85, init) {
58690
+ async function centralRequest(opts, path86, init) {
58558
58691
  const f = opts.fetchImpl ?? globalThis.fetch;
58559
- const url = `${opts.api.replace(/\/+$/, "")}${path85}`;
58692
+ const url = `${opts.api.replace(/\/+$/, "")}${path86}`;
58560
58693
  const ctrl = new AbortController();
58561
58694
  const timer = setTimeout(() => ctrl.abort(), opts.timeoutMs ?? 15e3);
58562
58695
  let res;
@@ -58750,8 +58883,8 @@ function verifyConnectToken(args) {
58750
58883
  }
58751
58884
 
58752
58885
  // src/feishu-auth/server-key.ts
58753
- var fs57 = __toESM(require("fs"), 1);
58754
- var path60 = __toESM(require("path"), 1);
58886
+ var fs58 = __toESM(require("fs"), 1);
58887
+ var path61 = __toESM(require("path"), 1);
58755
58888
  var FILE_NAME2 = "server-signing-key.json";
58756
58889
  var ServerKeyStore = class {
58757
58890
  constructor(dataDir) {
@@ -58759,12 +58892,12 @@ var ServerKeyStore = class {
58759
58892
  }
58760
58893
  dataDir;
58761
58894
  filePath() {
58762
- return path60.join(this.dataDir, FILE_NAME2);
58895
+ return path61.join(this.dataDir, FILE_NAME2);
58763
58896
  }
58764
58897
  /** 读缓存的公钥;无缓存 / 损坏 → null(调用方决定是否触发拉取) */
58765
58898
  read() {
58766
58899
  try {
58767
- const raw = fs57.readFileSync(this.filePath(), "utf8");
58900
+ const raw = fs58.readFileSync(this.filePath(), "utf8");
58768
58901
  const parsed = JSON.parse(raw);
58769
58902
  if (typeof parsed.publicKeyPem === "string" && parsed.publicKeyPem.includes("PUBLIC KEY")) {
58770
58903
  return parsed.publicKeyPem;
@@ -58779,12 +58912,12 @@ var ServerKeyStore = class {
58779
58912
  publicKeyPem,
58780
58913
  fetchedAt: (/* @__PURE__ */ new Date()).toISOString()
58781
58914
  };
58782
- fs57.mkdirSync(this.dataDir, { recursive: true });
58783
- fs57.writeFileSync(this.filePath(), JSON.stringify(content, null, 2), { mode: 384 });
58915
+ fs58.mkdirSync(this.dataDir, { recursive: true });
58916
+ fs58.writeFileSync(this.filePath(), JSON.stringify(content, null, 2), { mode: 384 });
58784
58917
  }
58785
58918
  clear() {
58786
58919
  try {
58787
- fs57.unlinkSync(this.filePath());
58920
+ fs58.unlinkSync(this.filePath());
58788
58921
  } catch {
58789
58922
  }
58790
58923
  }
@@ -59676,7 +59809,7 @@ function buildPermissionHandlers(deps) {
59676
59809
  }
59677
59810
 
59678
59811
  // src/handlers/history.ts
59679
- var path65 = __toESM(require("path"), 1);
59812
+ var path66 = __toESM(require("path"), 1);
59680
59813
  init_protocol();
59681
59814
 
59682
59815
  // src/session/recent-dirs.ts
@@ -59694,7 +59827,7 @@ function listRecentDirs(store, limit = 50) {
59694
59827
  }
59695
59828
 
59696
59829
  // src/permission/persona-paths.ts
59697
- var path64 = __toESM(require("path"), 1);
59830
+ var path65 = __toESM(require("path"), 1);
59698
59831
  function getAllowedPersonaIds(grants, action) {
59699
59832
  const ids = /* @__PURE__ */ new Set();
59700
59833
  for (const g2 of grants) {
@@ -59707,42 +59840,42 @@ function getAllowedPersonaIds(grants, action) {
59707
59840
  return ids;
59708
59841
  }
59709
59842
  function isGuestPathAllowed(grants, absPath, personaRoot, action = "read", userWorkDir) {
59710
- const target = path64.resolve(absPath);
59843
+ const target = path65.resolve(absPath);
59711
59844
  if (userWorkDir) {
59712
- const u = path64.resolve(userWorkDir);
59713
- const usep = u.endsWith(path64.sep) ? "" : path64.sep;
59845
+ const u = path65.resolve(userWorkDir);
59846
+ const usep = u.endsWith(path65.sep) ? "" : path65.sep;
59714
59847
  if (target === u || target.startsWith(u + usep)) return true;
59715
59848
  }
59716
- const root = path64.resolve(personaRoot);
59717
- const sep5 = root.endsWith(path64.sep) ? "" : path64.sep;
59849
+ const root = path65.resolve(personaRoot);
59850
+ const sep5 = root.endsWith(path65.sep) ? "" : path65.sep;
59718
59851
  if (!target.startsWith(root + sep5)) return false;
59719
- const rel = path64.relative(root, target);
59852
+ const rel = path65.relative(root, target);
59720
59853
  if (!rel || rel.startsWith("..")) return false;
59721
- const personaId2 = rel.split(path64.sep)[0];
59854
+ const personaId2 = rel.split(path65.sep)[0];
59722
59855
  if (!personaId2) return false;
59723
59856
  const allowed = getAllowedPersonaIds(grants, action);
59724
59857
  if (allowed === "*") return true;
59725
59858
  return allowed.has(personaId2);
59726
59859
  }
59727
59860
  function personaIdFromPath(absPath, personaRoot) {
59728
- const root = path64.resolve(personaRoot);
59729
- const target = path64.resolve(absPath);
59730
- const sep5 = root.endsWith(path64.sep) ? "" : path64.sep;
59861
+ const root = path65.resolve(personaRoot);
59862
+ const target = path65.resolve(absPath);
59863
+ const sep5 = root.endsWith(path65.sep) ? "" : path65.sep;
59731
59864
  if (!target.startsWith(root + sep5)) return null;
59732
- const rel = path64.relative(root, target);
59865
+ const rel = path65.relative(root, target);
59733
59866
  if (!rel || rel.startsWith("..")) return null;
59734
- const id = rel.split(path64.sep)[0];
59867
+ const id = rel.split(path65.sep)[0];
59735
59868
  return id || null;
59736
59869
  }
59737
59870
  function isPathWithin(dir, absPath) {
59738
- const d = path64.resolve(dir);
59739
- const t = path64.resolve(absPath);
59740
- const sep5 = d.endsWith(path64.sep) ? "" : path64.sep;
59871
+ const d = path65.resolve(dir);
59872
+ const t = path65.resolve(absPath);
59873
+ const sep5 = d.endsWith(path65.sep) ? "" : path65.sep;
59741
59874
  return t === d || t.startsWith(d + sep5);
59742
59875
  }
59743
59876
  function isPathInGuestBoundary(personaRoot, personaId2, userWorkDir, absPath) {
59744
59877
  if (userWorkDir && isPathWithin(userWorkDir, absPath)) return true;
59745
- return personaIdFromPath(path64.resolve(absPath), personaRoot) === personaId2;
59878
+ return personaIdFromPath(path65.resolve(absPath), personaRoot) === personaId2;
59746
59879
  }
59747
59880
 
59748
59881
  // src/handlers/history.ts
@@ -59795,7 +59928,7 @@ function buildHistoryHandlers(deps) {
59795
59928
  if (!pid) return false;
59796
59929
  return isGuestPathAllowed(
59797
59930
  ctx.grants,
59798
- path65.join(personaRoot, pid),
59931
+ path66.join(personaRoot, pid),
59799
59932
  personaRoot,
59800
59933
  "read",
59801
59934
  userWorkDir
@@ -59807,7 +59940,7 @@ function buildHistoryHandlers(deps) {
59807
59940
  };
59808
59941
  const list = async (frame, _client, ctx) => {
59809
59942
  const args = HistoryListArgs.parse(frame);
59810
- assertGuestPath(ctx, path65.resolve(args.projectPath), personaRoot, "history:list", usersRoot);
59943
+ assertGuestPath(ctx, path66.resolve(args.projectPath), personaRoot, "history:list", usersRoot);
59811
59944
  const sessions = await history.listSessions(args);
59812
59945
  return { response: { type: "history:list", sessions } };
59813
59946
  };
@@ -59855,14 +59988,14 @@ function buildHistoryHandlers(deps) {
59855
59988
  };
59856
59989
  const subagents = async (frame, _client, ctx) => {
59857
59990
  const args = HistorySubagentsArgs.parse(frame);
59858
- assertGuestPath(ctx, path65.resolve(args.cwd), personaRoot, "history:subagents", usersRoot);
59991
+ assertGuestPath(ctx, path66.resolve(args.cwd), personaRoot, "history:subagents", usersRoot);
59859
59992
  assertGuestOwnsToolSession(ctx, args.toolSessionId, "history:subagents");
59860
59993
  const subs = await historyReaderForToolSession(args.toolSessionId).listSubagents(args);
59861
59994
  return { response: { type: "history:subagents", subagents: subs } };
59862
59995
  };
59863
59996
  const subagentRead = async (frame, _client, ctx) => {
59864
59997
  const args = HistorySubagentReadArgs.parse(frame);
59865
- assertGuestPath(ctx, path65.resolve(args.cwd), personaRoot, "history:subagent-read", usersRoot);
59998
+ assertGuestPath(ctx, path66.resolve(args.cwd), personaRoot, "history:subagent-read", usersRoot);
59866
59999
  assertGuestOwnsToolSession(ctx, args.toolSessionId, "history:subagent-read");
59867
60000
  const res = await historyReaderForToolSession(args.toolSessionId).readSubagent(args);
59868
60001
  return { response: { type: "history:subagent-read", ...res } };
@@ -59872,7 +60005,7 @@ function buildHistoryHandlers(deps) {
59872
60005
  if (ctx?.principal.kind === "guest" && personaRoot) {
59873
60006
  const userWorkDir = usersRoot ? deriveUserWorkDir(ctx.principal.id, usersRoot) : void 0;
59874
60007
  const filtered = dirs.filter(
59875
- (d) => isGuestPathAllowed(ctx.grants, path65.resolve(d.cwd), personaRoot, "read", userWorkDir)
60008
+ (d) => isGuestPathAllowed(ctx.grants, path66.resolve(d.cwd), personaRoot, "read", userWorkDir)
59876
60009
  );
59877
60010
  return { response: { type: "history:recentDirs", dirs: filtered } };
59878
60011
  }
@@ -59889,17 +60022,17 @@ function buildHistoryHandlers(deps) {
59889
60022
  }
59890
60023
 
59891
60024
  // src/handlers/projects.ts
59892
- var fs61 = __toESM(require("fs"), 1);
60025
+ var fs62 = __toESM(require("fs"), 1);
59893
60026
  var os19 = __toESM(require("os"), 1);
59894
- var path66 = __toESM(require("path"), 1);
60027
+ var path67 = __toESM(require("path"), 1);
59895
60028
  var import_node_child_process13 = require("child_process");
59896
60029
  init_protocol();
59897
- var DEFAULT_PROJECTS_ROOT = path66.join(os19.homedir(), "Documents", "ChatGPT");
60030
+ var DEFAULT_PROJECTS_ROOT = path67.join(os19.homedir(), "Documents", "ChatGPT");
59898
60031
  function allocateDir(root, name) {
59899
- let candidate = path66.join(root, name);
60032
+ let candidate = path67.join(root, name);
59900
60033
  let n = 2;
59901
- while (fs61.existsSync(candidate)) {
59902
- candidate = path66.join(root, `${name} ${n}`);
60034
+ while (fs62.existsSync(candidate)) {
60035
+ candidate = path67.join(root, `${name} ${n}`);
59903
60036
  n += 1;
59904
60037
  }
59905
60038
  return candidate;
@@ -59920,7 +60053,7 @@ function buildProjectHandlers(deps) {
59920
60053
  let target;
59921
60054
  if (args.path) {
59922
60055
  try {
59923
- if (!fs61.statSync(args.path).isDirectory()) throw new Error("not dir");
60056
+ if (!fs62.statSync(args.path).isDirectory()) throw new Error("not dir");
59924
60057
  } catch {
59925
60058
  throw new ClawdError(ERROR_CODES.INVALID_CWD, `not a directory: ${args.path}`);
59926
60059
  }
@@ -59928,15 +60061,15 @@ function buildProjectHandlers(deps) {
59928
60061
  } else {
59929
60062
  const name = args.name;
59930
60063
  try {
59931
- fs61.mkdirSync(root, { recursive: true });
60064
+ fs62.mkdirSync(root, { recursive: true });
59932
60065
  target = allocateDir(root, name);
59933
- fs61.mkdirSync(target);
60066
+ fs62.mkdirSync(target);
59934
60067
  } catch (err) {
59935
60068
  throw new ClawdError(ERROR_CODES.INVALID_CWD, `\u521B\u5EFA\u9879\u76EE\u76EE\u5F55\u5931\u8D25: ${String(err)}`);
59936
60069
  }
59937
60070
  const git = (0, import_node_child_process13.spawnSync)("git", ["init"], { cwd: target, stdio: "ignore" });
59938
60071
  if (git.status !== 0) {
59939
- fs61.rmSync(target, { recursive: true, force: true });
60072
+ fs62.rmSync(target, { recursive: true, force: true });
59940
60073
  throw new ClawdError(
59941
60074
  ERROR_CODES.INVALID_CWD,
59942
60075
  `git init \u5931\u8D25\uFF08${git.error ? String(git.error) : `exit ${git.status}`}\uFF09: ${target}`
@@ -59956,7 +60089,7 @@ function buildProjectHandlers(deps) {
59956
60089
  }
59957
60090
 
59958
60091
  // src/handlers/workspace.ts
59959
- var path67 = __toESM(require("path"), 1);
60092
+ var path68 = __toESM(require("path"), 1);
59960
60093
  var os20 = __toESM(require("os"), 1);
59961
60094
  init_protocol();
59962
60095
  init_protocol();
@@ -59998,22 +60131,22 @@ function buildWorkspaceHandlers(deps) {
59998
60131
  const args = WorkspaceListArgs.parse(frame);
59999
60132
  const isGuest = ctx?.principal.kind === "guest";
60000
60133
  const fallbackCwd = isGuest && personaRoot ? personaRoot : os20.homedir();
60001
- const resolvedCwd = path67.resolve(args.cwd ?? fallbackCwd);
60002
- const target = args.path ? path67.resolve(resolvedCwd, args.path) : resolvedCwd;
60134
+ const resolvedCwd = path68.resolve(args.cwd ?? fallbackCwd);
60135
+ const target = args.path ? path68.resolve(resolvedCwd, args.path) : resolvedCwd;
60003
60136
  assertGuestPath2(ctx, target, personaRoot, "workspace:list", usersRoot);
60004
60137
  const res = workspace.list({ ...args, cwd: resolvedCwd });
60005
60138
  return { response: { type: "workspace:list", ...res } };
60006
60139
  };
60007
60140
  const read = async (frame, _client, ctx) => {
60008
60141
  const args = WorkspaceReadArgs.parse(frame);
60009
- const target = path67.isAbsolute(args.path) ? path67.resolve(args.path) : path67.resolve(args.cwd, args.path);
60142
+ const target = path68.isAbsolute(args.path) ? path68.resolve(args.path) : path68.resolve(args.cwd, args.path);
60010
60143
  assertGuestPath2(ctx, target, personaRoot, "workspace:read", usersRoot);
60011
60144
  const res = workspace.read(args);
60012
60145
  return { response: { type: "workspace:read", ...res } };
60013
60146
  };
60014
60147
  const skillsList = async (frame, _client, ctx) => {
60015
60148
  const args = SkillsListArgs.parse(frame);
60016
- const cwdAbs = path67.resolve(args.cwd);
60149
+ const cwdAbs = path68.resolve(args.cwd);
60017
60150
  assertGuestPath2(ctx, cwdAbs, personaRoot, "skills:list", usersRoot);
60018
60151
  const list2 = await getSkillsForTool(args.tool ?? "claude", cwdAbs);
60019
60152
  if (ctx?.principal.kind === "guest" && personaRoot) {
@@ -60025,7 +60158,7 @@ function buildWorkspaceHandlers(deps) {
60025
60158
  };
60026
60159
  const agentsList = async (frame, _client, ctx) => {
60027
60160
  const args = AgentsListArgs.parse(frame);
60028
- const cwdAbs = path67.resolve(args.cwd);
60161
+ const cwdAbs = path68.resolve(args.cwd);
60029
60162
  assertGuestPath2(ctx, cwdAbs, personaRoot, "agents:list", usersRoot);
60030
60163
  if (args.tool === "codex") {
60031
60164
  return { response: { type: "agents:list", agents: [] } };
@@ -60047,7 +60180,7 @@ function buildWorkspaceHandlers(deps) {
60047
60180
  }
60048
60181
 
60049
60182
  // src/handlers/git.ts
60050
- var path69 = __toESM(require("path"), 1);
60183
+ var path70 = __toESM(require("path"), 1);
60051
60184
  init_protocol();
60052
60185
  init_protocol();
60053
60186
 
@@ -60134,7 +60267,7 @@ async function listGitBranches(cwd) {
60134
60267
  function assertGuestCwd(ctx, cwd, personaRoot, method, usersRoot) {
60135
60268
  if (!ctx || ctx.principal.kind !== "guest" || !personaRoot) return;
60136
60269
  const userWorkDir = usersRoot ? deriveUserWorkDir(ctx.principal.id, usersRoot) : void 0;
60137
- if (!isGuestPathAllowed(ctx.grants, path69.resolve(cwd), personaRoot, "read", userWorkDir)) {
60270
+ if (!isGuestPathAllowed(ctx.grants, path70.resolve(cwd), personaRoot, "read", userWorkDir)) {
60138
60271
  throw new ClawdError(
60139
60272
  ERROR_CODES.UNAUTHORIZED,
60140
60273
  `guest ${ctx.principal.id} cannot ${method} cwd ${cwd}`
@@ -61035,21 +61168,21 @@ function computeMethodAccess(args) {
61035
61168
  }
61036
61169
 
61037
61170
  // src/version.ts
61038
- var version = "0.2.371".length > 0 ? "0.2.371" : "dev";
61171
+ var version = "0.2.373".length > 0 ? "0.2.373" : "dev";
61039
61172
 
61040
61173
  // src/cli-probe/probe.ts
61041
- var fs63 = __toESM(require("fs"), 1);
61042
- var path70 = __toESM(require("path"), 1);
61174
+ var fs64 = __toESM(require("fs"), 1);
61175
+ var path71 = __toESM(require("path"), 1);
61043
61176
  var PKG_NAME = "@clawos-dev/clawd";
61044
61177
  var BIN_NAME = "clawd";
61045
61178
  var MAX_PARENT_HOPS = 5;
61046
61179
  function probeGlobalCli(pathEnv) {
61047
61180
  if (!pathEnv) return null;
61048
- for (const dir of pathEnv.split(path70.delimiter)) {
61181
+ for (const dir of pathEnv.split(path71.delimiter)) {
61049
61182
  if (!dir) continue;
61050
61183
  let real;
61051
61184
  try {
61052
- real = fs63.realpathSync(path70.join(dir, BIN_NAME));
61185
+ real = fs64.realpathSync(path71.join(dir, BIN_NAME));
61053
61186
  } catch {
61054
61187
  continue;
61055
61188
  }
@@ -61059,15 +61192,15 @@ function probeGlobalCli(pathEnv) {
61059
61192
  return null;
61060
61193
  }
61061
61194
  function readOwnPackageVersion(entryPath) {
61062
- let dir = path70.dirname(entryPath);
61195
+ let dir = path71.dirname(entryPath);
61063
61196
  for (let i = 0; i < MAX_PARENT_HOPS; i++) {
61064
61197
  try {
61065
- const raw = fs63.readFileSync(path70.join(dir, "package.json"), "utf8");
61198
+ const raw = fs64.readFileSync(path71.join(dir, "package.json"), "utf8");
61066
61199
  const pkg = JSON.parse(raw);
61067
61200
  if (pkg.name !== PKG_NAME) return null;
61068
61201
  return typeof pkg.version === "string" && pkg.version ? pkg.version : null;
61069
61202
  } catch {
61070
- const parent = path70.dirname(dir);
61203
+ const parent = path71.dirname(dir);
61071
61204
  if (parent === dir) return null;
61072
61205
  dir = parent;
61073
61206
  }
@@ -64959,6 +65092,10 @@ async function startDaemon(config) {
64959
65092
  }
64960
65093
  }
64961
65094
  });
65095
+ const droppedSeed = dropSeededProjects({ dataDir: config.dataDir });
65096
+ if (!droppedSeed.skipped) {
65097
+ logger.info("projects.seed-dropped", { dropped: droppedSeed.dropped, backup: droppedSeed.backup });
65098
+ }
64962
65099
  const projectsStore = new ProjectsStore({
64963
65100
  file: import_node_path68.default.join(config.dataDir, "projects.json"),
64964
65101
  clawdDir: config.dataDir,
@@ -65037,12 +65174,14 @@ async function startDaemon(config) {
65037
65174
  "codex",
65038
65175
  new CodexAdapter({
65039
65176
  logger,
65040
- historyReader: new CodexHistoryReader(),
65177
+ historyReader: new CodexHistoryReader({ logger }),
65041
65178
  // projectPaths 每次调用现取 —— 用户新建 project 后立即生效,不用重启 daemon
65042
65179
  codexHomeFor: (cwd) => resolveCodexHome({
65043
65180
  cwd,
65044
65181
  personaRoot: import_node_path68.default.join(config.dataDir, "personas"),
65045
- projectPaths: projectsStore.list().map((x) => x.path),
65182
+ // 必须用 listMerged(Codex registry ∪ 叠加层):只用本地 list() 的话,用户在
65183
+ // Codex 里建的 project 不在表里,在它下面开的会话会被误判成隔离 → Codex 侧看不到
65184
+ projectPaths: projectsStore.listMerged().map((x) => x.path),
65046
65185
  sharedHome: import_node_path68.default.join(import_node_os24.default.homedir(), ".codex"),
65047
65186
  isolatedHome: codexIsolatedHome
65048
65187
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clawos-dev/clawd",
3
- "version": "0.2.371",
3
+ "version": "0.2.373",
4
4
  "description": "Standalone clawd daemon — Claude Code (and future Codex) session server over WebSocket",
5
5
  "type": "module",
6
6
  "license": "MIT",