duclaw-cli 1.9.1 → 1.9.2
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 +552 -428
- package/dist/main.js +1 -1
- package/dist/worker-main.js +1 -1
- package/package.json +1 -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.2" : "unknown"}`);
|
|
30246
30246
|
}
|
|
30247
30247
|
function getDuclawTemplate() {
|
|
30248
30248
|
return {
|
|
@@ -30757,6 +30757,10 @@ var feishuChannelPlugin = {
|
|
|
30757
30757
|
}
|
|
30758
30758
|
};
|
|
30759
30759
|
|
|
30760
|
+
// src/channels/mobile/mobileChannelPlugin.ts
|
|
30761
|
+
var import_promises2 = require("node:fs/promises");
|
|
30762
|
+
var import_node_path3 = __toESM(require("node:path"));
|
|
30763
|
+
|
|
30760
30764
|
// src/mobile/mobileStore.ts
|
|
30761
30765
|
var import_node_crypto = require("node:crypto");
|
|
30762
30766
|
|
|
@@ -31202,6 +31206,92 @@ var getMobileRun = (threadId) => {
|
|
|
31202
31206
|
};
|
|
31203
31207
|
|
|
31204
31208
|
// src/channels/mobile/mobileChannelPlugin.ts
|
|
31209
|
+
var inferMimeType = (fileName = "") => {
|
|
31210
|
+
const ext = import_node_path3.default.extname(fileName).toLowerCase();
|
|
31211
|
+
if (ext === ".png") return "image/png";
|
|
31212
|
+
if (ext === ".jpg" || ext === ".jpeg") return "image/jpeg";
|
|
31213
|
+
if (ext === ".gif") return "image/gif";
|
|
31214
|
+
if (ext === ".webp") return "image/webp";
|
|
31215
|
+
if (ext === ".pdf") return "application/pdf";
|
|
31216
|
+
return "application/octet-stream";
|
|
31217
|
+
};
|
|
31218
|
+
var inferAttachmentType = (mimeType = "", fileName = "") => {
|
|
31219
|
+
if (mimeType.startsWith("image/")) return "image";
|
|
31220
|
+
if (/\.(png|jpe?g|gif|webp)$/i.test(fileName)) return "image";
|
|
31221
|
+
return "file";
|
|
31222
|
+
};
|
|
31223
|
+
var toAbsoluteControlPlaneUrl = (url) => {
|
|
31224
|
+
if (/^https?:\/\//i.test(url)) return url;
|
|
31225
|
+
const baseUrl = process.env.DUCLAW_CONTROL_PLANE_BASE_URL?.replace(/\/$/, "");
|
|
31226
|
+
return baseUrl && url.startsWith("/") ? `${baseUrl}${url}` : url;
|
|
31227
|
+
};
|
|
31228
|
+
async function readOutboundFile(file) {
|
|
31229
|
+
if (typeof file === "string") {
|
|
31230
|
+
if (/^https?:\/\//i.test(file)) return { source: file };
|
|
31231
|
+
const buffer2 = await (0, import_promises2.readFile)(file);
|
|
31232
|
+
return {
|
|
31233
|
+
dataBase64: buffer2.toString("base64"),
|
|
31234
|
+
size: buffer2.length,
|
|
31235
|
+
source: file
|
|
31236
|
+
};
|
|
31237
|
+
}
|
|
31238
|
+
if (Buffer.isBuffer(file)) {
|
|
31239
|
+
return {
|
|
31240
|
+
dataBase64: file.toString("base64"),
|
|
31241
|
+
size: file.length
|
|
31242
|
+
};
|
|
31243
|
+
}
|
|
31244
|
+
const arrayBuffer = await new Response(file).arrayBuffer();
|
|
31245
|
+
const buffer = Buffer.from(arrayBuffer);
|
|
31246
|
+
return {
|
|
31247
|
+
dataBase64: buffer.toString("base64"),
|
|
31248
|
+
size: buffer.length
|
|
31249
|
+
};
|
|
31250
|
+
}
|
|
31251
|
+
async function uploadControlPlaneMobileAttachment(ctx) {
|
|
31252
|
+
const baseUrl = process.env.DUCLAW_CONTROL_PLANE_BASE_URL?.replace(/\/$/, "");
|
|
31253
|
+
const token = process.env.DUCLAW_CONTROL_PLANE_METERING_TOKEN;
|
|
31254
|
+
const tenantId = process.env.DUCLAW_TENANT_ID;
|
|
31255
|
+
const fileName = ctx.fileName || "attachment";
|
|
31256
|
+
const mimeType = inferMimeType(fileName);
|
|
31257
|
+
const fileBody = await readOutboundFile(ctx.file);
|
|
31258
|
+
if (!baseUrl || !token || !tenantId || !fileBody.dataBase64) {
|
|
31259
|
+
const localUrl = fileBody.source && /^https?:\/\//i.test(fileBody.source) ? fileBody.source : void 0;
|
|
31260
|
+
const localSize = fileBody.size ?? (typeof ctx.file === "string" ? await (0, import_promises2.stat)(ctx.file).then((s) => s.size).catch(() => void 0) : void 0);
|
|
31261
|
+
return saveMobileAttachment({
|
|
31262
|
+
type: inferAttachmentType(mimeType, fileName),
|
|
31263
|
+
name: fileName,
|
|
31264
|
+
mimeType,
|
|
31265
|
+
size: localSize,
|
|
31266
|
+
path: typeof ctx.file === "string" && !localUrl ? ctx.file : void 0,
|
|
31267
|
+
url: localUrl
|
|
31268
|
+
});
|
|
31269
|
+
}
|
|
31270
|
+
const response = await fetch(`${baseUrl}/internal/runtime/mobile/attachments`, {
|
|
31271
|
+
method: "POST",
|
|
31272
|
+
signal: AbortSignal.timeout(15e3),
|
|
31273
|
+
headers: {
|
|
31274
|
+
authorization: `Bearer ${token}`,
|
|
31275
|
+
"content-type": "application/json"
|
|
31276
|
+
},
|
|
31277
|
+
body: JSON.stringify({
|
|
31278
|
+
tenantId,
|
|
31279
|
+
fileName,
|
|
31280
|
+
mimeType,
|
|
31281
|
+
dataBase64: fileBody.dataBase64
|
|
31282
|
+
})
|
|
31283
|
+
});
|
|
31284
|
+
if (!response.ok) {
|
|
31285
|
+
console.warn(`[mobile-channel] control-plane \u9644\u4EF6\u4E0A\u4F20\u5931\u8D25: http=${response.status}`);
|
|
31286
|
+
return void 0;
|
|
31287
|
+
}
|
|
31288
|
+
const result = await response.json();
|
|
31289
|
+
if (!result.attachment) return void 0;
|
|
31290
|
+
return {
|
|
31291
|
+
...result.attachment,
|
|
31292
|
+
url: result.attachment.url ? toAbsoluteControlPlaneUrl(result.attachment.url) : result.attachment.url
|
|
31293
|
+
};
|
|
31294
|
+
}
|
|
31205
31295
|
async function postControlPlaneMobileMessage(ctx, threadId) {
|
|
31206
31296
|
const baseUrl = process.env.DUCLAW_CONTROL_PLANE_BASE_URL?.replace(/\/$/, "");
|
|
31207
31297
|
const token = process.env.DUCLAW_CONTROL_PLANE_METERING_TOKEN;
|
|
@@ -31222,8 +31312,10 @@ async function postControlPlaneMobileMessage(ctx, threadId) {
|
|
|
31222
31312
|
role: "assistant",
|
|
31223
31313
|
text: ctx.text,
|
|
31224
31314
|
status: "finished",
|
|
31315
|
+
attachments: ctx.attachments ?? [],
|
|
31225
31316
|
metadata: {
|
|
31226
31317
|
...ctx.metadata ?? {},
|
|
31318
|
+
...ctx.attachments?.length ? { attachments: ctx.attachments } : {},
|
|
31227
31319
|
accountId: ctx.accountId,
|
|
31228
31320
|
source: "mobile-channel"
|
|
31229
31321
|
}
|
|
@@ -31268,6 +31360,38 @@ var mobileChannelPlugin = {
|
|
|
31268
31360
|
lastResult: ctx.text
|
|
31269
31361
|
});
|
|
31270
31362
|
appendMobileRunLog(threadId, `[\u5B8C\u6210] ${ctx.text.slice(0, 500)}`);
|
|
31363
|
+
},
|
|
31364
|
+
sendFile: async (ctx) => {
|
|
31365
|
+
const threadId = ctx.to;
|
|
31366
|
+
const attachment = await uploadControlPlaneMobileAttachment(ctx);
|
|
31367
|
+
const attachments = attachment ? [attachment] : [];
|
|
31368
|
+
const text2 = attachments.length > 0 ? `\u5DF2\u53D1\u9001\u9644\u4EF6\uFF1A${ctx.fileName}` : `\u9644\u4EF6\u53D1\u9001\u5931\u8D25\uFF1A${ctx.fileName}`;
|
|
31369
|
+
const metadata = {
|
|
31370
|
+
accountId: ctx.accountId,
|
|
31371
|
+
source: "mobile-channel",
|
|
31372
|
+
attachments
|
|
31373
|
+
};
|
|
31374
|
+
await postControlPlaneMobileMessage({
|
|
31375
|
+
text: text2,
|
|
31376
|
+
accountId: ctx.accountId,
|
|
31377
|
+
metadata,
|
|
31378
|
+
attachments
|
|
31379
|
+
}, threadId);
|
|
31380
|
+
appendMobileMessage({
|
|
31381
|
+
threadId,
|
|
31382
|
+
userId: threadId,
|
|
31383
|
+
role: "assistant",
|
|
31384
|
+
text: text2,
|
|
31385
|
+
status: attachments.length > 0 ? "finished" : "failed",
|
|
31386
|
+
attachments,
|
|
31387
|
+
metadata
|
|
31388
|
+
});
|
|
31389
|
+
upsertMobileRun(threadId, {
|
|
31390
|
+
userId: threadId,
|
|
31391
|
+
running: false,
|
|
31392
|
+
lastResult: text2
|
|
31393
|
+
});
|
|
31394
|
+
appendMobileRunLog(threadId, `[\u9644\u4EF6] ${text2}`);
|
|
31271
31395
|
}
|
|
31272
31396
|
},
|
|
31273
31397
|
gateway: {
|
|
@@ -31416,12 +31540,12 @@ var generateId = () => {
|
|
|
31416
31540
|
// node_modules/.pnpm/chokidar@5.0.0/node_modules/chokidar/index.js
|
|
31417
31541
|
var import_node_events = require("node:events");
|
|
31418
31542
|
var import_node_fs2 = require("node:fs");
|
|
31419
|
-
var
|
|
31543
|
+
var import_promises5 = require("node:fs/promises");
|
|
31420
31544
|
var sp2 = __toESM(require("node:path"), 1);
|
|
31421
31545
|
|
|
31422
31546
|
// node_modules/.pnpm/readdirp@5.0.0/node_modules/readdirp/index.js
|
|
31423
|
-
var
|
|
31424
|
-
var
|
|
31547
|
+
var import_promises3 = require("node:fs/promises");
|
|
31548
|
+
var import_node_path4 = require("node:path");
|
|
31425
31549
|
var import_node_stream = require("node:stream");
|
|
31426
31550
|
var EntryTypes = {
|
|
31427
31551
|
FILE_TYPE: "files",
|
|
@@ -31501,9 +31625,9 @@ var ReaddirpStream = class extends import_node_stream.Readable {
|
|
|
31501
31625
|
const { root, type } = opts;
|
|
31502
31626
|
this._fileFilter = normalizeFilter(opts.fileFilter);
|
|
31503
31627
|
this._directoryFilter = normalizeFilter(opts.directoryFilter);
|
|
31504
|
-
const statMethod = opts.lstat ?
|
|
31628
|
+
const statMethod = opts.lstat ? import_promises3.lstat : import_promises3.stat;
|
|
31505
31629
|
if (wantBigintFsStats) {
|
|
31506
|
-
this._stat = (
|
|
31630
|
+
this._stat = (path21) => statMethod(path21, { bigint: true });
|
|
31507
31631
|
} else {
|
|
31508
31632
|
this._stat = statMethod;
|
|
31509
31633
|
}
|
|
@@ -31511,7 +31635,7 @@ var ReaddirpStream = class extends import_node_stream.Readable {
|
|
|
31511
31635
|
this._wantsDir = type ? DIR_TYPES.has(type) : false;
|
|
31512
31636
|
this._wantsFile = type ? FILE_TYPES.has(type) : false;
|
|
31513
31637
|
this._wantsEverything = type === EntryTypes.EVERYTHING_TYPE;
|
|
31514
|
-
this._root = (0,
|
|
31638
|
+
this._root = (0, import_node_path4.resolve)(root);
|
|
31515
31639
|
this._isDirent = !opts.alwaysStat;
|
|
31516
31640
|
this._statsProp = this._isDirent ? "dirent" : "stats";
|
|
31517
31641
|
this._rdOptions = { encoding: "utf8", withFileTypes: this._isDirent };
|
|
@@ -31528,8 +31652,8 @@ var ReaddirpStream = class extends import_node_stream.Readable {
|
|
|
31528
31652
|
const par = this.parent;
|
|
31529
31653
|
const fil = par && par.files;
|
|
31530
31654
|
if (fil && fil.length > 0) {
|
|
31531
|
-
const { path:
|
|
31532
|
-
const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent,
|
|
31655
|
+
const { path: path21, depth } = par;
|
|
31656
|
+
const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path21));
|
|
31533
31657
|
const awaited = await Promise.all(slice);
|
|
31534
31658
|
for (const entry of awaited) {
|
|
31535
31659
|
if (!entry)
|
|
@@ -31569,21 +31693,21 @@ var ReaddirpStream = class extends import_node_stream.Readable {
|
|
|
31569
31693
|
this.reading = false;
|
|
31570
31694
|
}
|
|
31571
31695
|
}
|
|
31572
|
-
async _exploreDir(
|
|
31696
|
+
async _exploreDir(path21, depth) {
|
|
31573
31697
|
let files;
|
|
31574
31698
|
try {
|
|
31575
|
-
files = await (0,
|
|
31699
|
+
files = await (0, import_promises3.readdir)(path21, this._rdOptions);
|
|
31576
31700
|
} catch (error) {
|
|
31577
31701
|
this._onError(error);
|
|
31578
31702
|
}
|
|
31579
|
-
return { files, depth, path:
|
|
31703
|
+
return { files, depth, path: path21 };
|
|
31580
31704
|
}
|
|
31581
|
-
async _formatEntry(dirent,
|
|
31705
|
+
async _formatEntry(dirent, path21) {
|
|
31582
31706
|
let entry;
|
|
31583
31707
|
const basename4 = this._isDirent ? dirent.name : dirent;
|
|
31584
31708
|
try {
|
|
31585
|
-
const fullPath = (0,
|
|
31586
|
-
entry = { path: (0,
|
|
31709
|
+
const fullPath = (0, import_node_path4.resolve)((0, import_node_path4.join)(path21, basename4));
|
|
31710
|
+
entry = { path: (0, import_node_path4.relative)(this._root, fullPath), fullPath, basename: basename4 };
|
|
31587
31711
|
entry[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
|
|
31588
31712
|
} catch (err) {
|
|
31589
31713
|
this._onError(err);
|
|
@@ -31610,14 +31734,14 @@ var ReaddirpStream = class extends import_node_stream.Readable {
|
|
|
31610
31734
|
if (stats && stats.isSymbolicLink()) {
|
|
31611
31735
|
const full = entry.fullPath;
|
|
31612
31736
|
try {
|
|
31613
|
-
const entryRealPath = await (0,
|
|
31614
|
-
const entryRealPathStats = await (0,
|
|
31737
|
+
const entryRealPath = await (0, import_promises3.realpath)(full);
|
|
31738
|
+
const entryRealPathStats = await (0, import_promises3.lstat)(entryRealPath);
|
|
31615
31739
|
if (entryRealPathStats.isFile()) {
|
|
31616
31740
|
return "file";
|
|
31617
31741
|
}
|
|
31618
31742
|
if (entryRealPathStats.isDirectory()) {
|
|
31619
31743
|
const len = entryRealPath.length;
|
|
31620
|
-
if (full.startsWith(entryRealPath) && full.substr(len, 1) ===
|
|
31744
|
+
if (full.startsWith(entryRealPath) && full.substr(len, 1) === import_node_path4.sep) {
|
|
31621
31745
|
const recursiveError = new Error(`Circular symlink detected: "${full}" points to "${entryRealPath}"`);
|
|
31622
31746
|
recursiveError.code = RECURSIVE_ERROR_CODE;
|
|
31623
31747
|
return this._onError(recursiveError);
|
|
@@ -31654,7 +31778,7 @@ function readdirp(root, options = {}) {
|
|
|
31654
31778
|
|
|
31655
31779
|
// node_modules/.pnpm/chokidar@5.0.0/node_modules/chokidar/handler.js
|
|
31656
31780
|
var import_node_fs = require("node:fs");
|
|
31657
|
-
var
|
|
31781
|
+
var import_promises4 = require("node:fs/promises");
|
|
31658
31782
|
var import_node_os = require("node:os");
|
|
31659
31783
|
var sp = __toESM(require("node:path"), 1);
|
|
31660
31784
|
var STR_DATA = "data";
|
|
@@ -31681,7 +31805,7 @@ var EVENTS = {
|
|
|
31681
31805
|
};
|
|
31682
31806
|
var EV = EVENTS;
|
|
31683
31807
|
var THROTTLE_MODE_WATCH = "watch";
|
|
31684
|
-
var statMethods = { lstat:
|
|
31808
|
+
var statMethods = { lstat: import_promises4.lstat, stat: import_promises4.stat };
|
|
31685
31809
|
var KEY_LISTENERS = "listeners";
|
|
31686
31810
|
var KEY_ERR = "errHandlers";
|
|
31687
31811
|
var KEY_RAW = "rawEmitters";
|
|
@@ -31982,16 +32106,16 @@ var delFromSet = (main2, prop, item) => {
|
|
|
31982
32106
|
};
|
|
31983
32107
|
var isEmptySet = (val) => val instanceof Set ? val.size === 0 : !val;
|
|
31984
32108
|
var FsWatchInstances = /* @__PURE__ */ new Map();
|
|
31985
|
-
function createFsWatchInstance(
|
|
32109
|
+
function createFsWatchInstance(path21, options, listener, errHandler, emitRaw) {
|
|
31986
32110
|
const handleEvent = (rawEvent, evPath) => {
|
|
31987
|
-
listener(
|
|
31988
|
-
emitRaw(rawEvent, evPath, { watchedPath:
|
|
31989
|
-
if (evPath &&
|
|
31990
|
-
fsWatchBroadcast(sp.resolve(
|
|
32111
|
+
listener(path21);
|
|
32112
|
+
emitRaw(rawEvent, evPath, { watchedPath: path21 });
|
|
32113
|
+
if (evPath && path21 !== evPath) {
|
|
32114
|
+
fsWatchBroadcast(sp.resolve(path21, evPath), KEY_LISTENERS, sp.join(path21, evPath));
|
|
31991
32115
|
}
|
|
31992
32116
|
};
|
|
31993
32117
|
try {
|
|
31994
|
-
return (0, import_node_fs.watch)(
|
|
32118
|
+
return (0, import_node_fs.watch)(path21, {
|
|
31995
32119
|
persistent: options.persistent
|
|
31996
32120
|
}, handleEvent);
|
|
31997
32121
|
} catch (error) {
|
|
@@ -32007,12 +32131,12 @@ var fsWatchBroadcast = (fullPath, listenerType, val1, val2, val3) => {
|
|
|
32007
32131
|
listener(val1, val2, val3);
|
|
32008
32132
|
});
|
|
32009
32133
|
};
|
|
32010
|
-
var setFsWatchListener = (
|
|
32134
|
+
var setFsWatchListener = (path21, fullPath, options, handlers) => {
|
|
32011
32135
|
const { listener, errHandler, rawEmitter } = handlers;
|
|
32012
32136
|
let cont = FsWatchInstances.get(fullPath);
|
|
32013
32137
|
let watcher;
|
|
32014
32138
|
if (!options.persistent) {
|
|
32015
|
-
watcher = createFsWatchInstance(
|
|
32139
|
+
watcher = createFsWatchInstance(path21, options, listener, errHandler, rawEmitter);
|
|
32016
32140
|
if (!watcher)
|
|
32017
32141
|
return;
|
|
32018
32142
|
return watcher.close.bind(watcher);
|
|
@@ -32023,7 +32147,7 @@ var setFsWatchListener = (path20, fullPath, options, handlers) => {
|
|
|
32023
32147
|
addAndConvert(cont, KEY_RAW, rawEmitter);
|
|
32024
32148
|
} else {
|
|
32025
32149
|
watcher = createFsWatchInstance(
|
|
32026
|
-
|
|
32150
|
+
path21,
|
|
32027
32151
|
options,
|
|
32028
32152
|
fsWatchBroadcast.bind(null, fullPath, KEY_LISTENERS),
|
|
32029
32153
|
errHandler,
|
|
@@ -32038,7 +32162,7 @@ var setFsWatchListener = (path20, fullPath, options, handlers) => {
|
|
|
32038
32162
|
cont.watcherUnusable = true;
|
|
32039
32163
|
if (isWindows && error.code === "EPERM") {
|
|
32040
32164
|
try {
|
|
32041
|
-
const fd = await (0,
|
|
32165
|
+
const fd = await (0, import_promises4.open)(path21, "r");
|
|
32042
32166
|
await fd.close();
|
|
32043
32167
|
broadcastErr(error);
|
|
32044
32168
|
} catch (err) {
|
|
@@ -32069,7 +32193,7 @@ var setFsWatchListener = (path20, fullPath, options, handlers) => {
|
|
|
32069
32193
|
};
|
|
32070
32194
|
};
|
|
32071
32195
|
var FsWatchFileInstances = /* @__PURE__ */ new Map();
|
|
32072
|
-
var setFsWatchFileListener = (
|
|
32196
|
+
var setFsWatchFileListener = (path21, fullPath, options, handlers) => {
|
|
32073
32197
|
const { listener, rawEmitter } = handlers;
|
|
32074
32198
|
let cont = FsWatchFileInstances.get(fullPath);
|
|
32075
32199
|
const copts = cont && cont.options;
|
|
@@ -32091,7 +32215,7 @@ var setFsWatchFileListener = (path20, fullPath, options, handlers) => {
|
|
|
32091
32215
|
});
|
|
32092
32216
|
const currmtime = curr.mtimeMs;
|
|
32093
32217
|
if (curr.size !== prev.size || currmtime > prev.mtimeMs || currmtime === 0) {
|
|
32094
|
-
foreach(cont.listeners, (listener2) => listener2(
|
|
32218
|
+
foreach(cont.listeners, (listener2) => listener2(path21, curr));
|
|
32095
32219
|
}
|
|
32096
32220
|
})
|
|
32097
32221
|
};
|
|
@@ -32121,13 +32245,13 @@ var NodeFsHandler = class {
|
|
|
32121
32245
|
* @param listener on fs change
|
|
32122
32246
|
* @returns closer for the watcher instance
|
|
32123
32247
|
*/
|
|
32124
|
-
_watchWithNodeFs(
|
|
32248
|
+
_watchWithNodeFs(path21, listener) {
|
|
32125
32249
|
const opts = this.fsw.options;
|
|
32126
|
-
const directory = sp.dirname(
|
|
32127
|
-
const basename4 = sp.basename(
|
|
32250
|
+
const directory = sp.dirname(path21);
|
|
32251
|
+
const basename4 = sp.basename(path21);
|
|
32128
32252
|
const parent = this.fsw._getWatchedDir(directory);
|
|
32129
32253
|
parent.add(basename4);
|
|
32130
|
-
const absolutePath = sp.resolve(
|
|
32254
|
+
const absolutePath = sp.resolve(path21);
|
|
32131
32255
|
const options = {
|
|
32132
32256
|
persistent: opts.persistent
|
|
32133
32257
|
};
|
|
@@ -32137,12 +32261,12 @@ var NodeFsHandler = class {
|
|
|
32137
32261
|
if (opts.usePolling) {
|
|
32138
32262
|
const enableBin = opts.interval !== opts.binaryInterval;
|
|
32139
32263
|
options.interval = enableBin && isBinaryPath(basename4) ? opts.binaryInterval : opts.interval;
|
|
32140
|
-
closer = setFsWatchFileListener(
|
|
32264
|
+
closer = setFsWatchFileListener(path21, absolutePath, options, {
|
|
32141
32265
|
listener,
|
|
32142
32266
|
rawEmitter: this.fsw._emitRaw
|
|
32143
32267
|
});
|
|
32144
32268
|
} else {
|
|
32145
|
-
closer = setFsWatchListener(
|
|
32269
|
+
closer = setFsWatchListener(path21, absolutePath, options, {
|
|
32146
32270
|
listener,
|
|
32147
32271
|
errHandler: this._boundHandleError,
|
|
32148
32272
|
rawEmitter: this.fsw._emitRaw
|
|
@@ -32164,12 +32288,12 @@ var NodeFsHandler = class {
|
|
|
32164
32288
|
let prevStats = stats;
|
|
32165
32289
|
if (parent.has(basename4))
|
|
32166
32290
|
return;
|
|
32167
|
-
const listener = async (
|
|
32291
|
+
const listener = async (path21, newStats) => {
|
|
32168
32292
|
if (!this.fsw._throttle(THROTTLE_MODE_WATCH, file, 5))
|
|
32169
32293
|
return;
|
|
32170
32294
|
if (!newStats || newStats.mtimeMs === 0) {
|
|
32171
32295
|
try {
|
|
32172
|
-
const newStats2 = await (0,
|
|
32296
|
+
const newStats2 = await (0, import_promises4.stat)(file);
|
|
32173
32297
|
if (this.fsw.closed)
|
|
32174
32298
|
return;
|
|
32175
32299
|
const at = newStats2.atimeMs;
|
|
@@ -32178,11 +32302,11 @@ var NodeFsHandler = class {
|
|
|
32178
32302
|
this.fsw._emit(EV.CHANGE, file, newStats2);
|
|
32179
32303
|
}
|
|
32180
32304
|
if ((isMacos || isLinux || isFreeBSD) && prevStats.ino !== newStats2.ino) {
|
|
32181
|
-
this.fsw._closeFile(
|
|
32305
|
+
this.fsw._closeFile(path21);
|
|
32182
32306
|
prevStats = newStats2;
|
|
32183
32307
|
const closer2 = this._watchWithNodeFs(file, listener);
|
|
32184
32308
|
if (closer2)
|
|
32185
|
-
this.fsw._addPathCloser(
|
|
32309
|
+
this.fsw._addPathCloser(path21, closer2);
|
|
32186
32310
|
} else {
|
|
32187
32311
|
prevStats = newStats2;
|
|
32188
32312
|
}
|
|
@@ -32214,7 +32338,7 @@ var NodeFsHandler = class {
|
|
|
32214
32338
|
* @param item basename of this item
|
|
32215
32339
|
* @returns true if no more processing is needed for this entry.
|
|
32216
32340
|
*/
|
|
32217
|
-
async _handleSymlink(entry, directory,
|
|
32341
|
+
async _handleSymlink(entry, directory, path21, item) {
|
|
32218
32342
|
if (this.fsw.closed) {
|
|
32219
32343
|
return;
|
|
32220
32344
|
}
|
|
@@ -32224,7 +32348,7 @@ var NodeFsHandler = class {
|
|
|
32224
32348
|
this.fsw._incrReadyCount();
|
|
32225
32349
|
let linkPath;
|
|
32226
32350
|
try {
|
|
32227
|
-
linkPath = await (0,
|
|
32351
|
+
linkPath = await (0, import_promises4.realpath)(path21);
|
|
32228
32352
|
} catch (e) {
|
|
32229
32353
|
this.fsw._emitReady();
|
|
32230
32354
|
return true;
|
|
@@ -32234,12 +32358,12 @@ var NodeFsHandler = class {
|
|
|
32234
32358
|
if (dir.has(item)) {
|
|
32235
32359
|
if (this.fsw._symlinkPaths.get(full) !== linkPath) {
|
|
32236
32360
|
this.fsw._symlinkPaths.set(full, linkPath);
|
|
32237
|
-
this.fsw._emit(EV.CHANGE,
|
|
32361
|
+
this.fsw._emit(EV.CHANGE, path21, entry.stats);
|
|
32238
32362
|
}
|
|
32239
32363
|
} else {
|
|
32240
32364
|
dir.add(item);
|
|
32241
32365
|
this.fsw._symlinkPaths.set(full, linkPath);
|
|
32242
|
-
this.fsw._emit(EV.ADD,
|
|
32366
|
+
this.fsw._emit(EV.ADD, path21, entry.stats);
|
|
32243
32367
|
}
|
|
32244
32368
|
this.fsw._emitReady();
|
|
32245
32369
|
return true;
|
|
@@ -32269,9 +32393,9 @@ var NodeFsHandler = class {
|
|
|
32269
32393
|
return;
|
|
32270
32394
|
}
|
|
32271
32395
|
const item = entry.path;
|
|
32272
|
-
let
|
|
32396
|
+
let path21 = sp.join(directory, item);
|
|
32273
32397
|
current.add(item);
|
|
32274
|
-
if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory,
|
|
32398
|
+
if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path21, item)) {
|
|
32275
32399
|
return;
|
|
32276
32400
|
}
|
|
32277
32401
|
if (this.fsw.closed) {
|
|
@@ -32280,8 +32404,8 @@ var NodeFsHandler = class {
|
|
|
32280
32404
|
}
|
|
32281
32405
|
if (item === target || !target && !previous.has(item)) {
|
|
32282
32406
|
this.fsw._incrReadyCount();
|
|
32283
|
-
|
|
32284
|
-
this._addToNodeFs(
|
|
32407
|
+
path21 = sp.join(dir, sp.relative(dir, path21));
|
|
32408
|
+
this._addToNodeFs(path21, initialAdd, wh, depth + 1);
|
|
32285
32409
|
}
|
|
32286
32410
|
}).on(EV.ERROR, this._boundHandleError);
|
|
32287
32411
|
return new Promise((resolve11, reject) => {
|
|
@@ -32350,13 +32474,13 @@ var NodeFsHandler = class {
|
|
|
32350
32474
|
* @param depth Child path actually targeted for watch
|
|
32351
32475
|
* @param target Child path actually targeted for watch
|
|
32352
32476
|
*/
|
|
32353
|
-
async _addToNodeFs(
|
|
32477
|
+
async _addToNodeFs(path21, initialAdd, priorWh, depth, target) {
|
|
32354
32478
|
const ready = this.fsw._emitReady;
|
|
32355
|
-
if (this.fsw._isIgnored(
|
|
32479
|
+
if (this.fsw._isIgnored(path21) || this.fsw.closed) {
|
|
32356
32480
|
ready();
|
|
32357
32481
|
return false;
|
|
32358
32482
|
}
|
|
32359
|
-
const wh = this.fsw._getWatchHelpers(
|
|
32483
|
+
const wh = this.fsw._getWatchHelpers(path21);
|
|
32360
32484
|
if (priorWh) {
|
|
32361
32485
|
wh.filterPath = (entry) => priorWh.filterPath(entry);
|
|
32362
32486
|
wh.filterDir = (entry) => priorWh.filterDir(entry);
|
|
@@ -32372,8 +32496,8 @@ var NodeFsHandler = class {
|
|
|
32372
32496
|
const follow = this.fsw.options.followSymlinks;
|
|
32373
32497
|
let closer;
|
|
32374
32498
|
if (stats.isDirectory()) {
|
|
32375
|
-
const absPath = sp.resolve(
|
|
32376
|
-
const targetPath = follow ? await (0,
|
|
32499
|
+
const absPath = sp.resolve(path21);
|
|
32500
|
+
const targetPath = follow ? await (0, import_promises4.realpath)(path21) : path21;
|
|
32377
32501
|
if (this.fsw.closed)
|
|
32378
32502
|
return;
|
|
32379
32503
|
closer = await this._handleDir(wh.watchPath, stats, initialAdd, depth, target, wh, targetPath);
|
|
@@ -32383,29 +32507,29 @@ var NodeFsHandler = class {
|
|
|
32383
32507
|
this.fsw._symlinkPaths.set(absPath, targetPath);
|
|
32384
32508
|
}
|
|
32385
32509
|
} else if (stats.isSymbolicLink()) {
|
|
32386
|
-
const targetPath = follow ? await (0,
|
|
32510
|
+
const targetPath = follow ? await (0, import_promises4.realpath)(path21) : path21;
|
|
32387
32511
|
if (this.fsw.closed)
|
|
32388
32512
|
return;
|
|
32389
32513
|
const parent = sp.dirname(wh.watchPath);
|
|
32390
32514
|
this.fsw._getWatchedDir(parent).add(wh.watchPath);
|
|
32391
32515
|
this.fsw._emit(EV.ADD, wh.watchPath, stats);
|
|
32392
|
-
closer = await this._handleDir(parent, stats, initialAdd, depth,
|
|
32516
|
+
closer = await this._handleDir(parent, stats, initialAdd, depth, path21, wh, targetPath);
|
|
32393
32517
|
if (this.fsw.closed)
|
|
32394
32518
|
return;
|
|
32395
32519
|
if (targetPath !== void 0) {
|
|
32396
|
-
this.fsw._symlinkPaths.set(sp.resolve(
|
|
32520
|
+
this.fsw._symlinkPaths.set(sp.resolve(path21), targetPath);
|
|
32397
32521
|
}
|
|
32398
32522
|
} else {
|
|
32399
32523
|
closer = this._handleFile(wh.watchPath, stats, initialAdd);
|
|
32400
32524
|
}
|
|
32401
32525
|
ready();
|
|
32402
32526
|
if (closer)
|
|
32403
|
-
this.fsw._addPathCloser(
|
|
32527
|
+
this.fsw._addPathCloser(path21, closer);
|
|
32404
32528
|
return false;
|
|
32405
32529
|
} catch (error) {
|
|
32406
32530
|
if (this.fsw._handleError(error)) {
|
|
32407
32531
|
ready();
|
|
32408
|
-
return
|
|
32532
|
+
return path21;
|
|
32409
32533
|
}
|
|
32410
32534
|
}
|
|
32411
32535
|
}
|
|
@@ -32448,24 +32572,24 @@ function createPattern(matcher) {
|
|
|
32448
32572
|
}
|
|
32449
32573
|
return () => false;
|
|
32450
32574
|
}
|
|
32451
|
-
function normalizePath(
|
|
32452
|
-
if (typeof
|
|
32575
|
+
function normalizePath(path21) {
|
|
32576
|
+
if (typeof path21 !== "string")
|
|
32453
32577
|
throw new Error("string expected");
|
|
32454
|
-
|
|
32455
|
-
|
|
32578
|
+
path21 = sp2.normalize(path21);
|
|
32579
|
+
path21 = path21.replace(/\\/g, "/");
|
|
32456
32580
|
let prepend = false;
|
|
32457
|
-
if (
|
|
32581
|
+
if (path21.startsWith("//"))
|
|
32458
32582
|
prepend = true;
|
|
32459
|
-
|
|
32583
|
+
path21 = path21.replace(DOUBLE_SLASH_RE, "/");
|
|
32460
32584
|
if (prepend)
|
|
32461
|
-
|
|
32462
|
-
return
|
|
32585
|
+
path21 = "/" + path21;
|
|
32586
|
+
return path21;
|
|
32463
32587
|
}
|
|
32464
32588
|
function matchPatterns(patterns, testString, stats) {
|
|
32465
|
-
const
|
|
32589
|
+
const path21 = normalizePath(testString);
|
|
32466
32590
|
for (let index = 0; index < patterns.length; index++) {
|
|
32467
32591
|
const pattern = patterns[index];
|
|
32468
|
-
if (pattern(
|
|
32592
|
+
if (pattern(path21, stats)) {
|
|
32469
32593
|
return true;
|
|
32470
32594
|
}
|
|
32471
32595
|
}
|
|
@@ -32503,19 +32627,19 @@ var toUnix = (string) => {
|
|
|
32503
32627
|
}
|
|
32504
32628
|
return str;
|
|
32505
32629
|
};
|
|
32506
|
-
var normalizePathToUnix = (
|
|
32507
|
-
var normalizeIgnored = (cwd = "") => (
|
|
32508
|
-
if (typeof
|
|
32509
|
-
return normalizePathToUnix(sp2.isAbsolute(
|
|
32630
|
+
var normalizePathToUnix = (path21) => toUnix(sp2.normalize(toUnix(path21)));
|
|
32631
|
+
var normalizeIgnored = (cwd = "") => (path21) => {
|
|
32632
|
+
if (typeof path21 === "string") {
|
|
32633
|
+
return normalizePathToUnix(sp2.isAbsolute(path21) ? path21 : sp2.join(cwd, path21));
|
|
32510
32634
|
} else {
|
|
32511
|
-
return
|
|
32635
|
+
return path21;
|
|
32512
32636
|
}
|
|
32513
32637
|
};
|
|
32514
|
-
var getAbsolutePath = (
|
|
32515
|
-
if (sp2.isAbsolute(
|
|
32516
|
-
return
|
|
32638
|
+
var getAbsolutePath = (path21, cwd) => {
|
|
32639
|
+
if (sp2.isAbsolute(path21)) {
|
|
32640
|
+
return path21;
|
|
32517
32641
|
}
|
|
32518
|
-
return sp2.join(cwd,
|
|
32642
|
+
return sp2.join(cwd, path21);
|
|
32519
32643
|
};
|
|
32520
32644
|
var EMPTY_SET = Object.freeze(/* @__PURE__ */ new Set());
|
|
32521
32645
|
var DirEntry = class {
|
|
@@ -32543,7 +32667,7 @@ var DirEntry = class {
|
|
|
32543
32667
|
return;
|
|
32544
32668
|
const dir = this.path;
|
|
32545
32669
|
try {
|
|
32546
|
-
await (0,
|
|
32670
|
+
await (0, import_promises5.readdir)(dir);
|
|
32547
32671
|
} catch (err) {
|
|
32548
32672
|
if (this._removeWatcher) {
|
|
32549
32673
|
this._removeWatcher(sp2.dirname(dir), sp2.basename(dir));
|
|
@@ -32580,10 +32704,10 @@ var WatchHelper = class {
|
|
|
32580
32704
|
dirParts;
|
|
32581
32705
|
followSymlinks;
|
|
32582
32706
|
statMethod;
|
|
32583
|
-
constructor(
|
|
32707
|
+
constructor(path21, follow, fsw) {
|
|
32584
32708
|
this.fsw = fsw;
|
|
32585
|
-
const watchPath =
|
|
32586
|
-
this.path =
|
|
32709
|
+
const watchPath = path21;
|
|
32710
|
+
this.path = path21 = path21.replace(REPLACER_RE, "");
|
|
32587
32711
|
this.watchPath = watchPath;
|
|
32588
32712
|
this.fullWatchPath = sp2.resolve(watchPath);
|
|
32589
32713
|
this.dirParts = [];
|
|
@@ -32723,20 +32847,20 @@ var FSWatcher = class extends import_node_events.EventEmitter {
|
|
|
32723
32847
|
this._closePromise = void 0;
|
|
32724
32848
|
let paths = unifyPaths(paths_);
|
|
32725
32849
|
if (cwd) {
|
|
32726
|
-
paths = paths.map((
|
|
32727
|
-
const absPath = getAbsolutePath(
|
|
32850
|
+
paths = paths.map((path21) => {
|
|
32851
|
+
const absPath = getAbsolutePath(path21, cwd);
|
|
32728
32852
|
return absPath;
|
|
32729
32853
|
});
|
|
32730
32854
|
}
|
|
32731
|
-
paths.forEach((
|
|
32732
|
-
this._removeIgnoredPath(
|
|
32855
|
+
paths.forEach((path21) => {
|
|
32856
|
+
this._removeIgnoredPath(path21);
|
|
32733
32857
|
});
|
|
32734
32858
|
this._userIgnored = void 0;
|
|
32735
32859
|
if (!this._readyCount)
|
|
32736
32860
|
this._readyCount = 0;
|
|
32737
32861
|
this._readyCount += paths.length;
|
|
32738
|
-
Promise.all(paths.map(async (
|
|
32739
|
-
const res = await this._nodeFsHandler._addToNodeFs(
|
|
32862
|
+
Promise.all(paths.map(async (path21) => {
|
|
32863
|
+
const res = await this._nodeFsHandler._addToNodeFs(path21, !_internal, void 0, 0, _origAdd);
|
|
32740
32864
|
if (res)
|
|
32741
32865
|
this._emitReady();
|
|
32742
32866
|
return res;
|
|
@@ -32758,17 +32882,17 @@ var FSWatcher = class extends import_node_events.EventEmitter {
|
|
|
32758
32882
|
return this;
|
|
32759
32883
|
const paths = unifyPaths(paths_);
|
|
32760
32884
|
const { cwd } = this.options;
|
|
32761
|
-
paths.forEach((
|
|
32762
|
-
if (!sp2.isAbsolute(
|
|
32885
|
+
paths.forEach((path21) => {
|
|
32886
|
+
if (!sp2.isAbsolute(path21) && !this._closers.has(path21)) {
|
|
32763
32887
|
if (cwd)
|
|
32764
|
-
|
|
32765
|
-
|
|
32888
|
+
path21 = sp2.join(cwd, path21);
|
|
32889
|
+
path21 = sp2.resolve(path21);
|
|
32766
32890
|
}
|
|
32767
|
-
this._closePath(
|
|
32768
|
-
this._addIgnoredPath(
|
|
32769
|
-
if (this._watched.has(
|
|
32891
|
+
this._closePath(path21);
|
|
32892
|
+
this._addIgnoredPath(path21);
|
|
32893
|
+
if (this._watched.has(path21)) {
|
|
32770
32894
|
this._addIgnoredPath({
|
|
32771
|
-
path:
|
|
32895
|
+
path: path21,
|
|
32772
32896
|
recursive: true
|
|
32773
32897
|
});
|
|
32774
32898
|
}
|
|
@@ -32832,38 +32956,38 @@ var FSWatcher = class extends import_node_events.EventEmitter {
|
|
|
32832
32956
|
* @param stats arguments to be passed with event
|
|
32833
32957
|
* @returns the error if defined, otherwise the value of the FSWatcher instance's `closed` flag
|
|
32834
32958
|
*/
|
|
32835
|
-
async _emit(event,
|
|
32959
|
+
async _emit(event, path21, stats) {
|
|
32836
32960
|
if (this.closed)
|
|
32837
32961
|
return;
|
|
32838
32962
|
const opts = this.options;
|
|
32839
32963
|
if (isWindows)
|
|
32840
|
-
|
|
32964
|
+
path21 = sp2.normalize(path21);
|
|
32841
32965
|
if (opts.cwd)
|
|
32842
|
-
|
|
32843
|
-
const args = [
|
|
32966
|
+
path21 = sp2.relative(opts.cwd, path21);
|
|
32967
|
+
const args = [path21];
|
|
32844
32968
|
if (stats != null)
|
|
32845
32969
|
args.push(stats);
|
|
32846
32970
|
const awf = opts.awaitWriteFinish;
|
|
32847
32971
|
let pw;
|
|
32848
|
-
if (awf && (pw = this._pendingWrites.get(
|
|
32972
|
+
if (awf && (pw = this._pendingWrites.get(path21))) {
|
|
32849
32973
|
pw.lastChange = /* @__PURE__ */ new Date();
|
|
32850
32974
|
return this;
|
|
32851
32975
|
}
|
|
32852
32976
|
if (opts.atomic) {
|
|
32853
32977
|
if (event === EVENTS.UNLINK) {
|
|
32854
|
-
this._pendingUnlinks.set(
|
|
32978
|
+
this._pendingUnlinks.set(path21, [event, ...args]);
|
|
32855
32979
|
setTimeout(() => {
|
|
32856
|
-
this._pendingUnlinks.forEach((entry,
|
|
32980
|
+
this._pendingUnlinks.forEach((entry, path22) => {
|
|
32857
32981
|
this.emit(...entry);
|
|
32858
32982
|
this.emit(EVENTS.ALL, ...entry);
|
|
32859
|
-
this._pendingUnlinks.delete(
|
|
32983
|
+
this._pendingUnlinks.delete(path22);
|
|
32860
32984
|
});
|
|
32861
32985
|
}, typeof opts.atomic === "number" ? opts.atomic : 100);
|
|
32862
32986
|
return this;
|
|
32863
32987
|
}
|
|
32864
|
-
if (event === EVENTS.ADD && this._pendingUnlinks.has(
|
|
32988
|
+
if (event === EVENTS.ADD && this._pendingUnlinks.has(path21)) {
|
|
32865
32989
|
event = EVENTS.CHANGE;
|
|
32866
|
-
this._pendingUnlinks.delete(
|
|
32990
|
+
this._pendingUnlinks.delete(path21);
|
|
32867
32991
|
}
|
|
32868
32992
|
}
|
|
32869
32993
|
if (awf && (event === EVENTS.ADD || event === EVENTS.CHANGE) && this._readyEmitted) {
|
|
@@ -32881,19 +33005,19 @@ var FSWatcher = class extends import_node_events.EventEmitter {
|
|
|
32881
33005
|
this.emitWithAll(event, args);
|
|
32882
33006
|
}
|
|
32883
33007
|
};
|
|
32884
|
-
this._awaitWriteFinish(
|
|
33008
|
+
this._awaitWriteFinish(path21, awf.stabilityThreshold, event, awfEmit);
|
|
32885
33009
|
return this;
|
|
32886
33010
|
}
|
|
32887
33011
|
if (event === EVENTS.CHANGE) {
|
|
32888
|
-
const isThrottled = !this._throttle(EVENTS.CHANGE,
|
|
33012
|
+
const isThrottled = !this._throttle(EVENTS.CHANGE, path21, 50);
|
|
32889
33013
|
if (isThrottled)
|
|
32890
33014
|
return this;
|
|
32891
33015
|
}
|
|
32892
33016
|
if (opts.alwaysStat && stats === void 0 && (event === EVENTS.ADD || event === EVENTS.ADD_DIR || event === EVENTS.CHANGE)) {
|
|
32893
|
-
const fullPath = opts.cwd ? sp2.join(opts.cwd,
|
|
33017
|
+
const fullPath = opts.cwd ? sp2.join(opts.cwd, path21) : path21;
|
|
32894
33018
|
let stats2;
|
|
32895
33019
|
try {
|
|
32896
|
-
stats2 = await (0,
|
|
33020
|
+
stats2 = await (0, import_promises5.stat)(fullPath);
|
|
32897
33021
|
} catch (err) {
|
|
32898
33022
|
}
|
|
32899
33023
|
if (!stats2 || this.closed)
|
|
@@ -32921,23 +33045,23 @@ var FSWatcher = class extends import_node_events.EventEmitter {
|
|
|
32921
33045
|
* @param timeout duration of time to suppress duplicate actions
|
|
32922
33046
|
* @returns tracking object or false if action should be suppressed
|
|
32923
33047
|
*/
|
|
32924
|
-
_throttle(actionType,
|
|
33048
|
+
_throttle(actionType, path21, timeout) {
|
|
32925
33049
|
if (!this._throttled.has(actionType)) {
|
|
32926
33050
|
this._throttled.set(actionType, /* @__PURE__ */ new Map());
|
|
32927
33051
|
}
|
|
32928
33052
|
const action = this._throttled.get(actionType);
|
|
32929
33053
|
if (!action)
|
|
32930
33054
|
throw new Error("invalid throttle");
|
|
32931
|
-
const actionPath = action.get(
|
|
33055
|
+
const actionPath = action.get(path21);
|
|
32932
33056
|
if (actionPath) {
|
|
32933
33057
|
actionPath.count++;
|
|
32934
33058
|
return false;
|
|
32935
33059
|
}
|
|
32936
33060
|
let timeoutObject;
|
|
32937
33061
|
const clear = () => {
|
|
32938
|
-
const item = action.get(
|
|
33062
|
+
const item = action.get(path21);
|
|
32939
33063
|
const count = item ? item.count : 0;
|
|
32940
|
-
action.delete(
|
|
33064
|
+
action.delete(path21);
|
|
32941
33065
|
clearTimeout(timeoutObject);
|
|
32942
33066
|
if (item)
|
|
32943
33067
|
clearTimeout(item.timeoutObject);
|
|
@@ -32945,7 +33069,7 @@ var FSWatcher = class extends import_node_events.EventEmitter {
|
|
|
32945
33069
|
};
|
|
32946
33070
|
timeoutObject = setTimeout(clear, timeout);
|
|
32947
33071
|
const thr = { timeoutObject, clear, count: 0 };
|
|
32948
|
-
action.set(
|
|
33072
|
+
action.set(path21, thr);
|
|
32949
33073
|
return thr;
|
|
32950
33074
|
}
|
|
32951
33075
|
_incrReadyCount() {
|
|
@@ -32959,44 +33083,44 @@ var FSWatcher = class extends import_node_events.EventEmitter {
|
|
|
32959
33083
|
* @param event
|
|
32960
33084
|
* @param awfEmit Callback to be called when ready for event to be emitted.
|
|
32961
33085
|
*/
|
|
32962
|
-
_awaitWriteFinish(
|
|
33086
|
+
_awaitWriteFinish(path21, threshold, event, awfEmit) {
|
|
32963
33087
|
const awf = this.options.awaitWriteFinish;
|
|
32964
33088
|
if (typeof awf !== "object")
|
|
32965
33089
|
return;
|
|
32966
33090
|
const pollInterval = awf.pollInterval;
|
|
32967
33091
|
let timeoutHandler;
|
|
32968
|
-
let fullPath =
|
|
32969
|
-
if (this.options.cwd && !sp2.isAbsolute(
|
|
32970
|
-
fullPath = sp2.join(this.options.cwd,
|
|
33092
|
+
let fullPath = path21;
|
|
33093
|
+
if (this.options.cwd && !sp2.isAbsolute(path21)) {
|
|
33094
|
+
fullPath = sp2.join(this.options.cwd, path21);
|
|
32971
33095
|
}
|
|
32972
33096
|
const now = /* @__PURE__ */ new Date();
|
|
32973
33097
|
const writes = this._pendingWrites;
|
|
32974
33098
|
function awaitWriteFinishFn(prevStat) {
|
|
32975
33099
|
(0, import_node_fs2.stat)(fullPath, (err, curStat) => {
|
|
32976
|
-
if (err || !writes.has(
|
|
33100
|
+
if (err || !writes.has(path21)) {
|
|
32977
33101
|
if (err && err.code !== "ENOENT")
|
|
32978
33102
|
awfEmit(err);
|
|
32979
33103
|
return;
|
|
32980
33104
|
}
|
|
32981
33105
|
const now2 = Number(/* @__PURE__ */ new Date());
|
|
32982
33106
|
if (prevStat && curStat.size !== prevStat.size) {
|
|
32983
|
-
writes.get(
|
|
33107
|
+
writes.get(path21).lastChange = now2;
|
|
32984
33108
|
}
|
|
32985
|
-
const pw = writes.get(
|
|
33109
|
+
const pw = writes.get(path21);
|
|
32986
33110
|
const df = now2 - pw.lastChange;
|
|
32987
33111
|
if (df >= threshold) {
|
|
32988
|
-
writes.delete(
|
|
33112
|
+
writes.delete(path21);
|
|
32989
33113
|
awfEmit(void 0, curStat);
|
|
32990
33114
|
} else {
|
|
32991
33115
|
timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval, curStat);
|
|
32992
33116
|
}
|
|
32993
33117
|
});
|
|
32994
33118
|
}
|
|
32995
|
-
if (!writes.has(
|
|
32996
|
-
writes.set(
|
|
33119
|
+
if (!writes.has(path21)) {
|
|
33120
|
+
writes.set(path21, {
|
|
32997
33121
|
lastChange: now,
|
|
32998
33122
|
cancelWait: () => {
|
|
32999
|
-
writes.delete(
|
|
33123
|
+
writes.delete(path21);
|
|
33000
33124
|
clearTimeout(timeoutHandler);
|
|
33001
33125
|
return event;
|
|
33002
33126
|
}
|
|
@@ -33007,8 +33131,8 @@ var FSWatcher = class extends import_node_events.EventEmitter {
|
|
|
33007
33131
|
/**
|
|
33008
33132
|
* Determines whether user has asked to ignore this path.
|
|
33009
33133
|
*/
|
|
33010
|
-
_isIgnored(
|
|
33011
|
-
if (this.options.atomic && DOT_RE.test(
|
|
33134
|
+
_isIgnored(path21, stats) {
|
|
33135
|
+
if (this.options.atomic && DOT_RE.test(path21))
|
|
33012
33136
|
return true;
|
|
33013
33137
|
if (!this._userIgnored) {
|
|
33014
33138
|
const { cwd } = this.options;
|
|
@@ -33018,17 +33142,17 @@ var FSWatcher = class extends import_node_events.EventEmitter {
|
|
|
33018
33142
|
const list = [...ignoredPaths.map(normalizeIgnored(cwd)), ...ignored];
|
|
33019
33143
|
this._userIgnored = anymatch(list, void 0);
|
|
33020
33144
|
}
|
|
33021
|
-
return this._userIgnored(
|
|
33145
|
+
return this._userIgnored(path21, stats);
|
|
33022
33146
|
}
|
|
33023
|
-
_isntIgnored(
|
|
33024
|
-
return !this._isIgnored(
|
|
33147
|
+
_isntIgnored(path21, stat11) {
|
|
33148
|
+
return !this._isIgnored(path21, stat11);
|
|
33025
33149
|
}
|
|
33026
33150
|
/**
|
|
33027
33151
|
* Provides a set of common helpers and properties relating to symlink handling.
|
|
33028
33152
|
* @param path file or directory pattern being watched
|
|
33029
33153
|
*/
|
|
33030
|
-
_getWatchHelpers(
|
|
33031
|
-
return new WatchHelper(
|
|
33154
|
+
_getWatchHelpers(path21) {
|
|
33155
|
+
return new WatchHelper(path21, this.options.followSymlinks, this);
|
|
33032
33156
|
}
|
|
33033
33157
|
// Directory helpers
|
|
33034
33158
|
// -----------------
|
|
@@ -33060,63 +33184,63 @@ var FSWatcher = class extends import_node_events.EventEmitter {
|
|
|
33060
33184
|
* @param item base path of item/directory
|
|
33061
33185
|
*/
|
|
33062
33186
|
_remove(directory, item, isDirectory) {
|
|
33063
|
-
const
|
|
33064
|
-
const fullPath = sp2.resolve(
|
|
33065
|
-
isDirectory = isDirectory != null ? isDirectory : this._watched.has(
|
|
33066
|
-
if (!this._throttle("remove",
|
|
33187
|
+
const path21 = sp2.join(directory, item);
|
|
33188
|
+
const fullPath = sp2.resolve(path21);
|
|
33189
|
+
isDirectory = isDirectory != null ? isDirectory : this._watched.has(path21) || this._watched.has(fullPath);
|
|
33190
|
+
if (!this._throttle("remove", path21, 100))
|
|
33067
33191
|
return;
|
|
33068
33192
|
if (!isDirectory && this._watched.size === 1) {
|
|
33069
33193
|
this.add(directory, item, true);
|
|
33070
33194
|
}
|
|
33071
|
-
const wp = this._getWatchedDir(
|
|
33195
|
+
const wp = this._getWatchedDir(path21);
|
|
33072
33196
|
const nestedDirectoryChildren = wp.getChildren();
|
|
33073
|
-
nestedDirectoryChildren.forEach((nested) => this._remove(
|
|
33197
|
+
nestedDirectoryChildren.forEach((nested) => this._remove(path21, nested));
|
|
33074
33198
|
const parent = this._getWatchedDir(directory);
|
|
33075
33199
|
const wasTracked = parent.has(item);
|
|
33076
33200
|
parent.remove(item);
|
|
33077
33201
|
if (this._symlinkPaths.has(fullPath)) {
|
|
33078
33202
|
this._symlinkPaths.delete(fullPath);
|
|
33079
33203
|
}
|
|
33080
|
-
let relPath =
|
|
33204
|
+
let relPath = path21;
|
|
33081
33205
|
if (this.options.cwd)
|
|
33082
|
-
relPath = sp2.relative(this.options.cwd,
|
|
33206
|
+
relPath = sp2.relative(this.options.cwd, path21);
|
|
33083
33207
|
if (this.options.awaitWriteFinish && this._pendingWrites.has(relPath)) {
|
|
33084
33208
|
const event = this._pendingWrites.get(relPath).cancelWait();
|
|
33085
33209
|
if (event === EVENTS.ADD)
|
|
33086
33210
|
return;
|
|
33087
33211
|
}
|
|
33088
|
-
this._watched.delete(
|
|
33212
|
+
this._watched.delete(path21);
|
|
33089
33213
|
this._watched.delete(fullPath);
|
|
33090
33214
|
const eventName = isDirectory ? EVENTS.UNLINK_DIR : EVENTS.UNLINK;
|
|
33091
|
-
if (wasTracked && !this._isIgnored(
|
|
33092
|
-
this._emit(eventName,
|
|
33093
|
-
this._closePath(
|
|
33215
|
+
if (wasTracked && !this._isIgnored(path21))
|
|
33216
|
+
this._emit(eventName, path21);
|
|
33217
|
+
this._closePath(path21);
|
|
33094
33218
|
}
|
|
33095
33219
|
/**
|
|
33096
33220
|
* Closes all watchers for a path
|
|
33097
33221
|
*/
|
|
33098
|
-
_closePath(
|
|
33099
|
-
this._closeFile(
|
|
33100
|
-
const dir = sp2.dirname(
|
|
33101
|
-
this._getWatchedDir(dir).remove(sp2.basename(
|
|
33222
|
+
_closePath(path21) {
|
|
33223
|
+
this._closeFile(path21);
|
|
33224
|
+
const dir = sp2.dirname(path21);
|
|
33225
|
+
this._getWatchedDir(dir).remove(sp2.basename(path21));
|
|
33102
33226
|
}
|
|
33103
33227
|
/**
|
|
33104
33228
|
* Closes only file-specific watchers
|
|
33105
33229
|
*/
|
|
33106
|
-
_closeFile(
|
|
33107
|
-
const closers = this._closers.get(
|
|
33230
|
+
_closeFile(path21) {
|
|
33231
|
+
const closers = this._closers.get(path21);
|
|
33108
33232
|
if (!closers)
|
|
33109
33233
|
return;
|
|
33110
33234
|
closers.forEach((closer) => closer());
|
|
33111
|
-
this._closers.delete(
|
|
33235
|
+
this._closers.delete(path21);
|
|
33112
33236
|
}
|
|
33113
|
-
_addPathCloser(
|
|
33237
|
+
_addPathCloser(path21, closer) {
|
|
33114
33238
|
if (!closer)
|
|
33115
33239
|
return;
|
|
33116
|
-
let list = this._closers.get(
|
|
33240
|
+
let list = this._closers.get(path21);
|
|
33117
33241
|
if (!list) {
|
|
33118
33242
|
list = [];
|
|
33119
|
-
this._closers.set(
|
|
33243
|
+
this._closers.set(path21, list);
|
|
33120
33244
|
}
|
|
33121
33245
|
list.push(closer);
|
|
33122
33246
|
}
|
|
@@ -34580,12 +34704,12 @@ function encodeURIPath(str) {
|
|
|
34580
34704
|
return str.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g, encodeURIComponent);
|
|
34581
34705
|
}
|
|
34582
34706
|
var EMPTY = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.create(null));
|
|
34583
|
-
var createPathTagFunction = (pathEncoder = encodeURIPath) => function
|
|
34707
|
+
var createPathTagFunction = (pathEncoder = encodeURIPath) => function path21(statics, ...params) {
|
|
34584
34708
|
if (statics.length === 1)
|
|
34585
34709
|
return statics[0];
|
|
34586
34710
|
let postPath = false;
|
|
34587
34711
|
const invalidSegments = [];
|
|
34588
|
-
const
|
|
34712
|
+
const path22 = statics.reduce((previousValue, currentValue, index) => {
|
|
34589
34713
|
if (/[?#]/.test(currentValue)) {
|
|
34590
34714
|
postPath = true;
|
|
34591
34715
|
}
|
|
@@ -34602,7 +34726,7 @@ var createPathTagFunction = (pathEncoder = encodeURIPath) => function path20(sta
|
|
|
34602
34726
|
}
|
|
34603
34727
|
return previousValue + currentValue + (index === params.length ? "" : encoded);
|
|
34604
34728
|
}, "");
|
|
34605
|
-
const pathOnly =
|
|
34729
|
+
const pathOnly = path22.split(/[?#]/, 1)[0];
|
|
34606
34730
|
const invalidSegmentPattern = /(?<=^|\/)(?:\.|%2e){1,2}(?=\/|$)/gi;
|
|
34607
34731
|
let match2;
|
|
34608
34732
|
while ((match2 = invalidSegmentPattern.exec(pathOnly)) !== null) {
|
|
@@ -34623,12 +34747,12 @@ var createPathTagFunction = (pathEncoder = encodeURIPath) => function path20(sta
|
|
|
34623
34747
|
}, "");
|
|
34624
34748
|
throw new AnthropicError(`Path parameters result in path with invalid segments:
|
|
34625
34749
|
${invalidSegments.map((e) => e.error).join("\n")}
|
|
34626
|
-
${
|
|
34750
|
+
${path22}
|
|
34627
34751
|
${underline}`);
|
|
34628
34752
|
}
|
|
34629
|
-
return
|
|
34753
|
+
return path22;
|
|
34630
34754
|
};
|
|
34631
|
-
var
|
|
34755
|
+
var path5 = /* @__PURE__ */ createPathTagFunction(encodeURIPath);
|
|
34632
34756
|
|
|
34633
34757
|
// node_modules/.pnpm/@anthropic-ai+sdk@0.78.0_zod@4.3.6/node_modules/@anthropic-ai/sdk/resources/beta/files.mjs
|
|
34634
34758
|
var Files = class extends APIResource {
|
|
@@ -34666,7 +34790,7 @@ var Files = class extends APIResource {
|
|
|
34666
34790
|
*/
|
|
34667
34791
|
delete(fileID, params = {}, options) {
|
|
34668
34792
|
const { betas } = params ?? {};
|
|
34669
|
-
return this._client.delete(
|
|
34793
|
+
return this._client.delete(path5`/v1/files/${fileID}`, {
|
|
34670
34794
|
...options,
|
|
34671
34795
|
headers: buildHeaders([
|
|
34672
34796
|
{ "anthropic-beta": [...betas ?? [], "files-api-2025-04-14"].toString() },
|
|
@@ -34689,7 +34813,7 @@ var Files = class extends APIResource {
|
|
|
34689
34813
|
*/
|
|
34690
34814
|
download(fileID, params = {}, options) {
|
|
34691
34815
|
const { betas } = params ?? {};
|
|
34692
|
-
return this._client.get(
|
|
34816
|
+
return this._client.get(path5`/v1/files/${fileID}/content`, {
|
|
34693
34817
|
...options,
|
|
34694
34818
|
headers: buildHeaders([
|
|
34695
34819
|
{
|
|
@@ -34712,7 +34836,7 @@ var Files = class extends APIResource {
|
|
|
34712
34836
|
*/
|
|
34713
34837
|
retrieveMetadata(fileID, params = {}, options) {
|
|
34714
34838
|
const { betas } = params ?? {};
|
|
34715
|
-
return this._client.get(
|
|
34839
|
+
return this._client.get(path5`/v1/files/${fileID}`, {
|
|
34716
34840
|
...options,
|
|
34717
34841
|
headers: buildHeaders([
|
|
34718
34842
|
{ "anthropic-beta": [...betas ?? [], "files-api-2025-04-14"].toString() },
|
|
@@ -34761,7 +34885,7 @@ var Models = class extends APIResource {
|
|
|
34761
34885
|
*/
|
|
34762
34886
|
retrieve(modelID, params = {}, options) {
|
|
34763
34887
|
const { betas } = params ?? {};
|
|
34764
|
-
return this._client.get(
|
|
34888
|
+
return this._client.get(path5`/v1/models/${modelID}?beta=true`, {
|
|
34765
34889
|
...options,
|
|
34766
34890
|
headers: buildHeaders([
|
|
34767
34891
|
{ ...betas?.toString() != null ? { "anthropic-beta": betas?.toString() } : void 0 },
|
|
@@ -36183,7 +36307,7 @@ var Batches = class extends APIResource {
|
|
|
36183
36307
|
*/
|
|
36184
36308
|
retrieve(messageBatchID, params = {}, options) {
|
|
36185
36309
|
const { betas } = params ?? {};
|
|
36186
|
-
return this._client.get(
|
|
36310
|
+
return this._client.get(path5`/v1/messages/batches/${messageBatchID}?beta=true`, {
|
|
36187
36311
|
...options,
|
|
36188
36312
|
headers: buildHeaders([
|
|
36189
36313
|
{ "anthropic-beta": [...betas ?? [], "message-batches-2024-09-24"].toString() },
|
|
@@ -36236,7 +36360,7 @@ var Batches = class extends APIResource {
|
|
|
36236
36360
|
*/
|
|
36237
36361
|
delete(messageBatchID, params = {}, options) {
|
|
36238
36362
|
const { betas } = params ?? {};
|
|
36239
|
-
return this._client.delete(
|
|
36363
|
+
return this._client.delete(path5`/v1/messages/batches/${messageBatchID}?beta=true`, {
|
|
36240
36364
|
...options,
|
|
36241
36365
|
headers: buildHeaders([
|
|
36242
36366
|
{ "anthropic-beta": [...betas ?? [], "message-batches-2024-09-24"].toString() },
|
|
@@ -36268,7 +36392,7 @@ var Batches = class extends APIResource {
|
|
|
36268
36392
|
*/
|
|
36269
36393
|
cancel(messageBatchID, params = {}, options) {
|
|
36270
36394
|
const { betas } = params ?? {};
|
|
36271
|
-
return this._client.post(
|
|
36395
|
+
return this._client.post(path5`/v1/messages/batches/${messageBatchID}/cancel?beta=true`, {
|
|
36272
36396
|
...options,
|
|
36273
36397
|
headers: buildHeaders([
|
|
36274
36398
|
{ "anthropic-beta": [...betas ?? [], "message-batches-2024-09-24"].toString() },
|
|
@@ -36463,7 +36587,7 @@ var Versions = class extends APIResource {
|
|
|
36463
36587
|
*/
|
|
36464
36588
|
create(skillID, params = {}, options) {
|
|
36465
36589
|
const { betas, ...body } = params ?? {};
|
|
36466
|
-
return this._client.post(
|
|
36590
|
+
return this._client.post(path5`/v1/skills/${skillID}/versions?beta=true`, multipartFormRequestOptions({
|
|
36467
36591
|
body,
|
|
36468
36592
|
...options,
|
|
36469
36593
|
headers: buildHeaders([
|
|
@@ -36485,7 +36609,7 @@ var Versions = class extends APIResource {
|
|
|
36485
36609
|
*/
|
|
36486
36610
|
retrieve(version, params, options) {
|
|
36487
36611
|
const { skill_id, betas } = params;
|
|
36488
|
-
return this._client.get(
|
|
36612
|
+
return this._client.get(path5`/v1/skills/${skill_id}/versions/${version}?beta=true`, {
|
|
36489
36613
|
...options,
|
|
36490
36614
|
headers: buildHeaders([
|
|
36491
36615
|
{ "anthropic-beta": [...betas ?? [], "skills-2025-10-02"].toString() },
|
|
@@ -36508,7 +36632,7 @@ var Versions = class extends APIResource {
|
|
|
36508
36632
|
*/
|
|
36509
36633
|
list(skillID, params = {}, options) {
|
|
36510
36634
|
const { betas, ...query } = params ?? {};
|
|
36511
|
-
return this._client.getAPIList(
|
|
36635
|
+
return this._client.getAPIList(path5`/v1/skills/${skillID}/versions?beta=true`, PageCursor, {
|
|
36512
36636
|
query,
|
|
36513
36637
|
...options,
|
|
36514
36638
|
headers: buildHeaders([
|
|
@@ -36530,7 +36654,7 @@ var Versions = class extends APIResource {
|
|
|
36530
36654
|
*/
|
|
36531
36655
|
delete(version, params, options) {
|
|
36532
36656
|
const { skill_id, betas } = params;
|
|
36533
|
-
return this._client.delete(
|
|
36657
|
+
return this._client.delete(path5`/v1/skills/${skill_id}/versions/${version}?beta=true`, {
|
|
36534
36658
|
...options,
|
|
36535
36659
|
headers: buildHeaders([
|
|
36536
36660
|
{ "anthropic-beta": [...betas ?? [], "skills-2025-10-02"].toString() },
|
|
@@ -36575,7 +36699,7 @@ var Skills = class extends APIResource {
|
|
|
36575
36699
|
*/
|
|
36576
36700
|
retrieve(skillID, params = {}, options) {
|
|
36577
36701
|
const { betas } = params ?? {};
|
|
36578
|
-
return this._client.get(
|
|
36702
|
+
return this._client.get(path5`/v1/skills/${skillID}?beta=true`, {
|
|
36579
36703
|
...options,
|
|
36580
36704
|
headers: buildHeaders([
|
|
36581
36705
|
{ "anthropic-beta": [...betas ?? [], "skills-2025-10-02"].toString() },
|
|
@@ -36615,7 +36739,7 @@ var Skills = class extends APIResource {
|
|
|
36615
36739
|
*/
|
|
36616
36740
|
delete(skillID, params = {}, options) {
|
|
36617
36741
|
const { betas } = params ?? {};
|
|
36618
|
-
return this._client.delete(
|
|
36742
|
+
return this._client.delete(path5`/v1/skills/${skillID}?beta=true`, {
|
|
36619
36743
|
...options,
|
|
36620
36744
|
headers: buildHeaders([
|
|
36621
36745
|
{ "anthropic-beta": [...betas ?? [], "skills-2025-10-02"].toString() },
|
|
@@ -37358,7 +37482,7 @@ var Batches2 = class extends APIResource {
|
|
|
37358
37482
|
* ```
|
|
37359
37483
|
*/
|
|
37360
37484
|
retrieve(messageBatchID, options) {
|
|
37361
|
-
return this._client.get(
|
|
37485
|
+
return this._client.get(path5`/v1/messages/batches/${messageBatchID}`, options);
|
|
37362
37486
|
}
|
|
37363
37487
|
/**
|
|
37364
37488
|
* List all Message Batches within a Workspace. Most recently created batches are
|
|
@@ -37394,7 +37518,7 @@ var Batches2 = class extends APIResource {
|
|
|
37394
37518
|
* ```
|
|
37395
37519
|
*/
|
|
37396
37520
|
delete(messageBatchID, options) {
|
|
37397
|
-
return this._client.delete(
|
|
37521
|
+
return this._client.delete(path5`/v1/messages/batches/${messageBatchID}`, options);
|
|
37398
37522
|
}
|
|
37399
37523
|
/**
|
|
37400
37524
|
* Batches may be canceled any time before processing ends. Once cancellation is
|
|
@@ -37418,7 +37542,7 @@ var Batches2 = class extends APIResource {
|
|
|
37418
37542
|
* ```
|
|
37419
37543
|
*/
|
|
37420
37544
|
cancel(messageBatchID, options) {
|
|
37421
|
-
return this._client.post(
|
|
37545
|
+
return this._client.post(path5`/v1/messages/batches/${messageBatchID}/cancel`, options);
|
|
37422
37546
|
}
|
|
37423
37547
|
/**
|
|
37424
37548
|
* Streams the results of a Message Batch as a `.jsonl` file.
|
|
@@ -37573,7 +37697,7 @@ var Models2 = class extends APIResource {
|
|
|
37573
37697
|
*/
|
|
37574
37698
|
retrieve(modelID, params = {}, options) {
|
|
37575
37699
|
const { betas } = params ?? {};
|
|
37576
|
-
return this._client.get(
|
|
37700
|
+
return this._client.get(path5`/v1/models/${modelID}`, {
|
|
37577
37701
|
...options,
|
|
37578
37702
|
headers: buildHeaders([
|
|
37579
37703
|
{ ...betas?.toString() != null ? { "anthropic-beta": betas?.toString() } : void 0 },
|
|
@@ -37737,9 +37861,9 @@ var BaseAnthropic = class {
|
|
|
37737
37861
|
makeStatusError(status, error, message, headers) {
|
|
37738
37862
|
return APIError.generate(status, error, message, headers);
|
|
37739
37863
|
}
|
|
37740
|
-
buildURL(
|
|
37864
|
+
buildURL(path21, query, defaultBaseURL) {
|
|
37741
37865
|
const baseURL = !__classPrivateFieldGet(this, _BaseAnthropic_instances, "m", _BaseAnthropic_baseURLOverridden).call(this) && defaultBaseURL || this.baseURL;
|
|
37742
|
-
const url = isAbsoluteURL(
|
|
37866
|
+
const url = isAbsoluteURL(path21) ? new URL(path21) : new URL(baseURL + (baseURL.endsWith("/") && path21.startsWith("/") ? path21.slice(1) : path21));
|
|
37743
37867
|
const defaultQuery = this.defaultQuery();
|
|
37744
37868
|
if (!isEmptyObj(defaultQuery)) {
|
|
37745
37869
|
query = { ...defaultQuery, ...query };
|
|
@@ -37770,24 +37894,24 @@ var BaseAnthropic = class {
|
|
|
37770
37894
|
*/
|
|
37771
37895
|
async prepareRequest(request, { url, options }) {
|
|
37772
37896
|
}
|
|
37773
|
-
get(
|
|
37774
|
-
return this.methodRequest("get",
|
|
37897
|
+
get(path21, opts) {
|
|
37898
|
+
return this.methodRequest("get", path21, opts);
|
|
37775
37899
|
}
|
|
37776
|
-
post(
|
|
37777
|
-
return this.methodRequest("post",
|
|
37900
|
+
post(path21, opts) {
|
|
37901
|
+
return this.methodRequest("post", path21, opts);
|
|
37778
37902
|
}
|
|
37779
|
-
patch(
|
|
37780
|
-
return this.methodRequest("patch",
|
|
37903
|
+
patch(path21, opts) {
|
|
37904
|
+
return this.methodRequest("patch", path21, opts);
|
|
37781
37905
|
}
|
|
37782
|
-
put(
|
|
37783
|
-
return this.methodRequest("put",
|
|
37906
|
+
put(path21, opts) {
|
|
37907
|
+
return this.methodRequest("put", path21, opts);
|
|
37784
37908
|
}
|
|
37785
|
-
delete(
|
|
37786
|
-
return this.methodRequest("delete",
|
|
37909
|
+
delete(path21, opts) {
|
|
37910
|
+
return this.methodRequest("delete", path21, opts);
|
|
37787
37911
|
}
|
|
37788
|
-
methodRequest(method,
|
|
37912
|
+
methodRequest(method, path21, opts) {
|
|
37789
37913
|
return this.request(Promise.resolve(opts).then((opts2) => {
|
|
37790
|
-
return { method, path:
|
|
37914
|
+
return { method, path: path21, ...opts2 };
|
|
37791
37915
|
}));
|
|
37792
37916
|
}
|
|
37793
37917
|
request(options, remainingRetries = null) {
|
|
@@ -37891,8 +38015,8 @@ var BaseAnthropic = class {
|
|
|
37891
38015
|
}));
|
|
37892
38016
|
return { response, options, controller, requestLogID, retryOfRequestLogID, startTime: startTime2 };
|
|
37893
38017
|
}
|
|
37894
|
-
getAPIList(
|
|
37895
|
-
return this.requestAPIList(Page2, opts && "then" in opts ? opts.then((opts2) => ({ method: "get", path:
|
|
38018
|
+
getAPIList(path21, Page2, opts) {
|
|
38019
|
+
return this.requestAPIList(Page2, opts && "then" in opts ? opts.then((opts2) => ({ method: "get", path: path21, ...opts2 })) : { method: "get", path: path21, ...opts });
|
|
37896
38020
|
}
|
|
37897
38021
|
requestAPIList(Page2, options) {
|
|
37898
38022
|
const request = this.makeRequest(options, null, void 0);
|
|
@@ -37980,8 +38104,8 @@ var BaseAnthropic = class {
|
|
|
37980
38104
|
}
|
|
37981
38105
|
async buildRequest(inputOptions, { retryCount = 0 } = {}) {
|
|
37982
38106
|
const options = { ...inputOptions };
|
|
37983
|
-
const { method, path:
|
|
37984
|
-
const url = this.buildURL(
|
|
38107
|
+
const { method, path: path21, query, defaultBaseURL } = options;
|
|
38108
|
+
const url = this.buildURL(path21, query, defaultBaseURL);
|
|
37985
38109
|
if ("timeout" in options)
|
|
37986
38110
|
validatePositiveInteger("timeout", options.timeout);
|
|
37987
38111
|
options.timeout = options.timeout ?? this.timeout;
|
|
@@ -38349,17 +38473,17 @@ var toInternalContent = (sdkContent) => {
|
|
|
38349
38473
|
};
|
|
38350
38474
|
|
|
38351
38475
|
// src/storage/FileStorage.ts
|
|
38352
|
-
var
|
|
38353
|
-
var
|
|
38476
|
+
var import_promises6 = require("node:fs/promises");
|
|
38477
|
+
var import_node_path5 = __toESM(require("node:path"));
|
|
38354
38478
|
var encodeKey = (key) => Buffer.from(key).toString("base64url");
|
|
38355
38479
|
var normalizePrefix = (prefix) => prefix.replace(/[:/\\]+$/g, "") || "agent";
|
|
38356
38480
|
var createFileStorage = (options = {}) => {
|
|
38357
|
-
const rootDir =
|
|
38358
|
-
const fileForKey = (key) =>
|
|
38481
|
+
const rootDir = import_node_path5.default.join(options.rootDir || getDuclawDataDir(), "kv", normalizePrefix(options.prefix || "agent"));
|
|
38482
|
+
const fileForKey = (key) => import_node_path5.default.join(rootDir, `${encodeKey(key)}.json`);
|
|
38359
38483
|
return {
|
|
38360
38484
|
async get(key) {
|
|
38361
38485
|
try {
|
|
38362
|
-
const raw2 = await (0,
|
|
38486
|
+
const raw2 = await (0, import_promises6.readFile)(fileForKey(key), "utf8");
|
|
38363
38487
|
return JSON.parse(raw2);
|
|
38364
38488
|
} catch (err) {
|
|
38365
38489
|
if (err.code === "ENOENT") return null;
|
|
@@ -38367,14 +38491,14 @@ var createFileStorage = (options = {}) => {
|
|
|
38367
38491
|
}
|
|
38368
38492
|
},
|
|
38369
38493
|
async set(key, value) {
|
|
38370
|
-
await (0,
|
|
38494
|
+
await (0, import_promises6.mkdir)(rootDir, { recursive: true });
|
|
38371
38495
|
const target = fileForKey(key);
|
|
38372
38496
|
const tmp = `${target}.${process.pid}.${Date.now()}.tmp`;
|
|
38373
|
-
await (0,
|
|
38374
|
-
await (0,
|
|
38497
|
+
await (0, import_promises6.writeFile)(tmp, JSON.stringify(value), "utf8");
|
|
38498
|
+
await (0, import_promises6.rename)(tmp, target);
|
|
38375
38499
|
},
|
|
38376
38500
|
async del(key) {
|
|
38377
|
-
await (0,
|
|
38501
|
+
await (0, import_promises6.rm)(fileForKey(key), { force: true });
|
|
38378
38502
|
}
|
|
38379
38503
|
};
|
|
38380
38504
|
};
|
|
@@ -39334,14 +39458,14 @@ var taskUpdate = {
|
|
|
39334
39458
|
};
|
|
39335
39459
|
|
|
39336
39460
|
// src/tools/tools/Glob.ts
|
|
39337
|
-
var
|
|
39338
|
-
var
|
|
39461
|
+
var import_node_path7 = require("node:path");
|
|
39462
|
+
var import_promises7 = require("node:fs/promises");
|
|
39339
39463
|
|
|
39340
39464
|
// src/tools/utils/workspaceGuard.ts
|
|
39341
|
-
var
|
|
39465
|
+
var import_node_path6 = require("node:path");
|
|
39342
39466
|
var validateWorkspacePath = (filePath, workspacePath) => {
|
|
39343
|
-
const resolved = (0,
|
|
39344
|
-
const workspace = (0,
|
|
39467
|
+
const resolved = (0, import_node_path6.isAbsolute)(filePath) ? (0, import_node_path6.resolve)(filePath) : (0, import_node_path6.resolve)(process.cwd(), filePath);
|
|
39468
|
+
const workspace = (0, import_node_path6.resolve)(workspacePath);
|
|
39345
39469
|
if (!resolved.startsWith(workspace + "/") && resolved !== workspace) {
|
|
39346
39470
|
return `\u8DEF\u5F84 ${resolved} \u4E0D\u5728\u5DE5\u4F5C\u533A ${workspace} \u8303\u56F4\u5185\uFF0C\u64CD\u4F5C\u88AB\u62D2\u7EDD\u3002\u8BF7\u5C06\u6587\u4EF6\u653E\u5728\u5DE5\u4F5C\u533A\u76EE\u5F55\u4E0B\u3002`;
|
|
39347
39471
|
}
|
|
@@ -39399,23 +39523,23 @@ var globTool = {
|
|
|
39399
39523
|
const pattern = input.pattern;
|
|
39400
39524
|
const effectiveCwd = getEffectiveCwd(userRequest);
|
|
39401
39525
|
const searchDir = input.path || effectiveCwd;
|
|
39402
|
-
const resolvedDir = (0,
|
|
39526
|
+
const resolvedDir = (0, import_node_path7.isAbsolute)(searchDir) ? searchDir : (0, import_node_path7.resolve)(effectiveCwd, searchDir);
|
|
39403
39527
|
const LIMIT = 100;
|
|
39404
39528
|
const regex = globToRegex(pattern);
|
|
39405
39529
|
const files = [];
|
|
39406
39530
|
let truncated = false;
|
|
39407
39531
|
let entries;
|
|
39408
39532
|
try {
|
|
39409
|
-
entries = await (0,
|
|
39533
|
+
entries = await (0, import_promises7.readdir)(resolvedDir, { recursive: true });
|
|
39410
39534
|
} catch {
|
|
39411
39535
|
return `\u76EE\u5F55\u4E0D\u5B58\u5728\u6216\u65E0\u6CD5\u8BBF\u95EE: ${resolvedDir}`;
|
|
39412
39536
|
}
|
|
39413
39537
|
for (const entry of entries) {
|
|
39414
39538
|
const normalized = entry.replace(/\\/g, "/");
|
|
39415
39539
|
if (!regex.test(normalized)) continue;
|
|
39416
|
-
const fullPath = (0,
|
|
39540
|
+
const fullPath = (0, import_node_path7.resolve)(resolvedDir, entry);
|
|
39417
39541
|
try {
|
|
39418
|
-
const s = await (0,
|
|
39542
|
+
const s = await (0, import_promises7.stat)(fullPath);
|
|
39419
39543
|
if (!s.isFile()) continue;
|
|
39420
39544
|
if (files.length >= LIMIT) {
|
|
39421
39545
|
truncated = true;
|
|
@@ -39436,8 +39560,8 @@ var globTool = {
|
|
|
39436
39560
|
};
|
|
39437
39561
|
|
|
39438
39562
|
// src/tools/tools/Grep.ts
|
|
39439
|
-
var
|
|
39440
|
-
var
|
|
39563
|
+
var import_node_path8 = require("node:path");
|
|
39564
|
+
var import_promises8 = require("node:fs/promises");
|
|
39441
39565
|
var MAX_LINE_LENGTH = 2e3;
|
|
39442
39566
|
var DESCRIPTION2 = `
|
|
39443
39567
|
- Fast content search tool that works with any codebase size
|
|
@@ -39509,7 +39633,7 @@ var grepTool = {
|
|
|
39509
39633
|
const effectiveCwd = getEffectiveCwd(userRequest);
|
|
39510
39634
|
const searchDir = input.path || effectiveCwd;
|
|
39511
39635
|
const includePattern = input.include;
|
|
39512
|
-
const resolvedDir = (0,
|
|
39636
|
+
const resolvedDir = (0, import_node_path8.isAbsolute)(searchDir) ? searchDir : (0, import_node_path8.resolve)(effectiveCwd, searchDir);
|
|
39513
39637
|
let regex;
|
|
39514
39638
|
try {
|
|
39515
39639
|
regex = new RegExp(pattern);
|
|
@@ -39519,7 +39643,7 @@ var grepTool = {
|
|
|
39519
39643
|
const includeRegex = includePattern ? includeToRegex(includePattern) : null;
|
|
39520
39644
|
let entries;
|
|
39521
39645
|
try {
|
|
39522
|
-
entries = await (0,
|
|
39646
|
+
entries = await (0, import_promises8.readdir)(resolvedDir, { recursive: true });
|
|
39523
39647
|
} catch {
|
|
39524
39648
|
return `\u76EE\u5F55\u4E0D\u5B58\u5728\u6216\u65E0\u6CD5\u8BBF\u95EE: ${resolvedDir}`;
|
|
39525
39649
|
}
|
|
@@ -39533,17 +39657,17 @@ var grepTool = {
|
|
|
39533
39657
|
const fileName = normalized.split("/").pop() || normalized;
|
|
39534
39658
|
if (!includeRegex.test(fileName)) continue;
|
|
39535
39659
|
}
|
|
39536
|
-
const fullPath = (0,
|
|
39660
|
+
const fullPath = (0, import_node_path8.resolve)(resolvedDir, entry);
|
|
39537
39661
|
let s;
|
|
39538
39662
|
try {
|
|
39539
|
-
s = await (0,
|
|
39663
|
+
s = await (0, import_promises8.stat)(fullPath);
|
|
39540
39664
|
} catch {
|
|
39541
39665
|
continue;
|
|
39542
39666
|
}
|
|
39543
39667
|
if (!s.isFile()) continue;
|
|
39544
39668
|
let content;
|
|
39545
39669
|
try {
|
|
39546
|
-
content = await (0,
|
|
39670
|
+
content = await (0, import_promises8.readFile)(fullPath, "utf-8");
|
|
39547
39671
|
} catch {
|
|
39548
39672
|
continue;
|
|
39549
39673
|
}
|
|
@@ -39676,8 +39800,8 @@ var codeSearchTool = {
|
|
|
39676
39800
|
};
|
|
39677
39801
|
|
|
39678
39802
|
// src/tools/tools/Read.ts
|
|
39679
|
-
var
|
|
39680
|
-
var
|
|
39803
|
+
var import_node_path9 = require("node:path");
|
|
39804
|
+
var import_promises9 = require("node:fs/promises");
|
|
39681
39805
|
var DEFAULT_READ_LIMIT = 2e3;
|
|
39682
39806
|
var MAX_LINE_LENGTH2 = 2e3;
|
|
39683
39807
|
var MAX_BYTES = 50 * 1024;
|
|
@@ -39737,11 +39861,11 @@ var IMAGE_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
|
39737
39861
|
".heif"
|
|
39738
39862
|
]);
|
|
39739
39863
|
async function isBinaryFile(filePath) {
|
|
39740
|
-
const ext = (0,
|
|
39864
|
+
const ext = (0, import_node_path9.extname)(filePath).toLowerCase();
|
|
39741
39865
|
if (BINARY_EXTENSIONS.has(ext)) return true;
|
|
39742
39866
|
let buffer;
|
|
39743
39867
|
try {
|
|
39744
|
-
const fd = await (0,
|
|
39868
|
+
const fd = await (0, import_promises9.readFile)(filePath);
|
|
39745
39869
|
buffer = Buffer.from(fd.buffer, 0, Math.min(4096, fd.byteLength));
|
|
39746
39870
|
} catch {
|
|
39747
39871
|
return false;
|
|
@@ -39779,20 +39903,20 @@ var readTool = {
|
|
|
39779
39903
|
},
|
|
39780
39904
|
async execute(input, userRequest) {
|
|
39781
39905
|
let filePath = input.filePath;
|
|
39782
|
-
if (!(0,
|
|
39783
|
-
filePath = (0,
|
|
39906
|
+
if (!(0, import_node_path9.isAbsolute)(filePath)) {
|
|
39907
|
+
filePath = (0, import_node_path9.resolve)(getEffectiveCwd(userRequest), filePath);
|
|
39784
39908
|
}
|
|
39785
39909
|
let fileStat;
|
|
39786
39910
|
try {
|
|
39787
|
-
fileStat = await (0,
|
|
39911
|
+
fileStat = await (0, import_promises9.stat)(filePath);
|
|
39788
39912
|
} catch {
|
|
39789
39913
|
try {
|
|
39790
|
-
const dir = (0,
|
|
39791
|
-
const base = (0,
|
|
39792
|
-
const dirEntries = await (0,
|
|
39914
|
+
const dir = (0, import_node_path9.dirname)(filePath);
|
|
39915
|
+
const base = (0, import_node_path9.basename)(filePath);
|
|
39916
|
+
const dirEntries = await (0, import_promises9.readdir)(dir);
|
|
39793
39917
|
const suggestions = dirEntries.filter(
|
|
39794
39918
|
(entry) => entry.toLowerCase().includes(base.toLowerCase()) || base.toLowerCase().includes(entry.toLowerCase())
|
|
39795
|
-
).map((entry) => (0,
|
|
39919
|
+
).map((entry) => (0, import_node_path9.join)(dir, entry)).slice(0, 3);
|
|
39796
39920
|
if (suggestions.length > 0) {
|
|
39797
39921
|
return `File not found: ${filePath}
|
|
39798
39922
|
|
|
@@ -39809,7 +39933,7 @@ ${suggestions.join("\n")}`;
|
|
|
39809
39933
|
if (fileStat.size === 0) {
|
|
39810
39934
|
return `<system-reminder>File exists but has empty contents: ${filePath}</system-reminder>`;
|
|
39811
39935
|
}
|
|
39812
|
-
const ext = (0,
|
|
39936
|
+
const ext = (0, import_node_path9.extname)(filePath).toLowerCase();
|
|
39813
39937
|
if (IMAGE_EXTENSIONS.has(ext)) {
|
|
39814
39938
|
return `Cannot read image file with this tool. Use the image_understand tool instead to analyze image: ${filePath}`;
|
|
39815
39939
|
}
|
|
@@ -39818,7 +39942,7 @@ ${suggestions.join("\n")}`;
|
|
|
39818
39942
|
}
|
|
39819
39943
|
let text2;
|
|
39820
39944
|
try {
|
|
39821
|
-
text2 = await (0,
|
|
39945
|
+
text2 = await (0, import_promises9.readFile)(filePath, "utf-8");
|
|
39822
39946
|
} catch {
|
|
39823
39947
|
return `\u65E0\u6CD5\u8BFB\u53D6\u6587\u4EF6: ${filePath}`;
|
|
39824
39948
|
}
|
|
@@ -39983,8 +40107,8 @@ var webSearchTool = {
|
|
|
39983
40107
|
};
|
|
39984
40108
|
|
|
39985
40109
|
// src/tools/tools/Write.ts
|
|
39986
|
-
var
|
|
39987
|
-
var
|
|
40110
|
+
var import_node_path10 = require("node:path");
|
|
40111
|
+
var import_promises10 = require("node:fs/promises");
|
|
39988
40112
|
|
|
39989
40113
|
// node_modules/.pnpm/diff@8.0.3/node_modules/diff/libesm/diff/base.js
|
|
39990
40114
|
var Diff = class {
|
|
@@ -40086,16 +40210,16 @@ var Diff = class {
|
|
|
40086
40210
|
}
|
|
40087
40211
|
}
|
|
40088
40212
|
}
|
|
40089
|
-
addToPath(
|
|
40090
|
-
const last =
|
|
40213
|
+
addToPath(path21, added, removed, oldPosInc, options) {
|
|
40214
|
+
const last = path21.lastComponent;
|
|
40091
40215
|
if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) {
|
|
40092
40216
|
return {
|
|
40093
|
-
oldPos:
|
|
40217
|
+
oldPos: path21.oldPos + oldPosInc,
|
|
40094
40218
|
lastComponent: { count: last.count + 1, added, removed, previousComponent: last.previousComponent }
|
|
40095
40219
|
};
|
|
40096
40220
|
} else {
|
|
40097
40221
|
return {
|
|
40098
|
-
oldPos:
|
|
40222
|
+
oldPos: path21.oldPos + oldPosInc,
|
|
40099
40223
|
lastComponent: { count: 1, added, removed, previousComponent: last }
|
|
40100
40224
|
};
|
|
40101
40225
|
}
|
|
@@ -40448,8 +40572,8 @@ var writeTool = {
|
|
|
40448
40572
|
async execute(input, userRequest) {
|
|
40449
40573
|
let filePath = input.filePath;
|
|
40450
40574
|
const content = input.content;
|
|
40451
|
-
if (!(0,
|
|
40452
|
-
filePath = (0,
|
|
40575
|
+
if (!(0, import_node_path10.isAbsolute)(filePath)) {
|
|
40576
|
+
filePath = (0, import_node_path10.resolve)(getEffectiveCwd(userRequest), filePath);
|
|
40453
40577
|
}
|
|
40454
40578
|
if (userRequest?.workspacePath) {
|
|
40455
40579
|
const rejection = validateWorkspacePath(filePath, userRequest.workspacePath);
|
|
@@ -40458,15 +40582,15 @@ var writeTool = {
|
|
|
40458
40582
|
let exists = false;
|
|
40459
40583
|
let contentOld = "";
|
|
40460
40584
|
try {
|
|
40461
|
-
const fileStat = await (0,
|
|
40585
|
+
const fileStat = await (0, import_promises10.stat)(filePath);
|
|
40462
40586
|
if (fileStat.isFile()) {
|
|
40463
40587
|
exists = true;
|
|
40464
|
-
contentOld = await (0,
|
|
40588
|
+
contentOld = await (0, import_promises10.readFile)(filePath, "utf-8");
|
|
40465
40589
|
}
|
|
40466
40590
|
} catch {
|
|
40467
40591
|
}
|
|
40468
|
-
await (0,
|
|
40469
|
-
await (0,
|
|
40592
|
+
await (0, import_promises10.mkdir)((0, import_node_path10.dirname)(filePath), { recursive: true });
|
|
40593
|
+
await (0, import_promises10.writeFile)(filePath, content, "utf-8");
|
|
40470
40594
|
let output = `\u6587\u4EF6\u5199\u5165\u6210\u529F: ${filePath}`;
|
|
40471
40595
|
if (exists) {
|
|
40472
40596
|
const diff = createTwoFilesPatch(filePath, filePath, contentOld, content);
|
|
@@ -40487,8 +40611,8 @@ ${trimmed}${suffix}
|
|
|
40487
40611
|
};
|
|
40488
40612
|
|
|
40489
40613
|
// src/tools/tools/Edit.ts
|
|
40490
|
-
var
|
|
40491
|
-
var
|
|
40614
|
+
var import_node_path11 = require("node:path");
|
|
40615
|
+
var import_promises11 = require("node:fs/promises");
|
|
40492
40616
|
var DESCRIPTION7 = `Performs exact string replacements in files.
|
|
40493
40617
|
|
|
40494
40618
|
Usage:
|
|
@@ -40886,24 +41010,24 @@ var editTool = {
|
|
|
40886
41010
|
if (oldString === newString) {
|
|
40887
41011
|
return "\u9519\u8BEF: oldString \u548C newString \u5FC5\u987B\u4E0D\u540C";
|
|
40888
41012
|
}
|
|
40889
|
-
if (!(0,
|
|
40890
|
-
filePath = (0,
|
|
41013
|
+
if (!(0, import_node_path11.isAbsolute)(filePath)) {
|
|
41014
|
+
filePath = (0, import_node_path11.resolve)(getEffectiveCwd(userRequest), filePath);
|
|
40891
41015
|
}
|
|
40892
41016
|
if (userRequest?.workspacePath) {
|
|
40893
41017
|
const rejection = validateWorkspacePath(filePath, userRequest.workspacePath);
|
|
40894
41018
|
if (rejection) return rejection;
|
|
40895
41019
|
}
|
|
40896
41020
|
if (oldString === "") {
|
|
40897
|
-
await (0,
|
|
41021
|
+
await (0, import_promises11.writeFile)(filePath, newString, "utf-8");
|
|
40898
41022
|
return `\u65B0\u6587\u4EF6\u5DF2\u521B\u5EFA: ${filePath} (${newString.length} \u5B57\u7B26)`;
|
|
40899
41023
|
}
|
|
40900
41024
|
let contentOld;
|
|
40901
41025
|
try {
|
|
40902
|
-
const fileStat = await (0,
|
|
41026
|
+
const fileStat = await (0, import_promises11.stat)(filePath);
|
|
40903
41027
|
if (!fileStat.isFile()) {
|
|
40904
41028
|
return `\u9519\u8BEF: \u8DEF\u5F84\u4E0D\u662F\u6587\u4EF6: ${filePath}`;
|
|
40905
41029
|
}
|
|
40906
|
-
contentOld = await (0,
|
|
41030
|
+
contentOld = await (0, import_promises11.readFile)(filePath, "utf-8");
|
|
40907
41031
|
} catch {
|
|
40908
41032
|
return `\u9519\u8BEF: \u6587\u4EF6\u4E0D\u5B58\u5728: ${filePath}`;
|
|
40909
41033
|
}
|
|
@@ -40914,7 +41038,7 @@ var editTool = {
|
|
|
40914
41038
|
const msg = error instanceof Error ? error.message : String(error);
|
|
40915
41039
|
return `\u7F16\u8F91\u5931\u8D25: ${msg}`;
|
|
40916
41040
|
}
|
|
40917
|
-
await (0,
|
|
41041
|
+
await (0, import_promises11.writeFile)(filePath, contentNew, "utf-8");
|
|
40918
41042
|
const diff = trimDiff(
|
|
40919
41043
|
createTwoFilesPatch(filePath, filePath, contentOld, contentNew)
|
|
40920
41044
|
);
|
|
@@ -43497,12 +43621,12 @@ ${replies}`;
|
|
|
43497
43621
|
|
|
43498
43622
|
// src/department/learning.ts
|
|
43499
43623
|
var import_node_fs4 = require("node:fs");
|
|
43500
|
-
var
|
|
43624
|
+
var import_node_path13 = __toESM(require("node:path"));
|
|
43501
43625
|
var import_node_crypto9 = require("node:crypto");
|
|
43502
43626
|
|
|
43503
43627
|
// src/skill/SkillValidator.ts
|
|
43504
43628
|
var import_node_fs3 = require("node:fs");
|
|
43505
|
-
var
|
|
43629
|
+
var import_node_path12 = __toESM(require("node:path"));
|
|
43506
43630
|
var SKILL_NAME_PATTERN = /^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$/;
|
|
43507
43631
|
var REQUIRED_SECTIONS = [
|
|
43508
43632
|
/(^|\n)##\s+(when to use|何时使用|trigger|triggers)\b/i,
|
|
@@ -43528,9 +43652,9 @@ var assertSafeSkillTarget = (rootDir, skillName) => {
|
|
|
43528
43652
|
if (!isValidSkillName(skillName)) {
|
|
43529
43653
|
throw new Error(`Invalid skill name "${skillName}". Use lowercase letters, digits, and single hyphens only.`);
|
|
43530
43654
|
}
|
|
43531
|
-
const root =
|
|
43532
|
-
const target =
|
|
43533
|
-
if (target !==
|
|
43655
|
+
const root = import_node_path12.default.resolve(rootDir);
|
|
43656
|
+
const target = import_node_path12.default.resolve(root, skillName);
|
|
43657
|
+
if (target !== import_node_path12.default.join(root, skillName) || !target.startsWith(root + import_node_path12.default.sep)) {
|
|
43534
43658
|
throw new Error(`Invalid skill install target for "${skillName}".`);
|
|
43535
43659
|
}
|
|
43536
43660
|
return target;
|
|
@@ -43603,12 +43727,12 @@ var validateSkillDocument = (input) => {
|
|
|
43603
43727
|
}
|
|
43604
43728
|
}
|
|
43605
43729
|
if (input.baseDir) {
|
|
43606
|
-
const normalizedBase =
|
|
43730
|
+
const normalizedBase = import_node_path12.default.resolve(input.baseDir);
|
|
43607
43731
|
for (const match2 of parsed.body.matchAll(/\]\(([^)]+)\)/g)) {
|
|
43608
43732
|
const href = match2[1].trim();
|
|
43609
43733
|
if (!href || /^[a-z][a-z0-9+.-]*:/i.test(href) || href.startsWith(`#`)) continue;
|
|
43610
|
-
const target =
|
|
43611
|
-
if (!target.startsWith(normalizedBase +
|
|
43734
|
+
const target = import_node_path12.default.resolve(normalizedBase, href.split(`#`)[0]);
|
|
43735
|
+
if (!target.startsWith(normalizedBase + import_node_path12.default.sep) && target !== normalizedBase) {
|
|
43612
43736
|
addError(errors, `unsafe_reference`, `Relative link "${href}" escapes the skill directory.`);
|
|
43613
43737
|
} else if (!(0, import_node_fs3.existsSync)(target)) {
|
|
43614
43738
|
addError(errors, `missing_reference`, `Relative link "${href}" does not exist in the skill directory.`);
|
|
@@ -43627,7 +43751,7 @@ var mergeIssues = (target, source) => {
|
|
|
43627
43751
|
target.warnings.push(...source.warnings);
|
|
43628
43752
|
};
|
|
43629
43753
|
var validateScriptsDirectory = (skillDir, warnings) => {
|
|
43630
|
-
const scriptsDir =
|
|
43754
|
+
const scriptsDir = import_node_path12.default.join(skillDir, `scripts`);
|
|
43631
43755
|
if (!(0, import_node_fs3.existsSync)(scriptsDir)) return;
|
|
43632
43756
|
const entries = (0, import_node_fs3.readdirSync)(scriptsDir, { withFileTypes: true }).filter((entry) => entry.isFile());
|
|
43633
43757
|
if (entries.length === 0) {
|
|
@@ -43637,8 +43761,8 @@ var validateScriptsDirectory = (skillDir, warnings) => {
|
|
|
43637
43761
|
var validateSkillDirectory = (skillDir, options = {}) => {
|
|
43638
43762
|
const errors = [];
|
|
43639
43763
|
const warnings = [];
|
|
43640
|
-
const normalizedSkillDir =
|
|
43641
|
-
const skillMdPath =
|
|
43764
|
+
const normalizedSkillDir = import_node_path12.default.resolve(skillDir);
|
|
43765
|
+
const skillMdPath = import_node_path12.default.join(normalizedSkillDir, `SKILL.md`);
|
|
43642
43766
|
if (!(0, import_node_fs3.existsSync)(normalizedSkillDir) || !(0, import_node_fs3.statSync)(normalizedSkillDir).isDirectory()) {
|
|
43643
43767
|
addError(errors, `missing_skill_dir`, `Skill directory does not exist: ${normalizedSkillDir}`);
|
|
43644
43768
|
return { ok: false, errors, warnings, skillDir: normalizedSkillDir, skillMdPath };
|
|
@@ -43649,7 +43773,7 @@ var validateSkillDirectory = (skillDir, options = {}) => {
|
|
|
43649
43773
|
}
|
|
43650
43774
|
const raw2 = (0, import_node_fs3.readFileSync)(skillMdPath, `utf-8`);
|
|
43651
43775
|
const documentResult = validateSkillDocument({
|
|
43652
|
-
skillName: options.expectedName ??
|
|
43776
|
+
skillName: options.expectedName ?? import_node_path12.default.basename(normalizedSkillDir),
|
|
43653
43777
|
skillMd: raw2,
|
|
43654
43778
|
baseDir: normalizedSkillDir
|
|
43655
43779
|
});
|
|
@@ -43707,20 +43831,20 @@ var readJsonArray = (filePath) => {
|
|
|
43707
43831
|
return JSON.parse((0, import_node_fs4.readFileSync)(filePath, "utf-8"));
|
|
43708
43832
|
};
|
|
43709
43833
|
var writeJsonArray = (filePath, records) => {
|
|
43710
|
-
ensureDir(
|
|
43834
|
+
ensureDir(import_node_path13.default.dirname(filePath));
|
|
43711
43835
|
(0, import_node_fs4.writeFileSync)(filePath, JSON.stringify(records, null, " "), "utf-8");
|
|
43712
43836
|
};
|
|
43713
43837
|
var departmentMemoryPath = (departmentName) => {
|
|
43714
|
-
return
|
|
43838
|
+
return import_node_path13.default.join(getDepartmentWorkSpaceDir(departmentName), "department-memory.json");
|
|
43715
43839
|
};
|
|
43716
43840
|
var departmentSkillPath = (departmentName) => {
|
|
43717
|
-
return
|
|
43841
|
+
return import_node_path13.default.join(getDepartmentWorkSpaceDir(departmentName), "department-skills.json");
|
|
43718
43842
|
};
|
|
43719
43843
|
var departmentSkillDir = (departmentName, skillName) => {
|
|
43720
|
-
return assertSafeSkillTarget(
|
|
43844
|
+
return assertSafeSkillTarget(import_node_path13.default.join(getDepartmentWorkSpaceDir(departmentName), "skills"), skillName);
|
|
43721
43845
|
};
|
|
43722
43846
|
var proposalsPath = () => {
|
|
43723
|
-
return
|
|
43847
|
+
return import_node_path13.default.join(getDepartmentBaseDir(), "department-proposals.json");
|
|
43724
43848
|
};
|
|
43725
43849
|
var getDepartmentNameForHead = (request) => {
|
|
43726
43850
|
const mailboxId = request?.departmentAgentId;
|
|
@@ -43818,7 +43942,7 @@ var keepDepartmentSkill = (departmentName, id) => {
|
|
|
43818
43942
|
${formatSkillValidationIssues(validation)}`);
|
|
43819
43943
|
}
|
|
43820
43944
|
ensureDir(skillDir);
|
|
43821
|
-
(0, import_node_fs4.writeFileSync)(
|
|
43945
|
+
(0, import_node_fs4.writeFileSync)(import_node_path13.default.join(skillDir, "SKILL.md"), records[idx].skillMd, "utf-8");
|
|
43822
43946
|
const smokeTest = smokeTestSkillDirectory(skillDir, { expectedName: records[idx].skillName });
|
|
43823
43947
|
if (!smokeTest.ok) {
|
|
43824
43948
|
throw new Error(`[departmentSkill] Skill smoke test \u5931\u8D25\uFF1A
|
|
@@ -44220,8 +44344,8 @@ function findExecutableShell2() {
|
|
|
44220
44344
|
}
|
|
44221
44345
|
function validateCwd(cwd) {
|
|
44222
44346
|
try {
|
|
44223
|
-
const
|
|
44224
|
-
if (!
|
|
44347
|
+
const stat11 = (0, import_node_fs5.statSync)(cwd);
|
|
44348
|
+
if (!stat11.isDirectory()) {
|
|
44225
44349
|
return `[bash] \u9519\u8BEF: cwd \u4E0D\u662F\u76EE\u5F55: ${cwd}`;
|
|
44226
44350
|
}
|
|
44227
44351
|
(0, import_node_fs5.accessSync)(cwd, import_node_fs5.constants.R_OK | import_node_fs5.constants.X_OK);
|
|
@@ -44958,7 +45082,7 @@ var readDreamHistoryLimit = () => {
|
|
|
44958
45082
|
// src/skillForge/SkillForgeEngine.ts
|
|
44959
45083
|
var import_node_fs6 = require("node:fs");
|
|
44960
45084
|
var import_node_os2 = require("node:os");
|
|
44961
|
-
var
|
|
45085
|
+
var import_node_path14 = require("node:path");
|
|
44962
45086
|
var import_node_crypto11 = require("node:crypto");
|
|
44963
45087
|
var SkillForgeEngine = class {
|
|
44964
45088
|
proposalStorage;
|
|
@@ -44967,8 +45091,8 @@ var SkillForgeEngine = class {
|
|
|
44967
45091
|
constructor(deps) {
|
|
44968
45092
|
this.proposalStorage = deps.proposalStorage;
|
|
44969
45093
|
const opt = deps.options ?? {};
|
|
44970
|
-
this.draftRoot = opt.draftRoot ?? (0,
|
|
44971
|
-
this.skillsInstallDir = opt.skillsInstallDir ?? (0,
|
|
45094
|
+
this.draftRoot = opt.draftRoot ?? (0, import_node_path14.join)((0, import_node_os2.homedir)(), ".duclaw", "skill-proposals");
|
|
45095
|
+
this.skillsInstallDir = opt.skillsInstallDir ?? (0, import_node_path14.join)((0, import_node_os2.homedir)(), ".agents", "skills");
|
|
44972
45096
|
}
|
|
44973
45097
|
// ---------- 公开方法 ----------
|
|
44974
45098
|
/**
|
|
@@ -44994,9 +45118,9 @@ ${formatSkillValidationIssues(validation)}`);
|
|
|
44994
45118
|
return null;
|
|
44995
45119
|
}
|
|
44996
45120
|
const id = (0, import_node_crypto11.randomBytes)(4).toString("hex");
|
|
44997
|
-
const draftDir = (0,
|
|
45121
|
+
const draftDir = (0, import_node_path14.join)(this.draftRoot, userId, id);
|
|
44998
45122
|
(0, import_node_fs6.mkdirSync)(draftDir, { recursive: true });
|
|
44999
|
-
(0, import_node_fs6.writeFileSync)((0,
|
|
45123
|
+
(0, import_node_fs6.writeFileSync)((0, import_node_path14.join)(draftDir, "SKILL.md"), skillMd, "utf-8");
|
|
45000
45124
|
const directoryValidation = validateSkillDirectory(draftDir, { expectedName: skillName });
|
|
45001
45125
|
if (!directoryValidation.ok) {
|
|
45002
45126
|
try {
|
|
@@ -48187,26 +48311,26 @@ var handleParsingNestedValues = (form, key, value) => {
|
|
|
48187
48311
|
};
|
|
48188
48312
|
|
|
48189
48313
|
// node_modules/.pnpm/hono@4.12.9/node_modules/hono/dist/utils/url.js
|
|
48190
|
-
var splitPath = (
|
|
48191
|
-
const paths =
|
|
48314
|
+
var splitPath = (path21) => {
|
|
48315
|
+
const paths = path21.split("/");
|
|
48192
48316
|
if (paths[0] === "") {
|
|
48193
48317
|
paths.shift();
|
|
48194
48318
|
}
|
|
48195
48319
|
return paths;
|
|
48196
48320
|
};
|
|
48197
48321
|
var splitRoutingPath = (routePath) => {
|
|
48198
|
-
const { groups, path:
|
|
48199
|
-
const paths = splitPath(
|
|
48322
|
+
const { groups, path: path21 } = extractGroupsFromPath(routePath);
|
|
48323
|
+
const paths = splitPath(path21);
|
|
48200
48324
|
return replaceGroupMarks(paths, groups);
|
|
48201
48325
|
};
|
|
48202
|
-
var extractGroupsFromPath = (
|
|
48326
|
+
var extractGroupsFromPath = (path21) => {
|
|
48203
48327
|
const groups = [];
|
|
48204
|
-
|
|
48328
|
+
path21 = path21.replace(/\{[^}]+\}/g, (match2, index) => {
|
|
48205
48329
|
const mark = `@${index}`;
|
|
48206
48330
|
groups.push([mark, match2]);
|
|
48207
48331
|
return mark;
|
|
48208
48332
|
});
|
|
48209
|
-
return { groups, path:
|
|
48333
|
+
return { groups, path: path21 };
|
|
48210
48334
|
};
|
|
48211
48335
|
var replaceGroupMarks = (paths, groups) => {
|
|
48212
48336
|
for (let i = groups.length - 1; i >= 0; i--) {
|
|
@@ -48263,8 +48387,8 @@ var getPath = (request) => {
|
|
|
48263
48387
|
const queryIndex = url.indexOf("?", i);
|
|
48264
48388
|
const hashIndex = url.indexOf("#", i);
|
|
48265
48389
|
const end = queryIndex === -1 ? hashIndex === -1 ? void 0 : hashIndex : hashIndex === -1 ? queryIndex : Math.min(queryIndex, hashIndex);
|
|
48266
|
-
const
|
|
48267
|
-
return tryDecodeURI(
|
|
48390
|
+
const path21 = url.slice(start, end);
|
|
48391
|
+
return tryDecodeURI(path21.includes("%25") ? path21.replace(/%25/g, "%2525") : path21);
|
|
48268
48392
|
} else if (charCode === 63 || charCode === 35) {
|
|
48269
48393
|
break;
|
|
48270
48394
|
}
|
|
@@ -48281,11 +48405,11 @@ var mergePath = (base, sub, ...rest) => {
|
|
|
48281
48405
|
}
|
|
48282
48406
|
return `${base?.[0] === "/" ? "" : "/"}${base}${sub === "/" ? "" : `${base?.at(-1) === "/" ? "" : "/"}${sub?.[0] === "/" ? sub.slice(1) : sub}`}`;
|
|
48283
48407
|
};
|
|
48284
|
-
var checkOptionalParameter = (
|
|
48285
|
-
if (
|
|
48408
|
+
var checkOptionalParameter = (path21) => {
|
|
48409
|
+
if (path21.charCodeAt(path21.length - 1) !== 63 || !path21.includes(":")) {
|
|
48286
48410
|
return null;
|
|
48287
48411
|
}
|
|
48288
|
-
const segments =
|
|
48412
|
+
const segments = path21.split("/");
|
|
48289
48413
|
const results = [];
|
|
48290
48414
|
let basePath = "";
|
|
48291
48415
|
segments.forEach((segment) => {
|
|
@@ -48426,9 +48550,9 @@ var HonoRequest = class {
|
|
|
48426
48550
|
*/
|
|
48427
48551
|
path;
|
|
48428
48552
|
bodyCache = {};
|
|
48429
|
-
constructor(request,
|
|
48553
|
+
constructor(request, path21 = "/", matchResult = [[]]) {
|
|
48430
48554
|
this.raw = request;
|
|
48431
|
-
this.path =
|
|
48555
|
+
this.path = path21;
|
|
48432
48556
|
this.#matchResult = matchResult;
|
|
48433
48557
|
this.#validatedData = {};
|
|
48434
48558
|
}
|
|
@@ -49165,8 +49289,8 @@ var Hono = class _Hono {
|
|
|
49165
49289
|
return this;
|
|
49166
49290
|
};
|
|
49167
49291
|
});
|
|
49168
|
-
this.on = (method,
|
|
49169
|
-
for (const p of [
|
|
49292
|
+
this.on = (method, path21, ...handlers) => {
|
|
49293
|
+
for (const p of [path21].flat()) {
|
|
49170
49294
|
this.#path = p;
|
|
49171
49295
|
for (const m of [method].flat()) {
|
|
49172
49296
|
handlers.map((handler) => {
|
|
@@ -49223,8 +49347,8 @@ var Hono = class _Hono {
|
|
|
49223
49347
|
* app.route("/api", app2) // GET /api/user
|
|
49224
49348
|
* ```
|
|
49225
49349
|
*/
|
|
49226
|
-
route(
|
|
49227
|
-
const subApp = this.basePath(
|
|
49350
|
+
route(path21, app) {
|
|
49351
|
+
const subApp = this.basePath(path21);
|
|
49228
49352
|
app.routes.map((r) => {
|
|
49229
49353
|
let handler;
|
|
49230
49354
|
if (app.errorHandler === errorHandler) {
|
|
@@ -49250,9 +49374,9 @@ var Hono = class _Hono {
|
|
|
49250
49374
|
* const api = new Hono().basePath('/api')
|
|
49251
49375
|
* ```
|
|
49252
49376
|
*/
|
|
49253
|
-
basePath(
|
|
49377
|
+
basePath(path21) {
|
|
49254
49378
|
const subApp = this.#clone();
|
|
49255
|
-
subApp._basePath = mergePath(this._basePath,
|
|
49379
|
+
subApp._basePath = mergePath(this._basePath, path21);
|
|
49256
49380
|
return subApp;
|
|
49257
49381
|
}
|
|
49258
49382
|
/**
|
|
@@ -49326,7 +49450,7 @@ var Hono = class _Hono {
|
|
|
49326
49450
|
* })
|
|
49327
49451
|
* ```
|
|
49328
49452
|
*/
|
|
49329
|
-
mount(
|
|
49453
|
+
mount(path21, applicationHandler, options) {
|
|
49330
49454
|
let replaceRequest;
|
|
49331
49455
|
let optionHandler;
|
|
49332
49456
|
if (options) {
|
|
@@ -49353,7 +49477,7 @@ var Hono = class _Hono {
|
|
|
49353
49477
|
return [c.env, executionContext];
|
|
49354
49478
|
};
|
|
49355
49479
|
replaceRequest ||= (() => {
|
|
49356
|
-
const mergedPath = mergePath(this._basePath,
|
|
49480
|
+
const mergedPath = mergePath(this._basePath, path21);
|
|
49357
49481
|
const pathPrefixLength = mergedPath === "/" ? 0 : mergedPath.length;
|
|
49358
49482
|
return (request) => {
|
|
49359
49483
|
const url = new URL(request.url);
|
|
@@ -49368,14 +49492,14 @@ var Hono = class _Hono {
|
|
|
49368
49492
|
}
|
|
49369
49493
|
await next();
|
|
49370
49494
|
};
|
|
49371
|
-
this.#addRoute(METHOD_NAME_ALL, mergePath(
|
|
49495
|
+
this.#addRoute(METHOD_NAME_ALL, mergePath(path21, "*"), handler);
|
|
49372
49496
|
return this;
|
|
49373
49497
|
}
|
|
49374
|
-
#addRoute(method,
|
|
49498
|
+
#addRoute(method, path21, handler) {
|
|
49375
49499
|
method = method.toUpperCase();
|
|
49376
|
-
|
|
49377
|
-
const r = { basePath: this._basePath, path:
|
|
49378
|
-
this.router.add(method,
|
|
49500
|
+
path21 = mergePath(this._basePath, path21);
|
|
49501
|
+
const r = { basePath: this._basePath, path: path21, method, handler };
|
|
49502
|
+
this.router.add(method, path21, [handler, r]);
|
|
49379
49503
|
this.routes.push(r);
|
|
49380
49504
|
}
|
|
49381
49505
|
#handleError(err, c) {
|
|
@@ -49388,10 +49512,10 @@ var Hono = class _Hono {
|
|
|
49388
49512
|
if (method === "HEAD") {
|
|
49389
49513
|
return (async () => new Response(null, await this.#dispatch(request, executionCtx, env, "GET")))();
|
|
49390
49514
|
}
|
|
49391
|
-
const
|
|
49392
|
-
const matchResult = this.router.match(method,
|
|
49515
|
+
const path21 = this.getPath(request, { env });
|
|
49516
|
+
const matchResult = this.router.match(method, path21);
|
|
49393
49517
|
const c = new Context(request, {
|
|
49394
|
-
path:
|
|
49518
|
+
path: path21,
|
|
49395
49519
|
matchResult,
|
|
49396
49520
|
env,
|
|
49397
49521
|
executionCtx,
|
|
@@ -49491,7 +49615,7 @@ var Hono = class _Hono {
|
|
|
49491
49615
|
|
|
49492
49616
|
// node_modules/.pnpm/hono@4.12.9/node_modules/hono/dist/router/reg-exp-router/matcher.js
|
|
49493
49617
|
var emptyParam = [];
|
|
49494
|
-
function match(method,
|
|
49618
|
+
function match(method, path21) {
|
|
49495
49619
|
const matchers = this.buildAllMatchers();
|
|
49496
49620
|
const match2 = ((method2, path22) => {
|
|
49497
49621
|
const matcher = matchers[method2] || matchers[METHOD_NAME_ALL];
|
|
@@ -49507,7 +49631,7 @@ function match(method, path20) {
|
|
|
49507
49631
|
return [matcher[1][index], match3];
|
|
49508
49632
|
});
|
|
49509
49633
|
this.match = match2;
|
|
49510
|
-
return match2(method,
|
|
49634
|
+
return match2(method, path21);
|
|
49511
49635
|
}
|
|
49512
49636
|
|
|
49513
49637
|
// node_modules/.pnpm/hono@4.12.9/node_modules/hono/dist/router/reg-exp-router/node.js
|
|
@@ -49622,12 +49746,12 @@ var Node = class _Node {
|
|
|
49622
49746
|
var Trie = class {
|
|
49623
49747
|
#context = { varIndex: 0 };
|
|
49624
49748
|
#root = new Node();
|
|
49625
|
-
insert(
|
|
49749
|
+
insert(path21, index, pathErrorCheckOnly) {
|
|
49626
49750
|
const paramAssoc = [];
|
|
49627
49751
|
const groups = [];
|
|
49628
49752
|
for (let i = 0; ; ) {
|
|
49629
49753
|
let replaced = false;
|
|
49630
|
-
|
|
49754
|
+
path21 = path21.replace(/\{[^}]+\}/g, (m) => {
|
|
49631
49755
|
const mark = `@\\${i}`;
|
|
49632
49756
|
groups[i] = [mark, m];
|
|
49633
49757
|
i++;
|
|
@@ -49638,7 +49762,7 @@ var Trie = class {
|
|
|
49638
49762
|
break;
|
|
49639
49763
|
}
|
|
49640
49764
|
}
|
|
49641
|
-
const tokens =
|
|
49765
|
+
const tokens = path21.match(/(?::[^\/]+)|(?:\/\*$)|./g) || [];
|
|
49642
49766
|
for (let i = groups.length - 1; i >= 0; i--) {
|
|
49643
49767
|
const [mark] = groups[i];
|
|
49644
49768
|
for (let j = tokens.length - 1; j >= 0; j--) {
|
|
@@ -49677,9 +49801,9 @@ var Trie = class {
|
|
|
49677
49801
|
// node_modules/.pnpm/hono@4.12.9/node_modules/hono/dist/router/reg-exp-router/router.js
|
|
49678
49802
|
var nullMatcher = [/^$/, [], /* @__PURE__ */ Object.create(null)];
|
|
49679
49803
|
var wildcardRegExpCache = /* @__PURE__ */ Object.create(null);
|
|
49680
|
-
function buildWildcardRegExp(
|
|
49681
|
-
return wildcardRegExpCache[
|
|
49682
|
-
|
|
49804
|
+
function buildWildcardRegExp(path21) {
|
|
49805
|
+
return wildcardRegExpCache[path21] ??= new RegExp(
|
|
49806
|
+
path21 === "*" ? "" : `^${path21.replace(
|
|
49683
49807
|
/\/\*$|([.\\+*[^\]$()])/g,
|
|
49684
49808
|
(_, metaChar) => metaChar ? `\\${metaChar}` : "(?:|/.*)"
|
|
49685
49809
|
)}$`
|
|
@@ -49701,17 +49825,17 @@ function buildMatcherFromPreprocessedRoutes(routes) {
|
|
|
49701
49825
|
);
|
|
49702
49826
|
const staticMap = /* @__PURE__ */ Object.create(null);
|
|
49703
49827
|
for (let i = 0, j = -1, len = routesWithStaticPathFlag.length; i < len; i++) {
|
|
49704
|
-
const [pathErrorCheckOnly,
|
|
49828
|
+
const [pathErrorCheckOnly, path21, handlers] = routesWithStaticPathFlag[i];
|
|
49705
49829
|
if (pathErrorCheckOnly) {
|
|
49706
|
-
staticMap[
|
|
49830
|
+
staticMap[path21] = [handlers.map(([h]) => [h, /* @__PURE__ */ Object.create(null)]), emptyParam];
|
|
49707
49831
|
} else {
|
|
49708
49832
|
j++;
|
|
49709
49833
|
}
|
|
49710
49834
|
let paramAssoc;
|
|
49711
49835
|
try {
|
|
49712
|
-
paramAssoc = trie.insert(
|
|
49836
|
+
paramAssoc = trie.insert(path21, j, pathErrorCheckOnly);
|
|
49713
49837
|
} catch (e) {
|
|
49714
|
-
throw e === PATH_ERROR ? new UnsupportedPathError(
|
|
49838
|
+
throw e === PATH_ERROR ? new UnsupportedPathError(path21) : e;
|
|
49715
49839
|
}
|
|
49716
49840
|
if (pathErrorCheckOnly) {
|
|
49717
49841
|
continue;
|
|
@@ -49745,12 +49869,12 @@ function buildMatcherFromPreprocessedRoutes(routes) {
|
|
|
49745
49869
|
}
|
|
49746
49870
|
return [regexp, handlerMap, staticMap];
|
|
49747
49871
|
}
|
|
49748
|
-
function findMiddleware(middleware,
|
|
49872
|
+
function findMiddleware(middleware, path21) {
|
|
49749
49873
|
if (!middleware) {
|
|
49750
49874
|
return void 0;
|
|
49751
49875
|
}
|
|
49752
49876
|
for (const k of Object.keys(middleware).sort((a, b) => b.length - a.length)) {
|
|
49753
|
-
if (buildWildcardRegExp(k).test(
|
|
49877
|
+
if (buildWildcardRegExp(k).test(path21)) {
|
|
49754
49878
|
return [...middleware[k]];
|
|
49755
49879
|
}
|
|
49756
49880
|
}
|
|
@@ -49764,7 +49888,7 @@ var RegExpRouter = class {
|
|
|
49764
49888
|
this.#middleware = { [METHOD_NAME_ALL]: /* @__PURE__ */ Object.create(null) };
|
|
49765
49889
|
this.#routes = { [METHOD_NAME_ALL]: /* @__PURE__ */ Object.create(null) };
|
|
49766
49890
|
}
|
|
49767
|
-
add(method,
|
|
49891
|
+
add(method, path21, handler) {
|
|
49768
49892
|
const middleware = this.#middleware;
|
|
49769
49893
|
const routes = this.#routes;
|
|
49770
49894
|
if (!middleware || !routes) {
|
|
@@ -49779,18 +49903,18 @@ var RegExpRouter = class {
|
|
|
49779
49903
|
});
|
|
49780
49904
|
});
|
|
49781
49905
|
}
|
|
49782
|
-
if (
|
|
49783
|
-
|
|
49906
|
+
if (path21 === "/*") {
|
|
49907
|
+
path21 = "*";
|
|
49784
49908
|
}
|
|
49785
|
-
const paramCount = (
|
|
49786
|
-
if (/\*$/.test(
|
|
49787
|
-
const re = buildWildcardRegExp(
|
|
49909
|
+
const paramCount = (path21.match(/\/:/g) || []).length;
|
|
49910
|
+
if (/\*$/.test(path21)) {
|
|
49911
|
+
const re = buildWildcardRegExp(path21);
|
|
49788
49912
|
if (method === METHOD_NAME_ALL) {
|
|
49789
49913
|
Object.keys(middleware).forEach((m) => {
|
|
49790
|
-
middleware[m][
|
|
49914
|
+
middleware[m][path21] ||= findMiddleware(middleware[m], path21) || findMiddleware(middleware[METHOD_NAME_ALL], path21) || [];
|
|
49791
49915
|
});
|
|
49792
49916
|
} else {
|
|
49793
|
-
middleware[method][
|
|
49917
|
+
middleware[method][path21] ||= findMiddleware(middleware[method], path21) || findMiddleware(middleware[METHOD_NAME_ALL], path21) || [];
|
|
49794
49918
|
}
|
|
49795
49919
|
Object.keys(middleware).forEach((m) => {
|
|
49796
49920
|
if (method === METHOD_NAME_ALL || method === m) {
|
|
@@ -49808,7 +49932,7 @@ var RegExpRouter = class {
|
|
|
49808
49932
|
});
|
|
49809
49933
|
return;
|
|
49810
49934
|
}
|
|
49811
|
-
const paths = checkOptionalParameter(
|
|
49935
|
+
const paths = checkOptionalParameter(path21) || [path21];
|
|
49812
49936
|
for (let i = 0, len = paths.length; i < len; i++) {
|
|
49813
49937
|
const path22 = paths[i];
|
|
49814
49938
|
Object.keys(routes).forEach((m) => {
|
|
@@ -49835,13 +49959,13 @@ var RegExpRouter = class {
|
|
|
49835
49959
|
const routes = [];
|
|
49836
49960
|
let hasOwnRoute = method === METHOD_NAME_ALL;
|
|
49837
49961
|
[this.#middleware, this.#routes].forEach((r) => {
|
|
49838
|
-
const ownRoute = r[method] ? Object.keys(r[method]).map((
|
|
49962
|
+
const ownRoute = r[method] ? Object.keys(r[method]).map((path21) => [path21, r[method][path21]]) : [];
|
|
49839
49963
|
if (ownRoute.length !== 0) {
|
|
49840
49964
|
hasOwnRoute ||= true;
|
|
49841
49965
|
routes.push(...ownRoute);
|
|
49842
49966
|
} else if (method !== METHOD_NAME_ALL) {
|
|
49843
49967
|
routes.push(
|
|
49844
|
-
...Object.keys(r[METHOD_NAME_ALL]).map((
|
|
49968
|
+
...Object.keys(r[METHOD_NAME_ALL]).map((path21) => [path21, r[METHOD_NAME_ALL][path21]])
|
|
49845
49969
|
);
|
|
49846
49970
|
}
|
|
49847
49971
|
});
|
|
@@ -49861,13 +49985,13 @@ var SmartRouter = class {
|
|
|
49861
49985
|
constructor(init) {
|
|
49862
49986
|
this.#routers = init.routers;
|
|
49863
49987
|
}
|
|
49864
|
-
add(method,
|
|
49988
|
+
add(method, path21, handler) {
|
|
49865
49989
|
if (!this.#routes) {
|
|
49866
49990
|
throw new Error(MESSAGE_MATCHER_IS_ALREADY_BUILT);
|
|
49867
49991
|
}
|
|
49868
|
-
this.#routes.push([method,
|
|
49992
|
+
this.#routes.push([method, path21, handler]);
|
|
49869
49993
|
}
|
|
49870
|
-
match(method,
|
|
49994
|
+
match(method, path21) {
|
|
49871
49995
|
if (!this.#routes) {
|
|
49872
49996
|
throw new Error("Fatal error");
|
|
49873
49997
|
}
|
|
@@ -49882,7 +50006,7 @@ var SmartRouter = class {
|
|
|
49882
50006
|
for (let i2 = 0, len2 = routes.length; i2 < len2; i2++) {
|
|
49883
50007
|
router.add(...routes[i2]);
|
|
49884
50008
|
}
|
|
49885
|
-
res = router.match(method,
|
|
50009
|
+
res = router.match(method, path21);
|
|
49886
50010
|
} catch (e) {
|
|
49887
50011
|
if (e instanceof UnsupportedPathError) {
|
|
49888
50012
|
continue;
|
|
@@ -49932,10 +50056,10 @@ var Node2 = class _Node2 {
|
|
|
49932
50056
|
}
|
|
49933
50057
|
this.#patterns = [];
|
|
49934
50058
|
}
|
|
49935
|
-
insert(method,
|
|
50059
|
+
insert(method, path21, handler) {
|
|
49936
50060
|
this.#order = ++this.#order;
|
|
49937
50061
|
let curNode = this;
|
|
49938
|
-
const parts = splitRoutingPath(
|
|
50062
|
+
const parts = splitRoutingPath(path21);
|
|
49939
50063
|
const possibleKeys = [];
|
|
49940
50064
|
for (let i = 0, len = parts.length; i < len; i++) {
|
|
49941
50065
|
const p = parts[i];
|
|
@@ -49984,12 +50108,12 @@ var Node2 = class _Node2 {
|
|
|
49984
50108
|
}
|
|
49985
50109
|
}
|
|
49986
50110
|
}
|
|
49987
|
-
search(method,
|
|
50111
|
+
search(method, path21) {
|
|
49988
50112
|
const handlerSets = [];
|
|
49989
50113
|
this.#params = emptyParams;
|
|
49990
50114
|
const curNode = this;
|
|
49991
50115
|
let curNodes = [curNode];
|
|
49992
|
-
const parts = splitPath(
|
|
50116
|
+
const parts = splitPath(path21);
|
|
49993
50117
|
const curNodesQueue = [];
|
|
49994
50118
|
const len = parts.length;
|
|
49995
50119
|
let partOffsets = null;
|
|
@@ -50031,13 +50155,13 @@ var Node2 = class _Node2 {
|
|
|
50031
50155
|
if (matcher instanceof RegExp) {
|
|
50032
50156
|
if (partOffsets === null) {
|
|
50033
50157
|
partOffsets = new Array(len);
|
|
50034
|
-
let offset =
|
|
50158
|
+
let offset = path21[0] === "/" ? 1 : 0;
|
|
50035
50159
|
for (let p = 0; p < len; p++) {
|
|
50036
50160
|
partOffsets[p] = offset;
|
|
50037
50161
|
offset += parts[p].length + 1;
|
|
50038
50162
|
}
|
|
50039
50163
|
}
|
|
50040
|
-
const restPathString =
|
|
50164
|
+
const restPathString = path21.substring(partOffsets[i]);
|
|
50041
50165
|
const m = matcher.exec(restPathString);
|
|
50042
50166
|
if (m) {
|
|
50043
50167
|
params[name] = m[0];
|
|
@@ -50090,18 +50214,18 @@ var TrieRouter = class {
|
|
|
50090
50214
|
constructor() {
|
|
50091
50215
|
this.#node = new Node2();
|
|
50092
50216
|
}
|
|
50093
|
-
add(method,
|
|
50094
|
-
const results = checkOptionalParameter(
|
|
50217
|
+
add(method, path21, handler) {
|
|
50218
|
+
const results = checkOptionalParameter(path21);
|
|
50095
50219
|
if (results) {
|
|
50096
50220
|
for (let i = 0, len = results.length; i < len; i++) {
|
|
50097
50221
|
this.#node.insert(method, results[i], handler);
|
|
50098
50222
|
}
|
|
50099
50223
|
return;
|
|
50100
50224
|
}
|
|
50101
|
-
this.#node.insert(method,
|
|
50225
|
+
this.#node.insert(method, path21, handler);
|
|
50102
50226
|
}
|
|
50103
|
-
match(method,
|
|
50104
|
-
return this.#node.search(method,
|
|
50227
|
+
match(method, path21) {
|
|
50228
|
+
return this.#node.search(method, path21);
|
|
50105
50229
|
}
|
|
50106
50230
|
};
|
|
50107
50231
|
|
|
@@ -50803,10 +50927,10 @@ var createStreamBody = (stream) => {
|
|
|
50803
50927
|
});
|
|
50804
50928
|
return body;
|
|
50805
50929
|
};
|
|
50806
|
-
var getStats = (
|
|
50930
|
+
var getStats = (path21) => {
|
|
50807
50931
|
let stats;
|
|
50808
50932
|
try {
|
|
50809
|
-
stats = (0, import_fs15.statSync)(
|
|
50933
|
+
stats = (0, import_fs15.statSync)(path21);
|
|
50810
50934
|
} catch {
|
|
50811
50935
|
}
|
|
50812
50936
|
return stats;
|
|
@@ -50849,21 +50973,21 @@ var serveStatic = (options = { root: "" }) => {
|
|
|
50849
50973
|
return next();
|
|
50850
50974
|
}
|
|
50851
50975
|
}
|
|
50852
|
-
let
|
|
50976
|
+
let path21 = (0, import_path20.join)(
|
|
50853
50977
|
root,
|
|
50854
50978
|
!optionPath && options.rewriteRequestPath ? options.rewriteRequestPath(filename, c) : filename
|
|
50855
50979
|
);
|
|
50856
|
-
let stats = getStats(
|
|
50980
|
+
let stats = getStats(path21);
|
|
50857
50981
|
if (stats && stats.isDirectory()) {
|
|
50858
50982
|
const indexFile = options.index ?? "index.html";
|
|
50859
|
-
|
|
50860
|
-
stats = getStats(
|
|
50983
|
+
path21 = (0, import_path20.join)(path21, indexFile);
|
|
50984
|
+
stats = getStats(path21);
|
|
50861
50985
|
}
|
|
50862
50986
|
if (!stats) {
|
|
50863
|
-
await options.onNotFound?.(
|
|
50987
|
+
await options.onNotFound?.(path21, c);
|
|
50864
50988
|
return next();
|
|
50865
50989
|
}
|
|
50866
|
-
const mimeType = getMimeType(
|
|
50990
|
+
const mimeType = getMimeType(path21);
|
|
50867
50991
|
c.header("Content-Type", mimeType || "application/octet-stream");
|
|
50868
50992
|
if (options.precompressed && (!mimeType || COMPRESSIBLE_CONTENT_TYPE_REGEX.test(mimeType))) {
|
|
50869
50993
|
const acceptEncodingSet = new Set(
|
|
@@ -50873,12 +50997,12 @@ var serveStatic = (options = { root: "" }) => {
|
|
|
50873
50997
|
if (!acceptEncodingSet.has(encoding)) {
|
|
50874
50998
|
continue;
|
|
50875
50999
|
}
|
|
50876
|
-
const precompressedStats = getStats(
|
|
51000
|
+
const precompressedStats = getStats(path21 + ENCODINGS[encoding]);
|
|
50877
51001
|
if (precompressedStats) {
|
|
50878
51002
|
c.header("Content-Encoding", encoding);
|
|
50879
51003
|
c.header("Vary", "Accept-Encoding", { append: true });
|
|
50880
51004
|
stats = precompressedStats;
|
|
50881
|
-
|
|
51005
|
+
path21 = path21 + ENCODINGS[encoding];
|
|
50882
51006
|
break;
|
|
50883
51007
|
}
|
|
50884
51008
|
}
|
|
@@ -50892,7 +51016,7 @@ var serveStatic = (options = { root: "" }) => {
|
|
|
50892
51016
|
result = c.body(null);
|
|
50893
51017
|
} else if (!range) {
|
|
50894
51018
|
c.header("Content-Length", size.toString());
|
|
50895
|
-
result = c.body(createStreamBody((0, import_fs15.createReadStream)(
|
|
51019
|
+
result = c.body(createStreamBody((0, import_fs15.createReadStream)(path21)), 200);
|
|
50896
51020
|
} else {
|
|
50897
51021
|
c.header("Accept-Ranges", "bytes");
|
|
50898
51022
|
c.header("Date", stats.birthtime.toUTCString());
|
|
@@ -50903,12 +51027,12 @@ var serveStatic = (options = { root: "" }) => {
|
|
|
50903
51027
|
end = size - 1;
|
|
50904
51028
|
}
|
|
50905
51029
|
const chunksize = end - start + 1;
|
|
50906
|
-
const stream = (0, import_fs15.createReadStream)(
|
|
51030
|
+
const stream = (0, import_fs15.createReadStream)(path21, { start, end });
|
|
50907
51031
|
c.header("Content-Length", chunksize.toString());
|
|
50908
51032
|
c.header("Content-Range", `bytes ${start}-${end}/${stats.size}`);
|
|
50909
51033
|
result = c.body(createStreamBody(stream), 206);
|
|
50910
51034
|
}
|
|
50911
|
-
await options.onFound?.(
|
|
51035
|
+
await options.onFound?.(path21, c);
|
|
50912
51036
|
return result;
|
|
50913
51037
|
};
|
|
50914
51038
|
};
|
|
@@ -51002,8 +51126,8 @@ var cors = (options) => {
|
|
|
51002
51126
|
};
|
|
51003
51127
|
|
|
51004
51128
|
// src/server/index.ts
|
|
51005
|
-
var
|
|
51006
|
-
var
|
|
51129
|
+
var import_promises13 = require("node:fs/promises");
|
|
51130
|
+
var import_node_path17 = __toESM(require("node:path"));
|
|
51007
51131
|
|
|
51008
51132
|
// src/git/worktree.ts
|
|
51009
51133
|
var import_child_process2 = require("child_process");
|
|
@@ -52349,7 +52473,7 @@ mailboxRoutes.get("/mailbox/summary", (c) => {
|
|
|
52349
52473
|
// src/server/routes/memory.ts
|
|
52350
52474
|
var import_redis4 = __toESM(require_dist2());
|
|
52351
52475
|
var import_node_fs8 = require("node:fs");
|
|
52352
|
-
var
|
|
52476
|
+
var import_node_path15 = __toESM(require("node:path"));
|
|
52353
52477
|
var memoryEngineSingleton = null;
|
|
52354
52478
|
var dreamStorageSingleton = null;
|
|
52355
52479
|
var dreamHistoryStorageSingleton = null;
|
|
@@ -52454,7 +52578,7 @@ var readJsonFilesFromDir = (dir) => {
|
|
|
52454
52578
|
for (const file of (0, import_node_fs8.readdirSync)(dir)) {
|
|
52455
52579
|
if (!file.endsWith(".json")) continue;
|
|
52456
52580
|
try {
|
|
52457
|
-
result.push(JSON.parse((0, import_node_fs8.readFileSync)(
|
|
52581
|
+
result.push(JSON.parse((0, import_node_fs8.readFileSync)(import_node_path15.default.join(dir, file), "utf-8")));
|
|
52458
52582
|
} catch (err) {
|
|
52459
52583
|
console.warn(`[memoryRoutes] \u8DF3\u8FC7\u65E0\u6CD5\u89E3\u6790\u7684\u672C\u5730\u4E0A\u4E0B\u6587\u6587\u4EF6 ${file}: ${err.message}`);
|
|
52460
52584
|
}
|
|
@@ -52462,11 +52586,11 @@ var readJsonFilesFromDir = (dir) => {
|
|
|
52462
52586
|
return result;
|
|
52463
52587
|
};
|
|
52464
52588
|
var extractFileBackedStorageKeysForTest = (dataDir) => {
|
|
52465
|
-
const kvRoot =
|
|
52589
|
+
const kvRoot = import_node_path15.default.join(dataDir, "kv");
|
|
52466
52590
|
if (!(0, import_node_fs8.existsSync)(kvRoot)) return [];
|
|
52467
52591
|
const keys = [];
|
|
52468
52592
|
for (const prefixDir of (0, import_node_fs8.readdirSync)(kvRoot)) {
|
|
52469
|
-
const absolutePrefixDir =
|
|
52593
|
+
const absolutePrefixDir = import_node_path15.default.join(kvRoot, prefixDir);
|
|
52470
52594
|
if (!(0, import_node_fs8.existsSync)(absolutePrefixDir)) continue;
|
|
52471
52595
|
for (const file of (0, import_node_fs8.readdirSync)(absolutePrefixDir)) {
|
|
52472
52596
|
if (!file.endsWith(".json")) continue;
|
|
@@ -52486,12 +52610,12 @@ var collectLocalConversationUserIds = () => {
|
|
|
52486
52610
|
};
|
|
52487
52611
|
var extractLocalConversationUserIdsForTest = (homeDir) => {
|
|
52488
52612
|
const userIds = /* @__PURE__ */ new Set();
|
|
52489
|
-
for (const context of readJsonFilesFromDir(
|
|
52613
|
+
for (const context of readJsonFilesFromDir(import_node_path15.default.join(homeDir, "goal-context"))) {
|
|
52490
52614
|
addPlausibleUserId(userIds, context.threadId);
|
|
52491
52615
|
addPlausibleUserId(userIds, context.originUserId);
|
|
52492
52616
|
if (context.goalId) addPlausibleUserId(userIds, `kanban:goal:${context.goalId}`);
|
|
52493
52617
|
}
|
|
52494
|
-
for (const goal of readJsonFilesFromDir(
|
|
52618
|
+
for (const goal of readJsonFilesFromDir(import_node_path15.default.join(homeDir, "tasks"))) {
|
|
52495
52619
|
if (goal.id) addPlausibleUserId(userIds, `kanban:goal:${goal.id}`);
|
|
52496
52620
|
}
|
|
52497
52621
|
return userIds;
|
|
@@ -52962,7 +53086,7 @@ var systemRoutes = new Hono2();
|
|
|
52962
53086
|
var startTime = Date.now();
|
|
52963
53087
|
systemRoutes.get("/system/info", (c) => {
|
|
52964
53088
|
return c.json({
|
|
52965
|
-
version: true ? "1.9.
|
|
53089
|
+
version: true ? "1.9.2" : "unknown",
|
|
52966
53090
|
uptime: Math.floor((Date.now() - startTime) / 1e3),
|
|
52967
53091
|
env: process.env.NODE_ENV || "development",
|
|
52968
53092
|
nodeVersion: process.version
|
|
@@ -52971,8 +53095,8 @@ systemRoutes.get("/system/info", (c) => {
|
|
|
52971
53095
|
|
|
52972
53096
|
// src/server/routes/mobile.ts
|
|
52973
53097
|
var import_node_crypto15 = require("node:crypto");
|
|
52974
|
-
var
|
|
52975
|
-
var
|
|
53098
|
+
var import_promises12 = require("node:fs/promises");
|
|
53099
|
+
var import_node_path16 = __toESM(require("node:path"));
|
|
52976
53100
|
var mobileRoutes = new Hono2();
|
|
52977
53101
|
var resolveMobileUserId = (body, headerUserId) => {
|
|
52978
53102
|
return body.userId?.trim() || headerUserId?.trim() || "ios:local-user";
|
|
@@ -53014,12 +53138,12 @@ ${goal.tasks.map((task) => `- [${task.status}] ${task.subject}`).join("\n")}` :
|
|
|
53014
53138
|
return lines.join("\n");
|
|
53015
53139
|
};
|
|
53016
53140
|
var sanitizeFileName = (fileName) => {
|
|
53017
|
-
const cleaned =
|
|
53141
|
+
const cleaned = import_node_path16.default.basename(fileName).replace(/[^\w.\-()\u4e00-\u9fa5 ]+/g, "_").trim();
|
|
53018
53142
|
return cleaned || `attachment-${Date.now()}`;
|
|
53019
53143
|
};
|
|
53020
|
-
var
|
|
53144
|
+
var inferAttachmentType2 = (mimeType = "", fileName = "") => {
|
|
53021
53145
|
if (mimeType.startsWith("image/")) return "image";
|
|
53022
|
-
const ext =
|
|
53146
|
+
const ext = import_node_path16.default.extname(fileName).toLowerCase();
|
|
53023
53147
|
if ([".png", ".jpg", ".jpeg", ".gif", ".webp"].includes(ext)) return "image";
|
|
53024
53148
|
return "file";
|
|
53025
53149
|
};
|
|
@@ -53073,13 +53197,13 @@ mobileRoutes.post("/mobile/attachments", async (c) => {
|
|
|
53073
53197
|
const mobileUserId = resolveMobileUserId(body, c.req.header("x-user-id"));
|
|
53074
53198
|
const fileName = sanitizeFileName(body.fileName || `attachment-${Date.now()}`);
|
|
53075
53199
|
const mimeType = body.mimeType || "application/octet-stream";
|
|
53076
|
-
const type =
|
|
53200
|
+
const type = inferAttachmentType2(mimeType, fileName);
|
|
53077
53201
|
const attachmentId = (0, import_node_crypto15.randomUUID)();
|
|
53078
53202
|
const buffer = Buffer.from(dataBase64, "base64");
|
|
53079
|
-
const dir =
|
|
53080
|
-
await (0,
|
|
53081
|
-
const localPath =
|
|
53082
|
-
await (0,
|
|
53203
|
+
const dir = import_node_path16.default.join(getDuclawWorkspaceDir(), mobileUserId, "mobile", type === "image" ? "images" : "files");
|
|
53204
|
+
await (0, import_promises12.mkdir)(dir, { recursive: true });
|
|
53205
|
+
const localPath = import_node_path16.default.join(dir, `${attachmentId}-${fileName}`);
|
|
53206
|
+
await (0, import_promises12.writeFile)(localPath, buffer);
|
|
53083
53207
|
const attachment = saveMobileAttachment({
|
|
53084
53208
|
id: attachmentId,
|
|
53085
53209
|
type,
|
|
@@ -53297,7 +53421,7 @@ function createServer() {
|
|
|
53297
53421
|
app.route("/api", mobileRoutes);
|
|
53298
53422
|
app.use("/*", serveStatic({ root: webDistRoot }));
|
|
53299
53423
|
app.get("/*", async (c) => {
|
|
53300
|
-
const indexHtml = await (0,
|
|
53424
|
+
const indexHtml = await (0, import_promises13.readFile)(import_node_path17.default.join(webDistRoot, "index.html"), "utf8");
|
|
53301
53425
|
const tenantId = c.req.header("x-tenant-id");
|
|
53302
53426
|
const assetBase = tenantId ? `/t/${tenantId}` : "";
|
|
53303
53427
|
const html = indexHtml.replaceAll('"./', `"${assetBase}/`);
|
|
@@ -53325,9 +53449,9 @@ function shouldStartCoreChannelGateways(env = process.env) {
|
|
|
53325
53449
|
|
|
53326
53450
|
// src/runtime/saasAssets.ts
|
|
53327
53451
|
var import_node_fs9 = require("node:fs");
|
|
53328
|
-
var
|
|
53452
|
+
var import_promises14 = require("node:fs/promises");
|
|
53329
53453
|
var import_node_os3 = require("node:os");
|
|
53330
|
-
var
|
|
53454
|
+
var import_node_path18 = __toESM(require("node:path"));
|
|
53331
53455
|
var MAX_CONTEXT_ASSETS = Number(process.env.DUCLAW_SAAS_ASSET_CONTEXT_LIMIT ?? 1e3);
|
|
53332
53456
|
var MAX_SKILL_ASSETS = Number(process.env.DUCLAW_SAAS_ASSET_SKILL_LIMIT ?? 200);
|
|
53333
53457
|
async function restoreSaasRuntimeAssets(reason) {
|
|
@@ -53358,8 +53482,8 @@ async function restoreContextAsset(context, overwrite) {
|
|
|
53358
53482
|
const target = contextPathForSourceKey(context.sourceKey);
|
|
53359
53483
|
if (!target) return false;
|
|
53360
53484
|
if (!overwrite && (0, import_node_fs9.existsSync)(target)) return false;
|
|
53361
|
-
await (0,
|
|
53362
|
-
await (0,
|
|
53485
|
+
await (0, import_promises14.mkdir)(import_node_path18.default.dirname(target), { recursive: true });
|
|
53486
|
+
await (0, import_promises14.writeFile)(target, JSON.stringify(context.payload), "utf8");
|
|
53363
53487
|
return true;
|
|
53364
53488
|
}
|
|
53365
53489
|
async function restoreSkillAsset(skill, overwrite) {
|
|
@@ -53367,8 +53491,8 @@ async function restoreSkillAsset(skill, overwrite) {
|
|
|
53367
53491
|
const target = safeSkillTargetPath(skill.sourcePath, skill.skillName);
|
|
53368
53492
|
if (!target) return false;
|
|
53369
53493
|
if (!overwrite && (0, import_node_fs9.existsSync)(target)) return false;
|
|
53370
|
-
await (0,
|
|
53371
|
-
await (0,
|
|
53494
|
+
await (0, import_promises14.mkdir)(import_node_path18.default.dirname(target), { recursive: true });
|
|
53495
|
+
await (0, import_promises14.writeFile)(target, skill.skillMd, "utf8");
|
|
53372
53496
|
return true;
|
|
53373
53497
|
}
|
|
53374
53498
|
function runtimeAssetClient() {
|
|
@@ -53400,30 +53524,30 @@ function runtimeAssetClient() {
|
|
|
53400
53524
|
function contextPathForSourceKey(sourceKey) {
|
|
53401
53525
|
if (sourceKey.startsWith("agent:")) {
|
|
53402
53526
|
const logicalKey = sourceKey.slice("agent:".length);
|
|
53403
|
-
return
|
|
53527
|
+
return import_node_path18.default.join(getDuclawDataDir(), "kv", "agent", `${Buffer.from(logicalKey).toString("base64url")}.json`);
|
|
53404
53528
|
}
|
|
53405
53529
|
if (sourceKey.startsWith("goal-context:")) {
|
|
53406
|
-
return
|
|
53530
|
+
return import_node_path18.default.join(getDuclawHomeDir(), "goal-context", `${sourceKey.slice("goal-context:".length)}.json`);
|
|
53407
53531
|
}
|
|
53408
53532
|
if (sourceKey.startsWith("tasks:")) {
|
|
53409
|
-
return
|
|
53533
|
+
return import_node_path18.default.join(getDuclawHomeDir(), "tasks", `${sourceKey.slice("tasks:".length)}.json`);
|
|
53410
53534
|
}
|
|
53411
53535
|
return null;
|
|
53412
53536
|
}
|
|
53413
53537
|
function safeSkillTargetPath(sourcePath, skillName) {
|
|
53414
|
-
const allowedRoots = skillRoots().map((root) =>
|
|
53415
|
-
const normalized =
|
|
53416
|
-
if (allowedRoots.some((root) => normalized ===
|
|
53538
|
+
const allowedRoots = skillRoots().map((root) => import_node_path18.default.resolve(root));
|
|
53539
|
+
const normalized = import_node_path18.default.resolve(sourcePath);
|
|
53540
|
+
if (allowedRoots.some((root) => normalized === import_node_path18.default.join(root, import_node_path18.default.basename(import_node_path18.default.dirname(normalized)), "SKILL.md"))) {
|
|
53417
53541
|
return normalized;
|
|
53418
53542
|
}
|
|
53419
53543
|
const safeName = skillName.replace(/[^a-zA-Z0-9._-]/g, "-").slice(0, 120) || "imported-skill";
|
|
53420
|
-
return
|
|
53544
|
+
return import_node_path18.default.join("/home/user/app/skills", safeName, "SKILL.md");
|
|
53421
53545
|
}
|
|
53422
53546
|
function skillRoots() {
|
|
53423
53547
|
return [
|
|
53424
53548
|
"/home/user/app/skills",
|
|
53425
|
-
|
|
53426
|
-
|
|
53549
|
+
import_node_path18.default.join(getDuclawHomeDir(), "skills"),
|
|
53550
|
+
import_node_path18.default.join((0, import_node_os3.homedir)(), ".agents", "skills")
|
|
53427
53551
|
];
|
|
53428
53552
|
}
|
|
53429
53553
|
|