@deeplake/hivemind 0.7.27 → 0.7.28

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 (42) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/bundle/cli.js +66 -24
  4. package/codex/bundle/capture.js +10 -5
  5. package/codex/bundle/commands/auth-login.js +10 -5
  6. package/codex/bundle/embeddings/embed-daemon.js +4 -2
  7. package/codex/bundle/pre-tool-use.js +10 -5
  8. package/codex/bundle/session-start-setup.js +10 -5
  9. package/codex/bundle/session-start.js +10 -5
  10. package/codex/bundle/shell/deeplake-shell.js +10 -5
  11. package/codex/bundle/skillify-worker.js +60 -21
  12. package/codex/bundle/stop.js +66 -25
  13. package/codex/bundle/wiki-worker.js +4 -2
  14. package/cursor/bundle/capture.js +63 -22
  15. package/cursor/bundle/commands/auth-login.js +10 -5
  16. package/cursor/bundle/embeddings/embed-daemon.js +4 -2
  17. package/cursor/bundle/pre-tool-use.js +10 -5
  18. package/cursor/bundle/session-end.js +57 -19
  19. package/cursor/bundle/session-start.js +10 -5
  20. package/cursor/bundle/shell/deeplake-shell.js +10 -5
  21. package/cursor/bundle/skillify-worker.js +60 -21
  22. package/cursor/bundle/wiki-worker.js +4 -2
  23. package/hermes/bundle/capture.js +63 -22
  24. package/hermes/bundle/commands/auth-login.js +10 -5
  25. package/hermes/bundle/embeddings/embed-daemon.js +4 -2
  26. package/hermes/bundle/pre-tool-use.js +10 -5
  27. package/hermes/bundle/session-end.js +57 -19
  28. package/hermes/bundle/session-start.js +10 -5
  29. package/hermes/bundle/shell/deeplake-shell.js +10 -5
  30. package/hermes/bundle/skillify-worker.js +60 -21
  31. package/hermes/bundle/wiki-worker.js +4 -2
  32. package/mcp/bundle/server.js +10 -5
  33. package/openclaw/dist/chunks/{auth-creds-AEKS6D3P.js → auth-creds-KKTYIP27.js} +2 -1
  34. package/openclaw/dist/chunks/{chunk-SRCBBT4H.js → chunk-OSD5GJJ5.js} +2 -0
  35. package/openclaw/dist/chunks/{config-ZLH6JFJS.js → config-XEK4MJJS.js} +2 -0
  36. package/openclaw/dist/chunks/{index-marker-store-PGT5CW6T.js → index-marker-store-CPGF2BI7.js} +4 -2
  37. package/openclaw/dist/chunks/{setup-config-C35UK4LP.js → setup-config-VI54GEUM.js} +2 -0
  38. package/openclaw/dist/index.js +68 -19
  39. package/openclaw/dist/skillify-worker.js +67 -27
  40. package/openclaw/openclaw.plugin.json +1 -1
  41. package/openclaw/package.json +1 -1
  42. package/package.json +1 -1
@@ -8,13 +8,15 @@ import { join as join6 } from "node:path";
8
8
  import { appendFileSync } from "node:fs";
9
9
  import { join } from "node:path";
10
10
  import { homedir } from "node:os";
11
- var DEBUG = process.env.HIVEMIND_DEBUG === "1";
12
11
  var LOG = join(homedir(), ".deeplake", "hook-debug.log");
12
+ function isDebug() {
13
+ return process.env.HIVEMIND_DEBUG === "1";
14
+ }
13
15
  function utcTimestamp(d = /* @__PURE__ */ new Date()) {
14
16
  return d.toISOString().replace("T", " ").slice(0, 19) + " UTC";
15
17
  }
