@clawos-dev/clawd 0.2.203-beta.407.bb42013 → 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;
|
|
@@ -40324,53 +40324,10 @@ var require_lib3 = __commonJS({
|
|
|
40324
40324
|
}
|
|
40325
40325
|
});
|
|
40326
40326
|
|
|
40327
|
-
// src/sshd/contact-ssh-log.ts
|
|
40328
|
-
function createContactSshLog(dataDir) {
|
|
40329
|
-
const file = import_node_path40.default.join(dataDir, "contact-ssh.log");
|
|
40330
|
-
function append(level, tag, message, meta) {
|
|
40331
|
-
const time = (/* @__PURE__ */ new Date()).toISOString();
|
|
40332
|
-
let line = `[${time}] [${level}] [${tag}] ${message}`;
|
|
40333
|
-
if (meta && Object.keys(meta).length > 0) {
|
|
40334
|
-
try {
|
|
40335
|
-
line += " " + JSON.stringify(meta);
|
|
40336
|
-
} catch {
|
|
40337
|
-
line += " [meta-serialize-failed]";
|
|
40338
|
-
}
|
|
40339
|
-
}
|
|
40340
|
-
line += "\n";
|
|
40341
|
-
try {
|
|
40342
|
-
import_node_fs39.default.mkdirSync(import_node_path40.default.dirname(file), { recursive: true });
|
|
40343
|
-
import_node_fs39.default.appendFileSync(file, line, { mode: 384 });
|
|
40344
|
-
} catch {
|
|
40345
|
-
}
|
|
40346
|
-
}
|
|
40347
|
-
return {
|
|
40348
|
-
info: (tag, message, meta) => append("INFO", tag, message, meta),
|
|
40349
|
-
warn: (tag, message, meta) => append("WARN", tag, message, meta),
|
|
40350
|
-
error: (tag, message, meta) => append("ERROR", tag, message, meta)
|
|
40351
|
-
};
|
|
40352
|
-
}
|
|
40353
|
-
var import_node_fs39, import_node_path40, nullContactSshLog;
|
|
40354
|
-
var init_contact_ssh_log = __esm({
|
|
40355
|
-
"src/sshd/contact-ssh-log.ts"() {
|
|
40356
|
-
"use strict";
|
|
40357
|
-
import_node_fs39 = __toESM(require("fs"), 1);
|
|
40358
|
-
import_node_path40 = __toESM(require("path"), 1);
|
|
40359
|
-
nullContactSshLog = {
|
|
40360
|
-
info: () => {
|
|
40361
|
-
},
|
|
40362
|
-
warn: () => {
|
|
40363
|
-
},
|
|
40364
|
-
error: () => {
|
|
40365
|
-
}
|
|
40366
|
-
};
|
|
40367
|
-
}
|
|
40368
|
-
});
|
|
40369
|
-
|
|
40370
40327
|
// src/run-case/recorder.ts
|
|
40371
40328
|
function startRunCaseRecorder(opts) {
|
|
40372
40329
|
const now = opts.now ?? Date.now;
|
|
40373
|
-
const dir =
|
|
40330
|
+
const dir = import_node_path63.default.dirname(opts.recordPath);
|
|
40374
40331
|
let stream = null;
|
|
40375
40332
|
let closing = false;
|
|
40376
40333
|
let closedSettled = false;
|
|
@@ -40384,8 +40341,8 @@ function startRunCaseRecorder(opts) {
|
|
|
40384
40341
|
});
|
|
40385
40342
|
const ensureStream = () => {
|
|
40386
40343
|
if (stream) return stream;
|
|
40387
|
-
|
|
40388
|
-
stream =
|
|
40344
|
+
import_node_fs50.default.mkdirSync(dir, { recursive: true });
|
|
40345
|
+
stream = import_node_fs50.default.createWriteStream(opts.recordPath, { flags: "a" });
|
|
40389
40346
|
stream.on("close", () => closedResolve());
|
|
40390
40347
|
return stream;
|
|
40391
40348
|
};
|
|
@@ -40410,12 +40367,12 @@ function startRunCaseRecorder(opts) {
|
|
|
40410
40367
|
};
|
|
40411
40368
|
return { tap, close, closed };
|
|
40412
40369
|
}
|
|
40413
|
-
var
|
|
40370
|
+
var import_node_fs50, import_node_path63;
|
|
40414
40371
|
var init_recorder = __esm({
|
|
40415
40372
|
"src/run-case/recorder.ts"() {
|
|
40416
40373
|
"use strict";
|
|
40417
|
-
|
|
40418
|
-
|
|
40374
|
+
import_node_fs50 = __toESM(require("fs"), 1);
|
|
40375
|
+
import_node_path63 = __toESM(require("path"), 1);
|
|
40419
40376
|
}
|
|
40420
40377
|
});
|
|
40421
40378
|
|
|
@@ -40458,7 +40415,7 @@ var init_wire = __esm({
|
|
|
40458
40415
|
// src/run-case/controller.ts
|
|
40459
40416
|
async function runController(opts) {
|
|
40460
40417
|
const now = opts.now ?? Date.now;
|
|
40461
|
-
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-"));
|
|
40462
40419
|
const ownsCwd = opts.cwd === void 0;
|
|
40463
40420
|
const recorder = startRunCaseRecorder({ recordPath: opts.record, now });
|
|
40464
40421
|
const spawnCtx = { cwd };
|
|
@@ -40619,19 +40576,19 @@ async function runController(opts) {
|
|
|
40619
40576
|
if (sigintHandler) process.off("SIGINT", sigintHandler);
|
|
40620
40577
|
if (ownsCwd) {
|
|
40621
40578
|
try {
|
|
40622
|
-
(0,
|
|
40579
|
+
(0, import_node_fs51.rmSync)(cwd, { recursive: true, force: true });
|
|
40623
40580
|
} catch {
|
|
40624
40581
|
}
|
|
40625
40582
|
}
|
|
40626
40583
|
return exitCode ?? 0;
|
|
40627
40584
|
}
|
|
40628
|
-
var
|
|
40585
|
+
var import_node_fs51, import_node_os22, import_node_path64;
|
|
40629
40586
|
var init_controller = __esm({
|
|
40630
40587
|
"src/run-case/controller.ts"() {
|
|
40631
40588
|
"use strict";
|
|
40632
|
-
|
|
40589
|
+
import_node_fs51 = require("fs");
|
|
40633
40590
|
import_node_os22 = __toESM(require("os"), 1);
|
|
40634
|
-
|
|
40591
|
+
import_node_path64 = __toESM(require("path"), 1);
|
|
40635
40592
|
init_claude();
|
|
40636
40593
|
init_stdout_splitter();
|
|
40637
40594
|
init_permission_stdio();
|
|
@@ -40742,23 +40699,14 @@ async function sshRelay(argv) {
|
|
|
40742
40699
|
process.stderr.write("clawd ssh-relay: missing <peer-device-id>\n" + SSH_RELAY_HELP);
|
|
40743
40700
|
return 2;
|
|
40744
40701
|
}
|
|
40745
|
-
const dataDir = args.dataDir ??
|
|
40746
|
-
const sshLog = createContactSshLog(dataDir);
|
|
40702
|
+
const dataDir = args.dataDir ?? import_node_path65.default.join(import_node_os23.default.homedir(), ".clawd");
|
|
40747
40703
|
const contact = findContact(dataDir, args.peerDeviceId);
|
|
40748
40704
|
if (!contact) {
|
|
40749
|
-
sshLog.error("relay.contact-not-found", "ssh-relay \u627E\u4E0D\u5230 peer contact", {
|
|
40750
|
-
peerDeviceId: args.peerDeviceId,
|
|
40751
|
-
contactsPath: import_node_path66.default.join(dataDir, "contacts.json")
|
|
40752
|
-
});
|
|
40753
40705
|
process.stderr.write(`clawd ssh-relay: contact ${args.peerDeviceId} not found in ${dataDir}/contacts.json
|
|
40754
40706
|
`);
|
|
40755
40707
|
return 2;
|
|
40756
40708
|
}
|
|
40757
40709
|
if (!contact.connectToken) {
|
|
40758
|
-
sshLog.error("relay.token-missing", "contact \u6709\u8BB0\u5F55\u4F46\u7F3A connectToken\uFF08auto-reverse \u672A\u6362\u7968\uFF09", {
|
|
40759
|
-
peerDeviceId: args.peerDeviceId,
|
|
40760
|
-
peerDisplayName: contact.displayName
|
|
40761
|
-
});
|
|
40762
40710
|
process.stderr.write(
|
|
40763
40711
|
`clawd ssh-relay: contact ${args.peerDeviceId} has no connectToken (auto-reverse \u672A\u6362\u7968)
|
|
40764
40712
|
`
|
|
@@ -40768,11 +40716,6 @@ async function sshRelay(argv) {
|
|
|
40768
40716
|
const baseHttp = wsUrlToHttp(contact.remoteUrl).replace(/\/+$/, "");
|
|
40769
40717
|
const wsBase = baseHttp.replace(/^http:/, "ws:").replace(/^https:/, "wss:");
|
|
40770
40718
|
const url = `${wsBase}/rpc/ssh-tunnel`;
|
|
40771
|
-
sshLog.info("relay.dial", "\u5F00\u59CB\u62E8 A \u4FA7 /rpc/ssh-tunnel", {
|
|
40772
|
-
peerDeviceId: args.peerDeviceId,
|
|
40773
|
-
peerDisplayName: contact.displayName,
|
|
40774
|
-
url
|
|
40775
|
-
});
|
|
40776
40719
|
return new Promise((resolve6) => {
|
|
40777
40720
|
const ws = new import_websocket.default(url, {
|
|
40778
40721
|
headers: {
|
|
@@ -40792,9 +40735,6 @@ async function sshRelay(argv) {
|
|
|
40792
40735
|
resolve6(exitCode);
|
|
40793
40736
|
};
|
|
40794
40737
|
ws.on("open", () => {
|
|
40795
|
-
sshLog.info("relay.dial-open", "ws open\uFF0C\u8FDB\u5165 stdio \u2194 ws \u4E2D\u7EE7", {
|
|
40796
|
-
peerDeviceId: args.peerDeviceId
|
|
40797
|
-
});
|
|
40798
40738
|
process.stdin.on("data", (chunk) => {
|
|
40799
40739
|
if (ws.readyState === ws.OPEN) {
|
|
40800
40740
|
ws.send(chunk, { binary: true });
|
|
@@ -40819,25 +40759,9 @@ async function sshRelay(argv) {
|
|
|
40819
40759
|
}
|
|
40820
40760
|
});
|
|
40821
40761
|
ws.on("close", (code) => {
|
|
40822
|
-
if (code === 1e3) {
|
|
40823
|
-
sshLog.info("relay.dial-close", "ws \u6B63\u5E38\u5173\u95ED", {
|
|
40824
|
-
peerDeviceId: args.peerDeviceId,
|
|
40825
|
-
code
|
|
40826
|
-
});
|
|
40827
|
-
} else {
|
|
40828
|
-
sshLog.warn("relay.dial-close-abnormal", "ws \u975E\u6B63\u5E38\u5173\u95ED\uFF08A \u4FA7\u62D2 auth / \u7F51\u7EDC\u65AD / peer \u5D29\uFF09", {
|
|
40829
|
-
peerDeviceId: args.peerDeviceId,
|
|
40830
|
-
code
|
|
40831
|
-
});
|
|
40832
|
-
}
|
|
40833
40762
|
settle(code === 1e3 ? 0 : 1);
|
|
40834
40763
|
});
|
|
40835
40764
|
ws.on("error", (err) => {
|
|
40836
|
-
sshLog.error("relay.dial-error", "ws \u8FDE\u63A5\u9519\u8BEF\uFF08peer \u4E0D\u53EF\u8FBE / \u7AEF\u53E3\u4E0D\u901A / TLS \u5931\u8D25\uFF09", {
|
|
40837
|
-
peerDeviceId: args.peerDeviceId,
|
|
40838
|
-
url,
|
|
40839
|
-
message: err.message
|
|
40840
|
-
});
|
|
40841
40765
|
process.stderr.write(`clawd ssh-relay: ws error ${err.message}
|
|
40842
40766
|
`);
|
|
40843
40767
|
settle(1);
|
|
@@ -40869,10 +40793,10 @@ function parseSshRelayArgs(argv) {
|
|
|
40869
40793
|
return out;
|
|
40870
40794
|
}
|
|
40871
40795
|
function findContact(dataDir, deviceId) {
|
|
40872
|
-
const file =
|
|
40796
|
+
const file = import_node_path65.default.join(dataDir, "contacts.json");
|
|
40873
40797
|
let raw;
|
|
40874
40798
|
try {
|
|
40875
|
-
raw =
|
|
40799
|
+
raw = import_node_fs52.default.readFileSync(file, "utf8");
|
|
40876
40800
|
} catch {
|
|
40877
40801
|
return null;
|
|
40878
40802
|
}
|
|
@@ -40890,17 +40814,16 @@ function findContact(dataDir, deviceId) {
|
|
|
40890
40814
|
}
|
|
40891
40815
|
return null;
|
|
40892
40816
|
}
|
|
40893
|
-
var
|
|
40817
|
+
var import_node_fs52, import_node_os23, import_node_path65, SSH_RELAY_HELP;
|
|
40894
40818
|
var init_sshd_cli_relay = __esm({
|
|
40895
40819
|
"src/sshd/sshd-cli-relay.ts"() {
|
|
40896
40820
|
"use strict";
|
|
40897
|
-
|
|
40821
|
+
import_node_fs52 = __toESM(require("fs"), 1);
|
|
40898
40822
|
import_node_os23 = __toESM(require("os"), 1);
|
|
40899
|
-
|
|
40823
|
+
import_node_path65 = __toESM(require("path"), 1);
|
|
40900
40824
|
init_wrapper();
|
|
40901
40825
|
init_src();
|
|
40902
40826
|
init_peer_forward();
|
|
40903
|
-
init_contact_ssh_log();
|
|
40904
40827
|
SSH_RELAY_HELP = `clawd ssh-relay <peer-device-id> [options]
|
|
40905
40828
|
|
|
40906
40829
|
WebSocket relay to a peer daemon's /rpc/ssh-tunnel, exposing raw SSH bytes on
|
|
@@ -41100,8 +41023,8 @@ Env (advanced):
|
|
|
41100
41023
|
`;
|
|
41101
41024
|
|
|
41102
41025
|
// src/index.ts
|
|
41103
|
-
var
|
|
41104
|
-
var
|
|
41026
|
+
var import_node_path62 = __toESM(require("path"), 1);
|
|
41027
|
+
var import_node_fs49 = __toESM(require("fs"), 1);
|
|
41105
41028
|
var import_node_os21 = __toESM(require("os"), 1);
|
|
41106
41029
|
|
|
41107
41030
|
// ../node_modules/.pnpm/uuid@10.0.0/node_modules/uuid/dist/esm-node/stringify.js
|
|
@@ -41812,7 +41735,7 @@ function composeGuestSandbox(base, userWorkDir, spawnCwd) {
|
|
|
41812
41735
|
fsv.denyWrite = unionArr((fsv.denyWrite ?? []).filter((p2) => p2 !== "~/"), [spawnCwd]);
|
|
41813
41736
|
fsv.allowRead = unionArr(fsv.allowRead, [userWorkDir]);
|
|
41814
41737
|
fsv.allowWrite = unionArr(fsv.allowWrite, [userWorkDir]);
|
|
41815
|
-
fsv.allowRead = unionArr(fsv.allowRead, ["~/.clawd/contact-ssh-keys", "~/.clawd/
|
|
41738
|
+
fsv.allowRead = unionArr(fsv.allowRead, ["~/.clawd/contact-ssh-keys", "~/.clawd/contacts.json"]);
|
|
41816
41739
|
return s;
|
|
41817
41740
|
}
|
|
41818
41741
|
|
|
@@ -41962,14 +41885,12 @@ var CONTACT_SSH_SYSTEM_PROMPT_HINT = `## \u8DE8\u8BBE\u5907\u6587\u4EF6\u8BBF\u9
|
|
|
41962
41885
|
\uFF08\u6BCF\u4E2A \`<deviceId>.ed25519\` \u5C31\u662F\u4E00\u628A privkey\uFF0C\u53BB\u6389\u540E\u7F00\u5C31\u662F deviceId\uFF09
|
|
41963
41886
|
2. \u7528 SSH \u62E8\u53F7\uFF08\u628A \`<A>\` \u6362\u6210\u5B9E\u9645 deviceId\uFF09\uFF1A
|
|
41964
41887
|
\`\`\`bash
|
|
41965
|
-
ssh -o ProxyCommand='
|
|
41888
|
+
ssh -o ProxyCommand='clawd ssh-relay <A>' \\
|
|
41966
41889
|
-i ~/.clawd/contact-ssh-keys/<A>.ed25519 \\
|
|
41967
41890
|
-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \\
|
|
41968
41891
|
$USER@127.0.0.1 <command>
|
|
41969
41892
|
# \u4F8B\u5982\uFF1A... $USER@127.0.0.1 cat /Users/xxx/some/file.md
|
|
41970
41893
|
# ... $USER@127.0.0.1 ls -la /Users/xxx/proj
|
|
41971
|
-
# \u8BF4\u660E\uFF1A\`~/.clawd/bin/clawd\` \u662F daemon \u542F\u52A8\u65F6 seed \u7684 shim\uFF0C\u786C\u7F16\u7801\u5F53\u524D daemon \u7684
|
|
41972
|
-
# 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
|
|
41973
41894
|
\`\`\`
|
|
41974
41895
|
|
|
41975
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
|
|
@@ -46639,8 +46560,8 @@ function turnStartInput(text) {
|
|
|
46639
46560
|
const items = [];
|
|
46640
46561
|
let leftover = text;
|
|
46641
46562
|
for (const m2 of text.matchAll(SKILL_RE)) {
|
|
46642
|
-
const [marker, name,
|
|
46643
|
-
items.push({ type: "skill", name, path:
|
|
46563
|
+
const [marker, name, path76] = m2;
|
|
46564
|
+
items.push({ type: "skill", name, path: path76 });
|
|
46644
46565
|
leftover = leftover.replace(marker, "");
|
|
46645
46566
|
}
|
|
46646
46567
|
for (const m2 of text.matchAll(ATTACHMENT_RE2)) {
|
|
@@ -49094,13 +49015,13 @@ function mapSkillsListResponse(res) {
|
|
|
49094
49015
|
const r = s ?? {};
|
|
49095
49016
|
const name = str3(r.name);
|
|
49096
49017
|
if (!name) continue;
|
|
49097
|
-
const
|
|
49018
|
+
const path76 = str3(r.path);
|
|
49098
49019
|
const description = str3(r.description);
|
|
49099
49020
|
const isPlugin = name.includes(":");
|
|
49100
49021
|
out.push({
|
|
49101
49022
|
name,
|
|
49102
49023
|
source: isPlugin ? "plugin" : "project",
|
|
49103
|
-
...
|
|
49024
|
+
...path76 ? { path: path76 } : {},
|
|
49104
49025
|
...description ? { description } : {},
|
|
49105
49026
|
...isPlugin ? { plugin: name.split(":")[0] } : {}
|
|
49106
49027
|
});
|
|
@@ -53072,8 +52993,8 @@ async function waitForFrpcReady(proc, timeoutMs) {
|
|
|
53072
52993
|
}
|
|
53073
52994
|
|
|
53074
52995
|
// src/sshd/sshd-manager.ts
|
|
53075
|
-
var
|
|
53076
|
-
var
|
|
52996
|
+
var import_node_fs36 = __toESM(require("fs"), 1);
|
|
52997
|
+
var import_node_path37 = __toESM(require("path"), 1);
|
|
53077
52998
|
var import_node_child_process11 = require("child_process");
|
|
53078
52999
|
|
|
53079
53000
|
// src/sshd/sshd-config.ts
|
|
@@ -53356,35 +53277,11 @@ function ensureJailScript(dataDir) {
|
|
|
53356
53277
|
return target;
|
|
53357
53278
|
}
|
|
53358
53279
|
|
|
53359
|
-
// src/sshd/clawd-shim.ts
|
|
53360
|
-
var import_node_fs36 = __toESM(require("fs"), 1);
|
|
53361
|
-
var import_node_path37 = __toESM(require("path"), 1);
|
|
53362
|
-
function shellQuote(s) {
|
|
53363
|
-
return `'${s.replace(/'/g, "'\\''")}'`;
|
|
53364
|
-
}
|
|
53365
|
-
function buildClawdShim(execPath, cliPath) {
|
|
53366
|
-
return `#!/usr/bin/env bash
|
|
53367
|
-
# clawd shim (managed by clawd; do not edit)
|
|
53368
|
-
#
|
|
53369
|
-
# \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
|
|
53370
|
-
# guest CC \u7528 SSH ProxyCommand \u8D70 ~/.clawd/bin/clawd ssh-relay \u65F6\u4F1A\u547D\u4E2D\u672C shim\uFF0C\u4FDD\u8BC1
|
|
53371
|
-
# relay \u4E8C\u8FDB\u5236\u8DDF\u5F53\u524D\u8DD1\u7740\u7684 daemon \u540C\u6E90\u540C\u7248\u672C\u3002
|
|
53372
|
-
exec ${shellQuote(execPath)} ${shellQuote(cliPath)} "$@"
|
|
53373
|
-
`;
|
|
53374
|
-
}
|
|
53375
|
-
function ensureClawdShim(dataDir, execPath, cliPath) {
|
|
53376
|
-
const binDir = import_node_path37.default.join(dataDir, "bin");
|
|
53377
|
-
import_node_fs36.default.mkdirSync(binDir, { recursive: true, mode: 493 });
|
|
53378
|
-
const target = import_node_path37.default.join(binDir, "clawd");
|
|
53379
|
-
import_node_fs36.default.writeFileSync(target, buildClawdShim(execPath, cliPath), { mode: 493 });
|
|
53380
|
-
return target;
|
|
53381
|
-
}
|
|
53382
|
-
|
|
53383
53280
|
// src/sshd/sshd-manager.ts
|
|
53384
53281
|
var SshdManager = class {
|
|
53385
53282
|
constructor(deps) {
|
|
53386
53283
|
this.deps = deps;
|
|
53387
|
-
this.sshdDir =
|
|
53284
|
+
this.sshdDir = import_node_path37.default.join(deps.dataDir, "sshd");
|
|
53388
53285
|
this.startupTimeoutMs = deps.startupTimeoutMs ?? 15e3;
|
|
53389
53286
|
}
|
|
53390
53287
|
deps;
|
|
@@ -53403,32 +53300,31 @@ var SshdManager = class {
|
|
|
53403
53300
|
ownPid: process.pid,
|
|
53404
53301
|
logger
|
|
53405
53302
|
});
|
|
53406
|
-
|
|
53407
|
-
|
|
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 });
|
|
53408
53305
|
ensureJailScript(this.deps.dataDir);
|
|
53409
|
-
|
|
53410
|
-
|
|
53411
|
-
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)) {
|
|
53412
53308
|
await this.generateHostKey(hostKeyPath);
|
|
53413
53309
|
}
|
|
53414
|
-
const akFile =
|
|
53415
|
-
if (!
|
|
53416
|
-
|
|
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 });
|
|
53417
53313
|
}
|
|
53418
|
-
const configPath =
|
|
53314
|
+
const configPath = import_node_path37.default.join(this.sshdDir, "sshd_config");
|
|
53419
53315
|
const config = buildSshdConfig({
|
|
53420
53316
|
listenAddress: "127.0.0.1",
|
|
53421
53317
|
port: this.deps.port,
|
|
53422
53318
|
hostKeyPath,
|
|
53423
53319
|
authorizedKeysFile: akFile,
|
|
53424
|
-
pidFilePath:
|
|
53320
|
+
pidFilePath: import_node_path37.default.join(this.sshdDir, "sshd.pid")
|
|
53425
53321
|
});
|
|
53426
|
-
|
|
53322
|
+
import_node_fs36.default.writeFileSync(configPath, config, { mode: 384 });
|
|
53427
53323
|
const sshdBin = this.deps.sshdBin ?? "/usr/sbin/sshd";
|
|
53428
53324
|
const proc = (this.deps.spawnImpl ?? import_node_child_process11.spawn)(sshdBin, ["-D", "-e", "-f", configPath], {
|
|
53429
53325
|
stdio: ["ignore", "pipe", "pipe"]
|
|
53430
53326
|
});
|
|
53431
|
-
const logStream =
|
|
53327
|
+
const logStream = import_node_fs36.default.createWriteStream(import_node_path37.default.join(this.sshdDir, "sshd.log"), {
|
|
53432
53328
|
flags: "a",
|
|
53433
53329
|
mode: 384
|
|
53434
53330
|
});
|
|
@@ -53521,7 +53417,7 @@ ${tail}` : ready.error;
|
|
|
53521
53417
|
p2.on("error", reject);
|
|
53522
53418
|
});
|
|
53523
53419
|
try {
|
|
53524
|
-
|
|
53420
|
+
import_node_fs36.default.chmodSync(hostKeyPath, 384);
|
|
53525
53421
|
} catch {
|
|
53526
53422
|
}
|
|
53527
53423
|
}
|
|
@@ -53564,17 +53460,17 @@ async function waitForSshdReady(proc, timeoutMs) {
|
|
|
53564
53460
|
}
|
|
53565
53461
|
|
|
53566
53462
|
// src/sshd/authorized-keys.ts
|
|
53567
|
-
var
|
|
53568
|
-
var
|
|
53463
|
+
var import_node_fs37 = __toESM(require("fs"), 1);
|
|
53464
|
+
var import_node_path38 = __toESM(require("path"), 1);
|
|
53569
53465
|
var JAIL_BIN_PATH_ENV = "CLAWD_JAIL_BIN_PATH";
|
|
53570
53466
|
var AUTHORIZED_KEYS_FILE = "clawd-contacts";
|
|
53571
53467
|
function jailBinPath() {
|
|
53572
|
-
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");
|
|
53573
53469
|
}
|
|
53574
53470
|
function rebuildAuthorizedKeys(store, sshdDir) {
|
|
53575
|
-
const akDir =
|
|
53576
|
-
const target =
|
|
53577
|
-
|
|
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 });
|
|
53578
53474
|
const lines = ["# managed by clawd; do not edit", ""];
|
|
53579
53475
|
for (const c of store.list()) {
|
|
53580
53476
|
if (!c.sshAllowed) continue;
|
|
@@ -53588,28 +53484,66 @@ function rebuildAuthorizedKeys(store, sshdDir) {
|
|
|
53588
53484
|
}
|
|
53589
53485
|
const body = lines.join("\n") + "\n";
|
|
53590
53486
|
const tmp = `${target}.tmp-${process.pid}-${Date.now()}`;
|
|
53591
|
-
|
|
53592
|
-
|
|
53487
|
+
import_node_fs37.default.writeFileSync(tmp, body, { mode: 384 });
|
|
53488
|
+
import_node_fs37.default.renameSync(tmp, target);
|
|
53593
53489
|
}
|
|
53594
53490
|
function readIssuedPubkey(sshdDir, deviceId) {
|
|
53595
53491
|
const safeId = deviceId.replace(/[\/\\]/g, "_");
|
|
53596
|
-
const p2 =
|
|
53492
|
+
const p2 = import_node_path38.default.join(sshdDir, "keys", `${safeId}.ed25519.pub`);
|
|
53597
53493
|
try {
|
|
53598
|
-
return
|
|
53494
|
+
return import_node_fs37.default.readFileSync(p2, "utf8");
|
|
53599
53495
|
} catch {
|
|
53600
53496
|
return null;
|
|
53601
53497
|
}
|
|
53602
53498
|
}
|
|
53603
53499
|
|
|
53604
53500
|
// src/sshd/contact-key-puller.ts
|
|
53605
|
-
var
|
|
53606
|
-
var
|
|
53501
|
+
var import_node_fs39 = __toESM(require("fs"), 1);
|
|
53502
|
+
var import_node_path40 = __toESM(require("path"), 1);
|
|
53607
53503
|
init_peer_forward();
|
|
53608
|
-
|
|
53504
|
+
|
|
53505
|
+
// src/sshd/contact-ssh-log.ts
|
|
53506
|
+
var import_node_fs38 = __toESM(require("fs"), 1);
|
|
53507
|
+
var import_node_path39 = __toESM(require("path"), 1);
|
|
53508
|
+
function createContactSshLog(dataDir) {
|
|
53509
|
+
const file = import_node_path39.default.join(dataDir, "contact-ssh.log");
|
|
53510
|
+
function append(level, tag, message, meta) {
|
|
53511
|
+
const time = (/* @__PURE__ */ new Date()).toISOString();
|
|
53512
|
+
let line = `[${time}] [${level}] [${tag}] ${message}`;
|
|
53513
|
+
if (meta && Object.keys(meta).length > 0) {
|
|
53514
|
+
try {
|
|
53515
|
+
line += " " + JSON.stringify(meta);
|
|
53516
|
+
} catch {
|
|
53517
|
+
line += " [meta-serialize-failed]";
|
|
53518
|
+
}
|
|
53519
|
+
}
|
|
53520
|
+
line += "\n";
|
|
53521
|
+
try {
|
|
53522
|
+
import_node_fs38.default.mkdirSync(import_node_path39.default.dirname(file), { recursive: true });
|
|
53523
|
+
import_node_fs38.default.appendFileSync(file, line, { mode: 384 });
|
|
53524
|
+
} catch {
|
|
53525
|
+
}
|
|
53526
|
+
}
|
|
53527
|
+
return {
|
|
53528
|
+
info: (tag, message, meta) => append("INFO", tag, message, meta),
|
|
53529
|
+
warn: (tag, message, meta) => append("WARN", tag, message, meta),
|
|
53530
|
+
error: (tag, message, meta) => append("ERROR", tag, message, meta)
|
|
53531
|
+
};
|
|
53532
|
+
}
|
|
53533
|
+
var nullContactSshLog = {
|
|
53534
|
+
info: () => {
|
|
53535
|
+
},
|
|
53536
|
+
warn: () => {
|
|
53537
|
+
},
|
|
53538
|
+
error: () => {
|
|
53539
|
+
}
|
|
53540
|
+
};
|
|
53541
|
+
|
|
53542
|
+
// src/sshd/contact-key-puller.ts
|
|
53609
53543
|
var CONTACT_KEYS_DIR = "contact-ssh-keys";
|
|
53610
53544
|
function safeContactKeyPath(dataDir, deviceId) {
|
|
53611
53545
|
const safeId = deviceId.replace(/[\/\\]/g, "_");
|
|
53612
|
-
return
|
|
53546
|
+
return import_node_path40.default.join(dataDir, CONTACT_KEYS_DIR, `${safeId}.ed25519`);
|
|
53613
53547
|
}
|
|
53614
53548
|
async function pullContactSshKeyOnce(deps) {
|
|
53615
53549
|
const forward = deps.forwardImpl ?? ((c) => forwardContactSshKeyIssueToPeer({
|
|
@@ -53675,12 +53609,12 @@ async function pullContactSshKeyOnce(deps) {
|
|
|
53675
53609
|
}
|
|
53676
53610
|
function writeKeyFile(dataDir, deviceId, pem) {
|
|
53677
53611
|
const p2 = safeContactKeyPath(dataDir, deviceId);
|
|
53678
|
-
|
|
53679
|
-
|
|
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 });
|
|
53680
53614
|
}
|
|
53681
53615
|
function removeKeyFile(dataDir, deviceId) {
|
|
53682
53616
|
try {
|
|
53683
|
-
|
|
53617
|
+
import_node_fs39.default.unlinkSync(safeContactKeyPath(dataDir, deviceId));
|
|
53684
53618
|
return true;
|
|
53685
53619
|
} catch {
|
|
53686
53620
|
return false;
|
|
@@ -53717,7 +53651,6 @@ var ContactKeyPuller = class {
|
|
|
53717
53651
|
|
|
53718
53652
|
// src/sshd/ssh-tunnel-relay.ts
|
|
53719
53653
|
var import_node_net2 = __toESM(require("net"), 1);
|
|
53720
|
-
init_contact_ssh_log();
|
|
53721
53654
|
async function handleSshTunnelUpgrade(req, socket, head, deps) {
|
|
53722
53655
|
const sshLog = deps.sshLog ?? nullContactSshLog;
|
|
53723
53656
|
const clientAddr = (req.socket && "remoteAddress" in req.socket ? req.socket.remoteAddress : null) ?? "unknown";
|
|
@@ -53825,32 +53758,29 @@ function pumpWsToSshd(ws, deps, clientAddr) {
|
|
|
53825
53758
|
});
|
|
53826
53759
|
}
|
|
53827
53760
|
|
|
53828
|
-
// src/index.ts
|
|
53829
|
-
init_contact_ssh_log();
|
|
53830
|
-
|
|
53831
53761
|
// src/tunnel/device-key.ts
|
|
53832
53762
|
var import_node_os14 = __toESM(require("os"), 1);
|
|
53833
|
-
var
|
|
53763
|
+
var import_node_path41 = __toESM(require("path"), 1);
|
|
53834
53764
|
var import_node_crypto11 = __toESM(require("crypto"), 1);
|
|
53835
53765
|
var DERIVE_SALT = "clawd-tunnel-device-v1";
|
|
53836
53766
|
function deriveStableDeviceKey(opts = {}) {
|
|
53837
53767
|
const hostname = opts.hostname ?? import_node_os14.default.hostname();
|
|
53838
53768
|
const uid = opts.uid ?? (typeof import_node_os14.default.userInfo === "function" ? import_node_os14.default.userInfo().uid : 0);
|
|
53839
53769
|
const home = opts.home ?? import_node_os14.default.homedir();
|
|
53840
|
-
const defaultDataDir =
|
|
53841
|
-
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;
|
|
53842
53772
|
const isDefaultDir = normalizedDataDir == null || normalizedDataDir === defaultDataDir;
|
|
53843
53773
|
const input = isDefaultDir ? `${hostname}::${uid}` : `${hostname}::${uid}::${normalizedDataDir}`;
|
|
53844
53774
|
return import_node_crypto11.default.createHmac("sha256", DERIVE_SALT).update(input).digest("hex").slice(0, 32);
|
|
53845
53775
|
}
|
|
53846
53776
|
|
|
53847
53777
|
// src/auth-store.ts
|
|
53848
|
-
var
|
|
53849
|
-
var
|
|
53778
|
+
var import_node_fs40 = __toESM(require("fs"), 1);
|
|
53779
|
+
var import_node_path42 = __toESM(require("path"), 1);
|
|
53850
53780
|
var import_node_crypto12 = __toESM(require("crypto"), 1);
|
|
53851
53781
|
var AUTH_FILE_NAME = "auth.json";
|
|
53852
53782
|
function authFilePath(dataDir) {
|
|
53853
|
-
return
|
|
53783
|
+
return import_node_path42.default.join(dataDir, AUTH_FILE_NAME);
|
|
53854
53784
|
}
|
|
53855
53785
|
function loadOrCreateAuthFile(opts) {
|
|
53856
53786
|
const file = authFilePath(opts.dataDir);
|
|
@@ -53886,7 +53816,7 @@ function defaultGenerateOwnerPrincipalId() {
|
|
|
53886
53816
|
}
|
|
53887
53817
|
function readAuthFile(file) {
|
|
53888
53818
|
try {
|
|
53889
|
-
const raw =
|
|
53819
|
+
const raw = import_node_fs40.default.readFileSync(file, "utf8");
|
|
53890
53820
|
const parsed = JSON.parse(raw);
|
|
53891
53821
|
if (typeof parsed?.token !== "string" || parsed.token.length === 0) {
|
|
53892
53822
|
return null;
|
|
@@ -53906,25 +53836,25 @@ function readAuthFile(file) {
|
|
|
53906
53836
|
}
|
|
53907
53837
|
}
|
|
53908
53838
|
function writeAuthFile(file, content) {
|
|
53909
|
-
|
|
53910
|
-
|
|
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 });
|
|
53911
53841
|
try {
|
|
53912
|
-
|
|
53842
|
+
import_node_fs40.default.chmodSync(file, 384);
|
|
53913
53843
|
} catch {
|
|
53914
53844
|
}
|
|
53915
53845
|
}
|
|
53916
53846
|
|
|
53917
53847
|
// src/owner-profile.ts
|
|
53918
|
-
var
|
|
53848
|
+
var import_node_fs41 = __toESM(require("fs"), 1);
|
|
53919
53849
|
var import_node_os15 = __toESM(require("os"), 1);
|
|
53920
|
-
var
|
|
53850
|
+
var import_node_path43 = __toESM(require("path"), 1);
|
|
53921
53851
|
var PROFILE_FILENAME = "profile.json";
|
|
53922
53852
|
function loadOwnerDisplayName(dataDir) {
|
|
53923
53853
|
const fallback = import_node_os15.default.userInfo().username;
|
|
53924
|
-
const profilePath =
|
|
53854
|
+
const profilePath = import_node_path43.default.join(dataDir, PROFILE_FILENAME);
|
|
53925
53855
|
let raw;
|
|
53926
53856
|
try {
|
|
53927
|
-
raw =
|
|
53857
|
+
raw = import_node_fs41.default.readFileSync(profilePath, "utf8");
|
|
53928
53858
|
} catch {
|
|
53929
53859
|
return fallback;
|
|
53930
53860
|
}
|
|
@@ -53947,18 +53877,18 @@ function loadOwnerDisplayName(dataDir) {
|
|
|
53947
53877
|
}
|
|
53948
53878
|
|
|
53949
53879
|
// src/feishu-auth/owner-identity-store.ts
|
|
53950
|
-
var
|
|
53951
|
-
var
|
|
53880
|
+
var import_node_fs42 = __toESM(require("fs"), 1);
|
|
53881
|
+
var import_node_path44 = __toESM(require("path"), 1);
|
|
53952
53882
|
var OWNER_IDENTITY_FILE_NAME = "owner-identity.json";
|
|
53953
53883
|
var OwnerIdentityStore = class {
|
|
53954
53884
|
file;
|
|
53955
53885
|
constructor(dataDir) {
|
|
53956
|
-
this.file =
|
|
53886
|
+
this.file = import_node_path44.default.join(dataDir, OWNER_IDENTITY_FILE_NAME);
|
|
53957
53887
|
}
|
|
53958
53888
|
read() {
|
|
53959
53889
|
let raw;
|
|
53960
53890
|
try {
|
|
53961
|
-
raw =
|
|
53891
|
+
raw = import_node_fs42.default.readFileSync(this.file, "utf8");
|
|
53962
53892
|
} catch {
|
|
53963
53893
|
return null;
|
|
53964
53894
|
}
|
|
@@ -53986,16 +53916,16 @@ var OwnerIdentityStore = class {
|
|
|
53986
53916
|
};
|
|
53987
53917
|
}
|
|
53988
53918
|
write(record) {
|
|
53989
|
-
|
|
53990
|
-
|
|
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 });
|
|
53991
53921
|
try {
|
|
53992
|
-
|
|
53922
|
+
import_node_fs42.default.chmodSync(this.file, 384);
|
|
53993
53923
|
} catch {
|
|
53994
53924
|
}
|
|
53995
53925
|
}
|
|
53996
53926
|
clear() {
|
|
53997
53927
|
try {
|
|
53998
|
-
|
|
53928
|
+
import_node_fs42.default.unlinkSync(this.file);
|
|
53999
53929
|
} catch (err) {
|
|
54000
53930
|
const code = err?.code;
|
|
54001
53931
|
if (code !== "ENOENT") throw err;
|
|
@@ -54116,9 +54046,9 @@ var CentralClientError = class extends Error {
|
|
|
54116
54046
|
code;
|
|
54117
54047
|
cause;
|
|
54118
54048
|
};
|
|
54119
|
-
async function centralRequest(opts,
|
|
54049
|
+
async function centralRequest(opts, path76, init) {
|
|
54120
54050
|
const f = opts.fetchImpl ?? globalThis.fetch;
|
|
54121
|
-
const url = `${opts.api.replace(/\/+$/, "")}${
|
|
54051
|
+
const url = `${opts.api.replace(/\/+$/, "")}${path76}`;
|
|
54122
54052
|
const ctrl = new AbortController();
|
|
54123
54053
|
const timer = setTimeout(() => ctrl.abort(), opts.timeoutMs ?? 15e3);
|
|
54124
54054
|
let res;
|
|
@@ -54260,8 +54190,8 @@ function verifyConnectToken(args) {
|
|
|
54260
54190
|
}
|
|
54261
54191
|
|
|
54262
54192
|
// src/feishu-auth/server-key.ts
|
|
54263
|
-
var
|
|
54264
|
-
var
|
|
54193
|
+
var fs52 = __toESM(require("fs"), 1);
|
|
54194
|
+
var path53 = __toESM(require("path"), 1);
|
|
54265
54195
|
var FILE_NAME2 = "server-signing-key.json";
|
|
54266
54196
|
var ServerKeyStore = class {
|
|
54267
54197
|
constructor(dataDir) {
|
|
@@ -54269,12 +54199,12 @@ var ServerKeyStore = class {
|
|
|
54269
54199
|
}
|
|
54270
54200
|
dataDir;
|
|
54271
54201
|
filePath() {
|
|
54272
|
-
return
|
|
54202
|
+
return path53.join(this.dataDir, FILE_NAME2);
|
|
54273
54203
|
}
|
|
54274
54204
|
/** 读缓存的公钥;无缓存 / 损坏 → null(调用方决定是否触发拉取) */
|
|
54275
54205
|
read() {
|
|
54276
54206
|
try {
|
|
54277
|
-
const raw =
|
|
54207
|
+
const raw = fs52.readFileSync(this.filePath(), "utf8");
|
|
54278
54208
|
const parsed = JSON.parse(raw);
|
|
54279
54209
|
if (typeof parsed.publicKeyPem === "string" && parsed.publicKeyPem.includes("PUBLIC KEY")) {
|
|
54280
54210
|
return parsed.publicKeyPem;
|
|
@@ -54289,12 +54219,12 @@ var ServerKeyStore = class {
|
|
|
54289
54219
|
publicKeyPem,
|
|
54290
54220
|
fetchedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
54291
54221
|
};
|
|
54292
|
-
|
|
54293
|
-
|
|
54222
|
+
fs52.mkdirSync(this.dataDir, { recursive: true });
|
|
54223
|
+
fs52.writeFileSync(this.filePath(), JSON.stringify(content, null, 2), { mode: 384 });
|
|
54294
54224
|
}
|
|
54295
54225
|
clear() {
|
|
54296
54226
|
try {
|
|
54297
|
-
|
|
54227
|
+
fs52.unlinkSync(this.filePath());
|
|
54298
54228
|
} catch {
|
|
54299
54229
|
}
|
|
54300
54230
|
}
|
|
@@ -54307,12 +54237,12 @@ init_protocol();
|
|
|
54307
54237
|
init_protocol();
|
|
54308
54238
|
|
|
54309
54239
|
// src/session/fork.ts
|
|
54310
|
-
var
|
|
54240
|
+
var import_node_fs43 = __toESM(require("fs"), 1);
|
|
54311
54241
|
var import_node_os16 = __toESM(require("os"), 1);
|
|
54312
|
-
var
|
|
54242
|
+
var import_node_path45 = __toESM(require("path"), 1);
|
|
54313
54243
|
init_claude_history();
|
|
54314
54244
|
function readJsonlEntries(file) {
|
|
54315
|
-
const raw =
|
|
54245
|
+
const raw = import_node_fs43.default.readFileSync(file, "utf8");
|
|
54316
54246
|
const out = [];
|
|
54317
54247
|
for (const line of raw.split("\n")) {
|
|
54318
54248
|
const t = line.trim();
|
|
@@ -54325,10 +54255,10 @@ function readJsonlEntries(file) {
|
|
|
54325
54255
|
return out;
|
|
54326
54256
|
}
|
|
54327
54257
|
function forkSession(input) {
|
|
54328
|
-
const baseDir = input.baseDir ??
|
|
54329
|
-
const projectDir =
|
|
54330
|
-
const sourceFile =
|
|
54331
|
-
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)) {
|
|
54332
54262
|
throw new Error(`fork: source transcript not found: ${sourceFile}`);
|
|
54333
54263
|
}
|
|
54334
54264
|
const entries = readJsonlEntries(sourceFile);
|
|
@@ -54358,9 +54288,9 @@ function forkSession(input) {
|
|
|
54358
54288
|
}
|
|
54359
54289
|
forkedLines.push(JSON.stringify(forked));
|
|
54360
54290
|
}
|
|
54361
|
-
const forkedFilePath =
|
|
54362
|
-
|
|
54363
|
-
|
|
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 });
|
|
54364
54294
|
return { forkedToolSessionId, forkedFilePath };
|
|
54365
54295
|
}
|
|
54366
54296
|
|
|
@@ -54712,7 +54642,7 @@ function buildPermissionHandlers(deps) {
|
|
|
54712
54642
|
}
|
|
54713
54643
|
|
|
54714
54644
|
// src/handlers/history.ts
|
|
54715
|
-
var
|
|
54645
|
+
var path56 = __toESM(require("path"), 1);
|
|
54716
54646
|
init_protocol();
|
|
54717
54647
|
|
|
54718
54648
|
// src/session/recent-dirs.ts
|
|
@@ -54730,7 +54660,7 @@ function listRecentDirs(store, limit = 50) {
|
|
|
54730
54660
|
}
|
|
54731
54661
|
|
|
54732
54662
|
// src/permission/persona-paths.ts
|
|
54733
|
-
var
|
|
54663
|
+
var path55 = __toESM(require("path"), 1);
|
|
54734
54664
|
function getAllowedPersonaIds(grants, action) {
|
|
54735
54665
|
const ids = /* @__PURE__ */ new Set();
|
|
54736
54666
|
for (const g2 of grants) {
|
|
@@ -54743,42 +54673,42 @@ function getAllowedPersonaIds(grants, action) {
|
|
|
54743
54673
|
return ids;
|
|
54744
54674
|
}
|
|
54745
54675
|
function isGuestPathAllowed(grants, absPath, personaRoot, action = "read", userWorkDir) {
|
|
54746
|
-
const target =
|
|
54676
|
+
const target = path55.resolve(absPath);
|
|
54747
54677
|
if (userWorkDir) {
|
|
54748
|
-
const u =
|
|
54749
|
-
const usep = u.endsWith(
|
|
54678
|
+
const u = path55.resolve(userWorkDir);
|
|
54679
|
+
const usep = u.endsWith(path55.sep) ? "" : path55.sep;
|
|
54750
54680
|
if (target === u || target.startsWith(u + usep)) return true;
|
|
54751
54681
|
}
|
|
54752
|
-
const root =
|
|
54753
|
-
const sep3 = root.endsWith(
|
|
54682
|
+
const root = path55.resolve(personaRoot);
|
|
54683
|
+
const sep3 = root.endsWith(path55.sep) ? "" : path55.sep;
|
|
54754
54684
|
if (!target.startsWith(root + sep3)) return false;
|
|
54755
|
-
const rel =
|
|
54685
|
+
const rel = path55.relative(root, target);
|
|
54756
54686
|
if (!rel || rel.startsWith("..")) return false;
|
|
54757
|
-
const personaId = rel.split(
|
|
54687
|
+
const personaId = rel.split(path55.sep)[0];
|
|
54758
54688
|
if (!personaId) return false;
|
|
54759
54689
|
const allowed = getAllowedPersonaIds(grants, action);
|
|
54760
54690
|
if (allowed === "*") return true;
|
|
54761
54691
|
return allowed.has(personaId);
|
|
54762
54692
|
}
|
|
54763
54693
|
function personaIdFromPath(absPath, personaRoot) {
|
|
54764
|
-
const root =
|
|
54765
|
-
const target =
|
|
54766
|
-
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;
|
|
54767
54697
|
if (!target.startsWith(root + sep3)) return null;
|
|
54768
|
-
const rel =
|
|
54698
|
+
const rel = path55.relative(root, target);
|
|
54769
54699
|
if (!rel || rel.startsWith("..")) return null;
|
|
54770
|
-
const id = rel.split(
|
|
54700
|
+
const id = rel.split(path55.sep)[0];
|
|
54771
54701
|
return id || null;
|
|
54772
54702
|
}
|
|
54773
54703
|
function isPathWithin(dir, absPath) {
|
|
54774
|
-
const d =
|
|
54775
|
-
const t =
|
|
54776
|
-
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;
|
|
54777
54707
|
return t === d || t.startsWith(d + sep3);
|
|
54778
54708
|
}
|
|
54779
54709
|
function isPathInGuestBoundary(personaRoot, personaId, userWorkDir, absPath) {
|
|
54780
54710
|
if (userWorkDir && isPathWithin(userWorkDir, absPath)) return true;
|
|
54781
|
-
return personaIdFromPath(
|
|
54711
|
+
return personaIdFromPath(path55.resolve(absPath), personaRoot) === personaId;
|
|
54782
54712
|
}
|
|
54783
54713
|
|
|
54784
54714
|
// src/handlers/history.ts
|
|
@@ -54804,7 +54734,7 @@ function buildHistoryHandlers(deps) {
|
|
|
54804
54734
|
if (!pid) return false;
|
|
54805
54735
|
return isGuestPathAllowed(
|
|
54806
54736
|
ctx.grants,
|
|
54807
|
-
|
|
54737
|
+
path56.join(personaRoot, pid),
|
|
54808
54738
|
personaRoot,
|
|
54809
54739
|
"read",
|
|
54810
54740
|
userWorkDir
|
|
@@ -54816,7 +54746,7 @@ function buildHistoryHandlers(deps) {
|
|
|
54816
54746
|
};
|
|
54817
54747
|
const list = async (frame, _client, ctx) => {
|
|
54818
54748
|
const args = HistoryListArgs.parse(frame);
|
|
54819
|
-
assertGuestPath(ctx,
|
|
54749
|
+
assertGuestPath(ctx, path56.resolve(args.projectPath), personaRoot, "history:list");
|
|
54820
54750
|
const sessions = await history.listSessions(args);
|
|
54821
54751
|
return { response: { type: "history:list", sessions } };
|
|
54822
54752
|
};
|
|
@@ -54848,13 +54778,13 @@ function buildHistoryHandlers(deps) {
|
|
|
54848
54778
|
};
|
|
54849
54779
|
const subagents = async (frame, _client, ctx) => {
|
|
54850
54780
|
const args = HistorySubagentsArgs.parse(frame);
|
|
54851
|
-
assertGuestPath(ctx,
|
|
54781
|
+
assertGuestPath(ctx, path56.resolve(args.cwd), personaRoot, "history:subagents", usersRoot);
|
|
54852
54782
|
const subs = await history.listSubagents(args);
|
|
54853
54783
|
return { response: { type: "history:subagents", subagents: subs } };
|
|
54854
54784
|
};
|
|
54855
54785
|
const subagentRead = async (frame, _client, ctx) => {
|
|
54856
54786
|
const args = HistorySubagentReadArgs.parse(frame);
|
|
54857
|
-
assertGuestPath(ctx,
|
|
54787
|
+
assertGuestPath(ctx, path56.resolve(args.cwd), personaRoot, "history:subagent-read", usersRoot);
|
|
54858
54788
|
const res = await history.readSubagent(args);
|
|
54859
54789
|
return { response: { type: "history:subagent-read", ...res } };
|
|
54860
54790
|
};
|
|
@@ -54863,7 +54793,7 @@ function buildHistoryHandlers(deps) {
|
|
|
54863
54793
|
if (ctx?.principal.kind === "guest" && personaRoot) {
|
|
54864
54794
|
const userWorkDir = usersRoot ? deriveUserWorkDir(ctx.principal.id, usersRoot) : void 0;
|
|
54865
54795
|
const filtered = dirs.filter(
|
|
54866
|
-
(d) => isGuestPathAllowed(ctx.grants,
|
|
54796
|
+
(d) => isGuestPathAllowed(ctx.grants, path56.resolve(d.cwd), personaRoot, "read", userWorkDir)
|
|
54867
54797
|
);
|
|
54868
54798
|
return { response: { type: "history:recentDirs", dirs: filtered } };
|
|
54869
54799
|
}
|
|
@@ -54880,7 +54810,7 @@ function buildHistoryHandlers(deps) {
|
|
|
54880
54810
|
}
|
|
54881
54811
|
|
|
54882
54812
|
// src/handlers/workspace.ts
|
|
54883
|
-
var
|
|
54813
|
+
var path57 = __toESM(require("path"), 1);
|
|
54884
54814
|
var os16 = __toESM(require("os"), 1);
|
|
54885
54815
|
init_protocol();
|
|
54886
54816
|
init_protocol();
|
|
@@ -54922,22 +54852,22 @@ function buildWorkspaceHandlers(deps) {
|
|
|
54922
54852
|
const args = WorkspaceListArgs.parse(frame);
|
|
54923
54853
|
const isGuest = ctx?.principal.kind === "guest";
|
|
54924
54854
|
const fallbackCwd = isGuest && personaRoot ? personaRoot : os16.homedir();
|
|
54925
|
-
const resolvedCwd =
|
|
54926
|
-
const target = args.path ?
|
|
54855
|
+
const resolvedCwd = path57.resolve(args.cwd ?? fallbackCwd);
|
|
54856
|
+
const target = args.path ? path57.resolve(resolvedCwd, args.path) : resolvedCwd;
|
|
54927
54857
|
assertGuestPath2(ctx, target, personaRoot, "workspace:list", usersRoot);
|
|
54928
54858
|
const res = workspace.list({ ...args, cwd: resolvedCwd });
|
|
54929
54859
|
return { response: { type: "workspace:list", ...res } };
|
|
54930
54860
|
};
|
|
54931
54861
|
const read = async (frame, _client, ctx) => {
|
|
54932
54862
|
const args = WorkspaceReadArgs.parse(frame);
|
|
54933
|
-
const target =
|
|
54863
|
+
const target = path57.isAbsolute(args.path) ? path57.resolve(args.path) : path57.resolve(args.cwd, args.path);
|
|
54934
54864
|
assertGuestPath2(ctx, target, personaRoot, "workspace:read", usersRoot);
|
|
54935
54865
|
const res = workspace.read(args);
|
|
54936
54866
|
return { response: { type: "workspace:read", ...res } };
|
|
54937
54867
|
};
|
|
54938
54868
|
const skillsList = async (frame, _client, ctx) => {
|
|
54939
54869
|
const args = SkillsListArgs.parse(frame);
|
|
54940
|
-
const cwdAbs =
|
|
54870
|
+
const cwdAbs = path57.resolve(args.cwd);
|
|
54941
54871
|
assertGuestPath2(ctx, cwdAbs, personaRoot, "skills:list", usersRoot);
|
|
54942
54872
|
const list2 = await getSkillsForTool(args.tool ?? "claude", cwdAbs);
|
|
54943
54873
|
if (ctx?.principal.kind === "guest" && personaRoot) {
|
|
@@ -54949,7 +54879,7 @@ function buildWorkspaceHandlers(deps) {
|
|
|
54949
54879
|
};
|
|
54950
54880
|
const agentsList = async (frame, _client, ctx) => {
|
|
54951
54881
|
const args = AgentsListArgs.parse(frame);
|
|
54952
|
-
const cwdAbs =
|
|
54882
|
+
const cwdAbs = path57.resolve(args.cwd);
|
|
54953
54883
|
assertGuestPath2(ctx, cwdAbs, personaRoot, "agents:list", usersRoot);
|
|
54954
54884
|
if (args.tool === "codex") {
|
|
54955
54885
|
return { response: { type: "agents:list", agents: [] } };
|
|
@@ -54971,20 +54901,20 @@ function buildWorkspaceHandlers(deps) {
|
|
|
54971
54901
|
}
|
|
54972
54902
|
|
|
54973
54903
|
// src/handlers/git.ts
|
|
54974
|
-
var
|
|
54904
|
+
var path59 = __toESM(require("path"), 1);
|
|
54975
54905
|
init_protocol();
|
|
54976
54906
|
init_protocol();
|
|
54977
54907
|
|
|
54978
54908
|
// src/workspace/git.ts
|
|
54979
54909
|
var import_node_child_process12 = require("child_process");
|
|
54980
|
-
var
|
|
54981
|
-
var
|
|
54910
|
+
var import_node_fs44 = __toESM(require("fs"), 1);
|
|
54911
|
+
var import_node_path46 = __toESM(require("path"), 1);
|
|
54982
54912
|
var import_node_util = require("util");
|
|
54983
54913
|
var pexec = (0, import_node_util.promisify)(import_node_child_process12.execFile);
|
|
54984
54914
|
function normalizePath(p2) {
|
|
54985
|
-
const resolved =
|
|
54915
|
+
const resolved = import_node_path46.default.resolve(p2);
|
|
54986
54916
|
try {
|
|
54987
|
-
return
|
|
54917
|
+
return import_node_fs44.default.realpathSync(resolved);
|
|
54988
54918
|
} catch {
|
|
54989
54919
|
return resolved;
|
|
54990
54920
|
}
|
|
@@ -55058,7 +54988,7 @@ async function listGitBranches(cwd) {
|
|
|
55058
54988
|
function assertGuestCwd(ctx, cwd, personaRoot, method, usersRoot) {
|
|
55059
54989
|
if (!ctx || ctx.principal.kind !== "guest" || !personaRoot) return;
|
|
55060
54990
|
const userWorkDir = usersRoot ? deriveUserWorkDir(ctx.principal.id, usersRoot) : void 0;
|
|
55061
|
-
if (!isGuestPathAllowed(ctx.grants,
|
|
54991
|
+
if (!isGuestPathAllowed(ctx.grants, path59.resolve(cwd), personaRoot, "read", userWorkDir)) {
|
|
55062
54992
|
throw new ClawdError(
|
|
55063
54993
|
ERROR_CODES.UNAUTHORIZED,
|
|
55064
54994
|
`guest ${ctx.principal.id} cannot ${method} cwd ${cwd}`
|
|
@@ -55399,22 +55329,22 @@ init_src();
|
|
|
55399
55329
|
init_protocol();
|
|
55400
55330
|
|
|
55401
55331
|
// src/sshd/key-issue.ts
|
|
55402
|
-
var
|
|
55403
|
-
var
|
|
55332
|
+
var import_node_fs45 = __toESM(require("fs"), 1);
|
|
55333
|
+
var import_node_path47 = __toESM(require("path"), 1);
|
|
55404
55334
|
var import_node_child_process13 = require("child_process");
|
|
55405
55335
|
function safeDeviceId(deviceId) {
|
|
55406
55336
|
return deviceId.replace(/[\/\\]/g, "_");
|
|
55407
55337
|
}
|
|
55408
55338
|
async function issueContactSshKey(deviceId, sshdDir, opts = {}) {
|
|
55409
55339
|
const safeId = safeDeviceId(deviceId);
|
|
55410
|
-
const keysDir =
|
|
55411
|
-
|
|
55412
|
-
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`);
|
|
55413
55343
|
const pubPath = `${privPath}.pub`;
|
|
55414
|
-
if (
|
|
55344
|
+
if (import_node_fs45.default.existsSync(privPath) && import_node_fs45.default.existsSync(pubPath)) {
|
|
55415
55345
|
return {
|
|
55416
|
-
privateKeyPem:
|
|
55417
|
-
publicKeyLine:
|
|
55346
|
+
privateKeyPem: import_node_fs45.default.readFileSync(privPath, "utf8"),
|
|
55347
|
+
publicKeyLine: import_node_fs45.default.readFileSync(pubPath, "utf8").trim()
|
|
55418
55348
|
};
|
|
55419
55349
|
}
|
|
55420
55350
|
const bin = opts.keygenBin ?? "/usr/bin/ssh-keygen";
|
|
@@ -55428,21 +55358,20 @@ async function issueContactSshKey(deviceId, sshdDir, opts = {}) {
|
|
|
55428
55358
|
p2.on("error", reject);
|
|
55429
55359
|
});
|
|
55430
55360
|
try {
|
|
55431
|
-
|
|
55361
|
+
import_node_fs45.default.chmodSync(privPath, 384);
|
|
55432
55362
|
} catch {
|
|
55433
55363
|
}
|
|
55434
55364
|
try {
|
|
55435
|
-
|
|
55365
|
+
import_node_fs45.default.chmodSync(pubPath, 420);
|
|
55436
55366
|
} catch {
|
|
55437
55367
|
}
|
|
55438
55368
|
return {
|
|
55439
|
-
privateKeyPem:
|
|
55440
|
-
publicKeyLine:
|
|
55369
|
+
privateKeyPem: import_node_fs45.default.readFileSync(privPath, "utf8"),
|
|
55370
|
+
publicKeyLine: import_node_fs45.default.readFileSync(pubPath, "utf8").trim()
|
|
55441
55371
|
};
|
|
55442
55372
|
}
|
|
55443
55373
|
|
|
55444
55374
|
// src/handlers/contact-ssh.ts
|
|
55445
|
-
init_contact_ssh_log();
|
|
55446
55375
|
function ensureOwner2(ctx) {
|
|
55447
55376
|
if (!ctx || ctx.principal.kind !== "owner") {
|
|
55448
55377
|
throw new ClawdError(
|
|
@@ -55857,7 +55786,7 @@ function buildPersonaHandlers(deps) {
|
|
|
55857
55786
|
}
|
|
55858
55787
|
|
|
55859
55788
|
// src/handlers/attachment.ts
|
|
55860
|
-
var
|
|
55789
|
+
var import_node_path48 = __toESM(require("path"), 1);
|
|
55861
55790
|
init_protocol();
|
|
55862
55791
|
init_protocol();
|
|
55863
55792
|
var DEFAULT_TTL_SECONDS = 24 * 3600;
|
|
@@ -55937,12 +55866,12 @@ function buildAttachmentHandlers(deps) {
|
|
|
55937
55866
|
`session ${args.sessionId} scope unresolved`
|
|
55938
55867
|
);
|
|
55939
55868
|
}
|
|
55940
|
-
const cwdAbs =
|
|
55941
|
-
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);
|
|
55942
55871
|
guardAttachmentPath(ctx, args.sessionId, candidateAbs, "attachment.signUrl", "group-acl");
|
|
55943
55872
|
const entries = deps.groupFileStore.list(scope, args.sessionId);
|
|
55944
55873
|
const entry = entries.find((e) => {
|
|
55945
|
-
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);
|
|
55946
55875
|
return storedAbs === candidateAbs && !e.stale;
|
|
55947
55876
|
});
|
|
55948
55877
|
if (!entry) {
|
|
@@ -55967,7 +55896,7 @@ function buildAttachmentHandlers(deps) {
|
|
|
55967
55896
|
if (!ctx || ctx.principal.kind !== "guest" || !deps.personaRoot || !deps.sessionStore) return;
|
|
55968
55897
|
const f = deps.sessionStore.read(sessionId);
|
|
55969
55898
|
if (!f) return;
|
|
55970
|
-
assertGuestAttachmentPath(ctx,
|
|
55899
|
+
assertGuestAttachmentPath(ctx, import_node_path48.default.resolve(f.cwd), deps.personaRoot, method, deps.usersRoot);
|
|
55971
55900
|
}
|
|
55972
55901
|
const groupAdd = async (frame, _client, ctx) => {
|
|
55973
55902
|
if (!deps.groupFileStore || !deps.getSessionScope) {
|
|
@@ -55982,8 +55911,8 @@ function buildAttachmentHandlers(deps) {
|
|
|
55982
55911
|
if (!scope) {
|
|
55983
55912
|
throw new ClawdError(ERROR_CODES.VALIDATION_ERROR, `session ${args.sessionId} not found`);
|
|
55984
55913
|
}
|
|
55985
|
-
const cwdAbs =
|
|
55986
|
-
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);
|
|
55987
55916
|
guardAttachmentPath(ctx, args.sessionId, candidateAbs, "attachment.groupAdd", "cwd-subtree");
|
|
55988
55917
|
const from = ctx?.principal.kind === "owner" ? "owner" : "agent";
|
|
55989
55918
|
const size = 0;
|
|
@@ -56042,20 +55971,20 @@ function buildAttachmentHandlers(deps) {
|
|
|
56042
55971
|
|
|
56043
55972
|
// src/handlers/extension.ts
|
|
56044
55973
|
var import_promises8 = __toESM(require("fs/promises"), 1);
|
|
56045
|
-
var
|
|
55974
|
+
var import_node_path53 = __toESM(require("path"), 1);
|
|
56046
55975
|
init_protocol();
|
|
56047
55976
|
init_src();
|
|
56048
55977
|
|
|
56049
55978
|
// src/extension/bundle-zip.ts
|
|
56050
55979
|
var import_promises5 = __toESM(require("fs/promises"), 1);
|
|
56051
|
-
var
|
|
55980
|
+
var import_node_path49 = __toESM(require("path"), 1);
|
|
56052
55981
|
var import_node_crypto14 = __toESM(require("crypto"), 1);
|
|
56053
55982
|
var import_jszip2 = __toESM(require_lib3(), 1);
|
|
56054
55983
|
async function bundleExtensionDir(dir) {
|
|
56055
55984
|
const entries = await listFilesSorted(dir);
|
|
56056
55985
|
const zip = new import_jszip2.default();
|
|
56057
55986
|
for (const rel of entries) {
|
|
56058
|
-
const abs =
|
|
55987
|
+
const abs = import_node_path49.default.join(dir, rel);
|
|
56059
55988
|
const content = await import_promises5.default.readFile(abs);
|
|
56060
55989
|
zip.file(rel, content, { date: FIXED_DATE });
|
|
56061
55990
|
}
|
|
@@ -56076,7 +56005,7 @@ async function listFilesSorted(rootDir) {
|
|
|
56076
56005
|
return out;
|
|
56077
56006
|
}
|
|
56078
56007
|
async function walk(absRoot, relPrefix, out) {
|
|
56079
|
-
const dirAbs =
|
|
56008
|
+
const dirAbs = import_node_path49.default.join(absRoot, relPrefix);
|
|
56080
56009
|
const entries = await import_promises5.default.readdir(dirAbs, { withFileTypes: true });
|
|
56081
56010
|
for (const e of entries) {
|
|
56082
56011
|
if (IGNORE_BASENAMES.has(e.name)) continue;
|
|
@@ -56132,7 +56061,7 @@ function computePublishCheck(args) {
|
|
|
56132
56061
|
|
|
56133
56062
|
// src/extension/install-flow.ts
|
|
56134
56063
|
var import_promises6 = __toESM(require("fs/promises"), 1);
|
|
56135
|
-
var
|
|
56064
|
+
var import_node_path51 = __toESM(require("path"), 1);
|
|
56136
56065
|
var import_node_os19 = __toESM(require("os"), 1);
|
|
56137
56066
|
var import_node_crypto15 = __toESM(require("crypto"), 1);
|
|
56138
56067
|
var import_jszip3 = __toESM(require_lib3(), 1);
|
|
@@ -56140,19 +56069,19 @@ init_src();
|
|
|
56140
56069
|
|
|
56141
56070
|
// src/extension/paths.ts
|
|
56142
56071
|
var import_node_os18 = __toESM(require("os"), 1);
|
|
56143
|
-
var
|
|
56072
|
+
var import_node_path50 = __toESM(require("path"), 1);
|
|
56144
56073
|
init_src();
|
|
56145
56074
|
function clawdHomeRoot(override) {
|
|
56146
|
-
return override ?? process.env.CLAWD_HOME ??
|
|
56075
|
+
return override ?? process.env.CLAWD_HOME ?? import_node_path50.default.join(import_node_os18.default.homedir(), ".clawd");
|
|
56147
56076
|
}
|
|
56148
56077
|
function extensionsRoot(override) {
|
|
56149
|
-
return
|
|
56078
|
+
return import_node_path50.default.join(clawdHomeRoot(override), "extensions");
|
|
56150
56079
|
}
|
|
56151
56080
|
function publishedChannelsFile(override) {
|
|
56152
|
-
return
|
|
56081
|
+
return import_node_path50.default.join(clawdHomeRoot(override), "extensions-published.json");
|
|
56153
56082
|
}
|
|
56154
56083
|
function bundleCacheRoot(override) {
|
|
56155
|
-
return
|
|
56084
|
+
return import_node_path50.default.join(clawdHomeRoot(override), "extension-bundles");
|
|
56156
56085
|
}
|
|
56157
56086
|
|
|
56158
56087
|
// src/extension/install-flow.ts
|
|
@@ -56179,7 +56108,7 @@ async function installFromChannel(args, deps) {
|
|
|
56179
56108
|
throw new InstallError("ZIP_INVALID", `failed to load zip: ${e.message}`);
|
|
56180
56109
|
}
|
|
56181
56110
|
for (const name of Object.keys(zip.files)) {
|
|
56182
|
-
if (name.includes("..") || name.startsWith("/") ||
|
|
56111
|
+
if (name.includes("..") || name.startsWith("/") || import_node_path51.default.isAbsolute(name)) {
|
|
56183
56112
|
throw new InstallError("ZIP_INVALID", `unsafe zip entry: ${name}`);
|
|
56184
56113
|
}
|
|
56185
56114
|
}
|
|
@@ -56211,7 +56140,7 @@ async function installFromChannel(args, deps) {
|
|
|
56211
56140
|
);
|
|
56212
56141
|
}
|
|
56213
56142
|
const localExtId = namespacedExtId(ownerSlug, channelRef.ownerPrincipalId);
|
|
56214
|
-
const destDir =
|
|
56143
|
+
const destDir = import_node_path51.default.join(deps.extensionsRoot, localExtId);
|
|
56215
56144
|
let destExists = false;
|
|
56216
56145
|
try {
|
|
56217
56146
|
await import_promises6.default.access(destDir);
|
|
@@ -56225,16 +56154,16 @@ async function installFromChannel(args, deps) {
|
|
|
56225
56154
|
);
|
|
56226
56155
|
}
|
|
56227
56156
|
const stage = await import_promises6.default.mkdtemp(
|
|
56228
|
-
|
|
56157
|
+
import_node_path51.default.join(import_node_os19.default.tmpdir(), `clawd-ext-install-${localExtId}-`)
|
|
56229
56158
|
);
|
|
56230
56159
|
try {
|
|
56231
56160
|
for (const [name, entry] of Object.entries(zip.files)) {
|
|
56232
|
-
const dest =
|
|
56161
|
+
const dest = import_node_path51.default.join(stage, name);
|
|
56233
56162
|
if (entry.dir) {
|
|
56234
56163
|
await import_promises6.default.mkdir(dest, { recursive: true });
|
|
56235
56164
|
continue;
|
|
56236
56165
|
}
|
|
56237
|
-
await import_promises6.default.mkdir(
|
|
56166
|
+
await import_promises6.default.mkdir(import_node_path51.default.dirname(dest), { recursive: true });
|
|
56238
56167
|
if (name === "manifest.json") {
|
|
56239
56168
|
const rewritten = { ...parsed.data, id: localExtId };
|
|
56240
56169
|
await import_promises6.default.writeFile(dest, JSON.stringify(rewritten, null, 2));
|
|
@@ -56255,7 +56184,7 @@ async function installFromChannel(args, deps) {
|
|
|
56255
56184
|
|
|
56256
56185
|
// src/extension/update-flow.ts
|
|
56257
56186
|
var import_promises7 = __toESM(require("fs/promises"), 1);
|
|
56258
|
-
var
|
|
56187
|
+
var import_node_path52 = __toESM(require("path"), 1);
|
|
56259
56188
|
var import_node_os20 = __toESM(require("os"), 1);
|
|
56260
56189
|
var import_node_crypto16 = __toESM(require("crypto"), 1);
|
|
56261
56190
|
var import_jszip4 = __toESM(require_lib3(), 1);
|
|
@@ -56273,11 +56202,11 @@ async function updateFromChannel(args, deps) {
|
|
|
56273
56202
|
channelRef.extId,
|
|
56274
56203
|
channelRef.ownerPrincipalId
|
|
56275
56204
|
);
|
|
56276
|
-
const liveDir =
|
|
56205
|
+
const liveDir = import_node_path52.default.join(deps.extensionsRoot, localExtId);
|
|
56277
56206
|
const prevDir = `${liveDir}.prev`;
|
|
56278
56207
|
let existingVersion;
|
|
56279
56208
|
try {
|
|
56280
|
-
const raw = await import_promises7.default.readFile(
|
|
56209
|
+
const raw = await import_promises7.default.readFile(import_node_path52.default.join(liveDir, "manifest.json"), "utf8");
|
|
56281
56210
|
const parsed2 = ExtensionManifestSchema.safeParse(JSON.parse(raw));
|
|
56282
56211
|
if (!parsed2.success) {
|
|
56283
56212
|
throw new UpdateError(
|
|
@@ -56310,7 +56239,7 @@ async function updateFromChannel(args, deps) {
|
|
|
56310
56239
|
throw new UpdateError("ZIP_INVALID", `failed to load zip: ${e.message}`);
|
|
56311
56240
|
}
|
|
56312
56241
|
for (const name of Object.keys(zip.files)) {
|
|
56313
|
-
if (name.includes("..") || name.startsWith("/") ||
|
|
56242
|
+
if (name.includes("..") || name.startsWith("/") || import_node_path52.default.isAbsolute(name)) {
|
|
56314
56243
|
throw new UpdateError("ZIP_INVALID", `unsafe zip entry: ${name}`);
|
|
56315
56244
|
}
|
|
56316
56245
|
}
|
|
@@ -56345,16 +56274,16 @@ async function updateFromChannel(args, deps) {
|
|
|
56345
56274
|
await import_promises7.default.rm(prevDir, { recursive: true, force: true });
|
|
56346
56275
|
await import_promises7.default.rename(liveDir, prevDir);
|
|
56347
56276
|
const stage = await import_promises7.default.mkdtemp(
|
|
56348
|
-
|
|
56277
|
+
import_node_path52.default.join(import_node_os20.default.tmpdir(), `clawd-ext-update-${localExtId}-`)
|
|
56349
56278
|
);
|
|
56350
56279
|
try {
|
|
56351
56280
|
for (const [name, entry] of Object.entries(zip.files)) {
|
|
56352
|
-
const dest =
|
|
56281
|
+
const dest = import_node_path52.default.join(stage, name);
|
|
56353
56282
|
if (entry.dir) {
|
|
56354
56283
|
await import_promises7.default.mkdir(dest, { recursive: true });
|
|
56355
56284
|
continue;
|
|
56356
56285
|
}
|
|
56357
|
-
await import_promises7.default.mkdir(
|
|
56286
|
+
await import_promises7.default.mkdir(import_node_path52.default.dirname(dest), { recursive: true });
|
|
56358
56287
|
if (name === "manifest.json") {
|
|
56359
56288
|
const rewritten = { ...parsed.data, id: localExtId };
|
|
56360
56289
|
await import_promises7.default.writeFile(dest, JSON.stringify(rewritten, null, 2));
|
|
@@ -56448,7 +56377,7 @@ async function rewriteManifestVersion(root, extId, newVersion, previousPublished
|
|
|
56448
56377
|
);
|
|
56449
56378
|
}
|
|
56450
56379
|
}
|
|
56451
|
-
const manifestPath =
|
|
56380
|
+
const manifestPath = import_node_path53.default.join(root, extId, "manifest.json");
|
|
56452
56381
|
const manifest = await readManifest(root, extId);
|
|
56453
56382
|
const next = { ...manifest, version: newVersion };
|
|
56454
56383
|
const tmp = `${manifestPath}.tmp`;
|
|
@@ -56456,7 +56385,7 @@ async function rewriteManifestVersion(root, extId, newVersion, previousPublished
|
|
|
56456
56385
|
await import_promises8.default.rename(tmp, manifestPath);
|
|
56457
56386
|
}
|
|
56458
56387
|
async function readManifest(root, extId) {
|
|
56459
|
-
const file =
|
|
56388
|
+
const file = import_node_path53.default.join(root, extId, "manifest.json");
|
|
56460
56389
|
let raw;
|
|
56461
56390
|
try {
|
|
56462
56391
|
raw = await import_promises8.default.readFile(file, "utf8");
|
|
@@ -56547,7 +56476,7 @@ function buildExtensionHandlers(deps) {
|
|
|
56547
56476
|
};
|
|
56548
56477
|
async function buildSnapshotMeta(extId) {
|
|
56549
56478
|
const manifest = await readManifest(deps.root, extId);
|
|
56550
|
-
const { sha256, buffer } = await bundleExtensionDir(
|
|
56479
|
+
const { sha256, buffer } = await bundleExtensionDir(import_node_path53.default.join(deps.root, extId));
|
|
56551
56480
|
return { manifest, contentHash: sha256, buffer };
|
|
56552
56481
|
}
|
|
56553
56482
|
const publish = async (frame, _client, ctx) => {
|
|
@@ -56728,9 +56657,9 @@ function buildExtensionHandlers(deps) {
|
|
|
56728
56657
|
}
|
|
56729
56658
|
|
|
56730
56659
|
// src/app-builder/project-store.ts
|
|
56731
|
-
var
|
|
56660
|
+
var import_node_fs46 = require("fs");
|
|
56732
56661
|
var import_node_child_process14 = require("child_process");
|
|
56733
|
-
var
|
|
56662
|
+
var import_node_path54 = require("path");
|
|
56734
56663
|
init_protocol();
|
|
56735
56664
|
var PROJECTS_DIR = "projects";
|
|
56736
56665
|
var META_FILE = ".clawd-project.json";
|
|
@@ -56744,19 +56673,19 @@ var ProjectStore = class {
|
|
|
56744
56673
|
root;
|
|
56745
56674
|
/** projects/<name>/.clawd-project.json 路径 */
|
|
56746
56675
|
metaPath(name) {
|
|
56747
|
-
return (0,
|
|
56676
|
+
return (0, import_node_path54.join)(this.projectsRoot(), name, META_FILE);
|
|
56748
56677
|
}
|
|
56749
56678
|
/** projects/<name>/ 目录路径(cwd 用) */
|
|
56750
56679
|
projectDir(name) {
|
|
56751
|
-
return (0,
|
|
56680
|
+
return (0, import_node_path54.join)(this.projectsRoot(), name);
|
|
56752
56681
|
}
|
|
56753
56682
|
projectsRoot() {
|
|
56754
|
-
return (0,
|
|
56683
|
+
return (0, import_node_path54.join)(this.root, PROJECTS_DIR);
|
|
56755
56684
|
}
|
|
56756
56685
|
async list() {
|
|
56757
56686
|
let entries;
|
|
56758
56687
|
try {
|
|
56759
|
-
entries = await
|
|
56688
|
+
entries = await import_node_fs46.promises.readdir(this.projectsRoot());
|
|
56760
56689
|
} catch (err) {
|
|
56761
56690
|
if (err.code === "ENOENT") return [];
|
|
56762
56691
|
throw err;
|
|
@@ -56764,7 +56693,7 @@ var ProjectStore = class {
|
|
|
56764
56693
|
const out = [];
|
|
56765
56694
|
for (const name of entries) {
|
|
56766
56695
|
try {
|
|
56767
|
-
const raw = await
|
|
56696
|
+
const raw = await import_node_fs46.promises.readFile(this.metaPath(name), "utf8");
|
|
56768
56697
|
const json = JSON.parse(raw);
|
|
56769
56698
|
let migrated = false;
|
|
56770
56699
|
if (typeof json.devCommand !== "string" || json.devCommand.length === 0) {
|
|
@@ -56775,7 +56704,7 @@ var ProjectStore = class {
|
|
|
56775
56704
|
if (parsed.success) {
|
|
56776
56705
|
out.push(parsed.data);
|
|
56777
56706
|
if (migrated) {
|
|
56778
|
-
void
|
|
56707
|
+
void import_node_fs46.promises.writeFile(this.metaPath(name), JSON.stringify(parsed.data, null, 2) + "\n", "utf8").catch(() => {
|
|
56779
56708
|
});
|
|
56780
56709
|
}
|
|
56781
56710
|
}
|
|
@@ -56819,8 +56748,8 @@ var ProjectStore = class {
|
|
|
56819
56748
|
throw new Error(`invalid name "${name}": ${validated.error.message}`);
|
|
56820
56749
|
}
|
|
56821
56750
|
const dir = this.projectDir(name);
|
|
56822
|
-
await
|
|
56823
|
-
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");
|
|
56824
56753
|
return meta;
|
|
56825
56754
|
}
|
|
56826
56755
|
/**
|
|
@@ -56863,7 +56792,7 @@ var ProjectStore = class {
|
|
|
56863
56792
|
}
|
|
56864
56793
|
async delete(name) {
|
|
56865
56794
|
const dir = this.projectDir(name);
|
|
56866
|
-
await
|
|
56795
|
+
await import_node_fs46.promises.rm(dir, { recursive: true, force: true });
|
|
56867
56796
|
}
|
|
56868
56797
|
async updatePort(name, newPort) {
|
|
56869
56798
|
if (newPort < PROJECT_PORT_MIN || newPort > PROJECT_PORT_MAX) {
|
|
@@ -56879,7 +56808,7 @@ var ProjectStore = class {
|
|
|
56879
56808
|
throw new Error(`port ${newPort} already used / \u5DF2\u88AB project "${conflict.name}" \u5360\u7528`);
|
|
56880
56809
|
}
|
|
56881
56810
|
const updated = { ...target, port: newPort };
|
|
56882
|
-
await
|
|
56811
|
+
await import_node_fs46.promises.writeFile(this.metaPath(name), JSON.stringify(updated, null, 2) + "\n", "utf8");
|
|
56883
56812
|
return updated;
|
|
56884
56813
|
}
|
|
56885
56814
|
/**
|
|
@@ -56896,7 +56825,7 @@ var ProjectStore = class {
|
|
|
56896
56825
|
if (!validated.success) {
|
|
56897
56826
|
throw new Error(`invalid prodUrl "${url}": ${validated.error.message}`);
|
|
56898
56827
|
}
|
|
56899
|
-
await
|
|
56828
|
+
await import_node_fs46.promises.writeFile(this.metaPath(name), JSON.stringify(validated.data, null, 2) + "\n", "utf8");
|
|
56900
56829
|
return validated.data;
|
|
56901
56830
|
}
|
|
56902
56831
|
/**
|
|
@@ -56917,7 +56846,7 @@ var ProjectStore = class {
|
|
|
56917
56846
|
if (!validated.success) {
|
|
56918
56847
|
throw new Error(`invalid publishJob: ${validated.error.message}`);
|
|
56919
56848
|
}
|
|
56920
|
-
await
|
|
56849
|
+
await import_node_fs46.promises.writeFile(this.metaPath(name), JSON.stringify(validated.data, null, 2) + "\n", "utf8");
|
|
56921
56850
|
return validated.data;
|
|
56922
56851
|
}
|
|
56923
56852
|
/** 清掉 .clawd-project.json.publishJob 字段。其他字段保持原样。 */
|
|
@@ -56932,7 +56861,7 @@ var ProjectStore = class {
|
|
|
56932
56861
|
if (!validated.success) {
|
|
56933
56862
|
throw new Error(`failed to clear publishJob: ${validated.error.message}`);
|
|
56934
56863
|
}
|
|
56935
|
-
await
|
|
56864
|
+
await import_node_fs46.promises.writeFile(this.metaPath(name), JSON.stringify(validated.data, null, 2) + "\n", "utf8");
|
|
56936
56865
|
return validated.data;
|
|
56937
56866
|
}
|
|
56938
56867
|
};
|
|
@@ -57053,8 +56982,8 @@ var PublishJobRegistry = class {
|
|
|
57053
56982
|
|
|
57054
56983
|
// src/app-builder/publish-job-runner.ts
|
|
57055
56984
|
var import_node_child_process16 = require("child_process");
|
|
57056
|
-
var
|
|
57057
|
-
var
|
|
56985
|
+
var import_node_fs47 = require("fs");
|
|
56986
|
+
var import_node_path55 = require("path");
|
|
57058
56987
|
|
|
57059
56988
|
// src/app-builder/publish-stage-parser.ts
|
|
57060
56989
|
var STAGE_RE = /^\s*::stage::(build|deploy|verify)\s*$/;
|
|
@@ -57086,10 +57015,10 @@ async function startPublishJob(deps, args) {
|
|
|
57086
57015
|
return { jobId: registry2.get(args.name).jobId, status: "already-publishing" };
|
|
57087
57016
|
}
|
|
57088
57017
|
const projDir = projectDir(args.name);
|
|
57089
|
-
const logPath = (0,
|
|
57018
|
+
const logPath = (0, import_node_path55.join)(projDir, ".publish.log");
|
|
57090
57019
|
let logStream = null;
|
|
57091
57020
|
try {
|
|
57092
|
-
logStream = (0,
|
|
57021
|
+
logStream = (0, import_node_fs47.createWriteStream)(logPath, { flags: "w" });
|
|
57093
57022
|
} catch {
|
|
57094
57023
|
logStream = null;
|
|
57095
57024
|
}
|
|
@@ -57346,8 +57275,8 @@ async function recoverInterruptedJobs(deps) {
|
|
|
57346
57275
|
|
|
57347
57276
|
// src/handlers/app-builder.ts
|
|
57348
57277
|
init_protocol();
|
|
57349
|
-
var
|
|
57350
|
-
var
|
|
57278
|
+
var import_node_path56 = require("path");
|
|
57279
|
+
var import_node_fs48 = require("fs");
|
|
57351
57280
|
var APP_BUILDER_PERSONAS = ["persona-app-builder", "persona-dataclaw-builder"];
|
|
57352
57281
|
var DEV_SERVER_READY_TIMEOUT_MS = 3e4;
|
|
57353
57282
|
async function recoverInterruptedPublishJobs(store, logger) {
|
|
@@ -57428,7 +57357,7 @@ function buildAppBuilderHandlers(deps) {
|
|
|
57428
57357
|
async function listAllUsersProjects() {
|
|
57429
57358
|
if (!deps.usersRoot || !deps.getStore) return [];
|
|
57430
57359
|
const getStore = deps.getStore;
|
|
57431
|
-
const userIds = await
|
|
57360
|
+
const userIds = await import_node_fs48.promises.readdir(deps.usersRoot).catch(() => []);
|
|
57432
57361
|
const perUser = await Promise.all(
|
|
57433
57362
|
userIds.map((uid) => getStore(uid).list().catch(() => []))
|
|
57434
57363
|
);
|
|
@@ -57504,8 +57433,8 @@ function buildAppBuilderHandlers(deps) {
|
|
|
57504
57433
|
const project = await userStore.create(f.name, reservedPorts);
|
|
57505
57434
|
try {
|
|
57506
57435
|
const personaRoot = deps.resolvePersonaRoot ? deps.resolvePersonaRoot(session.ownerPersonaId ?? "") : deps.personaRoot;
|
|
57507
|
-
const templateSrcDir = (0,
|
|
57508
|
-
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");
|
|
57509
57438
|
const scaffoldResult = await userStore.scaffold(project.name, templateSrcDir, scaffoldScript);
|
|
57510
57439
|
deps.logger?.info("app-builder.scaffold.done", {
|
|
57511
57440
|
name: project.name,
|
|
@@ -57726,7 +57655,7 @@ function buildAppBuilderHandlers(deps) {
|
|
|
57726
57655
|
await userStore.clearPublishJob(args.name);
|
|
57727
57656
|
}
|
|
57728
57657
|
const personaRoot = deps.resolvePersonaRoot ? deps.resolvePersonaRoot(boundSession.ownerPersonaId ?? "") : deps.personaRoot;
|
|
57729
|
-
const scriptPath = (0,
|
|
57658
|
+
const scriptPath = (0, import_node_path56.join)(deps.deployKitRoot, "scripts", "publish.sh");
|
|
57730
57659
|
deps.logger?.info("app-builder.publish.start", {
|
|
57731
57660
|
name: args.name,
|
|
57732
57661
|
sessionId: boundSession.sessionId,
|
|
@@ -57895,7 +57824,7 @@ function buildVisitorHandlers(deps) {
|
|
|
57895
57824
|
|
|
57896
57825
|
// src/extension/registry.ts
|
|
57897
57826
|
var import_promises9 = __toESM(require("fs/promises"), 1);
|
|
57898
|
-
var
|
|
57827
|
+
var import_node_path57 = __toESM(require("path"), 1);
|
|
57899
57828
|
init_src();
|
|
57900
57829
|
async function loadAll(root) {
|
|
57901
57830
|
let entries;
|
|
@@ -57909,13 +57838,13 @@ async function loadAll(root) {
|
|
|
57909
57838
|
for (const ent of entries) {
|
|
57910
57839
|
if (!ent.isDirectory()) continue;
|
|
57911
57840
|
if (ent.name.startsWith(".")) continue;
|
|
57912
|
-
records.push(await loadOne(
|
|
57841
|
+
records.push(await loadOne(import_node_path57.default.join(root, ent.name), ent.name));
|
|
57913
57842
|
}
|
|
57914
57843
|
records.sort((a, b2) => a.extId < b2.extId ? -1 : a.extId > b2.extId ? 1 : 0);
|
|
57915
57844
|
return records;
|
|
57916
57845
|
}
|
|
57917
57846
|
async function loadOne(dir, dirName) {
|
|
57918
|
-
const manifestPath =
|
|
57847
|
+
const manifestPath = import_node_path57.default.join(dir, "manifest.json");
|
|
57919
57848
|
let raw;
|
|
57920
57849
|
try {
|
|
57921
57850
|
raw = await import_promises9.default.readFile(manifestPath, "utf8");
|
|
@@ -57960,7 +57889,7 @@ async function loadOne(dir, dirName) {
|
|
|
57960
57889
|
|
|
57961
57890
|
// src/extension/uninstall.ts
|
|
57962
57891
|
var import_promises10 = __toESM(require("fs/promises"), 1);
|
|
57963
|
-
var
|
|
57892
|
+
var import_node_path58 = __toESM(require("path"), 1);
|
|
57964
57893
|
var UninstallError = class extends Error {
|
|
57965
57894
|
constructor(code, message) {
|
|
57966
57895
|
super(message);
|
|
@@ -57969,7 +57898,7 @@ var UninstallError = class extends Error {
|
|
|
57969
57898
|
code;
|
|
57970
57899
|
};
|
|
57971
57900
|
async function uninstall(deps) {
|
|
57972
|
-
const dir =
|
|
57901
|
+
const dir = import_node_path58.default.join(deps.root, deps.extId);
|
|
57973
57902
|
try {
|
|
57974
57903
|
await import_promises10.default.access(dir);
|
|
57975
57904
|
} catch {
|
|
@@ -58553,7 +58482,7 @@ async function dispatchRpc(method, frame, client, ctx, deps) {
|
|
|
58553
58482
|
|
|
58554
58483
|
// src/extension/runtime.ts
|
|
58555
58484
|
var import_node_child_process18 = require("child_process");
|
|
58556
|
-
var
|
|
58485
|
+
var import_node_path59 = __toESM(require("path"), 1);
|
|
58557
58486
|
var import_promises11 = require("timers/promises");
|
|
58558
58487
|
init_src();
|
|
58559
58488
|
|
|
@@ -58655,7 +58584,7 @@ var Runtime = class {
|
|
|
58655
58584
|
/\$CLAWOS_EXT_PORT/g,
|
|
58656
58585
|
String(port)
|
|
58657
58586
|
);
|
|
58658
|
-
const dir =
|
|
58587
|
+
const dir = import_node_path59.default.join(this.root, extId);
|
|
58659
58588
|
const env = {
|
|
58660
58589
|
...process.env,
|
|
58661
58590
|
CLAWOS_EXT_PORT: String(port),
|
|
@@ -58767,7 +58696,7 @@ ${handle.stderrTail}`
|
|
|
58767
58696
|
|
|
58768
58697
|
// src/extension/published-channels.ts
|
|
58769
58698
|
var import_promises12 = __toESM(require("fs/promises"), 1);
|
|
58770
|
-
var
|
|
58699
|
+
var import_node_path60 = __toESM(require("path"), 1);
|
|
58771
58700
|
init_src();
|
|
58772
58701
|
init_zod();
|
|
58773
58702
|
var PublishedChannelsError = class extends Error {
|
|
@@ -58867,7 +58796,7 @@ var PublishedChannelStore = class {
|
|
|
58867
58796
|
)
|
|
58868
58797
|
};
|
|
58869
58798
|
const tmp = `${this.filePath}.tmp`;
|
|
58870
|
-
await import_promises12.default.mkdir(
|
|
58799
|
+
await import_promises12.default.mkdir(import_node_path60.default.dirname(this.filePath), { recursive: true });
|
|
58871
58800
|
await import_promises12.default.writeFile(tmp, JSON.stringify(data, null, 2), { mode: 384 });
|
|
58872
58801
|
await import_promises12.default.rename(tmp, this.filePath);
|
|
58873
58802
|
}
|
|
@@ -58875,7 +58804,7 @@ var PublishedChannelStore = class {
|
|
|
58875
58804
|
|
|
58876
58805
|
// src/extension/bundle-cache.ts
|
|
58877
58806
|
var import_promises13 = __toESM(require("fs/promises"), 1);
|
|
58878
|
-
var
|
|
58807
|
+
var import_node_path61 = __toESM(require("path"), 1);
|
|
58879
58808
|
var BundleCache = class {
|
|
58880
58809
|
constructor(rootDir) {
|
|
58881
58810
|
this.rootDir = rootDir;
|
|
@@ -58884,14 +58813,14 @@ var BundleCache = class {
|
|
|
58884
58813
|
/** Atomic write: stage tmp → rename. Caller passes the hex sha256. */
|
|
58885
58814
|
async write(snapshotHash, buffer) {
|
|
58886
58815
|
await import_promises13.default.mkdir(this.rootDir, { recursive: true });
|
|
58887
|
-
const file =
|
|
58816
|
+
const file = import_node_path61.default.join(this.rootDir, `${snapshotHash}.zip`);
|
|
58888
58817
|
const tmp = `${file}.tmp`;
|
|
58889
58818
|
await import_promises13.default.writeFile(tmp, buffer, { mode: 384 });
|
|
58890
58819
|
await import_promises13.default.rename(tmp, file);
|
|
58891
58820
|
}
|
|
58892
58821
|
/** Returns the bundle bytes, or null when the file doesn't exist. */
|
|
58893
58822
|
async read(snapshotHash) {
|
|
58894
|
-
const file =
|
|
58823
|
+
const file = import_node_path61.default.join(this.rootDir, `${snapshotHash}.zip`);
|
|
58895
58824
|
try {
|
|
58896
58825
|
return await import_promises13.default.readFile(file);
|
|
58897
58826
|
} catch (e) {
|
|
@@ -58901,7 +58830,7 @@ var BundleCache = class {
|
|
|
58901
58830
|
}
|
|
58902
58831
|
/** Idempotent — missing file is not an error. */
|
|
58903
58832
|
async delete(snapshotHash) {
|
|
58904
|
-
const file =
|
|
58833
|
+
const file = import_node_path61.default.join(this.rootDir, `${snapshotHash}.zip`);
|
|
58905
58834
|
await import_promises13.default.rm(file, { force: true });
|
|
58906
58835
|
}
|
|
58907
58836
|
};
|
|
@@ -58926,16 +58855,16 @@ async function startDaemon(config) {
|
|
|
58926
58855
|
});
|
|
58927
58856
|
const logger = createLogger({
|
|
58928
58857
|
level: config.logLevel,
|
|
58929
|
-
file:
|
|
58858
|
+
file: import_node_path62.default.join(config.dataDir, "clawd.log"),
|
|
58930
58859
|
logClient
|
|
58931
58860
|
});
|
|
58932
58861
|
logger.info("starting clawd", { version, config: { port: config.port, host: config.host, dataDir: config.dataDir } });
|
|
58933
58862
|
const screenIdleProbeLogger = createFileOnlyLogger({
|
|
58934
|
-
file:
|
|
58863
|
+
file: import_node_path62.default.join(config.dataDir, "screen-idle-probe.log"),
|
|
58935
58864
|
level: "debug"
|
|
58936
58865
|
});
|
|
58937
58866
|
logger.info("screen-idle probe logger enabled", {
|
|
58938
|
-
file:
|
|
58867
|
+
file: import_node_path62.default.join(config.dataDir, "screen-idle-probe.log")
|
|
58939
58868
|
});
|
|
58940
58869
|
const stateMgr = new StateFileManager({ dataDir: config.dataDir });
|
|
58941
58870
|
const pre = stateMgr.preflight();
|
|
@@ -59073,8 +59002,8 @@ async function startDaemon(config) {
|
|
|
59073
59002
|
const agents = new AgentsScanner();
|
|
59074
59003
|
const history = new ClaudeHistoryReader();
|
|
59075
59004
|
let transport = null;
|
|
59076
|
-
const personaStore = new PersonaStore(
|
|
59077
|
-
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");
|
|
59078
59007
|
const defaultsRoot = findDefaultsRoot(logger);
|
|
59079
59008
|
if (defaultsRoot) {
|
|
59080
59009
|
seedDefaultPersonas({ store: personaStore, defaultsRoot, logger });
|
|
@@ -59094,17 +59023,17 @@ async function startDaemon(config) {
|
|
|
59094
59023
|
migrateCodexSandbox({ store: personaStore, logger });
|
|
59095
59024
|
const groupFileStore = new GroupFileStore({ dataDir: config.dataDir, logger });
|
|
59096
59025
|
const personaDispatchManager = new PersonaDispatchManager({ genId: () => v4_default() });
|
|
59097
|
-
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));
|
|
59098
59027
|
const dispatchServerCandidates = [
|
|
59099
|
-
|
|
59028
|
+
import_node_path62.default.join(here, "dispatch", "mcp-server.cjs"),
|
|
59100
59029
|
// 生产 dist/index → dist/dispatch/mcp-server.cjs
|
|
59101
|
-
|
|
59030
|
+
import_node_path62.default.join(here, "..", "dist", "dispatch", "mcp-server.cjs")
|
|
59102
59031
|
// dev tsx src/index → ../dist/dispatch/mcp-server.cjs
|
|
59103
59032
|
];
|
|
59104
|
-
const dispatchServerScriptPath = dispatchServerCandidates.find((p2) =>
|
|
59033
|
+
const dispatchServerScriptPath = dispatchServerCandidates.find((p2) => import_node_fs49.default.existsSync(p2));
|
|
59105
59034
|
let dispatchMcpConfigPath2;
|
|
59106
59035
|
if (dispatchServerScriptPath) {
|
|
59107
|
-
const dispatchLogPath =
|
|
59036
|
+
const dispatchLogPath = import_node_path62.default.join(config.dataDir, "dispatch-mcp-server.log");
|
|
59108
59037
|
dispatchMcpConfigPath2 = writeDispatchMcpConfig({
|
|
59109
59038
|
dataDir: config.dataDir,
|
|
59110
59039
|
serverScriptPath: dispatchServerScriptPath,
|
|
@@ -59121,15 +59050,15 @@ async function startDaemon(config) {
|
|
|
59121
59050
|
});
|
|
59122
59051
|
}
|
|
59123
59052
|
const ticketServerCandidates = [
|
|
59124
|
-
|
|
59125
|
-
|
|
59053
|
+
import_node_path62.default.join(here, "ticket", "mcp-server.cjs"),
|
|
59054
|
+
import_node_path62.default.join(here, "..", "dist", "ticket", "mcp-server.cjs")
|
|
59126
59055
|
];
|
|
59127
|
-
const ticketServerScriptPath = ticketServerCandidates.find((p2) =>
|
|
59056
|
+
const ticketServerScriptPath = ticketServerCandidates.find((p2) => import_node_fs49.default.existsSync(p2));
|
|
59128
59057
|
const ticketOwnerUnionId = feishuIdentity?.identity.unionId ?? "";
|
|
59129
59058
|
const ticketOwnerName = feishuIdentity?.identity.displayName ?? "";
|
|
59130
59059
|
let ticketMcpConfigPath2;
|
|
59131
59060
|
if (ticketServerScriptPath && ticketOwnerUnionId) {
|
|
59132
|
-
const ticketLogPath =
|
|
59061
|
+
const ticketLogPath = import_node_path62.default.join(config.dataDir, "ticket-mcp-server.log");
|
|
59133
59062
|
ticketMcpConfigPath2 = writeTicketMcpConfig({
|
|
59134
59063
|
dataDir: config.dataDir,
|
|
59135
59064
|
serverScriptPath: ticketServerScriptPath,
|
|
@@ -59150,13 +59079,13 @@ async function startDaemon(config) {
|
|
|
59150
59079
|
});
|
|
59151
59080
|
}
|
|
59152
59081
|
const shiftServerCandidates = [
|
|
59153
|
-
|
|
59154
|
-
|
|
59082
|
+
import_node_path62.default.join(here, "shift", "mcp-server.cjs"),
|
|
59083
|
+
import_node_path62.default.join(here, "..", "dist", "shift", "mcp-server.cjs")
|
|
59155
59084
|
];
|
|
59156
|
-
const shiftServerScriptPath = shiftServerCandidates.find((p2) =>
|
|
59085
|
+
const shiftServerScriptPath = shiftServerCandidates.find((p2) => import_node_fs49.default.existsSync(p2));
|
|
59157
59086
|
let shiftMcpConfigPath2;
|
|
59158
59087
|
if (shiftServerScriptPath) {
|
|
59159
|
-
const shiftLogPath =
|
|
59088
|
+
const shiftLogPath = import_node_path62.default.join(config.dataDir, "shift-mcp-server.log");
|
|
59160
59089
|
shiftMcpConfigPath2 = await writeShiftMcpConfig({
|
|
59161
59090
|
dataDir: config.dataDir,
|
|
59162
59091
|
serverScriptPath: shiftServerScriptPath,
|
|
@@ -59174,13 +59103,13 @@ async function startDaemon(config) {
|
|
|
59174
59103
|
);
|
|
59175
59104
|
}
|
|
59176
59105
|
const inboxServerCandidates = [
|
|
59177
|
-
|
|
59178
|
-
|
|
59106
|
+
import_node_path62.default.join(here, "inbox", "mcp-server.cjs"),
|
|
59107
|
+
import_node_path62.default.join(here, "..", "dist", "inbox", "mcp-server.cjs")
|
|
59179
59108
|
];
|
|
59180
|
-
const inboxServerScriptPath = inboxServerCandidates.find((p2) =>
|
|
59109
|
+
const inboxServerScriptPath = inboxServerCandidates.find((p2) => import_node_fs49.default.existsSync(p2));
|
|
59181
59110
|
let inboxMcpConfigPath2;
|
|
59182
59111
|
if (inboxServerScriptPath) {
|
|
59183
|
-
const inboxLogPath =
|
|
59112
|
+
const inboxLogPath = import_node_path62.default.join(config.dataDir, "inbox-mcp-server.log");
|
|
59184
59113
|
inboxMcpConfigPath2 = await writeInboxMcpConfig({
|
|
59185
59114
|
dataDir: config.dataDir,
|
|
59186
59115
|
serverScriptPath: inboxServerScriptPath,
|
|
@@ -59198,7 +59127,7 @@ async function startDaemon(config) {
|
|
|
59198
59127
|
);
|
|
59199
59128
|
}
|
|
59200
59129
|
const shiftStore = createShiftStore({
|
|
59201
|
-
filePath:
|
|
59130
|
+
filePath: import_node_path62.default.join(config.dataDir, "shift.json"),
|
|
59202
59131
|
ownerIdProvider: () => ownerPrincipalId,
|
|
59203
59132
|
now: () => Date.now()
|
|
59204
59133
|
});
|
|
@@ -59220,7 +59149,7 @@ async function startDaemon(config) {
|
|
|
59220
59149
|
getAdapter,
|
|
59221
59150
|
historyReader: history,
|
|
59222
59151
|
dataDir: config.dataDir,
|
|
59223
|
-
personaRoot:
|
|
59152
|
+
personaRoot: import_node_path62.default.join(config.dataDir, "personas"),
|
|
59224
59153
|
usersRoot,
|
|
59225
59154
|
personaStore,
|
|
59226
59155
|
ownerDisplayName,
|
|
@@ -59263,10 +59192,10 @@ async function startDaemon(config) {
|
|
|
59263
59192
|
// 文件可能 agent 写完又被自己删(罕见),用 size=0 / fallback mime 兜底。
|
|
59264
59193
|
attachmentGroup: {
|
|
59265
59194
|
onFileEdit: (input) => {
|
|
59266
|
-
const absPath =
|
|
59195
|
+
const absPath = import_node_path62.default.isAbsolute(input.relPath) ? input.relPath : import_node_path62.default.join(input.cwd, input.relPath);
|
|
59267
59196
|
let size = 0;
|
|
59268
59197
|
try {
|
|
59269
|
-
size =
|
|
59198
|
+
size = import_node_fs49.default.statSync(absPath).size;
|
|
59270
59199
|
} catch (err) {
|
|
59271
59200
|
logger.warn("attachment.onFileEdit stat failed", {
|
|
59272
59201
|
sessionId: input.sessionId,
|
|
@@ -59465,11 +59394,11 @@ async function startDaemon(config) {
|
|
|
59465
59394
|
// 'persona/<pid>/owner',default 走 'default'。
|
|
59466
59395
|
getSessionScope: (sid) => manager.findOwnedSessionScope(sid),
|
|
59467
59396
|
// guest path guard:candidate 必须在 personaRoot 子树或调用者自己的 user-dir 下
|
|
59468
|
-
personaRoot:
|
|
59397
|
+
personaRoot: import_node_path62.default.join(config.dataDir, "personas"),
|
|
59469
59398
|
usersRoot
|
|
59470
59399
|
},
|
|
59471
59400
|
// workspace/git/history/skills/agents handler 共用的 guest path guard 锚点
|
|
59472
|
-
personaRoot:
|
|
59401
|
+
personaRoot: import_node_path62.default.join(config.dataDir, "personas"),
|
|
59473
59402
|
// v2 多人 persona 隔离:handler 派生 guest user-dir 放行
|
|
59474
59403
|
usersRoot,
|
|
59475
59404
|
// capability:list / delete handler 依赖
|
|
@@ -59491,7 +59420,7 @@ async function startDaemon(config) {
|
|
|
59491
59420
|
contactStore,
|
|
59492
59421
|
// <dataDir>/sshd 绝对路径 —— contact-ssh handlers 用它拼 authorized_keys / keys/ 子路径
|
|
59493
59422
|
// Task 10 会加 SshdManager 起 sshd;handlers wire 提前挂 sshdDir 让 typecheck 过
|
|
59494
|
-
sshdDir:
|
|
59423
|
+
sshdDir: import_node_path62.default.join(config.dataDir, "sshd"),
|
|
59495
59424
|
contactSshLog: sshLog,
|
|
59496
59425
|
// inbox:sendDm 用:sessionId → session 出身(复用 attachment 同款 findOwnedSessionScope)
|
|
59497
59426
|
getSessionScope: (sid) => manager.findOwnedSessionScope(sid),
|
|
@@ -59582,11 +59511,11 @@ async function startDaemon(config) {
|
|
|
59582
59511
|
// 发布上线脚手架化 (spec 2026-06-03 §5.2):
|
|
59583
59512
|
// appBuilderPersonaRoot 用于拼 publish.sh 绝对路径(persona-app-builder 安装在
|
|
59584
59513
|
// dataDir/personas/persona-app-builder 之下,extension-kit/scripts/publish.sh 是相对路径)。
|
|
59585
|
-
appBuilderPersonaRoot:
|
|
59514
|
+
appBuilderPersonaRoot: import_node_path62.default.join(config.dataDir, "personas", "persona-app-builder"),
|
|
59586
59515
|
// 共享 deploy-kit 根:scaffold/publish 脚本骨架 + 阿里云凭证单一真源。
|
|
59587
|
-
deployKitRoot:
|
|
59516
|
+
deployKitRoot: import_node_path62.default.join(config.dataDir, "deploy-kit"),
|
|
59588
59517
|
// scaffold/publish 按当前 session 的 persona 解析其安装根,让每个 persona 用自己的模板/注入配置。
|
|
59589
|
-
resolvePersonaRoot: (personaId) =>
|
|
59518
|
+
resolvePersonaRoot: (personaId) => import_node_path62.default.join(config.dataDir, "personas", personaId),
|
|
59590
59519
|
// 发布上线脚手架化 (spec 2026-06-03 §5.2.2):
|
|
59591
59520
|
// 复用 SessionManagerDeps.broadcastFrame 同款 dispatch 逻辑 —— runner 调 manager.send
|
|
59592
59521
|
// 取回 broadcast 帧后逐帧 push 到 transport,跟 manager 自身的 deps 一致。
|
|
@@ -59629,7 +59558,7 @@ async function startDaemon(config) {
|
|
|
59629
59558
|
}
|
|
59630
59559
|
let sourceJsonlPath = "(no transcript yet \u2014 operate from the task description alone)";
|
|
59631
59560
|
if (sourceFile && sourceFile.toolSessionId) {
|
|
59632
|
-
sourceJsonlPath =
|
|
59561
|
+
sourceJsonlPath = import_node_path62.default.join(
|
|
59633
59562
|
import_node_os21.default.homedir(),
|
|
59634
59563
|
".claude",
|
|
59635
59564
|
"projects",
|
|
@@ -59959,8 +59888,8 @@ async function startDaemon(config) {
|
|
|
59959
59888
|
const lines = [
|
|
59960
59889
|
`Tunnel: ${r.url}`,
|
|
59961
59890
|
...resolvedAuthToken ? [`Connect: ${connectUrl}`] : [],
|
|
59962
|
-
`Frpc config: ${
|
|
59963
|
-
`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")}`
|
|
59964
59893
|
];
|
|
59965
59894
|
const width = Math.max(...lines.map((l) => l.length));
|
|
59966
59895
|
const bar = "\u2550".repeat(width + 4);
|
|
@@ -59973,8 +59902,8 @@ ${bar}
|
|
|
59973
59902
|
|
|
59974
59903
|
`);
|
|
59975
59904
|
try {
|
|
59976
|
-
const connectPath =
|
|
59977
|
-
|
|
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 });
|
|
59978
59907
|
} catch {
|
|
59979
59908
|
}
|
|
59980
59909
|
} catch (err) {
|
|
@@ -60008,7 +59937,7 @@ ${bar}
|
|
|
60008
59937
|
});
|
|
60009
59938
|
try {
|
|
60010
59939
|
await sshdMgr.start();
|
|
60011
|
-
rebuildAuthorizedKeys(contactStore,
|
|
59940
|
+
rebuildAuthorizedKeys(contactStore, import_node_path62.default.join(config.dataDir, "sshd"));
|
|
60012
59941
|
logger.info("sshd: contact-ssh sandbox ready", { port: config.sshdPort });
|
|
60013
59942
|
} catch (err) {
|
|
60014
59943
|
logger.warn("sshd start failed; contact SSH grant will not work until fixed", {
|
|
@@ -60076,9 +60005,9 @@ ${bar}
|
|
|
60076
60005
|
};
|
|
60077
60006
|
}
|
|
60078
60007
|
function migrateDropPersonsDir(dataDir) {
|
|
60079
|
-
const dir =
|
|
60008
|
+
const dir = import_node_path62.default.join(dataDir, "persons");
|
|
60080
60009
|
try {
|
|
60081
|
-
|
|
60010
|
+
import_node_fs49.default.rmSync(dir, { recursive: true, force: true });
|
|
60082
60011
|
} catch {
|
|
60083
60012
|
}
|
|
60084
60013
|
}
|