@deeplake/hivemind 0.7.79 → 0.7.81

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.
Files changed (46) hide show
  1. package/.claude-plugin/marketplace.json +3 -3
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/bundle/cli.js +140 -94
  4. package/codex/bundle/capture.js +232 -72
  5. package/codex/bundle/commands/auth-login.js +14 -10
  6. package/codex/bundle/embeddings/embed-daemon.js +9 -5
  7. package/codex/bundle/graph-on-stop.js +32 -28
  8. package/codex/bundle/graph-pull-worker.js +27 -23
  9. package/codex/bundle/pre-tool-use.js +366 -123
  10. package/codex/bundle/session-start-setup.js +18 -14
  11. package/codex/bundle/session-start.js +26 -22
  12. package/codex/bundle/shell/deeplake-shell.js +30 -26
  13. package/codex/bundle/skillify-worker.js +14 -10
  14. package/codex/bundle/skillopt-worker.js +2061 -0
  15. package/codex/bundle/stop.js +50 -45
  16. package/codex/bundle/wiki-worker.js +18 -14
  17. package/cursor/bundle/capture.js +71 -44
  18. package/cursor/bundle/commands/auth-login.js +14 -10
  19. package/cursor/bundle/embeddings/embed-daemon.js +9 -5
  20. package/cursor/bundle/graph-on-stop.js +32 -28
  21. package/cursor/bundle/graph-pull-worker.js +27 -23
  22. package/cursor/bundle/pre-tool-use.js +28 -24
  23. package/cursor/bundle/session-end.js +40 -36
  24. package/cursor/bundle/session-start.js +39 -35
  25. package/cursor/bundle/shell/deeplake-shell.js +30 -26
  26. package/cursor/bundle/skillify-worker.js +14 -10
  27. package/cursor/bundle/wiki-worker.js +18 -14
  28. package/hermes/bundle/capture.js +235 -85
  29. package/hermes/bundle/commands/auth-login.js +14 -10
  30. package/hermes/bundle/embeddings/embed-daemon.js +9 -5
  31. package/hermes/bundle/graph-on-stop.js +32 -28
  32. package/hermes/bundle/graph-pull-worker.js +27 -23
  33. package/hermes/bundle/pre-tool-use.js +298 -74
  34. package/hermes/bundle/session-end.js +40 -36
  35. package/hermes/bundle/session-start.js +39 -35
  36. package/hermes/bundle/shell/deeplake-shell.js +30 -26
  37. package/hermes/bundle/skillify-worker.js +14 -10
  38. package/hermes/bundle/skillopt-worker.js +2061 -0
  39. package/hermes/bundle/wiki-worker.js +18 -14
  40. package/mcp/bundle/server.js +15 -11
  41. package/openclaw/dist/index.js +11 -7
  42. package/openclaw/dist/skillify-worker.js +14 -10
  43. package/openclaw/openclaw.plugin.json +1 -1
  44. package/openclaw/package.json +1 -1
  45. package/package.json +1 -1
  46. package/pi/extension-source/hivemind.ts +93 -0
@@ -17,7 +17,7 @@ __export(index_marker_store_exports, {
17
17
  hasFreshIndexMarker: () => hasFreshIndexMarker,
18
18
  writeIndexMarker: () => writeIndexMarker
19
19
  });
20
- import { existsSync as existsSync2, mkdirSync as mkdirSync3, readFileSync as readFileSync4, writeFileSync as writeFileSync3 } from "node:fs";
20
+ import { existsSync as existsSync2, mkdirSync as mkdirSync4, readFileSync as readFileSync4, writeFileSync as writeFileSync3 } from "node:fs";
21
21
  import { join as join5 } from "node:path";
22
22
  import { tmpdir } from "node:os";
23
23
  function getIndexMarkerDir() {
@@ -41,7 +41,7 @@ function hasFreshIndexMarker(markerPath) {
41
41
  }
42
42
  }
