@clawos-dev/clawd 0.2.662 → 0.2.663
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 +874 -844
- 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: path111, errorMaps, issueData } = params;
|
|
454
|
+
const fullPath = [...path111, ...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, path111, key) {
|
|
766
766
|
this._cachedPath = [];
|
|
767
767
|
this.parent = parent;
|
|
768
768
|
this.data = value;
|
|
769
|
-
this._path =
|
|
769
|
+
this._path = path111;
|
|
770
770
|
this._key = key;
|
|
771
771
|
}
|
|
772
772
|
get path() {
|
|
@@ -10448,11 +10448,11 @@ var init_lib = __esm({
|
|
|
10448
10448
|
}
|
|
10449
10449
|
}
|
|
10450
10450
|
},
|
|
10451
|
-
addToPath: function addToPath(
|
|
10452
|
-
var last =
|
|
10451
|
+
addToPath: function addToPath(path111, added, removed, oldPosInc, options) {
|
|
10452
|
+
var last = path111.lastComponent;
|
|
10453
10453
|
if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) {
|
|
10454
10454
|
return {
|
|
10455
|
-
oldPos:
|
|
10455
|
+
oldPos: path111.oldPos + oldPosInc,
|
|
10456
10456
|
lastComponent: {
|
|
10457
10457
|
count: last.count + 1,
|
|
10458
10458
|
added,
|
|
@@ -10462,7 +10462,7 @@ var init_lib = __esm({
|
|
|
10462
10462
|
};
|
|
10463
10463
|
} else {
|
|
10464
10464
|
return {
|
|
10465
|
-
oldPos:
|
|
10465
|
+
oldPos: path111.oldPos + oldPosInc,
|
|
10466
10466
|
lastComponent: {
|
|
10467
10467
|
count: 1,
|
|
10468
10468
|
added,
|
|
@@ -11068,10 +11068,10 @@ function attachmentToHistoryMessage(o2, ts) {
|
|
|
11068
11068
|
const memories = raw.map((m3) => {
|
|
11069
11069
|
if (!m3 || typeof m3 !== "object") return null;
|
|
11070
11070
|
const rec6 = m3;
|
|
11071
|
-
const
|
|
11071
|
+
const path111 = typeof rec6.path === "string" ? rec6.path : null;
|
|
11072
11072
|
const content = typeof rec6.content === "string" ? rec6.content : null;
|
|
11073
|
-
if (!
|
|
11074
|
-
const entry = { path:
|
|
11073
|
+
if (!path111 || content == null) return null;
|
|
11074
|
+
const entry = { path: path111, content };
|
|
11075
11075
|
if (typeof rec6.mtimeMs === "number") entry.mtimeMs = rec6.mtimeMs;
|
|
11076
11076
|
return entry;
|
|
11077
11077
|
}).filter((m3) => m3 !== null);
|
|
@@ -11806,8 +11806,8 @@ var require_req = __commonJS({
|
|
|
11806
11806
|
if (req.originalUrl) {
|
|
11807
11807
|
_req.url = req.originalUrl;
|
|
11808
11808
|
} else {
|
|
11809
|
-
const
|
|
11810
|
-
_req.url = typeof
|
|
11809
|
+
const path111 = req.path;
|
|
11810
|
+
_req.url = typeof path111 === "string" ? path111 : req.url ? req.url.path || req.url : void 0;
|
|
11811
11811
|
}
|
|
11812
11812
|
if (req.query) {
|
|
11813
11813
|
_req.query = req.query;
|
|
@@ -11972,14 +11972,14 @@ var require_redact = __commonJS({
|
|
|
11972
11972
|
}
|
|
11973
11973
|
return obj;
|
|
11974
11974
|
}
|
|
11975
|
-
function parsePath(
|
|
11975
|
+
function parsePath(path111) {
|
|
11976
11976
|
const parts = [];
|
|
11977
11977
|
let current = "";
|
|
11978
11978
|
let inBrackets = false;
|
|
11979
11979
|
let inQuotes = false;
|
|
11980
11980
|
let quoteChar = "";
|
|
11981
|
-
for (let i2 = 0; i2 <
|
|
11982
|
-
const char =
|
|
11981
|
+
for (let i2 = 0; i2 < path111.length; i2++) {
|
|
11982
|
+
const char = path111[i2];
|
|
11983
11983
|
if (!inBrackets && char === ".") {
|
|
11984
11984
|
if (current) {
|
|
11985
11985
|
parts.push(current);
|
|
@@ -12110,10 +12110,10 @@ var require_redact = __commonJS({
|
|
|
12110
12110
|
return current;
|
|
12111
12111
|
}
|
|
12112
12112
|
function redactPaths(obj, paths, censor, remove = false) {
|
|
12113
|
-
for (const
|
|
12114
|
-
const parts = parsePath(
|
|
12113
|
+
for (const path111 of paths) {
|
|
12114
|
+
const parts = parsePath(path111);
|
|
12115
12115
|
if (parts.includes("*")) {
|
|
12116
|
-
redactWildcardPath(obj, parts, censor,
|
|
12116
|
+
redactWildcardPath(obj, parts, censor, path111, remove);
|
|
12117
12117
|
} else {
|
|
12118
12118
|
if (remove) {
|
|
12119
12119
|
removeKey(obj, parts);
|
|
@@ -12198,8 +12198,8 @@ var require_redact = __commonJS({
|
|
|
12198
12198
|
}
|
|
12199
12199
|
} else {
|
|
12200
12200
|
if (afterWildcard.includes("*")) {
|
|
12201
|
-
const wrappedCensor = typeof censor === "function" ? (value,
|
|
12202
|
-
const fullPath = [...pathArray.slice(0, pathLength), ...
|
|
12201
|
+
const wrappedCensor = typeof censor === "function" ? (value, path111) => {
|
|
12202
|
+
const fullPath = [...pathArray.slice(0, pathLength), ...path111];
|
|
12203
12203
|
return censor(value, fullPath);
|
|
12204
12204
|
} : censor;
|
|
12205
12205
|
redactWildcardPath(current, afterWildcard, wrappedCensor, originalPath, remove);
|
|
@@ -12234,8 +12234,8 @@ var require_redact = __commonJS({
|
|
|
12234
12234
|
return null;
|
|
12235
12235
|
}
|
|
12236
12236
|
const pathStructure = /* @__PURE__ */ new Map();
|
|
12237
|
-
for (const
|
|
12238
|
-
const parts = parsePath(
|
|
12237
|
+
for (const path111 of pathsToClone) {
|
|
12238
|
+
const parts = parsePath(path111);
|
|
12239
12239
|
let current = pathStructure;
|
|
12240
12240
|
for (let i2 = 0; i2 < parts.length; i2++) {
|
|
12241
12241
|
const part = parts[i2];
|
|
@@ -12287,24 +12287,24 @@ var require_redact = __commonJS({
|
|
|
12287
12287
|
}
|
|
12288
12288
|
return cloneSelectively(obj, pathStructure);
|
|
12289
12289
|
}
|
|
12290
|
-
function validatePath(
|
|
12291
|
-
if (typeof
|
|
12290
|
+
function validatePath(path111) {
|
|
12291
|
+
if (typeof path111 !== "string") {
|
|
12292
12292
|
throw new Error("Paths must be (non-empty) strings");
|
|
12293
12293
|
}
|
|
12294
|
-
if (
|
|
12294
|
+
if (path111 === "") {
|
|
12295
12295
|
throw new Error("Invalid redaction path ()");
|
|
12296
12296
|
}
|
|
12297
|
-
if (
|
|
12298
|
-
throw new Error(`Invalid redaction path (${
|
|
12297
|
+
if (path111.includes("..")) {
|
|
12298
|
+
throw new Error(`Invalid redaction path (${path111})`);
|
|
12299
12299
|
}
|
|
12300
|
-
if (
|
|
12301
|
-
throw new Error(`Invalid redaction path (${
|
|
12300
|
+
if (path111.includes(",")) {
|
|
12301
|
+
throw new Error(`Invalid redaction path (${path111})`);
|
|
12302
12302
|
}
|
|
12303
12303
|
let bracketCount = 0;
|
|
12304
12304
|
let inQuotes = false;
|
|
12305
12305
|
let quoteChar = "";
|
|
12306
|
-
for (let i2 = 0; i2 <
|
|
12307
|
-
const char =
|
|
12306
|
+
for (let i2 = 0; i2 < path111.length; i2++) {
|
|
12307
|
+
const char = path111[i2];
|
|
12308
12308
|
if ((char === '"' || char === "'") && bracketCount > 0) {
|
|
12309
12309
|
if (!inQuotes) {
|
|
12310
12310
|
inQuotes = true;
|
|
@@ -12318,20 +12318,20 @@ var require_redact = __commonJS({
|
|
|
12318
12318
|
} else if (char === "]" && !inQuotes) {
|
|
12319
12319
|
bracketCount--;
|
|
12320
12320
|
if (bracketCount < 0) {
|
|
12321
|
-
throw new Error(`Invalid redaction path (${
|
|
12321
|
+
throw new Error(`Invalid redaction path (${path111})`);
|
|
12322
12322
|
}
|
|
12323
12323
|
}
|
|
12324
12324
|
}
|
|
12325
12325
|
if (bracketCount !== 0) {
|
|
12326
|
-
throw new Error(`Invalid redaction path (${
|
|
12326
|
+
throw new Error(`Invalid redaction path (${path111})`);
|
|
12327
12327
|
}
|
|
12328
12328
|
}
|
|
12329
12329
|
function validatePaths(paths) {
|
|
12330
12330
|
if (!Array.isArray(paths)) {
|
|
12331
12331
|
throw new TypeError("paths must be an array");
|
|
12332
12332
|
}
|
|
12333
|
-
for (const
|
|
12334
|
-
validatePath(
|
|
12333
|
+
for (const path111 of paths) {
|
|
12334
|
+
validatePath(path111);
|
|
12335
12335
|
}
|
|
12336
12336
|
}
|
|
12337
12337
|
function slowRedact(options = {}) {
|
|
@@ -12499,8 +12499,8 @@ var require_redaction = __commonJS({
|
|
|
12499
12499
|
if (shape[k3] === null) {
|
|
12500
12500
|
o2[k3] = (value) => topCensor(value, [k3]);
|
|
12501
12501
|
} else {
|
|
12502
|
-
const wrappedCensor = typeof censor === "function" ? (value,
|
|
12503
|
-
return censor(value, [k3, ...
|
|
12502
|
+
const wrappedCensor = typeof censor === "function" ? (value, path111) => {
|
|
12503
|
+
return censor(value, [k3, ...path111]);
|
|
12504
12504
|
} : censor;
|
|
12505
12505
|
o2[k3] = Redact({
|
|
12506
12506
|
paths: shape[k3],
|
|
@@ -12718,10 +12718,10 @@ var require_atomic_sleep = __commonJS({
|
|
|
12718
12718
|
var require_sonic_boom = __commonJS({
|
|
12719
12719
|
"../node_modules/.pnpm/sonic-boom@4.2.1/node_modules/sonic-boom/index.js"(exports2, module2) {
|
|
12720
12720
|
"use strict";
|
|
12721
|
-
var
|
|
12721
|
+
var fs98 = require("fs");
|
|
12722
12722
|
var EventEmitter2 = require("events");
|
|
12723
12723
|
var inherits = require("util").inherits;
|
|
12724
|
-
var
|
|
12724
|
+
var path111 = require("path");
|
|
12725
12725
|
var sleep2 = require_atomic_sleep();
|
|
12726
12726
|
var assert = require("assert");
|
|
12727
12727
|
var BUSY_WRITE_TIMEOUT = 100;
|
|
@@ -12775,20 +12775,20 @@ var require_sonic_boom = __commonJS({
|
|
|
12775
12775
|
const mode = sonic.mode;
|
|
12776
12776
|
if (sonic.sync) {
|
|
12777
12777
|
try {
|
|
12778
|
-
if (sonic.mkdir)
|
|
12779
|
-
const fd =
|
|
12778
|
+
if (sonic.mkdir) fs98.mkdirSync(path111.dirname(file), { recursive: true });
|
|
12779
|
+
const fd = fs98.openSync(file, flags, mode);
|
|
12780
12780
|
fileOpened(null, fd);
|
|
12781
12781
|
} catch (err) {
|
|
12782
12782
|
fileOpened(err);
|
|
12783
12783
|
throw err;
|
|
12784
12784
|
}
|
|
12785
12785
|
} else if (sonic.mkdir) {
|
|
12786
|
-
|
|
12786
|
+
fs98.mkdir(path111.dirname(file), { recursive: true }, (err) => {
|
|
12787
12787
|
if (err) return fileOpened(err);
|
|
12788
|
-
|
|
12788
|
+
fs98.open(file, flags, mode, fileOpened);
|
|
12789
12789
|
});
|
|
12790
12790
|
} else {
|
|
12791
|
-
|
|
12791
|
+
fs98.open(file, flags, mode, fileOpened);
|
|
12792
12792
|
}
|
|
12793
12793
|
}
|
|
12794
12794
|
function SonicBoom(opts) {
|
|
@@ -12829,8 +12829,8 @@ var require_sonic_boom = __commonJS({
|
|
|
12829
12829
|
this.flush = flushBuffer;
|
|
12830
12830
|
this.flushSync = flushBufferSync;
|
|
12831
12831
|
this._actualWrite = actualWriteBuffer;
|
|
12832
|
-
fsWriteSync = () =>
|
|
12833
|
-
fsWrite = () =>
|
|
12832
|
+
fsWriteSync = () => fs98.writeSync(this.fd, this._writingBuf);
|
|
12833
|
+
fsWrite = () => fs98.write(this.fd, this._writingBuf, this.release);
|
|
12834
12834
|
} else if (contentMode === void 0 || contentMode === kContentModeUtf8) {
|
|
12835
12835
|
this._writingBuf = "";
|
|
12836
12836
|
this.write = write;
|
|
@@ -12839,15 +12839,15 @@ var require_sonic_boom = __commonJS({
|
|
|
12839
12839
|
this._actualWrite = actualWrite;
|
|
12840
12840
|
fsWriteSync = () => {
|
|
12841
12841
|
if (Buffer.isBuffer(this._writingBuf)) {
|
|
12842
|
-
return
|
|
12842
|
+
return fs98.writeSync(this.fd, this._writingBuf);
|
|
12843
12843
|
}
|
|
12844
|
-
return
|
|
12844
|
+
return fs98.writeSync(this.fd, this._writingBuf, "utf8");
|
|
12845
12845
|
};
|
|
12846
12846
|
fsWrite = () => {
|
|
12847
12847
|
if (Buffer.isBuffer(this._writingBuf)) {
|
|
12848
|
-
return
|
|
12848
|
+
return fs98.write(this.fd, this._writingBuf, this.release);
|
|
12849
12849
|
}
|
|
12850
|
-
return
|
|
12850
|
+
return fs98.write(this.fd, this._writingBuf, "utf8", this.release);
|
|
12851
12851
|
};
|
|
12852
12852
|
} else {
|
|
12853
12853
|
throw new Error(`SonicBoom supports "${kContentModeUtf8}" and "${kContentModeBuffer}", but passed ${contentMode}`);
|
|
@@ -12904,7 +12904,7 @@ var require_sonic_boom = __commonJS({
|
|
|
12904
12904
|
}
|
|
12905
12905
|
}
|
|
12906
12906
|
if (this._fsync) {
|
|
12907
|
-
|
|
12907
|
+
fs98.fsyncSync(this.fd);
|
|
12908
12908
|
}
|
|
12909
12909
|
const len = this._len;
|
|
12910
12910
|
if (this._reopening) {
|
|
@@ -13018,7 +13018,7 @@ var require_sonic_boom = __commonJS({
|
|
|
13018
13018
|
const onDrain = () => {
|
|
13019
13019
|
if (!this._fsync) {
|
|
13020
13020
|
try {
|
|
13021
|
-
|
|
13021
|
+
fs98.fsync(this.fd, (err) => {
|
|
13022
13022
|
this._flushPending = false;
|
|
13023
13023
|
cb(err);
|
|
13024
13024
|
});
|
|
@@ -13120,7 +13120,7 @@ var require_sonic_boom = __commonJS({
|
|
|
13120
13120
|
const fd = this.fd;
|
|
13121
13121
|
this.once("ready", () => {
|
|
13122
13122
|
if (fd !== this.fd) {
|
|
13123
|
-
|
|
13123
|
+
fs98.close(fd, (err) => {
|
|
13124
13124
|
if (err) {
|
|
13125
13125
|
return this.emit("error", err);
|
|
13126
13126
|
}
|
|
@@ -13169,7 +13169,7 @@ var require_sonic_boom = __commonJS({
|
|
|
13169
13169
|
buf = this._bufs[0];
|
|
13170
13170
|
}
|
|
13171
13171
|
try {
|
|
13172
|
-
const n2 = Buffer.isBuffer(buf) ?
|
|
13172
|
+
const n2 = Buffer.isBuffer(buf) ? fs98.writeSync(this.fd, buf) : fs98.writeSync(this.fd, buf, "utf8");
|
|
13173
13173
|
const releasedBufObj = releaseWritingBuf(buf, this._len, n2);
|
|
13174
13174
|
buf = releasedBufObj.writingBuf;
|
|
13175
13175
|
this._len = releasedBufObj.len;
|
|
@@ -13185,7 +13185,7 @@ var require_sonic_boom = __commonJS({
|
|
|
13185
13185
|
}
|
|
13186
13186
|
}
|
|
13187
13187
|
try {
|
|
13188
|
-
|
|
13188
|
+
fs98.fsyncSync(this.fd);
|
|
13189
13189
|
} catch {
|
|
13190
13190
|
}
|
|
13191
13191
|
}
|
|
@@ -13206,7 +13206,7 @@ var require_sonic_boom = __commonJS({
|
|
|
13206
13206
|
buf = mergeBuf(this._bufs[0], this._lens[0]);
|
|
13207
13207
|
}
|
|
13208
13208
|
try {
|
|
13209
|
-
const n2 =
|
|
13209
|
+
const n2 = fs98.writeSync(this.fd, buf);
|
|
13210
13210
|
buf = buf.subarray(n2);
|
|
13211
13211
|
this._len = Math.max(this._len - n2, 0);
|
|
13212
13212
|
if (buf.length <= 0) {
|
|
@@ -13234,13 +13234,13 @@ var require_sonic_boom = __commonJS({
|
|
|
13234
13234
|
this._writingBuf = this._writingBuf.length ? this._writingBuf : this._bufs.shift() || "";
|
|
13235
13235
|
if (this.sync) {
|
|
13236
13236
|
try {
|
|
13237
|
-
const written = Buffer.isBuffer(this._writingBuf) ?
|
|
13237
|
+
const written = Buffer.isBuffer(this._writingBuf) ? fs98.writeSync(this.fd, this._writingBuf) : fs98.writeSync(this.fd, this._writingBuf, "utf8");
|
|
13238
13238
|
release2(null, written);
|
|
13239
13239
|
} catch (err) {
|
|
13240
13240
|
release2(err);
|
|
13241
13241
|
}
|
|
13242
13242
|
} else {
|
|
13243
|
-
|
|
13243
|
+
fs98.write(this.fd, this._writingBuf, release2);
|
|
13244
13244
|
}
|
|
13245
13245
|
}
|
|
13246
13246
|
function actualWriteBuffer() {
|
|
@@ -13249,7 +13249,7 @@ var require_sonic_boom = __commonJS({
|
|
|
13249
13249
|
this._writingBuf = this._writingBuf.length ? this._writingBuf : mergeBuf(this._bufs.shift(), this._lens.shift());
|
|
13250
13250
|
if (this.sync) {
|
|
13251
13251
|
try {
|
|
13252
|
-
const written =
|
|
13252
|
+
const written = fs98.writeSync(this.fd, this._writingBuf);
|
|
13253
13253
|
release2(null, written);
|
|
13254
13254
|
} catch (err) {
|
|
13255
13255
|
release2(err);
|
|
@@ -13258,7 +13258,7 @@ var require_sonic_boom = __commonJS({
|
|
|
13258
13258
|
if (kCopyBuffer) {
|
|
13259
13259
|
this._writingBuf = Buffer.from(this._writingBuf);
|
|
13260
13260
|
}
|
|
13261
|
-
|
|
13261
|
+
fs98.write(this.fd, this._writingBuf, release2);
|
|
13262
13262
|
}
|
|
13263
13263
|
}
|
|
13264
13264
|
function actualClose(sonic) {
|
|
@@ -13274,12 +13274,12 @@ var require_sonic_boom = __commonJS({
|
|
|
13274
13274
|
sonic._lens = [];
|
|
13275
13275
|
assert(typeof sonic.fd === "number", `sonic.fd must be a number, got ${typeof sonic.fd}`);
|
|
13276
13276
|
try {
|
|
13277
|
-
|
|
13277
|
+
fs98.fsync(sonic.fd, closeWrapped);
|
|
13278
13278
|
} catch {
|
|
13279
13279
|
}
|
|
13280
13280
|
function closeWrapped() {
|
|
13281
13281
|
if (sonic.fd !== 1 && sonic.fd !== 2) {
|
|
13282
|
-
|
|
13282
|
+
fs98.close(sonic.fd, done);
|
|
13283
13283
|
} else {
|
|
13284
13284
|
done();
|
|
13285
13285
|
}
|
|
@@ -15643,7 +15643,7 @@ var require_multistream = __commonJS({
|
|
|
15643
15643
|
var require_pino = __commonJS({
|
|
15644
15644
|
"../node_modules/.pnpm/pino@9.14.0/node_modules/pino/pino.js"(exports2, module2) {
|
|
15645
15645
|
"use strict";
|
|
15646
|
-
var
|
|
15646
|
+
var os38 = require("os");
|
|
15647
15647
|
var stdSerializers = require_pino_std_serializers();
|
|
15648
15648
|
var caller = require_caller();
|
|
15649
15649
|
var redaction = require_redaction();
|
|
@@ -15690,7 +15690,7 @@ var require_pino = __commonJS({
|
|
|
15690
15690
|
} = symbols;
|
|
15691
15691
|
var { epochTime, nullTime } = time;
|
|
15692
15692
|
var { pid } = process;
|
|
15693
|
-
var hostname =
|
|
15693
|
+
var hostname = os38.hostname();
|
|
15694
15694
|
var defaultErrorSerializer = stdSerializers.err;
|
|
15695
15695
|
var defaultOptions2 = {
|
|
15696
15696
|
level: "info",
|
|
@@ -16171,29 +16171,29 @@ function parseValueAt(s2, start) {
|
|
|
16171
16171
|
const bare = /^[^\s,\]}#]+/.exec(s2.slice(i2));
|
|
16172
16172
|
return bare ? { value: bare[0], end: i2 + bare[0].length } : null;
|
|
16173
16173
|
}
|
|
16174
|
-
function setPath(target,
|
|
16174
|
+
function setPath(target, path111, value) {
|
|
16175
16175
|
let node = target;
|
|
16176
|
-
for (const part of
|
|
16176
|
+
for (const part of path111.slice(0, -1)) {
|
|
16177
16177
|
const next = node[part];
|
|
16178
16178
|
if (!next || typeof next !== "object" || Array.isArray(next)) node[part] = {};
|
|
16179
16179
|
node = node[part];
|
|
16180
16180
|
}
|
|
16181
|
-
const last =
|
|
16181
|
+
const last = path111[path111.length - 1];
|
|
16182
16182
|
const existing = node[last];
|
|
16183
16183
|
if (existing && typeof existing === "object" && !Array.isArray(existing) && value && typeof value === "object" && !Array.isArray(value)) {
|
|
16184
16184
|
Object.assign(existing, value);
|
|
16185
16185
|
} else node[last] = value;
|
|
16186
16186
|
}
|
|
16187
|
-
function readTomlTable(text,
|
|
16187
|
+
function readTomlTable(text, path111) {
|
|
16188
16188
|
const result = {};
|
|
16189
16189
|
let found = false;
|
|
16190
|
-
const within = (full) => full.length >=
|
|
16190
|
+
const within = (full) => full.length >= path111.length && path111.every((part, i2) => full[i2] === part);
|
|
16191
16191
|
const lines = scanToml(text);
|
|
16192
16192
|
for (let index = 0; index < lines.length; index++) {
|
|
16193
16193
|
const line = lines[index];
|
|
16194
16194
|
if (line.kind === "header" && within(line.key)) {
|
|
16195
16195
|
found = true;
|
|
16196
|
-
if (line.key.length >
|
|
16196
|
+
if (line.key.length > path111.length) setPath(result, line.key.slice(path111.length), {});
|
|
16197
16197
|
continue;
|
|
16198
16198
|
}
|
|
16199
16199
|
if (line.kind !== "key") continue;
|
|
@@ -16205,9 +16205,9 @@ ${lines[++index].text}`;
|
|
|
16205
16205
|
const parsed = parseTomlValue(raw);
|
|
16206
16206
|
const value = parsed === void 0 ? UNREADABLE : parsed;
|
|
16207
16207
|
found = true;
|
|
16208
|
-
if (full.length ===
|
|
16208
|
+
if (full.length === path111.length) {
|
|
16209
16209
|
if (value && typeof value === "object" && !Array.isArray(value)) Object.assign(result, value);
|
|
16210
|
-
} else setPath(result, full.slice(
|
|
16210
|
+
} else setPath(result, full.slice(path111.length), value);
|
|
16211
16211
|
}
|
|
16212
16212
|
return found ? result : null;
|
|
16213
16213
|
}
|
|
@@ -16365,7 +16365,7 @@ var init_subscription_channels_apply = __esm({
|
|
|
16365
16365
|
import_node_path22 = __toESM(require("path"), 1);
|
|
16366
16366
|
init_codex_config_toml();
|
|
16367
16367
|
PROVIDER_ID = "cliproxyapi";
|
|
16368
|
-
isOwnProvider = (
|
|
16368
|
+
isOwnProvider = (path111) => path111[0] === "model_providers" && path111[1] === PROVIDER_ID;
|
|
16369
16369
|
resolveCodexHome2 = (codexHome) => codexHome || process.env.CODEX_HOME || import_node_path22.default.join(import_node_os11.default.homedir(), ".codex");
|
|
16370
16370
|
resolvePiAgentDir = (agentDir) => agentDir || process.env.PI_CODING_AGENT_DIR || import_node_path22.default.join(import_node_os11.default.homedir(), ".pi", "agent");
|
|
16371
16371
|
PI_SUBSCRIPTION_FILE = "cliproxyapi.json";
|
|
@@ -16744,10 +16744,10 @@ function parseAttachment(obj) {
|
|
|
16744
16744
|
const memories = raw.map((m3) => {
|
|
16745
16745
|
if (!m3 || typeof m3 !== "object") return null;
|
|
16746
16746
|
const rec6 = m3;
|
|
16747
|
-
const
|
|
16747
|
+
const path111 = typeof rec6.path === "string" ? rec6.path : null;
|
|
16748
16748
|
const content = typeof rec6.content === "string" ? rec6.content : null;
|
|
16749
|
-
if (!
|
|
16750
|
-
const out = { path:
|
|
16749
|
+
if (!path111 || content == null) return null;
|
|
16750
|
+
const out = { path: path111, content };
|
|
16751
16751
|
if (typeof rec6.mtimeMs === "number") out.mtimeMs = rec6.mtimeMs;
|
|
16752
16752
|
return out;
|
|
16753
16753
|
}).filter((m3) => m3 !== null);
|
|
@@ -34139,8 +34139,8 @@ var require_utils = __commonJS({
|
|
|
34139
34139
|
var result = transform[inputType][outputType](input);
|
|
34140
34140
|
return result;
|
|
34141
34141
|
};
|
|
34142
|
-
exports2.resolve = function(
|
|
34143
|
-
var parts =
|
|
34142
|
+
exports2.resolve = function(path111) {
|
|
34143
|
+
var parts = path111.split("/");
|
|
34144
34144
|
var result = [];
|
|
34145
34145
|
for (var index = 0; index < parts.length; index++) {
|
|
34146
34146
|
var part = parts[index];
|
|
@@ -39993,18 +39993,18 @@ var require_object = __commonJS({
|
|
|
39993
39993
|
var object = new ZipObject(name, zipObjectContent, o2);
|
|
39994
39994
|
this.files[name] = object;
|
|
39995
39995
|
};
|
|
39996
|
-
var parentFolder = function(
|
|
39997
|
-
if (
|
|
39998
|
-
|
|
39996
|
+
var parentFolder = function(path111) {
|
|
39997
|
+
if (path111.slice(-1) === "/") {
|
|
39998
|
+
path111 = path111.substring(0, path111.length - 1);
|
|
39999
39999
|
}
|
|
40000
|
-
var lastSlash =
|
|
40001
|
-
return lastSlash > 0 ?
|
|
40000
|
+
var lastSlash = path111.lastIndexOf("/");
|
|
40001
|
+
return lastSlash > 0 ? path111.substring(0, lastSlash) : "";
|
|
40002
40002
|
};
|
|
40003
|
-
var forceTrailingSlash = function(
|
|
40004
|
-
if (
|
|
40005
|
-
|
|
40003
|
+
var forceTrailingSlash = function(path111) {
|
|
40004
|
+
if (path111.slice(-1) !== "/") {
|
|
40005
|
+
path111 += "/";
|
|
40006
40006
|
}
|
|
40007
|
-
return
|
|
40007
|
+
return path111;
|
|
40008
40008
|
};
|
|
40009
40009
|
var folderAdd = function(name, createFolders) {
|
|
40010
40010
|
createFolders = typeof createFolders !== "undefined" ? createFolders : defaults.createFolders;
|
|
@@ -44622,7 +44622,7 @@ var require_websocket_server = __commonJS({
|
|
|
44622
44622
|
// src/run-case/recorder.ts
|
|
44623
44623
|
function startRunCaseRecorder(opts) {
|
|
44624
44624
|
const now = opts.now ?? Date.now;
|
|
44625
|
-
const dir =
|
|
44625
|
+
const dir = import_node_path90.default.dirname(opts.recordPath);
|
|
44626
44626
|
let stream = null;
|
|
44627
44627
|
let closing = false;
|
|
44628
44628
|
let closedSettled = false;
|
|
@@ -44636,8 +44636,8 @@ function startRunCaseRecorder(opts) {
|
|
|
44636
44636
|
});
|
|
44637
44637
|
const ensureStream = () => {
|
|
44638
44638
|
if (stream) return stream;
|
|
44639
|
-
|
|
44640
|
-
stream =
|
|
44639
|
+
import_node_fs69.default.mkdirSync(dir, { recursive: true });
|
|
44640
|
+
stream = import_node_fs69.default.createWriteStream(opts.recordPath, { flags: "a" });
|
|
44641
44641
|
stream.on("close", () => closedResolve());
|
|
44642
44642
|
return stream;
|
|
44643
44643
|
};
|
|
@@ -44662,12 +44662,12 @@ function startRunCaseRecorder(opts) {
|
|
|
44662
44662
|
};
|
|
44663
44663
|
return { tap, close, closed };
|
|
44664
44664
|
}
|
|
44665
|
-
var
|
|
44665
|
+
var import_node_fs69, import_node_path90;
|
|
44666
44666
|
var init_recorder = __esm({
|
|
44667
44667
|
"src/run-case/recorder.ts"() {
|
|
44668
44668
|
"use strict";
|
|
44669
|
-
|
|
44670
|
-
|
|
44669
|
+
import_node_fs69 = __toESM(require("fs"), 1);
|
|
44670
|
+
import_node_path90 = __toESM(require("path"), 1);
|
|
44671
44671
|
}
|
|
44672
44672
|
});
|
|
44673
44673
|
|
|
@@ -44710,7 +44710,7 @@ var init_wire = __esm({
|
|
|
44710
44710
|
// src/run-case/controller.ts
|
|
44711
44711
|
async function runController(opts) {
|
|
44712
44712
|
const now = opts.now ?? Date.now;
|
|
44713
|
-
const cwd = opts.cwd ?? (0,
|
|
44713
|
+
const cwd = opts.cwd ?? (0, import_node_fs70.mkdtempSync)(import_node_path91.default.join(import_node_os34.default.tmpdir(), "clawd-runcase-"));
|
|
44714
44714
|
const ownsCwd = opts.cwd === void 0;
|
|
44715
44715
|
const recorder = startRunCaseRecorder({ recordPath: opts.record, now });
|
|
44716
44716
|
const spawnCtx = { cwd };
|
|
@@ -44871,19 +44871,19 @@ async function runController(opts) {
|
|
|
44871
44871
|
if (sigintHandler) process.off("SIGINT", sigintHandler);
|
|
44872
44872
|
if (ownsCwd) {
|
|
44873
44873
|
try {
|
|
44874
|
-
(0,
|
|
44874
|
+
(0, import_node_fs70.rmSync)(cwd, { recursive: true, force: true });
|
|
44875
44875
|
} catch {
|
|
44876
44876
|
}
|
|
44877
44877
|
}
|
|
44878
44878
|
return exitCode ?? 0;
|
|
44879
44879
|
}
|
|
44880
|
-
var
|
|
44880
|
+
var import_node_fs70, import_node_os34, import_node_path91;
|
|
44881
44881
|
var init_controller = __esm({
|
|
44882
44882
|
"src/run-case/controller.ts"() {
|
|
44883
44883
|
"use strict";
|
|
44884
|
-
|
|
44885
|
-
|
|
44886
|
-
|
|
44884
|
+
import_node_fs70 = require("fs");
|
|
44885
|
+
import_node_os34 = __toESM(require("os"), 1);
|
|
44886
|
+
import_node_path91 = __toESM(require("path"), 1);
|
|
44887
44887
|
init_claude();
|
|
44888
44888
|
init_stdout_splitter();
|
|
44889
44889
|
init_permission_stdio();
|
|
@@ -46595,9 +46595,9 @@ function requireEnvironmentIdentity(stores, environment) {
|
|
|
46595
46595
|
}
|
|
46596
46596
|
|
|
46597
46597
|
// src/index.ts
|
|
46598
|
-
var
|
|
46599
|
-
var
|
|
46600
|
-
var
|
|
46598
|
+
var import_node_path89 = __toESM(require("path"), 1);
|
|
46599
|
+
var import_node_fs68 = __toESM(require("fs"), 1);
|
|
46600
|
+
var import_node_os33 = __toESM(require("os"), 1);
|
|
46601
46601
|
var import_node_crypto30 = require("crypto");
|
|
46602
46602
|
var import_node_url6 = require("url");
|
|
46603
46603
|
|
|
@@ -53282,9 +53282,9 @@ var CentralClientError = class extends Error {
|
|
|
53282
53282
|
cause;
|
|
53283
53283
|
status;
|
|
53284
53284
|
};
|
|
53285
|
-
async function centralRequest(opts,
|
|
53285
|
+
async function centralRequest(opts, path111, init) {
|
|
53286
53286
|
const f2 = opts.fetchImpl ?? globalThis.fetch;
|
|
53287
|
-
const url = `${opts.api.replace(/\/+$/, "")}${
|
|
53287
|
+
const url = `${opts.api.replace(/\/+$/, "")}${path111}`;
|
|
53288
53288
|
const ctrl = new AbortController();
|
|
53289
53289
|
const timer = setTimeout(() => ctrl.abort(), opts.timeoutMs ?? 15e3);
|
|
53290
53290
|
let res;
|
|
@@ -53806,9 +53806,37 @@ function createVisitorStore(opts) {
|
|
|
53806
53806
|
// src/index.ts
|
|
53807
53807
|
init_claude();
|
|
53808
53808
|
|
|
53809
|
+
// src/tools/codex-model-catalog.ts
|
|
53810
|
+
var import_node_child_process5 = require("child_process");
|
|
53811
|
+
var import_node_fs24 = __toESM(require("fs"), 1);
|
|
53812
|
+
var import_node_os12 = __toESM(require("os"), 1);
|
|
53813
|
+
var import_node_path23 = __toESM(require("path"), 1);
|
|
53814
|
+
var defaultValidate = (cmd, catalogFlag, env) => {
|
|
53815
|
+
const result = (0, import_node_child_process5.spawnSync)(cmd, [...catalogFlag, "debug", "models"], { env, stdio: "ignore", timeout: 5e3 });
|
|
53816
|
+
return result.status === 0;
|
|
53817
|
+
};
|
|
53818
|
+
var verdicts = /* @__PURE__ */ new Map();
|
|
53819
|
+
function codexModelCatalogCliArgs(cmd, env, validate = defaultValidate) {
|
|
53820
|
+
const file = import_node_path23.default.join(env.CODEX_HOME || import_node_path23.default.join(import_node_os12.default.homedir(), ".codex"), "models_cache.json");
|
|
53821
|
+
let key;
|
|
53822
|
+
try {
|
|
53823
|
+
const stat = import_node_fs24.default.statSync(file);
|
|
53824
|
+
key = `${cmd}\0${file}\0${stat.mtimeMs}\0${stat.size}`;
|
|
53825
|
+
} catch {
|
|
53826
|
+
return [];
|
|
53827
|
+
}
|
|
53828
|
+
const flag = ["-c", `model_catalog_json=${JSON.stringify(file)}`];
|
|
53829
|
+
let ok = verdicts.get(key);
|
|
53830
|
+
if (ok === void 0) {
|
|
53831
|
+
ok = validate(cmd, flag, env);
|
|
53832
|
+
verdicts.set(key, ok);
|
|
53833
|
+
}
|
|
53834
|
+
return ok ? flag : [];
|
|
53835
|
+
}
|
|
53836
|
+
|
|
53809
53837
|
// src/tools/codex-session.ts
|
|
53810
|
-
var
|
|
53811
|
-
var
|
|
53838
|
+
var import_node_child_process7 = require("child_process");
|
|
53839
|
+
var import_node_path27 = __toESM(require("path"), 1);
|
|
53812
53840
|
|
|
53813
53841
|
// src/tools/codex-app-server-events.ts
|
|
53814
53842
|
function translateNotification(method, params) {
|
|
@@ -54243,8 +54271,8 @@ function turnStartInput(text, resolveImage) {
|
|
|
54243
54271
|
const items = [];
|
|
54244
54272
|
let leftover = text;
|
|
54245
54273
|
for (const m3 of text.matchAll(SKILL_RE)) {
|
|
54246
|
-
const [marker, name,
|
|
54247
|
-
items.push({ type: "skill", name, path:
|
|
54274
|
+
const [marker, name, path111] = m3;
|
|
54275
|
+
items.push({ type: "skill", name, path: path111 });
|
|
54248
54276
|
leftover = leftover.replace(marker, "");
|
|
54249
54277
|
}
|
|
54250
54278
|
for (const m3 of text.matchAll(ATTACHMENT_RE2)) {
|
|
@@ -54431,17 +54459,17 @@ function stringValue2(value) {
|
|
|
54431
54459
|
}
|
|
54432
54460
|
|
|
54433
54461
|
// src/tools/mcp-server-defs.ts
|
|
54434
|
-
var
|
|
54435
|
-
var
|
|
54462
|
+
var import_node_fs25 = __toESM(require("fs"), 1);
|
|
54463
|
+
var import_node_path24 = __toESM(require("path"), 1);
|
|
54436
54464
|
var HTTP_TYPES = /* @__PURE__ */ new Set(["http", "sse", "streamable_http", "streamable-http"]);
|
|
54437
54465
|
function loadMcpServerDefs(args) {
|
|
54438
54466
|
const out = [];
|
|
54439
54467
|
const seen = /* @__PURE__ */ new Set();
|
|
54440
|
-
const sources = [...args.mcpConfigPaths,
|
|
54468
|
+
const sources = [...args.mcpConfigPaths, import_node_path24.default.join(args.cwd, ".mcp.json")];
|
|
54441
54469
|
for (const file of sources) {
|
|
54442
54470
|
let parsed;
|
|
54443
54471
|
try {
|
|
54444
|
-
parsed = JSON.parse(
|
|
54472
|
+
parsed = JSON.parse(import_node_fs25.default.readFileSync(file, "utf8"));
|
|
54445
54473
|
} catch (e) {
|
|
54446
54474
|
const code = e.code;
|
|
54447
54475
|
if (code !== "ENOENT") {
|
|
@@ -54505,18 +54533,18 @@ function loadMcpServerDefs(args) {
|
|
|
54505
54533
|
}
|
|
54506
54534
|
|
|
54507
54535
|
// src/tools/codex-agents-config.ts
|
|
54508
|
-
var
|
|
54509
|
-
var
|
|
54536
|
+
var import_node_fs26 = __toESM(require("fs"), 1);
|
|
54537
|
+
var import_node_path25 = __toESM(require("path"), 1);
|
|
54510
54538
|
var AGENTS_SECTION = /^\[agents\][^\n]*\n([\s\S]*?)(?=^\[|$(?![\s\S]))/m;
|
|
54511
54539
|
function readKey(section, key) {
|
|
54512
54540
|
const m3 = new RegExp(`^[ \\t]*${key}[ \\t]*=[ \\t]*(["'])(.*?)\\1`, "m").exec(section);
|
|
54513
54541
|
return m3?.[2].trim() || void 0;
|
|
54514
54542
|
}
|
|
54515
54543
|
function loadCodexAgentsConfig(args) {
|
|
54516
|
-
const file =
|
|
54544
|
+
const file = import_node_path25.default.join(args.cwd, ".codex", "config.toml");
|
|
54517
54545
|
let text;
|
|
54518
54546
|
try {
|
|
54519
|
-
text =
|
|
54547
|
+
text = import_node_fs26.default.readFileSync(file, "utf8");
|
|
54520
54548
|
} catch (e) {
|
|
54521
54549
|
const code = e.code;
|
|
54522
54550
|
if (code !== "ENOENT") {
|
|
@@ -54534,13 +54562,13 @@ function loadCodexAgentsConfig(args) {
|
|
|
54534
54562
|
}
|
|
54535
54563
|
|
|
54536
54564
|
// src/tools/codex-features.ts
|
|
54537
|
-
var
|
|
54565
|
+
var import_node_child_process6 = require("child_process");
|
|
54538
54566
|
var cachedNetworkProxy;
|
|
54539
54567
|
function hasNetworkProxyFeature(deps = {}) {
|
|
54540
54568
|
if (cachedNetworkProxy !== void 0) return cachedNetworkProxy;
|
|
54541
54569
|
try {
|
|
54542
54570
|
const cmd = codexCommand();
|
|
54543
|
-
const out = deps.execOverride ? deps.execOverride() : (0,
|
|
54571
|
+
const out = deps.execOverride ? deps.execOverride() : (0, import_node_child_process6.execFileSync)(cmd, ["features", "list"], {
|
|
54544
54572
|
env: codexEnvironment(cmd),
|
|
54545
54573
|
encoding: "utf8",
|
|
54546
54574
|
timeout: 3e3
|
|
@@ -54557,7 +54585,7 @@ function warmCodexFeatureCache() {
|
|
|
54557
54585
|
if (cachedNetworkProxy !== void 0 || warming) return;
|
|
54558
54586
|
warming = true;
|
|
54559
54587
|
const cmd = codexCommand();
|
|
54560
|
-
(0,
|
|
54588
|
+
(0, import_node_child_process6.execFile)(
|
|
54561
54589
|
cmd,
|
|
54562
54590
|
["features", "list"],
|
|
54563
54591
|
{ encoding: "utf8", timeout: 3e3, env: codexEnvironment(cmd) },
|
|
@@ -54575,7 +54603,7 @@ function warmCodexFeatureCache() {
|
|
|
54575
54603
|
}
|
|
54576
54604
|
|
|
54577
54605
|
// src/attachment/mime.ts
|
|
54578
|
-
var
|
|
54606
|
+
var import_node_path26 = __toESM(require("path"), 1);
|
|
54579
54607
|
var TEXT_PLAIN = "text/plain; charset=utf-8";
|
|
54580
54608
|
var EXT_TO_NATIVE_MIME = {
|
|
54581
54609
|
".png": "image/png",
|
|
@@ -54674,7 +54702,7 @@ var TEXT_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
|
54674
54702
|
".mk"
|
|
54675
54703
|
]);
|
|
54676
54704
|
function lookupMime(filePathOrName) {
|
|
54677
|
-
const ext =
|
|
54705
|
+
const ext = import_node_path26.default.extname(filePathOrName).toLowerCase();
|
|
54678
54706
|
if (EXT_TO_NATIVE_MIME[ext]) return EXT_TO_NATIVE_MIME[ext];
|
|
54679
54707
|
if (TEXT_EXTENSIONS.has(ext)) return TEXT_PLAIN;
|
|
54680
54708
|
return "application/octet-stream";
|
|
@@ -54711,7 +54739,8 @@ function createCodexSession(ctx, sink, deps = {}) {
|
|
|
54711
54739
|
...resolvedCodexHome ? { CODEX_HOME: resolvedCodexHome } : {},
|
|
54712
54740
|
...ctx.env
|
|
54713
54741
|
});
|
|
54714
|
-
|
|
54742
|
+
args.unshift(...codexModelCatalogCliArgs(cmd, env, deps.validateModelCatalog));
|
|
54743
|
+
const proc = deps.spawnOverride ? deps.spawnOverride(cmd, args, ctx.cwd, env) : (0, import_node_child_process7.spawn)(cmd, args, { cwd: ctx.cwd, env, stdio: ["pipe", "pipe", "pipe"] });
|
|
54715
54744
|
const alive = () => proc.exitCode === null && proc.signalCode === null;
|
|
54716
54745
|
const driver = driveCodexThread({
|
|
54717
54746
|
ctx,
|
|
@@ -54721,7 +54750,7 @@ function createCodexSession(ctx, sink, deps = {}) {
|
|
|
54721
54750
|
threadParams: threadStartParams(ctx),
|
|
54722
54751
|
// persona 惯例装在 <cwd>/.claude/skills/,经 extraRoots 注入 discovery
|
|
54723
54752
|
// (skills:list RPC 侧 codex-skills.ts 同款注入,两处保持一致)。
|
|
54724
|
-
skillsExtraRoots: [
|
|
54753
|
+
skillsExtraRoots: [import_node_path27.default.join(ctx.cwd, ".claude", "skills")],
|
|
54725
54754
|
// 附件图片:验签认出本机 absPath → localImage,codex 自己读文件(TUI 拖图 / SDK local_image 同一条路)。
|
|
54726
54755
|
// 0.145 起 http(s) URL 在 turn/start 入口被拒,不能再按 url 传(codex-app-server-params.ts 头注释)。
|
|
54727
54756
|
// 与云上 cloudImageInput 同一道 mime 门:非图片(签过的 .md 之类)留文本,别让 codex 读到一半才炸。
|
|
@@ -54750,12 +54779,12 @@ function createCodexSession(ctx, sink, deps = {}) {
|
|
|
54750
54779
|
}
|
|
54751
54780
|
|
|
54752
54781
|
// src/tools/codex-app-server-query.ts
|
|
54753
|
-
var
|
|
54782
|
+
var import_node_child_process8 = require("child_process");
|
|
54754
54783
|
var DEFAULT_CODEX_QUERY_TIMEOUT_MS = 8e3;
|
|
54755
54784
|
async function withCodexAppServerClient(cwd, operation, run, deps = {}) {
|
|
54756
54785
|
const cmd = codexCommand();
|
|
54757
54786
|
const args = ["app-server", "--listen", "stdio://"];
|
|
54758
|
-
const proc = deps.spawnOverride ? deps.spawnOverride(cmd, args, cwd) : (0,
|
|
54787
|
+
const proc = deps.spawnOverride ? deps.spawnOverride(cmd, args, cwd) : (0, import_node_child_process8.spawn)(cmd, args, { cwd, env: codexEnvironment(cmd), stdio: ["pipe", "pipe", "pipe"] });
|
|
54759
54788
|
const client = new CodexAppServerClient(stdioLineStream(proc), {});
|
|
54760
54789
|
const timeoutMs = deps.timeoutMs ?? DEFAULT_CODEX_QUERY_TIMEOUT_MS;
|
|
54761
54790
|
let timer;
|
|
@@ -55057,9 +55086,9 @@ var CodexAdapter = class {
|
|
|
55057
55086
|
|
|
55058
55087
|
// src/tools/claude-tui.ts
|
|
55059
55088
|
var import_node_crypto9 = require("crypto");
|
|
55060
|
-
var
|
|
55061
|
-
var
|
|
55062
|
-
var
|
|
55089
|
+
var import_node_fs27 = __toESM(require("fs"), 1);
|
|
55090
|
+
var import_node_os13 = __toESM(require("os"), 1);
|
|
55091
|
+
var import_node_path28 = __toESM(require("path"), 1);
|
|
55063
55092
|
var import_headless = __toESM(require_xterm_headless(), 1);
|
|
55064
55093
|
|
|
55065
55094
|
// ../node_modules/.pnpm/@xterm+addon-serialize@0.14.0/node_modules/@xterm/addon-serialize/lib/addon-serialize.mjs
|
|
@@ -56267,10 +56296,10 @@ function buildTuiSpawnArgs(ctx, isResume = false) {
|
|
|
56267
56296
|
}
|
|
56268
56297
|
function jsonlExistsForCtx(ctx) {
|
|
56269
56298
|
if (!ctx.toolSessionId) return false;
|
|
56270
|
-
const home =
|
|
56271
|
-
const file =
|
|
56299
|
+
const home = import_node_os13.default.homedir();
|
|
56300
|
+
const file = import_node_path28.default.join(home, ".claude", "projects", cwdToHashDir(ctx.cwd), `${ctx.toolSessionId}.jsonl`);
|
|
56272
56301
|
try {
|
|
56273
|
-
return
|
|
56302
|
+
return import_node_fs27.default.statSync(file).isFile();
|
|
56274
56303
|
} catch {
|
|
56275
56304
|
return false;
|
|
56276
56305
|
}
|
|
@@ -56353,7 +56382,7 @@ var PersonaDispatchManager = class {
|
|
|
56353
56382
|
|
|
56354
56383
|
// src/dispatch/store.ts
|
|
56355
56384
|
var import_promises = __toESM(require("fs/promises"), 1);
|
|
56356
|
-
var
|
|
56385
|
+
var import_node_path29 = __toESM(require("path"), 1);
|
|
56357
56386
|
|
|
56358
56387
|
// src/shift/constants.ts
|
|
56359
56388
|
var MAX_RUNS_PER_SHIFT = 30;
|
|
@@ -56391,7 +56420,7 @@ function createDispatchStore(deps) {
|
|
|
56391
56420
|
flushTimer = null;
|
|
56392
56421
|
}
|
|
56393
56422
|
const content = { version: 1, records };
|
|
56394
|
-
await import_promises.default.mkdir(
|
|
56423
|
+
await import_promises.default.mkdir(import_node_path29.default.dirname(deps.filePath), { recursive: true });
|
|
56395
56424
|
const tmp = `${deps.filePath}.tmp-${deps.now()}-${Math.floor(Math.random() * 1e6)}`;
|
|
56396
56425
|
await import_promises.default.writeFile(tmp, JSON.stringify(content, null, 2), "utf8");
|
|
56397
56426
|
await import_promises.default.rename(tmp, deps.filePath);
|
|
@@ -56460,7 +56489,7 @@ function createDispatchStore(deps) {
|
|
|
56460
56489
|
|
|
56461
56490
|
// src/channel/json-store.ts
|
|
56462
56491
|
var import_promises2 = __toESM(require("fs/promises"), 1);
|
|
56463
|
-
var
|
|
56492
|
+
var import_node_path30 = __toESM(require("path"), 1);
|
|
56464
56493
|
function createJsonStore(deps) {
|
|
56465
56494
|
let items = [];
|
|
56466
56495
|
let flushTimer = null;
|
|
@@ -56471,7 +56500,7 @@ function createJsonStore(deps) {
|
|
|
56471
56500
|
flushTimer = null;
|
|
56472
56501
|
}
|
|
56473
56502
|
const content = { version: version2, [deps.key]: items };
|
|
56474
|
-
await import_promises2.default.mkdir(
|
|
56503
|
+
await import_promises2.default.mkdir(import_node_path30.default.dirname(deps.filePath), { recursive: true });
|
|
56475
56504
|
const tmp = `${deps.filePath}.tmp-${deps.now()}-${Math.floor(Math.random() * 1e6)}`;
|
|
56476
56505
|
await import_promises2.default.writeFile(tmp, JSON.stringify(content, null, 2), "utf8");
|
|
56477
56506
|
await import_promises2.default.rename(tmp, deps.filePath);
|
|
@@ -56742,10 +56771,10 @@ function createTopicStore(deps) {
|
|
|
56742
56771
|
}
|
|
56743
56772
|
|
|
56744
56773
|
// src/dispatch/mcp-config.ts
|
|
56745
|
-
var
|
|
56746
|
-
var
|
|
56774
|
+
var import_node_fs28 = __toESM(require("fs"), 1);
|
|
56775
|
+
var import_node_path31 = __toESM(require("path"), 1);
|
|
56747
56776
|
function dispatchMcpConfigPath(dataDir) {
|
|
56748
|
-
return
|
|
56777
|
+
return import_node_path31.default.join(dataDir, "dispatch.mcp.json");
|
|
56749
56778
|
}
|
|
56750
56779
|
function writeDispatchMcpConfig(args) {
|
|
56751
56780
|
const cfgPath = dispatchMcpConfigPath(args.dataDir);
|
|
@@ -56764,16 +56793,16 @@ function writeDispatchMcpConfig(args) {
|
|
|
56764
56793
|
}
|
|
56765
56794
|
}
|
|
56766
56795
|
};
|
|
56767
|
-
|
|
56768
|
-
|
|
56796
|
+
import_node_fs28.default.mkdirSync(args.dataDir, { recursive: true });
|
|
56797
|
+
import_node_fs28.default.writeFileSync(cfgPath, JSON.stringify(content, null, 2), "utf8");
|
|
56769
56798
|
return cfgPath;
|
|
56770
56799
|
}
|
|
56771
56800
|
|
|
56772
56801
|
// src/ticket/mcp-config.ts
|
|
56773
|
-
var
|
|
56774
|
-
var
|
|
56802
|
+
var import_node_fs29 = __toESM(require("fs"), 1);
|
|
56803
|
+
var import_node_path32 = __toESM(require("path"), 1);
|
|
56775
56804
|
function ticketMcpConfigPath(dataDir) {
|
|
56776
|
-
return
|
|
56805
|
+
return import_node_path32.default.join(dataDir, "ticket.mcp.json");
|
|
56777
56806
|
}
|
|
56778
56807
|
function writeTicketMcpConfig(args) {
|
|
56779
56808
|
const cfgPath = ticketMcpConfigPath(args.dataDir);
|
|
@@ -56795,16 +56824,16 @@ function writeTicketMcpConfig(args) {
|
|
|
56795
56824
|
}
|
|
56796
56825
|
}
|
|
56797
56826
|
};
|
|
56798
|
-
|
|
56799
|
-
|
|
56827
|
+
import_node_fs29.default.mkdirSync(args.dataDir, { recursive: true });
|
|
56828
|
+
import_node_fs29.default.writeFileSync(cfgPath, JSON.stringify(content, null, 2), "utf8");
|
|
56800
56829
|
return cfgPath;
|
|
56801
56830
|
}
|
|
56802
56831
|
|
|
56803
56832
|
// src/shift/mcp-config.ts
|
|
56804
|
-
var
|
|
56805
|
-
var
|
|
56833
|
+
var import_node_fs30 = __toESM(require("fs"), 1);
|
|
56834
|
+
var import_node_path33 = __toESM(require("path"), 1);
|
|
56806
56835
|
function shiftMcpConfigPath(dataDir) {
|
|
56807
|
-
return
|
|
56836
|
+
return import_node_path33.default.join(dataDir, "shift.mcp.json");
|
|
56808
56837
|
}
|
|
56809
56838
|
async function writeShiftMcpConfig(args) {
|
|
56810
56839
|
const cfgPath = shiftMcpConfigPath(args.dataDir);
|
|
@@ -56823,16 +56852,16 @@ async function writeShiftMcpConfig(args) {
|
|
|
56823
56852
|
}
|
|
56824
56853
|
}
|
|
56825
56854
|
};
|
|
56826
|
-
await
|
|
56827
|
-
await
|
|
56855
|
+
await import_node_fs30.default.promises.mkdir(args.dataDir, { recursive: true });
|
|
56856
|
+
await import_node_fs30.default.promises.writeFile(cfgPath, JSON.stringify(content, null, 2), "utf8");
|
|
56828
56857
|
return cfgPath;
|
|
56829
56858
|
}
|
|
56830
56859
|
|
|
56831
56860
|
// src/inbox/mcp-config.ts
|
|
56832
|
-
var
|
|
56833
|
-
var
|
|
56861
|
+
var import_node_fs31 = __toESM(require("fs"), 1);
|
|
56862
|
+
var import_node_path34 = __toESM(require("path"), 1);
|
|
56834
56863
|
function inboxMcpConfigPath(dataDir) {
|
|
56835
|
-
return
|
|
56864
|
+
return import_node_path34.default.join(dataDir, "inbox.mcp.json");
|
|
56836
56865
|
}
|
|
56837
56866
|
async function writeInboxMcpConfig(args) {
|
|
56838
56867
|
const cfgPath = inboxMcpConfigPath(args.dataDir);
|
|
@@ -56851,16 +56880,16 @@ async function writeInboxMcpConfig(args) {
|
|
|
56851
56880
|
}
|
|
56852
56881
|
}
|
|
56853
56882
|
};
|
|
56854
|
-
await
|
|
56855
|
-
await
|
|
56883
|
+
await import_node_fs31.default.promises.mkdir(args.dataDir, { recursive: true });
|
|
56884
|
+
await import_node_fs31.default.promises.writeFile(cfgPath, JSON.stringify(content, null, 2), "utf8");
|
|
56856
56885
|
return cfgPath;
|
|
56857
56886
|
}
|
|
56858
56887
|
|
|
56859
56888
|
// src/peer-ops/mcp-config.ts
|
|
56860
|
-
var
|
|
56861
|
-
var
|
|
56889
|
+
var import_node_fs32 = __toESM(require("fs"), 1);
|
|
56890
|
+
var import_node_path35 = __toESM(require("path"), 1);
|
|
56862
56891
|
function peerOpsMcpConfigPath(dataDir) {
|
|
56863
|
-
return
|
|
56892
|
+
return import_node_path35.default.join(dataDir, "peer-ops.mcp.json");
|
|
56864
56893
|
}
|
|
56865
56894
|
function writePeerOpsMcpConfig(args) {
|
|
56866
56895
|
const cfgPath = peerOpsMcpConfigPath(args.dataDir);
|
|
@@ -56877,16 +56906,16 @@ function writePeerOpsMcpConfig(args) {
|
|
|
56877
56906
|
}
|
|
56878
56907
|
}
|
|
56879
56908
|
};
|
|
56880
|
-
|
|
56881
|
-
|
|
56909
|
+
import_node_fs32.default.mkdirSync(args.dataDir, { recursive: true });
|
|
56910
|
+
import_node_fs32.default.writeFileSync(cfgPath, JSON.stringify(cfg, null, 2));
|
|
56882
56911
|
return cfgPath;
|
|
56883
56912
|
}
|
|
56884
56913
|
|
|
56885
56914
|
// src/rpc-tool/mcp-config.ts
|
|
56886
|
-
var
|
|
56887
|
-
var
|
|
56915
|
+
var import_node_fs33 = __toESM(require("fs"), 1);
|
|
56916
|
+
var import_node_path36 = __toESM(require("path"), 1);
|
|
56888
56917
|
function rpcToolMcpConfigPath(dataDir) {
|
|
56889
|
-
return
|
|
56918
|
+
return import_node_path36.default.join(dataDir, "rpc-tool.mcp.json");
|
|
56890
56919
|
}
|
|
56891
56920
|
function writeRpcToolMcpConfig(args) {
|
|
56892
56921
|
const cfgPath = rpcToolMcpConfigPath(args.dataDir);
|
|
@@ -56905,29 +56934,29 @@ function writeRpcToolMcpConfig(args) {
|
|
|
56905
56934
|
}
|
|
56906
56935
|
}
|
|
56907
56936
|
};
|
|
56908
|
-
|
|
56909
|
-
|
|
56937
|
+
import_node_fs33.default.mkdirSync(args.dataDir, { recursive: true });
|
|
56938
|
+
import_node_fs33.default.writeFileSync(cfgPath, JSON.stringify(content, null, 2), "utf8");
|
|
56910
56939
|
return cfgPath;
|
|
56911
56940
|
}
|
|
56912
56941
|
|
|
56913
56942
|
// src/deploy/secret-table.ts
|
|
56914
|
-
var
|
|
56915
|
-
var
|
|
56943
|
+
var import_node_fs34 = __toESM(require("fs"), 1);
|
|
56944
|
+
var import_node_path37 = __toESM(require("path"), 1);
|
|
56916
56945
|
var import_node_url5 = require("url");
|
|
56917
56946
|
var import_meta5 = {};
|
|
56918
56947
|
var LOCAL_SECRETS_DIRNAME = "secrets";
|
|
56919
56948
|
function findSecretsBundleRoot(logger) {
|
|
56920
56949
|
const candidates = [];
|
|
56921
56950
|
try {
|
|
56922
|
-
const here =
|
|
56923
|
-
candidates.push(
|
|
56951
|
+
const here = import_node_path37.default.dirname((0, import_node_url5.fileURLToPath)(import_meta5.url));
|
|
56952
|
+
candidates.push(import_node_path37.default.resolve(here, "..", "secrets"));
|
|
56924
56953
|
} catch {
|
|
56925
56954
|
}
|
|
56926
56955
|
const fromArgv = bundleSiblingFromArgv(process.argv[1], "secrets");
|
|
56927
56956
|
if (fromArgv) candidates.push(fromArgv);
|
|
56928
56957
|
for (const c2 of candidates) {
|
|
56929
56958
|
try {
|
|
56930
|
-
if (
|
|
56959
|
+
if (import_node_fs34.default.statSync(c2).isDirectory()) return c2;
|
|
56931
56960
|
} catch {
|
|
56932
56961
|
}
|
|
56933
56962
|
}
|
|
@@ -56953,7 +56982,7 @@ function readDir(dir, logger) {
|
|
|
56953
56982
|
const out = {};
|
|
56954
56983
|
let files;
|
|
56955
56984
|
try {
|
|
56956
|
-
files =
|
|
56985
|
+
files = import_node_fs34.default.readdirSync(dir).filter((f2) => f2.endsWith(".env")).sort();
|
|
56957
56986
|
} catch (e) {
|
|
56958
56987
|
const code = e.code;
|
|
56959
56988
|
if (code !== "ENOENT") logger?.warn("secrets.dir-unreadable", { dir, code: code ?? "unknown" });
|
|
@@ -56961,19 +56990,19 @@ function readDir(dir, logger) {
|
|
|
56961
56990
|
}
|
|
56962
56991
|
for (const f2 of files) {
|
|
56963
56992
|
try {
|
|
56964
|
-
Object.assign(out, parseEnvFile(
|
|
56993
|
+
Object.assign(out, parseEnvFile(import_node_fs34.default.readFileSync(import_node_path37.default.join(dir, f2), "utf8")));
|
|
56965
56994
|
} catch (e) {
|
|
56966
|
-
logger?.warn("secrets.file-unreadable", { file:
|
|
56995
|
+
logger?.warn("secrets.file-unreadable", { file: import_node_path37.default.join(dir, f2), error: e.message });
|
|
56967
56996
|
}
|
|
56968
56997
|
}
|
|
56969
56998
|
return out;
|
|
56970
56999
|
}
|
|
56971
57000
|
function upsertEnvFileVar(file, key, value) {
|
|
56972
57001
|
if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(key)) throw new Error(`invalid env name: ${key}`);
|
|
56973
|
-
|
|
57002
|
+
import_node_fs34.default.mkdirSync(import_node_path37.default.dirname(file), { recursive: true, mode: 448 });
|
|
56974
57003
|
let lines = [];
|
|
56975
57004
|
try {
|
|
56976
|
-
lines =
|
|
57005
|
+
lines = import_node_fs34.default.readFileSync(file, "utf8").split("\n");
|
|
56977
57006
|
if (lines[lines.length - 1] === "") lines.pop();
|
|
56978
57007
|
} catch {
|
|
56979
57008
|
}
|
|
@@ -56981,12 +57010,12 @@ function upsertEnvFileVar(file, key, value) {
|
|
|
56981
57010
|
let replaced = false;
|
|
56982
57011
|
const out = lines.map((l2) => re2.test(l2) ? (replaced = true, `${key}=${value}`) : l2);
|
|
56983
57012
|
if (!replaced) out.push(`${key}=${value}`);
|
|
56984
|
-
|
|
57013
|
+
import_node_fs34.default.writeFileSync(file, `${out.join("\n")}
|
|
56985
57014
|
`, { encoding: "utf8", mode: 384 });
|
|
56986
57015
|
}
|
|
56987
57016
|
function readEnvFileVar(file, key) {
|
|
56988
57017
|
try {
|
|
56989
|
-
return parseEnvFile(
|
|
57018
|
+
return parseEnvFile(import_node_fs34.default.readFileSync(file, "utf8"))[key];
|
|
56990
57019
|
} catch {
|
|
56991
57020
|
return void 0;
|
|
56992
57021
|
}
|
|
@@ -56995,7 +57024,7 @@ function removeEnvFileVar(file, key) {
|
|
|
56995
57024
|
if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(key)) throw new Error(`invalid env name: ${key}`);
|
|
56996
57025
|
let lines;
|
|
56997
57026
|
try {
|
|
56998
|
-
lines =
|
|
57027
|
+
lines = import_node_fs34.default.readFileSync(file, "utf8").split("\n");
|
|
56999
57028
|
} catch {
|
|
57000
57029
|
return;
|
|
57001
57030
|
}
|
|
@@ -57004,10 +57033,10 @@ function removeEnvFileVar(file, key) {
|
|
|
57004
57033
|
const out = lines.filter((l2) => !re2.test(l2));
|
|
57005
57034
|
if (out.length === lines.length) return;
|
|
57006
57035
|
if (out.every((l2) => l2.trim() === "" || l2.trim().startsWith("#"))) {
|
|
57007
|
-
|
|
57036
|
+
import_node_fs34.default.rmSync(file, { force: true });
|
|
57008
57037
|
return;
|
|
57009
57038
|
}
|
|
57010
|
-
|
|
57039
|
+
import_node_fs34.default.writeFileSync(file, `${out.join("\n")}
|
|
57011
57040
|
`, { encoding: "utf8", mode: 384 });
|
|
57012
57041
|
}
|
|
57013
57042
|
function readSecretTable(args) {
|
|
@@ -57018,12 +57047,12 @@ function readSecretTable(args) {
|
|
|
57018
57047
|
}
|
|
57019
57048
|
|
|
57020
57049
|
// src/dispatch/source-transcript.ts
|
|
57021
|
-
var
|
|
57050
|
+
var import_node_path38 = __toESM(require("path"), 1);
|
|
57022
57051
|
init_claude_history();
|
|
57023
57052
|
var NO_SOURCE_TRANSCRIPT = "(no transcript yet \u2014 operate from the task description alone)";
|
|
57024
57053
|
function resolveSourceJsonlPath(sourceFile, home) {
|
|
57025
57054
|
if (!sourceFile?.toolSessionId) return NO_SOURCE_TRANSCRIPT;
|
|
57026
|
-
return
|
|
57055
|
+
return import_node_path38.default.join(
|
|
57027
57056
|
home,
|
|
57028
57057
|
".claude",
|
|
57029
57058
|
"projects",
|
|
@@ -57034,7 +57063,7 @@ function resolveSourceJsonlPath(sourceFile, home) {
|
|
|
57034
57063
|
|
|
57035
57064
|
// src/shift/store.ts
|
|
57036
57065
|
var import_promises3 = __toESM(require("fs/promises"), 1);
|
|
57037
|
-
var
|
|
57066
|
+
var import_node_path39 = __toESM(require("path"), 1);
|
|
57038
57067
|
var import_node_crypto10 = require("crypto");
|
|
57039
57068
|
|
|
57040
57069
|
// src/shift/schedule.ts
|
|
@@ -57109,7 +57138,7 @@ function createShiftStore(deps) {
|
|
|
57109
57138
|
flushTimer = null;
|
|
57110
57139
|
}
|
|
57111
57140
|
const content = { version: 1, shifts };
|
|
57112
|
-
await import_promises3.default.mkdir(
|
|
57141
|
+
await import_promises3.default.mkdir(import_node_path39.default.dirname(deps.filePath), { recursive: true });
|
|
57113
57142
|
const tmp = `${deps.filePath}.tmp-${deps.now()}-${Math.floor(Math.random() * 1e6)}`;
|
|
57114
57143
|
await import_promises3.default.writeFile(tmp, JSON.stringify(content, null, 2), "utf8");
|
|
57115
57144
|
await import_promises3.default.rename(tmp, deps.filePath);
|
|
@@ -57192,7 +57221,7 @@ function createShiftStore(deps) {
|
|
|
57192
57221
|
}
|
|
57193
57222
|
|
|
57194
57223
|
// src/github/gh.ts
|
|
57195
|
-
var
|
|
57224
|
+
var import_node_child_process9 = require("child_process");
|
|
57196
57225
|
var GhError = class extends Error {
|
|
57197
57226
|
constructor(kind, message, stderr) {
|
|
57198
57227
|
super(message);
|
|
@@ -57207,7 +57236,7 @@ var DEFAULT_TIMEOUT_MS2 = 15e3;
|
|
|
57207
57236
|
var MAX_BUFFER = 4 * 1024 * 1024;
|
|
57208
57237
|
function createGhRunner(defaults) {
|
|
57209
57238
|
const baseTimeoutMs = defaults?.timeoutMs ?? DEFAULT_TIMEOUT_MS2;
|
|
57210
|
-
const spawn17 = defaults?.execFile ??
|
|
57239
|
+
const spawn17 = defaults?.execFile ?? import_node_child_process9.execFile;
|
|
57211
57240
|
return {
|
|
57212
57241
|
run(args, opts) {
|
|
57213
57242
|
const token = defaults?.token?.();
|
|
@@ -57533,40 +57562,40 @@ var import_node_crypto14 = require("crypto");
|
|
|
57533
57562
|
var import_node_perf_hooks = require("perf_hooks");
|
|
57534
57563
|
|
|
57535
57564
|
// src/deploy/persona-test.ts
|
|
57536
|
-
var
|
|
57537
|
-
var
|
|
57565
|
+
var import_node_fs35 = __toESM(require("fs"), 1);
|
|
57566
|
+
var import_node_path40 = __toESM(require("path"), 1);
|
|
57538
57567
|
init_protocol();
|
|
57539
57568
|
var TEST_SCAN_NOTE_PREFIX = PUBLISHER_TEST_NOTE_PREFIX;
|
|
57540
57569
|
function regularFile(root, relative5) {
|
|
57541
57570
|
let current = root;
|
|
57542
57571
|
for (const segment of relative5.split("/")) {
|
|
57543
|
-
current =
|
|
57544
|
-
if (
|
|
57572
|
+
current = import_node_path40.default.join(current, segment);
|
|
57573
|
+
if (import_node_fs35.default.lstatSync(current).isSymbolicLink()) throw new Error("symlink");
|
|
57545
57574
|
}
|
|
57546
|
-
if (!
|
|
57547
|
-
const resolved =
|
|
57548
|
-
if (!resolved.startsWith(root +
|
|
57575
|
+
if (!import_node_fs35.default.statSync(current).isFile()) throw new Error("not a file");
|
|
57576
|
+
const resolved = import_node_fs35.default.realpathSync(current);
|
|
57577
|
+
if (!resolved.startsWith(root + import_node_path40.default.sep)) throw new Error("outside root");
|
|
57549
57578
|
return resolved;
|
|
57550
57579
|
}
|
|
57551
57580
|
function discoverPublisherTest(dir) {
|
|
57552
57581
|
try {
|
|
57553
|
-
const root =
|
|
57582
|
+
const root = import_node_fs35.default.realpathSync(dir);
|
|
57554
57583
|
try {
|
|
57555
|
-
|
|
57584
|
+
import_node_fs35.default.lstatSync(import_node_path40.default.join(root, ".clawd"));
|
|
57556
57585
|
} catch (error) {
|
|
57557
57586
|
if (error.code === "ENOENT") return { problems: [] };
|
|
57558
57587
|
throw error;
|
|
57559
57588
|
}
|
|
57560
|
-
if (
|
|
57589
|
+
if (import_node_fs35.default.lstatSync(import_node_path40.default.join(root, ".clawd")).isSymbolicLink()) throw new Error("symlink");
|
|
57561
57590
|
try {
|
|
57562
|
-
|
|
57591
|
+
import_node_fs35.default.lstatSync(import_node_path40.default.join(root, ".clawd/test.json"));
|
|
57563
57592
|
} catch (error) {
|
|
57564
57593
|
if (error.code === "ENOENT") return { problems: [] };
|
|
57565
57594
|
throw error;
|
|
57566
57595
|
}
|
|
57567
57596
|
const file = regularFile(root, ".clawd/test.json");
|
|
57568
|
-
if (
|
|
57569
|
-
const test = PublisherTestSchema.parse(JSON.parse(
|
|
57597
|
+
if (import_node_fs35.default.statSync(file).size > 64 * 1024) throw new Error("oversized");
|
|
57598
|
+
const test = PublisherTestSchema.parse(JSON.parse(import_node_fs35.default.readFileSync(file, "utf8")));
|
|
57570
57599
|
regularFile(root, test.entry);
|
|
57571
57600
|
return { test, problems: [] };
|
|
57572
57601
|
} catch {
|
|
@@ -57967,19 +57996,19 @@ function openHttpTurn(opts) {
|
|
|
57967
57996
|
|
|
57968
57997
|
// src/deploy/repo.ts
|
|
57969
57998
|
var import_promises5 = __toESM(require("fs/promises"), 1);
|
|
57970
|
-
var
|
|
57999
|
+
var import_node_path43 = __toESM(require("path"), 1);
|
|
57971
58000
|
init_protocol();
|
|
57972
58001
|
|
|
57973
58002
|
// src/deploy/deploy-file.ts
|
|
57974
58003
|
var import_promises4 = __toESM(require("fs/promises"), 1);
|
|
57975
|
-
var
|
|
58004
|
+
var import_node_path42 = __toESM(require("path"), 1);
|
|
57976
58005
|
var import_node_crypto11 = require("crypto");
|
|
57977
58006
|
init_zod();
|
|
57978
58007
|
init_protocol();
|
|
57979
58008
|
|
|
57980
58009
|
// src/deploy/connectors.ts
|
|
57981
|
-
var
|
|
57982
|
-
var
|
|
58010
|
+
var import_node_fs36 = __toESM(require("fs"), 1);
|
|
58011
|
+
var import_node_path41 = __toESM(require("path"), 1);
|
|
57983
58012
|
init_zod();
|
|
57984
58013
|
init_protocol();
|
|
57985
58014
|
|
|
@@ -58067,11 +58096,11 @@ var PACKAGE_RUNNERS = /* @__PURE__ */ new Set(["npx", "uvx", "pnpx", "bunx"]);
|
|
|
58067
58096
|
var SCRIPT_RUNNERS = /* @__PURE__ */ new Set(["node", "bun", "deno", "python", "python3"]);
|
|
58068
58097
|
var HOST_ARG_PLACEHOLDER = "CLAWD_PERSONA_DIR";
|
|
58069
58098
|
function scanMcpConnectors(personaDir) {
|
|
58070
|
-
const file =
|
|
58099
|
+
const file = import_node_path41.default.join(personaDir, ".mcp.json");
|
|
58071
58100
|
const out = { readable: true, connectors: [], evidence: [], warnings: [] };
|
|
58072
58101
|
let parsed;
|
|
58073
58102
|
try {
|
|
58074
|
-
parsed = JSON.parse(
|
|
58103
|
+
parsed = JSON.parse(import_node_fs36.default.readFileSync(file, "utf8"));
|
|
58075
58104
|
} catch (e) {
|
|
58076
58105
|
if (e.code === "ENOENT") return out;
|
|
58077
58106
|
out.readable = false;
|
|
@@ -58167,8 +58196,8 @@ function mergeScannedConnectors(existing, scanned) {
|
|
|
58167
58196
|
}
|
|
58168
58197
|
|
|
58169
58198
|
// src/deploy/deploy-file.ts
|
|
58170
|
-
var DEPLOY_FILE =
|
|
58171
|
-
var SCAN_FILE =
|
|
58199
|
+
var DEPLOY_FILE = import_node_path42.default.join(".clawd", "deploy.json");
|
|
58200
|
+
var SCAN_FILE = import_node_path42.default.join(".clawd", "deploy-scan.json");
|
|
58172
58201
|
async function readJson(file) {
|
|
58173
58202
|
let raw;
|
|
58174
58203
|
try {
|
|
@@ -58184,14 +58213,14 @@ async function readJson(file) {
|
|
|
58184
58213
|
}
|
|
58185
58214
|
}
|
|
58186
58215
|
async function writeJson(file, value) {
|
|
58187
|
-
await import_promises4.default.mkdir(
|
|
58216
|
+
await import_promises4.default.mkdir(import_node_path42.default.dirname(file), { recursive: true });
|
|
58188
58217
|
const tmp = `${file}.tmp-${process.pid}`;
|
|
58189
58218
|
await import_promises4.default.writeFile(tmp, `${JSON.stringify(value, null, 2)}
|
|
58190
58219
|
`);
|
|
58191
58220
|
await import_promises4.default.rename(tmp, file);
|
|
58192
58221
|
}
|
|
58193
58222
|
async function readDeployFile(dir) {
|
|
58194
|
-
const raw = await readJson(
|
|
58223
|
+
const raw = await readJson(import_node_path42.default.join(dir, DEPLOY_FILE));
|
|
58195
58224
|
if (raw === void 0) return void 0;
|
|
58196
58225
|
const parsed = DeployFileSchema.safeParse(raw);
|
|
58197
58226
|
if (!parsed.success) {
|
|
@@ -58201,18 +58230,18 @@ async function readDeployFile(dir) {
|
|
|
58201
58230
|
return parsed.data;
|
|
58202
58231
|
}
|
|
58203
58232
|
async function writeDeployFile(dir, file) {
|
|
58204
|
-
await writeJson(
|
|
58233
|
+
await writeJson(import_node_path42.default.join(dir, DEPLOY_FILE), DeployFileSchema.parse(file));
|
|
58205
58234
|
}
|
|
58206
58235
|
async function readDeployFileRaw(dir) {
|
|
58207
58236
|
try {
|
|
58208
|
-
return await import_promises4.default.readFile(
|
|
58237
|
+
return await import_promises4.default.readFile(import_node_path42.default.join(dir, DEPLOY_FILE), "utf8");
|
|
58209
58238
|
} catch (err) {
|
|
58210
58239
|
if (err.code === "ENOENT") return void 0;
|
|
58211
58240
|
throw err;
|
|
58212
58241
|
}
|
|
58213
58242
|
}
|
|
58214
58243
|
async function restoreDeployFileRaw(dir, raw) {
|
|
58215
|
-
const file =
|
|
58244
|
+
const file = import_node_path42.default.join(dir, DEPLOY_FILE);
|
|
58216
58245
|
if (raw === void 0) await import_promises4.default.rm(file, { force: true });
|
|
58217
58246
|
else await import_promises4.default.writeFile(file, raw);
|
|
58218
58247
|
}
|
|
@@ -58263,7 +58292,7 @@ function normalizeLegacyScan(raw) {
|
|
|
58263
58292
|
return fix(raw);
|
|
58264
58293
|
}
|
|
58265
58294
|
async function readScanFile(dir) {
|
|
58266
|
-
const raw = normalizeLegacyScan(await readJson(
|
|
58295
|
+
const raw = normalizeLegacyScan(await readJson(import_node_path42.default.join(dir, SCAN_FILE)));
|
|
58267
58296
|
if (raw === void 0) return void 0;
|
|
58268
58297
|
const badShape = (issues) => {
|
|
58269
58298
|
const first = issues[0];
|
|
@@ -58289,7 +58318,7 @@ async function readScanFile(dir) {
|
|
|
58289
58318
|
return parsed.data;
|
|
58290
58319
|
}
|
|
58291
58320
|
async function writeScanFile(dir, file) {
|
|
58292
|
-
await writeJson(
|
|
58321
|
+
await writeJson(import_node_path42.default.join(dir, SCAN_FILE), DeployScanFileSchema.parse(file));
|
|
58293
58322
|
}
|
|
58294
58323
|
function replaceScan(file, entry) {
|
|
58295
58324
|
const idx = file.scans.findIndex((s2) => s2.id === entry.id);
|
|
@@ -61828,10 +61857,10 @@ function createGithubApi(args) {
|
|
|
61828
61857
|
const seal = args.seal ?? sealWithSodium;
|
|
61829
61858
|
const timeoutMs = args.timeoutMs ?? TIMEOUT_MS;
|
|
61830
61859
|
const secretsPath = (slug, environment) => `/repos/${slug}/${environment ? `environments/${encodeURIComponent(environment)}` : "actions"}/secrets`;
|
|
61831
|
-
async function request(method,
|
|
61860
|
+
async function request(method, path111, body) {
|
|
61832
61861
|
let res;
|
|
61833
61862
|
try {
|
|
61834
|
-
res = await doFetch(`${API}${
|
|
61863
|
+
res = await doFetch(`${API}${path111}`, {
|
|
61835
61864
|
method,
|
|
61836
61865
|
headers: {
|
|
61837
61866
|
Authorization: `Bearer ${args.token}`,
|
|
@@ -61856,8 +61885,8 @@ function createGithubApi(args) {
|
|
|
61856
61885
|
}
|
|
61857
61886
|
return { status: res.status, json };
|
|
61858
61887
|
}
|
|
61859
|
-
async function must(method,
|
|
61860
|
-
const r2 = await request(method,
|
|
61888
|
+
async function must(method, path111, what, body) {
|
|
61889
|
+
const r2 = await request(method, path111, body);
|
|
61861
61890
|
if (r2.status < 200 || r2.status >= 300) throw new GithubApiError(r2.status, explain(r2.status, what, r2.json));
|
|
61862
61891
|
return r2.json;
|
|
61863
61892
|
}
|
|
@@ -61913,16 +61942,16 @@ function createGithubApi(args) {
|
|
|
61913
61942
|
return { env: x2.name, ...Number.isFinite(at3) ? { setAt: at3 } : {} };
|
|
61914
61943
|
});
|
|
61915
61944
|
},
|
|
61916
|
-
async getJson(
|
|
61945
|
+
async getJson(path111) {
|
|
61917
61946
|
try {
|
|
61918
|
-
const r2 = await request("GET",
|
|
61947
|
+
const r2 = await request("GET", path111);
|
|
61919
61948
|
return r2.status >= 200 && r2.status < 300 ? r2.json : void 0;
|
|
61920
61949
|
} catch {
|
|
61921
61950
|
return void 0;
|
|
61922
61951
|
}
|
|
61923
61952
|
},
|
|
61924
|
-
async getJsonStrict(
|
|
61925
|
-
return must("GET",
|
|
61953
|
+
async getJsonStrict(path111) {
|
|
61954
|
+
return must("GET", path111, "\u8BFB\u53D6\u53D1\u5E03\u8BB0\u5F55");
|
|
61926
61955
|
},
|
|
61927
61956
|
async downloadArtifact(slug, artifactId) {
|
|
61928
61957
|
if (!Number.isSafeInteger(artifactId) || artifactId <= 0) throw new GithubApiError(0, "\u5236\u54C1 ID \u65E0\u6548");
|
|
@@ -62481,10 +62510,10 @@ var U2 = [
|
|
|
62481
62510
|
var UNPUBLISH_WORKFLOW_TEMPLATE = U2.join("\n");
|
|
62482
62511
|
|
|
62483
62512
|
// src/deploy/exec.ts
|
|
62484
|
-
var
|
|
62513
|
+
var import_node_child_process10 = require("child_process");
|
|
62485
62514
|
var DEFAULT_TIMEOUT_MS3 = 6e4;
|
|
62486
62515
|
var runCommand = (cmd, args, opts = {}) => new Promise((resolve9) => {
|
|
62487
|
-
const child = (0,
|
|
62516
|
+
const child = (0, import_node_child_process10.spawn)(cmd, args, {
|
|
62488
62517
|
cwd: opts.cwd,
|
|
62489
62518
|
...opts.env ? { env: { ...process.env, ...opts.env } } : {},
|
|
62490
62519
|
stdio: [opts.stdin === void 0 ? "ignore" : "pipe", "pipe", "pipe"]
|
|
@@ -62519,7 +62548,7 @@ var runCommand = (cmd, args, opts = {}) => new Promise((resolve9) => {
|
|
|
62519
62548
|
});
|
|
62520
62549
|
|
|
62521
62550
|
// src/deploy/repo.ts
|
|
62522
|
-
var DEPLOY_FILE_REL = DEPLOY_FILE.split(
|
|
62551
|
+
var DEPLOY_FILE_REL = DEPLOY_FILE.split(import_node_path43.default.sep).join("/");
|
|
62523
62552
|
var PERSONA_FILE_REL = ".clawd/persona.json";
|
|
62524
62553
|
var DIRTY_IGNORED = [DEPLOY_FILE_REL, PERSONA_FILE_REL];
|
|
62525
62554
|
var RepoError = class extends Error {
|
|
@@ -62552,7 +62581,7 @@ async function prepareIntegration(exec, dir, auth) {
|
|
|
62552
62581
|
for (const name of ["MERGE_HEAD", "CHERRY_PICK_HEAD", "REVERT_HEAD", "rebase-merge", "rebase-apply"]) {
|
|
62553
62582
|
const rel = await mustGit(exec, dir, ["rev-parse", "--git-path", name], "\u68C0\u67E5 Git \u64CD\u4F5C");
|
|
62554
62583
|
try {
|
|
62555
|
-
await import_promises5.default.stat(
|
|
62584
|
+
await import_promises5.default.stat(import_node_path43.default.resolve(dir, rel));
|
|
62556
62585
|
throw new RepoError("Git \u5408\u5E76\u6216\u53D8\u57FA\u8FD8\u672A\u5B8C\u6210\uFF0C\u5148\u5904\u7406\u518D\u53D1\u5E03");
|
|
62557
62586
|
} catch (err) {
|
|
62558
62587
|
if (err.code !== "ENOENT") throw err;
|
|
@@ -62613,7 +62642,7 @@ async function samePath(a2, b3) {
|
|
|
62613
62642
|
try {
|
|
62614
62643
|
return await import_promises5.default.realpath(x2);
|
|
62615
62644
|
} catch {
|
|
62616
|
-
return
|
|
62645
|
+
return import_node_path43.default.resolve(x2);
|
|
62617
62646
|
}
|
|
62618
62647
|
};
|
|
62619
62648
|
return await real(a2) === await real(b3);
|
|
@@ -62639,7 +62668,7 @@ async function identityArgs(exec, dir) {
|
|
|
62639
62668
|
return ["-c", "user.name=clawd", "-c", "user.email=clawd@clawos.local"];
|
|
62640
62669
|
}
|
|
62641
62670
|
async function writeGitignore(dir) {
|
|
62642
|
-
const gi =
|
|
62671
|
+
const gi = import_node_path43.default.join(dir, ".gitignore");
|
|
62643
62672
|
let existing;
|
|
62644
62673
|
try {
|
|
62645
62674
|
existing = await import_promises5.default.readFile(gi, "utf8");
|
|
@@ -62650,18 +62679,18 @@ async function writeGitignore(dir) {
|
|
|
62650
62679
|
}
|
|
62651
62680
|
async function writeWorkflow(dir) {
|
|
62652
62681
|
for (const [rel, body] of [[WORKFLOW_PATH, WORKFLOW_TEMPLATE], [UNPUBLISH_WORKFLOW_PATH, UNPUBLISH_WORKFLOW_TEMPLATE]]) {
|
|
62653
|
-
const wf =
|
|
62654
|
-
await import_promises5.default.mkdir(
|
|
62682
|
+
const wf = import_node_path43.default.join(dir, rel);
|
|
62683
|
+
await import_promises5.default.mkdir(import_node_path43.default.dirname(wf), { recursive: true });
|
|
62655
62684
|
await import_promises5.default.writeFile(wf, body);
|
|
62656
62685
|
}
|
|
62657
62686
|
}
|
|
62658
62687
|
async function writeDockerfile(dir, personaId2, image) {
|
|
62659
62688
|
const baseImage = image.replace("registry-vpc.cn-hangzhou.aliyuncs.com/", "registry.cn-hangzhou.aliyuncs.com/");
|
|
62660
|
-
await import_promises5.default.mkdir(
|
|
62661
|
-
await import_promises5.default.writeFile(
|
|
62689
|
+
await import_promises5.default.mkdir(import_node_path43.default.join(dir, ".clawd"), { recursive: true });
|
|
62690
|
+
await import_promises5.default.writeFile(import_node_path43.default.join(dir, ".clawd", "base-image.txt"), `${baseImage}
|
|
62662
62691
|
`);
|
|
62663
|
-
await import_promises5.default.writeFile(
|
|
62664
|
-
await import_promises5.default.writeFile(
|
|
62692
|
+
await import_promises5.default.writeFile(import_node_path43.default.join(dir, DOCKERFILE_PATH), renderDockerfile(personaId2, baseImage));
|
|
62693
|
+
await import_promises5.default.writeFile(import_node_path43.default.join(dir, DOCKERIGNORE_PATH), DOCKERIGNORE_TEMPLATE);
|
|
62665
62694
|
}
|
|
62666
62695
|
var RepoAlreadyExistsError = class extends RepoError {
|
|
62667
62696
|
constructor(slug) {
|
|
@@ -62700,7 +62729,7 @@ async function ensureRepo(exec, api, args) {
|
|
|
62700
62729
|
const existing = await repoInfo(exec, dir);
|
|
62701
62730
|
if (existing) return { created: false, url: existing.url };
|
|
62702
62731
|
await writeGitignore(dir);
|
|
62703
|
-
await import_promises5.default.rm(
|
|
62732
|
+
await import_promises5.default.rm(import_node_path43.default.join(dir, WORKFLOW_PATH), { force: true });
|
|
62704
62733
|
let created;
|
|
62705
62734
|
try {
|
|
62706
62735
|
created = await createOrgRepo(exec, api, { dir, org, repoName: personaId2, message: "clawd: \u4E0A\u4E91", auth: args.auth });
|
|
@@ -62918,9 +62947,9 @@ init_protocol();
|
|
|
62918
62947
|
|
|
62919
62948
|
// src/deploy/artifact.ts
|
|
62920
62949
|
var import_node_crypto13 = require("crypto");
|
|
62921
|
-
var
|
|
62922
|
-
var
|
|
62923
|
-
var
|
|
62950
|
+
var import_node_fs37 = __toESM(require("fs"), 1);
|
|
62951
|
+
var import_node_os14 = __toESM(require("os"), 1);
|
|
62952
|
+
var import_node_path44 = __toESM(require("path"), 1);
|
|
62924
62953
|
var import_node_stream3 = require("stream");
|
|
62925
62954
|
var import_promises6 = require("stream/promises");
|
|
62926
62955
|
var ARTIFACT_MAX_BYTES = 200 * 1024 * 1024;
|
|
@@ -62954,8 +62983,8 @@ function downloadArtifact(exec) {
|
|
|
62954
62983
|
if (!res.ok || !res.body) throw new Error(`\u4E0B\u8F7D\u5931\u8D25 HTTP ${res.status}\uFF1A${url}`);
|
|
62955
62984
|
const declared = Number(res.headers.get("content-length") ?? 0);
|
|
62956
62985
|
if (declared > ARTIFACT_MAX_BYTES) throw new Error(`\u8D44\u4EA7 ${declared} \u5B57\u8282\uFF0C\u8D85\u8FC7\u4E0A\u9650 ${ARTIFACT_MAX_BYTES}\uFF1A${url}`);
|
|
62957
|
-
const dir = await
|
|
62958
|
-
const file =
|
|
62986
|
+
const dir = await import_node_fs37.default.promises.mkdtemp(import_node_path44.default.join(import_node_os14.default.tmpdir(), "clawd-artifact-"));
|
|
62987
|
+
const file = import_node_path44.default.join(dir, "pkg");
|
|
62959
62988
|
const hash = (0, import_node_crypto13.createHash)("sha256");
|
|
62960
62989
|
let size = 0;
|
|
62961
62990
|
const meter = new import_node_stream3.Transform({
|
|
@@ -62967,7 +62996,7 @@ function downloadArtifact(exec) {
|
|
|
62967
62996
|
}
|
|
62968
62997
|
});
|
|
62969
62998
|
try {
|
|
62970
|
-
await (0, import_promises6.pipeline)(import_node_stream3.Readable.fromWeb(res.body), meter,
|
|
62999
|
+
await (0, import_promises6.pipeline)(import_node_stream3.Readable.fromWeb(res.body), meter, import_node_fs37.default.createWriteStream(file));
|
|
62971
63000
|
let entries;
|
|
62972
63001
|
if (listEntries) {
|
|
62973
63002
|
const r2 = await exec("tar", ["-tzf", file], { timeoutMs: 3e4 });
|
|
@@ -62976,7 +63005,7 @@ function downloadArtifact(exec) {
|
|
|
62976
63005
|
}
|
|
62977
63006
|
return { sha256: hash.digest("hex"), size, ...entries ? { entries } : {} };
|
|
62978
63007
|
} finally {
|
|
62979
|
-
await
|
|
63008
|
+
await import_node_fs37.default.promises.rm(dir, { recursive: true, force: true });
|
|
62980
63009
|
}
|
|
62981
63010
|
};
|
|
62982
63011
|
}
|
|
@@ -63029,12 +63058,12 @@ init_protocol();
|
|
|
63029
63058
|
// src/deploy/publishing-config.ts
|
|
63030
63059
|
async function requireIntegrationPublishingConfig(api, slug) {
|
|
63031
63060
|
const base = `/repos/${slug}`;
|
|
63032
|
-
async function rows(
|
|
63061
|
+
async function rows(path111, field, absentEnvironment = false) {
|
|
63033
63062
|
const result = [];
|
|
63034
63063
|
for (let page = 1; page <= 30; page++) {
|
|
63035
63064
|
let raw;
|
|
63036
63065
|
try {
|
|
63037
|
-
raw = await api.getJsonStrict(`${
|
|
63066
|
+
raw = await api.getJsonStrict(`${path111}?per_page=100&page=${page}`);
|
|
63038
63067
|
} catch (error) {
|
|
63039
63068
|
if (absentEnvironment && page === 1 && error instanceof GithubApiError && error.status === 404) return [];
|
|
63040
63069
|
throw error;
|
|
@@ -64188,9 +64217,9 @@ function buildDeployHandlers(deps) {
|
|
|
64188
64217
|
}
|
|
64189
64218
|
|
|
64190
64219
|
// src/tools/subscription-channels-store.ts
|
|
64191
|
-
var
|
|
64192
|
-
var
|
|
64193
|
-
var
|
|
64220
|
+
var import_node_fs38 = __toESM(require("fs"), 1);
|
|
64221
|
+
var import_node_os15 = __toESM(require("os"), 1);
|
|
64222
|
+
var import_node_path45 = __toESM(require("path"), 1);
|
|
64194
64223
|
init_subscription_channels_apply();
|
|
64195
64224
|
init_codex_config_toml();
|
|
64196
64225
|
var CHANNELS_FILE_NAME = "subscription-channels.json";
|
|
@@ -64212,7 +64241,7 @@ function providerKey(provider, codexHome) {
|
|
|
64212
64241
|
}
|
|
64213
64242
|
function readAuthKey2(codexHome) {
|
|
64214
64243
|
try {
|
|
64215
|
-
const key = JSON.parse(
|
|
64244
|
+
const key = JSON.parse(import_node_fs38.default.readFileSync(import_node_path45.default.join(codexHome, "auth.json"), "utf8")).OPENAI_API_KEY;
|
|
64216
64245
|
return typeof key === "string" && key ? key : null;
|
|
64217
64246
|
} catch {
|
|
64218
64247
|
return null;
|
|
@@ -64222,8 +64251,8 @@ var SubscriptionChannelStore = class {
|
|
|
64222
64251
|
filePath;
|
|
64223
64252
|
codexHome;
|
|
64224
64253
|
constructor(options) {
|
|
64225
|
-
this.filePath =
|
|
64226
|
-
this.codexHome = options.codexHome || process.env.CODEX_HOME ||
|
|
64254
|
+
this.filePath = import_node_path45.default.join(options.dataDir, CHANNELS_FILE_NAME);
|
|
64255
|
+
this.codexHome = options.codexHome || process.env.CODEX_HOME || import_node_path45.default.join(import_node_os15.default.homedir(), ".codex");
|
|
64227
64256
|
}
|
|
64228
64257
|
/** 存储文件的快照(首次初始化 / 迁移先落盘);返回的函数把它恢复成此刻的样子,通道切换失败时回滚用 */
|
|
64229
64258
|
snapshot() {
|
|
@@ -64320,9 +64349,9 @@ var SubscriptionChannelStore = class {
|
|
|
64320
64349
|
return target;
|
|
64321
64350
|
}
|
|
64322
64351
|
readOrCreate() {
|
|
64323
|
-
if (
|
|
64352
|
+
if (import_node_fs38.default.existsSync(this.filePath)) {
|
|
64324
64353
|
try {
|
|
64325
|
-
const raw = JSON.parse(
|
|
64354
|
+
const raw = JSON.parse(import_node_fs38.default.readFileSync(this.filePath, "utf8"));
|
|
64326
64355
|
if (raw && Array.isArray(raw.channels)) {
|
|
64327
64356
|
return {
|
|
64328
64357
|
activeChannelId: typeof raw.activeChannelId === "string" ? raw.activeChannelId : null,
|
|
@@ -64342,9 +64371,9 @@ var SubscriptionChannelStore = class {
|
|
|
64342
64371
|
}
|
|
64343
64372
|
tryMigrateFromCodexConfig() {
|
|
64344
64373
|
try {
|
|
64345
|
-
const configPath =
|
|
64346
|
-
if (!
|
|
64347
|
-
const content =
|
|
64374
|
+
const configPath = import_node_path45.default.join(this.codexHome, "config.toml");
|
|
64375
|
+
if (!import_node_fs38.default.existsSync(configPath)) return null;
|
|
64376
|
+
const content = import_node_fs38.default.readFileSync(configPath, "utf8");
|
|
64348
64377
|
if (readTomlTable(content, [])?.model_provider !== "cliproxyapi") return null;
|
|
64349
64378
|
const provider = readTomlTable(content, ["model_providers", "cliproxyapi"]);
|
|
64350
64379
|
if (!provider) return null;
|
|
@@ -64371,8 +64400,8 @@ var SubscriptionChannelStore = class {
|
|
|
64371
64400
|
return null;
|
|
64372
64401
|
}
|
|
64373
64402
|
write(data) {
|
|
64374
|
-
const dir =
|
|
64375
|
-
|
|
64403
|
+
const dir = import_node_path45.default.dirname(this.filePath);
|
|
64404
|
+
import_node_fs38.default.mkdirSync(dir, { recursive: true });
|
|
64376
64405
|
writeFileAtomic(this.filePath, JSON.stringify(data, null, 2) + "\n");
|
|
64377
64406
|
}
|
|
64378
64407
|
};
|
|
@@ -64427,19 +64456,19 @@ async function probeLocalVersion(exec, pkg) {
|
|
|
64427
64456
|
}
|
|
64428
64457
|
|
|
64429
64458
|
// src/tools/shell-path.ts
|
|
64430
|
-
var
|
|
64431
|
-
var
|
|
64459
|
+
var import_node_child_process11 = require("child_process");
|
|
64460
|
+
var import_node_os16 = __toESM(require("os"), 1);
|
|
64432
64461
|
function refreshPathFromLoginShell() {
|
|
64433
64462
|
if (process.platform === "win32") return;
|
|
64434
|
-
const shell = process.env.SHELL ??
|
|
64463
|
+
const shell = process.env.SHELL ?? import_node_os16.default.userInfo().shell ?? "/bin/zsh";
|
|
64435
64464
|
try {
|
|
64436
|
-
const out = (0,
|
|
64465
|
+
const out = (0, import_node_child_process11.execFileSync)(shell, ["-ilc", 'command echo -n "$PATH"'], {
|
|
64437
64466
|
encoding: "utf8",
|
|
64438
64467
|
timeout: 3e3,
|
|
64439
64468
|
stdio: ["ignore", "pipe", "ignore"]
|
|
64440
64469
|
});
|
|
64441
|
-
const
|
|
64442
|
-
if (
|
|
64470
|
+
const path111 = out.trim();
|
|
64471
|
+
if (path111) process.env.PATH = path111;
|
|
64443
64472
|
} catch {
|
|
64444
64473
|
}
|
|
64445
64474
|
}
|
|
@@ -65232,10 +65261,10 @@ function createCloudPersonaBotClient(opts) {
|
|
|
65232
65261
|
const f2 = opts.fetchImpl ?? fetch;
|
|
65233
65262
|
const base = opts.api.replace(/\/+$/, "");
|
|
65234
65263
|
const route = (personaId2) => `/api/lark-bot/cloud/${encodeURIComponent(personaId2)}`;
|
|
65235
|
-
async function request(method,
|
|
65264
|
+
async function request(method, path111, body) {
|
|
65236
65265
|
const pass = opts.getLoginPass();
|
|
65237
65266
|
if (!pass) throw new LarkBotCloudError("\u98DE\u4E66\u767B\u5F55\u540E\u624D\u80FD\u7BA1\u7406\u4E91 Persona \u7684 Bot", 401);
|
|
65238
|
-
const response = await f2(base +
|
|
65267
|
+
const response = await f2(base + path111, {
|
|
65239
65268
|
method,
|
|
65240
65269
|
headers: { authorization: `Bearer ${pass}`, "content-type": "application/json" },
|
|
65241
65270
|
...body ? { body: JSON.stringify(body) } : {},
|
|
@@ -65244,7 +65273,7 @@ function createCloudPersonaBotClient(opts) {
|
|
|
65244
65273
|
const json = await response.json().catch(() => ({}));
|
|
65245
65274
|
if (!response.ok) {
|
|
65246
65275
|
const detail = typeof json.message === "string" ? json.message : `HTTP ${response.status}`;
|
|
65247
|
-
throw new LarkBotCloudError(`cloud bot ${method} ${
|
|
65276
|
+
throw new LarkBotCloudError(`cloud bot ${method} ${path111}: ${detail}`, response.status);
|
|
65248
65277
|
}
|
|
65249
65278
|
return json;
|
|
65250
65279
|
}
|
|
@@ -65260,15 +65289,15 @@ function createCloudPersonaBotClient(opts) {
|
|
|
65260
65289
|
}
|
|
65261
65290
|
|
|
65262
65291
|
// src/lark-bot-connector/binding-store.ts
|
|
65263
|
-
var
|
|
65264
|
-
var
|
|
65292
|
+
var import_node_fs39 = __toESM(require("fs"), 1);
|
|
65293
|
+
var import_node_path46 = __toESM(require("path"), 1);
|
|
65265
65294
|
function createLarkBotBindingStore(personaRoot) {
|
|
65266
|
-
const filePath = (personaId2) =>
|
|
65295
|
+
const filePath = (personaId2) => import_node_path46.default.join(personaRoot, safeFileName(personaId2), ".clawd", "lark-bot.json");
|
|
65267
65296
|
const read = (personaId2) => {
|
|
65268
65297
|
const file = filePath(personaId2);
|
|
65269
|
-
if (!
|
|
65298
|
+
if (!import_node_fs39.default.existsSync(file)) return null;
|
|
65270
65299
|
try {
|
|
65271
|
-
const raw = JSON.parse(
|
|
65300
|
+
const raw = JSON.parse(import_node_fs39.default.readFileSync(file, "utf8"));
|
|
65272
65301
|
if (typeof raw?.appId !== "string" || raw.appId.length === 0) return null;
|
|
65273
65302
|
return raw;
|
|
65274
65303
|
} catch {
|
|
@@ -65277,16 +65306,16 @@ function createLarkBotBindingStore(personaRoot) {
|
|
|
65277
65306
|
};
|
|
65278
65307
|
const write = (personaId2, meta) => {
|
|
65279
65308
|
const file = filePath(personaId2);
|
|
65280
|
-
|
|
65309
|
+
import_node_fs39.default.mkdirSync(import_node_path46.default.dirname(file), { recursive: true });
|
|
65281
65310
|
const tmp = `${file}.tmp-${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
65282
|
-
|
|
65283
|
-
|
|
65311
|
+
import_node_fs39.default.writeFileSync(tmp, JSON.stringify(meta, null, 2), { mode: 384 });
|
|
65312
|
+
import_node_fs39.default.renameSync(tmp, file);
|
|
65284
65313
|
};
|
|
65285
65314
|
return {
|
|
65286
65315
|
read,
|
|
65287
65316
|
write,
|
|
65288
65317
|
remove(personaId2) {
|
|
65289
|
-
|
|
65318
|
+
import_node_fs39.default.rmSync(filePath(personaId2), { force: true });
|
|
65290
65319
|
},
|
|
65291
65320
|
addRemovedChat(personaId2, chatId) {
|
|
65292
65321
|
const meta = read(personaId2);
|
|
@@ -65299,8 +65328,8 @@ function createLarkBotBindingStore(personaRoot) {
|
|
|
65299
65328
|
}
|
|
65300
65329
|
|
|
65301
65330
|
// src/lark-bot-connector/chat-router.ts
|
|
65302
|
-
var
|
|
65303
|
-
var
|
|
65331
|
+
var import_node_fs40 = __toESM(require("fs"), 1);
|
|
65332
|
+
var import_node_path47 = __toESM(require("path"), 1);
|
|
65304
65333
|
init_protocol();
|
|
65305
65334
|
var ERROR_REPLY_TEXT = "\u5904\u7406\u51FA\u9519\u4E86\uFF0C\u8BF7\u91CD\u8BD5";
|
|
65306
65335
|
var LOCAL_TURN_RETRIES = 2;
|
|
@@ -65378,9 +65407,9 @@ function createLarkChatRouter(deps) {
|
|
|
65378
65407
|
continue;
|
|
65379
65408
|
}
|
|
65380
65409
|
const dir = deps.mediaRootFor(env.chatId);
|
|
65381
|
-
|
|
65382
|
-
const p3 =
|
|
65383
|
-
|
|
65410
|
+
import_node_fs40.default.mkdirSync(dir, { recursive: true });
|
|
65411
|
+
const p3 = import_node_path47.default.join(dir, `${safeMediaName(ownerMessageId)}-${i2}.${ext}`);
|
|
65412
|
+
import_node_fs40.default.writeFileSync(p3, r2.data);
|
|
65384
65413
|
lines.push(`[\u56FE\u7247: ${p3}]\uFF08\u7528 Read \u5DE5\u5177\u67E5\u770B\uFF09`);
|
|
65385
65414
|
} catch (err) {
|
|
65386
65415
|
deps.logger?.warn(`larkBot image fetch failed ${key}: ${err.message}`);
|
|
@@ -65401,9 +65430,9 @@ function createLarkChatRouter(deps) {
|
|
|
65401
65430
|
continue;
|
|
65402
65431
|
}
|
|
65403
65432
|
const dir = deps.mediaRootFor(env.chatId);
|
|
65404
|
-
|
|
65405
|
-
const p3 =
|
|
65406
|
-
|
|
65433
|
+
import_node_fs40.default.mkdirSync(dir, { recursive: true });
|
|
65434
|
+
const p3 = import_node_path47.default.join(dir, `${safeMediaName(ownerMessageId)}-${i2}-${safeAttachmentName(f2.name)}`);
|
|
65435
|
+
import_node_fs40.default.writeFileSync(p3, r2.data);
|
|
65407
65436
|
lines.push(`[\u6587\u4EF6: ${p3}]\uFF08\u7528 Read \u5DE5\u5177\u67E5\u770B\uFF09`);
|
|
65408
65437
|
} catch (err) {
|
|
65409
65438
|
deps.logger?.warn(`larkBot file fetch failed ${f2.key}: ${err.message}`);
|
|
@@ -66218,7 +66247,7 @@ async function forwardPeerExecToPeer(args) {
|
|
|
66218
66247
|
init_protocol();
|
|
66219
66248
|
|
|
66220
66249
|
// src/tools/codex-cloud-session.ts
|
|
66221
|
-
var
|
|
66250
|
+
var import_node_fs41 = __toESM(require("fs"), 1);
|
|
66222
66251
|
|
|
66223
66252
|
// src/tools/cloud-portable-input.ts
|
|
66224
66253
|
async function portableCloudInput(text, resolvers) {
|
|
@@ -66374,7 +66403,7 @@ function cloudImageInput(deps) {
|
|
|
66374
66403
|
const mime = lookupMime(p3);
|
|
66375
66404
|
if (!mime.startsWith("image/")) return null;
|
|
66376
66405
|
try {
|
|
66377
|
-
const bytes = (deps.readFile ??
|
|
66406
|
+
const bytes = (deps.readFile ?? import_node_fs41.default.readFileSync)(p3);
|
|
66378
66407
|
return { type: "image", url: `data:${mime};base64,${bytes.toString("base64")}` };
|
|
66379
66408
|
} catch (e) {
|
|
66380
66409
|
deps.logger?.warn("cloud image attachment unreadable", { path: p3, message: e.message });
|
|
@@ -66475,8 +66504,8 @@ var CloudCodexAdapter = class {
|
|
|
66475
66504
|
init_protocol();
|
|
66476
66505
|
|
|
66477
66506
|
// src/tools/pi.ts
|
|
66478
|
-
var
|
|
66479
|
-
var
|
|
66507
|
+
var import_node_child_process13 = require("child_process");
|
|
66508
|
+
var import_node_fs43 = __toESM(require("fs"), 1);
|
|
66480
66509
|
init_protocol();
|
|
66481
66510
|
|
|
66482
66511
|
// src/tools/pi-rpc-client.ts
|
|
@@ -66575,10 +66604,10 @@ var PiRpcClient = class {
|
|
|
66575
66604
|
};
|
|
66576
66605
|
|
|
66577
66606
|
// src/tools/pi-session.ts
|
|
66578
|
-
var
|
|
66607
|
+
var import_node_child_process12 = require("child_process");
|
|
66579
66608
|
var import_node_crypto17 = require("crypto");
|
|
66580
|
-
var
|
|
66581
|
-
var
|
|
66609
|
+
var import_node_fs42 = __toESM(require("fs"), 1);
|
|
66610
|
+
var import_node_path48 = __toESM(require("path"), 1);
|
|
66582
66611
|
|
|
66583
66612
|
// src/tools/pi-events.ts
|
|
66584
66613
|
init_protocol();
|
|
@@ -66859,8 +66888,8 @@ ${dirs.map((d2) => `- ${d2}`).join("\n")}`;
|
|
|
66859
66888
|
function createPiSession(ctx, sink, deps = {}) {
|
|
66860
66889
|
const cmd = process.env.PI_BIN ?? "pi";
|
|
66861
66890
|
const sessionId = ctx.toolSessionId ?? (0, import_node_crypto17.randomUUID)();
|
|
66862
|
-
const skillsDir =
|
|
66863
|
-
const exists = deps.skillsDirExists ?? ((d2) =>
|
|
66891
|
+
const skillsDir = import_node_path48.default.join(ctx.cwd, ".claude", "skills");
|
|
66892
|
+
const exists = deps.skillsDirExists ?? ((d2) => import_node_fs42.default.existsSync(d2));
|
|
66864
66893
|
const args = buildPiArgs(ctx, {
|
|
66865
66894
|
sessionId,
|
|
66866
66895
|
skillsDir: exists(skillsDir) ? skillsDir : void 0,
|
|
@@ -66871,7 +66900,7 @@ function createPiSession(ctx, sink, deps = {}) {
|
|
|
66871
66900
|
...ctx.env,
|
|
66872
66901
|
...deps.mcpBridgePath ? { [PI_MCP_CONFIGS_ENV]: JSON.stringify((ctx.mcpConfigs ?? []).map((m3) => m3.path)) } : {}
|
|
66873
66902
|
};
|
|
66874
|
-
const proc = deps.spawnOverride ? deps.spawnOverride(cmd, args, ctx.cwd, env) : (0,
|
|
66903
|
+
const proc = deps.spawnOverride ? deps.spawnOverride(cmd, args, ctx.cwd, env) : (0, import_node_child_process12.spawn)(cmd, args, { cwd: ctx.cwd, env, stdio: ["pipe", "pipe", "pipe"] });
|
|
66875
66904
|
const alive = () => proc.exitCode === null && proc.signalCode === null;
|
|
66876
66905
|
const driver = drivePiSession({
|
|
66877
66906
|
sink,
|
|
@@ -66922,10 +66951,10 @@ var PI_DEFAULT_MODEL_ENTRY = {
|
|
|
66922
66951
|
};
|
|
66923
66952
|
var PI_FULL_ACCESS = { id: "never", label: "Full Access", description: "pi \u65E0\u5BA1\u6279\uFF1A\u4ECE\u4E0D\u8BE2\u95EE\uFF0C\u81EA\u4E3B\u6267\u884C" };
|
|
66924
66953
|
async function probePi(env = process.env) {
|
|
66925
|
-
if (env.PI_BIN &&
|
|
66954
|
+
if (env.PI_BIN && import_node_fs43.default.existsSync(env.PI_BIN)) return { available: true, path: env.PI_BIN };
|
|
66926
66955
|
try {
|
|
66927
|
-
const out = (0,
|
|
66928
|
-
if (out &&
|
|
66956
|
+
const out = (0, import_node_child_process13.execFileSync)("which", ["pi"], { encoding: "utf8" }).trim();
|
|
66957
|
+
if (out && import_node_fs43.default.existsSync(out)) return { available: true, path: out };
|
|
66929
66958
|
} catch {
|
|
66930
66959
|
}
|
|
66931
66960
|
return { available: false };
|
|
@@ -66991,7 +67020,7 @@ function buildPiCapabilities(models) {
|
|
|
66991
67020
|
async function queryPiModels(deps = {}) {
|
|
66992
67021
|
const cmd = process.env.PI_BIN ?? "pi";
|
|
66993
67022
|
const args = ["--mode", "rpc", "--no-session", "--no-skills", "--no-context-files"];
|
|
66994
|
-
const proc = deps.spawnOverride ? deps.spawnOverride(cmd, args) : (0,
|
|
67023
|
+
const proc = deps.spawnOverride ? deps.spawnOverride(cmd, args) : (0, import_node_child_process13.spawn)(cmd, args, { stdio: ["pipe", "pipe", "pipe"] });
|
|
66995
67024
|
proc.stdin?.on("error", () => {
|
|
66996
67025
|
});
|
|
66997
67026
|
let refreshingCliproxy = false;
|
|
@@ -67318,7 +67347,7 @@ var CloudClaudeAdapter = class {
|
|
|
67318
67347
|
init_protocol();
|
|
67319
67348
|
|
|
67320
67349
|
// src/tools/codex-skills.ts
|
|
67321
|
-
var
|
|
67350
|
+
var import_node_path49 = __toESM(require("path"), 1);
|
|
67322
67351
|
function str4(v3) {
|
|
67323
67352
|
return typeof v3 === "string" ? v3 : void 0;
|
|
67324
67353
|
}
|
|
@@ -67333,13 +67362,13 @@ function mapSkillsListResponse(res) {
|
|
|
67333
67362
|
const r2 = s2 ?? {};
|
|
67334
67363
|
const name = str4(r2.name);
|
|
67335
67364
|
if (!name) continue;
|
|
67336
|
-
const
|
|
67365
|
+
const path111 = str4(r2.path);
|
|
67337
67366
|
const description = str4(r2.description);
|
|
67338
67367
|
const isPlugin = name.includes(":");
|
|
67339
67368
|
out.push({
|
|
67340
67369
|
name,
|
|
67341
67370
|
source: isPlugin ? "plugin" : "project",
|
|
67342
|
-
...
|
|
67371
|
+
...path111 ? { path: path111 } : {},
|
|
67343
67372
|
...description ? { description } : {},
|
|
67344
67373
|
...isPlugin ? { plugin: name.split(":")[0] } : {}
|
|
67345
67374
|
});
|
|
@@ -67355,7 +67384,7 @@ async function listCodexSkills(cwd, deps = {}) {
|
|
|
67355
67384
|
// 先写 extraRoots 再写 list(stdio 按写入顺序处理,fire-and-forget 不 await 回包;
|
|
67356
67385
|
// codex-session.ts ready 序列同款,两处保持一致)。失败不阻塞 list。
|
|
67357
67386
|
beforeRequest: (client) => {
|
|
67358
|
-
void client.request("skills/extraRoots/set", { extraRoots: [
|
|
67387
|
+
void client.request("skills/extraRoots/set", { extraRoots: [import_node_path49.default.join(cwd, ".claude", "skills")] }).catch(() => void 0);
|
|
67359
67388
|
}
|
|
67360
67389
|
});
|
|
67361
67390
|
return mapSkillsListResponse(res);
|
|
@@ -67429,23 +67458,23 @@ function rec4(v3) {
|
|
|
67429
67458
|
}
|
|
67430
67459
|
|
|
67431
67460
|
// src/workspace/browser.ts
|
|
67432
|
-
var
|
|
67433
|
-
var
|
|
67434
|
-
var
|
|
67461
|
+
var import_node_fs44 = __toESM(require("fs"), 1);
|
|
67462
|
+
var import_node_os17 = __toESM(require("os"), 1);
|
|
67463
|
+
var import_node_path50 = __toESM(require("path"), 1);
|
|
67435
67464
|
init_protocol();
|
|
67436
67465
|
var MAX_FILE_BYTES2 = 2 * 1024 * 1024;
|
|
67437
67466
|
function resolveInsideCwd(cwd, subpath) {
|
|
67438
|
-
const absCwd =
|
|
67439
|
-
const joined =
|
|
67440
|
-
const rel =
|
|
67441
|
-
if (rel.startsWith("..") ||
|
|
67467
|
+
const absCwd = import_node_path50.default.resolve(cwd);
|
|
67468
|
+
const joined = import_node_path50.default.resolve(absCwd, subpath ?? ".");
|
|
67469
|
+
const rel = import_node_path50.default.relative(absCwd, joined);
|
|
67470
|
+
if (rel.startsWith("..") || import_node_path50.default.isAbsolute(rel)) {
|
|
67442
67471
|
throw new ClawdError(ERROR_CODES.INVALID_PATH, `path escapes cwd: ${subpath}`);
|
|
67443
67472
|
}
|
|
67444
67473
|
return joined;
|
|
67445
67474
|
}
|
|
67446
67475
|
function ensureCwd(cwd) {
|
|
67447
67476
|
try {
|
|
67448
|
-
const stat =
|
|
67477
|
+
const stat = import_node_fs44.default.statSync(cwd);
|
|
67449
67478
|
if (!stat.isDirectory()) {
|
|
67450
67479
|
throw new ClawdError(ERROR_CODES.INVALID_CWD, `not a directory: ${cwd}`);
|
|
67451
67480
|
}
|
|
@@ -67456,10 +67485,10 @@ function ensureCwd(cwd) {
|
|
|
67456
67485
|
}
|
|
67457
67486
|
var WorkspaceBrowser = class {
|
|
67458
67487
|
list(args) {
|
|
67459
|
-
const cwd = args.cwd && args.cwd.length > 0 ? args.cwd :
|
|
67488
|
+
const cwd = args.cwd && args.cwd.length > 0 ? args.cwd : import_node_os17.default.homedir();
|
|
67460
67489
|
ensureCwd(cwd);
|
|
67461
67490
|
const full = resolveInsideCwd(cwd, args.path);
|
|
67462
|
-
const dirents =
|
|
67491
|
+
const dirents = import_node_fs44.default.readdirSync(full, { withFileTypes: true });
|
|
67463
67492
|
const entries = [];
|
|
67464
67493
|
for (const d2 of dirents) {
|
|
67465
67494
|
if (!args.showHidden && d2.name.startsWith(".")) continue;
|
|
@@ -67469,7 +67498,7 @@ var WorkspaceBrowser = class {
|
|
|
67469
67498
|
mtime: ""
|
|
67470
67499
|
};
|
|
67471
67500
|
try {
|
|
67472
|
-
const st2 =
|
|
67501
|
+
const st2 = import_node_fs44.default.statSync(import_node_path50.default.join(full, d2.name));
|
|
67473
67502
|
entry.mtime = new Date(st2.mtimeMs).toISOString();
|
|
67474
67503
|
if (d2.isFile()) entry.size = st2.size;
|
|
67475
67504
|
} catch {
|
|
@@ -67485,14 +67514,14 @@ var WorkspaceBrowser = class {
|
|
|
67485
67514
|
read(args) {
|
|
67486
67515
|
ensureCwd(args.cwd);
|
|
67487
67516
|
const full = resolveInsideCwd(args.cwd, args.path);
|
|
67488
|
-
const st2 =
|
|
67517
|
+
const st2 = import_node_fs44.default.statSync(full);
|
|
67489
67518
|
if (!st2.isFile()) {
|
|
67490
67519
|
throw new ClawdError(ERROR_CODES.INVALID_PATH, `not a file: ${args.path}`);
|
|
67491
67520
|
}
|
|
67492
67521
|
if (st2.size > MAX_FILE_BYTES2) {
|
|
67493
67522
|
throw new ClawdError(ERROR_CODES.FILE_TOO_LARGE, `file > ${MAX_FILE_BYTES2} bytes`);
|
|
67494
67523
|
}
|
|
67495
|
-
const buf =
|
|
67524
|
+
const buf = import_node_fs44.default.readFileSync(full);
|
|
67496
67525
|
const isBinary = buf.includes(0);
|
|
67497
67526
|
if (isBinary) {
|
|
67498
67527
|
return {
|
|
@@ -67514,20 +67543,20 @@ var WorkspaceBrowser = class {
|
|
|
67514
67543
|
};
|
|
67515
67544
|
|
|
67516
67545
|
// src/skills/agents-scanner.ts
|
|
67517
|
-
var
|
|
67518
|
-
var
|
|
67519
|
-
var
|
|
67546
|
+
var import_node_fs45 = __toESM(require("fs"), 1);
|
|
67547
|
+
var import_node_os18 = __toESM(require("os"), 1);
|
|
67548
|
+
var import_node_path51 = __toESM(require("path"), 1);
|
|
67520
67549
|
var DEFAULT_POLICY_DIR_DARWIN = "/Library/Application Support/ClaudeCode/.claude/agents";
|
|
67521
67550
|
function isDirLikeSync2(p3) {
|
|
67522
67551
|
try {
|
|
67523
|
-
return
|
|
67552
|
+
return import_node_fs45.default.statSync(p3).isDirectory();
|
|
67524
67553
|
} catch {
|
|
67525
67554
|
return false;
|
|
67526
67555
|
}
|
|
67527
67556
|
}
|
|
67528
67557
|
function fileExistsSync(p3) {
|
|
67529
67558
|
try {
|
|
67530
|
-
return
|
|
67559
|
+
return import_node_fs45.default.statSync(p3).isFile();
|
|
67531
67560
|
} catch {
|
|
67532
67561
|
return false;
|
|
67533
67562
|
}
|
|
@@ -67535,7 +67564,7 @@ function fileExistsSync(p3) {
|
|
|
67535
67564
|
function parseAgentFile(filePath) {
|
|
67536
67565
|
let content;
|
|
67537
67566
|
try {
|
|
67538
|
-
content =
|
|
67567
|
+
content = import_node_fs45.default.readFileSync(filePath, "utf8");
|
|
67539
67568
|
} catch {
|
|
67540
67569
|
return {};
|
|
67541
67570
|
}
|
|
@@ -67548,16 +67577,16 @@ function parseAgentFile(filePath) {
|
|
|
67548
67577
|
function scanAgentsDir(dir, source, seen, out) {
|
|
67549
67578
|
let entries;
|
|
67550
67579
|
try {
|
|
67551
|
-
entries =
|
|
67580
|
+
entries = import_node_fs45.default.readdirSync(dir, { withFileTypes: true });
|
|
67552
67581
|
} catch {
|
|
67553
67582
|
return;
|
|
67554
67583
|
}
|
|
67555
67584
|
for (const ent of entries) {
|
|
67556
67585
|
if (!ent.name.endsWith(".md")) continue;
|
|
67557
|
-
if (!ent.isFile() && !(ent.isSymbolicLink() && fileExistsSync(
|
|
67586
|
+
if (!ent.isFile() && !(ent.isSymbolicLink() && fileExistsSync(import_node_path51.default.join(dir, ent.name)))) {
|
|
67558
67587
|
continue;
|
|
67559
67588
|
}
|
|
67560
|
-
const filePath =
|
|
67589
|
+
const filePath = import_node_path51.default.join(dir, ent.name);
|
|
67561
67590
|
const baseName = ent.name.replace(/\.md$/, "");
|
|
67562
67591
|
if (seen.has(baseName)) continue;
|
|
67563
67592
|
seen.add(baseName);
|
|
@@ -67575,12 +67604,12 @@ function scanPluginAgentsTree(root, pluginName, seen, out) {
|
|
|
67575
67604
|
function walk2(dir, namespaces) {
|
|
67576
67605
|
let entries;
|
|
67577
67606
|
try {
|
|
67578
|
-
entries =
|
|
67607
|
+
entries = import_node_fs45.default.readdirSync(dir, { withFileTypes: true });
|
|
67579
67608
|
} catch {
|
|
67580
67609
|
return;
|
|
67581
67610
|
}
|
|
67582
67611
|
for (const ent of entries) {
|
|
67583
|
-
const childPath =
|
|
67612
|
+
const childPath = import_node_path51.default.join(dir, ent.name);
|
|
67584
67613
|
if (ent.isDirectory() || ent.isSymbolicLink() && isDirLikeSync2(childPath)) {
|
|
67585
67614
|
walk2(childPath, [...namespaces, ent.name]);
|
|
67586
67615
|
continue;
|
|
@@ -67605,13 +67634,13 @@ function scanPluginAgentsTree(root, pluginName, seen, out) {
|
|
|
67605
67634
|
walk2(root, []);
|
|
67606
67635
|
}
|
|
67607
67636
|
function readInstalledPlugins2(home) {
|
|
67608
|
-
const pluginsDir =
|
|
67609
|
-
const v22 =
|
|
67610
|
-
const v1 =
|
|
67637
|
+
const pluginsDir = import_node_path51.default.join(home, ".claude", "plugins");
|
|
67638
|
+
const v22 = import_node_path51.default.join(pluginsDir, "installed_plugins_v2.json");
|
|
67639
|
+
const v1 = import_node_path51.default.join(pluginsDir, "installed_plugins.json");
|
|
67611
67640
|
let raw = null;
|
|
67612
67641
|
for (const candidate of [v22, v1]) {
|
|
67613
67642
|
try {
|
|
67614
|
-
raw =
|
|
67643
|
+
raw = import_node_fs45.default.readFileSync(candidate, "utf8");
|
|
67615
67644
|
break;
|
|
67616
67645
|
} catch {
|
|
67617
67646
|
}
|
|
@@ -67636,19 +67665,19 @@ function readInstalledPlugins2(home) {
|
|
|
67636
67665
|
return out;
|
|
67637
67666
|
}
|
|
67638
67667
|
function walkUpProjectAgentsDirs(startCwd, home, seen, out) {
|
|
67639
|
-
let cur =
|
|
67640
|
-
const fsRoot =
|
|
67668
|
+
let cur = import_node_path51.default.resolve(startCwd);
|
|
67669
|
+
const fsRoot = import_node_path51.default.parse(cur).root;
|
|
67641
67670
|
while (true) {
|
|
67642
|
-
scanAgentsDir(
|
|
67671
|
+
scanAgentsDir(import_node_path51.default.join(cur, ".claude", "agents"), "project", seen, out);
|
|
67643
67672
|
let hasGit = false;
|
|
67644
67673
|
try {
|
|
67645
|
-
hasGit =
|
|
67674
|
+
hasGit = import_node_fs45.default.existsSync(import_node_path51.default.join(cur, ".git"));
|
|
67646
67675
|
} catch {
|
|
67647
67676
|
}
|
|
67648
67677
|
if (hasGit) return;
|
|
67649
67678
|
if (cur === home) return;
|
|
67650
67679
|
if (cur === fsRoot) return;
|
|
67651
|
-
const parent =
|
|
67680
|
+
const parent = import_node_path51.default.dirname(cur);
|
|
67652
67681
|
if (parent === cur) return;
|
|
67653
67682
|
cur = parent;
|
|
67654
67683
|
}
|
|
@@ -67658,7 +67687,7 @@ var AgentsScanner = class {
|
|
|
67658
67687
|
extraPluginRoots;
|
|
67659
67688
|
policyDir;
|
|
67660
67689
|
constructor(opts = {}) {
|
|
67661
|
-
this.home = opts.home ?? process.env.CLAUDE_CONFIG_DIR ??
|
|
67690
|
+
this.home = opts.home ?? process.env.CLAUDE_CONFIG_DIR ?? import_node_os18.default.homedir();
|
|
67662
67691
|
this.extraPluginRoots = opts.extraPluginRoots ?? [];
|
|
67663
67692
|
if (opts.policyDir !== void 0) {
|
|
67664
67693
|
this.policyDir = opts.policyDir;
|
|
@@ -67683,7 +67712,7 @@ var AgentsScanner = class {
|
|
|
67683
67712
|
}
|
|
67684
67713
|
const fsBlock = [];
|
|
67685
67714
|
scanAgentsDir(
|
|
67686
|
-
|
|
67715
|
+
import_node_path51.default.join(this.home, ".claude", "agents"),
|
|
67687
67716
|
"global",
|
|
67688
67717
|
seen,
|
|
67689
67718
|
fsBlock
|
|
@@ -67697,7 +67726,7 @@ var AgentsScanner = class {
|
|
|
67697
67726
|
...this.extraPluginRoots
|
|
67698
67727
|
];
|
|
67699
67728
|
for (const { name, root } of plugins) {
|
|
67700
|
-
const agentsRoot =
|
|
67729
|
+
const agentsRoot = import_node_path51.default.join(root, "agents");
|
|
67701
67730
|
scanPluginAgentsTree(agentsRoot, name, seen, fsBlock);
|
|
67702
67731
|
}
|
|
67703
67732
|
return [...builtinBlock, ...fsBlock];
|
|
@@ -67705,28 +67734,28 @@ var AgentsScanner = class {
|
|
|
67705
67734
|
};
|
|
67706
67735
|
|
|
67707
67736
|
// src/observer/session-observer.ts
|
|
67708
|
-
var
|
|
67709
|
-
var
|
|
67710
|
-
var
|
|
67737
|
+
var import_node_fs47 = __toESM(require("fs"), 1);
|
|
67738
|
+
var import_node_os20 = __toESM(require("os"), 1);
|
|
67739
|
+
var import_node_path53 = __toESM(require("path"), 1);
|
|
67711
67740
|
init_claude_history();
|
|
67712
67741
|
|
|
67713
67742
|
// src/observer/subagent-meta-observer.ts
|
|
67714
|
-
var
|
|
67715
|
-
var
|
|
67716
|
-
var
|
|
67743
|
+
var import_node_fs46 = __toESM(require("fs"), 1);
|
|
67744
|
+
var import_node_os19 = __toESM(require("os"), 1);
|
|
67745
|
+
var import_node_path52 = __toESM(require("path"), 1);
|
|
67717
67746
|
init_claude_history();
|
|
67718
67747
|
var META_RE = /^agent-([A-Za-z0-9_-]+)\.meta\.json$/;
|
|
67719
67748
|
var SubagentMetaObserver = class {
|
|
67720
67749
|
constructor(opts) {
|
|
67721
67750
|
this.opts = opts;
|
|
67722
|
-
this.home = opts.home ??
|
|
67751
|
+
this.home = opts.home ?? import_node_os19.default.homedir();
|
|
67723
67752
|
}
|
|
67724
67753
|
opts;
|
|
67725
67754
|
home;
|
|
67726
67755
|
watches = /* @__PURE__ */ new Map();
|
|
67727
67756
|
// public for spec only:测试直接拼路径写假 meta.json;生产 start() 内部自己解析
|
|
67728
67757
|
resolveSubagentDir(cwd, toolSessionId) {
|
|
67729
|
-
return
|
|
67758
|
+
return import_node_path52.default.join(
|
|
67730
67759
|
this.home,
|
|
67731
67760
|
".claude",
|
|
67732
67761
|
"projects",
|
|
@@ -67755,7 +67784,7 @@ var SubagentMetaObserver = class {
|
|
|
67755
67784
|
attachWatcher(w3) {
|
|
67756
67785
|
if (w3.watcher) return;
|
|
67757
67786
|
try {
|
|
67758
|
-
w3.watcher =
|
|
67787
|
+
w3.watcher = import_node_fs46.default.watch(w3.dirPath, { persistent: false }, (_evt, name) => {
|
|
67759
67788
|
if (!name) return;
|
|
67760
67789
|
const m3 = META_RE.exec(String(name));
|
|
67761
67790
|
if (!m3) return;
|
|
@@ -67767,7 +67796,7 @@ var SubagentMetaObserver = class {
|
|
|
67767
67796
|
scan(w3) {
|
|
67768
67797
|
let entries;
|
|
67769
67798
|
try {
|
|
67770
|
-
entries =
|
|
67799
|
+
entries = import_node_fs46.default.readdirSync(w3.dirPath);
|
|
67771
67800
|
} catch {
|
|
67772
67801
|
return;
|
|
67773
67802
|
}
|
|
@@ -67781,10 +67810,10 @@ var SubagentMetaObserver = class {
|
|
|
67781
67810
|
if (!m3) return;
|
|
67782
67811
|
const agentId = m3[1];
|
|
67783
67812
|
if (w3.emitted.has(agentId)) return;
|
|
67784
|
-
const file =
|
|
67813
|
+
const file = import_node_path52.default.join(w3.dirPath, name);
|
|
67785
67814
|
let raw;
|
|
67786
67815
|
try {
|
|
67787
|
-
raw =
|
|
67816
|
+
raw = import_node_fs46.default.readFileSync(file, "utf8");
|
|
67788
67817
|
} catch {
|
|
67789
67818
|
return;
|
|
67790
67819
|
}
|
|
@@ -67829,7 +67858,7 @@ var SubagentMetaObserver = class {
|
|
|
67829
67858
|
var SessionObserver = class {
|
|
67830
67859
|
constructor(opts) {
|
|
67831
67860
|
this.opts = opts;
|
|
67832
|
-
this.home = opts.home ??
|
|
67861
|
+
this.home = opts.home ?? import_node_os20.default.homedir();
|
|
67833
67862
|
this.metaObserver = opts.enableSubagentMetaObserver ? new SubagentMetaObserver({ home: this.home, onEvent: opts.onEvent }) : null;
|
|
67834
67863
|
}
|
|
67835
67864
|
opts;
|
|
@@ -67838,14 +67867,14 @@ var SessionObserver = class {
|
|
|
67838
67867
|
metaObserver;
|
|
67839
67868
|
resolveJsonlPath(cwd, toolSessionId, override) {
|
|
67840
67869
|
if (override) return override;
|
|
67841
|
-
return
|
|
67870
|
+
return import_node_path53.default.join(this.home, ".claude", "projects", cwdToHashDir(cwd), `${toolSessionId}.jsonl`);
|
|
67842
67871
|
}
|
|
67843
67872
|
start(args) {
|
|
67844
67873
|
this.stop(args.sessionId);
|
|
67845
67874
|
const filePath = this.resolveJsonlPath(args.cwd, args.toolSessionId, args.jsonlPath);
|
|
67846
67875
|
let size = 0;
|
|
67847
67876
|
try {
|
|
67848
|
-
size =
|
|
67877
|
+
size = import_node_fs47.default.statSync(filePath).size;
|
|
67849
67878
|
} catch {
|
|
67850
67879
|
}
|
|
67851
67880
|
const w3 = {
|
|
@@ -67858,16 +67887,16 @@ var SessionObserver = class {
|
|
|
67858
67887
|
adapter: args.adapter,
|
|
67859
67888
|
prevIsRejectSentinel: false,
|
|
67860
67889
|
toolSessionId: args.toolSessionId,
|
|
67861
|
-
sawFile:
|
|
67890
|
+
sawFile: import_node_fs47.default.existsSync(filePath),
|
|
67862
67891
|
lastRelocateScanMs: 0,
|
|
67863
67892
|
pendingCwdDerive: false,
|
|
67864
67893
|
lastDeriveMs: 0
|
|
67865
67894
|
};
|
|
67866
67895
|
try {
|
|
67867
|
-
|
|
67896
|
+
import_node_fs47.default.mkdirSync(import_node_path53.default.dirname(filePath), { recursive: true });
|
|
67868
67897
|
} catch {
|
|
67869
67898
|
}
|
|
67870
|
-
w3.watcher =
|
|
67899
|
+
w3.watcher = import_node_fs47.default.watch(import_node_path53.default.dirname(filePath), { persistent: false }, (_event, changedName) => {
|
|
67871
67900
|
if (!changedName || !w3.filePath.endsWith(changedName)) return;
|
|
67872
67901
|
this.poll(w3);
|
|
67873
67902
|
});
|
|
@@ -67887,7 +67916,7 @@ var SessionObserver = class {
|
|
|
67887
67916
|
// 读取或解析失败不阻塞 watcher 启动。
|
|
67888
67917
|
hydrateMetaTail(w3, maxLines = 200) {
|
|
67889
67918
|
try {
|
|
67890
|
-
const raw =
|
|
67919
|
+
const raw = import_node_fs47.default.readFileSync(w3.filePath, "utf8");
|
|
67891
67920
|
if (!raw) return;
|
|
67892
67921
|
const allLines = raw.split("\n").filter((l2) => l2.trim().length > 0);
|
|
67893
67922
|
if (allLines.length === 0) return;
|
|
@@ -67911,7 +67940,7 @@ var SessionObserver = class {
|
|
|
67911
67940
|
poll(w3) {
|
|
67912
67941
|
let size = 0;
|
|
67913
67942
|
try {
|
|
67914
|
-
size =
|
|
67943
|
+
size = import_node_fs47.default.statSync(w3.filePath).size;
|
|
67915
67944
|
} catch {
|
|
67916
67945
|
if (w3.sawFile) this.maybeRelocate(w3);
|
|
67917
67946
|
return;
|
|
@@ -67922,11 +67951,11 @@ var SessionObserver = class {
|
|
|
67922
67951
|
w3.buf = "";
|
|
67923
67952
|
}
|
|
67924
67953
|
if (size === w3.lastSize) return;
|
|
67925
|
-
const fd =
|
|
67954
|
+
const fd = import_node_fs47.default.openSync(w3.filePath, "r");
|
|
67926
67955
|
try {
|
|
67927
67956
|
const len = size - w3.lastSize;
|
|
67928
67957
|
const buf = Buffer.alloc(len);
|
|
67929
|
-
|
|
67958
|
+
import_node_fs47.default.readSync(fd, buf, 0, len, w3.lastSize);
|
|
67930
67959
|
w3.lastSize = size;
|
|
67931
67960
|
w3.buf += buf.toString("utf8");
|
|
67932
67961
|
let newlineIndex;
|
|
@@ -67949,7 +67978,7 @@ var SessionObserver = class {
|
|
|
67949
67978
|
}
|
|
67950
67979
|
}
|
|
67951
67980
|
} finally {
|
|
67952
|
-
|
|
67981
|
+
import_node_fs47.default.closeSync(fd);
|
|
67953
67982
|
}
|
|
67954
67983
|
if (w3.pendingCwdDerive) this.maybeDeriveCwd(w3);
|
|
67955
67984
|
}
|
|
@@ -67959,7 +67988,7 @@ var SessionObserver = class {
|
|
|
67959
67988
|
const now = Date.now();
|
|
67960
67989
|
if (now - w3.lastRelocateScanMs < 1e3) return;
|
|
67961
67990
|
w3.lastRelocateScanMs = now;
|
|
67962
|
-
const projectsRoot =
|
|
67991
|
+
const projectsRoot = import_node_path53.default.join(this.home, ".claude", "projects");
|
|
67963
67992
|
const found = findTranscriptByToolSessionId(projectsRoot, w3.toolSessionId);
|
|
67964
67993
|
if (!found || found === w3.filePath) return;
|
|
67965
67994
|
try {
|
|
@@ -67968,7 +67997,7 @@ var SessionObserver = class {
|
|
|
67968
67997
|
}
|
|
67969
67998
|
w3.filePath = found;
|
|
67970
67999
|
try {
|
|
67971
|
-
w3.watcher =
|
|
68000
|
+
w3.watcher = import_node_fs47.default.watch(import_node_path53.default.dirname(found), { persistent: false }, (_event, changedName) => {
|
|
67972
68001
|
if (!changedName || !w3.filePath.endsWith(changedName)) return;
|
|
67973
68002
|
this.poll(w3);
|
|
67974
68003
|
});
|
|
@@ -68086,11 +68115,11 @@ function listRegistered() {
|
|
|
68086
68115
|
}
|
|
68087
68116
|
|
|
68088
68117
|
// src/tools/title-generator.ts
|
|
68089
|
-
var
|
|
68118
|
+
var import_node_child_process14 = require("child_process");
|
|
68090
68119
|
init_protocol();
|
|
68091
|
-
var
|
|
68092
|
-
var
|
|
68093
|
-
var
|
|
68120
|
+
var import_node_fs48 = __toESM(require("fs"), 1);
|
|
68121
|
+
var import_node_os21 = __toESM(require("os"), 1);
|
|
68122
|
+
var import_node_path54 = __toESM(require("path"), 1);
|
|
68094
68123
|
var TITLE_GEN_DIR_PREFIX = "clawd-title-";
|
|
68095
68124
|
var TITLE_INPUT_MAX_CHARS = 400;
|
|
68096
68125
|
var DEFAULT_TITLE_GEN_TIMEOUT_MS = 45e3;
|
|
@@ -68181,21 +68210,21 @@ async function generateSessionTitle(file, firstMessage, deps = {}) {
|
|
|
68181
68210
|
}
|
|
68182
68211
|
let workDir;
|
|
68183
68212
|
try {
|
|
68184
|
-
workDir =
|
|
68213
|
+
workDir = import_node_fs48.default.mkdtempSync(import_node_path54.default.join(import_node_os21.default.tmpdir(), TITLE_GEN_DIR_PREFIX));
|
|
68185
68214
|
} catch {
|
|
68186
68215
|
return null;
|
|
68187
68216
|
}
|
|
68188
68217
|
const cleanupWorkDir = () => {
|
|
68189
68218
|
try {
|
|
68190
|
-
|
|
68219
|
+
import_node_fs48.default.rmSync(workDir, { recursive: true, force: true });
|
|
68191
68220
|
} catch {
|
|
68192
68221
|
}
|
|
68193
68222
|
};
|
|
68194
|
-
const outFile =
|
|
68195
|
-
const schemaFile =
|
|
68223
|
+
const outFile = import_node_path54.default.join(workDir, `codex-title-${process.pid}-${++outFileSeq}-${Date.now()}.txt`);
|
|
68224
|
+
const schemaFile = import_node_path54.default.join(workDir, "title-schema.json");
|
|
68196
68225
|
if (tool === "codex") {
|
|
68197
68226
|
try {
|
|
68198
|
-
|
|
68227
|
+
import_node_fs48.default.writeFileSync(schemaFile, CODEX_TITLE_SCHEMA);
|
|
68199
68228
|
} catch {
|
|
68200
68229
|
cleanupWorkDir();
|
|
68201
68230
|
return null;
|
|
@@ -68205,7 +68234,7 @@ async function generateSessionTitle(file, firstMessage, deps = {}) {
|
|
|
68205
68234
|
const chosenModel = file.resolvedModel || file.model;
|
|
68206
68235
|
const model = tool === "codex" ? sanitizeCodexModel(chosenModel) : chosenModel;
|
|
68207
68236
|
const args = tool === "claude" ? buildClaudeTitleArgs(buildClaudeTitlePrompt(text), model) : tool === "pi" ? buildPiTitleArgs(buildClaudeTitlePrompt(text), model) : buildCodexTitleArgs(buildTitlePrompt(text), outFile, schemaFile, model);
|
|
68208
|
-
const doSpawn = deps.spawnOverride ?? ((c2, a2, o2) => (0,
|
|
68237
|
+
const doSpawn = deps.spawnOverride ?? ((c2, a2, o2) => (0, import_node_child_process14.spawn)(c2, a2, { ...o2, stdio: ["ignore", "pipe", "pipe"] }));
|
|
68209
68238
|
const timeoutMs = deps.timeoutMs ?? DEFAULT_TITLE_GEN_TIMEOUT_MS;
|
|
68210
68239
|
return await new Promise((resolve9) => {
|
|
68211
68240
|
let proc;
|
|
@@ -68250,7 +68279,7 @@ async function generateSessionTitle(file, firstMessage, deps = {}) {
|
|
|
68250
68279
|
if (tool === "claude" || tool === "pi") return finish(parseTitleJson(stdout));
|
|
68251
68280
|
let fileText = "";
|
|
68252
68281
|
try {
|
|
68253
|
-
fileText =
|
|
68282
|
+
fileText = import_node_fs48.default.readFileSync(outFile, "utf8");
|
|
68254
68283
|
} catch {
|
|
68255
68284
|
return finish(null);
|
|
68256
68285
|
}
|
|
@@ -68928,8 +68957,8 @@ async function authenticate(token, deps) {
|
|
|
68928
68957
|
}
|
|
68929
68958
|
|
|
68930
68959
|
// src/legacy-cleanup.ts
|
|
68931
|
-
var
|
|
68932
|
-
var
|
|
68960
|
+
var fs59 = __toESM(require("fs/promises"), 1);
|
|
68961
|
+
var path62 = __toESM(require("path"), 1);
|
|
68933
68962
|
var LEGACY_FILES = [
|
|
68934
68963
|
"personal-capability.json",
|
|
68935
68964
|
"received-capabilities.json",
|
|
@@ -68938,9 +68967,9 @@ var LEGACY_FILES = [
|
|
|
68938
68967
|
async function cleanupLegacyCapabilityFiles(dataDir, logger) {
|
|
68939
68968
|
const removed = [];
|
|
68940
68969
|
for (const name of LEGACY_FILES) {
|
|
68941
|
-
const p3 =
|
|
68970
|
+
const p3 = path62.join(dataDir, name);
|
|
68942
68971
|
try {
|
|
68943
|
-
await
|
|
68972
|
+
await fs59.unlink(p3);
|
|
68944
68973
|
removed.push(name);
|
|
68945
68974
|
logger.debug("legacy capability file removed", { file: name });
|
|
68946
68975
|
} catch (err) {
|
|
@@ -68952,13 +68981,13 @@ async function cleanupLegacyCapabilityFiles(dataDir, logger) {
|
|
|
68952
68981
|
}
|
|
68953
68982
|
|
|
68954
68983
|
// src/inbox/inbox-store.ts
|
|
68955
|
-
var
|
|
68956
|
-
var
|
|
68984
|
+
var fs60 = __toESM(require("fs"), 1);
|
|
68985
|
+
var path63 = __toESM(require("path"), 1);
|
|
68957
68986
|
var INBOX_SUBDIR = "inbox";
|
|
68958
68987
|
var InboxStore = class {
|
|
68959
68988
|
constructor(dataDir) {
|
|
68960
68989
|
this.dataDir = dataDir;
|
|
68961
|
-
|
|
68990
|
+
fs60.mkdirSync(this.dirPath(), { recursive: true });
|
|
68962
68991
|
}
|
|
68963
68992
|
dataDir;
|
|
68964
68993
|
/** sinceCreatedAt 缺省读全量,否则仅读时间戳更大的消息;读取失败返回空数组。 */
|
|
@@ -68966,7 +68995,7 @@ var InboxStore = class {
|
|
|
68966
68995
|
const file = this.filePath(peerDeviceId);
|
|
68967
68996
|
let raw;
|
|
68968
68997
|
try {
|
|
68969
|
-
raw =
|
|
68998
|
+
raw = fs60.readFileSync(file, "utf8");
|
|
68970
68999
|
} catch (err) {
|
|
68971
69000
|
if (err?.code === "ENOENT") return [];
|
|
68972
69001
|
return [];
|
|
@@ -68979,7 +69008,7 @@ var InboxStore = class {
|
|
|
68979
69008
|
const dir = this.dirPath();
|
|
68980
69009
|
let entries;
|
|
68981
69010
|
try {
|
|
68982
|
-
entries =
|
|
69011
|
+
entries = fs60.readdirSync(dir);
|
|
68983
69012
|
} catch (err) {
|
|
68984
69013
|
if (err?.code === "ENOENT") return [];
|
|
68985
69014
|
return [];
|
|
@@ -68992,9 +69021,9 @@ var InboxStore = class {
|
|
|
68992
69021
|
if (existing.some((m3) => m3.id === message.id)) return;
|
|
68993
69022
|
const file = this.filePath(message.peerDeviceId);
|
|
68994
69023
|
const line = JSON.stringify(message) + "\n";
|
|
68995
|
-
|
|
69024
|
+
fs60.appendFileSync(file, line, { mode: 384 });
|
|
68996
69025
|
try {
|
|
68997
|
-
|
|
69026
|
+
fs60.chmodSync(file, 384);
|
|
68998
69027
|
} catch {
|
|
68999
69028
|
}
|
|
69000
69029
|
}
|
|
@@ -69017,7 +69046,7 @@ var InboxStore = class {
|
|
|
69017
69046
|
removeByPeerDeviceId(peerDeviceId) {
|
|
69018
69047
|
const file = this.filePath(peerDeviceId);
|
|
69019
69048
|
try {
|
|
69020
|
-
|
|
69049
|
+
fs60.unlinkSync(file);
|
|
69021
69050
|
} catch (err) {
|
|
69022
69051
|
if (err?.code === "ENOENT") return;
|
|
69023
69052
|
}
|
|
@@ -69026,18 +69055,18 @@ var InboxStore = class {
|
|
|
69026
69055
|
const file = this.filePath(peerDeviceId);
|
|
69027
69056
|
const tmp = `${file}.tmp-${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
69028
69057
|
const content = messages.map((m3) => JSON.stringify(m3)).join("\n") + (messages.length > 0 ? "\n" : "");
|
|
69029
|
-
|
|
69030
|
-
|
|
69058
|
+
fs60.writeFileSync(tmp, content, { mode: 384 });
|
|
69059
|
+
fs60.renameSync(tmp, file);
|
|
69031
69060
|
try {
|
|
69032
|
-
|
|
69061
|
+
fs60.chmodSync(file, 384);
|
|
69033
69062
|
} catch {
|
|
69034
69063
|
}
|
|
69035
69064
|
}
|
|
69036
69065
|
dirPath() {
|
|
69037
|
-
return
|
|
69066
|
+
return path63.join(this.dataDir, INBOX_SUBDIR);
|
|
69038
69067
|
}
|
|
69039
69068
|
filePath(peerDeviceId) {
|
|
69040
|
-
return
|
|
69069
|
+
return path63.join(this.dirPath(), `${peerDeviceId}.jsonl`);
|
|
69041
69070
|
}
|
|
69042
69071
|
};
|
|
69043
69072
|
function parseAllLines(raw) {
|
|
@@ -69115,8 +69144,8 @@ var InboxManager = class {
|
|
|
69115
69144
|
};
|
|
69116
69145
|
|
|
69117
69146
|
// src/state/contact-store.ts
|
|
69118
|
-
var
|
|
69119
|
-
var
|
|
69147
|
+
var fs61 = __toESM(require("fs"), 1);
|
|
69148
|
+
var path64 = __toESM(require("path"), 1);
|
|
69120
69149
|
var FILE_NAME = "contacts.json";
|
|
69121
69150
|
var ContactStore = class {
|
|
69122
69151
|
constructor(dataDir) {
|
|
@@ -69126,10 +69155,10 @@ var ContactStore = class {
|
|
|
69126
69155
|
contacts = /* @__PURE__ */ new Map();
|
|
69127
69156
|
load() {
|
|
69128
69157
|
this.contacts.clear();
|
|
69129
|
-
const file =
|
|
69158
|
+
const file = path64.join(this.dataDir, FILE_NAME);
|
|
69130
69159
|
let raw;
|
|
69131
69160
|
try {
|
|
69132
|
-
raw =
|
|
69161
|
+
raw = fs61.readFileSync(file, "utf8");
|
|
69133
69162
|
} catch (err) {
|
|
69134
69163
|
if (err?.code !== "ENOENT") this.renameBak(file);
|
|
69135
69164
|
return;
|
|
@@ -69199,20 +69228,20 @@ var ContactStore = class {
|
|
|
69199
69228
|
return true;
|
|
69200
69229
|
}
|
|
69201
69230
|
flush() {
|
|
69202
|
-
const file =
|
|
69231
|
+
const file = path64.join(this.dataDir, FILE_NAME);
|
|
69203
69232
|
const tmp = `${file}.tmp-${process.pid}-${Date.now()}`;
|
|
69204
69233
|
const content = JSON.stringify(
|
|
69205
69234
|
{ contacts: Array.from(this.contacts.values()) },
|
|
69206
69235
|
null,
|
|
69207
69236
|
2
|
|
69208
69237
|
);
|
|
69209
|
-
|
|
69210
|
-
|
|
69211
|
-
|
|
69238
|
+
fs61.mkdirSync(this.dataDir, { recursive: true });
|
|
69239
|
+
fs61.writeFileSync(tmp, content, { mode: 384 });
|
|
69240
|
+
fs61.renameSync(tmp, file);
|
|
69212
69241
|
}
|
|
69213
69242
|
renameBak(file) {
|
|
69214
69243
|
try {
|
|
69215
|
-
|
|
69244
|
+
fs61.renameSync(file, `${file}.bak`);
|
|
69216
69245
|
} catch {
|
|
69217
69246
|
}
|
|
69218
69247
|
}
|
|
@@ -69320,61 +69349,61 @@ async function connectRemote(args) {
|
|
|
69320
69349
|
}
|
|
69321
69350
|
|
|
69322
69351
|
// src/migrations/2026-05-20-flatten-sessions.ts
|
|
69323
|
-
var
|
|
69324
|
-
var
|
|
69352
|
+
var fs62 = __toESM(require("fs"), 1);
|
|
69353
|
+
var path65 = __toESM(require("path"), 1);
|
|
69325
69354
|
var MIGRATION_FLAG_NAME = ".migration.v1.done";
|
|
69326
69355
|
function migrateFlattenSessions(opts) {
|
|
69327
69356
|
const dataDir = opts.dataDir;
|
|
69328
69357
|
const now = opts.now ?? Date.now;
|
|
69329
|
-
const sessionsDir =
|
|
69330
|
-
const flagPath =
|
|
69358
|
+
const sessionsDir = path65.join(dataDir, "sessions");
|
|
69359
|
+
const flagPath = path65.join(sessionsDir, MIGRATION_FLAG_NAME);
|
|
69331
69360
|
if (existsSync3(flagPath)) {
|
|
69332
69361
|
return { skipped: true, flagWritten: false, movedBare: 0, movedVmOwner: 0, archivedListener: 0 };
|
|
69333
69362
|
}
|
|
69334
69363
|
let movedBare = 0;
|
|
69335
69364
|
let movedVmOwner = 0;
|
|
69336
69365
|
let archivedListener = 0;
|
|
69337
|
-
const defaultDir =
|
|
69366
|
+
const defaultDir = path65.join(sessionsDir, "default");
|
|
69338
69367
|
if (existsSync3(defaultDir)) {
|
|
69339
69368
|
for (const entry of readdirSafe(defaultDir)) {
|
|
69340
69369
|
if (!entry.endsWith(".json")) continue;
|
|
69341
|
-
const src =
|
|
69342
|
-
const dst =
|
|
69343
|
-
|
|
69370
|
+
const src = path65.join(defaultDir, entry);
|
|
69371
|
+
const dst = path65.join(sessionsDir, entry);
|
|
69372
|
+
fs62.renameSync(src, dst);
|
|
69344
69373
|
movedBare += 1;
|
|
69345
69374
|
}
|
|
69346
69375
|
rmdirIfEmpty(defaultDir);
|
|
69347
69376
|
}
|
|
69348
69377
|
for (const pid of readdirSafe(sessionsDir)) {
|
|
69349
|
-
const personaDir =
|
|
69378
|
+
const personaDir = path65.join(sessionsDir, pid);
|
|
69350
69379
|
if (!isDir(personaDir)) continue;
|
|
69351
69380
|
if (pid === "default") continue;
|
|
69352
|
-
const ownerSrc =
|
|
69381
|
+
const ownerSrc = path65.join(personaDir, "owner");
|
|
69353
69382
|
if (existsSync3(ownerSrc) && isDir(ownerSrc)) {
|
|
69354
|
-
const ownerDst =
|
|
69355
|
-
|
|
69383
|
+
const ownerDst = path65.join(dataDir, "personas", pid, ".clawd", "sessions", "owner");
|
|
69384
|
+
fs62.mkdirSync(ownerDst, { recursive: true });
|
|
69356
69385
|
for (const file of readdirSafe(ownerSrc)) {
|
|
69357
69386
|
if (!file.endsWith(".json")) continue;
|
|
69358
|
-
|
|
69387
|
+
fs62.renameSync(path65.join(ownerSrc, file), path65.join(ownerDst, file));
|
|
69359
69388
|
movedVmOwner += 1;
|
|
69360
69389
|
}
|
|
69361
69390
|
rmdirIfEmpty(ownerSrc);
|
|
69362
69391
|
}
|
|
69363
|
-
const listenerSrc =
|
|
69392
|
+
const listenerSrc = path65.join(personaDir, "listener");
|
|
69364
69393
|
if (existsSync3(listenerSrc) && isDir(listenerSrc)) {
|
|
69365
|
-
const archiveDst =
|
|
69366
|
-
|
|
69394
|
+
const archiveDst = path65.join(dataDir, ".legacy", `listener-${pid}`);
|
|
69395
|
+
fs62.mkdirSync(archiveDst, { recursive: true });
|
|
69367
69396
|
for (const file of readdirSafe(listenerSrc)) {
|
|
69368
69397
|
if (!file.endsWith(".json")) continue;
|
|
69369
|
-
|
|
69398
|
+
fs62.renameSync(path65.join(listenerSrc, file), path65.join(archiveDst, file));
|
|
69370
69399
|
archivedListener += 1;
|
|
69371
69400
|
}
|
|
69372
69401
|
rmdirIfEmpty(listenerSrc);
|
|
69373
69402
|
}
|
|
69374
69403
|
rmdirIfEmpty(personaDir);
|
|
69375
69404
|
}
|
|
69376
|
-
|
|
69377
|
-
|
|
69405
|
+
fs62.mkdirSync(sessionsDir, { recursive: true });
|
|
69406
|
+
fs62.writeFileSync(flagPath, JSON.stringify({ migratedAt: now() }, null, 2));
|
|
69378
69407
|
return {
|
|
69379
69408
|
skipped: false,
|
|
69380
69409
|
flagWritten: true,
|
|
@@ -69385,7 +69414,7 @@ function migrateFlattenSessions(opts) {
|
|
|
69385
69414
|
}
|
|
69386
69415
|
function existsSync3(p3) {
|
|
69387
69416
|
try {
|
|
69388
|
-
|
|
69417
|
+
fs62.statSync(p3);
|
|
69389
69418
|
return true;
|
|
69390
69419
|
} catch {
|
|
69391
69420
|
return false;
|
|
@@ -69393,62 +69422,62 @@ function existsSync3(p3) {
|
|
|
69393
69422
|
}
|
|
69394
69423
|
function isDir(p3) {
|
|
69395
69424
|
try {
|
|
69396
|
-
return
|
|
69425
|
+
return fs62.statSync(p3).isDirectory();
|
|
69397
69426
|
} catch {
|
|
69398
69427
|
return false;
|
|
69399
69428
|
}
|
|
69400
69429
|
}
|
|
69401
69430
|
function readdirSafe(p3) {
|
|
69402
69431
|
try {
|
|
69403
|
-
return
|
|
69432
|
+
return fs62.readdirSync(p3);
|
|
69404
69433
|
} catch {
|
|
69405
69434
|
return [];
|
|
69406
69435
|
}
|
|
69407
69436
|
}
|
|
69408
69437
|
function rmdirIfEmpty(p3) {
|
|
69409
69438
|
try {
|
|
69410
|
-
|
|
69439
|
+
fs62.rmdirSync(p3);
|
|
69411
69440
|
} catch {
|
|
69412
69441
|
}
|
|
69413
69442
|
}
|
|
69414
69443
|
|
|
69415
69444
|
// src/migrations/2026-08-18-drop-seeded-projects.ts
|
|
69416
|
-
var
|
|
69417
|
-
var
|
|
69445
|
+
var fs63 = __toESM(require("fs"), 1);
|
|
69446
|
+
var path66 = __toESM(require("path"), 1);
|
|
69418
69447
|
var DROP_SEEDED_PROJECTS_FLAG = ".projects-seed-dropped.v1.done";
|
|
69419
69448
|
function dropSeededProjects(opts) {
|
|
69420
|
-
|
|
69421
|
-
const flag =
|
|
69422
|
-
if (
|
|
69423
|
-
const file =
|
|
69449
|
+
fs63.mkdirSync(opts.dataDir, { recursive: true });
|
|
69450
|
+
const flag = path66.join(opts.dataDir, DROP_SEEDED_PROJECTS_FLAG);
|
|
69451
|
+
if (fs63.existsSync(flag)) return { skipped: true, dropped: 0, backup: null };
|
|
69452
|
+
const file = path66.join(opts.dataDir, "projects.json");
|
|
69424
69453
|
let raw = null;
|
|
69425
69454
|
let dropped = 0;
|
|
69426
69455
|
try {
|
|
69427
|
-
raw =
|
|
69456
|
+
raw = fs63.readFileSync(file, "utf8");
|
|
69428
69457
|
dropped = JSON.parse(raw).projects?.length ?? 0;
|
|
69429
69458
|
} catch {
|
|
69430
69459
|
}
|
|
69431
69460
|
let backup = null;
|
|
69432
69461
|
if (raw != null && dropped > 0) {
|
|
69433
|
-
const dir =
|
|
69434
|
-
|
|
69435
|
-
backup =
|
|
69436
|
-
|
|
69462
|
+
const dir = path66.join(opts.dataDir, "backups");
|
|
69463
|
+
fs63.mkdirSync(dir, { recursive: true });
|
|
69464
|
+
backup = path66.join(dir, `projects.seed-dropped.${(opts.now ?? Date.now)()}.json`);
|
|
69465
|
+
fs63.writeFileSync(backup, raw);
|
|
69437
69466
|
}
|
|
69438
69467
|
if (raw != null || dropped > 0) {
|
|
69439
|
-
|
|
69468
|
+
fs63.writeFileSync(file, JSON.stringify({ projects: [] }, null, 2));
|
|
69440
69469
|
}
|
|
69441
|
-
|
|
69470
|
+
fs63.writeFileSync(flag, (/* @__PURE__ */ new Date()).toISOString());
|
|
69442
69471
|
return { skipped: false, dropped, backup };
|
|
69443
69472
|
}
|
|
69444
69473
|
|
|
69445
69474
|
// src/transport/http-router.ts
|
|
69446
|
-
var
|
|
69447
|
-
var
|
|
69475
|
+
var import_node_fs50 = __toESM(require("fs"), 1);
|
|
69476
|
+
var import_node_path57 = __toESM(require("path"), 1);
|
|
69448
69477
|
|
|
69449
69478
|
// src/attachment/upload.ts
|
|
69450
|
-
var
|
|
69451
|
-
var
|
|
69479
|
+
var import_node_fs49 = __toESM(require("fs"), 1);
|
|
69480
|
+
var import_node_path55 = __toESM(require("path"), 1);
|
|
69452
69481
|
var import_node_crypto19 = __toESM(require("crypto"), 1);
|
|
69453
69482
|
var import_promises8 = require("stream/promises");
|
|
69454
69483
|
var UploadError = class extends Error {
|
|
@@ -69460,22 +69489,22 @@ var UploadError = class extends Error {
|
|
|
69460
69489
|
code;
|
|
69461
69490
|
};
|
|
69462
69491
|
function assertValidFileName(fileName) {
|
|
69463
|
-
if (fileName.length === 0 || fileName === "." || fileName === ".." || fileName.startsWith(".") || fileName.includes("/") || fileName.includes("\\") || fileName !==
|
|
69492
|
+
if (fileName.length === 0 || fileName === "." || fileName === ".." || fileName.startsWith(".") || fileName.includes("/") || fileName.includes("\\") || fileName !== import_node_path55.default.basename(fileName)) {
|
|
69464
69493
|
throw new UploadError("INVALID_FILENAME", `fileName must be a plain basename, got: ${fileName}`);
|
|
69465
69494
|
}
|
|
69466
69495
|
}
|
|
69467
69496
|
var HASH_PREFIX_LEN = 16;
|
|
69468
69497
|
async function writeUploadedAttachment(args) {
|
|
69469
69498
|
assertValidFileName(args.fileName);
|
|
69470
|
-
const attachmentsRoot =
|
|
69499
|
+
const attachmentsRoot = import_node_path55.default.join(args.baseDir, ".attachments");
|
|
69471
69500
|
try {
|
|
69472
|
-
|
|
69501
|
+
import_node_fs49.default.mkdirSync(attachmentsRoot, { recursive: true });
|
|
69473
69502
|
} catch (err) {
|
|
69474
69503
|
throw new UploadError("STORAGE_ERROR", `mkdir failed: ${err.message}`);
|
|
69475
69504
|
}
|
|
69476
69505
|
const hasher = import_node_crypto19.default.createHash("sha256");
|
|
69477
69506
|
let actualSize = 0;
|
|
69478
|
-
const tmpPath =
|
|
69507
|
+
const tmpPath = import_node_path55.default.join(
|
|
69479
69508
|
attachmentsRoot,
|
|
69480
69509
|
`.upload-${process.pid}-${Date.now()}-${import_node_crypto19.default.randomBytes(4).toString("hex")}`
|
|
69481
69510
|
);
|
|
@@ -69490,18 +69519,18 @@ async function writeUploadedAttachment(args) {
|
|
|
69490
69519
|
yield buf;
|
|
69491
69520
|
}
|
|
69492
69521
|
},
|
|
69493
|
-
|
|
69522
|
+
import_node_fs49.default.createWriteStream(tmpPath, { mode: 384 })
|
|
69494
69523
|
);
|
|
69495
69524
|
} catch (err) {
|
|
69496
69525
|
try {
|
|
69497
|
-
|
|
69526
|
+
import_node_fs49.default.unlinkSync(tmpPath);
|
|
69498
69527
|
} catch {
|
|
69499
69528
|
}
|
|
69500
69529
|
throw new UploadError("STORAGE_ERROR", `write failed: ${err.message}`);
|
|
69501
69530
|
}
|
|
69502
69531
|
if (actualSize !== args.contentLength) {
|
|
69503
69532
|
try {
|
|
69504
|
-
|
|
69533
|
+
import_node_fs49.default.unlinkSync(tmpPath);
|
|
69505
69534
|
} catch {
|
|
69506
69535
|
}
|
|
69507
69536
|
throw new UploadError(
|
|
@@ -69510,34 +69539,34 @@ async function writeUploadedAttachment(args) {
|
|
|
69510
69539
|
);
|
|
69511
69540
|
}
|
|
69512
69541
|
const attachmentId = hasher.digest("hex").slice(0, HASH_PREFIX_LEN);
|
|
69513
|
-
const hashDir =
|
|
69542
|
+
const hashDir = import_node_path55.default.join(attachmentsRoot, attachmentId);
|
|
69514
69543
|
let finalFileName;
|
|
69515
69544
|
let hashDirExists = false;
|
|
69516
69545
|
try {
|
|
69517
|
-
hashDirExists =
|
|
69546
|
+
hashDirExists = import_node_fs49.default.statSync(hashDir).isDirectory();
|
|
69518
69547
|
} catch {
|
|
69519
69548
|
}
|
|
69520
69549
|
if (hashDirExists) {
|
|
69521
|
-
const existing =
|
|
69550
|
+
const existing = import_node_fs49.default.readdirSync(hashDir).filter((n2) => !n2.startsWith("."));
|
|
69522
69551
|
finalFileName = existing[0] ?? args.fileName;
|
|
69523
69552
|
try {
|
|
69524
|
-
|
|
69553
|
+
import_node_fs49.default.unlinkSync(tmpPath);
|
|
69525
69554
|
} catch {
|
|
69526
69555
|
}
|
|
69527
69556
|
} else {
|
|
69528
69557
|
try {
|
|
69529
|
-
|
|
69558
|
+
import_node_fs49.default.mkdirSync(hashDir, { recursive: true });
|
|
69530
69559
|
finalFileName = args.fileName;
|
|
69531
|
-
|
|
69560
|
+
import_node_fs49.default.renameSync(tmpPath, import_node_path55.default.join(hashDir, finalFileName));
|
|
69532
69561
|
} catch (err) {
|
|
69533
69562
|
try {
|
|
69534
|
-
|
|
69563
|
+
import_node_fs49.default.unlinkSync(tmpPath);
|
|
69535
69564
|
} catch {
|
|
69536
69565
|
}
|
|
69537
69566
|
throw new UploadError("STORAGE_ERROR", `rename failed: ${err.message}`);
|
|
69538
69567
|
}
|
|
69539
69568
|
}
|
|
69540
|
-
const absPath =
|
|
69569
|
+
const absPath = import_node_path55.default.join(hashDir, finalFileName);
|
|
69541
69570
|
const relPath = absPath;
|
|
69542
69571
|
args.groupFileStore.upsert(args.scope, args.sessionId, {
|
|
69543
69572
|
relPath: absPath,
|
|
@@ -69551,8 +69580,8 @@ async function writeUploadedAttachment(args) {
|
|
|
69551
69580
|
|
|
69552
69581
|
// src/extension/import.ts
|
|
69553
69582
|
var import_promises9 = __toESM(require("fs/promises"), 1);
|
|
69554
|
-
var
|
|
69555
|
-
var
|
|
69583
|
+
var import_node_path56 = __toESM(require("path"), 1);
|
|
69584
|
+
var import_node_os22 = __toESM(require("os"), 1);
|
|
69556
69585
|
var import_jszip2 = __toESM(require_lib3(), 1);
|
|
69557
69586
|
var ImportError = class extends Error {
|
|
69558
69587
|
constructor(code, message) {
|
|
@@ -69569,7 +69598,7 @@ async function importZip(buf, root) {
|
|
|
69569
69598
|
throw new ImportError("ZIP_INVALID", `failed to load zip: ${e.message}`);
|
|
69570
69599
|
}
|
|
69571
69600
|
for (const name of Object.keys(zip.files)) {
|
|
69572
|
-
if (name.includes("..") || name.startsWith("/") ||
|
|
69601
|
+
if (name.includes("..") || name.startsWith("/") || import_node_path56.default.isAbsolute(name)) {
|
|
69573
69602
|
throw new ImportError("ZIP_INVALID", `unsafe zip entry path: ${name}`);
|
|
69574
69603
|
}
|
|
69575
69604
|
}
|
|
@@ -69602,7 +69631,7 @@ async function importZip(buf, root) {
|
|
|
69602
69631
|
);
|
|
69603
69632
|
}
|
|
69604
69633
|
}
|
|
69605
|
-
const destDir =
|
|
69634
|
+
const destDir = import_node_path56.default.join(root, manifest.id);
|
|
69606
69635
|
let destExists = false;
|
|
69607
69636
|
try {
|
|
69608
69637
|
await import_promises9.default.access(destDir);
|
|
@@ -69612,15 +69641,15 @@ async function importZip(buf, root) {
|
|
|
69612
69641
|
if (destExists) {
|
|
69613
69642
|
throw new ImportError("ALREADY_EXISTS", `extension ${manifest.id} already installed`);
|
|
69614
69643
|
}
|
|
69615
|
-
const stage = await import_promises9.default.mkdtemp(
|
|
69644
|
+
const stage = await import_promises9.default.mkdtemp(import_node_path56.default.join(import_node_os22.default.tmpdir(), `clawd-ext-stage-${manifest.id}-`));
|
|
69616
69645
|
try {
|
|
69617
69646
|
for (const [name, entry] of Object.entries(zip.files)) {
|
|
69618
|
-
const dest =
|
|
69647
|
+
const dest = import_node_path56.default.join(stage, name);
|
|
69619
69648
|
if (entry.dir) {
|
|
69620
69649
|
await import_promises9.default.mkdir(dest, { recursive: true });
|
|
69621
69650
|
continue;
|
|
69622
69651
|
}
|
|
69623
|
-
await import_promises9.default.mkdir(
|
|
69652
|
+
await import_promises9.default.mkdir(import_node_path56.default.dirname(dest), { recursive: true });
|
|
69624
69653
|
const content = await entry.async("nodebuffer");
|
|
69625
69654
|
await import_promises9.default.writeFile(dest, content);
|
|
69626
69655
|
}
|
|
@@ -69674,7 +69703,7 @@ var SHARE_UI_ASSET_MIME = {
|
|
|
69674
69703
|
".wasm": "application/wasm"
|
|
69675
69704
|
};
|
|
69676
69705
|
function shareUiAssetMime(filePath) {
|
|
69677
|
-
const ext =
|
|
69706
|
+
const ext = import_node_path57.default.extname(filePath).toLowerCase();
|
|
69678
69707
|
return SHARE_UI_ASSET_MIME[ext] ?? lookupMime(filePath);
|
|
69679
69708
|
}
|
|
69680
69709
|
var AUTHED_RPC_ROUTE_PREFIX = "/rpc/";
|
|
@@ -69760,7 +69789,7 @@ function isValidUploadFileName(fileName) {
|
|
|
69760
69789
|
if (fileName === "." || fileName === "..") return false;
|
|
69761
69790
|
if (fileName.startsWith(".")) return false;
|
|
69762
69791
|
if (fileName.includes("/") || fileName.includes("\\")) return false;
|
|
69763
|
-
return fileName ===
|
|
69792
|
+
return fileName === import_node_path57.default.basename(fileName);
|
|
69764
69793
|
}
|
|
69765
69794
|
function createHttpRouter(deps) {
|
|
69766
69795
|
return async (req, res) => {
|
|
@@ -69844,7 +69873,7 @@ function createHttpRouter(deps) {
|
|
|
69844
69873
|
}
|
|
69845
69874
|
let buf;
|
|
69846
69875
|
try {
|
|
69847
|
-
buf = await
|
|
69876
|
+
buf = await import_node_fs50.default.promises.readFile(abs);
|
|
69848
69877
|
} catch {
|
|
69849
69878
|
sendJson2(res, 404, { code: "NOT_FOUND", message: "asset not found" });
|
|
69850
69879
|
return true;
|
|
@@ -69990,7 +70019,7 @@ function createHttpRouter(deps) {
|
|
|
69990
70019
|
sendHtml(res, statusByCode[r2.code], loader.renderErrorHtml(r2.code, msgByCode[r2.code]));
|
|
69991
70020
|
return true;
|
|
69992
70021
|
}
|
|
69993
|
-
sendHtml(res, 200, loader.renderViewerHtml(
|
|
70022
|
+
sendHtml(res, 200, loader.renderViewerHtml(import_node_path57.default.basename(r2.absPath)));
|
|
69994
70023
|
return true;
|
|
69995
70024
|
}
|
|
69996
70025
|
const ctx = deps.authResolver.resolveFromHeader(
|
|
@@ -70112,7 +70141,7 @@ function createHttpRouter(deps) {
|
|
|
70112
70141
|
return true;
|
|
70113
70142
|
}
|
|
70114
70143
|
let absPath;
|
|
70115
|
-
if (
|
|
70144
|
+
if (import_node_path57.default.isAbsolute(pathParam)) {
|
|
70116
70145
|
absPath = pathParam;
|
|
70117
70146
|
} else if (deps.sessionStore) {
|
|
70118
70147
|
const file = deps.sessionStore.read(sid);
|
|
@@ -70120,7 +70149,7 @@ function createHttpRouter(deps) {
|
|
|
70120
70149
|
sendJson2(res, 404, { code: "NOT_FOUND", message: `session ${sid} not found` });
|
|
70121
70150
|
return true;
|
|
70122
70151
|
}
|
|
70123
|
-
absPath =
|
|
70152
|
+
absPath = import_node_path57.default.join(file.cwd, pathParam);
|
|
70124
70153
|
} else {
|
|
70125
70154
|
sendJson2(res, 501, withCtx(ctx, { code: "NOT_IMPLEMENTED", message: "sessionStore not wired" }));
|
|
70126
70155
|
return true;
|
|
@@ -70204,7 +70233,7 @@ function withCtx(ctx, body) {
|
|
|
70204
70233
|
function streamFile(res, absPath, logger) {
|
|
70205
70234
|
let stat;
|
|
70206
70235
|
try {
|
|
70207
|
-
stat =
|
|
70236
|
+
stat = import_node_fs50.default.statSync(absPath);
|
|
70208
70237
|
} catch (err) {
|
|
70209
70238
|
const code = err?.code;
|
|
70210
70239
|
if (code === "ENOENT") {
|
|
@@ -70219,7 +70248,7 @@ function streamFile(res, absPath, logger) {
|
|
|
70219
70248
|
return;
|
|
70220
70249
|
}
|
|
70221
70250
|
const mime = lookupMime(absPath);
|
|
70222
|
-
const basename2 =
|
|
70251
|
+
const basename2 = import_node_path57.default.basename(absPath);
|
|
70223
70252
|
res.writeHead(200, {
|
|
70224
70253
|
"Content-Type": mime,
|
|
70225
70254
|
"Content-Length": String(stat.size),
|
|
@@ -70227,7 +70256,7 @@ function streamFile(res, absPath, logger) {
|
|
|
70227
70256
|
// Prevent MIME sniffing; explicit HTML MIME remains renderable.
|
|
70228
70257
|
"X-Content-Type-Options": "nosniff"
|
|
70229
70258
|
});
|
|
70230
|
-
const stream =
|
|
70259
|
+
const stream = import_node_fs50.default.createReadStream(absPath);
|
|
70231
70260
|
stream.on("error", (err) => {
|
|
70232
70261
|
logger?.warn("streamFile read error", { absPath, err: err.message });
|
|
70233
70262
|
res.destroy();
|
|
@@ -70236,8 +70265,8 @@ function streamFile(res, absPath, logger) {
|
|
|
70236
70265
|
}
|
|
70237
70266
|
|
|
70238
70267
|
// src/attachment/gc.ts
|
|
70239
|
-
var
|
|
70240
|
-
var
|
|
70268
|
+
var import_node_fs51 = __toESM(require("fs"), 1);
|
|
70269
|
+
var import_node_path58 = __toESM(require("path"), 1);
|
|
70241
70270
|
var DEFAULT_TTL_MS = 30 * 24 * 3600 * 1e3;
|
|
70242
70271
|
function runAttachmentGc(args) {
|
|
70243
70272
|
const now = (args.now ?? Date.now)();
|
|
@@ -70246,12 +70275,12 @@ function runAttachmentGc(args) {
|
|
|
70246
70275
|
for (const { scope, sessionId } of args.sessionScopes) {
|
|
70247
70276
|
for (const entry of args.groupFileStore.list(scope, sessionId)) {
|
|
70248
70277
|
if (entry.stale) continue;
|
|
70249
|
-
if (
|
|
70278
|
+
if (import_node_path58.default.isAbsolute(entry.relPath)) liveAbs.add(entry.relPath);
|
|
70250
70279
|
}
|
|
70251
70280
|
}
|
|
70252
70281
|
const visited = /* @__PURE__ */ new Set();
|
|
70253
70282
|
for (const { scope, sessionId } of args.sessionScopes) {
|
|
70254
|
-
const legacyDir = args.getSessionCwd?.(sessionId) ??
|
|
70283
|
+
const legacyDir = args.getSessionCwd?.(sessionId) ?? import_node_path58.default.join(
|
|
70255
70284
|
args.dataDir,
|
|
70256
70285
|
"sessions",
|
|
70257
70286
|
...scopeSubPath(scope).map(safeFileName),
|
|
@@ -70264,28 +70293,28 @@ function runAttachmentGc(args) {
|
|
|
70264
70293
|
return true;
|
|
70265
70294
|
});
|
|
70266
70295
|
for (const rootDir of roots) {
|
|
70267
|
-
const attRoot =
|
|
70296
|
+
const attRoot = import_node_path58.default.join(rootDir, ".attachments");
|
|
70268
70297
|
let hashDirs;
|
|
70269
70298
|
try {
|
|
70270
|
-
hashDirs =
|
|
70299
|
+
hashDirs = import_node_fs51.default.readdirSync(attRoot);
|
|
70271
70300
|
} catch (err) {
|
|
70272
70301
|
if (err.code === "ENOENT") continue;
|
|
70273
70302
|
args.logger?.warn("attachment gc: readdir failed", { attRoot, err: err.message });
|
|
70274
70303
|
continue;
|
|
70275
70304
|
}
|
|
70276
70305
|
for (const hashDir of hashDirs) {
|
|
70277
|
-
const hashDirAbs =
|
|
70306
|
+
const hashDirAbs = import_node_path58.default.join(attRoot, hashDir);
|
|
70278
70307
|
let files;
|
|
70279
70308
|
try {
|
|
70280
|
-
files =
|
|
70309
|
+
files = import_node_fs51.default.readdirSync(hashDirAbs);
|
|
70281
70310
|
} catch {
|
|
70282
70311
|
continue;
|
|
70283
70312
|
}
|
|
70284
70313
|
for (const name of files) {
|
|
70285
|
-
const file =
|
|
70314
|
+
const file = import_node_path58.default.join(hashDirAbs, name);
|
|
70286
70315
|
let stat;
|
|
70287
70316
|
try {
|
|
70288
|
-
stat =
|
|
70317
|
+
stat = import_node_fs51.default.statSync(file);
|
|
70289
70318
|
} catch {
|
|
70290
70319
|
continue;
|
|
70291
70320
|
}
|
|
@@ -70294,18 +70323,18 @@ function runAttachmentGc(args) {
|
|
|
70294
70323
|
if (age < ttlMs) continue;
|
|
70295
70324
|
if (liveAbs.has(file)) continue;
|
|
70296
70325
|
try {
|
|
70297
|
-
|
|
70326
|
+
import_node_fs51.default.unlinkSync(file);
|
|
70298
70327
|
} catch (err) {
|
|
70299
70328
|
args.logger?.warn("attachment gc: unlink failed", { file, err: err.message });
|
|
70300
70329
|
}
|
|
70301
70330
|
}
|
|
70302
70331
|
try {
|
|
70303
|
-
if (
|
|
70332
|
+
if (import_node_fs51.default.readdirSync(hashDirAbs).length === 0) import_node_fs51.default.rmdirSync(hashDirAbs);
|
|
70304
70333
|
} catch {
|
|
70305
70334
|
}
|
|
70306
70335
|
}
|
|
70307
70336
|
try {
|
|
70308
|
-
if (
|
|
70337
|
+
if (import_node_fs51.default.readdirSync(attRoot).length === 0) import_node_fs51.default.rmdirSync(attRoot);
|
|
70309
70338
|
} catch {
|
|
70310
70339
|
}
|
|
70311
70340
|
}
|
|
@@ -70313,8 +70342,8 @@ function runAttachmentGc(args) {
|
|
|
70313
70342
|
}
|
|
70314
70343
|
|
|
70315
70344
|
// src/attachment/group.ts
|
|
70316
|
-
var
|
|
70317
|
-
var
|
|
70345
|
+
var import_node_fs52 = __toESM(require("fs"), 1);
|
|
70346
|
+
var import_node_path59 = __toESM(require("path"), 1);
|
|
70318
70347
|
var import_node_crypto20 = __toESM(require("crypto"), 1);
|
|
70319
70348
|
init_protocol();
|
|
70320
70349
|
var GroupFileStore = class {
|
|
@@ -70326,10 +70355,10 @@ var GroupFileStore = class {
|
|
|
70326
70355
|
this.logger = opts.logger;
|
|
70327
70356
|
}
|
|
70328
70357
|
rootForScope(scope) {
|
|
70329
|
-
return
|
|
70358
|
+
return import_node_path59.default.join(this.dataDir, "sessions", ...scopeSubPath(scope).map(safeFileName));
|
|
70330
70359
|
}
|
|
70331
70360
|
filePath(scope, sessionId) {
|
|
70332
|
-
return
|
|
70361
|
+
return import_node_path59.default.join(this.rootForScope(scope), `${safeFileName(sessionId)}.group-files.json`);
|
|
70333
70362
|
}
|
|
70334
70363
|
cacheKey(scope, sessionId) {
|
|
70335
70364
|
return scope.kind === "default" ? `default::${sessionId}` : `persona:${scope.personaId}:${scope.mode}::${sessionId}`;
|
|
@@ -70337,7 +70366,7 @@ var GroupFileStore = class {
|
|
|
70337
70366
|
readFile(scope, sessionId) {
|
|
70338
70367
|
const file = this.filePath(scope, sessionId);
|
|
70339
70368
|
try {
|
|
70340
|
-
const raw =
|
|
70369
|
+
const raw = import_node_fs52.default.readFileSync(file, "utf8");
|
|
70341
70370
|
const parsed = JSON.parse(raw);
|
|
70342
70371
|
if (!Array.isArray(parsed)) {
|
|
70343
70372
|
this.logger?.warn("GroupFileStore.readFile: not an array; resetting session entries", {
|
|
@@ -70363,10 +70392,10 @@ var GroupFileStore = class {
|
|
|
70363
70392
|
}
|
|
70364
70393
|
writeFile(scope, sessionId, entries) {
|
|
70365
70394
|
const file = this.filePath(scope, sessionId);
|
|
70366
|
-
|
|
70395
|
+
import_node_fs52.default.mkdirSync(import_node_path59.default.dirname(file), { recursive: true });
|
|
70367
70396
|
const tmp = `${file}.tmp-${process.pid}-${Date.now()}`;
|
|
70368
|
-
|
|
70369
|
-
|
|
70397
|
+
import_node_fs52.default.writeFileSync(tmp, JSON.stringify(entries, null, 2), { mode: 384 });
|
|
70398
|
+
import_node_fs52.default.renameSync(tmp, file);
|
|
70370
70399
|
}
|
|
70371
70400
|
list(scope, sessionId) {
|
|
70372
70401
|
const key = this.cacheKey(scope, sessionId);
|
|
@@ -70430,7 +70459,7 @@ var GroupFileStore = class {
|
|
|
70430
70459
|
/** Delete the separate manifest and cache; deleting a persona session file does not remove this store. */
|
|
70431
70460
|
deleteSession(scope, sessionId) {
|
|
70432
70461
|
try {
|
|
70433
|
-
|
|
70462
|
+
import_node_fs52.default.unlinkSync(this.filePath(scope, sessionId));
|
|
70434
70463
|
} catch (err) {
|
|
70435
70464
|
if (err?.code !== "ENOENT") throw err;
|
|
70436
70465
|
}
|
|
@@ -70438,7 +70467,7 @@ var GroupFileStore = class {
|
|
|
70438
70467
|
}
|
|
70439
70468
|
/** Remove all manifests and cache entries for this persona; these files live outside the persona directory. */
|
|
70440
70469
|
deletePersona(personaId2) {
|
|
70441
|
-
|
|
70470
|
+
import_node_fs52.default.rmSync(import_node_path59.default.join(this.dataDir, "sessions", safeFileName(personaId2)), { recursive: true, force: true });
|
|
70442
70471
|
const prefix = `persona:${personaId2}:`;
|
|
70443
70472
|
for (const key of this.cache.keys()) {
|
|
70444
70473
|
if (key.startsWith(prefix)) this.cache.delete(key);
|
|
@@ -70447,10 +70476,10 @@ var GroupFileStore = class {
|
|
|
70447
70476
|
};
|
|
70448
70477
|
|
|
70449
70478
|
// src/discovery/state-file.ts
|
|
70450
|
-
var
|
|
70451
|
-
var
|
|
70479
|
+
var import_node_fs53 = __toESM(require("fs"), 1);
|
|
70480
|
+
var import_node_path60 = __toESM(require("path"), 1);
|
|
70452
70481
|
function defaultStateFilePath(dataDir) {
|
|
70453
|
-
return
|
|
70482
|
+
return import_node_path60.default.join(dataDir, "state.json");
|
|
70454
70483
|
}
|
|
70455
70484
|
function isPidAlive(pid) {
|
|
70456
70485
|
if (!Number.isFinite(pid) || pid <= 0) return false;
|
|
@@ -70472,7 +70501,7 @@ var StateFileManager = class {
|
|
|
70472
70501
|
}
|
|
70473
70502
|
read() {
|
|
70474
70503
|
try {
|
|
70475
|
-
const raw =
|
|
70504
|
+
const raw = import_node_fs53.default.readFileSync(this.file, "utf8");
|
|
70476
70505
|
const parsed = JSON.parse(raw);
|
|
70477
70506
|
return parsed;
|
|
70478
70507
|
} catch {
|
|
@@ -70486,20 +70515,20 @@ var StateFileManager = class {
|
|
|
70486
70515
|
return { status: "stale", existing };
|
|
70487
70516
|
}
|
|
70488
70517
|
write(state) {
|
|
70489
|
-
|
|
70518
|
+
import_node_fs53.default.mkdirSync(import_node_path60.default.dirname(this.file), { recursive: true });
|
|
70490
70519
|
const tmp = `${this.file}.tmp.${process.pid}.${Date.now()}`;
|
|
70491
|
-
|
|
70492
|
-
|
|
70520
|
+
import_node_fs53.default.writeFileSync(tmp, JSON.stringify(state, null, 2), { mode: 384 });
|
|
70521
|
+
import_node_fs53.default.renameSync(tmp, this.file);
|
|
70493
70522
|
if (process.platform !== "win32") {
|
|
70494
70523
|
try {
|
|
70495
|
-
|
|
70524
|
+
import_node_fs53.default.chmodSync(this.file, 384);
|
|
70496
70525
|
} catch {
|
|
70497
70526
|
}
|
|
70498
70527
|
}
|
|
70499
70528
|
}
|
|
70500
70529
|
delete() {
|
|
70501
70530
|
try {
|
|
70502
|
-
|
|
70531
|
+
import_node_fs53.default.unlinkSync(this.file);
|
|
70503
70532
|
} catch {
|
|
70504
70533
|
}
|
|
70505
70534
|
}
|
|
@@ -70513,14 +70542,14 @@ function readSpawnedByDesktopFromEnv(env = process.env) {
|
|
|
70513
70542
|
}
|
|
70514
70543
|
|
|
70515
70544
|
// src/tunnel/tunnel-manager.ts
|
|
70516
|
-
var
|
|
70517
|
-
var
|
|
70545
|
+
var import_node_fs57 = __toESM(require("fs"), 1);
|
|
70546
|
+
var import_node_path64 = __toESM(require("path"), 1);
|
|
70518
70547
|
var import_node_crypto21 = __toESM(require("crypto"), 1);
|
|
70519
|
-
var
|
|
70548
|
+
var import_node_child_process17 = require("child_process");
|
|
70520
70549
|
|
|
70521
70550
|
// src/tunnel/tunnel-store.ts
|
|
70522
|
-
var
|
|
70523
|
-
var
|
|
70551
|
+
var import_node_fs54 = __toESM(require("fs"), 1);
|
|
70552
|
+
var import_node_path61 = __toESM(require("path"), 1);
|
|
70524
70553
|
var TunnelStore = class {
|
|
70525
70554
|
constructor(filePath) {
|
|
70526
70555
|
this.filePath = filePath;
|
|
@@ -70528,7 +70557,7 @@ var TunnelStore = class {
|
|
|
70528
70557
|
filePath;
|
|
70529
70558
|
async get() {
|
|
70530
70559
|
try {
|
|
70531
|
-
const raw = await
|
|
70560
|
+
const raw = await import_node_fs54.default.promises.readFile(this.filePath, "utf8");
|
|
70532
70561
|
const obj = JSON.parse(raw);
|
|
70533
70562
|
if (!isPersistedTunnel(obj)) return null;
|
|
70534
70563
|
return obj;
|
|
@@ -70539,22 +70568,22 @@ var TunnelStore = class {
|
|
|
70539
70568
|
}
|
|
70540
70569
|
}
|
|
70541
70570
|
async set(v3) {
|
|
70542
|
-
const dir =
|
|
70543
|
-
await
|
|
70571
|
+
const dir = import_node_path61.default.dirname(this.filePath);
|
|
70572
|
+
await import_node_fs54.default.promises.mkdir(dir, { recursive: true });
|
|
70544
70573
|
const data = JSON.stringify(v3, null, 2);
|
|
70545
70574
|
const tmp = `${this.filePath}.tmp.${process.pid}.${Date.now()}`;
|
|
70546
|
-
await
|
|
70575
|
+
await import_node_fs54.default.promises.writeFile(tmp, data, { mode: 384 });
|
|
70547
70576
|
if (process.platform !== "win32") {
|
|
70548
70577
|
try {
|
|
70549
|
-
await
|
|
70578
|
+
await import_node_fs54.default.promises.chmod(tmp, 384);
|
|
70550
70579
|
} catch {
|
|
70551
70580
|
}
|
|
70552
70581
|
}
|
|
70553
|
-
await
|
|
70582
|
+
await import_node_fs54.default.promises.rename(tmp, this.filePath);
|
|
70554
70583
|
}
|
|
70555
70584
|
async clear() {
|
|
70556
70585
|
try {
|
|
70557
|
-
await
|
|
70586
|
+
await import_node_fs54.default.promises.unlink(this.filePath);
|
|
70558
70587
|
} catch (err) {
|
|
70559
70588
|
const code = err?.code;
|
|
70560
70589
|
if (code !== "ENOENT") throw err;
|
|
@@ -70649,10 +70678,10 @@ function escape2(v3) {
|
|
|
70649
70678
|
}
|
|
70650
70679
|
|
|
70651
70680
|
// src/tunnel/frpc-binary.ts
|
|
70652
|
-
var
|
|
70653
|
-
var
|
|
70654
|
-
var
|
|
70655
|
-
var
|
|
70681
|
+
var import_node_fs55 = __toESM(require("fs"), 1);
|
|
70682
|
+
var import_node_os23 = __toESM(require("os"), 1);
|
|
70683
|
+
var import_node_path62 = __toESM(require("path"), 1);
|
|
70684
|
+
var import_node_child_process15 = require("child_process");
|
|
70656
70685
|
var import_node_stream4 = require("stream");
|
|
70657
70686
|
var import_promises10 = require("stream/promises");
|
|
70658
70687
|
var FRPC_VERSION = "0.68.0";
|
|
@@ -70683,20 +70712,20 @@ function frpcDownloadUrl(version2, p3) {
|
|
|
70683
70712
|
}
|
|
70684
70713
|
async function ensureFrpcBinary(opts) {
|
|
70685
70714
|
if (opts.override) {
|
|
70686
|
-
if (!
|
|
70715
|
+
if (!import_node_fs55.default.existsSync(opts.override)) {
|
|
70687
70716
|
throw new Error(`frpc binary not found at override path: ${opts.override}`);
|
|
70688
70717
|
}
|
|
70689
70718
|
return opts.override;
|
|
70690
70719
|
}
|
|
70691
70720
|
const version2 = opts.version ?? FRPC_VERSION;
|
|
70692
70721
|
const platform = opts.platform ?? detectPlatform();
|
|
70693
|
-
const binDir =
|
|
70694
|
-
|
|
70722
|
+
const binDir = import_node_path62.default.join(opts.dataDir, "bin");
|
|
70723
|
+
import_node_fs55.default.mkdirSync(binDir, { recursive: true });
|
|
70695
70724
|
cleanupStaleArtifacts(binDir);
|
|
70696
|
-
const stableBin =
|
|
70697
|
-
if (
|
|
70725
|
+
const stableBin = import_node_path62.default.join(binDir, "frpc");
|
|
70726
|
+
if (import_node_fs55.default.existsSync(stableBin)) return stableBin;
|
|
70698
70727
|
const partialBin = `${stableBin}.partial`;
|
|
70699
|
-
const tarballPath =
|
|
70728
|
+
const tarballPath = import_node_path62.default.join(binDir, `frp_${version2}_${platform.os}_${platform.arch}.tar.gz.partial`);
|
|
70700
70729
|
try {
|
|
70701
70730
|
const url = frpcDownloadUrl(version2, platform);
|
|
70702
70731
|
await downloadToFile(url, tarballPath, opts.fetchImpl);
|
|
@@ -70705,8 +70734,8 @@ async function ensureFrpcBinary(opts) {
|
|
|
70705
70734
|
} else {
|
|
70706
70735
|
await extractFrpcFromTarball(tarballPath, binDir, version2, platform, partialBin);
|
|
70707
70736
|
}
|
|
70708
|
-
|
|
70709
|
-
|
|
70737
|
+
import_node_fs55.default.chmodSync(partialBin, 493);
|
|
70738
|
+
import_node_fs55.default.renameSync(partialBin, stableBin);
|
|
70710
70739
|
} finally {
|
|
70711
70740
|
safeUnlink(tarballPath);
|
|
70712
70741
|
safeUnlink(partialBin);
|
|
@@ -70716,15 +70745,15 @@ async function ensureFrpcBinary(opts) {
|
|
|
70716
70745
|
function cleanupStaleArtifacts(binDir) {
|
|
70717
70746
|
let entries;
|
|
70718
70747
|
try {
|
|
70719
|
-
entries =
|
|
70748
|
+
entries = import_node_fs55.default.readdirSync(binDir);
|
|
70720
70749
|
} catch {
|
|
70721
70750
|
return;
|
|
70722
70751
|
}
|
|
70723
70752
|
for (const name of entries) {
|
|
70724
70753
|
if (name.endsWith(".partial") || name.startsWith("extract-")) {
|
|
70725
|
-
const full =
|
|
70754
|
+
const full = import_node_path62.default.join(binDir, name);
|
|
70726
70755
|
try {
|
|
70727
|
-
|
|
70756
|
+
import_node_fs55.default.rmSync(full, { recursive: true, force: true });
|
|
70728
70757
|
} catch {
|
|
70729
70758
|
}
|
|
70730
70759
|
}
|
|
@@ -70732,7 +70761,7 @@ function cleanupStaleArtifacts(binDir) {
|
|
|
70732
70761
|
}
|
|
70733
70762
|
function safeUnlink(p3) {
|
|
70734
70763
|
try {
|
|
70735
|
-
|
|
70764
|
+
import_node_fs55.default.unlinkSync(p3);
|
|
70736
70765
|
} catch {
|
|
70737
70766
|
}
|
|
70738
70767
|
}
|
|
@@ -70743,46 +70772,46 @@ async function downloadToFile(url, dest, fetchImpl) {
|
|
|
70743
70772
|
if (!res.ok || !res.body) {
|
|
70744
70773
|
throw new Error(`download failed: ${res.status} ${res.statusText}`);
|
|
70745
70774
|
}
|
|
70746
|
-
const out =
|
|
70775
|
+
const out = import_node_fs55.default.createWriteStream(dest);
|
|
70747
70776
|
const nodeStream = import_node_stream4.Readable.fromWeb(res.body);
|
|
70748
70777
|
await (0, import_promises10.pipeline)(nodeStream, out);
|
|
70749
70778
|
}
|
|
70750
70779
|
async function extractFrpcFromTarball(tarball, binDir, version2, platform, destBin) {
|
|
70751
|
-
const work =
|
|
70752
|
-
|
|
70780
|
+
const work = import_node_path62.default.join(binDir, `extract-${process.pid}-${Date.now()}`);
|
|
70781
|
+
import_node_fs55.default.mkdirSync(work, { recursive: true });
|
|
70753
70782
|
try {
|
|
70754
70783
|
await new Promise((resolve9, reject) => {
|
|
70755
|
-
const proc = (0,
|
|
70784
|
+
const proc = (0, import_node_child_process15.spawn)("tar", ["xzf", tarball, "-C", work], { stdio: "pipe" });
|
|
70756
70785
|
proc.on("error", reject);
|
|
70757
70786
|
proc.on("exit", (code) => code === 0 ? resolve9() : reject(new Error(`tar exited ${code}`)));
|
|
70758
70787
|
});
|
|
70759
70788
|
const dirName = `frp_${version2}_${platform.os}_${platform.arch}`;
|
|
70760
|
-
const src =
|
|
70761
|
-
if (!
|
|
70789
|
+
const src = import_node_path62.default.join(work, dirName, "frpc");
|
|
70790
|
+
if (!import_node_fs55.default.existsSync(src)) {
|
|
70762
70791
|
throw new Error(`frpc not found inside tarball at ${src}`);
|
|
70763
70792
|
}
|
|
70764
|
-
|
|
70793
|
+
import_node_fs55.default.copyFileSync(src, destBin);
|
|
70765
70794
|
} finally {
|
|
70766
|
-
|
|
70795
|
+
import_node_fs55.default.rmSync(work, { recursive: true, force: true });
|
|
70767
70796
|
}
|
|
70768
70797
|
}
|
|
70769
70798
|
|
|
70770
70799
|
// src/tunnel/frpc-process.ts
|
|
70771
|
-
var
|
|
70772
|
-
var
|
|
70773
|
-
var
|
|
70800
|
+
var import_node_fs56 = __toESM(require("fs"), 1);
|
|
70801
|
+
var import_node_path63 = __toESM(require("path"), 1);
|
|
70802
|
+
var import_node_child_process16 = require("child_process");
|
|
70774
70803
|
function frpcPidFilePath(dataDir) {
|
|
70775
|
-
return
|
|
70804
|
+
return import_node_path63.default.join(dataDir, "frpc.pid");
|
|
70776
70805
|
}
|
|
70777
70806
|
function writeFrpcPid(dataDir, pid) {
|
|
70778
70807
|
try {
|
|
70779
|
-
|
|
70808
|
+
import_node_fs56.default.writeFileSync(frpcPidFilePath(dataDir), String(pid), { mode: 384 });
|
|
70780
70809
|
} catch {
|
|
70781
70810
|
}
|
|
70782
70811
|
}
|
|
70783
70812
|
function clearFrpcPid(dataDir) {
|
|
70784
70813
|
try {
|
|
70785
|
-
|
|
70814
|
+
import_node_fs56.default.unlinkSync(frpcPidFilePath(dataDir));
|
|
70786
70815
|
} catch {
|
|
70787
70816
|
}
|
|
70788
70817
|
}
|
|
@@ -70798,7 +70827,7 @@ function defaultIsPidAlive(pid) {
|
|
|
70798
70827
|
}
|
|
70799
70828
|
function defaultReadPidFile(file) {
|
|
70800
70829
|
try {
|
|
70801
|
-
return
|
|
70830
|
+
return import_node_fs56.default.readFileSync(file, "utf8");
|
|
70802
70831
|
} catch {
|
|
70803
70832
|
return null;
|
|
70804
70833
|
}
|
|
@@ -70814,7 +70843,7 @@ function defaultSleep2(ms) {
|
|
|
70814
70843
|
}
|
|
70815
70844
|
async function killStaleFrpc(deps) {
|
|
70816
70845
|
const pidFile = frpcPidFilePath(deps.dataDir);
|
|
70817
|
-
const tomlPath =
|
|
70846
|
+
const tomlPath = import_node_path63.default.join(deps.dataDir, "frpc.toml");
|
|
70818
70847
|
const readPidFile = deps.readPidFileImpl ?? defaultReadPidFile;
|
|
70819
70848
|
const isAlive = deps.isPidAliveImpl ?? defaultIsPidAlive;
|
|
70820
70849
|
const killPid = deps.killPidImpl ?? defaultKillPid;
|
|
@@ -70838,7 +70867,7 @@ async function killStaleFrpc(deps) {
|
|
|
70838
70867
|
}
|
|
70839
70868
|
if (victims.size === 0) {
|
|
70840
70869
|
try {
|
|
70841
|
-
|
|
70870
|
+
import_node_fs56.default.unlinkSync(pidFile);
|
|
70842
70871
|
} catch {
|
|
70843
70872
|
}
|
|
70844
70873
|
return;
|
|
@@ -70849,14 +70878,14 @@ async function killStaleFrpc(deps) {
|
|
|
70849
70878
|
}
|
|
70850
70879
|
await sleep2(deps.reapWaitMs ?? 300);
|
|
70851
70880
|
try {
|
|
70852
|
-
|
|
70881
|
+
import_node_fs56.default.unlinkSync(pidFile);
|
|
70853
70882
|
} catch {
|
|
70854
70883
|
}
|
|
70855
70884
|
}
|
|
70856
70885
|
async function defaultScanFrpcPidsByCmdline(tomlPath, logger) {
|
|
70857
70886
|
if (process.platform === "win32") return [];
|
|
70858
70887
|
return new Promise((resolve9) => {
|
|
70859
|
-
const ps = (0,
|
|
70888
|
+
const ps = (0, import_node_child_process16.spawn)("ps", ["-axo", "pid=,command="], { stdio: ["ignore", "pipe", "ignore"] });
|
|
70860
70889
|
let buf = "";
|
|
70861
70890
|
ps.stdout.on("data", (c2) => {
|
|
70862
70891
|
buf += c2.toString();
|
|
@@ -70886,7 +70915,7 @@ var DEFAULT_TUNNEL_TTL_MS = 7 * 24 * 60 * 60 * 1e3;
|
|
|
70886
70915
|
var TunnelManager = class {
|
|
70887
70916
|
constructor(deps) {
|
|
70888
70917
|
this.deps = deps;
|
|
70889
|
-
this.store = deps.store ?? new TunnelStore(
|
|
70918
|
+
this.store = deps.store ?? new TunnelStore(import_node_path64.default.join(deps.dataDir, "tunnel.json"));
|
|
70890
70919
|
this.ttlMs = deps.ttlMs ?? DEFAULT_TUNNEL_TTL_MS;
|
|
70891
70920
|
this.startupTimeoutMs = deps.startupTimeoutMs ?? 15e3;
|
|
70892
70921
|
}
|
|
@@ -71011,7 +71040,7 @@ var TunnelManager = class {
|
|
|
71011
71040
|
dataDir: this.deps.dataDir,
|
|
71012
71041
|
override: this.deps.frpcBinaryOverride ?? void 0
|
|
71013
71042
|
});
|
|
71014
|
-
const tomlPath =
|
|
71043
|
+
const tomlPath = import_node_path64.default.join(this.deps.dataDir, "frpc.toml");
|
|
71015
71044
|
const proxyName = `clawd-${t2.subdomain}-${localPort}-${import_node_crypto21.default.randomBytes(3).toString("hex")}`;
|
|
71016
71045
|
const toml = buildFrpcToml({
|
|
71017
71046
|
serverAddr: t2.frpsHost,
|
|
@@ -71022,14 +71051,14 @@ var TunnelManager = class {
|
|
|
71022
71051
|
localPort,
|
|
71023
71052
|
logLevel: "info"
|
|
71024
71053
|
});
|
|
71025
|
-
await
|
|
71026
|
-
const proc = (this.deps.spawnImpl ??
|
|
71054
|
+
await import_node_fs57.default.promises.writeFile(tomlPath, toml, { mode: 384 });
|
|
71055
|
+
const proc = (this.deps.spawnImpl ?? import_node_child_process17.spawn)(frpcBin, ["-c", tomlPath], {
|
|
71027
71056
|
stdio: ["ignore", "pipe", "pipe"]
|
|
71028
71057
|
});
|
|
71029
|
-
const logDir =
|
|
71030
|
-
|
|
71031
|
-
const logFilePath =
|
|
71032
|
-
const logStream =
|
|
71058
|
+
const logDir = import_node_path64.default.join(this.deps.dataDir, "log");
|
|
71059
|
+
import_node_fs57.default.mkdirSync(logDir, { recursive: true });
|
|
71060
|
+
const logFilePath = import_node_path64.default.join(logDir, "frpc.log");
|
|
71061
|
+
const logStream = import_node_fs57.default.createWriteStream(logFilePath, { flags: "a", mode: 384 });
|
|
71033
71062
|
logStream.on("error", () => {
|
|
71034
71063
|
});
|
|
71035
71064
|
const tee = (chunk) => {
|
|
@@ -71111,28 +71140,28 @@ async function waitForFrpcReady(proc, timeoutMs) {
|
|
|
71111
71140
|
}
|
|
71112
71141
|
|
|
71113
71142
|
// src/tunnel/device-key.ts
|
|
71114
|
-
var
|
|
71115
|
-
var
|
|
71143
|
+
var import_node_os24 = __toESM(require("os"), 1);
|
|
71144
|
+
var import_node_path65 = __toESM(require("path"), 1);
|
|
71116
71145
|
var import_node_crypto22 = __toESM(require("crypto"), 1);
|
|
71117
71146
|
var DERIVE_SALT = "clawd-tunnel-device-v1";
|
|
71118
71147
|
function deriveStableDeviceKey(opts = {}) {
|
|
71119
|
-
const hostname = opts.hostname ??
|
|
71120
|
-
const uid = opts.uid ?? (typeof
|
|
71121
|
-
const home = opts.home ??
|
|
71122
|
-
const defaultDataDir =
|
|
71123
|
-
const normalizedDataDir = opts.dataDir ?
|
|
71148
|
+
const hostname = opts.hostname ?? import_node_os24.default.hostname();
|
|
71149
|
+
const uid = opts.uid ?? (typeof import_node_os24.default.userInfo === "function" ? import_node_os24.default.userInfo().uid : 0);
|
|
71150
|
+
const home = opts.home ?? import_node_os24.default.homedir();
|
|
71151
|
+
const defaultDataDir = import_node_path65.default.resolve(import_node_path65.default.join(home, ".clawd"));
|
|
71152
|
+
const normalizedDataDir = opts.dataDir ? import_node_path65.default.resolve(opts.dataDir) : null;
|
|
71124
71153
|
const isDefaultDir = normalizedDataDir == null || normalizedDataDir === defaultDataDir;
|
|
71125
71154
|
const input = isDefaultDir ? `${hostname}::${uid}` : `${hostname}::${uid}::${normalizedDataDir}`;
|
|
71126
71155
|
return import_node_crypto22.default.createHmac("sha256", DERIVE_SALT).update(input).digest("hex").slice(0, 32);
|
|
71127
71156
|
}
|
|
71128
71157
|
|
|
71129
71158
|
// src/auth-store.ts
|
|
71130
|
-
var
|
|
71131
|
-
var
|
|
71159
|
+
var import_node_fs58 = __toESM(require("fs"), 1);
|
|
71160
|
+
var import_node_path66 = __toESM(require("path"), 1);
|
|
71132
71161
|
var import_node_crypto23 = __toESM(require("crypto"), 1);
|
|
71133
71162
|
var AUTH_FILE_NAME = "auth.json";
|
|
71134
71163
|
function authFilePath(dataDir) {
|
|
71135
|
-
return
|
|
71164
|
+
return import_node_path66.default.join(dataDir, AUTH_FILE_NAME);
|
|
71136
71165
|
}
|
|
71137
71166
|
function loadOrCreateAuthFile(opts) {
|
|
71138
71167
|
const file = authFilePath(opts.dataDir);
|
|
@@ -71173,7 +71202,7 @@ function defaultGenerateOwnerPrincipalId() {
|
|
|
71173
71202
|
}
|
|
71174
71203
|
function readAuthFile(file) {
|
|
71175
71204
|
try {
|
|
71176
|
-
const raw =
|
|
71205
|
+
const raw = import_node_fs58.default.readFileSync(file, "utf8");
|
|
71177
71206
|
const parsed = JSON.parse(raw);
|
|
71178
71207
|
if (typeof parsed?.token !== "string" || parsed.token.length === 0) {
|
|
71179
71208
|
return null;
|
|
@@ -71194,26 +71223,26 @@ function readAuthFile(file) {
|
|
|
71194
71223
|
}
|
|
71195
71224
|
}
|
|
71196
71225
|
function writeAuthFile(file, content) {
|
|
71197
|
-
|
|
71198
|
-
|
|
71226
|
+
import_node_fs58.default.mkdirSync(import_node_path66.default.dirname(file), { recursive: true });
|
|
71227
|
+
import_node_fs58.default.writeFileSync(file, JSON.stringify(content, null, 2), { mode: 384 });
|
|
71199
71228
|
try {
|
|
71200
|
-
|
|
71229
|
+
import_node_fs58.default.chmodSync(file, 384);
|
|
71201
71230
|
} catch {
|
|
71202
71231
|
}
|
|
71203
71232
|
}
|
|
71204
71233
|
|
|
71205
71234
|
// src/owner-profile.ts
|
|
71206
|
-
var
|
|
71207
|
-
var
|
|
71208
|
-
var
|
|
71235
|
+
var import_node_fs59 = __toESM(require("fs"), 1);
|
|
71236
|
+
var import_node_os25 = __toESM(require("os"), 1);
|
|
71237
|
+
var import_node_path67 = __toESM(require("path"), 1);
|
|
71209
71238
|
var PROFILE_FILENAME = "profile.json";
|
|
71210
71239
|
function profilePath(dataDir) {
|
|
71211
|
-
return
|
|
71240
|
+
return import_node_path67.default.join(dataDir, PROFILE_FILENAME);
|
|
71212
71241
|
}
|
|
71213
71242
|
function loadOwnerProfile(dataDir) {
|
|
71214
71243
|
let raw;
|
|
71215
71244
|
try {
|
|
71216
|
-
raw =
|
|
71245
|
+
raw = import_node_fs59.default.readFileSync(profilePath(dataDir), "utf8");
|
|
71217
71246
|
} catch {
|
|
71218
71247
|
return {};
|
|
71219
71248
|
}
|
|
@@ -71229,11 +71258,11 @@ function loadOwnerProfile(dataDir) {
|
|
|
71229
71258
|
}
|
|
71230
71259
|
function patchOwnerProfile(dataDir, patch) {
|
|
71231
71260
|
const merged = { ...loadOwnerProfile(dataDir), ...patch };
|
|
71232
|
-
|
|
71261
|
+
import_node_fs59.default.writeFileSync(profilePath(dataDir), JSON.stringify(merged, null, 2), { encoding: "utf8", mode: 384 });
|
|
71233
71262
|
return merged;
|
|
71234
71263
|
}
|
|
71235
71264
|
function loadOwnerDisplayName(dataDir) {
|
|
71236
|
-
const fallback =
|
|
71265
|
+
const fallback = import_node_os25.default.userInfo().username;
|
|
71237
71266
|
const displayName = loadOwnerProfile(dataDir).displayName;
|
|
71238
71267
|
if (typeof displayName !== "string" || displayName.length === 0) {
|
|
71239
71268
|
if (displayName !== void 0) {
|
|
@@ -71245,18 +71274,18 @@ function loadOwnerDisplayName(dataDir) {
|
|
|
71245
71274
|
}
|
|
71246
71275
|
|
|
71247
71276
|
// src/feishu-auth/owner-identity-store.ts
|
|
71248
|
-
var
|
|
71249
|
-
var
|
|
71277
|
+
var import_node_fs60 = __toESM(require("fs"), 1);
|
|
71278
|
+
var import_node_path68 = __toESM(require("path"), 1);
|
|
71250
71279
|
var OWNER_IDENTITY_FILE_NAME = "owner-identity.json";
|
|
71251
71280
|
var OwnerIdentityStore = class {
|
|
71252
71281
|
file;
|
|
71253
71282
|
constructor(dataDir, environment = "production") {
|
|
71254
|
-
this.file =
|
|
71283
|
+
this.file = import_node_path68.default.join(dataDir, environment === "production" ? OWNER_IDENTITY_FILE_NAME : "owner-identity.integration.json");
|
|
71255
71284
|
}
|
|
71256
71285
|
read() {
|
|
71257
71286
|
let raw;
|
|
71258
71287
|
try {
|
|
71259
|
-
raw =
|
|
71288
|
+
raw = import_node_fs60.default.readFileSync(this.file, "utf8");
|
|
71260
71289
|
} catch {
|
|
71261
71290
|
return null;
|
|
71262
71291
|
}
|
|
@@ -71283,16 +71312,16 @@ var OwnerIdentityStore = class {
|
|
|
71283
71312
|
};
|
|
71284
71313
|
}
|
|
71285
71314
|
write(record4) {
|
|
71286
|
-
|
|
71287
|
-
|
|
71315
|
+
import_node_fs60.default.mkdirSync(import_node_path68.default.dirname(this.file), { recursive: true });
|
|
71316
|
+
import_node_fs60.default.writeFileSync(this.file, JSON.stringify(record4, null, 2), { mode: 384 });
|
|
71288
71317
|
try {
|
|
71289
|
-
|
|
71318
|
+
import_node_fs60.default.chmodSync(this.file, 384);
|
|
71290
71319
|
} catch {
|
|
71291
71320
|
}
|
|
71292
71321
|
}
|
|
71293
71322
|
clear() {
|
|
71294
71323
|
try {
|
|
71295
|
-
|
|
71324
|
+
import_node_fs60.default.unlinkSync(this.file);
|
|
71296
71325
|
} catch (err) {
|
|
71297
71326
|
const code = err?.code;
|
|
71298
71327
|
if (code !== "ENOENT") throw err;
|
|
@@ -71792,8 +71821,8 @@ function verifyConnectToken(args) {
|
|
|
71792
71821
|
}
|
|
71793
71822
|
|
|
71794
71823
|
// src/feishu-auth/server-key.ts
|
|
71795
|
-
var
|
|
71796
|
-
var
|
|
71824
|
+
var fs77 = __toESM(require("fs"), 1);
|
|
71825
|
+
var path81 = __toESM(require("path"), 1);
|
|
71797
71826
|
var FILE_NAME2 = "server-signing-key.json";
|
|
71798
71827
|
var ServerKeyStore = class {
|
|
71799
71828
|
constructor(dataDir) {
|
|
@@ -71801,12 +71830,12 @@ var ServerKeyStore = class {
|
|
|
71801
71830
|
}
|
|
71802
71831
|
dataDir;
|
|
71803
71832
|
filePath() {
|
|
71804
|
-
return
|
|
71833
|
+
return path81.join(this.dataDir, FILE_NAME2);
|
|
71805
71834
|
}
|
|
71806
71835
|
/** 读缓存的公钥;无缓存 / 损坏 → null(调用方决定是否触发拉取) */
|
|
71807
71836
|
read() {
|
|
71808
71837
|
try {
|
|
71809
|
-
const raw =
|
|
71838
|
+
const raw = fs77.readFileSync(this.filePath(), "utf8");
|
|
71810
71839
|
const parsed = JSON.parse(raw);
|
|
71811
71840
|
if (typeof parsed.publicKeyPem === "string" && parsed.publicKeyPem.includes("PUBLIC KEY")) {
|
|
71812
71841
|
return parsed.publicKeyPem;
|
|
@@ -71821,12 +71850,12 @@ var ServerKeyStore = class {
|
|
|
71821
71850
|
publicKeyPem,
|
|
71822
71851
|
fetchedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
71823
71852
|
};
|
|
71824
|
-
|
|
71825
|
-
|
|
71853
|
+
fs77.mkdirSync(this.dataDir, { recursive: true });
|
|
71854
|
+
fs77.writeFileSync(this.filePath(), JSON.stringify(content, null, 2), { mode: 384 });
|
|
71826
71855
|
}
|
|
71827
71856
|
clear() {
|
|
71828
71857
|
try {
|
|
71829
|
-
|
|
71858
|
+
fs77.unlinkSync(this.filePath());
|
|
71830
71859
|
} catch {
|
|
71831
71860
|
}
|
|
71832
71861
|
}
|
|
@@ -71836,19 +71865,19 @@ var ServerKeyStore = class {
|
|
|
71836
71865
|
init_protocol();
|
|
71837
71866
|
|
|
71838
71867
|
// src/handlers/index.ts
|
|
71839
|
-
var
|
|
71868
|
+
var import_node_path85 = __toESM(require("path"), 1);
|
|
71840
71869
|
|
|
71841
71870
|
// src/handlers/session.ts
|
|
71842
71871
|
init_protocol();
|
|
71843
71872
|
|
|
71844
71873
|
// src/session/fork.ts
|
|
71845
|
-
var
|
|
71846
|
-
var
|
|
71847
|
-
var
|
|
71874
|
+
var import_node_fs61 = __toESM(require("fs"), 1);
|
|
71875
|
+
var import_node_os26 = __toESM(require("os"), 1);
|
|
71876
|
+
var import_node_path69 = __toESM(require("path"), 1);
|
|
71848
71877
|
var import_node_crypto25 = require("crypto");
|
|
71849
71878
|
init_claude_history();
|
|
71850
71879
|
function readJsonlEntries(file) {
|
|
71851
|
-
const raw =
|
|
71880
|
+
const raw = import_node_fs61.default.readFileSync(file, "utf8");
|
|
71852
71881
|
const out = [];
|
|
71853
71882
|
for (const line of raw.split("\n")) {
|
|
71854
71883
|
const t2 = line.trim();
|
|
@@ -71861,19 +71890,19 @@ function readJsonlEntries(file) {
|
|
|
71861
71890
|
return out;
|
|
71862
71891
|
}
|
|
71863
71892
|
function forkSession(input) {
|
|
71864
|
-
const baseDir = input.baseDir ??
|
|
71865
|
-
let projectDir =
|
|
71866
|
-
let sourceFile =
|
|
71867
|
-
if (!
|
|
71893
|
+
const baseDir = input.baseDir ?? import_node_path69.default.join(import_node_os26.default.homedir(), ".claude");
|
|
71894
|
+
let projectDir = import_node_path69.default.join(baseDir, "projects", cwdToHashDir(input.cwd));
|
|
71895
|
+
let sourceFile = import_node_path69.default.join(projectDir, `${input.toolSessionId}.jsonl`);
|
|
71896
|
+
if (!import_node_fs61.default.existsSync(sourceFile)) {
|
|
71868
71897
|
const found = findTranscriptByToolSessionId(
|
|
71869
|
-
|
|
71898
|
+
import_node_path69.default.join(baseDir, "projects"),
|
|
71870
71899
|
input.toolSessionId
|
|
71871
71900
|
);
|
|
71872
71901
|
if (!found) {
|
|
71873
71902
|
throw new Error(`fork: source transcript not found: ${sourceFile}`);
|
|
71874
71903
|
}
|
|
71875
71904
|
sourceFile = found;
|
|
71876
|
-
projectDir =
|
|
71905
|
+
projectDir = import_node_path69.default.dirname(found);
|
|
71877
71906
|
}
|
|
71878
71907
|
const entries = readJsonlEntries(sourceFile);
|
|
71879
71908
|
const mainEntries = entries.filter((e) => e.isSidechain !== true);
|
|
@@ -71902,22 +71931,23 @@ function forkSession(input) {
|
|
|
71902
71931
|
}
|
|
71903
71932
|
forkedLines.push(JSON.stringify(forked));
|
|
71904
71933
|
}
|
|
71905
|
-
const outDir = input.targetCwd ?
|
|
71906
|
-
const forkedFilePath =
|
|
71907
|
-
|
|
71908
|
-
|
|
71934
|
+
const outDir = input.targetCwd ? import_node_path69.default.join(baseDir, "projects", cwdToHashDir(input.targetCwd)) : projectDir;
|
|
71935
|
+
const forkedFilePath = import_node_path69.default.join(outDir, `${forkedToolSessionId}.jsonl`);
|
|
71936
|
+
import_node_fs61.default.mkdirSync(outDir, { recursive: true });
|
|
71937
|
+
import_node_fs61.default.writeFileSync(forkedFilePath, forkedLines.join("\n") + "\n", { mode: 384 });
|
|
71909
71938
|
return { forkedToolSessionId, forkedFilePath };
|
|
71910
71939
|
}
|
|
71911
71940
|
|
|
71912
71941
|
// src/tools/codex-fork.ts
|
|
71913
|
-
var
|
|
71914
|
-
var
|
|
71915
|
-
var
|
|
71942
|
+
var import_node_child_process18 = require("child_process");
|
|
71943
|
+
var import_node_fs62 = __toESM(require("fs"), 1);
|
|
71944
|
+
var import_node_path70 = __toESM(require("path"), 1);
|
|
71916
71945
|
function openCodexAppServer(home, cwd) {
|
|
71917
71946
|
const cmd = codexCommand();
|
|
71918
|
-
const
|
|
71947
|
+
const env = codexEnvironment(cmd, { ...process.env, CODEX_HOME: home });
|
|
71948
|
+
const proc = (0, import_node_child_process18.spawn)(cmd, [...codexModelCatalogCliArgs(cmd, env), "app-server", "--listen", "stdio://"], {
|
|
71919
71949
|
cwd,
|
|
71920
|
-
env
|
|
71950
|
+
env,
|
|
71921
71951
|
stdio: ["pipe", "pipe", "pipe"]
|
|
71922
71952
|
});
|
|
71923
71953
|
proc.on("error", () => proc.stdout?.destroy());
|
|
@@ -71933,7 +71963,7 @@ function openCodexAppServer(home, cwd) {
|
|
|
71933
71963
|
async function forkCodexThread(input, deps = {}) {
|
|
71934
71964
|
const source = locateCodexThread(input.roots, input.sourceThreadId);
|
|
71935
71965
|
if (!source) throw new Error(`codex fork: source thread not found: ${input.sourceThreadId}`);
|
|
71936
|
-
const rollout = parseCodexRollout(
|
|
71966
|
+
const rollout = parseCodexRollout(import_node_fs62.default.readFileSync(source.file, "utf8"));
|
|
71937
71967
|
if (rollout.meta?.threadId.toLowerCase() !== input.sourceThreadId.toLowerCase()) {
|
|
71938
71968
|
throw new Error(`codex fork: source thread metadata does not match ${input.sourceThreadId}`);
|
|
71939
71969
|
}
|
|
@@ -71968,7 +71998,7 @@ async function forkCodexThread(input, deps = {}) {
|
|
|
71968
71998
|
if (typeof forkedToolSessionId !== "string" || !forkedToolSessionId) {
|
|
71969
71999
|
throw new Error("codex fork: app-server returned no thread id");
|
|
71970
72000
|
}
|
|
71971
|
-
const forked = locateCodexThread([
|
|
72001
|
+
const forked = locateCodexThread([import_node_path70.default.join(owner2.home, "sessions")], forkedToolSessionId);
|
|
71972
72002
|
if (!forked) throw new Error(`codex fork: rollout not found for forked thread ${forkedToolSessionId}`);
|
|
71973
72003
|
return { forkedToolSessionId, forkedFilePath: forked.file };
|
|
71974
72004
|
})()]);
|
|
@@ -71979,19 +72009,19 @@ async function forkCodexThread(input, deps = {}) {
|
|
|
71979
72009
|
}
|
|
71980
72010
|
|
|
71981
72011
|
// src/session/external-scan.ts
|
|
71982
|
-
var
|
|
72012
|
+
var import_node_fs63 = __toESM(require("fs"), 1);
|
|
71983
72013
|
var import_promises11 = __toESM(require("fs/promises"), 1);
|
|
71984
|
-
var
|
|
71985
|
-
var
|
|
72014
|
+
var import_node_os27 = __toESM(require("os"), 1);
|
|
72015
|
+
var import_node_path71 = __toESM(require("path"), 1);
|
|
71986
72016
|
var import_node_module = require("module");
|
|
71987
|
-
var
|
|
72017
|
+
var import_node_child_process19 = require("child_process");
|
|
71988
72018
|
var import_meta7 = {};
|
|
71989
72019
|
function defaultRoots() {
|
|
71990
|
-
const home =
|
|
72020
|
+
const home = import_node_os27.default.homedir();
|
|
71991
72021
|
return {
|
|
71992
|
-
claudeProjectsDir:
|
|
71993
|
-
codexDir:
|
|
71994
|
-
clawdDir:
|
|
72022
|
+
claudeProjectsDir: import_node_path71.default.join(home, ".claude", "projects"),
|
|
72023
|
+
codexDir: import_node_path71.default.join(home, ".codex"),
|
|
72024
|
+
clawdDir: import_node_path71.default.join(home, ".clawd")
|
|
71995
72025
|
};
|
|
71996
72026
|
}
|
|
71997
72027
|
function width(s2) {
|
|
@@ -72042,7 +72072,7 @@ function userText(msg) {
|
|
|
72042
72072
|
}
|
|
72043
72073
|
function isDir2(p3) {
|
|
72044
72074
|
try {
|
|
72045
|
-
return
|
|
72075
|
+
return import_node_fs63.default.statSync(p3).isDirectory();
|
|
72046
72076
|
} catch {
|
|
72047
72077
|
return false;
|
|
72048
72078
|
}
|
|
@@ -72051,7 +72081,7 @@ async function scanClaude(roots) {
|
|
|
72051
72081
|
const out = [];
|
|
72052
72082
|
let dirs;
|
|
72053
72083
|
try {
|
|
72054
|
-
dirs =
|
|
72084
|
+
dirs = import_node_fs63.default.readdirSync(roots.claudeProjectsDir, { withFileTypes: true });
|
|
72055
72085
|
} catch {
|
|
72056
72086
|
return out;
|
|
72057
72087
|
}
|
|
@@ -72059,16 +72089,16 @@ async function scanClaude(roots) {
|
|
|
72059
72089
|
if (!d2.isDirectory()) continue;
|
|
72060
72090
|
let files;
|
|
72061
72091
|
try {
|
|
72062
|
-
files =
|
|
72092
|
+
files = import_node_fs63.default.readdirSync(import_node_path71.default.join(roots.claudeProjectsDir, d2.name));
|
|
72063
72093
|
} catch {
|
|
72064
72094
|
continue;
|
|
72065
72095
|
}
|
|
72066
72096
|
for (const name of files) {
|
|
72067
72097
|
if (!name.endsWith(".jsonl")) continue;
|
|
72068
|
-
const file =
|
|
72098
|
+
const file = import_node_path71.default.join(roots.claudeProjectsDir, d2.name, name);
|
|
72069
72099
|
let st2;
|
|
72070
72100
|
try {
|
|
72071
|
-
st2 =
|
|
72101
|
+
st2 = import_node_fs63.default.statSync(file);
|
|
72072
72102
|
} catch {
|
|
72073
72103
|
continue;
|
|
72074
72104
|
}
|
|
@@ -72121,7 +72151,7 @@ async function scanClaude(roots) {
|
|
|
72121
72151
|
return out;
|
|
72122
72152
|
}
|
|
72123
72153
|
async function countCodexTurns(rolloutPath) {
|
|
72124
|
-
if (!rolloutPath || !
|
|
72154
|
+
if (!rolloutPath || !import_node_fs63.default.existsSync(rolloutPath)) return { turns: 0, first: "" };
|
|
72125
72155
|
let turns = 0;
|
|
72126
72156
|
let first = "";
|
|
72127
72157
|
for await (const rec6 of jsonLines(rolloutPath)) {
|
|
@@ -72152,14 +72182,14 @@ function readCodexThreads(db) {
|
|
|
72152
72182
|
} catch {
|
|
72153
72183
|
}
|
|
72154
72184
|
try {
|
|
72155
|
-
const info = (0,
|
|
72185
|
+
const info = (0, import_node_child_process19.spawnSync)("sqlite3", [db, "PRAGMA table_info(threads);"], { encoding: "utf8" });
|
|
72156
72186
|
if (info.status !== 0) return null;
|
|
72157
72187
|
const have = new Set(
|
|
72158
72188
|
info.stdout.split("\n").map((l2) => l2.split("|")[1]).filter(Boolean)
|
|
72159
72189
|
);
|
|
72160
72190
|
if (!["id", "cwd", "updated_at", "thread_source"].every((c2) => have.has(c2))) return null;
|
|
72161
72191
|
const sel = COLS.map((c2) => have.has(c2) ? c2 : `NULL AS ${c2}`).join(", ");
|
|
72162
|
-
const res = (0,
|
|
72192
|
+
const res = (0, import_node_child_process19.spawnSync)("sqlite3", ["-json", db, `SELECT ${sel} FROM threads;`], {
|
|
72163
72193
|
encoding: "utf8",
|
|
72164
72194
|
maxBuffer: 64 * 1024 * 1024
|
|
72165
72195
|
});
|
|
@@ -72195,7 +72225,7 @@ async function codexFromRows(rows) {
|
|
|
72195
72225
|
async function scanCodex(roots) {
|
|
72196
72226
|
let dbs = [];
|
|
72197
72227
|
try {
|
|
72198
|
-
dbs =
|
|
72228
|
+
dbs = import_node_fs63.default.readdirSync(roots.codexDir).filter((n2) => /^state_.*\.sqlite$/.test(n2)).sort().map((n2) => import_node_path71.default.join(roots.codexDir, n2));
|
|
72199
72229
|
} catch {
|
|
72200
72230
|
}
|
|
72201
72231
|
if (!dbs.length) return [];
|
|
@@ -72204,14 +72234,14 @@ async function scanCodex(roots) {
|
|
|
72204
72234
|
}
|
|
72205
72235
|
async function scanExternalSessions(rootsIn) {
|
|
72206
72236
|
const roots = { ...defaultRoots(), ...rootsIn };
|
|
72207
|
-
const personaRoot =
|
|
72237
|
+
const personaRoot = import_node_path71.default.join(roots.clawdDir, "personas");
|
|
72208
72238
|
const all = [...await scanClaude(roots), ...await scanCodex(roots)];
|
|
72209
72239
|
const out = [];
|
|
72210
72240
|
for (const c2 of all) {
|
|
72211
72241
|
if (c2.skip) continue;
|
|
72212
72242
|
if (c2.turns < 1) continue;
|
|
72213
72243
|
if (!c2.cwd || !isDir2(c2.cwd)) continue;
|
|
72214
|
-
if (c2.cwd === roots.clawdDir || c2.cwd === personaRoot || c2.cwd.startsWith(personaRoot +
|
|
72244
|
+
if (c2.cwd === roots.clawdDir || c2.cwd === personaRoot || c2.cwd.startsWith(personaRoot + import_node_path71.default.sep) || c2.cwd.startsWith(roots.clawdDir + import_node_path71.default.sep)) {
|
|
72215
72245
|
continue;
|
|
72216
72246
|
}
|
|
72217
72247
|
out.push({
|
|
@@ -72228,13 +72258,13 @@ async function scanExternalSessions(rootsIn) {
|
|
|
72228
72258
|
}
|
|
72229
72259
|
|
|
72230
72260
|
// src/session/import-ledger.ts
|
|
72231
|
-
var
|
|
72232
|
-
var
|
|
72261
|
+
var import_node_fs64 = __toESM(require("fs"), 1);
|
|
72262
|
+
var import_node_path72 = __toESM(require("path"), 1);
|
|
72233
72263
|
var LEDGER_FILENAME = "session-import-ledger.json";
|
|
72234
72264
|
function readImportLedger(dataDir) {
|
|
72235
72265
|
try {
|
|
72236
72266
|
const parsed = JSON.parse(
|
|
72237
|
-
|
|
72267
|
+
import_node_fs64.default.readFileSync(import_node_path72.default.join(dataDir, LEDGER_FILENAME), "utf8")
|
|
72238
72268
|
);
|
|
72239
72269
|
return Array.isArray(parsed) ? parsed : [];
|
|
72240
72270
|
} catch {
|
|
@@ -72242,15 +72272,15 @@ function readImportLedger(dataDir) {
|
|
|
72242
72272
|
}
|
|
72243
72273
|
}
|
|
72244
72274
|
function appendImportLedger(dataDir, entry) {
|
|
72245
|
-
const file =
|
|
72275
|
+
const file = import_node_path72.default.join(dataDir, LEDGER_FILENAME);
|
|
72246
72276
|
const entries = readImportLedger(dataDir);
|
|
72247
72277
|
entries.push(entry);
|
|
72248
|
-
|
|
72278
|
+
import_node_fs64.default.writeFileSync(file, JSON.stringify(entries, null, 2), { encoding: "utf8", mode: 384 });
|
|
72249
72279
|
}
|
|
72250
72280
|
|
|
72251
72281
|
// src/handlers/session.ts
|
|
72252
72282
|
init_protocol();
|
|
72253
|
-
var
|
|
72283
|
+
var import_node_path73 = __toESM(require("path"), 1);
|
|
72254
72284
|
function canReadSearchHit(ctx, file) {
|
|
72255
72285
|
if (!ctx || ctx.principal.kind === "owner") return true;
|
|
72256
72286
|
return canAccessPersona(ctx.grants, file.ownerPersonaId, "read") && file.creatorPrincipalId === ctx.principal.id;
|
|
@@ -72531,7 +72561,7 @@ ${attribution}` } : args;
|
|
|
72531
72561
|
`principal guest:${ctx.principal.id} cannot fork tool session ${args.toolSessionId}`
|
|
72532
72562
|
);
|
|
72533
72563
|
}
|
|
72534
|
-
if (source?.tool === "codex" && args.targetCwd &&
|
|
72564
|
+
if (source?.tool === "codex" && args.targetCwd && import_node_path73.default.resolve(args.targetCwd) !== import_node_path73.default.resolve(source.cwd)) {
|
|
72535
72565
|
throw new ClawdError(ERROR_CODES.FORBIDDEN, "fork: guest targetCwd must match source cwd");
|
|
72536
72566
|
}
|
|
72537
72567
|
}
|
|
@@ -72808,7 +72838,7 @@ function buildPermissionHandlers(deps) {
|
|
|
72808
72838
|
}
|
|
72809
72839
|
|
|
72810
72840
|
// src/handlers/history.ts
|
|
72811
|
-
var
|
|
72841
|
+
var path88 = __toESM(require("path"), 1);
|
|
72812
72842
|
init_protocol();
|
|
72813
72843
|
|
|
72814
72844
|
// src/session/recent-dirs.ts
|
|
@@ -72826,7 +72856,7 @@ function listRecentDirs(store, limit = 50) {
|
|
|
72826
72856
|
}
|
|
72827
72857
|
|
|
72828
72858
|
// src/permission/persona-paths.ts
|
|
72829
|
-
var
|
|
72859
|
+
var path87 = __toESM(require("path"), 1);
|
|
72830
72860
|
function getAllowedPersonaIds(grants, action) {
|
|
72831
72861
|
const ids = /* @__PURE__ */ new Set();
|
|
72832
72862
|
for (const g3 of grants) {
|
|
@@ -72839,42 +72869,42 @@ function getAllowedPersonaIds(grants, action) {
|
|
|
72839
72869
|
return ids;
|
|
72840
72870
|
}
|
|
72841
72871
|
function isGuestPathAllowed(grants, absPath, personaRoot, action = "read", userWorkDir) {
|
|
72842
|
-
const target =
|
|
72872
|
+
const target = path87.resolve(absPath);
|
|
72843
72873
|
if (userWorkDir) {
|
|
72844
|
-
const u2 =
|
|
72845
|
-
const usep = u2.endsWith(
|
|
72874
|
+
const u2 = path87.resolve(userWorkDir);
|
|
72875
|
+
const usep = u2.endsWith(path87.sep) ? "" : path87.sep;
|
|
72846
72876
|
if (target === u2 || target.startsWith(u2 + usep)) return true;
|
|
72847
72877
|
}
|
|
72848
|
-
const root =
|
|
72849
|
-
const sep4 = root.endsWith(
|
|
72878
|
+
const root = path87.resolve(personaRoot);
|
|
72879
|
+
const sep4 = root.endsWith(path87.sep) ? "" : path87.sep;
|
|
72850
72880
|
if (!target.startsWith(root + sep4)) return false;
|
|
72851
|
-
const rel =
|
|
72881
|
+
const rel = path87.relative(root, target);
|
|
72852
72882
|
if (!rel || rel.startsWith("..")) return false;
|
|
72853
|
-
const personaId2 = rel.split(
|
|
72883
|
+
const personaId2 = rel.split(path87.sep)[0];
|
|
72854
72884
|
if (!personaId2) return false;
|
|
72855
72885
|
const allowed = getAllowedPersonaIds(grants, action);
|
|
72856
72886
|
if (allowed === "*") return true;
|
|
72857
72887
|
return allowed.has(personaId2);
|
|
72858
72888
|
}
|
|
72859
72889
|
function personaIdFromPath(absPath, personaRoot) {
|
|
72860
|
-
const root =
|
|
72861
|
-
const target =
|
|
72862
|
-
const sep4 = root.endsWith(
|
|
72890
|
+
const root = path87.resolve(personaRoot);
|
|
72891
|
+
const target = path87.resolve(absPath);
|
|
72892
|
+
const sep4 = root.endsWith(path87.sep) ? "" : path87.sep;
|
|
72863
72893
|
if (!target.startsWith(root + sep4)) return null;
|
|
72864
|
-
const rel =
|
|
72894
|
+
const rel = path87.relative(root, target);
|
|
72865
72895
|
if (!rel || rel.startsWith("..")) return null;
|
|
72866
|
-
const id = rel.split(
|
|
72896
|
+
const id = rel.split(path87.sep)[0];
|
|
72867
72897
|
return id || null;
|
|
72868
72898
|
}
|
|
72869
72899
|
function isPathWithin(dir, absPath) {
|
|
72870
|
-
const d2 =
|
|
72871
|
-
const t2 =
|
|
72872
|
-
const sep4 = d2.endsWith(
|
|
72900
|
+
const d2 = path87.resolve(dir);
|
|
72901
|
+
const t2 = path87.resolve(absPath);
|
|
72902
|
+
const sep4 = d2.endsWith(path87.sep) ? "" : path87.sep;
|
|
72873
72903
|
return t2 === d2 || t2.startsWith(d2 + sep4);
|
|
72874
72904
|
}
|
|
72875
72905
|
function isPathInGuestBoundary(personaRoot, personaId2, userWorkDir, absPath) {
|
|
72876
72906
|
if (userWorkDir && isPathWithin(userWorkDir, absPath)) return true;
|
|
72877
|
-
return personaIdFromPath(
|
|
72907
|
+
return personaIdFromPath(path87.resolve(absPath), personaRoot) === personaId2;
|
|
72878
72908
|
}
|
|
72879
72909
|
|
|
72880
72910
|
// src/handlers/history.ts
|
|
@@ -72928,7 +72958,7 @@ function buildHistoryHandlers(deps) {
|
|
|
72928
72958
|
if (!pid) return false;
|
|
72929
72959
|
return isGuestPathAllowed(
|
|
72930
72960
|
ctx.grants,
|
|
72931
|
-
|
|
72961
|
+
path88.join(personaRoot, pid),
|
|
72932
72962
|
personaRoot,
|
|
72933
72963
|
"read",
|
|
72934
72964
|
userWorkDir
|
|
@@ -72940,7 +72970,7 @@ function buildHistoryHandlers(deps) {
|
|
|
72940
72970
|
};
|
|
72941
72971
|
const list = async (frame, _client, ctx) => {
|
|
72942
72972
|
const args = HistoryListArgs.parse(frame);
|
|
72943
|
-
assertGuestPath(ctx,
|
|
72973
|
+
assertGuestPath(ctx, path88.resolve(args.projectPath), personaRoot, "history:list", usersRoot);
|
|
72944
72974
|
const sessions = await history.listSessions(args);
|
|
72945
72975
|
return { response: { type: "history:list", sessions } };
|
|
72946
72976
|
};
|
|
@@ -73032,14 +73062,14 @@ function buildHistoryHandlers(deps) {
|
|
|
73032
73062
|
};
|
|
73033
73063
|
const subagents = async (frame, _client, ctx) => {
|
|
73034
73064
|
const args = HistorySubagentsArgs.parse(frame);
|
|
73035
|
-
assertGuestPath(ctx,
|
|
73065
|
+
assertGuestPath(ctx, path88.resolve(args.cwd), personaRoot, "history:subagents", usersRoot);
|
|
73036
73066
|
assertGuestOwnsToolSession(ctx, args.toolSessionId, "history:subagents");
|
|
73037
73067
|
const subs = await historyReaderForToolSession(args.toolSessionId).listSubagents(args);
|
|
73038
73068
|
return { response: { type: "history:subagents", subagents: subs } };
|
|
73039
73069
|
};
|
|
73040
73070
|
const subagentRead = async (frame, _client, ctx) => {
|
|
73041
73071
|
const args = HistorySubagentReadArgs.parse(frame);
|
|
73042
|
-
assertGuestPath(ctx,
|
|
73072
|
+
assertGuestPath(ctx, path88.resolve(args.cwd), personaRoot, "history:subagent-read", usersRoot);
|
|
73043
73073
|
assertGuestOwnsToolSession(ctx, args.toolSessionId, "history:subagent-read");
|
|
73044
73074
|
const res = await historyReaderForToolSession(args.toolSessionId).readSubagent(args);
|
|
73045
73075
|
return { response: { type: "history:subagent-read", ...res } };
|
|
@@ -73049,7 +73079,7 @@ function buildHistoryHandlers(deps) {
|
|
|
73049
73079
|
if (ctx?.principal.kind === "guest" && personaRoot) {
|
|
73050
73080
|
const userWorkDir = usersRoot ? deriveUserWorkDir(ctx.principal.id, usersRoot) : void 0;
|
|
73051
73081
|
const filtered = dirs.filter(
|
|
73052
|
-
(d2) => isGuestPathAllowed(ctx.grants,
|
|
73082
|
+
(d2) => isGuestPathAllowed(ctx.grants, path88.resolve(d2.cwd), personaRoot, "read", userWorkDir)
|
|
73053
73083
|
);
|
|
73054
73084
|
return { response: { type: "history:recentDirs", dirs: filtered } };
|
|
73055
73085
|
}
|
|
@@ -73066,17 +73096,17 @@ function buildHistoryHandlers(deps) {
|
|
|
73066
73096
|
}
|
|
73067
73097
|
|
|
73068
73098
|
// src/handlers/projects.ts
|
|
73069
|
-
var
|
|
73070
|
-
var
|
|
73071
|
-
var
|
|
73072
|
-
var
|
|
73099
|
+
var fs82 = __toESM(require("fs"), 1);
|
|
73100
|
+
var os29 = __toESM(require("os"), 1);
|
|
73101
|
+
var path89 = __toESM(require("path"), 1);
|
|
73102
|
+
var import_node_child_process20 = require("child_process");
|
|
73073
73103
|
init_protocol();
|
|
73074
|
-
var DEFAULT_PROJECTS_ROOT =
|
|
73104
|
+
var DEFAULT_PROJECTS_ROOT = path89.join(os29.homedir(), "Documents", "ChatGPT");
|
|
73075
73105
|
function allocateDir(root, name) {
|
|
73076
|
-
let candidate =
|
|
73106
|
+
let candidate = path89.join(root, name);
|
|
73077
73107
|
let n2 = 2;
|
|
73078
|
-
while (
|
|
73079
|
-
candidate =
|
|
73108
|
+
while (fs82.existsSync(candidate)) {
|
|
73109
|
+
candidate = path89.join(root, `${name} ${n2}`);
|
|
73080
73110
|
n2 += 1;
|
|
73081
73111
|
}
|
|
73082
73112
|
return candidate;
|
|
@@ -73104,11 +73134,11 @@ function buildProjectHandlers(deps) {
|
|
|
73104
73134
|
throw new ClawdError(ERROR_CODES.INVALID_CWD, "project:reveal \u4EC5\u652F\u6301 macOS");
|
|
73105
73135
|
}
|
|
73106
73136
|
try {
|
|
73107
|
-
if (!
|
|
73137
|
+
if (!fs82.statSync(args.path).isDirectory()) throw new Error("not dir");
|
|
73108
73138
|
} catch {
|
|
73109
73139
|
throw new ClawdError(ERROR_CODES.INVALID_CWD, `not a directory: ${args.path}`);
|
|
73110
73140
|
}
|
|
73111
|
-
const r2 = (0,
|
|
73141
|
+
const r2 = (0, import_node_child_process20.spawnSync)("open", ["-R", args.path], { stdio: "ignore" });
|
|
73112
73142
|
if (r2.status !== 0) {
|
|
73113
73143
|
throw new ClawdError(ERROR_CODES.INVALID_CWD, `open -R \u5931\u8D25: exit ${r2.status}`);
|
|
73114
73144
|
}
|
|
@@ -73120,7 +73150,7 @@ function buildProjectHandlers(deps) {
|
|
|
73120
73150
|
let target;
|
|
73121
73151
|
if (args.path) {
|
|
73122
73152
|
try {
|
|
73123
|
-
if (!
|
|
73153
|
+
if (!fs82.statSync(args.path).isDirectory()) throw new Error("not dir");
|
|
73124
73154
|
} catch {
|
|
73125
73155
|
throw new ClawdError(ERROR_CODES.INVALID_CWD, `not a directory: ${args.path}`);
|
|
73126
73156
|
}
|
|
@@ -73128,15 +73158,15 @@ function buildProjectHandlers(deps) {
|
|
|
73128
73158
|
} else {
|
|
73129
73159
|
const name = args.name;
|
|
73130
73160
|
try {
|
|
73131
|
-
|
|
73161
|
+
fs82.mkdirSync(root, { recursive: true });
|
|
73132
73162
|
target = allocateDir(root, name);
|
|
73133
|
-
|
|
73163
|
+
fs82.mkdirSync(target);
|
|
73134
73164
|
} catch (err) {
|
|
73135
73165
|
throw new ClawdError(ERROR_CODES.INVALID_CWD, `\u521B\u5EFA\u9879\u76EE\u76EE\u5F55\u5931\u8D25: ${String(err)}`);
|
|
73136
73166
|
}
|
|
73137
|
-
const git2 = (0,
|
|
73167
|
+
const git2 = (0, import_node_child_process20.spawnSync)("git", ["init"], { cwd: target, stdio: "ignore" });
|
|
73138
73168
|
if (git2.status !== 0) {
|
|
73139
|
-
|
|
73169
|
+
fs82.rmSync(target, { recursive: true, force: true });
|
|
73140
73170
|
throw new ClawdError(
|
|
73141
73171
|
ERROR_CODES.INVALID_CWD,
|
|
73142
73172
|
`git init \u5931\u8D25\uFF08${git2.error ? String(git2.error) : `exit ${git2.status}`}\uFF09: ${target}`
|
|
@@ -73161,9 +73191,9 @@ function buildProjectHandlers(deps) {
|
|
|
73161
73191
|
}
|
|
73162
73192
|
|
|
73163
73193
|
// src/handlers/workspace.ts
|
|
73164
|
-
var
|
|
73194
|
+
var path90 = __toESM(require("path"), 1);
|
|
73165
73195
|
init_protocol();
|
|
73166
|
-
var
|
|
73196
|
+
var os30 = __toESM(require("os"), 1);
|
|
73167
73197
|
init_protocol();
|
|
73168
73198
|
init_protocol();
|
|
73169
73199
|
function buildEnabledPluginNames(personaManager, personaId2) {
|
|
@@ -73203,23 +73233,23 @@ function buildWorkspaceHandlers(deps) {
|
|
|
73203
73233
|
const list = async (frame, _client, ctx) => {
|
|
73204
73234
|
const args = WorkspaceListArgs.parse(frame);
|
|
73205
73235
|
const isGuest = ctx?.principal.kind === "guest";
|
|
73206
|
-
const fallbackCwd = isGuest && personaRoot ? personaRoot :
|
|
73207
|
-
const resolvedCwd =
|
|
73208
|
-
const target = args.path ?
|
|
73236
|
+
const fallbackCwd = isGuest && personaRoot ? personaRoot : os30.homedir();
|
|
73237
|
+
const resolvedCwd = path90.resolve(args.cwd ?? fallbackCwd);
|
|
73238
|
+
const target = args.path ? path90.resolve(resolvedCwd, args.path) : resolvedCwd;
|
|
73209
73239
|
assertGuestPath2(ctx, target, personaRoot, "workspace:list", usersRoot);
|
|
73210
73240
|
const res = workspace.list({ ...args, cwd: resolvedCwd });
|
|
73211
73241
|
return { response: { type: "workspace:list", ...res } };
|
|
73212
73242
|
};
|
|
73213
73243
|
const read = async (frame, _client, ctx) => {
|
|
73214
73244
|
const args = WorkspaceReadArgs.parse(frame);
|
|
73215
|
-
const target =
|
|
73245
|
+
const target = path90.isAbsolute(args.path) ? path90.resolve(args.path) : path90.resolve(args.cwd, args.path);
|
|
73216
73246
|
assertGuestPath2(ctx, target, personaRoot, "workspace:read", usersRoot);
|
|
73217
73247
|
const res = workspace.read(args);
|
|
73218
73248
|
return { response: { type: "workspace:read", ...res } };
|
|
73219
73249
|
};
|
|
73220
73250
|
const skillsList = async (frame, _client, ctx) => {
|
|
73221
73251
|
const args = SkillsListArgs.parse(frame);
|
|
73222
|
-
const cwdAbs =
|
|
73252
|
+
const cwdAbs = path90.resolve(args.cwd);
|
|
73223
73253
|
assertGuestPath2(ctx, cwdAbs, personaRoot, "skills:list", usersRoot);
|
|
73224
73254
|
const list2 = await getSkillsForTool(args.tool ?? "claude", cwdAbs);
|
|
73225
73255
|
if (ctx?.principal.kind === "guest" && personaRoot) {
|
|
@@ -73231,7 +73261,7 @@ function buildWorkspaceHandlers(deps) {
|
|
|
73231
73261
|
};
|
|
73232
73262
|
const agentsList = async (frame, _client, ctx) => {
|
|
73233
73263
|
const args = AgentsListArgs.parse(frame);
|
|
73234
|
-
const cwdAbs =
|
|
73264
|
+
const cwdAbs = path90.resolve(args.cwd);
|
|
73235
73265
|
assertGuestPath2(ctx, cwdAbs, personaRoot, "agents:list", usersRoot);
|
|
73236
73266
|
if (isCodexFamily(args.tool) || isPiFamily(args.tool)) {
|
|
73237
73267
|
return { response: { type: "agents:list", agents: [] } };
|
|
@@ -73253,20 +73283,20 @@ function buildWorkspaceHandlers(deps) {
|
|
|
73253
73283
|
}
|
|
73254
73284
|
|
|
73255
73285
|
// src/handlers/git.ts
|
|
73256
|
-
var
|
|
73286
|
+
var path92 = __toESM(require("path"), 1);
|
|
73257
73287
|
init_protocol();
|
|
73258
73288
|
init_protocol();
|
|
73259
73289
|
|
|
73260
73290
|
// src/workspace/git.ts
|
|
73261
|
-
var
|
|
73262
|
-
var
|
|
73263
|
-
var
|
|
73291
|
+
var import_node_child_process21 = require("child_process");
|
|
73292
|
+
var import_node_fs65 = __toESM(require("fs"), 1);
|
|
73293
|
+
var import_node_path74 = __toESM(require("path"), 1);
|
|
73264
73294
|
var import_node_util2 = require("util");
|
|
73265
|
-
var pexec = (0, import_node_util2.promisify)(
|
|
73295
|
+
var pexec = (0, import_node_util2.promisify)(import_node_child_process21.execFile);
|
|
73266
73296
|
function normalizePath(p3) {
|
|
73267
|
-
const resolved =
|
|
73297
|
+
const resolved = import_node_path74.default.resolve(p3);
|
|
73268
73298
|
try {
|
|
73269
|
-
return
|
|
73299
|
+
return import_node_fs65.default.realpathSync(resolved);
|
|
73270
73300
|
} catch {
|
|
73271
73301
|
return resolved;
|
|
73272
73302
|
}
|
|
@@ -73340,7 +73370,7 @@ async function listGitBranches(cwd) {
|
|
|
73340
73370
|
function assertGuestCwd(ctx, cwd, personaRoot, method, usersRoot) {
|
|
73341
73371
|
if (!ctx || ctx.principal.kind !== "guest" || !personaRoot) return;
|
|
73342
73372
|
const userWorkDir = usersRoot ? deriveUserWorkDir(ctx.principal.id, usersRoot) : void 0;
|
|
73343
|
-
if (!isGuestPathAllowed(ctx.grants,
|
|
73373
|
+
if (!isGuestPathAllowed(ctx.grants, path92.resolve(cwd), personaRoot, "read", userWorkDir)) {
|
|
73344
73374
|
throw new ClawdError(
|
|
73345
73375
|
ERROR_CODES.UNAUTHORIZED,
|
|
73346
73376
|
`guest ${ctx.principal.id} cannot ${method} cwd ${cwd}`
|
|
@@ -73392,7 +73422,7 @@ function buildCapabilitiesHandlers(deps) {
|
|
|
73392
73422
|
init_protocol();
|
|
73393
73423
|
|
|
73394
73424
|
// src/tools/version-probe.ts
|
|
73395
|
-
var
|
|
73425
|
+
var import_node_child_process22 = require("child_process");
|
|
73396
73426
|
init_claude();
|
|
73397
73427
|
init_protocol();
|
|
73398
73428
|
function parseVersionOutput(out) {
|
|
@@ -73400,7 +73430,7 @@ function parseVersionOutput(out) {
|
|
|
73400
73430
|
}
|
|
73401
73431
|
function execVersion(bin, tool) {
|
|
73402
73432
|
return new Promise((resolve9, reject) => {
|
|
73403
|
-
(0,
|
|
73433
|
+
(0, import_node_child_process22.execFile)(bin, ["--version"], { timeout: 5e3, env: tool === "codex" ? codexEnvironment(bin) : process.env }, (err, stdout) => {
|
|
73404
73434
|
if (err) reject(err);
|
|
73405
73435
|
else resolve9(String(stdout));
|
|
73406
73436
|
});
|
|
@@ -73433,7 +73463,7 @@ async function probeToolVersions(opts = {}) {
|
|
|
73433
73463
|
}
|
|
73434
73464
|
|
|
73435
73465
|
// src/tools/pool-connect.ts
|
|
73436
|
-
var
|
|
73466
|
+
var import_node_child_process23 = require("child_process");
|
|
73437
73467
|
init_protocol();
|
|
73438
73468
|
var POOL_SETUP_SCRIPT_PATH = "/api/setup.sh";
|
|
73439
73469
|
var POOL_SCRIPT_FETCH_TIMEOUT_MS = 5e3;
|
|
@@ -73459,7 +73489,7 @@ async function fetchScript(deps) {
|
|
|
73459
73489
|
}
|
|
73460
73490
|
function runScript(script, apiKey, deps) {
|
|
73461
73491
|
return new Promise((resolve9, reject) => {
|
|
73462
|
-
const proc = (0,
|
|
73492
|
+
const proc = (0, import_node_child_process23.spawn)("bash", ["-s"], {
|
|
73463
73493
|
env: { ...deps.env ?? process.env, CPA_KEY: apiKey, CPA_MODE: "api" },
|
|
73464
73494
|
stdio: ["pipe", "pipe", "pipe"]
|
|
73465
73495
|
});
|
|
@@ -73504,7 +73534,7 @@ function runScript(script, apiKey, deps) {
|
|
|
73504
73534
|
}
|
|
73505
73535
|
|
|
73506
73536
|
// src/tools/claude-auth-status.ts
|
|
73507
|
-
var
|
|
73537
|
+
var import_node_child_process24 = require("child_process");
|
|
73508
73538
|
var str5 = (v3) => typeof v3 === "string" && v3 ? v3 : void 0;
|
|
73509
73539
|
function mapClaudeAuthStatus(raw) {
|
|
73510
73540
|
if (!raw || typeof raw !== "object" || Array.isArray(raw)) {
|
|
@@ -73527,7 +73557,7 @@ function mapClaudeAuthStatus(raw) {
|
|
|
73527
73557
|
};
|
|
73528
73558
|
}
|
|
73529
73559
|
async function queryClaudeAuthStatus(deps = {}) {
|
|
73530
|
-
const run = deps.execFileImpl ??
|
|
73560
|
+
const run = deps.execFileImpl ?? import_node_child_process24.execFile;
|
|
73531
73561
|
const env = deps.env ?? process.env;
|
|
73532
73562
|
const bin = env.CLAUDE_BIN ?? "claude";
|
|
73533
73563
|
const stdout = await new Promise((resolve9, reject) => {
|
|
@@ -73597,12 +73627,12 @@ async function queryCodexAccount(deps = {}) {
|
|
|
73597
73627
|
}
|
|
73598
73628
|
|
|
73599
73629
|
// src/tools/pi-account.ts
|
|
73600
|
-
var
|
|
73601
|
-
var
|
|
73630
|
+
var import_node_fs66 = __toESM(require("fs"), 1);
|
|
73631
|
+
var import_node_path75 = __toESM(require("path"), 1);
|
|
73602
73632
|
function readPiCredentials(agentDir) {
|
|
73603
73633
|
let raw;
|
|
73604
73634
|
try {
|
|
73605
|
-
raw = JSON.parse(
|
|
73635
|
+
raw = JSON.parse(import_node_fs66.default.readFileSync(import_node_path75.default.join(agentDir, "auth.json"), "utf8"));
|
|
73606
73636
|
} catch {
|
|
73607
73637
|
return {};
|
|
73608
73638
|
}
|
|
@@ -73686,8 +73716,8 @@ function buildEngineHandlers(deps, overrides = {}) {
|
|
|
73686
73716
|
}
|
|
73687
73717
|
|
|
73688
73718
|
// src/handlers/channels.ts
|
|
73689
|
-
var
|
|
73690
|
-
var
|
|
73719
|
+
var import_node_fs67 = __toESM(require("fs"), 1);
|
|
73720
|
+
var import_node_path76 = __toESM(require("path"), 1);
|
|
73691
73721
|
init_subscription_channels_apply();
|
|
73692
73722
|
init_codex_provider_models();
|
|
73693
73723
|
function buildChannelsHandlers(deps) {
|
|
@@ -73709,8 +73739,8 @@ function buildChannelsHandlers(deps) {
|
|
|
73709
73739
|
for (const tool of ["codex", "claude", "pi"]) deps.manager.invalidateCapabilities(tool);
|
|
73710
73740
|
};
|
|
73711
73741
|
const restoreStore = deps.store.snapshot();
|
|
73712
|
-
const restoreCodex = snapshotFile(
|
|
73713
|
-
const restorePi =
|
|
73742
|
+
const restoreCodex = snapshotFile(import_node_path76.default.join(codexHome, "config.toml"));
|
|
73743
|
+
const restorePi = import_node_fs67.default.existsSync(agentDir) ? snapshotFile(import_node_path76.default.join(agentDir, PI_SUBSCRIPTION_FILE)) : null;
|
|
73714
73744
|
let next;
|
|
73715
73745
|
try {
|
|
73716
73746
|
next = mutate();
|
|
@@ -73730,8 +73760,8 @@ function buildChannelsHandlers(deps) {
|
|
|
73730
73760
|
}
|
|
73731
73761
|
commitStore();
|
|
73732
73762
|
}
|
|
73733
|
-
restoreClaude = snapshotFile(
|
|
73734
|
-
restoreClaudeBackup = snapshotFile(
|
|
73763
|
+
restoreClaude = snapshotFile(import_node_path76.default.join(claudeDir, "settings.json"));
|
|
73764
|
+
restoreClaudeBackup = snapshotFile(import_node_path76.default.join(claudeDir, CLAUDE_SUBSCRIPTION_BACKUP));
|
|
73735
73765
|
applyCodexSubscriptionChannel({ codexHome, channel: next });
|
|
73736
73766
|
applyPiSubscriptionChannel({ agentDir, channel: next });
|
|
73737
73767
|
applyClaudeSubscriptionChannel({ configDir: claudeDir, channel: next });
|
|
@@ -74447,7 +74477,7 @@ function buildDashboardHandlers(deps) {
|
|
|
74447
74477
|
}
|
|
74448
74478
|
|
|
74449
74479
|
// src/handlers/meta.ts
|
|
74450
|
-
var
|
|
74480
|
+
var import_node_os28 = __toESM(require("os"), 1);
|
|
74451
74481
|
init_protocol();
|
|
74452
74482
|
|
|
74453
74483
|
// src/handlers/method-grants.ts
|
|
@@ -74708,21 +74738,21 @@ function computeMethodAccess(args) {
|
|
|
74708
74738
|
}
|
|
74709
74739
|
|
|
74710
74740
|
// src/version.ts
|
|
74711
|
-
var version = "0.2.
|
|
74741
|
+
var version = "0.2.663".length > 0 ? "0.2.663" : "dev";
|
|
74712
74742
|
|
|
74713
74743
|
// src/cli-probe/probe.ts
|
|
74714
|
-
var
|
|
74715
|
-
var
|
|
74744
|
+
var fs86 = __toESM(require("fs"), 1);
|
|
74745
|
+
var path95 = __toESM(require("path"), 1);
|
|
74716
74746
|
var PKG_NAME = "@clawos-dev/clawd";
|
|
74717
74747
|
var BIN_NAME = "clawd";
|
|
74718
74748
|
var MAX_PARENT_HOPS = 5;
|
|
74719
74749
|
function probeGlobalCli(pathEnv) {
|
|
74720
74750
|
if (!pathEnv) return null;
|
|
74721
|
-
for (const dir of pathEnv.split(
|
|
74751
|
+
for (const dir of pathEnv.split(path95.delimiter)) {
|
|
74722
74752
|
if (!dir) continue;
|
|
74723
74753
|
let real;
|
|
74724
74754
|
try {
|
|
74725
|
-
real =
|
|
74755
|
+
real = fs86.realpathSync(path95.join(dir, BIN_NAME));
|
|
74726
74756
|
} catch {
|
|
74727
74757
|
continue;
|
|
74728
74758
|
}
|
|
@@ -74732,15 +74762,15 @@ function probeGlobalCli(pathEnv) {
|
|
|
74732
74762
|
return null;
|
|
74733
74763
|
}
|
|
74734
74764
|
function readOwnPackageVersion(entryPath) {
|
|
74735
|
-
let dir =
|
|
74765
|
+
let dir = path95.dirname(entryPath);
|
|
74736
74766
|
for (let i2 = 0; i2 < MAX_PARENT_HOPS; i2++) {
|
|
74737
74767
|
try {
|
|
74738
|
-
const raw =
|
|
74768
|
+
const raw = fs86.readFileSync(path95.join(dir, "package.json"), "utf8");
|
|
74739
74769
|
const pkg = JSON.parse(raw);
|
|
74740
74770
|
if (pkg.name !== PKG_NAME) return null;
|
|
74741
74771
|
return typeof pkg.version === "string" && pkg.version ? pkg.version : null;
|
|
74742
74772
|
} catch {
|
|
74743
|
-
const parent =
|
|
74773
|
+
const parent = path95.dirname(dir);
|
|
74744
74774
|
if (parent === dir) return null;
|
|
74745
74775
|
dir = parent;
|
|
74746
74776
|
}
|
|
@@ -74776,7 +74806,7 @@ function buildReadyFrame(deps, client) {
|
|
|
74776
74806
|
return {
|
|
74777
74807
|
version,
|
|
74778
74808
|
protocolVersion: PROTOCOL_VERSION,
|
|
74779
|
-
hostname:
|
|
74809
|
+
hostname: import_node_os28.default.hostname(),
|
|
74780
74810
|
os: process.platform,
|
|
74781
74811
|
tools,
|
|
74782
74812
|
runningSessions: info.runningSessions,
|
|
@@ -74913,7 +74943,7 @@ function buildPersonaHandlers(deps) {
|
|
|
74913
74943
|
}
|
|
74914
74944
|
|
|
74915
74945
|
// src/handlers/attachment.ts
|
|
74916
|
-
var
|
|
74946
|
+
var import_node_path77 = __toESM(require("path"), 1);
|
|
74917
74947
|
init_protocol();
|
|
74918
74948
|
init_protocol();
|
|
74919
74949
|
function assertGuestAttachmentPath(ctx, absPath, personaRoot, method, usersRoot) {
|
|
@@ -74992,12 +75022,12 @@ function buildAttachmentHandlers(deps) {
|
|
|
74992
75022
|
`session ${args.sessionId} scope unresolved`
|
|
74993
75023
|
);
|
|
74994
75024
|
}
|
|
74995
|
-
const cwdAbs =
|
|
74996
|
-
const candidateAbs =
|
|
75025
|
+
const cwdAbs = import_node_path77.default.resolve(sessionFile.cwd);
|
|
75026
|
+
const candidateAbs = import_node_path77.default.isAbsolute(args.relPath) ? import_node_path77.default.resolve(args.relPath) : import_node_path77.default.resolve(cwdAbs, args.relPath);
|
|
74997
75027
|
guardAttachmentPath(ctx, args.sessionId, candidateAbs, "attachment.signUrl", "group-acl");
|
|
74998
75028
|
const entries = deps.groupFileStore.list(scope, args.sessionId);
|
|
74999
75029
|
const entry = entries.find((e) => {
|
|
75000
|
-
const storedAbs =
|
|
75030
|
+
const storedAbs = import_node_path77.default.isAbsolute(e.relPath) ? import_node_path77.default.resolve(e.relPath) : import_node_path77.default.resolve(cwdAbs, e.relPath);
|
|
75001
75031
|
return storedAbs === candidateAbs && !e.stale;
|
|
75002
75032
|
});
|
|
75003
75033
|
if (!entry) {
|
|
@@ -75021,7 +75051,7 @@ function buildAttachmentHandlers(deps) {
|
|
|
75021
75051
|
if (!ctx || ctx.principal.kind !== "guest" || !deps.personaRoot || !deps.sessionStore) return;
|
|
75022
75052
|
const f2 = deps.sessionStore.read(sessionId);
|
|
75023
75053
|
if (!f2) return;
|
|
75024
|
-
assertGuestAttachmentPath(ctx,
|
|
75054
|
+
assertGuestAttachmentPath(ctx, import_node_path77.default.resolve(f2.cwd), deps.personaRoot, method, deps.usersRoot);
|
|
75025
75055
|
}
|
|
75026
75056
|
const groupAdd = async (frame, _client, ctx) => {
|
|
75027
75057
|
if (!deps.groupFileStore || !deps.getSessionScope) {
|
|
@@ -75036,8 +75066,8 @@ function buildAttachmentHandlers(deps) {
|
|
|
75036
75066
|
if (!scope) {
|
|
75037
75067
|
throw new ClawdError(ERROR_CODES.VALIDATION_ERROR, `session ${args.sessionId} not found`);
|
|
75038
75068
|
}
|
|
75039
|
-
const cwdAbs =
|
|
75040
|
-
const candidateAbs =
|
|
75069
|
+
const cwdAbs = import_node_path77.default.resolve(deps.sessionStore?.read(args.sessionId)?.cwd ?? ".");
|
|
75070
|
+
const candidateAbs = import_node_path77.default.isAbsolute(args.relPath) ? import_node_path77.default.resolve(args.relPath) : import_node_path77.default.resolve(cwdAbs, args.relPath);
|
|
75041
75071
|
guardAttachmentPath(ctx, args.sessionId, candidateAbs, "attachment.groupAdd", "cwd-subtree");
|
|
75042
75072
|
const from = args.origin === "agent" ? "agent" : ctx?.principal.kind === "owner" ? "owner" : "agent";
|
|
75043
75073
|
const size = 0;
|
|
@@ -75096,19 +75126,19 @@ function buildAttachmentHandlers(deps) {
|
|
|
75096
75126
|
|
|
75097
75127
|
// src/handlers/extension.ts
|
|
75098
75128
|
var import_promises15 = __toESM(require("fs/promises"), 1);
|
|
75099
|
-
var
|
|
75129
|
+
var import_node_path82 = __toESM(require("path"), 1);
|
|
75100
75130
|
init_protocol();
|
|
75101
75131
|
|
|
75102
75132
|
// src/extension/bundle-zip.ts
|
|
75103
75133
|
var import_promises12 = __toESM(require("fs/promises"), 1);
|
|
75104
|
-
var
|
|
75134
|
+
var import_node_path78 = __toESM(require("path"), 1);
|
|
75105
75135
|
var import_node_crypto26 = __toESM(require("crypto"), 1);
|
|
75106
75136
|
var import_jszip3 = __toESM(require_lib3(), 1);
|
|
75107
75137
|
async function bundleExtensionDir(dir) {
|
|
75108
75138
|
const entries = await listFilesSorted(dir);
|
|
75109
75139
|
const zip = new import_jszip3.default();
|
|
75110
75140
|
for (const rel of entries) {
|
|
75111
|
-
const abs =
|
|
75141
|
+
const abs = import_node_path78.default.join(dir, rel);
|
|
75112
75142
|
const content = await import_promises12.default.readFile(abs);
|
|
75113
75143
|
zip.file(rel, content, { date: FIXED_DATE });
|
|
75114
75144
|
}
|
|
@@ -75129,7 +75159,7 @@ async function listFilesSorted(rootDir) {
|
|
|
75129
75159
|
return out;
|
|
75130
75160
|
}
|
|
75131
75161
|
async function walk(absRoot, relPrefix, out) {
|
|
75132
|
-
const dirAbs =
|
|
75162
|
+
const dirAbs = import_node_path78.default.join(absRoot, relPrefix);
|
|
75133
75163
|
const entries = await import_promises12.default.readdir(dirAbs, { withFileTypes: true });
|
|
75134
75164
|
for (const e of entries) {
|
|
75135
75165
|
if (IGNORE_BASENAMES.has(e.name)) continue;
|
|
@@ -75183,25 +75213,25 @@ function computePublishCheck(args) {
|
|
|
75183
75213
|
|
|
75184
75214
|
// src/extension/install-flow.ts
|
|
75185
75215
|
var import_promises13 = __toESM(require("fs/promises"), 1);
|
|
75186
|
-
var
|
|
75187
|
-
var
|
|
75216
|
+
var import_node_path80 = __toESM(require("path"), 1);
|
|
75217
|
+
var import_node_os30 = __toESM(require("os"), 1);
|
|
75188
75218
|
var import_node_crypto27 = __toESM(require("crypto"), 1);
|
|
75189
75219
|
var import_jszip4 = __toESM(require_lib3(), 1);
|
|
75190
75220
|
|
|
75191
75221
|
// src/extension/paths.ts
|
|
75192
|
-
var
|
|
75193
|
-
var
|
|
75222
|
+
var import_node_os29 = __toESM(require("os"), 1);
|
|
75223
|
+
var import_node_path79 = __toESM(require("path"), 1);
|
|
75194
75224
|
function clawdHomeRoot(override) {
|
|
75195
|
-
return override ?? process.env.CLAWD_HOME ??
|
|
75225
|
+
return override ?? process.env.CLAWD_HOME ?? import_node_path79.default.join(import_node_os29.default.homedir(), ".clawd");
|
|
75196
75226
|
}
|
|
75197
75227
|
function extensionsRoot(override) {
|
|
75198
|
-
return
|
|
75228
|
+
return import_node_path79.default.join(clawdHomeRoot(override), "extensions");
|
|
75199
75229
|
}
|
|
75200
75230
|
function publishedChannelsFile(override) {
|
|
75201
|
-
return
|
|
75231
|
+
return import_node_path79.default.join(clawdHomeRoot(override), "extensions-published.json");
|
|
75202
75232
|
}
|
|
75203
75233
|
function bundleCacheRoot(override) {
|
|
75204
|
-
return
|
|
75234
|
+
return import_node_path79.default.join(clawdHomeRoot(override), "extension-bundles");
|
|
75205
75235
|
}
|
|
75206
75236
|
|
|
75207
75237
|
// src/extension/install-flow.ts
|
|
@@ -75228,7 +75258,7 @@ async function installFromChannel(args, deps) {
|
|
|
75228
75258
|
throw new InstallError("ZIP_INVALID", `failed to load zip: ${e.message}`);
|
|
75229
75259
|
}
|
|
75230
75260
|
for (const name of Object.keys(zip.files)) {
|
|
75231
|
-
if (name.includes("..") || name.startsWith("/") ||
|
|
75261
|
+
if (name.includes("..") || name.startsWith("/") || import_node_path80.default.isAbsolute(name)) {
|
|
75232
75262
|
throw new InstallError("ZIP_INVALID", `unsafe zip entry: ${name}`);
|
|
75233
75263
|
}
|
|
75234
75264
|
}
|
|
@@ -75260,7 +75290,7 @@ async function installFromChannel(args, deps) {
|
|
|
75260
75290
|
);
|
|
75261
75291
|
}
|
|
75262
75292
|
const localExtId = namespacedExtId(ownerSlug, channelRef.ownerPrincipalId);
|
|
75263
|
-
const destDir =
|
|
75293
|
+
const destDir = import_node_path80.default.join(deps.extensionsRoot, localExtId);
|
|
75264
75294
|
let destExists = false;
|
|
75265
75295
|
try {
|
|
75266
75296
|
await import_promises13.default.access(destDir);
|
|
@@ -75274,16 +75304,16 @@ async function installFromChannel(args, deps) {
|
|
|
75274
75304
|
);
|
|
75275
75305
|
}
|
|
75276
75306
|
const stage = await import_promises13.default.mkdtemp(
|
|
75277
|
-
|
|
75307
|
+
import_node_path80.default.join(import_node_os30.default.tmpdir(), `clawd-ext-install-${localExtId}-`)
|
|
75278
75308
|
);
|
|
75279
75309
|
try {
|
|
75280
75310
|
for (const [name, entry] of Object.entries(zip.files)) {
|
|
75281
|
-
const dest =
|
|
75311
|
+
const dest = import_node_path80.default.join(stage, name);
|
|
75282
75312
|
if (entry.dir) {
|
|
75283
75313
|
await import_promises13.default.mkdir(dest, { recursive: true });
|
|
75284
75314
|
continue;
|
|
75285
75315
|
}
|
|
75286
|
-
await import_promises13.default.mkdir(
|
|
75316
|
+
await import_promises13.default.mkdir(import_node_path80.default.dirname(dest), { recursive: true });
|
|
75287
75317
|
if (name === "manifest.json") {
|
|
75288
75318
|
const rewritten = { ...parsed.data, id: localExtId };
|
|
75289
75319
|
await import_promises13.default.writeFile(dest, JSON.stringify(rewritten, null, 2));
|
|
@@ -75304,8 +75334,8 @@ async function installFromChannel(args, deps) {
|
|
|
75304
75334
|
|
|
75305
75335
|
// src/extension/update-flow.ts
|
|
75306
75336
|
var import_promises14 = __toESM(require("fs/promises"), 1);
|
|
75307
|
-
var
|
|
75308
|
-
var
|
|
75337
|
+
var import_node_path81 = __toESM(require("path"), 1);
|
|
75338
|
+
var import_node_os31 = __toESM(require("os"), 1);
|
|
75309
75339
|
var import_node_crypto28 = __toESM(require("crypto"), 1);
|
|
75310
75340
|
var import_jszip5 = __toESM(require_lib3(), 1);
|
|
75311
75341
|
var UpdateError = class extends Error {
|
|
@@ -75321,11 +75351,11 @@ async function updateFromChannel(args, deps) {
|
|
|
75321
75351
|
channelRef.extId,
|
|
75322
75352
|
channelRef.ownerPrincipalId
|
|
75323
75353
|
);
|
|
75324
|
-
const liveDir =
|
|
75354
|
+
const liveDir = import_node_path81.default.join(deps.extensionsRoot, localExtId);
|
|
75325
75355
|
const prevDir = `${liveDir}.prev`;
|
|
75326
75356
|
let existingVersion;
|
|
75327
75357
|
try {
|
|
75328
|
-
const raw = await import_promises14.default.readFile(
|
|
75358
|
+
const raw = await import_promises14.default.readFile(import_node_path81.default.join(liveDir, "manifest.json"), "utf8");
|
|
75329
75359
|
const parsed2 = ExtensionManifestSchema.safeParse(JSON.parse(raw));
|
|
75330
75360
|
if (!parsed2.success) {
|
|
75331
75361
|
throw new UpdateError(
|
|
@@ -75358,7 +75388,7 @@ async function updateFromChannel(args, deps) {
|
|
|
75358
75388
|
throw new UpdateError("ZIP_INVALID", `failed to load zip: ${e.message}`);
|
|
75359
75389
|
}
|
|
75360
75390
|
for (const name of Object.keys(zip.files)) {
|
|
75361
|
-
if (name.includes("..") || name.startsWith("/") ||
|
|
75391
|
+
if (name.includes("..") || name.startsWith("/") || import_node_path81.default.isAbsolute(name)) {
|
|
75362
75392
|
throw new UpdateError("ZIP_INVALID", `unsafe zip entry: ${name}`);
|
|
75363
75393
|
}
|
|
75364
75394
|
}
|
|
@@ -75393,16 +75423,16 @@ async function updateFromChannel(args, deps) {
|
|
|
75393
75423
|
await import_promises14.default.rm(prevDir, { recursive: true, force: true });
|
|
75394
75424
|
await import_promises14.default.rename(liveDir, prevDir);
|
|
75395
75425
|
const stage = await import_promises14.default.mkdtemp(
|
|
75396
|
-
|
|
75426
|
+
import_node_path81.default.join(import_node_os31.default.tmpdir(), `clawd-ext-update-${localExtId}-`)
|
|
75397
75427
|
);
|
|
75398
75428
|
try {
|
|
75399
75429
|
for (const [name, entry] of Object.entries(zip.files)) {
|
|
75400
|
-
const dest =
|
|
75430
|
+
const dest = import_node_path81.default.join(stage, name);
|
|
75401
75431
|
if (entry.dir) {
|
|
75402
75432
|
await import_promises14.default.mkdir(dest, { recursive: true });
|
|
75403
75433
|
continue;
|
|
75404
75434
|
}
|
|
75405
|
-
await import_promises14.default.mkdir(
|
|
75435
|
+
await import_promises14.default.mkdir(import_node_path81.default.dirname(dest), { recursive: true });
|
|
75406
75436
|
if (name === "manifest.json") {
|
|
75407
75437
|
const rewritten = { ...parsed.data, id: localExtId };
|
|
75408
75438
|
await import_promises14.default.writeFile(dest, JSON.stringify(rewritten, null, 2));
|
|
@@ -75469,7 +75499,7 @@ async function rewriteManifestVersion(root, extId, newVersion, previousPublished
|
|
|
75469
75499
|
);
|
|
75470
75500
|
}
|
|
75471
75501
|
}
|
|
75472
|
-
const manifestPath =
|
|
75502
|
+
const manifestPath = import_node_path82.default.join(root, extId, "manifest.json");
|
|
75473
75503
|
const manifest = await readManifest(root, extId);
|
|
75474
75504
|
const next = { ...manifest, version: newVersion };
|
|
75475
75505
|
const tmp = `${manifestPath}.tmp`;
|
|
@@ -75477,7 +75507,7 @@ async function rewriteManifestVersion(root, extId, newVersion, previousPublished
|
|
|
75477
75507
|
await import_promises15.default.rename(tmp, manifestPath);
|
|
75478
75508
|
}
|
|
75479
75509
|
async function readManifest(root, extId) {
|
|
75480
|
-
const file =
|
|
75510
|
+
const file = import_node_path82.default.join(root, extId, "manifest.json");
|
|
75481
75511
|
let raw;
|
|
75482
75512
|
try {
|
|
75483
75513
|
raw = await import_promises15.default.readFile(file, "utf8");
|
|
@@ -75561,7 +75591,7 @@ function buildExtensionHandlers(deps) {
|
|
|
75561
75591
|
};
|
|
75562
75592
|
async function buildSnapshotMeta(extId) {
|
|
75563
75593
|
const manifest = await readManifest(deps.root, extId);
|
|
75564
|
-
const { sha256, buffer } = await bundleExtensionDir(
|
|
75594
|
+
const { sha256, buffer } = await bundleExtensionDir(import_node_path82.default.join(deps.root, extId));
|
|
75565
75595
|
return { manifest, contentHash: sha256, buffer };
|
|
75566
75596
|
}
|
|
75567
75597
|
const publish = async (frame, _client, ctx) => {
|
|
@@ -76388,7 +76418,7 @@ function buildVisitorHandlers(deps) {
|
|
|
76388
76418
|
|
|
76389
76419
|
// src/extension/registry.ts
|
|
76390
76420
|
var import_promises17 = __toESM(require("fs/promises"), 1);
|
|
76391
|
-
var
|
|
76421
|
+
var import_node_path83 = __toESM(require("path"), 1);
|
|
76392
76422
|
async function loadAll(root) {
|
|
76393
76423
|
let entries;
|
|
76394
76424
|
try {
|
|
@@ -76401,13 +76431,13 @@ async function loadAll(root) {
|
|
|
76401
76431
|
for (const ent of entries) {
|
|
76402
76432
|
if (!ent.isDirectory()) continue;
|
|
76403
76433
|
if (ent.name.startsWith(".")) continue;
|
|
76404
|
-
records.push(await loadOne(
|
|
76434
|
+
records.push(await loadOne(import_node_path83.default.join(root, ent.name), ent.name));
|
|
76405
76435
|
}
|
|
76406
76436
|
records.sort((a2, b3) => a2.extId < b3.extId ? -1 : a2.extId > b3.extId ? 1 : 0);
|
|
76407
76437
|
return records;
|
|
76408
76438
|
}
|
|
76409
76439
|
async function loadOne(dir, dirName) {
|
|
76410
|
-
const manifestPath =
|
|
76440
|
+
const manifestPath = import_node_path83.default.join(dir, "manifest.json");
|
|
76411
76441
|
let raw;
|
|
76412
76442
|
try {
|
|
76413
76443
|
raw = await import_promises17.default.readFile(manifestPath, "utf8");
|
|
@@ -76452,7 +76482,7 @@ async function loadOne(dir, dirName) {
|
|
|
76452
76482
|
|
|
76453
76483
|
// src/extension/uninstall.ts
|
|
76454
76484
|
var import_promises18 = __toESM(require("fs/promises"), 1);
|
|
76455
|
-
var
|
|
76485
|
+
var import_node_path84 = __toESM(require("path"), 1);
|
|
76456
76486
|
var UninstallError = class extends Error {
|
|
76457
76487
|
constructor(code, message) {
|
|
76458
76488
|
super(message);
|
|
@@ -76461,7 +76491,7 @@ var UninstallError = class extends Error {
|
|
|
76461
76491
|
code;
|
|
76462
76492
|
};
|
|
76463
76493
|
async function uninstall(deps) {
|
|
76464
|
-
const dir =
|
|
76494
|
+
const dir = import_node_path84.default.join(deps.root, deps.extId);
|
|
76465
76495
|
try {
|
|
76466
76496
|
await import_promises18.default.access(dir);
|
|
76467
76497
|
} catch {
|
|
@@ -76478,15 +76508,15 @@ var import_node_crypto29 = require("crypto");
|
|
|
76478
76508
|
init_protocol();
|
|
76479
76509
|
|
|
76480
76510
|
// src/peer-ops/run-command.ts
|
|
76481
|
-
var
|
|
76482
|
-
var
|
|
76511
|
+
var import_node_child_process25 = require("child_process");
|
|
76512
|
+
var import_node_os32 = __toESM(require("os"), 1);
|
|
76483
76513
|
var DEFAULT_TIMEOUT_MS6 = 3e4;
|
|
76484
76514
|
var MAX_TIMEOUT_MS = 3e5;
|
|
76485
76515
|
var MAX_OUTPUT_BYTES = 1048576;
|
|
76486
76516
|
function runCommand2(command, opts = {}) {
|
|
76487
76517
|
const timeoutMs = Math.min(opts.timeoutMs ?? DEFAULT_TIMEOUT_MS6, MAX_TIMEOUT_MS);
|
|
76488
76518
|
return new Promise((resolve9) => {
|
|
76489
|
-
const child = (0,
|
|
76519
|
+
const child = (0, import_node_child_process25.spawn)("bash", ["-c", command], { cwd: import_node_os32.default.homedir() });
|
|
76490
76520
|
const out = [];
|
|
76491
76521
|
const err = [];
|
|
76492
76522
|
let outBytes = 0;
|
|
@@ -76677,7 +76707,7 @@ function buildMethodHandlers(deps) {
|
|
|
76677
76707
|
broadcast: deps.broadcastToOwners
|
|
76678
76708
|
}),
|
|
76679
76709
|
...buildMasterHandlers({
|
|
76680
|
-
authorityTablePath:
|
|
76710
|
+
authorityTablePath: import_node_path85.default.join(deps.masterDataDir, "master-authority.json")
|
|
76681
76711
|
}),
|
|
76682
76712
|
...buildTopicHandlers({
|
|
76683
76713
|
topicStore: deps.topicStore,
|
|
@@ -76818,8 +76848,8 @@ async function dispatchRpc(method, frame, client, ctx, deps) {
|
|
|
76818
76848
|
}
|
|
76819
76849
|
|
|
76820
76850
|
// src/extension/runtime.ts
|
|
76821
|
-
var
|
|
76822
|
-
var
|
|
76851
|
+
var import_node_child_process26 = require("child_process");
|
|
76852
|
+
var import_node_path86 = __toESM(require("path"), 1);
|
|
76823
76853
|
var import_promises19 = require("timers/promises");
|
|
76824
76854
|
|
|
76825
76855
|
// src/extension/port-allocator.ts
|
|
@@ -76920,13 +76950,13 @@ var Runtime = class {
|
|
|
76920
76950
|
/\$CLAWOS_EXT_PORT/g,
|
|
76921
76951
|
String(port)
|
|
76922
76952
|
);
|
|
76923
|
-
const dir =
|
|
76953
|
+
const dir = import_node_path86.default.join(this.root, extId);
|
|
76924
76954
|
const env = {
|
|
76925
76955
|
...process.env,
|
|
76926
76956
|
CLAWOS_EXT_PORT: String(port),
|
|
76927
76957
|
CLAWOS_EXT_ID: extId
|
|
76928
76958
|
};
|
|
76929
|
-
const child = (0,
|
|
76959
|
+
const child = (0, import_node_child_process26.spawn)("sh", ["-c", cmd], {
|
|
76930
76960
|
cwd: dir,
|
|
76931
76961
|
env,
|
|
76932
76962
|
stdio: ["ignore", "pipe", "pipe"],
|
|
@@ -77032,7 +77062,7 @@ ${handle.stderrTail}`
|
|
|
77032
77062
|
|
|
77033
77063
|
// src/extension/published-channels.ts
|
|
77034
77064
|
var import_promises20 = __toESM(require("fs/promises"), 1);
|
|
77035
|
-
var
|
|
77065
|
+
var import_node_path87 = __toESM(require("path"), 1);
|
|
77036
77066
|
init_zod();
|
|
77037
77067
|
var PublishedChannelsError = class extends Error {
|
|
77038
77068
|
constructor(code, message) {
|
|
@@ -77129,7 +77159,7 @@ var PublishedChannelStore = class {
|
|
|
77129
77159
|
)
|
|
77130
77160
|
};
|
|
77131
77161
|
const tmp = `${this.filePath}.tmp`;
|
|
77132
|
-
await import_promises20.default.mkdir(
|
|
77162
|
+
await import_promises20.default.mkdir(import_node_path87.default.dirname(this.filePath), { recursive: true });
|
|
77133
77163
|
await import_promises20.default.writeFile(tmp, JSON.stringify(data, null, 2), { mode: 384 });
|
|
77134
77164
|
await import_promises20.default.rename(tmp, this.filePath);
|
|
77135
77165
|
}
|
|
@@ -77137,7 +77167,7 @@ var PublishedChannelStore = class {
|
|
|
77137
77167
|
|
|
77138
77168
|
// src/extension/bundle-cache.ts
|
|
77139
77169
|
var import_promises21 = __toESM(require("fs/promises"), 1);
|
|
77140
|
-
var
|
|
77170
|
+
var import_node_path88 = __toESM(require("path"), 1);
|
|
77141
77171
|
var BundleCache = class {
|
|
77142
77172
|
constructor(rootDir) {
|
|
77143
77173
|
this.rootDir = rootDir;
|
|
@@ -77146,13 +77176,13 @@ var BundleCache = class {
|
|
|
77146
77176
|
/** Atomic write: stage tmp → rename. Caller passes the hex sha256. */
|
|
77147
77177
|
async write(snapshotHash, buffer) {
|
|
77148
77178
|
await import_promises21.default.mkdir(this.rootDir, { recursive: true });
|
|
77149
|
-
const file =
|
|
77179
|
+
const file = import_node_path88.default.join(this.rootDir, `${snapshotHash}.zip`);
|
|
77150
77180
|
const tmp = `${file}.tmp`;
|
|
77151
77181
|
await import_promises21.default.writeFile(tmp, buffer, { mode: 384 });
|
|
77152
77182
|
await import_promises21.default.rename(tmp, file);
|
|
77153
77183
|
}
|
|
77154
77184
|
async read(snapshotHash) {
|
|
77155
|
-
const file =
|
|
77185
|
+
const file = import_node_path88.default.join(this.rootDir, `${snapshotHash}.zip`);
|
|
77156
77186
|
try {
|
|
77157
77187
|
return await import_promises21.default.readFile(file);
|
|
77158
77188
|
} catch (e) {
|
|
@@ -77161,7 +77191,7 @@ var BundleCache = class {
|
|
|
77161
77191
|
}
|
|
77162
77192
|
}
|
|
77163
77193
|
async delete(snapshotHash) {
|
|
77164
|
-
const file =
|
|
77194
|
+
const file = import_node_path88.default.join(this.rootDir, `${snapshotHash}.zip`);
|
|
77165
77195
|
await import_promises21.default.rm(file, { force: true });
|
|
77166
77196
|
}
|
|
77167
77197
|
};
|
|
@@ -77182,26 +77212,26 @@ async function startDaemon(config) {
|
|
|
77182
77212
|
},
|
|
77183
77213
|
source: "daemon",
|
|
77184
77214
|
sampling: logShippingCfg.sampling,
|
|
77185
|
-
homeDir:
|
|
77215
|
+
homeDir: import_node_os33.default.homedir()
|
|
77186
77216
|
});
|
|
77187
|
-
const logDir =
|
|
77188
|
-
|
|
77217
|
+
const logDir = import_node_path89.default.join(config.dataDir, "log");
|
|
77218
|
+
import_node_fs68.default.mkdirSync(logDir, { recursive: true });
|
|
77189
77219
|
const logger = createLogger({
|
|
77190
77220
|
level: config.logLevel,
|
|
77191
|
-
file:
|
|
77221
|
+
file: import_node_path89.default.join(logDir, "clawd.log"),
|
|
77192
77222
|
logClient
|
|
77193
77223
|
});
|
|
77194
77224
|
logger.info("starting clawd", { version, config: { port: config.port, host: config.host, dataDir: config.dataDir } });
|
|
77195
77225
|
const screenIdleProbeLogger = createFileOnlyLogger({
|
|
77196
|
-
file:
|
|
77226
|
+
file: import_node_path89.default.join(logDir, "screen-idle-probe.log"),
|
|
77197
77227
|
level: "debug"
|
|
77198
77228
|
});
|
|
77199
77229
|
logger.info("screen-idle probe logger enabled", {
|
|
77200
|
-
file:
|
|
77230
|
+
file: import_node_path89.default.join(logDir, "screen-idle-probe.log")
|
|
77201
77231
|
});
|
|
77202
77232
|
const CAP_TARGETS = [
|
|
77203
|
-
|
|
77204
|
-
|
|
77233
|
+
import_node_path89.default.join(logDir, "clawd.log"),
|
|
77234
|
+
import_node_path89.default.join(logDir, "screen-idle-probe.log")
|
|
77205
77235
|
];
|
|
77206
77236
|
const LOG_CAP_MAX_BYTES = 10 * 1024 * 1024;
|
|
77207
77237
|
const LOG_CAP_KEEP_BYTES = 5 * 1024 * 1024;
|
|
@@ -77318,14 +77348,14 @@ async function startDaemon(config) {
|
|
|
77318
77348
|
const agents = new AgentsScanner();
|
|
77319
77349
|
const history = new ClaudeHistoryReader();
|
|
77320
77350
|
let transport = null;
|
|
77321
|
-
const personaStore = new PersonaStore(
|
|
77351
|
+
const personaStore = new PersonaStore(import_node_path89.default.join(config.dataDir, "personas"));
|
|
77322
77352
|
const subscriptionChannelStore = new SubscriptionChannelStore({ dataDir: config.dataDir });
|
|
77323
77353
|
const activeSubscriptionChannel = subscriptionChannelStore.getActive();
|
|
77324
77354
|
if (activeSubscriptionChannel) {
|
|
77325
77355
|
applyPiSubscriptionChannel({ channel: activeSubscriptionChannel });
|
|
77326
77356
|
applyClaudeSubscriptionChannel({ channel: activeSubscriptionChannel });
|
|
77327
77357
|
}
|
|
77328
|
-
const usersRoot =
|
|
77358
|
+
const usersRoot = import_node_path89.default.join(config.dataDir, "users");
|
|
77329
77359
|
const defaultsRoot = findDefaultsRoot(logger);
|
|
77330
77360
|
if (defaultsRoot) {
|
|
77331
77361
|
seedDefaultPersonas({ store: personaStore, defaultsRoot, logger });
|
|
@@ -77342,7 +77372,7 @@ async function startDaemon(config) {
|
|
|
77342
77372
|
retirePersonaBuilder({ store: personaStore, logger });
|
|
77343
77373
|
const groupFileStore = new GroupFileStore({ dataDir: config.dataDir, logger });
|
|
77344
77374
|
const dispatchStore = createDispatchStore({
|
|
77345
|
-
filePath:
|
|
77375
|
+
filePath: import_node_path89.default.join(config.dataDir, "dispatch.json"),
|
|
77346
77376
|
now: () => Date.now(),
|
|
77347
77377
|
onFlushError: (err) => logger.error("dispatch store flush failed", {
|
|
77348
77378
|
reason: err instanceof Error ? err.message : String(err)
|
|
@@ -77351,7 +77381,7 @@ async function startDaemon(config) {
|
|
|
77351
77381
|
await dispatchStore.load();
|
|
77352
77382
|
dispatchStore.markInterruptedAsFailed((/* @__PURE__ */ new Date()).toISOString());
|
|
77353
77383
|
const channelStore = createChannelStore({
|
|
77354
|
-
filePath:
|
|
77384
|
+
filePath: import_node_path89.default.join(config.dataDir, "channels.json"),
|
|
77355
77385
|
now: () => Date.now(),
|
|
77356
77386
|
genId: () => `ch-${(0, import_node_crypto30.randomUUID)().slice(0, 8)}`,
|
|
77357
77387
|
onFlushError: (err) => logger.error("channel store flush failed", {
|
|
@@ -77360,7 +77390,7 @@ async function startDaemon(config) {
|
|
|
77360
77390
|
});
|
|
77361
77391
|
await channelStore.load();
|
|
77362
77392
|
const topicStore = createTopicStore({
|
|
77363
|
-
filePath:
|
|
77393
|
+
filePath: import_node_path89.default.join(config.dataDir, "topics.json"),
|
|
77364
77394
|
now: () => Date.now(),
|
|
77365
77395
|
genId: () => `tp-${(0, import_node_crypto30.randomUUID)().slice(0, 8)}`,
|
|
77366
77396
|
onFlushError: (err) => logger.error("topic store flush failed", {
|
|
@@ -77387,12 +77417,12 @@ async function startDaemon(config) {
|
|
|
77387
77417
|
});
|
|
77388
77418
|
}
|
|
77389
77419
|
});
|
|
77390
|
-
const here = typeof __dirname === "string" ? __dirname :
|
|
77420
|
+
const here = typeof __dirname === "string" ? __dirname : import_node_path89.default.dirname((0, import_node_url6.fileURLToPath)(import_meta10.url));
|
|
77391
77421
|
const mcpConfigs = [];
|
|
77392
77422
|
const secretsBundleRoot = findSecretsBundleRoot(logger);
|
|
77393
|
-
const localSecretsDir =
|
|
77423
|
+
const localSecretsDir = import_node_path89.default.join(config.dataDir, LOCAL_SECRETS_DIRNAME);
|
|
77394
77424
|
const readSecrets = () => readSecretTable({ bundleRoot: secretsBundleRoot, overrideDir: localSecretsDir, logger });
|
|
77395
|
-
const githubTokenFile =
|
|
77425
|
+
const githubTokenFile = import_node_path89.default.join(localSecretsDir, GITHUB_TOKEN_FILE);
|
|
77396
77426
|
const githubIdentity = createGithubIdentity({
|
|
77397
77427
|
resolve: () => resolveGithubAuth({ exec: runCommand, fileToken: () => readEnvFileVar(githubTokenFile, GITHUB_TOKEN_VAR) }),
|
|
77398
77428
|
store: (token) => storeGithubAuth({
|
|
@@ -77430,20 +77460,20 @@ async function startDaemon(config) {
|
|
|
77430
77460
|
void githubIdentity.refresh();
|
|
77431
77461
|
return renderPersonaMcpSecrets({
|
|
77432
77462
|
personaId: personaId2,
|
|
77433
|
-
personaDir:
|
|
77463
|
+
personaDir: import_node_path89.default.join(config.dataDir, "personas", personaId2),
|
|
77434
77464
|
secrets,
|
|
77435
|
-
outDir:
|
|
77465
|
+
outDir: import_node_path89.default.join(config.dataDir, "persona-mcp"),
|
|
77436
77466
|
logger
|
|
77437
77467
|
});
|
|
77438
77468
|
};
|
|
77439
77469
|
const mcpDaemonUrl = `http://127.0.0.1:${config.port}`;
|
|
77440
77470
|
const dispatchServerCandidates = [
|
|
77441
|
-
|
|
77442
|
-
|
|
77471
|
+
import_node_path89.default.join(here, "dispatch", "mcp-server.cjs"),
|
|
77472
|
+
import_node_path89.default.join(here, "..", "dist", "dispatch", "mcp-server.cjs")
|
|
77443
77473
|
];
|
|
77444
|
-
const dispatchServerScriptPath = dispatchServerCandidates.find((p3) =>
|
|
77474
|
+
const dispatchServerScriptPath = dispatchServerCandidates.find((p3) => import_node_fs68.default.existsSync(p3));
|
|
77445
77475
|
if (dispatchServerScriptPath) {
|
|
77446
|
-
const dispatchLogPath =
|
|
77476
|
+
const dispatchLogPath = import_node_path89.default.join(logDir, "dispatch-mcp-server.log");
|
|
77447
77477
|
const dispatchCfgPath = writeDispatchMcpConfig({
|
|
77448
77478
|
dataDir: config.dataDir,
|
|
77449
77479
|
serverScriptPath: dispatchServerScriptPath,
|
|
@@ -77463,12 +77493,12 @@ async function startDaemon(config) {
|
|
|
77463
77493
|
});
|
|
77464
77494
|
}
|
|
77465
77495
|
const ticketServerCandidates = [
|
|
77466
|
-
|
|
77467
|
-
|
|
77496
|
+
import_node_path89.default.join(here, "ticket", "mcp-server.cjs"),
|
|
77497
|
+
import_node_path89.default.join(here, "..", "dist", "ticket", "mcp-server.cjs")
|
|
77468
77498
|
];
|
|
77469
|
-
const ticketServerScriptPath = ticketServerCandidates.find((p3) =>
|
|
77499
|
+
const ticketServerScriptPath = ticketServerCandidates.find((p3) => import_node_fs68.default.existsSync(p3));
|
|
77470
77500
|
if (ticketServerScriptPath) {
|
|
77471
|
-
const ticketLogPath =
|
|
77501
|
+
const ticketLogPath = import_node_path89.default.join(logDir, "ticket-mcp-server.log");
|
|
77472
77502
|
const ticketCfgPath = writeTicketMcpConfig({
|
|
77473
77503
|
dataDir: config.dataDir,
|
|
77474
77504
|
serverScriptPath: ticketServerScriptPath,
|
|
@@ -77490,12 +77520,12 @@ async function startDaemon(config) {
|
|
|
77490
77520
|
});
|
|
77491
77521
|
}
|
|
77492
77522
|
const shiftServerCandidates = [
|
|
77493
|
-
|
|
77494
|
-
|
|
77523
|
+
import_node_path89.default.join(here, "shift", "mcp-server.cjs"),
|
|
77524
|
+
import_node_path89.default.join(here, "..", "dist", "shift", "mcp-server.cjs")
|
|
77495
77525
|
];
|
|
77496
|
-
const shiftServerScriptPath = shiftServerCandidates.find((p3) =>
|
|
77526
|
+
const shiftServerScriptPath = shiftServerCandidates.find((p3) => import_node_fs68.default.existsSync(p3));
|
|
77497
77527
|
if (shiftServerScriptPath) {
|
|
77498
|
-
const shiftLogPath =
|
|
77528
|
+
const shiftLogPath = import_node_path89.default.join(logDir, "shift-mcp-server.log");
|
|
77499
77529
|
const shiftCfgPath = await writeShiftMcpConfig({
|
|
77500
77530
|
dataDir: config.dataDir,
|
|
77501
77531
|
serverScriptPath: shiftServerScriptPath,
|
|
@@ -77516,12 +77546,12 @@ async function startDaemon(config) {
|
|
|
77516
77546
|
);
|
|
77517
77547
|
}
|
|
77518
77548
|
const inboxServerCandidates = [
|
|
77519
|
-
|
|
77520
|
-
|
|
77549
|
+
import_node_path89.default.join(here, "inbox", "mcp-server.cjs"),
|
|
77550
|
+
import_node_path89.default.join(here, "..", "dist", "inbox", "mcp-server.cjs")
|
|
77521
77551
|
];
|
|
77522
|
-
const inboxServerScriptPath = inboxServerCandidates.find((p3) =>
|
|
77552
|
+
const inboxServerScriptPath = inboxServerCandidates.find((p3) => import_node_fs68.default.existsSync(p3));
|
|
77523
77553
|
if (inboxServerScriptPath) {
|
|
77524
|
-
const inboxLogPath =
|
|
77554
|
+
const inboxLogPath = import_node_path89.default.join(logDir, "inbox-mcp-server.log");
|
|
77525
77555
|
const inboxCfgPath = await writeInboxMcpConfig({
|
|
77526
77556
|
dataDir: config.dataDir,
|
|
77527
77557
|
serverScriptPath: inboxServerScriptPath,
|
|
@@ -77542,10 +77572,10 @@ async function startDaemon(config) {
|
|
|
77542
77572
|
);
|
|
77543
77573
|
}
|
|
77544
77574
|
const peerOpsServerCandidates = [
|
|
77545
|
-
|
|
77546
|
-
|
|
77575
|
+
import_node_path89.default.join(here, "peer-ops", "mcp-server.cjs"),
|
|
77576
|
+
import_node_path89.default.join(here, "..", "dist", "peer-ops", "mcp-server.cjs")
|
|
77547
77577
|
];
|
|
77548
|
-
const peerOpsServerScriptPath = peerOpsServerCandidates.find((p3) =>
|
|
77578
|
+
const peerOpsServerScriptPath = peerOpsServerCandidates.find((p3) => import_node_fs68.default.existsSync(p3));
|
|
77549
77579
|
if (peerOpsServerScriptPath) {
|
|
77550
77580
|
const peerOpsCfgPath = writePeerOpsMcpConfig({
|
|
77551
77581
|
dataDir: config.dataDir,
|
|
@@ -77565,12 +77595,12 @@ async function startDaemon(config) {
|
|
|
77565
77595
|
);
|
|
77566
77596
|
}
|
|
77567
77597
|
const rpcToolServerCandidates = [
|
|
77568
|
-
|
|
77569
|
-
|
|
77598
|
+
import_node_path89.default.join(here, "rpc-tool", "mcp-server.cjs"),
|
|
77599
|
+
import_node_path89.default.join(here, "..", "dist", "rpc-tool", "mcp-server.cjs")
|
|
77570
77600
|
];
|
|
77571
|
-
const rpcToolServerScriptPath = rpcToolServerCandidates.find((p3) =>
|
|
77601
|
+
const rpcToolServerScriptPath = rpcToolServerCandidates.find((p3) => import_node_fs68.default.existsSync(p3));
|
|
77572
77602
|
if (rpcToolServerScriptPath) {
|
|
77573
|
-
const rpcToolLogPath =
|
|
77603
|
+
const rpcToolLogPath = import_node_path89.default.join(logDir, "rpc-tool-mcp-server.log");
|
|
77574
77604
|
const rpcToolCfgPath = writeRpcToolMcpConfig({
|
|
77575
77605
|
dataDir: config.dataDir,
|
|
77576
77606
|
serverScriptPath: rpcToolServerScriptPath,
|
|
@@ -77591,7 +77621,7 @@ async function startDaemon(config) {
|
|
|
77591
77621
|
);
|
|
77592
77622
|
}
|
|
77593
77623
|
const shiftStore = createShiftStore({
|
|
77594
|
-
filePath:
|
|
77624
|
+
filePath: import_node_path89.default.join(config.dataDir, "shift.json"),
|
|
77595
77625
|
ownerIdProvider: () => ownerPrincipalId,
|
|
77596
77626
|
now: () => Date.now()
|
|
77597
77627
|
});
|
|
@@ -77608,7 +77638,7 @@ async function startDaemon(config) {
|
|
|
77608
77638
|
getAdapter,
|
|
77609
77639
|
historyReader: history,
|
|
77610
77640
|
dataDir: config.dataDir,
|
|
77611
|
-
personaRoot:
|
|
77641
|
+
personaRoot: import_node_path89.default.join(config.dataDir, "personas"),
|
|
77612
77642
|
// Registry defaults are read only after startup, when the later registry binding is initialized.
|
|
77613
77643
|
getPersonaDefaults: (personaId2) => personaRegistry.get(personaId2),
|
|
77614
77644
|
usersRoot,
|
|
@@ -77649,10 +77679,10 @@ async function startDaemon(config) {
|
|
|
77649
77679
|
// File edits update the group manifest without making optional stat/manifest failures fail the engine turn.
|
|
77650
77680
|
attachmentGroup: {
|
|
77651
77681
|
onFileEdit: (input) => {
|
|
77652
|
-
const absPath =
|
|
77682
|
+
const absPath = import_node_path89.default.isAbsolute(input.relPath) ? input.relPath : import_node_path89.default.join(input.cwd, input.relPath);
|
|
77653
77683
|
let size = 0;
|
|
77654
77684
|
try {
|
|
77655
|
-
size =
|
|
77685
|
+
size = import_node_fs68.default.statSync(absPath).size;
|
|
77656
77686
|
} catch (err) {
|
|
77657
77687
|
logger.warn("attachment.onFileEdit stat failed", {
|
|
77658
77688
|
sessionId: input.sessionId,
|
|
@@ -77693,9 +77723,9 @@ async function startDaemon(config) {
|
|
|
77693
77723
|
logger.info("projects.seed-dropped", { dropped: droppedSeed.dropped, backup: droppedSeed.backup });
|
|
77694
77724
|
}
|
|
77695
77725
|
const projectsStore = new ProjectsStore({
|
|
77696
|
-
file:
|
|
77726
|
+
file: import_node_path89.default.join(config.dataDir, "projects.json"),
|
|
77697
77727
|
clawdDir: config.dataDir,
|
|
77698
|
-
codexStateFile:
|
|
77728
|
+
codexStateFile: import_node_path89.default.join(import_node_os33.default.homedir(), ".codex", ".codex-global-state.json"),
|
|
77699
77729
|
logger
|
|
77700
77730
|
});
|
|
77701
77731
|
const observer = new SessionObserver({
|
|
@@ -77765,13 +77795,13 @@ async function startDaemon(config) {
|
|
|
77765
77795
|
runner?.confirmCloudCancelled();
|
|
77766
77796
|
});
|
|
77767
77797
|
registerAdapter("claude", claudeAdapter);
|
|
77768
|
-
const codexIsolatedHome =
|
|
77798
|
+
const codexIsolatedHome = import_node_path89.default.join(config.dataDir, "codex-home");
|
|
77769
77799
|
try {
|
|
77770
|
-
|
|
77800
|
+
import_node_fs68.default.mkdirSync(codexIsolatedHome, { recursive: true });
|
|
77771
77801
|
for (const f2 of ["auth.json", "config.toml"]) {
|
|
77772
|
-
const link =
|
|
77773
|
-
const target =
|
|
77774
|
-
if (!
|
|
77802
|
+
const link = import_node_path89.default.join(codexIsolatedHome, f2);
|
|
77803
|
+
const target = import_node_path89.default.join(import_node_os33.default.homedir(), ".codex", f2);
|
|
77804
|
+
if (!import_node_fs68.default.existsSync(link) && import_node_fs68.default.existsSync(target)) import_node_fs68.default.symlinkSync(target, link);
|
|
77775
77805
|
}
|
|
77776
77806
|
} catch (err) {
|
|
77777
77807
|
logger.warn("codex isolated home setup failed", { err: String(err) });
|
|
@@ -77782,16 +77812,16 @@ async function startDaemon(config) {
|
|
|
77782
77812
|
logger,
|
|
77783
77813
|
historyReader: new CodexHistoryReader({
|
|
77784
77814
|
roots: codexRolloutRoots(config.dataDir),
|
|
77785
|
-
sharedHome:
|
|
77815
|
+
sharedHome: import_node_path89.default.join(import_node_os33.default.homedir(), ".codex"),
|
|
77786
77816
|
logger
|
|
77787
77817
|
}),
|
|
77788
77818
|
codexHomeFor: (cwd) => resolveCodexHome({
|
|
77789
77819
|
cwd,
|
|
77790
|
-
personaRoot:
|
|
77820
|
+
personaRoot: import_node_path89.default.join(config.dataDir, "personas"),
|
|
77791
77821
|
// 必须用 listMerged(Codex registry ∪ 叠加层):只用本地 list() 的话,用户在
|
|
77792
77822
|
// Codex 里建的 project 不在表里,在它下面开的会话会被误判成隔离 → Codex 侧看不到
|
|
77793
77823
|
projectPaths: projectsStore.listMerged().map((x2) => x2.path),
|
|
77794
|
-
sharedHome:
|
|
77824
|
+
sharedHome: import_node_path89.default.join(import_node_os33.default.homedir(), ".codex"),
|
|
77795
77825
|
isolatedHome: codexIsolatedHome
|
|
77796
77826
|
}),
|
|
77797
77827
|
codexHomeForThread: (threadId) => locateCodexThread(codexRolloutRoots(config.dataDir), threadId)?.home,
|
|
@@ -77822,10 +77852,10 @@ async function startDaemon(config) {
|
|
|
77822
77852
|
registerAdapter(PI_CLOUD_TOOL_ID, new CloudPiAdapter({ client: cloudGateway, clientForEnvironment: gatewayForEnvironment, history: cloudHistorySource, logger }));
|
|
77823
77853
|
registerAdapter(CLAUDE_CLOUD_TOOL_ID, new CloudClaudeAdapter({ client: cloudGateway, clientForEnvironment: gatewayForEnvironment, history: cloudHistorySource, logger }));
|
|
77824
77854
|
const piMcpBridgeCandidates = [
|
|
77825
|
-
|
|
77826
|
-
|
|
77855
|
+
import_node_path89.default.join(here, "pi-mcp-bridge", "extension.cjs"),
|
|
77856
|
+
import_node_path89.default.join(here, "..", "dist", "pi-mcp-bridge", "extension.cjs")
|
|
77827
77857
|
];
|
|
77828
|
-
const piMcpBridgePath = piMcpBridgeCandidates.find((p3) =>
|
|
77858
|
+
const piMcpBridgePath = piMcpBridgeCandidates.find((p3) => import_node_fs68.default.existsSync(p3));
|
|
77829
77859
|
if (piMcpBridgePath) {
|
|
77830
77860
|
logger.info("pi-mcp-bridge extension resolved", { path: piMcpBridgePath });
|
|
77831
77861
|
} else {
|
|
@@ -78140,10 +78170,10 @@ async function startDaemon(config) {
|
|
|
78140
78170
|
getSignSecret: () => authFile.token,
|
|
78141
78171
|
getSessionScope: (sid) => manager.findOwnedSessionScope(sid),
|
|
78142
78172
|
// Guest attachment paths are guarded against persona and caller work roots.
|
|
78143
|
-
personaRoot:
|
|
78173
|
+
personaRoot: import_node_path89.default.join(config.dataDir, "personas"),
|
|
78144
78174
|
usersRoot
|
|
78145
78175
|
},
|
|
78146
|
-
personaRoot:
|
|
78176
|
+
personaRoot: import_node_path89.default.join(config.dataDir, "personas"),
|
|
78147
78177
|
usersRoot,
|
|
78148
78178
|
getOwnerIdentity,
|
|
78149
78179
|
ownerPrincipalId,
|
|
@@ -78266,7 +78296,7 @@ async function startDaemon(config) {
|
|
|
78266
78296
|
sourceSessionId: args.sourceSessionId
|
|
78267
78297
|
});
|
|
78268
78298
|
const sourceFile = manager.findOwnedSession(args.sourceSessionId);
|
|
78269
|
-
const sourceJsonlPath = resolveSourceJsonlPath(sourceFile,
|
|
78299
|
+
const sourceJsonlPath = resolveSourceJsonlPath(sourceFile, import_node_os33.default.homedir());
|
|
78270
78300
|
logger.info("dispatch.spawnB.source-resolved", {
|
|
78271
78301
|
dispatchId: args.dispatchId,
|
|
78272
78302
|
sourceJsonlPath,
|
|
@@ -78443,7 +78473,7 @@ async function startDaemon(config) {
|
|
|
78443
78473
|
});
|
|
78444
78474
|
shiftScheduler.start();
|
|
78445
78475
|
logger.info("shift scheduler started", { shiftCount: shiftStore.list().length });
|
|
78446
|
-
const larkBotStore = createLarkBotBindingStore(
|
|
78476
|
+
const larkBotStore = createLarkBotBindingStore(import_node_path89.default.join(config.dataDir, "personas"));
|
|
78447
78477
|
const larkBotCloud = createLarkBotCloudClient({
|
|
78448
78478
|
api: config.clawosApi ?? DEFAULT_CLAWOS_API,
|
|
78449
78479
|
getLoginPass: () => ownerIdentityStore.read()?.loginPass ?? null
|
|
@@ -78454,7 +78484,7 @@ async function startDaemon(config) {
|
|
|
78454
78484
|
cloud: larkBotCloud,
|
|
78455
78485
|
store: larkBotStore,
|
|
78456
78486
|
fetchResource: (appId, messageId, fileKey, maxBytes, type) => larkBotCloud.fetchResource(appId, messageId, fileKey, maxBytes, type),
|
|
78457
|
-
mediaRootFor: (chatId) =>
|
|
78487
|
+
mediaRootFor: (chatId) => import_node_path89.default.join(deriveUserWorkDir(`lark-${chatId}`, usersRoot), "lark-media"),
|
|
78458
78488
|
isShuttingDown: () => larkDraining,
|
|
78459
78489
|
logger: {
|
|
78460
78490
|
warn: (msg) => logger.warn(msg),
|
|
@@ -78753,8 +78783,8 @@ async function startDaemon(config) {
|
|
|
78753
78783
|
const lines = [
|
|
78754
78784
|
`Tunnel: ${r2.url}`,
|
|
78755
78785
|
...resolvedAuthToken ? [`Connect: ${connectUrl}`] : [],
|
|
78756
|
-
`Frpc config: ${
|
|
78757
|
-
`Frpc log: ${
|
|
78786
|
+
`Frpc config: ${import_node_path89.default.join(config.dataDir, "frpc.toml")}`,
|
|
78787
|
+
`Frpc log: ${import_node_path89.default.join(logDir, "frpc.log")}`
|
|
78758
78788
|
];
|
|
78759
78789
|
const width2 = Math.max(...lines.map((l2) => l2.length));
|
|
78760
78790
|
const bar = "\u2550".repeat(width2 + 4);
|
|
@@ -78767,8 +78797,8 @@ ${bar}
|
|
|
78767
78797
|
|
|
78768
78798
|
`);
|
|
78769
78799
|
try {
|
|
78770
|
-
const connectPath =
|
|
78771
|
-
|
|
78800
|
+
const connectPath = import_node_path89.default.join(config.dataDir, "connect.txt");
|
|
78801
|
+
import_node_fs68.default.writeFileSync(connectPath, lines.join("\n") + "\n", { mode: 384 });
|
|
78772
78802
|
} catch {
|
|
78773
78803
|
}
|
|
78774
78804
|
} catch (err) {
|
|
@@ -78866,9 +78896,9 @@ ${bar}
|
|
|
78866
78896
|
};
|
|
78867
78897
|
}
|
|
78868
78898
|
function migrateDropPersonsDir(dataDir) {
|
|
78869
|
-
const dir =
|
|
78899
|
+
const dir = import_node_path89.default.join(dataDir, "persons");
|
|
78870
78900
|
try {
|
|
78871
|
-
|
|
78901
|
+
import_node_fs68.default.rmSync(dir, { recursive: true, force: true });
|
|
78872
78902
|
} catch {
|
|
78873
78903
|
}
|
|
78874
78904
|
}
|