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