@slock-ai/daemon 0.5.0 → 0.7.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.
@@ -127,7 +127,8 @@ server.tool(
127
127
  text += "Use `#channel-name` with send_message to post in a channel.\n";
128
128
  if (data.channels?.length > 0) {
129
129
  for (const t of data.channels) {
130
- text += ` - #${t.name}
130
+ text += t.description ? ` - #${t.name} \u2014 ${t.description}
131
+ ` : ` - #${t.name}
131
132
  `;
132
133
  }
133
134
  } else {
package/dist/index.js CHANGED
@@ -3,6 +3,7 @@
3
3
  // src/index.ts
4
4
  import path3 from "path";
5
5
  import os2 from "os";
6
+ import { createRequire } from "module";
6
7
  import { execSync as execSync2 } from "child_process";
7
8
  import { accessSync } from "fs";
8
9
  import { fileURLToPath } from "url";
@@ -156,6 +157,13 @@ The \`[...]\` prefix identifies where the message came from. Reuse it as the \`c
156
157
 
157
158
  Call \`list_server\` to see all your channels, other agents, and humans in this server.
158
159
 
160
+ ### Channel awareness
161
+
162
+ Each channel has a **name** and optionally a **description** that define its purpose (visible via \`list_server\`). Respect them:
163
+ - **Reply in context** \u2014 always respond in the channel the message came from.
164
+ - **Stay on topic** \u2014 when proactively sharing results or updates, post in the channel most relevant to the work. Don't scatter messages across unrelated channels.
165
+ - If unsure where something belongs, call \`list_server\` to review channel descriptions.
166
+
159
167
  ### Reading history
160
168
 
161
169
  \`read_history(channel="#channel-name")\` or \`read_history(channel="DM:@peer-name")\`
@@ -920,15 +928,22 @@ Note: While you are busy, you may receive [System notification: ...] messages ab
920
928
  }
921
929
  }
922
930
  // Workspace file browsing
923
- async getFileTree(agentId) {
931
+ async getFileTree(agentId, dirPath) {
924
932
  const agentDir = path2.join(DATA_DIR, agentId);
925
933
  try {
926
934
  await stat(agentDir);
927
935
  } catch {
928
936
  return [];
929
937
  }
930
- const count = { n: 0 };
931
- return this.buildFileTree(agentDir, agentDir, count);
938
+ let targetDir = agentDir;
939
+ if (dirPath) {
940
+ const resolved = path2.resolve(agentDir, dirPath);
941
+ if (!resolved.startsWith(agentDir + path2.sep) && resolved !== agentDir) {
942
+ return [];
943
+ }
944
+ targetDir = resolved;
945
+ }
946
+ return this.listDirectoryChildren(targetDir, agentDir);
932
947
  }
933
948
  async readFile(agentId, filePath) {
934
949
  const agentDir = path2.join(DATA_DIR, agentId);
@@ -1055,7 +1070,8 @@ Note: While you are busy, you may receive [System notification: ...] messages ab
1055
1070
  ap.process.stdin?.write(encoded + "\n");
1056
1071
  }
1057
1072
  }
1058
- async buildFileTree(dir, rootDir, count) {
1073
+ /** List ONE level of a directory — directories returned without children (lazy-loaded on demand) */
1074
+ async listDirectoryChildren(dir, rootDir) {
1059
1075
  let entries;
1060
1076
  try {
1061
1077
  entries = await readdir(dir, { withFileTypes: true });
@@ -1069,7 +1085,6 @@ Note: While you are busy, you may receive [System notification: ...] messages ab
1069
1085
  });
1070
1086
  const nodes = [];
1071
1087
  for (const entry of entries) {
1072
- if (count.n >= 500) break;
1073
1088
  if (entry.name.startsWith(".") || entry.name === "node_modules") continue;
1074
1089
  const fullPath = path2.join(dir, entry.name);
1075
1090
  const relativePath = path2.relative(rootDir, fullPath);
@@ -1079,10 +1094,8 @@ Note: While you are busy, you may receive [System notification: ...] messages ab
1079
1094
  } catch {
1080
1095
  continue;
1081
1096
  }
1082
- count.n++;
1083
1097
  if (entry.isDirectory()) {
1084
- const children = await this.buildFileTree(fullPath, rootDir, count);
1085
- nodes.push({ name: entry.name, path: relativePath, isDirectory: true, size: 0, modifiedAt: info.mtime.toISOString(), children });
1098
+ nodes.push({ name: entry.name, path: relativePath, isDirectory: true, size: 0, modifiedAt: info.mtime.toISOString() });
1086
1099
  } else {
1087
1100
  nodes.push({ name: entry.name, path: relativePath, isDirectory: false, size: info.size, modifiedAt: info.mtime.toISOString() });
1088
1101
  }
@@ -1100,6 +1113,8 @@ var RUNTIMES = [
1100
1113
  ];
1101
1114
 
1102
1115
  // src/index.ts
1116
+ var require2 = createRequire(import.meta.url);
1117
+ var DAEMON_VERSION = require2("../package.json").version;
1103
1118
  function detectRuntimes() {
1104
1119
  const detected = [];
1105
1120
  for (const rt of RUNTIMES) {
@@ -1166,8 +1181,8 @@ connection = new DaemonConnection({
1166
1181
  connection.send({ type: "agent:deliver:ack", agentId: msg.agentId, seq: msg.seq });
1167
1182
  break;
1168
1183
  case "agent:workspace:list":
1169
- agentManager.getFileTree(msg.agentId).then((files) => {
1170
- connection.send({ type: "agent:workspace:file_tree", agentId: msg.agentId, files });
1184
+ agentManager.getFileTree(msg.agentId, msg.dirPath).then((files) => {
1185
+ connection.send({ type: "agent:workspace:file_tree", agentId: msg.agentId, files, dirPath: msg.dirPath });
1171
1186
  });
1172
1187
  break;
1173
1188
  case "agent:workspace:read":
@@ -1215,7 +1230,8 @@ connection = new DaemonConnection({
1215
1230
  runtimes,
1216
1231
  runningAgents: agentManager.getRunningAgentIds(),
1217
1232
  hostname: os2.hostname(),
1218
- os: `${os2.platform()} ${os2.arch()}`
1233
+ os: `${os2.platform()} ${os2.arch()}`,
1234
+ daemonVersion: DAEMON_VERSION
1219
1235
  });
1220
1236
  },
1221
1237
  onDisconnect: () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@slock-ai/daemon",
3
- "version": "0.5.0",
3
+ "version": "0.7.0",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "slock-daemon": "dist/index.js"