@clawos-dev/clawd 0.2.45 → 0.2.46-beta.68.ed2b1e6

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 (41) hide show
  1. package/dist/cli.cjs +217 -115
  2. package/dist/persona-defaults/persona-knowledge-base/.claude/skills/karpathy-llm-wiki/SKILL.md +187 -0
  3. package/dist/persona-defaults/persona-knowledge-base/.claude/skills/karpathy-llm-wiki/references/archive-template.md +21 -0
  4. package/dist/persona-defaults/persona-knowledge-base/.claude/skills/karpathy-llm-wiki/references/article-template.md +20 -0
  5. package/dist/persona-defaults/persona-knowledge-base/.claude/skills/karpathy-llm-wiki/references/index-template.md +18 -0
  6. package/dist/persona-defaults/persona-knowledge-base/.claude/skills/karpathy-llm-wiki/references/raw-template.md +7 -0
  7. package/dist/persona-defaults/persona-knowledge-base/CLAUDE.md +105 -0
  8. package/dist/persona-defaults/persona-researcher/.claude/skills/deep-research/README.md +119 -0
  9. package/dist/persona-defaults/persona-researcher/.claude/skills/deep-research/SKILL.md +108 -0
  10. package/dist/persona-defaults/persona-researcher/.claude/skills/deep-research/reference/continuation.md +167 -0
  11. package/dist/persona-defaults/persona-researcher/.claude/skills/deep-research/reference/html-generation.md +103 -0
  12. package/dist/persona-defaults/persona-researcher/.claude/skills/deep-research/reference/methodology.md +421 -0
  13. package/dist/persona-defaults/persona-researcher/.claude/skills/deep-research/reference/quality-gates.md +192 -0
  14. package/dist/persona-defaults/persona-researcher/.claude/skills/deep-research/reference/report-assembly.md +130 -0
  15. package/dist/persona-defaults/persona-researcher/.claude/skills/deep-research/reference/weasyprint_guidelines.md +324 -0
  16. package/dist/persona-defaults/persona-researcher/.claude/skills/deep-research/requirements.txt +14 -0
  17. package/dist/persona-defaults/persona-researcher/.claude/skills/deep-research/schemas/claim.schema.json +49 -0
  18. package/dist/persona-defaults/persona-researcher/.claude/skills/deep-research/schemas/evidence.schema.json +43 -0
  19. package/dist/persona-defaults/persona-researcher/.claude/skills/deep-research/schemas/run_manifest.schema.json +97 -0
  20. package/dist/persona-defaults/persona-researcher/.claude/skills/deep-research/schemas/source.schema.json +49 -0
  21. package/dist/persona-defaults/persona-researcher/.claude/skills/deep-research/scripts/citation_manager.py +300 -0
  22. package/dist/persona-defaults/persona-researcher/.claude/skills/deep-research/scripts/evidence_store.py +205 -0
  23. package/dist/persona-defaults/persona-researcher/.claude/skills/deep-research/scripts/extract_claims.py +358 -0
  24. package/dist/persona-defaults/persona-researcher/.claude/skills/deep-research/scripts/md_to_html.py +330 -0
  25. package/dist/persona-defaults/persona-researcher/.claude/skills/deep-research/scripts/research_engine.py +584 -0
  26. package/dist/persona-defaults/persona-researcher/.claude/skills/deep-research/scripts/source_evaluator.py +292 -0
  27. package/dist/persona-defaults/persona-researcher/.claude/skills/deep-research/scripts/validate_report.py +354 -0
  28. package/dist/persona-defaults/persona-researcher/.claude/skills/deep-research/scripts/verify_citations.py +426 -0
  29. package/dist/persona-defaults/persona-researcher/.claude/skills/deep-research/scripts/verify_claim_support.py +344 -0
  30. package/dist/persona-defaults/persona-researcher/.claude/skills/deep-research/scripts/verify_html.py +220 -0
  31. package/dist/persona-defaults/persona-researcher/.claude/skills/deep-research/templates/mckinsey_report_template.html +443 -0
  32. package/dist/persona-defaults/persona-researcher/.claude/skills/deep-research/templates/report_template.md +414 -0
  33. package/dist/persona-defaults/persona-researcher/.claude/skills/deep-research/tests/fixtures/invalid_report.md +27 -0
  34. package/dist/persona-defaults/persona-researcher/.claude/skills/deep-research/tests/fixtures/valid_report.md +114 -0
  35. package/dist/persona-defaults/persona-researcher/.claude/skills/deep-research/tests/test_citation_manager.py +195 -0
  36. package/dist/persona-defaults/persona-researcher/.claude/skills/deep-research/tests/test_evidence_store.py +166 -0
  37. package/dist/persona-defaults/persona-researcher/.claude/skills/deep-research/tests/test_extract_claims.py +213 -0
  38. package/dist/persona-defaults/persona-researcher/.claude/skills/deep-research/tests/test_verify_claim_support.py +230 -0
  39. package/dist/persona-defaults/persona-researcher/CLAUDE.md +30 -0
  40. package/dist/persona-defaults/persona-researcher/skills-lock.json +11 -0
  41. package/package.json +2 -2
