@slock-ai/daemon 0.5.0 → 0.6.0
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/index.js +15 -10
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -920,15 +920,22 @@ Note: While you are busy, you may receive [System notification: ...] messages ab
|
|
|
920
920
|
}
|
|
921
921
|
}
|
|
922
922
|
// Workspace file browsing
|
|
923
|
-
async getFileTree(agentId) {
|
|
923
|
+
async getFileTree(agentId, dirPath) {
|
|
924
924
|
const agentDir = path2.join(DATA_DIR, agentId);
|
|
925
925
|
try {
|
|
926
926
|
await stat(agentDir);
|
|
927
927
|
} catch {
|
|
928
928
|
return [];
|
|
929
929
|
}
|
|
930
|
-
|
|
931
|
-
|
|
930
|
+
let targetDir = agentDir;
|
|
931
|
+
if (dirPath) {
|
|
932
|
+
const resolved = path2.resolve(agentDir, dirPath);
|
|
933
|
+
if (!resolved.startsWith(agentDir + path2.sep) && resolved !== agentDir) {
|
|
934
|
+
return [];
|
|
935
|
+
}
|
|
936
|
+
targetDir = resolved;
|
|
937
|
+
}
|
|
938
|
+
return this.listDirectoryChildren(targetDir, agentDir);
|
|
932
939
|
}
|
|
933
940
|
async readFile(agentId, filePath) {
|
|
934
941
|
const agentDir = path2.join(DATA_DIR, agentId);
|
|
@@ -1055,7 +1062,8 @@ Note: While you are busy, you may receive [System notification: ...] messages ab
|
|
|
1055
1062
|
ap.process.stdin?.write(encoded + "\n");
|
|
1056
1063
|
}
|
|
1057
1064
|
}
|
|
1058
|
-
|
|
1065
|
+
/** List ONE level of a directory — directories returned without children (lazy-loaded on demand) */
|
|
1066
|
+
async listDirectoryChildren(dir, rootDir) {
|
|
1059
1067
|
let entries;
|
|
1060
1068
|
try {
|
|
1061
1069
|
entries = await readdir(dir, { withFileTypes: true });
|
|
@@ -1069,7 +1077,6 @@ Note: While you are busy, you may receive [System notification: ...] messages ab
|
|
|
1069
1077
|
});
|
|
1070
1078
|
const nodes = [];
|
|
1071
1079
|
for (const entry of entries) {
|
|
1072
|
-
if (count.n >= 500) break;
|
|
1073
1080
|
if (entry.name.startsWith(".") || entry.name === "node_modules") continue;
|
|
1074
1081
|
const fullPath = path2.join(dir, entry.name);
|
|
1075
1082
|
const relativePath = path2.relative(rootDir, fullPath);
|
|
@@ -1079,10 +1086,8 @@ Note: While you are busy, you may receive [System notification: ...] messages ab
|
|
|
1079
1086
|
} catch {
|
|
1080
1087
|
continue;
|
|
1081
1088
|
}
|
|
1082
|
-
count.n++;
|
|
1083
1089
|
if (entry.isDirectory()) {
|
|
1084
|
-
|
|
1085
|
-
nodes.push({ name: entry.name, path: relativePath, isDirectory: true, size: 0, modifiedAt: info.mtime.toISOString(), children });
|
|
1090
|
+
nodes.push({ name: entry.name, path: relativePath, isDirectory: true, size: 0, modifiedAt: info.mtime.toISOString() });
|
|
1086
1091
|
} else {
|
|
1087
1092
|
nodes.push({ name: entry.name, path: relativePath, isDirectory: false, size: info.size, modifiedAt: info.mtime.toISOString() });
|
|
1088
1093
|
}
|
|
@@ -1166,8 +1171,8 @@ connection = new DaemonConnection({
|
|
|
1166
1171
|
connection.send({ type: "agent:deliver:ack", agentId: msg.agentId, seq: msg.seq });
|
|
1167
1172
|
break;
|
|
1168
1173
|
case "agent:workspace:list":
|
|
1169
|
-
agentManager.getFileTree(msg.agentId).then((files) => {
|
|
1170
|
-
connection.send({ type: "agent:workspace:file_tree", agentId: msg.agentId, files });
|
|
1174
|
+
agentManager.getFileTree(msg.agentId, msg.dirPath).then((files) => {
|
|
1175
|
+
connection.send({ type: "agent:workspace:file_tree", agentId: msg.agentId, files, dirPath: msg.dirPath });
|
|
1171
1176
|
});
|
|
1172
1177
|
break;
|
|
1173
1178
|
case "agent:workspace:read":
|