duclaw-cli 1.9.8 → 1.9.10
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/bundle.js +450 -312
- package/dist/main.js +1 -1
- package/dist/web/assets/{index-BYLnL8Rp.js → index-DnD9jpKq.js} +2 -2
- package/dist/web/index.html +1 -1
- package/dist/worker-main.js +1 -1
- package/package.json +2 -1
package/dist/bundle.js
CHANGED
|
@@ -115,7 +115,7 @@ var require_package = __commonJS({
|
|
|
115
115
|
var require_main = __commonJS({
|
|
116
116
|
"node_modules/.pnpm/dotenv@17.3.1/node_modules/dotenv/lib/main.js"(exports2, module2) {
|
|
117
117
|
var fs3 = require("fs");
|
|
118
|
-
var
|
|
118
|
+
var path21 = require("path");
|
|
119
119
|
var os = require("os");
|
|
120
120
|
var crypto2 = require("crypto");
|
|
121
121
|
var packageJson = require_package();
|
|
@@ -261,7 +261,7 @@ var require_main = __commonJS({
|
|
|
261
261
|
possibleVaultPath = options.path.endsWith(".vault") ? options.path : `${options.path}.vault`;
|
|
262
262
|
}
|
|
263
263
|
} else {
|
|
264
|
-
possibleVaultPath =
|
|
264
|
+
possibleVaultPath = path21.resolve(process.cwd(), ".env.vault");
|
|
265
265
|
}
|
|
266
266
|
if (fs3.existsSync(possibleVaultPath)) {
|
|
267
267
|
return possibleVaultPath;
|
|
@@ -269,7 +269,7 @@ var require_main = __commonJS({
|
|
|
269
269
|
return null;
|
|
270
270
|
}
|
|
271
271
|
function _resolveHome(envPath) {
|
|
272
|
-
return envPath[0] === "~" ?
|
|
272
|
+
return envPath[0] === "~" ? path21.join(os.homedir(), envPath.slice(1)) : envPath;
|
|
273
273
|
}
|
|
274
274
|
function _configVault(options) {
|
|
275
275
|
const debug = parseBoolean(process.env.DOTENV_CONFIG_DEBUG || options && options.debug);
|
|
@@ -286,7 +286,7 @@ var require_main = __commonJS({
|
|
|
286
286
|
return { parsed };
|
|
287
287
|
}
|
|
288
288
|
function configDotenv(options) {
|
|
289
|
-
const dotenvPath =
|
|
289
|
+
const dotenvPath = path21.resolve(process.cwd(), ".env");
|
|
290
290
|
let encoding = "utf8";
|
|
291
291
|
let processEnv = process.env;
|
|
292
292
|
if (options && options.processEnv != null) {
|
|
@@ -314,13 +314,13 @@ var require_main = __commonJS({
|
|
|
314
314
|
}
|
|
315
315
|
let lastError;
|
|
316
316
|
const parsedAll = {};
|
|
317
|
-
for (const
|
|
317
|
+
for (const path22 of optionPaths) {
|
|
318
318
|
try {
|
|
319
|
-
const parsed = DotenvModule.parse(fs3.readFileSync(
|
|
319
|
+
const parsed = DotenvModule.parse(fs3.readFileSync(path22, { encoding }));
|
|
320
320
|
DotenvModule.populate(parsedAll, parsed, options);
|
|
321
321
|
} catch (e) {
|
|
322
322
|
if (debug) {
|
|
323
|
-
_debug(`Failed to load ${
|
|
323
|
+
_debug(`Failed to load ${path22} ${e.message}`);
|
|
324
324
|
}
|
|
325
325
|
lastError = e;
|
|
326
326
|
}
|
|
@@ -333,7 +333,7 @@ var require_main = __commonJS({
|
|
|
333
333
|
const shortPaths = [];
|
|
334
334
|
for (const filePath of optionPaths) {
|
|
335
335
|
try {
|
|
336
|
-
const relative4 =
|
|
336
|
+
const relative4 = path21.relative(process.cwd(), filePath);
|
|
337
337
|
shortPaths.push(relative4);
|
|
338
338
|
} catch (e) {
|
|
339
339
|
if (debug) {
|
|
@@ -8237,8 +8237,8 @@ var require_MODULE_LOAD = __commonJS({
|
|
|
8237
8237
|
* @param moduleArguments - Optional arguments to pass to the module
|
|
8238
8238
|
* @see https://redis.io/commands/module-load/
|
|
8239
8239
|
*/
|
|
8240
|
-
parseCommand(parser,
|
|
8241
|
-
parser.push("MODULE", "LOAD",
|
|
8240
|
+
parseCommand(parser, path21, moduleArguments) {
|
|
8241
|
+
parser.push("MODULE", "LOAD", path21);
|
|
8242
8242
|
if (moduleArguments) {
|
|
8243
8243
|
parser.push(...moduleArguments);
|
|
8244
8244
|
}
|
|
@@ -23539,10 +23539,10 @@ var require_ARRAPPEND = __commonJS({
|
|
|
23539
23539
|
* @param json - The first value to append
|
|
23540
23540
|
* @param jsons - Additional values to append
|
|
23541
23541
|
*/
|
|
23542
|
-
parseCommand(parser, key,
|
|
23542
|
+
parseCommand(parser, key, path21, json, ...jsons) {
|
|
23543
23543
|
parser.push("JSON.ARRAPPEND");
|
|
23544
23544
|
parser.pushKey(key);
|
|
23545
|
-
parser.push(
|
|
23545
|
+
parser.push(path21, (0, generic_transformers_1.transformRedisJsonArgument)(json));
|
|
23546
23546
|
for (let i = 0; i < jsons.length; i++) {
|
|
23547
23547
|
parser.push((0, generic_transformers_1.transformRedisJsonArgument)(jsons[i]));
|
|
23548
23548
|
}
|
|
@@ -23572,10 +23572,10 @@ var require_ARRINDEX = __commonJS({
|
|
|
23572
23572
|
* @param options.range.start - Starting index for the search
|
|
23573
23573
|
* @param options.range.stop - Optional ending index for the search
|
|
23574
23574
|
*/
|
|
23575
|
-
parseCommand(parser, key,
|
|
23575
|
+
parseCommand(parser, key, path21, json, options) {
|
|
23576
23576
|
parser.push("JSON.ARRINDEX");
|
|
23577
23577
|
parser.pushKey(key);
|
|
23578
|
-
parser.push(
|
|
23578
|
+
parser.push(path21, (0, generic_transformers_1.transformRedisJsonArgument)(json));
|
|
23579
23579
|
if (options?.range) {
|
|
23580
23580
|
parser.push(options.range.start.toString());
|
|
23581
23581
|
if (options.range.stop !== void 0) {
|
|
@@ -23607,10 +23607,10 @@ var require_ARRINSERT = __commonJS({
|
|
|
23607
23607
|
* @param json - The first value to insert
|
|
23608
23608
|
* @param jsons - Additional values to insert
|
|
23609
23609
|
*/
|
|
23610
|
-
parseCommand(parser, key,
|
|
23610
|
+
parseCommand(parser, key, path21, index, json, ...jsons) {
|
|
23611
23611
|
parser.push("JSON.ARRINSERT");
|
|
23612
23612
|
parser.pushKey(key);
|
|
23613
|
-
parser.push(
|
|
23613
|
+
parser.push(path21, index.toString(), (0, generic_transformers_1.transformRedisJsonArgument)(json));
|
|
23614
23614
|
for (let i = 0; i < jsons.length; i++) {
|
|
23615
23615
|
parser.push((0, generic_transformers_1.transformRedisJsonArgument)(jsons[i]));
|
|
23616
23616
|
}
|
|
@@ -23700,10 +23700,10 @@ var require_ARRTRIM = __commonJS({
|
|
|
23700
23700
|
* @param start - Starting index (inclusive)
|
|
23701
23701
|
* @param stop - Ending index (inclusive)
|
|
23702
23702
|
*/
|
|
23703
|
-
parseCommand(parser, key,
|
|
23703
|
+
parseCommand(parser, key, path21, start, stop) {
|
|
23704
23704
|
parser.push("JSON.ARRTRIM");
|
|
23705
23705
|
parser.pushKey(key);
|
|
23706
|
-
parser.push(
|
|
23706
|
+
parser.push(path21, start.toString(), stop.toString());
|
|
23707
23707
|
},
|
|
23708
23708
|
transformReply: void 0
|
|
23709
23709
|
};
|
|
@@ -23868,10 +23868,10 @@ var require_MERGE3 = __commonJS({
|
|
|
23868
23868
|
* @param path - Path to merge into
|
|
23869
23869
|
* @param value - JSON value to merge
|
|
23870
23870
|
*/
|
|
23871
|
-
parseCommand(parser, key,
|
|
23871
|
+
parseCommand(parser, key, path21, value) {
|
|
23872
23872
|
parser.push("JSON.MERGE");
|
|
23873
23873
|
parser.pushKey(key);
|
|
23874
|
-
parser.push(
|
|
23874
|
+
parser.push(path21, (0, generic_transformers_1.transformRedisJsonArgument)(value));
|
|
23875
23875
|
},
|
|
23876
23876
|
transformReply: void 0
|
|
23877
23877
|
};
|
|
@@ -23894,10 +23894,10 @@ var require_MGET2 = __commonJS({
|
|
|
23894
23894
|
* @param keys - Array of keys containing JSON documents
|
|
23895
23895
|
* @param path - Path to retrieve from each document
|
|
23896
23896
|
*/
|
|
23897
|
-
parseCommand(parser, keys,
|
|
23897
|
+
parseCommand(parser, keys, path21) {
|
|
23898
23898
|
parser.push("JSON.MGET");
|
|
23899
23899
|
parser.pushKeys(keys);
|
|
23900
|
-
parser.push(
|
|
23900
|
+
parser.push(path21);
|
|
23901
23901
|
},
|
|
23902
23902
|
transformReply(reply) {
|
|
23903
23903
|
return reply.map((json) => (0, generic_transformers_1.transformRedisJsonNullReply)(json));
|
|
@@ -23952,10 +23952,10 @@ var require_NUMINCRBY = __commonJS({
|
|
|
23952
23952
|
* @param path - Path to the numeric value
|
|
23953
23953
|
* @param by - Amount to increment by
|
|
23954
23954
|
*/
|
|
23955
|
-
parseCommand(parser, key,
|
|
23955
|
+
parseCommand(parser, key, path21, by) {
|
|
23956
23956
|
parser.push("JSON.NUMINCRBY");
|
|
23957
23957
|
parser.pushKey(key);
|
|
23958
|
-
parser.push(
|
|
23958
|
+
parser.push(path21, by.toString());
|
|
23959
23959
|
},
|
|
23960
23960
|
transformReply: {
|
|
23961
23961
|
2: (reply) => {
|
|
@@ -23987,10 +23987,10 @@ var require_NUMMULTBY = __commonJS({
|
|
|
23987
23987
|
* @param path - Path to the numeric value
|
|
23988
23988
|
* @param by - Amount to multiply by
|
|
23989
23989
|
*/
|
|
23990
|
-
parseCommand(parser, key,
|
|
23990
|
+
parseCommand(parser, key, path21, by) {
|
|
23991
23991
|
parser.push("JSON.NUMMULTBY");
|
|
23992
23992
|
parser.pushKey(key);
|
|
23993
|
-
parser.push(
|
|
23993
|
+
parser.push(path21, by.toString());
|
|
23994
23994
|
},
|
|
23995
23995
|
transformReply: NUMINCRBY_1.default.transformReply
|
|
23996
23996
|
};
|
|
@@ -24074,10 +24074,10 @@ var require_SET2 = __commonJS({
|
|
|
24074
24074
|
* @deprecated options.NX - Use options.condition instead
|
|
24075
24075
|
* @deprecated options.XX - Use options.condition instead
|
|
24076
24076
|
*/
|
|
24077
|
-
parseCommand(parser, key,
|
|
24077
|
+
parseCommand(parser, key, path21, json, options) {
|
|
24078
24078
|
parser.push("JSON.SET");
|
|
24079
24079
|
parser.pushKey(key);
|
|
24080
|
-
parser.push(
|
|
24080
|
+
parser.push(path21, (0, generic_transformers_1.transformRedisJsonArgument)(json));
|
|
24081
24081
|
if (options?.condition) {
|
|
24082
24082
|
parser.push(options?.condition);
|
|
24083
24083
|
} else if (options?.NX) {
|
|
@@ -24165,10 +24165,10 @@ var require_TOGGLE = __commonJS({
|
|
|
24165
24165
|
* @param key - The key containing the JSON document
|
|
24166
24166
|
* @param path - Path to the boolean value
|
|
24167
24167
|
*/
|
|
24168
|
-
parseCommand(parser, key,
|
|
24168
|
+
parseCommand(parser, key, path21) {
|
|
24169
24169
|
parser.push("JSON.TOGGLE");
|
|
24170
24170
|
parser.pushKey(key);
|
|
24171
|
-
parser.push(
|
|
24171
|
+
parser.push(path21);
|
|
24172
24172
|
},
|
|
24173
24173
|
transformReply: void 0
|
|
24174
24174
|
};
|
|
@@ -30242,7 +30242,7 @@ function printHelp() {
|
|
|
30242
30242
|
`);
|
|
30243
30243
|
}
|
|
30244
30244
|
function printVersion() {
|
|
30245
|
-
console.log(`duclaw-cli v${true ? "1.9.
|
|
30245
|
+
console.log(`duclaw-cli v${true ? "1.9.10" : "unknown"}`);
|
|
30246
30246
|
}
|
|
30247
30247
|
function getDuclawTemplate() {
|
|
30248
30248
|
return {
|
|
@@ -31633,7 +31633,7 @@ var ReaddirpStream = class extends import_node_stream.Readable {
|
|
|
31633
31633
|
this._directoryFilter = normalizeFilter(opts.directoryFilter);
|
|
31634
31634
|
const statMethod = opts.lstat ? import_promises3.lstat : import_promises3.stat;
|
|
31635
31635
|
if (wantBigintFsStats) {
|
|
31636
|
-
this._stat = (
|
|
31636
|
+
this._stat = (path21) => statMethod(path21, { bigint: true });
|
|
31637
31637
|
} else {
|
|
31638
31638
|
this._stat = statMethod;
|
|
31639
31639
|
}
|
|
@@ -31658,8 +31658,8 @@ var ReaddirpStream = class extends import_node_stream.Readable {
|
|
|
31658
31658
|
const par = this.parent;
|
|
31659
31659
|
const fil = par && par.files;
|
|
31660
31660
|
if (fil && fil.length > 0) {
|
|
31661
|
-
const { path:
|
|
31662
|
-
const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent,
|
|
31661
|
+
const { path: path21, depth } = par;
|
|
31662
|
+
const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path21));
|
|
31663
31663
|
const awaited = await Promise.all(slice);
|
|
31664
31664
|
for (const entry of awaited) {
|
|
31665
31665
|
if (!entry)
|
|
@@ -31699,20 +31699,20 @@ var ReaddirpStream = class extends import_node_stream.Readable {
|
|
|
31699
31699
|
this.reading = false;
|
|
31700
31700
|
}
|
|
31701
31701
|
}
|
|
31702
|
-
async _exploreDir(
|
|
31702
|
+
async _exploreDir(path21, depth) {
|
|
31703
31703
|
let files;
|
|
31704
31704
|
try {
|
|
31705
|
-
files = await (0, import_promises3.readdir)(
|
|
31705
|
+
files = await (0, import_promises3.readdir)(path21, this._rdOptions);
|
|
31706
31706
|
} catch (error) {
|
|
31707
31707
|
this._onError(error);
|
|
31708
31708
|
}
|
|
31709
|
-
return { files, depth, path:
|
|
31709
|
+
return { files, depth, path: path21 };
|
|
31710
31710
|
}
|
|
31711
|
-
async _formatEntry(dirent,
|
|
31711
|
+
async _formatEntry(dirent, path21) {
|
|
31712
31712
|
let entry;
|
|
31713
31713
|
const basename4 = this._isDirent ? dirent.name : dirent;
|
|
31714
31714
|
try {
|
|
31715
|
-
const fullPath = (0, import_node_path4.resolve)((0, import_node_path4.join)(
|
|
31715
|
+
const fullPath = (0, import_node_path4.resolve)((0, import_node_path4.join)(path21, basename4));
|
|
31716
31716
|
entry = { path: (0, import_node_path4.relative)(this._root, fullPath), fullPath, basename: basename4 };
|
|
31717
31717
|
entry[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
|
|
31718
31718
|
} catch (err) {
|
|
@@ -32112,16 +32112,16 @@ var delFromSet = (main2, prop, item) => {
|
|
|
32112
32112
|
};
|
|
32113
32113
|
var isEmptySet = (val) => val instanceof Set ? val.size === 0 : !val;
|
|
32114
32114
|
var FsWatchInstances = /* @__PURE__ */ new Map();
|
|
32115
|
-
function createFsWatchInstance(
|
|
32115
|
+
function createFsWatchInstance(path21, options, listener, errHandler, emitRaw) {
|
|
32116
32116
|
const handleEvent = (rawEvent, evPath) => {
|
|
32117
|
-
listener(
|
|
32118
|
-
emitRaw(rawEvent, evPath, { watchedPath:
|
|
32119
|
-
if (evPath &&
|
|
32120
|
-
fsWatchBroadcast(sp.resolve(
|
|
32117
|
+
listener(path21);
|
|
32118
|
+
emitRaw(rawEvent, evPath, { watchedPath: path21 });
|
|
32119
|
+
if (evPath && path21 !== evPath) {
|
|
32120
|
+
fsWatchBroadcast(sp.resolve(path21, evPath), KEY_LISTENERS, sp.join(path21, evPath));
|
|
32121
32121
|
}
|
|
32122
32122
|
};
|
|
32123
32123
|
try {
|
|
32124
|
-
return (0, import_node_fs.watch)(
|
|
32124
|
+
return (0, import_node_fs.watch)(path21, {
|
|
32125
32125
|
persistent: options.persistent
|
|
32126
32126
|
}, handleEvent);
|
|
32127
32127
|
} catch (error) {
|
|
@@ -32137,12 +32137,12 @@ var fsWatchBroadcast = (fullPath, listenerType, val1, val2, val3) => {
|
|
|
32137
32137
|
listener(val1, val2, val3);
|
|
32138
32138
|
});
|
|
32139
32139
|
};
|
|
32140
|
-
var setFsWatchListener = (
|
|
32140
|
+
var setFsWatchListener = (path21, fullPath, options, handlers) => {
|
|
32141
32141
|
const { listener, errHandler, rawEmitter } = handlers;
|
|
32142
32142
|
let cont = FsWatchInstances.get(fullPath);
|
|
32143
32143
|
let watcher;
|
|
32144
32144
|
if (!options.persistent) {
|
|
32145
|
-
watcher = createFsWatchInstance(
|
|
32145
|
+
watcher = createFsWatchInstance(path21, options, listener, errHandler, rawEmitter);
|
|
32146
32146
|
if (!watcher)
|
|
32147
32147
|
return;
|
|
32148
32148
|
return watcher.close.bind(watcher);
|
|
@@ -32153,7 +32153,7 @@ var setFsWatchListener = (path20, fullPath, options, handlers) => {
|
|
|
32153
32153
|
addAndConvert(cont, KEY_RAW, rawEmitter);
|
|
32154
32154
|
} else {
|
|
32155
32155
|
watcher = createFsWatchInstance(
|
|
32156
|
-
|
|
32156
|
+
path21,
|
|
32157
32157
|
options,
|
|
32158
32158
|
fsWatchBroadcast.bind(null, fullPath, KEY_LISTENERS),
|
|
32159
32159
|
errHandler,
|
|
@@ -32168,7 +32168,7 @@ var setFsWatchListener = (path20, fullPath, options, handlers) => {
|
|
|
32168
32168
|
cont.watcherUnusable = true;
|
|
32169
32169
|
if (isWindows && error.code === "EPERM") {
|
|
32170
32170
|
try {
|
|
32171
|
-
const fd = await (0, import_promises4.open)(
|
|
32171
|
+
const fd = await (0, import_promises4.open)(path21, "r");
|
|
32172
32172
|
await fd.close();
|
|
32173
32173
|
broadcastErr(error);
|
|
32174
32174
|
} catch (err) {
|
|
@@ -32199,7 +32199,7 @@ var setFsWatchListener = (path20, fullPath, options, handlers) => {
|
|
|
32199
32199
|
};
|
|
32200
32200
|
};
|
|
32201
32201
|
var FsWatchFileInstances = /* @__PURE__ */ new Map();
|
|
32202
|
-
var setFsWatchFileListener = (
|
|
32202
|
+
var setFsWatchFileListener = (path21, fullPath, options, handlers) => {
|
|
32203
32203
|
const { listener, rawEmitter } = handlers;
|
|
32204
32204
|
let cont = FsWatchFileInstances.get(fullPath);
|
|
32205
32205
|
const copts = cont && cont.options;
|
|
@@ -32221,7 +32221,7 @@ var setFsWatchFileListener = (path20, fullPath, options, handlers) => {
|
|
|
32221
32221
|
});
|
|
32222
32222
|
const currmtime = curr.mtimeMs;
|
|
32223
32223
|
if (curr.size !== prev.size || currmtime > prev.mtimeMs || currmtime === 0) {
|
|
32224
|
-
foreach(cont.listeners, (listener2) => listener2(
|
|
32224
|
+
foreach(cont.listeners, (listener2) => listener2(path21, curr));
|
|
32225
32225
|
}
|
|
32226
32226
|
})
|
|
32227
32227
|
};
|
|
@@ -32251,13 +32251,13 @@ var NodeFsHandler = class {
|
|
|
32251
32251
|
* @param listener on fs change
|
|
32252
32252
|
* @returns closer for the watcher instance
|
|
32253
32253
|
*/
|
|
32254
|
-
_watchWithNodeFs(
|
|
32254
|
+
_watchWithNodeFs(path21, listener) {
|
|
32255
32255
|
const opts = this.fsw.options;
|
|
32256
|
-
const directory = sp.dirname(
|
|
32257
|
-
const basename4 = sp.basename(
|
|
32256
|
+
const directory = sp.dirname(path21);
|
|
32257
|
+
const basename4 = sp.basename(path21);
|
|
32258
32258
|
const parent = this.fsw._getWatchedDir(directory);
|
|
32259
32259
|
parent.add(basename4);
|
|
32260
|
-
const absolutePath = sp.resolve(
|
|
32260
|
+
const absolutePath = sp.resolve(path21);
|
|
32261
32261
|
const options = {
|
|
32262
32262
|
persistent: opts.persistent
|
|
32263
32263
|
};
|
|
@@ -32267,12 +32267,12 @@ var NodeFsHandler = class {
|
|
|
32267
32267
|
if (opts.usePolling) {
|
|
32268
32268
|
const enableBin = opts.interval !== opts.binaryInterval;
|
|
32269
32269
|
options.interval = enableBin && isBinaryPath(basename4) ? opts.binaryInterval : opts.interval;
|
|
32270
|
-
closer = setFsWatchFileListener(
|
|
32270
|
+
closer = setFsWatchFileListener(path21, absolutePath, options, {
|
|
32271
32271
|
listener,
|
|
32272
32272
|
rawEmitter: this.fsw._emitRaw
|
|
32273
32273
|
});
|
|
32274
32274
|
} else {
|
|
32275
|
-
closer = setFsWatchListener(
|
|
32275
|
+
closer = setFsWatchListener(path21, absolutePath, options, {
|
|
32276
32276
|
listener,
|
|
32277
32277
|
errHandler: this._boundHandleError,
|
|
32278
32278
|
rawEmitter: this.fsw._emitRaw
|
|
@@ -32294,7 +32294,7 @@ var NodeFsHandler = class {
|
|
|
32294
32294
|
let prevStats = stats;
|
|
32295
32295
|
if (parent.has(basename4))
|
|
32296
32296
|
return;
|
|
32297
|
-
const listener = async (
|
|
32297
|
+
const listener = async (path21, newStats) => {
|
|
32298
32298
|
if (!this.fsw._throttle(THROTTLE_MODE_WATCH, file, 5))
|
|
32299
32299
|
return;
|
|
32300
32300
|
if (!newStats || newStats.mtimeMs === 0) {
|
|
@@ -32308,11 +32308,11 @@ var NodeFsHandler = class {
|
|
|
32308
32308
|
this.fsw._emit(EV.CHANGE, file, newStats2);
|
|
32309
32309
|
}
|
|
32310
32310
|
if ((isMacos || isLinux || isFreeBSD) && prevStats.ino !== newStats2.ino) {
|
|
32311
|
-
this.fsw._closeFile(
|
|
32311
|
+
this.fsw._closeFile(path21);
|
|
32312
32312
|
prevStats = newStats2;
|
|
32313
32313
|
const closer2 = this._watchWithNodeFs(file, listener);
|
|
32314
32314
|
if (closer2)
|
|
32315
|
-
this.fsw._addPathCloser(
|
|
32315
|
+
this.fsw._addPathCloser(path21, closer2);
|
|
32316
32316
|
} else {
|
|
32317
32317
|
prevStats = newStats2;
|
|
32318
32318
|
}
|
|
@@ -32344,7 +32344,7 @@ var NodeFsHandler = class {
|
|
|
32344
32344
|
* @param item basename of this item
|
|
32345
32345
|
* @returns true if no more processing is needed for this entry.
|
|
32346
32346
|
*/
|
|
32347
|
-
async _handleSymlink(entry, directory,
|
|
32347
|
+
async _handleSymlink(entry, directory, path21, item) {
|
|
32348
32348
|
if (this.fsw.closed) {
|
|
32349
32349
|
return;
|
|
32350
32350
|
}
|
|
@@ -32354,7 +32354,7 @@ var NodeFsHandler = class {
|
|
|
32354
32354
|
this.fsw._incrReadyCount();
|
|
32355
32355
|
let linkPath;
|
|
32356
32356
|
try {
|
|
32357
|
-
linkPath = await (0, import_promises4.realpath)(
|
|
32357
|
+
linkPath = await (0, import_promises4.realpath)(path21);
|
|
32358
32358
|
} catch (e) {
|
|
32359
32359
|
this.fsw._emitReady();
|
|
32360
32360
|
return true;
|
|
@@ -32364,12 +32364,12 @@ var NodeFsHandler = class {
|
|
|
32364
32364
|
if (dir.has(item)) {
|
|
32365
32365
|
if (this.fsw._symlinkPaths.get(full) !== linkPath) {
|
|
32366
32366
|
this.fsw._symlinkPaths.set(full, linkPath);
|
|
32367
|
-
this.fsw._emit(EV.CHANGE,
|
|
32367
|
+
this.fsw._emit(EV.CHANGE, path21, entry.stats);
|
|
32368
32368
|
}
|
|
32369
32369
|
} else {
|
|
32370
32370
|
dir.add(item);
|
|
32371
32371
|
this.fsw._symlinkPaths.set(full, linkPath);
|
|
32372
|
-
this.fsw._emit(EV.ADD,
|
|
32372
|
+
this.fsw._emit(EV.ADD, path21, entry.stats);
|
|
32373
32373
|
}
|
|
32374
32374
|
this.fsw._emitReady();
|
|
32375
32375
|
return true;
|
|
@@ -32399,9 +32399,9 @@ var NodeFsHandler = class {
|
|
|
32399
32399
|
return;
|
|
32400
32400
|
}
|
|
32401
32401
|
const item = entry.path;
|
|
32402
|
-
let
|
|
32402
|
+
let path21 = sp.join(directory, item);
|
|
32403
32403
|
current.add(item);
|
|
32404
|
-
if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory,
|
|
32404
|
+
if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path21, item)) {
|
|
32405
32405
|
return;
|
|
32406
32406
|
}
|
|
32407
32407
|
if (this.fsw.closed) {
|
|
@@ -32410,8 +32410,8 @@ var NodeFsHandler = class {
|
|
|
32410
32410
|
}
|
|
32411
32411
|
if (item === target || !target && !previous.has(item)) {
|
|
32412
32412
|
this.fsw._incrReadyCount();
|
|
32413
|
-
|
|
32414
|
-
this._addToNodeFs(
|
|
32413
|
+
path21 = sp.join(dir, sp.relative(dir, path21));
|
|
32414
|
+
this._addToNodeFs(path21, initialAdd, wh, depth + 1);
|
|
32415
32415
|
}
|
|
32416
32416
|
}).on(EV.ERROR, this._boundHandleError);
|
|
32417
32417
|
return new Promise((resolve11, reject) => {
|
|
@@ -32480,13 +32480,13 @@ var NodeFsHandler = class {
|
|
|
32480
32480
|
* @param depth Child path actually targeted for watch
|
|
32481
32481
|
* @param target Child path actually targeted for watch
|
|
32482
32482
|
*/
|
|
32483
|
-
async _addToNodeFs(
|
|
32483
|
+
async _addToNodeFs(path21, initialAdd, priorWh, depth, target) {
|
|
32484
32484
|
const ready = this.fsw._emitReady;
|
|
32485
|
-
if (this.fsw._isIgnored(
|
|
32485
|
+
if (this.fsw._isIgnored(path21) || this.fsw.closed) {
|
|
32486
32486
|
ready();
|
|
32487
32487
|
return false;
|
|
32488
32488
|
}
|
|
32489
|
-
const wh = this.fsw._getWatchHelpers(
|
|
32489
|
+
const wh = this.fsw._getWatchHelpers(path21);
|
|
32490
32490
|
if (priorWh) {
|
|
32491
32491
|
wh.filterPath = (entry) => priorWh.filterPath(entry);
|
|
32492
32492
|
wh.filterDir = (entry) => priorWh.filterDir(entry);
|
|
@@ -32502,8 +32502,8 @@ var NodeFsHandler = class {
|
|
|
32502
32502
|
const follow = this.fsw.options.followSymlinks;
|
|
32503
32503
|
let closer;
|
|
32504
32504
|
if (stats.isDirectory()) {
|
|
32505
|
-
const absPath = sp.resolve(
|
|
32506
|
-
const targetPath = follow ? await (0, import_promises4.realpath)(
|
|
32505
|
+
const absPath = sp.resolve(path21);
|
|
32506
|
+
const targetPath = follow ? await (0, import_promises4.realpath)(path21) : path21;
|
|
32507
32507
|
if (this.fsw.closed)
|
|
32508
32508
|
return;
|
|
32509
32509
|
closer = await this._handleDir(wh.watchPath, stats, initialAdd, depth, target, wh, targetPath);
|
|
@@ -32513,29 +32513,29 @@ var NodeFsHandler = class {
|
|
|
32513
32513
|
this.fsw._symlinkPaths.set(absPath, targetPath);
|
|
32514
32514
|
}
|
|
32515
32515
|
} else if (stats.isSymbolicLink()) {
|
|
32516
|
-
const targetPath = follow ? await (0, import_promises4.realpath)(
|
|
32516
|
+
const targetPath = follow ? await (0, import_promises4.realpath)(path21) : path21;
|
|
32517
32517
|
if (this.fsw.closed)
|
|
32518
32518
|
return;
|
|
32519
32519
|
const parent = sp.dirname(wh.watchPath);
|
|
32520
32520
|
this.fsw._getWatchedDir(parent).add(wh.watchPath);
|
|
32521
32521
|
this.fsw._emit(EV.ADD, wh.watchPath, stats);
|
|
32522
|
-
closer = await this._handleDir(parent, stats, initialAdd, depth,
|
|
32522
|
+
closer = await this._handleDir(parent, stats, initialAdd, depth, path21, wh, targetPath);
|
|
32523
32523
|
if (this.fsw.closed)
|
|
32524
32524
|
return;
|
|
32525
32525
|
if (targetPath !== void 0) {
|
|
32526
|
-
this.fsw._symlinkPaths.set(sp.resolve(
|
|
32526
|
+
this.fsw._symlinkPaths.set(sp.resolve(path21), targetPath);
|
|
32527
32527
|
}
|
|
32528
32528
|
} else {
|
|
32529
32529
|
closer = this._handleFile(wh.watchPath, stats, initialAdd);
|
|
32530
32530
|
}
|
|
32531
32531
|
ready();
|
|
32532
32532
|
if (closer)
|
|
32533
|
-
this.fsw._addPathCloser(
|
|
32533
|
+
this.fsw._addPathCloser(path21, closer);
|
|
32534
32534
|
return false;
|
|
32535
32535
|
} catch (error) {
|
|
32536
32536
|
if (this.fsw._handleError(error)) {
|
|
32537
32537
|
ready();
|
|
32538
|
-
return
|
|
32538
|
+
return path21;
|
|
32539
32539
|
}
|
|
32540
32540
|
}
|
|
32541
32541
|
}
|
|
@@ -32578,24 +32578,24 @@ function createPattern(matcher) {
|
|
|
32578
32578
|
}
|
|
32579
32579
|
return () => false;
|
|
32580
32580
|
}
|
|
32581
|
-
function normalizePath(
|
|
32582
|
-
if (typeof
|
|
32581
|
+
function normalizePath(path21) {
|
|
32582
|
+
if (typeof path21 !== "string")
|
|
32583
32583
|
throw new Error("string expected");
|
|
32584
|
-
|
|
32585
|
-
|
|
32584
|
+
path21 = sp2.normalize(path21);
|
|
32585
|
+
path21 = path21.replace(/\\/g, "/");
|
|
32586
32586
|
let prepend = false;
|
|
32587
|
-
if (
|
|
32587
|
+
if (path21.startsWith("//"))
|
|
32588
32588
|
prepend = true;
|
|
32589
|
-
|
|
32589
|
+
path21 = path21.replace(DOUBLE_SLASH_RE, "/");
|
|
32590
32590
|
if (prepend)
|
|
32591
|
-
|
|
32592
|
-
return
|
|
32591
|
+
path21 = "/" + path21;
|
|
32592
|
+
return path21;
|
|
32593
32593
|
}
|
|
32594
32594
|
function matchPatterns(patterns, testString, stats) {
|
|
32595
|
-
const
|
|
32595
|
+
const path21 = normalizePath(testString);
|
|
32596
32596
|
for (let index = 0; index < patterns.length; index++) {
|
|
32597
32597
|
const pattern = patterns[index];
|
|
32598
|
-
if (pattern(
|
|
32598
|
+
if (pattern(path21, stats)) {
|
|
32599
32599
|
return true;
|
|
32600
32600
|
}
|
|
32601
32601
|
}
|
|
@@ -32633,19 +32633,19 @@ var toUnix = (string) => {
|
|
|
32633
32633
|
}
|
|
32634
32634
|
return str;
|
|
32635
32635
|
};
|
|
32636
|
-
var normalizePathToUnix = (
|
|
32637
|
-
var normalizeIgnored = (cwd = "") => (
|
|
32638
|
-
if (typeof
|
|
32639
|
-
return normalizePathToUnix(sp2.isAbsolute(
|
|
32636
|
+
var normalizePathToUnix = (path21) => toUnix(sp2.normalize(toUnix(path21)));
|
|
32637
|
+
var normalizeIgnored = (cwd = "") => (path21) => {
|
|
32638
|
+
if (typeof path21 === "string") {
|
|
32639
|
+
return normalizePathToUnix(sp2.isAbsolute(path21) ? path21 : sp2.join(cwd, path21));
|
|
32640
32640
|
} else {
|
|
32641
|
-
return
|
|
32641
|
+
return path21;
|
|
32642
32642
|
}
|
|
32643
32643
|
};
|
|
32644
|
-
var getAbsolutePath = (
|
|
32645
|
-
if (sp2.isAbsolute(
|
|
32646
|
-
return
|
|
32644
|
+
var getAbsolutePath = (path21, cwd) => {
|
|
32645
|
+
if (sp2.isAbsolute(path21)) {
|
|
32646
|
+
return path21;
|
|
32647
32647
|
}
|
|
32648
|
-
return sp2.join(cwd,
|
|
32648
|
+
return sp2.join(cwd, path21);
|
|
32649
32649
|
};
|
|
32650
32650
|
var EMPTY_SET = Object.freeze(/* @__PURE__ */ new Set());
|
|
32651
32651
|
var DirEntry = class {
|
|
@@ -32710,10 +32710,10 @@ var WatchHelper = class {
|
|
|
32710
32710
|
dirParts;
|
|
32711
32711
|
followSymlinks;
|
|
32712
32712
|
statMethod;
|
|
32713
|
-
constructor(
|
|
32713
|
+
constructor(path21, follow, fsw) {
|
|
32714
32714
|
this.fsw = fsw;
|
|
32715
|
-
const watchPath =
|
|
32716
|
-
this.path =
|
|
32715
|
+
const watchPath = path21;
|
|
32716
|
+
this.path = path21 = path21.replace(REPLACER_RE, "");
|
|
32717
32717
|
this.watchPath = watchPath;
|
|
32718
32718
|
this.fullWatchPath = sp2.resolve(watchPath);
|
|
32719
32719
|
this.dirParts = [];
|
|
@@ -32853,20 +32853,20 @@ var FSWatcher = class extends import_node_events.EventEmitter {
|
|
|
32853
32853
|
this._closePromise = void 0;
|
|
32854
32854
|
let paths = unifyPaths(paths_);
|
|
32855
32855
|
if (cwd) {
|
|
32856
|
-
paths = paths.map((
|
|
32857
|
-
const absPath = getAbsolutePath(
|
|
32856
|
+
paths = paths.map((path21) => {
|
|
32857
|
+
const absPath = getAbsolutePath(path21, cwd);
|
|
32858
32858
|
return absPath;
|
|
32859
32859
|
});
|
|
32860
32860
|
}
|
|
32861
|
-
paths.forEach((
|
|
32862
|
-
this._removeIgnoredPath(
|
|
32861
|
+
paths.forEach((path21) => {
|
|
32862
|
+
this._removeIgnoredPath(path21);
|
|
32863
32863
|
});
|
|
32864
32864
|
this._userIgnored = void 0;
|
|
32865
32865
|
if (!this._readyCount)
|
|
32866
32866
|
this._readyCount = 0;
|
|
32867
32867
|
this._readyCount += paths.length;
|
|
32868
|
-
Promise.all(paths.map(async (
|
|
32869
|
-
const res = await this._nodeFsHandler._addToNodeFs(
|
|
32868
|
+
Promise.all(paths.map(async (path21) => {
|
|
32869
|
+
const res = await this._nodeFsHandler._addToNodeFs(path21, !_internal, void 0, 0, _origAdd);
|
|
32870
32870
|
if (res)
|
|
32871
32871
|
this._emitReady();
|
|
32872
32872
|
return res;
|
|
@@ -32888,17 +32888,17 @@ var FSWatcher = class extends import_node_events.EventEmitter {
|
|
|
32888
32888
|
return this;
|
|
32889
32889
|
const paths = unifyPaths(paths_);
|
|
32890
32890
|
const { cwd } = this.options;
|
|
32891
|
-
paths.forEach((
|
|
32892
|
-
if (!sp2.isAbsolute(
|
|
32891
|
+
paths.forEach((path21) => {
|
|
32892
|
+
if (!sp2.isAbsolute(path21) && !this._closers.has(path21)) {
|
|
32893
32893
|
if (cwd)
|
|
32894
|
-
|
|
32895
|
-
|
|
32894
|
+
path21 = sp2.join(cwd, path21);
|
|
32895
|
+
path21 = sp2.resolve(path21);
|
|
32896
32896
|
}
|
|
32897
|
-
this._closePath(
|
|
32898
|
-
this._addIgnoredPath(
|
|
32899
|
-
if (this._watched.has(
|
|
32897
|
+
this._closePath(path21);
|
|
32898
|
+
this._addIgnoredPath(path21);
|
|
32899
|
+
if (this._watched.has(path21)) {
|
|
32900
32900
|
this._addIgnoredPath({
|
|
32901
|
-
path:
|
|
32901
|
+
path: path21,
|
|
32902
32902
|
recursive: true
|
|
32903
32903
|
});
|
|
32904
32904
|
}
|
|
@@ -32962,38 +32962,38 @@ var FSWatcher = class extends import_node_events.EventEmitter {
|
|
|
32962
32962
|
* @param stats arguments to be passed with event
|
|
32963
32963
|
* @returns the error if defined, otherwise the value of the FSWatcher instance's `closed` flag
|
|
32964
32964
|
*/
|
|
32965
|
-
async _emit(event,
|
|
32965
|
+
async _emit(event, path21, stats) {
|
|
32966
32966
|
if (this.closed)
|
|
32967
32967
|
return;
|
|
32968
32968
|
const opts = this.options;
|
|
32969
32969
|
if (isWindows)
|
|
32970
|
-
|
|
32970
|
+
path21 = sp2.normalize(path21);
|
|
32971
32971
|
if (opts.cwd)
|
|
32972
|
-
|
|
32973
|
-
const args = [
|
|
32972
|
+
path21 = sp2.relative(opts.cwd, path21);
|
|
32973
|
+
const args = [path21];
|
|
32974
32974
|
if (stats != null)
|
|
32975
32975
|
args.push(stats);
|
|
32976
32976
|
const awf = opts.awaitWriteFinish;
|
|
32977
32977
|
let pw;
|
|
32978
|
-
if (awf && (pw = this._pendingWrites.get(
|
|
32978
|
+
if (awf && (pw = this._pendingWrites.get(path21))) {
|
|
32979
32979
|
pw.lastChange = /* @__PURE__ */ new Date();
|
|
32980
32980
|
return this;
|
|
32981
32981
|
}
|
|
32982
32982
|
if (opts.atomic) {
|
|
32983
32983
|
if (event === EVENTS.UNLINK) {
|
|
32984
|
-
this._pendingUnlinks.set(
|
|
32984
|
+
this._pendingUnlinks.set(path21, [event, ...args]);
|
|
32985
32985
|
setTimeout(() => {
|
|
32986
|
-
this._pendingUnlinks.forEach((entry,
|
|
32986
|
+
this._pendingUnlinks.forEach((entry, path22) => {
|
|
32987
32987
|
this.emit(...entry);
|
|
32988
32988
|
this.emit(EVENTS.ALL, ...entry);
|
|
32989
|
-
this._pendingUnlinks.delete(
|
|
32989
|
+
this._pendingUnlinks.delete(path22);
|
|
32990
32990
|
});
|
|
32991
32991
|
}, typeof opts.atomic === "number" ? opts.atomic : 100);
|
|
32992
32992
|
return this;
|
|
32993
32993
|
}
|
|
32994
|
-
if (event === EVENTS.ADD && this._pendingUnlinks.has(
|
|
32994
|
+
if (event === EVENTS.ADD && this._pendingUnlinks.has(path21)) {
|
|
32995
32995
|
event = EVENTS.CHANGE;
|
|
32996
|
-
this._pendingUnlinks.delete(
|
|
32996
|
+
this._pendingUnlinks.delete(path21);
|
|
32997
32997
|
}
|
|
32998
32998
|
}
|
|
32999
32999
|
if (awf && (event === EVENTS.ADD || event === EVENTS.CHANGE) && this._readyEmitted) {
|
|
@@ -33011,16 +33011,16 @@ var FSWatcher = class extends import_node_events.EventEmitter {
|
|
|
33011
33011
|
this.emitWithAll(event, args);
|
|
33012
33012
|
}
|
|
33013
33013
|
};
|
|
33014
|
-
this._awaitWriteFinish(
|
|
33014
|
+
this._awaitWriteFinish(path21, awf.stabilityThreshold, event, awfEmit);
|
|
33015
33015
|
return this;
|
|
33016
33016
|
}
|
|
33017
33017
|
if (event === EVENTS.CHANGE) {
|
|
33018
|
-
const isThrottled = !this._throttle(EVENTS.CHANGE,
|
|
33018
|
+
const isThrottled = !this._throttle(EVENTS.CHANGE, path21, 50);
|
|
33019
33019
|
if (isThrottled)
|
|
33020
33020
|
return this;
|
|
33021
33021
|
}
|
|
33022
33022
|
if (opts.alwaysStat && stats === void 0 && (event === EVENTS.ADD || event === EVENTS.ADD_DIR || event === EVENTS.CHANGE)) {
|
|
33023
|
-
const fullPath = opts.cwd ? sp2.join(opts.cwd,
|
|
33023
|
+
const fullPath = opts.cwd ? sp2.join(opts.cwd, path21) : path21;
|
|
33024
33024
|
let stats2;
|
|
33025
33025
|
try {
|
|
33026
33026
|
stats2 = await (0, import_promises5.stat)(fullPath);
|
|
@@ -33051,23 +33051,23 @@ var FSWatcher = class extends import_node_events.EventEmitter {
|
|
|
33051
33051
|
* @param timeout duration of time to suppress duplicate actions
|
|
33052
33052
|
* @returns tracking object or false if action should be suppressed
|
|
33053
33053
|
*/
|
|
33054
|
-
_throttle(actionType,
|
|
33054
|
+
_throttle(actionType, path21, timeout) {
|
|
33055
33055
|
if (!this._throttled.has(actionType)) {
|
|
33056
33056
|
this._throttled.set(actionType, /* @__PURE__ */ new Map());
|
|
33057
33057
|
}
|
|
33058
33058
|
const action = this._throttled.get(actionType);
|
|
33059
33059
|
if (!action)
|
|
33060
33060
|
throw new Error("invalid throttle");
|
|
33061
|
-
const actionPath = action.get(
|
|
33061
|
+
const actionPath = action.get(path21);
|
|
33062
33062
|
if (actionPath) {
|
|
33063
33063
|
actionPath.count++;
|
|
33064
33064
|
return false;
|
|
33065
33065
|
}
|
|
33066
33066
|
let timeoutObject;
|
|
33067
33067
|
const clear = () => {
|
|
33068
|
-
const item = action.get(
|
|
33068
|
+
const item = action.get(path21);
|
|
33069
33069
|
const count = item ? item.count : 0;
|
|
33070
|
-
action.delete(
|
|
33070
|
+
action.delete(path21);
|
|
33071
33071
|
clearTimeout(timeoutObject);
|
|
33072
33072
|
if (item)
|
|
33073
33073
|
clearTimeout(item.timeoutObject);
|
|
@@ -33075,7 +33075,7 @@ var FSWatcher = class extends import_node_events.EventEmitter {
|
|
|
33075
33075
|
};
|
|
33076
33076
|
timeoutObject = setTimeout(clear, timeout);
|
|
33077
33077
|
const thr = { timeoutObject, clear, count: 0 };
|
|
33078
|
-
action.set(
|
|
33078
|
+
action.set(path21, thr);
|
|
33079
33079
|
return thr;
|
|
33080
33080
|
}
|
|
33081
33081
|
_incrReadyCount() {
|
|
@@ -33089,44 +33089,44 @@ var FSWatcher = class extends import_node_events.EventEmitter {
|
|
|
33089
33089
|
* @param event
|
|
33090
33090
|
* @param awfEmit Callback to be called when ready for event to be emitted.
|
|
33091
33091
|
*/
|
|
33092
|
-
_awaitWriteFinish(
|
|
33092
|
+
_awaitWriteFinish(path21, threshold, event, awfEmit) {
|
|
33093
33093
|
const awf = this.options.awaitWriteFinish;
|
|
33094
33094
|
if (typeof awf !== "object")
|
|
33095
33095
|
return;
|
|
33096
33096
|
const pollInterval = awf.pollInterval;
|
|
33097
33097
|
let timeoutHandler;
|
|
33098
|
-
let fullPath =
|
|
33099
|
-
if (this.options.cwd && !sp2.isAbsolute(
|
|
33100
|
-
fullPath = sp2.join(this.options.cwd,
|
|
33098
|
+
let fullPath = path21;
|
|
33099
|
+
if (this.options.cwd && !sp2.isAbsolute(path21)) {
|
|
33100
|
+
fullPath = sp2.join(this.options.cwd, path21);
|
|
33101
33101
|
}
|
|
33102
33102
|
const now = /* @__PURE__ */ new Date();
|
|
33103
33103
|
const writes = this._pendingWrites;
|
|
33104
33104
|
function awaitWriteFinishFn(prevStat) {
|
|
33105
33105
|
(0, import_node_fs2.stat)(fullPath, (err, curStat) => {
|
|
33106
|
-
if (err || !writes.has(
|
|
33106
|
+
if (err || !writes.has(path21)) {
|
|
33107
33107
|
if (err && err.code !== "ENOENT")
|
|
33108
33108
|
awfEmit(err);
|
|
33109
33109
|
return;
|
|
33110
33110
|
}
|
|
33111
33111
|
const now2 = Number(/* @__PURE__ */ new Date());
|
|
33112
33112
|
if (prevStat && curStat.size !== prevStat.size) {
|
|
33113
|
-
writes.get(
|
|
33113
|
+
writes.get(path21).lastChange = now2;
|
|
33114
33114
|
}
|
|
33115
|
-
const pw = writes.get(
|
|
33115
|
+
const pw = writes.get(path21);
|
|
33116
33116
|
const df = now2 - pw.lastChange;
|
|
33117
33117
|
if (df >= threshold) {
|
|
33118
|
-
writes.delete(
|
|
33118
|
+
writes.delete(path21);
|
|
33119
33119
|
awfEmit(void 0, curStat);
|
|
33120
33120
|
} else {
|
|
33121
33121
|
timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval, curStat);
|
|
33122
33122
|
}
|
|
33123
33123
|
});
|
|
33124
33124
|
}
|
|
33125
|
-
if (!writes.has(
|
|
33126
|
-
writes.set(
|
|
33125
|
+
if (!writes.has(path21)) {
|
|
33126
|
+
writes.set(path21, {
|
|
33127
33127
|
lastChange: now,
|
|
33128
33128
|
cancelWait: () => {
|
|
33129
|
-
writes.delete(
|
|
33129
|
+
writes.delete(path21);
|
|
33130
33130
|
clearTimeout(timeoutHandler);
|
|
33131
33131
|
return event;
|
|
33132
33132
|
}
|
|
@@ -33137,8 +33137,8 @@ var FSWatcher = class extends import_node_events.EventEmitter {
|
|
|
33137
33137
|
/**
|
|
33138
33138
|
* Determines whether user has asked to ignore this path.
|
|
33139
33139
|
*/
|
|
33140
|
-
_isIgnored(
|
|
33141
|
-
if (this.options.atomic && DOT_RE.test(
|
|
33140
|
+
_isIgnored(path21, stats) {
|
|
33141
|
+
if (this.options.atomic && DOT_RE.test(path21))
|
|
33142
33142
|
return true;
|
|
33143
33143
|
if (!this._userIgnored) {
|
|
33144
33144
|
const { cwd } = this.options;
|
|
@@ -33148,17 +33148,17 @@ var FSWatcher = class extends import_node_events.EventEmitter {
|
|
|
33148
33148
|
const list = [...ignoredPaths.map(normalizeIgnored(cwd)), ...ignored];
|
|
33149
33149
|
this._userIgnored = anymatch(list, void 0);
|
|
33150
33150
|
}
|
|
33151
|
-
return this._userIgnored(
|
|
33151
|
+
return this._userIgnored(path21, stats);
|
|
33152
33152
|
}
|
|
33153
|
-
_isntIgnored(
|
|
33154
|
-
return !this._isIgnored(
|
|
33153
|
+
_isntIgnored(path21, stat11) {
|
|
33154
|
+
return !this._isIgnored(path21, stat11);
|
|
33155
33155
|
}
|
|
33156
33156
|
/**
|
|
33157
33157
|
* Provides a set of common helpers and properties relating to symlink handling.
|
|
33158
33158
|
* @param path file or directory pattern being watched
|
|
33159
33159
|
*/
|
|
33160
|
-
_getWatchHelpers(
|
|
33161
|
-
return new WatchHelper(
|
|
33160
|
+
_getWatchHelpers(path21) {
|
|
33161
|
+
return new WatchHelper(path21, this.options.followSymlinks, this);
|
|
33162
33162
|
}
|
|
33163
33163
|
// Directory helpers
|
|
33164
33164
|
// -----------------
|
|
@@ -33190,63 +33190,63 @@ var FSWatcher = class extends import_node_events.EventEmitter {
|
|
|
33190
33190
|
* @param item base path of item/directory
|
|
33191
33191
|
*/
|
|
33192
33192
|
_remove(directory, item, isDirectory) {
|
|
33193
|
-
const
|
|
33194
|
-
const fullPath = sp2.resolve(
|
|
33195
|
-
isDirectory = isDirectory != null ? isDirectory : this._watched.has(
|
|
33196
|
-
if (!this._throttle("remove",
|
|
33193
|
+
const path21 = sp2.join(directory, item);
|
|
33194
|
+
const fullPath = sp2.resolve(path21);
|
|
33195
|
+
isDirectory = isDirectory != null ? isDirectory : this._watched.has(path21) || this._watched.has(fullPath);
|
|
33196
|
+
if (!this._throttle("remove", path21, 100))
|
|
33197
33197
|
return;
|
|
33198
33198
|
if (!isDirectory && this._watched.size === 1) {
|
|
33199
33199
|
this.add(directory, item, true);
|
|
33200
33200
|
}
|
|
33201
|
-
const wp = this._getWatchedDir(
|
|
33201
|
+
const wp = this._getWatchedDir(path21);
|
|
33202
33202
|
const nestedDirectoryChildren = wp.getChildren();
|
|
33203
|
-
nestedDirectoryChildren.forEach((nested) => this._remove(
|
|
33203
|
+
nestedDirectoryChildren.forEach((nested) => this._remove(path21, nested));
|
|
33204
33204
|
const parent = this._getWatchedDir(directory);
|
|
33205
33205
|
const wasTracked = parent.has(item);
|
|
33206
33206
|
parent.remove(item);
|
|
33207
33207
|
if (this._symlinkPaths.has(fullPath)) {
|
|
33208
33208
|
this._symlinkPaths.delete(fullPath);
|
|
33209
33209
|
}
|
|
33210
|
-
let relPath =
|
|
33210
|
+
let relPath = path21;
|
|
33211
33211
|
if (this.options.cwd)
|
|
33212
|
-
relPath = sp2.relative(this.options.cwd,
|
|
33212
|
+
relPath = sp2.relative(this.options.cwd, path21);
|
|
33213
33213
|
if (this.options.awaitWriteFinish && this._pendingWrites.has(relPath)) {
|
|
33214
33214
|
const event = this._pendingWrites.get(relPath).cancelWait();
|
|
33215
33215
|
if (event === EVENTS.ADD)
|
|
33216
33216
|
return;
|
|
33217
33217
|
}
|
|
33218
|
-
this._watched.delete(
|
|
33218
|
+
this._watched.delete(path21);
|
|
33219
33219
|
this._watched.delete(fullPath);
|
|
33220
33220
|
const eventName = isDirectory ? EVENTS.UNLINK_DIR : EVENTS.UNLINK;
|
|
33221
|
-
if (wasTracked && !this._isIgnored(
|
|
33222
|
-
this._emit(eventName,
|
|
33223
|
-
this._closePath(
|
|
33221
|
+
if (wasTracked && !this._isIgnored(path21))
|
|
33222
|
+
this._emit(eventName, path21);
|
|
33223
|
+
this._closePath(path21);
|
|
33224
33224
|
}
|
|
33225
33225
|
/**
|
|
33226
33226
|
* Closes all watchers for a path
|
|
33227
33227
|
*/
|
|
33228
|
-
_closePath(
|
|
33229
|
-
this._closeFile(
|
|
33230
|
-
const dir = sp2.dirname(
|
|
33231
|
-
this._getWatchedDir(dir).remove(sp2.basename(
|
|
33228
|
+
_closePath(path21) {
|
|
33229
|
+
this._closeFile(path21);
|
|
33230
|
+
const dir = sp2.dirname(path21);
|
|
33231
|
+
this._getWatchedDir(dir).remove(sp2.basename(path21));
|
|
33232
33232
|
}
|
|
33233
33233
|
/**
|
|
33234
33234
|
* Closes only file-specific watchers
|
|
33235
33235
|
*/
|
|
33236
|
-
_closeFile(
|
|
33237
|
-
const closers = this._closers.get(
|
|
33236
|
+
_closeFile(path21) {
|
|
33237
|
+
const closers = this._closers.get(path21);
|
|
33238
33238
|
if (!closers)
|
|
33239
33239
|
return;
|
|
33240
33240
|
closers.forEach((closer) => closer());
|
|
33241
|
-
this._closers.delete(
|
|
33241
|
+
this._closers.delete(path21);
|
|
33242
33242
|
}
|
|
33243
|
-
_addPathCloser(
|
|
33243
|
+
_addPathCloser(path21, closer) {
|
|
33244
33244
|
if (!closer)
|
|
33245
33245
|
return;
|
|
33246
|
-
let list = this._closers.get(
|
|
33246
|
+
let list = this._closers.get(path21);
|
|
33247
33247
|
if (!list) {
|
|
33248
33248
|
list = [];
|
|
33249
|
-
this._closers.set(
|
|
33249
|
+
this._closers.set(path21, list);
|
|
33250
33250
|
}
|
|
33251
33251
|
list.push(closer);
|
|
33252
33252
|
}
|
|
@@ -34710,12 +34710,12 @@ function encodeURIPath(str) {
|
|
|
34710
34710
|
return str.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g, encodeURIComponent);
|
|
34711
34711
|
}
|
|
34712
34712
|
var EMPTY = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.create(null));
|
|
34713
|
-
var createPathTagFunction = (pathEncoder = encodeURIPath) => function
|
|
34713
|
+
var createPathTagFunction = (pathEncoder = encodeURIPath) => function path21(statics, ...params) {
|
|
34714
34714
|
if (statics.length === 1)
|
|
34715
34715
|
return statics[0];
|
|
34716
34716
|
let postPath = false;
|
|
34717
34717
|
const invalidSegments = [];
|
|
34718
|
-
const
|
|
34718
|
+
const path22 = statics.reduce((previousValue, currentValue, index) => {
|
|
34719
34719
|
if (/[?#]/.test(currentValue)) {
|
|
34720
34720
|
postPath = true;
|
|
34721
34721
|
}
|
|
@@ -34732,7 +34732,7 @@ var createPathTagFunction = (pathEncoder = encodeURIPath) => function path20(sta
|
|
|
34732
34732
|
}
|
|
34733
34733
|
return previousValue + currentValue + (index === params.length ? "" : encoded);
|
|
34734
34734
|
}, "");
|
|
34735
|
-
const pathOnly =
|
|
34735
|
+
const pathOnly = path22.split(/[?#]/, 1)[0];
|
|
34736
34736
|
const invalidSegmentPattern = /(?<=^|\/)(?:\.|%2e){1,2}(?=\/|$)/gi;
|
|
34737
34737
|
let match2;
|
|
34738
34738
|
while ((match2 = invalidSegmentPattern.exec(pathOnly)) !== null) {
|
|
@@ -34753,10 +34753,10 @@ var createPathTagFunction = (pathEncoder = encodeURIPath) => function path20(sta
|
|
|
34753
34753
|
}, "");
|
|
34754
34754
|
throw new AnthropicError(`Path parameters result in path with invalid segments:
|
|
34755
34755
|
${invalidSegments.map((e) => e.error).join("\n")}
|
|
34756
|
-
${
|
|
34756
|
+
${path22}
|
|
34757
34757
|
${underline}`);
|
|
34758
34758
|
}
|
|
34759
|
-
return
|
|
34759
|
+
return path22;
|
|
34760
34760
|
};
|
|
34761
34761
|
var path5 = /* @__PURE__ */ createPathTagFunction(encodeURIPath);
|
|
34762
34762
|
|
|
@@ -37867,9 +37867,9 @@ var BaseAnthropic = class {
|
|
|
37867
37867
|
makeStatusError(status, error, message, headers) {
|
|
37868
37868
|
return APIError.generate(status, error, message, headers);
|
|
37869
37869
|
}
|
|
37870
|
-
buildURL(
|
|
37870
|
+
buildURL(path21, query, defaultBaseURL) {
|
|
37871
37871
|
const baseURL = !__classPrivateFieldGet(this, _BaseAnthropic_instances, "m", _BaseAnthropic_baseURLOverridden).call(this) && defaultBaseURL || this.baseURL;
|
|
37872
|
-
const url = isAbsoluteURL(
|
|
37872
|
+
const url = isAbsoluteURL(path21) ? new URL(path21) : new URL(baseURL + (baseURL.endsWith("/") && path21.startsWith("/") ? path21.slice(1) : path21));
|
|
37873
37873
|
const defaultQuery = this.defaultQuery();
|
|
37874
37874
|
if (!isEmptyObj(defaultQuery)) {
|
|
37875
37875
|
query = { ...defaultQuery, ...query };
|
|
@@ -37900,24 +37900,24 @@ var BaseAnthropic = class {
|
|
|
37900
37900
|
*/
|
|
37901
37901
|
async prepareRequest(request, { url, options }) {
|
|
37902
37902
|
}
|
|
37903
|
-
get(
|
|
37904
|
-
return this.methodRequest("get",
|
|
37903
|
+
get(path21, opts) {
|
|
37904
|
+
return this.methodRequest("get", path21, opts);
|
|
37905
37905
|
}
|
|
37906
|
-
post(
|
|
37907
|
-
return this.methodRequest("post",
|
|
37906
|
+
post(path21, opts) {
|
|
37907
|
+
return this.methodRequest("post", path21, opts);
|
|
37908
37908
|
}
|
|
37909
|
-
patch(
|
|
37910
|
-
return this.methodRequest("patch",
|
|
37909
|
+
patch(path21, opts) {
|
|
37910
|
+
return this.methodRequest("patch", path21, opts);
|
|
37911
37911
|
}
|
|
37912
|
-
put(
|
|
37913
|
-
return this.methodRequest("put",
|
|
37912
|
+
put(path21, opts) {
|
|
37913
|
+
return this.methodRequest("put", path21, opts);
|
|
37914
37914
|
}
|
|
37915
|
-
delete(
|
|
37916
|
-
return this.methodRequest("delete",
|
|
37915
|
+
delete(path21, opts) {
|
|
37916
|
+
return this.methodRequest("delete", path21, opts);
|
|
37917
37917
|
}
|
|
37918
|
-
methodRequest(method,
|
|
37918
|
+
methodRequest(method, path21, opts) {
|
|
37919
37919
|
return this.request(Promise.resolve(opts).then((opts2) => {
|
|
37920
|
-
return { method, path:
|
|
37920
|
+
return { method, path: path21, ...opts2 };
|
|
37921
37921
|
}));
|
|
37922
37922
|
}
|
|
37923
37923
|
request(options, remainingRetries = null) {
|
|
@@ -38021,8 +38021,8 @@ var BaseAnthropic = class {
|
|
|
38021
38021
|
}));
|
|
38022
38022
|
return { response, options, controller, requestLogID, retryOfRequestLogID, startTime: startTime2 };
|
|
38023
38023
|
}
|
|
38024
|
-
getAPIList(
|
|
38025
|
-
return this.requestAPIList(Page2, opts && "then" in opts ? opts.then((opts2) => ({ method: "get", path:
|
|
38024
|
+
getAPIList(path21, Page2, opts) {
|
|
38025
|
+
return this.requestAPIList(Page2, opts && "then" in opts ? opts.then((opts2) => ({ method: "get", path: path21, ...opts2 })) : { method: "get", path: path21, ...opts });
|
|
38026
38026
|
}
|
|
38027
38027
|
requestAPIList(Page2, options) {
|
|
38028
38028
|
const request = this.makeRequest(options, null, void 0);
|
|
@@ -38110,8 +38110,8 @@ var BaseAnthropic = class {
|
|
|
38110
38110
|
}
|
|
38111
38111
|
async buildRequest(inputOptions, { retryCount = 0 } = {}) {
|
|
38112
38112
|
const options = { ...inputOptions };
|
|
38113
|
-
const { method, path:
|
|
38114
|
-
const url = this.buildURL(
|
|
38113
|
+
const { method, path: path21, query, defaultBaseURL } = options;
|
|
38114
|
+
const url = this.buildURL(path21, query, defaultBaseURL);
|
|
38115
38115
|
if ("timeout" in options)
|
|
38116
38116
|
validatePositiveInteger("timeout", options.timeout);
|
|
38117
38117
|
options.timeout = options.timeout ?? this.timeout;
|
|
@@ -40321,16 +40321,16 @@ var Diff = class {
|
|
|
40321
40321
|
}
|
|
40322
40322
|
}
|
|
40323
40323
|
}
|
|
40324
|
-
addToPath(
|
|
40325
|
-
const last =
|
|
40324
|
+
addToPath(path21, added, removed, oldPosInc, options) {
|
|
40325
|
+
const last = path21.lastComponent;
|
|
40326
40326
|
if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) {
|
|
40327
40327
|
return {
|
|
40328
|
-
oldPos:
|
|
40328
|
+
oldPos: path21.oldPos + oldPosInc,
|
|
40329
40329
|
lastComponent: { count: last.count + 1, added, removed, previousComponent: last.previousComponent }
|
|
40330
40330
|
};
|
|
40331
40331
|
} else {
|
|
40332
40332
|
return {
|
|
40333
|
-
oldPos:
|
|
40333
|
+
oldPos: path21.oldPos + oldPosInc,
|
|
40334
40334
|
lastComponent: { count: 1, added, removed, previousComponent: last }
|
|
40335
40335
|
};
|
|
40336
40336
|
}
|
|
@@ -41855,7 +41855,7 @@ var getSkillPaths = () => {
|
|
|
41855
41855
|
var getDirectories = (dirPath) => {
|
|
41856
41856
|
return (0, import_fs11.readdirSync)(dirPath).filter((name) => (0, import_fs11.statSync)((0, import_path16.join)(dirPath, name)).isDirectory());
|
|
41857
41857
|
};
|
|
41858
|
-
var parseSkill = (mdPath, skillDir) => {
|
|
41858
|
+
var parseSkill = (mdPath, skillDir, options = {}) => {
|
|
41859
41859
|
if (!(0, import_fs11.existsSync)(mdPath)) return null;
|
|
41860
41860
|
const raw2 = (0, import_fs11.readFileSync)(mdPath, "utf-8");
|
|
41861
41861
|
let name = "";
|
|
@@ -41878,13 +41878,17 @@ var parseSkill = (mdPath, skillDir) => {
|
|
|
41878
41878
|
if (!description && body) {
|
|
41879
41879
|
description = body.split("\n")[0].replace(/^#+\s*/, "").trim();
|
|
41880
41880
|
}
|
|
41881
|
-
const projectSkillsPath = getProjectSkillsPath();
|
|
41882
41881
|
const normalizedSkillDir = import_path16.default.resolve(skillDir);
|
|
41883
|
-
const
|
|
41882
|
+
const projectSkillsPath = getProjectSkillsPath();
|
|
41883
|
+
const isProjectSkill = projectSkillsPath ? normalizedSkillDir === import_path16.default.resolve(projectSkillsPath, import_path16.default.basename(normalizedSkillDir)) && normalizedSkillDir.startsWith(import_path16.default.resolve(projectSkillsPath) + import_path16.default.sep) : false;
|
|
41884
|
+
const scope = options.scope ?? (isProjectSkill ? "project" : "global");
|
|
41885
|
+
const deletable = options.deletable ?? (scope === "project" && isProjectSkill);
|
|
41884
41886
|
return {
|
|
41885
41887
|
name,
|
|
41886
41888
|
description,
|
|
41887
41889
|
baseDir: skillDir,
|
|
41890
|
+
scope,
|
|
41891
|
+
departmentName: options.departmentName,
|
|
41888
41892
|
deletable,
|
|
41889
41893
|
getDetail: () => {
|
|
41890
41894
|
let content = body.replace(/<Skill目录>/g, skillDir).replace(/\$\{CLAUDE_SKILL_DIR\}/g, skillDir);
|
|
@@ -41896,7 +41900,6 @@ ${content}`;
|
|
|
41896
41900
|
};
|
|
41897
41901
|
var loadSkill = () => {
|
|
41898
41902
|
const skillPaths = getSkillPaths();
|
|
41899
|
-
if (skillPaths.length === 0) return [];
|
|
41900
41903
|
const seen = /* @__PURE__ */ new Set();
|
|
41901
41904
|
const skills = [];
|
|
41902
41905
|
for (const skillPath of skillPaths) {
|
|
@@ -44502,6 +44505,8 @@ var DESCRIPTION29 = `\u5728\u7CFB\u7EDF shell \u4E2D\u6267\u884C\u547D\u4EE4\u30
|
|
|
44502
44505
|
- \u4E0D\u8981\u6267\u884C\u7834\u574F\u6027\u547D\u4EE4\uFF08\u5982 rm -rf /\uFF09
|
|
44503
44506
|
- \u957F\u65F6\u95F4\u8FD0\u884C\u7684\u547D\u4EE4\uFF08\u5982\u542F\u52A8\u670D\u52A1\u5668\uFF09\u8D85\u8FC7\u7B49\u5F85\u65F6\u95F4\u540E\u4F1A\u4FDD\u7559\u4F1A\u8BDD\uFF0C\u53EF\u7528 session_id \u67E5\u8BE2\u589E\u91CF\u8F93\u51FA
|
|
44504
44507
|
- \u5982\u679C\u4F60\u5904\u4E8E\u90E8\u95E8\u5DE5\u4F5C\u533A\u6A21\u5F0F\uFF0Ccwd \u5FC5\u987B\u5728\u5DE5\u4F5C\u533A\u8303\u56F4\u5185
|
|
44508
|
+
- Duclaw runtime \u4FDD\u7559\u7AEF\u53E3 3100 \u627F\u8F7D\u5F53\u524D\u667A\u80FD\u4F53 HTTP/gateway\uFF0Cduclaw-cli start \u548C duclaw-worker \u662F\u7CFB\u7EDF\u8FDB\u7A0B\u3002\u4E0D\u8981\u5BF9 3100 \u6216\u8FD9\u4E9B\u8FDB\u7A0B\u6267\u884C kill/pkill/killall/fuser/lsof|xargs kill/ss|xargs kill\uFF0C\u5426\u5219 iOS \u4F1A\u663E\u793A\u5DF2\u5173\u673A\u6216 502\u3002
|
|
44509
|
+
- \u505C\u6B62\u81EA\u5DF1\u542F\u52A8\u7684\u5F00\u53D1\u670D\u52A1\u65F6\uFF0C\u4F18\u5148\u4F7F\u7528 action=stop \u548C session_id\uFF1B\u65E0\u6CD5\u786E\u8BA4 PID \u5C5E\u4E8E\u5F53\u524D\u9879\u76EE\u65F6\u4E0D\u8981 kill\u3002
|
|
44505
44510
|
`;
|
|
44506
44511
|
var MAX_OUTPUT_LENGTH = 1e4;
|
|
44507
44512
|
var MAX_SESSION_OUTPUT_LENGTH = 5e4;
|
|
@@ -44509,6 +44514,7 @@ var DEFAULT_TIMEOUT_MS = 3e4;
|
|
|
44509
44514
|
var DEFAULT_SESSION_TTL_MS = 30 * 60 * 1e3;
|
|
44510
44515
|
var SHELL_CANDIDATES2 = ["/bin/sh", "/usr/bin/sh", "/bin/bash"];
|
|
44511
44516
|
var DEFAULT_PROTECTED_PORTS = ["3100"];
|
|
44517
|
+
var RESERVED_PORT_ENV_KEYS = ["PORT", "KANBAN_PORT"];
|
|
44512
44518
|
var sessions = /* @__PURE__ */ new Map();
|
|
44513
44519
|
function findExecutableShell2() {
|
|
44514
44520
|
for (const shell of SHELL_CANDIDATES2) {
|
|
@@ -44569,6 +44575,60 @@ function validateProtectedRuntimeCommand(command) {
|
|
|
44569
44575
|
}
|
|
44570
44576
|
return null;
|
|
44571
44577
|
}
|
|
44578
|
+
function createBashChildEnv() {
|
|
44579
|
+
const env = { ...process.env, PAGER: "cat" };
|
|
44580
|
+
const protectedPorts = new Set(getProtectedPorts());
|
|
44581
|
+
for (const key of RESERVED_PORT_ENV_KEYS) {
|
|
44582
|
+
const value = env[key]?.trim();
|
|
44583
|
+
if (value && protectedPorts.has(value)) {
|
|
44584
|
+
delete env[key];
|
|
44585
|
+
}
|
|
44586
|
+
}
|
|
44587
|
+
return env;
|
|
44588
|
+
}
|
|
44589
|
+
function listProtectedRuntimeProcesses() {
|
|
44590
|
+
try {
|
|
44591
|
+
const output = (0, import_node_child_process.execFileSync)("ps", ["-eo", "pid=,ppid=,args="], { encoding: "utf8" });
|
|
44592
|
+
const currentPid = process.pid;
|
|
44593
|
+
return output.split("\n").map((line) => line.trim().match(/^(\d+)\s+(\d+)\s+(.*)$/)).filter((match2) => Boolean(match2)).map((match2) => ({
|
|
44594
|
+
pid: Number(match2[1]),
|
|
44595
|
+
command: match2[3] ?? ""
|
|
44596
|
+
})).filter(
|
|
44597
|
+
(processInfo) => Number.isFinite(processInfo.pid) && processInfo.pid !== currentPid && (processInfo.command.includes("duclaw-cli start") || processInfo.command.includes("duclaw-worker"))
|
|
44598
|
+
).map(({ pid, command }) => ({ pid, command }));
|
|
44599
|
+
} catch {
|
|
44600
|
+
return [];
|
|
44601
|
+
}
|
|
44602
|
+
}
|
|
44603
|
+
function validateProtectedRuntimePidCommand(command) {
|
|
44604
|
+
if (!/\bkill\b/.test(command)) return null;
|
|
44605
|
+
const protectedProcesses = listProtectedRuntimeProcesses();
|
|
44606
|
+
for (const protectedProcess of protectedProcesses) {
|
|
44607
|
+
const pidRef = new RegExp(`(^|[^\\d])${protectedProcess.pid}([^\\d]|$)`);
|
|
44608
|
+
if (!pidRef.test(command)) continue;
|
|
44609
|
+
return [
|
|
44610
|
+
`[bash] \u62D2\u7EDD\u6267\u884C: \u547D\u4EE4\u8BD5\u56FE\u7EC8\u6B62 Duclaw runtime \u8FDB\u7A0B PID ${protectedProcess.pid}\u3002`,
|
|
44611
|
+
`\u5339\u914D\u8FDB\u7A0B: ${protectedProcess.command}`,
|
|
44612
|
+
`\u8BF7\u53EA\u7EC8\u6B62\u660E\u786E\u5C5E\u4E8E\u5F53\u524D\u9879\u76EE\u7684\u5F00\u53D1\u670D\u52A1 PID\uFF0C\u4E0D\u8981\u6740 duclaw-cli start \u6216 duclaw-worker\u3002`
|
|
44613
|
+
].join("\n");
|
|
44614
|
+
}
|
|
44615
|
+
return null;
|
|
44616
|
+
}
|
|
44617
|
+
function terminateSessionProcessGroup(session, signal = "SIGTERM") {
|
|
44618
|
+
const pid = session.child.pid;
|
|
44619
|
+
if (!pid) {
|
|
44620
|
+
session.child.kill(signal);
|
|
44621
|
+
return;
|
|
44622
|
+
}
|
|
44623
|
+
try {
|
|
44624
|
+
if (process.platform !== "win32") {
|
|
44625
|
+
process.kill(-pid, signal);
|
|
44626
|
+
return;
|
|
44627
|
+
}
|
|
44628
|
+
} catch {
|
|
44629
|
+
}
|
|
44630
|
+
session.child.kill(signal);
|
|
44631
|
+
}
|
|
44572
44632
|
function truncateOutput(output, limit = MAX_OUTPUT_LENGTH) {
|
|
44573
44633
|
if (output.length <= limit) return output;
|
|
44574
44634
|
return output.slice(0, limit) + `
|
|
@@ -44674,7 +44734,7 @@ var bashTool = {
|
|
|
44674
44734
|
}
|
|
44675
44735
|
if (action === "stop") {
|
|
44676
44736
|
if (session.status === "running") {
|
|
44677
|
-
session
|
|
44737
|
+
terminateSessionProcessGroup(session, "SIGTERM");
|
|
44678
44738
|
finishSession(session, "stopped", null, "SIGTERM");
|
|
44679
44739
|
}
|
|
44680
44740
|
return renderSessionDelta(session, `[bash] \u5DF2\u505C\u6B62 session ${session.id}`);
|
|
@@ -44692,6 +44752,8 @@ var bashTool = {
|
|
|
44692
44752
|
}
|
|
44693
44753
|
const protectedCommandError = validateProtectedRuntimeCommand(command);
|
|
44694
44754
|
if (protectedCommandError) return protectedCommandError;
|
|
44755
|
+
const protectedRuntimePidError = validateProtectedRuntimePidCommand(command);
|
|
44756
|
+
if (protectedRuntimePidError) return protectedRuntimePidError;
|
|
44695
44757
|
if (userRequest?.workspacePath && explicitCwd) {
|
|
44696
44758
|
const rejection = validateWorkspacePath(explicitCwd, userRequest.workspacePath);
|
|
44697
44759
|
if (rejection) return `[bash] ${rejection}`;
|
|
@@ -44705,12 +44767,13 @@ var bashTool = {
|
|
|
44705
44767
|
}
|
|
44706
44768
|
return new Promise(async (resolve11) => {
|
|
44707
44769
|
const options = {
|
|
44708
|
-
env:
|
|
44770
|
+
env: createBashChildEnv()
|
|
44709
44771
|
};
|
|
44710
44772
|
if (cwd) options.cwd = cwd;
|
|
44711
44773
|
const child = (0, import_node_child_process.spawn)(shell, ["-c", command], {
|
|
44712
44774
|
...options,
|
|
44713
|
-
stdio: ["pipe", "pipe", "pipe"]
|
|
44775
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
44776
|
+
detached: process.platform !== "win32"
|
|
44714
44777
|
});
|
|
44715
44778
|
const id = (0, import_node_crypto11.randomUUID)().slice(0, 8);
|
|
44716
44779
|
const session = {
|
|
@@ -44725,7 +44788,7 @@ var bashTool = {
|
|
|
44725
44788
|
const current = sessions.get(id);
|
|
44726
44789
|
if (!current) return;
|
|
44727
44790
|
if (current.status === "running") {
|
|
44728
|
-
current
|
|
44791
|
+
terminateSessionProcessGroup(current, "SIGTERM");
|
|
44729
44792
|
finishSession(current, "stopped", null, "SIGTERM");
|
|
44730
44793
|
}
|
|
44731
44794
|
sessions.delete(id);
|
|
@@ -44878,11 +44941,26 @@ var createRuntimeActivityToolHookPlugin = () => ({
|
|
|
44878
44941
|
}
|
|
44879
44942
|
});
|
|
44880
44943
|
function activityMetadata(ctx) {
|
|
44881
|
-
|
|
44944
|
+
const metadata = {
|
|
44882
44945
|
platform: ctx.userRequest?.platform,
|
|
44883
44946
|
requestId: ctx.userRequest?.requestId,
|
|
44884
44947
|
departmentAgentId: ctx.userRequest?.departmentAgentId
|
|
44885
44948
|
};
|
|
44949
|
+
if (ctx.toolName === "bash") {
|
|
44950
|
+
if (typeof ctx.input.command === "string") {
|
|
44951
|
+
metadata.command = summarizeText2(ctx.input.command, 1e3);
|
|
44952
|
+
}
|
|
44953
|
+
if (typeof ctx.input.action === "string") {
|
|
44954
|
+
metadata.action = ctx.input.action;
|
|
44955
|
+
}
|
|
44956
|
+
if (typeof ctx.input.session_id === "string") {
|
|
44957
|
+
metadata.sessionId = ctx.input.session_id;
|
|
44958
|
+
}
|
|
44959
|
+
}
|
|
44960
|
+
return metadata;
|
|
44961
|
+
}
|
|
44962
|
+
function summarizeText2(value, maxChars) {
|
|
44963
|
+
return value.length <= maxChars ? value : `${value.slice(0, maxChars)}...`;
|
|
44886
44964
|
}
|
|
44887
44965
|
|
|
44888
44966
|
// src/runtime/plugins/saasCreditToolHook.ts
|
|
@@ -46492,6 +46570,16 @@ var claimOutboundSend = (userId, text2, windowMs = DEFAULT_WINDOW_MS) => {
|
|
|
46492
46570
|
return true;
|
|
46493
46571
|
};
|
|
46494
46572
|
|
|
46573
|
+
// src/runtime/runtimeSafetyPrompt.ts
|
|
46574
|
+
var RUNTIME_PROCESS_SAFETY_PROMPT = `
|
|
46575
|
+
<Runtime Process Safety>
|
|
46576
|
+
- Duclaw runtime \u81EA\u8EAB\u5360\u7528\u4FDD\u7559\u7AEF\u53E3 3100\uFF0C\u5E76\u7531 duclaw-cli start \u63D0\u4F9B HTTP/gateway\uFF0C\u7531 duclaw-worker \u5904\u7406\u540E\u53F0 mailbox/worker \u5DE5\u4F5C\u3002\u4E0D\u8981\u7EC8\u6B62\u8FD9\u4E9B\u8FDB\u7A0B\u3002
|
|
46577
|
+
- \u4E0D\u8981\u5BF9 3100\u3001duclaw-cli start\u3001duclaw-worker \u6267\u884C kill\u3001pkill\u3001killall\u3001fuser\u3001lsof|xargs kill\u3001ss|xargs kill\uFF0C\u6740\u6389\u5B83\u4F1A\u5BFC\u81F4 iOS \u663E\u793A\u5DF2\u5173\u673A\u6216 HTTP 502\u3002
|
|
46578
|
+
- \u53D1\u73B0 3100 \u88AB\u5360\u7528\u65F6\uFF0C\u9ED8\u8BA4\u5B83\u662F\u7CFB\u7EDF\u4FDD\u7559\u7AEF\u53E3\uFF0C\u4E0D\u8981\u6E05\u7406\uFF1B\u9879\u76EE\u5F00\u53D1\u670D\u52A1\u8BF7\u6539\u7528\u81EA\u5DF1\u7684\u7AEF\u53E3\uFF0C\u4F8B\u5982 3001\u30015173\u30015174\u3002
|
|
46579
|
+
- \u505C\u6B62\u81EA\u5DF1\u542F\u52A8\u7684\u5F00\u53D1\u670D\u52A1\u65F6\uFF0C\u4F18\u5148\u4F7F\u7528 bash \u7684 action=stop \u548C\u5BF9\u5E94 session_id\u3002\u53EA\u6709\u80FD\u660E\u786E PID \u5C5E\u4E8E\u5F53\u524D\u9879\u76EE\u5F00\u53D1\u670D\u52A1\u65F6\u624D\u53EF\u4EE5\u7EC8\u6B62\uFF1B\u65E0\u6CD5\u5224\u65AD\u65F6\u5148\u6C47\u62A5\uFF0C\u4E0D\u8981 kill\u3002
|
|
46580
|
+
</Runtime Process Safety>
|
|
46581
|
+
`.trim();
|
|
46582
|
+
|
|
46495
46583
|
// src/agent/createAgent.ts
|
|
46496
46584
|
var DEFAULT_WORKSPACE_PATH = getDuclawWorkspaceDir();
|
|
46497
46585
|
var assistantMessageFromResponse = (response) => ({
|
|
@@ -46546,6 +46634,8 @@ The user will primarily request you perform software engineering tasks. This inc
|
|
|
46546
46634
|
- \u5982\u679C\u5386\u53F2\u4E2D\u51FA\u73B0 <department-agent-reply ... owner_mailbox_id="...">\uFF0C\u628A\u8BE5\u6210\u5458\u89C6\u4E3A\u5BF9\u5E94\u4EA7\u51FA/\u5B9E\u73B0\u7EBF\u7A0B\u7684\u8D23\u4EFB\u4EBA\uFF1B\u5F53\u7528\u6237\u968F\u540E\u63D0\u51FA bug\u3001\u4FEE\u6539\u3001\u8FD4\u5DE5\u3001\u6253\u4E0D\u5F00\u3001\u518D\u4F18\u5316\u7B49\u53CD\u9988\u65F6\uFF0C\u4F18\u5148\u6CBF\u8BE5 reply \u7684 mailbox \u7EBF\u7A0B\u7EE7\u7EED\u59D4\u6D3E\u7ED9\u539F\u8D23\u4EFB\u4EBA\uFF0C\u800C\u4E0D\u662F\u81EA\u5DF1\u63A5\u624B\u5B9E\u73B0\u3002
|
|
46547
46635
|
</Doing tasks>
|
|
46548
46636
|
|
|
46637
|
+
${RUNTIME_PROCESS_SAFETY_PROMPT}
|
|
46638
|
+
|
|
46549
46639
|
<\u4F60\u7684\u8EAB\u4EFD>
|
|
46550
46640
|
\u4F60\u662F\u8FD9\u5BB6 AI \u516C\u53F8\u7684 CEO\uFF0C\u76F4\u63A5\u5411\u8001\u677F\uFF08\u7528\u6237\uFF09\u8D1F\u8D23\u3002\u4F60\u7684\u672C\u4E8B\u662F\u901A\u8FC7\u56E2\u961F\u628A\u4E8B\u60C5\u505A\u6210\uFF0C\u800C\u4E0D\u662F\u81EA\u5DF1\u57CB\u5934\u505A\u3002
|
|
46551
46641
|
|
|
@@ -48567,6 +48657,8 @@ ${workspacePath ? `
|
|
|
48567
48657
|
\u56DE\u590D\u5199\u5F97\u6E05\u695A\u3001\u6709\u6761\u7406\uFF0C\u65B9\u4FBF\u5BF9\u65B9\u63A5\u7740\u5E72\u3002
|
|
48568
48658
|
</Mailbox \u5DE5\u4F5C\u65B9\u5F0F>
|
|
48569
48659
|
|
|
48660
|
+
${RUNTIME_PROCESS_SAFETY_PROMPT}
|
|
48661
|
+
|
|
48570
48662
|
<Task Execution>
|
|
48571
48663
|
- Use available tools to complete the work.
|
|
48572
48664
|
- For file operations, use the dedicated file tools:
|
|
@@ -48762,26 +48854,26 @@ var handleParsingNestedValues = (form, key, value) => {
|
|
|
48762
48854
|
};
|
|
48763
48855
|
|
|
48764
48856
|
// node_modules/.pnpm/hono@4.12.9/node_modules/hono/dist/utils/url.js
|
|
48765
|
-
var splitPath = (
|
|
48766
|
-
const paths =
|
|
48857
|
+
var splitPath = (path21) => {
|
|
48858
|
+
const paths = path21.split("/");
|
|
48767
48859
|
if (paths[0] === "") {
|
|
48768
48860
|
paths.shift();
|
|
48769
48861
|
}
|
|
48770
48862
|
return paths;
|
|
48771
48863
|
};
|
|
48772
48864
|
var splitRoutingPath = (routePath) => {
|
|
48773
|
-
const { groups, path:
|
|
48774
|
-
const paths = splitPath(
|
|
48865
|
+
const { groups, path: path21 } = extractGroupsFromPath(routePath);
|
|
48866
|
+
const paths = splitPath(path21);
|
|
48775
48867
|
return replaceGroupMarks(paths, groups);
|
|
48776
48868
|
};
|
|
48777
|
-
var extractGroupsFromPath = (
|
|
48869
|
+
var extractGroupsFromPath = (path21) => {
|
|
48778
48870
|
const groups = [];
|
|
48779
|
-
|
|
48871
|
+
path21 = path21.replace(/\{[^}]+\}/g, (match2, index) => {
|
|
48780
48872
|
const mark = `@${index}`;
|
|
48781
48873
|
groups.push([mark, match2]);
|
|
48782
48874
|
return mark;
|
|
48783
48875
|
});
|
|
48784
|
-
return { groups, path:
|
|
48876
|
+
return { groups, path: path21 };
|
|
48785
48877
|
};
|
|
48786
48878
|
var replaceGroupMarks = (paths, groups) => {
|
|
48787
48879
|
for (let i = groups.length - 1; i >= 0; i--) {
|
|
@@ -48838,8 +48930,8 @@ var getPath = (request) => {
|
|
|
48838
48930
|
const queryIndex = url.indexOf("?", i);
|
|
48839
48931
|
const hashIndex = url.indexOf("#", i);
|
|
48840
48932
|
const end = queryIndex === -1 ? hashIndex === -1 ? void 0 : hashIndex : hashIndex === -1 ? queryIndex : Math.min(queryIndex, hashIndex);
|
|
48841
|
-
const
|
|
48842
|
-
return tryDecodeURI(
|
|
48933
|
+
const path21 = url.slice(start, end);
|
|
48934
|
+
return tryDecodeURI(path21.includes("%25") ? path21.replace(/%25/g, "%2525") : path21);
|
|
48843
48935
|
} else if (charCode === 63 || charCode === 35) {
|
|
48844
48936
|
break;
|
|
48845
48937
|
}
|
|
@@ -48856,11 +48948,11 @@ var mergePath = (base, sub, ...rest) => {
|
|
|
48856
48948
|
}
|
|
48857
48949
|
return `${base?.[0] === "/" ? "" : "/"}${base}${sub === "/" ? "" : `${base?.at(-1) === "/" ? "" : "/"}${sub?.[0] === "/" ? sub.slice(1) : sub}`}`;
|
|
48858
48950
|
};
|
|
48859
|
-
var checkOptionalParameter = (
|
|
48860
|
-
if (
|
|
48951
|
+
var checkOptionalParameter = (path21) => {
|
|
48952
|
+
if (path21.charCodeAt(path21.length - 1) !== 63 || !path21.includes(":")) {
|
|
48861
48953
|
return null;
|
|
48862
48954
|
}
|
|
48863
|
-
const segments =
|
|
48955
|
+
const segments = path21.split("/");
|
|
48864
48956
|
const results = [];
|
|
48865
48957
|
let basePath = "";
|
|
48866
48958
|
segments.forEach((segment) => {
|
|
@@ -49001,9 +49093,9 @@ var HonoRequest = class {
|
|
|
49001
49093
|
*/
|
|
49002
49094
|
path;
|
|
49003
49095
|
bodyCache = {};
|
|
49004
|
-
constructor(request,
|
|
49096
|
+
constructor(request, path21 = "/", matchResult = [[]]) {
|
|
49005
49097
|
this.raw = request;
|
|
49006
|
-
this.path =
|
|
49098
|
+
this.path = path21;
|
|
49007
49099
|
this.#matchResult = matchResult;
|
|
49008
49100
|
this.#validatedData = {};
|
|
49009
49101
|
}
|
|
@@ -49740,8 +49832,8 @@ var Hono = class _Hono {
|
|
|
49740
49832
|
return this;
|
|
49741
49833
|
};
|
|
49742
49834
|
});
|
|
49743
|
-
this.on = (method,
|
|
49744
|
-
for (const p of [
|
|
49835
|
+
this.on = (method, path21, ...handlers) => {
|
|
49836
|
+
for (const p of [path21].flat()) {
|
|
49745
49837
|
this.#path = p;
|
|
49746
49838
|
for (const m of [method].flat()) {
|
|
49747
49839
|
handlers.map((handler) => {
|
|
@@ -49798,8 +49890,8 @@ var Hono = class _Hono {
|
|
|
49798
49890
|
* app.route("/api", app2) // GET /api/user
|
|
49799
49891
|
* ```
|
|
49800
49892
|
*/
|
|
49801
|
-
route(
|
|
49802
|
-
const subApp = this.basePath(
|
|
49893
|
+
route(path21, app) {
|
|
49894
|
+
const subApp = this.basePath(path21);
|
|
49803
49895
|
app.routes.map((r) => {
|
|
49804
49896
|
let handler;
|
|
49805
49897
|
if (app.errorHandler === errorHandler) {
|
|
@@ -49825,9 +49917,9 @@ var Hono = class _Hono {
|
|
|
49825
49917
|
* const api = new Hono().basePath('/api')
|
|
49826
49918
|
* ```
|
|
49827
49919
|
*/
|
|
49828
|
-
basePath(
|
|
49920
|
+
basePath(path21) {
|
|
49829
49921
|
const subApp = this.#clone();
|
|
49830
|
-
subApp._basePath = mergePath(this._basePath,
|
|
49922
|
+
subApp._basePath = mergePath(this._basePath, path21);
|
|
49831
49923
|
return subApp;
|
|
49832
49924
|
}
|
|
49833
49925
|
/**
|
|
@@ -49901,7 +49993,7 @@ var Hono = class _Hono {
|
|
|
49901
49993
|
* })
|
|
49902
49994
|
* ```
|
|
49903
49995
|
*/
|
|
49904
|
-
mount(
|
|
49996
|
+
mount(path21, applicationHandler, options) {
|
|
49905
49997
|
let replaceRequest;
|
|
49906
49998
|
let optionHandler;
|
|
49907
49999
|
if (options) {
|
|
@@ -49928,7 +50020,7 @@ var Hono = class _Hono {
|
|
|
49928
50020
|
return [c.env, executionContext];
|
|
49929
50021
|
};
|
|
49930
50022
|
replaceRequest ||= (() => {
|
|
49931
|
-
const mergedPath = mergePath(this._basePath,
|
|
50023
|
+
const mergedPath = mergePath(this._basePath, path21);
|
|
49932
50024
|
const pathPrefixLength = mergedPath === "/" ? 0 : mergedPath.length;
|
|
49933
50025
|
return (request) => {
|
|
49934
50026
|
const url = new URL(request.url);
|
|
@@ -49943,14 +50035,14 @@ var Hono = class _Hono {
|
|
|
49943
50035
|
}
|
|
49944
50036
|
await next();
|
|
49945
50037
|
};
|
|
49946
|
-
this.#addRoute(METHOD_NAME_ALL, mergePath(
|
|
50038
|
+
this.#addRoute(METHOD_NAME_ALL, mergePath(path21, "*"), handler);
|
|
49947
50039
|
return this;
|
|
49948
50040
|
}
|
|
49949
|
-
#addRoute(method,
|
|
50041
|
+
#addRoute(method, path21, handler) {
|
|
49950
50042
|
method = method.toUpperCase();
|
|
49951
|
-
|
|
49952
|
-
const r = { basePath: this._basePath, path:
|
|
49953
|
-
this.router.add(method,
|
|
50043
|
+
path21 = mergePath(this._basePath, path21);
|
|
50044
|
+
const r = { basePath: this._basePath, path: path21, method, handler };
|
|
50045
|
+
this.router.add(method, path21, [handler, r]);
|
|
49954
50046
|
this.routes.push(r);
|
|
49955
50047
|
}
|
|
49956
50048
|
#handleError(err, c) {
|
|
@@ -49963,10 +50055,10 @@ var Hono = class _Hono {
|
|
|
49963
50055
|
if (method === "HEAD") {
|
|
49964
50056
|
return (async () => new Response(null, await this.#dispatch(request, executionCtx, env, "GET")))();
|
|
49965
50057
|
}
|
|
49966
|
-
const
|
|
49967
|
-
const matchResult = this.router.match(method,
|
|
50058
|
+
const path21 = this.getPath(request, { env });
|
|
50059
|
+
const matchResult = this.router.match(method, path21);
|
|
49968
50060
|
const c = new Context(request, {
|
|
49969
|
-
path:
|
|
50061
|
+
path: path21,
|
|
49970
50062
|
matchResult,
|
|
49971
50063
|
env,
|
|
49972
50064
|
executionCtx,
|
|
@@ -50066,7 +50158,7 @@ var Hono = class _Hono {
|
|
|
50066
50158
|
|
|
50067
50159
|
// node_modules/.pnpm/hono@4.12.9/node_modules/hono/dist/router/reg-exp-router/matcher.js
|
|
50068
50160
|
var emptyParam = [];
|
|
50069
|
-
function match(method,
|
|
50161
|
+
function match(method, path21) {
|
|
50070
50162
|
const matchers = this.buildAllMatchers();
|
|
50071
50163
|
const match2 = ((method2, path22) => {
|
|
50072
50164
|
const matcher = matchers[method2] || matchers[METHOD_NAME_ALL];
|
|
@@ -50082,7 +50174,7 @@ function match(method, path20) {
|
|
|
50082
50174
|
return [matcher[1][index], match3];
|
|
50083
50175
|
});
|
|
50084
50176
|
this.match = match2;
|
|
50085
|
-
return match2(method,
|
|
50177
|
+
return match2(method, path21);
|
|
50086
50178
|
}
|
|
50087
50179
|
|
|
50088
50180
|
// node_modules/.pnpm/hono@4.12.9/node_modules/hono/dist/router/reg-exp-router/node.js
|
|
@@ -50197,12 +50289,12 @@ var Node = class _Node {
|
|
|
50197
50289
|
var Trie = class {
|
|
50198
50290
|
#context = { varIndex: 0 };
|
|
50199
50291
|
#root = new Node();
|
|
50200
|
-
insert(
|
|
50292
|
+
insert(path21, index, pathErrorCheckOnly) {
|
|
50201
50293
|
const paramAssoc = [];
|
|
50202
50294
|
const groups = [];
|
|
50203
50295
|
for (let i = 0; ; ) {
|
|
50204
50296
|
let replaced = false;
|
|
50205
|
-
|
|
50297
|
+
path21 = path21.replace(/\{[^}]+\}/g, (m) => {
|
|
50206
50298
|
const mark = `@\\${i}`;
|
|
50207
50299
|
groups[i] = [mark, m];
|
|
50208
50300
|
i++;
|
|
@@ -50213,7 +50305,7 @@ var Trie = class {
|
|
|
50213
50305
|
break;
|
|
50214
50306
|
}
|
|
50215
50307
|
}
|
|
50216
|
-
const tokens =
|
|
50308
|
+
const tokens = path21.match(/(?::[^\/]+)|(?:\/\*$)|./g) || [];
|
|
50217
50309
|
for (let i = groups.length - 1; i >= 0; i--) {
|
|
50218
50310
|
const [mark] = groups[i];
|
|
50219
50311
|
for (let j = tokens.length - 1; j >= 0; j--) {
|
|
@@ -50252,9 +50344,9 @@ var Trie = class {
|
|
|
50252
50344
|
// node_modules/.pnpm/hono@4.12.9/node_modules/hono/dist/router/reg-exp-router/router.js
|
|
50253
50345
|
var nullMatcher = [/^$/, [], /* @__PURE__ */ Object.create(null)];
|
|
50254
50346
|
var wildcardRegExpCache = /* @__PURE__ */ Object.create(null);
|
|
50255
|
-
function buildWildcardRegExp(
|
|
50256
|
-
return wildcardRegExpCache[
|
|
50257
|
-
|
|
50347
|
+
function buildWildcardRegExp(path21) {
|
|
50348
|
+
return wildcardRegExpCache[path21] ??= new RegExp(
|
|
50349
|
+
path21 === "*" ? "" : `^${path21.replace(
|
|
50258
50350
|
/\/\*$|([.\\+*[^\]$()])/g,
|
|
50259
50351
|
(_, metaChar) => metaChar ? `\\${metaChar}` : "(?:|/.*)"
|
|
50260
50352
|
)}$`
|
|
@@ -50276,17 +50368,17 @@ function buildMatcherFromPreprocessedRoutes(routes) {
|
|
|
50276
50368
|
);
|
|
50277
50369
|
const staticMap = /* @__PURE__ */ Object.create(null);
|
|
50278
50370
|
for (let i = 0, j = -1, len = routesWithStaticPathFlag.length; i < len; i++) {
|
|
50279
|
-
const [pathErrorCheckOnly,
|
|
50371
|
+
const [pathErrorCheckOnly, path21, handlers] = routesWithStaticPathFlag[i];
|
|
50280
50372
|
if (pathErrorCheckOnly) {
|
|
50281
|
-
staticMap[
|
|
50373
|
+
staticMap[path21] = [handlers.map(([h]) => [h, /* @__PURE__ */ Object.create(null)]), emptyParam];
|
|
50282
50374
|
} else {
|
|
50283
50375
|
j++;
|
|
50284
50376
|
}
|
|
50285
50377
|
let paramAssoc;
|
|
50286
50378
|
try {
|
|
50287
|
-
paramAssoc = trie.insert(
|
|
50379
|
+
paramAssoc = trie.insert(path21, j, pathErrorCheckOnly);
|
|
50288
50380
|
} catch (e) {
|
|
50289
|
-
throw e === PATH_ERROR ? new UnsupportedPathError(
|
|
50381
|
+
throw e === PATH_ERROR ? new UnsupportedPathError(path21) : e;
|
|
50290
50382
|
}
|
|
50291
50383
|
if (pathErrorCheckOnly) {
|
|
50292
50384
|
continue;
|
|
@@ -50320,12 +50412,12 @@ function buildMatcherFromPreprocessedRoutes(routes) {
|
|
|
50320
50412
|
}
|
|
50321
50413
|
return [regexp, handlerMap, staticMap];
|
|
50322
50414
|
}
|
|
50323
|
-
function findMiddleware(middleware,
|
|
50415
|
+
function findMiddleware(middleware, path21) {
|
|
50324
50416
|
if (!middleware) {
|
|
50325
50417
|
return void 0;
|
|
50326
50418
|
}
|
|
50327
50419
|
for (const k of Object.keys(middleware).sort((a, b) => b.length - a.length)) {
|
|
50328
|
-
if (buildWildcardRegExp(k).test(
|
|
50420
|
+
if (buildWildcardRegExp(k).test(path21)) {
|
|
50329
50421
|
return [...middleware[k]];
|
|
50330
50422
|
}
|
|
50331
50423
|
}
|
|
@@ -50339,7 +50431,7 @@ var RegExpRouter = class {
|
|
|
50339
50431
|
this.#middleware = { [METHOD_NAME_ALL]: /* @__PURE__ */ Object.create(null) };
|
|
50340
50432
|
this.#routes = { [METHOD_NAME_ALL]: /* @__PURE__ */ Object.create(null) };
|
|
50341
50433
|
}
|
|
50342
|
-
add(method,
|
|
50434
|
+
add(method, path21, handler) {
|
|
50343
50435
|
const middleware = this.#middleware;
|
|
50344
50436
|
const routes = this.#routes;
|
|
50345
50437
|
if (!middleware || !routes) {
|
|
@@ -50354,18 +50446,18 @@ var RegExpRouter = class {
|
|
|
50354
50446
|
});
|
|
50355
50447
|
});
|
|
50356
50448
|
}
|
|
50357
|
-
if (
|
|
50358
|
-
|
|
50449
|
+
if (path21 === "/*") {
|
|
50450
|
+
path21 = "*";
|
|
50359
50451
|
}
|
|
50360
|
-
const paramCount = (
|
|
50361
|
-
if (/\*$/.test(
|
|
50362
|
-
const re = buildWildcardRegExp(
|
|
50452
|
+
const paramCount = (path21.match(/\/:/g) || []).length;
|
|
50453
|
+
if (/\*$/.test(path21)) {
|
|
50454
|
+
const re = buildWildcardRegExp(path21);
|
|
50363
50455
|
if (method === METHOD_NAME_ALL) {
|
|
50364
50456
|
Object.keys(middleware).forEach((m) => {
|
|
50365
|
-
middleware[m][
|
|
50457
|
+
middleware[m][path21] ||= findMiddleware(middleware[m], path21) || findMiddleware(middleware[METHOD_NAME_ALL], path21) || [];
|
|
50366
50458
|
});
|
|
50367
50459
|
} else {
|
|
50368
|
-
middleware[method][
|
|
50460
|
+
middleware[method][path21] ||= findMiddleware(middleware[method], path21) || findMiddleware(middleware[METHOD_NAME_ALL], path21) || [];
|
|
50369
50461
|
}
|
|
50370
50462
|
Object.keys(middleware).forEach((m) => {
|
|
50371
50463
|
if (method === METHOD_NAME_ALL || method === m) {
|
|
@@ -50383,7 +50475,7 @@ var RegExpRouter = class {
|
|
|
50383
50475
|
});
|
|
50384
50476
|
return;
|
|
50385
50477
|
}
|
|
50386
|
-
const paths = checkOptionalParameter(
|
|
50478
|
+
const paths = checkOptionalParameter(path21) || [path21];
|
|
50387
50479
|
for (let i = 0, len = paths.length; i < len; i++) {
|
|
50388
50480
|
const path22 = paths[i];
|
|
50389
50481
|
Object.keys(routes).forEach((m) => {
|
|
@@ -50410,13 +50502,13 @@ var RegExpRouter = class {
|
|
|
50410
50502
|
const routes = [];
|
|
50411
50503
|
let hasOwnRoute = method === METHOD_NAME_ALL;
|
|
50412
50504
|
[this.#middleware, this.#routes].forEach((r) => {
|
|
50413
|
-
const ownRoute = r[method] ? Object.keys(r[method]).map((
|
|
50505
|
+
const ownRoute = r[method] ? Object.keys(r[method]).map((path21) => [path21, r[method][path21]]) : [];
|
|
50414
50506
|
if (ownRoute.length !== 0) {
|
|
50415
50507
|
hasOwnRoute ||= true;
|
|
50416
50508
|
routes.push(...ownRoute);
|
|
50417
50509
|
} else if (method !== METHOD_NAME_ALL) {
|
|
50418
50510
|
routes.push(
|
|
50419
|
-
...Object.keys(r[METHOD_NAME_ALL]).map((
|
|
50511
|
+
...Object.keys(r[METHOD_NAME_ALL]).map((path21) => [path21, r[METHOD_NAME_ALL][path21]])
|
|
50420
50512
|
);
|
|
50421
50513
|
}
|
|
50422
50514
|
});
|
|
@@ -50436,13 +50528,13 @@ var SmartRouter = class {
|
|
|
50436
50528
|
constructor(init) {
|
|
50437
50529
|
this.#routers = init.routers;
|
|
50438
50530
|
}
|
|
50439
|
-
add(method,
|
|
50531
|
+
add(method, path21, handler) {
|
|
50440
50532
|
if (!this.#routes) {
|
|
50441
50533
|
throw new Error(MESSAGE_MATCHER_IS_ALREADY_BUILT);
|
|
50442
50534
|
}
|
|
50443
|
-
this.#routes.push([method,
|
|
50535
|
+
this.#routes.push([method, path21, handler]);
|
|
50444
50536
|
}
|
|
50445
|
-
match(method,
|
|
50537
|
+
match(method, path21) {
|
|
50446
50538
|
if (!this.#routes) {
|
|
50447
50539
|
throw new Error("Fatal error");
|
|
50448
50540
|
}
|
|
@@ -50457,7 +50549,7 @@ var SmartRouter = class {
|
|
|
50457
50549
|
for (let i2 = 0, len2 = routes.length; i2 < len2; i2++) {
|
|
50458
50550
|
router.add(...routes[i2]);
|
|
50459
50551
|
}
|
|
50460
|
-
res = router.match(method,
|
|
50552
|
+
res = router.match(method, path21);
|
|
50461
50553
|
} catch (e) {
|
|
50462
50554
|
if (e instanceof UnsupportedPathError) {
|
|
50463
50555
|
continue;
|
|
@@ -50507,10 +50599,10 @@ var Node2 = class _Node2 {
|
|
|
50507
50599
|
}
|
|
50508
50600
|
this.#patterns = [];
|
|
50509
50601
|
}
|
|
50510
|
-
insert(method,
|
|
50602
|
+
insert(method, path21, handler) {
|
|
50511
50603
|
this.#order = ++this.#order;
|
|
50512
50604
|
let curNode = this;
|
|
50513
|
-
const parts = splitRoutingPath(
|
|
50605
|
+
const parts = splitRoutingPath(path21);
|
|
50514
50606
|
const possibleKeys = [];
|
|
50515
50607
|
for (let i = 0, len = parts.length; i < len; i++) {
|
|
50516
50608
|
const p = parts[i];
|
|
@@ -50559,12 +50651,12 @@ var Node2 = class _Node2 {
|
|
|
50559
50651
|
}
|
|
50560
50652
|
}
|
|
50561
50653
|
}
|
|
50562
|
-
search(method,
|
|
50654
|
+
search(method, path21) {
|
|
50563
50655
|
const handlerSets = [];
|
|
50564
50656
|
this.#params = emptyParams;
|
|
50565
50657
|
const curNode = this;
|
|
50566
50658
|
let curNodes = [curNode];
|
|
50567
|
-
const parts = splitPath(
|
|
50659
|
+
const parts = splitPath(path21);
|
|
50568
50660
|
const curNodesQueue = [];
|
|
50569
50661
|
const len = parts.length;
|
|
50570
50662
|
let partOffsets = null;
|
|
@@ -50606,13 +50698,13 @@ var Node2 = class _Node2 {
|
|
|
50606
50698
|
if (matcher instanceof RegExp) {
|
|
50607
50699
|
if (partOffsets === null) {
|
|
50608
50700
|
partOffsets = new Array(len);
|
|
50609
|
-
let offset =
|
|
50701
|
+
let offset = path21[0] === "/" ? 1 : 0;
|
|
50610
50702
|
for (let p = 0; p < len; p++) {
|
|
50611
50703
|
partOffsets[p] = offset;
|
|
50612
50704
|
offset += parts[p].length + 1;
|
|
50613
50705
|
}
|
|
50614
50706
|
}
|
|
50615
|
-
const restPathString =
|
|
50707
|
+
const restPathString = path21.substring(partOffsets[i]);
|
|
50616
50708
|
const m = matcher.exec(restPathString);
|
|
50617
50709
|
if (m) {
|
|
50618
50710
|
params[name] = m[0];
|
|
@@ -50665,18 +50757,18 @@ var TrieRouter = class {
|
|
|
50665
50757
|
constructor() {
|
|
50666
50758
|
this.#node = new Node2();
|
|
50667
50759
|
}
|
|
50668
|
-
add(method,
|
|
50669
|
-
const results = checkOptionalParameter(
|
|
50760
|
+
add(method, path21, handler) {
|
|
50761
|
+
const results = checkOptionalParameter(path21);
|
|
50670
50762
|
if (results) {
|
|
50671
50763
|
for (let i = 0, len = results.length; i < len; i++) {
|
|
50672
50764
|
this.#node.insert(method, results[i], handler);
|
|
50673
50765
|
}
|
|
50674
50766
|
return;
|
|
50675
50767
|
}
|
|
50676
|
-
this.#node.insert(method,
|
|
50768
|
+
this.#node.insert(method, path21, handler);
|
|
50677
50769
|
}
|
|
50678
|
-
match(method,
|
|
50679
|
-
return this.#node.search(method,
|
|
50770
|
+
match(method, path21) {
|
|
50771
|
+
return this.#node.search(method, path21);
|
|
50680
50772
|
}
|
|
50681
50773
|
};
|
|
50682
50774
|
|
|
@@ -51378,10 +51470,10 @@ var createStreamBody = (stream) => {
|
|
|
51378
51470
|
});
|
|
51379
51471
|
return body;
|
|
51380
51472
|
};
|
|
51381
|
-
var getStats = (
|
|
51473
|
+
var getStats = (path21) => {
|
|
51382
51474
|
let stats;
|
|
51383
51475
|
try {
|
|
51384
|
-
stats = (0, import_fs15.statSync)(
|
|
51476
|
+
stats = (0, import_fs15.statSync)(path21);
|
|
51385
51477
|
} catch {
|
|
51386
51478
|
}
|
|
51387
51479
|
return stats;
|
|
@@ -51424,21 +51516,21 @@ var serveStatic = (options = { root: "" }) => {
|
|
|
51424
51516
|
return next();
|
|
51425
51517
|
}
|
|
51426
51518
|
}
|
|
51427
|
-
let
|
|
51519
|
+
let path21 = (0, import_path19.join)(
|
|
51428
51520
|
root,
|
|
51429
51521
|
!optionPath && options.rewriteRequestPath ? options.rewriteRequestPath(filename, c) : filename
|
|
51430
51522
|
);
|
|
51431
|
-
let stats = getStats(
|
|
51523
|
+
let stats = getStats(path21);
|
|
51432
51524
|
if (stats && stats.isDirectory()) {
|
|
51433
51525
|
const indexFile = options.index ?? "index.html";
|
|
51434
|
-
|
|
51435
|
-
stats = getStats(
|
|
51526
|
+
path21 = (0, import_path19.join)(path21, indexFile);
|
|
51527
|
+
stats = getStats(path21);
|
|
51436
51528
|
}
|
|
51437
51529
|
if (!stats) {
|
|
51438
|
-
await options.onNotFound?.(
|
|
51530
|
+
await options.onNotFound?.(path21, c);
|
|
51439
51531
|
return next();
|
|
51440
51532
|
}
|
|
51441
|
-
const mimeType = getMimeType(
|
|
51533
|
+
const mimeType = getMimeType(path21);
|
|
51442
51534
|
c.header("Content-Type", mimeType || "application/octet-stream");
|
|
51443
51535
|
if (options.precompressed && (!mimeType || COMPRESSIBLE_CONTENT_TYPE_REGEX.test(mimeType))) {
|
|
51444
51536
|
const acceptEncodingSet = new Set(
|
|
@@ -51448,12 +51540,12 @@ var serveStatic = (options = { root: "" }) => {
|
|
|
51448
51540
|
if (!acceptEncodingSet.has(encoding)) {
|
|
51449
51541
|
continue;
|
|
51450
51542
|
}
|
|
51451
|
-
const precompressedStats = getStats(
|
|
51543
|
+
const precompressedStats = getStats(path21 + ENCODINGS[encoding]);
|
|
51452
51544
|
if (precompressedStats) {
|
|
51453
51545
|
c.header("Content-Encoding", encoding);
|
|
51454
51546
|
c.header("Vary", "Accept-Encoding", { append: true });
|
|
51455
51547
|
stats = precompressedStats;
|
|
51456
|
-
|
|
51548
|
+
path21 = path21 + ENCODINGS[encoding];
|
|
51457
51549
|
break;
|
|
51458
51550
|
}
|
|
51459
51551
|
}
|
|
@@ -51467,7 +51559,7 @@ var serveStatic = (options = { root: "" }) => {
|
|
|
51467
51559
|
result = c.body(null);
|
|
51468
51560
|
} else if (!range) {
|
|
51469
51561
|
c.header("Content-Length", size.toString());
|
|
51470
|
-
result = c.body(createStreamBody((0, import_fs15.createReadStream)(
|
|
51562
|
+
result = c.body(createStreamBody((0, import_fs15.createReadStream)(path21)), 200);
|
|
51471
51563
|
} else {
|
|
51472
51564
|
c.header("Accept-Ranges", "bytes");
|
|
51473
51565
|
c.header("Date", stats.birthtime.toUTCString());
|
|
@@ -51478,12 +51570,12 @@ var serveStatic = (options = { root: "" }) => {
|
|
|
51478
51570
|
end = size - 1;
|
|
51479
51571
|
}
|
|
51480
51572
|
const chunksize = end - start + 1;
|
|
51481
|
-
const stream = (0, import_fs15.createReadStream)(
|
|
51573
|
+
const stream = (0, import_fs15.createReadStream)(path21, { start, end });
|
|
51482
51574
|
c.header("Content-Length", chunksize.toString());
|
|
51483
51575
|
c.header("Content-Range", `bytes ${start}-${end}/${stats.size}`);
|
|
51484
51576
|
result = c.body(createStreamBody(stream), 206);
|
|
51485
51577
|
}
|
|
51486
|
-
await options.onFound?.(
|
|
51578
|
+
await options.onFound?.(path21, c);
|
|
51487
51579
|
return result;
|
|
51488
51580
|
};
|
|
51489
51581
|
};
|
|
@@ -51578,7 +51670,7 @@ var cors = (options) => {
|
|
|
51578
51670
|
|
|
51579
51671
|
// src/server/index.ts
|
|
51580
51672
|
var import_promises13 = require("node:fs/promises");
|
|
51581
|
-
var
|
|
51673
|
+
var import_node_path18 = __toESM(require("node:path"));
|
|
51582
51674
|
|
|
51583
51675
|
// src/git/worktree.ts
|
|
51584
51676
|
var import_child_process2 = require("child_process");
|
|
@@ -53483,7 +53575,25 @@ ${item.dreamContent}` : item.dreamContent).join("\n\n");
|
|
|
53483
53575
|
});
|
|
53484
53576
|
|
|
53485
53577
|
// src/server/routes/tools.ts
|
|
53578
|
+
var import_node_path16 = __toESM(require("node:path"));
|
|
53486
53579
|
var toolRoutes = new Hono2();
|
|
53580
|
+
var listActiveDepartmentSkills = () => {
|
|
53581
|
+
return listDepartments().flatMap(
|
|
53582
|
+
(department) => listDepartmentSkills(department.name).filter((skill) => skill.status === "active").map((skill) => ({
|
|
53583
|
+
name: skill.skillName,
|
|
53584
|
+
description: skill.description,
|
|
53585
|
+
deletable: false,
|
|
53586
|
+
scope: "department",
|
|
53587
|
+
departmentName: department.name,
|
|
53588
|
+
detail: () => {
|
|
53589
|
+
const skillDir = import_node_path16.default.join(getDepartmentWorkSpaceDir(department.name), "skills", skill.skillName);
|
|
53590
|
+
return `Base directory for this skill: ${skillDir}
|
|
53591
|
+
|
|
53592
|
+
${skill.skillMd}`;
|
|
53593
|
+
}
|
|
53594
|
+
}))
|
|
53595
|
+
);
|
|
53596
|
+
};
|
|
53487
53597
|
toolRoutes.get("/tools", (c) => {
|
|
53488
53598
|
try {
|
|
53489
53599
|
const { registry: registry2 } = createDefaultTools();
|
|
@@ -53500,14 +53610,40 @@ toolRoutes.get("/tools", (c) => {
|
|
|
53500
53610
|
toolRoutes.get("/skills", (c) => {
|
|
53501
53611
|
try {
|
|
53502
53612
|
const skills = SkillRegistry_default();
|
|
53503
|
-
|
|
53613
|
+
const departmentSkills = listActiveDepartmentSkills();
|
|
53614
|
+
return c.json([...skills.map((s) => ({
|
|
53615
|
+
name: s.name,
|
|
53616
|
+
description: s.description,
|
|
53617
|
+
deletable: !!s.deletable,
|
|
53618
|
+
scope: s.scope ?? (s.deletable ? "project" : "global"),
|
|
53619
|
+
departmentName: s.departmentName
|
|
53620
|
+
})), ...departmentSkills.map((s) => ({
|
|
53621
|
+
name: s.name,
|
|
53622
|
+
description: s.description,
|
|
53623
|
+
deletable: s.deletable,
|
|
53624
|
+
scope: s.scope,
|
|
53625
|
+
departmentName: s.departmentName
|
|
53626
|
+
}))]);
|
|
53504
53627
|
} catch (err) {
|
|
53505
53628
|
return c.json({ error: err.message || "Failed to list skills" }, 500);
|
|
53506
53629
|
}
|
|
53507
53630
|
});
|
|
53508
53631
|
toolRoutes.get("/skills/:name", (c) => {
|
|
53509
53632
|
const name = c.req.param("name");
|
|
53633
|
+
const departmentName = c.req.query("departmentName");
|
|
53510
53634
|
try {
|
|
53635
|
+
if (departmentName) {
|
|
53636
|
+
const skill2 = listActiveDepartmentSkills().find((s) => s.name === name && s.departmentName === departmentName);
|
|
53637
|
+
if (!skill2) return c.json({ error: "Skill not found" }, 404);
|
|
53638
|
+
return c.json({
|
|
53639
|
+
name: skill2.name,
|
|
53640
|
+
description: skill2.description,
|
|
53641
|
+
deletable: skill2.deletable,
|
|
53642
|
+
scope: skill2.scope,
|
|
53643
|
+
departmentName: skill2.departmentName,
|
|
53644
|
+
detail: skill2.detail()
|
|
53645
|
+
});
|
|
53646
|
+
}
|
|
53511
53647
|
const skills = SkillRegistry_default();
|
|
53512
53648
|
const skill = skills.find((s) => s.name === name);
|
|
53513
53649
|
if (!skill) return c.json({ error: "Skill not found" }, 404);
|
|
@@ -53515,6 +53651,8 @@ toolRoutes.get("/skills/:name", (c) => {
|
|
|
53515
53651
|
name: skill.name,
|
|
53516
53652
|
description: skill.description,
|
|
53517
53653
|
deletable: !!skill.deletable,
|
|
53654
|
+
scope: skill.scope ?? (skill.deletable ? "project" : "global"),
|
|
53655
|
+
departmentName: skill.departmentName,
|
|
53518
53656
|
detail: skill.getDetail()
|
|
53519
53657
|
});
|
|
53520
53658
|
} catch (err) {
|
|
@@ -53537,7 +53675,7 @@ var systemRoutes = new Hono2();
|
|
|
53537
53675
|
var startTime = Date.now();
|
|
53538
53676
|
systemRoutes.get("/system/info", (c) => {
|
|
53539
53677
|
return c.json({
|
|
53540
|
-
version: true ? "1.9.
|
|
53678
|
+
version: true ? "1.9.10" : "unknown",
|
|
53541
53679
|
uptime: Math.floor((Date.now() - startTime) / 1e3),
|
|
53542
53680
|
env: process.env.NODE_ENV || "development",
|
|
53543
53681
|
nodeVersion: process.version
|
|
@@ -53547,7 +53685,7 @@ systemRoutes.get("/system/info", (c) => {
|
|
|
53547
53685
|
// src/server/routes/mobile.ts
|
|
53548
53686
|
var import_node_crypto16 = require("node:crypto");
|
|
53549
53687
|
var import_promises12 = require("node:fs/promises");
|
|
53550
|
-
var
|
|
53688
|
+
var import_node_path17 = __toESM(require("node:path"));
|
|
53551
53689
|
var mobileRoutes = new Hono2();
|
|
53552
53690
|
var resolveMobileUserId = (body, headerUserId) => {
|
|
53553
53691
|
return body.userId?.trim() || headerUserId?.trim() || "ios:local-user";
|
|
@@ -53589,12 +53727,12 @@ ${goal.tasks.map((task) => `- [${task.status}] ${task.subject}`).join("\n")}` :
|
|
|
53589
53727
|
return lines.join("\n");
|
|
53590
53728
|
};
|
|
53591
53729
|
var sanitizeFileName = (fileName) => {
|
|
53592
|
-
const cleaned =
|
|
53730
|
+
const cleaned = import_node_path17.default.basename(fileName).replace(/[^\w.\-()\u4e00-\u9fa5 ]+/g, "_").trim();
|
|
53593
53731
|
return cleaned || `attachment-${Date.now()}`;
|
|
53594
53732
|
};
|
|
53595
53733
|
var inferAttachmentType2 = (mimeType = "", fileName = "") => {
|
|
53596
53734
|
if (mimeType.startsWith("image/")) return "image";
|
|
53597
|
-
const ext =
|
|
53735
|
+
const ext = import_node_path17.default.extname(fileName).toLowerCase();
|
|
53598
53736
|
if ([".png", ".jpg", ".jpeg", ".gif", ".webp"].includes(ext)) return "image";
|
|
53599
53737
|
return "file";
|
|
53600
53738
|
};
|
|
@@ -53651,9 +53789,9 @@ mobileRoutes.post("/mobile/attachments", async (c) => {
|
|
|
53651
53789
|
const type = inferAttachmentType2(mimeType, fileName);
|
|
53652
53790
|
const attachmentId = (0, import_node_crypto16.randomUUID)();
|
|
53653
53791
|
const buffer = Buffer.from(dataBase64, "base64");
|
|
53654
|
-
const dir =
|
|
53792
|
+
const dir = import_node_path17.default.join(getDuclawWorkspaceDir(), mobileUserId, "mobile", type === "image" ? "images" : "files");
|
|
53655
53793
|
await (0, import_promises12.mkdir)(dir, { recursive: true });
|
|
53656
|
-
const localPath =
|
|
53794
|
+
const localPath = import_node_path17.default.join(dir, `${attachmentId}-${fileName}`);
|
|
53657
53795
|
await (0, import_promises12.writeFile)(localPath, buffer);
|
|
53658
53796
|
const attachment = saveMobileAttachment({
|
|
53659
53797
|
id: attachmentId,
|
|
@@ -53872,7 +54010,7 @@ function createServer() {
|
|
|
53872
54010
|
app.route("/api", mobileRoutes);
|
|
53873
54011
|
app.use("/*", serveStatic({ root: webDistRoot }));
|
|
53874
54012
|
app.get("/*", async (c) => {
|
|
53875
|
-
const indexHtml = await (0, import_promises13.readFile)(
|
|
54013
|
+
const indexHtml = await (0, import_promises13.readFile)(import_node_path18.default.join(webDistRoot, "index.html"), "utf8");
|
|
53876
54014
|
const tenantId = c.req.header("x-tenant-id");
|
|
53877
54015
|
const assetBase = tenantId ? `/t/${tenantId}` : "";
|
|
53878
54016
|
const html = indexHtml.replaceAll('"./', `"${assetBase}/`);
|
|
@@ -53902,7 +54040,7 @@ function shouldStartCoreChannelGateways(env = process.env) {
|
|
|
53902
54040
|
var import_node_fs9 = require("node:fs");
|
|
53903
54041
|
var import_promises14 = require("node:fs/promises");
|
|
53904
54042
|
var import_node_os3 = require("node:os");
|
|
53905
|
-
var
|
|
54043
|
+
var import_node_path19 = __toESM(require("node:path"));
|
|
53906
54044
|
var MAX_CONTEXT_ASSETS = Number(process.env.DUCLAW_SAAS_ASSET_CONTEXT_LIMIT ?? 1e3);
|
|
53907
54045
|
var MAX_SKILL_ASSETS = Number(process.env.DUCLAW_SAAS_ASSET_SKILL_LIMIT ?? 200);
|
|
53908
54046
|
async function restoreSaasRuntimeAssets(reason) {
|
|
@@ -53933,7 +54071,7 @@ async function restoreContextAsset(context, overwrite) {
|
|
|
53933
54071
|
const target = contextPathForSourceKey(context.sourceKey);
|
|
53934
54072
|
if (!target) return false;
|
|
53935
54073
|
if (!overwrite && (0, import_node_fs9.existsSync)(target)) return false;
|
|
53936
|
-
await (0, import_promises14.mkdir)(
|
|
54074
|
+
await (0, import_promises14.mkdir)(import_node_path19.default.dirname(target), { recursive: true });
|
|
53937
54075
|
await (0, import_promises14.writeFile)(target, JSON.stringify(context.payload), "utf8");
|
|
53938
54076
|
return true;
|
|
53939
54077
|
}
|
|
@@ -53942,7 +54080,7 @@ async function restoreSkillAsset(skill, overwrite) {
|
|
|
53942
54080
|
const target = safeSkillTargetPath(skill.sourcePath, skill.skillName);
|
|
53943
54081
|
if (!target) return false;
|
|
53944
54082
|
if (!overwrite && (0, import_node_fs9.existsSync)(target)) return false;
|
|
53945
|
-
await (0, import_promises14.mkdir)(
|
|
54083
|
+
await (0, import_promises14.mkdir)(import_node_path19.default.dirname(target), { recursive: true });
|
|
53946
54084
|
await (0, import_promises14.writeFile)(target, skill.skillMd, "utf8");
|
|
53947
54085
|
return true;
|
|
53948
54086
|
}
|
|
@@ -53975,30 +54113,30 @@ function runtimeAssetClient() {
|
|
|
53975
54113
|
function contextPathForSourceKey(sourceKey) {
|
|
53976
54114
|
if (sourceKey.startsWith("agent:")) {
|
|
53977
54115
|
const logicalKey = sourceKey.slice("agent:".length);
|
|
53978
|
-
return
|
|
54116
|
+
return import_node_path19.default.join(getDuclawDataDir(), "kv", "agent", `${Buffer.from(logicalKey).toString("base64url")}.json`);
|
|
53979
54117
|
}
|
|
53980
54118
|
if (sourceKey.startsWith("goal-context:")) {
|
|
53981
|
-
return
|
|
54119
|
+
return import_node_path19.default.join(getDuclawHomeDir(), "goal-context", `${sourceKey.slice("goal-context:".length)}.json`);
|
|
53982
54120
|
}
|
|
53983
54121
|
if (sourceKey.startsWith("tasks:")) {
|
|
53984
|
-
return
|
|
54122
|
+
return import_node_path19.default.join(getDuclawHomeDir(), "tasks", `${sourceKey.slice("tasks:".length)}.json`);
|
|
53985
54123
|
}
|
|
53986
54124
|
return null;
|
|
53987
54125
|
}
|
|
53988
54126
|
function safeSkillTargetPath(sourcePath, skillName) {
|
|
53989
|
-
const allowedRoots = skillRoots().map((root) =>
|
|
53990
|
-
const normalized =
|
|
53991
|
-
if (allowedRoots.some((root) => normalized ===
|
|
54127
|
+
const allowedRoots = skillRoots().map((root) => import_node_path19.default.resolve(root));
|
|
54128
|
+
const normalized = import_node_path19.default.resolve(sourcePath);
|
|
54129
|
+
if (allowedRoots.some((root) => normalized === import_node_path19.default.join(root, import_node_path19.default.basename(import_node_path19.default.dirname(normalized)), "SKILL.md"))) {
|
|
53992
54130
|
return normalized;
|
|
53993
54131
|
}
|
|
53994
54132
|
const safeName = skillName.replace(/[^a-zA-Z0-9._-]/g, "-").slice(0, 120) || "imported-skill";
|
|
53995
|
-
return
|
|
54133
|
+
return import_node_path19.default.join("/home/user/app/skills", safeName, "SKILL.md");
|
|
53996
54134
|
}
|
|
53997
54135
|
function skillRoots() {
|
|
53998
54136
|
return [
|
|
53999
54137
|
"/home/user/app/skills",
|
|
54000
|
-
|
|
54001
|
-
|
|
54138
|
+
import_node_path19.default.join(getDuclawHomeDir(), "skills"),
|
|
54139
|
+
import_node_path19.default.join((0, import_node_os3.homedir)(), ".agents", "skills")
|
|
54002
54140
|
];
|
|
54003
54141
|
}
|
|
54004
54142
|
|