@clawos-dev/clawd 0.2.592 → 0.2.594
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 +249 -311
- 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: path104, errorMaps, issueData } = params;
|
|
454
|
+
const fullPath = [...path104, ...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, path104, key) {
|
|
766
766
|
this._cachedPath = [];
|
|
767
767
|
this.parent = parent;
|
|
768
768
|
this.data = value;
|
|
769
|
-
this._path =
|
|
769
|
+
this._path = path104;
|
|
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 path104 = req.path;
|
|
10329
|
+
_req.url = typeof path104 === "string" ? path104 : 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(path104) {
|
|
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 < path104.length; i2++) {
|
|
10501
|
+
const char = path104[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 path104 of paths) {
|
|
10633
|
+
const parts = parsePath(path104);
|
|
10634
10634
|
if (parts.includes("*")) {
|
|
10635
|
-
redactWildcardPath(obj, parts, censor,
|
|
10635
|
+
redactWildcardPath(obj, parts, censor, path104, 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, path104) => {
|
|
10721
|
+
const fullPath = [...pathArray.slice(0, pathLength), ...path104];
|
|
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 path104 of pathsToClone) {
|
|
10757
|
+
const parts = parsePath(path104);
|
|
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(path104) {
|
|
10810
|
+
if (typeof path104 !== "string") {
|
|
10811
10811
|
throw new Error("Paths must be (non-empty) strings");
|
|
10812
10812
|
}
|
|
10813
|
-
if (
|
|
10813
|
+
if (path104 === "") {
|
|
10814
10814
|
throw new Error("Invalid redaction path ()");
|
|
10815
10815
|
}
|
|
10816
|
-
if (
|
|
10817
|
-
throw new Error(`Invalid redaction path (${
|
|
10816
|
+
if (path104.includes("..")) {
|
|
10817
|
+
throw new Error(`Invalid redaction path (${path104})`);
|
|
10818
10818
|
}
|
|
10819
|
-
if (
|
|
10820
|
-
throw new Error(`Invalid redaction path (${
|
|
10819
|
+
if (path104.includes(",")) {
|
|
10820
|
+
throw new Error(`Invalid redaction path (${path104})`);
|
|
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 < path104.length; i2++) {
|
|
10826
|
+
const char = path104[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 (${path104})`);
|
|
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 (${path104})`);
|
|
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 path104 of paths) {
|
|
10853
|
+
validatePath(path104);
|
|
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, path104) => {
|
|
11022
|
+
return censor(value, [k3, ...path104]);
|
|
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 fs94 = require("fs");
|
|
11241
11241
|
var EventEmitter2 = require("events");
|
|
11242
11242
|
var inherits = require("util").inherits;
|
|
11243
|
-
var
|
|
11243
|
+
var path104 = 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) fs94.mkdirSync(path104.dirname(file), { recursive: true });
|
|
11298
|
+
const fd = fs94.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
|
+
fs94.mkdir(path104.dirname(file), { recursive: true }, (err) => {
|
|
11306
11306
|
if (err) return fileOpened(err);
|
|
11307
|
-
|
|
11307
|
+
fs94.open(file, flags, mode, fileOpened);
|
|
11308
11308
|
});
|
|
11309
11309
|
} else {
|
|
11310
|
-
|
|
11310
|
+
fs94.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 = () => fs94.writeSync(this.fd, this._writingBuf);
|
|
11352
|
+
fsWrite = () => fs94.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 fs94.writeSync(this.fd, this._writingBuf);
|
|
11362
11362
|
}
|
|
11363
|
-
return
|
|
11363
|
+
return fs94.writeSync(this.fd, this._writingBuf, "utf8");
|
|
11364
11364
|
};
|
|
11365
11365
|
fsWrite = () => {
|
|
11366
11366
|
if (Buffer.isBuffer(this._writingBuf)) {
|
|
11367
|
-
return
|
|
11367
|
+
return fs94.write(this.fd, this._writingBuf, this.release);
|
|
11368
11368
|
}
|
|
11369
|
-
return
|
|
11369
|
+
return fs94.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
|
+
fs94.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
|
+
fs94.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
|
+
fs94.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) ? fs94.writeSync(this.fd, buf) : fs94.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
|
+
fs94.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 = fs94.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) ? fs94.writeSync(this.fd, this._writingBuf) : fs94.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
|
+
fs94.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 = fs94.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
|
+
fs94.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
|
+
fs94.fsync(sonic.fd, closeWrapped);
|
|
11797
11797
|
} catch {
|
|
11798
11798
|
}
|
|
11799
11799
|
function closeWrapped() {
|
|
11800
11800
|
if (sonic.fd !== 1 && sonic.fd !== 2) {
|
|
11801
|
-
|
|
11801
|
+
fs94.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 os36 = 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 = os36.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(path104, added, removed, oldPosInc, options) {
|
|
14937
|
+
var last = path104.lastComponent;
|
|
14938
14938
|
if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) {
|
|
14939
14939
|
return {
|
|
14940
|
-
oldPos:
|
|
14940
|
+
oldPos: path104.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: path104.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 path104 = 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 (!path104 || content == null) return null;
|
|
15535
|
+
const entry = { path: path104, 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 path104 = 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 (!path104 || content == null) return null;
|
|
16404
|
+
const out = { path: path104, 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(path104) {
|
|
37379
|
+
var parts = path104.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(path104) {
|
|
43233
|
+
if (path104.slice(-1) === "/") {
|
|
43234
|
+
path104 = path104.substring(0, path104.length - 1);
|
|
43235
43235
|
}
|
|
43236
|
-
var lastSlash =
|
|
43237
|
-
return lastSlash > 0 ?
|
|
43236
|
+
var lastSlash = path104.lastIndexOf("/");
|
|
43237
|
+
return lastSlash > 0 ? path104.substring(0, lastSlash) : "";
|
|
43238
43238
|
};
|
|
43239
|
-
var forceTrailingSlash = function(
|
|
43240
|
-
if (
|
|
43241
|
-
|
|
43239
|
+
var forceTrailingSlash = function(path104) {
|
|
43240
|
+
if (path104.slice(-1) !== "/") {
|
|
43241
|
+
path104 += "/";
|
|
43242
43242
|
}
|
|
43243
|
-
return
|
|
43243
|
+
return path104;
|
|
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_path83.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_fs65.default.mkdirSync(dir, { recursive: true });
|
|
44260
|
+
stream = import_node_fs65.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_fs65, import_node_path83;
|
|
44286
44286
|
var init_recorder = __esm({
|
|
44287
44287
|
"src/run-case/recorder.ts"() {
|
|
44288
44288
|
"use strict";
|
|
44289
|
-
|
|
44290
|
-
|
|
44289
|
+
import_node_fs65 = __toESM(require("fs"), 1);
|
|
44290
|
+
import_node_path83 = __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_fs66.mkdtempSync)(import_node_path84.default.join(import_node_os32.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_fs66.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_fs66, import_node_os32, import_node_path84;
|
|
44501
44501
|
var init_controller = __esm({
|
|
44502
44502
|
"src/run-case/controller.ts"() {
|
|
44503
44503
|
"use strict";
|
|
44504
|
-
|
|
44505
|
-
|
|
44506
|
-
|
|
44504
|
+
import_node_fs66 = require("fs");
|
|
44505
|
+
import_node_os32 = __toESM(require("os"), 1);
|
|
44506
|
+
import_node_path84 = __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_path82 = __toESM(require("path"), 1);
|
|
44779
|
+
var import_node_fs64 = __toESM(require("fs"), 1);
|
|
44780
|
+
var import_node_os31 = __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, path104, init) {
|
|
52527
52527
|
const f2 = opts.fetchImpl ?? globalThis.fetch;
|
|
52528
|
-
const url = `${opts.api.replace(/\/+$/, "")}${
|
|
52528
|
+
const url = `${opts.api.replace(/\/+$/, "")}${path104}`;
|
|
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, path104] = m3;
|
|
53563
|
+
items.push({ type: "skill", name, path: path104 });
|
|
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, path104, body) {
|
|
60937
60937
|
let res;
|
|
60938
60938
|
try {
|
|
60939
|
-
res = await doFetch(`${API}${
|
|
60939
|
+
res = await doFetch(`${API}${path104}`, {
|
|
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, path104, what, body) {
|
|
60965
|
+
const r2 = await request(method, path104, 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(path104) {
|
|
61011
61011
|
try {
|
|
61012
|
-
const r2 = await request("GET",
|
|
61012
|
+
const r2 = await request("GET", path104);
|
|
61013
61013
|
return r2.status >= 200 && r2.status < 300 ? r2.json : void 0;
|
|
61014
61014
|
} catch {
|
|
61015
61015
|
return void 0;
|
|
@@ -62271,21 +62271,6 @@ 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
|
-
}
|
|
62289
62274
|
var SubscriptionChannelStore = class {
|
|
62290
62275
|
filePath;
|
|
62291
62276
|
codexHome;
|
|
@@ -62412,20 +62397,15 @@ var SubscriptionChannelStore = class {
|
|
|
62412
62397
|
if (!import_node_fs35.default.existsSync(configPath)) return null;
|
|
62413
62398
|
const content = import_node_fs35.default.readFileSync(configPath, "utf8");
|
|
62414
62399
|
if (!content.includes('model_provider = "cliproxyapi"')) return null;
|
|
62415
|
-
const
|
|
62416
|
-
|
|
62417
|
-
|
|
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) {
|
|
62400
|
+
const urlMatch = /base_url\s*=\s*["']([^"']+)["']/.exec(content);
|
|
62401
|
+
const keyMatch = /args\s*=\s*\[\s*["']([^"']+)["']\s*\]/.exec(content) || /experimental_bearer_token\s*=\s*["']([^"']+)["']/.exec(content);
|
|
62402
|
+
if (urlMatch && keyMatch) {
|
|
62423
62403
|
const id = "default-pool";
|
|
62424
62404
|
const channel = {
|
|
62425
62405
|
id,
|
|
62426
62406
|
name: "\u9ED8\u8BA4\u56E2\u961F\u53F7\u6C60",
|
|
62427
62407
|
baseUrl: normalizeEngineBaseUrl(urlMatch[1]),
|
|
62428
|
-
apiKey:
|
|
62408
|
+
apiKey: keyMatch[1],
|
|
62429
62409
|
remark: "\u4ECE\u672C\u673A\u5DF2\u63A5\u5165\u7684\u53F7\u6C60\u914D\u7F6E\u81EA\u52A8\u8FC1\u79FB",
|
|
62430
62410
|
createdAt: Date.now(),
|
|
62431
62411
|
updatedAt: Date.now()
|
|
@@ -62506,8 +62486,8 @@ function refreshPathFromLoginShell() {
|
|
|
62506
62486
|
timeout: 3e3,
|
|
62507
62487
|
stdio: ["ignore", "pipe", "ignore"]
|
|
62508
62488
|
});
|
|
62509
|
-
const
|
|
62510
|
-
if (
|
|
62489
|
+
const path104 = out.trim();
|
|
62490
|
+
if (path104) process.env.PATH = path104;
|
|
62511
62491
|
} catch {
|
|
62512
62492
|
}
|
|
62513
62493
|
}
|
|
@@ -65456,13 +65436,13 @@ function mapSkillsListResponse(res) {
|
|
|
65456
65436
|
const r2 = s2 ?? {};
|
|
65457
65437
|
const name = str4(r2.name);
|
|
65458
65438
|
if (!name) continue;
|
|
65459
|
-
const
|
|
65439
|
+
const path104 = str4(r2.path);
|
|
65460
65440
|
const description = str4(r2.description);
|
|
65461
65441
|
const isPlugin = name.includes(":");
|
|
65462
65442
|
out.push({
|
|
65463
65443
|
name,
|
|
65464
65444
|
source: isPlugin ? "plugin" : "project",
|
|
65465
|
-
...
|
|
65445
|
+
...path104 ? { path: path104 } : {},
|
|
65466
65446
|
...description ? { description } : {},
|
|
65467
65447
|
...isPlugin ? { plugin: name.split(":")[0] } : {}
|
|
65468
65448
|
});
|
|
@@ -69996,7 +69976,7 @@ var ServerKeyStore = class {
|
|
|
69996
69976
|
init_protocol();
|
|
69997
69977
|
|
|
69998
69978
|
// src/handlers/index.ts
|
|
69999
|
-
var
|
|
69979
|
+
var import_node_path78 = __toESM(require("path"), 1);
|
|
70000
69980
|
|
|
70001
69981
|
// src/handlers/session.ts
|
|
70002
69982
|
init_protocol();
|
|
@@ -71701,11 +71681,6 @@ function buildEngineHandlers(deps, overrides = {}) {
|
|
|
71701
71681
|
return { "engine:status": status, "engine:connectPool": connectPool };
|
|
71702
71682
|
}
|
|
71703
71683
|
|
|
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
|
-
|
|
71709
71684
|
// src/tools/subscription-channels-apply.ts
|
|
71710
71685
|
var import_node_fs63 = __toESM(require("fs"), 1);
|
|
71711
71686
|
var import_node_os25 = __toESM(require("os"), 1);
|
|
@@ -71782,20 +71757,7 @@ function applyPiSubscriptionChannel(opts) {
|
|
|
71782
71757
|
}
|
|
71783
71758
|
|
|
71784
71759
|
// 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
|
-
}
|
|
71797
71760
|
function buildChannelsHandlers(deps) {
|
|
71798
|
-
let activationQueue = Promise.resolve();
|
|
71799
71761
|
const get = async () => {
|
|
71800
71762
|
return { response: deps.store.list() };
|
|
71801
71763
|
};
|
|
@@ -71824,37 +71786,13 @@ function buildChannelsHandlers(deps) {
|
|
|
71824
71786
|
}
|
|
71825
71787
|
return { response: { ok: true } };
|
|
71826
71788
|
};
|
|
71827
|
-
const activate = async (frame
|
|
71828
|
-
const run = activationQueue.then(() => activateChannel(frame, context));
|
|
71829
|
-
activationQueue = run.then(() => {
|
|
71830
|
-
}, () => {
|
|
71831
|
-
});
|
|
71832
|
-
return run;
|
|
71833
|
-
};
|
|
71834
|
-
const activateChannel = async (frame) => {
|
|
71789
|
+
const activate = async (frame) => {
|
|
71835
71790
|
const args = parseArgs2(SubscriptionChannelActivateArgsSchema, frame, "subscriptionChannel:activate");
|
|
71836
|
-
const channel =
|
|
71837
|
-
|
|
71838
|
-
|
|
71839
|
-
|
|
71840
|
-
|
|
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;
|
|
71791
|
+
const channel = deps.store.setActive(args.id);
|
|
71792
|
+
applyCodexSubscriptionChannel({ codexHome: deps.codexHome, channel });
|
|
71793
|
+
applyPiSubscriptionChannel({ agentDir: deps.agentDir, channel });
|
|
71794
|
+
if (channel) {
|
|
71795
|
+
await deps.manager.getCapabilities("codex", { refresh: true });
|
|
71858
71796
|
}
|
|
71859
71797
|
return { response: { ok: true } };
|
|
71860
71798
|
};
|
|
@@ -72500,7 +72438,7 @@ function buildDashboardHandlers(deps) {
|
|
|
72500
72438
|
}
|
|
72501
72439
|
|
|
72502
72440
|
// src/handlers/meta.ts
|
|
72503
|
-
var
|
|
72441
|
+
var import_node_os26 = __toESM(require("os"), 1);
|
|
72504
72442
|
init_protocol();
|
|
72505
72443
|
|
|
72506
72444
|
// src/handlers/method-grants.ts
|
|
@@ -72820,21 +72758,21 @@ function computeMethodAccess(args) {
|
|
|
72820
72758
|
}
|
|
72821
72759
|
|
|
72822
72760
|
// src/version.ts
|
|
72823
|
-
var version = "0.2.
|
|
72761
|
+
var version = "0.2.594".length > 0 ? "0.2.594" : "dev";
|
|
72824
72762
|
|
|
72825
72763
|
// src/cli-probe/probe.ts
|
|
72826
|
-
var
|
|
72827
|
-
var
|
|
72764
|
+
var fs82 = __toESM(require("fs"), 1);
|
|
72765
|
+
var path88 = __toESM(require("path"), 1);
|
|
72828
72766
|
var PKG_NAME = "@clawos-dev/clawd";
|
|
72829
72767
|
var BIN_NAME = "clawd";
|
|
72830
72768
|
var MAX_PARENT_HOPS = 5;
|
|
72831
72769
|
function probeGlobalCli(pathEnv) {
|
|
72832
72770
|
if (!pathEnv) return null;
|
|
72833
|
-
for (const dir of pathEnv.split(
|
|
72771
|
+
for (const dir of pathEnv.split(path88.delimiter)) {
|
|
72834
72772
|
if (!dir) continue;
|
|
72835
72773
|
let real;
|
|
72836
72774
|
try {
|
|
72837
|
-
real =
|
|
72775
|
+
real = fs82.realpathSync(path88.join(dir, BIN_NAME));
|
|
72838
72776
|
} catch {
|
|
72839
72777
|
continue;
|
|
72840
72778
|
}
|
|
@@ -72844,15 +72782,15 @@ function probeGlobalCli(pathEnv) {
|
|
|
72844
72782
|
return null;
|
|
72845
72783
|
}
|
|
72846
72784
|
function readOwnPackageVersion(entryPath) {
|
|
72847
|
-
let dir =
|
|
72785
|
+
let dir = path88.dirname(entryPath);
|
|
72848
72786
|
for (let i2 = 0; i2 < MAX_PARENT_HOPS; i2++) {
|
|
72849
72787
|
try {
|
|
72850
|
-
const raw =
|
|
72788
|
+
const raw = fs82.readFileSync(path88.join(dir, "package.json"), "utf8");
|
|
72851
72789
|
const pkg = JSON.parse(raw);
|
|
72852
72790
|
if (pkg.name !== PKG_NAME) return null;
|
|
72853
72791
|
return typeof pkg.version === "string" && pkg.version ? pkg.version : null;
|
|
72854
72792
|
} catch {
|
|
72855
|
-
const parent =
|
|
72793
|
+
const parent = path88.dirname(dir);
|
|
72856
72794
|
if (parent === dir) return null;
|
|
72857
72795
|
dir = parent;
|
|
72858
72796
|
}
|
|
@@ -72888,7 +72826,7 @@ function buildReadyFrame(deps, client) {
|
|
|
72888
72826
|
return {
|
|
72889
72827
|
version,
|
|
72890
72828
|
protocolVersion: PROTOCOL_VERSION,
|
|
72891
|
-
hostname:
|
|
72829
|
+
hostname: import_node_os26.default.hostname(),
|
|
72892
72830
|
os: process.platform,
|
|
72893
72831
|
tools,
|
|
72894
72832
|
runningSessions: info.runningSessions,
|
|
@@ -73028,7 +72966,7 @@ function buildPersonaHandlers(deps) {
|
|
|
73028
72966
|
}
|
|
73029
72967
|
|
|
73030
72968
|
// src/handlers/attachment.ts
|
|
73031
|
-
var
|
|
72969
|
+
var import_node_path70 = __toESM(require("path"), 1);
|
|
73032
72970
|
init_protocol();
|
|
73033
72971
|
init_protocol();
|
|
73034
72972
|
function assertGuestAttachmentPath(ctx, absPath, personaRoot, method, usersRoot) {
|
|
@@ -73107,12 +73045,12 @@ function buildAttachmentHandlers(deps) {
|
|
|
73107
73045
|
`session ${args.sessionId} scope unresolved`
|
|
73108
73046
|
);
|
|
73109
73047
|
}
|
|
73110
|
-
const cwdAbs =
|
|
73111
|
-
const candidateAbs =
|
|
73048
|
+
const cwdAbs = import_node_path70.default.resolve(sessionFile.cwd);
|
|
73049
|
+
const candidateAbs = import_node_path70.default.isAbsolute(args.relPath) ? import_node_path70.default.resolve(args.relPath) : import_node_path70.default.resolve(cwdAbs, args.relPath);
|
|
73112
73050
|
guardAttachmentPath(ctx, args.sessionId, candidateAbs, "attachment.signUrl", "group-acl");
|
|
73113
73051
|
const entries = deps.groupFileStore.list(scope, args.sessionId);
|
|
73114
73052
|
const entry = entries.find((e) => {
|
|
73115
|
-
const storedAbs =
|
|
73053
|
+
const storedAbs = import_node_path70.default.isAbsolute(e.relPath) ? import_node_path70.default.resolve(e.relPath) : import_node_path70.default.resolve(cwdAbs, e.relPath);
|
|
73116
73054
|
return storedAbs === candidateAbs && !e.stale;
|
|
73117
73055
|
});
|
|
73118
73056
|
if (!entry) {
|
|
@@ -73136,7 +73074,7 @@ function buildAttachmentHandlers(deps) {
|
|
|
73136
73074
|
if (!ctx || ctx.principal.kind !== "guest" || !deps.personaRoot || !deps.sessionStore) return;
|
|
73137
73075
|
const f2 = deps.sessionStore.read(sessionId);
|
|
73138
73076
|
if (!f2) return;
|
|
73139
|
-
assertGuestAttachmentPath(ctx,
|
|
73077
|
+
assertGuestAttachmentPath(ctx, import_node_path70.default.resolve(f2.cwd), deps.personaRoot, method, deps.usersRoot);
|
|
73140
73078
|
}
|
|
73141
73079
|
const groupAdd = async (frame, _client, ctx) => {
|
|
73142
73080
|
if (!deps.groupFileStore || !deps.getSessionScope) {
|
|
@@ -73151,8 +73089,8 @@ function buildAttachmentHandlers(deps) {
|
|
|
73151
73089
|
if (!scope) {
|
|
73152
73090
|
throw new ClawdError(ERROR_CODES.VALIDATION_ERROR, `session ${args.sessionId} not found`);
|
|
73153
73091
|
}
|
|
73154
|
-
const cwdAbs =
|
|
73155
|
-
const candidateAbs =
|
|
73092
|
+
const cwdAbs = import_node_path70.default.resolve(deps.sessionStore?.read(args.sessionId)?.cwd ?? ".");
|
|
73093
|
+
const candidateAbs = import_node_path70.default.isAbsolute(args.relPath) ? import_node_path70.default.resolve(args.relPath) : import_node_path70.default.resolve(cwdAbs, args.relPath);
|
|
73156
73094
|
guardAttachmentPath(ctx, args.sessionId, candidateAbs, "attachment.groupAdd", "cwd-subtree");
|
|
73157
73095
|
const from = args.origin === "agent" ? "agent" : ctx?.principal.kind === "owner" ? "owner" : "agent";
|
|
73158
73096
|
const size = 0;
|
|
@@ -73211,19 +73149,19 @@ function buildAttachmentHandlers(deps) {
|
|
|
73211
73149
|
|
|
73212
73150
|
// src/handlers/extension.ts
|
|
73213
73151
|
var import_promises15 = __toESM(require("fs/promises"), 1);
|
|
73214
|
-
var
|
|
73152
|
+
var import_node_path75 = __toESM(require("path"), 1);
|
|
73215
73153
|
init_protocol();
|
|
73216
73154
|
|
|
73217
73155
|
// src/extension/bundle-zip.ts
|
|
73218
73156
|
var import_promises12 = __toESM(require("fs/promises"), 1);
|
|
73219
|
-
var
|
|
73157
|
+
var import_node_path71 = __toESM(require("path"), 1);
|
|
73220
73158
|
var import_node_crypto22 = __toESM(require("crypto"), 1);
|
|
73221
73159
|
var import_jszip2 = __toESM(require_lib3(), 1);
|
|
73222
73160
|
async function bundleExtensionDir(dir) {
|
|
73223
73161
|
const entries = await listFilesSorted(dir);
|
|
73224
73162
|
const zip = new import_jszip2.default();
|
|
73225
73163
|
for (const rel of entries) {
|
|
73226
|
-
const abs =
|
|
73164
|
+
const abs = import_node_path71.default.join(dir, rel);
|
|
73227
73165
|
const content = await import_promises12.default.readFile(abs);
|
|
73228
73166
|
zip.file(rel, content, { date: FIXED_DATE });
|
|
73229
73167
|
}
|
|
@@ -73244,7 +73182,7 @@ async function listFilesSorted(rootDir) {
|
|
|
73244
73182
|
return out;
|
|
73245
73183
|
}
|
|
73246
73184
|
async function walk(absRoot, relPrefix, out) {
|
|
73247
|
-
const dirAbs =
|
|
73185
|
+
const dirAbs = import_node_path71.default.join(absRoot, relPrefix);
|
|
73248
73186
|
const entries = await import_promises12.default.readdir(dirAbs, { withFileTypes: true });
|
|
73249
73187
|
for (const e of entries) {
|
|
73250
73188
|
if (IGNORE_BASENAMES.has(e.name)) continue;
|
|
@@ -73298,25 +73236,25 @@ function computePublishCheck(args) {
|
|
|
73298
73236
|
|
|
73299
73237
|
// src/extension/install-flow.ts
|
|
73300
73238
|
var import_promises13 = __toESM(require("fs/promises"), 1);
|
|
73301
|
-
var
|
|
73302
|
-
var
|
|
73239
|
+
var import_node_path73 = __toESM(require("path"), 1);
|
|
73240
|
+
var import_node_os28 = __toESM(require("os"), 1);
|
|
73303
73241
|
var import_node_crypto23 = __toESM(require("crypto"), 1);
|
|
73304
73242
|
var import_jszip3 = __toESM(require_lib3(), 1);
|
|
73305
73243
|
|
|
73306
73244
|
// src/extension/paths.ts
|
|
73307
|
-
var
|
|
73308
|
-
var
|
|
73245
|
+
var import_node_os27 = __toESM(require("os"), 1);
|
|
73246
|
+
var import_node_path72 = __toESM(require("path"), 1);
|
|
73309
73247
|
function clawdHomeRoot(override) {
|
|
73310
|
-
return override ?? process.env.CLAWD_HOME ??
|
|
73248
|
+
return override ?? process.env.CLAWD_HOME ?? import_node_path72.default.join(import_node_os27.default.homedir(), ".clawd");
|
|
73311
73249
|
}
|
|
73312
73250
|
function extensionsRoot(override) {
|
|
73313
|
-
return
|
|
73251
|
+
return import_node_path72.default.join(clawdHomeRoot(override), "extensions");
|
|
73314
73252
|
}
|
|
73315
73253
|
function publishedChannelsFile(override) {
|
|
73316
|
-
return
|
|
73254
|
+
return import_node_path72.default.join(clawdHomeRoot(override), "extensions-published.json");
|
|
73317
73255
|
}
|
|
73318
73256
|
function bundleCacheRoot(override) {
|
|
73319
|
-
return
|
|
73257
|
+
return import_node_path72.default.join(clawdHomeRoot(override), "extension-bundles");
|
|
73320
73258
|
}
|
|
73321
73259
|
|
|
73322
73260
|
// src/extension/install-flow.ts
|
|
@@ -73343,7 +73281,7 @@ async function installFromChannel(args, deps) {
|
|
|
73343
73281
|
throw new InstallError("ZIP_INVALID", `failed to load zip: ${e.message}`);
|
|
73344
73282
|
}
|
|
73345
73283
|
for (const name of Object.keys(zip.files)) {
|
|
73346
|
-
if (name.includes("..") || name.startsWith("/") ||
|
|
73284
|
+
if (name.includes("..") || name.startsWith("/") || import_node_path73.default.isAbsolute(name)) {
|
|
73347
73285
|
throw new InstallError("ZIP_INVALID", `unsafe zip entry: ${name}`);
|
|
73348
73286
|
}
|
|
73349
73287
|
}
|
|
@@ -73375,7 +73313,7 @@ async function installFromChannel(args, deps) {
|
|
|
73375
73313
|
);
|
|
73376
73314
|
}
|
|
73377
73315
|
const localExtId = namespacedExtId(ownerSlug, channelRef.ownerPrincipalId);
|
|
73378
|
-
const destDir =
|
|
73316
|
+
const destDir = import_node_path73.default.join(deps.extensionsRoot, localExtId);
|
|
73379
73317
|
let destExists = false;
|
|
73380
73318
|
try {
|
|
73381
73319
|
await import_promises13.default.access(destDir);
|
|
@@ -73389,16 +73327,16 @@ async function installFromChannel(args, deps) {
|
|
|
73389
73327
|
);
|
|
73390
73328
|
}
|
|
73391
73329
|
const stage = await import_promises13.default.mkdtemp(
|
|
73392
|
-
|
|
73330
|
+
import_node_path73.default.join(import_node_os28.default.tmpdir(), `clawd-ext-install-${localExtId}-`)
|
|
73393
73331
|
);
|
|
73394
73332
|
try {
|
|
73395
73333
|
for (const [name, entry] of Object.entries(zip.files)) {
|
|
73396
|
-
const dest =
|
|
73334
|
+
const dest = import_node_path73.default.join(stage, name);
|
|
73397
73335
|
if (entry.dir) {
|
|
73398
73336
|
await import_promises13.default.mkdir(dest, { recursive: true });
|
|
73399
73337
|
continue;
|
|
73400
73338
|
}
|
|
73401
|
-
await import_promises13.default.mkdir(
|
|
73339
|
+
await import_promises13.default.mkdir(import_node_path73.default.dirname(dest), { recursive: true });
|
|
73402
73340
|
if (name === "manifest.json") {
|
|
73403
73341
|
const rewritten = { ...parsed.data, id: localExtId };
|
|
73404
73342
|
await import_promises13.default.writeFile(dest, JSON.stringify(rewritten, null, 2));
|
|
@@ -73419,8 +73357,8 @@ async function installFromChannel(args, deps) {
|
|
|
73419
73357
|
|
|
73420
73358
|
// src/extension/update-flow.ts
|
|
73421
73359
|
var import_promises14 = __toESM(require("fs/promises"), 1);
|
|
73422
|
-
var
|
|
73423
|
-
var
|
|
73360
|
+
var import_node_path74 = __toESM(require("path"), 1);
|
|
73361
|
+
var import_node_os29 = __toESM(require("os"), 1);
|
|
73424
73362
|
var import_node_crypto24 = __toESM(require("crypto"), 1);
|
|
73425
73363
|
var import_jszip4 = __toESM(require_lib3(), 1);
|
|
73426
73364
|
var UpdateError = class extends Error {
|
|
@@ -73436,11 +73374,11 @@ async function updateFromChannel(args, deps) {
|
|
|
73436
73374
|
channelRef.extId,
|
|
73437
73375
|
channelRef.ownerPrincipalId
|
|
73438
73376
|
);
|
|
73439
|
-
const liveDir =
|
|
73377
|
+
const liveDir = import_node_path74.default.join(deps.extensionsRoot, localExtId);
|
|
73440
73378
|
const prevDir = `${liveDir}.prev`;
|
|
73441
73379
|
let existingVersion;
|
|
73442
73380
|
try {
|
|
73443
|
-
const raw = await import_promises14.default.readFile(
|
|
73381
|
+
const raw = await import_promises14.default.readFile(import_node_path74.default.join(liveDir, "manifest.json"), "utf8");
|
|
73444
73382
|
const parsed2 = ExtensionManifestSchema.safeParse(JSON.parse(raw));
|
|
73445
73383
|
if (!parsed2.success) {
|
|
73446
73384
|
throw new UpdateError(
|
|
@@ -73473,7 +73411,7 @@ async function updateFromChannel(args, deps) {
|
|
|
73473
73411
|
throw new UpdateError("ZIP_INVALID", `failed to load zip: ${e.message}`);
|
|
73474
73412
|
}
|
|
73475
73413
|
for (const name of Object.keys(zip.files)) {
|
|
73476
|
-
if (name.includes("..") || name.startsWith("/") ||
|
|
73414
|
+
if (name.includes("..") || name.startsWith("/") || import_node_path74.default.isAbsolute(name)) {
|
|
73477
73415
|
throw new UpdateError("ZIP_INVALID", `unsafe zip entry: ${name}`);
|
|
73478
73416
|
}
|
|
73479
73417
|
}
|
|
@@ -73508,16 +73446,16 @@ async function updateFromChannel(args, deps) {
|
|
|
73508
73446
|
await import_promises14.default.rm(prevDir, { recursive: true, force: true });
|
|
73509
73447
|
await import_promises14.default.rename(liveDir, prevDir);
|
|
73510
73448
|
const stage = await import_promises14.default.mkdtemp(
|
|
73511
|
-
|
|
73449
|
+
import_node_path74.default.join(import_node_os29.default.tmpdir(), `clawd-ext-update-${localExtId}-`)
|
|
73512
73450
|
);
|
|
73513
73451
|
try {
|
|
73514
73452
|
for (const [name, entry] of Object.entries(zip.files)) {
|
|
73515
|
-
const dest =
|
|
73453
|
+
const dest = import_node_path74.default.join(stage, name);
|
|
73516
73454
|
if (entry.dir) {
|
|
73517
73455
|
await import_promises14.default.mkdir(dest, { recursive: true });
|
|
73518
73456
|
continue;
|
|
73519
73457
|
}
|
|
73520
|
-
await import_promises14.default.mkdir(
|
|
73458
|
+
await import_promises14.default.mkdir(import_node_path74.default.dirname(dest), { recursive: true });
|
|
73521
73459
|
if (name === "manifest.json") {
|
|
73522
73460
|
const rewritten = { ...parsed.data, id: localExtId };
|
|
73523
73461
|
await import_promises14.default.writeFile(dest, JSON.stringify(rewritten, null, 2));
|
|
@@ -73584,7 +73522,7 @@ async function rewriteManifestVersion(root, extId, newVersion, previousPublished
|
|
|
73584
73522
|
);
|
|
73585
73523
|
}
|
|
73586
73524
|
}
|
|
73587
|
-
const manifestPath =
|
|
73525
|
+
const manifestPath = import_node_path75.default.join(root, extId, "manifest.json");
|
|
73588
73526
|
const manifest = await readManifest(root, extId);
|
|
73589
73527
|
const next = { ...manifest, version: newVersion };
|
|
73590
73528
|
const tmp = `${manifestPath}.tmp`;
|
|
@@ -73592,7 +73530,7 @@ async function rewriteManifestVersion(root, extId, newVersion, previousPublished
|
|
|
73592
73530
|
await import_promises15.default.rename(tmp, manifestPath);
|
|
73593
73531
|
}
|
|
73594
73532
|
async function readManifest(root, extId) {
|
|
73595
|
-
const file =
|
|
73533
|
+
const file = import_node_path75.default.join(root, extId, "manifest.json");
|
|
73596
73534
|
let raw;
|
|
73597
73535
|
try {
|
|
73598
73536
|
raw = await import_promises15.default.readFile(file, "utf8");
|
|
@@ -73676,7 +73614,7 @@ function buildExtensionHandlers(deps) {
|
|
|
73676
73614
|
};
|
|
73677
73615
|
async function buildSnapshotMeta(extId) {
|
|
73678
73616
|
const manifest = await readManifest(deps.root, extId);
|
|
73679
|
-
const { sha256, buffer } = await bundleExtensionDir(
|
|
73617
|
+
const { sha256, buffer } = await bundleExtensionDir(import_node_path75.default.join(deps.root, extId));
|
|
73680
73618
|
return { manifest, contentHash: sha256, buffer };
|
|
73681
73619
|
}
|
|
73682
73620
|
const publish = async (frame, _client, ctx) => {
|
|
@@ -74504,7 +74442,7 @@ function buildVisitorHandlers(deps) {
|
|
|
74504
74442
|
|
|
74505
74443
|
// src/extension/registry.ts
|
|
74506
74444
|
var import_promises17 = __toESM(require("fs/promises"), 1);
|
|
74507
|
-
var
|
|
74445
|
+
var import_node_path76 = __toESM(require("path"), 1);
|
|
74508
74446
|
async function loadAll(root) {
|
|
74509
74447
|
let entries;
|
|
74510
74448
|
try {
|
|
@@ -74517,13 +74455,13 @@ async function loadAll(root) {
|
|
|
74517
74455
|
for (const ent of entries) {
|
|
74518
74456
|
if (!ent.isDirectory()) continue;
|
|
74519
74457
|
if (ent.name.startsWith(".")) continue;
|
|
74520
|
-
records.push(await loadOne(
|
|
74458
|
+
records.push(await loadOne(import_node_path76.default.join(root, ent.name), ent.name));
|
|
74521
74459
|
}
|
|
74522
74460
|
records.sort((a2, b3) => a2.extId < b3.extId ? -1 : a2.extId > b3.extId ? 1 : 0);
|
|
74523
74461
|
return records;
|
|
74524
74462
|
}
|
|
74525
74463
|
async function loadOne(dir, dirName) {
|
|
74526
|
-
const manifestPath =
|
|
74464
|
+
const manifestPath = import_node_path76.default.join(dir, "manifest.json");
|
|
74527
74465
|
let raw;
|
|
74528
74466
|
try {
|
|
74529
74467
|
raw = await import_promises17.default.readFile(manifestPath, "utf8");
|
|
@@ -74568,7 +74506,7 @@ async function loadOne(dir, dirName) {
|
|
|
74568
74506
|
|
|
74569
74507
|
// src/extension/uninstall.ts
|
|
74570
74508
|
var import_promises18 = __toESM(require("fs/promises"), 1);
|
|
74571
|
-
var
|
|
74509
|
+
var import_node_path77 = __toESM(require("path"), 1);
|
|
74572
74510
|
var UninstallError = class extends Error {
|
|
74573
74511
|
constructor(code, message) {
|
|
74574
74512
|
super(message);
|
|
@@ -74577,7 +74515,7 @@ var UninstallError = class extends Error {
|
|
|
74577
74515
|
code;
|
|
74578
74516
|
};
|
|
74579
74517
|
async function uninstall(deps) {
|
|
74580
|
-
const dir =
|
|
74518
|
+
const dir = import_node_path77.default.join(deps.root, deps.extId);
|
|
74581
74519
|
try {
|
|
74582
74520
|
await import_promises18.default.access(dir);
|
|
74583
74521
|
} catch {
|
|
@@ -74595,14 +74533,14 @@ init_protocol();
|
|
|
74595
74533
|
|
|
74596
74534
|
// src/peer-ops/run-command.ts
|
|
74597
74535
|
var import_node_child_process23 = require("child_process");
|
|
74598
|
-
var
|
|
74536
|
+
var import_node_os30 = __toESM(require("os"), 1);
|
|
74599
74537
|
var DEFAULT_TIMEOUT_MS6 = 3e4;
|
|
74600
74538
|
var MAX_TIMEOUT_MS = 3e5;
|
|
74601
74539
|
var MAX_OUTPUT_BYTES = 1048576;
|
|
74602
74540
|
function runCommand2(command, opts = {}) {
|
|
74603
74541
|
const timeoutMs = Math.min(opts.timeoutMs ?? DEFAULT_TIMEOUT_MS6, MAX_TIMEOUT_MS);
|
|
74604
74542
|
return new Promise((resolve9) => {
|
|
74605
|
-
const child = (0, import_node_child_process23.spawn)("bash", ["-c", command], { cwd:
|
|
74543
|
+
const child = (0, import_node_child_process23.spawn)("bash", ["-c", command], { cwd: import_node_os30.default.homedir() });
|
|
74606
74544
|
const out = [];
|
|
74607
74545
|
const err = [];
|
|
74608
74546
|
let outBytes = 0;
|
|
@@ -74795,7 +74733,7 @@ function buildMethodHandlers(deps) {
|
|
|
74795
74733
|
broadcast: deps.broadcastToOwners
|
|
74796
74734
|
}),
|
|
74797
74735
|
...buildMasterHandlers({
|
|
74798
|
-
authorityTablePath:
|
|
74736
|
+
authorityTablePath: import_node_path78.default.join(deps.masterDataDir, "master-authority.json")
|
|
74799
74737
|
}),
|
|
74800
74738
|
...buildTopicHandlers({
|
|
74801
74739
|
topicStore: deps.topicStore,
|
|
@@ -74938,7 +74876,7 @@ async function dispatchRpc(method, frame, client, ctx, deps) {
|
|
|
74938
74876
|
|
|
74939
74877
|
// src/extension/runtime.ts
|
|
74940
74878
|
var import_node_child_process24 = require("child_process");
|
|
74941
|
-
var
|
|
74879
|
+
var import_node_path79 = __toESM(require("path"), 1);
|
|
74942
74880
|
var import_promises19 = require("timers/promises");
|
|
74943
74881
|
|
|
74944
74882
|
// src/extension/port-allocator.ts
|
|
@@ -75039,7 +74977,7 @@ var Runtime = class {
|
|
|
75039
74977
|
/\$CLAWOS_EXT_PORT/g,
|
|
75040
74978
|
String(port)
|
|
75041
74979
|
);
|
|
75042
|
-
const dir =
|
|
74980
|
+
const dir = import_node_path79.default.join(this.root, extId);
|
|
75043
74981
|
const env = {
|
|
75044
74982
|
...process.env,
|
|
75045
74983
|
CLAWOS_EXT_PORT: String(port),
|
|
@@ -75151,7 +75089,7 @@ ${handle.stderrTail}`
|
|
|
75151
75089
|
|
|
75152
75090
|
// src/extension/published-channels.ts
|
|
75153
75091
|
var import_promises20 = __toESM(require("fs/promises"), 1);
|
|
75154
|
-
var
|
|
75092
|
+
var import_node_path80 = __toESM(require("path"), 1);
|
|
75155
75093
|
init_zod();
|
|
75156
75094
|
var PublishedChannelsError = class extends Error {
|
|
75157
75095
|
constructor(code, message) {
|
|
@@ -75250,7 +75188,7 @@ var PublishedChannelStore = class {
|
|
|
75250
75188
|
)
|
|
75251
75189
|
};
|
|
75252
75190
|
const tmp = `${this.filePath}.tmp`;
|
|
75253
|
-
await import_promises20.default.mkdir(
|
|
75191
|
+
await import_promises20.default.mkdir(import_node_path80.default.dirname(this.filePath), { recursive: true });
|
|
75254
75192
|
await import_promises20.default.writeFile(tmp, JSON.stringify(data, null, 2), { mode: 384 });
|
|
75255
75193
|
await import_promises20.default.rename(tmp, this.filePath);
|
|
75256
75194
|
}
|
|
@@ -75258,7 +75196,7 @@ var PublishedChannelStore = class {
|
|
|
75258
75196
|
|
|
75259
75197
|
// src/extension/bundle-cache.ts
|
|
75260
75198
|
var import_promises21 = __toESM(require("fs/promises"), 1);
|
|
75261
|
-
var
|
|
75199
|
+
var import_node_path81 = __toESM(require("path"), 1);
|
|
75262
75200
|
var BundleCache = class {
|
|
75263
75201
|
constructor(rootDir) {
|
|
75264
75202
|
this.rootDir = rootDir;
|
|
@@ -75267,14 +75205,14 @@ var BundleCache = class {
|
|
|
75267
75205
|
/** Atomic write: stage tmp → rename. Caller passes the hex sha256. */
|
|
75268
75206
|
async write(snapshotHash, buffer) {
|
|
75269
75207
|
await import_promises21.default.mkdir(this.rootDir, { recursive: true });
|
|
75270
|
-
const file =
|
|
75208
|
+
const file = import_node_path81.default.join(this.rootDir, `${snapshotHash}.zip`);
|
|
75271
75209
|
const tmp = `${file}.tmp`;
|
|
75272
75210
|
await import_promises21.default.writeFile(tmp, buffer, { mode: 384 });
|
|
75273
75211
|
await import_promises21.default.rename(tmp, file);
|
|
75274
75212
|
}
|
|
75275
75213
|
/** Returns the bundle bytes, or null when the file doesn't exist. */
|
|
75276
75214
|
async read(snapshotHash) {
|
|
75277
|
-
const file =
|
|
75215
|
+
const file = import_node_path81.default.join(this.rootDir, `${snapshotHash}.zip`);
|
|
75278
75216
|
try {
|
|
75279
75217
|
return await import_promises21.default.readFile(file);
|
|
75280
75218
|
} catch (e) {
|
|
@@ -75284,7 +75222,7 @@ var BundleCache = class {
|
|
|
75284
75222
|
}
|
|
75285
75223
|
/** Idempotent — missing file is not an error. */
|
|
75286
75224
|
async delete(snapshotHash) {
|
|
75287
|
-
const file =
|
|
75225
|
+
const file = import_node_path81.default.join(this.rootDir, `${snapshotHash}.zip`);
|
|
75288
75226
|
await import_promises21.default.rm(file, { force: true });
|
|
75289
75227
|
}
|
|
75290
75228
|
};
|
|
@@ -75305,26 +75243,26 @@ async function startDaemon(config) {
|
|
|
75305
75243
|
},
|
|
75306
75244
|
source: "daemon",
|
|
75307
75245
|
sampling: logShippingCfg.sampling,
|
|
75308
|
-
homeDir:
|
|
75246
|
+
homeDir: import_node_os31.default.homedir()
|
|
75309
75247
|
});
|
|
75310
|
-
const logDir =
|
|
75311
|
-
|
|
75248
|
+
const logDir = import_node_path82.default.join(config.dataDir, "log");
|
|
75249
|
+
import_node_fs64.default.mkdirSync(logDir, { recursive: true });
|
|
75312
75250
|
const logger = createLogger({
|
|
75313
75251
|
level: config.logLevel,
|
|
75314
|
-
file:
|
|
75252
|
+
file: import_node_path82.default.join(logDir, "clawd.log"),
|
|
75315
75253
|
logClient
|
|
75316
75254
|
});
|
|
75317
75255
|
logger.info("starting clawd", { version, config: { port: config.port, host: config.host, dataDir: config.dataDir } });
|
|
75318
75256
|
const screenIdleProbeLogger = createFileOnlyLogger({
|
|
75319
|
-
file:
|
|
75257
|
+
file: import_node_path82.default.join(logDir, "screen-idle-probe.log"),
|
|
75320
75258
|
level: "debug"
|
|
75321
75259
|
});
|
|
75322
75260
|
logger.info("screen-idle probe logger enabled", {
|
|
75323
|
-
file:
|
|
75261
|
+
file: import_node_path82.default.join(logDir, "screen-idle-probe.log")
|
|
75324
75262
|
});
|
|
75325
75263
|
const CAP_TARGETS = [
|
|
75326
|
-
|
|
75327
|
-
|
|
75264
|
+
import_node_path82.default.join(logDir, "clawd.log"),
|
|
75265
|
+
import_node_path82.default.join(logDir, "screen-idle-probe.log")
|
|
75328
75266
|
];
|
|
75329
75267
|
const LOG_CAP_MAX_BYTES = 10 * 1024 * 1024;
|
|
75330
75268
|
const LOG_CAP_KEEP_BYTES = 5 * 1024 * 1024;
|
|
@@ -75446,9 +75384,9 @@ async function startDaemon(config) {
|
|
|
75446
75384
|
const agents = new AgentsScanner();
|
|
75447
75385
|
const history = new ClaudeHistoryReader();
|
|
75448
75386
|
let transport = null;
|
|
75449
|
-
const personaStore = new PersonaStore(
|
|
75387
|
+
const personaStore = new PersonaStore(import_node_path82.default.join(config.dataDir, "personas"));
|
|
75450
75388
|
const subscriptionChannelStore = new SubscriptionChannelStore({ dataDir: config.dataDir });
|
|
75451
|
-
const usersRoot =
|
|
75389
|
+
const usersRoot = import_node_path82.default.join(config.dataDir, "users");
|
|
75452
75390
|
const defaultsRoot = findDefaultsRoot(logger);
|
|
75453
75391
|
if (defaultsRoot) {
|
|
75454
75392
|
seedDefaultPersonas({ store: personaStore, defaultsRoot, logger });
|
|
@@ -75465,7 +75403,7 @@ async function startDaemon(config) {
|
|
|
75465
75403
|
retirePersonaBuilder({ store: personaStore, logger });
|
|
75466
75404
|
const groupFileStore = new GroupFileStore({ dataDir: config.dataDir, logger });
|
|
75467
75405
|
const dispatchStore = createDispatchStore({
|
|
75468
|
-
filePath:
|
|
75406
|
+
filePath: import_node_path82.default.join(config.dataDir, "dispatch.json"),
|
|
75469
75407
|
now: () => Date.now(),
|
|
75470
75408
|
onFlushError: (err) => logger.error("dispatch store flush failed", {
|
|
75471
75409
|
reason: err instanceof Error ? err.message : String(err)
|
|
@@ -75474,7 +75412,7 @@ async function startDaemon(config) {
|
|
|
75474
75412
|
await dispatchStore.load();
|
|
75475
75413
|
dispatchStore.markInterruptedAsFailed((/* @__PURE__ */ new Date()).toISOString());
|
|
75476
75414
|
const channelStore = createChannelStore({
|
|
75477
|
-
filePath:
|
|
75415
|
+
filePath: import_node_path82.default.join(config.dataDir, "channels.json"),
|
|
75478
75416
|
now: () => Date.now(),
|
|
75479
75417
|
genId: () => `ch-${(0, import_node_crypto26.randomUUID)().slice(0, 8)}`,
|
|
75480
75418
|
onFlushError: (err) => logger.error("channel store flush failed", {
|
|
@@ -75483,7 +75421,7 @@ async function startDaemon(config) {
|
|
|
75483
75421
|
});
|
|
75484
75422
|
await channelStore.load();
|
|
75485
75423
|
const topicStore = createTopicStore({
|
|
75486
|
-
filePath:
|
|
75424
|
+
filePath: import_node_path82.default.join(config.dataDir, "topics.json"),
|
|
75487
75425
|
now: () => Date.now(),
|
|
75488
75426
|
genId: () => `tp-${(0, import_node_crypto26.randomUUID)().slice(0, 8)}`,
|
|
75489
75427
|
onFlushError: (err) => logger.error("topic store flush failed", {
|
|
@@ -75510,12 +75448,12 @@ async function startDaemon(config) {
|
|
|
75510
75448
|
});
|
|
75511
75449
|
}
|
|
75512
75450
|
});
|
|
75513
|
-
const here = typeof __dirname === "string" ? __dirname :
|
|
75451
|
+
const here = typeof __dirname === "string" ? __dirname : import_node_path82.default.dirname((0, import_node_url6.fileURLToPath)(import_meta10.url));
|
|
75514
75452
|
const mcpConfigs = [];
|
|
75515
75453
|
const secretsBundleRoot = findSecretsBundleRoot(logger);
|
|
75516
|
-
const localSecretsDir =
|
|
75454
|
+
const localSecretsDir = import_node_path82.default.join(config.dataDir, LOCAL_SECRETS_DIRNAME);
|
|
75517
75455
|
const readSecrets = () => readSecretTable({ bundleRoot: secretsBundleRoot, overrideDir: localSecretsDir, logger });
|
|
75518
|
-
const githubTokenFile =
|
|
75456
|
+
const githubTokenFile = import_node_path82.default.join(localSecretsDir, GITHUB_TOKEN_FILE);
|
|
75519
75457
|
const githubIdentity = createGithubIdentity({
|
|
75520
75458
|
resolve: () => resolveGithubAuth({ exec: runCommand, fileToken: () => readEnvFileVar(githubTokenFile, GITHUB_TOKEN_VAR) }),
|
|
75521
75459
|
store: (token) => storeGithubAuth({
|
|
@@ -75553,22 +75491,22 @@ async function startDaemon(config) {
|
|
|
75553
75491
|
void githubIdentity.refresh();
|
|
75554
75492
|
return renderPersonaMcpSecrets({
|
|
75555
75493
|
personaId: personaId2,
|
|
75556
|
-
personaDir:
|
|
75494
|
+
personaDir: import_node_path82.default.join(config.dataDir, "personas", personaId2),
|
|
75557
75495
|
secrets,
|
|
75558
|
-
outDir:
|
|
75496
|
+
outDir: import_node_path82.default.join(config.dataDir, "persona-mcp"),
|
|
75559
75497
|
logger
|
|
75560
75498
|
});
|
|
75561
75499
|
};
|
|
75562
75500
|
const mcpDaemonUrl = `http://127.0.0.1:${config.port}`;
|
|
75563
75501
|
const dispatchServerCandidates = [
|
|
75564
|
-
|
|
75502
|
+
import_node_path82.default.join(here, "dispatch", "mcp-server.cjs"),
|
|
75565
75503
|
// 生产 dist/index → dist/dispatch/mcp-server.cjs
|
|
75566
|
-
|
|
75504
|
+
import_node_path82.default.join(here, "..", "dist", "dispatch", "mcp-server.cjs")
|
|
75567
75505
|
// dev tsx src/index → ../dist/dispatch/mcp-server.cjs
|
|
75568
75506
|
];
|
|
75569
|
-
const dispatchServerScriptPath = dispatchServerCandidates.find((p3) =>
|
|
75507
|
+
const dispatchServerScriptPath = dispatchServerCandidates.find((p3) => import_node_fs64.default.existsSync(p3));
|
|
75570
75508
|
if (dispatchServerScriptPath) {
|
|
75571
|
-
const dispatchLogPath =
|
|
75509
|
+
const dispatchLogPath = import_node_path82.default.join(logDir, "dispatch-mcp-server.log");
|
|
75572
75510
|
const dispatchCfgPath = writeDispatchMcpConfig({
|
|
75573
75511
|
dataDir: config.dataDir,
|
|
75574
75512
|
serverScriptPath: dispatchServerScriptPath,
|
|
@@ -75588,12 +75526,12 @@ async function startDaemon(config) {
|
|
|
75588
75526
|
});
|
|
75589
75527
|
}
|
|
75590
75528
|
const ticketServerCandidates = [
|
|
75591
|
-
|
|
75592
|
-
|
|
75529
|
+
import_node_path82.default.join(here, "ticket", "mcp-server.cjs"),
|
|
75530
|
+
import_node_path82.default.join(here, "..", "dist", "ticket", "mcp-server.cjs")
|
|
75593
75531
|
];
|
|
75594
|
-
const ticketServerScriptPath = ticketServerCandidates.find((p3) =>
|
|
75532
|
+
const ticketServerScriptPath = ticketServerCandidates.find((p3) => import_node_fs64.default.existsSync(p3));
|
|
75595
75533
|
if (ticketServerScriptPath) {
|
|
75596
|
-
const ticketLogPath =
|
|
75534
|
+
const ticketLogPath = import_node_path82.default.join(logDir, "ticket-mcp-server.log");
|
|
75597
75535
|
const ticketCfgPath = writeTicketMcpConfig({
|
|
75598
75536
|
dataDir: config.dataDir,
|
|
75599
75537
|
serverScriptPath: ticketServerScriptPath,
|
|
@@ -75615,12 +75553,12 @@ async function startDaemon(config) {
|
|
|
75615
75553
|
});
|
|
75616
75554
|
}
|
|
75617
75555
|
const shiftServerCandidates = [
|
|
75618
|
-
|
|
75619
|
-
|
|
75556
|
+
import_node_path82.default.join(here, "shift", "mcp-server.cjs"),
|
|
75557
|
+
import_node_path82.default.join(here, "..", "dist", "shift", "mcp-server.cjs")
|
|
75620
75558
|
];
|
|
75621
|
-
const shiftServerScriptPath = shiftServerCandidates.find((p3) =>
|
|
75559
|
+
const shiftServerScriptPath = shiftServerCandidates.find((p3) => import_node_fs64.default.existsSync(p3));
|
|
75622
75560
|
if (shiftServerScriptPath) {
|
|
75623
|
-
const shiftLogPath =
|
|
75561
|
+
const shiftLogPath = import_node_path82.default.join(logDir, "shift-mcp-server.log");
|
|
75624
75562
|
const shiftCfgPath = await writeShiftMcpConfig({
|
|
75625
75563
|
dataDir: config.dataDir,
|
|
75626
75564
|
serverScriptPath: shiftServerScriptPath,
|
|
@@ -75641,12 +75579,12 @@ async function startDaemon(config) {
|
|
|
75641
75579
|
);
|
|
75642
75580
|
}
|
|
75643
75581
|
const inboxServerCandidates = [
|
|
75644
|
-
|
|
75645
|
-
|
|
75582
|
+
import_node_path82.default.join(here, "inbox", "mcp-server.cjs"),
|
|
75583
|
+
import_node_path82.default.join(here, "..", "dist", "inbox", "mcp-server.cjs")
|
|
75646
75584
|
];
|
|
75647
|
-
const inboxServerScriptPath = inboxServerCandidates.find((p3) =>
|
|
75585
|
+
const inboxServerScriptPath = inboxServerCandidates.find((p3) => import_node_fs64.default.existsSync(p3));
|
|
75648
75586
|
if (inboxServerScriptPath) {
|
|
75649
|
-
const inboxLogPath =
|
|
75587
|
+
const inboxLogPath = import_node_path82.default.join(logDir, "inbox-mcp-server.log");
|
|
75650
75588
|
const inboxCfgPath = await writeInboxMcpConfig({
|
|
75651
75589
|
dataDir: config.dataDir,
|
|
75652
75590
|
serverScriptPath: inboxServerScriptPath,
|
|
@@ -75667,10 +75605,10 @@ async function startDaemon(config) {
|
|
|
75667
75605
|
);
|
|
75668
75606
|
}
|
|
75669
75607
|
const peerOpsServerCandidates = [
|
|
75670
|
-
|
|
75671
|
-
|
|
75608
|
+
import_node_path82.default.join(here, "peer-ops", "mcp-server.cjs"),
|
|
75609
|
+
import_node_path82.default.join(here, "..", "dist", "peer-ops", "mcp-server.cjs")
|
|
75672
75610
|
];
|
|
75673
|
-
const peerOpsServerScriptPath = peerOpsServerCandidates.find((p3) =>
|
|
75611
|
+
const peerOpsServerScriptPath = peerOpsServerCandidates.find((p3) => import_node_fs64.default.existsSync(p3));
|
|
75674
75612
|
if (peerOpsServerScriptPath) {
|
|
75675
75613
|
const peerOpsCfgPath = writePeerOpsMcpConfig({
|
|
75676
75614
|
dataDir: config.dataDir,
|
|
@@ -75690,12 +75628,12 @@ async function startDaemon(config) {
|
|
|
75690
75628
|
);
|
|
75691
75629
|
}
|
|
75692
75630
|
const rpcToolServerCandidates = [
|
|
75693
|
-
|
|
75694
|
-
|
|
75631
|
+
import_node_path82.default.join(here, "rpc-tool", "mcp-server.cjs"),
|
|
75632
|
+
import_node_path82.default.join(here, "..", "dist", "rpc-tool", "mcp-server.cjs")
|
|
75695
75633
|
];
|
|
75696
|
-
const rpcToolServerScriptPath = rpcToolServerCandidates.find((p3) =>
|
|
75634
|
+
const rpcToolServerScriptPath = rpcToolServerCandidates.find((p3) => import_node_fs64.default.existsSync(p3));
|
|
75697
75635
|
if (rpcToolServerScriptPath) {
|
|
75698
|
-
const rpcToolLogPath =
|
|
75636
|
+
const rpcToolLogPath = import_node_path82.default.join(logDir, "rpc-tool-mcp-server.log");
|
|
75699
75637
|
const rpcToolCfgPath = writeRpcToolMcpConfig({
|
|
75700
75638
|
dataDir: config.dataDir,
|
|
75701
75639
|
serverScriptPath: rpcToolServerScriptPath,
|
|
@@ -75716,7 +75654,7 @@ async function startDaemon(config) {
|
|
|
75716
75654
|
);
|
|
75717
75655
|
}
|
|
75718
75656
|
const shiftStore = createShiftStore({
|
|
75719
|
-
filePath:
|
|
75657
|
+
filePath: import_node_path82.default.join(config.dataDir, "shift.json"),
|
|
75720
75658
|
ownerIdProvider: () => ownerPrincipalId,
|
|
75721
75659
|
now: () => Date.now()
|
|
75722
75660
|
});
|
|
@@ -75738,7 +75676,7 @@ async function startDaemon(config) {
|
|
|
75738
75676
|
getAdapter,
|
|
75739
75677
|
historyReader: history,
|
|
75740
75678
|
dataDir: config.dataDir,
|
|
75741
|
-
personaRoot:
|
|
75679
|
+
personaRoot: import_node_path82.default.join(config.dataDir, "personas"),
|
|
75742
75680
|
// dispatch / shift 自动化 spawn 按 persona 绑定 tool 起 B session(codex persona 用 codex)。
|
|
75743
75681
|
// personaRegistry 声明在 manager 之后(同作用域 const,调用时机在启动完成后,无 TDZ 风险)。
|
|
75744
75682
|
getPersonaDefaults: (personaId2) => personaRegistry.get(personaId2),
|
|
@@ -75795,10 +75733,10 @@ async function startDaemon(config) {
|
|
|
75795
75733
|
// 文件可能 agent 写完又被自己删(罕见),用 size=0 / fallback mime 兜底。
|
|
75796
75734
|
attachmentGroup: {
|
|
75797
75735
|
onFileEdit: (input) => {
|
|
75798
|
-
const absPath =
|
|
75736
|
+
const absPath = import_node_path82.default.isAbsolute(input.relPath) ? input.relPath : import_node_path82.default.join(input.cwd, input.relPath);
|
|
75799
75737
|
let size = 0;
|
|
75800
75738
|
try {
|
|
75801
|
-
size =
|
|
75739
|
+
size = import_node_fs64.default.statSync(absPath).size;
|
|
75802
75740
|
} catch (err) {
|
|
75803
75741
|
logger.warn("attachment.onFileEdit stat failed", {
|
|
75804
75742
|
sessionId: input.sessionId,
|
|
@@ -75839,9 +75777,9 @@ async function startDaemon(config) {
|
|
|
75839
75777
|
logger.info("projects.seed-dropped", { dropped: droppedSeed.dropped, backup: droppedSeed.backup });
|
|
75840
75778
|
}
|
|
75841
75779
|
const projectsStore = new ProjectsStore({
|
|
75842
|
-
file:
|
|
75780
|
+
file: import_node_path82.default.join(config.dataDir, "projects.json"),
|
|
75843
75781
|
clawdDir: config.dataDir,
|
|
75844
|
-
codexStateFile:
|
|
75782
|
+
codexStateFile: import_node_path82.default.join(import_node_os31.default.homedir(), ".codex", ".codex-global-state.json"),
|
|
75845
75783
|
logger
|
|
75846
75784
|
});
|
|
75847
75785
|
const observer = new SessionObserver({
|
|
@@ -75906,13 +75844,13 @@ async function startDaemon(config) {
|
|
|
75906
75844
|
logger
|
|
75907
75845
|
});
|
|
75908
75846
|
registerAdapter("claude", claudeAdapter);
|
|
75909
|
-
const codexIsolatedHome =
|
|
75847
|
+
const codexIsolatedHome = import_node_path82.default.join(config.dataDir, "codex-home");
|
|
75910
75848
|
try {
|
|
75911
|
-
|
|
75849
|
+
import_node_fs64.default.mkdirSync(codexIsolatedHome, { recursive: true });
|
|
75912
75850
|
for (const f2 of ["auth.json", "config.toml"]) {
|
|
75913
|
-
const link =
|
|
75914
|
-
const target =
|
|
75915
|
-
if (!
|
|
75851
|
+
const link = import_node_path82.default.join(codexIsolatedHome, f2);
|
|
75852
|
+
const target = import_node_path82.default.join(import_node_os31.default.homedir(), ".codex", f2);
|
|
75853
|
+
if (!import_node_fs64.default.existsSync(link) && import_node_fs64.default.existsSync(target)) import_node_fs64.default.symlinkSync(target, link);
|
|
75916
75854
|
}
|
|
75917
75855
|
} catch (err) {
|
|
75918
75856
|
logger.warn("codex isolated home setup failed", { err: String(err) });
|
|
@@ -75923,17 +75861,17 @@ async function startDaemon(config) {
|
|
|
75923
75861
|
logger,
|
|
75924
75862
|
historyReader: new CodexHistoryReader({
|
|
75925
75863
|
roots: codexRolloutRoots(config.dataDir),
|
|
75926
|
-
sharedHome:
|
|
75864
|
+
sharedHome: import_node_path82.default.join(import_node_os31.default.homedir(), ".codex"),
|
|
75927
75865
|
logger
|
|
75928
75866
|
}),
|
|
75929
75867
|
// projectPaths 每次调用现取 —— 用户新建 project 后立即生效,不用重启 daemon
|
|
75930
75868
|
codexHomeFor: (cwd) => resolveCodexHome({
|
|
75931
75869
|
cwd,
|
|
75932
|
-
personaRoot:
|
|
75870
|
+
personaRoot: import_node_path82.default.join(config.dataDir, "personas"),
|
|
75933
75871
|
// 必须用 listMerged(Codex registry ∪ 叠加层):只用本地 list() 的话,用户在
|
|
75934
75872
|
// Codex 里建的 project 不在表里,在它下面开的会话会被误判成隔离 → Codex 侧看不到
|
|
75935
75873
|
projectPaths: projectsStore.listMerged().map((x2) => x2.path),
|
|
75936
|
-
sharedHome:
|
|
75874
|
+
sharedHome: import_node_path82.default.join(import_node_os31.default.homedir(), ".codex"),
|
|
75937
75875
|
isolatedHome: codexIsolatedHome
|
|
75938
75876
|
}),
|
|
75939
75877
|
// 附件图片验签:与 http-router /files 路由同一把 secret
|
|
@@ -75958,10 +75896,10 @@ async function startDaemon(config) {
|
|
|
75958
75896
|
);
|
|
75959
75897
|
registerAdapter(PI_CLOUD_TOOL_ID, new CloudPiAdapter({ client: cloudGateway, history: cloudHistorySource, logger }));
|
|
75960
75898
|
const piMcpBridgeCandidates = [
|
|
75961
|
-
|
|
75962
|
-
|
|
75899
|
+
import_node_path82.default.join(here, "pi-mcp-bridge", "extension.cjs"),
|
|
75900
|
+
import_node_path82.default.join(here, "..", "dist", "pi-mcp-bridge", "extension.cjs")
|
|
75963
75901
|
];
|
|
75964
|
-
const piMcpBridgePath = piMcpBridgeCandidates.find((p3) =>
|
|
75902
|
+
const piMcpBridgePath = piMcpBridgeCandidates.find((p3) => import_node_fs64.default.existsSync(p3));
|
|
75965
75903
|
if (piMcpBridgePath) {
|
|
75966
75904
|
logger.info("pi-mcp-bridge extension resolved", { path: piMcpBridgePath });
|
|
75967
75905
|
} else {
|
|
@@ -76257,11 +76195,11 @@ async function startDaemon(config) {
|
|
|
76257
76195
|
// 'persona/<pid>/owner',default 走 'default'。
|
|
76258
76196
|
getSessionScope: (sid) => manager.findOwnedSessionScope(sid),
|
|
76259
76197
|
// guest path guard:candidate 必须在 personaRoot 子树或调用者自己的 user-dir 下
|
|
76260
|
-
personaRoot:
|
|
76198
|
+
personaRoot: import_node_path82.default.join(config.dataDir, "personas"),
|
|
76261
76199
|
usersRoot
|
|
76262
76200
|
},
|
|
76263
76201
|
// workspace/git/history/skills/agents handler 共用的 guest path guard 锚点
|
|
76264
|
-
personaRoot:
|
|
76202
|
+
personaRoot: import_node_path82.default.join(config.dataDir, "personas"),
|
|
76265
76203
|
// v2 多人 persona 隔离:handler 派生 guest user-dir 放行
|
|
76266
76204
|
usersRoot,
|
|
76267
76205
|
// v2 Phase 6: whoami handler 装在 owner principal.displayName + persona 解析
|
|
@@ -76407,7 +76345,7 @@ async function startDaemon(config) {
|
|
|
76407
76345
|
sourceSessionId: args.sourceSessionId
|
|
76408
76346
|
});
|
|
76409
76347
|
const sourceFile = manager.findOwnedSession(args.sourceSessionId);
|
|
76410
|
-
const sourceJsonlPath = resolveSourceJsonlPath(sourceFile,
|
|
76348
|
+
const sourceJsonlPath = resolveSourceJsonlPath(sourceFile, import_node_os31.default.homedir());
|
|
76411
76349
|
logger.info("dispatch.spawnB.source-resolved", {
|
|
76412
76350
|
dispatchId: args.dispatchId,
|
|
76413
76351
|
sourceJsonlPath,
|
|
@@ -76567,7 +76505,7 @@ async function startDaemon(config) {
|
|
|
76567
76505
|
});
|
|
76568
76506
|
shiftScheduler.start();
|
|
76569
76507
|
logger.info("shift scheduler started", { shiftCount: shiftStore.list().length });
|
|
76570
|
-
const larkBotStore = createLarkBotBindingStore(
|
|
76508
|
+
const larkBotStore = createLarkBotBindingStore(import_node_path82.default.join(config.dataDir, "personas"));
|
|
76571
76509
|
const larkBotCloud = createLarkBotCloudClient({
|
|
76572
76510
|
api: config.clawosApi ?? DEFAULT_CLAWOS_API,
|
|
76573
76511
|
getLoginPass: () => ownerIdentityStore.read()?.loginPass ?? null
|
|
@@ -76579,7 +76517,7 @@ async function startDaemon(config) {
|
|
|
76579
76517
|
store: larkBotStore,
|
|
76580
76518
|
fetchResource: (appId, messageId, fileKey, maxBytes, type) => larkBotCloud.fetchResource(appId, messageId, fileKey, maxBytes, type),
|
|
76581
76519
|
// 图片落 guest userWorkDir 下(capId = lark-<chat_id>):CC 经 --add-dir + allowRead carve 可 Read
|
|
76582
|
-
mediaRootFor: (chatId) =>
|
|
76520
|
+
mediaRootFor: (chatId) => import_node_path82.default.join(deriveUserWorkDir(`lark-${chatId}`, usersRoot), "lark-media"),
|
|
76583
76521
|
isShuttingDown: () => larkDraining,
|
|
76584
76522
|
logger: {
|
|
76585
76523
|
warn: (msg) => logger.warn(msg),
|
|
@@ -76879,8 +76817,8 @@ async function startDaemon(config) {
|
|
|
76879
76817
|
const lines = [
|
|
76880
76818
|
`Tunnel: ${r2.url}`,
|
|
76881
76819
|
...resolvedAuthToken ? [`Connect: ${connectUrl}`] : [],
|
|
76882
|
-
`Frpc config: ${
|
|
76883
|
-
`Frpc log: ${
|
|
76820
|
+
`Frpc config: ${import_node_path82.default.join(config.dataDir, "frpc.toml")}`,
|
|
76821
|
+
`Frpc log: ${import_node_path82.default.join(logDir, "frpc.log")}`
|
|
76884
76822
|
];
|
|
76885
76823
|
const width2 = Math.max(...lines.map((l2) => l2.length));
|
|
76886
76824
|
const bar = "\u2550".repeat(width2 + 4);
|
|
@@ -76893,8 +76831,8 @@ ${bar}
|
|
|
76893
76831
|
|
|
76894
76832
|
`);
|
|
76895
76833
|
try {
|
|
76896
|
-
const connectPath =
|
|
76897
|
-
|
|
76834
|
+
const connectPath = import_node_path82.default.join(config.dataDir, "connect.txt");
|
|
76835
|
+
import_node_fs64.default.writeFileSync(connectPath, lines.join("\n") + "\n", { mode: 384 });
|
|
76898
76836
|
} catch {
|
|
76899
76837
|
}
|
|
76900
76838
|
} catch (err) {
|
|
@@ -76992,9 +76930,9 @@ ${bar}
|
|
|
76992
76930
|
};
|
|
76993
76931
|
}
|
|
76994
76932
|
function migrateDropPersonsDir(dataDir) {
|
|
76995
|
-
const dir =
|
|
76933
|
+
const dir = import_node_path82.default.join(dataDir, "persons");
|
|
76996
76934
|
try {
|
|
76997
|
-
|
|
76935
|
+
import_node_fs64.default.rmSync(dir, { recursive: true, force: true });
|
|
76998
76936
|
} catch {
|
|
76999
76937
|
}
|
|
77000
76938
|
}
|