43
43
  function writeIndexMarker(markerPath) {
44
- mkdirSync3(getIndexMarkerDir(), { recursive: true });
44
+ mkdirSync4(getIndexMarkerDir(), { recursive: true });
45
45
  writeFileSync3(markerPath, JSON.stringify({ updatedAt: (/* @__PURE__ */ new Date()).toISOString() }), "utf-8");
46
46
  }
47
47
  var INDEX_MARKER_TTL_MS;
@@ -55,7 +55,7 @@ var init_index_marker_store = __esm({
55
55
  // dist/src/hooks/codex/stop.js
56
56
  import { readFileSync as readFileSync11, existsSync as existsSync10 } from "node:fs";
57
57
  import { fileURLToPath as fileURLToPath3 } from "node:url";
58
- import { dirname as dirname6, join as join19 } from "node:path";
58
+ import { dirname as dirname7, join as join19 } from "node:path";
59
59
 
60
60
  // dist/src/utils/stdin.js
61
61
  function readStdin() {
@@ -125,8 +125,8 @@ function loadConfig() {
125
125
  import { randomUUID } from "node:crypto";
126
126
 
127
127
  // dist/src/utils/debug.js
128
- import { appendFileSync } from "node:fs";
129
- import { join as join2 } from "node:path";
128
+ import { appendFileSync, mkdirSync } from "node:fs";
129
+ import { dirname, join as join2 } from "node:path";
130
130
  import { homedir as homedir2 } from "node:os";
131
131
  var LOG = join2(homedir2(), ".deeplake", "hook-debug.log");
132
132
  function isDebug() {
@@ -138,8 +138,12 @@ function utcTimestamp(d = /* @__PURE__ */ new Date()) {
138
138
  function log(tag, msg) {
139
139
  if (!isDebug())
140
140
  return;
141
- appendFileSync(LOG, `${(/* @__PURE__ */ new Date()).toISOString()} [${tag}] ${msg}
141
+ try {
142
+ mkdirSync(dirname(LOG), { recursive: true });
143
+ appendFileSync(LOG, `${(/* @__PURE__ */ new Date()).toISOString()} [${tag}] ${msg}
142
144
  `);
145
+ } catch {
146
+ }
143
147
  }
144
148
 
145
149
  // dist/src/utils/sql.js
@@ -345,7 +349,7 @@ async function healMissingColumns(args) {
345
349
  }
346
350
 
347
351
  // dist/src/notifications/queue.js
348
- import { readFileSync as readFileSync2, writeFileSync, renameSync, mkdirSync, openSync, closeSync, unlinkSync, statSync } from "node:fs";
352
+ import { readFileSync as readFileSync2, writeFileSync, renameSync, mkdirSync as mkdirSync2, openSync, closeSync, unlinkSync, statSync } from "node:fs";
349
353
  import { join as join3, resolve } from "node:path";
350
354
  import { homedir as homedir3 } from "node:os";
351
355
  import { setTimeout as sleep } from "node:timers/promises";
@@ -383,14 +387,14 @@ function writeQueue(q) {
383
387
  if (!_isQueuePathInsideHome(path, home)) {
384
388
  throw new Error(`notifications-queue write blocked: ${path} is outside ${home}`);
385
389
  }
386
- mkdirSync(join3(home, ".deeplake"), { recursive: true, mode: 448 });
390
+ mkdirSync2(join3(home, ".deeplake"), { recursive: true, mode: 448 });
387
391
  const tmp = `${path}.${process.pid}.tmp`;
388
392
  writeFileSync(tmp, JSON.stringify(q, null, 2), { mode: 384 });
389
393
  renameSync(tmp, path);
390
394
  }
391
395
  async function withQueueLock(fn) {
392
396
  const path = lockPath();
393
- mkdirSync(join3(homedir3(), ".deeplake"), { recursive: true, mode: 448 });
397
+ mkdirSync2(join3(homedir3(), ".deeplake"), { recursive: true, mode: 448 });
394
398
  let fd = null;
395
399
  for (let attempt = 0; attempt < LOCK_RETRY_MAX; attempt++) {
396
400
  try {
@@ -446,7 +450,7 @@ async function enqueueNotification(n) {
446
450
  }
447
451
 
448
452
  // dist/src/commands/auth-creds.js
449
- import { readFileSync as readFileSync3, writeFileSync as writeFileSync2, mkdirSync as mkdirSync2, unlinkSync as unlinkSync2 } from "node:fs";
453
+ import { readFileSync as readFileSync3, writeFileSync as writeFileSync2, mkdirSync as mkdirSync3, unlinkSync as unlinkSync2 } from "node:fs";
450
454
  import { join as join4 } from "node:path";
451
455
  import { homedir as homedir4 } from "node:os";
452
456
  function configDir() {
@@ -991,12 +995,12 @@ function projectNameFromCwd(cwd) {
991
995
  // dist/src/hooks/codex/spawn-wiki-worker.js
992
996
  import { execSync } from "node:child_process";
993
997
  import { fileURLToPath } from "node:url";
994
- import { dirname as dirname2, join as join8 } from "node:path";
995
- import { writeFileSync as writeFileSync4, mkdirSync as mkdirSync5 } from "node:fs";
998
+ import { dirname as dirname3, join as join8 } from "node:path";
999
+ import { writeFileSync as writeFileSync4, mkdirSync as mkdirSync6 } from "node:fs";
996
1000
  import { homedir as homedir5, tmpdir as tmpdir2 } from "node:os";
997
1001
 
998
1002
  // dist/src/utils/wiki-log.js
999
- import { mkdirSync as mkdirSync4, appendFileSync as appendFileSync2 } from "node:fs";
1003
+ import { mkdirSync as mkdirSync5, appendFileSync as appendFileSync2 } from "node:fs";
1000
1004
  import { join as join6 } from "node:path";
1001
1005
  function makeWikiLogger(hooksDir, filename = "deeplake-wiki.log") {
1002
1006
  const path = join6(hooksDir, filename);
@@ -1004,7 +1008,7 @@ function makeWikiLogger(hooksDir, filename = "deeplake-wiki.log") {
1004
1008
  path,
1005
1009
  log(msg) {
1006
1010
  try {
1007
- mkdirSync4(hooksDir, { recursive: true });
1011
+ mkdirSync5(hooksDir, { recursive: true });
1008
1012
  appendFileSync2(path, `[${utcTimestamp()}] ${msg}
1009
1013
  `);
1010
1014
  } catch {
@@ -1015,7 +1019,7 @@ function makeWikiLogger(hooksDir, filename = "deeplake-wiki.log") {
1015
1019
 
1016
1020
  // dist/src/utils/version-check.js
1017
1021
  import { readFileSync as readFileSync5 } from "node:fs";
1018
- import { dirname, join as join7 } from "node:path";
1022
+ import { dirname as dirname2, join as join7 } from "node:path";
1019
1023
  function getInstalledVersion(bundleDir, pluginManifestDir) {
1020
1024
  try {
1021
1025
  const pluginJson = join7(bundleDir, "..", pluginManifestDir, "plugin.json");
@@ -1047,7 +1051,7 @@ function getInstalledVersion(bundleDir, pluginManifestDir) {
1047
1051
  return pkg.version;
1048
1052
  } catch {
1049
1053
  }
1050
- const parent = dirname(dir);
1054
+ const parent = dirname2(dir);
1051
1055
  if (parent === dir)
1052
1056
  break;
1053
1057
  dir = parent;
@@ -1143,7 +1147,7 @@ function spawnCodexWikiWorker(opts) {
1143
1147
  const { config, sessionId, cwd, bundleDir, reason } = opts;
1144
1148
  const projectName = projectNameFromCwd(cwd);
1145
1149
  const tmpDir = join8(tmpdir2(), `deeplake-wiki-${sessionId}-${Date.now()}`);
1146
- mkdirSync5(tmpDir, { recursive: true });
1150
+ mkdirSync6(tmpDir, { recursive: true });
1147
1151
  const pluginVersion = getInstalledVersion(bundleDir, ".codex-plugin") ?? "";
1148
1152
  const configFile = join8(tmpDir, "config.json");
1149
1153
  writeFileSync4(configFile, JSON.stringify({
@@ -1169,13 +1173,13 @@ function spawnCodexWikiWorker(opts) {
1169
1173
  wikiLog(`${reason}: spawned summary worker for ${sessionId}`);
1170
1174
  }
1171
1175
  function bundleDirFromImportMeta(importMetaUrl) {
1172
- return dirname2(fileURLToPath(importMetaUrl));
1176
+ return dirname3(fileURLToPath(importMetaUrl));
1173
1177
  }
1174
1178
 
1175
1179
  // dist/src/skillify/spawn-skillify-worker.js
1176
1180
  import { fileURLToPath as fileURLToPath2 } from "node:url";
1177
- import { dirname as dirname3, join as join10 } from "node:path";
1178
- import { writeFileSync as writeFileSync5, mkdirSync as mkdirSync6, appendFileSync as appendFileSync3, chmodSync } from "node:fs";
1181
+ import { dirname as dirname4, join as join10 } from "node:path";
1182
+ import { writeFileSync as writeFileSync5, mkdirSync as mkdirSync7, appendFileSync as appendFileSync3, chmodSync } from "node:fs";
1179
1183
  import { homedir as homedir7, tmpdir as tmpdir3 } from "node:os";
1180
1184
 
1181
1185
  // dist/src/skillify/gate-runner.js
@@ -1250,7 +1254,7 @@ var HOME2 = homedir7();
1250
1254
  var SKILLIFY_LOG = join10(HOME2, ".claude", "hooks", "skillify.log");
1251
1255
  function skillifyLog(msg) {
1252
1256
  try {
1253
- mkdirSync6(dirname3(SKILLIFY_LOG), { recursive: true });
1257
+ mkdirSync7(dirname4(SKILLIFY_LOG), { recursive: true });
1254
1258
  appendFileSync3(SKILLIFY_LOG, `[${utcTimestamp()}] ${msg}
1255
1259
  `);
1256
1260
  } catch {
@@ -1259,7 +1263,7 @@ function skillifyLog(msg) {
1259
1263
  function spawnSkillifyWorker(opts) {
1260
1264
  const { config, cwd, projectKey, project, bundleDir, agent, scopeConfig, currentSessionId, reason } = opts;
1261
1265
  const tmpDir = join10(tmpdir3(), `deeplake-skillify-${projectKey}-${Date.now()}`);
1262
- mkdirSync6(tmpDir, { recursive: true, mode: 448 });
1266
+ mkdirSync7(tmpDir, { recursive: true, mode: 448 });
1263
1267
  const gateBin = findAgentBin(agent);
1264
1268
  const configFile = join10(tmpDir, "config.json");
1265
1269
  writeFileSync5(configFile, JSON.stringify({
@@ -1298,7 +1302,7 @@ function spawnSkillifyWorker(opts) {
1298
1302
  }
1299
1303
 
1300
1304
  // dist/src/skillify/state.js
1301
- import { readFileSync as readFileSync6, writeFileSync as writeFileSync6, writeSync, mkdirSync as mkdirSync7, renameSync as renameSync3, rmdirSync, existsSync as existsSync5, lstatSync, unlinkSync as unlinkSync3, openSync as openSync2, closeSync as closeSync2 } from "node:fs";
1305
+ import { readFileSync as readFileSync6, writeFileSync as writeFileSync6, writeSync, mkdirSync as mkdirSync8, renameSync as renameSync3, rmdirSync, existsSync as existsSync5, lstatSync, unlinkSync as unlinkSync3, openSync as openSync2, closeSync as closeSync2 } from "node:fs";
1302
1306
  import { join as join13 } from "node:path";
1303
1307
 
1304
1308
  // dist/src/utils/repo-identity.js
@@ -1350,7 +1354,7 @@ function deriveProjectKey(cwd) {
1350
1354
 
1351
1355
  // dist/src/skillify/legacy-migration.js
1352
1356
  import { existsSync as existsSync4, renameSync as renameSync2 } from "node:fs";
1353
- import { dirname as dirname4, join as join12 } from "node:path";
1357
+ import { dirname as dirname5, join as join12 } from "node:path";
1354
1358
 
1355
1359
  // dist/src/skillify/state-dir.js
1356
1360
  import { homedir as homedir8 } from "node:os";
@@ -1370,7 +1374,7 @@ function migrateLegacyStateDir() {
1370
1374
  return;
1371
1375
  attempted = true;
1372
1376
  const current = getStateDir();
1373
- const legacy = join12(dirname4(current), "skilify");
1377
+ const legacy = join12(dirname5(current), "skilify");
1374
1378
  if (!existsSync4(legacy))
1375
1379
  return;
1376
1380
  if (existsSync4(current))
@@ -1414,7 +1418,7 @@ function readState(projectKey) {
1414
1418
  }
1415
1419
  function writeState(projectKey, state) {
1416
1420
  migrateLegacyStateDir();
1417
- mkdirSync7(getStateDir(), { recursive: true });
1421
+ mkdirSync8(getStateDir(), { recursive: true });
1418
1422
  const p = statePath(projectKey);
1419
1423
  const tmp = `${p}.${process.pid}.${Date.now()}.tmp`;
1420
1424
  writeFileSync6(tmp, JSON.stringify(state, null, 2));
@@ -1422,7 +1426,7 @@ function writeState(projectKey, state) {
1422
1426
  }
1423
1427
  function withRmwLock(projectKey, fn) {
1424
1428
  migrateLegacyStateDir();
1425
- mkdirSync7(getStateDir(), { recursive: true });
1429
+ mkdirSync8(getStateDir(), { recursive: true });
1426
1430
  const rmw = lockPath2(projectKey) + ".rmw";
1427
1431
  const deadline = Date.now() + 2e3;
1428
1432
  let fd = null;
@@ -1465,7 +1469,7 @@ function resetCounter(projectKey) {
1465
1469
  }
1466
1470
  function tryAcquireWorkerLock(projectKey, maxAgeMs = 10 * 60 * 1e3) {
1467
1471
  migrateLegacyStateDir();
1468
- mkdirSync7(getStateDir(), { recursive: true });
1472
+ mkdirSync8(getStateDir(), { recursive: true });
1469
1473
  const p = lockPath2(projectKey);
1470
1474
  if (existsSync5(p)) {
1471
1475
  try {
@@ -1517,7 +1521,7 @@ function releaseWorkerLock(projectKey) {
1517
1521
  }
1518
1522
 
1519
1523
  // dist/src/skillify/scope-config.js
1520
- import { existsSync as existsSync6, mkdirSync as mkdirSync8, readFileSync as readFileSync7, writeFileSync as writeFileSync7 } from "node:fs";
1524
+ import { existsSync as existsSync6, mkdirSync as mkdirSync9, readFileSync as readFileSync7, writeFileSync as writeFileSync7 } from "node:fs";
1521
1525
  import { join as join14 } from "node:path";
1522
1526
  function configPath() {
1523
1527
  return join14(getStateDir(), "config.json");
@@ -1580,7 +1584,7 @@ function forceSessionEndTrigger(opts) {
1580
1584
  }
1581
1585
 
1582
1586
  // dist/src/hooks/summary-state.js
1583
- import { readFileSync as readFileSync8, writeFileSync as writeFileSync8, writeSync as writeSync2, mkdirSync as mkdirSync9, renameSync as renameSync4, existsSync as existsSync7, unlinkSync as unlinkSync4, openSync as openSync3, closeSync as closeSync3, statSync as statSync2 } from "node:fs";
1587
+ import { readFileSync as readFileSync8, writeFileSync as writeFileSync8, writeSync as writeSync2, mkdirSync as mkdirSync10, renameSync as renameSync4, existsSync as existsSync7, unlinkSync as unlinkSync4, openSync as openSync3, closeSync as closeSync3, statSync as statSync2 } from "node:fs";
1584
1588
  import { homedir as homedir9 } from "node:os";
1585
1589
  import { join as join15 } from "node:path";
1586
1590
  var dlog3 = (msg) => log("summary-state", msg);
@@ -1590,7 +1594,7 @@ function lockPath3(sessionId) {
1590
1594
  return join15(STATE_DIR, `${sessionId}.lock`);
1591
1595
  }
1592
1596
  function tryAcquireLock(sessionId, maxAgeMs = 10 * 60 * 1e3) {
1593
- mkdirSync9(STATE_DIR, { recursive: true });
1597
+ mkdirSync10(STATE_DIR, { recursive: true });
1594
1598
  const p = lockPath3(sessionId);
1595
1599
  if (existsSync7(p)) {
1596
1600
  try {
@@ -2042,9 +2046,9 @@ import { join as join18 } from "node:path";
2042
2046
  import { pathToFileURL } from "node:url";
2043
2047
 
2044
2048
  // dist/src/user-config.js
2045
- import { existsSync as existsSync9, mkdirSync as mkdirSync10, readFileSync as readFileSync10, renameSync as renameSync5, writeFileSync as writeFileSync9 } from "node:fs";
2049
+ import { existsSync as existsSync9, mkdirSync as mkdirSync11, readFileSync as readFileSync10, renameSync as renameSync5, writeFileSync as writeFileSync9 } from "node:fs";
2046
2050
  import { homedir as homedir11 } from "node:os";
2047
- import { dirname as dirname5, join as join17 } from "node:path";
2051
+ import { dirname as dirname6, join as join17 } from "node:path";
2048
2052
  var _configPath = () => process.env.HIVEMIND_CONFIG_PATH ?? join17(homedir11(), ".deeplake", "config.json");
2049
2053
  var _cache = null;
2050
2054
  var _migrated = false;
@@ -2069,9 +2073,9 @@ function writeUserConfig(patch) {
2069
2073
  const current = readUserConfig();
2070
2074
  const merged = deepMerge(current, patch);
2071
2075
  const path = _configPath();
2072
- const dir = dirname5(path);
2076
+ const dir = dirname6(path);
2073
2077
  if (!existsSync9(dir))
2074
- mkdirSync10(dir, { recursive: true });
2078
+ mkdirSync11(dir, { recursive: true });
2075
2079
  const tmp = `${path}.tmp.${process.pid}`;
2076
2080
  writeFileSync9(tmp, JSON.stringify(merged, null, 2) + "\n", "utf-8");
2077
2081
  renameSync5(tmp, path);
@@ -2156,9 +2160,9 @@ function embeddingsDisabled() {
2156
2160
  // dist/src/hooks/codex/stop.js
2157
2161
  var log5 = (msg) => log("codex-stop", msg);
2158
2162
  function resolveEmbedDaemonPath() {
2159
- return join19(dirname6(fileURLToPath3(import.meta.url)), "embeddings", "embed-daemon.js");
2163
+ return join19(dirname7(fileURLToPath3(import.meta.url)), "embeddings", "embed-daemon.js");
2160
2164
  }
2161
- var __bundleDir = dirname6(fileURLToPath3(import.meta.url));
2165
+ var __bundleDir = dirname7(fileURLToPath3(import.meta.url));
2162
2166
  var PLUGIN_VERSION = getInstalledVersion(__bundleDir, ".codex-plugin") ?? "";
2163
2167
  var CAPTURE = process.env.HIVEMIND_CAPTURE !== "false";
2164
2168
  async function main() {
@@ -2233,6 +2237,14 @@ async function main() {
2233
2237
  }
2234
2238
  if (!CAPTURE)
2235
2239
  return;
2240
+ const cwd = input.cwd || process.cwd();
2241
+ forceSessionEndTrigger({
2242
+ config,
2243
+ cwd,
2244
+ bundleDir: bundleDirFromImportMeta(import.meta.url),
2245
+ agent: "codex",
2246
+ sessionId
2247
+ });
2236
2248
  if (!tryAcquireLock(sessionId)) {
2237
2249
  wikiLog(`Stop: periodic worker already running for ${sessionId}, skipping`);
2238
2250
  return;
@@ -2242,7 +2254,7 @@ async function main() {
2242
2254
  spawnCodexWikiWorker({
2243
2255
  config,
2244
2256
  sessionId,
2245
- cwd: input.cwd ?? "",
2257
+ cwd,
2246
2258
  bundleDir: bundleDirFromImportMeta(import.meta.url),
2247
2259
  reason: "Stop"
2248
2260
  });
@@ -2255,13 +2267,6 @@ async function main() {
2255
2267
  }
2256
2268
  throw e;
2257
2269
  }
2258
- forceSessionEndTrigger({
2259
- config,
2260
- cwd: input.cwd ?? "",
2261
- bundleDir: bundleDirFromImportMeta(import.meta.url),
2262
- agent: "codex",
2263
- sessionId
2264
- });
2265
2270
  }
2266
2271
  main().catch((e) => {
2267
2272
  log5(`fatal: ${e.message}`);
@@ -1,19 +1,19 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // dist/src/hooks/codex/wiki-worker.js
4
- import { readFileSync as readFileSync4, writeFileSync as writeFileSync3, existsSync as existsSync4, appendFileSync as appendFileSync2, mkdirSync as mkdirSync3, rmSync } from "node:fs";
4
+ import { readFileSync as readFileSync4, writeFileSync as writeFileSync3, existsSync as existsSync4, appendFileSync as appendFileSync2, mkdirSync as mkdirSync4, rmSync } from "node:fs";
5
5
  import { execFileSync } from "node:child_process";
6
- import { dirname as dirname2, join as join6 } from "node:path";
6
+ import { dirname as dirname3, join as join6 } from "node:path";
7
7
  import { fileURLToPath } from "node:url";
8
8
 
9
9
  // dist/src/hooks/summary-state.js
10
- import { readFileSync, writeFileSync, writeSync, mkdirSync, renameSync, existsSync, unlinkSync, openSync, closeSync, statSync } from "node:fs";
10
+ import { readFileSync, writeFileSync, writeSync, mkdirSync as mkdirSync2, renameSync, existsSync, unlinkSync, openSync, closeSync, statSync } from "node:fs";
11
11
  import { homedir as homedir2 } from "node:os";
12
12
  import { join as join2 } from "node:path";
13
13
 
14
14
  // dist/src/utils/debug.js
15
- import { appendFileSync } from "node:fs";
16
- import { join } from "node:path";
15
+ import { appendFileSync, mkdirSync } from "node:fs";
16
+ import { dirname, join } from "node:path";
17
17
  import { homedir } from "node:os";
18
18
  var LOG = join(homedir(), ".deeplake", "hook-debug.log");
19
19
  function isDebug() {
@@ -22,8 +22,12 @@ function isDebug() {
22
22
  function log(tag, msg) {
23
23
  if (!isDebug())
24
24
  return;
25
- appendFileSync(LOG, `${(/* @__PURE__ */ new Date()).toISOString()} [${tag}] ${msg}
25
+ try {
26
+ mkdirSync(dirname(LOG), { recursive: true });
27
+ appendFileSync(LOG, `${(/* @__PURE__ */ new Date()).toISOString()} [${tag}] ${msg}
26
28
  `);
29
+ } catch {
30
+ }
27
31
  }
28
32
 
29
33
  // dist/src/hooks/summary-state.js
@@ -47,14 +51,14 @@ function readState(sessionId) {
47
51
  }
48
52
  }
49
53
  function writeState(sessionId, state) {
50
- mkdirSync(STATE_DIR, { recursive: true });
54
+ mkdirSync2(STATE_DIR, { recursive: true });
51
55
  const p = statePath(sessionId);
52
56
  const tmp = `${p}.${process.pid}.${Date.now()}.tmp`;
53
57
  writeFileSync(tmp, JSON.stringify(state));
54
58
  renameSync(tmp, p);
55
59
  }
56
60
  function withRmwLock(sessionId, fn) {
57
- mkdirSync(STATE_DIR, { recursive: true });
61
+ mkdirSync2(STATE_DIR, { recursive: true });
58
62
  const rmwLock = statePath(sessionId) + ".rmw";
59
63
  const deadline = Date.now() + 2e3;
60
64
  let fd = null;
@@ -543,9 +547,9 @@ import { join as join5 } from "node:path";
543
547
  import { pathToFileURL } from "node:url";
544
548
 
545
549
  // dist/src/user-config.js
546
- import { existsSync as existsSync3, mkdirSync as mkdirSync2, readFileSync as readFileSync3, renameSync as renameSync2, writeFileSync as writeFileSync2 } from "node:fs";
550
+ import { existsSync as existsSync3, mkdirSync as mkdirSync3, readFileSync as readFileSync3, renameSync as renameSync2, writeFileSync as writeFileSync2 } from "node:fs";
547
551
  import { homedir as homedir4 } from "node:os";
548
- import { dirname, join as join4 } from "node:path";
552
+ import { dirname as dirname2, join as join4 } from "node:path";
549
553
  var _configPath = () => process.env.HIVEMIND_CONFIG_PATH ?? join4(homedir4(), ".deeplake", "config.json");
550
554
  var _cache = null;
551
555
  var _migrated = false;
@@ -570,9 +574,9 @@ function writeUserConfig(patch) {
570
574
  const current = readUserConfig();
571
575
  const merged = deepMerge(current, patch);
572
576
  const path = _configPath();
573
- const dir = dirname(path);
577
+ const dir = dirname2(path);
574
578
  if (!existsSync3(dir))
575
- mkdirSync2(dir, { recursive: true });
579
+ mkdirSync3(dir, { recursive: true });
576
580
  const tmp = `${path}.tmp.${process.pid}`;
577
581
  writeFileSync2(tmp, JSON.stringify(merged, null, 2) + "\n", "utf-8");
578
582
  renameSync2(tmp, path);
@@ -671,7 +675,7 @@ var tmpJsonl = join6(tmpDir, "session.jsonl");
671
675
  var tmpSummary = join6(tmpDir, "summary.md");
672
676
  function wlog(msg) {
673
677
  try {
674
- mkdirSync3(cfg.hooksDir, { recursive: true });
678
+ mkdirSync4(cfg.hooksDir, { recursive: true });
675
679
  appendFileSync2(cfg.wikiLog, `[${(/* @__PURE__ */ new Date()).toISOString().replace("T", " ").slice(0, 19)}] wiki-worker(${cfg.sessionId}): ${msg}
676
680
  `);
677
681
  } catch {
@@ -799,7 +803,7 @@ async function main() {
799
803
  let embedding = null;
800
804
  if (!embeddingsDisabled()) {
801
805
  try {
802
- const daemonEntry = join6(dirname2(fileURLToPath(import.meta.url)), "embeddings", "embed-daemon.js");
806
+ const daemonEntry = join6(dirname3(fileURLToPath(import.meta.url)), "embeddings", "embed-daemon.js");
803
807
  embedding = await new EmbedClient({ daemonEntry }).embed(text, "document");
804
808
  } catch (e) {
805
809
  wlog(`summary embedding failed, writing NULL: ${e.message}`);