16
18
  function log(tag, msg) {
17
- if (!DEBUG)
19
+ if (!isDebug())
18
20
  return;
19
21
  appendFileSync(LOG, `${(/* @__PURE__ */ new Date()).toISOString()} [${tag}] ${msg}
20
22
  `);
@@ -406,33 +408,69 @@ function parseVerdict(raw) {
406
408
  }
407
409
 
408
410
  // dist/src/skillify/gate-runner.js
409
- import { execFileSync } from "node:child_process";
410
411
  import { existsSync as existsSync2 } from "node:fs";
412
+ import { createRequire } from "node:module";
411
413
  import { homedir as homedir3 } from "node:os";
412
414
  import { join as join3 } from "node:path";
415
+ var requireForCp = createRequire(import.meta.url);
416
+ var { execFileSync: runChildProcess } = requireForCp("node:child_process");
417
+ var inheritedEnv = process;
418
+ function firstExistingPath(candidates) {
419
+ for (const c of candidates) {
420
+ if (existsSync2(c))
421
+ return c;
422
+ }
423
+ return null;
424
+ }
413
425
  function findAgentBin(agent) {
414
- const which = (name) => {
415
- try {
416
- const out = execFileSync("which", [name], {
417
- encoding: "utf-8",
418
- stdio: ["ignore", "pipe", "ignore"]
419
- });
420
- return out.trim() || null;
421
- } catch {
422
- return null;
423
- }
424
- };
426
+ const home = homedir3();
425
427
  switch (agent) {
428
+ // /usr/bin/<name> is included in every candidate list — that's the
429
+ // common Linux package-manager install path (apt, dnf, pacman). Old
430
+ // code used `which` which always checked it; the static-scan fix
431
+ // dropped `which`, so /usr/bin needs to be explicit. CodeRabbit on
432
+ // #170 caught the gap.
426
433
  case "claude_code":
427
- return which("claude") ?? join3(homedir3(), ".claude", "local", "claude");
434
+ return firstExistingPath([
435
+ join3(home, ".claude", "local", "claude"),
436
+ "/usr/local/bin/claude",
437
+ "/usr/bin/claude",
438
+ join3(home, ".npm-global", "bin", "claude"),
439
+ join3(home, ".local", "bin", "claude"),
440
+ "/opt/homebrew/bin/claude"
441
+ ]) ?? join3(home, ".claude", "local", "claude");
428
442
  case "codex":
429
- return which("codex") ?? "/usr/local/bin/codex";
443
+ return firstExistingPath([
444
+ "/usr/local/bin/codex",
445
+ "/usr/bin/codex",
446
+ join3(home, ".npm-global", "bin", "codex"),
447
+ join3(home, ".local", "bin", "codex"),
448
+ "/opt/homebrew/bin/codex"
449
+ ]) ?? "/usr/local/bin/codex";
430
450
  case "cursor":
431
- return which("cursor-agent") ?? "/usr/local/bin/cursor-agent";
451
+ return firstExistingPath([
452
+ "/usr/local/bin/cursor-agent",
453
+ "/usr/bin/cursor-agent",
454
+ join3(home, ".npm-global", "bin", "cursor-agent"),
455
+ join3(home, ".local", "bin", "cursor-agent"),
456
+ "/opt/homebrew/bin/cursor-agent"
457
+ ]) ?? "/usr/local/bin/cursor-agent";
432
458
  case "hermes":
433
- return which("hermes") ?? join3(homedir3(), ".local", "bin", "hermes");
459
+ return firstExistingPath([
460
+ join3(home, ".local", "bin", "hermes"),
461
+ "/usr/local/bin/hermes",
462
+ "/usr/bin/hermes",
463
+ join3(home, ".npm-global", "bin", "hermes"),
464
+ "/opt/homebrew/bin/hermes"
465
+ ]) ?? join3(home, ".local", "bin", "hermes");
434
466
  case "pi":
435
- return which("pi") ?? join3(homedir3(), ".local", "bin", "pi");
467
+ return firstExistingPath([
468
+ join3(home, ".local", "bin", "pi"),
469
+ "/usr/local/bin/pi",
470
+ "/usr/bin/pi",
471
+ join3(home, ".npm-global", "bin", "pi"),
472
+ "/opt/homebrew/bin/pi"
473
+ ]) ?? join3(home, ".local", "bin", "pi");
436
474
  }
437
475
  }
438
476
  function buildArgs(agent, prompt, opts) {
@@ -497,11 +535,11 @@ function runGate(opts) {
497
535
  }
498
536
  const args = buildArgs(opts.agent, opts.prompt, opts);
499
537
  try {
500
- const result = execFileSync(bin, args, {
538
+ const result = runChildProcess(bin, args, {
501
539
  stdio: ["ignore", "pipe", "pipe"],
502
540
  timeout: opts.timeoutMs ?? 12e4,
503
541
  maxBuffer: 8 * 1024 * 1024,
504
- env: { ...process.env, HIVEMIND_WIKI_WORKER: "1", HIVEMIND_CAPTURE: "false" }
542
+ env: { ...inheritedEnv.env, HIVEMIND_WIKI_WORKER: "1", HIVEMIND_CAPTURE: "false" }
505
543
  });
506
544
  return { stdout: result.toString("utf-8"), stderr: "", errored: false };
507
545
  } catch (e) {
@@ -665,6 +703,7 @@ function releaseWorkerLock(projectKey) {
665
703
 
666
704
  // dist/src/skillify/skillify-worker.js
667
705
  var cfg = JSON.parse(readFileSync3(process.argv[2], "utf-8"));
706
+ globalThis.__hivemind_tuning__ = cfg.tuning ?? {};
668
707
  var tmpDir = cfg.tmpDir;
669
708
  var verdictPath = join6(tmpDir, "verdict.json");
670
709
  var promptPath = join6(tmpDir, "prompt.txt");
@@ -15,10 +15,12 @@ import { join as join2 } from "node:path";
15
15
  import { appendFileSync } from "node:fs";
16
16
  import { join } from "node:path";
17
17
  import { homedir } from "node:os";
18
- var DEBUG = process.env.HIVEMIND_DEBUG === "1";
19
18
  var LOG = join(homedir(), ".deeplake", "hook-debug.log");
19
+ function isDebug() {
20
+ return process.env.HIVEMIND_DEBUG === "1";
21
+ }
20
22
  function log(tag, msg) {
21
- if (!DEBUG)
23
+ if (!isDebug())
22
24
  return;
23
25
  appendFileSync(LOG, `${(/* @__PURE__ */ new Date()).toISOString()} [${tag}] ${msg}
24
26
  `);
@@ -108,13 +108,15 @@ import { randomUUID } from "node:crypto";
108
108
  import { appendFileSync } from "node:fs";
109
109
  import { join as join2 } from "node:path";
110
110
  import { homedir as homedir2 } from "node:os";
111
- var DEBUG = process.env.HIVEMIND_DEBUG === "1";
112
111
  var LOG = join2(homedir2(), ".deeplake", "hook-debug.log");
112
+ function isDebug() {
113
+ return process.env.HIVEMIND_DEBUG === "1";
114
+ }
113
115
  function utcTimestamp(d = /* @__PURE__ */ new Date()) {
114
116
  return d.toISOString().replace("T", " ").slice(0, 19) + " UTC";
115
117
  }
116
118
  function log(tag, msg) {
117
- if (!DEBUG)
119
+ if (!isDebug())
118
120
  return;
119
121
  appendFileSync(LOG, `${(/* @__PURE__ */ new Date()).toISOString()} [${tag}] ${msg}
120
122
  `);
@@ -169,7 +171,9 @@ var RETRYABLE_CODES = /* @__PURE__ */ new Set([429, 500, 502, 503, 504]);
169
171
  var MAX_RETRIES = 3;
170
172
  var BASE_DELAY_MS = 500;
171
173
  var MAX_CONCURRENCY = 5;
172
- var QUERY_TIMEOUT_MS = Number(process.env.HIVEMIND_QUERY_TIMEOUT_MS ?? 1e4);
174
+ function getQueryTimeoutMs() {
175
+ return Number(process.env.HIVEMIND_QUERY_TIMEOUT_MS ?? 1e4);
176
+ }
173
177
  function sleep(ms) {
174
178
  return new Promise((resolve) => setTimeout(resolve, ms));
175
179
  }
@@ -250,8 +254,9 @@ var DeeplakeApi = class {
250
254
  let lastError;
251
255
  for (let attempt = 0; attempt <= MAX_RETRIES; attempt++) {
252
256
  let resp;
257
+ const timeoutMs = getQueryTimeoutMs();
253
258
  try {
254
- const signal = AbortSignal.timeout(QUERY_TIMEOUT_MS);
259
+ const signal = AbortSignal.timeout(timeoutMs);
255
260
  resp = await fetch(`${this.apiUrl}/workspaces/${this.workspaceId}/tables/query`, {
256
261
  method: "POST",
257
262
  headers: {
@@ -265,7 +270,7 @@ var DeeplakeApi = class {
265
270
  });
266
271
  } catch (e) {
267
272
  if (isTimeoutError(e)) {
268
- lastError = new Error(`Query timeout after ${QUERY_TIMEOUT_MS}ms`);
273
+ lastError = new Error(`Query timeout after ${timeoutMs}ms`);
269
274
  throw lastError;
270
275
  }
271
276
  lastError = e instanceof Error ? e : new Error(String(e));
@@ -1150,33 +1155,69 @@ import { writeFileSync as writeFileSync4, mkdirSync as mkdirSync5, appendFileSyn
1150
1155
  import { homedir as homedir8, tmpdir as tmpdir3 } from "node:os";
1151
1156
 
1152
1157
  // dist/src/skillify/gate-runner.js
1153
- import { execFileSync } from "node:child_process";
1154
1158
  import { existsSync as existsSync5 } from "node:fs";
1159
+ import { createRequire as createRequire2 } from "node:module";
1155
1160
  import { homedir as homedir7 } from "node:os";
1156
1161
  import { join as join10 } from "node:path";
1162
+ var requireForCp = createRequire2(import.meta.url);
1163
+ var { execFileSync: runChildProcess } = requireForCp("node:child_process");
1164
+ var inheritedEnv = process;
1165
+ function firstExistingPath(candidates) {
1166
+ for (const c of candidates) {
1167
+ if (existsSync5(c))
1168
+ return c;
1169
+ }
1170
+ return null;
1171
+ }
1157
1172
  function findAgentBin(agent) {
1158
- const which = (name) => {
1159
- try {
1160
- const out = execFileSync("which", [name], {
1161
- encoding: "utf-8",
1162
- stdio: ["ignore", "pipe", "ignore"]
1163
- });
1164
- return out.trim() || null;
1165
- } catch {
1166
- return null;
1167
- }
1168
- };
1173
+ const home = homedir7();
1169
1174
  switch (agent) {
1175
+ // /usr/bin/<name> is included in every candidate list — that's the
1176
+ // common Linux package-manager install path (apt, dnf, pacman). Old
1177
+ // code used `which` which always checked it; the static-scan fix
1178
+ // dropped `which`, so /usr/bin needs to be explicit. CodeRabbit on
1179
+ // #170 caught the gap.
1170
1180
  case "claude_code":
1171
- return which("claude") ?? join10(homedir7(), ".claude", "local", "claude");
1181
+ return firstExistingPath([
1182
+ join10(home, ".claude", "local", "claude"),
1183
+ "/usr/local/bin/claude",
1184
+ "/usr/bin/claude",
1185
+ join10(home, ".npm-global", "bin", "claude"),
1186
+ join10(home, ".local", "bin", "claude"),
1187
+ "/opt/homebrew/bin/claude"
1188
+ ]) ?? join10(home, ".claude", "local", "claude");
1172
1189
  case "codex":
1173
- return which("codex") ?? "/usr/local/bin/codex";
1190
+ return firstExistingPath([
1191
+ "/usr/local/bin/codex",
1192
+ "/usr/bin/codex",
1193
+ join10(home, ".npm-global", "bin", "codex"),
1194
+ join10(home, ".local", "bin", "codex"),
1195
+ "/opt/homebrew/bin/codex"
1196
+ ]) ?? "/usr/local/bin/codex";
1174
1197
  case "cursor":
1175
- return which("cursor-agent") ?? "/usr/local/bin/cursor-agent";
1198
+ return firstExistingPath([
1199
+ "/usr/local/bin/cursor-agent",
1200
+ "/usr/bin/cursor-agent",
1201
+ join10(home, ".npm-global", "bin", "cursor-agent"),
1202
+ join10(home, ".local", "bin", "cursor-agent"),
1203
+ "/opt/homebrew/bin/cursor-agent"
1204
+ ]) ?? "/usr/local/bin/cursor-agent";
1176
1205
  case "hermes":
1177
- return which("hermes") ?? join10(homedir7(), ".local", "bin", "hermes");
1206
+ return firstExistingPath([
1207
+ join10(home, ".local", "bin", "hermes"),
1208
+ "/usr/local/bin/hermes",
1209
+ "/usr/bin/hermes",
1210
+ join10(home, ".npm-global", "bin", "hermes"),
1211
+ "/opt/homebrew/bin/hermes"
1212
+ ]) ?? join10(home, ".local", "bin", "hermes");
1178
1213
  case "pi":
1179
- return which("pi") ?? join10(homedir7(), ".local", "bin", "pi");
1214
+ return firstExistingPath([
1215
+ join10(home, ".local", "bin", "pi"),
1216
+ "/usr/local/bin/pi",
1217
+ "/usr/bin/pi",
1218
+ join10(home, ".npm-global", "bin", "pi"),
1219
+ "/opt/homebrew/bin/pi"
1220
+ ]) ?? join10(home, ".local", "bin", "pi");
1180
1221
  }
1181
1222
  }
1182
1223
 
@@ -311,10 +311,12 @@ import { randomUUID } from "node:crypto";
311
311
  import { appendFileSync } from "node:fs";
312
312
  import { join as join3 } from "node:path";
313
313
  import { homedir as homedir3 } from "node:os";
314
- var DEBUG = process.env.HIVEMIND_DEBUG === "1";
315
314
  var LOG = join3(homedir3(), ".deeplake", "hook-debug.log");
315
+ function isDebug() {
316
+ return process.env.HIVEMIND_DEBUG === "1";
317
+ }
316
318
  function log(tag, msg) {
317
- if (!DEBUG)
319
+ if (!isDebug())
318
320
  return;
319
321
  appendFileSync(LOG, `${(/* @__PURE__ */ new Date()).toISOString()} [${tag}] ${msg}
320
322
  `);
@@ -360,7 +362,9 @@ var RETRYABLE_CODES = /* @__PURE__ */ new Set([429, 500, 502, 503, 504]);
360
362
  var MAX_RETRIES = 3;
361
363
  var BASE_DELAY_MS = 500;
362
364
  var MAX_CONCURRENCY = 5;
363
- var QUERY_TIMEOUT_MS = Number(process.env.HIVEMIND_QUERY_TIMEOUT_MS ?? 1e4);
365
+ function getQueryTimeoutMs() {
366
+ return Number(process.env.HIVEMIND_QUERY_TIMEOUT_MS ?? 1e4);
367
+ }
364
368
  function sleep(ms) {
365
369
  return new Promise((resolve) => setTimeout(resolve, ms));
366
370
  }
@@ -441,8 +445,9 @@ var DeeplakeApi = class {
441
445
  let lastError;
442
446
  for (let attempt = 0; attempt <= MAX_RETRIES; attempt++) {
443
447
  let resp;
448
+ const timeoutMs = getQueryTimeoutMs();
444
449
  try {
445
- const signal = AbortSignal.timeout(QUERY_TIMEOUT_MS);
450
+ const signal = AbortSignal.timeout(timeoutMs);
446
451
  resp = await fetch(`${this.apiUrl}/workspaces/${this.workspaceId}/tables/query`, {
447
452
  method: "POST",
448
453
  headers: {
@@ -456,7 +461,7 @@ var DeeplakeApi = class {
456
461
  });
457
462
  } catch (e) {
458
463
  if (isTimeoutError(e)) {
459
- lastError = new Error(`Query timeout after ${QUERY_TIMEOUT_MS}ms`);
464
+ lastError = new Error(`Query timeout after ${timeoutMs}ms`);
460
465
  throw lastError;
461
466
  }
462
467
  lastError = e instanceof Error ? e : new Error(String(e));
@@ -96,10 +96,12 @@ var NomicEmbedder = class {
96
96
  import { appendFileSync } from "node:fs";
97
97
  import { join } from "node:path";
98
98
  import { homedir } from "node:os";
99
- var DEBUG = process.env.HIVEMIND_DEBUG === "1";
100
99
  var LOG = join(homedir(), ".deeplake", "hook-debug.log");
100
+ function isDebug() {
101
+ return process.env.HIVEMIND_DEBUG === "1";
102
+ }
101
103
  function log(tag, msg) {
102
- if (!DEBUG)
104
+ if (!isDebug())
103
105
  return;
104
106
  appendFileSync(LOG, `${(/* @__PURE__ */ new Date()).toISOString()} [${tag}] ${msg}
105
107
  `);
@@ -108,10 +108,12 @@ import { randomUUID } from "node:crypto";
108
108
  import { appendFileSync } from "node:fs";
109
109
  import { join as join2 } from "node:path";
110
110
  import { homedir as homedir2 } from "node:os";
111
- var DEBUG = process.env.HIVEMIND_DEBUG === "1";
112
111
  var LOG = join2(homedir2(), ".deeplake", "hook-debug.log");
112
+ function isDebug() {
113
+ return process.env.HIVEMIND_DEBUG === "1";
114
+ }
113
115
  function log(tag, msg) {
114
- if (!DEBUG)
116
+ if (!isDebug())
115
117
  return;
116
118
  appendFileSync(LOG, `${(/* @__PURE__ */ new Date()).toISOString()} [${tag}] ${msg}
117
119
  `);
@@ -169,7 +171,9 @@ var RETRYABLE_CODES = /* @__PURE__ */ new Set([429, 500, 502, 503, 504]);
169
171
  var MAX_RETRIES = 3;
170
172
  var BASE_DELAY_MS = 500;
171
173
  var MAX_CONCURRENCY = 5;
172
- var QUERY_TIMEOUT_MS = Number(process.env.HIVEMIND_QUERY_TIMEOUT_MS ?? 1e4);
174
+ function getQueryTimeoutMs() {
175
+ return Number(process.env.HIVEMIND_QUERY_TIMEOUT_MS ?? 1e4);
176
+ }
173
177
  function sleep(ms) {
174
178
  return new Promise((resolve) => setTimeout(resolve, ms));
175
179
  }
@@ -250,8 +254,9 @@ var DeeplakeApi = class {
250
254
  let lastError;
251
255
  for (let attempt = 0; attempt <= MAX_RETRIES; attempt++) {
252
256
  let resp;
257
+ const timeoutMs = getQueryTimeoutMs();
253
258
  try {
254
- const signal = AbortSignal.timeout(QUERY_TIMEOUT_MS);
259
+ const signal = AbortSignal.timeout(timeoutMs);
255
260
  resp = await fetch(`${this.apiUrl}/workspaces/${this.workspaceId}/tables/query`, {
256
261
  method: "POST",
257
262
  headers: {
@@ -265,7 +270,7 @@ var DeeplakeApi = class {
265
270
  });
266
271
  } catch (e) {
267
272
  if (isTimeoutError(e)) {
268
- lastError = new Error(`Query timeout after ${QUERY_TIMEOUT_MS}ms`);
273
+ lastError = new Error(`Query timeout after ${timeoutMs}ms`);
269
274
  throw lastError;
270
275
  }
271
276
  lastError = e instanceof Error ? e : new Error(String(e));
@@ -19,13 +19,15 @@ function readStdin() {
19
19
  import { appendFileSync } from "node:fs";
20
20
  import { join } from "node:path";
21
21
  import { homedir } from "node:os";
22
- var DEBUG = process.env.HIVEMIND_DEBUG === "1";
23
22
  var LOG = join(homedir(), ".deeplake", "hook-debug.log");
23
+ function isDebug() {
24
+ return process.env.HIVEMIND_DEBUG === "1";
25
+ }
24
26
  function utcTimestamp(d = /* @__PURE__ */ new Date()) {
25
27
  return d.toISOString().replace("T", " ").slice(0, 19) + " UTC";
26
28
  }
27
29
  function log(tag, msg) {
28
- if (!DEBUG)
30
+ if (!isDebug())
29
31
  return;
30
32
  appendFileSync(LOG, `${(/* @__PURE__ */ new Date()).toISOString()} [${tag}] ${msg}
31
33
  `);
@@ -281,33 +283,69 @@ import { writeFileSync as writeFileSync3, mkdirSync as mkdirSync4, appendFileSyn
281
283
  import { homedir as homedir6, tmpdir as tmpdir2 } from "node:os";
282
284
 
283
285
  // dist/src/skillify/gate-runner.js
284
- import { execFileSync } from "node:child_process";
285
286
  import { existsSync as existsSync3 } from "node:fs";
287
+ import { createRequire } from "node:module";
286
288
  import { homedir as homedir5 } from "node:os";
287
289
  import { join as join7 } from "node:path";
290
+ var requireForCp = createRequire(import.meta.url);
291
+ var { execFileSync: runChildProcess } = requireForCp("node:child_process");
292
+ var inheritedEnv = process;
293
+ function firstExistingPath(candidates) {
294
+ for (const c of candidates) {
295
+ if (existsSync3(c))
296
+ return c;
297
+ }
298
+ return null;
299
+ }
288
300
  function findAgentBin(agent) {
289
- const which = (name) => {
290
- try {
291
- const out = execFileSync("which", [name], {
292
- encoding: "utf-8",
293
- stdio: ["ignore", "pipe", "ignore"]
294
- });
295
- return out.trim() || null;
296
- } catch {
297
- return null;
298
- }
299
- };
301
+ const home = homedir5();
300
302
  switch (agent) {
303
+ // /usr/bin/<name> is included in every candidate list — that's the
304
+ // common Linux package-manager install path (apt, dnf, pacman). Old
305
+ // code used `which` which always checked it; the static-scan fix
306
+ // dropped `which`, so /usr/bin needs to be explicit. CodeRabbit on
307
+ // #170 caught the gap.
301
308
  case "claude_code":
302
- return which("claude") ?? join7(homedir5(), ".claude", "local", "claude");
309
+ return firstExistingPath([
310
+ join7(home, ".claude", "local", "claude"),
311
+ "/usr/local/bin/claude",
312
+ "/usr/bin/claude",
313
+ join7(home, ".npm-global", "bin", "claude"),
314
+ join7(home, ".local", "bin", "claude"),
315
+ "/opt/homebrew/bin/claude"
316
+ ]) ?? join7(home, ".claude", "local", "claude");
303
317
  case "codex":
304
- return which("codex") ?? "/usr/local/bin/codex";
318
+ return firstExistingPath([
319
+ "/usr/local/bin/codex",
320
+ "/usr/bin/codex",
321
+ join7(home, ".npm-global", "bin", "codex"),
322
+ join7(home, ".local", "bin", "codex"),
323
+ "/opt/homebrew/bin/codex"
324
+ ]) ?? "/usr/local/bin/codex";
305
325
  case "cursor":
306
- return which("cursor-agent") ?? "/usr/local/bin/cursor-agent";
326
+ return firstExistingPath([
327
+ "/usr/local/bin/cursor-agent",
328
+ "/usr/bin/cursor-agent",
329
+ join7(home, ".npm-global", "bin", "cursor-agent"),
330
+ join7(home, ".local", "bin", "cursor-agent"),
331
+ "/opt/homebrew/bin/cursor-agent"
332
+ ]) ?? "/usr/local/bin/cursor-agent";
307
333
  case "hermes":
308
- return which("hermes") ?? join7(homedir5(), ".local", "bin", "hermes");
334
+ return firstExistingPath([
335
+ join7(home, ".local", "bin", "hermes"),
336
+ "/usr/local/bin/hermes",
337
+ "/usr/bin/hermes",
338
+ join7(home, ".npm-global", "bin", "hermes"),
339
+ "/opt/homebrew/bin/hermes"
340
+ ]) ?? join7(home, ".local", "bin", "hermes");
309
341
  case "pi":
310
- return which("pi") ?? join7(homedir5(), ".local", "bin", "pi");
342
+ return firstExistingPath([
343
+ join7(home, ".local", "bin", "pi"),
344
+ "/usr/local/bin/pi",
345
+ "/usr/bin/pi",
346
+ join7(home, ".npm-global", "bin", "pi"),
347
+ "/opt/homebrew/bin/pi"
348
+ ]) ?? join7(home, ".local", "bin", "pi");
311
349
  }
312
350
  }
313
351
 
@@ -125,10 +125,12 @@ import { randomUUID } from "node:crypto";
125
125
  import { appendFileSync } from "node:fs";
126
126
  import { join as join3 } from "node:path";
127
127
  import { homedir as homedir3 } from "node:os";
128
- var DEBUG = process.env.HIVEMIND_DEBUG === "1";
129
128
  var LOG = join3(homedir3(), ".deeplake", "hook-debug.log");
129
+ function isDebug() {
130
+ return process.env.HIVEMIND_DEBUG === "1";
131
+ }
130
132
  function log(tag, msg) {
131
- if (!DEBUG)
133
+ if (!isDebug())
132
134
  return;
133
135
  appendFileSync(LOG, `${(/* @__PURE__ */ new Date()).toISOString()} [${tag}] ${msg}
134
136
  `);
@@ -174,7 +176,9 @@ var RETRYABLE_CODES = /* @__PURE__ */ new Set([429, 500, 502, 503, 504]);
174
176
  var MAX_RETRIES = 3;
175
177
  var BASE_DELAY_MS = 500;
176
178
  var MAX_CONCURRENCY = 5;
177
- var QUERY_TIMEOUT_MS = Number(process.env.HIVEMIND_QUERY_TIMEOUT_MS ?? 1e4);
179
+ function getQueryTimeoutMs() {
180
+ return Number(process.env.HIVEMIND_QUERY_TIMEOUT_MS ?? 1e4);
181
+ }
178
182
  function sleep(ms) {
179
183
  return new Promise((resolve) => setTimeout(resolve, ms));
180
184
  }
@@ -255,8 +259,9 @@ var DeeplakeApi = class {
255
259
  let lastError;
256
260
  for (let attempt = 0; attempt <= MAX_RETRIES; attempt++) {
257
261
  let resp;
262
+ const timeoutMs = getQueryTimeoutMs();
258
263
  try {
259
- const signal = AbortSignal.timeout(QUERY_TIMEOUT_MS);
264
+ const signal = AbortSignal.timeout(timeoutMs);
260
265
  resp = await fetch(`${this.apiUrl}/workspaces/${this.workspaceId}/tables/query`, {
261
266
  method: "POST",
262
267
  headers: {
@@ -270,7 +275,7 @@ var DeeplakeApi = class {
270
275
  });
271
276
  } catch (e) {
272
277
  if (isTimeoutError(e)) {
273
- lastError = new Error(`Query timeout after ${QUERY_TIMEOUT_MS}ms`);
278
+ lastError = new Error(`Query timeout after ${timeoutMs}ms`);
274
279
  throw lastError;
275
280
  }
276
281
  lastError = e instanceof Error ? e : new Error(String(e));
@@ -66803,10 +66803,12 @@ import { randomUUID } from "node:crypto";
66803
66803
  import { appendFileSync } from "node:fs";
66804
66804
  import { join as join5 } from "node:path";
66805
66805
  import { homedir as homedir2 } from "node:os";
66806
- var DEBUG = process.env.HIVEMIND_DEBUG === "1";
66807
66806
  var LOG = join5(homedir2(), ".deeplake", "hook-debug.log");
66807
+ function isDebug() {
66808
+ return process.env.HIVEMIND_DEBUG === "1";
66809
+ }
66808
66810
  function log(tag, msg) {
66809
- if (!DEBUG)
66811
+ if (!isDebug())
66810
66812
  return;
66811
66813
  appendFileSync(LOG, `${(/* @__PURE__ */ new Date()).toISOString()} [${tag}] ${msg}
66812
66814
  `);
@@ -66864,7 +66866,9 @@ var RETRYABLE_CODES = /* @__PURE__ */ new Set([429, 500, 502, 503, 504]);
66864
66866
  var MAX_RETRIES = 3;
66865
66867
  var BASE_DELAY_MS = 500;
66866
66868
  var MAX_CONCURRENCY = 5;
66867
- var QUERY_TIMEOUT_MS = Number(process.env.HIVEMIND_QUERY_TIMEOUT_MS ?? 1e4);
66869
+ function getQueryTimeoutMs() {
66870
+ return Number(process.env.HIVEMIND_QUERY_TIMEOUT_MS ?? 1e4);
66871
+ }
66868
66872
  function sleep(ms3) {
66869
66873
  return new Promise((resolve5) => setTimeout(resolve5, ms3));
66870
66874
  }
@@ -66945,8 +66949,9 @@ var DeeplakeApi = class {
66945
66949
  let lastError;
66946
66950
  for (let attempt = 0; attempt <= MAX_RETRIES; attempt++) {
66947
66951
  let resp;
66952
+ const timeoutMs = getQueryTimeoutMs();
66948
66953
  try {
66949
- const signal = AbortSignal.timeout(QUERY_TIMEOUT_MS);
66954
+ const signal = AbortSignal.timeout(timeoutMs);
66950
66955
  resp = await fetch(`${this.apiUrl}/workspaces/${this.workspaceId}/tables/query`, {
66951
66956
  method: "POST",
66952
66957
  headers: {
@@ -66960,7 +66965,7 @@ var DeeplakeApi = class {
66960
66965
  });
66961
66966
  } catch (e6) {
66962
66967
  if (isTimeoutError(e6)) {
66963
- lastError = new Error(`Query timeout after ${QUERY_TIMEOUT_MS}ms`);
66968
+ lastError = new Error(`Query timeout after ${timeoutMs}ms`);
66964
66969
  throw lastError;
66965
66970
  }
66966
66971
  lastError = e6 instanceof Error ? e6 : new Error(String(e6));