@slock-ai/daemon 0.46.2 → 0.47.0-staging.20260511155804

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.
@@ -4,8 +4,9 @@ import {
4
4
  buildFetchDispatcher,
5
5
  executeJsonRequest,
6
6
  executeResponseRequest,
7
- logger
8
- } from "./chunk-Z3PCMYZO.js";
7
+ logger,
8
+ resolveSlockHomePath
9
+ } from "./chunk-B7XIMLOT.js";
9
10
 
10
11
  // src/chat-bridge.ts
11
12
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
@@ -722,8 +723,7 @@ Use this ID in send_message's attachment_ids parameter to include it in a messag
722
723
  try {
723
724
  const fs = await import("fs");
724
725
  const path = await import("path");
725
- const os = await import("os");
726
- const cacheDir = path.join(os.homedir(), ".slock", "attachments");
726
+ const cacheDir = resolveSlockHomePath("attachments");
727
727
  fs.mkdirSync(cacheDir, { recursive: true });
728
728
  const existing = fs.readdirSync(cacheDir).find((f) => f.startsWith(attachment_id));
729
729
  if (existing) {
@@ -207,6 +207,45 @@ async function executeResponseRequest(url, init, {
207
207
  }
208
208
  }
209
209
 
210
+ // src/slockHome.ts
211
+ import os from "os";
212
+ import path from "path";
213
+ import { existsSync } from "fs";
214
+ var SLOCK_HOME_ENV = "SLOCK_HOME";
215
+ function resolveDefaultSlockHome(homeDir = os.homedir()) {
216
+ return path.resolve(path.join(homeDir, ".slock"));
217
+ }
218
+ function resolveSlockHome(env = process.env, homeDir = os.homedir()) {
219
+ const raw = env[SLOCK_HOME_ENV]?.trim();
220
+ const root = raw && raw.length > 0 ? raw : resolveDefaultSlockHome(homeDir);
221
+ return path.resolve(root);
222
+ }
223
+ function resolveSlockHomePath(childPath, slockHome = resolveSlockHome()) {
224
+ return path.join(slockHome, childPath);
225
+ }
226
+ function listLegacySlockStatePaths(slockHome = resolveSlockHome(), homeDir = os.homedir()) {
227
+ const defaultHome = resolveDefaultSlockHome(homeDir);
228
+ if (path.resolve(slockHome) === defaultHome) return [];
229
+ const candidates = [
230
+ {
231
+ path: path.join(defaultHome, "agents"),
232
+ destination: path.join(slockHome, "agents"),
233
+ description: "agent workspaces and per-agent runtime wrapper state"
234
+ },
235
+ {
236
+ path: path.join(defaultHome, "machines"),
237
+ destination: path.join(slockHome, "machines"),
238
+ description: "daemon machine locks, local traces, and machine-scoped state"
239
+ },
240
+ {
241
+ path: path.join(defaultHome, "attachments"),
242
+ destination: path.join(slockHome, "attachments"),
243
+ description: "chat bridge attachment download cache"
244
+ }
245
+ ];
246
+ return candidates.filter((candidate) => existsSync(candidate.path));
247
+ }
248
+
210
249
  export {
211
250
  subscribeDaemonLogs,
212
251
  logger,
@@ -214,5 +253,9 @@ export {
214
253
  buildFetchDispatcher,
215
254
  DEFAULT_CHAT_BRIDGE_TOOL_TIMEOUT_MS,
216
255
  executeJsonRequest,
217
- executeResponseRequest
256
+ executeResponseRequest,
257
+ SLOCK_HOME_ENV,
258
+ resolveSlockHome,
259
+ resolveSlockHomePath,
260
+ listLegacySlockStatePaths
218
261
  };