@clawos-dev/clawd 0.2.32 → 0.2.33
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 +530 -220
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -296,8 +296,8 @@ var require_req = __commonJS({
|
|
|
296
296
|
if (req.originalUrl) {
|
|
297
297
|
_req.url = req.originalUrl;
|
|
298
298
|
} else {
|
|
299
|
-
const
|
|
300
|
-
_req.url = typeof
|
|
299
|
+
const path22 = req.path;
|
|
300
|
+
_req.url = typeof path22 === "string" ? path22 : req.url ? req.url.path || req.url : void 0;
|
|
301
301
|
}
|
|
302
302
|
if (req.query) {
|
|
303
303
|
_req.query = req.query;
|
|
@@ -462,14 +462,14 @@ var require_redact = __commonJS({
|
|
|
462
462
|
}
|
|
463
463
|
return obj;
|
|
464
464
|
}
|
|
465
|
-
function parsePath(
|
|
465
|
+
function parsePath(path22) {
|
|
466
466
|
const parts = [];
|
|
467
467
|
let current = "";
|
|
468
468
|
let inBrackets = false;
|
|
469
469
|
let inQuotes = false;
|
|
470
470
|
let quoteChar = "";
|
|
471
|
-
for (let i = 0; i <
|
|
472
|
-
const char =
|
|
471
|
+
for (let i = 0; i < path22.length; i++) {
|
|
472
|
+
const char = path22[i];
|
|
473
473
|
if (!inBrackets && char === ".") {
|
|
474
474
|
if (current) {
|
|
475
475
|
parts.push(current);
|
|
@@ -600,10 +600,10 @@ var require_redact = __commonJS({
|
|
|
600
600
|
return current;
|
|
601
601
|
}
|
|
602
602
|
function redactPaths(obj, paths, censor, remove = false) {
|
|
603
|
-
for (const
|
|
604
|
-
const parts = parsePath(
|
|
603
|
+
for (const path22 of paths) {
|
|
604
|
+
const parts = parsePath(path22);
|
|
605
605
|
if (parts.includes("*")) {
|
|
606
|
-
redactWildcardPath(obj, parts, censor,
|
|
606
|
+
redactWildcardPath(obj, parts, censor, path22, remove);
|
|
607
607
|
} else {
|
|
608
608
|
if (remove) {
|
|
609
609
|
removeKey(obj, parts);
|
|
@@ -688,8 +688,8 @@ var require_redact = __commonJS({
|
|
|
688
688
|
}
|
|
689
689
|
} else {
|
|
690
690
|
if (afterWildcard.includes("*")) {
|
|
691
|
-
const wrappedCensor = typeof censor === "function" ? (value,
|
|
692
|
-
const fullPath = [...pathArray.slice(0, pathLength), ...
|
|
691
|
+
const wrappedCensor = typeof censor === "function" ? (value, path22) => {
|
|
692
|
+
const fullPath = [...pathArray.slice(0, pathLength), ...path22];
|
|
693
693
|
return censor(value, fullPath);
|
|
694
694
|
} : censor;
|
|
695
695
|
redactWildcardPath(current, afterWildcard, wrappedCensor, originalPath, remove);
|
|
@@ -724,8 +724,8 @@ var require_redact = __commonJS({
|
|
|
724
724
|
return null;
|
|
725
725
|
}
|
|
726
726
|
const pathStructure = /* @__PURE__ */ new Map();
|
|
727
|
-
for (const
|
|
728
|
-
const parts = parsePath(
|
|
727
|
+
for (const path22 of pathsToClone) {
|
|
728
|
+
const parts = parsePath(path22);
|
|
729
729
|
let current = pathStructure;
|
|
730
730
|
for (let i = 0; i < parts.length; i++) {
|
|
731
731
|
const part = parts[i];
|
|
@@ -777,24 +777,24 @@ var require_redact = __commonJS({
|
|
|
777
777
|
}
|
|
778
778
|
return cloneSelectively(obj, pathStructure);
|
|
779
779
|
}
|
|
780
|
-
function validatePath(
|
|
781
|
-
if (typeof
|
|
780
|
+
function validatePath(path22) {
|
|
781
|
+
if (typeof path22 !== "string") {
|
|
782
782
|
throw new Error("Paths must be (non-empty) strings");
|
|
783
783
|
}
|
|
784
|
-
if (
|
|
784
|
+
if (path22 === "") {
|
|
785
785
|
throw new Error("Invalid redaction path ()");
|
|
786
786
|
}
|
|
787
|
-
if (
|
|
788
|
-
throw new Error(`Invalid redaction path (${
|
|
787
|
+
if (path22.includes("..")) {
|
|
788
|
+
throw new Error(`Invalid redaction path (${path22})`);
|
|
789
789
|
}
|
|
790
|
-
if (
|
|
791
|
-
throw new Error(`Invalid redaction path (${
|
|
790
|
+
if (path22.includes(",")) {
|
|
791
|
+
throw new Error(`Invalid redaction path (${path22})`);
|
|
792
792
|
}
|
|
793
793
|
let bracketCount = 0;
|
|
794
794
|
let inQuotes = false;
|
|
795
795
|
let quoteChar = "";
|
|
796
|
-
for (let i = 0; i <
|
|
797
|
-
const char =
|
|
796
|
+
for (let i = 0; i < path22.length; i++) {
|
|
797
|
+
const char = path22[i];
|
|
798
798
|
if ((char === '"' || char === "'") && bracketCount > 0) {
|
|
799
799
|
if (!inQuotes) {
|
|
800
800
|
inQuotes = true;
|
|
@@ -808,20 +808,20 @@ var require_redact = __commonJS({
|
|
|
808
808
|
} else if (char === "]" && !inQuotes) {
|
|
809
809
|
bracketCount--;
|
|
810
810
|
if (bracketCount < 0) {
|
|
811
|
-
throw new Error(`Invalid redaction path (${
|
|
811
|
+
throw new Error(`Invalid redaction path (${path22})`);
|
|
812
812
|
}
|
|
813
813
|
}
|
|
814
814
|
}
|
|
815
815
|
if (bracketCount !== 0) {
|
|
816
|
-
throw new Error(`Invalid redaction path (${
|
|
816
|
+
throw new Error(`Invalid redaction path (${path22})`);
|
|
817
817
|
}
|
|
818
818
|
}
|
|
819
819
|
function validatePaths(paths) {
|
|
820
820
|
if (!Array.isArray(paths)) {
|
|
821
821
|
throw new TypeError("paths must be an array");
|
|
822
822
|
}
|
|
823
|
-
for (const
|
|
824
|
-
validatePath(
|
|
823
|
+
for (const path22 of paths) {
|
|
824
|
+
validatePath(path22);
|
|
825
825
|
}
|
|
826
826
|
}
|
|
827
827
|
function slowRedact(options = {}) {
|
|
@@ -989,8 +989,8 @@ var require_redaction = __commonJS({
|
|
|
989
989
|
if (shape[k] === null) {
|
|
990
990
|
o[k] = (value) => topCensor(value, [k]);
|
|
991
991
|
} else {
|
|
992
|
-
const wrappedCensor = typeof censor === "function" ? (value,
|
|
993
|
-
return censor(value, [k, ...
|
|
992
|
+
const wrappedCensor = typeof censor === "function" ? (value, path22) => {
|
|
993
|
+
return censor(value, [k, ...path22]);
|
|
994
994
|
} : censor;
|
|
995
995
|
o[k] = Redact({
|
|
996
996
|
paths: shape[k],
|
|
@@ -1208,10 +1208,10 @@ var require_atomic_sleep = __commonJS({
|
|
|
1208
1208
|
var require_sonic_boom = __commonJS({
|
|
1209
1209
|
"../node_modules/.pnpm/sonic-boom@4.2.1/node_modules/sonic-boom/index.js"(exports2, module2) {
|
|
1210
1210
|
"use strict";
|
|
1211
|
-
var
|
|
1211
|
+
var fs22 = require("fs");
|
|
1212
1212
|
var EventEmitter = require("events");
|
|
1213
1213
|
var inherits = require("util").inherits;
|
|
1214
|
-
var
|
|
1214
|
+
var path22 = require("path");
|
|
1215
1215
|
var sleep = require_atomic_sleep();
|
|
1216
1216
|
var assert = require("assert");
|
|
1217
1217
|
var BUSY_WRITE_TIMEOUT = 100;
|
|
@@ -1265,20 +1265,20 @@ var require_sonic_boom = __commonJS({
|
|
|
1265
1265
|
const mode = sonic.mode;
|
|
1266
1266
|
if (sonic.sync) {
|
|
1267
1267
|
try {
|
|
1268
|
-
if (sonic.mkdir)
|
|
1269
|
-
const fd =
|
|
1268
|
+
if (sonic.mkdir) fs22.mkdirSync(path22.dirname(file), { recursive: true });
|
|
1269
|
+
const fd = fs22.openSync(file, flags, mode);
|
|
1270
1270
|
fileOpened(null, fd);
|
|
1271
1271
|
} catch (err) {
|
|
1272
1272
|
fileOpened(err);
|
|
1273
1273
|
throw err;
|
|
1274
1274
|
}
|
|
1275
1275
|
} else if (sonic.mkdir) {
|
|
1276
|
-
|
|
1276
|
+
fs22.mkdir(path22.dirname(file), { recursive: true }, (err) => {
|
|
1277
1277
|
if (err) return fileOpened(err);
|
|
1278
|
-
|
|
1278
|
+
fs22.open(file, flags, mode, fileOpened);
|
|
1279
1279
|
});
|
|
1280
1280
|
} else {
|
|
1281
|
-
|
|
1281
|
+
fs22.open(file, flags, mode, fileOpened);
|
|
1282
1282
|
}
|
|
1283
1283
|
}
|
|
1284
1284
|
function SonicBoom(opts) {
|
|
@@ -1319,8 +1319,8 @@ var require_sonic_boom = __commonJS({
|
|
|
1319
1319
|
this.flush = flushBuffer;
|
|
1320
1320
|
this.flushSync = flushBufferSync;
|
|
1321
1321
|
this._actualWrite = actualWriteBuffer;
|
|
1322
|
-
fsWriteSync = () =>
|
|
1323
|
-
fsWrite = () =>
|
|
1322
|
+
fsWriteSync = () => fs22.writeSync(this.fd, this._writingBuf);
|
|
1323
|
+
fsWrite = () => fs22.write(this.fd, this._writingBuf, this.release);
|
|
1324
1324
|
} else if (contentMode === void 0 || contentMode === kContentModeUtf8) {
|
|
1325
1325
|
this._writingBuf = "";
|
|
1326
1326
|
this.write = write;
|
|
@@ -1329,15 +1329,15 @@ var require_sonic_boom = __commonJS({
|
|
|
1329
1329
|
this._actualWrite = actualWrite;
|
|
1330
1330
|
fsWriteSync = () => {
|
|
1331
1331
|
if (Buffer.isBuffer(this._writingBuf)) {
|
|
1332
|
-
return
|
|
1332
|
+
return fs22.writeSync(this.fd, this._writingBuf);
|
|
1333
1333
|
}
|
|
1334
|
-
return
|
|
1334
|
+
return fs22.writeSync(this.fd, this._writingBuf, "utf8");
|
|
1335
1335
|
};
|
|
1336
1336
|
fsWrite = () => {
|
|
1337
1337
|
if (Buffer.isBuffer(this._writingBuf)) {
|
|
1338
|
-
return
|
|
1338
|
+
return fs22.write(this.fd, this._writingBuf, this.release);
|
|
1339
1339
|
}
|
|
1340
|
-
return
|
|
1340
|
+
return fs22.write(this.fd, this._writingBuf, "utf8", this.release);
|
|
1341
1341
|
};
|
|
1342
1342
|
} else {
|
|
1343
1343
|
throw new Error(`SonicBoom supports "${kContentModeUtf8}" and "${kContentModeBuffer}", but passed ${contentMode}`);
|
|
@@ -1394,7 +1394,7 @@ var require_sonic_boom = __commonJS({
|
|
|
1394
1394
|
}
|
|
1395
1395
|
}
|
|
1396
1396
|
if (this._fsync) {
|
|
1397
|
-
|
|
1397
|
+
fs22.fsyncSync(this.fd);
|
|
1398
1398
|
}
|
|
1399
1399
|
const len = this._len;
|
|
1400
1400
|
if (this._reopening) {
|
|
@@ -1508,7 +1508,7 @@ var require_sonic_boom = __commonJS({
|
|
|
1508
1508
|
const onDrain = () => {
|
|
1509
1509
|
if (!this._fsync) {
|
|
1510
1510
|
try {
|
|
1511
|
-
|
|
1511
|
+
fs22.fsync(this.fd, (err) => {
|
|
1512
1512
|
this._flushPending = false;
|
|
1513
1513
|
cb(err);
|
|
1514
1514
|
});
|
|
@@ -1610,7 +1610,7 @@ var require_sonic_boom = __commonJS({
|
|
|
1610
1610
|
const fd = this.fd;
|
|
1611
1611
|
this.once("ready", () => {
|
|
1612
1612
|
if (fd !== this.fd) {
|
|
1613
|
-
|
|
1613
|
+
fs22.close(fd, (err) => {
|
|
1614
1614
|
if (err) {
|
|
1615
1615
|
return this.emit("error", err);
|
|
1616
1616
|
}
|
|
@@ -1659,7 +1659,7 @@ var require_sonic_boom = __commonJS({
|
|
|
1659
1659
|
buf = this._bufs[0];
|
|
1660
1660
|
}
|
|
1661
1661
|
try {
|
|
1662
|
-
const n = Buffer.isBuffer(buf) ?
|
|
1662
|
+
const n = Buffer.isBuffer(buf) ? fs22.writeSync(this.fd, buf) : fs22.writeSync(this.fd, buf, "utf8");
|
|
1663
1663
|
const releasedBufObj = releaseWritingBuf(buf, this._len, n);
|
|
1664
1664
|
buf = releasedBufObj.writingBuf;
|
|
1665
1665
|
this._len = releasedBufObj.len;
|
|
@@ -1675,7 +1675,7 @@ var require_sonic_boom = __commonJS({
|
|
|
1675
1675
|
}
|
|
1676
1676
|
}
|
|
1677
1677
|
try {
|
|
1678
|
-
|
|
1678
|
+
fs22.fsyncSync(this.fd);
|
|
1679
1679
|
} catch {
|
|
1680
1680
|
}
|
|
1681
1681
|
}
|
|
@@ -1696,7 +1696,7 @@ var require_sonic_boom = __commonJS({
|
|
|
1696
1696
|
buf = mergeBuf(this._bufs[0], this._lens[0]);
|
|
1697
1697
|
}
|
|
1698
1698
|
try {
|
|
1699
|
-
const n =
|
|
1699
|
+
const n = fs22.writeSync(this.fd, buf);
|
|
1700
1700
|
buf = buf.subarray(n);
|
|
1701
1701
|
this._len = Math.max(this._len - n, 0);
|
|
1702
1702
|
if (buf.length <= 0) {
|
|
@@ -1724,13 +1724,13 @@ var require_sonic_boom = __commonJS({
|
|
|
1724
1724
|
this._writingBuf = this._writingBuf.length ? this._writingBuf : this._bufs.shift() || "";
|
|
1725
1725
|
if (this.sync) {
|
|
1726
1726
|
try {
|
|
1727
|
-
const written = Buffer.isBuffer(this._writingBuf) ?
|
|
1727
|
+
const written = Buffer.isBuffer(this._writingBuf) ? fs22.writeSync(this.fd, this._writingBuf) : fs22.writeSync(this.fd, this._writingBuf, "utf8");
|
|
1728
1728
|
release(null, written);
|
|
1729
1729
|
} catch (err) {
|
|
1730
1730
|
release(err);
|
|
1731
1731
|
}
|
|
1732
1732
|
} else {
|
|
1733
|
-
|
|
1733
|
+
fs22.write(this.fd, this._writingBuf, release);
|
|
1734
1734
|
}
|
|
1735
1735
|
}
|
|
1736
1736
|
function actualWriteBuffer() {
|
|
@@ -1739,7 +1739,7 @@ var require_sonic_boom = __commonJS({
|
|
|
1739
1739
|
this._writingBuf = this._writingBuf.length ? this._writingBuf : mergeBuf(this._bufs.shift(), this._lens.shift());
|
|
1740
1740
|
if (this.sync) {
|
|
1741
1741
|
try {
|
|
1742
|
-
const written =
|
|
1742
|
+
const written = fs22.writeSync(this.fd, this._writingBuf);
|
|
1743
1743
|
release(null, written);
|
|
1744
1744
|
} catch (err) {
|
|
1745
1745
|
release(err);
|
|
@@ -1748,7 +1748,7 @@ var require_sonic_boom = __commonJS({
|
|
|
1748
1748
|
if (kCopyBuffer) {
|
|
1749
1749
|
this._writingBuf = Buffer.from(this._writingBuf);
|
|
1750
1750
|
}
|
|
1751
|
-
|
|
1751
|
+
fs22.write(this.fd, this._writingBuf, release);
|
|
1752
1752
|
}
|
|
1753
1753
|
}
|
|
1754
1754
|
function actualClose(sonic) {
|
|
@@ -1764,12 +1764,12 @@ var require_sonic_boom = __commonJS({
|
|
|
1764
1764
|
sonic._lens = [];
|
|
1765
1765
|
assert(typeof sonic.fd === "number", `sonic.fd must be a number, got ${typeof sonic.fd}`);
|
|
1766
1766
|
try {
|
|
1767
|
-
|
|
1767
|
+
fs22.fsync(sonic.fd, closeWrapped);
|
|
1768
1768
|
} catch {
|
|
1769
1769
|
}
|
|
1770
1770
|
function closeWrapped() {
|
|
1771
1771
|
if (sonic.fd !== 1 && sonic.fd !== 2) {
|
|
1772
|
-
|
|
1772
|
+
fs22.close(sonic.fd, done);
|
|
1773
1773
|
} else {
|
|
1774
1774
|
done();
|
|
1775
1775
|
}
|
|
@@ -4133,7 +4133,7 @@ var require_multistream = __commonJS({
|
|
|
4133
4133
|
var require_pino = __commonJS({
|
|
4134
4134
|
"../node_modules/.pnpm/pino@9.14.0/node_modules/pino/pino.js"(exports2, module2) {
|
|
4135
4135
|
"use strict";
|
|
4136
|
-
var
|
|
4136
|
+
var os14 = require("os");
|
|
4137
4137
|
var stdSerializers = require_pino_std_serializers();
|
|
4138
4138
|
var caller = require_caller();
|
|
4139
4139
|
var redaction = require_redaction();
|
|
@@ -4180,7 +4180,7 @@ var require_pino = __commonJS({
|
|
|
4180
4180
|
} = symbols;
|
|
4181
4181
|
var { epochTime, nullTime } = time;
|
|
4182
4182
|
var { pid } = process;
|
|
4183
|
-
var hostname =
|
|
4183
|
+
var hostname = os14.hostname();
|
|
4184
4184
|
var defaultErrorSerializer = stdSerializers.err;
|
|
4185
4185
|
var defaultOptions = {
|
|
4186
4186
|
level: "info",
|
|
@@ -4384,6 +4384,7 @@ var init_methods = __esm({
|
|
|
4384
4384
|
"workspace:list",
|
|
4385
4385
|
"workspace:read",
|
|
4386
4386
|
"skills:list",
|
|
4387
|
+
"agents:list",
|
|
4387
4388
|
"git:root",
|
|
4388
4389
|
"git:branch",
|
|
4389
4390
|
"git:branches",
|
|
@@ -4408,7 +4409,7 @@ var init_methods = __esm({
|
|
|
4408
4409
|
});
|
|
4409
4410
|
|
|
4410
4411
|
// ../protocol/src/events.ts
|
|
4411
|
-
var SESSION_STATUS_VALUES, HISTORY_USER_META_VALUES, ASK_USER_QUESTION_TOOL_NAME;
|
|
4412
|
+
var SESSION_STATUS_VALUES, HISTORY_USER_META_VALUES, SKILL_SOURCE_VALUES, AGENT_SOURCE_VALUES, ASK_USER_QUESTION_TOOL_NAME;
|
|
4412
4413
|
var init_events = __esm({
|
|
4413
4414
|
"../protocol/src/events.ts"() {
|
|
4414
4415
|
"use strict";
|
|
@@ -4429,6 +4430,14 @@ var init_events = __esm({
|
|
|
4429
4430
|
"attachment-skills",
|
|
4430
4431
|
"attachment-deferred-tools"
|
|
4431
4432
|
];
|
|
4433
|
+
SKILL_SOURCE_VALUES = ["builtin", "global", "project", "plugin"];
|
|
4434
|
+
AGENT_SOURCE_VALUES = [
|
|
4435
|
+
"builtin",
|
|
4436
|
+
"global",
|
|
4437
|
+
"project",
|
|
4438
|
+
"policy",
|
|
4439
|
+
"plugin"
|
|
4440
|
+
];
|
|
4432
4441
|
ASK_USER_QUESTION_TOOL_NAME = "AskUserQuestion";
|
|
4433
4442
|
}
|
|
4434
4443
|
});
|
|
@@ -4883,8 +4892,8 @@ var init_parseUtil = __esm({
|
|
|
4883
4892
|
init_errors2();
|
|
4884
4893
|
init_en();
|
|
4885
4894
|
makeIssue = (params) => {
|
|
4886
|
-
const { data, path:
|
|
4887
|
-
const fullPath = [...
|
|
4895
|
+
const { data, path: path22, errorMaps, issueData } = params;
|
|
4896
|
+
const fullPath = [...path22, ...issueData.path || []];
|
|
4888
4897
|
const fullIssue = {
|
|
4889
4898
|
...issueData,
|
|
4890
4899
|
path: fullPath
|
|
@@ -5195,11 +5204,11 @@ var init_types = __esm({
|
|
|
5195
5204
|
init_parseUtil();
|
|
5196
5205
|
init_util();
|
|
5197
5206
|
ParseInputLazyPath = class {
|
|
5198
|
-
constructor(parent, value,
|
|
5207
|
+
constructor(parent, value, path22, key) {
|
|
5199
5208
|
this._cachedPath = [];
|
|
5200
5209
|
this.parent = parent;
|
|
5201
5210
|
this.data = value;
|
|
5202
|
-
this._path =
|
|
5211
|
+
this._path = path22;
|
|
5203
5212
|
this._key = key;
|
|
5204
5213
|
}
|
|
5205
5214
|
get path() {
|
|
@@ -8637,7 +8646,7 @@ var init_persona_schemas = __esm({
|
|
|
8637
8646
|
});
|
|
8638
8647
|
|
|
8639
8648
|
// ../protocol/src/schemas.ts
|
|
8640
|
-
var SessionStatusSchema, UsageSchema, ContextUsageSchema, sessionMetaShape, SessionMetaSchema, ModelInfoSchema, ModeInfoSchema, ConfigFieldSchemaSchema, CapabilitiesGetArgs, CapabilitiesResponseSchema, AllowRuleSchema, SessionFileSchema, ParsedEventBase, HistoryUserMetaSchema, SubagentToolStatsSchema, StructuredPatchHunkSchema, ToolResultExtraSchema, MemoryEntrySchema, AskQuestionOptionSchema, AskQuestionItemSchema, ParsedEventSchema, SessionCreateArgs, SessionIdArgs, SessionUpdateArgs, SessionSendArgs, SessionRewindArgs, SessionRewindResponseSchema, SessionRewindDiffArgs, RewindDiffHunkSchema, RewindDiffFileSchema, SessionRewindDiffResponseSchema, SessionRewindableMessageIdsArgs, SessionRewindableMessageIdsResponseSchema, SessionResumeArgs, SessionForkArgs, SessionForkResponseSchema, SessionObserveArgs, SessionEventsArgs, PermissionRespondArgs, HistoryListArgs, HistoryReadArgs, HistorySubagentsArgs, HistorySubagentReadArgs, WorkspaceListArgs, WorkspaceReadArgs, SkillsListArgs, SessionSubscribeArgs, SessionPinArgs, SessionReorderPinsArgs, GitRootArgs, GitRootResponseSchema, GitBranchArgs, GitBranchResponseSchema, GitBranchesArgs, GitBranchesResponseSchema, GitWorktreePrefixArgs, GitWorktreePrefixResponseSchema, GitWorktreeCreateArgs, GitWorktreeCreateResponseSchema, GitWorktreeRemoveArgs, GitWorktreeRemoveResponseSchema, HistoryRecentDirsArgs, RecentDirEntrySchema, HistoryRecentDirsResponseSchema, SessionQuestionFrameSchema, SessionQuestionClearedFrameSchema, AnswerQuestionArgs, AnswerQuestionResponseSchema, AuthRequestFrameSchema, AuthOkFrameSchema, TunnelExitedEventSchema, InfoRunningSessionSchema, InfoResponseSchema;
|
|
8649
|
+
var SessionStatusSchema, UsageSchema, ContextUsageSchema, sessionMetaShape, SessionMetaSchema, ModelInfoSchema, ModeInfoSchema, ConfigFieldSchemaSchema, CapabilitiesGetArgs, CapabilitiesResponseSchema, AllowRuleSchema, SessionFileSchema, ParsedEventBase, HistoryUserMetaSchema, SubagentToolStatsSchema, StructuredPatchHunkSchema, ToolResultExtraSchema, MemoryEntrySchema, AskQuestionOptionSchema, AskQuestionItemSchema, ParsedEventSchema, SessionCreateArgs, SessionIdArgs, SessionUpdateArgs, SessionSendArgs, SessionRewindArgs, SessionRewindResponseSchema, SessionRewindDiffArgs, RewindDiffHunkSchema, RewindDiffFileSchema, SessionRewindDiffResponseSchema, SessionRewindableMessageIdsArgs, SessionRewindableMessageIdsResponseSchema, SessionResumeArgs, SessionForkArgs, SessionForkResponseSchema, SessionObserveArgs, SessionEventsArgs, PermissionRespondArgs, HistoryListArgs, HistoryReadArgs, HistorySubagentsArgs, HistorySubagentReadArgs, WorkspaceListArgs, WorkspaceReadArgs, SkillsListArgs, SkillEntrySchema, AgentEntrySchema, AgentsListArgs, AgentsListResponseSchema, SessionSubscribeArgs, SessionPinArgs, SessionReorderPinsArgs, GitRootArgs, GitRootResponseSchema, GitBranchArgs, GitBranchResponseSchema, GitBranchesArgs, GitBranchesResponseSchema, GitWorktreePrefixArgs, GitWorktreePrefixResponseSchema, GitWorktreeCreateArgs, GitWorktreeCreateResponseSchema, GitWorktreeRemoveArgs, GitWorktreeRemoveResponseSchema, HistoryRecentDirsArgs, RecentDirEntrySchema, HistoryRecentDirsResponseSchema, SessionQuestionFrameSchema, SessionQuestionClearedFrameSchema, AnswerQuestionArgs, AnswerQuestionResponseSchema, AuthRequestFrameSchema, AuthOkFrameSchema, TunnelExitedEventSchema, InfoRunningSessionSchema, InfoResponseSchema;
|
|
8641
8650
|
var init_schemas = __esm({
|
|
8642
8651
|
"../protocol/src/schemas.ts"() {
|
|
8643
8652
|
"use strict";
|
|
@@ -9060,6 +9069,25 @@ var init_schemas = __esm({
|
|
|
9060
9069
|
path: external_exports.string().min(1)
|
|
9061
9070
|
});
|
|
9062
9071
|
SkillsListArgs = external_exports.object({ cwd: external_exports.string().min(1) });
|
|
9072
|
+
SkillEntrySchema = external_exports.object({
|
|
9073
|
+
name: external_exports.string().min(1),
|
|
9074
|
+
source: external_exports.enum(SKILL_SOURCE_VALUES),
|
|
9075
|
+
path: external_exports.string().optional(),
|
|
9076
|
+
description: external_exports.string().optional(),
|
|
9077
|
+
plugin: external_exports.string().optional()
|
|
9078
|
+
});
|
|
9079
|
+
AgentEntrySchema = external_exports.object({
|
|
9080
|
+
name: external_exports.string().min(1),
|
|
9081
|
+
source: external_exports.enum(AGENT_SOURCE_VALUES),
|
|
9082
|
+
path: external_exports.string().optional(),
|
|
9083
|
+
description: external_exports.string().optional(),
|
|
9084
|
+
whenToUse: external_exports.string().optional(),
|
|
9085
|
+
plugin: external_exports.string().optional()
|
|
9086
|
+
});
|
|
9087
|
+
AgentsListArgs = external_exports.object({ cwd: external_exports.string().min(1) });
|
|
9088
|
+
AgentsListResponseSchema = external_exports.object({
|
|
9089
|
+
agents: external_exports.array(AgentEntrySchema)
|
|
9090
|
+
});
|
|
9063
9091
|
SessionSubscribeArgs = external_exports.object({ sessionId: external_exports.string().min(1) });
|
|
9064
9092
|
SessionPinArgs = external_exports.object({
|
|
9065
9093
|
sessionId: external_exports.string().min(1),
|
|
@@ -9760,11 +9788,11 @@ var init_lib = __esm({
|
|
|
9760
9788
|
}
|
|
9761
9789
|
}
|
|
9762
9790
|
},
|
|
9763
|
-
addToPath: function addToPath(
|
|
9764
|
-
var last =
|
|
9791
|
+
addToPath: function addToPath(path22, added, removed, oldPosInc, options) {
|
|
9792
|
+
var last = path22.lastComponent;
|
|
9765
9793
|
if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) {
|
|
9766
9794
|
return {
|
|
9767
|
-
oldPos:
|
|
9795
|
+
oldPos: path22.oldPos + oldPosInc,
|
|
9768
9796
|
lastComponent: {
|
|
9769
9797
|
count: last.count + 1,
|
|
9770
9798
|
added,
|
|
@@ -9774,7 +9802,7 @@ var init_lib = __esm({
|
|
|
9774
9802
|
};
|
|
9775
9803
|
} else {
|
|
9776
9804
|
return {
|
|
9777
|
-
oldPos:
|
|
9805
|
+
oldPos: path22.oldPos + oldPosInc,
|
|
9778
9806
|
lastComponent: {
|
|
9779
9807
|
count: 1,
|
|
9780
9808
|
added,
|
|
@@ -10205,10 +10233,10 @@ function attachmentToHistoryMessage(o, ts) {
|
|
|
10205
10233
|
const memories = raw.map((m) => {
|
|
10206
10234
|
if (!m || typeof m !== "object") return null;
|
|
10207
10235
|
const rec = m;
|
|
10208
|
-
const
|
|
10236
|
+
const path22 = typeof rec.path === "string" ? rec.path : null;
|
|
10209
10237
|
const content = typeof rec.content === "string" ? rec.content : null;
|
|
10210
|
-
if (!
|
|
10211
|
-
const entry = { path:
|
|
10238
|
+
if (!path22 || content == null) return null;
|
|
10239
|
+
const entry = { path: path22, content };
|
|
10212
10240
|
if (typeof rec.mtimeMs === "number") entry.mtimeMs = rec.mtimeMs;
|
|
10213
10241
|
return entry;
|
|
10214
10242
|
}).filter((m) => m !== null);
|
|
@@ -10999,10 +11027,10 @@ function parseAttachment(obj) {
|
|
|
10999
11027
|
const memories = raw.map((m) => {
|
|
11000
11028
|
if (!m || typeof m !== "object") return null;
|
|
11001
11029
|
const rec = m;
|
|
11002
|
-
const
|
|
11030
|
+
const path22 = typeof rec.path === "string" ? rec.path : null;
|
|
11003
11031
|
const content = typeof rec.content === "string" ? rec.content : null;
|
|
11004
|
-
if (!
|
|
11005
|
-
const out = { path:
|
|
11032
|
+
if (!path22 || content == null) return null;
|
|
11033
|
+
const out = { path: path22, content };
|
|
11006
11034
|
if (typeof rec.mtimeMs === "number") out.mtimeMs = rec.mtimeMs;
|
|
11007
11035
|
return out;
|
|
11008
11036
|
}).filter((m) => m !== null);
|
|
@@ -14869,7 +14897,7 @@ var require_websocket_server = __commonJS({
|
|
|
14869
14897
|
// src/run-case/recorder.ts
|
|
14870
14898
|
function startRunCaseRecorder(opts) {
|
|
14871
14899
|
const now = opts.now ?? Date.now;
|
|
14872
|
-
const dir =
|
|
14900
|
+
const dir = import_node_path19.default.dirname(opts.recordPath);
|
|
14873
14901
|
let stream = null;
|
|
14874
14902
|
let closing = false;
|
|
14875
14903
|
let closedSettled = false;
|
|
@@ -14883,8 +14911,8 @@ function startRunCaseRecorder(opts) {
|
|
|
14883
14911
|
});
|
|
14884
14912
|
const ensureStream = () => {
|
|
14885
14913
|
if (stream) return stream;
|
|
14886
|
-
|
|
14887
|
-
stream =
|
|
14914
|
+
import_node_fs20.default.mkdirSync(dir, { recursive: true });
|
|
14915
|
+
stream = import_node_fs20.default.createWriteStream(opts.recordPath, { flags: "a" });
|
|
14888
14916
|
stream.on("close", () => closedResolve());
|
|
14889
14917
|
return stream;
|
|
14890
14918
|
};
|
|
@@ -14909,12 +14937,12 @@ function startRunCaseRecorder(opts) {
|
|
|
14909
14937
|
};
|
|
14910
14938
|
return { tap, close, closed };
|
|
14911
14939
|
}
|
|
14912
|
-
var
|
|
14940
|
+
var import_node_fs20, import_node_path19;
|
|
14913
14941
|
var init_recorder = __esm({
|
|
14914
14942
|
"src/run-case/recorder.ts"() {
|
|
14915
14943
|
"use strict";
|
|
14916
|
-
|
|
14917
|
-
|
|
14944
|
+
import_node_fs20 = __toESM(require("fs"), 1);
|
|
14945
|
+
import_node_path19 = __toESM(require("path"), 1);
|
|
14918
14946
|
}
|
|
14919
14947
|
});
|
|
14920
14948
|
|
|
@@ -14957,7 +14985,7 @@ var init_wire = __esm({
|
|
|
14957
14985
|
// src/run-case/controller.ts
|
|
14958
14986
|
async function runController(opts) {
|
|
14959
14987
|
const now = opts.now ?? Date.now;
|
|
14960
|
-
const cwd = opts.cwd ?? (0,
|
|
14988
|
+
const cwd = opts.cwd ?? (0, import_node_fs21.mkdtempSync)(import_node_path20.default.join(import_node_os13.default.tmpdir(), "clawd-runcase-"));
|
|
14961
14989
|
const ownsCwd = opts.cwd === void 0;
|
|
14962
14990
|
const recorder = startRunCaseRecorder({ recordPath: opts.record, now });
|
|
14963
14991
|
const spawnCtx = { cwd };
|
|
@@ -15118,19 +15146,19 @@ async function runController(opts) {
|
|
|
15118
15146
|
if (sigintHandler) process.off("SIGINT", sigintHandler);
|
|
15119
15147
|
if (ownsCwd) {
|
|
15120
15148
|
try {
|
|
15121
|
-
(0,
|
|
15149
|
+
(0, import_node_fs21.rmSync)(cwd, { recursive: true, force: true });
|
|
15122
15150
|
} catch {
|
|
15123
15151
|
}
|
|
15124
15152
|
}
|
|
15125
15153
|
return exitCode ?? 0;
|
|
15126
15154
|
}
|
|
15127
|
-
var
|
|
15155
|
+
var import_node_fs21, import_node_os13, import_node_path20;
|
|
15128
15156
|
var init_controller = __esm({
|
|
15129
15157
|
"src/run-case/controller.ts"() {
|
|
15130
15158
|
"use strict";
|
|
15131
|
-
|
|
15132
|
-
|
|
15133
|
-
|
|
15159
|
+
import_node_fs21 = require("fs");
|
|
15160
|
+
import_node_os13 = __toESM(require("os"), 1);
|
|
15161
|
+
import_node_path20 = __toESM(require("path"), 1);
|
|
15134
15162
|
init_claude();
|
|
15135
15163
|
init_stdout_splitter();
|
|
15136
15164
|
init_permission_stdio();
|
|
@@ -15355,8 +15383,8 @@ Env (advanced):
|
|
|
15355
15383
|
`;
|
|
15356
15384
|
|
|
15357
15385
|
// src/index.ts
|
|
15358
|
-
var
|
|
15359
|
-
var
|
|
15386
|
+
var import_node_path18 = __toESM(require("path"), 1);
|
|
15387
|
+
var import_node_fs19 = __toESM(require("fs"), 1);
|
|
15360
15388
|
|
|
15361
15389
|
// src/logger.ts
|
|
15362
15390
|
var import_node_fs2 = __toESM(require("fs"), 1);
|
|
@@ -17747,20 +17775,24 @@ var WorkspaceBrowser = class {
|
|
|
17747
17775
|
var import_node_fs9 = __toESM(require("fs"), 1);
|
|
17748
17776
|
var import_node_os5 = __toESM(require("os"), 1);
|
|
17749
17777
|
var import_node_path8 = __toESM(require("path"), 1);
|
|
17750
|
-
|
|
17751
|
-
|
|
17778
|
+
|
|
17779
|
+
// src/skills/frontmatter.ts
|
|
17780
|
+
var STRIP_QUOTES = /^["']|["']$/g;
|
|
17781
|
+
function strip(s) {
|
|
17782
|
+
return s.trim().replace(STRIP_QUOTES, "");
|
|
17783
|
+
}
|
|
17784
|
+
function parseFrontmatter(content, keys) {
|
|
17785
|
+
const out = {};
|
|
17786
|
+
if (!content.startsWith("---")) return out;
|
|
17752
17787
|
const end = content.indexOf("---", 3);
|
|
17753
|
-
if (end === -1) return
|
|
17788
|
+
if (end === -1) return out;
|
|
17754
17789
|
const lines = content.slice(3, end).split("\n");
|
|
17755
|
-
const strip = (s) => s.trim().replace(/^["']|["']$/g, "");
|
|
17756
|
-
let name = "";
|
|
17757
|
-
let description = "";
|
|
17758
17790
|
for (let i = 0; i < lines.length; i++) {
|
|
17759
17791
|
const trimmed = lines[i].trim();
|
|
17760
|
-
|
|
17761
|
-
|
|
17762
|
-
|
|
17763
|
-
const rest = trimmed.slice(
|
|
17792
|
+
for (const key of keys) {
|
|
17793
|
+
const prefix = `${key}:`;
|
|
17794
|
+
if (!trimmed.startsWith(prefix)) continue;
|
|
17795
|
+
const rest = trimmed.slice(prefix.length).trim();
|
|
17764
17796
|
if (rest === "|" || rest === ">" || rest === "|-" || rest === ">-") {
|
|
17765
17797
|
const parts = [];
|
|
17766
17798
|
for (let j = i + 1; j < lines.length; j++) {
|
|
@@ -17772,13 +17804,82 @@ function parseFrontmatter(content) {
|
|
|
17772
17804
|
if (!/^\s/.test(next)) break;
|
|
17773
17805
|
parts.push(next.replace(/^\s+/, ""));
|
|
17774
17806
|
}
|
|
17775
|
-
|
|
17807
|
+
const value = parts.filter(Boolean).join(" ").trim();
|
|
17808
|
+
if (value) out[key] = value;
|
|
17776
17809
|
} else {
|
|
17777
|
-
|
|
17810
|
+
const value = strip(rest);
|
|
17811
|
+
if (value) out[key] = value;
|
|
17778
17812
|
}
|
|
17813
|
+
break;
|
|
17779
17814
|
}
|
|
17780
17815
|
}
|
|
17781
|
-
return
|
|
17816
|
+
return out;
|
|
17817
|
+
}
|
|
17818
|
+
|
|
17819
|
+
// src/skills/builtin-cc-resources.ts
|
|
17820
|
+
var BUILTIN_SKILLS = [
|
|
17821
|
+
{ name: "update-config", source: "builtin", description: "Update Claude Code configuration." },
|
|
17822
|
+
{ name: "keybindings-help", source: "builtin", description: "Show available keybindings." },
|
|
17823
|
+
{ name: "verify", source: "builtin", description: "Verify the implementation." },
|
|
17824
|
+
{ name: "debug", source: "builtin", description: "Debug current issue." },
|
|
17825
|
+
{ name: "lorem-ipsum", source: "builtin", description: "Generate lorem ipsum placeholder text." },
|
|
17826
|
+
{ name: "skillify", source: "builtin", description: "Convert a process into a reusable skill." },
|
|
17827
|
+
{ name: "remember", source: "builtin", description: "Remember context for later use." },
|
|
17828
|
+
{ name: "simplify", source: "builtin", description: "Simplify the code or message." },
|
|
17829
|
+
{ name: "batch", source: "builtin", description: "Run a batch of similar operations." },
|
|
17830
|
+
{ name: "stuck", source: "builtin", description: "Help unstick a stalled task." },
|
|
17831
|
+
{ name: "loop", source: "builtin", description: "Loop a task until a condition is met." },
|
|
17832
|
+
{ name: "cron-list", source: "builtin", description: "List scheduled cron tasks." },
|
|
17833
|
+
{ name: "cron-delete", source: "builtin", description: "Delete a scheduled cron task." },
|
|
17834
|
+
{ name: "dream", source: "builtin", description: "Brainstorm freely without constraints." },
|
|
17835
|
+
{ name: "hunter", source: "builtin", description: "Hunt down a bug or root cause." },
|
|
17836
|
+
{ name: "schedule", source: "builtin", description: "Schedule a task to run later." },
|
|
17837
|
+
{ name: "claude-api", source: "builtin", description: "Use the Claude API directly." },
|
|
17838
|
+
{ name: "claude-in-chrome", source: "builtin", description: "Drive Claude inside Chrome via the Chrome extension." }
|
|
17839
|
+
];
|
|
17840
|
+
var BUILTIN_AGENTS = [
|
|
17841
|
+
{
|
|
17842
|
+
name: "general-purpose",
|
|
17843
|
+
source: "builtin",
|
|
17844
|
+
description: "General-purpose agent for researching complex questions and executing multi-step tasks.",
|
|
17845
|
+
whenToUse: "When you are searching for a keyword or file and are not confident you will find the right match in the first few tries."
|
|
17846
|
+
},
|
|
17847
|
+
{
|
|
17848
|
+
name: "statusline-setup",
|
|
17849
|
+
source: "builtin",
|
|
17850
|
+
description: "Configure the user's Claude Code status line setting.",
|
|
17851
|
+
whenToUse: "When the user is setting up or changing their status line configuration."
|
|
17852
|
+
},
|
|
17853
|
+
{
|
|
17854
|
+
name: "Explore",
|
|
17855
|
+
source: "builtin",
|
|
17856
|
+
description: "Explore the codebase to gather context.",
|
|
17857
|
+
whenToUse: "Before making changes that require understanding the surrounding code."
|
|
17858
|
+
},
|
|
17859
|
+
{
|
|
17860
|
+
name: "Plan",
|
|
17861
|
+
source: "builtin",
|
|
17862
|
+
description: "Produce an implementation plan before writing code.",
|
|
17863
|
+
whenToUse: "When the task is non-trivial and would benefit from an explicit plan."
|
|
17864
|
+
},
|
|
17865
|
+
{
|
|
17866
|
+
name: "claude-code-guide",
|
|
17867
|
+
source: "builtin",
|
|
17868
|
+
description: "Guide the user through Claude Code features.",
|
|
17869
|
+
whenToUse: "When the user needs help understanding what Claude Code can do."
|
|
17870
|
+
},
|
|
17871
|
+
{
|
|
17872
|
+
name: "verification",
|
|
17873
|
+
source: "builtin",
|
|
17874
|
+
description: "Verify that a change works as intended.",
|
|
17875
|
+
whenToUse: "After implementing a change, before declaring it done."
|
|
17876
|
+
}
|
|
17877
|
+
];
|
|
17878
|
+
|
|
17879
|
+
// src/skills/scanner.ts
|
|
17880
|
+
function parseDescription(content) {
|
|
17881
|
+
const fields = parseFrontmatter(content, ["description"]);
|
|
17882
|
+
return { description: fields.description ?? "" };
|
|
17782
17883
|
}
|
|
17783
17884
|
function isDirLikeSync(p) {
|
|
17784
17885
|
try {
|
|
@@ -17807,7 +17908,7 @@ function scanSkillDir(dir, source, seen, out, pluginName) {
|
|
|
17807
17908
|
continue;
|
|
17808
17909
|
}
|
|
17809
17910
|
}
|
|
17810
|
-
const { description } =
|
|
17911
|
+
const { description } = parseDescription(content);
|
|
17811
17912
|
const baseName = ent.name;
|
|
17812
17913
|
const name = pluginName ? `${pluginName}:${baseName}` : baseName;
|
|
17813
17914
|
if (seen.has(name)) continue;
|
|
@@ -17844,7 +17945,7 @@ function scanCommandDir(dir, source, seen, out, pluginName) {
|
|
|
17844
17945
|
continue;
|
|
17845
17946
|
}
|
|
17846
17947
|
const cmd = se.name.replace(/\.md$/, "");
|
|
17847
|
-
const { description } =
|
|
17948
|
+
const { description } = parseDescription(content);
|
|
17848
17949
|
const qualified = `${ns}:${cmd}`;
|
|
17849
17950
|
const name = pluginName ? `${pluginName}:${qualified}` : qualified;
|
|
17850
17951
|
if (seen.has(name)) continue;
|
|
@@ -17861,7 +17962,7 @@ function scanCommandDir(dir, source, seen, out, pluginName) {
|
|
|
17861
17962
|
continue;
|
|
17862
17963
|
}
|
|
17863
17964
|
const cmd = ent.name.replace(/\.md$/, "");
|
|
17864
|
-
const { description } =
|
|
17965
|
+
const { description } = parseDescription(content);
|
|
17865
17966
|
const name = pluginName ? `${pluginName}:${cmd}` : cmd;
|
|
17866
17967
|
if (seen.has(name)) continue;
|
|
17867
17968
|
seen.add(name);
|
|
@@ -17912,44 +18013,245 @@ var SkillsScanner = class {
|
|
|
17912
18013
|
*/
|
|
17913
18014
|
list(args) {
|
|
17914
18015
|
const seen = /* @__PURE__ */ new Set();
|
|
17915
|
-
const
|
|
17916
|
-
|
|
17917
|
-
|
|
17918
|
-
|
|
17919
|
-
|
|
18016
|
+
const builtinBlock = [];
|
|
18017
|
+
for (const b of BUILTIN_SKILLS) {
|
|
18018
|
+
if (seen.has(b.name)) continue;
|
|
18019
|
+
seen.add(b.name);
|
|
18020
|
+
builtinBlock.push({
|
|
18021
|
+
name: b.name,
|
|
18022
|
+
source: "builtin",
|
|
18023
|
+
description: b.description
|
|
18024
|
+
});
|
|
18025
|
+
}
|
|
18026
|
+
const fsBlock = [];
|
|
18027
|
+
scanSkillDir(import_node_path8.default.join(this.home, ".claude", "skills"), "global", seen, fsBlock);
|
|
18028
|
+
scanCommandDir(import_node_path8.default.join(this.home, ".claude", "commands"), "global", seen, fsBlock);
|
|
18029
|
+
scanSkillDir(import_node_path8.default.join(args.cwd, ".claude", "skills"), "project", seen, fsBlock);
|
|
18030
|
+
scanCommandDir(import_node_path8.default.join(args.cwd, ".claude", "commands"), "project", seen, fsBlock);
|
|
17920
18031
|
const plugins = [...readInstalledPlugins(this.home), ...this.extraPluginRoots];
|
|
17921
18032
|
for (const { name, root } of plugins) {
|
|
17922
|
-
scanSkillDir(import_node_path8.default.join(root, "skills"), "plugin", seen,
|
|
17923
|
-
scanCommandDir(import_node_path8.default.join(root, "commands"), "plugin", seen,
|
|
18033
|
+
scanSkillDir(import_node_path8.default.join(root, "skills"), "plugin", seen, fsBlock, name);
|
|
18034
|
+
scanCommandDir(import_node_path8.default.join(root, "commands"), "plugin", seen, fsBlock, name);
|
|
17924
18035
|
}
|
|
17925
|
-
|
|
17926
|
-
return
|
|
18036
|
+
fsBlock.sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0);
|
|
18037
|
+
return [...builtinBlock, ...fsBlock];
|
|
17927
18038
|
}
|
|
17928
18039
|
};
|
|
17929
18040
|
|
|
17930
|
-
// src/
|
|
18041
|
+
// src/skills/agents-scanner.ts
|
|
17931
18042
|
var import_node_fs10 = __toESM(require("fs"), 1);
|
|
17932
18043
|
var import_node_os6 = __toESM(require("os"), 1);
|
|
17933
18044
|
var import_node_path9 = __toESM(require("path"), 1);
|
|
18045
|
+
var DEFAULT_POLICY_DIR_DARWIN = "/Library/Application Support/ClaudeCode/.claude/agents";
|
|
18046
|
+
function isDirLikeSync2(p) {
|
|
18047
|
+
try {
|
|
18048
|
+
return import_node_fs10.default.statSync(p).isDirectory();
|
|
18049
|
+
} catch {
|
|
18050
|
+
return false;
|
|
18051
|
+
}
|
|
18052
|
+
}
|
|
18053
|
+
function fileExistsSync(p) {
|
|
18054
|
+
try {
|
|
18055
|
+
return import_node_fs10.default.statSync(p).isFile();
|
|
18056
|
+
} catch {
|
|
18057
|
+
return false;
|
|
18058
|
+
}
|
|
18059
|
+
}
|
|
18060
|
+
function parseAgentFile(filePath) {
|
|
18061
|
+
let content;
|
|
18062
|
+
try {
|
|
18063
|
+
content = import_node_fs10.default.readFileSync(filePath, "utf8");
|
|
18064
|
+
} catch {
|
|
18065
|
+
return {};
|
|
18066
|
+
}
|
|
18067
|
+
const fm = parseFrontmatter(content, ["description", "whenToUse"]);
|
|
18068
|
+
return {
|
|
18069
|
+
description: fm.description,
|
|
18070
|
+
whenToUse: fm.whenToUse
|
|
18071
|
+
};
|
|
18072
|
+
}
|
|
18073
|
+
function scanAgentsDir(dir, source, seen, out) {
|
|
18074
|
+
let entries;
|
|
18075
|
+
try {
|
|
18076
|
+
entries = import_node_fs10.default.readdirSync(dir, { withFileTypes: true });
|
|
18077
|
+
} catch {
|
|
18078
|
+
return;
|
|
18079
|
+
}
|
|
18080
|
+
for (const ent of entries) {
|
|
18081
|
+
if (!ent.name.endsWith(".md")) continue;
|
|
18082
|
+
if (!ent.isFile() && !(ent.isSymbolicLink() && fileExistsSync(import_node_path9.default.join(dir, ent.name)))) {
|
|
18083
|
+
continue;
|
|
18084
|
+
}
|
|
18085
|
+
const filePath = import_node_path9.default.join(dir, ent.name);
|
|
18086
|
+
const baseName = ent.name.replace(/\.md$/, "");
|
|
18087
|
+
if (seen.has(baseName)) continue;
|
|
18088
|
+
seen.add(baseName);
|
|
18089
|
+
const { description, whenToUse } = parseAgentFile(filePath);
|
|
18090
|
+
out.push({
|
|
18091
|
+
name: baseName,
|
|
18092
|
+
source,
|
|
18093
|
+
path: filePath,
|
|
18094
|
+
...description ? { description } : {},
|
|
18095
|
+
...whenToUse ? { whenToUse } : {}
|
|
18096
|
+
});
|
|
18097
|
+
}
|
|
18098
|
+
}
|
|
18099
|
+
function scanPluginAgentsTree(root, pluginName, seen, out) {
|
|
18100
|
+
function walk(dir, namespaces) {
|
|
18101
|
+
let entries;
|
|
18102
|
+
try {
|
|
18103
|
+
entries = import_node_fs10.default.readdirSync(dir, { withFileTypes: true });
|
|
18104
|
+
} catch {
|
|
18105
|
+
return;
|
|
18106
|
+
}
|
|
18107
|
+
for (const ent of entries) {
|
|
18108
|
+
const childPath = import_node_path9.default.join(dir, ent.name);
|
|
18109
|
+
if (ent.isDirectory() || ent.isSymbolicLink() && isDirLikeSync2(childPath)) {
|
|
18110
|
+
walk(childPath, [...namespaces, ent.name]);
|
|
18111
|
+
continue;
|
|
18112
|
+
}
|
|
18113
|
+
if (!ent.name.endsWith(".md")) continue;
|
|
18114
|
+
const baseName = ent.name.replace(/\.md$/, "");
|
|
18115
|
+
const nameParts = [pluginName, ...namespaces, baseName];
|
|
18116
|
+
const name = nameParts.join(":");
|
|
18117
|
+
if (seen.has(name)) continue;
|
|
18118
|
+
seen.add(name);
|
|
18119
|
+
const { description, whenToUse } = parseAgentFile(childPath);
|
|
18120
|
+
out.push({
|
|
18121
|
+
name,
|
|
18122
|
+
source: "plugin",
|
|
18123
|
+
path: childPath,
|
|
18124
|
+
plugin: pluginName,
|
|
18125
|
+
...description ? { description } : {},
|
|
18126
|
+
...whenToUse ? { whenToUse } : {}
|
|
18127
|
+
});
|
|
18128
|
+
}
|
|
18129
|
+
}
|
|
18130
|
+
walk(root, []);
|
|
18131
|
+
}
|
|
18132
|
+
function readInstalledPlugins2(home) {
|
|
18133
|
+
const pluginsDir = import_node_path9.default.join(home, ".claude", "plugins");
|
|
18134
|
+
const v2 = import_node_path9.default.join(pluginsDir, "installed_plugins_v2.json");
|
|
18135
|
+
const v1 = import_node_path9.default.join(pluginsDir, "installed_plugins.json");
|
|
18136
|
+
let raw = null;
|
|
18137
|
+
for (const candidate of [v2, v1]) {
|
|
18138
|
+
try {
|
|
18139
|
+
raw = import_node_fs10.default.readFileSync(candidate, "utf8");
|
|
18140
|
+
break;
|
|
18141
|
+
} catch {
|
|
18142
|
+
}
|
|
18143
|
+
}
|
|
18144
|
+
if (!raw) return [];
|
|
18145
|
+
let parsed;
|
|
18146
|
+
try {
|
|
18147
|
+
parsed = JSON.parse(raw);
|
|
18148
|
+
} catch {
|
|
18149
|
+
return [];
|
|
18150
|
+
}
|
|
18151
|
+
const out = [];
|
|
18152
|
+
for (const [key, entries] of Object.entries(parsed.plugins ?? {})) {
|
|
18153
|
+
if (!Array.isArray(entries) || entries.length === 0) continue;
|
|
18154
|
+
const entry = entries[0];
|
|
18155
|
+
if (!entry?.installPath) continue;
|
|
18156
|
+
if (entry.enabled === false) continue;
|
|
18157
|
+
const pluginName = key.includes("@") ? key.slice(0, key.indexOf("@")) : key;
|
|
18158
|
+
if (!pluginName) continue;
|
|
18159
|
+
out.push({ name: pluginName, root: entry.installPath });
|
|
18160
|
+
}
|
|
18161
|
+
return out;
|
|
18162
|
+
}
|
|
18163
|
+
function walkUpProjectAgentsDirs(startCwd, home, seen, out) {
|
|
18164
|
+
let cur = import_node_path9.default.resolve(startCwd);
|
|
18165
|
+
const fsRoot = import_node_path9.default.parse(cur).root;
|
|
18166
|
+
while (true) {
|
|
18167
|
+
scanAgentsDir(import_node_path9.default.join(cur, ".claude", "agents"), "project", seen, out);
|
|
18168
|
+
let hasGit = false;
|
|
18169
|
+
try {
|
|
18170
|
+
hasGit = import_node_fs10.default.existsSync(import_node_path9.default.join(cur, ".git"));
|
|
18171
|
+
} catch {
|
|
18172
|
+
}
|
|
18173
|
+
if (hasGit) return;
|
|
18174
|
+
if (cur === home) return;
|
|
18175
|
+
if (cur === fsRoot) return;
|
|
18176
|
+
const parent = import_node_path9.default.dirname(cur);
|
|
18177
|
+
if (parent === cur) return;
|
|
18178
|
+
cur = parent;
|
|
18179
|
+
}
|
|
18180
|
+
}
|
|
18181
|
+
var AgentsScanner = class {
|
|
18182
|
+
home;
|
|
18183
|
+
extraPluginRoots;
|
|
18184
|
+
policyDir;
|
|
18185
|
+
constructor(opts = {}) {
|
|
18186
|
+
this.home = opts.home ?? process.env.CLAUDE_CONFIG_DIR ?? import_node_os6.default.homedir();
|
|
18187
|
+
this.extraPluginRoots = opts.extraPluginRoots ?? [];
|
|
18188
|
+
if (opts.policyDir !== void 0) {
|
|
18189
|
+
this.policyDir = opts.policyDir;
|
|
18190
|
+
} else if (process.platform === "darwin") {
|
|
18191
|
+
this.policyDir = DEFAULT_POLICY_DIR_DARWIN;
|
|
18192
|
+
} else {
|
|
18193
|
+
this.policyDir = null;
|
|
18194
|
+
}
|
|
18195
|
+
}
|
|
18196
|
+
list(args) {
|
|
18197
|
+
const seen = /* @__PURE__ */ new Set();
|
|
18198
|
+
const builtinBlock = [];
|
|
18199
|
+
for (const b of BUILTIN_AGENTS) {
|
|
18200
|
+
if (seen.has(b.name)) continue;
|
|
18201
|
+
seen.add(b.name);
|
|
18202
|
+
builtinBlock.push({
|
|
18203
|
+
name: b.name,
|
|
18204
|
+
source: "builtin",
|
|
18205
|
+
...b.description ? { description: b.description } : {},
|
|
18206
|
+
...b.whenToUse ? { whenToUse: b.whenToUse } : {}
|
|
18207
|
+
});
|
|
18208
|
+
}
|
|
18209
|
+
const fsBlock = [];
|
|
18210
|
+
scanAgentsDir(
|
|
18211
|
+
import_node_path9.default.join(this.home, ".claude", "agents"),
|
|
18212
|
+
"global",
|
|
18213
|
+
seen,
|
|
18214
|
+
fsBlock
|
|
18215
|
+
);
|
|
18216
|
+
walkUpProjectAgentsDirs(args.cwd, this.home, seen, fsBlock);
|
|
18217
|
+
if (this.policyDir) {
|
|
18218
|
+
scanAgentsDir(this.policyDir, "policy", seen, fsBlock);
|
|
18219
|
+
}
|
|
18220
|
+
const plugins = [
|
|
18221
|
+
...readInstalledPlugins2(this.home),
|
|
18222
|
+
...this.extraPluginRoots
|
|
18223
|
+
];
|
|
18224
|
+
for (const { name, root } of plugins) {
|
|
18225
|
+
const agentsRoot = import_node_path9.default.join(root, "agents");
|
|
18226
|
+
scanPluginAgentsTree(agentsRoot, name, seen, fsBlock);
|
|
18227
|
+
}
|
|
18228
|
+
return [...builtinBlock, ...fsBlock];
|
|
18229
|
+
}
|
|
18230
|
+
};
|
|
18231
|
+
|
|
18232
|
+
// src/observer/session-observer.ts
|
|
18233
|
+
var import_node_fs11 = __toESM(require("fs"), 1);
|
|
18234
|
+
var import_node_os7 = __toESM(require("os"), 1);
|
|
18235
|
+
var import_node_path10 = __toESM(require("path"), 1);
|
|
17934
18236
|
init_claude_history();
|
|
17935
18237
|
var SessionObserver = class {
|
|
17936
18238
|
constructor(opts) {
|
|
17937
18239
|
this.opts = opts;
|
|
17938
|
-
this.home = opts.home ??
|
|
18240
|
+
this.home = opts.home ?? import_node_os7.default.homedir();
|
|
17939
18241
|
}
|
|
17940
18242
|
opts;
|
|
17941
18243
|
home;
|
|
17942
18244
|
watches = /* @__PURE__ */ new Map();
|
|
17943
18245
|
resolveJsonlPath(cwd, toolSessionId, override) {
|
|
17944
18246
|
if (override) return override;
|
|
17945
|
-
return
|
|
18247
|
+
return import_node_path10.default.join(this.home, ".claude", "projects", cwdToHashDir(cwd), `${toolSessionId}.jsonl`);
|
|
17946
18248
|
}
|
|
17947
18249
|
start(args) {
|
|
17948
18250
|
this.stop(args.sessionId);
|
|
17949
18251
|
const filePath = this.resolveJsonlPath(args.cwd, args.toolSessionId, args.jsonlPath);
|
|
17950
18252
|
let size = 0;
|
|
17951
18253
|
try {
|
|
17952
|
-
size =
|
|
18254
|
+
size = import_node_fs11.default.statSync(filePath).size;
|
|
17953
18255
|
} catch {
|
|
17954
18256
|
}
|
|
17955
18257
|
const w = {
|
|
@@ -17962,10 +18264,10 @@ var SessionObserver = class {
|
|
|
17962
18264
|
adapter: args.adapter
|
|
17963
18265
|
};
|
|
17964
18266
|
try {
|
|
17965
|
-
|
|
18267
|
+
import_node_fs11.default.mkdirSync(import_node_path10.default.dirname(filePath), { recursive: true });
|
|
17966
18268
|
} catch {
|
|
17967
18269
|
}
|
|
17968
|
-
w.watcher =
|
|
18270
|
+
w.watcher = import_node_fs11.default.watch(import_node_path10.default.dirname(filePath), { persistent: false }, (_event, changedName) => {
|
|
17969
18271
|
if (!changedName || !filePath.endsWith(changedName)) return;
|
|
17970
18272
|
this.poll(w);
|
|
17971
18273
|
});
|
|
@@ -17980,7 +18282,7 @@ var SessionObserver = class {
|
|
|
17980
18282
|
// reducer.shallowEqMeta diff 让重复 patch 静默吞掉;异常静默吞,不阻塞 watcher 启动
|
|
17981
18283
|
hydrateMetaTail(w, maxLines = 200) {
|
|
17982
18284
|
try {
|
|
17983
|
-
const raw =
|
|
18285
|
+
const raw = import_node_fs11.default.readFileSync(w.filePath, "utf8");
|
|
17984
18286
|
if (!raw) return;
|
|
17985
18287
|
const allLines = raw.split("\n").filter((l) => l.trim().length > 0);
|
|
17986
18288
|
if (allLines.length === 0) return;
|
|
@@ -18001,7 +18303,7 @@ var SessionObserver = class {
|
|
|
18001
18303
|
poll(w) {
|
|
18002
18304
|
let size = 0;
|
|
18003
18305
|
try {
|
|
18004
|
-
size =
|
|
18306
|
+
size = import_node_fs11.default.statSync(w.filePath).size;
|
|
18005
18307
|
} catch {
|
|
18006
18308
|
return;
|
|
18007
18309
|
}
|
|
@@ -18010,11 +18312,11 @@ var SessionObserver = class {
|
|
|
18010
18312
|
w.buf = "";
|
|
18011
18313
|
}
|
|
18012
18314
|
if (size === w.lastSize) return;
|
|
18013
|
-
const fd =
|
|
18315
|
+
const fd = import_node_fs11.default.openSync(w.filePath, "r");
|
|
18014
18316
|
try {
|
|
18015
18317
|
const len = size - w.lastSize;
|
|
18016
18318
|
const buf = Buffer.alloc(len);
|
|
18017
|
-
|
|
18319
|
+
import_node_fs11.default.readSync(fd, buf, 0, len, w.lastSize);
|
|
18018
18320
|
w.lastSize = size;
|
|
18019
18321
|
w.buf += buf.toString("utf8");
|
|
18020
18322
|
let newlineIndex;
|
|
@@ -18028,7 +18330,7 @@ var SessionObserver = class {
|
|
|
18028
18330
|
this.maybeReportUserMessage(w.sessionId, line);
|
|
18029
18331
|
}
|
|
18030
18332
|
} finally {
|
|
18031
|
-
|
|
18333
|
+
import_node_fs11.default.closeSync(fd);
|
|
18032
18334
|
}
|
|
18033
18335
|
}
|
|
18034
18336
|
// 解析 JSONL 单行:仅当是主链 user 文本行(非 sidechain / 非 sub-agent / message.role='user'
|
|
@@ -18680,10 +18982,10 @@ function isLocalhost(addr) {
|
|
|
18680
18982
|
}
|
|
18681
18983
|
|
|
18682
18984
|
// src/discovery/state-file.ts
|
|
18683
|
-
var
|
|
18684
|
-
var
|
|
18985
|
+
var import_node_fs12 = __toESM(require("fs"), 1);
|
|
18986
|
+
var import_node_path11 = __toESM(require("path"), 1);
|
|
18685
18987
|
function defaultStateFilePath(dataDir) {
|
|
18686
|
-
return
|
|
18988
|
+
return import_node_path11.default.join(dataDir, "state.json");
|
|
18687
18989
|
}
|
|
18688
18990
|
function isPidAlive(pid) {
|
|
18689
18991
|
if (!Number.isFinite(pid) || pid <= 0) return false;
|
|
@@ -18705,7 +19007,7 @@ var StateFileManager = class {
|
|
|
18705
19007
|
}
|
|
18706
19008
|
read() {
|
|
18707
19009
|
try {
|
|
18708
|
-
const raw =
|
|
19010
|
+
const raw = import_node_fs12.default.readFileSync(this.file, "utf8");
|
|
18709
19011
|
const parsed = JSON.parse(raw);
|
|
18710
19012
|
return parsed;
|
|
18711
19013
|
} catch {
|
|
@@ -18719,34 +19021,34 @@ var StateFileManager = class {
|
|
|
18719
19021
|
return { status: "stale", existing };
|
|
18720
19022
|
}
|
|
18721
19023
|
write(state) {
|
|
18722
|
-
|
|
19024
|
+
import_node_fs12.default.mkdirSync(import_node_path11.default.dirname(this.file), { recursive: true });
|
|
18723
19025
|
const tmp = `${this.file}.tmp.${process.pid}.${Date.now()}`;
|
|
18724
|
-
|
|
18725
|
-
|
|
19026
|
+
import_node_fs12.default.writeFileSync(tmp, JSON.stringify(state, null, 2), { mode: 384 });
|
|
19027
|
+
import_node_fs12.default.renameSync(tmp, this.file);
|
|
18726
19028
|
if (process.platform !== "win32") {
|
|
18727
19029
|
try {
|
|
18728
|
-
|
|
19030
|
+
import_node_fs12.default.chmodSync(this.file, 384);
|
|
18729
19031
|
} catch {
|
|
18730
19032
|
}
|
|
18731
19033
|
}
|
|
18732
19034
|
}
|
|
18733
19035
|
delete() {
|
|
18734
19036
|
try {
|
|
18735
|
-
|
|
19037
|
+
import_node_fs12.default.unlinkSync(this.file);
|
|
18736
19038
|
} catch {
|
|
18737
19039
|
}
|
|
18738
19040
|
}
|
|
18739
19041
|
};
|
|
18740
19042
|
|
|
18741
19043
|
// src/tunnel/tunnel-manager.ts
|
|
18742
|
-
var
|
|
18743
|
-
var
|
|
19044
|
+
var import_node_fs15 = __toESM(require("fs"), 1);
|
|
19045
|
+
var import_node_path14 = __toESM(require("path"), 1);
|
|
18744
19046
|
var import_node_crypto4 = __toESM(require("crypto"), 1);
|
|
18745
19047
|
var import_node_child_process4 = require("child_process");
|
|
18746
19048
|
|
|
18747
19049
|
// src/tunnel/tunnel-store.ts
|
|
18748
|
-
var
|
|
18749
|
-
var
|
|
19050
|
+
var import_node_fs13 = __toESM(require("fs"), 1);
|
|
19051
|
+
var import_node_path12 = __toESM(require("path"), 1);
|
|
18750
19052
|
var TunnelStore = class {
|
|
18751
19053
|
constructor(filePath) {
|
|
18752
19054
|
this.filePath = filePath;
|
|
@@ -18754,7 +19056,7 @@ var TunnelStore = class {
|
|
|
18754
19056
|
filePath;
|
|
18755
19057
|
async get() {
|
|
18756
19058
|
try {
|
|
18757
|
-
const raw = await
|
|
19059
|
+
const raw = await import_node_fs13.default.promises.readFile(this.filePath, "utf8");
|
|
18758
19060
|
const obj = JSON.parse(raw);
|
|
18759
19061
|
if (!isPersistedTunnel(obj)) return null;
|
|
18760
19062
|
return obj;
|
|
@@ -18765,22 +19067,22 @@ var TunnelStore = class {
|
|
|
18765
19067
|
}
|
|
18766
19068
|
}
|
|
18767
19069
|
async set(v) {
|
|
18768
|
-
const dir =
|
|
18769
|
-
await
|
|
19070
|
+
const dir = import_node_path12.default.dirname(this.filePath);
|
|
19071
|
+
await import_node_fs13.default.promises.mkdir(dir, { recursive: true });
|
|
18770
19072
|
const data = JSON.stringify(v, null, 2);
|
|
18771
19073
|
const tmp = `${this.filePath}.tmp.${process.pid}.${Date.now()}`;
|
|
18772
|
-
await
|
|
19074
|
+
await import_node_fs13.default.promises.writeFile(tmp, data, { mode: 384 });
|
|
18773
19075
|
if (process.platform !== "win32") {
|
|
18774
19076
|
try {
|
|
18775
|
-
await
|
|
19077
|
+
await import_node_fs13.default.promises.chmod(tmp, 384);
|
|
18776
19078
|
} catch {
|
|
18777
19079
|
}
|
|
18778
19080
|
}
|
|
18779
|
-
await
|
|
19081
|
+
await import_node_fs13.default.promises.rename(tmp, this.filePath);
|
|
18780
19082
|
}
|
|
18781
19083
|
async clear() {
|
|
18782
19084
|
try {
|
|
18783
|
-
await
|
|
19085
|
+
await import_node_fs13.default.promises.unlink(this.filePath);
|
|
18784
19086
|
} catch (err) {
|
|
18785
19087
|
const code = err?.code;
|
|
18786
19088
|
if (code !== "ENOENT") throw err;
|
|
@@ -18875,9 +19177,9 @@ function escape(v) {
|
|
|
18875
19177
|
}
|
|
18876
19178
|
|
|
18877
19179
|
// src/tunnel/frpc-binary.ts
|
|
18878
|
-
var
|
|
18879
|
-
var
|
|
18880
|
-
var
|
|
19180
|
+
var import_node_fs14 = __toESM(require("fs"), 1);
|
|
19181
|
+
var import_node_os8 = __toESM(require("os"), 1);
|
|
19182
|
+
var import_node_path13 = __toESM(require("path"), 1);
|
|
18881
19183
|
var import_node_child_process3 = require("child_process");
|
|
18882
19184
|
var import_node_stream = require("stream");
|
|
18883
19185
|
var import_promises = require("stream/promises");
|
|
@@ -18909,20 +19211,20 @@ function frpcDownloadUrl(version2, p) {
|
|
|
18909
19211
|
}
|
|
18910
19212
|
async function ensureFrpcBinary(opts) {
|
|
18911
19213
|
if (opts.override) {
|
|
18912
|
-
if (!
|
|
19214
|
+
if (!import_node_fs14.default.existsSync(opts.override)) {
|
|
18913
19215
|
throw new Error(`frpc binary not found at override path: ${opts.override}`);
|
|
18914
19216
|
}
|
|
18915
19217
|
return opts.override;
|
|
18916
19218
|
}
|
|
18917
19219
|
const version2 = opts.version ?? FRPC_VERSION;
|
|
18918
19220
|
const platform = opts.platform ?? detectPlatform();
|
|
18919
|
-
const binDir =
|
|
18920
|
-
|
|
19221
|
+
const binDir = import_node_path13.default.join(opts.dataDir, "bin");
|
|
19222
|
+
import_node_fs14.default.mkdirSync(binDir, { recursive: true });
|
|
18921
19223
|
cleanupStaleArtifacts(binDir);
|
|
18922
|
-
const stableBin =
|
|
18923
|
-
if (
|
|
19224
|
+
const stableBin = import_node_path13.default.join(binDir, "frpc");
|
|
19225
|
+
if (import_node_fs14.default.existsSync(stableBin)) return stableBin;
|
|
18924
19226
|
const partialBin = `${stableBin}.partial`;
|
|
18925
|
-
const tarballPath =
|
|
19227
|
+
const tarballPath = import_node_path13.default.join(binDir, `frp_${version2}_${platform.os}_${platform.arch}.tar.gz.partial`);
|
|
18926
19228
|
try {
|
|
18927
19229
|
const url = frpcDownloadUrl(version2, platform);
|
|
18928
19230
|
await downloadToFile(url, tarballPath, opts.fetchImpl);
|
|
@@ -18931,8 +19233,8 @@ async function ensureFrpcBinary(opts) {
|
|
|
18931
19233
|
} else {
|
|
18932
19234
|
await extractFrpcFromTarball(tarballPath, binDir, version2, platform, partialBin);
|
|
18933
19235
|
}
|
|
18934
|
-
|
|
18935
|
-
|
|
19236
|
+
import_node_fs14.default.chmodSync(partialBin, 493);
|
|
19237
|
+
import_node_fs14.default.renameSync(partialBin, stableBin);
|
|
18936
19238
|
} finally {
|
|
18937
19239
|
safeUnlink(tarballPath);
|
|
18938
19240
|
safeUnlink(partialBin);
|
|
@@ -18942,15 +19244,15 @@ async function ensureFrpcBinary(opts) {
|
|
|
18942
19244
|
function cleanupStaleArtifacts(binDir) {
|
|
18943
19245
|
let entries;
|
|
18944
19246
|
try {
|
|
18945
|
-
entries =
|
|
19247
|
+
entries = import_node_fs14.default.readdirSync(binDir);
|
|
18946
19248
|
} catch {
|
|
18947
19249
|
return;
|
|
18948
19250
|
}
|
|
18949
19251
|
for (const name of entries) {
|
|
18950
19252
|
if (name.endsWith(".partial") || name.startsWith("extract-")) {
|
|
18951
|
-
const full =
|
|
19253
|
+
const full = import_node_path13.default.join(binDir, name);
|
|
18952
19254
|
try {
|
|
18953
|
-
|
|
19255
|
+
import_node_fs14.default.rmSync(full, { recursive: true, force: true });
|
|
18954
19256
|
} catch {
|
|
18955
19257
|
}
|
|
18956
19258
|
}
|
|
@@ -18958,7 +19260,7 @@ function cleanupStaleArtifacts(binDir) {
|
|
|
18958
19260
|
}
|
|
18959
19261
|
function safeUnlink(p) {
|
|
18960
19262
|
try {
|
|
18961
|
-
|
|
19263
|
+
import_node_fs14.default.unlinkSync(p);
|
|
18962
19264
|
} catch {
|
|
18963
19265
|
}
|
|
18964
19266
|
}
|
|
@@ -18969,13 +19271,13 @@ async function downloadToFile(url, dest, fetchImpl) {
|
|
|
18969
19271
|
if (!res.ok || !res.body) {
|
|
18970
19272
|
throw new Error(`download failed: ${res.status} ${res.statusText}`);
|
|
18971
19273
|
}
|
|
18972
|
-
const out =
|
|
19274
|
+
const out = import_node_fs14.default.createWriteStream(dest);
|
|
18973
19275
|
const nodeStream = import_node_stream.Readable.fromWeb(res.body);
|
|
18974
19276
|
await (0, import_promises.pipeline)(nodeStream, out);
|
|
18975
19277
|
}
|
|
18976
19278
|
async function extractFrpcFromTarball(tarball, binDir, version2, platform, destBin) {
|
|
18977
|
-
const work =
|
|
18978
|
-
|
|
19279
|
+
const work = import_node_path13.default.join(binDir, `extract-${process.pid}-${Date.now()}`);
|
|
19280
|
+
import_node_fs14.default.mkdirSync(work, { recursive: true });
|
|
18979
19281
|
try {
|
|
18980
19282
|
await new Promise((resolve, reject) => {
|
|
18981
19283
|
const proc = (0, import_node_child_process3.spawn)("tar", ["xzf", tarball, "-C", work], { stdio: "pipe" });
|
|
@@ -18983,13 +19285,13 @@ async function extractFrpcFromTarball(tarball, binDir, version2, platform, destB
|
|
|
18983
19285
|
proc.on("exit", (code) => code === 0 ? resolve() : reject(new Error(`tar exited ${code}`)));
|
|
18984
19286
|
});
|
|
18985
19287
|
const dirName = `frp_${version2}_${platform.os}_${platform.arch}`;
|
|
18986
|
-
const src =
|
|
18987
|
-
if (!
|
|
19288
|
+
const src = import_node_path13.default.join(work, dirName, "frpc");
|
|
19289
|
+
if (!import_node_fs14.default.existsSync(src)) {
|
|
18988
19290
|
throw new Error(`frpc not found inside tarball at ${src}`);
|
|
18989
19291
|
}
|
|
18990
|
-
|
|
19292
|
+
import_node_fs14.default.copyFileSync(src, destBin);
|
|
18991
19293
|
} finally {
|
|
18992
|
-
|
|
19294
|
+
import_node_fs14.default.rmSync(work, { recursive: true, force: true });
|
|
18993
19295
|
}
|
|
18994
19296
|
}
|
|
18995
19297
|
|
|
@@ -18998,7 +19300,7 @@ var DEFAULT_TUNNEL_TTL_MS = 7 * 24 * 60 * 60 * 1e3;
|
|
|
18998
19300
|
var TunnelManager = class {
|
|
18999
19301
|
constructor(deps) {
|
|
19000
19302
|
this.deps = deps;
|
|
19001
|
-
this.store = deps.store ?? new TunnelStore(
|
|
19303
|
+
this.store = deps.store ?? new TunnelStore(import_node_path14.default.join(deps.dataDir, "tunnel.json"));
|
|
19002
19304
|
this.ttlMs = deps.ttlMs ?? DEFAULT_TUNNEL_TTL_MS;
|
|
19003
19305
|
this.startupTimeoutMs = deps.startupTimeoutMs ?? 15e3;
|
|
19004
19306
|
}
|
|
@@ -19115,7 +19417,7 @@ var TunnelManager = class {
|
|
|
19115
19417
|
dataDir: this.deps.dataDir,
|
|
19116
19418
|
override: this.deps.frpcBinaryOverride ?? void 0
|
|
19117
19419
|
});
|
|
19118
|
-
const tomlPath =
|
|
19420
|
+
const tomlPath = import_node_path14.default.join(this.deps.dataDir, "frpc.toml");
|
|
19119
19421
|
const proxyName = `clawd-${t.subdomain}-${localPort}-${import_node_crypto4.default.randomBytes(3).toString("hex")}`;
|
|
19120
19422
|
const toml = buildFrpcToml({
|
|
19121
19423
|
serverAddr: t.frpsHost,
|
|
@@ -19126,12 +19428,12 @@ var TunnelManager = class {
|
|
|
19126
19428
|
localPort,
|
|
19127
19429
|
logLevel: "info"
|
|
19128
19430
|
});
|
|
19129
|
-
await
|
|
19431
|
+
await import_node_fs15.default.promises.writeFile(tomlPath, toml, { mode: 384 });
|
|
19130
19432
|
const proc = (this.deps.spawnImpl ?? import_node_child_process4.spawn)(frpcBin, ["-c", tomlPath], {
|
|
19131
19433
|
stdio: ["ignore", "pipe", "pipe"]
|
|
19132
19434
|
});
|
|
19133
|
-
const logFilePath =
|
|
19134
|
-
const logStream =
|
|
19435
|
+
const logFilePath = import_node_path14.default.join(this.deps.dataDir, "frpc.log");
|
|
19436
|
+
const logStream = import_node_fs15.default.createWriteStream(logFilePath, { flags: "a", mode: 384 });
|
|
19135
19437
|
logStream.on("error", () => {
|
|
19136
19438
|
});
|
|
19137
19439
|
const tee = (chunk) => {
|
|
@@ -19212,23 +19514,23 @@ async function waitForFrpcReady(proc, timeoutMs) {
|
|
|
19212
19514
|
}
|
|
19213
19515
|
|
|
19214
19516
|
// src/tunnel/device-key.ts
|
|
19215
|
-
var
|
|
19517
|
+
var import_node_os9 = __toESM(require("os"), 1);
|
|
19216
19518
|
var import_node_crypto5 = __toESM(require("crypto"), 1);
|
|
19217
19519
|
var DERIVE_SALT = "clawd-tunnel-device-v1";
|
|
19218
19520
|
function deriveStableDeviceKey(opts = {}) {
|
|
19219
|
-
const hostname = opts.hostname ??
|
|
19220
|
-
const uid = opts.uid ?? (typeof
|
|
19521
|
+
const hostname = opts.hostname ?? import_node_os9.default.hostname();
|
|
19522
|
+
const uid = opts.uid ?? (typeof import_node_os9.default.userInfo === "function" ? import_node_os9.default.userInfo().uid : 0);
|
|
19221
19523
|
const input = `${hostname}::${uid}`;
|
|
19222
19524
|
return import_node_crypto5.default.createHmac("sha256", DERIVE_SALT).update(input).digest("hex").slice(0, 32);
|
|
19223
19525
|
}
|
|
19224
19526
|
|
|
19225
19527
|
// src/auth-store.ts
|
|
19226
|
-
var
|
|
19227
|
-
var
|
|
19528
|
+
var import_node_fs16 = __toESM(require("fs"), 1);
|
|
19529
|
+
var import_node_path15 = __toESM(require("path"), 1);
|
|
19228
19530
|
var import_node_crypto6 = __toESM(require("crypto"), 1);
|
|
19229
19531
|
var AUTH_FILE_NAME = "auth.json";
|
|
19230
19532
|
function authFilePath(dataDir) {
|
|
19231
|
-
return
|
|
19533
|
+
return import_node_path15.default.join(dataDir, AUTH_FILE_NAME);
|
|
19232
19534
|
}
|
|
19233
19535
|
function loadOrCreateAuthToken(opts) {
|
|
19234
19536
|
const file = authFilePath(opts.dataDir);
|
|
@@ -19244,7 +19546,7 @@ function defaultGenerate() {
|
|
|
19244
19546
|
}
|
|
19245
19547
|
function readAuthFile(file) {
|
|
19246
19548
|
try {
|
|
19247
|
-
const raw =
|
|
19549
|
+
const raw = import_node_fs16.default.readFileSync(file, "utf8");
|
|
19248
19550
|
const parsed = JSON.parse(raw);
|
|
19249
19551
|
if (typeof parsed?.token === "string" && parsed.token.length > 0) {
|
|
19250
19552
|
return {
|
|
@@ -19260,10 +19562,10 @@ function readAuthFile(file) {
|
|
|
19260
19562
|
}
|
|
19261
19563
|
}
|
|
19262
19564
|
function writeAuthFile(file, content) {
|
|
19263
|
-
|
|
19264
|
-
|
|
19565
|
+
import_node_fs16.default.mkdirSync(import_node_path15.default.dirname(file), { recursive: true });
|
|
19566
|
+
import_node_fs16.default.writeFileSync(file, JSON.stringify(content, null, 2), { mode: 384 });
|
|
19265
19567
|
try {
|
|
19266
|
-
|
|
19568
|
+
import_node_fs16.default.chmodSync(file, 384);
|
|
19267
19569
|
} catch {
|
|
19268
19570
|
}
|
|
19269
19571
|
}
|
|
@@ -19275,12 +19577,12 @@ init_protocol();
|
|
|
19275
19577
|
init_protocol();
|
|
19276
19578
|
|
|
19277
19579
|
// src/session/fork.ts
|
|
19278
|
-
var
|
|
19279
|
-
var
|
|
19280
|
-
var
|
|
19580
|
+
var import_node_fs17 = __toESM(require("fs"), 1);
|
|
19581
|
+
var import_node_os10 = __toESM(require("os"), 1);
|
|
19582
|
+
var import_node_path16 = __toESM(require("path"), 1);
|
|
19281
19583
|
init_claude_history();
|
|
19282
19584
|
function readJsonlEntries(file) {
|
|
19283
|
-
const raw =
|
|
19585
|
+
const raw = import_node_fs17.default.readFileSync(file, "utf8");
|
|
19284
19586
|
const out = [];
|
|
19285
19587
|
for (const line of raw.split("\n")) {
|
|
19286
19588
|
const t = line.trim();
|
|
@@ -19293,10 +19595,10 @@ function readJsonlEntries(file) {
|
|
|
19293
19595
|
return out;
|
|
19294
19596
|
}
|
|
19295
19597
|
function forkSession(input) {
|
|
19296
|
-
const baseDir = input.baseDir ??
|
|
19297
|
-
const projectDir =
|
|
19298
|
-
const sourceFile =
|
|
19299
|
-
if (!
|
|
19598
|
+
const baseDir = input.baseDir ?? import_node_path16.default.join(import_node_os10.default.homedir(), ".claude");
|
|
19599
|
+
const projectDir = import_node_path16.default.join(baseDir, "projects", cwdToHashDir(input.cwd));
|
|
19600
|
+
const sourceFile = import_node_path16.default.join(projectDir, `${input.toolSessionId}.jsonl`);
|
|
19601
|
+
if (!import_node_fs17.default.existsSync(sourceFile)) {
|
|
19300
19602
|
throw new Error(`fork: source transcript not found: ${sourceFile}`);
|
|
19301
19603
|
}
|
|
19302
19604
|
const entries = readJsonlEntries(sourceFile);
|
|
@@ -19326,9 +19628,9 @@ function forkSession(input) {
|
|
|
19326
19628
|
}
|
|
19327
19629
|
forkedLines.push(JSON.stringify(forked));
|
|
19328
19630
|
}
|
|
19329
|
-
const forkedFilePath =
|
|
19330
|
-
|
|
19331
|
-
|
|
19631
|
+
const forkedFilePath = import_node_path16.default.join(projectDir, `${forkedToolSessionId}.jsonl`);
|
|
19632
|
+
import_node_fs17.default.mkdirSync(projectDir, { recursive: true });
|
|
19633
|
+
import_node_fs17.default.writeFileSync(forkedFilePath, forkedLines.join("\n") + "\n", { mode: 384 });
|
|
19332
19634
|
return { forkedToolSessionId, forkedFilePath };
|
|
19333
19635
|
}
|
|
19334
19636
|
|
|
@@ -19570,7 +19872,7 @@ function buildHistoryHandlers(deps) {
|
|
|
19570
19872
|
// src/handlers/workspace.ts
|
|
19571
19873
|
init_protocol();
|
|
19572
19874
|
function buildWorkspaceHandlers(deps) {
|
|
19573
|
-
const { workspace, skills } = deps;
|
|
19875
|
+
const { workspace, skills, agents } = deps;
|
|
19574
19876
|
const list = async (frame) => {
|
|
19575
19877
|
const args = WorkspaceListArgs.parse(frame);
|
|
19576
19878
|
const res = workspace.list(args);
|
|
@@ -19586,10 +19888,16 @@ function buildWorkspaceHandlers(deps) {
|
|
|
19586
19888
|
const list2 = skills.list(args);
|
|
19587
19889
|
return { response: { type: "skills:list", skills: list2 } };
|
|
19588
19890
|
};
|
|
19891
|
+
const agentsList = async (frame) => {
|
|
19892
|
+
const args = AgentsListArgs.parse(frame);
|
|
19893
|
+
const list2 = agents.list(args);
|
|
19894
|
+
return { response: { type: "agents:list", agents: list2 } };
|
|
19895
|
+
};
|
|
19589
19896
|
return {
|
|
19590
19897
|
"workspace:list": list,
|
|
19591
19898
|
"workspace:read": read,
|
|
19592
|
-
"skills:list": skillsList
|
|
19899
|
+
"skills:list": skillsList,
|
|
19900
|
+
"agents:list": agentsList
|
|
19593
19901
|
};
|
|
19594
19902
|
}
|
|
19595
19903
|
|
|
@@ -19598,9 +19906,9 @@ init_protocol();
|
|
|
19598
19906
|
|
|
19599
19907
|
// src/workspace/git.ts
|
|
19600
19908
|
var import_node_child_process5 = require("child_process");
|
|
19601
|
-
var
|
|
19602
|
-
var
|
|
19603
|
-
var
|
|
19909
|
+
var import_node_fs18 = __toESM(require("fs"), 1);
|
|
19910
|
+
var import_node_os11 = __toESM(require("os"), 1);
|
|
19911
|
+
var import_node_path17 = __toESM(require("path"), 1);
|
|
19604
19912
|
var import_node_util = require("util");
|
|
19605
19913
|
var pexec = (0, import_node_util.promisify)(import_node_child_process5.execFile);
|
|
19606
19914
|
function formatChildProcessError(err) {
|
|
@@ -19615,9 +19923,9 @@ function formatChildProcessError(err) {
|
|
|
19615
19923
|
return e.message ?? "unknown error";
|
|
19616
19924
|
}
|
|
19617
19925
|
function normalizePath(p) {
|
|
19618
|
-
const resolved =
|
|
19926
|
+
const resolved = import_node_path17.default.resolve(p);
|
|
19619
19927
|
try {
|
|
19620
|
-
return
|
|
19928
|
+
return import_node_fs18.default.realpathSync(resolved);
|
|
19621
19929
|
} catch {
|
|
19622
19930
|
return resolved;
|
|
19623
19931
|
}
|
|
@@ -19704,7 +20012,7 @@ function sanitizeLabel(raw) {
|
|
|
19704
20012
|
function computePrefix() {
|
|
19705
20013
|
let username;
|
|
19706
20014
|
try {
|
|
19707
|
-
username =
|
|
20015
|
+
username = import_node_os11.default.userInfo().username;
|
|
19708
20016
|
} catch {
|
|
19709
20017
|
username = void 0;
|
|
19710
20018
|
}
|
|
@@ -19718,13 +20026,13 @@ function flattenToDirName(branch) {
|
|
|
19718
20026
|
}
|
|
19719
20027
|
function encodeClaudeProjectDir(absPath) {
|
|
19720
20028
|
if (!absPath || typeof absPath !== "string") return "";
|
|
19721
|
-
let canonical =
|
|
20029
|
+
let canonical = import_node_path17.default.resolve(absPath);
|
|
19722
20030
|
try {
|
|
19723
|
-
canonical =
|
|
20031
|
+
canonical = import_node_fs18.default.realpathSync(canonical);
|
|
19724
20032
|
} catch {
|
|
19725
20033
|
try {
|
|
19726
|
-
const parent =
|
|
19727
|
-
canonical =
|
|
20034
|
+
const parent = import_node_fs18.default.realpathSync(import_node_path17.default.dirname(canonical));
|
|
20035
|
+
canonical = import_node_path17.default.join(parent, import_node_path17.default.basename(canonical));
|
|
19728
20036
|
} catch {
|
|
19729
20037
|
}
|
|
19730
20038
|
}
|
|
@@ -19748,11 +20056,11 @@ async function createWorktree(input) {
|
|
|
19748
20056
|
if (!isGitRoot) {
|
|
19749
20057
|
throw new Error(`\u76EE\u5F55 ${cwd} \u4E0D\u662F git repo \u6839`);
|
|
19750
20058
|
}
|
|
19751
|
-
const parent =
|
|
19752
|
-
if (parent === "/" || parent ===
|
|
20059
|
+
const parent = import_node_path17.default.dirname(import_node_path17.default.resolve(cwd));
|
|
20060
|
+
if (parent === "/" || parent === import_node_path17.default.resolve(cwd)) {
|
|
19753
20061
|
throw new Error("repo \u5728\u78C1\u76D8\u6839\u76EE\u5F55\uFF0C\u65E0\u6CD5\u5728\u540C\u7EA7\u521B\u5EFA worktree");
|
|
19754
20062
|
}
|
|
19755
|
-
const worktreeRoot =
|
|
20063
|
+
const worktreeRoot = import_node_path17.default.join(parent, dirName);
|
|
19756
20064
|
try {
|
|
19757
20065
|
await pexec("git", ["-C", cwd, "rev-parse", "--verify", `refs/heads/${baseBranch}`], {
|
|
19758
20066
|
timeout: 3e3
|
|
@@ -19769,7 +20077,7 @@ async function createWorktree(input) {
|
|
|
19769
20077
|
const msg = err.message;
|
|
19770
20078
|
if (msg.startsWith("\u5206\u652F ")) throw err;
|
|
19771
20079
|
}
|
|
19772
|
-
if (
|
|
20080
|
+
if (import_node_fs18.default.existsSync(worktreeRoot)) {
|
|
19773
20081
|
throw new Error(`\u76EE\u5F55 ${worktreeRoot} \u5DF2\u5B58\u5728\uFF0C\u8BF7\u6362\u4E00\u4E2A label \u6216\u6E05\u7406\u540E\u91CD\u8BD5`);
|
|
19774
20082
|
}
|
|
19775
20083
|
try {
|
|
@@ -19797,8 +20105,8 @@ async function removeWorktree(input) {
|
|
|
19797
20105
|
);
|
|
19798
20106
|
const gitCommonDir = stdout.trim();
|
|
19799
20107
|
if (!gitCommonDir) throw new Error("empty git-common-dir");
|
|
19800
|
-
const absGitCommon =
|
|
19801
|
-
repoRoot =
|
|
20108
|
+
const absGitCommon = import_node_path17.default.isAbsolute(gitCommonDir) ? gitCommonDir : import_node_path17.default.resolve(worktreeRoot, gitCommonDir);
|
|
20109
|
+
repoRoot = import_node_path17.default.dirname(absGitCommon);
|
|
19802
20110
|
} catch {
|
|
19803
20111
|
repoRoot = null;
|
|
19804
20112
|
}
|
|
@@ -19810,7 +20118,7 @@ async function removeWorktree(input) {
|
|
|
19810
20118
|
} catch (err) {
|
|
19811
20119
|
const stderr = err.stderr ?? "";
|
|
19812
20120
|
const lower = stderr.toLowerCase();
|
|
19813
|
-
const vanished = lower.includes("not a working tree") || lower.includes("is not a working tree") || !
|
|
20121
|
+
const vanished = lower.includes("not a working tree") || lower.includes("is not a working tree") || !import_node_fs18.default.existsSync(worktreeRoot);
|
|
19814
20122
|
if (!vanished) {
|
|
19815
20123
|
throw new Error(`\u6E05\u7406 worktree \u5931\u8D25\uFF1A${formatChildProcessError(err)}`);
|
|
19816
20124
|
}
|
|
@@ -19829,10 +20137,10 @@ async function removeWorktree(input) {
|
|
|
19829
20137
|
try {
|
|
19830
20138
|
const encoded = encodeClaudeProjectDir(worktreeRoot);
|
|
19831
20139
|
if (encoded) {
|
|
19832
|
-
const projectsRoot =
|
|
19833
|
-
const target =
|
|
19834
|
-
if (target.startsWith(projectsRoot +
|
|
19835
|
-
|
|
20140
|
+
const projectsRoot = import_node_path17.default.join(import_node_os11.default.homedir(), ".claude", "projects");
|
|
20141
|
+
const target = import_node_path17.default.resolve(projectsRoot, encoded);
|
|
20142
|
+
if (target.startsWith(projectsRoot + import_node_path17.default.sep) && target !== projectsRoot) {
|
|
20143
|
+
import_node_fs18.default.rmSync(target, { recursive: true, force: true });
|
|
19836
20144
|
}
|
|
19837
20145
|
}
|
|
19838
20146
|
} catch {
|
|
@@ -19904,7 +20212,7 @@ function buildCapabilitiesHandlers(deps) {
|
|
|
19904
20212
|
}
|
|
19905
20213
|
|
|
19906
20214
|
// src/handlers/meta.ts
|
|
19907
|
-
var
|
|
20215
|
+
var import_node_os12 = __toESM(require("os"), 1);
|
|
19908
20216
|
init_protocol();
|
|
19909
20217
|
|
|
19910
20218
|
// src/version.ts
|
|
@@ -19926,7 +20234,7 @@ function buildReadyFrame(deps) {
|
|
|
19926
20234
|
return {
|
|
19927
20235
|
version,
|
|
19928
20236
|
protocolVersion: PROTOCOL_VERSION,
|
|
19929
|
-
hostname:
|
|
20237
|
+
hostname: import_node_os12.default.hostname(),
|
|
19930
20238
|
os: process.platform,
|
|
19931
20239
|
tools,
|
|
19932
20240
|
runningSessions: info.runningSessions,
|
|
@@ -20044,7 +20352,7 @@ function buildMethodHandlers(deps) {
|
|
|
20044
20352
|
async function startDaemon(config) {
|
|
20045
20353
|
const logger = createLogger({
|
|
20046
20354
|
level: config.logLevel,
|
|
20047
|
-
file:
|
|
20355
|
+
file: import_node_path18.default.join(config.dataDir, "clawd.log")
|
|
20048
20356
|
});
|
|
20049
20357
|
logger.info("starting clawd", { version, config: { port: config.port, host: config.host, dataDir: config.dataDir } });
|
|
20050
20358
|
const stateMgr = new StateFileManager({ dataDir: config.dataDir });
|
|
@@ -20077,6 +20385,7 @@ async function startDaemon(config) {
|
|
|
20077
20385
|
const store = new SessionStore({ dataDir: config.dataDir });
|
|
20078
20386
|
const workspace = new WorkspaceBrowser();
|
|
20079
20387
|
const skills = new SkillsScanner();
|
|
20388
|
+
const agents = new AgentsScanner();
|
|
20080
20389
|
const history = new ClaudeHistoryReader();
|
|
20081
20390
|
let transport = null;
|
|
20082
20391
|
const manager = new SessionManager({
|
|
@@ -20085,7 +20394,7 @@ async function startDaemon(config) {
|
|
|
20085
20394
|
getAdapter,
|
|
20086
20395
|
historyReader: history,
|
|
20087
20396
|
dataDir: config.dataDir,
|
|
20088
|
-
personaRoot:
|
|
20397
|
+
personaRoot: import_node_path18.default.join(config.dataDir, "personas"),
|
|
20089
20398
|
broadcastFrame: (frame, target) => {
|
|
20090
20399
|
if (target === "all") {
|
|
20091
20400
|
transport?.broadcastAll(frame);
|
|
@@ -20125,7 +20434,7 @@ async function startDaemon(config) {
|
|
|
20125
20434
|
manager.recordRealUserUuid({ sessionId, realUuid, text });
|
|
20126
20435
|
}
|
|
20127
20436
|
});
|
|
20128
|
-
const personaStore = new PersonaStore(
|
|
20437
|
+
const personaStore = new PersonaStore(import_node_path18.default.join(config.dataDir, "personas"));
|
|
20129
20438
|
const personaRegistry = new PersonaRegistry(personaStore);
|
|
20130
20439
|
const personaManager = new PersonaManager({
|
|
20131
20440
|
store: personaStore,
|
|
@@ -20137,6 +20446,7 @@ async function startDaemon(config) {
|
|
|
20137
20446
|
manager,
|
|
20138
20447
|
workspace,
|
|
20139
20448
|
skills,
|
|
20449
|
+
agents,
|
|
20140
20450
|
history,
|
|
20141
20451
|
observer,
|
|
20142
20452
|
getAdapter,
|
|
@@ -20257,8 +20567,8 @@ async function startDaemon(config) {
|
|
|
20257
20567
|
const lines = [
|
|
20258
20568
|
`Tunnel: ${r.url}`,
|
|
20259
20569
|
...resolvedAuthToken ? [`Connect: ${connectUrl}`] : [],
|
|
20260
|
-
`Frpc config: ${
|
|
20261
|
-
`Frpc log: ${
|
|
20570
|
+
`Frpc config: ${import_node_path18.default.join(config.dataDir, "frpc.toml")}`,
|
|
20571
|
+
`Frpc log: ${import_node_path18.default.join(config.dataDir, "frpc.log")}`
|
|
20262
20572
|
];
|
|
20263
20573
|
const width = Math.max(...lines.map((l) => l.length));
|
|
20264
20574
|
const bar = "\u2550".repeat(width + 4);
|
|
@@ -20271,8 +20581,8 @@ ${bar}
|
|
|
20271
20581
|
|
|
20272
20582
|
`);
|
|
20273
20583
|
try {
|
|
20274
|
-
const connectPath =
|
|
20275
|
-
|
|
20584
|
+
const connectPath = import_node_path18.default.join(config.dataDir, "connect.txt");
|
|
20585
|
+
import_node_fs19.default.writeFileSync(connectPath, lines.join("\n") + "\n", { mode: 384 });
|
|
20276
20586
|
} catch {
|
|
20277
20587
|
}
|
|
20278
20588
|
} catch (err) {
|