@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.
- package/.claude-plugin/marketplace.json +3 -3
- package/.claude-plugin/plugin.json +1 -1
- package/bundle/cli.js +205 -162
- package/codex/bundle/commands/auth-login.js +89 -46
- package/codex/bundle/session-start-setup.js +57 -51
- package/codex/bundle/session-start.js +102 -96
- package/cursor/bundle/commands/auth-login.js +89 -46
- package/cursor/bundle/session-start.js +102 -96
- package/hermes/bundle/commands/auth-login.js +89 -46
- package/hermes/bundle/session-start.js +102 -96
- package/mcp/bundle/server.js +53 -47
- package/openclaw/dist/index.js +68 -27
- package/openclaw/openclaw.plugin.json +1 -1
- package/openclaw/package.json +1 -1
- package/package.json +1 -1
|
@@ -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
|
|
21
|
-
import { join as
|
|
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 ??
|
|
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
|
|
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(
|
|
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
|
-
|
|
45
|
-
|
|
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/
|
|
68
|
-
import { readFileSync, writeFileSync, mkdirSync
|
|
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
|
|
110
|
+
return join2(configDir2(), "credentials.json");
|
|
76
111
|
}
|
|
77
112
|
function loadCredentials() {
|
|
78
113
|
try {
|
|
79
|
-
return JSON.parse(
|
|
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
|
-
|
|
86
|
-
|
|
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: {
|
|
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: {
|
|
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
|
|
317
|
-
import { join as
|
|
318
|
-
import { homedir as
|
|
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 =
|
|
321
|
-
const credPath =
|
|
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(
|
|
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 ??
|
|
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
|
|
354
|
-
import { homedir as
|
|
355
|
-
var 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
|
|
499
|
-
import { join as
|
|
500
|
-
import { homedir as
|
|
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
|
|
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 =
|
|
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(
|
|
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
|
-
|
|
579
|
+
mkdirSync3(join5(home, ".deeplake"), { recursive: true, mode: 448 });
|
|
537
580
|
const tmp = `${path}.${process.pid}.tmp`;
|
|
538
|
-
|
|
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
|
-
|
|
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 =
|
|
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
|
|
1015
|
-
import { join as
|
|
1016
|
-
import { homedir as
|
|
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 =
|
|
1062
|
+
var HOME = homedir6();
|
|
1020
1063
|
var PLATFORM_MARKERS = [
|
|
1021
|
-
{ id: "claude", markerDir:
|
|
1022
|
-
{ id: "codex", markerDir:
|
|
1023
|
-
{ id: "claw", markerDir:
|
|
1024
|
-
{ id: "cursor", markerDir:
|
|
1025
|
-
{ id: "hermes", markerDir:
|
|
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:
|
|
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]";
|
|
@@ -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
|
|
21
|
-
import { join as
|
|
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 ??
|
|
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
|
|
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(
|
|
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
|
-
|
|
45
|
-
|
|
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({
|
|
@@ -53,9 +53,9 @@ var init_index_marker_store = __esm({
|
|
|
53
53
|
});
|
|
54
54
|
|
|
55
55
|
// dist/src/hooks/codex/session-start-setup.js
|
|
56
|
-
import { dirname as dirname2, join as
|
|
56
|
+
import { dirname as dirname2, join as join10 } from "node:path";
|
|
57
57
|
import { fileURLToPath } from "node:url";
|
|
58
|
-
import { homedir as
|
|
58
|
+
import { homedir as homedir6 } from "node:os";
|
|
59
59
|
|
|
60
60
|
// dist/src/commands/auth.js
|
|
61
61
|
import { execSync } from "node:child_process";
|
|
@@ -69,39 +69,45 @@ function deeplakeClientHeader() {
|
|
|
69
69
|
return { [DEEPLAKE_CLIENT_HEADER]: deeplakeClientValue() };
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
// dist/src/commands/
|
|
73
|
-
import { readFileSync, writeFileSync, mkdirSync
|
|
72
|
+
// dist/src/commands/install-id.js
|
|
73
|
+
import { readFileSync, writeFileSync, mkdirSync } from "node:fs";
|
|
74
74
|
import { join } from "node:path";
|
|
75
75
|
import { homedir } from "node:os";
|
|
76
|
+
import { randomUUID } from "node:crypto";
|
|
77
|
+
|
|
78
|
+
// dist/src/commands/auth-creds.js
|
|
79
|
+
import { readFileSync as readFileSync2, writeFileSync as writeFileSync2, mkdirSync as mkdirSync2, unlinkSync } from "node:fs";
|
|
80
|
+
import { join as join2 } from "node:path";
|
|
81
|
+
import { homedir as homedir2 } from "node:os";
|
|
76
82
|
function configDir() {
|
|
77
|
-
return
|
|
83
|
+
return join2(homedir2(), ".deeplake");
|
|
78
84
|
}
|
|
79
85
|
function credsPath() {
|
|
80
|
-
return
|
|
86
|
+
return join2(configDir(), "credentials.json");
|
|
81
87
|
}
|
|
82
88
|
function loadCredentials() {
|
|
83
89
|
try {
|
|
84
|
-
return JSON.parse(
|
|
90
|
+
return JSON.parse(readFileSync2(credsPath(), "utf-8"));
|
|
85
91
|
} catch {
|
|
86
92
|
return null;
|
|
87
93
|
}
|
|
88
94
|
}
|
|
89
95
|
function saveCredentials(creds) {
|
|
90
|
-
|
|
91
|
-
|
|
96
|
+
mkdirSync2(configDir(), { recursive: true, mode: 448 });
|
|
97
|
+
writeFileSync2(credsPath(), JSON.stringify({ ...creds, savedAt: (/* @__PURE__ */ new Date()).toISOString() }, null, 2), { mode: 384 });
|
|
92
98
|
}
|
|
93
99
|
|
|
94
100
|
// dist/src/config.js
|
|
95
|
-
import { readFileSync as
|
|
96
|
-
import { join as
|
|
97
|
-
import { homedir as
|
|
101
|
+
import { readFileSync as readFileSync3, existsSync } from "node:fs";
|
|
102
|
+
import { join as join3 } from "node:path";
|
|
103
|
+
import { homedir as homedir3, userInfo } from "node:os";
|
|
98
104
|
function loadConfig() {
|
|
99
|
-
const home =
|
|
100
|
-
const credPath =
|
|
105
|
+
const home = homedir3();
|
|
106
|
+
const credPath = join3(home, ".deeplake", "credentials.json");
|
|
101
107
|
let creds = null;
|
|
102
108
|
if (existsSync(credPath)) {
|
|
103
109
|
try {
|
|
104
|
-
creds = JSON.parse(
|
|
110
|
+
creds = JSON.parse(readFileSync3(credPath, "utf-8"));
|
|
105
111
|
} catch {
|
|
106
112
|
return null;
|
|
107
113
|
}
|
|
@@ -120,18 +126,18 @@ function loadConfig() {
|
|
|
120
126
|
tableName: process.env.HIVEMIND_TABLE ?? "memory",
|
|
121
127
|
sessionsTableName: process.env.HIVEMIND_SESSIONS_TABLE ?? "sessions",
|
|
122
128
|
skillsTableName: process.env.HIVEMIND_SKILLS_TABLE ?? "skills",
|
|
123
|
-
memoryPath: process.env.HIVEMIND_MEMORY_PATH ??
|
|
129
|
+
memoryPath: process.env.HIVEMIND_MEMORY_PATH ?? join3(home, ".deeplake", "memory")
|
|
124
130
|
};
|
|
125
131
|
}
|
|
126
132
|
|
|
127
133
|
// dist/src/deeplake-api.js
|
|
128
|
-
import { randomUUID } from "node:crypto";
|
|
134
|
+
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
129
135
|
|
|
130
136
|
// dist/src/utils/debug.js
|
|
131
137
|
import { appendFileSync } from "node:fs";
|
|
132
|
-
import { join as
|
|
133
|
-
import { homedir as
|
|
134
|
-
var LOG =
|
|
138
|
+
import { join as join4 } from "node:path";
|
|
139
|
+
import { homedir as homedir4 } from "node:os";
|
|
140
|
+
var LOG = join4(homedir4(), ".deeplake", "hook-debug.log");
|
|
135
141
|
function isDebug() {
|
|
136
142
|
return process.env.HIVEMIND_DEBUG === "1";
|
|
137
143
|
}
|
|
@@ -277,23 +283,23 @@ async function healMissingColumns(args) {
|
|
|
277
283
|
}
|
|
278
284
|
|
|
279
285
|
// dist/src/notifications/queue.js
|
|
280
|
-
import { readFileSync as
|
|
281
|
-
import { join as
|
|
282
|
-
import { homedir as
|
|
286
|
+
import { readFileSync as readFileSync4, writeFileSync as writeFileSync3, renameSync, mkdirSync as mkdirSync3, openSync, closeSync, unlinkSync as unlinkSync2, statSync } from "node:fs";
|
|
287
|
+
import { join as join5, resolve } from "node:path";
|
|
288
|
+
import { homedir as homedir5 } from "node:os";
|
|
283
289
|
import { setTimeout as sleep } from "node:timers/promises";
|
|
284
290
|
var log2 = (msg) => log("notifications-queue", msg);
|
|
285
291
|
var LOCK_RETRY_MAX = 50;
|
|
286
292
|
var LOCK_RETRY_BASE_MS = 5;
|
|
287
293
|
var LOCK_STALE_MS = 5e3;
|
|
288
294
|
function queuePath() {
|
|
289
|
-
return
|
|
295
|
+
return join5(homedir5(), ".deeplake", "notifications-queue.json");
|
|
290
296
|
}
|
|
291
297
|
function lockPath() {
|
|
292
298
|
return `${queuePath()}.lock`;
|
|
293
299
|
}
|
|
294
300
|
function readQueue() {
|
|
295
301
|
try {
|
|
296
|
-
const raw =
|
|
302
|
+
const raw = readFileSync4(queuePath(), "utf-8");
|
|
297
303
|
const parsed = JSON.parse(raw);
|
|
298
304
|
if (!parsed || !Array.isArray(parsed.queue)) {
|
|
299
305
|
log2(`queue malformed \u2192 treating as empty`);
|
|
@@ -311,18 +317,18 @@ function _isQueuePathInsideHome(path, home) {
|
|
|
311
317
|
}
|
|
312
318
|
function writeQueue(q) {
|
|
313
319
|
const path = queuePath();
|
|
314
|
-
const home = resolve(
|
|
320
|
+
const home = resolve(homedir5());
|
|
315
321
|
if (!_isQueuePathInsideHome(path, home)) {
|
|
316
322
|
throw new Error(`notifications-queue write blocked: ${path} is outside ${home}`);
|
|
317
323
|
}
|
|
318
|
-
|
|
324
|
+
mkdirSync3(join5(home, ".deeplake"), { recursive: true, mode: 448 });
|
|
319
325
|
const tmp = `${path}.${process.pid}.tmp`;
|
|
320
|
-
|
|
326
|
+
writeFileSync3(tmp, JSON.stringify(q, null, 2), { mode: 384 });
|
|
321
327
|
renameSync(tmp, path);
|
|
322
328
|
}
|
|
323
329
|
async function withQueueLock(fn) {
|
|
324
330
|
const path = lockPath();
|
|
325
|
-
|
|
331
|
+
mkdirSync3(join5(homedir5(), ".deeplake"), { recursive: true, mode: 448 });
|
|
326
332
|
let fd = null;
|
|
327
333
|
for (let attempt = 0; attempt < LOCK_RETRY_MAX; attempt++) {
|
|
328
334
|
try {
|
|
@@ -595,7 +601,7 @@ var DeeplakeApi = class {
|
|
|
595
601
|
setClauses += `, description = '${sqlStr(row.description)}'`;
|
|
596
602
|
await this.query(`UPDATE "${this.tableName}" SET ${setClauses} WHERE path = '${sqlStr(row.path)}'`);
|
|
597
603
|
} else {
|
|
598
|
-
const id =
|
|
604
|
+
const id = randomUUID2();
|
|
599
605
|
let cols = `id, path, filename, summary, ${SUMMARY_EMBEDDING_COL}, mime_type, size_bytes, creation_date, last_update_date`;
|
|
600
606
|
let vals = `'${id}', '${sqlStr(row.path)}', '${sqlStr(row.filename)}', E'${sqlStr(row.contentText)}', NULL, '${sqlStr(row.mimeType)}', ${row.sizeBytes}, '${cd}', '${lud}'`;
|
|
601
607
|
if (row.project !== void 0) {
|
|
@@ -810,15 +816,15 @@ function readStdin() {
|
|
|
810
816
|
}
|
|
811
817
|
|
|
812
818
|
// dist/src/utils/wiki-log.js
|
|
813
|
-
import { mkdirSync as
|
|
814
|
-
import { join as
|
|
819
|
+
import { mkdirSync as mkdirSync5, appendFileSync as appendFileSync2 } from "node:fs";
|
|
820
|
+
import { join as join7 } from "node:path";
|
|
815
821
|
function makeWikiLogger(hooksDir, filename = "deeplake-wiki.log") {
|
|
816
|
-
const path =
|
|
822
|
+
const path = join7(hooksDir, filename);
|
|
817
823
|
return {
|
|
818
824
|
path,
|
|
819
825
|
log(msg) {
|
|
820
826
|
try {
|
|
821
|
-
|
|
827
|
+
mkdirSync5(hooksDir, { recursive: true });
|
|
822
828
|
appendFileSync2(path, `[${utcTimestamp()}] ${msg}
|
|
823
829
|
`);
|
|
824
830
|
} catch {
|
|
@@ -830,7 +836,7 @@ function makeWikiLogger(hooksDir, filename = "deeplake-wiki.log") {
|
|
|
830
836
|
// dist/src/hooks/shared/autoupdate.js
|
|
831
837
|
import { spawn } from "node:child_process";
|
|
832
838
|
import { existsSync as existsSync3 } from "node:fs";
|
|
833
|
-
import { join as
|
|
839
|
+
import { join as join8 } from "node:path";
|
|
834
840
|
var log4 = (msg) => log("autoupdate", msg);
|
|
835
841
|
var defaultSpawn = (cmd, args) => {
|
|
836
842
|
const child = spawn(cmd, args, {
|
|
@@ -846,7 +852,7 @@ function findHivemindOnPath() {
|
|
|
846
852
|
const PATH = process.env.PATH ?? "";
|
|
847
853
|
const dirs = PATH.split(":").filter(Boolean);
|
|
848
854
|
for (const dir of dirs) {
|
|
849
|
-
const candidate =
|
|
855
|
+
const candidate = join8(dir, "hivemind");
|
|
850
856
|
if (existsSync3(candidate))
|
|
851
857
|
return candidate;
|
|
852
858
|
}
|
|
@@ -881,18 +887,18 @@ async function autoUpdate(creds, opts) {
|
|
|
881
887
|
}
|
|
882
888
|
|
|
883
889
|
// dist/src/utils/version-check.js
|
|
884
|
-
import { readFileSync as
|
|
885
|
-
import { dirname, join as
|
|
890
|
+
import { readFileSync as readFileSync6 } from "node:fs";
|
|
891
|
+
import { dirname, join as join9 } from "node:path";
|
|
886
892
|
function getInstalledVersion(bundleDir, pluginManifestDir) {
|
|
887
893
|
try {
|
|
888
|
-
const pluginJson =
|
|
889
|
-
const plugin = JSON.parse(
|
|
894
|
+
const pluginJson = join9(bundleDir, "..", pluginManifestDir, "plugin.json");
|
|
895
|
+
const plugin = JSON.parse(readFileSync6(pluginJson, "utf-8"));
|
|
890
896
|
if (plugin.version)
|
|
891
897
|
return plugin.version;
|
|
892
898
|
} catch {
|
|
893
899
|
}
|
|
894
900
|
try {
|
|
895
|
-
const stamp =
|
|
901
|
+
const stamp = readFileSync6(join9(bundleDir, "..", ".hivemind_version"), "utf-8").trim();
|
|
896
902
|
if (stamp)
|
|
897
903
|
return stamp;
|
|
898
904
|
} catch {
|
|
@@ -907,9 +913,9 @@ function getInstalledVersion(bundleDir, pluginManifestDir) {
|
|
|
907
913
|
]);
|
|
908
914
|
let dir = bundleDir;
|
|
909
915
|
for (let i = 0; i < 5; i++) {
|
|
910
|
-
const candidate =
|
|
916
|
+
const candidate = join9(dir, "package.json");
|
|
911
917
|
try {
|
|
912
|
-
const pkg = JSON.parse(
|
|
918
|
+
const pkg = JSON.parse(readFileSync6(candidate, "utf-8"));
|
|
913
919
|
if (HIVEMIND_PKG_NAMES.has(pkg.name) && pkg.version)
|
|
914
920
|
return pkg.version;
|
|
915
921
|
} catch {
|
|
@@ -924,7 +930,7 @@ function getInstalledVersion(bundleDir, pluginManifestDir) {
|
|
|
924
930
|
|
|
925
931
|
// dist/src/hooks/codex/session-start-setup.js
|
|
926
932
|
var log5 = (msg) => log("codex-session-setup", msg);
|
|
927
|
-
var { log: wikiLog } = makeWikiLogger(
|
|
933
|
+
var { log: wikiLog } = makeWikiLogger(join10(homedir6(), ".codex", "hooks"));
|
|
928
934
|
var __bundleDir = dirname2(fileURLToPath(import.meta.url));
|
|
929
935
|
var PLUGIN_VERSION = getInstalledVersion(__bundleDir, ".codex-plugin") ?? "";
|
|
930
936
|
async function createPlaceholder(api, table, sessionId, cwd, userName, orgName, workspaceId) {
|