@deeplake/hivemind 0.7.40 → 0.7.41

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.
@@ -17,21 +17,21 @@ __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";
21
- import { join as join5 } from "node:path";
20
+ import { existsSync as existsSync2, mkdirSync as mkdirSync4, readFileSync as readFileSync5, writeFileSync as writeFileSync4 } from "node:fs";
21
+ import { join as join6 } from "node:path";
22
22
  import { tmpdir } from "node:os";
23
23
  function getIndexMarkerDir() {
24
- return process.env.HIVEMIND_INDEX_MARKER_DIR ?? join5(tmpdir(), "hivemind-deeplake-indexes");
24
+ return process.env.HIVEMIND_INDEX_MARKER_DIR ?? join6(tmpdir(), "hivemind-deeplake-indexes");
25
25
  }
26
26
  function buildIndexMarkerPath(workspaceId, orgId, table, suffix) {
27
27
  const markerKey = [workspaceId, orgId, table, suffix].join("__").replace(/[^a-zA-Z0-9_.-]/g, "_");
28
- return join5(getIndexMarkerDir(), `${markerKey}.json`);
28
+ return join6(getIndexMarkerDir(), `${markerKey}.json`);
29
29
  }
30
30
  function hasFreshIndexMarker(markerPath) {
31
31
  if (!existsSync2(markerPath))
32
32
  return false;
33
33
  try {
34
- const raw = JSON.parse(readFileSync4(markerPath, "utf-8"));
34
+ const raw = JSON.parse(readFileSync5(markerPath, "utf-8"));
35
35
  const updatedAt = raw.updatedAt ? new Date(raw.updatedAt).getTime() : NaN;
36
36
  if (!Number.isFinite(updatedAt) || Date.now() - updatedAt > INDEX_MARKER_TTL_MS)
37
37
  return false;
@@ -41,8 +41,8 @@ function hasFreshIndexMarker(markerPath) {
41
41
  }
42
42
  }
43
43
  function writeIndexMarker(markerPath) {
44
- mkdirSync3(getIndexMarkerDir(), { recursive: true });
45
- writeFileSync3(markerPath, JSON.stringify({ updatedAt: (/* @__PURE__ */ new Date()).toISOString() }), "utf-8");
44
+ mkdirSync4(getIndexMarkerDir(), { recursive: true });
45
+ writeFileSync4(markerPath, JSON.stringify({ updatedAt: (/* @__PURE__ */ new Date()).toISOString() }), "utf-8");
46
46
  }
47
47
  var INDEX_MARKER_TTL_MS;
48
48
  var init_index_marker_store = __esm({
@@ -64,26 +64,61 @@ function deeplakeClientHeader() {
64
64
  return { [DEEPLAKE_CLIENT_HEADER]: deeplakeClientValue() };
65
65
  }
66
66
 
67
- // dist/src/commands/auth-creds.js
68
- import { readFileSync, writeFileSync, mkdirSync, unlinkSync } from "node:fs";
67
+ // dist/src/commands/install-id.js
68
+ import { readFileSync, writeFileSync, mkdirSync } from "node:fs";
69
69
  import { join } from "node:path";
70
70
  import { homedir } from "node:os";
71
+ import { randomUUID } from "node:crypto";
71
72
  function configDir() {
72
73
  return join(homedir(), ".deeplake");
73
74
  }
75
+ function installIDPath() {
76
+ return join(configDir(), "install-id");
77
+ }
78
+ var UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
79
+ function getOrCreateInstallID() {
80
+ try {
81
+ const value = readFileSync(installIDPath(), "utf-8").trim();
82
+ if (UUID_RE.test(value))
83
+ return value;
84
+ } catch {
85
+ }
86
+ const id = randomUUID();
87
+ try {
88
+ mkdirSync(configDir(), { recursive: true, mode: 448 });
89
+ writeFileSync(installIDPath(), id, { mode: 384 });
90
+ return id;
91
+ } catch {
92
+ return "";
93
+ }
94
+ }
95
+ function hivemindInstallIDHeader() {
96
+ const id = getOrCreateInstallID();
97
+ if (!id)
98
+ return {};
99
+ return { "X-Hivemind-Install-Id": id };
100
+ }
101
+
102
+ // dist/src/commands/auth-creds.js
103
+ import { readFileSync as readFileSync2, writeFileSync as writeFileSync2, mkdirSync as mkdirSync2, unlinkSync } from "node:fs";
104
+ import { join as join2 } from "node:path";
105
+ import { homedir as homedir2 } from "node:os";
106
+ function configDir2() {
107
+ return join2(homedir2(), ".deeplake");
108
+ }
74
109
  function credsPath() {
75
- return join(configDir(), "credentials.json");
110
+ return join2(configDir2(), "credentials.json");
76
111
  }
77
112
  function loadCredentials() {
78
113
  try {
79
- return JSON.parse(readFileSync(credsPath(), "utf-8"));
114
+ return JSON.parse(readFileSync2(credsPath(), "utf-8"));
80
115
  } catch {
81
116
  return null;
82
117
  }
83
118
  }
84
119
  function saveCredentials(creds) {
85
- mkdirSync(configDir(), { recursive: true, mode: 448 });
86
- writeFileSync(credsPath(), JSON.stringify({ ...creds, savedAt: (/* @__PURE__ */ new Date()).toISOString() }, null, 2), { mode: 384 });
120
+ mkdirSync2(configDir2(), { recursive: true, mode: 448 });
121
+ writeFileSync2(credsPath(), JSON.stringify({ ...creds, savedAt: (/* @__PURE__ */ new Date()).toISOString() }, null, 2), { mode: 384 });
87
122
  }
88
123
  function deleteCredentials() {
89
124
  try {
@@ -150,7 +185,11 @@ async function apiDelete(path, token, apiUrl, orgId) {
150
185
  async function requestDeviceCode(apiUrl = DEFAULT_API_URL) {
151
186
  const resp = await fetch(`${apiUrl}/auth/device/code`, {
152
187
  method: "POST",
153
- headers: { "Content-Type": "application/json", ...deeplakeClientHeader() }
188
+ headers: {
189
+ "Content-Type": "application/json",
190
+ ...deeplakeClientHeader(),
191
+ ...hivemindInstallIDHeader()
192
+ }
154
193
  });
155
194
  if (!resp.ok)
156
195
  throw new Error(`Device flow unavailable: HTTP ${resp.status}`);
@@ -159,7 +198,11 @@ async function requestDeviceCode(apiUrl = DEFAULT_API_URL) {
159
198
  async function pollForToken(deviceCode, apiUrl = DEFAULT_API_URL) {
160
199
  const resp = await fetch(`${apiUrl}/auth/device/token`, {
161
200
  method: "POST",
162
- headers: { "Content-Type": "application/json", ...deeplakeClientHeader() },
201
+ headers: {
202
+ "Content-Type": "application/json",
203
+ ...deeplakeClientHeader(),
204
+ ...hivemindInstallIDHeader()
205
+ },
163
206
  body: JSON.stringify({ device_code: deviceCode })
164
207
  });
165
208
  if (resp.ok)
@@ -313,16 +356,16 @@ async function login(apiUrl = DEFAULT_API_URL) {
313
356
  }
314
357
 
315
358
  // dist/src/config.js
316
- import { readFileSync as readFileSync2, existsSync } from "node:fs";
317
- import { join as join2 } from "node:path";
318
- import { homedir as homedir2, userInfo } from "node:os";
359
+ import { readFileSync as readFileSync3, existsSync } from "node:fs";
360
+ import { join as join3 } from "node:path";
361
+ import { homedir as homedir3, userInfo } from "node:os";
319
362
  function loadConfig() {
320
- const home = homedir2();
321
- const credPath = join2(home, ".deeplake", "credentials.json");
363
+ const home = homedir3();
364
+ const credPath = join3(home, ".deeplake", "credentials.json");
322
365
  let creds = null;
323
366
  if (existsSync(credPath)) {
324
367
  try {
325
- creds = JSON.parse(readFileSync2(credPath, "utf-8"));
368
+ creds = JSON.parse(readFileSync3(credPath, "utf-8"));
326
369
  } catch {
327
370
  return null;
328
371
  }
@@ -341,18 +384,18 @@ function loadConfig() {
341
384
  tableName: process.env.HIVEMIND_TABLE ?? "memory",
342
385
  sessionsTableName: process.env.HIVEMIND_SESSIONS_TABLE ?? "sessions",
343
386
  skillsTableName: process.env.HIVEMIND_SKILLS_TABLE ?? "skills",
344
- memoryPath: process.env.HIVEMIND_MEMORY_PATH ?? join2(home, ".deeplake", "memory")
387
+ memoryPath: process.env.HIVEMIND_MEMORY_PATH ?? join3(home, ".deeplake", "memory")
345
388
  };
346
389
  }
347
390
 
348
391
  // dist/src/deeplake-api.js
349
- import { randomUUID } from "node:crypto";
392
+ import { randomUUID as randomUUID2 } from "node:crypto";
350
393
 
351
394
  // dist/src/utils/debug.js
352
395
  import { appendFileSync } from "node:fs";
353
- import { join as join3 } from "node:path";
354
- import { homedir as homedir3 } from "node:os";
355
- var LOG = join3(homedir3(), ".deeplake", "hook-debug.log");
396
+ import { join as join4 } from "node:path";
397
+ import { homedir as homedir4 } from "node:os";
398
+ var LOG = join4(homedir4(), ".deeplake", "hook-debug.log");
356
399
  function isDebug() {
357
400
  return process.env.HIVEMIND_DEBUG === "1";
358
401
  }
@@ -495,23 +538,23 @@ async function healMissingColumns(args) {
495
538
  }
496
539
 
497
540
  // dist/src/notifications/queue.js
498
- import { readFileSync as readFileSync3, writeFileSync as writeFileSync2, renameSync, mkdirSync as mkdirSync2, openSync, closeSync, unlinkSync as unlinkSync2, statSync } from "node:fs";
499
- import { join as join4, resolve } from "node:path";
500
- import { homedir as homedir4 } from "node:os";
541
+ import { readFileSync as readFileSync4, writeFileSync as writeFileSync3, renameSync, mkdirSync as mkdirSync3, openSync, closeSync, unlinkSync as unlinkSync2, statSync } from "node:fs";
542
+ import { join as join5, resolve } from "node:path";
543
+ import { homedir as homedir5 } from "node:os";
501
544
  import { setTimeout as sleep } from "node:timers/promises";
502
545
  var log2 = (msg) => log("notifications-queue", msg);
503
546
  var LOCK_RETRY_MAX = 50;
504
547
  var LOCK_RETRY_BASE_MS = 5;
505
548
  var LOCK_STALE_MS = 5e3;
506
549
  function queuePath() {
507
- return join4(homedir4(), ".deeplake", "notifications-queue.json");
550
+ return join5(homedir5(), ".deeplake", "notifications-queue.json");
508
551
  }
509
552
  function lockPath() {
510
553
  return `${queuePath()}.lock`;
511
554
  }
512
555
  function readQueue() {
513
556
  try {
514
- const raw = readFileSync3(queuePath(), "utf-8");
557
+ const raw = readFileSync4(queuePath(), "utf-8");
515
558
  const parsed = JSON.parse(raw);
516
559
  if (!parsed || !Array.isArray(parsed.queue)) {
517
560
  log2(`queue malformed \u2192 treating as empty`);
@@ -529,18 +572,18 @@ function _isQueuePathInsideHome(path, home) {
529
572
  }
530
573
  function writeQueue(q) {
531
574
  const path = queuePath();
532
- const home = resolve(homedir4());
575
+ const home = resolve(homedir5());
533
576
  if (!_isQueuePathInsideHome(path, home)) {
534
577
  throw new Error(`notifications-queue write blocked: ${path} is outside ${home}`);
535
578
  }
536
- mkdirSync2(join4(home, ".deeplake"), { recursive: true, mode: 448 });
579
+ mkdirSync3(join5(home, ".deeplake"), { recursive: true, mode: 448 });
537
580
  const tmp = `${path}.${process.pid}.tmp`;
538
- writeFileSync2(tmp, JSON.stringify(q, null, 2), { mode: 384 });
581
+ writeFileSync3(tmp, JSON.stringify(q, null, 2), { mode: 384 });
539
582
  renameSync(tmp, path);
540
583
  }
541
584
  async function withQueueLock(fn) {
542
585
  const path = lockPath();
543
- mkdirSync2(join4(homedir4(), ".deeplake"), { recursive: true, mode: 448 });
586
+ mkdirSync3(join5(homedir5(), ".deeplake"), { recursive: true, mode: 448 });
544
587
  let fd = null;
545
588
  for (let attempt = 0; attempt < LOCK_RETRY_MAX; attempt++) {
546
589
  try {
@@ -813,7 +856,7 @@ var DeeplakeApi = class {
813
856
  setClauses += `, description = '${sqlStr(row.description)}'`;
814
857
  await this.query(`UPDATE "${this.tableName}" SET ${setClauses} WHERE path = '${sqlStr(row.path)}'`);
815
858
  } else {
816
- const id = randomUUID();
859
+ const id = randomUUID2();
817
860
  let cols = `id, path, filename, summary, ${SUMMARY_EMBEDDING_COL}, mime_type, size_bytes, creation_date, last_update_date`;
818
861
  let vals = `'${id}', '${sqlStr(row.path)}', '${sqlStr(row.filename)}', E'${sqlStr(row.contentText)}', NULL, '${sqlStr(row.mimeType)}', ${row.sizeBytes}, '${cd}', '${lud}'`;
819
862
  if (row.project !== void 0) {
@@ -1011,22 +1054,22 @@ var DeeplakeApi = class {
1011
1054
  };
1012
1055
 
1013
1056
  // dist/src/cli/util.js
1014
- import { existsSync as existsSync3, mkdirSync as mkdirSync4, readFileSync as readFileSync5, writeFileSync as writeFileSync4, cpSync, symlinkSync, unlinkSync as unlinkSync3, lstatSync } from "node:fs";
1015
- import { join as join6, dirname } from "node:path";
1016
- import { homedir as homedir5 } from "node:os";
1057
+ import { existsSync as existsSync3, mkdirSync as mkdirSync5, readFileSync as readFileSync6, writeFileSync as writeFileSync5, cpSync, symlinkSync, unlinkSync as unlinkSync3, lstatSync } from "node:fs";
1058
+ import { join as join7, dirname } from "node:path";
1059
+ import { homedir as homedir6 } from "node:os";
1017
1060
  import { fileURLToPath } from "node:url";
1018
1061
  import { createInterface } from "node:readline";
1019
- var HOME = homedir5();
1062
+ var HOME = homedir6();
1020
1063
  var PLATFORM_MARKERS = [
1021
- { id: "claude", markerDir: join6(HOME, ".claude") },
1022
- { id: "codex", markerDir: join6(HOME, ".codex") },
1023
- { id: "claw", markerDir: join6(HOME, ".openclaw") },
1024
- { id: "cursor", markerDir: join6(HOME, ".cursor") },
1025
- { id: "hermes", markerDir: join6(HOME, ".hermes") },
1064
+ { id: "claude", markerDir: join7(HOME, ".claude") },
1065
+ { id: "codex", markerDir: join7(HOME, ".codex") },
1066
+ { id: "claw", markerDir: join7(HOME, ".openclaw") },
1067
+ { id: "cursor", markerDir: join7(HOME, ".cursor") },
1068
+ { id: "hermes", markerDir: join7(HOME, ".hermes") },
1026
1069
  // pi (badlogic/pi-mono coding-agent) — config at ~/.pi/agent/. pi exposes
1027
1070
  // a rich extension event API (session_start / input / tool_call /
1028
1071
  // tool_result / message_end / session_shutdown / etc.) — Tier 1 capable.
1029
- { id: "pi", markerDir: join6(HOME, ".pi") }
1072
+ { id: "pi", markerDir: join7(HOME, ".pi") }
1030
1073
  ];
1031
1074
  function confirm(message, defaultYes = true) {
1032
1075
  const hint = defaultYes ? "[Y/n]" : "[y/N]";