@clawos-dev/clawd 0.2.202 → 0.2.203-beta.406.d63010a
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
CHANGED
|
@@ -742,8 +742,8 @@ var init_parseUtil = __esm({
|
|
|
742
742
|
init_errors2();
|
|
743
743
|
init_en();
|
|
744
744
|
makeIssue = (params) => {
|
|
745
|
-
const { data, path:
|
|
746
|
-
const fullPath = [...
|
|
745
|
+
const { data, path: path77, errorMaps, issueData } = params;
|
|
746
|
+
const fullPath = [...path77, ...issueData.path || []];
|
|
747
747
|
const fullIssue = {
|
|
748
748
|
...issueData,
|
|
749
749
|
path: fullPath
|
|
@@ -1054,11 +1054,11 @@ var init_types = __esm({
|
|
|
1054
1054
|
init_parseUtil();
|
|
1055
1055
|
init_util();
|
|
1056
1056
|
ParseInputLazyPath = class {
|
|
1057
|
-
constructor(parent, value,
|
|
1057
|
+
constructor(parent, value, path77, key) {
|
|
1058
1058
|
this._cachedPath = [];
|
|
1059
1059
|
this.parent = parent;
|
|
1060
1060
|
this.data = value;
|
|
1061
|
-
this._path =
|
|
1061
|
+
this._path = path77;
|
|
1062
1062
|
this._key = key;
|
|
1063
1063
|
}
|
|
1064
1064
|
get path() {
|
|
@@ -6449,8 +6449,8 @@ var require_req = __commonJS({
|
|
|
6449
6449
|
if (req.originalUrl) {
|
|
6450
6450
|
_req.url = req.originalUrl;
|
|
6451
6451
|
} else {
|
|
6452
|
-
const
|
|
6453
|
-
_req.url = typeof
|
|
6452
|
+
const path77 = req.path;
|
|
6453
|
+
_req.url = typeof path77 === "string" ? path77 : req.url ? req.url.path || req.url : void 0;
|
|
6454
6454
|
}
|
|
6455
6455
|
if (req.query) {
|
|
6456
6456
|
_req.query = req.query;
|
|
@@ -6615,14 +6615,14 @@ var require_redact = __commonJS({
|
|
|
6615
6615
|
}
|
|
6616
6616
|
return obj;
|
|
6617
6617
|
}
|
|
6618
|
-
function parsePath(
|
|
6618
|
+
function parsePath(path77) {
|
|
6619
6619
|
const parts = [];
|
|
6620
6620
|
let current = "";
|
|
6621
6621
|
let inBrackets = false;
|
|
6622
6622
|
let inQuotes = false;
|
|
6623
6623
|
let quoteChar = "";
|
|
6624
|
-
for (let i = 0; i <
|
|
6625
|
-
const char =
|
|
6624
|
+
for (let i = 0; i < path77.length; i++) {
|
|
6625
|
+
const char = path77[i];
|
|
6626
6626
|
if (!inBrackets && char === ".") {
|
|
6627
6627
|
if (current) {
|
|
6628
6628
|
parts.push(current);
|
|
@@ -6753,10 +6753,10 @@ var require_redact = __commonJS({
|
|
|
6753
6753
|
return current;
|
|
6754
6754
|
}
|
|
6755
6755
|
function redactPaths(obj, paths, censor, remove = false) {
|
|
6756
|
-
for (const
|
|
6757
|
-
const parts = parsePath(
|
|
6756
|
+
for (const path77 of paths) {
|
|
6757
|
+
const parts = parsePath(path77);
|
|
6758
6758
|
if (parts.includes("*")) {
|
|
6759
|
-
redactWildcardPath(obj, parts, censor,
|
|
6759
|
+
redactWildcardPath(obj, parts, censor, path77, remove);
|
|
6760
6760
|
} else {
|
|
6761
6761
|
if (remove) {
|
|
6762
6762
|
removeKey(obj, parts);
|
|
@@ -6841,8 +6841,8 @@ var require_redact = __commonJS({
|
|
|
6841
6841
|
}
|
|
6842
6842
|
} else {
|
|
6843
6843
|
if (afterWildcard.includes("*")) {
|
|
6844
|
-
const wrappedCensor = typeof censor === "function" ? (value,
|
|
6845
|
-
const fullPath = [...pathArray.slice(0, pathLength), ...
|
|
6844
|
+
const wrappedCensor = typeof censor === "function" ? (value, path77) => {
|
|
6845
|
+
const fullPath = [...pathArray.slice(0, pathLength), ...path77];
|
|
6846
6846
|
return censor(value, fullPath);
|
|
6847
6847
|
} : censor;
|
|
6848
6848
|
redactWildcardPath(current, afterWildcard, wrappedCensor, originalPath, remove);
|
|
@@ -6877,8 +6877,8 @@ var require_redact = __commonJS({
|
|
|
6877
6877
|
return null;
|
|
6878
6878
|
}
|
|
6879
6879
|
const pathStructure = /* @__PURE__ */ new Map();
|
|
6880
|
-
for (const
|
|
6881
|
-
const parts = parsePath(
|
|
6880
|
+
for (const path77 of pathsToClone) {
|
|
6881
|
+
const parts = parsePath(path77);
|
|
6882
6882
|
let current = pathStructure;
|
|
6883
6883
|
for (let i = 0; i < parts.length; i++) {
|
|
6884
6884
|
const part = parts[i];
|
|
@@ -6930,24 +6930,24 @@ var require_redact = __commonJS({
|
|
|
6930
6930
|
}
|
|
6931
6931
|
return cloneSelectively(obj, pathStructure);
|
|
6932
6932
|
}
|
|
6933
|
-
function validatePath(
|
|
6934
|
-
if (typeof
|
|
6933
|
+
function validatePath(path77) {
|
|
6934
|
+
if (typeof path77 !== "string") {
|
|
6935
6935
|
throw new Error("Paths must be (non-empty) strings");
|
|
6936
6936
|
}
|
|
6937
|
-
if (
|
|
6937
|
+
if (path77 === "") {
|
|
6938
6938
|
throw new Error("Invalid redaction path ()");
|
|
6939
6939
|
}
|
|
6940
|
-
if (
|
|
6941
|
-
throw new Error(`Invalid redaction path (${
|
|
6940
|
+
if (path77.includes("..")) {
|
|
6941
|
+
throw new Error(`Invalid redaction path (${path77})`);
|
|
6942
6942
|
}
|
|
6943
|
-
if (
|
|
6944
|
-
throw new Error(`Invalid redaction path (${
|
|
6943
|
+
if (path77.includes(",")) {
|
|
6944
|
+
throw new Error(`Invalid redaction path (${path77})`);
|
|
6945
6945
|
}
|
|
6946
6946
|
let bracketCount = 0;
|
|
6947
6947
|
let inQuotes = false;
|
|
6948
6948
|
let quoteChar = "";
|
|
6949
|
-
for (let i = 0; i <
|
|
6950
|
-
const char =
|
|
6949
|
+
for (let i = 0; i < path77.length; i++) {
|
|
6950
|
+
const char = path77[i];
|
|
6951
6951
|
if ((char === '"' || char === "'") && bracketCount > 0) {
|
|
6952
6952
|
if (!inQuotes) {
|
|
6953
6953
|
inQuotes = true;
|
|
@@ -6961,20 +6961,20 @@ var require_redact = __commonJS({
|
|
|
6961
6961
|
} else if (char === "]" && !inQuotes) {
|
|
6962
6962
|
bracketCount--;
|
|
6963
6963
|
if (bracketCount < 0) {
|
|
6964
|
-
throw new Error(`Invalid redaction path (${
|
|
6964
|
+
throw new Error(`Invalid redaction path (${path77})`);
|
|
6965
6965
|
}
|
|
6966
6966
|
}
|
|
6967
6967
|
}
|
|
6968
6968
|
if (bracketCount !== 0) {
|
|
6969
|
-
throw new Error(`Invalid redaction path (${
|
|
6969
|
+
throw new Error(`Invalid redaction path (${path77})`);
|
|
6970
6970
|
}
|
|
6971
6971
|
}
|
|
6972
6972
|
function validatePaths(paths) {
|
|
6973
6973
|
if (!Array.isArray(paths)) {
|
|
6974
6974
|
throw new TypeError("paths must be an array");
|
|
6975
6975
|
}
|
|
6976
|
-
for (const
|
|
6977
|
-
validatePath(
|
|
6976
|
+
for (const path77 of paths) {
|
|
6977
|
+
validatePath(path77);
|
|
6978
6978
|
}
|
|
6979
6979
|
}
|
|
6980
6980
|
function slowRedact(options = {}) {
|
|
@@ -7142,8 +7142,8 @@ var require_redaction = __commonJS({
|
|
|
7142
7142
|
if (shape[k2] === null) {
|
|
7143
7143
|
o[k2] = (value) => topCensor(value, [k2]);
|
|
7144
7144
|
} else {
|
|
7145
|
-
const wrappedCensor = typeof censor === "function" ? (value,
|
|
7146
|
-
return censor(value, [k2, ...
|
|
7145
|
+
const wrappedCensor = typeof censor === "function" ? (value, path77) => {
|
|
7146
|
+
return censor(value, [k2, ...path77]);
|
|
7147
7147
|
} : censor;
|
|
7148
7148
|
o[k2] = Redact({
|
|
7149
7149
|
paths: shape[k2],
|
|
@@ -7361,10 +7361,10 @@ var require_atomic_sleep = __commonJS({
|
|
|
7361
7361
|
var require_sonic_boom = __commonJS({
|
|
7362
7362
|
"../node_modules/.pnpm/sonic-boom@4.2.1/node_modules/sonic-boom/index.js"(exports2, module2) {
|
|
7363
7363
|
"use strict";
|
|
7364
|
-
var
|
|
7364
|
+
var fs70 = require("fs");
|
|
7365
7365
|
var EventEmitter3 = require("events");
|
|
7366
7366
|
var inherits = require("util").inherits;
|
|
7367
|
-
var
|
|
7367
|
+
var path77 = require("path");
|
|
7368
7368
|
var sleep2 = require_atomic_sleep();
|
|
7369
7369
|
var assert = require("assert");
|
|
7370
7370
|
var BUSY_WRITE_TIMEOUT = 100;
|
|
@@ -7418,20 +7418,20 @@ var require_sonic_boom = __commonJS({
|
|
|
7418
7418
|
const mode = sonic.mode;
|
|
7419
7419
|
if (sonic.sync) {
|
|
7420
7420
|
try {
|
|
7421
|
-
if (sonic.mkdir)
|
|
7422
|
-
const fd =
|
|
7421
|
+
if (sonic.mkdir) fs70.mkdirSync(path77.dirname(file), { recursive: true });
|
|
7422
|
+
const fd = fs70.openSync(file, flags, mode);
|
|
7423
7423
|
fileOpened(null, fd);
|
|
7424
7424
|
} catch (err) {
|
|
7425
7425
|
fileOpened(err);
|
|
7426
7426
|
throw err;
|
|
7427
7427
|
}
|
|
7428
7428
|
} else if (sonic.mkdir) {
|
|
7429
|
-
|
|
7429
|
+
fs70.mkdir(path77.dirname(file), { recursive: true }, (err) => {
|
|
7430
7430
|
if (err) return fileOpened(err);
|
|
7431
|
-
|
|
7431
|
+
fs70.open(file, flags, mode, fileOpened);
|
|
7432
7432
|
});
|
|
7433
7433
|
} else {
|
|
7434
|
-
|
|
7434
|
+
fs70.open(file, flags, mode, fileOpened);
|
|
7435
7435
|
}
|
|
7436
7436
|
}
|
|
7437
7437
|
function SonicBoom(opts) {
|
|
@@ -7472,8 +7472,8 @@ var require_sonic_boom = __commonJS({
|
|
|
7472
7472
|
this.flush = flushBuffer;
|
|
7473
7473
|
this.flushSync = flushBufferSync;
|
|
7474
7474
|
this._actualWrite = actualWriteBuffer;
|
|
7475
|
-
fsWriteSync = () =>
|
|
7476
|
-
fsWrite = () =>
|
|
7475
|
+
fsWriteSync = () => fs70.writeSync(this.fd, this._writingBuf);
|
|
7476
|
+
fsWrite = () => fs70.write(this.fd, this._writingBuf, this.release);
|
|
7477
7477
|
} else if (contentMode === void 0 || contentMode === kContentModeUtf8) {
|
|
7478
7478
|
this._writingBuf = "";
|
|
7479
7479
|
this.write = write;
|
|
@@ -7482,15 +7482,15 @@ var require_sonic_boom = __commonJS({
|
|
|
7482
7482
|
this._actualWrite = actualWrite;
|
|
7483
7483
|
fsWriteSync = () => {
|
|
7484
7484
|
if (Buffer.isBuffer(this._writingBuf)) {
|
|
7485
|
-
return
|
|
7485
|
+
return fs70.writeSync(this.fd, this._writingBuf);
|
|
7486
7486
|
}
|
|
7487
|
-
return
|
|
7487
|
+
return fs70.writeSync(this.fd, this._writingBuf, "utf8");
|
|
7488
7488
|
};
|
|
7489
7489
|
fsWrite = () => {
|
|
7490
7490
|
if (Buffer.isBuffer(this._writingBuf)) {
|
|
7491
|
-
return
|
|
7491
|
+
return fs70.write(this.fd, this._writingBuf, this.release);
|
|
7492
7492
|
}
|
|
7493
|
-
return
|
|
7493
|
+
return fs70.write(this.fd, this._writingBuf, "utf8", this.release);
|
|
7494
7494
|
};
|
|
7495
7495
|
} else {
|
|
7496
7496
|
throw new Error(`SonicBoom supports "${kContentModeUtf8}" and "${kContentModeBuffer}", but passed ${contentMode}`);
|
|
@@ -7547,7 +7547,7 @@ var require_sonic_boom = __commonJS({
|
|
|
7547
7547
|
}
|
|
7548
7548
|
}
|
|
7549
7549
|
if (this._fsync) {
|
|
7550
|
-
|
|
7550
|
+
fs70.fsyncSync(this.fd);
|
|
7551
7551
|
}
|
|
7552
7552
|
const len = this._len;
|
|
7553
7553
|
if (this._reopening) {
|
|
@@ -7661,7 +7661,7 @@ var require_sonic_boom = __commonJS({
|
|
|
7661
7661
|
const onDrain = () => {
|
|
7662
7662
|
if (!this._fsync) {
|
|
7663
7663
|
try {
|
|
7664
|
-
|
|
7664
|
+
fs70.fsync(this.fd, (err) => {
|
|
7665
7665
|
this._flushPending = false;
|
|
7666
7666
|
cb(err);
|
|
7667
7667
|
});
|
|
@@ -7763,7 +7763,7 @@ var require_sonic_boom = __commonJS({
|
|
|
7763
7763
|
const fd = this.fd;
|
|
7764
7764
|
this.once("ready", () => {
|
|
7765
7765
|
if (fd !== this.fd) {
|
|
7766
|
-
|
|
7766
|
+
fs70.close(fd, (err) => {
|
|
7767
7767
|
if (err) {
|
|
7768
7768
|
return this.emit("error", err);
|
|
7769
7769
|
}
|
|
@@ -7812,7 +7812,7 @@ var require_sonic_boom = __commonJS({
|
|
|
7812
7812
|
buf = this._bufs[0];
|
|
7813
7813
|
}
|
|
7814
7814
|
try {
|
|
7815
|
-
const n = Buffer.isBuffer(buf) ?
|
|
7815
|
+
const n = Buffer.isBuffer(buf) ? fs70.writeSync(this.fd, buf) : fs70.writeSync(this.fd, buf, "utf8");
|
|
7816
7816
|
const releasedBufObj = releaseWritingBuf(buf, this._len, n);
|
|
7817
7817
|
buf = releasedBufObj.writingBuf;
|
|
7818
7818
|
this._len = releasedBufObj.len;
|
|
@@ -7828,7 +7828,7 @@ var require_sonic_boom = __commonJS({
|
|
|
7828
7828
|
}
|
|
7829
7829
|
}
|
|
7830
7830
|
try {
|
|
7831
|
-
|
|
7831
|
+
fs70.fsyncSync(this.fd);
|
|
7832
7832
|
} catch {
|
|
7833
7833
|
}
|
|
7834
7834
|
}
|
|
@@ -7849,7 +7849,7 @@ var require_sonic_boom = __commonJS({
|
|
|
7849
7849
|
buf = mergeBuf(this._bufs[0], this._lens[0]);
|
|
7850
7850
|
}
|
|
7851
7851
|
try {
|
|
7852
|
-
const n =
|
|
7852
|
+
const n = fs70.writeSync(this.fd, buf);
|
|
7853
7853
|
buf = buf.subarray(n);
|
|
7854
7854
|
this._len = Math.max(this._len - n, 0);
|
|
7855
7855
|
if (buf.length <= 0) {
|
|
@@ -7877,13 +7877,13 @@ var require_sonic_boom = __commonJS({
|
|
|
7877
7877
|
this._writingBuf = this._writingBuf.length ? this._writingBuf : this._bufs.shift() || "";
|
|
7878
7878
|
if (this.sync) {
|
|
7879
7879
|
try {
|
|
7880
|
-
const written = Buffer.isBuffer(this._writingBuf) ?
|
|
7880
|
+
const written = Buffer.isBuffer(this._writingBuf) ? fs70.writeSync(this.fd, this._writingBuf) : fs70.writeSync(this.fd, this._writingBuf, "utf8");
|
|
7881
7881
|
release(null, written);
|
|
7882
7882
|
} catch (err) {
|
|
7883
7883
|
release(err);
|
|
7884
7884
|
}
|
|
7885
7885
|
} else {
|
|
7886
|
-
|
|
7886
|
+
fs70.write(this.fd, this._writingBuf, release);
|
|
7887
7887
|
}
|
|
7888
7888
|
}
|
|
7889
7889
|
function actualWriteBuffer() {
|
|
@@ -7892,7 +7892,7 @@ var require_sonic_boom = __commonJS({
|
|
|
7892
7892
|
this._writingBuf = this._writingBuf.length ? this._writingBuf : mergeBuf(this._bufs.shift(), this._lens.shift());
|
|
7893
7893
|
if (this.sync) {
|
|
7894
7894
|
try {
|
|
7895
|
-
const written =
|
|
7895
|
+
const written = fs70.writeSync(this.fd, this._writingBuf);
|
|
7896
7896
|
release(null, written);
|
|
7897
7897
|
} catch (err) {
|
|
7898
7898
|
release(err);
|
|
@@ -7901,7 +7901,7 @@ var require_sonic_boom = __commonJS({
|
|
|
7901
7901
|
if (kCopyBuffer) {
|
|
7902
7902
|
this._writingBuf = Buffer.from(this._writingBuf);
|
|
7903
7903
|
}
|
|
7904
|
-
|
|
7904
|
+
fs70.write(this.fd, this._writingBuf, release);
|
|
7905
7905
|
}
|
|
7906
7906
|
}
|
|
7907
7907
|
function actualClose(sonic) {
|
|
@@ -7917,12 +7917,12 @@ var require_sonic_boom = __commonJS({
|
|
|
7917
7917
|
sonic._lens = [];
|
|
7918
7918
|
assert(typeof sonic.fd === "number", `sonic.fd must be a number, got ${typeof sonic.fd}`);
|
|
7919
7919
|
try {
|
|
7920
|
-
|
|
7920
|
+
fs70.fsync(sonic.fd, closeWrapped);
|
|
7921
7921
|
} catch {
|
|
7922
7922
|
}
|
|
7923
7923
|
function closeWrapped() {
|
|
7924
7924
|
if (sonic.fd !== 1 && sonic.fd !== 2) {
|
|
7925
|
-
|
|
7925
|
+
fs70.close(sonic.fd, done);
|
|
7926
7926
|
} else {
|
|
7927
7927
|
done();
|
|
7928
7928
|
}
|
|
@@ -11057,11 +11057,11 @@ var init_lib = __esm({
|
|
|
11057
11057
|
}
|
|
11058
11058
|
}
|
|
11059
11059
|
},
|
|
11060
|
-
addToPath: function addToPath(
|
|
11061
|
-
var last =
|
|
11060
|
+
addToPath: function addToPath(path77, added, removed, oldPosInc, options) {
|
|
11061
|
+
var last = path77.lastComponent;
|
|
11062
11062
|
if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) {
|
|
11063
11063
|
return {
|
|
11064
|
-
oldPos:
|
|
11064
|
+
oldPos: path77.oldPos + oldPosInc,
|
|
11065
11065
|
lastComponent: {
|
|
11066
11066
|
count: last.count + 1,
|
|
11067
11067
|
added,
|
|
@@ -11071,7 +11071,7 @@ var init_lib = __esm({
|
|
|
11071
11071
|
};
|
|
11072
11072
|
} else {
|
|
11073
11073
|
return {
|
|
11074
|
-
oldPos:
|
|
11074
|
+
oldPos: path77.oldPos + oldPosInc,
|
|
11075
11075
|
lastComponent: {
|
|
11076
11076
|
count: 1,
|
|
11077
11077
|
added,
|
|
@@ -11537,10 +11537,10 @@ function attachmentToHistoryMessage(o, ts) {
|
|
|
11537
11537
|
const memories = raw.map((m2) => {
|
|
11538
11538
|
if (!m2 || typeof m2 !== "object") return null;
|
|
11539
11539
|
const rec3 = m2;
|
|
11540
|
-
const
|
|
11540
|
+
const path77 = typeof rec3.path === "string" ? rec3.path : null;
|
|
11541
11541
|
const content = typeof rec3.content === "string" ? rec3.content : null;
|
|
11542
|
-
if (!
|
|
11543
|
-
const entry = { path:
|
|
11542
|
+
if (!path77 || content == null) return null;
|
|
11543
|
+
const entry = { path: path77, content };
|
|
11544
11544
|
if (typeof rec3.mtimeMs === "number") entry.mtimeMs = rec3.mtimeMs;
|
|
11545
11545
|
return entry;
|
|
11546
11546
|
}).filter((m2) => m2 !== null);
|
|
@@ -12360,10 +12360,10 @@ function parseAttachment(obj) {
|
|
|
12360
12360
|
const memories = raw.map((m2) => {
|
|
12361
12361
|
if (!m2 || typeof m2 !== "object") return null;
|
|
12362
12362
|
const rec3 = m2;
|
|
12363
|
-
const
|
|
12363
|
+
const path77 = typeof rec3.path === "string" ? rec3.path : null;
|
|
12364
12364
|
const content = typeof rec3.content === "string" ? rec3.content : null;
|
|
12365
|
-
if (!
|
|
12366
|
-
const out = { path:
|
|
12365
|
+
if (!path77 || content == null) return null;
|
|
12366
|
+
const out = { path: path77, content };
|
|
12367
12367
|
if (typeof rec3.mtimeMs === "number") out.mtimeMs = rec3.mtimeMs;
|
|
12368
12368
|
return out;
|
|
12369
12369
|
}).filter((m2) => m2 !== null);
|
|
@@ -33460,8 +33460,8 @@ var require_utils = __commonJS({
|
|
|
33460
33460
|
var result = transform[inputType][outputType](input);
|
|
33461
33461
|
return result;
|
|
33462
33462
|
};
|
|
33463
|
-
exports2.resolve = function(
|
|
33464
|
-
var parts =
|
|
33463
|
+
exports2.resolve = function(path77) {
|
|
33464
|
+
var parts = path77.split("/");
|
|
33465
33465
|
var result = [];
|
|
33466
33466
|
for (var index = 0; index < parts.length; index++) {
|
|
33467
33467
|
var part = parts[index];
|
|
@@ -39314,18 +39314,18 @@ var require_object = __commonJS({
|
|
|
39314
39314
|
var object = new ZipObject(name, zipObjectContent, o);
|
|
39315
39315
|
this.files[name] = object;
|
|
39316
39316
|
};
|
|
39317
|
-
var parentFolder = function(
|
|
39318
|
-
if (
|
|
39319
|
-
|
|
39317
|
+
var parentFolder = function(path77) {
|
|
39318
|
+
if (path77.slice(-1) === "/") {
|
|
39319
|
+
path77 = path77.substring(0, path77.length - 1);
|
|
39320
39320
|
}
|
|
39321
|
-
var lastSlash =
|
|
39322
|
-
return lastSlash > 0 ?
|
|
39321
|
+
var lastSlash = path77.lastIndexOf("/");
|
|
39322
|
+
return lastSlash > 0 ? path77.substring(0, lastSlash) : "";
|
|
39323
39323
|
};
|
|
39324
|
-
var forceTrailingSlash = function(
|
|
39325
|
-
if (
|
|
39326
|
-
|
|
39324
|
+
var forceTrailingSlash = function(path77) {
|
|
39325
|
+
if (path77.slice(-1) !== "/") {
|
|
39326
|
+
path77 += "/";
|
|
39327
39327
|
}
|
|
39328
|
-
return
|
|
39328
|
+
return path77;
|
|
39329
39329
|
};
|
|
39330
39330
|
var folderAdd = function(name, createFolders) {
|
|
39331
39331
|
createFolders = typeof createFolders !== "undefined" ? createFolders : defaults.createFolders;
|
|
@@ -40327,7 +40327,7 @@ var require_lib3 = __commonJS({
|
|
|
40327
40327
|
// src/run-case/recorder.ts
|
|
40328
40328
|
function startRunCaseRecorder(opts) {
|
|
40329
40329
|
const now = opts.now ?? Date.now;
|
|
40330
|
-
const dir =
|
|
40330
|
+
const dir = import_node_path64.default.dirname(opts.recordPath);
|
|
40331
40331
|
let stream = null;
|
|
40332
40332
|
let closing = false;
|
|
40333
40333
|
let closedSettled = false;
|
|
@@ -40341,8 +40341,8 @@ function startRunCaseRecorder(opts) {
|
|
|
40341
40341
|
});
|
|
40342
40342
|
const ensureStream = () => {
|
|
40343
40343
|
if (stream) return stream;
|
|
40344
|
-
|
|
40345
|
-
stream =
|
|
40344
|
+
import_node_fs51.default.mkdirSync(dir, { recursive: true });
|
|
40345
|
+
stream = import_node_fs51.default.createWriteStream(opts.recordPath, { flags: "a" });
|
|
40346
40346
|
stream.on("close", () => closedResolve());
|
|
40347
40347
|
return stream;
|
|
40348
40348
|
};
|
|
@@ -40367,12 +40367,12 @@ function startRunCaseRecorder(opts) {
|
|
|
40367
40367
|
};
|
|
40368
40368
|
return { tap, close, closed };
|
|
40369
40369
|
}
|
|
40370
|
-
var
|
|
40370
|
+
var import_node_fs51, import_node_path64;
|
|
40371
40371
|
var init_recorder = __esm({
|
|
40372
40372
|
"src/run-case/recorder.ts"() {
|
|
40373
40373
|
"use strict";
|
|
40374
|
-
|
|
40375
|
-
|
|
40374
|
+
import_node_fs51 = __toESM(require("fs"), 1);
|
|
40375
|
+
import_node_path64 = __toESM(require("path"), 1);
|
|
40376
40376
|
}
|
|
40377
40377
|
});
|
|
40378
40378
|
|
|
@@ -40415,7 +40415,7 @@ var init_wire = __esm({
|
|
|
40415
40415
|
// src/run-case/controller.ts
|
|
40416
40416
|
async function runController(opts) {
|
|
40417
40417
|
const now = opts.now ?? Date.now;
|
|
40418
|
-
const cwd = opts.cwd ?? (0,
|
|
40418
|
+
const cwd = opts.cwd ?? (0, import_node_fs52.mkdtempSync)(import_node_path65.default.join(import_node_os22.default.tmpdir(), "clawd-runcase-"));
|
|
40419
40419
|
const ownsCwd = opts.cwd === void 0;
|
|
40420
40420
|
const recorder = startRunCaseRecorder({ recordPath: opts.record, now });
|
|
40421
40421
|
const spawnCtx = { cwd };
|
|
@@ -40576,19 +40576,19 @@ async function runController(opts) {
|
|
|
40576
40576
|
if (sigintHandler) process.off("SIGINT", sigintHandler);
|
|
40577
40577
|
if (ownsCwd) {
|
|
40578
40578
|
try {
|
|
40579
|
-
(0,
|
|
40579
|
+
(0, import_node_fs52.rmSync)(cwd, { recursive: true, force: true });
|
|
40580
40580
|
} catch {
|
|
40581
40581
|
}
|
|
40582
40582
|
}
|
|
40583
40583
|
return exitCode ?? 0;
|
|
40584
40584
|
}
|
|
40585
|
-
var
|
|
40585
|
+
var import_node_fs52, import_node_os22, import_node_path65;
|
|
40586
40586
|
var init_controller = __esm({
|
|
40587
40587
|
"src/run-case/controller.ts"() {
|
|
40588
40588
|
"use strict";
|
|
40589
|
-
|
|
40589
|
+
import_node_fs52 = require("fs");
|
|
40590
40590
|
import_node_os22 = __toESM(require("os"), 1);
|
|
40591
|
-
|
|
40591
|
+
import_node_path65 = __toESM(require("path"), 1);
|
|
40592
40592
|
init_claude();
|
|
40593
40593
|
init_stdout_splitter();
|
|
40594
40594
|
init_permission_stdio();
|
|
@@ -40699,7 +40699,7 @@ async function sshRelay(argv) {
|
|
|
40699
40699
|
process.stderr.write("clawd ssh-relay: missing <peer-device-id>\n" + SSH_RELAY_HELP);
|
|
40700
40700
|
return 2;
|
|
40701
40701
|
}
|
|
40702
|
-
const dataDir = args.dataDir ??
|
|
40702
|
+
const dataDir = args.dataDir ?? import_node_path66.default.join(import_node_os23.default.homedir(), ".clawd");
|
|
40703
40703
|
const contact = findContact(dataDir, args.peerDeviceId);
|
|
40704
40704
|
if (!contact) {
|
|
40705
40705
|
process.stderr.write(`clawd ssh-relay: contact ${args.peerDeviceId} not found in ${dataDir}/contacts.json
|
|
@@ -40793,10 +40793,10 @@ function parseSshRelayArgs(argv) {
|
|
|
40793
40793
|
return out;
|
|
40794
40794
|
}
|
|
40795
40795
|
function findContact(dataDir, deviceId) {
|
|
40796
|
-
const file =
|
|
40796
|
+
const file = import_node_path66.default.join(dataDir, "contacts.json");
|
|
40797
40797
|
let raw;
|
|
40798
40798
|
try {
|
|
40799
|
-
raw =
|
|
40799
|
+
raw = import_node_fs53.default.readFileSync(file, "utf8");
|
|
40800
40800
|
} catch {
|
|
40801
40801
|
return null;
|
|
40802
40802
|
}
|
|
@@ -40814,13 +40814,13 @@ function findContact(dataDir, deviceId) {
|
|
|
40814
40814
|
}
|
|
40815
40815
|
return null;
|
|
40816
40816
|
}
|
|
40817
|
-
var
|
|
40817
|
+
var import_node_fs53, import_node_os23, import_node_path66, SSH_RELAY_HELP;
|
|
40818
40818
|
var init_sshd_cli_relay = __esm({
|
|
40819
40819
|
"src/sshd/sshd-cli-relay.ts"() {
|
|
40820
40820
|
"use strict";
|
|
40821
|
-
|
|
40821
|
+
import_node_fs53 = __toESM(require("fs"), 1);
|
|
40822
40822
|
import_node_os23 = __toESM(require("os"), 1);
|
|
40823
|
-
|
|
40823
|
+
import_node_path66 = __toESM(require("path"), 1);
|
|
40824
40824
|
init_wrapper();
|
|
40825
40825
|
init_src();
|
|
40826
40826
|
init_peer_forward();
|
|
@@ -41023,8 +41023,8 @@ Env (advanced):
|
|
|
41023
41023
|
`;
|
|
41024
41024
|
|
|
41025
41025
|
// src/index.ts
|
|
41026
|
-
var
|
|
41027
|
-
var
|
|
41026
|
+
var import_node_path63 = __toESM(require("path"), 1);
|
|
41027
|
+
var import_node_fs50 = __toESM(require("fs"), 1);
|
|
41028
41028
|
var import_node_os21 = __toESM(require("os"), 1);
|
|
41029
41029
|
|
|
41030
41030
|
// ../node_modules/.pnpm/uuid@10.0.0/node_modules/uuid/dist/esm-node/stringify.js
|
|
@@ -41735,7 +41735,7 @@ function composeGuestSandbox(base, userWorkDir, spawnCwd) {
|
|
|
41735
41735
|
fsv.denyWrite = unionArr((fsv.denyWrite ?? []).filter((p2) => p2 !== "~/"), [spawnCwd]);
|
|
41736
41736
|
fsv.allowRead = unionArr(fsv.allowRead, [userWorkDir]);
|
|
41737
41737
|
fsv.allowWrite = unionArr(fsv.allowWrite, [userWorkDir]);
|
|
41738
|
-
fsv.allowRead = unionArr(fsv.allowRead, ["~/.clawd/contact-ssh-keys"]);
|
|
41738
|
+
fsv.allowRead = unionArr(fsv.allowRead, ["~/.clawd/contact-ssh-keys", "~/.clawd/bin"]);
|
|
41739
41739
|
return s;
|
|
41740
41740
|
}
|
|
41741
41741
|
|
|
@@ -41885,12 +41885,14 @@ var CONTACT_SSH_SYSTEM_PROMPT_HINT = `## \u8DE8\u8BBE\u5907\u6587\u4EF6\u8BBF\u9
|
|
|
41885
41885
|
\uFF08\u6BCF\u4E2A \`<deviceId>.ed25519\` \u5C31\u662F\u4E00\u628A privkey\uFF0C\u53BB\u6389\u540E\u7F00\u5C31\u662F deviceId\uFF09
|
|
41886
41886
|
2. \u7528 SSH \u62E8\u53F7\uFF08\u628A \`<A>\` \u6362\u6210\u5B9E\u9645 deviceId\uFF09\uFF1A
|
|
41887
41887
|
\`\`\`bash
|
|
41888
|
-
ssh -o ProxyCommand='clawd ssh-relay <A>' \\
|
|
41888
|
+
ssh -o ProxyCommand='~/.clawd/bin/clawd ssh-relay <A>' \\
|
|
41889
41889
|
-i ~/.clawd/contact-ssh-keys/<A>.ed25519 \\
|
|
41890
41890
|
-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \\
|
|
41891
41891
|
$USER@127.0.0.1 <command>
|
|
41892
41892
|
# \u4F8B\u5982\uFF1A... $USER@127.0.0.1 cat /Users/xxx/some/file.md
|
|
41893
41893
|
# ... $USER@127.0.0.1 ls -la /Users/xxx/proj
|
|
41894
|
+
# \u8BF4\u660E\uFF1A\`~/.clawd/bin/clawd\` \u662F daemon \u542F\u52A8\u65F6 seed \u7684 shim\uFF0C\u786C\u7F16\u7801\u5F53\u524D daemon \u7684
|
|
41895
|
+
# execPath+cliPath\uFF0C\u4FDD\u8BC1 relay \u8DDF daemon \u7248\u672C\u540C\u6B65\u3002\u4E0D\u8981\u7528\u88F8 \`clawd\`\uFF08\u8D70 $PATH \u4F1A\u6F02\uFF09\u3002
|
|
41894
41896
|
\`\`\`
|
|
41895
41897
|
|
|
41896
41898
|
**A \u6388\u6743\u54EA\u4E9B\u76EE\u5F55\u4E0D\u7528\u4F60\u63D0\u524D\u8BB0**\uFF1AA \u4FA7\u7684 sshd \u62E8\u53F7\u4F1A\u5F3A\u5236\u8D70 sandbox jail\uFF0C\u8FDB\u6C99\u7BB1\u524D\u4F1A\u628A\u6388\u6743\u76EE\u5F55\u5217\u8868\u5199\u5230 stderr\uFF08\u683C\u5F0F \`[clawd-ssh-jail] Access allowed to these directories: ...\`\uFF09\u3002\u4F60\u5373\u4F7F\u731C\u9519\u8DEF\u5F84\u4E5F\u4F1A\u88AB sandbox deny\uFF0C\u4F46 stderr \u91CC\u5C31\u81EA\u5E26\u7B54\u6848\uFF0C\u8BD5\u9519\u4E00\u6B21\u5C31\u5B66\u5230 A \u6388\u6743\u4E86\u54EA\u4E9B\u76EE\u5F55\uFF0C\u4E0B\u6B21\u76F4\u63A5\u7528\u5BF9\u7684\u8DEF\u5F84\u3002
|
|
@@ -46560,8 +46562,8 @@ function turnStartInput(text) {
|
|
|
46560
46562
|
const items = [];
|
|
46561
46563
|
let leftover = text;
|
|
46562
46564
|
for (const m2 of text.matchAll(SKILL_RE)) {
|
|
46563
|
-
const [marker, name,
|
|
46564
|
-
items.push({ type: "skill", name, path:
|
|
46565
|
+
const [marker, name, path77] = m2;
|
|
46566
|
+
items.push({ type: "skill", name, path: path77 });
|
|
46565
46567
|
leftover = leftover.replace(marker, "");
|
|
46566
46568
|
}
|
|
46567
46569
|
for (const m2 of text.matchAll(ATTACHMENT_RE2)) {
|
|
@@ -49015,13 +49017,13 @@ function mapSkillsListResponse(res) {
|
|
|
49015
49017
|
const r = s ?? {};
|
|
49016
49018
|
const name = str3(r.name);
|
|
49017
49019
|
if (!name) continue;
|
|
49018
|
-
const
|
|
49020
|
+
const path77 = str3(r.path);
|
|
49019
49021
|
const description = str3(r.description);
|
|
49020
49022
|
const isPlugin = name.includes(":");
|
|
49021
49023
|
out.push({
|
|
49022
49024
|
name,
|
|
49023
49025
|
source: isPlugin ? "plugin" : "project",
|
|
49024
|
-
...
|
|
49026
|
+
...path77 ? { path: path77 } : {},
|
|
49025
49027
|
...description ? { description } : {},
|
|
49026
49028
|
...isPlugin ? { plugin: name.split(":")[0] } : {}
|
|
49027
49029
|
});
|
|
@@ -52993,8 +52995,8 @@ async function waitForFrpcReady(proc, timeoutMs) {
|
|
|
52993
52995
|
}
|
|
52994
52996
|
|
|
52995
52997
|
// src/sshd/sshd-manager.ts
|
|
52996
|
-
var
|
|
52997
|
-
var
|
|
52998
|
+
var import_node_fs37 = __toESM(require("fs"), 1);
|
|
52999
|
+
var import_node_path38 = __toESM(require("path"), 1);
|
|
52998
53000
|
var import_node_child_process11 = require("child_process");
|
|
52999
53001
|
|
|
53000
53002
|
// src/sshd/sshd-config.ts
|
|
@@ -53277,11 +53279,35 @@ function ensureJailScript(dataDir) {
|
|
|
53277
53279
|
return target;
|
|
53278
53280
|
}
|
|
53279
53281
|
|
|
53282
|
+
// src/sshd/clawd-shim.ts
|
|
53283
|
+
var import_node_fs36 = __toESM(require("fs"), 1);
|
|
53284
|
+
var import_node_path37 = __toESM(require("path"), 1);
|
|
53285
|
+
function shellQuote(s) {
|
|
53286
|
+
return `'${s.replace(/'/g, "'\\''")}'`;
|
|
53287
|
+
}
|
|
53288
|
+
function buildClawdShim(execPath, cliPath) {
|
|
53289
|
+
return `#!/usr/bin/env bash
|
|
53290
|
+
# clawd shim (managed by clawd; do not edit)
|
|
53291
|
+
#
|
|
53292
|
+
# \u786C\u7F16\u7801\u672C daemon \u542F\u52A8\u65F6\u7528\u7684 execPath + cliPath\uFF1Bdaemon \u91CD\u542F\u4F1A\u8986\u5199\u672C\u6587\u4EF6\uFF08\u5E42\u7B49 seed\uFF09\u3002
|
|
53293
|
+
# guest CC \u7528 SSH ProxyCommand \u8D70 ~/.clawd/bin/clawd ssh-relay \u65F6\u4F1A\u547D\u4E2D\u672C shim\uFF0C\u4FDD\u8BC1
|
|
53294
|
+
# relay \u4E8C\u8FDB\u5236\u8DDF\u5F53\u524D\u8DD1\u7740\u7684 daemon \u540C\u6E90\u540C\u7248\u672C\u3002
|
|
53295
|
+
exec ${shellQuote(execPath)} ${shellQuote(cliPath)} "$@"
|
|
53296
|
+
`;
|
|
53297
|
+
}
|
|
53298
|
+
function ensureClawdShim(dataDir, execPath, cliPath) {
|
|
53299
|
+
const binDir = import_node_path37.default.join(dataDir, "bin");
|
|
53300
|
+
import_node_fs36.default.mkdirSync(binDir, { recursive: true, mode: 493 });
|
|
53301
|
+
const target = import_node_path37.default.join(binDir, "clawd");
|
|
53302
|
+
import_node_fs36.default.writeFileSync(target, buildClawdShim(execPath, cliPath), { mode: 493 });
|
|
53303
|
+
return target;
|
|
53304
|
+
}
|
|
53305
|
+
|
|
53280
53306
|
// src/sshd/sshd-manager.ts
|
|
53281
53307
|
var SshdManager = class {
|
|
53282
53308
|
constructor(deps) {
|
|
53283
53309
|
this.deps = deps;
|
|
53284
|
-
this.sshdDir =
|
|
53310
|
+
this.sshdDir = import_node_path38.default.join(deps.dataDir, "sshd");
|
|
53285
53311
|
this.startupTimeoutMs = deps.startupTimeoutMs ?? 15e3;
|
|
53286
53312
|
}
|
|
53287
53313
|
deps;
|
|
@@ -53300,31 +53326,32 @@ var SshdManager = class {
|
|
|
53300
53326
|
ownPid: process.pid,
|
|
53301
53327
|
logger
|
|
53302
53328
|
});
|
|
53303
|
-
|
|
53304
|
-
|
|
53329
|
+
import_node_fs37.default.mkdirSync(this.sshdDir, { recursive: true, mode: 448 });
|
|
53330
|
+
import_node_fs37.default.mkdirSync(import_node_path38.default.join(this.sshdDir, "authorized_keys.d"), { recursive: true, mode: 448 });
|
|
53305
53331
|
ensureJailScript(this.deps.dataDir);
|
|
53306
|
-
|
|
53307
|
-
|
|
53332
|
+
ensureClawdShim(this.deps.dataDir, process.execPath, process.argv[1] ?? "");
|
|
53333
|
+
const hostKeyPath = import_node_path38.default.join(this.sshdDir, "host_key");
|
|
53334
|
+
if (!import_node_fs37.default.existsSync(hostKeyPath)) {
|
|
53308
53335
|
await this.generateHostKey(hostKeyPath);
|
|
53309
53336
|
}
|
|
53310
|
-
const akFile =
|
|
53311
|
-
if (!
|
|
53312
|
-
|
|
53337
|
+
const akFile = import_node_path38.default.join(this.sshdDir, "authorized_keys.d", "clawd-contacts");
|
|
53338
|
+
if (!import_node_fs37.default.existsSync(akFile)) {
|
|
53339
|
+
import_node_fs37.default.writeFileSync(akFile, "", { mode: 384 });
|
|
53313
53340
|
}
|
|
53314
|
-
const configPath =
|
|
53341
|
+
const configPath = import_node_path38.default.join(this.sshdDir, "sshd_config");
|
|
53315
53342
|
const config = buildSshdConfig({
|
|
53316
53343
|
listenAddress: "127.0.0.1",
|
|
53317
53344
|
port: this.deps.port,
|
|
53318
53345
|
hostKeyPath,
|
|
53319
53346
|
authorizedKeysFile: akFile,
|
|
53320
|
-
pidFilePath:
|
|
53347
|
+
pidFilePath: import_node_path38.default.join(this.sshdDir, "sshd.pid")
|
|
53321
53348
|
});
|
|
53322
|
-
|
|
53349
|
+
import_node_fs37.default.writeFileSync(configPath, config, { mode: 384 });
|
|
53323
53350
|
const sshdBin = this.deps.sshdBin ?? "/usr/sbin/sshd";
|
|
53324
53351
|
const proc = (this.deps.spawnImpl ?? import_node_child_process11.spawn)(sshdBin, ["-D", "-e", "-f", configPath], {
|
|
53325
53352
|
stdio: ["ignore", "pipe", "pipe"]
|
|
53326
53353
|
});
|
|
53327
|
-
const logStream =
|
|
53354
|
+
const logStream = import_node_fs37.default.createWriteStream(import_node_path38.default.join(this.sshdDir, "sshd.log"), {
|
|
53328
53355
|
flags: "a",
|
|
53329
53356
|
mode: 384
|
|
53330
53357
|
});
|
|
@@ -53417,7 +53444,7 @@ ${tail}` : ready.error;
|
|
|
53417
53444
|
p2.on("error", reject);
|
|
53418
53445
|
});
|
|
53419
53446
|
try {
|
|
53420
|
-
|
|
53447
|
+
import_node_fs37.default.chmodSync(hostKeyPath, 384);
|
|
53421
53448
|
} catch {
|
|
53422
53449
|
}
|
|
53423
53450
|
}
|
|
@@ -53460,17 +53487,17 @@ async function waitForSshdReady(proc, timeoutMs) {
|
|
|
53460
53487
|
}
|
|
53461
53488
|
|
|
53462
53489
|
// src/sshd/authorized-keys.ts
|
|
53463
|
-
var
|
|
53464
|
-
var
|
|
53490
|
+
var import_node_fs38 = __toESM(require("fs"), 1);
|
|
53491
|
+
var import_node_path39 = __toESM(require("path"), 1);
|
|
53465
53492
|
var JAIL_BIN_PATH_ENV = "CLAWD_JAIL_BIN_PATH";
|
|
53466
53493
|
var AUTHORIZED_KEYS_FILE = "clawd-contacts";
|
|
53467
53494
|
function jailBinPath() {
|
|
53468
|
-
return process.env[JAIL_BIN_PATH_ENV] ??
|
|
53495
|
+
return process.env[JAIL_BIN_PATH_ENV] ?? import_node_path39.default.join(process.env.HOME ?? "", ".clawd", "bin", "clawd-ssh-jail");
|
|
53469
53496
|
}
|
|
53470
53497
|
function rebuildAuthorizedKeys(store, sshdDir) {
|
|
53471
|
-
const akDir =
|
|
53472
|
-
const target =
|
|
53473
|
-
|
|
53498
|
+
const akDir = import_node_path39.default.join(sshdDir, "authorized_keys.d");
|
|
53499
|
+
const target = import_node_path39.default.join(akDir, AUTHORIZED_KEYS_FILE);
|
|
53500
|
+
import_node_fs38.default.mkdirSync(akDir, { recursive: true, mode: 448 });
|
|
53474
53501
|
const lines = ["# managed by clawd; do not edit", ""];
|
|
53475
53502
|
for (const c of store.list()) {
|
|
53476
53503
|
if (!c.sshAllowed) continue;
|
|
@@ -53484,29 +53511,29 @@ function rebuildAuthorizedKeys(store, sshdDir) {
|
|
|
53484
53511
|
}
|
|
53485
53512
|
const body = lines.join("\n") + "\n";
|
|
53486
53513
|
const tmp = `${target}.tmp-${process.pid}-${Date.now()}`;
|
|
53487
|
-
|
|
53488
|
-
|
|
53514
|
+
import_node_fs38.default.writeFileSync(tmp, body, { mode: 384 });
|
|
53515
|
+
import_node_fs38.default.renameSync(tmp, target);
|
|
53489
53516
|
}
|
|
53490
53517
|
function readIssuedPubkey(sshdDir, deviceId) {
|
|
53491
53518
|
const safeId = deviceId.replace(/[\/\\]/g, "_");
|
|
53492
|
-
const p2 =
|
|
53519
|
+
const p2 = import_node_path39.default.join(sshdDir, "keys", `${safeId}.ed25519.pub`);
|
|
53493
53520
|
try {
|
|
53494
|
-
return
|
|
53521
|
+
return import_node_fs38.default.readFileSync(p2, "utf8");
|
|
53495
53522
|
} catch {
|
|
53496
53523
|
return null;
|
|
53497
53524
|
}
|
|
53498
53525
|
}
|
|
53499
53526
|
|
|
53500
53527
|
// src/sshd/contact-key-puller.ts
|
|
53501
|
-
var
|
|
53502
|
-
var
|
|
53528
|
+
var import_node_fs40 = __toESM(require("fs"), 1);
|
|
53529
|
+
var import_node_path41 = __toESM(require("path"), 1);
|
|
53503
53530
|
init_peer_forward();
|
|
53504
53531
|
|
|
53505
53532
|
// src/sshd/contact-ssh-log.ts
|
|
53506
|
-
var
|
|
53507
|
-
var
|
|
53533
|
+
var import_node_fs39 = __toESM(require("fs"), 1);
|
|
53534
|
+
var import_node_path40 = __toESM(require("path"), 1);
|
|
53508
53535
|
function createContactSshLog(dataDir) {
|
|
53509
|
-
const file =
|
|
53536
|
+
const file = import_node_path40.default.join(dataDir, "contact-ssh.log");
|
|
53510
53537
|
function append(level, tag, message, meta) {
|
|
53511
53538
|
const time = (/* @__PURE__ */ new Date()).toISOString();
|
|
53512
53539
|
let line = `[${time}] [${level}] [${tag}] ${message}`;
|
|
@@ -53519,8 +53546,8 @@ function createContactSshLog(dataDir) {
|
|
|
53519
53546
|
}
|
|
53520
53547
|
line += "\n";
|
|
53521
53548
|
try {
|
|
53522
|
-
|
|
53523
|
-
|
|
53549
|
+
import_node_fs39.default.mkdirSync(import_node_path40.default.dirname(file), { recursive: true });
|
|
53550
|
+
import_node_fs39.default.appendFileSync(file, line, { mode: 384 });
|
|
53524
53551
|
} catch {
|
|
53525
53552
|
}
|
|
53526
53553
|
}
|
|
@@ -53543,7 +53570,7 @@ var nullContactSshLog = {
|
|
|
53543
53570
|
var CONTACT_KEYS_DIR = "contact-ssh-keys";
|
|
53544
53571
|
function safeContactKeyPath(dataDir, deviceId) {
|
|
53545
53572
|
const safeId = deviceId.replace(/[\/\\]/g, "_");
|
|
53546
|
-
return
|
|
53573
|
+
return import_node_path41.default.join(dataDir, CONTACT_KEYS_DIR, `${safeId}.ed25519`);
|
|
53547
53574
|
}
|
|
53548
53575
|
async function pullContactSshKeyOnce(deps) {
|
|
53549
53576
|
const forward = deps.forwardImpl ?? ((c) => forwardContactSshKeyIssueToPeer({
|
|
@@ -53609,12 +53636,12 @@ async function pullContactSshKeyOnce(deps) {
|
|
|
53609
53636
|
}
|
|
53610
53637
|
function writeKeyFile(dataDir, deviceId, pem) {
|
|
53611
53638
|
const p2 = safeContactKeyPath(dataDir, deviceId);
|
|
53612
|
-
|
|
53613
|
-
|
|
53639
|
+
import_node_fs40.default.mkdirSync(import_node_path41.default.dirname(p2), { recursive: true, mode: 448 });
|
|
53640
|
+
import_node_fs40.default.writeFileSync(p2, pem, { mode: 384 });
|
|
53614
53641
|
}
|
|
53615
53642
|
function removeKeyFile(dataDir, deviceId) {
|
|
53616
53643
|
try {
|
|
53617
|
-
|
|
53644
|
+
import_node_fs40.default.unlinkSync(safeContactKeyPath(dataDir, deviceId));
|
|
53618
53645
|
return true;
|
|
53619
53646
|
} catch {
|
|
53620
53647
|
return false;
|
|
@@ -53760,27 +53787,27 @@ function pumpWsToSshd(ws, deps, clientAddr) {
|
|
|
53760
53787
|
|
|
53761
53788
|
// src/tunnel/device-key.ts
|
|
53762
53789
|
var import_node_os14 = __toESM(require("os"), 1);
|
|
53763
|
-
var
|
|
53790
|
+
var import_node_path42 = __toESM(require("path"), 1);
|
|
53764
53791
|
var import_node_crypto11 = __toESM(require("crypto"), 1);
|
|
53765
53792
|
var DERIVE_SALT = "clawd-tunnel-device-v1";
|
|
53766
53793
|
function deriveStableDeviceKey(opts = {}) {
|
|
53767
53794
|
const hostname = opts.hostname ?? import_node_os14.default.hostname();
|
|
53768
53795
|
const uid = opts.uid ?? (typeof import_node_os14.default.userInfo === "function" ? import_node_os14.default.userInfo().uid : 0);
|
|
53769
53796
|
const home = opts.home ?? import_node_os14.default.homedir();
|
|
53770
|
-
const defaultDataDir =
|
|
53771
|
-
const normalizedDataDir = opts.dataDir ?
|
|
53797
|
+
const defaultDataDir = import_node_path42.default.resolve(import_node_path42.default.join(home, ".clawd"));
|
|
53798
|
+
const normalizedDataDir = opts.dataDir ? import_node_path42.default.resolve(opts.dataDir) : null;
|
|
53772
53799
|
const isDefaultDir = normalizedDataDir == null || normalizedDataDir === defaultDataDir;
|
|
53773
53800
|
const input = isDefaultDir ? `${hostname}::${uid}` : `${hostname}::${uid}::${normalizedDataDir}`;
|
|
53774
53801
|
return import_node_crypto11.default.createHmac("sha256", DERIVE_SALT).update(input).digest("hex").slice(0, 32);
|
|
53775
53802
|
}
|
|
53776
53803
|
|
|
53777
53804
|
// src/auth-store.ts
|
|
53778
|
-
var
|
|
53779
|
-
var
|
|
53805
|
+
var import_node_fs41 = __toESM(require("fs"), 1);
|
|
53806
|
+
var import_node_path43 = __toESM(require("path"), 1);
|
|
53780
53807
|
var import_node_crypto12 = __toESM(require("crypto"), 1);
|
|
53781
53808
|
var AUTH_FILE_NAME = "auth.json";
|
|
53782
53809
|
function authFilePath(dataDir) {
|
|
53783
|
-
return
|
|
53810
|
+
return import_node_path43.default.join(dataDir, AUTH_FILE_NAME);
|
|
53784
53811
|
}
|
|
53785
53812
|
function loadOrCreateAuthFile(opts) {
|
|
53786
53813
|
const file = authFilePath(opts.dataDir);
|
|
@@ -53816,7 +53843,7 @@ function defaultGenerateOwnerPrincipalId() {
|
|
|
53816
53843
|
}
|
|
53817
53844
|
function readAuthFile(file) {
|
|
53818
53845
|
try {
|
|
53819
|
-
const raw =
|
|
53846
|
+
const raw = import_node_fs41.default.readFileSync(file, "utf8");
|
|
53820
53847
|
const parsed = JSON.parse(raw);
|
|
53821
53848
|
if (typeof parsed?.token !== "string" || parsed.token.length === 0) {
|
|
53822
53849
|
return null;
|
|
@@ -53836,25 +53863,25 @@ function readAuthFile(file) {
|
|
|
53836
53863
|
}
|
|
53837
53864
|
}
|
|
53838
53865
|
function writeAuthFile(file, content) {
|
|
53839
|
-
|
|
53840
|
-
|
|
53866
|
+
import_node_fs41.default.mkdirSync(import_node_path43.default.dirname(file), { recursive: true });
|
|
53867
|
+
import_node_fs41.default.writeFileSync(file, JSON.stringify(content, null, 2), { mode: 384 });
|
|
53841
53868
|
try {
|
|
53842
|
-
|
|
53869
|
+
import_node_fs41.default.chmodSync(file, 384);
|
|
53843
53870
|
} catch {
|
|
53844
53871
|
}
|
|
53845
53872
|
}
|
|
53846
53873
|
|
|
53847
53874
|
// src/owner-profile.ts
|
|
53848
|
-
var
|
|
53875
|
+
var import_node_fs42 = __toESM(require("fs"), 1);
|
|
53849
53876
|
var import_node_os15 = __toESM(require("os"), 1);
|
|
53850
|
-
var
|
|
53877
|
+
var import_node_path44 = __toESM(require("path"), 1);
|
|
53851
53878
|
var PROFILE_FILENAME = "profile.json";
|
|
53852
53879
|
function loadOwnerDisplayName(dataDir) {
|
|
53853
53880
|
const fallback = import_node_os15.default.userInfo().username;
|
|
53854
|
-
const profilePath =
|
|
53881
|
+
const profilePath = import_node_path44.default.join(dataDir, PROFILE_FILENAME);
|
|
53855
53882
|
let raw;
|
|
53856
53883
|
try {
|
|
53857
|
-
raw =
|
|
53884
|
+
raw = import_node_fs42.default.readFileSync(profilePath, "utf8");
|
|
53858
53885
|
} catch {
|
|
53859
53886
|
return fallback;
|
|
53860
53887
|
}
|
|
@@ -53877,18 +53904,18 @@ function loadOwnerDisplayName(dataDir) {
|
|
|
53877
53904
|
}
|
|
53878
53905
|
|
|
53879
53906
|
// src/feishu-auth/owner-identity-store.ts
|
|
53880
|
-
var
|
|
53881
|
-
var
|
|
53907
|
+
var import_node_fs43 = __toESM(require("fs"), 1);
|
|
53908
|
+
var import_node_path45 = __toESM(require("path"), 1);
|
|
53882
53909
|
var OWNER_IDENTITY_FILE_NAME = "owner-identity.json";
|
|
53883
53910
|
var OwnerIdentityStore = class {
|
|
53884
53911
|
file;
|
|
53885
53912
|
constructor(dataDir) {
|
|
53886
|
-
this.file =
|
|
53913
|
+
this.file = import_node_path45.default.join(dataDir, OWNER_IDENTITY_FILE_NAME);
|
|
53887
53914
|
}
|
|
53888
53915
|
read() {
|
|
53889
53916
|
let raw;
|
|
53890
53917
|
try {
|
|
53891
|
-
raw =
|
|
53918
|
+
raw = import_node_fs43.default.readFileSync(this.file, "utf8");
|
|
53892
53919
|
} catch {
|
|
53893
53920
|
return null;
|
|
53894
53921
|
}
|
|
@@ -53916,16 +53943,16 @@ var OwnerIdentityStore = class {
|
|
|
53916
53943
|
};
|
|
53917
53944
|
}
|
|
53918
53945
|
write(record) {
|
|
53919
|
-
|
|
53920
|
-
|
|
53946
|
+
import_node_fs43.default.mkdirSync(import_node_path45.default.dirname(this.file), { recursive: true });
|
|
53947
|
+
import_node_fs43.default.writeFileSync(this.file, JSON.stringify(record, null, 2), { mode: 384 });
|
|
53921
53948
|
try {
|
|
53922
|
-
|
|
53949
|
+
import_node_fs43.default.chmodSync(this.file, 384);
|
|
53923
53950
|
} catch {
|
|
53924
53951
|
}
|
|
53925
53952
|
}
|
|
53926
53953
|
clear() {
|
|
53927
53954
|
try {
|
|
53928
|
-
|
|
53955
|
+
import_node_fs43.default.unlinkSync(this.file);
|
|
53929
53956
|
} catch (err) {
|
|
53930
53957
|
const code = err?.code;
|
|
53931
53958
|
if (code !== "ENOENT") throw err;
|
|
@@ -54046,9 +54073,9 @@ var CentralClientError = class extends Error {
|
|
|
54046
54073
|
code;
|
|
54047
54074
|
cause;
|
|
54048
54075
|
};
|
|
54049
|
-
async function centralRequest(opts,
|
|
54076
|
+
async function centralRequest(opts, path77, init) {
|
|
54050
54077
|
const f = opts.fetchImpl ?? globalThis.fetch;
|
|
54051
|
-
const url = `${opts.api.replace(/\/+$/, "")}${
|
|
54078
|
+
const url = `${opts.api.replace(/\/+$/, "")}${path77}`;
|
|
54052
54079
|
const ctrl = new AbortController();
|
|
54053
54080
|
const timer = setTimeout(() => ctrl.abort(), opts.timeoutMs ?? 15e3);
|
|
54054
54081
|
let res;
|
|
@@ -54190,8 +54217,8 @@ function verifyConnectToken(args) {
|
|
|
54190
54217
|
}
|
|
54191
54218
|
|
|
54192
54219
|
// src/feishu-auth/server-key.ts
|
|
54193
|
-
var
|
|
54194
|
-
var
|
|
54220
|
+
var fs53 = __toESM(require("fs"), 1);
|
|
54221
|
+
var path54 = __toESM(require("path"), 1);
|
|
54195
54222
|
var FILE_NAME2 = "server-signing-key.json";
|
|
54196
54223
|
var ServerKeyStore = class {
|
|
54197
54224
|
constructor(dataDir) {
|
|
@@ -54199,12 +54226,12 @@ var ServerKeyStore = class {
|
|
|
54199
54226
|
}
|
|
54200
54227
|
dataDir;
|
|
54201
54228
|
filePath() {
|
|
54202
|
-
return
|
|
54229
|
+
return path54.join(this.dataDir, FILE_NAME2);
|
|
54203
54230
|
}
|
|
54204
54231
|
/** 读缓存的公钥;无缓存 / 损坏 → null(调用方决定是否触发拉取) */
|
|
54205
54232
|
read() {
|
|
54206
54233
|
try {
|
|
54207
|
-
const raw =
|
|
54234
|
+
const raw = fs53.readFileSync(this.filePath(), "utf8");
|
|
54208
54235
|
const parsed = JSON.parse(raw);
|
|
54209
54236
|
if (typeof parsed.publicKeyPem === "string" && parsed.publicKeyPem.includes("PUBLIC KEY")) {
|
|
54210
54237
|
return parsed.publicKeyPem;
|
|
@@ -54219,12 +54246,12 @@ var ServerKeyStore = class {
|
|
|
54219
54246
|
publicKeyPem,
|
|
54220
54247
|
fetchedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
54221
54248
|
};
|
|
54222
|
-
|
|
54223
|
-
|
|
54249
|
+
fs53.mkdirSync(this.dataDir, { recursive: true });
|
|
54250
|
+
fs53.writeFileSync(this.filePath(), JSON.stringify(content, null, 2), { mode: 384 });
|
|
54224
54251
|
}
|
|
54225
54252
|
clear() {
|
|
54226
54253
|
try {
|
|
54227
|
-
|
|
54254
|
+
fs53.unlinkSync(this.filePath());
|
|
54228
54255
|
} catch {
|
|
54229
54256
|
}
|
|
54230
54257
|
}
|
|
@@ -54237,12 +54264,12 @@ init_protocol();
|
|
|
54237
54264
|
init_protocol();
|
|
54238
54265
|
|
|
54239
54266
|
// src/session/fork.ts
|
|
54240
|
-
var
|
|
54267
|
+
var import_node_fs44 = __toESM(require("fs"), 1);
|
|
54241
54268
|
var import_node_os16 = __toESM(require("os"), 1);
|
|
54242
|
-
var
|
|
54269
|
+
var import_node_path46 = __toESM(require("path"), 1);
|
|
54243
54270
|
init_claude_history();
|
|
54244
54271
|
function readJsonlEntries(file) {
|
|
54245
|
-
const raw =
|
|
54272
|
+
const raw = import_node_fs44.default.readFileSync(file, "utf8");
|
|
54246
54273
|
const out = [];
|
|
54247
54274
|
for (const line of raw.split("\n")) {
|
|
54248
54275
|
const t = line.trim();
|
|
@@ -54255,10 +54282,10 @@ function readJsonlEntries(file) {
|
|
|
54255
54282
|
return out;
|
|
54256
54283
|
}
|
|
54257
54284
|
function forkSession(input) {
|
|
54258
|
-
const baseDir = input.baseDir ??
|
|
54259
|
-
const projectDir =
|
|
54260
|
-
const sourceFile =
|
|
54261
|
-
if (!
|
|
54285
|
+
const baseDir = input.baseDir ?? import_node_path46.default.join(import_node_os16.default.homedir(), ".claude");
|
|
54286
|
+
const projectDir = import_node_path46.default.join(baseDir, "projects", cwdToHashDir(input.cwd));
|
|
54287
|
+
const sourceFile = import_node_path46.default.join(projectDir, `${input.toolSessionId}.jsonl`);
|
|
54288
|
+
if (!import_node_fs44.default.existsSync(sourceFile)) {
|
|
54262
54289
|
throw new Error(`fork: source transcript not found: ${sourceFile}`);
|
|
54263
54290
|
}
|
|
54264
54291
|
const entries = readJsonlEntries(sourceFile);
|
|
@@ -54288,9 +54315,9 @@ function forkSession(input) {
|
|
|
54288
54315
|
}
|
|
54289
54316
|
forkedLines.push(JSON.stringify(forked));
|
|
54290
54317
|
}
|
|
54291
|
-
const forkedFilePath =
|
|
54292
|
-
|
|
54293
|
-
|
|
54318
|
+
const forkedFilePath = import_node_path46.default.join(projectDir, `${forkedToolSessionId}.jsonl`);
|
|
54319
|
+
import_node_fs44.default.mkdirSync(projectDir, { recursive: true });
|
|
54320
|
+
import_node_fs44.default.writeFileSync(forkedFilePath, forkedLines.join("\n") + "\n", { mode: 384 });
|
|
54294
54321
|
return { forkedToolSessionId, forkedFilePath };
|
|
54295
54322
|
}
|
|
54296
54323
|
|
|
@@ -54642,7 +54669,7 @@ function buildPermissionHandlers(deps) {
|
|
|
54642
54669
|
}
|
|
54643
54670
|
|
|
54644
54671
|
// src/handlers/history.ts
|
|
54645
|
-
var
|
|
54672
|
+
var path57 = __toESM(require("path"), 1);
|
|
54646
54673
|
init_protocol();
|
|
54647
54674
|
|
|
54648
54675
|
// src/session/recent-dirs.ts
|
|
@@ -54660,7 +54687,7 @@ function listRecentDirs(store, limit = 50) {
|
|
|
54660
54687
|
}
|
|
54661
54688
|
|
|
54662
54689
|
// src/permission/persona-paths.ts
|
|
54663
|
-
var
|
|
54690
|
+
var path56 = __toESM(require("path"), 1);
|
|
54664
54691
|
function getAllowedPersonaIds(grants, action) {
|
|
54665
54692
|
const ids = /* @__PURE__ */ new Set();
|
|
54666
54693
|
for (const g2 of grants) {
|
|
@@ -54673,42 +54700,42 @@ function getAllowedPersonaIds(grants, action) {
|
|
|
54673
54700
|
return ids;
|
|
54674
54701
|
}
|
|
54675
54702
|
function isGuestPathAllowed(grants, absPath, personaRoot, action = "read", userWorkDir) {
|
|
54676
|
-
const target =
|
|
54703
|
+
const target = path56.resolve(absPath);
|
|
54677
54704
|
if (userWorkDir) {
|
|
54678
|
-
const u =
|
|
54679
|
-
const usep = u.endsWith(
|
|
54705
|
+
const u = path56.resolve(userWorkDir);
|
|
54706
|
+
const usep = u.endsWith(path56.sep) ? "" : path56.sep;
|
|
54680
54707
|
if (target === u || target.startsWith(u + usep)) return true;
|
|
54681
54708
|
}
|
|
54682
|
-
const root =
|
|
54683
|
-
const sep3 = root.endsWith(
|
|
54709
|
+
const root = path56.resolve(personaRoot);
|
|
54710
|
+
const sep3 = root.endsWith(path56.sep) ? "" : path56.sep;
|
|
54684
54711
|
if (!target.startsWith(root + sep3)) return false;
|
|
54685
|
-
const rel =
|
|
54712
|
+
const rel = path56.relative(root, target);
|
|
54686
54713
|
if (!rel || rel.startsWith("..")) return false;
|
|
54687
|
-
const personaId = rel.split(
|
|
54714
|
+
const personaId = rel.split(path56.sep)[0];
|
|
54688
54715
|
if (!personaId) return false;
|
|
54689
54716
|
const allowed = getAllowedPersonaIds(grants, action);
|
|
54690
54717
|
if (allowed === "*") return true;
|
|
54691
54718
|
return allowed.has(personaId);
|
|
54692
54719
|
}
|
|
54693
54720
|
function personaIdFromPath(absPath, personaRoot) {
|
|
54694
|
-
const root =
|
|
54695
|
-
const target =
|
|
54696
|
-
const sep3 = root.endsWith(
|
|
54721
|
+
const root = path56.resolve(personaRoot);
|
|
54722
|
+
const target = path56.resolve(absPath);
|
|
54723
|
+
const sep3 = root.endsWith(path56.sep) ? "" : path56.sep;
|
|
54697
54724
|
if (!target.startsWith(root + sep3)) return null;
|
|
54698
|
-
const rel =
|
|
54725
|
+
const rel = path56.relative(root, target);
|
|
54699
54726
|
if (!rel || rel.startsWith("..")) return null;
|
|
54700
|
-
const id = rel.split(
|
|
54727
|
+
const id = rel.split(path56.sep)[0];
|
|
54701
54728
|
return id || null;
|
|
54702
54729
|
}
|
|
54703
54730
|
function isPathWithin(dir, absPath) {
|
|
54704
|
-
const d =
|
|
54705
|
-
const t =
|
|
54706
|
-
const sep3 = d.endsWith(
|
|
54731
|
+
const d = path56.resolve(dir);
|
|
54732
|
+
const t = path56.resolve(absPath);
|
|
54733
|
+
const sep3 = d.endsWith(path56.sep) ? "" : path56.sep;
|
|
54707
54734
|
return t === d || t.startsWith(d + sep3);
|
|
54708
54735
|
}
|
|
54709
54736
|
function isPathInGuestBoundary(personaRoot, personaId, userWorkDir, absPath) {
|
|
54710
54737
|
if (userWorkDir && isPathWithin(userWorkDir, absPath)) return true;
|
|
54711
|
-
return personaIdFromPath(
|
|
54738
|
+
return personaIdFromPath(path56.resolve(absPath), personaRoot) === personaId;
|
|
54712
54739
|
}
|
|
54713
54740
|
|
|
54714
54741
|
// src/handlers/history.ts
|
|
@@ -54734,7 +54761,7 @@ function buildHistoryHandlers(deps) {
|
|
|
54734
54761
|
if (!pid) return false;
|
|
54735
54762
|
return isGuestPathAllowed(
|
|
54736
54763
|
ctx.grants,
|
|
54737
|
-
|
|
54764
|
+
path57.join(personaRoot, pid),
|
|
54738
54765
|
personaRoot,
|
|
54739
54766
|
"read",
|
|
54740
54767
|
userWorkDir
|
|
@@ -54746,7 +54773,7 @@ function buildHistoryHandlers(deps) {
|
|
|
54746
54773
|
};
|
|
54747
54774
|
const list = async (frame, _client, ctx) => {
|
|
54748
54775
|
const args = HistoryListArgs.parse(frame);
|
|
54749
|
-
assertGuestPath(ctx,
|
|
54776
|
+
assertGuestPath(ctx, path57.resolve(args.projectPath), personaRoot, "history:list");
|
|
54750
54777
|
const sessions = await history.listSessions(args);
|
|
54751
54778
|
return { response: { type: "history:list", sessions } };
|
|
54752
54779
|
};
|
|
@@ -54778,13 +54805,13 @@ function buildHistoryHandlers(deps) {
|
|
|
54778
54805
|
};
|
|
54779
54806
|
const subagents = async (frame, _client, ctx) => {
|
|
54780
54807
|
const args = HistorySubagentsArgs.parse(frame);
|
|
54781
|
-
assertGuestPath(ctx,
|
|
54808
|
+
assertGuestPath(ctx, path57.resolve(args.cwd), personaRoot, "history:subagents", usersRoot);
|
|
54782
54809
|
const subs = await history.listSubagents(args);
|
|
54783
54810
|
return { response: { type: "history:subagents", subagents: subs } };
|
|
54784
54811
|
};
|
|
54785
54812
|
const subagentRead = async (frame, _client, ctx) => {
|
|
54786
54813
|
const args = HistorySubagentReadArgs.parse(frame);
|
|
54787
|
-
assertGuestPath(ctx,
|
|
54814
|
+
assertGuestPath(ctx, path57.resolve(args.cwd), personaRoot, "history:subagent-read", usersRoot);
|
|
54788
54815
|
const res = await history.readSubagent(args);
|
|
54789
54816
|
return { response: { type: "history:subagent-read", ...res } };
|
|
54790
54817
|
};
|
|
@@ -54793,7 +54820,7 @@ function buildHistoryHandlers(deps) {
|
|
|
54793
54820
|
if (ctx?.principal.kind === "guest" && personaRoot) {
|
|
54794
54821
|
const userWorkDir = usersRoot ? deriveUserWorkDir(ctx.principal.id, usersRoot) : void 0;
|
|
54795
54822
|
const filtered = dirs.filter(
|
|
54796
|
-
(d) => isGuestPathAllowed(ctx.grants,
|
|
54823
|
+
(d) => isGuestPathAllowed(ctx.grants, path57.resolve(d.cwd), personaRoot, "read", userWorkDir)
|
|
54797
54824
|
);
|
|
54798
54825
|
return { response: { type: "history:recentDirs", dirs: filtered } };
|
|
54799
54826
|
}
|
|
@@ -54810,7 +54837,7 @@ function buildHistoryHandlers(deps) {
|
|
|
54810
54837
|
}
|
|
54811
54838
|
|
|
54812
54839
|
// src/handlers/workspace.ts
|
|
54813
|
-
var
|
|
54840
|
+
var path58 = __toESM(require("path"), 1);
|
|
54814
54841
|
var os16 = __toESM(require("os"), 1);
|
|
54815
54842
|
init_protocol();
|
|
54816
54843
|
init_protocol();
|
|
@@ -54852,22 +54879,22 @@ function buildWorkspaceHandlers(deps) {
|
|
|
54852
54879
|
const args = WorkspaceListArgs.parse(frame);
|
|
54853
54880
|
const isGuest = ctx?.principal.kind === "guest";
|
|
54854
54881
|
const fallbackCwd = isGuest && personaRoot ? personaRoot : os16.homedir();
|
|
54855
|
-
const resolvedCwd =
|
|
54856
|
-
const target = args.path ?
|
|
54882
|
+
const resolvedCwd = path58.resolve(args.cwd ?? fallbackCwd);
|
|
54883
|
+
const target = args.path ? path58.resolve(resolvedCwd, args.path) : resolvedCwd;
|
|
54857
54884
|
assertGuestPath2(ctx, target, personaRoot, "workspace:list", usersRoot);
|
|
54858
54885
|
const res = workspace.list({ ...args, cwd: resolvedCwd });
|
|
54859
54886
|
return { response: { type: "workspace:list", ...res } };
|
|
54860
54887
|
};
|
|
54861
54888
|
const read = async (frame, _client, ctx) => {
|
|
54862
54889
|
const args = WorkspaceReadArgs.parse(frame);
|
|
54863
|
-
const target =
|
|
54890
|
+
const target = path58.isAbsolute(args.path) ? path58.resolve(args.path) : path58.resolve(args.cwd, args.path);
|
|
54864
54891
|
assertGuestPath2(ctx, target, personaRoot, "workspace:read", usersRoot);
|
|
54865
54892
|
const res = workspace.read(args);
|
|
54866
54893
|
return { response: { type: "workspace:read", ...res } };
|
|
54867
54894
|
};
|
|
54868
54895
|
const skillsList = async (frame, _client, ctx) => {
|
|
54869
54896
|
const args = SkillsListArgs.parse(frame);
|
|
54870
|
-
const cwdAbs =
|
|
54897
|
+
const cwdAbs = path58.resolve(args.cwd);
|
|
54871
54898
|
assertGuestPath2(ctx, cwdAbs, personaRoot, "skills:list", usersRoot);
|
|
54872
54899
|
const list2 = await getSkillsForTool(args.tool ?? "claude", cwdAbs);
|
|
54873
54900
|
if (ctx?.principal.kind === "guest" && personaRoot) {
|
|
@@ -54879,7 +54906,7 @@ function buildWorkspaceHandlers(deps) {
|
|
|
54879
54906
|
};
|
|
54880
54907
|
const agentsList = async (frame, _client, ctx) => {
|
|
54881
54908
|
const args = AgentsListArgs.parse(frame);
|
|
54882
|
-
const cwdAbs =
|
|
54909
|
+
const cwdAbs = path58.resolve(args.cwd);
|
|
54883
54910
|
assertGuestPath2(ctx, cwdAbs, personaRoot, "agents:list", usersRoot);
|
|
54884
54911
|
if (args.tool === "codex") {
|
|
54885
54912
|
return { response: { type: "agents:list", agents: [] } };
|
|
@@ -54901,20 +54928,20 @@ function buildWorkspaceHandlers(deps) {
|
|
|
54901
54928
|
}
|
|
54902
54929
|
|
|
54903
54930
|
// src/handlers/git.ts
|
|
54904
|
-
var
|
|
54931
|
+
var path60 = __toESM(require("path"), 1);
|
|
54905
54932
|
init_protocol();
|
|
54906
54933
|
init_protocol();
|
|
54907
54934
|
|
|
54908
54935
|
// src/workspace/git.ts
|
|
54909
54936
|
var import_node_child_process12 = require("child_process");
|
|
54910
|
-
var
|
|
54911
|
-
var
|
|
54937
|
+
var import_node_fs45 = __toESM(require("fs"), 1);
|
|
54938
|
+
var import_node_path47 = __toESM(require("path"), 1);
|
|
54912
54939
|
var import_node_util = require("util");
|
|
54913
54940
|
var pexec = (0, import_node_util.promisify)(import_node_child_process12.execFile);
|
|
54914
54941
|
function normalizePath(p2) {
|
|
54915
|
-
const resolved =
|
|
54942
|
+
const resolved = import_node_path47.default.resolve(p2);
|
|
54916
54943
|
try {
|
|
54917
|
-
return
|
|
54944
|
+
return import_node_fs45.default.realpathSync(resolved);
|
|
54918
54945
|
} catch {
|
|
54919
54946
|
return resolved;
|
|
54920
54947
|
}
|
|
@@ -54988,7 +55015,7 @@ async function listGitBranches(cwd) {
|
|
|
54988
55015
|
function assertGuestCwd(ctx, cwd, personaRoot, method, usersRoot) {
|
|
54989
55016
|
if (!ctx || ctx.principal.kind !== "guest" || !personaRoot) return;
|
|
54990
55017
|
const userWorkDir = usersRoot ? deriveUserWorkDir(ctx.principal.id, usersRoot) : void 0;
|
|
54991
|
-
if (!isGuestPathAllowed(ctx.grants,
|
|
55018
|
+
if (!isGuestPathAllowed(ctx.grants, path60.resolve(cwd), personaRoot, "read", userWorkDir)) {
|
|
54992
55019
|
throw new ClawdError(
|
|
54993
55020
|
ERROR_CODES.UNAUTHORIZED,
|
|
54994
55021
|
`guest ${ctx.principal.id} cannot ${method} cwd ${cwd}`
|
|
@@ -55329,22 +55356,22 @@ init_src();
|
|
|
55329
55356
|
init_protocol();
|
|
55330
55357
|
|
|
55331
55358
|
// src/sshd/key-issue.ts
|
|
55332
|
-
var
|
|
55333
|
-
var
|
|
55359
|
+
var import_node_fs46 = __toESM(require("fs"), 1);
|
|
55360
|
+
var import_node_path48 = __toESM(require("path"), 1);
|
|
55334
55361
|
var import_node_child_process13 = require("child_process");
|
|
55335
55362
|
function safeDeviceId(deviceId) {
|
|
55336
55363
|
return deviceId.replace(/[\/\\]/g, "_");
|
|
55337
55364
|
}
|
|
55338
55365
|
async function issueContactSshKey(deviceId, sshdDir, opts = {}) {
|
|
55339
55366
|
const safeId = safeDeviceId(deviceId);
|
|
55340
|
-
const keysDir =
|
|
55341
|
-
|
|
55342
|
-
const privPath =
|
|
55367
|
+
const keysDir = import_node_path48.default.join(sshdDir, "keys");
|
|
55368
|
+
import_node_fs46.default.mkdirSync(keysDir, { recursive: true, mode: 448 });
|
|
55369
|
+
const privPath = import_node_path48.default.join(keysDir, `${safeId}.ed25519`);
|
|
55343
55370
|
const pubPath = `${privPath}.pub`;
|
|
55344
|
-
if (
|
|
55371
|
+
if (import_node_fs46.default.existsSync(privPath) && import_node_fs46.default.existsSync(pubPath)) {
|
|
55345
55372
|
return {
|
|
55346
|
-
privateKeyPem:
|
|
55347
|
-
publicKeyLine:
|
|
55373
|
+
privateKeyPem: import_node_fs46.default.readFileSync(privPath, "utf8"),
|
|
55374
|
+
publicKeyLine: import_node_fs46.default.readFileSync(pubPath, "utf8").trim()
|
|
55348
55375
|
};
|
|
55349
55376
|
}
|
|
55350
55377
|
const bin = opts.keygenBin ?? "/usr/bin/ssh-keygen";
|
|
@@ -55358,16 +55385,16 @@ async function issueContactSshKey(deviceId, sshdDir, opts = {}) {
|
|
|
55358
55385
|
p2.on("error", reject);
|
|
55359
55386
|
});
|
|
55360
55387
|
try {
|
|
55361
|
-
|
|
55388
|
+
import_node_fs46.default.chmodSync(privPath, 384);
|
|
55362
55389
|
} catch {
|
|
55363
55390
|
}
|
|
55364
55391
|
try {
|
|
55365
|
-
|
|
55392
|
+
import_node_fs46.default.chmodSync(pubPath, 420);
|
|
55366
55393
|
} catch {
|
|
55367
55394
|
}
|
|
55368
55395
|
return {
|
|
55369
|
-
privateKeyPem:
|
|
55370
|
-
publicKeyLine:
|
|
55396
|
+
privateKeyPem: import_node_fs46.default.readFileSync(privPath, "utf8"),
|
|
55397
|
+
publicKeyLine: import_node_fs46.default.readFileSync(pubPath, "utf8").trim()
|
|
55371
55398
|
};
|
|
55372
55399
|
}
|
|
55373
55400
|
|
|
@@ -55786,7 +55813,7 @@ function buildPersonaHandlers(deps) {
|
|
|
55786
55813
|
}
|
|
55787
55814
|
|
|
55788
55815
|
// src/handlers/attachment.ts
|
|
55789
|
-
var
|
|
55816
|
+
var import_node_path49 = __toESM(require("path"), 1);
|
|
55790
55817
|
init_protocol();
|
|
55791
55818
|
init_protocol();
|
|
55792
55819
|
var DEFAULT_TTL_SECONDS = 24 * 3600;
|
|
@@ -55866,12 +55893,12 @@ function buildAttachmentHandlers(deps) {
|
|
|
55866
55893
|
`session ${args.sessionId} scope unresolved`
|
|
55867
55894
|
);
|
|
55868
55895
|
}
|
|
55869
|
-
const cwdAbs =
|
|
55870
|
-
const candidateAbs =
|
|
55896
|
+
const cwdAbs = import_node_path49.default.resolve(sessionFile.cwd);
|
|
55897
|
+
const candidateAbs = import_node_path49.default.isAbsolute(args.relPath) ? import_node_path49.default.resolve(args.relPath) : import_node_path49.default.resolve(cwdAbs, args.relPath);
|
|
55871
55898
|
guardAttachmentPath(ctx, args.sessionId, candidateAbs, "attachment.signUrl", "group-acl");
|
|
55872
55899
|
const entries = deps.groupFileStore.list(scope, args.sessionId);
|
|
55873
55900
|
const entry = entries.find((e) => {
|
|
55874
|
-
const storedAbs =
|
|
55901
|
+
const storedAbs = import_node_path49.default.isAbsolute(e.relPath) ? import_node_path49.default.resolve(e.relPath) : import_node_path49.default.resolve(cwdAbs, e.relPath);
|
|
55875
55902
|
return storedAbs === candidateAbs && !e.stale;
|
|
55876
55903
|
});
|
|
55877
55904
|
if (!entry) {
|
|
@@ -55896,7 +55923,7 @@ function buildAttachmentHandlers(deps) {
|
|
|
55896
55923
|
if (!ctx || ctx.principal.kind !== "guest" || !deps.personaRoot || !deps.sessionStore) return;
|
|
55897
55924
|
const f = deps.sessionStore.read(sessionId);
|
|
55898
55925
|
if (!f) return;
|
|
55899
|
-
assertGuestAttachmentPath(ctx,
|
|
55926
|
+
assertGuestAttachmentPath(ctx, import_node_path49.default.resolve(f.cwd), deps.personaRoot, method, deps.usersRoot);
|
|
55900
55927
|
}
|
|
55901
55928
|
const groupAdd = async (frame, _client, ctx) => {
|
|
55902
55929
|
if (!deps.groupFileStore || !deps.getSessionScope) {
|
|
@@ -55911,8 +55938,8 @@ function buildAttachmentHandlers(deps) {
|
|
|
55911
55938
|
if (!scope) {
|
|
55912
55939
|
throw new ClawdError(ERROR_CODES.VALIDATION_ERROR, `session ${args.sessionId} not found`);
|
|
55913
55940
|
}
|
|
55914
|
-
const cwdAbs =
|
|
55915
|
-
const candidateAbs =
|
|
55941
|
+
const cwdAbs = import_node_path49.default.resolve(deps.sessionStore?.read(args.sessionId)?.cwd ?? ".");
|
|
55942
|
+
const candidateAbs = import_node_path49.default.isAbsolute(args.relPath) ? import_node_path49.default.resolve(args.relPath) : import_node_path49.default.resolve(cwdAbs, args.relPath);
|
|
55916
55943
|
guardAttachmentPath(ctx, args.sessionId, candidateAbs, "attachment.groupAdd", "cwd-subtree");
|
|
55917
55944
|
const from = ctx?.principal.kind === "owner" ? "owner" : "agent";
|
|
55918
55945
|
const size = 0;
|
|
@@ -55971,20 +55998,20 @@ function buildAttachmentHandlers(deps) {
|
|
|
55971
55998
|
|
|
55972
55999
|
// src/handlers/extension.ts
|
|
55973
56000
|
var import_promises8 = __toESM(require("fs/promises"), 1);
|
|
55974
|
-
var
|
|
56001
|
+
var import_node_path54 = __toESM(require("path"), 1);
|
|
55975
56002
|
init_protocol();
|
|
55976
56003
|
init_src();
|
|
55977
56004
|
|
|
55978
56005
|
// src/extension/bundle-zip.ts
|
|
55979
56006
|
var import_promises5 = __toESM(require("fs/promises"), 1);
|
|
55980
|
-
var
|
|
56007
|
+
var import_node_path50 = __toESM(require("path"), 1);
|
|
55981
56008
|
var import_node_crypto14 = __toESM(require("crypto"), 1);
|
|
55982
56009
|
var import_jszip2 = __toESM(require_lib3(), 1);
|
|
55983
56010
|
async function bundleExtensionDir(dir) {
|
|
55984
56011
|
const entries = await listFilesSorted(dir);
|
|
55985
56012
|
const zip = new import_jszip2.default();
|
|
55986
56013
|
for (const rel of entries) {
|
|
55987
|
-
const abs =
|
|
56014
|
+
const abs = import_node_path50.default.join(dir, rel);
|
|
55988
56015
|
const content = await import_promises5.default.readFile(abs);
|
|
55989
56016
|
zip.file(rel, content, { date: FIXED_DATE });
|
|
55990
56017
|
}
|
|
@@ -56005,7 +56032,7 @@ async function listFilesSorted(rootDir) {
|
|
|
56005
56032
|
return out;
|
|
56006
56033
|
}
|
|
56007
56034
|
async function walk(absRoot, relPrefix, out) {
|
|
56008
|
-
const dirAbs =
|
|
56035
|
+
const dirAbs = import_node_path50.default.join(absRoot, relPrefix);
|
|
56009
56036
|
const entries = await import_promises5.default.readdir(dirAbs, { withFileTypes: true });
|
|
56010
56037
|
for (const e of entries) {
|
|
56011
56038
|
if (IGNORE_BASENAMES.has(e.name)) continue;
|
|
@@ -56061,7 +56088,7 @@ function computePublishCheck(args) {
|
|
|
56061
56088
|
|
|
56062
56089
|
// src/extension/install-flow.ts
|
|
56063
56090
|
var import_promises6 = __toESM(require("fs/promises"), 1);
|
|
56064
|
-
var
|
|
56091
|
+
var import_node_path52 = __toESM(require("path"), 1);
|
|
56065
56092
|
var import_node_os19 = __toESM(require("os"), 1);
|
|
56066
56093
|
var import_node_crypto15 = __toESM(require("crypto"), 1);
|
|
56067
56094
|
var import_jszip3 = __toESM(require_lib3(), 1);
|
|
@@ -56069,19 +56096,19 @@ init_src();
|
|
|
56069
56096
|
|
|
56070
56097
|
// src/extension/paths.ts
|
|
56071
56098
|
var import_node_os18 = __toESM(require("os"), 1);
|
|
56072
|
-
var
|
|
56099
|
+
var import_node_path51 = __toESM(require("path"), 1);
|
|
56073
56100
|
init_src();
|
|
56074
56101
|
function clawdHomeRoot(override) {
|
|
56075
|
-
return override ?? process.env.CLAWD_HOME ??
|
|
56102
|
+
return override ?? process.env.CLAWD_HOME ?? import_node_path51.default.join(import_node_os18.default.homedir(), ".clawd");
|
|
56076
56103
|
}
|
|
56077
56104
|
function extensionsRoot(override) {
|
|
56078
|
-
return
|
|
56105
|
+
return import_node_path51.default.join(clawdHomeRoot(override), "extensions");
|
|
56079
56106
|
}
|
|
56080
56107
|
function publishedChannelsFile(override) {
|
|
56081
|
-
return
|
|
56108
|
+
return import_node_path51.default.join(clawdHomeRoot(override), "extensions-published.json");
|
|
56082
56109
|
}
|
|
56083
56110
|
function bundleCacheRoot(override) {
|
|
56084
|
-
return
|
|
56111
|
+
return import_node_path51.default.join(clawdHomeRoot(override), "extension-bundles");
|
|
56085
56112
|
}
|
|
56086
56113
|
|
|
56087
56114
|
// src/extension/install-flow.ts
|
|
@@ -56108,7 +56135,7 @@ async function installFromChannel(args, deps) {
|
|
|
56108
56135
|
throw new InstallError("ZIP_INVALID", `failed to load zip: ${e.message}`);
|
|
56109
56136
|
}
|
|
56110
56137
|
for (const name of Object.keys(zip.files)) {
|
|
56111
|
-
if (name.includes("..") || name.startsWith("/") ||
|
|
56138
|
+
if (name.includes("..") || name.startsWith("/") || import_node_path52.default.isAbsolute(name)) {
|
|
56112
56139
|
throw new InstallError("ZIP_INVALID", `unsafe zip entry: ${name}`);
|
|
56113
56140
|
}
|
|
56114
56141
|
}
|
|
@@ -56140,7 +56167,7 @@ async function installFromChannel(args, deps) {
|
|
|
56140
56167
|
);
|
|
56141
56168
|
}
|
|
56142
56169
|
const localExtId = namespacedExtId(ownerSlug, channelRef.ownerPrincipalId);
|
|
56143
|
-
const destDir =
|
|
56170
|
+
const destDir = import_node_path52.default.join(deps.extensionsRoot, localExtId);
|
|
56144
56171
|
let destExists = false;
|
|
56145
56172
|
try {
|
|
56146
56173
|
await import_promises6.default.access(destDir);
|
|
@@ -56154,16 +56181,16 @@ async function installFromChannel(args, deps) {
|
|
|
56154
56181
|
);
|
|
56155
56182
|
}
|
|
56156
56183
|
const stage = await import_promises6.default.mkdtemp(
|
|
56157
|
-
|
|
56184
|
+
import_node_path52.default.join(import_node_os19.default.tmpdir(), `clawd-ext-install-${localExtId}-`)
|
|
56158
56185
|
);
|
|
56159
56186
|
try {
|
|
56160
56187
|
for (const [name, entry] of Object.entries(zip.files)) {
|
|
56161
|
-
const dest =
|
|
56188
|
+
const dest = import_node_path52.default.join(stage, name);
|
|
56162
56189
|
if (entry.dir) {
|
|
56163
56190
|
await import_promises6.default.mkdir(dest, { recursive: true });
|
|
56164
56191
|
continue;
|
|
56165
56192
|
}
|
|
56166
|
-
await import_promises6.default.mkdir(
|
|
56193
|
+
await import_promises6.default.mkdir(import_node_path52.default.dirname(dest), { recursive: true });
|
|
56167
56194
|
if (name === "manifest.json") {
|
|
56168
56195
|
const rewritten = { ...parsed.data, id: localExtId };
|
|
56169
56196
|
await import_promises6.default.writeFile(dest, JSON.stringify(rewritten, null, 2));
|
|
@@ -56184,7 +56211,7 @@ async function installFromChannel(args, deps) {
|
|
|
56184
56211
|
|
|
56185
56212
|
// src/extension/update-flow.ts
|
|
56186
56213
|
var import_promises7 = __toESM(require("fs/promises"), 1);
|
|
56187
|
-
var
|
|
56214
|
+
var import_node_path53 = __toESM(require("path"), 1);
|
|
56188
56215
|
var import_node_os20 = __toESM(require("os"), 1);
|
|
56189
56216
|
var import_node_crypto16 = __toESM(require("crypto"), 1);
|
|
56190
56217
|
var import_jszip4 = __toESM(require_lib3(), 1);
|
|
@@ -56202,11 +56229,11 @@ async function updateFromChannel(args, deps) {
|
|
|
56202
56229
|
channelRef.extId,
|
|
56203
56230
|
channelRef.ownerPrincipalId
|
|
56204
56231
|
);
|
|
56205
|
-
const liveDir =
|
|
56232
|
+
const liveDir = import_node_path53.default.join(deps.extensionsRoot, localExtId);
|
|
56206
56233
|
const prevDir = `${liveDir}.prev`;
|
|
56207
56234
|
let existingVersion;
|
|
56208
56235
|
try {
|
|
56209
|
-
const raw = await import_promises7.default.readFile(
|
|
56236
|
+
const raw = await import_promises7.default.readFile(import_node_path53.default.join(liveDir, "manifest.json"), "utf8");
|
|
56210
56237
|
const parsed2 = ExtensionManifestSchema.safeParse(JSON.parse(raw));
|
|
56211
56238
|
if (!parsed2.success) {
|
|
56212
56239
|
throw new UpdateError(
|
|
@@ -56239,7 +56266,7 @@ async function updateFromChannel(args, deps) {
|
|
|
56239
56266
|
throw new UpdateError("ZIP_INVALID", `failed to load zip: ${e.message}`);
|
|
56240
56267
|
}
|
|
56241
56268
|
for (const name of Object.keys(zip.files)) {
|
|
56242
|
-
if (name.includes("..") || name.startsWith("/") ||
|
|
56269
|
+
if (name.includes("..") || name.startsWith("/") || import_node_path53.default.isAbsolute(name)) {
|
|
56243
56270
|
throw new UpdateError("ZIP_INVALID", `unsafe zip entry: ${name}`);
|
|
56244
56271
|
}
|
|
56245
56272
|
}
|
|
@@ -56274,16 +56301,16 @@ async function updateFromChannel(args, deps) {
|
|
|
56274
56301
|
await import_promises7.default.rm(prevDir, { recursive: true, force: true });
|
|
56275
56302
|
await import_promises7.default.rename(liveDir, prevDir);
|
|
56276
56303
|
const stage = await import_promises7.default.mkdtemp(
|
|
56277
|
-
|
|
56304
|
+
import_node_path53.default.join(import_node_os20.default.tmpdir(), `clawd-ext-update-${localExtId}-`)
|
|
56278
56305
|
);
|
|
56279
56306
|
try {
|
|
56280
56307
|
for (const [name, entry] of Object.entries(zip.files)) {
|
|
56281
|
-
const dest =
|
|
56308
|
+
const dest = import_node_path53.default.join(stage, name);
|
|
56282
56309
|
if (entry.dir) {
|
|
56283
56310
|
await import_promises7.default.mkdir(dest, { recursive: true });
|
|
56284
56311
|
continue;
|
|
56285
56312
|
}
|
|
56286
|
-
await import_promises7.default.mkdir(
|
|
56313
|
+
await import_promises7.default.mkdir(import_node_path53.default.dirname(dest), { recursive: true });
|
|
56287
56314
|
if (name === "manifest.json") {
|
|
56288
56315
|
const rewritten = { ...parsed.data, id: localExtId };
|
|
56289
56316
|
await import_promises7.default.writeFile(dest, JSON.stringify(rewritten, null, 2));
|
|
@@ -56377,7 +56404,7 @@ async function rewriteManifestVersion(root, extId, newVersion, previousPublished
|
|
|
56377
56404
|
);
|
|
56378
56405
|
}
|
|
56379
56406
|
}
|
|
56380
|
-
const manifestPath =
|
|
56407
|
+
const manifestPath = import_node_path54.default.join(root, extId, "manifest.json");
|
|
56381
56408
|
const manifest = await readManifest(root, extId);
|
|
56382
56409
|
const next = { ...manifest, version: newVersion };
|
|
56383
56410
|
const tmp = `${manifestPath}.tmp`;
|
|
@@ -56385,7 +56412,7 @@ async function rewriteManifestVersion(root, extId, newVersion, previousPublished
|
|
|
56385
56412
|
await import_promises8.default.rename(tmp, manifestPath);
|
|
56386
56413
|
}
|
|
56387
56414
|
async function readManifest(root, extId) {
|
|
56388
|
-
const file =
|
|
56415
|
+
const file = import_node_path54.default.join(root, extId, "manifest.json");
|
|
56389
56416
|
let raw;
|
|
56390
56417
|
try {
|
|
56391
56418
|
raw = await import_promises8.default.readFile(file, "utf8");
|
|
@@ -56476,7 +56503,7 @@ function buildExtensionHandlers(deps) {
|
|
|
56476
56503
|
};
|
|
56477
56504
|
async function buildSnapshotMeta(extId) {
|
|
56478
56505
|
const manifest = await readManifest(deps.root, extId);
|
|
56479
|
-
const { sha256, buffer } = await bundleExtensionDir(
|
|
56506
|
+
const { sha256, buffer } = await bundleExtensionDir(import_node_path54.default.join(deps.root, extId));
|
|
56480
56507
|
return { manifest, contentHash: sha256, buffer };
|
|
56481
56508
|
}
|
|
56482
56509
|
const publish = async (frame, _client, ctx) => {
|
|
@@ -56657,9 +56684,9 @@ function buildExtensionHandlers(deps) {
|
|
|
56657
56684
|
}
|
|
56658
56685
|
|
|
56659
56686
|
// src/app-builder/project-store.ts
|
|
56660
|
-
var
|
|
56687
|
+
var import_node_fs47 = require("fs");
|
|
56661
56688
|
var import_node_child_process14 = require("child_process");
|
|
56662
|
-
var
|
|
56689
|
+
var import_node_path55 = require("path");
|
|
56663
56690
|
init_protocol();
|
|
56664
56691
|
var PROJECTS_DIR = "projects";
|
|
56665
56692
|
var META_FILE = ".clawd-project.json";
|
|
@@ -56673,19 +56700,19 @@ var ProjectStore = class {
|
|
|
56673
56700
|
root;
|
|
56674
56701
|
/** projects/<name>/.clawd-project.json 路径 */
|
|
56675
56702
|
metaPath(name) {
|
|
56676
|
-
return (0,
|
|
56703
|
+
return (0, import_node_path55.join)(this.projectsRoot(), name, META_FILE);
|
|
56677
56704
|
}
|
|
56678
56705
|
/** projects/<name>/ 目录路径(cwd 用) */
|
|
56679
56706
|
projectDir(name) {
|
|
56680
|
-
return (0,
|
|
56707
|
+
return (0, import_node_path55.join)(this.projectsRoot(), name);
|
|
56681
56708
|
}
|
|
56682
56709
|
projectsRoot() {
|
|
56683
|
-
return (0,
|
|
56710
|
+
return (0, import_node_path55.join)(this.root, PROJECTS_DIR);
|
|
56684
56711
|
}
|
|
56685
56712
|
async list() {
|
|
56686
56713
|
let entries;
|
|
56687
56714
|
try {
|
|
56688
|
-
entries = await
|
|
56715
|
+
entries = await import_node_fs47.promises.readdir(this.projectsRoot());
|
|
56689
56716
|
} catch (err) {
|
|
56690
56717
|
if (err.code === "ENOENT") return [];
|
|
56691
56718
|
throw err;
|
|
@@ -56693,7 +56720,7 @@ var ProjectStore = class {
|
|
|
56693
56720
|
const out = [];
|
|
56694
56721
|
for (const name of entries) {
|
|
56695
56722
|
try {
|
|
56696
|
-
const raw = await
|
|
56723
|
+
const raw = await import_node_fs47.promises.readFile(this.metaPath(name), "utf8");
|
|
56697
56724
|
const json = JSON.parse(raw);
|
|
56698
56725
|
let migrated = false;
|
|
56699
56726
|
if (typeof json.devCommand !== "string" || json.devCommand.length === 0) {
|
|
@@ -56704,7 +56731,7 @@ var ProjectStore = class {
|
|
|
56704
56731
|
if (parsed.success) {
|
|
56705
56732
|
out.push(parsed.data);
|
|
56706
56733
|
if (migrated) {
|
|
56707
|
-
void
|
|
56734
|
+
void import_node_fs47.promises.writeFile(this.metaPath(name), JSON.stringify(parsed.data, null, 2) + "\n", "utf8").catch(() => {
|
|
56708
56735
|
});
|
|
56709
56736
|
}
|
|
56710
56737
|
}
|
|
@@ -56748,8 +56775,8 @@ var ProjectStore = class {
|
|
|
56748
56775
|
throw new Error(`invalid name "${name}": ${validated.error.message}`);
|
|
56749
56776
|
}
|
|
56750
56777
|
const dir = this.projectDir(name);
|
|
56751
|
-
await
|
|
56752
|
-
await
|
|
56778
|
+
await import_node_fs47.promises.mkdir(dir, { recursive: true });
|
|
56779
|
+
await import_node_fs47.promises.writeFile(this.metaPath(name), JSON.stringify(meta, null, 2) + "\n", "utf8");
|
|
56753
56780
|
return meta;
|
|
56754
56781
|
}
|
|
56755
56782
|
/**
|
|
@@ -56792,7 +56819,7 @@ var ProjectStore = class {
|
|
|
56792
56819
|
}
|
|
56793
56820
|
async delete(name) {
|
|
56794
56821
|
const dir = this.projectDir(name);
|
|
56795
|
-
await
|
|
56822
|
+
await import_node_fs47.promises.rm(dir, { recursive: true, force: true });
|
|
56796
56823
|
}
|
|
56797
56824
|
async updatePort(name, newPort) {
|
|
56798
56825
|
if (newPort < PROJECT_PORT_MIN || newPort > PROJECT_PORT_MAX) {
|
|
@@ -56808,7 +56835,7 @@ var ProjectStore = class {
|
|
|
56808
56835
|
throw new Error(`port ${newPort} already used / \u5DF2\u88AB project "${conflict.name}" \u5360\u7528`);
|
|
56809
56836
|
}
|
|
56810
56837
|
const updated = { ...target, port: newPort };
|
|
56811
|
-
await
|
|
56838
|
+
await import_node_fs47.promises.writeFile(this.metaPath(name), JSON.stringify(updated, null, 2) + "\n", "utf8");
|
|
56812
56839
|
return updated;
|
|
56813
56840
|
}
|
|
56814
56841
|
/**
|
|
@@ -56825,7 +56852,7 @@ var ProjectStore = class {
|
|
|
56825
56852
|
if (!validated.success) {
|
|
56826
56853
|
throw new Error(`invalid prodUrl "${url}": ${validated.error.message}`);
|
|
56827
56854
|
}
|
|
56828
|
-
await
|
|
56855
|
+
await import_node_fs47.promises.writeFile(this.metaPath(name), JSON.stringify(validated.data, null, 2) + "\n", "utf8");
|
|
56829
56856
|
return validated.data;
|
|
56830
56857
|
}
|
|
56831
56858
|
/**
|
|
@@ -56846,7 +56873,7 @@ var ProjectStore = class {
|
|
|
56846
56873
|
if (!validated.success) {
|
|
56847
56874
|
throw new Error(`invalid publishJob: ${validated.error.message}`);
|
|
56848
56875
|
}
|
|
56849
|
-
await
|
|
56876
|
+
await import_node_fs47.promises.writeFile(this.metaPath(name), JSON.stringify(validated.data, null, 2) + "\n", "utf8");
|
|
56850
56877
|
return validated.data;
|
|
56851
56878
|
}
|
|
56852
56879
|
/** 清掉 .clawd-project.json.publishJob 字段。其他字段保持原样。 */
|
|
@@ -56861,7 +56888,7 @@ var ProjectStore = class {
|
|
|
56861
56888
|
if (!validated.success) {
|
|
56862
56889
|
throw new Error(`failed to clear publishJob: ${validated.error.message}`);
|
|
56863
56890
|
}
|
|
56864
|
-
await
|
|
56891
|
+
await import_node_fs47.promises.writeFile(this.metaPath(name), JSON.stringify(validated.data, null, 2) + "\n", "utf8");
|
|
56865
56892
|
return validated.data;
|
|
56866
56893
|
}
|
|
56867
56894
|
};
|
|
@@ -56982,8 +57009,8 @@ var PublishJobRegistry = class {
|
|
|
56982
57009
|
|
|
56983
57010
|
// src/app-builder/publish-job-runner.ts
|
|
56984
57011
|
var import_node_child_process16 = require("child_process");
|
|
56985
|
-
var
|
|
56986
|
-
var
|
|
57012
|
+
var import_node_fs48 = require("fs");
|
|
57013
|
+
var import_node_path56 = require("path");
|
|
56987
57014
|
|
|
56988
57015
|
// src/app-builder/publish-stage-parser.ts
|
|
56989
57016
|
var STAGE_RE = /^\s*::stage::(build|deploy|verify)\s*$/;
|
|
@@ -57015,10 +57042,10 @@ async function startPublishJob(deps, args) {
|
|
|
57015
57042
|
return { jobId: registry2.get(args.name).jobId, status: "already-publishing" };
|
|
57016
57043
|
}
|
|
57017
57044
|
const projDir = projectDir(args.name);
|
|
57018
|
-
const logPath = (0,
|
|
57045
|
+
const logPath = (0, import_node_path56.join)(projDir, ".publish.log");
|
|
57019
57046
|
let logStream = null;
|
|
57020
57047
|
try {
|
|
57021
|
-
logStream = (0,
|
|
57048
|
+
logStream = (0, import_node_fs48.createWriteStream)(logPath, { flags: "w" });
|
|
57022
57049
|
} catch {
|
|
57023
57050
|
logStream = null;
|
|
57024
57051
|
}
|
|
@@ -57275,8 +57302,8 @@ async function recoverInterruptedJobs(deps) {
|
|
|
57275
57302
|
|
|
57276
57303
|
// src/handlers/app-builder.ts
|
|
57277
57304
|
init_protocol();
|
|
57278
|
-
var
|
|
57279
|
-
var
|
|
57305
|
+
var import_node_path57 = require("path");
|
|
57306
|
+
var import_node_fs49 = require("fs");
|
|
57280
57307
|
var APP_BUILDER_PERSONAS = ["persona-app-builder", "persona-dataclaw-builder"];
|
|
57281
57308
|
var DEV_SERVER_READY_TIMEOUT_MS = 3e4;
|
|
57282
57309
|
async function recoverInterruptedPublishJobs(store, logger) {
|
|
@@ -57357,7 +57384,7 @@ function buildAppBuilderHandlers(deps) {
|
|
|
57357
57384
|
async function listAllUsersProjects() {
|
|
57358
57385
|
if (!deps.usersRoot || !deps.getStore) return [];
|
|
57359
57386
|
const getStore = deps.getStore;
|
|
57360
|
-
const userIds = await
|
|
57387
|
+
const userIds = await import_node_fs49.promises.readdir(deps.usersRoot).catch(() => []);
|
|
57361
57388
|
const perUser = await Promise.all(
|
|
57362
57389
|
userIds.map((uid) => getStore(uid).list().catch(() => []))
|
|
57363
57390
|
);
|
|
@@ -57433,8 +57460,8 @@ function buildAppBuilderHandlers(deps) {
|
|
|
57433
57460
|
const project = await userStore.create(f.name, reservedPorts);
|
|
57434
57461
|
try {
|
|
57435
57462
|
const personaRoot = deps.resolvePersonaRoot ? deps.resolvePersonaRoot(session.ownerPersonaId ?? "") : deps.personaRoot;
|
|
57436
|
-
const templateSrcDir = (0,
|
|
57437
|
-
const scaffoldScript = (0,
|
|
57463
|
+
const templateSrcDir = (0, import_node_path57.join)(personaRoot, "extension-kit", "examples", DEFAULT_TEMPLATE);
|
|
57464
|
+
const scaffoldScript = (0, import_node_path57.join)(deps.deployKitRoot, "scripts", "new-extension.sh");
|
|
57438
57465
|
const scaffoldResult = await userStore.scaffold(project.name, templateSrcDir, scaffoldScript);
|
|
57439
57466
|
deps.logger?.info("app-builder.scaffold.done", {
|
|
57440
57467
|
name: project.name,
|
|
@@ -57655,7 +57682,7 @@ function buildAppBuilderHandlers(deps) {
|
|
|
57655
57682
|
await userStore.clearPublishJob(args.name);
|
|
57656
57683
|
}
|
|
57657
57684
|
const personaRoot = deps.resolvePersonaRoot ? deps.resolvePersonaRoot(boundSession.ownerPersonaId ?? "") : deps.personaRoot;
|
|
57658
|
-
const scriptPath = (0,
|
|
57685
|
+
const scriptPath = (0, import_node_path57.join)(deps.deployKitRoot, "scripts", "publish.sh");
|
|
57659
57686
|
deps.logger?.info("app-builder.publish.start", {
|
|
57660
57687
|
name: args.name,
|
|
57661
57688
|
sessionId: boundSession.sessionId,
|
|
@@ -57824,7 +57851,7 @@ function buildVisitorHandlers(deps) {
|
|
|
57824
57851
|
|
|
57825
57852
|
// src/extension/registry.ts
|
|
57826
57853
|
var import_promises9 = __toESM(require("fs/promises"), 1);
|
|
57827
|
-
var
|
|
57854
|
+
var import_node_path58 = __toESM(require("path"), 1);
|
|
57828
57855
|
init_src();
|
|
57829
57856
|
async function loadAll(root) {
|
|
57830
57857
|
let entries;
|
|
@@ -57838,13 +57865,13 @@ async function loadAll(root) {
|
|
|
57838
57865
|
for (const ent of entries) {
|
|
57839
57866
|
if (!ent.isDirectory()) continue;
|
|
57840
57867
|
if (ent.name.startsWith(".")) continue;
|
|
57841
|
-
records.push(await loadOne(
|
|
57868
|
+
records.push(await loadOne(import_node_path58.default.join(root, ent.name), ent.name));
|
|
57842
57869
|
}
|
|
57843
57870
|
records.sort((a, b2) => a.extId < b2.extId ? -1 : a.extId > b2.extId ? 1 : 0);
|
|
57844
57871
|
return records;
|
|
57845
57872
|
}
|
|
57846
57873
|
async function loadOne(dir, dirName) {
|
|
57847
|
-
const manifestPath =
|
|
57874
|
+
const manifestPath = import_node_path58.default.join(dir, "manifest.json");
|
|
57848
57875
|
let raw;
|
|
57849
57876
|
try {
|
|
57850
57877
|
raw = await import_promises9.default.readFile(manifestPath, "utf8");
|
|
@@ -57889,7 +57916,7 @@ async function loadOne(dir, dirName) {
|
|
|
57889
57916
|
|
|
57890
57917
|
// src/extension/uninstall.ts
|
|
57891
57918
|
var import_promises10 = __toESM(require("fs/promises"), 1);
|
|
57892
|
-
var
|
|
57919
|
+
var import_node_path59 = __toESM(require("path"), 1);
|
|
57893
57920
|
var UninstallError = class extends Error {
|
|
57894
57921
|
constructor(code, message) {
|
|
57895
57922
|
super(message);
|
|
@@ -57898,7 +57925,7 @@ var UninstallError = class extends Error {
|
|
|
57898
57925
|
code;
|
|
57899
57926
|
};
|
|
57900
57927
|
async function uninstall(deps) {
|
|
57901
|
-
const dir =
|
|
57928
|
+
const dir = import_node_path59.default.join(deps.root, deps.extId);
|
|
57902
57929
|
try {
|
|
57903
57930
|
await import_promises10.default.access(dir);
|
|
57904
57931
|
} catch {
|
|
@@ -58482,7 +58509,7 @@ async function dispatchRpc(method, frame, client, ctx, deps) {
|
|
|
58482
58509
|
|
|
58483
58510
|
// src/extension/runtime.ts
|
|
58484
58511
|
var import_node_child_process18 = require("child_process");
|
|
58485
|
-
var
|
|
58512
|
+
var import_node_path60 = __toESM(require("path"), 1);
|
|
58486
58513
|
var import_promises11 = require("timers/promises");
|
|
58487
58514
|
init_src();
|
|
58488
58515
|
|
|
@@ -58584,7 +58611,7 @@ var Runtime = class {
|
|
|
58584
58611
|
/\$CLAWOS_EXT_PORT/g,
|
|
58585
58612
|
String(port)
|
|
58586
58613
|
);
|
|
58587
|
-
const dir =
|
|
58614
|
+
const dir = import_node_path60.default.join(this.root, extId);
|
|
58588
58615
|
const env = {
|
|
58589
58616
|
...process.env,
|
|
58590
58617
|
CLAWOS_EXT_PORT: String(port),
|
|
@@ -58696,7 +58723,7 @@ ${handle.stderrTail}`
|
|
|
58696
58723
|
|
|
58697
58724
|
// src/extension/published-channels.ts
|
|
58698
58725
|
var import_promises12 = __toESM(require("fs/promises"), 1);
|
|
58699
|
-
var
|
|
58726
|
+
var import_node_path61 = __toESM(require("path"), 1);
|
|
58700
58727
|
init_src();
|
|
58701
58728
|
init_zod();
|
|
58702
58729
|
var PublishedChannelsError = class extends Error {
|
|
@@ -58796,7 +58823,7 @@ var PublishedChannelStore = class {
|
|
|
58796
58823
|
)
|
|
58797
58824
|
};
|
|
58798
58825
|
const tmp = `${this.filePath}.tmp`;
|
|
58799
|
-
await import_promises12.default.mkdir(
|
|
58826
|
+
await import_promises12.default.mkdir(import_node_path61.default.dirname(this.filePath), { recursive: true });
|
|
58800
58827
|
await import_promises12.default.writeFile(tmp, JSON.stringify(data, null, 2), { mode: 384 });
|
|
58801
58828
|
await import_promises12.default.rename(tmp, this.filePath);
|
|
58802
58829
|
}
|
|
@@ -58804,7 +58831,7 @@ var PublishedChannelStore = class {
|
|
|
58804
58831
|
|
|
58805
58832
|
// src/extension/bundle-cache.ts
|
|
58806
58833
|
var import_promises13 = __toESM(require("fs/promises"), 1);
|
|
58807
|
-
var
|
|
58834
|
+
var import_node_path62 = __toESM(require("path"), 1);
|
|
58808
58835
|
var BundleCache = class {
|
|
58809
58836
|
constructor(rootDir) {
|
|
58810
58837
|
this.rootDir = rootDir;
|
|
@@ -58813,14 +58840,14 @@ var BundleCache = class {
|
|
|
58813
58840
|
/** Atomic write: stage tmp → rename. Caller passes the hex sha256. */
|
|
58814
58841
|
async write(snapshotHash, buffer) {
|
|
58815
58842
|
await import_promises13.default.mkdir(this.rootDir, { recursive: true });
|
|
58816
|
-
const file =
|
|
58843
|
+
const file = import_node_path62.default.join(this.rootDir, `${snapshotHash}.zip`);
|
|
58817
58844
|
const tmp = `${file}.tmp`;
|
|
58818
58845
|
await import_promises13.default.writeFile(tmp, buffer, { mode: 384 });
|
|
58819
58846
|
await import_promises13.default.rename(tmp, file);
|
|
58820
58847
|
}
|
|
58821
58848
|
/** Returns the bundle bytes, or null when the file doesn't exist. */
|
|
58822
58849
|
async read(snapshotHash) {
|
|
58823
|
-
const file =
|
|
58850
|
+
const file = import_node_path62.default.join(this.rootDir, `${snapshotHash}.zip`);
|
|
58824
58851
|
try {
|
|
58825
58852
|
return await import_promises13.default.readFile(file);
|
|
58826
58853
|
} catch (e) {
|
|
@@ -58830,7 +58857,7 @@ var BundleCache = class {
|
|
|
58830
58857
|
}
|
|
58831
58858
|
/** Idempotent — missing file is not an error. */
|
|
58832
58859
|
async delete(snapshotHash) {
|
|
58833
|
-
const file =
|
|
58860
|
+
const file = import_node_path62.default.join(this.rootDir, `${snapshotHash}.zip`);
|
|
58834
58861
|
await import_promises13.default.rm(file, { force: true });
|
|
58835
58862
|
}
|
|
58836
58863
|
};
|
|
@@ -58855,16 +58882,16 @@ async function startDaemon(config) {
|
|
|
58855
58882
|
});
|
|
58856
58883
|
const logger = createLogger({
|
|
58857
58884
|
level: config.logLevel,
|
|
58858
|
-
file:
|
|
58885
|
+
file: import_node_path63.default.join(config.dataDir, "clawd.log"),
|
|
58859
58886
|
logClient
|
|
58860
58887
|
});
|
|
58861
58888
|
logger.info("starting clawd", { version, config: { port: config.port, host: config.host, dataDir: config.dataDir } });
|
|
58862
58889
|
const screenIdleProbeLogger = createFileOnlyLogger({
|
|
58863
|
-
file:
|
|
58890
|
+
file: import_node_path63.default.join(config.dataDir, "screen-idle-probe.log"),
|
|
58864
58891
|
level: "debug"
|
|
58865
58892
|
});
|
|
58866
58893
|
logger.info("screen-idle probe logger enabled", {
|
|
58867
|
-
file:
|
|
58894
|
+
file: import_node_path63.default.join(config.dataDir, "screen-idle-probe.log")
|
|
58868
58895
|
});
|
|
58869
58896
|
const stateMgr = new StateFileManager({ dataDir: config.dataDir });
|
|
58870
58897
|
const pre = stateMgr.preflight();
|
|
@@ -59002,8 +59029,8 @@ async function startDaemon(config) {
|
|
|
59002
59029
|
const agents = new AgentsScanner();
|
|
59003
59030
|
const history = new ClaudeHistoryReader();
|
|
59004
59031
|
let transport = null;
|
|
59005
|
-
const personaStore = new PersonaStore(
|
|
59006
|
-
const usersRoot =
|
|
59032
|
+
const personaStore = new PersonaStore(import_node_path63.default.join(config.dataDir, "personas"));
|
|
59033
|
+
const usersRoot = import_node_path63.default.join(config.dataDir, "users");
|
|
59007
59034
|
const defaultsRoot = findDefaultsRoot(logger);
|
|
59008
59035
|
if (defaultsRoot) {
|
|
59009
59036
|
seedDefaultPersonas({ store: personaStore, defaultsRoot, logger });
|
|
@@ -59023,17 +59050,17 @@ async function startDaemon(config) {
|
|
|
59023
59050
|
migrateCodexSandbox({ store: personaStore, logger });
|
|
59024
59051
|
const groupFileStore = new GroupFileStore({ dataDir: config.dataDir, logger });
|
|
59025
59052
|
const personaDispatchManager = new PersonaDispatchManager({ genId: () => v4_default() });
|
|
59026
|
-
const here = typeof __dirname === "string" ? __dirname :
|
|
59053
|
+
const here = typeof __dirname === "string" ? __dirname : import_node_path63.default.dirname((0, import_node_url4.fileURLToPath)(import_meta6.url));
|
|
59027
59054
|
const dispatchServerCandidates = [
|
|
59028
|
-
|
|
59055
|
+
import_node_path63.default.join(here, "dispatch", "mcp-server.cjs"),
|
|
59029
59056
|
// 生产 dist/index → dist/dispatch/mcp-server.cjs
|
|
59030
|
-
|
|
59057
|
+
import_node_path63.default.join(here, "..", "dist", "dispatch", "mcp-server.cjs")
|
|
59031
59058
|
// dev tsx src/index → ../dist/dispatch/mcp-server.cjs
|
|
59032
59059
|
];
|
|
59033
|
-
const dispatchServerScriptPath = dispatchServerCandidates.find((p2) =>
|
|
59060
|
+
const dispatchServerScriptPath = dispatchServerCandidates.find((p2) => import_node_fs50.default.existsSync(p2));
|
|
59034
59061
|
let dispatchMcpConfigPath2;
|
|
59035
59062
|
if (dispatchServerScriptPath) {
|
|
59036
|
-
const dispatchLogPath =
|
|
59063
|
+
const dispatchLogPath = import_node_path63.default.join(config.dataDir, "dispatch-mcp-server.log");
|
|
59037
59064
|
dispatchMcpConfigPath2 = writeDispatchMcpConfig({
|
|
59038
59065
|
dataDir: config.dataDir,
|
|
59039
59066
|
serverScriptPath: dispatchServerScriptPath,
|
|
@@ -59050,15 +59077,15 @@ async function startDaemon(config) {
|
|
|
59050
59077
|
});
|
|
59051
59078
|
}
|
|
59052
59079
|
const ticketServerCandidates = [
|
|
59053
|
-
|
|
59054
|
-
|
|
59080
|
+
import_node_path63.default.join(here, "ticket", "mcp-server.cjs"),
|
|
59081
|
+
import_node_path63.default.join(here, "..", "dist", "ticket", "mcp-server.cjs")
|
|
59055
59082
|
];
|
|
59056
|
-
const ticketServerScriptPath = ticketServerCandidates.find((p2) =>
|
|
59083
|
+
const ticketServerScriptPath = ticketServerCandidates.find((p2) => import_node_fs50.default.existsSync(p2));
|
|
59057
59084
|
const ticketOwnerUnionId = feishuIdentity?.identity.unionId ?? "";
|
|
59058
59085
|
const ticketOwnerName = feishuIdentity?.identity.displayName ?? "";
|
|
59059
59086
|
let ticketMcpConfigPath2;
|
|
59060
59087
|
if (ticketServerScriptPath && ticketOwnerUnionId) {
|
|
59061
|
-
const ticketLogPath =
|
|
59088
|
+
const ticketLogPath = import_node_path63.default.join(config.dataDir, "ticket-mcp-server.log");
|
|
59062
59089
|
ticketMcpConfigPath2 = writeTicketMcpConfig({
|
|
59063
59090
|
dataDir: config.dataDir,
|
|
59064
59091
|
serverScriptPath: ticketServerScriptPath,
|
|
@@ -59079,13 +59106,13 @@ async function startDaemon(config) {
|
|
|
59079
59106
|
});
|
|
59080
59107
|
}
|
|
59081
59108
|
const shiftServerCandidates = [
|
|
59082
|
-
|
|
59083
|
-
|
|
59109
|
+
import_node_path63.default.join(here, "shift", "mcp-server.cjs"),
|
|
59110
|
+
import_node_path63.default.join(here, "..", "dist", "shift", "mcp-server.cjs")
|
|
59084
59111
|
];
|
|
59085
|
-
const shiftServerScriptPath = shiftServerCandidates.find((p2) =>
|
|
59112
|
+
const shiftServerScriptPath = shiftServerCandidates.find((p2) => import_node_fs50.default.existsSync(p2));
|
|
59086
59113
|
let shiftMcpConfigPath2;
|
|
59087
59114
|
if (shiftServerScriptPath) {
|
|
59088
|
-
const shiftLogPath =
|
|
59115
|
+
const shiftLogPath = import_node_path63.default.join(config.dataDir, "shift-mcp-server.log");
|
|
59089
59116
|
shiftMcpConfigPath2 = await writeShiftMcpConfig({
|
|
59090
59117
|
dataDir: config.dataDir,
|
|
59091
59118
|
serverScriptPath: shiftServerScriptPath,
|
|
@@ -59103,13 +59130,13 @@ async function startDaemon(config) {
|
|
|
59103
59130
|
);
|
|
59104
59131
|
}
|
|
59105
59132
|
const inboxServerCandidates = [
|
|
59106
|
-
|
|
59107
|
-
|
|
59133
|
+
import_node_path63.default.join(here, "inbox", "mcp-server.cjs"),
|
|
59134
|
+
import_node_path63.default.join(here, "..", "dist", "inbox", "mcp-server.cjs")
|
|
59108
59135
|
];
|
|
59109
|
-
const inboxServerScriptPath = inboxServerCandidates.find((p2) =>
|
|
59136
|
+
const inboxServerScriptPath = inboxServerCandidates.find((p2) => import_node_fs50.default.existsSync(p2));
|
|
59110
59137
|
let inboxMcpConfigPath2;
|
|
59111
59138
|
if (inboxServerScriptPath) {
|
|
59112
|
-
const inboxLogPath =
|
|
59139
|
+
const inboxLogPath = import_node_path63.default.join(config.dataDir, "inbox-mcp-server.log");
|
|
59113
59140
|
inboxMcpConfigPath2 = await writeInboxMcpConfig({
|
|
59114
59141
|
dataDir: config.dataDir,
|
|
59115
59142
|
serverScriptPath: inboxServerScriptPath,
|
|
@@ -59127,7 +59154,7 @@ async function startDaemon(config) {
|
|
|
59127
59154
|
);
|
|
59128
59155
|
}
|
|
59129
59156
|
const shiftStore = createShiftStore({
|
|
59130
|
-
filePath:
|
|
59157
|
+
filePath: import_node_path63.default.join(config.dataDir, "shift.json"),
|
|
59131
59158
|
ownerIdProvider: () => ownerPrincipalId,
|
|
59132
59159
|
now: () => Date.now()
|
|
59133
59160
|
});
|
|
@@ -59149,7 +59176,7 @@ async function startDaemon(config) {
|
|
|
59149
59176
|
getAdapter,
|
|
59150
59177
|
historyReader: history,
|
|
59151
59178
|
dataDir: config.dataDir,
|
|
59152
|
-
personaRoot:
|
|
59179
|
+
personaRoot: import_node_path63.default.join(config.dataDir, "personas"),
|
|
59153
59180
|
usersRoot,
|
|
59154
59181
|
personaStore,
|
|
59155
59182
|
ownerDisplayName,
|
|
@@ -59192,10 +59219,10 @@ async function startDaemon(config) {
|
|
|
59192
59219
|
// 文件可能 agent 写完又被自己删(罕见),用 size=0 / fallback mime 兜底。
|
|
59193
59220
|
attachmentGroup: {
|
|
59194
59221
|
onFileEdit: (input) => {
|
|
59195
|
-
const absPath =
|
|
59222
|
+
const absPath = import_node_path63.default.isAbsolute(input.relPath) ? input.relPath : import_node_path63.default.join(input.cwd, input.relPath);
|
|
59196
59223
|
let size = 0;
|
|
59197
59224
|
try {
|
|
59198
|
-
size =
|
|
59225
|
+
size = import_node_fs50.default.statSync(absPath).size;
|
|
59199
59226
|
} catch (err) {
|
|
59200
59227
|
logger.warn("attachment.onFileEdit stat failed", {
|
|
59201
59228
|
sessionId: input.sessionId,
|
|
@@ -59394,11 +59421,11 @@ async function startDaemon(config) {
|
|
|
59394
59421
|
// 'persona/<pid>/owner',default 走 'default'。
|
|
59395
59422
|
getSessionScope: (sid) => manager.findOwnedSessionScope(sid),
|
|
59396
59423
|
// guest path guard:candidate 必须在 personaRoot 子树或调用者自己的 user-dir 下
|
|
59397
|
-
personaRoot:
|
|
59424
|
+
personaRoot: import_node_path63.default.join(config.dataDir, "personas"),
|
|
59398
59425
|
usersRoot
|
|
59399
59426
|
},
|
|
59400
59427
|
// workspace/git/history/skills/agents handler 共用的 guest path guard 锚点
|
|
59401
|
-
personaRoot:
|
|
59428
|
+
personaRoot: import_node_path63.default.join(config.dataDir, "personas"),
|
|
59402
59429
|
// v2 多人 persona 隔离:handler 派生 guest user-dir 放行
|
|
59403
59430
|
usersRoot,
|
|
59404
59431
|
// capability:list / delete handler 依赖
|
|
@@ -59420,7 +59447,7 @@ async function startDaemon(config) {
|
|
|
59420
59447
|
contactStore,
|
|
59421
59448
|
// <dataDir>/sshd 绝对路径 —— contact-ssh handlers 用它拼 authorized_keys / keys/ 子路径
|
|
59422
59449
|
// Task 10 会加 SshdManager 起 sshd;handlers wire 提前挂 sshdDir 让 typecheck 过
|
|
59423
|
-
sshdDir:
|
|
59450
|
+
sshdDir: import_node_path63.default.join(config.dataDir, "sshd"),
|
|
59424
59451
|
contactSshLog: sshLog,
|
|
59425
59452
|
// inbox:sendDm 用:sessionId → session 出身(复用 attachment 同款 findOwnedSessionScope)
|
|
59426
59453
|
getSessionScope: (sid) => manager.findOwnedSessionScope(sid),
|
|
@@ -59511,11 +59538,11 @@ async function startDaemon(config) {
|
|
|
59511
59538
|
// 发布上线脚手架化 (spec 2026-06-03 §5.2):
|
|
59512
59539
|
// appBuilderPersonaRoot 用于拼 publish.sh 绝对路径(persona-app-builder 安装在
|
|
59513
59540
|
// dataDir/personas/persona-app-builder 之下,extension-kit/scripts/publish.sh 是相对路径)。
|
|
59514
|
-
appBuilderPersonaRoot:
|
|
59541
|
+
appBuilderPersonaRoot: import_node_path63.default.join(config.dataDir, "personas", "persona-app-builder"),
|
|
59515
59542
|
// 共享 deploy-kit 根:scaffold/publish 脚本骨架 + 阿里云凭证单一真源。
|
|
59516
|
-
deployKitRoot:
|
|
59543
|
+
deployKitRoot: import_node_path63.default.join(config.dataDir, "deploy-kit"),
|
|
59517
59544
|
// scaffold/publish 按当前 session 的 persona 解析其安装根,让每个 persona 用自己的模板/注入配置。
|
|
59518
|
-
resolvePersonaRoot: (personaId) =>
|
|
59545
|
+
resolvePersonaRoot: (personaId) => import_node_path63.default.join(config.dataDir, "personas", personaId),
|
|
59519
59546
|
// 发布上线脚手架化 (spec 2026-06-03 §5.2.2):
|
|
59520
59547
|
// 复用 SessionManagerDeps.broadcastFrame 同款 dispatch 逻辑 —— runner 调 manager.send
|
|
59521
59548
|
// 取回 broadcast 帧后逐帧 push 到 transport,跟 manager 自身的 deps 一致。
|
|
@@ -59558,7 +59585,7 @@ async function startDaemon(config) {
|
|
|
59558
59585
|
}
|
|
59559
59586
|
let sourceJsonlPath = "(no transcript yet \u2014 operate from the task description alone)";
|
|
59560
59587
|
if (sourceFile && sourceFile.toolSessionId) {
|
|
59561
|
-
sourceJsonlPath =
|
|
59588
|
+
sourceJsonlPath = import_node_path63.default.join(
|
|
59562
59589
|
import_node_os21.default.homedir(),
|
|
59563
59590
|
".claude",
|
|
59564
59591
|
"projects",
|
|
@@ -59888,8 +59915,8 @@ async function startDaemon(config) {
|
|
|
59888
59915
|
const lines = [
|
|
59889
59916
|
`Tunnel: ${r.url}`,
|
|
59890
59917
|
...resolvedAuthToken ? [`Connect: ${connectUrl}`] : [],
|
|
59891
|
-
`Frpc config: ${
|
|
59892
|
-
`Frpc log: ${
|
|
59918
|
+
`Frpc config: ${import_node_path63.default.join(config.dataDir, "frpc.toml")}`,
|
|
59919
|
+
`Frpc log: ${import_node_path63.default.join(config.dataDir, "frpc.log")}`
|
|
59893
59920
|
];
|
|
59894
59921
|
const width = Math.max(...lines.map((l) => l.length));
|
|
59895
59922
|
const bar = "\u2550".repeat(width + 4);
|
|
@@ -59902,8 +59929,8 @@ ${bar}
|
|
|
59902
59929
|
|
|
59903
59930
|
`);
|
|
59904
59931
|
try {
|
|
59905
|
-
const connectPath =
|
|
59906
|
-
|
|
59932
|
+
const connectPath = import_node_path63.default.join(config.dataDir, "connect.txt");
|
|
59933
|
+
import_node_fs50.default.writeFileSync(connectPath, lines.join("\n") + "\n", { mode: 384 });
|
|
59907
59934
|
} catch {
|
|
59908
59935
|
}
|
|
59909
59936
|
} catch (err) {
|
|
@@ -59937,7 +59964,7 @@ ${bar}
|
|
|
59937
59964
|
});
|
|
59938
59965
|
try {
|
|
59939
59966
|
await sshdMgr.start();
|
|
59940
|
-
rebuildAuthorizedKeys(contactStore,
|
|
59967
|
+
rebuildAuthorizedKeys(contactStore, import_node_path63.default.join(config.dataDir, "sshd"));
|
|
59941
59968
|
logger.info("sshd: contact-ssh sandbox ready", { port: config.sshdPort });
|
|
59942
59969
|
} catch (err) {
|
|
59943
59970
|
logger.warn("sshd start failed; contact SSH grant will not work until fixed", {
|
|
@@ -60005,9 +60032,9 @@ ${bar}
|
|
|
60005
60032
|
};
|
|
60006
60033
|
}
|
|
60007
60034
|
function migrateDropPersonsDir(dataDir) {
|
|
60008
|
-
const dir =
|
|
60035
|
+
const dir = import_node_path63.default.join(dataDir, "persons");
|
|
60009
60036
|
try {
|
|
60010
|
-
|
|
60037
|
+
import_node_fs50.default.rmSync(dir, { recursive: true, force: true });
|
|
60011
60038
|
} catch {
|
|
60012
60039
|
}
|
|
60013
60040
|
}
|