@clawos-dev/clawd 0.2.591 → 0.2.593
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 +311 -249
- 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:
|
|
454
|
-
const fullPath = [...
|
|
453
|
+
const { data, path: path105, errorMaps, issueData } = params;
|
|
454
|
+
const fullPath = [...path105, ...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,
|
|
765
|
+
constructor(parent, value, path105, key) {
|
|
766
766
|
this._cachedPath = [];
|
|
767
767
|
this.parent = parent;
|
|
768
768
|
this.data = value;
|
|
769
|
-
this._path =
|
|
769
|
+
this._path = path105;
|
|
770
770
|
this._key = key;
|
|
771
771
|
}
|
|
772
772
|
get path() {
|
|
@@ -10325,8 +10325,8 @@ var require_req = __commonJS({
|
|
|
10325
10325
|
if (req.originalUrl) {
|
|
10326
10326
|
_req.url = req.originalUrl;
|
|
10327
10327
|
} else {
|
|
10328
|
-
const
|
|
10329
|
-
_req.url = typeof
|
|
10328
|
+
const path105 = req.path;
|
|
10329
|
+
_req.url = typeof path105 === "string" ? path105 : req.url ? req.url.path || req.url : void 0;
|
|
10330
10330
|
}
|
|
10331
10331
|
if (req.query) {
|
|
10332
10332
|
_req.query = req.query;
|
|
@@ -10491,14 +10491,14 @@ var require_redact = __commonJS({
|
|
|
10491
10491
|
}
|
|
10492
10492
|
return obj;
|
|
10493
10493
|
}
|
|
10494
|
-
function parsePath(
|
|
10494
|
+
function parsePath(path105) {
|
|
10495
10495
|
const parts = [];
|
|
10496
10496
|
let current = "";
|
|
10497
10497
|
let inBrackets = false;
|
|
10498
10498
|
let inQuotes = false;
|
|
10499
10499
|
let quoteChar = "";
|
|
10500
|
-
for (let i2 = 0; i2 <
|
|
10501
|
-
const char =
|
|
10500
|
+
for (let i2 = 0; i2 < path105.length; i2++) {
|
|
10501
|
+
const char = path105[i2];
|
|
10502
10502
|
if (!inBrackets && char === ".") {
|
|
10503
10503
|
if (current) {
|
|
10504
10504
|
parts.push(current);
|
|
@@ -10629,10 +10629,10 @@ var require_redact = __commonJS({
|
|
|
10629
10629
|
return current;
|
|
10630
10630
|
}
|
|
10631
10631
|
function redactPaths(obj, paths, censor, remove = false) {
|
|
10632
|
-
for (const
|
|
10633
|
-
const parts = parsePath(
|
|
10632
|
+
for (const path105 of paths) {
|
|
10633
|
+
const parts = parsePath(path105);
|
|
10634
10634
|
if (parts.includes("*")) {
|
|
10635
|
-
redactWildcardPath(obj, parts, censor,
|
|
10635
|
+
redactWildcardPath(obj, parts, censor, path105, remove);
|
|
10636
10636
|
} else {
|
|
10637
10637
|
if (remove) {
|
|
10638
10638
|
removeKey(obj, parts);
|
|
@@ -10717,8 +10717,8 @@ var require_redact = __commonJS({
|
|
|
10717
10717
|
}
|
|
10718
10718
|
} else {
|
|
10719
10719
|
if (afterWildcard.includes("*")) {
|
|
10720
|
-
const wrappedCensor = typeof censor === "function" ? (value,
|
|
10721
|
-
const fullPath = [...pathArray.slice(0, pathLength), ...
|
|
10720
|
+
const wrappedCensor = typeof censor === "function" ? (value, path105) => {
|
|
10721
|
+
const fullPath = [...pathArray.slice(0, pathLength), ...path105];
|
|
10722
10722
|
return censor(value, fullPath);
|
|
10723
10723
|
} : censor;
|
|
10724
10724
|
redactWildcardPath(current, afterWildcard, wrappedCensor, originalPath, remove);
|
|
@@ -10753,8 +10753,8 @@ var require_redact = __commonJS({
|
|
|
10753
10753
|
return null;
|
|
10754
10754
|
}
|
|
10755
10755
|
const pathStructure = /* @__PURE__ */ new Map();
|
|
10756
|
-
for (const
|
|
10757
|
-
const parts = parsePath(
|
|
10756
|
+
for (const path105 of pathsToClone) {
|
|
10757
|
+
const parts = parsePath(path105);
|
|
10758
10758
|
let current = pathStructure;
|
|
10759
10759
|
for (let i2 = 0; i2 < parts.length; i2++) {
|
|
10760
10760
|
const part = parts[i2];
|
|
@@ -10806,24 +10806,24 @@ var require_redact = __commonJS({
|
|
|
10806
10806
|
}
|
|
10807
10807
|
return cloneSelectively(obj, pathStructure);
|
|
10808
10808
|
}
|
|
10809
|
-
function validatePath(
|
|
10810
|
-
if (typeof
|
|
10809
|
+
function validatePath(path105) {
|
|
10810
|
+
if (typeof path105 !== "string") {
|
|
10811
10811
|
throw new Error("Paths must be (non-empty) strings");
|
|
10812
10812
|
}
|
|
10813
|
-
if (
|
|
10813
|
+
if (path105 === "") {
|
|
10814
10814
|
throw new Error("Invalid redaction path ()");
|
|
10815
10815
|
}
|
|
10816
|
-
if (
|
|
10817
|
-
throw new Error(`Invalid redaction path (${
|
|
10816
|
+
if (path105.includes("..")) {
|
|
10817
|
+
throw new Error(`Invalid redaction path (${path105})`);
|
|
10818
10818
|
}
|
|
10819
|
-
if (
|
|
10820
|
-
throw new Error(`Invalid redaction path (${
|
|
10819
|
+
if (path105.includes(",")) {
|
|
10820
|
+
throw new Error(`Invalid redaction path (${path105})`);
|
|
10821
10821
|
}
|
|
10822
10822
|
let bracketCount = 0;
|
|
10823
10823
|
let inQuotes = false;
|
|
10824
10824
|
let quoteChar = "";
|
|
10825
|
-
for (let i2 = 0; i2 <
|
|
10826
|
-
const char =
|
|
10825
|
+
for (let i2 = 0; i2 < path105.length; i2++) {
|
|
10826
|
+
const char = path105[i2];
|
|
10827
10827
|
if ((char === '"' || char === "'") && bracketCount > 0) {
|
|
10828
10828
|
if (!inQuotes) {
|
|
10829
10829
|
inQuotes = true;
|
|
@@ -10837,20 +10837,20 @@ var require_redact = __commonJS({
|
|
|
10837
10837
|
} else if (char === "]" && !inQuotes) {
|
|
10838
10838
|
bracketCount--;
|
|
10839
10839
|
if (bracketCount < 0) {
|
|
10840
|
-
throw new Error(`Invalid redaction path (${
|
|
10840
|
+
throw new Error(`Invalid redaction path (${path105})`);
|
|
10841
10841
|
}
|
|
10842
10842
|
}
|
|
10843
10843
|
}
|
|
10844
10844
|
if (bracketCount !== 0) {
|
|
10845
|
-
throw new Error(`Invalid redaction path (${
|
|
10845
|
+
throw new Error(`Invalid redaction path (${path105})`);
|
|
10846
10846
|
}
|
|
10847
10847
|
}
|
|
10848
10848
|
function validatePaths(paths) {
|
|
10849
10849
|
if (!Array.isArray(paths)) {
|
|
10850
10850
|
throw new TypeError("paths must be an array");
|
|
10851
10851
|
}
|
|
10852
|
-
for (const
|
|
10853
|
-
validatePath(
|
|
10852
|
+
for (const path105 of paths) {
|
|
10853
|
+
validatePath(path105);
|
|
10854
10854
|
}
|
|
10855
10855
|
}
|
|
10856
10856
|
function slowRedact(options = {}) {
|
|
@@ -11018,8 +11018,8 @@ var require_redaction = __commonJS({
|
|
|
11018
11018
|
if (shape[k3] === null) {
|
|
11019
11019
|
o2[k3] = (value) => topCensor(value, [k3]);
|
|
11020
11020
|
} else {
|
|
11021
|
-
const wrappedCensor = typeof censor === "function" ? (value,
|
|
11022
|
-
return censor(value, [k3, ...
|
|
11021
|
+
const wrappedCensor = typeof censor === "function" ? (value, path105) => {
|
|
11022
|
+
return censor(value, [k3, ...path105]);
|
|
11023
11023
|
} : censor;
|
|
11024
11024
|
o2[k3] = Redact({
|
|
11025
11025
|
paths: shape[k3],
|
|
@@ -11237,10 +11237,10 @@ var require_atomic_sleep = __commonJS({
|
|
|
11237
11237
|
var require_sonic_boom = __commonJS({
|
|
11238
11238
|
"../node_modules/.pnpm/sonic-boom@4.2.1/node_modules/sonic-boom/index.js"(exports2, module2) {
|
|
11239
11239
|
"use strict";
|
|
11240
|
-
var
|
|
11240
|
+
var fs95 = require("fs");
|
|
11241
11241
|
var EventEmitter2 = require("events");
|
|
11242
11242
|
var inherits = require("util").inherits;
|
|
11243
|
-
var
|
|
11243
|
+
var path105 = require("path");
|
|
11244
11244
|
var sleep2 = require_atomic_sleep();
|
|
11245
11245
|
var assert = require("assert");
|
|
11246
11246
|
var BUSY_WRITE_TIMEOUT = 100;
|
|
@@ -11294,20 +11294,20 @@ var require_sonic_boom = __commonJS({
|
|
|
11294
11294
|
const mode = sonic.mode;
|
|
11295
11295
|
if (sonic.sync) {
|
|
11296
11296
|
try {
|
|
11297
|
-
if (sonic.mkdir)
|
|
11298
|
-
const fd =
|
|
11297
|
+
if (sonic.mkdir) fs95.mkdirSync(path105.dirname(file), { recursive: true });
|
|
11298
|
+
const fd = fs95.openSync(file, flags, mode);
|
|
11299
11299
|
fileOpened(null, fd);
|
|
11300
11300
|
} catch (err) {
|
|
11301
11301
|
fileOpened(err);
|
|
11302
11302
|
throw err;
|
|
11303
11303
|
}
|
|
11304
11304
|
} else if (sonic.mkdir) {
|
|
11305
|
-
|
|
11305
|
+
fs95.mkdir(path105.dirname(file), { recursive: true }, (err) => {
|
|
11306
11306
|
if (err) return fileOpened(err);
|
|
11307
|
-
|
|
11307
|
+
fs95.open(file, flags, mode, fileOpened);
|
|
11308
11308
|
});
|
|
11309
11309
|
} else {
|
|
11310
|
-
|
|
11310
|
+
fs95.open(file, flags, mode, fileOpened);
|
|
11311
11311
|
}
|
|
11312
11312
|
}
|
|
11313
11313
|
function SonicBoom(opts) {
|
|
@@ -11348,8 +11348,8 @@ var require_sonic_boom = __commonJS({
|
|
|
11348
11348
|
this.flush = flushBuffer;
|
|
11349
11349
|
this.flushSync = flushBufferSync;
|
|
11350
11350
|
this._actualWrite = actualWriteBuffer;
|
|
11351
|
-
fsWriteSync = () =>
|
|
11352
|
-
fsWrite = () =>
|
|
11351
|
+
fsWriteSync = () => fs95.writeSync(this.fd, this._writingBuf);
|
|
11352
|
+
fsWrite = () => fs95.write(this.fd, this._writingBuf, this.release);
|
|
11353
11353
|
} else if (contentMode === void 0 || contentMode === kContentModeUtf8) {
|
|
11354
11354
|
this._writingBuf = "";
|
|
11355
11355
|
this.write = write;
|
|
@@ -11358,15 +11358,15 @@ var require_sonic_boom = __commonJS({
|
|
|
11358
11358
|
this._actualWrite = actualWrite;
|
|
11359
11359
|
fsWriteSync = () => {
|
|
11360
11360
|
if (Buffer.isBuffer(this._writingBuf)) {
|
|
11361
|
-
return
|
|
11361
|
+
return fs95.writeSync(this.fd, this._writingBuf);
|
|
11362
11362
|
}
|
|
11363
|
-
return
|
|
11363
|
+
return fs95.writeSync(this.fd, this._writingBuf, "utf8");
|
|
11364
11364
|
};
|
|
11365
11365
|
fsWrite = () => {
|
|
11366
11366
|
if (Buffer.isBuffer(this._writingBuf)) {
|
|
11367
|
-
return
|
|
11367
|
+
return fs95.write(this.fd, this._writingBuf, this.release);
|
|
11368
11368
|
}
|
|
11369
|
-
return
|
|
11369
|
+
return fs95.write(this.fd, this._writingBuf, "utf8", this.release);
|
|
11370
11370
|
};
|
|
11371
11371
|
} else {
|
|
11372
11372
|
throw new Error(`SonicBoom supports "${kContentModeUtf8}" and "${kContentModeBuffer}", but passed ${contentMode}`);
|
|
@@ -11423,7 +11423,7 @@ var require_sonic_boom = __commonJS({
|
|
|
11423
11423
|
}
|
|
11424
11424
|
}
|
|
11425
11425
|
if (this._fsync) {
|
|
11426
|
-
|
|
11426
|
+
fs95.fsyncSync(this.fd);
|
|
11427
11427
|
}
|
|
11428
11428
|
const len = this._len;
|
|
11429
11429
|
if (this._reopening) {
|
|
@@ -11537,7 +11537,7 @@ var require_sonic_boom = __commonJS({
|
|
|
11537
11537
|
const onDrain = () => {
|
|
11538
11538
|
if (!this._fsync) {
|
|
11539
11539
|
try {
|
|
11540
|
-
|
|
11540
|
+
fs95.fsync(this.fd, (err) => {
|
|
11541
11541
|
this._flushPending = false;
|
|
11542
11542
|
cb(err);
|
|
11543
11543
|
});
|
|
@@ -11639,7 +11639,7 @@ var require_sonic_boom = __commonJS({
|
|
|
11639
11639
|
const fd = this.fd;
|
|
11640
11640
|
this.once("ready", () => {
|
|
11641
11641
|
if (fd !== this.fd) {
|
|
11642
|
-
|
|
11642
|
+
fs95.close(fd, (err) => {
|
|
11643
11643
|
if (err) {
|
|
11644
11644
|
return this.emit("error", err);
|
|
11645
11645
|
}
|
|
@@ -11688,7 +11688,7 @@ var require_sonic_boom = __commonJS({
|
|
|
11688
11688
|
buf = this._bufs[0];
|
|
11689
11689
|
}
|
|
11690
11690
|
try {
|
|
11691
|
-
const n2 = Buffer.isBuffer(buf) ?
|
|
11691
|
+
const n2 = Buffer.isBuffer(buf) ? fs95.writeSync(this.fd, buf) : fs95.writeSync(this.fd, buf, "utf8");
|
|
11692
11692
|
const releasedBufObj = releaseWritingBuf(buf, this._len, n2);
|
|
11693
11693
|
buf = releasedBufObj.writingBuf;
|
|
11694
11694
|
this._len = releasedBufObj.len;
|
|
@@ -11704,7 +11704,7 @@ var require_sonic_boom = __commonJS({
|
|
|
11704
11704
|
}
|
|
11705
11705
|
}
|
|
11706
11706
|
try {
|
|
11707
|
-
|
|
11707
|
+
fs95.fsyncSync(this.fd);
|
|
11708
11708
|
} catch {
|
|
11709
11709
|
}
|
|
11710
11710
|
}
|
|
@@ -11725,7 +11725,7 @@ var require_sonic_boom = __commonJS({
|
|
|
11725
11725
|
buf = mergeBuf(this._bufs[0], this._lens[0]);
|
|
11726
11726
|
}
|
|
11727
11727
|
try {
|
|
11728
|
-
const n2 =
|
|
11728
|
+
const n2 = fs95.writeSync(this.fd, buf);
|
|
11729
11729
|
buf = buf.subarray(n2);
|
|
11730
11730
|
this._len = Math.max(this._len - n2, 0);
|
|
11731
11731
|
if (buf.length <= 0) {
|
|
@@ -11753,13 +11753,13 @@ var require_sonic_boom = __commonJS({
|
|
|
11753
11753
|
this._writingBuf = this._writingBuf.length ? this._writingBuf : this._bufs.shift() || "";
|
|
11754
11754
|
if (this.sync) {
|
|
11755
11755
|
try {
|
|
11756
|
-
const written = Buffer.isBuffer(this._writingBuf) ?
|
|
11756
|
+
const written = Buffer.isBuffer(this._writingBuf) ? fs95.writeSync(this.fd, this._writingBuf) : fs95.writeSync(this.fd, this._writingBuf, "utf8");
|
|
11757
11757
|
release2(null, written);
|
|
11758
11758
|
} catch (err) {
|
|
11759
11759
|
release2(err);
|
|
11760
11760
|
}
|
|
11761
11761
|
} else {
|
|
11762
|
-
|
|
11762
|
+
fs95.write(this.fd, this._writingBuf, release2);
|
|
11763
11763
|
}
|
|
11764
11764
|
}
|
|
11765
11765
|
function actualWriteBuffer() {
|
|
@@ -11768,7 +11768,7 @@ var require_sonic_boom = __commonJS({
|
|
|
11768
11768
|
this._writingBuf = this._writingBuf.length ? this._writingBuf : mergeBuf(this._bufs.shift(), this._lens.shift());
|
|
11769
11769
|
if (this.sync) {
|
|
11770
11770
|
try {
|
|
11771
|
-
const written =
|
|
11771
|
+
const written = fs95.writeSync(this.fd, this._writingBuf);
|
|
11772
11772
|
release2(null, written);
|
|
11773
11773
|
} catch (err) {
|
|
11774
11774
|
release2(err);
|
|
@@ -11777,7 +11777,7 @@ var require_sonic_boom = __commonJS({
|
|
|
11777
11777
|
if (kCopyBuffer) {
|
|
11778
11778
|
this._writingBuf = Buffer.from(this._writingBuf);
|
|
11779
11779
|
}
|
|
11780
|
-
|
|
11780
|
+
fs95.write(this.fd, this._writingBuf, release2);
|
|
11781
11781
|
}
|
|
11782
11782
|
}
|
|
11783
11783
|
function actualClose(sonic) {
|
|
@@ -11793,12 +11793,12 @@ var require_sonic_boom = __commonJS({
|
|
|
11793
11793
|
sonic._lens = [];
|
|
11794
11794
|
assert(typeof sonic.fd === "number", `sonic.fd must be a number, got ${typeof sonic.fd}`);
|
|
11795
11795
|
try {
|
|
11796
|
-
|
|
11796
|
+
fs95.fsync(sonic.fd, closeWrapped);
|
|
11797
11797
|
} catch {
|
|
11798
11798
|
}
|
|
11799
11799
|
function closeWrapped() {
|
|
11800
11800
|
if (sonic.fd !== 1 && sonic.fd !== 2) {
|
|
11801
|
-
|
|
11801
|
+
fs95.close(sonic.fd, done);
|
|
11802
11802
|
} else {
|
|
11803
11803
|
done();
|
|
11804
11804
|
}
|
|
@@ -14162,7 +14162,7 @@ var require_multistream = __commonJS({
|
|
|
14162
14162
|
var require_pino = __commonJS({
|
|
14163
14163
|
"../node_modules/.pnpm/pino@9.14.0/node_modules/pino/pino.js"(exports2, module2) {
|
|
14164
14164
|
"use strict";
|
|
14165
|
-
var
|
|
14165
|
+
var os37 = require("os");
|
|
14166
14166
|
var stdSerializers = require_pino_std_serializers();
|
|
14167
14167
|
var caller = require_caller();
|
|
14168
14168
|
var redaction = require_redaction();
|
|
@@ -14209,7 +14209,7 @@ var require_pino = __commonJS({
|
|
|
14209
14209
|
} = symbols;
|
|
14210
14210
|
var { epochTime, nullTime } = time;
|
|
14211
14211
|
var { pid } = process;
|
|
14212
|
-
var hostname =
|
|
14212
|
+
var hostname = os37.hostname();
|
|
14213
14213
|
var defaultErrorSerializer = stdSerializers.err;
|
|
14214
14214
|
var defaultOptions2 = {
|
|
14215
14215
|
level: "info",
|
|
@@ -14933,11 +14933,11 @@ var init_lib = __esm({
|
|
|
14933
14933
|
}
|
|
14934
14934
|
}
|
|
14935
14935
|
},
|
|
14936
|
-
addToPath: function addToPath(
|
|
14937
|
-
var last =
|
|
14936
|
+
addToPath: function addToPath(path105, added, removed, oldPosInc, options) {
|
|
14937
|
+
var last = path105.lastComponent;
|
|
14938
14938
|
if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) {
|
|
14939
14939
|
return {
|
|
14940
|
-
oldPos:
|
|
14940
|
+
oldPos: path105.oldPos + oldPosInc,
|
|
14941
14941
|
lastComponent: {
|
|
14942
14942
|
count: last.count + 1,
|
|
14943
14943
|
added,
|
|
@@ -14947,7 +14947,7 @@ var init_lib = __esm({
|
|
|
14947
14947
|
};
|
|
14948
14948
|
} else {
|
|
14949
14949
|
return {
|
|
14950
|
-
oldPos:
|
|
14950
|
+
oldPos: path105.oldPos + oldPosInc,
|
|
14951
14951
|
lastComponent: {
|
|
14952
14952
|
count: 1,
|
|
14953
14953
|
added,
|
|
@@ -15529,10 +15529,10 @@ function attachmentToHistoryMessage(o2, ts) {
|
|
|
15529
15529
|
const memories = raw.map((m3) => {
|
|
15530
15530
|
if (!m3 || typeof m3 !== "object") return null;
|
|
15531
15531
|
const rec6 = m3;
|
|
15532
|
-
const
|
|
15532
|
+
const path105 = typeof rec6.path === "string" ? rec6.path : null;
|
|
15533
15533
|
const content = typeof rec6.content === "string" ? rec6.content : null;
|
|
15534
|
-
if (!
|
|
15535
|
-
const entry = { path:
|
|
15534
|
+
if (!path105 || content == null) return null;
|
|
15535
|
+
const entry = { path: path105, content };
|
|
15536
15536
|
if (typeof rec6.mtimeMs === "number") entry.mtimeMs = rec6.mtimeMs;
|
|
15537
15537
|
return entry;
|
|
15538
15538
|
}).filter((m3) => m3 !== null);
|
|
@@ -16398,10 +16398,10 @@ function parseAttachment(obj) {
|
|
|
16398
16398
|
const memories = raw.map((m3) => {
|
|
16399
16399
|
if (!m3 || typeof m3 !== "object") return null;
|
|
16400
16400
|
const rec6 = m3;
|
|
16401
|
-
const
|
|
16401
|
+
const path105 = typeof rec6.path === "string" ? rec6.path : null;
|
|
16402
16402
|
const content = typeof rec6.content === "string" ? rec6.content : null;
|
|
16403
|
-
if (!
|
|
16404
|
-
const out = { path:
|
|
16403
|
+
if (!path105 || content == null) return null;
|
|
16404
|
+
const out = { path: path105, content };
|
|
16405
16405
|
if (typeof rec6.mtimeMs === "number") out.mtimeMs = rec6.mtimeMs;
|
|
16406
16406
|
return out;
|
|
16407
16407
|
}).filter((m3) => m3 !== null);
|
|
@@ -37375,8 +37375,8 @@ var require_utils = __commonJS({
|
|
|
37375
37375
|
var result = transform[inputType][outputType](input);
|
|
37376
37376
|
return result;
|
|
37377
37377
|
};
|
|
37378
|
-
exports2.resolve = function(
|
|
37379
|
-
var parts =
|
|
37378
|
+
exports2.resolve = function(path105) {
|
|
37379
|
+
var parts = path105.split("/");
|
|
37380
37380
|
var result = [];
|
|
37381
37381
|
for (var index = 0; index < parts.length; index++) {
|
|
37382
37382
|
var part = parts[index];
|
|
@@ -43229,18 +43229,18 @@ var require_object = __commonJS({
|
|
|
43229
43229
|
var object = new ZipObject(name, zipObjectContent, o2);
|
|
43230
43230
|
this.files[name] = object;
|
|
43231
43231
|
};
|
|
43232
|
-
var parentFolder = function(
|
|
43233
|
-
if (
|
|
43234
|
-
|
|
43232
|
+
var parentFolder = function(path105) {
|
|
43233
|
+
if (path105.slice(-1) === "/") {
|
|
43234
|
+
path105 = path105.substring(0, path105.length - 1);
|
|
43235
43235
|
}
|
|
43236
|
-
var lastSlash =
|
|
43237
|
-
return lastSlash > 0 ?
|
|
43236
|
+
var lastSlash = path105.lastIndexOf("/");
|
|
43237
|
+
return lastSlash > 0 ? path105.substring(0, lastSlash) : "";
|
|
43238
43238
|
};
|
|
43239
|
-
var forceTrailingSlash = function(
|
|
43240
|
-
if (
|
|
43241
|
-
|
|
43239
|
+
var forceTrailingSlash = function(path105) {
|
|
43240
|
+
if (path105.slice(-1) !== "/") {
|
|
43241
|
+
path105 += "/";
|
|
43242
43242
|
}
|
|
43243
|
-
return
|
|
43243
|
+
return path105;
|
|
43244
43244
|
};
|
|
43245
43245
|
var folderAdd = function(name, createFolders) {
|
|
43246
43246
|
createFolders = typeof createFolders !== "undefined" ? createFolders : defaults.createFolders;
|
|
@@ -44242,7 +44242,7 @@ var require_lib3 = __commonJS({
|
|
|
44242
44242
|
// src/run-case/recorder.ts
|
|
44243
44243
|
function startRunCaseRecorder(opts) {
|
|
44244
44244
|
const now = opts.now ?? Date.now;
|
|
44245
|
-
const dir =
|
|
44245
|
+
const dir = import_node_path84.default.dirname(opts.recordPath);
|
|
44246
44246
|
let stream = null;
|
|
44247
44247
|
let closing = false;
|
|
44248
44248
|
let closedSettled = false;
|
|
@@ -44256,8 +44256,8 @@ function startRunCaseRecorder(opts) {
|
|
|
44256
44256
|
});
|
|
44257
44257
|
const ensureStream = () => {
|
|
44258
44258
|
if (stream) return stream;
|
|
44259
|
-
|
|
44260
|
-
stream =
|
|
44259
|
+
import_node_fs66.default.mkdirSync(dir, { recursive: true });
|
|
44260
|
+
stream = import_node_fs66.default.createWriteStream(opts.recordPath, { flags: "a" });
|
|
44261
44261
|
stream.on("close", () => closedResolve());
|
|
44262
44262
|
return stream;
|
|
44263
44263
|
};
|
|
@@ -44282,12 +44282,12 @@ function startRunCaseRecorder(opts) {
|
|
|
44282
44282
|
};
|
|
44283
44283
|
return { tap, close, closed };
|
|
44284
44284
|
}
|
|
44285
|
-
var
|
|
44285
|
+
var import_node_fs66, import_node_path84;
|
|
44286
44286
|
var init_recorder = __esm({
|
|
44287
44287
|
"src/run-case/recorder.ts"() {
|
|
44288
44288
|
"use strict";
|
|
44289
|
-
|
|
44290
|
-
|
|
44289
|
+
import_node_fs66 = __toESM(require("fs"), 1);
|
|
44290
|
+
import_node_path84 = __toESM(require("path"), 1);
|
|
44291
44291
|
}
|
|
44292
44292
|
});
|
|
44293
44293
|
|
|
@@ -44330,7 +44330,7 @@ var init_wire = __esm({
|
|
|
44330
44330
|
// src/run-case/controller.ts
|
|
44331
44331
|
async function runController(opts) {
|
|
44332
44332
|
const now = opts.now ?? Date.now;
|
|
44333
|
-
const cwd = opts.cwd ?? (0,
|
|
44333
|
+
const cwd = opts.cwd ?? (0, import_node_fs67.mkdtempSync)(import_node_path85.default.join(import_node_os33.default.tmpdir(), "clawd-runcase-"));
|
|
44334
44334
|
const ownsCwd = opts.cwd === void 0;
|
|
44335
44335
|
const recorder = startRunCaseRecorder({ recordPath: opts.record, now });
|
|
44336
44336
|
const spawnCtx = { cwd };
|
|
@@ -44491,19 +44491,19 @@ async function runController(opts) {
|
|
|
44491
44491
|
if (sigintHandler) process.off("SIGINT", sigintHandler);
|
|
44492
44492
|
if (ownsCwd) {
|
|
44493
44493
|
try {
|
|
44494
|
-
(0,
|
|
44494
|
+
(0, import_node_fs67.rmSync)(cwd, { recursive: true, force: true });
|
|
44495
44495
|
} catch {
|
|
44496
44496
|
}
|
|
44497
44497
|
}
|
|
44498
44498
|
return exitCode ?? 0;
|
|
44499
44499
|
}
|
|
44500
|
-
var
|
|
44500
|
+
var import_node_fs67, import_node_os33, import_node_path85;
|
|
44501
44501
|
var init_controller = __esm({
|
|
44502
44502
|
"src/run-case/controller.ts"() {
|
|
44503
44503
|
"use strict";
|
|
44504
|
-
|
|
44505
|
-
|
|
44506
|
-
|
|
44504
|
+
import_node_fs67 = require("fs");
|
|
44505
|
+
import_node_os33 = __toESM(require("os"), 1);
|
|
44506
|
+
import_node_path85 = __toESM(require("path"), 1);
|
|
44507
44507
|
init_claude();
|
|
44508
44508
|
init_stdout_splitter();
|
|
44509
44509
|
init_permission_stdio();
|
|
@@ -44775,9 +44775,9 @@ Env (advanced):
|
|
|
44775
44775
|
`;
|
|
44776
44776
|
|
|
44777
44777
|
// src/index.ts
|
|
44778
|
-
var
|
|
44779
|
-
var
|
|
44780
|
-
var
|
|
44778
|
+
var import_node_path83 = __toESM(require("path"), 1);
|
|
44779
|
+
var import_node_fs65 = __toESM(require("fs"), 1);
|
|
44780
|
+
var import_node_os32 = __toESM(require("os"), 1);
|
|
44781
44781
|
var import_node_crypto26 = require("crypto");
|
|
44782
44782
|
var import_node_url6 = require("url");
|
|
44783
44783
|
|
|
@@ -52523,9 +52523,9 @@ var CentralClientError = class extends Error {
|
|
|
52523
52523
|
cause;
|
|
52524
52524
|
status;
|
|
52525
52525
|
};
|
|
52526
|
-
async function centralRequest(opts,
|
|
52526
|
+
async function centralRequest(opts, path105, init) {
|
|
52527
52527
|
const f2 = opts.fetchImpl ?? globalThis.fetch;
|
|
52528
|
-
const url = `${opts.api.replace(/\/+$/, "")}${
|
|
52528
|
+
const url = `${opts.api.replace(/\/+$/, "")}${path105}`;
|
|
52529
52529
|
const ctrl = new AbortController();
|
|
52530
52530
|
const timer = setTimeout(() => ctrl.abort(), opts.timeoutMs ?? 15e3);
|
|
52531
52531
|
let res;
|
|
@@ -53559,8 +53559,8 @@ function turnStartInput(text, resolveImage) {
|
|
|
53559
53559
|
const items = [];
|
|
53560
53560
|
let leftover = text;
|
|
53561
53561
|
for (const m3 of text.matchAll(SKILL_RE)) {
|
|
53562
|
-
const [marker, name,
|
|
53563
|
-
items.push({ type: "skill", name, path:
|
|
53562
|
+
const [marker, name, path105] = m3;
|
|
53563
|
+
items.push({ type: "skill", name, path: path105 });
|
|
53564
53564
|
leftover = leftover.replace(marker, "");
|
|
53565
53565
|
}
|
|
53566
53566
|
for (const m3 of text.matchAll(ATTACHMENT_RE2)) {
|
|
@@ -60933,10 +60933,10 @@ function createGithubApi(args) {
|
|
|
60933
60933
|
const doFetch = args.fetch ?? fetch;
|
|
60934
60934
|
const seal = args.seal ?? sealWithSodium;
|
|
60935
60935
|
const timeoutMs = args.timeoutMs ?? TIMEOUT_MS;
|
|
60936
|
-
async function request(method,
|
|
60936
|
+
async function request(method, path105, body) {
|
|
60937
60937
|
let res;
|
|
60938
60938
|
try {
|
|
60939
|
-
res = await doFetch(`${API}${
|
|
60939
|
+
res = await doFetch(`${API}${path105}`, {
|
|
60940
60940
|
method,
|
|
60941
60941
|
headers: {
|
|
60942
60942
|
Authorization: `Bearer ${args.token}`,
|
|
@@ -60961,8 +60961,8 @@ function createGithubApi(args) {
|
|
|
60961
60961
|
}
|
|
60962
60962
|
return { status: res.status, json };
|
|
60963
60963
|
}
|
|
60964
|
-
async function must(method,
|
|
60965
|
-
const r2 = await request(method,
|
|
60964
|
+
async function must(method, path105, what, body) {
|
|
60965
|
+
const r2 = await request(method, path105, body);
|
|
60966
60966
|
if (r2.status < 200 || r2.status >= 300) throw new GithubApiError(r2.status, explain(r2.status, what, r2.json));
|
|
60967
60967
|
return r2.json;
|
|
60968
60968
|
}
|
|
@@ -61007,9 +61007,9 @@ function createGithubApi(args) {
|
|
|
61007
61007
|
return { env: x2.name, ...Number.isFinite(at3) ? { setAt: at3 } : {} };
|
|
61008
61008
|
});
|
|
61009
61009
|
},
|
|
61010
|
-
async getJson(
|
|
61010
|
+
async getJson(path105) {
|
|
61011
61011
|
try {
|
|
61012
|
-
const r2 = await request("GET",
|
|
61012
|
+
const r2 = await request("GET", path105);
|
|
61013
61013
|
return r2.status >= 200 && r2.status < 300 ? r2.json : void 0;
|
|
61014
61014
|
} catch {
|
|
61015
61015
|
return void 0;
|
|
@@ -62271,6 +62271,21 @@ var import_node_fs35 = __toESM(require("fs"), 1);
|
|
|
62271
62271
|
var import_node_os12 = __toESM(require("os"), 1);
|
|
62272
62272
|
var import_node_path40 = __toESM(require("path"), 1);
|
|
62273
62273
|
var CHANNELS_FILE_NAME = "subscription-channels.json";
|
|
62274
|
+
function providerSection(content) {
|
|
62275
|
+
const header = /^\[model_providers\.cliproxyapi\][^\n]*(?:\n|$)/m.exec(content);
|
|
62276
|
+
if (!header) return null;
|
|
62277
|
+
const body = content.slice(header.index + header[0].length);
|
|
62278
|
+
const nextHeader = body.search(/^\[/m);
|
|
62279
|
+
return nextHeader < 0 ? body : body.slice(0, nextHeader);
|
|
62280
|
+
}
|
|
62281
|
+
function readAuthKey2(codexHome) {
|
|
62282
|
+
try {
|
|
62283
|
+
const key = JSON.parse(import_node_fs35.default.readFileSync(import_node_path40.default.join(codexHome, "auth.json"), "utf8")).OPENAI_API_KEY;
|
|
62284
|
+
return typeof key === "string" && key ? key : null;
|
|
62285
|
+
} catch {
|
|
62286
|
+
return null;
|
|
62287
|
+
}
|
|
62288
|
+
}
|
|
62274
62289
|
var SubscriptionChannelStore = class {
|
|
62275
62290
|
filePath;
|
|
62276
62291
|
codexHome;
|
|
@@ -62397,15 +62412,20 @@ var SubscriptionChannelStore = class {
|
|
|
62397
62412
|
if (!import_node_fs35.default.existsSync(configPath)) return null;
|
|
62398
62413
|
const content = import_node_fs35.default.readFileSync(configPath, "utf8");
|
|
62399
62414
|
if (!content.includes('model_provider = "cliproxyapi"')) return null;
|
|
62400
|
-
const
|
|
62401
|
-
|
|
62402
|
-
|
|
62415
|
+
const section = providerSection(content);
|
|
62416
|
+
if (!section) return null;
|
|
62417
|
+
const urlMatch = /^\s*base_url\s*=\s*["']([^"']+)["']/m.exec(section);
|
|
62418
|
+
const echoKey = /^\s*auth\s*=\s*\{\s*command\s*=\s*["']echo["']\s*,\s*args\s*=\s*\[\s*["']([^"']+)["']\s*\]/m.exec(section)?.[1];
|
|
62419
|
+
const inlineKey = /^\s*experimental_bearer_token\s*=\s*["']([^"']+)["']/m.exec(section)?.[1];
|
|
62420
|
+
const envKey = /^\s*env_key\s*=\s*["']([^"']+)["']/m.exec(section)?.[1];
|
|
62421
|
+
const key = echoKey ?? inlineKey ?? (envKey ? process.env[envKey] : !/^\s*auth\s*=/m.test(section) ? readAuthKey2(this.codexHome) : null);
|
|
62422
|
+
if (urlMatch && key) {
|
|
62403
62423
|
const id = "default-pool";
|
|
62404
62424
|
const channel = {
|
|
62405
62425
|
id,
|
|
62406
62426
|
name: "\u9ED8\u8BA4\u56E2\u961F\u53F7\u6C60",
|
|
62407
62427
|
baseUrl: normalizeEngineBaseUrl(urlMatch[1]),
|
|
62408
|
-
apiKey:
|
|
62428
|
+
apiKey: key,
|
|
62409
62429
|
remark: "\u4ECE\u672C\u673A\u5DF2\u63A5\u5165\u7684\u53F7\u6C60\u914D\u7F6E\u81EA\u52A8\u8FC1\u79FB",
|
|
62410
62430
|
createdAt: Date.now(),
|
|
62411
62431
|
updatedAt: Date.now()
|
|
@@ -62486,8 +62506,8 @@ function refreshPathFromLoginShell() {
|
|
|
62486
62506
|
timeout: 3e3,
|
|
62487
62507
|
stdio: ["ignore", "pipe", "ignore"]
|
|
62488
62508
|
});
|
|
62489
|
-
const
|
|
62490
|
-
if (
|
|
62509
|
+
const path105 = out.trim();
|
|
62510
|
+
if (path105) process.env.PATH = path105;
|
|
62491
62511
|
} catch {
|
|
62492
62512
|
}
|
|
62493
62513
|
}
|
|
@@ -65436,13 +65456,13 @@ function mapSkillsListResponse(res) {
|
|
|
65436
65456
|
const r2 = s2 ?? {};
|
|
65437
65457
|
const name = str4(r2.name);
|
|
65438
65458
|
if (!name) continue;
|
|
65439
|
-
const
|
|
65459
|
+
const path105 = str4(r2.path);
|
|
65440
65460
|
const description = str4(r2.description);
|
|
65441
65461
|
const isPlugin = name.includes(":");
|
|
65442
65462
|
out.push({
|
|
65443
65463
|
name,
|
|
65444
65464
|
source: isPlugin ? "plugin" : "project",
|
|
65445
|
-
...
|
|
65465
|
+
...path105 ? { path: path105 } : {},
|
|
65446
65466
|
...description ? { description } : {},
|
|
65447
65467
|
...isPlugin ? { plugin: name.split(":")[0] } : {}
|
|
65448
65468
|
});
|
|
@@ -69976,7 +69996,7 @@ var ServerKeyStore = class {
|
|
|
69976
69996
|
init_protocol();
|
|
69977
69997
|
|
|
69978
69998
|
// src/handlers/index.ts
|
|
69979
|
-
var
|
|
69999
|
+
var import_node_path79 = __toESM(require("path"), 1);
|
|
69980
70000
|
|
|
69981
70001
|
// src/handlers/session.ts
|
|
69982
70002
|
init_protocol();
|
|
@@ -71681,6 +71701,11 @@ function buildEngineHandlers(deps, overrides = {}) {
|
|
|
71681
71701
|
return { "engine:status": status, "engine:connectPool": connectPool };
|
|
71682
71702
|
}
|
|
71683
71703
|
|
|
71704
|
+
// src/handlers/channels.ts
|
|
71705
|
+
var import_node_fs64 = __toESM(require("fs"), 1);
|
|
71706
|
+
var import_node_os26 = __toESM(require("os"), 1);
|
|
71707
|
+
var import_node_path70 = __toESM(require("path"), 1);
|
|
71708
|
+
|
|
71684
71709
|
// src/tools/subscription-channels-apply.ts
|
|
71685
71710
|
var import_node_fs63 = __toESM(require("fs"), 1);
|
|
71686
71711
|
var import_node_os25 = __toESM(require("os"), 1);
|
|
@@ -71757,7 +71782,20 @@ function applyPiSubscriptionChannel(opts) {
|
|
|
71757
71782
|
}
|
|
71758
71783
|
|
|
71759
71784
|
// src/handlers/channels.ts
|
|
71785
|
+
function snapshotFile(file) {
|
|
71786
|
+
const original = import_node_fs64.default.existsSync(file) ? import_node_fs64.default.readFileSync(file) : null;
|
|
71787
|
+
return () => {
|
|
71788
|
+
if (original === null) {
|
|
71789
|
+
import_node_fs64.default.rmSync(file, { force: true });
|
|
71790
|
+
} else {
|
|
71791
|
+
const tmp = `${file}.tmp.${Date.now()}`;
|
|
71792
|
+
import_node_fs64.default.writeFileSync(tmp, original, { mode: 384 });
|
|
71793
|
+
import_node_fs64.default.renameSync(tmp, file);
|
|
71794
|
+
}
|
|
71795
|
+
};
|
|
71796
|
+
}
|
|
71760
71797
|
function buildChannelsHandlers(deps) {
|
|
71798
|
+
let activationQueue = Promise.resolve();
|
|
71761
71799
|
const get = async () => {
|
|
71762
71800
|
return { response: deps.store.list() };
|
|
71763
71801
|
};
|
|
@@ -71786,13 +71824,37 @@ function buildChannelsHandlers(deps) {
|
|
|
71786
71824
|
}
|
|
71787
71825
|
return { response: { ok: true } };
|
|
71788
71826
|
};
|
|
71789
|
-
const activate = async (frame) => {
|
|
71827
|
+
const activate = async (frame, context) => {
|
|
71828
|
+
const run = activationQueue.then(() => activateChannel(frame, context));
|
|
71829
|
+
activationQueue = run.then(() => {
|
|
71830
|
+
}, () => {
|
|
71831
|
+
});
|
|
71832
|
+
return run;
|
|
71833
|
+
};
|
|
71834
|
+
const activateChannel = async (frame) => {
|
|
71790
71835
|
const args = parseArgs2(SubscriptionChannelActivateArgsSchema, frame, "subscriptionChannel:activate");
|
|
71791
|
-
const channel = deps.store.
|
|
71792
|
-
|
|
71793
|
-
|
|
71794
|
-
|
|
71795
|
-
|
|
71836
|
+
const channel = args.id === null ? null : deps.store.get(args.id);
|
|
71837
|
+
if (args.id !== null && !channel) throw new Error(`\u901A\u9053 ${args.id} \u4E0D\u5B58\u5728`);
|
|
71838
|
+
const codexHome = deps.codexHome || process.env.CODEX_HOME || import_node_path70.default.join(import_node_os26.default.homedir(), ".codex");
|
|
71839
|
+
const agentDir = deps.agentDir || process.env.PI_CODING_AGENT_DIR || import_node_path70.default.join(import_node_os26.default.homedir(), ".pi", "agent");
|
|
71840
|
+
const restoreCodex = snapshotFile(import_node_path70.default.join(codexHome, "config.toml"));
|
|
71841
|
+
const restorePi = import_node_fs64.default.existsSync(agentDir) ? snapshotFile(import_node_path70.default.join(agentDir, "cliproxyapi.json")) : null;
|
|
71842
|
+
let refreshed = false;
|
|
71843
|
+
try {
|
|
71844
|
+
applyCodexSubscriptionChannel({ codexHome, channel });
|
|
71845
|
+
if (channel) await deps.manager.getCapabilities("codex", { refresh: true });
|
|
71846
|
+
refreshed = Boolean(channel);
|
|
71847
|
+
applyPiSubscriptionChannel({ agentDir, channel });
|
|
71848
|
+
deps.store.setActive(args.id);
|
|
71849
|
+
} catch (err) {
|
|
71850
|
+
restoreCodex();
|
|
71851
|
+
restorePi?.();
|
|
71852
|
+
if (refreshed) await deps.manager.getCapabilities("codex", { refresh: true }).catch(() => {
|
|
71853
|
+
});
|
|
71854
|
+
if (channel?.id === "default-pool" && err instanceof Error && /HTTP 401/.test(err.message)) {
|
|
71855
|
+
throw new Error("\u9ED8\u8BA4\u53F7\u6C60\u8BA4\u8BC1\u5931\u8D25\uFF08HTTP 401\uFF09\uFF1A\u8BF7\u7F16\u8F91\u300C\u9ED8\u8BA4\u56E2\u961F\u53F7\u6C60\u300D\u5E76\u91CD\u65B0\u586B\u5199\u53F7\u6C60 API Key\uFF0C\u518D\u8BBE\u4E3A\u5F53\u524D\u3002");
|
|
71856
|
+
}
|
|
71857
|
+
throw err;
|
|
71796
71858
|
}
|
|
71797
71859
|
return { response: { ok: true } };
|
|
71798
71860
|
};
|
|
@@ -72438,7 +72500,7 @@ function buildDashboardHandlers(deps) {
|
|
|
72438
72500
|
}
|
|
72439
72501
|
|
|
72440
72502
|
// src/handlers/meta.ts
|
|
72441
|
-
var
|
|
72503
|
+
var import_node_os27 = __toESM(require("os"), 1);
|
|
72442
72504
|
init_protocol();
|
|
72443
72505
|
|
|
72444
72506
|
// src/handlers/method-grants.ts
|
|
@@ -72758,21 +72820,21 @@ function computeMethodAccess(args) {
|
|
|
72758
72820
|
}
|
|
72759
72821
|
|
|
72760
72822
|
// src/version.ts
|
|
72761
|
-
var version = "0.2.
|
|
72823
|
+
var version = "0.2.593".length > 0 ? "0.2.593" : "dev";
|
|
72762
72824
|
|
|
72763
72825
|
// src/cli-probe/probe.ts
|
|
72764
|
-
var
|
|
72765
|
-
var
|
|
72826
|
+
var fs83 = __toESM(require("fs"), 1);
|
|
72827
|
+
var path89 = __toESM(require("path"), 1);
|
|
72766
72828
|
var PKG_NAME = "@clawos-dev/clawd";
|
|
72767
72829
|
var BIN_NAME = "clawd";
|
|
72768
72830
|
var MAX_PARENT_HOPS = 5;
|
|
72769
72831
|
function probeGlobalCli(pathEnv) {
|
|
72770
72832
|
if (!pathEnv) return null;
|
|
72771
|
-
for (const dir of pathEnv.split(
|
|
72833
|
+
for (const dir of pathEnv.split(path89.delimiter)) {
|
|
72772
72834
|
if (!dir) continue;
|
|
72773
72835
|
let real;
|
|
72774
72836
|
try {
|
|
72775
|
-
real =
|
|
72837
|
+
real = fs83.realpathSync(path89.join(dir, BIN_NAME));
|
|
72776
72838
|
} catch {
|
|
72777
72839
|
continue;
|
|
72778
72840
|
}
|
|
@@ -72782,15 +72844,15 @@ function probeGlobalCli(pathEnv) {
|
|
|
72782
72844
|
return null;
|
|
72783
72845
|
}
|
|
72784
72846
|
function readOwnPackageVersion(entryPath) {
|
|
72785
|
-
let dir =
|
|
72847
|
+
let dir = path89.dirname(entryPath);
|
|
72786
72848
|
for (let i2 = 0; i2 < MAX_PARENT_HOPS; i2++) {
|
|
72787
72849
|
try {
|
|
72788
|
-
const raw =
|
|
72850
|
+
const raw = fs83.readFileSync(path89.join(dir, "package.json"), "utf8");
|
|
72789
72851
|
const pkg = JSON.parse(raw);
|
|
72790
72852
|
if (pkg.name !== PKG_NAME) return null;
|
|
72791
72853
|
return typeof pkg.version === "string" && pkg.version ? pkg.version : null;
|
|
72792
72854
|
} catch {
|
|
72793
|
-
const parent =
|
|
72855
|
+
const parent = path89.dirname(dir);
|
|
72794
72856
|
if (parent === dir) return null;
|
|
72795
72857
|
dir = parent;
|
|
72796
72858
|
}
|
|
@@ -72826,7 +72888,7 @@ function buildReadyFrame(deps, client) {
|
|
|
72826
72888
|
return {
|
|
72827
72889
|
version,
|
|
72828
72890
|
protocolVersion: PROTOCOL_VERSION,
|
|
72829
|
-
hostname:
|
|
72891
|
+
hostname: import_node_os27.default.hostname(),
|
|
72830
72892
|
os: process.platform,
|
|
72831
72893
|
tools,
|
|
72832
72894
|
runningSessions: info.runningSessions,
|
|
@@ -72966,7 +73028,7 @@ function buildPersonaHandlers(deps) {
|
|
|
72966
73028
|
}
|
|
72967
73029
|
|
|
72968
73030
|
// src/handlers/attachment.ts
|
|
72969
|
-
var
|
|
73031
|
+
var import_node_path71 = __toESM(require("path"), 1);
|
|
72970
73032
|
init_protocol();
|
|
72971
73033
|
init_protocol();
|
|
72972
73034
|
function assertGuestAttachmentPath(ctx, absPath, personaRoot, method, usersRoot) {
|
|
@@ -73045,12 +73107,12 @@ function buildAttachmentHandlers(deps) {
|
|
|
73045
73107
|
`session ${args.sessionId} scope unresolved`
|
|
73046
73108
|
);
|
|
73047
73109
|
}
|
|
73048
|
-
const cwdAbs =
|
|
73049
|
-
const candidateAbs =
|
|
73110
|
+
const cwdAbs = import_node_path71.default.resolve(sessionFile.cwd);
|
|
73111
|
+
const candidateAbs = import_node_path71.default.isAbsolute(args.relPath) ? import_node_path71.default.resolve(args.relPath) : import_node_path71.default.resolve(cwdAbs, args.relPath);
|
|
73050
73112
|
guardAttachmentPath(ctx, args.sessionId, candidateAbs, "attachment.signUrl", "group-acl");
|
|
73051
73113
|
const entries = deps.groupFileStore.list(scope, args.sessionId);
|
|
73052
73114
|
const entry = entries.find((e) => {
|
|
73053
|
-
const storedAbs =
|
|
73115
|
+
const storedAbs = import_node_path71.default.isAbsolute(e.relPath) ? import_node_path71.default.resolve(e.relPath) : import_node_path71.default.resolve(cwdAbs, e.relPath);
|
|
73054
73116
|
return storedAbs === candidateAbs && !e.stale;
|
|
73055
73117
|
});
|
|
73056
73118
|
if (!entry) {
|
|
@@ -73074,7 +73136,7 @@ function buildAttachmentHandlers(deps) {
|
|
|
73074
73136
|
if (!ctx || ctx.principal.kind !== "guest" || !deps.personaRoot || !deps.sessionStore) return;
|
|
73075
73137
|
const f2 = deps.sessionStore.read(sessionId);
|
|
73076
73138
|
if (!f2) return;
|
|
73077
|
-
assertGuestAttachmentPath(ctx,
|
|
73139
|
+
assertGuestAttachmentPath(ctx, import_node_path71.default.resolve(f2.cwd), deps.personaRoot, method, deps.usersRoot);
|
|
73078
73140
|
}
|
|
73079
73141
|
const groupAdd = async (frame, _client, ctx) => {
|
|
73080
73142
|
if (!deps.groupFileStore || !deps.getSessionScope) {
|
|
@@ -73089,8 +73151,8 @@ function buildAttachmentHandlers(deps) {
|
|
|
73089
73151
|
if (!scope) {
|
|
73090
73152
|
throw new ClawdError(ERROR_CODES.VALIDATION_ERROR, `session ${args.sessionId} not found`);
|
|
73091
73153
|
}
|
|
73092
|
-
const cwdAbs =
|
|
73093
|
-
const candidateAbs =
|
|
73154
|
+
const cwdAbs = import_node_path71.default.resolve(deps.sessionStore?.read(args.sessionId)?.cwd ?? ".");
|
|
73155
|
+
const candidateAbs = import_node_path71.default.isAbsolute(args.relPath) ? import_node_path71.default.resolve(args.relPath) : import_node_path71.default.resolve(cwdAbs, args.relPath);
|
|
73094
73156
|
guardAttachmentPath(ctx, args.sessionId, candidateAbs, "attachment.groupAdd", "cwd-subtree");
|
|
73095
73157
|
const from = args.origin === "agent" ? "agent" : ctx?.principal.kind === "owner" ? "owner" : "agent";
|
|
73096
73158
|
const size = 0;
|
|
@@ -73149,19 +73211,19 @@ function buildAttachmentHandlers(deps) {
|
|
|
73149
73211
|
|
|
73150
73212
|
// src/handlers/extension.ts
|
|
73151
73213
|
var import_promises15 = __toESM(require("fs/promises"), 1);
|
|
73152
|
-
var
|
|
73214
|
+
var import_node_path76 = __toESM(require("path"), 1);
|
|
73153
73215
|
init_protocol();
|
|
73154
73216
|
|
|
73155
73217
|
// src/extension/bundle-zip.ts
|
|
73156
73218
|
var import_promises12 = __toESM(require("fs/promises"), 1);
|
|
73157
|
-
var
|
|
73219
|
+
var import_node_path72 = __toESM(require("path"), 1);
|
|
73158
73220
|
var import_node_crypto22 = __toESM(require("crypto"), 1);
|
|
73159
73221
|
var import_jszip2 = __toESM(require_lib3(), 1);
|
|
73160
73222
|
async function bundleExtensionDir(dir) {
|
|
73161
73223
|
const entries = await listFilesSorted(dir);
|
|
73162
73224
|
const zip = new import_jszip2.default();
|
|
73163
73225
|
for (const rel of entries) {
|
|
73164
|
-
const abs =
|
|
73226
|
+
const abs = import_node_path72.default.join(dir, rel);
|
|
73165
73227
|
const content = await import_promises12.default.readFile(abs);
|
|
73166
73228
|
zip.file(rel, content, { date: FIXED_DATE });
|
|
73167
73229
|
}
|
|
@@ -73182,7 +73244,7 @@ async function listFilesSorted(rootDir) {
|
|
|
73182
73244
|
return out;
|
|
73183
73245
|
}
|
|
73184
73246
|
async function walk(absRoot, relPrefix, out) {
|
|
73185
|
-
const dirAbs =
|
|
73247
|
+
const dirAbs = import_node_path72.default.join(absRoot, relPrefix);
|
|
73186
73248
|
const entries = await import_promises12.default.readdir(dirAbs, { withFileTypes: true });
|
|
73187
73249
|
for (const e of entries) {
|
|
73188
73250
|
if (IGNORE_BASENAMES.has(e.name)) continue;
|
|
@@ -73236,25 +73298,25 @@ function computePublishCheck(args) {
|
|
|
73236
73298
|
|
|
73237
73299
|
// src/extension/install-flow.ts
|
|
73238
73300
|
var import_promises13 = __toESM(require("fs/promises"), 1);
|
|
73239
|
-
var
|
|
73240
|
-
var
|
|
73301
|
+
var import_node_path74 = __toESM(require("path"), 1);
|
|
73302
|
+
var import_node_os29 = __toESM(require("os"), 1);
|
|
73241
73303
|
var import_node_crypto23 = __toESM(require("crypto"), 1);
|
|
73242
73304
|
var import_jszip3 = __toESM(require_lib3(), 1);
|
|
73243
73305
|
|
|
73244
73306
|
// src/extension/paths.ts
|
|
73245
|
-
var
|
|
73246
|
-
var
|
|
73307
|
+
var import_node_os28 = __toESM(require("os"), 1);
|
|
73308
|
+
var import_node_path73 = __toESM(require("path"), 1);
|
|
73247
73309
|
function clawdHomeRoot(override) {
|
|
73248
|
-
return override ?? process.env.CLAWD_HOME ??
|
|
73310
|
+
return override ?? process.env.CLAWD_HOME ?? import_node_path73.default.join(import_node_os28.default.homedir(), ".clawd");
|
|
73249
73311
|
}
|
|
73250
73312
|
function extensionsRoot(override) {
|
|
73251
|
-
return
|
|
73313
|
+
return import_node_path73.default.join(clawdHomeRoot(override), "extensions");
|
|
73252
73314
|
}
|
|
73253
73315
|
function publishedChannelsFile(override) {
|
|
73254
|
-
return
|
|
73316
|
+
return import_node_path73.default.join(clawdHomeRoot(override), "extensions-published.json");
|
|
73255
73317
|
}
|
|
73256
73318
|
function bundleCacheRoot(override) {
|
|
73257
|
-
return
|
|
73319
|
+
return import_node_path73.default.join(clawdHomeRoot(override), "extension-bundles");
|
|
73258
73320
|
}
|
|
73259
73321
|
|
|
73260
73322
|
// src/extension/install-flow.ts
|
|
@@ -73281,7 +73343,7 @@ async function installFromChannel(args, deps) {
|
|
|
73281
73343
|
throw new InstallError("ZIP_INVALID", `failed to load zip: ${e.message}`);
|
|
73282
73344
|
}
|
|
73283
73345
|
for (const name of Object.keys(zip.files)) {
|
|
73284
|
-
if (name.includes("..") || name.startsWith("/") ||
|
|
73346
|
+
if (name.includes("..") || name.startsWith("/") || import_node_path74.default.isAbsolute(name)) {
|
|
73285
73347
|
throw new InstallError("ZIP_INVALID", `unsafe zip entry: ${name}`);
|
|
73286
73348
|
}
|
|
73287
73349
|
}
|
|
@@ -73313,7 +73375,7 @@ async function installFromChannel(args, deps) {
|
|
|
73313
73375
|
);
|
|
73314
73376
|
}
|
|
73315
73377
|
const localExtId = namespacedExtId(ownerSlug, channelRef.ownerPrincipalId);
|
|
73316
|
-
const destDir =
|
|
73378
|
+
const destDir = import_node_path74.default.join(deps.extensionsRoot, localExtId);
|
|
73317
73379
|
let destExists = false;
|
|
73318
73380
|
try {
|
|
73319
73381
|
await import_promises13.default.access(destDir);
|
|
@@ -73327,16 +73389,16 @@ async function installFromChannel(args, deps) {
|
|
|
73327
73389
|
);
|
|
73328
73390
|
}
|
|
73329
73391
|
const stage = await import_promises13.default.mkdtemp(
|
|
73330
|
-
|
|
73392
|
+
import_node_path74.default.join(import_node_os29.default.tmpdir(), `clawd-ext-install-${localExtId}-`)
|
|
73331
73393
|
);
|
|
73332
73394
|
try {
|
|
73333
73395
|
for (const [name, entry] of Object.entries(zip.files)) {
|
|
73334
|
-
const dest =
|
|
73396
|
+
const dest = import_node_path74.default.join(stage, name);
|
|
73335
73397
|
if (entry.dir) {
|
|
73336
73398
|
await import_promises13.default.mkdir(dest, { recursive: true });
|
|
73337
73399
|
continue;
|
|
73338
73400
|
}
|
|
73339
|
-
await import_promises13.default.mkdir(
|
|
73401
|
+
await import_promises13.default.mkdir(import_node_path74.default.dirname(dest), { recursive: true });
|
|
73340
73402
|
if (name === "manifest.json") {
|
|
73341
73403
|
const rewritten = { ...parsed.data, id: localExtId };
|
|
73342
73404
|
await import_promises13.default.writeFile(dest, JSON.stringify(rewritten, null, 2));
|
|
@@ -73357,8 +73419,8 @@ async function installFromChannel(args, deps) {
|
|
|
73357
73419
|
|
|
73358
73420
|
// src/extension/update-flow.ts
|
|
73359
73421
|
var import_promises14 = __toESM(require("fs/promises"), 1);
|
|
73360
|
-
var
|
|
73361
|
-
var
|
|
73422
|
+
var import_node_path75 = __toESM(require("path"), 1);
|
|
73423
|
+
var import_node_os30 = __toESM(require("os"), 1);
|
|
73362
73424
|
var import_node_crypto24 = __toESM(require("crypto"), 1);
|
|
73363
73425
|
var import_jszip4 = __toESM(require_lib3(), 1);
|
|
73364
73426
|
var UpdateError = class extends Error {
|
|
@@ -73374,11 +73436,11 @@ async function updateFromChannel(args, deps) {
|
|
|
73374
73436
|
channelRef.extId,
|
|
73375
73437
|
channelRef.ownerPrincipalId
|
|
73376
73438
|
);
|
|
73377
|
-
const liveDir =
|
|
73439
|
+
const liveDir = import_node_path75.default.join(deps.extensionsRoot, localExtId);
|
|
73378
73440
|
const prevDir = `${liveDir}.prev`;
|
|
73379
73441
|
let existingVersion;
|
|
73380
73442
|
try {
|
|
73381
|
-
const raw = await import_promises14.default.readFile(
|
|
73443
|
+
const raw = await import_promises14.default.readFile(import_node_path75.default.join(liveDir, "manifest.json"), "utf8");
|
|
73382
73444
|
const parsed2 = ExtensionManifestSchema.safeParse(JSON.parse(raw));
|
|
73383
73445
|
if (!parsed2.success) {
|
|
73384
73446
|
throw new UpdateError(
|
|
@@ -73411,7 +73473,7 @@ async function updateFromChannel(args, deps) {
|
|
|
73411
73473
|
throw new UpdateError("ZIP_INVALID", `failed to load zip: ${e.message}`);
|
|
73412
73474
|
}
|
|
73413
73475
|
for (const name of Object.keys(zip.files)) {
|
|
73414
|
-
if (name.includes("..") || name.startsWith("/") ||
|
|
73476
|
+
if (name.includes("..") || name.startsWith("/") || import_node_path75.default.isAbsolute(name)) {
|
|
73415
73477
|
throw new UpdateError("ZIP_INVALID", `unsafe zip entry: ${name}`);
|
|
73416
73478
|
}
|
|
73417
73479
|
}
|
|
@@ -73446,16 +73508,16 @@ async function updateFromChannel(args, deps) {
|
|
|
73446
73508
|
await import_promises14.default.rm(prevDir, { recursive: true, force: true });
|
|
73447
73509
|
await import_promises14.default.rename(liveDir, prevDir);
|
|
73448
73510
|
const stage = await import_promises14.default.mkdtemp(
|
|
73449
|
-
|
|
73511
|
+
import_node_path75.default.join(import_node_os30.default.tmpdir(), `clawd-ext-update-${localExtId}-`)
|
|
73450
73512
|
);
|
|
73451
73513
|
try {
|
|
73452
73514
|
for (const [name, entry] of Object.entries(zip.files)) {
|
|
73453
|
-
const dest =
|
|
73515
|
+
const dest = import_node_path75.default.join(stage, name);
|
|
73454
73516
|
if (entry.dir) {
|
|
73455
73517
|
await import_promises14.default.mkdir(dest, { recursive: true });
|
|
73456
73518
|
continue;
|
|
73457
73519
|
}
|
|
73458
|
-
await import_promises14.default.mkdir(
|
|
73520
|
+
await import_promises14.default.mkdir(import_node_path75.default.dirname(dest), { recursive: true });
|
|
73459
73521
|
if (name === "manifest.json") {
|
|
73460
73522
|
const rewritten = { ...parsed.data, id: localExtId };
|
|
73461
73523
|
await import_promises14.default.writeFile(dest, JSON.stringify(rewritten, null, 2));
|
|
@@ -73522,7 +73584,7 @@ async function rewriteManifestVersion(root, extId, newVersion, previousPublished
|
|
|
73522
73584
|
);
|
|
73523
73585
|
}
|
|
73524
73586
|
}
|
|
73525
|
-
const manifestPath =
|
|
73587
|
+
const manifestPath = import_node_path76.default.join(root, extId, "manifest.json");
|
|
73526
73588
|
const manifest = await readManifest(root, extId);
|
|
73527
73589
|
const next = { ...manifest, version: newVersion };
|
|
73528
73590
|
const tmp = `${manifestPath}.tmp`;
|
|
@@ -73530,7 +73592,7 @@ async function rewriteManifestVersion(root, extId, newVersion, previousPublished
|
|
|
73530
73592
|
await import_promises15.default.rename(tmp, manifestPath);
|
|
73531
73593
|
}
|
|
73532
73594
|
async function readManifest(root, extId) {
|
|
73533
|
-
const file =
|
|
73595
|
+
const file = import_node_path76.default.join(root, extId, "manifest.json");
|
|
73534
73596
|
let raw;
|
|
73535
73597
|
try {
|
|
73536
73598
|
raw = await import_promises15.default.readFile(file, "utf8");
|
|
@@ -73614,7 +73676,7 @@ function buildExtensionHandlers(deps) {
|
|
|
73614
73676
|
};
|
|
73615
73677
|
async function buildSnapshotMeta(extId) {
|
|
73616
73678
|
const manifest = await readManifest(deps.root, extId);
|
|
73617
|
-
const { sha256, buffer } = await bundleExtensionDir(
|
|
73679
|
+
const { sha256, buffer } = await bundleExtensionDir(import_node_path76.default.join(deps.root, extId));
|
|
73618
73680
|
return { manifest, contentHash: sha256, buffer };
|
|
73619
73681
|
}
|
|
73620
73682
|
const publish = async (frame, _client, ctx) => {
|
|
@@ -74442,7 +74504,7 @@ function buildVisitorHandlers(deps) {
|
|
|
74442
74504
|
|
|
74443
74505
|
// src/extension/registry.ts
|
|
74444
74506
|
var import_promises17 = __toESM(require("fs/promises"), 1);
|
|
74445
|
-
var
|
|
74507
|
+
var import_node_path77 = __toESM(require("path"), 1);
|
|
74446
74508
|
async function loadAll(root) {
|
|
74447
74509
|
let entries;
|
|
74448
74510
|
try {
|
|
@@ -74455,13 +74517,13 @@ async function loadAll(root) {
|
|
|
74455
74517
|
for (const ent of entries) {
|
|
74456
74518
|
if (!ent.isDirectory()) continue;
|
|
74457
74519
|
if (ent.name.startsWith(".")) continue;
|
|
74458
|
-
records.push(await loadOne(
|
|
74520
|
+
records.push(await loadOne(import_node_path77.default.join(root, ent.name), ent.name));
|
|
74459
74521
|
}
|
|
74460
74522
|
records.sort((a2, b3) => a2.extId < b3.extId ? -1 : a2.extId > b3.extId ? 1 : 0);
|
|
74461
74523
|
return records;
|
|
74462
74524
|
}
|
|
74463
74525
|
async function loadOne(dir, dirName) {
|
|
74464
|
-
const manifestPath =
|
|
74526
|
+
const manifestPath = import_node_path77.default.join(dir, "manifest.json");
|
|
74465
74527
|
let raw;
|
|
74466
74528
|
try {
|
|
74467
74529
|
raw = await import_promises17.default.readFile(manifestPath, "utf8");
|
|
@@ -74506,7 +74568,7 @@ async function loadOne(dir, dirName) {
|
|
|
74506
74568
|
|
|
74507
74569
|
// src/extension/uninstall.ts
|
|
74508
74570
|
var import_promises18 = __toESM(require("fs/promises"), 1);
|
|
74509
|
-
var
|
|
74571
|
+
var import_node_path78 = __toESM(require("path"), 1);
|
|
74510
74572
|
var UninstallError = class extends Error {
|
|
74511
74573
|
constructor(code, message) {
|
|
74512
74574
|
super(message);
|
|
@@ -74515,7 +74577,7 @@ var UninstallError = class extends Error {
|
|
|
74515
74577
|
code;
|
|
74516
74578
|
};
|
|
74517
74579
|
async function uninstall(deps) {
|
|
74518
|
-
const dir =
|
|
74580
|
+
const dir = import_node_path78.default.join(deps.root, deps.extId);
|
|
74519
74581
|
try {
|
|
74520
74582
|
await import_promises18.default.access(dir);
|
|
74521
74583
|
} catch {
|
|
@@ -74533,14 +74595,14 @@ init_protocol();
|
|
|
74533
74595
|
|
|
74534
74596
|
// src/peer-ops/run-command.ts
|
|
74535
74597
|
var import_node_child_process23 = require("child_process");
|
|
74536
|
-
var
|
|
74598
|
+
var import_node_os31 = __toESM(require("os"), 1);
|
|
74537
74599
|
var DEFAULT_TIMEOUT_MS6 = 3e4;
|
|
74538
74600
|
var MAX_TIMEOUT_MS = 3e5;
|
|
74539
74601
|
var MAX_OUTPUT_BYTES = 1048576;
|
|
74540
74602
|
function runCommand2(command, opts = {}) {
|
|
74541
74603
|
const timeoutMs = Math.min(opts.timeoutMs ?? DEFAULT_TIMEOUT_MS6, MAX_TIMEOUT_MS);
|
|
74542
74604
|
return new Promise((resolve9) => {
|
|
74543
|
-
const child = (0, import_node_child_process23.spawn)("bash", ["-c", command], { cwd:
|
|
74605
|
+
const child = (0, import_node_child_process23.spawn)("bash", ["-c", command], { cwd: import_node_os31.default.homedir() });
|
|
74544
74606
|
const out = [];
|
|
74545
74607
|
const err = [];
|
|
74546
74608
|
let outBytes = 0;
|
|
@@ -74733,7 +74795,7 @@ function buildMethodHandlers(deps) {
|
|
|
74733
74795
|
broadcast: deps.broadcastToOwners
|
|
74734
74796
|
}),
|
|
74735
74797
|
...buildMasterHandlers({
|
|
74736
|
-
authorityTablePath:
|
|
74798
|
+
authorityTablePath: import_node_path79.default.join(deps.masterDataDir, "master-authority.json")
|
|
74737
74799
|
}),
|
|
74738
74800
|
...buildTopicHandlers({
|
|
74739
74801
|
topicStore: deps.topicStore,
|
|
@@ -74876,7 +74938,7 @@ async function dispatchRpc(method, frame, client, ctx, deps) {
|
|
|
74876
74938
|
|
|
74877
74939
|
// src/extension/runtime.ts
|
|
74878
74940
|
var import_node_child_process24 = require("child_process");
|
|
74879
|
-
var
|
|
74941
|
+
var import_node_path80 = __toESM(require("path"), 1);
|
|
74880
74942
|
var import_promises19 = require("timers/promises");
|
|
74881
74943
|
|
|
74882
74944
|
// src/extension/port-allocator.ts
|
|
@@ -74977,7 +75039,7 @@ var Runtime = class {
|
|
|
74977
75039
|
/\$CLAWOS_EXT_PORT/g,
|
|
74978
75040
|
String(port)
|
|
74979
75041
|
);
|
|
74980
|
-
const dir =
|
|
75042
|
+
const dir = import_node_path80.default.join(this.root, extId);
|
|
74981
75043
|
const env = {
|
|
74982
75044
|
...process.env,
|
|
74983
75045
|
CLAWOS_EXT_PORT: String(port),
|
|
@@ -75089,7 +75151,7 @@ ${handle.stderrTail}`
|
|
|
75089
75151
|
|
|
75090
75152
|
// src/extension/published-channels.ts
|
|
75091
75153
|
var import_promises20 = __toESM(require("fs/promises"), 1);
|
|
75092
|
-
var
|
|
75154
|
+
var import_node_path81 = __toESM(require("path"), 1);
|
|
75093
75155
|
init_zod();
|
|
75094
75156
|
var PublishedChannelsError = class extends Error {
|
|
75095
75157
|
constructor(code, message) {
|
|
@@ -75188,7 +75250,7 @@ var PublishedChannelStore = class {
|
|
|
75188
75250
|
)
|
|
75189
75251
|
};
|
|
75190
75252
|
const tmp = `${this.filePath}.tmp`;
|
|
75191
|
-
await import_promises20.default.mkdir(
|
|
75253
|
+
await import_promises20.default.mkdir(import_node_path81.default.dirname(this.filePath), { recursive: true });
|
|
75192
75254
|
await import_promises20.default.writeFile(tmp, JSON.stringify(data, null, 2), { mode: 384 });
|
|
75193
75255
|
await import_promises20.default.rename(tmp, this.filePath);
|
|
75194
75256
|
}
|
|
@@ -75196,7 +75258,7 @@ var PublishedChannelStore = class {
|
|
|
75196
75258
|
|
|
75197
75259
|
// src/extension/bundle-cache.ts
|
|
75198
75260
|
var import_promises21 = __toESM(require("fs/promises"), 1);
|
|
75199
|
-
var
|
|
75261
|
+
var import_node_path82 = __toESM(require("path"), 1);
|
|
75200
75262
|
var BundleCache = class {
|
|
75201
75263
|
constructor(rootDir) {
|
|
75202
75264
|
this.rootDir = rootDir;
|
|
@@ -75205,14 +75267,14 @@ var BundleCache = class {
|
|
|
75205
75267
|
/** Atomic write: stage tmp → rename. Caller passes the hex sha256. */
|
|
75206
75268
|
async write(snapshotHash, buffer) {
|
|
75207
75269
|
await import_promises21.default.mkdir(this.rootDir, { recursive: true });
|
|
75208
|
-
const file =
|
|
75270
|
+
const file = import_node_path82.default.join(this.rootDir, `${snapshotHash}.zip`);
|
|
75209
75271
|
const tmp = `${file}.tmp`;
|
|
75210
75272
|
await import_promises21.default.writeFile(tmp, buffer, { mode: 384 });
|
|
75211
75273
|
await import_promises21.default.rename(tmp, file);
|
|
75212
75274
|
}
|
|
75213
75275
|
/** Returns the bundle bytes, or null when the file doesn't exist. */
|
|
75214
75276
|
async read(snapshotHash) {
|
|
75215
|
-
const file =
|
|
75277
|
+
const file = import_node_path82.default.join(this.rootDir, `${snapshotHash}.zip`);
|
|
75216
75278
|
try {
|
|
75217
75279
|
return await import_promises21.default.readFile(file);
|
|
75218
75280
|
} catch (e) {
|
|
@@ -75222,7 +75284,7 @@ var BundleCache = class {
|
|
|
75222
75284
|
}
|
|
75223
75285
|
/** Idempotent — missing file is not an error. */
|
|
75224
75286
|
async delete(snapshotHash) {
|
|
75225
|
-
const file =
|
|
75287
|
+
const file = import_node_path82.default.join(this.rootDir, `${snapshotHash}.zip`);
|
|
75226
75288
|
await import_promises21.default.rm(file, { force: true });
|
|
75227
75289
|
}
|
|
75228
75290
|
};
|
|
@@ -75243,26 +75305,26 @@ async function startDaemon(config) {
|
|
|
75243
75305
|
},
|
|
75244
75306
|
source: "daemon",
|
|
75245
75307
|
sampling: logShippingCfg.sampling,
|
|
75246
|
-
homeDir:
|
|
75308
|
+
homeDir: import_node_os32.default.homedir()
|
|
75247
75309
|
});
|
|
75248
|
-
const logDir =
|
|
75249
|
-
|
|
75310
|
+
const logDir = import_node_path83.default.join(config.dataDir, "log");
|
|
75311
|
+
import_node_fs65.default.mkdirSync(logDir, { recursive: true });
|
|
75250
75312
|
const logger = createLogger({
|
|
75251
75313
|
level: config.logLevel,
|
|
75252
|
-
file:
|
|
75314
|
+
file: import_node_path83.default.join(logDir, "clawd.log"),
|
|
75253
75315
|
logClient
|
|
75254
75316
|
});
|
|
75255
75317
|
logger.info("starting clawd", { version, config: { port: config.port, host: config.host, dataDir: config.dataDir } });
|
|
75256
75318
|
const screenIdleProbeLogger = createFileOnlyLogger({
|
|
75257
|
-
file:
|
|
75319
|
+
file: import_node_path83.default.join(logDir, "screen-idle-probe.log"),
|
|
75258
75320
|
level: "debug"
|
|
75259
75321
|
});
|
|
75260
75322
|
logger.info("screen-idle probe logger enabled", {
|
|
75261
|
-
file:
|
|
75323
|
+
file: import_node_path83.default.join(logDir, "screen-idle-probe.log")
|
|
75262
75324
|
});
|
|
75263
75325
|
const CAP_TARGETS = [
|
|
75264
|
-
|
|
75265
|
-
|
|
75326
|
+
import_node_path83.default.join(logDir, "clawd.log"),
|
|
75327
|
+
import_node_path83.default.join(logDir, "screen-idle-probe.log")
|
|
75266
75328
|
];
|
|
75267
75329
|
const LOG_CAP_MAX_BYTES = 10 * 1024 * 1024;
|
|
75268
75330
|
const LOG_CAP_KEEP_BYTES = 5 * 1024 * 1024;
|
|
@@ -75384,9 +75446,9 @@ async function startDaemon(config) {
|
|
|
75384
75446
|
const agents = new AgentsScanner();
|
|
75385
75447
|
const history = new ClaudeHistoryReader();
|
|
75386
75448
|
let transport = null;
|
|
75387
|
-
const personaStore = new PersonaStore(
|
|
75449
|
+
const personaStore = new PersonaStore(import_node_path83.default.join(config.dataDir, "personas"));
|
|
75388
75450
|
const subscriptionChannelStore = new SubscriptionChannelStore({ dataDir: config.dataDir });
|
|
75389
|
-
const usersRoot =
|
|
75451
|
+
const usersRoot = import_node_path83.default.join(config.dataDir, "users");
|
|
75390
75452
|
const defaultsRoot = findDefaultsRoot(logger);
|
|
75391
75453
|
if (defaultsRoot) {
|
|
75392
75454
|
seedDefaultPersonas({ store: personaStore, defaultsRoot, logger });
|
|
@@ -75403,7 +75465,7 @@ async function startDaemon(config) {
|
|
|
75403
75465
|
retirePersonaBuilder({ store: personaStore, logger });
|
|
75404
75466
|
const groupFileStore = new GroupFileStore({ dataDir: config.dataDir, logger });
|
|
75405
75467
|
const dispatchStore = createDispatchStore({
|
|
75406
|
-
filePath:
|
|
75468
|
+
filePath: import_node_path83.default.join(config.dataDir, "dispatch.json"),
|
|
75407
75469
|
now: () => Date.now(),
|
|
75408
75470
|
onFlushError: (err) => logger.error("dispatch store flush failed", {
|
|
75409
75471
|
reason: err instanceof Error ? err.message : String(err)
|
|
@@ -75412,7 +75474,7 @@ async function startDaemon(config) {
|
|
|
75412
75474
|
await dispatchStore.load();
|
|
75413
75475
|
dispatchStore.markInterruptedAsFailed((/* @__PURE__ */ new Date()).toISOString());
|
|
75414
75476
|
const channelStore = createChannelStore({
|
|
75415
|
-
filePath:
|
|
75477
|
+
filePath: import_node_path83.default.join(config.dataDir, "channels.json"),
|
|
75416
75478
|
now: () => Date.now(),
|
|
75417
75479
|
genId: () => `ch-${(0, import_node_crypto26.randomUUID)().slice(0, 8)}`,
|
|
75418
75480
|
onFlushError: (err) => logger.error("channel store flush failed", {
|
|
@@ -75421,7 +75483,7 @@ async function startDaemon(config) {
|
|
|
75421
75483
|
});
|
|
75422
75484
|
await channelStore.load();
|
|
75423
75485
|
const topicStore = createTopicStore({
|
|
75424
|
-
filePath:
|
|
75486
|
+
filePath: import_node_path83.default.join(config.dataDir, "topics.json"),
|
|
75425
75487
|
now: () => Date.now(),
|
|
75426
75488
|
genId: () => `tp-${(0, import_node_crypto26.randomUUID)().slice(0, 8)}`,
|
|
75427
75489
|
onFlushError: (err) => logger.error("topic store flush failed", {
|
|
@@ -75448,12 +75510,12 @@ async function startDaemon(config) {
|
|
|
75448
75510
|
});
|
|
75449
75511
|
}
|
|
75450
75512
|
});
|
|
75451
|
-
const here = typeof __dirname === "string" ? __dirname :
|
|
75513
|
+
const here = typeof __dirname === "string" ? __dirname : import_node_path83.default.dirname((0, import_node_url6.fileURLToPath)(import_meta10.url));
|
|
75452
75514
|
const mcpConfigs = [];
|
|
75453
75515
|
const secretsBundleRoot = findSecretsBundleRoot(logger);
|
|
75454
|
-
const localSecretsDir =
|
|
75516
|
+
const localSecretsDir = import_node_path83.default.join(config.dataDir, LOCAL_SECRETS_DIRNAME);
|
|
75455
75517
|
const readSecrets = () => readSecretTable({ bundleRoot: secretsBundleRoot, overrideDir: localSecretsDir, logger });
|
|
75456
|
-
const githubTokenFile =
|
|
75518
|
+
const githubTokenFile = import_node_path83.default.join(localSecretsDir, GITHUB_TOKEN_FILE);
|
|
75457
75519
|
const githubIdentity = createGithubIdentity({
|
|
75458
75520
|
resolve: () => resolveGithubAuth({ exec: runCommand, fileToken: () => readEnvFileVar(githubTokenFile, GITHUB_TOKEN_VAR) }),
|
|
75459
75521
|
store: (token) => storeGithubAuth({
|
|
@@ -75491,22 +75553,22 @@ async function startDaemon(config) {
|
|
|
75491
75553
|
void githubIdentity.refresh();
|
|
75492
75554
|
return renderPersonaMcpSecrets({
|
|
75493
75555
|
personaId: personaId2,
|
|
75494
|
-
personaDir:
|
|
75556
|
+
personaDir: import_node_path83.default.join(config.dataDir, "personas", personaId2),
|
|
75495
75557
|
secrets,
|
|
75496
|
-
outDir:
|
|
75558
|
+
outDir: import_node_path83.default.join(config.dataDir, "persona-mcp"),
|
|
75497
75559
|
logger
|
|
75498
75560
|
});
|
|
75499
75561
|
};
|
|
75500
75562
|
const mcpDaemonUrl = `http://127.0.0.1:${config.port}`;
|
|
75501
75563
|
const dispatchServerCandidates = [
|
|
75502
|
-
|
|
75564
|
+
import_node_path83.default.join(here, "dispatch", "mcp-server.cjs"),
|
|
75503
75565
|
// 生产 dist/index → dist/dispatch/mcp-server.cjs
|
|
75504
|
-
|
|
75566
|
+
import_node_path83.default.join(here, "..", "dist", "dispatch", "mcp-server.cjs")
|
|
75505
75567
|
// dev tsx src/index → ../dist/dispatch/mcp-server.cjs
|
|
75506
75568
|
];
|
|
75507
|
-
const dispatchServerScriptPath = dispatchServerCandidates.find((p3) =>
|
|
75569
|
+
const dispatchServerScriptPath = dispatchServerCandidates.find((p3) => import_node_fs65.default.existsSync(p3));
|
|
75508
75570
|
if (dispatchServerScriptPath) {
|
|
75509
|
-
const dispatchLogPath =
|
|
75571
|
+
const dispatchLogPath = import_node_path83.default.join(logDir, "dispatch-mcp-server.log");
|
|
75510
75572
|
const dispatchCfgPath = writeDispatchMcpConfig({
|
|
75511
75573
|
dataDir: config.dataDir,
|
|
75512
75574
|
serverScriptPath: dispatchServerScriptPath,
|
|
@@ -75526,12 +75588,12 @@ async function startDaemon(config) {
|
|
|
75526
75588
|
});
|
|
75527
75589
|
}
|
|
75528
75590
|
const ticketServerCandidates = [
|
|
75529
|
-
|
|
75530
|
-
|
|
75591
|
+
import_node_path83.default.join(here, "ticket", "mcp-server.cjs"),
|
|
75592
|
+
import_node_path83.default.join(here, "..", "dist", "ticket", "mcp-server.cjs")
|
|
75531
75593
|
];
|
|
75532
|
-
const ticketServerScriptPath = ticketServerCandidates.find((p3) =>
|
|
75594
|
+
const ticketServerScriptPath = ticketServerCandidates.find((p3) => import_node_fs65.default.existsSync(p3));
|
|
75533
75595
|
if (ticketServerScriptPath) {
|
|
75534
|
-
const ticketLogPath =
|
|
75596
|
+
const ticketLogPath = import_node_path83.default.join(logDir, "ticket-mcp-server.log");
|
|
75535
75597
|
const ticketCfgPath = writeTicketMcpConfig({
|
|
75536
75598
|
dataDir: config.dataDir,
|
|
75537
75599
|
serverScriptPath: ticketServerScriptPath,
|
|
@@ -75553,12 +75615,12 @@ async function startDaemon(config) {
|
|
|
75553
75615
|
});
|
|
75554
75616
|
}
|
|
75555
75617
|
const shiftServerCandidates = [
|
|
75556
|
-
|
|
75557
|
-
|
|
75618
|
+
import_node_path83.default.join(here, "shift", "mcp-server.cjs"),
|
|
75619
|
+
import_node_path83.default.join(here, "..", "dist", "shift", "mcp-server.cjs")
|
|
75558
75620
|
];
|
|
75559
|
-
const shiftServerScriptPath = shiftServerCandidates.find((p3) =>
|
|
75621
|
+
const shiftServerScriptPath = shiftServerCandidates.find((p3) => import_node_fs65.default.existsSync(p3));
|
|
75560
75622
|
if (shiftServerScriptPath) {
|
|
75561
|
-
const shiftLogPath =
|
|
75623
|
+
const shiftLogPath = import_node_path83.default.join(logDir, "shift-mcp-server.log");
|
|
75562
75624
|
const shiftCfgPath = await writeShiftMcpConfig({
|
|
75563
75625
|
dataDir: config.dataDir,
|
|
75564
75626
|
serverScriptPath: shiftServerScriptPath,
|
|
@@ -75579,12 +75641,12 @@ async function startDaemon(config) {
|
|
|
75579
75641
|
);
|
|
75580
75642
|
}
|
|
75581
75643
|
const inboxServerCandidates = [
|
|
75582
|
-
|
|
75583
|
-
|
|
75644
|
+
import_node_path83.default.join(here, "inbox", "mcp-server.cjs"),
|
|
75645
|
+
import_node_path83.default.join(here, "..", "dist", "inbox", "mcp-server.cjs")
|
|
75584
75646
|
];
|
|
75585
|
-
const inboxServerScriptPath = inboxServerCandidates.find((p3) =>
|
|
75647
|
+
const inboxServerScriptPath = inboxServerCandidates.find((p3) => import_node_fs65.default.existsSync(p3));
|
|
75586
75648
|
if (inboxServerScriptPath) {
|
|
75587
|
-
const inboxLogPath =
|
|
75649
|
+
const inboxLogPath = import_node_path83.default.join(logDir, "inbox-mcp-server.log");
|
|
75588
75650
|
const inboxCfgPath = await writeInboxMcpConfig({
|
|
75589
75651
|
dataDir: config.dataDir,
|
|
75590
75652
|
serverScriptPath: inboxServerScriptPath,
|
|
@@ -75605,10 +75667,10 @@ async function startDaemon(config) {
|
|
|
75605
75667
|
);
|
|
75606
75668
|
}
|
|
75607
75669
|
const peerOpsServerCandidates = [
|
|
75608
|
-
|
|
75609
|
-
|
|
75670
|
+
import_node_path83.default.join(here, "peer-ops", "mcp-server.cjs"),
|
|
75671
|
+
import_node_path83.default.join(here, "..", "dist", "peer-ops", "mcp-server.cjs")
|
|
75610
75672
|
];
|
|
75611
|
-
const peerOpsServerScriptPath = peerOpsServerCandidates.find((p3) =>
|
|
75673
|
+
const peerOpsServerScriptPath = peerOpsServerCandidates.find((p3) => import_node_fs65.default.existsSync(p3));
|
|
75612
75674
|
if (peerOpsServerScriptPath) {
|
|
75613
75675
|
const peerOpsCfgPath = writePeerOpsMcpConfig({
|
|
75614
75676
|
dataDir: config.dataDir,
|
|
@@ -75628,12 +75690,12 @@ async function startDaemon(config) {
|
|
|
75628
75690
|
);
|
|
75629
75691
|
}
|
|
75630
75692
|
const rpcToolServerCandidates = [
|
|
75631
|
-
|
|
75632
|
-
|
|
75693
|
+
import_node_path83.default.join(here, "rpc-tool", "mcp-server.cjs"),
|
|
75694
|
+
import_node_path83.default.join(here, "..", "dist", "rpc-tool", "mcp-server.cjs")
|
|
75633
75695
|
];
|
|
75634
|
-
const rpcToolServerScriptPath = rpcToolServerCandidates.find((p3) =>
|
|
75696
|
+
const rpcToolServerScriptPath = rpcToolServerCandidates.find((p3) => import_node_fs65.default.existsSync(p3));
|
|
75635
75697
|
if (rpcToolServerScriptPath) {
|
|
75636
|
-
const rpcToolLogPath =
|
|
75698
|
+
const rpcToolLogPath = import_node_path83.default.join(logDir, "rpc-tool-mcp-server.log");
|
|
75637
75699
|
const rpcToolCfgPath = writeRpcToolMcpConfig({
|
|
75638
75700
|
dataDir: config.dataDir,
|
|
75639
75701
|
serverScriptPath: rpcToolServerScriptPath,
|
|
@@ -75654,7 +75716,7 @@ async function startDaemon(config) {
|
|
|
75654
75716
|
);
|
|
75655
75717
|
}
|
|
75656
75718
|
const shiftStore = createShiftStore({
|
|
75657
|
-
filePath:
|
|
75719
|
+
filePath: import_node_path83.default.join(config.dataDir, "shift.json"),
|
|
75658
75720
|
ownerIdProvider: () => ownerPrincipalId,
|
|
75659
75721
|
now: () => Date.now()
|
|
75660
75722
|
});
|
|
@@ -75676,7 +75738,7 @@ async function startDaemon(config) {
|
|
|
75676
75738
|
getAdapter,
|
|
75677
75739
|
historyReader: history,
|
|
75678
75740
|
dataDir: config.dataDir,
|
|
75679
|
-
personaRoot:
|
|
75741
|
+
personaRoot: import_node_path83.default.join(config.dataDir, "personas"),
|
|
75680
75742
|
// dispatch / shift 自动化 spawn 按 persona 绑定 tool 起 B session(codex persona 用 codex)。
|
|
75681
75743
|
// personaRegistry 声明在 manager 之后(同作用域 const,调用时机在启动完成后,无 TDZ 风险)。
|
|
75682
75744
|
getPersonaDefaults: (personaId2) => personaRegistry.get(personaId2),
|
|
@@ -75733,10 +75795,10 @@ async function startDaemon(config) {
|
|
|
75733
75795
|
// 文件可能 agent 写完又被自己删(罕见),用 size=0 / fallback mime 兜底。
|
|
75734
75796
|
attachmentGroup: {
|
|
75735
75797
|
onFileEdit: (input) => {
|
|
75736
|
-
const absPath =
|
|
75798
|
+
const absPath = import_node_path83.default.isAbsolute(input.relPath) ? input.relPath : import_node_path83.default.join(input.cwd, input.relPath);
|
|
75737
75799
|
let size = 0;
|
|
75738
75800
|
try {
|
|
75739
|
-
size =
|
|
75801
|
+
size = import_node_fs65.default.statSync(absPath).size;
|
|
75740
75802
|
} catch (err) {
|
|
75741
75803
|
logger.warn("attachment.onFileEdit stat failed", {
|
|
75742
75804
|
sessionId: input.sessionId,
|
|
@@ -75777,9 +75839,9 @@ async function startDaemon(config) {
|
|
|
75777
75839
|
logger.info("projects.seed-dropped", { dropped: droppedSeed.dropped, backup: droppedSeed.backup });
|
|
75778
75840
|
}
|
|
75779
75841
|
const projectsStore = new ProjectsStore({
|
|
75780
|
-
file:
|
|
75842
|
+
file: import_node_path83.default.join(config.dataDir, "projects.json"),
|
|
75781
75843
|
clawdDir: config.dataDir,
|
|
75782
|
-
codexStateFile:
|
|
75844
|
+
codexStateFile: import_node_path83.default.join(import_node_os32.default.homedir(), ".codex", ".codex-global-state.json"),
|
|
75783
75845
|
logger
|
|
75784
75846
|
});
|
|
75785
75847
|
const observer = new SessionObserver({
|
|
@@ -75844,13 +75906,13 @@ async function startDaemon(config) {
|
|
|
75844
75906
|
logger
|
|
75845
75907
|
});
|
|
75846
75908
|
registerAdapter("claude", claudeAdapter);
|
|
75847
|
-
const codexIsolatedHome =
|
|
75909
|
+
const codexIsolatedHome = import_node_path83.default.join(config.dataDir, "codex-home");
|
|
75848
75910
|
try {
|
|
75849
|
-
|
|
75911
|
+
import_node_fs65.default.mkdirSync(codexIsolatedHome, { recursive: true });
|
|
75850
75912
|
for (const f2 of ["auth.json", "config.toml"]) {
|
|
75851
|
-
const link =
|
|
75852
|
-
const target =
|
|
75853
|
-
if (!
|
|
75913
|
+
const link = import_node_path83.default.join(codexIsolatedHome, f2);
|
|
75914
|
+
const target = import_node_path83.default.join(import_node_os32.default.homedir(), ".codex", f2);
|
|
75915
|
+
if (!import_node_fs65.default.existsSync(link) && import_node_fs65.default.existsSync(target)) import_node_fs65.default.symlinkSync(target, link);
|
|
75854
75916
|
}
|
|
75855
75917
|
} catch (err) {
|
|
75856
75918
|
logger.warn("codex isolated home setup failed", { err: String(err) });
|
|
@@ -75861,17 +75923,17 @@ async function startDaemon(config) {
|
|
|
75861
75923
|
logger,
|
|
75862
75924
|
historyReader: new CodexHistoryReader({
|
|
75863
75925
|
roots: codexRolloutRoots(config.dataDir),
|
|
75864
|
-
sharedHome:
|
|
75926
|
+
sharedHome: import_node_path83.default.join(import_node_os32.default.homedir(), ".codex"),
|
|
75865
75927
|
logger
|
|
75866
75928
|
}),
|
|
75867
75929
|
// projectPaths 每次调用现取 —— 用户新建 project 后立即生效,不用重启 daemon
|
|
75868
75930
|
codexHomeFor: (cwd) => resolveCodexHome({
|
|
75869
75931
|
cwd,
|
|
75870
|
-
personaRoot:
|
|
75932
|
+
personaRoot: import_node_path83.default.join(config.dataDir, "personas"),
|
|
75871
75933
|
// 必须用 listMerged(Codex registry ∪ 叠加层):只用本地 list() 的话,用户在
|
|
75872
75934
|
// Codex 里建的 project 不在表里,在它下面开的会话会被误判成隔离 → Codex 侧看不到
|
|
75873
75935
|
projectPaths: projectsStore.listMerged().map((x2) => x2.path),
|
|
75874
|
-
sharedHome:
|
|
75936
|
+
sharedHome: import_node_path83.default.join(import_node_os32.default.homedir(), ".codex"),
|
|
75875
75937
|
isolatedHome: codexIsolatedHome
|
|
75876
75938
|
}),
|
|
75877
75939
|
// 附件图片验签:与 http-router /files 路由同一把 secret
|
|
@@ -75896,10 +75958,10 @@ async function startDaemon(config) {
|
|
|
75896
75958
|
);
|
|
75897
75959
|
registerAdapter(PI_CLOUD_TOOL_ID, new CloudPiAdapter({ client: cloudGateway, history: cloudHistorySource, logger }));
|
|
75898
75960
|
const piMcpBridgeCandidates = [
|
|
75899
|
-
|
|
75900
|
-
|
|
75961
|
+
import_node_path83.default.join(here, "pi-mcp-bridge", "extension.cjs"),
|
|
75962
|
+
import_node_path83.default.join(here, "..", "dist", "pi-mcp-bridge", "extension.cjs")
|
|
75901
75963
|
];
|
|
75902
|
-
const piMcpBridgePath = piMcpBridgeCandidates.find((p3) =>
|
|
75964
|
+
const piMcpBridgePath = piMcpBridgeCandidates.find((p3) => import_node_fs65.default.existsSync(p3));
|
|
75903
75965
|
if (piMcpBridgePath) {
|
|
75904
75966
|
logger.info("pi-mcp-bridge extension resolved", { path: piMcpBridgePath });
|
|
75905
75967
|
} else {
|
|
@@ -76195,11 +76257,11 @@ async function startDaemon(config) {
|
|
|
76195
76257
|
// 'persona/<pid>/owner',default 走 'default'。
|
|
76196
76258
|
getSessionScope: (sid) => manager.findOwnedSessionScope(sid),
|
|
76197
76259
|
// guest path guard:candidate 必须在 personaRoot 子树或调用者自己的 user-dir 下
|
|
76198
|
-
personaRoot:
|
|
76260
|
+
personaRoot: import_node_path83.default.join(config.dataDir, "personas"),
|
|
76199
76261
|
usersRoot
|
|
76200
76262
|
},
|
|
76201
76263
|
// workspace/git/history/skills/agents handler 共用的 guest path guard 锚点
|
|
76202
|
-
personaRoot:
|
|
76264
|
+
personaRoot: import_node_path83.default.join(config.dataDir, "personas"),
|
|
76203
76265
|
// v2 多人 persona 隔离:handler 派生 guest user-dir 放行
|
|
76204
76266
|
usersRoot,
|
|
76205
76267
|
// v2 Phase 6: whoami handler 装在 owner principal.displayName + persona 解析
|
|
@@ -76345,7 +76407,7 @@ async function startDaemon(config) {
|
|
|
76345
76407
|
sourceSessionId: args.sourceSessionId
|
|
76346
76408
|
});
|
|
76347
76409
|
const sourceFile = manager.findOwnedSession(args.sourceSessionId);
|
|
76348
|
-
const sourceJsonlPath = resolveSourceJsonlPath(sourceFile,
|
|
76410
|
+
const sourceJsonlPath = resolveSourceJsonlPath(sourceFile, import_node_os32.default.homedir());
|
|
76349
76411
|
logger.info("dispatch.spawnB.source-resolved", {
|
|
76350
76412
|
dispatchId: args.dispatchId,
|
|
76351
76413
|
sourceJsonlPath,
|
|
@@ -76505,7 +76567,7 @@ async function startDaemon(config) {
|
|
|
76505
76567
|
});
|
|
76506
76568
|
shiftScheduler.start();
|
|
76507
76569
|
logger.info("shift scheduler started", { shiftCount: shiftStore.list().length });
|
|
76508
|
-
const larkBotStore = createLarkBotBindingStore(
|
|
76570
|
+
const larkBotStore = createLarkBotBindingStore(import_node_path83.default.join(config.dataDir, "personas"));
|
|
76509
76571
|
const larkBotCloud = createLarkBotCloudClient({
|
|
76510
76572
|
api: config.clawosApi ?? DEFAULT_CLAWOS_API,
|
|
76511
76573
|
getLoginPass: () => ownerIdentityStore.read()?.loginPass ?? null
|
|
@@ -76517,7 +76579,7 @@ async function startDaemon(config) {
|
|
|
76517
76579
|
store: larkBotStore,
|
|
76518
76580
|
fetchResource: (appId, messageId, fileKey, maxBytes, type) => larkBotCloud.fetchResource(appId, messageId, fileKey, maxBytes, type),
|
|
76519
76581
|
// 图片落 guest userWorkDir 下(capId = lark-<chat_id>):CC 经 --add-dir + allowRead carve 可 Read
|
|
76520
|
-
mediaRootFor: (chatId) =>
|
|
76582
|
+
mediaRootFor: (chatId) => import_node_path83.default.join(deriveUserWorkDir(`lark-${chatId}`, usersRoot), "lark-media"),
|
|
76521
76583
|
isShuttingDown: () => larkDraining,
|
|
76522
76584
|
logger: {
|
|
76523
76585
|
warn: (msg) => logger.warn(msg),
|
|
@@ -76817,8 +76879,8 @@ async function startDaemon(config) {
|
|
|
76817
76879
|
const lines = [
|
|
76818
76880
|
`Tunnel: ${r2.url}`,
|
|
76819
76881
|
...resolvedAuthToken ? [`Connect: ${connectUrl}`] : [],
|
|
76820
|
-
`Frpc config: ${
|
|
76821
|
-
`Frpc log: ${
|
|
76882
|
+
`Frpc config: ${import_node_path83.default.join(config.dataDir, "frpc.toml")}`,
|
|
76883
|
+
`Frpc log: ${import_node_path83.default.join(logDir, "frpc.log")}`
|
|
76822
76884
|
];
|
|
76823
76885
|
const width2 = Math.max(...lines.map((l2) => l2.length));
|
|
76824
76886
|
const bar = "\u2550".repeat(width2 + 4);
|
|
@@ -76831,8 +76893,8 @@ ${bar}
|
|
|
76831
76893
|
|
|
76832
76894
|
`);
|
|
76833
76895
|
try {
|
|
76834
|
-
const connectPath =
|
|
76835
|
-
|
|
76896
|
+
const connectPath = import_node_path83.default.join(config.dataDir, "connect.txt");
|
|
76897
|
+
import_node_fs65.default.writeFileSync(connectPath, lines.join("\n") + "\n", { mode: 384 });
|
|
76836
76898
|
} catch {
|
|
76837
76899
|
}
|
|
76838
76900
|
} catch (err) {
|
|
@@ -76930,9 +76992,9 @@ ${bar}
|
|
|
76930
76992
|
};
|
|
76931
76993
|
}
|
|
76932
76994
|
function migrateDropPersonsDir(dataDir) {
|
|
76933
|
-
const dir =
|
|
76995
|
+
const dir = import_node_path83.default.join(dataDir, "persons");
|
|
76934
76996
|
try {
|
|
76935
|
-
|
|
76997
|
+
import_node_fs65.default.rmSync(dir, { recursive: true, force: true });
|
|
76936
76998
|
} catch {
|
|
76937
76999
|
}
|
|
76938
77000
|
}
|