package/dist/cli.cjs CHANGED
@@ -296,8 +296,8 @@ var require_req = __commonJS({
296
296
  if (req.originalUrl) {
297
297
  _req.url = req.originalUrl;
298
298
  } else {
299
- const path23 = req.path;
300
- _req.url = typeof path23 === "string" ? path23 : req.url ? req.url.path || req.url : void 0;
299
+ const path24 = req.path;
300
+ _req.url = typeof path24 === "string" ? path24 : req.url ? req.url.path || req.url : void 0;
301
301
  }
302
302
  if (req.query) {
303
303
  _req.query = req.query;
@@ -462,14 +462,14 @@ var require_redact = __commonJS({
462
462
  }
463
463
  return obj;
464
464
  }
465
- function parsePath(path23) {
465
+ function parsePath(path24) {
466
466
  const parts = [];
467
467
  let current = "";
468
468
  let inBrackets = false;
469
469
  let inQuotes = false;
470
470
  let quoteChar = "";
471
- for (let i = 0; i < path23.length; i++) {
472
- const char = path23[i];
471
+ for (let i = 0; i < path24.length; i++) {
472
+ const char = path24[i];
473
473
  if (!inBrackets && char === ".") {
474
474
  if (current) {
475
475
  parts.push(current);
@@ -600,10 +600,10 @@ var require_redact = __commonJS({
600
600
  return current;
601
601
  }
602
602
  function redactPaths(obj, paths, censor, remove = false) {
603
- for (const path23 of paths) {
604
- const parts = parsePath(path23);
603
+ for (const path24 of paths) {
604
+ const parts = parsePath(path24);
605
605
  if (parts.includes("*")) {
606
- redactWildcardPath(obj, parts, censor, path23, remove);
606
+ redactWildcardPath(obj, parts, censor, path24, remove);
607
607
  } else {
608
608
  if (remove) {
609
609
  removeKey(obj, parts);
@@ -688,8 +688,8 @@ var require_redact = __commonJS({
688
688
  }
689
689
  } else {
690
690
  if (afterWildcard.includes("*")) {
691
- const wrappedCensor = typeof censor === "function" ? (value, path23) => {
692
- const fullPath = [...pathArray.slice(0, pathLength), ...path23];
691
+ const wrappedCensor = typeof censor === "function" ? (value, path24) => {
692
+ const fullPath = [...pathArray.slice(0, pathLength), ...path24];
693
693
  return censor(value, fullPath);
694
694
  } : censor;
695
695
  redactWildcardPath(current, afterWildcard, wrappedCensor, originalPath, remove);
@@ -724,8 +724,8 @@ var require_redact = __commonJS({
724
724
  return null;
725
725
  }
726
726
  const pathStructure = /* @__PURE__ */ new Map();
727
- for (const path23 of pathsToClone) {
728
- const parts = parsePath(path23);
727
+ for (const path24 of pathsToClone) {
728
+ const parts = parsePath(path24);
729
729
  let current = pathStructure;
730
730
  for (let i = 0; i < parts.length; i++) {
731
731
  const part = parts[i];
@@ -777,24 +777,24 @@ var require_redact = __commonJS({
777
777
  }
778
778
  return cloneSelectively(obj, pathStructure);
779
779
  }
780
- function validatePath(path23) {
781
- if (typeof path23 !== "string") {
780
+ function validatePath(path24) {
781
+ if (typeof path24 !== "string") {
782
782
  throw new Error("Paths must be (non-empty) strings");
783
783
  }
784
- if (path23 === "") {
784
+ if (path24 === "") {
785
785
  throw new Error("Invalid redaction path ()");
786
786
  }
787
- if (path23.includes("..")) {
788
- throw new Error(`Invalid redaction path (${path23})`);
787
+ if (path24.includes("..")) {
788
+ throw new Error(`Invalid redaction path (${path24})`);
789
789
  }
790
- if (path23.includes(",")) {
791
- throw new Error(`Invalid redaction path (${path23})`);
790
+ if (path24.includes(",")) {
791
+ throw new Error(`Invalid redaction path (${path24})`);
792
792
  }
793
793
  let bracketCount = 0;
794
794
  let inQuotes = false;
795
795
  let quoteChar = "";
796
- for (let i = 0; i < path23.length; i++) {
797
- const char = path23[i];
796
+ for (let i = 0; i < path24.length; i++) {
797
+ const char = path24[i];
798
798
  if ((char === '"' || char === "'") && bracketCount > 0) {
799
799
  if (!inQuotes) {
800
800
  inQuotes = true;
@@ -808,20 +808,20 @@ var require_redact = __commonJS({
808
808
  } else if (char === "]" && !inQuotes) {
809
809
  bracketCount--;
810
810
  if (bracketCount < 0) {
811
- throw new Error(`Invalid redaction path (${path23})`);
811
+ throw new Error(`Invalid redaction path (${path24})`);
812
812
  }
813
813
  }
814
814
  }
815
815
  if (bracketCount !== 0) {
816
- throw new Error(`Invalid redaction path (${path23})`);
816
+ throw new Error(`Invalid redaction path (${path24})`);
817
817
  }
818
818
  }
819
819
  function validatePaths(paths) {
820
820
  if (!Array.isArray(paths)) {
821
821
  throw new TypeError("paths must be an array");
822
822
  }
823
- for (const path23 of paths) {
824
- validatePath(path23);
823
+ for (const path24 of paths) {
824
+ validatePath(path24);
825
825
  }
826
826
  }
827
827
  function slowRedact(options = {}) {
@@ -989,8 +989,8 @@ var require_redaction = __commonJS({
989
989
  if (shape[k] === null) {
990
990
  o[k] = (value) => topCensor(value, [k]);
991
991
  } else {
992
- const wrappedCensor = typeof censor === "function" ? (value, path23) => {
993
- return censor(value, [k, ...path23]);
992
+ const wrappedCensor = typeof censor === "function" ? (value, path24) => {
993
+ return censor(value, [k, ...path24]);
994
994
  } : censor;
995
995
  o[k] = Redact({
996
996
  paths: shape[k],
@@ -1208,10 +1208,10 @@ var require_atomic_sleep = __commonJS({
1208
1208
  var require_sonic_boom = __commonJS({
1209
1209
  "../node_modules/.pnpm/sonic-boom@4.2.1/node_modules/sonic-boom/index.js"(exports2, module2) {
1210
1210
  "use strict";
1211
- var fs22 = require("fs");
1211
+ var fs23 = require("fs");
1212
1212
  var EventEmitter = require("events");
1213
1213
  var inherits = require("util").inherits;
1214
- var path23 = require("path");
1214
+ var path24 = require("path");
1215
1215
  var sleep = require_atomic_sleep();
1216
1216
  var assert = require("assert");
1217
1217
  var BUSY_WRITE_TIMEOUT = 100;
@@ -1265,20 +1265,20 @@ var require_sonic_boom = __commonJS({
1265
1265
  const mode = sonic.mode;
1266
1266
  if (sonic.sync) {
1267
1267
  try {
1268
- if (sonic.mkdir) fs22.mkdirSync(path23.dirname(file), { recursive: true });
1269
- const fd = fs22.openSync(file, flags, mode);
1268
+ if (sonic.mkdir) fs23.mkdirSync(path24.dirname(file), { recursive: true });
1269
+ const fd = fs23.openSync(file, flags, mode);
1270
1270
  fileOpened(null, fd);
1271
1271
  } catch (err) {
1272
1272
  fileOpened(err);
1273
1273
  throw err;
1274
1274
  }
1275
1275
  } else if (sonic.mkdir) {
1276
- fs22.mkdir(path23.dirname(file), { recursive: true }, (err) => {
1276
+ fs23.mkdir(path24.dirname(file), { recursive: true }, (err) => {
1277
1277
  if (err) return fileOpened(err);
1278
- fs22.open(file, flags, mode, fileOpened);
1278
+ fs23.open(file, flags, mode, fileOpened);
1279
1279
  });
1280
1280
  } else {
1281
- fs22.open(file, flags, mode, fileOpened);
1281
+ fs23.open(file, flags, mode, fileOpened);
1282
1282
  }
1283
1283
  }
1284
1284
  function SonicBoom(opts) {
@@ -1319,8 +1319,8 @@ var require_sonic_boom = __commonJS({
1319
1319
  this.flush = flushBuffer;
1320
1320
  this.flushSync = flushBufferSync;
1321
1321
  this._actualWrite = actualWriteBuffer;
1322
- fsWriteSync = () => fs22.writeSync(this.fd, this._writingBuf);
1323
- fsWrite = () => fs22.write(this.fd, this._writingBuf, this.release);
1322
+ fsWriteSync = () => fs23.writeSync(this.fd, this._writingBuf);
1323
+ fsWrite = () => fs23.write(this.fd, this._writingBuf, this.release);
1324
1324
  } else if (contentMode === void 0 || contentMode === kContentModeUtf8) {
1325
1325
  this._writingBuf = "";
1326
1326
  this.write = write;
@@ -1329,15 +1329,15 @@ var require_sonic_boom = __commonJS({
1329
1329
  this._actualWrite = actualWrite;
1330
1330
  fsWriteSync = () => {
1331
1331
  if (Buffer.isBuffer(this._writingBuf)) {
1332
- return fs22.writeSync(this.fd, this._writingBuf);
1332
+ return fs23.writeSync(this.fd, this._writingBuf);
1333
1333
  }
1334
- return fs22.writeSync(this.fd, this._writingBuf, "utf8");
1334
+ return fs23.writeSync(this.fd, this._writingBuf, "utf8");
1335
1335
  };
1336
1336
  fsWrite = () => {
1337
1337
  if (Buffer.isBuffer(this._writingBuf)) {
1338
- return fs22.write(this.fd, this._writingBuf, this.release);
1338
+ return fs23.write(this.fd, this._writingBuf, this.release);
1339
1339
  }
1340
- return fs22.write(this.fd, this._writingBuf, "utf8", this.release);
1340
+ return fs23.write(this.fd, this._writingBuf, "utf8", this.release);
1341
1341
  };
1342
1342
  } else {
1343
1343
  throw new Error(`SonicBoom supports "${kContentModeUtf8}" and "${kContentModeBuffer}", but passed ${contentMode}`);
@@ -1394,7 +1394,7 @@ var require_sonic_boom = __commonJS({
1394
1394
  }
1395
1395
  }
1396
1396
  if (this._fsync) {
1397
- fs22.fsyncSync(this.fd);
1397
+ fs23.fsyncSync(this.fd);
1398
1398
  }
1399
1399
  const len = this._len;
1400
1400
  if (this._reopening) {
@@ -1508,7 +1508,7 @@ var require_sonic_boom = __commonJS({
1508
1508
  const onDrain = () => {
1509
1509
  if (!this._fsync) {
1510
1510
  try {
1511
- fs22.fsync(this.fd, (err) => {
1511
+ fs23.fsync(this.fd, (err) => {
1512
1512
  this._flushPending = false;
1513
1513
  cb(err);
1514
1514
  });
@@ -1610,7 +1610,7 @@ var require_sonic_boom = __commonJS({
1610
1610
  const fd = this.fd;
1611
1611
  this.once("ready", () => {
1612
1612
  if (fd !== this.fd) {
1613
- fs22.close(fd, (err) => {
1613
+ fs23.close(fd, (err) => {
1614
1614
  if (err) {
1615
1615
  return this.emit("error", err);
1616
1616
  }
@@ -1659,7 +1659,7 @@ var require_sonic_boom = __commonJS({
1659
1659
  buf = this._bufs[0];
1660
1660
  }
1661
1661
  try {
1662
- const n = Buffer.isBuffer(buf) ? fs22.writeSync(this.fd, buf) : fs22.writeSync(this.fd, buf, "utf8");
1662
+ const n = Buffer.isBuffer(buf) ? fs23.writeSync(this.fd, buf) : fs23.writeSync(this.fd, buf, "utf8");
1663
1663
  const releasedBufObj = releaseWritingBuf(buf, this._len, n);
1664
1664
  buf = releasedBufObj.writingBuf;
1665
1665
  this._len = releasedBufObj.len;
@@ -1675,7 +1675,7 @@ var require_sonic_boom = __commonJS({
1675
1675
  }
1676
1676
  }
1677
1677
  try {
1678
- fs22.fsyncSync(this.fd);
1678
+ fs23.fsyncSync(this.fd);
1679
1679
  } catch {
1680
1680
  }
1681
1681
  }
@@ -1696,7 +1696,7 @@ var require_sonic_boom = __commonJS({
1696
1696
  buf = mergeBuf(this._bufs[0], this._lens[0]);
1697
1697
  }
1698
1698
  try {
1699
- const n = fs22.writeSync(this.fd, buf);
1699
+ const n = fs23.writeSync(this.fd, buf);
1700
1700
  buf = buf.subarray(n);
1701
1701
  this._len = Math.max(this._len - n, 0);
1702
1702
  if (buf.length <= 0) {
@@ -1724,13 +1724,13 @@ var require_sonic_boom = __commonJS({
1724
1724
  this._writingBuf = this._writingBuf.length ? this._writingBuf : this._bufs.shift() || "";
1725
1725
  if (this.sync) {
1726
1726
  try {
1727
- const written = Buffer.isBuffer(this._writingBuf) ? fs22.writeSync(this.fd, this._writingBuf) : fs22.writeSync(this.fd, this._writingBuf, "utf8");
1727
+ const written = Buffer.isBuffer(this._writingBuf) ? fs23.writeSync(this.fd, this._writingBuf) : fs23.writeSync(this.fd, this._writingBuf, "utf8");
1728
1728
  release(null, written);
1729
1729
  } catch (err) {
1730
1730
  release(err);
1731
1731
  }
1732
1732
  } else {
1733
- fs22.write(this.fd, this._writingBuf, release);
1733
+ fs23.write(this.fd, this._writingBuf, release);
1734
1734
  }
1735
1735
  }
1736
1736
  function actualWriteBuffer() {
@@ -1739,7 +1739,7 @@ var require_sonic_boom = __commonJS({
1739
1739
  this._writingBuf = this._writingBuf.length ? this._writingBuf : mergeBuf(this._bufs.shift(), this._lens.shift());
1740
1740
  if (this.sync) {
1741
1741
  try {
1742
- const written = fs22.writeSync(this.fd, this._writingBuf);
1742
+ const written = fs23.writeSync(this.fd, this._writingBuf);
1743
1743
  release(null, written);
1744
1744
  } catch (err) {
1745
1745
  release(err);
@@ -1748,7 +1748,7 @@ var require_sonic_boom = __commonJS({
1748
1748
  if (kCopyBuffer) {
1749
1749
  this._writingBuf = Buffer.from(this._writingBuf);
1750
1750
  }
1751
- fs22.write(this.fd, this._writingBuf, release);
1751
+ fs23.write(this.fd, this._writingBuf, release);
1752
1752
  }
1753
1753
  }
1754
1754
  function actualClose(sonic) {
@@ -1764,12 +1764,12 @@ var require_sonic_boom = __commonJS({
1764
1764
  sonic._lens = [];
1765
1765
  assert(typeof sonic.fd === "number", `sonic.fd must be a number, got ${typeof sonic.fd}`);
1766
1766
  try {
1767
- fs22.fsync(sonic.fd, closeWrapped);
1767
+ fs23.fsync(sonic.fd, closeWrapped);
1768
1768
  } catch {
1769
1769
  }
1770
1770
  function closeWrapped() {
1771
1771
  if (sonic.fd !== 1 && sonic.fd !== 2) {
1772
- fs22.close(sonic.fd, done);
1772
+ fs23.close(sonic.fd, done);
1773
1773
  } else {
1774
1774
  done();
1775
1775
  }
@@ -2026,7 +2026,7 @@ var require_thread_stream = __commonJS({
2026
2026
  var { version: version2 } = require_package();
2027
2027
  var { EventEmitter } = require("events");
2028
2028
  var { Worker } = require("worker_threads");
2029
- var { join: join3 } = require("path");
2029
+ var { join: join4 } = require("path");
2030
2030
  var { pathToFileURL } = require("url");
2031
2031
  var { wait } = require_wait();
2032
2032
  var {
@@ -2062,7 +2062,7 @@ var require_thread_stream = __commonJS({
2062
2062
  function createWorker(stream, opts) {
2063
2063
  const { filename, workerData } = opts;
2064
2064
  const bundlerOverrides = "__bundlerPathsOverrides" in globalThis ? globalThis.__bundlerPathsOverrides : {};
2065
- const toExecute = bundlerOverrides["thread-stream-worker"] || join3(__dirname, "lib", "worker.js");
2065
+ const toExecute = bundlerOverrides["thread-stream-worker"] || join4(__dirname, "lib", "worker.js");
2066
2066
  const worker = new Worker(toExecute, {
2067
2067
  ...opts.workerOpts,
2068
2068
  trackUnmanagedFds: false,
@@ -2448,7 +2448,7 @@ var require_transport = __commonJS({
2448
2448
  "use strict";
2449
2449
  var { createRequire } = require("module");
2450
2450
  var getCallers = require_caller();
2451
- var { join: join3, isAbsolute, sep } = require("path");
2451
+ var { join: join4, isAbsolute, sep } = require("path");
2452
2452
  var sleep = require_atomic_sleep();
2453
2453
  var onExit = require_on_exit_leak_free();
2454
2454
  var ThreadStream = require_thread_stream();
@@ -2511,7 +2511,7 @@ var require_transport = __commonJS({
2511
2511
  throw new Error("only one of target or targets can be specified");
2512
2512
  }
2513
2513
  if (targets) {
2514
- target = bundlerOverrides["pino-worker"] || join3(__dirname, "worker.js");
2514
+ target = bundlerOverrides["pino-worker"] || join4(__dirname, "worker.js");
2515
2515
  options.targets = targets.filter((dest) => dest.target).map((dest) => {
2516
2516
  return {
2517
2517
  ...dest,
@@ -2529,7 +2529,7 @@ var require_transport = __commonJS({
2529
2529
  });
2530
2530
  });
2531
2531
  } else if (pipeline2) {
2532
- target = bundlerOverrides["pino-worker"] || join3(__dirname, "worker.js");
2532
+ target = bundlerOverrides["pino-worker"] || join4(__dirname, "worker.js");
2533
2533
  options.pipelines = [pipeline2.map((dest) => {
2534
2534
  return {
2535
2535
  ...dest,
@@ -2551,7 +2551,7 @@ var require_transport = __commonJS({
2551
2551
  return origin;
2552
2552
  }
2553
2553
  if (origin === "pino/file") {
2554
- return join3(__dirname, "..", "file.js");
2554
+ return join4(__dirname, "..", "file.js");
2555
2555
  }
2556
2556
  let fixTarget2;
2557
2557
  for (const filePath of callers) {
@@ -3541,7 +3541,7 @@ var require_safe_stable_stringify = __commonJS({
3541
3541
  return circularValue;
3542
3542
  }
3543
3543
  let res = "";
3544
- let join3 = ",";
3544
+ let join4 = ",";
3545
3545
  const originalIndentation = indentation;
3546
3546
  if (Array.isArray(value)) {
3547
3547
  if (value.length === 0) {
@@ -3555,7 +3555,7 @@ var require_safe_stable_stringify = __commonJS({
3555
3555
  indentation += spacer;
3556
3556
  res += `
3557
3557
  ${indentation}`;
3558
- join3 = `,
3558
+ join4 = `,
3559
3559
  ${indentation}`;
3560
3560
  }
3561
3561
  const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
@@ -3563,13 +3563,13 @@ ${indentation}`;
3563
3563
  for (; i < maximumValuesToStringify - 1; i++) {
3564
3564
  const tmp2 = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
3565
3565
  res += tmp2 !== void 0 ? tmp2 : "null";
3566
- res += join3;
3566
+ res += join4;
3567
3567
  }
3568
3568
  const tmp = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
3569
3569
  res += tmp !== void 0 ? tmp : "null";
3570
3570
  if (value.length - 1 > maximumBreadth) {
3571
3571
  const removedKeys = value.length - maximumBreadth - 1;
3572
- res += `${join3}"... ${getItemCount(removedKeys)} not stringified"`;
3572
+ res += `${join4}"... ${getItemCount(removedKeys)} not stringified"`;
3573
3573
  }
3574
3574
  if (spacer !== "") {
3575
3575
  res += `
@@ -3590,7 +3590,7 @@ ${originalIndentation}`;
3590
3590
  let separator = "";
3591
3591
  if (spacer !== "") {
3592
3592
  indentation += spacer;
3593
- join3 = `,
3593
+ join4 = `,
3594
3594
  ${indentation}`;
3595
3595
  whitespace = " ";
3596
3596
  }
@@ -3604,13 +3604,13 @@ ${indentation}`;
3604
3604
  const tmp = stringifyFnReplacer(key2, value, stack, replacer, spacer, indentation);
3605
3605
  if (tmp !== void 0) {
3606
3606
  res += `${separator}${strEscape(key2)}:${whitespace}${tmp}`;
3607
- separator = join3;
3607
+ separator = join4;
3608
3608
  }
3609
3609
  }
3610
3610
  if (keyLength > maximumBreadth) {
3611
3611
  const removedKeys = keyLength - maximumBreadth;
3612
3612
  res += `${separator}"...":${whitespace}"${getItemCount(removedKeys)} not stringified"`;
3613
- separator = join3;
3613
+ separator = join4;
3614
3614
  }
3615
3615
  if (spacer !== "" && separator.length > 1) {
3616
3616
  res = `
@@ -3651,7 +3651,7 @@ ${originalIndentation}`;
3651
3651
  }
3652
3652
  const originalIndentation = indentation;
3653
3653
  let res = "";
3654
- let join3 = ",";
3654
+ let join4 = ",";
3655
3655
  if (Array.isArray(value)) {
3656
3656
  if (value.length === 0) {
3657
3657
  return "[]";
@@ -3664,7 +3664,7 @@ ${originalIndentation}`;
3664
3664
  indentation += spacer;
3665
3665
  res += `
3666
3666
  ${indentation}`;
3667
- join3 = `,
3667
+ join4 = `,
3668
3668
  ${indentation}`;
3669
3669
  }
3670
3670
  const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
@@ -3672,13 +3672,13 @@ ${indentation}`;
3672
3672
  for (; i < maximumValuesToStringify - 1; i++) {
3673
3673
  const tmp2 = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
3674
3674
  res += tmp2 !== void 0 ? tmp2 : "null";
3675
- res += join3;
3675
+ res += join4;
3676
3676
  }
3677
3677
  const tmp = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
3678
3678
  res += tmp !== void 0 ? tmp : "null";
3679
3679
  if (value.length - 1 > maximumBreadth) {
3680
3680
  const removedKeys = value.length - maximumBreadth - 1;
3681
- res += `${join3}"... ${getItemCount(removedKeys)} not stringified"`;
3681
+ res += `${join4}"... ${getItemCount(removedKeys)} not stringified"`;
3682
3682
  }
3683
3683
  if (spacer !== "") {
3684
3684
  res += `
@@ -3691,7 +3691,7 @@ ${originalIndentation}`;
3691
3691
  let whitespace = "";
3692
3692
  if (spacer !== "") {
3693
3693
  indentation += spacer;
3694
- join3 = `,
3694
+ join4 = `,
3695
3695
  ${indentation}`;
3696
3696
  whitespace = " ";
3697
3697
  }
@@ -3700,7 +3700,7 @@ ${indentation}`;
3700
3700
  const tmp = stringifyArrayReplacer(key2, value[key2], stack, replacer, spacer, indentation);
3701
3701
  if (tmp !== void 0) {
3702
3702
  res += `${separator}${strEscape(key2)}:${whitespace}${tmp}`;
3703
- separator = join3;
3703
+ separator = join4;
3704
3704
  }
3705
3705
  }
3706
3706
  if (spacer !== "" && separator.length > 1) {
@@ -3758,20 +3758,20 @@ ${originalIndentation}`;
3758
3758
  indentation += spacer;
3759
3759
  let res2 = `
3760
3760
  ${indentation}`;
3761
- const join4 = `,
3761
+ const join5 = `,
3762
3762
  ${indentation}`;
3763
3763
  const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
3764
3764
  let i = 0;
3765
3765
  for (; i < maximumValuesToStringify - 1; i++) {
3766
3766
  const tmp2 = stringifyIndent(String(i), value[i], stack, spacer, indentation);
3767
3767
  res2 += tmp2 !== void 0 ? tmp2 : "null";
3768
- res2 += join4;
3768
+ res2 += join5;
3769
3769
  }
3770
3770
  const tmp = stringifyIndent(String(i), value[i], stack, spacer, indentation);
3771
3771
  res2 += tmp !== void 0 ? tmp : "null";
3772
3772
  if (value.length - 1 > maximumBreadth) {
3773
3773
  const removedKeys = value.length - maximumBreadth - 1;
3774
- res2 += `${join4}"... ${getItemCount(removedKeys)} not stringified"`;
3774
+ res2 += `${join5}"... ${getItemCount(removedKeys)} not stringified"`;
3775
3775
  }
3776
3776
  res2 += `
3777
3777
  ${originalIndentation}`;
@@ -3787,16 +3787,16 @@ ${originalIndentation}`;
3787
3787
  return '"[Object]"';
3788
3788
  }
3789
3789
  indentation += spacer;
3790
- const join3 = `,
3790
+ const join4 = `,
3791
3791
  ${indentation}`;
3792
3792
  let res = "";
3793
3793
  let separator = "";
3794
3794
  let maximumPropertiesToStringify = Math.min(keyLength, maximumBreadth);
3795
3795
  if (isTypedArrayWithEntries(value)) {
3796
- res += stringifyTypedArray(value, join3, maximumBreadth);
3796
+ res += stringifyTypedArray(value, join4, maximumBreadth);
3797
3797
  keys = keys.slice(value.length);
3798
3798
  maximumPropertiesToStringify -= value.length;
3799
- separator = join3;
3799
+ separator = join4;
3800
3800
  }
3801
3801
  if (deterministic) {
3802
3802
  keys = sort(keys, comparator);
@@ -3807,13 +3807,13 @@ ${indentation}`;
3807
3807
  const tmp = stringifyIndent(key2, value[key2], stack, spacer, indentation);
3808
3808
  if (tmp !== void 0) {
3809
3809
  res += `${separator}${strEscape(key2)}: ${tmp}`;
3810
- separator = join3;
3810
+ separator = join4;
3811
3811
  }
3812
3812
  }
3813
3813
  if (keyLength > maximumBreadth) {
3814
3814
  const removedKeys = keyLength - maximumBreadth;
3815
3815
  res += `${separator}"...": "${getItemCount(removedKeys)} not stringified"`;
3816
- separator = join3;
3816
+ separator = join4;
3817
3817
  }
3818
3818
  if (separator !== "") {
3819
3819
  res = `
@@ -4895,8 +4895,8 @@ var init_parseUtil = __esm({
4895
4895
  init_errors2();
4896
4896
  init_en();
4897
4897
  makeIssue = (params) => {
4898
- const { data, path: path23, errorMaps, issueData } = params;
4899
- const fullPath = [...path23, ...issueData.path || []];
4898
+ const { data, path: path24, errorMaps, issueData } = params;
4899
+ const fullPath = [...path24, ...issueData.path || []];
4900
4900
  const fullIssue = {
4901
4901
  ...issueData,
4902
4902
  path: fullPath
@@ -5207,11 +5207,11 @@ var init_types = __esm({
5207
5207
  init_parseUtil();
5208
5208
  init_util();
5209
5209
  ParseInputLazyPath = class {
5210
- constructor(parent, value, path23, key) {
5210
+ constructor(parent, value, path24, key) {
5211
5211
  this._cachedPath = [];
5212
5212
  this.parent = parent;
5213
5213
  this.data = value;
5214
- this._path = path23;
5214
+ this._path = path24;
5215
5215
  this._key = key;
5216
5216
  }
5217
5217
  get path() {
@@ -9823,11 +9823,11 @@ var init_lib = __esm({
9823
9823
  }
9824
9824
  }
9825
9825
  },
9826
- addToPath: function addToPath(path23, added, removed, oldPosInc, options) {
9827
- var last = path23.lastComponent;
9826
+ addToPath: function addToPath(path24, added, removed, oldPosInc, options) {
9827
+ var last = path24.lastComponent;
9828
9828
  if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) {
9829
9829
  return {
9830
- oldPos: path23.oldPos + oldPosInc,
9830
+ oldPos: path24.oldPos + oldPosInc,
9831
9831
  lastComponent: {
9832
9832
  count: last.count + 1,
9833
9833
  added,
@@ -9837,7 +9837,7 @@ var init_lib = __esm({
9837
9837
  };
9838
9838
  } else {
9839
9839
  return {
9840
- oldPos: path23.oldPos + oldPosInc,
9840
+ oldPos: path24.oldPos + oldPosInc,
9841
9841
  lastComponent: {
9842
9842
  count: 1,
9843
9843
  added,
@@ -9895,7 +9895,7 @@ var init_lib = __esm({
9895
9895
  tokenize: function tokenize(value) {
9896
9896
  return Array.from(value);
9897
9897
  },
9898
- join: function join2(chars) {
9898
+ join: function join3(chars) {
9899
9899
  return chars.join("");
9900
9900
  },
9901
9901
  postProcess: function postProcess(changeObjects) {
@@ -10268,10 +10268,10 @@ function attachmentToHistoryMessage(o, ts) {
10268
10268
  const memories = raw.map((m) => {
10269
10269
  if (!m || typeof m !== "object") return null;
10270
10270
  const rec = m;
10271
- const path23 = typeof rec.path === "string" ? rec.path : null;
10271
+ const path24 = typeof rec.path === "string" ? rec.path : null;
10272
10272
  const content = typeof rec.content === "string" ? rec.content : null;
10273
- if (!path23 || content == null) return null;
10274
- const entry = { path: path23, content };
10273
+ if (!path24 || content == null) return null;
10274
+ const entry = { path: path24, content };
10275
10275
  if (typeof rec.mtimeMs === "number") entry.mtimeMs = rec.mtimeMs;
10276
10276
  return entry;
10277
10277
  }).filter((m) => m !== null);
@@ -11074,10 +11074,10 @@ function parseAttachment(obj) {
11074
11074
  const memories = raw.map((m) => {
11075
11075
  if (!m || typeof m !== "object") return null;
11076
11076
  const rec = m;
11077
- const path23 = typeof rec.path === "string" ? rec.path : null;
11077
+ const path24 = typeof rec.path === "string" ? rec.path : null;
11078
11078
  const content = typeof rec.content === "string" ? rec.content : null;
11079
- if (!path23 || content == null) return null;
11080
- const out = { path: path23, content };
11079
+ if (!path24 || content == null) return null;
11080
+ const out = { path: path24, content };
11081
11081
  if (typeof rec.mtimeMs === "number") out.mtimeMs = rec.mtimeMs;
11082
11082
  return out;
11083
11083
  }).filter((m) => m !== null);
@@ -14949,11 +14949,11 @@ function startRunCaseRecorder(opts) {
14949
14949
  let closing = false;
14950
14950
  let closedSettled = false;
14951
14951
  let closedResolve;
14952
- const closed = new Promise((resolve) => {
14952
+ const closed = new Promise((resolve2) => {
14953
14953
  closedResolve = () => {
14954
14954
  if (closedSettled) return;
14955
14955
  closedSettled = true;
14956
- resolve();
14956
+ resolve2();
14957
14957
  };
14958
14958
  });
14959
14959
  const ensureStream = () => {
@@ -15045,8 +15045,8 @@ async function runController(opts) {
15045
15045
  let exitCode = null;
15046
15046
  let procExited = false;
15047
15047
  let resolveProcExit;
15048
- const procExitPromise = new Promise((resolve) => {
15049
- resolveProcExit = resolve;
15048
+ const procExitPromise = new Promise((resolve2) => {
15049
+ resolveProcExit = resolve2;
15050
15050
  });
15051
15051
  const writeEvent = (event) => {
15052
15052
  try {
@@ -16286,8 +16286,8 @@ function startRecorder(opts) {
16286
16286
  const filePath = import_node_path4.default.join(dir, `${tsForFilename(now())}.jsonl`);
16287
16287
  let stream = null;
16288
16288
  let closedResolve;
16289
- const closed = new Promise((resolve) => {
16290
- closedResolve = resolve;
16289
+ const closed = new Promise((resolve2) => {
16290
+ closedResolve = resolve2;
16291
16291
  });
16292
16292
  let exited = false;
16293
16293
  const ensureStream = () => {
@@ -16427,13 +16427,13 @@ var SessionRunner = class {
16427
16427
  // 已经停止则立即 resolve;超时(默认 3000ms)抛错由上层透传成 RPC error
16428
16428
  async waitUntilStopped(timeoutMs = DEFAULT_WAIT_STOP_TIMEOUT_MS) {
16429
16429
  if (!this.state.procAlive) return;
16430
- return new Promise((resolve, reject) => {
16430
+ return new Promise((resolve2, reject) => {
16431
16431
  let settled = false;
16432
16432
  const onStop = () => {
16433
16433
  if (settled) return;
16434
16434
  settled = true;
16435
16435
  clearTimeout(timer);
16436
- resolve();
16436
+ resolve2();
16437
16437
  };
16438
16438
  const timer = setTimeout(() => {
16439
16439
  if (settled) return;
@@ -16478,7 +16478,7 @@ var SessionRunner = class {
16478
16478
  };
16479
16479
  const payload = JSON.stringify(frame) + "\n";
16480
16480
  const timeoutMs = opts.timeoutMs ?? DEFAULT_CONTROL_REQUEST_TIMEOUT_MS;
16481
- return new Promise((resolve, reject) => {
16481
+ return new Promise((resolve2, reject) => {
16482
16482
  const timer = setTimeout(() => {
16483
16483
  const pending = this.pendingControlRequests.get(requestId);
16484
16484
  if (!pending) return;
@@ -16486,7 +16486,7 @@ var SessionRunner = class {
16486
16486
  reject(new Error(`control_request timeout: ${subtype}`));
16487
16487
  }, timeoutMs);
16488
16488
  timer.unref?.();
16489
- this.pendingControlRequests.set(requestId, { resolve, reject, timer });
16489
+ this.pendingControlRequests.set(requestId, { resolve: resolve2, reject, timer });
16490
16490
  try {
16491
16491
  proc.stdin?.write(payload);
16492
16492
  this.recorder?.tapStdinWrite(payload);
@@ -17898,6 +17898,102 @@ var PersonaManager = class {
17898
17898
  }
17899
17899
  };
17900
17900
 
17901
+ // src/persona/seed.ts
17902
+ var fs7 = __toESM(require("fs"), 1);
17903
+ var path7 = __toESM(require("path"), 1);
17904
+ var import_node_url = require("url");
17905
+ var import_meta = {};
17906
+ var DEFAULT_PERSONAS = [
17907
+ {
17908
+ personaId: "persona-researcher",
17909
+ label: "\u8C03\u7814\u5458",
17910
+ model: "opus",
17911
+ iconKey: "research",
17912
+ public: false
17913
+ },
17914
+ {
17915
+ personaId: "persona-knowledge-base",
17916
+ label: "\u77E5\u8BC6\u5E93\u7BA1\u7406\u5458",
17917
+ model: "opus",
17918
+ iconKey: "reading",
17919
+ public: false
17920
+ }
17921
+ ];
17922
+ function findDefaultsRoot() {
17923
+ const candidates = [];
17924
+ try {
17925
+ const here = path7.dirname((0, import_node_url.fileURLToPath)(import_meta.url));
17926
+ candidates.push(path7.resolve(here, "defaults"));
17927
+ candidates.push(path7.resolve(here, "persona-defaults"));
17928
+ } catch {
17929
+ }
17930
+ if (process.argv[1]) {
17931
+ const argvDir = path7.dirname(process.argv[1]);
17932
+ candidates.push(path7.resolve(argvDir, "persona-defaults"));
17933
+ }
17934
+ for (const c of candidates) {
17935
+ try {
17936
+ if (fs7.statSync(c).isDirectory()) return c;
17937
+ } catch {
17938
+ }
17939
+ }
17940
+ return null;
17941
+ }
17942
+ function seedDefaultPersonas(args) {
17943
+ const entries = args.entries ?? DEFAULT_PERSONAS;
17944
+ for (const entry of entries) {
17945
+ if (args.store.has(entry.personaId)) {
17946
+ args.logger.info("persona.seed.skip", { personaId: entry.personaId, reason: "exists" });
17947
+ continue;
17948
+ }
17949
+ const bundleDir = path7.join(args.defaultsRoot, entry.personaId);
17950
+ if (!fs7.existsSync(bundleDir)) {
17951
+ args.logger.warn("persona.seed.skip", {
17952
+ personaId: entry.personaId,
17953
+ reason: "bundle-missing",
17954
+ bundleDir
17955
+ });
17956
+ continue;
17957
+ }
17958
+ const claudeMdPath = path7.join(bundleDir, "CLAUDE.md");
17959
+ if (!fs7.existsSync(claudeMdPath)) {
17960
+ args.logger.warn("persona.seed.skip", {
17961
+ personaId: entry.personaId,
17962
+ reason: "no-CLAUDE.md",
17963
+ bundleDir
17964
+ });
17965
+ continue;
17966
+ }
17967
+ const personality = fs7.readFileSync(claudeMdPath, "utf8");
17968
+ const now = Date.now();
17969
+ const persona = {
17970
+ personaId: entry.personaId,
17971
+ label: entry.label,
17972
+ model: entry.model,
17973
+ public: entry.public,
17974
+ iconKey: entry.iconKey,
17975
+ tokenMap: {},
17976
+ createdAt: now,
17977
+ updatedAt: now
17978
+ };
17979
+ args.store.write(persona, personality);
17980
+ copyBundleExtras(bundleDir, args.store.personaDirPath(entry.personaId));
17981
+ args.logger.info("persona.seed.created", { personaId: entry.personaId });
17982
+ }
17983
+ }
17984
+ function copyBundleExtras(srcDir, dstDir) {
17985
+ for (const entry of fs7.readdirSync(srcDir, { withFileTypes: true })) {
17986
+ if (entry.name === "CLAUDE.md" || entry.name === ".clawd") continue;
17987
+ const srcPath = path7.join(srcDir, entry.name);
17988
+ const dstPath = path7.join(dstDir, entry.name);
17989
+ if (entry.isDirectory()) {
17990
+ fs7.cpSync(srcPath, dstPath, { recursive: true, dereference: true });
17991
+ } else if (entry.isFile()) {
17992
+ fs7.copyFileSync(srcPath, dstPath);
17993
+ }
17994
+ }
17995
+ }
17996
+
17901
17997
  // src/index.ts
17902
17998
  init_claude();
17903
17999
  init_claude_history();
@@ -18659,7 +18755,7 @@ var LocalWsServer = class {
18659
18755
  pingIntervalMs;
18660
18756
  async start() {
18661
18757
  const host = this.opts.host ?? "127.0.0.1";
18662
- await new Promise((resolve, reject) => {
18758
+ await new Promise((resolve2, reject) => {
18663
18759
  const wss = new import_websocket_server.default({
18664
18760
  host,
18665
18761
  port: this.opts.port,
@@ -18667,7 +18763,7 @@ var LocalWsServer = class {
18667
18763
  });
18668
18764
  wss.on("listening", () => {
18669
18765
  this.logger?.info("ws listening", { host, port: this.opts.port });
18670
- resolve();
18766
+ resolve2();
18671
18767
  });
18672
18768
  wss.on("error", (err) => {
18673
18769
  this.logger?.error("ws server error", { err: err.message });
@@ -18687,8 +18783,8 @@ var LocalWsServer = class {
18687
18783
  if (c.pingTimer) clearInterval(c.pingTimer);
18688
18784
  }
18689
18785
  this.clients.clear();
18690
- await new Promise((resolve) => {
18691
- this.wss?.close(() => resolve());
18786
+ await new Promise((resolve2) => {
18787
+ this.wss?.close(() => resolve2());
18692
18788
  });
18693
18789
  this.wss = null;
18694
18790
  }
@@ -19495,10 +19591,10 @@ async function extractFrpcFromTarball(tarball, binDir, version2, platform, destB
19495
19591
  const work = import_node_path14.default.join(binDir, `extract-${process.pid}-${Date.now()}`);
19496
19592
  import_node_fs14.default.mkdirSync(work, { recursive: true });
19497
19593
  try {
19498
- await new Promise((resolve, reject) => {
19594
+ await new Promise((resolve2, reject) => {
19499
19595
  const proc = (0, import_node_child_process3.spawn)("tar", ["xzf", tarball, "-C", work], { stdio: "pipe" });
19500
19596
  proc.on("error", reject);
19501
- proc.on("exit", (code) => code === 0 ? resolve() : reject(new Error(`tar exited ${code}`)));
19597
+ proc.on("exit", (code) => code === 0 ? resolve2() : reject(new Error(`tar exited ${code}`)));
19502
19598
  });
19503
19599
  const dirName = `frp_${version2}_${platform.os}_${platform.arch}`;
19504
19600
  const src = import_node_path14.default.join(work, dirName, "frpc");
@@ -19576,17 +19672,17 @@ var TunnelManager = class {
19576
19672
  this.proc = null;
19577
19673
  if (!proc) return;
19578
19674
  proc.kill("SIGTERM");
19579
- await new Promise((resolve) => {
19675
+ await new Promise((resolve2) => {
19580
19676
  const t = setTimeout(() => {
19581
19677
  try {
19582
19678
  proc.kill("SIGKILL");
19583
19679
  } catch {
19584
19680
  }
19585
- resolve();
19681
+ resolve2();
19586
19682
  }, 5e3);
19587
19683
  proc.once("exit", () => {
19588
19684
  clearTimeout(t);
19589
- resolve();
19685
+ resolve2();
19590
19686
  });
19591
19687
  });
19592
19688
  }
@@ -19687,14 +19783,14 @@ function formatFrpcTail(raw, maxLines = 12) {
19687
19783
  return ["\u2500\u2500\u2500 frpc output (last lines) \u2500\u2500\u2500", tail, "\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"].join("\n");
19688
19784
  }
19689
19785
  async function waitForFrpcReady(proc, timeoutMs) {
19690
- return new Promise((resolve) => {
19786
+ return new Promise((resolve2) => {
19691
19787
  let settled = false;
19692
19788
  let buf = "";
19693
19789
  const finish = (r) => {
19694
19790
  if (settled) return;
19695
19791
  settled = true;
19696
19792
  cleanup();
19697
- resolve(r);
19793
+ resolve2(r);
19698
19794
  };
19699
19795
  const onData = (chunk) => {
19700
19796
  buf += String(chunk);
@@ -20622,6 +20718,12 @@ async function startDaemon(config) {
20622
20718
  const history = new ClaudeHistoryReader();
20623
20719
  let transport = null;
20624
20720
  const personaStore = new PersonaStore(import_node_path19.default.join(config.dataDir, "personas"));
20721
+ const defaultsRoot = findDefaultsRoot();
20722
+ if (defaultsRoot) {
20723
+ seedDefaultPersonas({ store: personaStore, defaultsRoot, logger });
20724
+ } else {
20725
+ logger.warn("persona.seed.skip", { reason: "defaults-root-not-found" });
20726
+ }
20625
20727
  const manager = new SessionManager({
20626
20728
  store,
20627
20729
  logger,