openclaw-multi-auto 1.8.4 → 1.8.6
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/{agent-ef71Xoo3.js → agent-BomWJjOy.js} +10 -10
- package/dist/{audio-preflight-BQoP-O-0.js → audio-preflight-CZHCr2-5.js} +9 -9
- package/dist/{audio-preflight-SOY4qjTl.js → audio-preflight-DcneE70v.js} +6 -6
- package/dist/{audit-membership-runtime-BQmoiW7f.js → audit-membership-runtime-BDoMjPgy.js} +3 -3
- package/dist/{audit-membership-runtime-0b4ZhE41.js → audit-membership-runtime-fBOVjLNx.js} +4 -4
- package/dist/{auth-profiles-CEEqFOKJ.js → auth-profiles-Dta-Mhaw.js} +438 -438
- package/dist/auth-profiles.runtime-CLSx3zsq.js +7 -0
- package/dist/auth-profiles.runtime-DNqCx0L5.js +11 -0
- package/dist/build-info.json +3 -3
- package/dist/bundled/boot-md/handler.js +10 -10
- package/dist/bundled/bootstrap-extra-files/handler.js +5 -5
- package/dist/bundled/command-logger/handler.js +2 -2
- package/dist/bundled/session-memory/handler.js +9 -9
- package/dist/canvas-host/a2ui/.bundle.hash +1 -1
- package/dist/compact.runtime-BgRco6mO.js +7 -0
- package/dist/compact.runtime-pgjSlzSY.js +11 -0
- package/dist/daemon-cli.js +53 -53
- package/dist/deliver-runtime-BBwve6gL.js +7 -0
- package/dist/deliver-runtime-D4aWAXZ9.js +11 -0
- package/dist/{fetch-sH_NN8SV.js → fetch-BdTTF2z-.js} +2 -2
- package/dist/{fetch-wjPVlu-r.js → fetch-Bdod8UI1.js} +3 -3
- package/dist/{frontmatter-DhmdUnBP.js → frontmatter-DZlWsaUx.js} +3 -3
- package/dist/{github-copilot-token-368sRGBD.js → github-copilot-token-BeFx3MLn.js} +7 -7
- package/dist/{github-copilot-token-C-NbPL95.js → github-copilot-token-BgPOyCXe.js} +7 -7
- package/dist/image-runtime-Brryt_BU.js +11 -0
- package/dist/image-runtime-DiA6CU2y.js +7 -0
- package/dist/llm-slug-generator.js +9 -9
- package/dist/{logger-mQKrXyAc.js → logger-Budylr6i.js} +18 -18
- package/dist/{logger-C0l_Gj8Y.js → logger-DCBlX1uz.js} +7 -7
- package/dist/{login-Ctt81ov4.js → login-Bk8BjEUN.js} +3 -3
- package/dist/{login-CvFRLU0k.js → login-CKmmxErc.js} +4 -4
- package/dist/{login-qr-CHrXhUJY.js → login-qr-CVQlH0l0.js} +7 -7
- package/dist/{login-qr-D-_3HfJq.js → login-qr-KVA4wuh0.js} +10 -10
- package/dist/manager-runtime-BW_M_Kzt.js +7 -0
- package/dist/manager-runtime-D9AEoM1M.js +11 -0
- package/dist/{manager.runtime-DF-LRAbL.js → manager.runtime-BV-CBNb2.js} +10 -10
- package/dist/{manager.runtime-C5odxL4B.js → manager.runtime-KPIwNjNW.js} +12 -12
- package/dist/{model-selection-C9tlIhgN.js → model-selection-CNRMBWfR.js} +271 -271
- package/dist/{paths-jtwudEDq.js → paths-BnSNMlFT.js} +5 -5
- package/dist/{paths-BwJ6yG6k.js → paths-CNIc83Pn.js} +5 -5
- package/dist/pi-model-discovery-runtime-CDKkuBYh.js +11 -0
- package/dist/{pi-model-discovery-runtime-C-YPAOQR.js → pi-model-discovery-runtime-CLfgSk3o.js} +6 -6
- package/dist/{pi-tools.before-tool-call.runtime-CWgsv7kC.js → pi-tools.before-tool-call.runtime-CKzFGrVv.js} +6 -6
- package/dist/{pi-tools.before-tool-call.runtime-CLRTNt4A.js → pi-tools.before-tool-call.runtime-DgAiY2la.js} +9 -9
- package/dist/{pw-ai-CRL5SGWK.js → pw-ai-3ual6adI.js} +9 -9
- package/dist/{pw-ai-BFfAJexr.js → pw-ai-BZnl84YT.js} +6 -6
- package/dist/{qmd-manager-rY-Y6sbN.js → qmd-manager-BmuMJQP3.js} +3 -3
- package/dist/{qmd-manager-CFVuAj9l.js → qmd-manager-DvglNhlJ.js} +5 -5
- package/dist/{query-expansion-BIMwPSMg.js → query-expansion-BMQzl41m.js} +89 -89
- package/dist/{query-expansion-DnS6CGY2.js → query-expansion-DXwSmE_K.js} +8 -8
- package/dist/runtime-whatsapp-login.runtime-Br3SxDXL.js +13 -0
- package/dist/runtime-whatsapp-login.runtime-Dd6rJjLo.js +9 -0
- package/dist/runtime-whatsapp-outbound.runtime-CatYliOE.js +8 -0
- package/dist/runtime-whatsapp-outbound.runtime-L3Qkst0n.js +12 -0
- package/dist/{send-UG1n3OAg.js → send-CHO1gc7n.js} +2 -2
- package/dist/{send-CsgNtXyY.js → send-CXnKWzde.js} +3 -3
- package/dist/{session-BhX4LYCK.js → session-kt-bqE_z.js} +7 -7
- package/dist/{session-Bpmn--zO.js → session-r38wrRC6.js} +6 -6
- package/dist/slash-commands.runtime-BYfxn_xu.js +11 -0
- package/dist/{slash-commands.runtime-DIrX0Ynq.js → slash-commands.runtime-J-gBOPcL.js} +6 -6
- package/dist/{slash-dispatch.runtime-cYx62DOd.js → slash-dispatch.runtime-Cu8ghe1h.js} +9 -9
- package/dist/{slash-dispatch.runtime-CG-xSDdf.js → slash-dispatch.runtime-CwO02PY8.js} +6 -6
- package/dist/slash-skill-commands.runtime-8dS5PTaH.js +11 -0
- package/dist/slash-skill-commands.runtime-BQRfyLdb.js +7 -0
- package/dist/{subagent-registry-runtime-rBYzVSXG.js → subagent-registry-runtime-1IiL0xom.js} +6 -6
- package/dist/{subagent-registry-runtime-DkamrsVw.js → subagent-registry-runtime-Z0fdsGSq.js} +9 -9
- package/dist/{subsystem-CDcEQtQK.js → subsystem-Cr1MiLhx.js} +14 -14
- package/dist/{web-DbsQPRh2.js → web-B_GcnsRF.js} +9 -9
- package/dist/{web-bHB4SzXZ.js → web-CXyjF_si.js} +12 -12
- package/dist/{whatsapp-actions-CnWp29AN.js → whatsapp-actions-BCgsmzOa.js} +7 -7
- package/dist/{whatsapp-actions-BqFiZbuw.js → whatsapp-actions-BUvGEDSk.js} +10 -10
- package/dist/{workspace-Cg3kGb1y.js → workspace-Bi8vpJN0.js} +20 -20
- package/package.json +1 -1
- package/scripts/create-instance.sh +20 -4
- package/dist/auth-profiles.runtime-CuInvQ6F.js +0 -11
- package/dist/auth-profiles.runtime-DXPqJP5A.js +0 -7
- package/dist/compact.runtime-BOg89Gro.js +0 -11
- package/dist/compact.runtime-DS9UVeOh.js +0 -7
- package/dist/deliver-runtime-CUrIlSzN.js +0 -11
- package/dist/deliver-runtime-D929PgeO.js +0 -7
- package/dist/image-runtime-CkdY0-Oo.js +0 -7
- package/dist/image-runtime-Dur8cmII.js +0 -11
- package/dist/manager-runtime-CfBjUnwB.js +0 -11
- package/dist/manager-runtime-PqJtJx-b.js +0 -7
- package/dist/pi-model-discovery-runtime-CK36RhYz.js +0 -11
- package/dist/runtime-whatsapp-login.runtime-CO-iUlqS.js +0 -13
- package/dist/runtime-whatsapp-login.runtime-DeV-bhiR.js +0 -9
- package/dist/runtime-whatsapp-outbound.runtime-BFY32bnC.js +0 -8
- package/dist/runtime-whatsapp-outbound.runtime-IeVUgrJu.js +0 -12
- package/dist/slash-commands.runtime-BTNXGYOP.js +0 -11
- package/dist/slash-skill-commands.runtime-JEA80FeR.js +0 -7
- package/dist/slash-skill-commands.runtime-ThOxhaze.js +0 -11
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { l as resolveStateDir, p as resolveRequiredHomeDir, u as expandHomePrefix } from "./paths-
|
|
2
|
-
import { B as shouldLogVerbose, D as resolveUserPath, I as danger, Y as resolveNodeRequireFromMeta, a as createSubsystemLogger, i as logWarn, n as logError, t as logDebug, w as pathExists$1 } from "./logger-
|
|
1
|
+
import { l as resolveStateDir, p as resolveRequiredHomeDir, u as expandHomePrefix } from "./paths-BnSNMlFT.js";
|
|
2
|
+
import { B as shouldLogVerbose, D as resolveUserPath, I as danger, Y as resolveNodeRequireFromMeta, a as createSubsystemLogger, i as logWarn, n as logError, t as logDebug, w as pathExists$1 } from "./logger-Budylr6i.js";
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
|
-
import
|
|
4
|
+
import fsSync, { constants, readFileSync, statSync } from "node:fs";
|
|
5
5
|
import os from "node:os";
|
|
6
6
|
import path from "node:path";
|
|
7
7
|
import { promisify } from "node:util";
|
|
8
|
-
import fs
|
|
8
|
+
import fs from "node:fs/promises";
|
|
9
9
|
import { execFile, spawn } from "node:child_process";
|
|
10
10
|
import process$1 from "node:process";
|
|
11
11
|
import { fileURLToPath } from "node:url";
|
|
@@ -569,7 +569,7 @@ async function resolveBoundaryPathLexicalAsync(params) {
|
|
|
569
569
|
const stat = await readLexicalStat({
|
|
570
570
|
...sharedStepParams,
|
|
571
571
|
missingFromIndex: idx,
|
|
572
|
-
read: (cursor) => fs
|
|
572
|
+
read: (cursor) => fs.lstat(cursor)
|
|
573
573
|
});
|
|
574
574
|
if (!stat) break;
|
|
575
575
|
const disposition = handleLexicalStatDisposition({
|
|
@@ -606,7 +606,7 @@ function resolveBoundaryPathLexicalSync(params) {
|
|
|
606
606
|
rootCanonicalPath: params.rootCanonicalPath,
|
|
607
607
|
resolveParams: params.params,
|
|
608
608
|
absolutePath: params.absolutePath,
|
|
609
|
-
read: (cursor) =>
|
|
609
|
+
read: (cursor) => fsSync.lstatSync(cursor)
|
|
610
610
|
});
|
|
611
611
|
if (isPromiseLike(maybeStat)) throw new Error("Unexpected async lexical stat");
|
|
612
612
|
const stat = maybeStat;
|
|
@@ -745,7 +745,7 @@ async function resolvePathViaExistingAncestor(targetPath) {
|
|
|
745
745
|
}
|
|
746
746
|
if (!await pathExists(cursor)) return normalized;
|
|
747
747
|
try {
|
|
748
|
-
const resolvedAncestor = path.resolve(await fs
|
|
748
|
+
const resolvedAncestor = path.resolve(await fs.realpath(cursor));
|
|
749
749
|
if (missingSuffix.length === 0) return resolvedAncestor;
|
|
750
750
|
return path.resolve(resolvedAncestor, ...missingSuffix);
|
|
751
751
|
} catch {
|
|
@@ -756,15 +756,15 @@ function resolvePathViaExistingAncestorSync(targetPath) {
|
|
|
756
756
|
const normalized = path.resolve(targetPath);
|
|
757
757
|
let cursor = normalized;
|
|
758
758
|
const missingSuffix = [];
|
|
759
|
-
while (!isFilesystemRoot(cursor) && !
|
|
759
|
+
while (!isFilesystemRoot(cursor) && !fsSync.existsSync(cursor)) {
|
|
760
760
|
missingSuffix.unshift(path.basename(cursor));
|
|
761
761
|
const parent = path.dirname(cursor);
|
|
762
762
|
if (parent === cursor) break;
|
|
763
763
|
cursor = parent;
|
|
764
764
|
}
|
|
765
|
-
if (!
|
|
765
|
+
if (!fsSync.existsSync(cursor)) return normalized;
|
|
766
766
|
try {
|
|
767
|
-
const resolvedAncestor = path.resolve(
|
|
767
|
+
const resolvedAncestor = path.resolve(fsSync.realpathSync(cursor));
|
|
768
768
|
if (missingSuffix.length === 0) return resolvedAncestor;
|
|
769
769
|
return path.resolve(resolvedAncestor, ...missingSuffix);
|
|
770
770
|
} catch {
|
|
@@ -775,7 +775,7 @@ async function getPathKind(absolutePath, preserveFinalSymlink) {
|
|
|
775
775
|
try {
|
|
776
776
|
return {
|
|
777
777
|
exists: true,
|
|
778
|
-
kind: toResolvedKind(preserveFinalSymlink ? await fs
|
|
778
|
+
kind: toResolvedKind(preserveFinalSymlink ? await fs.lstat(absolutePath) : await fs.stat(absolutePath))
|
|
779
779
|
};
|
|
780
780
|
} catch (error) {
|
|
781
781
|
if (isNotFoundPathError(error)) return {
|
|
@@ -789,7 +789,7 @@ function getPathKindSync(absolutePath, preserveFinalSymlink) {
|
|
|
789
789
|
try {
|
|
790
790
|
return {
|
|
791
791
|
exists: true,
|
|
792
|
-
kind: toResolvedKind(preserveFinalSymlink ?
|
|
792
|
+
kind: toResolvedKind(preserveFinalSymlink ? fsSync.lstatSync(absolutePath) : fsSync.statSync(absolutePath))
|
|
793
793
|
};
|
|
794
794
|
} catch (error) {
|
|
795
795
|
if (isNotFoundPathError(error)) return {
|
|
@@ -831,7 +831,7 @@ function isFilesystemRoot(candidate) {
|
|
|
831
831
|
}
|
|
832
832
|
async function pathExists(targetPath) {
|
|
833
833
|
try {
|
|
834
|
-
await fs
|
|
834
|
+
await fs.lstat(targetPath);
|
|
835
835
|
return true;
|
|
836
836
|
} catch (error) {
|
|
837
837
|
if (isNotFoundPathError(error)) return false;
|
|
@@ -840,19 +840,19 @@ async function pathExists(targetPath) {
|
|
|
840
840
|
}
|
|
841
841
|
async function resolveSymlinkHopPath(symlinkPath) {
|
|
842
842
|
try {
|
|
843
|
-
return path.resolve(await fs
|
|
843
|
+
return path.resolve(await fs.realpath(symlinkPath));
|
|
844
844
|
} catch (error) {
|
|
845
845
|
if (!isNotFoundPathError(error)) throw error;
|
|
846
|
-
const linkTarget = await fs
|
|
846
|
+
const linkTarget = await fs.readlink(symlinkPath);
|
|
847
847
|
return resolvePathViaExistingAncestor(path.resolve(path.dirname(symlinkPath), linkTarget));
|
|
848
848
|
}
|
|
849
849
|
}
|
|
850
850
|
function resolveSymlinkHopPathSync(symlinkPath) {
|
|
851
851
|
try {
|
|
852
|
-
return path.resolve(
|
|
852
|
+
return path.resolve(fsSync.realpathSync(symlinkPath));
|
|
853
853
|
} catch (error) {
|
|
854
854
|
if (!isNotFoundPathError(error)) throw error;
|
|
855
|
-
const linkTarget =
|
|
855
|
+
const linkTarget = fsSync.readlinkSync(symlinkPath);
|
|
856
856
|
return resolvePathViaExistingAncestorSync(path.resolve(path.dirname(symlinkPath), linkTarget));
|
|
857
857
|
}
|
|
858
858
|
}
|
|
@@ -876,7 +876,7 @@ function sameFileIdentity(left, right) {
|
|
|
876
876
|
return sameFileIdentity$1(left, right);
|
|
877
877
|
}
|
|
878
878
|
function openVerifiedFileSync(params) {
|
|
879
|
-
const ioFs = params.ioFs ??
|
|
879
|
+
const ioFs = params.ioFs ?? fsSync;
|
|
880
880
|
const allowedType = params.allowedType ?? "file";
|
|
881
881
|
const openReadFlags = ioFs.constants.O_RDONLY | (typeof ioFs.constants.O_NOFOLLOW === "number" ? ioFs.constants.O_NOFOLLOW : 0);
|
|
882
882
|
let fd = null;
|
|
@@ -952,7 +952,7 @@ function canUseBoundaryFileOpen(ioFs) {
|
|
|
952
952
|
return typeof ioFs.openSync === "function" && typeof ioFs.closeSync === "function" && typeof ioFs.fstatSync === "function" && typeof ioFs.lstatSync === "function" && typeof ioFs.realpathSync === "function" && typeof ioFs.readFileSync === "function" && typeof ioFs.constants === "object" && ioFs.constants !== null;
|
|
953
953
|
}
|
|
954
954
|
function openBoundaryFileSync(params) {
|
|
955
|
-
const ioFs = params.ioFs ??
|
|
955
|
+
const ioFs = params.ioFs ?? fsSync;
|
|
956
956
|
const resolved = resolveBoundaryFilePathGeneric({
|
|
957
957
|
absolutePath: params.absolutePath,
|
|
958
958
|
resolve: (absolutePath) => resolveBoundaryPathSync({
|
|
@@ -1003,7 +1003,7 @@ function finalizeBoundaryFileOpen(params) {
|
|
|
1003
1003
|
});
|
|
1004
1004
|
}
|
|
1005
1005
|
async function openBoundaryFile(params) {
|
|
1006
|
-
const ioFs = params.ioFs ??
|
|
1006
|
+
const ioFs = params.ioFs ?? fsSync;
|
|
1007
1007
|
const maybeResolved = resolveBoundaryFilePathGeneric({
|
|
1008
1008
|
absolutePath: params.absolutePath,
|
|
1009
1009
|
resolve: (absolutePath) => resolveBoundaryPath({
|
|
@@ -1168,7 +1168,7 @@ function resolveNpmArgvForWindows(argv) {
|
|
|
1168
1168
|
if (!cliName) return null;
|
|
1169
1169
|
const nodeDir = path.dirname(process$1.execPath);
|
|
1170
1170
|
const cliPath = path.join(nodeDir, "node_modules", "npm", "bin", cliName);
|
|
1171
|
-
if (!
|
|
1171
|
+
if (!fsSync.existsSync(cliPath)) {
|
|
1172
1172
|
const command = argv[0] ?? "";
|
|
1173
1173
|
return [path.extname(command).toLowerCase() ? command : `${command}.cmd`, ...argv.slice(1)];
|
|
1174
1174
|
}
|
|
@@ -1366,14 +1366,14 @@ function parsePackageName(raw) {
|
|
|
1366
1366
|
}
|
|
1367
1367
|
async function readPackageName(dir) {
|
|
1368
1368
|
try {
|
|
1369
|
-
return parsePackageName(await fs
|
|
1369
|
+
return parsePackageName(await fs.readFile(path.join(dir, "package.json"), "utf-8"));
|
|
1370
1370
|
} catch {
|
|
1371
1371
|
return null;
|
|
1372
1372
|
}
|
|
1373
1373
|
}
|
|
1374
1374
|
function readPackageNameSync(dir) {
|
|
1375
1375
|
try {
|
|
1376
|
-
return parsePackageName(
|
|
1376
|
+
return parsePackageName(fsSync.readFileSync(path.join(dir, "package.json"), "utf-8"));
|
|
1377
1377
|
} catch {
|
|
1378
1378
|
return null;
|
|
1379
1379
|
}
|
|
@@ -1405,7 +1405,7 @@ function candidateDirsFromArgv1(argv1) {
|
|
|
1405
1405
|
const normalized = path.resolve(argv1);
|
|
1406
1406
|
const candidates = [path.dirname(normalized)];
|
|
1407
1407
|
try {
|
|
1408
|
-
const resolved =
|
|
1408
|
+
const resolved = fsSync.realpathSync(normalized);
|
|
1409
1409
|
if (resolved !== normalized) candidates.push(path.dirname(resolved));
|
|
1410
1410
|
} catch {}
|
|
1411
1411
|
const parts = normalized.split(path.sep);
|
|
@@ -1517,14 +1517,14 @@ async function readWorkspaceFileWithGuards(params) {
|
|
|
1517
1517
|
const identity = workspaceFileIdentity(opened.stat, opened.path);
|
|
1518
1518
|
const cached = workspaceFileCache.get(params.filePath);
|
|
1519
1519
|
if (cached && cached.identity === identity) {
|
|
1520
|
-
|
|
1520
|
+
fsSync.closeSync(opened.fd);
|
|
1521
1521
|
return {
|
|
1522
1522
|
ok: true,
|
|
1523
1523
|
content: cached.content
|
|
1524
1524
|
};
|
|
1525
1525
|
}
|
|
1526
1526
|
try {
|
|
1527
|
-
const content =
|
|
1527
|
+
const content = fsSync.readFileSync(opened.fd, "utf-8");
|
|
1528
1528
|
workspaceFileCache.set(params.filePath, {
|
|
1529
1529
|
content,
|
|
1530
1530
|
identity
|
|
@@ -1541,7 +1541,7 @@ async function readWorkspaceFileWithGuards(params) {
|
|
|
1541
1541
|
error
|
|
1542
1542
|
};
|
|
1543
1543
|
} finally {
|
|
1544
|
-
|
|
1544
|
+
fsSync.closeSync(opened.fd);
|
|
1545
1545
|
}
|
|
1546
1546
|
}
|
|
1547
1547
|
function stripFrontMatter(content) {
|
|
@@ -1560,7 +1560,7 @@ async function loadTemplate(name) {
|
|
|
1560
1560
|
const templateDir = await resolveWorkspaceTemplateDir();
|
|
1561
1561
|
const templatePath = path.join(templateDir, name);
|
|
1562
1562
|
try {
|
|
1563
|
-
return stripFrontMatter(await fs
|
|
1563
|
+
return stripFrontMatter(await fs.readFile(templatePath, "utf-8"));
|
|
1564
1564
|
} catch {
|
|
1565
1565
|
throw new Error(`Missing workspace template: ${name} (${templatePath}). Ensure docs/reference/templates are packaged.`);
|
|
1566
1566
|
}
|
|
@@ -1575,7 +1575,7 @@ async function loadTemplate(name) {
|
|
|
1575
1575
|
}
|
|
1576
1576
|
async function writeFileIfMissing(filePath, content) {
|
|
1577
1577
|
try {
|
|
1578
|
-
await fs
|
|
1578
|
+
await fs.writeFile(filePath, content, {
|
|
1579
1579
|
encoding: "utf-8",
|
|
1580
1580
|
flag: "wx"
|
|
1581
1581
|
});
|
|
@@ -1587,7 +1587,7 @@ async function writeFileIfMissing(filePath, content) {
|
|
|
1587
1587
|
}
|
|
1588
1588
|
async function fileExists(filePath) {
|
|
1589
1589
|
try {
|
|
1590
|
-
await fs
|
|
1590
|
+
await fs.access(filePath);
|
|
1591
1591
|
return true;
|
|
1592
1592
|
} catch {
|
|
1593
1593
|
return false;
|
|
@@ -1611,27 +1611,27 @@ function parseWorkspaceOnboardingState(raw) {
|
|
|
1611
1611
|
}
|
|
1612
1612
|
async function readWorkspaceOnboardingState(statePath) {
|
|
1613
1613
|
try {
|
|
1614
|
-
return parseWorkspaceOnboardingState(await fs
|
|
1614
|
+
return parseWorkspaceOnboardingState(await fs.readFile(statePath, "utf-8")) ?? { version: WORKSPACE_STATE_VERSION };
|
|
1615
1615
|
} catch (err) {
|
|
1616
1616
|
if (err.code !== "ENOENT") throw err;
|
|
1617
1617
|
return { version: WORKSPACE_STATE_VERSION };
|
|
1618
1618
|
}
|
|
1619
1619
|
}
|
|
1620
1620
|
async function writeWorkspaceOnboardingState(statePath, state) {
|
|
1621
|
-
await fs
|
|
1621
|
+
await fs.mkdir(path.dirname(statePath), { recursive: true });
|
|
1622
1622
|
const payload = `${JSON.stringify(state, null, 2)}\n`;
|
|
1623
1623
|
const tmpPath = `${statePath}.tmp-${process.pid}-${Date.now().toString(36)}`;
|
|
1624
1624
|
try {
|
|
1625
|
-
await fs
|
|
1626
|
-
await fs
|
|
1625
|
+
await fs.writeFile(tmpPath, payload, { encoding: "utf-8" });
|
|
1626
|
+
await fs.rename(tmpPath, statePath);
|
|
1627
1627
|
} catch (err) {
|
|
1628
|
-
await fs
|
|
1628
|
+
await fs.unlink(tmpPath).catch(() => {});
|
|
1629
1629
|
throw err;
|
|
1630
1630
|
}
|
|
1631
1631
|
}
|
|
1632
1632
|
async function hasGitRepo(dir) {
|
|
1633
1633
|
try {
|
|
1634
|
-
await fs
|
|
1634
|
+
await fs.stat(path.join(dir, ".git"));
|
|
1635
1635
|
return true;
|
|
1636
1636
|
} catch {
|
|
1637
1637
|
return false;
|
|
@@ -1661,7 +1661,7 @@ async function ensureGitRepo(dir, isBrandNewWorkspace) {
|
|
|
1661
1661
|
}
|
|
1662
1662
|
async function ensureAgentWorkspace(params) {
|
|
1663
1663
|
const dir = resolveUserPath(params?.dir?.trim() ? params.dir.trim() : DEFAULT_AGENT_WORKSPACE_DIR);
|
|
1664
|
-
await fs
|
|
1664
|
+
await fs.mkdir(dir, { recursive: true });
|
|
1665
1665
|
if (!params?.ensureBootstrapFiles) return { dir };
|
|
1666
1666
|
const agentsPath = path.join(dir, DEFAULT_AGENTS_FILENAME);
|
|
1667
1667
|
const soulPath = path.join(dir, DEFAULT_SOUL_FILENAME);
|
|
@@ -1688,7 +1688,7 @@ async function ensureAgentWorkspace(params) {
|
|
|
1688
1688
|
const paths = [...templatePaths, ...userContentPaths];
|
|
1689
1689
|
return (await Promise.all(paths.map(async (p) => {
|
|
1690
1690
|
try {
|
|
1691
|
-
await fs
|
|
1691
|
+
await fs.access(p);
|
|
1692
1692
|
return true;
|
|
1693
1693
|
} catch {
|
|
1694
1694
|
return false;
|
|
@@ -1721,7 +1721,7 @@ async function ensureAgentWorkspace(params) {
|
|
|
1721
1721
|
if (!state.bootstrapSeededAt && bootstrapExists) markState({ bootstrapSeededAt: nowIso() });
|
|
1722
1722
|
if (!state.onboardingCompletedAt && state.bootstrapSeededAt && !bootstrapExists) markState({ onboardingCompletedAt: nowIso() });
|
|
1723
1723
|
if (!state.bootstrapSeededAt && !state.onboardingCompletedAt && !bootstrapExists) {
|
|
1724
|
-
const [identityContent, userContent] = await Promise.all([fs
|
|
1724
|
+
const [identityContent, userContent] = await Promise.all([fs.readFile(identityPath, "utf-8"), fs.readFile(userPath, "utf-8")]);
|
|
1725
1725
|
const hasUserContent = await (async () => {
|
|
1726
1726
|
const indicators = [
|
|
1727
1727
|
path.join(dir, "memory"),
|
|
@@ -1729,7 +1729,7 @@ async function ensureAgentWorkspace(params) {
|
|
|
1729
1729
|
path.join(dir, ".git")
|
|
1730
1730
|
];
|
|
1731
1731
|
for (const indicator of indicators) try {
|
|
1732
|
-
await fs
|
|
1732
|
+
await fs.access(indicator);
|
|
1733
1733
|
return true;
|
|
1734
1734
|
} catch {}
|
|
1735
1735
|
return false;
|
|
@@ -1758,7 +1758,7 @@ async function resolveMemoryBootstrapEntry(resolvedDir) {
|
|
|
1758
1758
|
for (const name of [DEFAULT_MEMORY_FILENAME, DEFAULT_MEMORY_ALT_FILENAME]) {
|
|
1759
1759
|
const filePath = path.join(resolvedDir, name);
|
|
1760
1760
|
try {
|
|
1761
|
-
await fs
|
|
1761
|
+
await fs.access(filePath);
|
|
1762
1762
|
return {
|
|
1763
1763
|
name,
|
|
1764
1764
|
filePath
|
|
@@ -2477,7 +2477,7 @@ async function assertNoHardlinkedFinalPath(params) {
|
|
|
2477
2477
|
if (params.allowFinalHardlinkForUnlink) return;
|
|
2478
2478
|
let stat;
|
|
2479
2479
|
try {
|
|
2480
|
-
stat = await fs
|
|
2480
|
+
stat = await fs.stat(params.filePath);
|
|
2481
2481
|
} catch (err) {
|
|
2482
2482
|
if (isNotFoundPathError(err)) return;
|
|
2483
2483
|
throw err;
|
|
@@ -2663,24 +2663,24 @@ async function runPinnedWriteHelper(params) {
|
|
|
2663
2663
|
}
|
|
2664
2664
|
async function runPinnedWriteFallback(params) {
|
|
2665
2665
|
const parentPath = params.relativeParentPath ? path.join(params.rootPath, ...params.relativeParentPath.split("/")) : params.rootPath;
|
|
2666
|
-
if (params.mkdir) await fs
|
|
2666
|
+
if (params.mkdir) await fs.mkdir(parentPath, { recursive: true });
|
|
2667
2667
|
const targetPath = path.join(parentPath, params.basename);
|
|
2668
2668
|
const tempPath = path.join(parentPath, `.${params.basename}.fallback.tmp`);
|
|
2669
|
-
if (params.input.kind === "buffer") if (typeof params.input.data === "string") await fs
|
|
2669
|
+
if (params.input.kind === "buffer") if (typeof params.input.data === "string") await fs.writeFile(tempPath, params.input.data, {
|
|
2670
2670
|
encoding: params.input.encoding ?? "utf8",
|
|
2671
2671
|
mode: params.mode
|
|
2672
2672
|
});
|
|
2673
|
-
else await fs
|
|
2673
|
+
else await fs.writeFile(tempPath, params.input.data, { mode: params.mode });
|
|
2674
2674
|
else {
|
|
2675
|
-
const handle = await fs
|
|
2675
|
+
const handle = await fs.open(tempPath, "w", params.mode);
|
|
2676
2676
|
try {
|
|
2677
2677
|
await pipeline(params.input.stream, handle.createWriteStream());
|
|
2678
2678
|
} finally {
|
|
2679
2679
|
await handle.close().catch(() => {});
|
|
2680
2680
|
}
|
|
2681
2681
|
}
|
|
2682
|
-
await fs
|
|
2683
|
-
const stat = await fs
|
|
2682
|
+
await fs.rename(tempPath, targetPath);
|
|
2683
|
+
const stat = await fs.stat(targetPath);
|
|
2684
2684
|
return {
|
|
2685
2685
|
dev: stat.dev,
|
|
2686
2686
|
ino: stat.ino
|
|
@@ -2705,19 +2705,19 @@ const ensureTrailingSep = (value) => value.endsWith(path.sep) ? value : value +
|
|
|
2705
2705
|
async function expandRelativePathWithHome(relativePath) {
|
|
2706
2706
|
let home = process.env.HOME || process.env.USERPROFILE || os.homedir();
|
|
2707
2707
|
try {
|
|
2708
|
-
home = await fs
|
|
2708
|
+
home = await fs.realpath(home);
|
|
2709
2709
|
} catch {}
|
|
2710
2710
|
return expandHomePrefix(relativePath, { home });
|
|
2711
2711
|
}
|
|
2712
2712
|
async function openVerifiedLocalFile(filePath, options) {
|
|
2713
2713
|
try {
|
|
2714
|
-
if ((await fs
|
|
2714
|
+
if ((await fs.lstat(filePath)).isDirectory()) throw new SafeOpenError("not-file", "not a file");
|
|
2715
2715
|
} catch (err) {
|
|
2716
2716
|
if (err instanceof SafeOpenError) throw err;
|
|
2717
2717
|
}
|
|
2718
2718
|
let handle;
|
|
2719
2719
|
try {
|
|
2720
|
-
handle = await fs
|
|
2720
|
+
handle = await fs.open(filePath, OPEN_READ_FLAGS);
|
|
2721
2721
|
} catch (err) {
|
|
2722
2722
|
if (isNotFoundPathError(err)) throw new SafeOpenError("not-found", "file not found");
|
|
2723
2723
|
if (isSymlinkOpenError(err)) throw new SafeOpenError("symlink", "symlink open blocked", { cause: err });
|
|
@@ -2725,13 +2725,13 @@ async function openVerifiedLocalFile(filePath, options) {
|
|
|
2725
2725
|
throw err;
|
|
2726
2726
|
}
|
|
2727
2727
|
try {
|
|
2728
|
-
const [stat, lstat] = await Promise.all([handle.stat(), fs
|
|
2728
|
+
const [stat, lstat] = await Promise.all([handle.stat(), fs.lstat(filePath)]);
|
|
2729
2729
|
if (lstat.isSymbolicLink()) throw new SafeOpenError("symlink", "symlink not allowed");
|
|
2730
2730
|
if (!stat.isFile()) throw new SafeOpenError("not-file", "not a file");
|
|
2731
2731
|
if (options?.rejectHardlinks && stat.nlink > 1) throw new SafeOpenError("invalid-path", "hardlinked path not allowed");
|
|
2732
2732
|
if (!sameFileIdentity$1(stat, lstat)) throw new SafeOpenError("path-mismatch", "path changed during read");
|
|
2733
|
-
const realPath = await fs
|
|
2734
|
-
const realStat = await fs
|
|
2733
|
+
const realPath = await fs.realpath(filePath);
|
|
2734
|
+
const realStat = await fs.stat(realPath);
|
|
2735
2735
|
if (options?.rejectHardlinks && realStat.nlink > 1) throw new SafeOpenError("invalid-path", "hardlinked path not allowed");
|
|
2736
2736
|
if (!sameFileIdentity$1(stat, realStat)) throw new SafeOpenError("path-mismatch", "path mismatch");
|
|
2737
2737
|
return {
|
|
@@ -2749,7 +2749,7 @@ async function openVerifiedLocalFile(filePath, options) {
|
|
|
2749
2749
|
async function resolvePathWithinRoot(params) {
|
|
2750
2750
|
let rootReal;
|
|
2751
2751
|
try {
|
|
2752
|
-
rootReal = await fs
|
|
2752
|
+
rootReal = await fs.realpath(params.rootDir);
|
|
2753
2753
|
} catch (err) {
|
|
2754
2754
|
if (isNotFoundPathError(err)) throw new SafeOpenError("not-found", "root dir not found");
|
|
2755
2755
|
throw err;
|
|
@@ -2850,7 +2850,7 @@ function buildAtomicWriteTempPath(targetPath) {
|
|
|
2850
2850
|
return path.join(dir, `.${base}.${process.pid}.${randomUUID()}.tmp`);
|
|
2851
2851
|
}
|
|
2852
2852
|
async function writeTempFileForAtomicReplace(params) {
|
|
2853
|
-
const tempHandle = await fs
|
|
2853
|
+
const tempHandle = await fs.open(params.tempPath, OPEN_WRITE_CREATE_FLAGS, params.mode);
|
|
2854
2854
|
try {
|
|
2855
2855
|
if (typeof params.data === "string") await tempHandle.writeFile(params.data, params.encoding ?? "utf8");
|
|
2856
2856
|
else await tempHandle.writeFile(params.data);
|
|
@@ -2860,7 +2860,7 @@ async function writeTempFileForAtomicReplace(params) {
|
|
|
2860
2860
|
}
|
|
2861
2861
|
}
|
|
2862
2862
|
async function verifyAtomicWriteResult(params) {
|
|
2863
|
-
const rootWithSep = ensureTrailingSep(await fs
|
|
2863
|
+
const rootWithSep = ensureTrailingSep(await fs.realpath(params.rootDir));
|
|
2864
2864
|
const opened = await openVerifiedLocalFile(params.targetPath, { rejectHardlinks: true });
|
|
2865
2865
|
try {
|
|
2866
2866
|
if (!sameFileIdentity$1(opened.stat, params.expectedIdentity)) throw new SafeOpenError("path-mismatch", "path changed during write");
|
|
@@ -2871,13 +2871,13 @@ async function verifyAtomicWriteResult(params) {
|
|
|
2871
2871
|
}
|
|
2872
2872
|
async function resolveOpenedFileRealPathForHandle(handle, ioPath) {
|
|
2873
2873
|
try {
|
|
2874
|
-
return await fs
|
|
2874
|
+
return await fs.realpath(ioPath);
|
|
2875
2875
|
} catch (err) {
|
|
2876
2876
|
if (!isNotFoundPathError(err)) throw err;
|
|
2877
2877
|
}
|
|
2878
2878
|
const fdCandidates = process.platform === "linux" ? [`/proc/self/fd/${handle.fd}`, `/dev/fd/${handle.fd}`] : process.platform === "win32" ? [] : [`/dev/fd/${handle.fd}`];
|
|
2879
2879
|
for (const fdPath of fdCandidates) try {
|
|
2880
|
-
return await fs
|
|
2880
|
+
return await fs.realpath(fdPath);
|
|
2881
2881
|
} catch {}
|
|
2882
2882
|
throw new SafeOpenError("path-mismatch", "unable to resolve opened file path");
|
|
2883
2883
|
}
|
|
@@ -2892,10 +2892,10 @@ async function openWritableFileWithinRoot(params) {
|
|
|
2892
2892
|
} catch (err) {
|
|
2893
2893
|
throw new SafeOpenError("invalid-path", "path alias escape blocked", { cause: err });
|
|
2894
2894
|
}
|
|
2895
|
-
if (params.mkdir !== false) await fs
|
|
2895
|
+
if (params.mkdir !== false) await fs.mkdir(path.dirname(resolved), { recursive: true });
|
|
2896
2896
|
let ioPath = resolved;
|
|
2897
2897
|
try {
|
|
2898
|
-
const resolvedRealPath = await fs
|
|
2898
|
+
const resolvedRealPath = await fs.realpath(resolved);
|
|
2899
2899
|
if (!isPathInside(rootWithSep, resolvedRealPath)) throw new SafeOpenError("outside-workspace", "file is outside workspace root");
|
|
2900
2900
|
ioPath = resolvedRealPath;
|
|
2901
2901
|
} catch (err) {
|
|
@@ -2909,10 +2909,10 @@ async function openWritableFileWithinRoot(params) {
|
|
|
2909
2909
|
const createFlags = params.append ? OPEN_APPEND_CREATE_FLAGS : OPEN_WRITE_CREATE_FLAGS;
|
|
2910
2910
|
try {
|
|
2911
2911
|
try {
|
|
2912
|
-
handle = await fs
|
|
2912
|
+
handle = await fs.open(ioPath, existingFlags, fileMode);
|
|
2913
2913
|
} catch (err) {
|
|
2914
2914
|
if (!isNotFoundPathError(err)) throw err;
|
|
2915
|
-
handle = await fs
|
|
2915
|
+
handle = await fs.open(ioPath, createFlags, fileMode);
|
|
2916
2916
|
createdForWrite = true;
|
|
2917
2917
|
}
|
|
2918
2918
|
} catch (err) {
|
|
@@ -2926,7 +2926,7 @@ async function openWritableFileWithinRoot(params) {
|
|
|
2926
2926
|
if (!stat.isFile()) throw new SafeOpenError("invalid-path", "path is not a regular file under root");
|
|
2927
2927
|
if (stat.nlink > 1) throw new SafeOpenError("invalid-path", "hardlinked path not allowed");
|
|
2928
2928
|
try {
|
|
2929
|
-
const lstat = await fs
|
|
2929
|
+
const lstat = await fs.lstat(ioPath);
|
|
2930
2930
|
if (lstat.isSymbolicLink() || !lstat.isFile()) throw new SafeOpenError("invalid-path", "path is not a regular file under root");
|
|
2931
2931
|
if (!sameFileIdentity$1(stat, lstat)) throw new SafeOpenError("path-mismatch", "path changed during write");
|
|
2932
2932
|
} catch (err) {
|
|
@@ -2934,7 +2934,7 @@ async function openWritableFileWithinRoot(params) {
|
|
|
2934
2934
|
}
|
|
2935
2935
|
const realPath = await resolveOpenedFileRealPathForHandle(handle, ioPath);
|
|
2936
2936
|
openedRealPath = realPath;
|
|
2937
|
-
const realStat = await fs
|
|
2937
|
+
const realStat = await fs.stat(realPath);
|
|
2938
2938
|
if (!sameFileIdentity$1(stat, realStat)) throw new SafeOpenError("path-mismatch", "path mismatch");
|
|
2939
2939
|
if (realStat.nlink > 1) throw new SafeOpenError("invalid-path", "hardlinked path not allowed");
|
|
2940
2940
|
if (!isPathInside(rootWithSep, realPath)) throw new SafeOpenError("outside-workspace", "file is outside workspace root");
|
|
@@ -2949,7 +2949,7 @@ async function openWritableFileWithinRoot(params) {
|
|
|
2949
2949
|
const cleanupCreatedPath = createdForWrite && err instanceof SafeOpenError;
|
|
2950
2950
|
const cleanupPath = openedRealPath ?? ioPath;
|
|
2951
2951
|
await handle.close().catch(() => {});
|
|
2952
|
-
if (cleanupCreatedPath) await fs
|
|
2952
|
+
if (cleanupCreatedPath) await fs.rm(cleanupPath, { force: true }).catch(() => {});
|
|
2953
2953
|
throw err;
|
|
2954
2954
|
}
|
|
2955
2955
|
}
|
|
@@ -3127,7 +3127,7 @@ async function writeFileWithinRootLegacy(params) {
|
|
|
3127
3127
|
encoding: params.encoding,
|
|
3128
3128
|
mode: targetMode || 384
|
|
3129
3129
|
});
|
|
3130
|
-
await fs
|
|
3130
|
+
await fs.rename(tempPath, destinationPath);
|
|
3131
3131
|
tempPath = null;
|
|
3132
3132
|
try {
|
|
3133
3133
|
await verifyAtomicWriteResult({
|
|
@@ -3140,7 +3140,7 @@ async function writeFileWithinRootLegacy(params) {
|
|
|
3140
3140
|
throw err;
|
|
3141
3141
|
}
|
|
3142
3142
|
} finally {
|
|
3143
|
-
if (tempPath) await fs
|
|
3143
|
+
if (tempPath) await fs.rm(tempPath, { force: true }).catch(() => {});
|
|
3144
3144
|
}
|
|
3145
3145
|
}
|
|
3146
3146
|
async function copyFileWithinRootLegacy(params, source) {
|
|
@@ -3162,7 +3162,7 @@ async function copyFileWithinRootLegacy(params, source) {
|
|
|
3162
3162
|
await target.handle.close().catch(() => {});
|
|
3163
3163
|
targetClosedByUs = true;
|
|
3164
3164
|
tempPath = buildAtomicWriteTempPath(destinationPath);
|
|
3165
|
-
tempHandle = await fs
|
|
3165
|
+
tempHandle = await fs.open(tempPath, OPEN_WRITE_CREATE_FLAGS, targetMode || 384);
|
|
3166
3166
|
const sourceStream = source.handle.createReadStream();
|
|
3167
3167
|
const targetStream = tempHandle.createWriteStream();
|
|
3168
3168
|
sourceStream.once("close", () => {
|
|
@@ -3172,13 +3172,13 @@ async function copyFileWithinRootLegacy(params, source) {
|
|
|
3172
3172
|
tempClosedByStream = true;
|
|
3173
3173
|
});
|
|
3174
3174
|
await import("node:stream/promises").then(({ pipeline }) => pipeline(sourceStream, targetStream));
|
|
3175
|
-
const writtenStat = await fs
|
|
3175
|
+
const writtenStat = await fs.stat(tempPath);
|
|
3176
3176
|
if (!tempClosedByStream) {
|
|
3177
3177
|
await tempHandle.close().catch(() => {});
|
|
3178
3178
|
tempClosedByStream = true;
|
|
3179
3179
|
}
|
|
3180
3180
|
tempHandle = null;
|
|
3181
|
-
await fs
|
|
3181
|
+
await fs.rename(tempPath, destinationPath);
|
|
3182
3182
|
tempPath = null;
|
|
3183
3183
|
try {
|
|
3184
3184
|
await verifyAtomicWriteResult({
|
|
@@ -3191,10 +3191,10 @@ async function copyFileWithinRootLegacy(params, source) {
|
|
|
3191
3191
|
throw err;
|
|
3192
3192
|
}
|
|
3193
3193
|
} catch (err) {
|
|
3194
|
-
if (target?.createdForWrite) await fs
|
|
3194
|
+
if (target?.createdForWrite) await fs.rm(target.openedRealPath, { force: true }).catch(() => {});
|
|
3195
3195
|
throw err;
|
|
3196
3196
|
} finally {
|
|
3197
|
-
if (tempPath) await fs
|
|
3197
|
+
if (tempPath) await fs.rm(tempPath, { force: true }).catch(() => {});
|
|
3198
3198
|
if (!sourceClosedByStream) await source.handle.close().catch(() => {});
|
|
3199
3199
|
if (tempHandle && !tempClosedByStream) await tempHandle.close().catch(() => {});
|
|
3200
3200
|
if (target && !targetClosedByUs) await target.handle.close().catch(() => {});
|
|
@@ -3431,7 +3431,7 @@ function resolveStructuralSessionFallbackPath(candidateAbsPath, expectedAgentId)
|
|
|
3431
3431
|
}
|
|
3432
3432
|
function safeRealpathSync(filePath) {
|
|
3433
3433
|
try {
|
|
3434
|
-
return
|
|
3434
|
+
return fsSync.realpathSync(filePath);
|
|
3435
3435
|
} catch {
|
|
3436
3436
|
return;
|
|
3437
3437
|
}
|
|
@@ -3598,7 +3598,7 @@ function isFileMissingError(err) {
|
|
|
3598
3598
|
async function statRegularFile(absPath) {
|
|
3599
3599
|
let stat;
|
|
3600
3600
|
try {
|
|
3601
|
-
stat = await fs
|
|
3601
|
+
stat = await fs.lstat(absPath);
|
|
3602
3602
|
} catch (err) {
|
|
3603
3603
|
if (isFileMissingError(err)) return { missing: true };
|
|
3604
3604
|
throw err;
|
|
@@ -3674,7 +3674,7 @@ const DISABLED_MULTIMODAL_SETTINGS = {
|
|
|
3674
3674
|
};
|
|
3675
3675
|
function ensureDir(dir) {
|
|
3676
3676
|
try {
|
|
3677
|
-
|
|
3677
|
+
fsSync.mkdirSync(dir, { recursive: true });
|
|
3678
3678
|
} catch {}
|
|
3679
3679
|
return dir;
|
|
3680
3680
|
}
|
|
@@ -3697,7 +3697,7 @@ function isAllowedMemoryFilePath(filePath, multimodal) {
|
|
|
3697
3697
|
return classifyMemoryMultimodalPath(filePath, multimodal ?? DISABLED_MULTIMODAL_SETTINGS) !== null;
|
|
3698
3698
|
}
|
|
3699
3699
|
async function walkDir(dir, files, multimodal) {
|
|
3700
|
-
const entries = await fs
|
|
3700
|
+
const entries = await fs.readdir(dir, { withFileTypes: true });
|
|
3701
3701
|
for (const entry of entries) {
|
|
3702
3702
|
const full = path.join(dir, entry.name);
|
|
3703
3703
|
if (entry.isSymbolicLink()) continue;
|
|
@@ -3717,7 +3717,7 @@ async function listMemoryFiles(workspaceDir, extraPaths, multimodal) {
|
|
|
3717
3717
|
const memoryDir = path.join(workspaceDir, "memory");
|
|
3718
3718
|
const addMarkdownFile = async (absPath) => {
|
|
3719
3719
|
try {
|
|
3720
|
-
const stat = await fs
|
|
3720
|
+
const stat = await fs.lstat(absPath);
|
|
3721
3721
|
if (stat.isSymbolicLink() || !stat.isFile()) return;
|
|
3722
3722
|
if (!absPath.endsWith(".md")) return;
|
|
3723
3723
|
result.push(absPath);
|
|
@@ -3726,12 +3726,12 @@ async function listMemoryFiles(workspaceDir, extraPaths, multimodal) {
|
|
|
3726
3726
|
await addMarkdownFile(memoryFile);
|
|
3727
3727
|
await addMarkdownFile(altMemoryFile);
|
|
3728
3728
|
try {
|
|
3729
|
-
const dirStat = await fs
|
|
3729
|
+
const dirStat = await fs.lstat(memoryDir);
|
|
3730
3730
|
if (!dirStat.isSymbolicLink() && dirStat.isDirectory()) await walkDir(memoryDir, result);
|
|
3731
3731
|
} catch {}
|
|
3732
3732
|
const normalizedExtraPaths = normalizeExtraMemoryPaths(workspaceDir, extraPaths);
|
|
3733
3733
|
if (normalizedExtraPaths.length > 0) for (const inputPath of normalizedExtraPaths) try {
|
|
3734
|
-
const stat = await fs
|
|
3734
|
+
const stat = await fs.lstat(inputPath);
|
|
3735
3735
|
if (stat.isSymbolicLink()) continue;
|
|
3736
3736
|
if (stat.isDirectory()) {
|
|
3737
3737
|
await walkDir(inputPath, result, multimodal);
|
|
@@ -3745,7 +3745,7 @@ async function listMemoryFiles(workspaceDir, extraPaths, multimodal) {
|
|
|
3745
3745
|
for (const entry of result) {
|
|
3746
3746
|
let key = entry;
|
|
3747
3747
|
try {
|
|
3748
|
-
key = await fs
|
|
3748
|
+
key = await fs.realpath(entry);
|
|
3749
3749
|
} catch {}
|
|
3750
3750
|
if (seen.has(key)) continue;
|
|
3751
3751
|
seen.add(key);
|
|
@@ -3759,7 +3759,7 @@ function hashText(value) {
|
|
|
3759
3759
|
async function buildFileEntry(absPath, workspaceDir, multimodal) {
|
|
3760
3760
|
let stat;
|
|
3761
3761
|
try {
|
|
3762
|
-
stat = await fs
|
|
3762
|
+
stat = await fs.stat(absPath);
|
|
3763
3763
|
} catch (err) {
|
|
3764
3764
|
if (isFileMissingError(err)) return null;
|
|
3765
3765
|
throw err;
|
|
@@ -3771,7 +3771,7 @@ async function buildFileEntry(absPath, workspaceDir, multimodal) {
|
|
|
3771
3771
|
if (stat.size > multimodalSettings.maxFileBytes) return null;
|
|
3772
3772
|
let buffer;
|
|
3773
3773
|
try {
|
|
3774
|
-
buffer = await fs
|
|
3774
|
+
buffer = await fs.readFile(absPath);
|
|
3775
3775
|
} catch (err) {
|
|
3776
3776
|
if (isFileMissingError(err)) return null;
|
|
3777
3777
|
throw err;
|
|
@@ -3804,7 +3804,7 @@ async function buildFileEntry(absPath, workspaceDir, multimodal) {
|
|
|
3804
3804
|
}
|
|
3805
3805
|
let content;
|
|
3806
3806
|
try {
|
|
3807
|
-
content = await fs
|
|
3807
|
+
content = await fs.readFile(absPath, "utf-8");
|
|
3808
3808
|
} catch (err) {
|
|
3809
3809
|
if (isFileMissingError(err)) return null;
|
|
3810
3810
|
throw err;
|
|
@@ -3823,7 +3823,7 @@ async function loadMultimodalEmbeddingInput(entry) {
|
|
|
3823
3823
|
if (entry.kind !== "multimodal" || !entry.contentText || !entry.mimeType) return null;
|
|
3824
3824
|
let stat;
|
|
3825
3825
|
try {
|
|
3826
|
-
stat = await fs
|
|
3826
|
+
stat = await fs.stat(entry.absPath);
|
|
3827
3827
|
} catch (err) {
|
|
3828
3828
|
if (isFileMissingError(err)) return null;
|
|
3829
3829
|
throw err;
|
|
@@ -3831,7 +3831,7 @@ async function loadMultimodalEmbeddingInput(entry) {
|
|
|
3831
3831
|
if (stat.size !== entry.size) return null;
|
|
3832
3832
|
let buffer;
|
|
3833
3833
|
try {
|
|
3834
|
-
buffer = await fs
|
|
3834
|
+
buffer = await fs.readFile(entry.absPath);
|
|
3835
3835
|
} catch (err) {
|
|
3836
3836
|
if (isFileMissingError(err)) return null;
|
|
3837
3837
|
throw err;
|
|
@@ -3984,7 +3984,7 @@ const log = createSubsystemLogger("memory");
|
|
|
3984
3984
|
async function listSessionFilesForAgent(agentId) {
|
|
3985
3985
|
const dir = resolveSessionTranscriptsDirForAgent(agentId);
|
|
3986
3986
|
try {
|
|
3987
|
-
return (await fs
|
|
3987
|
+
return (await fs.readdir(dir, { withFileTypes: true })).filter((entry) => entry.isFile()).map((entry) => entry.name).filter((name) => name.endsWith(".jsonl")).map((name) => path.join(dir, name));
|
|
3988
3988
|
} catch {
|
|
3989
3989
|
return [];
|
|
3990
3990
|
}
|
|
@@ -4014,8 +4014,8 @@ function extractSessionText(content) {
|
|
|
4014
4014
|
}
|
|
4015
4015
|
async function buildSessionEntry(absPath) {
|
|
4016
4016
|
try {
|
|
4017
|
-
const stat = await fs
|
|
4018
|
-
const lines = (await fs
|
|
4017
|
+
const stat = await fs.stat(absPath);
|
|
4018
|
+
const lines = (await fs.readFile(absPath, "utf-8")).split("\n");
|
|
4019
4019
|
const collected = [];
|
|
4020
4020
|
const lineMap = [];
|
|
4021
4021
|
for (let jsonlIdx = 0; jsonlIdx < lines.length; jsonlIdx++) {
|