@clawos-dev/clawd 0.2.60 → 0.2.61-beta.98.15637d6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.cjs +264 -139
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -601,8 +601,8 @@ var init_parseUtil = __esm({
|
|
|
601
601
|
init_errors2();
|
|
602
602
|
init_en();
|
|
603
603
|
makeIssue = (params) => {
|
|
604
|
-
const { data, path:
|
|
605
|
-
const fullPath = [...
|
|
604
|
+
const { data, path: path28, errorMaps, issueData } = params;
|
|
605
|
+
const fullPath = [...path28, ...issueData.path || []];
|
|
606
606
|
const fullIssue = {
|
|
607
607
|
...issueData,
|
|
608
608
|
path: fullPath
|
|
@@ -913,11 +913,11 @@ var init_types = __esm({
|
|
|
913
913
|
init_parseUtil();
|
|
914
914
|
init_util();
|
|
915
915
|
ParseInputLazyPath = class {
|
|
916
|
-
constructor(parent, value,
|
|
916
|
+
constructor(parent, value, path28, key) {
|
|
917
917
|
this._cachedPath = [];
|
|
918
918
|
this.parent = parent;
|
|
919
919
|
this.data = value;
|
|
920
|
-
this._path =
|
|
920
|
+
this._path = path28;
|
|
921
921
|
this._key = key;
|
|
922
922
|
}
|
|
923
923
|
get path() {
|
|
@@ -5367,8 +5367,8 @@ var require_req = __commonJS({
|
|
|
5367
5367
|
if (req.originalUrl) {
|
|
5368
5368
|
_req.url = req.originalUrl;
|
|
5369
5369
|
} else {
|
|
5370
|
-
const
|
|
5371
|
-
_req.url = typeof
|
|
5370
|
+
const path28 = req.path;
|
|
5371
|
+
_req.url = typeof path28 === "string" ? path28 : req.url ? req.url.path || req.url : void 0;
|
|
5372
5372
|
}
|
|
5373
5373
|
if (req.query) {
|
|
5374
5374
|
_req.query = req.query;
|
|
@@ -5533,14 +5533,14 @@ var require_redact = __commonJS({
|
|
|
5533
5533
|
}
|
|
5534
5534
|
return obj;
|
|
5535
5535
|
}
|
|
5536
|
-
function parsePath(
|
|
5536
|
+
function parsePath(path28) {
|
|
5537
5537
|
const parts = [];
|
|
5538
5538
|
let current = "";
|
|
5539
5539
|
let inBrackets = false;
|
|
5540
5540
|
let inQuotes = false;
|
|
5541
5541
|
let quoteChar = "";
|
|
5542
|
-
for (let i = 0; i <
|
|
5543
|
-
const char =
|
|
5542
|
+
for (let i = 0; i < path28.length; i++) {
|
|
5543
|
+
const char = path28[i];
|
|
5544
5544
|
if (!inBrackets && char === ".") {
|
|
5545
5545
|
if (current) {
|
|
5546
5546
|
parts.push(current);
|
|
@@ -5671,10 +5671,10 @@ var require_redact = __commonJS({
|
|
|
5671
5671
|
return current;
|
|
5672
5672
|
}
|
|
5673
5673
|
function redactPaths(obj, paths, censor, remove = false) {
|
|
5674
|
-
for (const
|
|
5675
|
-
const parts = parsePath(
|
|
5674
|
+
for (const path28 of paths) {
|
|
5675
|
+
const parts = parsePath(path28);
|
|
5676
5676
|
if (parts.includes("*")) {
|
|
5677
|
-
redactWildcardPath(obj, parts, censor,
|
|
5677
|
+
redactWildcardPath(obj, parts, censor, path28, remove);
|
|
5678
5678
|
} else {
|
|
5679
5679
|
if (remove) {
|
|
5680
5680
|
removeKey(obj, parts);
|
|
@@ -5759,8 +5759,8 @@ var require_redact = __commonJS({
|
|
|
5759
5759
|
}
|
|
5760
5760
|
} else {
|
|
5761
5761
|
if (afterWildcard.includes("*")) {
|
|
5762
|
-
const wrappedCensor = typeof censor === "function" ? (value,
|
|
5763
|
-
const fullPath = [...pathArray.slice(0, pathLength), ...
|
|
5762
|
+
const wrappedCensor = typeof censor === "function" ? (value, path28) => {
|
|
5763
|
+
const fullPath = [...pathArray.slice(0, pathLength), ...path28];
|
|
5764
5764
|
return censor(value, fullPath);
|
|
5765
5765
|
} : censor;
|
|
5766
5766
|
redactWildcardPath(current, afterWildcard, wrappedCensor, originalPath, remove);
|
|
@@ -5795,8 +5795,8 @@ var require_redact = __commonJS({
|
|
|
5795
5795
|
return null;
|
|
5796
5796
|
}
|
|
5797
5797
|
const pathStructure = /* @__PURE__ */ new Map();
|
|
5798
|
-
for (const
|
|
5799
|
-
const parts = parsePath(
|
|
5798
|
+
for (const path28 of pathsToClone) {
|
|
5799
|
+
const parts = parsePath(path28);
|
|
5800
5800
|
let current = pathStructure;
|
|
5801
5801
|
for (let i = 0; i < parts.length; i++) {
|
|
5802
5802
|
const part = parts[i];
|
|
@@ -5848,24 +5848,24 @@ var require_redact = __commonJS({
|
|
|
5848
5848
|
}
|
|
5849
5849
|
return cloneSelectively(obj, pathStructure);
|
|
5850
5850
|
}
|
|
5851
|
-
function validatePath(
|
|
5852
|
-
if (typeof
|
|
5851
|
+
function validatePath(path28) {
|
|
5852
|
+
if (typeof path28 !== "string") {
|
|
5853
5853
|
throw new Error("Paths must be (non-empty) strings");
|
|
5854
5854
|
}
|
|
5855
|
-
if (
|
|
5855
|
+
if (path28 === "") {
|
|
5856
5856
|
throw new Error("Invalid redaction path ()");
|
|
5857
5857
|
}
|
|
5858
|
-
if (
|
|
5859
|
-
throw new Error(`Invalid redaction path (${
|
|
5858
|
+
if (path28.includes("..")) {
|
|
5859
|
+
throw new Error(`Invalid redaction path (${path28})`);
|
|
5860
5860
|
}
|
|
5861
|
-
if (
|
|
5862
|
-
throw new Error(`Invalid redaction path (${
|
|
5861
|
+
if (path28.includes(",")) {
|
|
5862
|
+
throw new Error(`Invalid redaction path (${path28})`);
|
|
5863
5863
|
}
|
|
5864
5864
|
let bracketCount = 0;
|
|
5865
5865
|
let inQuotes = false;
|
|
5866
5866
|
let quoteChar = "";
|
|
5867
|
-
for (let i = 0; i <
|
|
5868
|
-
const char =
|
|
5867
|
+
for (let i = 0; i < path28.length; i++) {
|
|
5868
|
+
const char = path28[i];
|
|
5869
5869
|
if ((char === '"' || char === "'") && bracketCount > 0) {
|
|
5870
5870
|
if (!inQuotes) {
|
|
5871
5871
|
inQuotes = true;
|
|
@@ -5879,20 +5879,20 @@ var require_redact = __commonJS({
|
|
|
5879
5879
|
} else if (char === "]" && !inQuotes) {
|
|
5880
5880
|
bracketCount--;
|
|
5881
5881
|
if (bracketCount < 0) {
|
|
5882
|
-
throw new Error(`Invalid redaction path (${
|
|
5882
|
+
throw new Error(`Invalid redaction path (${path28})`);
|
|
5883
5883
|
}
|
|
5884
5884
|
}
|
|
5885
5885
|
}
|
|
5886
5886
|
if (bracketCount !== 0) {
|
|
5887
|
-
throw new Error(`Invalid redaction path (${
|
|
5887
|
+
throw new Error(`Invalid redaction path (${path28})`);
|
|
5888
5888
|
}
|
|
5889
5889
|
}
|
|
5890
5890
|
function validatePaths(paths) {
|
|
5891
5891
|
if (!Array.isArray(paths)) {
|
|
5892
5892
|
throw new TypeError("paths must be an array");
|
|
5893
5893
|
}
|
|
5894
|
-
for (const
|
|
5895
|
-
validatePath(
|
|
5894
|
+
for (const path28 of paths) {
|
|
5895
|
+
validatePath(path28);
|
|
5896
5896
|
}
|
|
5897
5897
|
}
|
|
5898
5898
|
function slowRedact(options = {}) {
|
|
@@ -6060,8 +6060,8 @@ var require_redaction = __commonJS({
|
|
|
6060
6060
|
if (shape[k2] === null) {
|
|
6061
6061
|
o[k2] = (value) => topCensor(value, [k2]);
|
|
6062
6062
|
} else {
|
|
6063
|
-
const wrappedCensor = typeof censor === "function" ? (value,
|
|
6064
|
-
return censor(value, [k2, ...
|
|
6063
|
+
const wrappedCensor = typeof censor === "function" ? (value, path28) => {
|
|
6064
|
+
return censor(value, [k2, ...path28]);
|
|
6065
6065
|
} : censor;
|
|
6066
6066
|
o[k2] = Redact({
|
|
6067
6067
|
paths: shape[k2],
|
|
@@ -6279,10 +6279,10 @@ var require_atomic_sleep = __commonJS({
|
|
|
6279
6279
|
var require_sonic_boom = __commonJS({
|
|
6280
6280
|
"../node_modules/.pnpm/sonic-boom@4.2.1/node_modules/sonic-boom/index.js"(exports2, module2) {
|
|
6281
6281
|
"use strict";
|
|
6282
|
-
var
|
|
6282
|
+
var fs26 = require("fs");
|
|
6283
6283
|
var EventEmitter2 = require("events");
|
|
6284
6284
|
var inherits = require("util").inherits;
|
|
6285
|
-
var
|
|
6285
|
+
var path28 = require("path");
|
|
6286
6286
|
var sleep = require_atomic_sleep();
|
|
6287
6287
|
var assert = require("assert");
|
|
6288
6288
|
var BUSY_WRITE_TIMEOUT = 100;
|
|
@@ -6336,20 +6336,20 @@ var require_sonic_boom = __commonJS({
|
|
|
6336
6336
|
const mode = sonic.mode;
|
|
6337
6337
|
if (sonic.sync) {
|
|
6338
6338
|
try {
|
|
6339
|
-
if (sonic.mkdir)
|
|
6340
|
-
const fd =
|
|
6339
|
+
if (sonic.mkdir) fs26.mkdirSync(path28.dirname(file), { recursive: true });
|
|
6340
|
+
const fd = fs26.openSync(file, flags, mode);
|
|
6341
6341
|
fileOpened(null, fd);
|
|
6342
6342
|
} catch (err) {
|
|
6343
6343
|
fileOpened(err);
|
|
6344
6344
|
throw err;
|
|
6345
6345
|
}
|
|
6346
6346
|
} else if (sonic.mkdir) {
|
|
6347
|
-
|
|
6347
|
+
fs26.mkdir(path28.dirname(file), { recursive: true }, (err) => {
|
|
6348
6348
|
if (err) return fileOpened(err);
|
|
6349
|
-
|
|
6349
|
+
fs26.open(file, flags, mode, fileOpened);
|
|
6350
6350
|
});
|
|
6351
6351
|
} else {
|
|
6352
|
-
|
|
6352
|
+
fs26.open(file, flags, mode, fileOpened);
|
|
6353
6353
|
}
|
|
6354
6354
|
}
|
|
6355
6355
|
function SonicBoom(opts) {
|
|
@@ -6390,8 +6390,8 @@ var require_sonic_boom = __commonJS({
|
|
|
6390
6390
|
this.flush = flushBuffer;
|
|
6391
6391
|
this.flushSync = flushBufferSync;
|
|
6392
6392
|
this._actualWrite = actualWriteBuffer;
|
|
6393
|
-
fsWriteSync = () =>
|
|
6394
|
-
fsWrite = () =>
|
|
6393
|
+
fsWriteSync = () => fs26.writeSync(this.fd, this._writingBuf);
|
|
6394
|
+
fsWrite = () => fs26.write(this.fd, this._writingBuf, this.release);
|
|
6395
6395
|
} else if (contentMode === void 0 || contentMode === kContentModeUtf8) {
|
|
6396
6396
|
this._writingBuf = "";
|
|
6397
6397
|
this.write = write;
|
|
@@ -6400,15 +6400,15 @@ var require_sonic_boom = __commonJS({
|
|
|
6400
6400
|
this._actualWrite = actualWrite;
|
|
6401
6401
|
fsWriteSync = () => {
|
|
6402
6402
|
if (Buffer.isBuffer(this._writingBuf)) {
|
|
6403
|
-
return
|
|
6403
|
+
return fs26.writeSync(this.fd, this._writingBuf);
|
|
6404
6404
|
}
|
|
6405
|
-
return
|
|
6405
|
+
return fs26.writeSync(this.fd, this._writingBuf, "utf8");
|
|
6406
6406
|
};
|
|
6407
6407
|
fsWrite = () => {
|
|
6408
6408
|
if (Buffer.isBuffer(this._writingBuf)) {
|
|
6409
|
-
return
|
|
6409
|
+
return fs26.write(this.fd, this._writingBuf, this.release);
|
|
6410
6410
|
}
|
|
6411
|
-
return
|
|
6411
|
+
return fs26.write(this.fd, this._writingBuf, "utf8", this.release);
|
|
6412
6412
|
};
|
|
6413
6413
|
} else {
|
|
6414
6414
|
throw new Error(`SonicBoom supports "${kContentModeUtf8}" and "${kContentModeBuffer}", but passed ${contentMode}`);
|
|
@@ -6465,7 +6465,7 @@ var require_sonic_boom = __commonJS({
|
|
|
6465
6465
|
}
|
|
6466
6466
|
}
|
|
6467
6467
|
if (this._fsync) {
|
|
6468
|
-
|
|
6468
|
+
fs26.fsyncSync(this.fd);
|
|
6469
6469
|
}
|
|
6470
6470
|
const len = this._len;
|
|
6471
6471
|
if (this._reopening) {
|
|
@@ -6579,7 +6579,7 @@ var require_sonic_boom = __commonJS({
|
|
|
6579
6579
|
const onDrain = () => {
|
|
6580
6580
|
if (!this._fsync) {
|
|
6581
6581
|
try {
|
|
6582
|
-
|
|
6582
|
+
fs26.fsync(this.fd, (err) => {
|
|
6583
6583
|
this._flushPending = false;
|
|
6584
6584
|
cb(err);
|
|
6585
6585
|
});
|
|
@@ -6681,7 +6681,7 @@ var require_sonic_boom = __commonJS({
|
|
|
6681
6681
|
const fd = this.fd;
|
|
6682
6682
|
this.once("ready", () => {
|
|
6683
6683
|
if (fd !== this.fd) {
|
|
6684
|
-
|
|
6684
|
+
fs26.close(fd, (err) => {
|
|
6685
6685
|
if (err) {
|
|
6686
6686
|
return this.emit("error", err);
|
|
6687
6687
|
}
|
|
@@ -6730,7 +6730,7 @@ var require_sonic_boom = __commonJS({
|
|
|
6730
6730
|
buf = this._bufs[0];
|
|
6731
6731
|
}
|
|
6732
6732
|
try {
|
|
6733
|
-
const n = Buffer.isBuffer(buf) ?
|
|
6733
|
+
const n = Buffer.isBuffer(buf) ? fs26.writeSync(this.fd, buf) : fs26.writeSync(this.fd, buf, "utf8");
|
|
6734
6734
|
const releasedBufObj = releaseWritingBuf(buf, this._len, n);
|
|
6735
6735
|
buf = releasedBufObj.writingBuf;
|
|
6736
6736
|
this._len = releasedBufObj.len;
|
|
@@ -6746,7 +6746,7 @@ var require_sonic_boom = __commonJS({
|
|
|
6746
6746
|
}
|
|
6747
6747
|
}
|
|
6748
6748
|
try {
|
|
6749
|
-
|
|
6749
|
+
fs26.fsyncSync(this.fd);
|
|
6750
6750
|
} catch {
|
|
6751
6751
|
}
|
|
6752
6752
|
}
|
|
@@ -6767,7 +6767,7 @@ var require_sonic_boom = __commonJS({
|
|
|
6767
6767
|
buf = mergeBuf(this._bufs[0], this._lens[0]);
|
|
6768
6768
|
}
|
|
6769
6769
|
try {
|
|
6770
|
-
const n =
|
|
6770
|
+
const n = fs26.writeSync(this.fd, buf);
|
|
6771
6771
|
buf = buf.subarray(n);
|
|
6772
6772
|
this._len = Math.max(this._len - n, 0);
|
|
6773
6773
|
if (buf.length <= 0) {
|
|
@@ -6795,13 +6795,13 @@ var require_sonic_boom = __commonJS({
|
|
|
6795
6795
|
this._writingBuf = this._writingBuf.length ? this._writingBuf : this._bufs.shift() || "";
|
|
6796
6796
|
if (this.sync) {
|
|
6797
6797
|
try {
|
|
6798
|
-
const written = Buffer.isBuffer(this._writingBuf) ?
|
|
6798
|
+
const written = Buffer.isBuffer(this._writingBuf) ? fs26.writeSync(this.fd, this._writingBuf) : fs26.writeSync(this.fd, this._writingBuf, "utf8");
|
|
6799
6799
|
release(null, written);
|
|
6800
6800
|
} catch (err) {
|
|
6801
6801
|
release(err);
|
|
6802
6802
|
}
|
|
6803
6803
|
} else {
|
|
6804
|
-
|
|
6804
|
+
fs26.write(this.fd, this._writingBuf, release);
|
|
6805
6805
|
}
|
|
6806
6806
|
}
|
|
6807
6807
|
function actualWriteBuffer() {
|
|
@@ -6810,7 +6810,7 @@ var require_sonic_boom = __commonJS({
|
|
|
6810
6810
|
this._writingBuf = this._writingBuf.length ? this._writingBuf : mergeBuf(this._bufs.shift(), this._lens.shift());
|
|
6811
6811
|
if (this.sync) {
|
|
6812
6812
|
try {
|
|
6813
|
-
const written =
|
|
6813
|
+
const written = fs26.writeSync(this.fd, this._writingBuf);
|
|
6814
6814
|
release(null, written);
|
|
6815
6815
|
} catch (err) {
|
|
6816
6816
|
release(err);
|
|
@@ -6819,7 +6819,7 @@ var require_sonic_boom = __commonJS({
|
|
|
6819
6819
|
if (kCopyBuffer) {
|
|
6820
6820
|
this._writingBuf = Buffer.from(this._writingBuf);
|
|
6821
6821
|
}
|
|
6822
|
-
|
|
6822
|
+
fs26.write(this.fd, this._writingBuf, release);
|
|
6823
6823
|
}
|
|
6824
6824
|
}
|
|
6825
6825
|
function actualClose(sonic) {
|
|
@@ -6835,12 +6835,12 @@ var require_sonic_boom = __commonJS({
|
|
|
6835
6835
|
sonic._lens = [];
|
|
6836
6836
|
assert(typeof sonic.fd === "number", `sonic.fd must be a number, got ${typeof sonic.fd}`);
|
|
6837
6837
|
try {
|
|
6838
|
-
|
|
6838
|
+
fs26.fsync(sonic.fd, closeWrapped);
|
|
6839
6839
|
} catch {
|
|
6840
6840
|
}
|
|
6841
6841
|
function closeWrapped() {
|
|
6842
6842
|
if (sonic.fd !== 1 && sonic.fd !== 2) {
|
|
6843
|
-
|
|
6843
|
+
fs26.close(sonic.fd, done);
|
|
6844
6844
|
} else {
|
|
6845
6845
|
done();
|
|
6846
6846
|
}
|
|
@@ -9975,11 +9975,11 @@ var init_lib = __esm({
|
|
|
9975
9975
|
}
|
|
9976
9976
|
}
|
|
9977
9977
|
},
|
|
9978
|
-
addToPath: function addToPath(
|
|
9979
|
-
var last =
|
|
9978
|
+
addToPath: function addToPath(path28, added, removed, oldPosInc, options) {
|
|
9979
|
+
var last = path28.lastComponent;
|
|
9980
9980
|
if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) {
|
|
9981
9981
|
return {
|
|
9982
|
-
oldPos:
|
|
9982
|
+
oldPos: path28.oldPos + oldPosInc,
|
|
9983
9983
|
lastComponent: {
|
|
9984
9984
|
count: last.count + 1,
|
|
9985
9985
|
added,
|
|
@@ -9989,7 +9989,7 @@ var init_lib = __esm({
|
|
|
9989
9989
|
};
|
|
9990
9990
|
} else {
|
|
9991
9991
|
return {
|
|
9992
|
-
oldPos:
|
|
9992
|
+
oldPos: path28.oldPos + oldPosInc,
|
|
9993
9993
|
lastComponent: {
|
|
9994
9994
|
count: 1,
|
|
9995
9995
|
added,
|
|
@@ -10420,10 +10420,10 @@ function attachmentToHistoryMessage(o, ts) {
|
|
|
10420
10420
|
const memories = raw.map((m2) => {
|
|
10421
10421
|
if (!m2 || typeof m2 !== "object") return null;
|
|
10422
10422
|
const rec = m2;
|
|
10423
|
-
const
|
|
10423
|
+
const path28 = typeof rec.path === "string" ? rec.path : null;
|
|
10424
10424
|
const content = typeof rec.content === "string" ? rec.content : null;
|
|
10425
|
-
if (!
|
|
10426
|
-
const entry = { path:
|
|
10425
|
+
if (!path28 || content == null) return null;
|
|
10426
|
+
const entry = { path: path28, content };
|
|
10427
10427
|
if (typeof rec.mtimeMs === "number") entry.mtimeMs = rec.mtimeMs;
|
|
10428
10428
|
return entry;
|
|
10429
10429
|
}).filter((m2) => m2 !== null);
|
|
@@ -11227,10 +11227,10 @@ function parseAttachment(obj) {
|
|
|
11227
11227
|
const memories = raw.map((m2) => {
|
|
11228
11228
|
if (!m2 || typeof m2 !== "object") return null;
|
|
11229
11229
|
const rec = m2;
|
|
11230
|
-
const
|
|
11230
|
+
const path28 = typeof rec.path === "string" ? rec.path : null;
|
|
11231
11231
|
const content = typeof rec.content === "string" ? rec.content : null;
|
|
11232
|
-
if (!
|
|
11233
|
-
const out = { path:
|
|
11232
|
+
if (!path28 || content == null) return null;
|
|
11233
|
+
const out = { path: path28, content };
|
|
11234
11234
|
if (typeof rec.mtimeMs === "number") out.mtimeMs = rec.mtimeMs;
|
|
11235
11235
|
return out;
|
|
11236
11236
|
}).filter((m2) => m2 !== null);
|
|
@@ -20144,7 +20144,7 @@ var require_websocket_server = __commonJS({
|
|
|
20144
20144
|
// src/run-case/recorder.ts
|
|
20145
20145
|
function startRunCaseRecorder(opts) {
|
|
20146
20146
|
const now = opts.now ?? Date.now;
|
|
20147
|
-
const dir =
|
|
20147
|
+
const dir = import_node_path24.default.dirname(opts.recordPath);
|
|
20148
20148
|
let stream = null;
|
|
20149
20149
|
let closing = false;
|
|
20150
20150
|
let closedSettled = false;
|
|
@@ -20158,8 +20158,8 @@ function startRunCaseRecorder(opts) {
|
|
|
20158
20158
|
});
|
|
20159
20159
|
const ensureStream = () => {
|
|
20160
20160
|
if (stream) return stream;
|
|
20161
|
-
|
|
20162
|
-
stream =
|
|
20161
|
+
import_node_fs23.default.mkdirSync(dir, { recursive: true });
|
|
20162
|
+
stream = import_node_fs23.default.createWriteStream(opts.recordPath, { flags: "a" });
|
|
20163
20163
|
stream.on("close", () => closedResolve());
|
|
20164
20164
|
return stream;
|
|
20165
20165
|
};
|
|
@@ -20184,12 +20184,12 @@ function startRunCaseRecorder(opts) {
|
|
|
20184
20184
|
};
|
|
20185
20185
|
return { tap, close, closed };
|
|
20186
20186
|
}
|
|
20187
|
-
var
|
|
20187
|
+
var import_node_fs23, import_node_path24;
|
|
20188
20188
|
var init_recorder = __esm({
|
|
20189
20189
|
"src/run-case/recorder.ts"() {
|
|
20190
20190
|
"use strict";
|
|
20191
|
-
|
|
20192
|
-
|
|
20191
|
+
import_node_fs23 = __toESM(require("fs"), 1);
|
|
20192
|
+
import_node_path24 = __toESM(require("path"), 1);
|
|
20193
20193
|
}
|
|
20194
20194
|
});
|
|
20195
20195
|
|
|
@@ -20232,7 +20232,7 @@ var init_wire = __esm({
|
|
|
20232
20232
|
// src/run-case/controller.ts
|
|
20233
20233
|
async function runController(opts) {
|
|
20234
20234
|
const now = opts.now ?? Date.now;
|
|
20235
|
-
const cwd = opts.cwd ?? (0,
|
|
20235
|
+
const cwd = opts.cwd ?? (0, import_node_fs24.mkdtempSync)(import_node_path25.default.join(import_node_os15.default.tmpdir(), "clawd-runcase-"));
|
|
20236
20236
|
const ownsCwd = opts.cwd === void 0;
|
|
20237
20237
|
const recorder = startRunCaseRecorder({ recordPath: opts.record, now });
|
|
20238
20238
|
const spawnCtx = { cwd };
|
|
@@ -20393,19 +20393,19 @@ async function runController(opts) {
|
|
|
20393
20393
|
if (sigintHandler) process.off("SIGINT", sigintHandler);
|
|
20394
20394
|
if (ownsCwd) {
|
|
20395
20395
|
try {
|
|
20396
|
-
(0,
|
|
20396
|
+
(0, import_node_fs24.rmSync)(cwd, { recursive: true, force: true });
|
|
20397
20397
|
} catch {
|
|
20398
20398
|
}
|
|
20399
20399
|
}
|
|
20400
20400
|
return exitCode ?? 0;
|
|
20401
20401
|
}
|
|
20402
|
-
var
|
|
20402
|
+
var import_node_fs24, import_node_os15, import_node_path25;
|
|
20403
20403
|
var init_controller = __esm({
|
|
20404
20404
|
"src/run-case/controller.ts"() {
|
|
20405
20405
|
"use strict";
|
|
20406
|
-
|
|
20406
|
+
import_node_fs24 = require("fs");
|
|
20407
20407
|
import_node_os15 = __toESM(require("os"), 1);
|
|
20408
|
-
|
|
20408
|
+
import_node_path25 = __toESM(require("path"), 1);
|
|
20409
20409
|
init_claude();
|
|
20410
20410
|
init_stdout_splitter();
|
|
20411
20411
|
init_permission_stdio();
|
|
@@ -20637,8 +20637,8 @@ Env (advanced):
|
|
|
20637
20637
|
`;
|
|
20638
20638
|
|
|
20639
20639
|
// src/index.ts
|
|
20640
|
-
var
|
|
20641
|
-
var
|
|
20640
|
+
var import_node_path23 = __toESM(require("path"), 1);
|
|
20641
|
+
var import_node_fs22 = __toESM(require("fs"), 1);
|
|
20642
20642
|
|
|
20643
20643
|
// src/logger.ts
|
|
20644
20644
|
var import_node_fs2 = __toESM(require("fs"), 1);
|
|
@@ -26055,10 +26055,10 @@ var StateFileManager = class {
|
|
|
26055
26055
|
};
|
|
26056
26056
|
|
|
26057
26057
|
// src/tunnel/tunnel-manager.ts
|
|
26058
|
-
var
|
|
26059
|
-
var
|
|
26058
|
+
var import_node_fs17 = __toESM(require("fs"), 1);
|
|
26059
|
+
var import_node_path18 = __toESM(require("path"), 1);
|
|
26060
26060
|
var import_node_crypto4 = __toESM(require("crypto"), 1);
|
|
26061
|
-
var
|
|
26061
|
+
var import_node_child_process5 = require("child_process");
|
|
26062
26062
|
|
|
26063
26063
|
// src/tunnel/tunnel-store.ts
|
|
26064
26064
|
var import_node_fs14 = __toESM(require("fs"), 1);
|
|
@@ -26309,12 +26309,126 @@ async function extractFrpcFromTarball(tarball, binDir, version2, platform, destB
|
|
|
26309
26309
|
}
|
|
26310
26310
|
}
|
|
26311
26311
|
|
|
26312
|
+
// src/tunnel/frpc-process.ts
|
|
26313
|
+
var import_node_fs16 = __toESM(require("fs"), 1);
|
|
26314
|
+
var import_node_path17 = __toESM(require("path"), 1);
|
|
26315
|
+
var import_node_child_process4 = require("child_process");
|
|
26316
|
+
function frpcPidFilePath(dataDir) {
|
|
26317
|
+
return import_node_path17.default.join(dataDir, "frpc.pid");
|
|
26318
|
+
}
|
|
26319
|
+
function writeFrpcPid(dataDir, pid) {
|
|
26320
|
+
try {
|
|
26321
|
+
import_node_fs16.default.writeFileSync(frpcPidFilePath(dataDir), String(pid), { mode: 384 });
|
|
26322
|
+
} catch {
|
|
26323
|
+
}
|
|
26324
|
+
}
|
|
26325
|
+
function clearFrpcPid(dataDir) {
|
|
26326
|
+
try {
|
|
26327
|
+
import_node_fs16.default.unlinkSync(frpcPidFilePath(dataDir));
|
|
26328
|
+
} catch {
|
|
26329
|
+
}
|
|
26330
|
+
}
|
|
26331
|
+
function defaultIsPidAlive(pid) {
|
|
26332
|
+
if (!Number.isFinite(pid) || pid <= 0) return false;
|
|
26333
|
+
try {
|
|
26334
|
+
process.kill(pid, 0);
|
|
26335
|
+
return true;
|
|
26336
|
+
} catch (err) {
|
|
26337
|
+
const code = err.code;
|
|
26338
|
+
return code === "EPERM";
|
|
26339
|
+
}
|
|
26340
|
+
}
|
|
26341
|
+
function defaultReadPidFile(file) {
|
|
26342
|
+
try {
|
|
26343
|
+
return import_node_fs16.default.readFileSync(file, "utf8");
|
|
26344
|
+
} catch {
|
|
26345
|
+
return null;
|
|
26346
|
+
}
|
|
26347
|
+
}
|
|
26348
|
+
function defaultKillPid(pid, signal) {
|
|
26349
|
+
try {
|
|
26350
|
+
process.kill(pid, signal);
|
|
26351
|
+
} catch {
|
|
26352
|
+
}
|
|
26353
|
+
}
|
|
26354
|
+
function defaultSleep(ms) {
|
|
26355
|
+
return new Promise((r) => setTimeout(r, ms));
|
|
26356
|
+
}
|
|
26357
|
+
async function killStaleFrpc(deps) {
|
|
26358
|
+
const pidFile = frpcPidFilePath(deps.dataDir);
|
|
26359
|
+
const tomlPath = import_node_path17.default.join(deps.dataDir, "frpc.toml");
|
|
26360
|
+
const readPidFile = deps.readPidFileImpl ?? defaultReadPidFile;
|
|
26361
|
+
const isAlive = deps.isPidAliveImpl ?? defaultIsPidAlive;
|
|
26362
|
+
const killPid = deps.killPidImpl ?? defaultKillPid;
|
|
26363
|
+
const scanPids = deps.scanFrpcPidsImpl ?? ((tp) => defaultScanFrpcPidsByCmdline(tp, deps.logger));
|
|
26364
|
+
const sleep = deps.sleepImpl ?? defaultSleep;
|
|
26365
|
+
const victims = /* @__PURE__ */ new Set();
|
|
26366
|
+
const raw = readPidFile(pidFile);
|
|
26367
|
+
if (raw) {
|
|
26368
|
+
const pid = parseInt(raw.trim(), 10);
|
|
26369
|
+
if (Number.isFinite(pid) && pid > 0 && pid !== deps.ownPid && isAlive(pid)) {
|
|
26370
|
+
victims.add(pid);
|
|
26371
|
+
}
|
|
26372
|
+
}
|
|
26373
|
+
try {
|
|
26374
|
+
const scanned = await scanPids(tomlPath);
|
|
26375
|
+
for (const pid of scanned) {
|
|
26376
|
+
if (pid > 0 && pid !== deps.ownPid && isAlive(pid)) victims.add(pid);
|
|
26377
|
+
}
|
|
26378
|
+
} catch (e) {
|
|
26379
|
+
deps.logger?.warn("tunnel: stale-frpc cmdline scan failed", { err: e.message });
|
|
26380
|
+
}
|
|
26381
|
+
if (victims.size === 0) {
|
|
26382
|
+
try {
|
|
26383
|
+
import_node_fs16.default.unlinkSync(pidFile);
|
|
26384
|
+
} catch {
|
|
26385
|
+
}
|
|
26386
|
+
return;
|
|
26387
|
+
}
|
|
26388
|
+
for (const pid of victims) {
|
|
26389
|
+
deps.logger?.warn("tunnel: killing stale frpc before respawn", { pid });
|
|
26390
|
+
killPid(pid, "SIGKILL");
|
|
26391
|
+
}
|
|
26392
|
+
await sleep(deps.reapWaitMs ?? 300);
|
|
26393
|
+
try {
|
|
26394
|
+
import_node_fs16.default.unlinkSync(pidFile);
|
|
26395
|
+
} catch {
|
|
26396
|
+
}
|
|
26397
|
+
}
|
|
26398
|
+
async function defaultScanFrpcPidsByCmdline(tomlPath, logger) {
|
|
26399
|
+
if (process.platform === "win32") return [];
|
|
26400
|
+
return new Promise((resolve2) => {
|
|
26401
|
+
const ps = (0, import_node_child_process4.spawn)("ps", ["-axo", "pid=,command="], { stdio: ["ignore", "pipe", "ignore"] });
|
|
26402
|
+
let buf = "";
|
|
26403
|
+
ps.stdout.on("data", (c) => {
|
|
26404
|
+
buf += c.toString();
|
|
26405
|
+
});
|
|
26406
|
+
ps.on("exit", () => {
|
|
26407
|
+
const pids = [];
|
|
26408
|
+
for (const line of buf.split("\n")) {
|
|
26409
|
+
const m2 = /^\s*(\d+)\s+(.*)$/.exec(line);
|
|
26410
|
+
if (!m2) continue;
|
|
26411
|
+
const cmd = m2[2];
|
|
26412
|
+
if (!/\bfrpc\b/.test(cmd)) continue;
|
|
26413
|
+
if (!cmd.includes(tomlPath)) continue;
|
|
26414
|
+
const pid = parseInt(m2[1], 10);
|
|
26415
|
+
if (Number.isFinite(pid) && pid > 0) pids.push(pid);
|
|
26416
|
+
}
|
|
26417
|
+
resolve2(pids);
|
|
26418
|
+
});
|
|
26419
|
+
ps.on("error", (e) => {
|
|
26420
|
+
logger?.warn("tunnel: ps scan failed", { err: e.message });
|
|
26421
|
+
resolve2([]);
|
|
26422
|
+
});
|
|
26423
|
+
});
|
|
26424
|
+
}
|
|
26425
|
+
|
|
26312
26426
|
// src/tunnel/tunnel-manager.ts
|
|
26313
26427
|
var DEFAULT_TUNNEL_TTL_MS = 7 * 24 * 60 * 60 * 1e3;
|
|
26314
26428
|
var TunnelManager = class {
|
|
26315
26429
|
constructor(deps) {
|
|
26316
26430
|
this.deps = deps;
|
|
26317
|
-
this.store = deps.store ?? new TunnelStore(
|
|
26431
|
+
this.store = deps.store ?? new TunnelStore(import_node_path18.default.join(deps.dataDir, "tunnel.json"));
|
|
26318
26432
|
this.ttlMs = deps.ttlMs ?? DEFAULT_TUNNEL_TTL_MS;
|
|
26319
26433
|
this.startupTimeoutMs = deps.startupTimeoutMs ?? 15e3;
|
|
26320
26434
|
}
|
|
@@ -26332,6 +26446,11 @@ var TunnelManager = class {
|
|
|
26332
26446
|
}
|
|
26333
26447
|
async start(opts) {
|
|
26334
26448
|
const { logger } = this.deps;
|
|
26449
|
+
await (this.deps.killStaleImpl ?? killStaleFrpc)({
|
|
26450
|
+
dataDir: this.deps.dataDir,
|
|
26451
|
+
ownPid: process.pid,
|
|
26452
|
+
logger
|
|
26453
|
+
});
|
|
26335
26454
|
if (!this.deps.noPersist) {
|
|
26336
26455
|
const cached = await this.store.get();
|
|
26337
26456
|
if (cached && this.isFresh(cached)) {
|
|
@@ -26372,7 +26491,10 @@ var TunnelManager = class {
|
|
|
26372
26491
|
this.stopping = true;
|
|
26373
26492
|
const proc = this.proc;
|
|
26374
26493
|
this.proc = null;
|
|
26375
|
-
if (!proc)
|
|
26494
|
+
if (!proc) {
|
|
26495
|
+
clearFrpcPid(this.deps.dataDir);
|
|
26496
|
+
return;
|
|
26497
|
+
}
|
|
26376
26498
|
proc.kill("SIGTERM");
|
|
26377
26499
|
await new Promise((resolve2) => {
|
|
26378
26500
|
const t = setTimeout(() => {
|
|
@@ -26387,12 +26509,14 @@ var TunnelManager = class {
|
|
|
26387
26509
|
resolve2();
|
|
26388
26510
|
});
|
|
26389
26511
|
});
|
|
26512
|
+
clearFrpcPid(this.deps.dataDir);
|
|
26390
26513
|
}
|
|
26391
26514
|
// 同步杀子进程:父进程崩溃 / SIGHUP / process.exit 路径下使用,
|
|
26392
26515
|
// async stop() 跑不完时的兜底,避免留下孤儿 frpc。
|
|
26393
26516
|
killSync() {
|
|
26394
26517
|
const proc = this.proc;
|
|
26395
26518
|
this.proc = null;
|
|
26519
|
+
clearFrpcPid(this.deps.dataDir);
|
|
26396
26520
|
if (!proc) return;
|
|
26397
26521
|
try {
|
|
26398
26522
|
proc.kill("SIGTERM");
|
|
@@ -26431,7 +26555,7 @@ var TunnelManager = class {
|
|
|
26431
26555
|
dataDir: this.deps.dataDir,
|
|
26432
26556
|
override: this.deps.frpcBinaryOverride ?? void 0
|
|
26433
26557
|
});
|
|
26434
|
-
const tomlPath =
|
|
26558
|
+
const tomlPath = import_node_path18.default.join(this.deps.dataDir, "frpc.toml");
|
|
26435
26559
|
const proxyName = `clawd-${t.subdomain}-${localPort}-${import_node_crypto4.default.randomBytes(3).toString("hex")}`;
|
|
26436
26560
|
const toml = buildFrpcToml({
|
|
26437
26561
|
serverAddr: t.frpsHost,
|
|
@@ -26442,12 +26566,12 @@ var TunnelManager = class {
|
|
|
26442
26566
|
localPort,
|
|
26443
26567
|
logLevel: "info"
|
|
26444
26568
|
});
|
|
26445
|
-
await
|
|
26446
|
-
const proc = (this.deps.spawnImpl ??
|
|
26569
|
+
await import_node_fs17.default.promises.writeFile(tomlPath, toml, { mode: 384 });
|
|
26570
|
+
const proc = (this.deps.spawnImpl ?? import_node_child_process5.spawn)(frpcBin, ["-c", tomlPath], {
|
|
26447
26571
|
stdio: ["ignore", "pipe", "pipe"]
|
|
26448
26572
|
});
|
|
26449
|
-
const logFilePath =
|
|
26450
|
-
const logStream =
|
|
26573
|
+
const logFilePath = import_node_path18.default.join(this.deps.dataDir, "frpc.log");
|
|
26574
|
+
const logStream = import_node_fs17.default.createWriteStream(logFilePath, { flags: "a", mode: 384 });
|
|
26451
26575
|
logStream.on("error", () => {
|
|
26452
26576
|
});
|
|
26453
26577
|
const tee = (chunk) => {
|
|
@@ -26469,7 +26593,8 @@ var TunnelManager = class {
|
|
|
26469
26593
|
${tail}` : ready.error;
|
|
26470
26594
|
return { ok: false, error: new Error(msg) };
|
|
26471
26595
|
}
|
|
26472
|
-
|
|
26596
|
+
if (typeof proc.pid === "number") writeFrpcPid(this.deps.dataDir, proc.pid);
|
|
26597
|
+
this.deps.logger?.info("tunnel: frpc up", { subdomain: t.subdomain, url: t.url, pid: proc.pid ?? null });
|
|
26473
26598
|
return { ok: true, proc };
|
|
26474
26599
|
} catch (err) {
|
|
26475
26600
|
if (err instanceof TunnelRegisterError) throw err;
|
|
@@ -26539,12 +26664,12 @@ function deriveStableDeviceKey(opts = {}) {
|
|
|
26539
26664
|
}
|
|
26540
26665
|
|
|
26541
26666
|
// src/auth-store.ts
|
|
26542
|
-
var
|
|
26543
|
-
var
|
|
26667
|
+
var import_node_fs18 = __toESM(require("fs"), 1);
|
|
26668
|
+
var import_node_path19 = __toESM(require("path"), 1);
|
|
26544
26669
|
var import_node_crypto6 = __toESM(require("crypto"), 1);
|
|
26545
26670
|
var AUTH_FILE_NAME = "auth.json";
|
|
26546
26671
|
function authFilePath(dataDir) {
|
|
26547
|
-
return
|
|
26672
|
+
return import_node_path19.default.join(dataDir, AUTH_FILE_NAME);
|
|
26548
26673
|
}
|
|
26549
26674
|
function loadOrCreateAuthToken(opts) {
|
|
26550
26675
|
const file = authFilePath(opts.dataDir);
|
|
@@ -26560,7 +26685,7 @@ function defaultGenerate() {
|
|
|
26560
26685
|
}
|
|
26561
26686
|
function readAuthFile(file) {
|
|
26562
26687
|
try {
|
|
26563
|
-
const raw =
|
|
26688
|
+
const raw = import_node_fs18.default.readFileSync(file, "utf8");
|
|
26564
26689
|
const parsed = JSON.parse(raw);
|
|
26565
26690
|
if (typeof parsed?.token === "string" && parsed.token.length > 0) {
|
|
26566
26691
|
return {
|
|
@@ -26576,25 +26701,25 @@ function readAuthFile(file) {
|
|
|
26576
26701
|
}
|
|
26577
26702
|
}
|
|
26578
26703
|
function writeAuthFile(file, content) {
|
|
26579
|
-
|
|
26580
|
-
|
|
26704
|
+
import_node_fs18.default.mkdirSync(import_node_path19.default.dirname(file), { recursive: true });
|
|
26705
|
+
import_node_fs18.default.writeFileSync(file, JSON.stringify(content, null, 2), { mode: 384 });
|
|
26581
26706
|
try {
|
|
26582
|
-
|
|
26707
|
+
import_node_fs18.default.chmodSync(file, 384);
|
|
26583
26708
|
} catch {
|
|
26584
26709
|
}
|
|
26585
26710
|
}
|
|
26586
26711
|
|
|
26587
26712
|
// src/owner-profile.ts
|
|
26588
|
-
var
|
|
26713
|
+
var import_node_fs19 = __toESM(require("fs"), 1);
|
|
26589
26714
|
var import_node_os11 = __toESM(require("os"), 1);
|
|
26590
|
-
var
|
|
26715
|
+
var import_node_path20 = __toESM(require("path"), 1);
|
|
26591
26716
|
var PROFILE_FILENAME = "profile.json";
|
|
26592
26717
|
function loadOwnerDisplayName(dataDir) {
|
|
26593
26718
|
const fallback = import_node_os11.default.userInfo().username;
|
|
26594
|
-
const profilePath =
|
|
26719
|
+
const profilePath = import_node_path20.default.join(dataDir, PROFILE_FILENAME);
|
|
26595
26720
|
let raw;
|
|
26596
26721
|
try {
|
|
26597
|
-
raw =
|
|
26722
|
+
raw = import_node_fs19.default.readFileSync(profilePath, "utf8");
|
|
26598
26723
|
} catch {
|
|
26599
26724
|
return fallback;
|
|
26600
26725
|
}
|
|
@@ -26623,12 +26748,12 @@ init_protocol();
|
|
|
26623
26748
|
init_protocol();
|
|
26624
26749
|
|
|
26625
26750
|
// src/session/fork.ts
|
|
26626
|
-
var
|
|
26751
|
+
var import_node_fs20 = __toESM(require("fs"), 1);
|
|
26627
26752
|
var import_node_os12 = __toESM(require("os"), 1);
|
|
26628
|
-
var
|
|
26753
|
+
var import_node_path21 = __toESM(require("path"), 1);
|
|
26629
26754
|
init_claude_history();
|
|
26630
26755
|
function readJsonlEntries(file) {
|
|
26631
|
-
const raw =
|
|
26756
|
+
const raw = import_node_fs20.default.readFileSync(file, "utf8");
|
|
26632
26757
|
const out = [];
|
|
26633
26758
|
for (const line of raw.split("\n")) {
|
|
26634
26759
|
const t = line.trim();
|
|
@@ -26641,10 +26766,10 @@ function readJsonlEntries(file) {
|
|
|
26641
26766
|
return out;
|
|
26642
26767
|
}
|
|
26643
26768
|
function forkSession(input) {
|
|
26644
|
-
const baseDir = input.baseDir ??
|
|
26645
|
-
const projectDir =
|
|
26646
|
-
const sourceFile =
|
|
26647
|
-
if (!
|
|
26769
|
+
const baseDir = input.baseDir ?? import_node_path21.default.join(import_node_os12.default.homedir(), ".claude");
|
|
26770
|
+
const projectDir = import_node_path21.default.join(baseDir, "projects", cwdToHashDir(input.cwd));
|
|
26771
|
+
const sourceFile = import_node_path21.default.join(projectDir, `${input.toolSessionId}.jsonl`);
|
|
26772
|
+
if (!import_node_fs20.default.existsSync(sourceFile)) {
|
|
26648
26773
|
throw new Error(`fork: source transcript not found: ${sourceFile}`);
|
|
26649
26774
|
}
|
|
26650
26775
|
const entries = readJsonlEntries(sourceFile);
|
|
@@ -26674,9 +26799,9 @@ function forkSession(input) {
|
|
|
26674
26799
|
}
|
|
26675
26800
|
forkedLines.push(JSON.stringify(forked));
|
|
26676
26801
|
}
|
|
26677
|
-
const forkedFilePath =
|
|
26678
|
-
|
|
26679
|
-
|
|
26802
|
+
const forkedFilePath = import_node_path21.default.join(projectDir, `${forkedToolSessionId}.jsonl`);
|
|
26803
|
+
import_node_fs20.default.mkdirSync(projectDir, { recursive: true });
|
|
26804
|
+
import_node_fs20.default.writeFileSync(forkedFilePath, forkedLines.join("\n") + "\n", { mode: 384 });
|
|
26680
26805
|
return { forkedToolSessionId, forkedFilePath };
|
|
26681
26806
|
}
|
|
26682
26807
|
|
|
@@ -26996,12 +27121,12 @@ function buildWorkspaceHandlers(deps) {
|
|
|
26996
27121
|
init_protocol();
|
|
26997
27122
|
|
|
26998
27123
|
// src/workspace/git.ts
|
|
26999
|
-
var
|
|
27000
|
-
var
|
|
27124
|
+
var import_node_child_process6 = require("child_process");
|
|
27125
|
+
var import_node_fs21 = __toESM(require("fs"), 1);
|
|
27001
27126
|
var import_node_os13 = __toESM(require("os"), 1);
|
|
27002
|
-
var
|
|
27127
|
+
var import_node_path22 = __toESM(require("path"), 1);
|
|
27003
27128
|
var import_node_util = require("util");
|
|
27004
|
-
var pexec = (0, import_node_util.promisify)(
|
|
27129
|
+
var pexec = (0, import_node_util.promisify)(import_node_child_process6.execFile);
|
|
27005
27130
|
function formatChildProcessError(err) {
|
|
27006
27131
|
const e = err;
|
|
27007
27132
|
const stderrLine = (e.stderr ?? "").split("\n").map((s) => s.trim()).find((s) => s.length > 0);
|
|
@@ -27014,9 +27139,9 @@ function formatChildProcessError(err) {
|
|
|
27014
27139
|
return e.message ?? "unknown error";
|
|
27015
27140
|
}
|
|
27016
27141
|
function normalizePath(p2) {
|
|
27017
|
-
const resolved =
|
|
27142
|
+
const resolved = import_node_path22.default.resolve(p2);
|
|
27018
27143
|
try {
|
|
27019
|
-
return
|
|
27144
|
+
return import_node_fs21.default.realpathSync(resolved);
|
|
27020
27145
|
} catch {
|
|
27021
27146
|
return resolved;
|
|
27022
27147
|
}
|
|
@@ -27117,13 +27242,13 @@ function flattenToDirName(branch) {
|
|
|
27117
27242
|
}
|
|
27118
27243
|
function encodeClaudeProjectDir(absPath) {
|
|
27119
27244
|
if (!absPath || typeof absPath !== "string") return "";
|
|
27120
|
-
let canonical =
|
|
27245
|
+
let canonical = import_node_path22.default.resolve(absPath);
|
|
27121
27246
|
try {
|
|
27122
|
-
canonical =
|
|
27247
|
+
canonical = import_node_fs21.default.realpathSync(canonical);
|
|
27123
27248
|
} catch {
|
|
27124
27249
|
try {
|
|
27125
|
-
const parent =
|
|
27126
|
-
canonical =
|
|
27250
|
+
const parent = import_node_fs21.default.realpathSync(import_node_path22.default.dirname(canonical));
|
|
27251
|
+
canonical = import_node_path22.default.join(parent, import_node_path22.default.basename(canonical));
|
|
27127
27252
|
} catch {
|
|
27128
27253
|
}
|
|
27129
27254
|
}
|
|
@@ -27147,11 +27272,11 @@ async function createWorktree(input) {
|
|
|
27147
27272
|
if (!isGitRoot) {
|
|
27148
27273
|
throw new Error(`\u76EE\u5F55 ${cwd} \u4E0D\u662F git repo \u6839`);
|
|
27149
27274
|
}
|
|
27150
|
-
const parent =
|
|
27151
|
-
if (parent === "/" || parent ===
|
|
27275
|
+
const parent = import_node_path22.default.dirname(import_node_path22.default.resolve(cwd));
|
|
27276
|
+
if (parent === "/" || parent === import_node_path22.default.resolve(cwd)) {
|
|
27152
27277
|
throw new Error("repo \u5728\u78C1\u76D8\u6839\u76EE\u5F55\uFF0C\u65E0\u6CD5\u5728\u540C\u7EA7\u521B\u5EFA worktree");
|
|
27153
27278
|
}
|
|
27154
|
-
const worktreeRoot =
|
|
27279
|
+
const worktreeRoot = import_node_path22.default.join(parent, dirName);
|
|
27155
27280
|
try {
|
|
27156
27281
|
await pexec("git", ["-C", cwd, "fetch", "origin", baseBranch, "--no-tags"], {
|
|
27157
27282
|
timeout: 3e4
|
|
@@ -27170,7 +27295,7 @@ async function createWorktree(input) {
|
|
|
27170
27295
|
const msg = err.message;
|
|
27171
27296
|
if (msg.startsWith("\u5206\u652F ")) throw err;
|
|
27172
27297
|
}
|
|
27173
|
-
if (
|
|
27298
|
+
if (import_node_fs21.default.existsSync(worktreeRoot)) {
|
|
27174
27299
|
throw new Error(`\u76EE\u5F55 ${worktreeRoot} \u5DF2\u5B58\u5728\uFF0C\u8BF7\u6362\u4E00\u4E2A label \u6216\u6E05\u7406\u540E\u91CD\u8BD5`);
|
|
27175
27300
|
}
|
|
27176
27301
|
try {
|
|
@@ -27198,8 +27323,8 @@ async function removeWorktree(input) {
|
|
|
27198
27323
|
);
|
|
27199
27324
|
const gitCommonDir = stdout.trim();
|
|
27200
27325
|
if (!gitCommonDir) throw new Error("empty git-common-dir");
|
|
27201
|
-
const absGitCommon =
|
|
27202
|
-
repoRoot =
|
|
27326
|
+
const absGitCommon = import_node_path22.default.isAbsolute(gitCommonDir) ? gitCommonDir : import_node_path22.default.resolve(worktreeRoot, gitCommonDir);
|
|
27327
|
+
repoRoot = import_node_path22.default.dirname(absGitCommon);
|
|
27203
27328
|
} catch {
|
|
27204
27329
|
repoRoot = null;
|
|
27205
27330
|
}
|
|
@@ -27211,7 +27336,7 @@ async function removeWorktree(input) {
|
|
|
27211
27336
|
} catch (err) {
|
|
27212
27337
|
const stderr = err.stderr ?? "";
|
|
27213
27338
|
const lower = stderr.toLowerCase();
|
|
27214
|
-
const vanished = lower.includes("not a working tree") || lower.includes("is not a working tree") || !
|
|
27339
|
+
const vanished = lower.includes("not a working tree") || lower.includes("is not a working tree") || !import_node_fs21.default.existsSync(worktreeRoot);
|
|
27215
27340
|
if (!vanished) {
|
|
27216
27341
|
throw new Error(`\u6E05\u7406 worktree \u5931\u8D25\uFF1A${formatChildProcessError(err)}`);
|
|
27217
27342
|
}
|
|
@@ -27230,10 +27355,10 @@ async function removeWorktree(input) {
|
|
|
27230
27355
|
try {
|
|
27231
27356
|
const encoded = encodeClaudeProjectDir(worktreeRoot);
|
|
27232
27357
|
if (encoded) {
|
|
27233
|
-
const projectsRoot =
|
|
27234
|
-
const target =
|
|
27235
|
-
if (target.startsWith(projectsRoot +
|
|
27236
|
-
|
|
27358
|
+
const projectsRoot = import_node_path22.default.join(import_node_os13.default.homedir(), ".claude", "projects");
|
|
27359
|
+
const target = import_node_path22.default.resolve(projectsRoot, encoded);
|
|
27360
|
+
if (target.startsWith(projectsRoot + import_node_path22.default.sep) && target !== projectsRoot) {
|
|
27361
|
+
import_node_fs21.default.rmSync(target, { recursive: true, force: true });
|
|
27237
27362
|
}
|
|
27238
27363
|
}
|
|
27239
27364
|
} catch {
|
|
@@ -27466,7 +27591,7 @@ function buildMethodHandlers(deps) {
|
|
|
27466
27591
|
async function startDaemon(config) {
|
|
27467
27592
|
const logger = createLogger({
|
|
27468
27593
|
level: config.logLevel,
|
|
27469
|
-
file:
|
|
27594
|
+
file: import_node_path23.default.join(config.dataDir, "clawd.log")
|
|
27470
27595
|
});
|
|
27471
27596
|
logger.info("starting clawd", { version, config: { port: config.port, host: config.host, dataDir: config.dataDir } });
|
|
27472
27597
|
const stateMgr = new StateFileManager({ dataDir: config.dataDir });
|
|
@@ -27498,7 +27623,7 @@ async function startDaemon(config) {
|
|
|
27498
27623
|
const agents = new AgentsScanner();
|
|
27499
27624
|
const history = new ClaudeHistoryReader();
|
|
27500
27625
|
let transport = null;
|
|
27501
|
-
const personaStore = new PersonaStore(
|
|
27626
|
+
const personaStore = new PersonaStore(import_node_path23.default.join(config.dataDir, "personas"));
|
|
27502
27627
|
const defaultsRoot = findDefaultsRoot();
|
|
27503
27628
|
if (defaultsRoot) {
|
|
27504
27629
|
seedDefaultPersonas({ store: personaStore, defaultsRoot, logger });
|
|
@@ -27512,7 +27637,7 @@ async function startDaemon(config) {
|
|
|
27512
27637
|
getAdapter,
|
|
27513
27638
|
historyReader: history,
|
|
27514
27639
|
dataDir: config.dataDir,
|
|
27515
|
-
personaRoot:
|
|
27640
|
+
personaRoot: import_node_path23.default.join(config.dataDir, "personas"),
|
|
27516
27641
|
personaStore,
|
|
27517
27642
|
ownerDisplayName,
|
|
27518
27643
|
mode: config.mode,
|
|
@@ -27730,8 +27855,8 @@ async function startDaemon(config) {
|
|
|
27730
27855
|
const lines = [
|
|
27731
27856
|
`Tunnel: ${r.url}`,
|
|
27732
27857
|
...resolvedAuthToken ? [`Connect: ${connectUrl}`] : [],
|
|
27733
|
-
`Frpc config: ${
|
|
27734
|
-
`Frpc log: ${
|
|
27858
|
+
`Frpc config: ${import_node_path23.default.join(config.dataDir, "frpc.toml")}`,
|
|
27859
|
+
`Frpc log: ${import_node_path23.default.join(config.dataDir, "frpc.log")}`
|
|
27735
27860
|
];
|
|
27736
27861
|
const width = Math.max(...lines.map((l) => l.length));
|
|
27737
27862
|
const bar = "\u2550".repeat(width + 4);
|
|
@@ -27744,8 +27869,8 @@ ${bar}
|
|
|
27744
27869
|
|
|
27745
27870
|
`);
|
|
27746
27871
|
try {
|
|
27747
|
-
const connectPath =
|
|
27748
|
-
|
|
27872
|
+
const connectPath = import_node_path23.default.join(config.dataDir, "connect.txt");
|
|
27873
|
+
import_node_fs22.default.writeFileSync(connectPath, lines.join("\n") + "\n", { mode: 384 });
|
|
27749
27874
|
} catch {
|
|
27750
27875
|
}
|
|
27751
27876
|
} catch (err) {
|
package/package.json
CHANGED