@deeplake/hivemind 0.7.32 → 0.7.34

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 (34) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/bundle/cli.js +332 -189
  4. package/codex/bundle/capture.js +365 -332
  5. package/codex/bundle/commands/auth-login.js +163 -30
  6. package/codex/bundle/pre-tool-use.js +334 -301
  7. package/codex/bundle/session-start-setup.js +193 -60
  8. package/codex/bundle/session-start.js +229 -87
  9. package/codex/bundle/shell/deeplake-shell.js +328 -295
  10. package/codex/bundle/skillify-worker.js +26 -18
  11. package/codex/bundle/stop.js +450 -394
  12. package/codex/bundle/wiki-worker.js +174 -292
  13. package/cursor/bundle/capture.js +448 -392
  14. package/cursor/bundle/commands/auth-login.js +163 -30
  15. package/cursor/bundle/pre-tool-use.js +324 -291
  16. package/cursor/bundle/session-end.js +43 -20
  17. package/cursor/bundle/session-start.js +272 -130
  18. package/cursor/bundle/shell/deeplake-shell.js +328 -295
  19. package/cursor/bundle/skillify-worker.js +26 -18
  20. package/cursor/bundle/wiki-worker.js +174 -292
  21. package/hermes/bundle/capture.js +448 -392
  22. package/hermes/bundle/commands/auth-login.js +163 -30
  23. package/hermes/bundle/pre-tool-use.js +324 -291
  24. package/hermes/bundle/session-end.js +43 -20
  25. package/hermes/bundle/session-start.js +269 -127
  26. package/hermes/bundle/shell/deeplake-shell.js +328 -295
  27. package/hermes/bundle/skillify-worker.js +26 -18
  28. package/hermes/bundle/wiki-worker.js +174 -292
  29. package/mcp/bundle/server.js +190 -57
  30. package/openclaw/dist/index.js +160 -32
  31. package/openclaw/dist/skillify-worker.js +26 -18
  32. package/openclaw/openclaw.plugin.json +1 -1
  33. package/openclaw/package.json +1 -1
  34. 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 mkdirSync2, readFileSync as readFileSync3, writeFileSync as writeFileSync2 } from "node:fs";
21
- import { join as join4 } from "node:path";
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";
22
22
  import { tmpdir } from "node:os";
23
23
  function getIndexMarkerDir() {
24
- return process.env.HIVEMIND_INDEX_MARKER_DIR ?? join4(tmpdir(), "hivemind-deeplake-indexes");
24
+ return process.env.HIVEMIND_INDEX_MARKER_DIR ?? join5(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 join4(getIndexMarkerDir(), `${markerKey}.json`);
28
+ return join5(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(readFileSync3(markerPath, "utf-8"));
34
+ const raw = JSON.parse(readFileSync4(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
- mkdirSync2(getIndexMarkerDir(), { recursive: true });
45
- writeFileSync2(markerPath, JSON.stringify({ updatedAt: (/* @__PURE__ */ new Date()).toISOString() }), "utf-8");
44
+ mkdirSync3(getIndexMarkerDir(), { recursive: true });
45
+ writeFileSync3(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 join8 } from "node:path";
56
+ import { dirname as dirname2, join as join9 } from "node:path";
57
57
  import { fileURLToPath } from "node:url";
58
- import { homedir as homedir4 } from "node:os";
58
+ import { homedir as homedir5 } from "node:os";
59
59
 
60
60
  // dist/src/commands/auth.js
61
61
  import { execSync } from "node:child_process";
@@ -160,6 +160,107 @@ function sqlIdent(name) {
160
160
  var SUMMARY_EMBEDDING_COL = "summary_embedding";
161
161
  var MESSAGE_EMBEDDING_COL = "message_embedding";
162
162
 
163
+ // dist/src/notifications/queue.js
164
+ import { readFileSync as readFileSync3, writeFileSync as writeFileSync2, renameSync, mkdirSync as mkdirSync2, openSync, closeSync, unlinkSync as unlinkSync2, statSync } from "node:fs";
165
+ import { join as join4, resolve } from "node:path";
166
+ import { homedir as homedir4 } from "node:os";
167
+ import { setTimeout as sleep } from "node:timers/promises";
168
+ var log2 = (msg) => log("notifications-queue", msg);
169
+ var LOCK_RETRY_MAX = 50;
170
+ var LOCK_RETRY_BASE_MS = 5;
171
+ var LOCK_STALE_MS = 5e3;
172
+ function queuePath() {
173
+ return join4(homedir4(), ".deeplake", "notifications-queue.json");
174
+ }
175
+ function lockPath() {
176
+ return `${queuePath()}.lock`;
177
+ }
178
+ function readQueue() {
179
+ try {
180
+ const raw = readFileSync3(queuePath(), "utf-8");
181
+ const parsed = JSON.parse(raw);
182
+ if (!parsed || !Array.isArray(parsed.queue)) {
183
+ log2(`queue malformed \u2192 treating as empty`);
184
+ return { queue: [] };
185
+ }
186
+ return { queue: parsed.queue };
187
+ } catch {
188
+ return { queue: [] };
189
+ }
190
+ }
191
+ function _isQueuePathInsideHome(path, home) {
192
+ const r = resolve(path);
193
+ const h = resolve(home);
194
+ return r.startsWith(h + "/") || r === h;
195
+ }
196
+ function writeQueue(q) {
197
+ const path = queuePath();
198
+ const home = resolve(homedir4());
199
+ if (!_isQueuePathInsideHome(path, home)) {
200
+ throw new Error(`notifications-queue write blocked: ${path} is outside ${home}`);
201
+ }
202
+ mkdirSync2(join4(home, ".deeplake"), { recursive: true, mode: 448 });
203
+ const tmp = `${path}.${process.pid}.tmp`;
204
+ writeFileSync2(tmp, JSON.stringify(q, null, 2), { mode: 384 });
205
+ renameSync(tmp, path);
206
+ }
207
+ async function withQueueLock(fn) {
208
+ const path = lockPath();
209
+ mkdirSync2(join4(homedir4(), ".deeplake"), { recursive: true, mode: 448 });
210
+ let fd = null;
211
+ for (let attempt = 0; attempt < LOCK_RETRY_MAX; attempt++) {
212
+ try {
213
+ fd = openSync(path, "wx", 384);
214
+ break;
215
+ } catch (e) {
216
+ const code = e.code;
217
+ if (code !== "EEXIST")
218
+ throw e;
219
+ try {
220
+ const age = Date.now() - statSync(path).mtimeMs;
221
+ if (age > LOCK_STALE_MS) {
222
+ unlinkSync2(path);
223
+ continue;
224
+ }
225
+ } catch {
226
+ }
227
+ const delay = LOCK_RETRY_BASE_MS * (attempt + 1);
228
+ await sleep(delay);
229
+ }
230
+ }
231
+ if (fd === null) {
232
+ log2(`lock acquisition gave up after ${LOCK_RETRY_MAX} attempts \u2014 proceeding unlocked (last-writer-wins)`);
233
+ return fn();
234
+ }
235
+ try {
236
+ return fn();
237
+ } finally {
238
+ try {
239
+ closeSync(fd);
240
+ } catch {
241
+ }
242
+ try {
243
+ unlinkSync2(path);
244
+ } catch {
245
+ }
246
+ }
247
+ }
248
+ function sameDedupKey(a, b) {
249
+ if (a.id !== b.id)
250
+ return false;
251
+ return JSON.stringify(a.dedupKey) === JSON.stringify(b.dedupKey);
252
+ }
253
+ async function enqueueNotification(n) {
254
+ await withQueueLock(() => {
255
+ const q = readQueue();
256
+ if (q.queue.some((existing) => sameDedupKey(existing, n))) {
257
+ return;
258
+ }
259
+ q.queue.push(n);
260
+ writeQueue(q);
261
+ });
262
+ }
263
+
163
264
  // dist/src/deeplake-api.js
164
265
  var indexMarkerStorePromise = null;
165
266
  function getIndexMarkerStore() {
@@ -167,7 +268,7 @@ function getIndexMarkerStore() {
167
268
  indexMarkerStorePromise = Promise.resolve().then(() => (init_index_marker_store(), index_marker_store_exports));
168
269
  return indexMarkerStorePromise;
169
270
  }
170
- var log2 = (msg) => log("sdk", msg);
271
+ var log3 = (msg) => log("sdk", msg);
171
272
  function summarizeSql(sql, maxLen = 220) {
172
273
  const compact = sql.replace(/\s+/g, " ").trim();
173
274
  return compact.length > maxLen ? `${compact.slice(0, maxLen)}...` : compact;
@@ -179,7 +280,38 @@ function traceSql(msg) {
179
280
  process.stderr.write(`[deeplake-sql] ${msg}
180
281
  `);
181
282
  if (process.env.HIVEMIND_DEBUG === "1")
182
- log2(msg);
283
+ log3(msg);
284
+ }
285
+ var _signalledBalanceExhausted = false;
286
+ function maybeSignalBalanceExhausted(status, bodyText) {
287
+ if (status !== 402)
288
+ return;
289
+ if (!bodyText.includes("balance_cents"))
290
+ return;
291
+ if (_signalledBalanceExhausted)
292
+ return;
293
+ _signalledBalanceExhausted = true;
294
+ log3(`balance exhausted \u2014 enqueuing session-start banner (body=${bodyText.slice(0, 120)})`);
295
+ enqueueNotification({
296
+ id: "balance-exhausted",
297
+ severity: "warn",
298
+ transient: true,
299
+ title: "Hivemind credits exhausted \u2014 top up to keep capturing",
300
+ body: `Sessions are not being saved and memory recall is returning empty. Top up at ${billingUrl()} to restore capture and recall.`,
301
+ dedupKey: { reason: "balance-zero" }
302
+ }).catch((e) => {
303
+ log3(`enqueue balance-exhausted failed: ${e instanceof Error ? e.message : String(e)}`);
304
+ });
305
+ }
306
+ function billingUrl() {
307
+ try {
308
+ const c = loadCredentials();
309
+ if (c?.orgName && c?.workspaceId) {
310
+ return `https://deeplake.ai/${encodeURIComponent(c.orgName)}/workspace/${encodeURIComponent(c.workspaceId)}/billing`;
311
+ }
312
+ } catch {
313
+ }
314
+ return "https://deeplake.ai";
183
315
  }
184
316
  var RETRYABLE_CODES = /* @__PURE__ */ new Set([429, 500, 502, 503, 504]);
185
317
  var MAX_RETRIES = 3;
@@ -188,8 +320,8 @@ var MAX_CONCURRENCY = 5;
188
320
  function getQueryTimeoutMs() {
189
321
  return Number(process.env.HIVEMIND_QUERY_TIMEOUT_MS ?? 1e4);
190
322
  }
191
- function sleep(ms) {
192
- return new Promise((resolve) => setTimeout(resolve, ms));
323
+ function sleep2(ms) {
324
+ return new Promise((resolve2) => setTimeout(resolve2, ms));
193
325
  }
194
326
  function isTimeoutError(error) {
195
327
  const name = error instanceof Error ? error.name.toLowerCase() : "";
@@ -219,7 +351,7 @@ var Semaphore = class {
219
351
  this.active++;
220
352
  return;
221
353
  }
222
- await new Promise((resolve) => this.waiting.push(resolve));
354
+ await new Promise((resolve2) => this.waiting.push(resolve2));
223
355
  }
224
356
  release() {
225
357
  this.active--;
@@ -290,8 +422,8 @@ var DeeplakeApi = class {
290
422
  lastError = e instanceof Error ? e : new Error(String(e));
291
423
  if (attempt < MAX_RETRIES) {
292
424
  const delay = BASE_DELAY_MS * Math.pow(2, attempt) + Math.random() * 200;
293
- log2(`query retry ${attempt + 1}/${MAX_RETRIES} (fetch error: ${lastError.message}) in ${delay.toFixed(0)}ms`);
294
- await sleep(delay);
425
+ log3(`query retry ${attempt + 1}/${MAX_RETRIES} (fetch error: ${lastError.message}) in ${delay.toFixed(0)}ms`);
426
+ await sleep2(delay);
295
427
  continue;
296
428
  }
297
429
  throw lastError;
@@ -307,10 +439,11 @@ var DeeplakeApi = class {
307
439
  const alreadyExists = resp.status === 500 && isDuplicateIndexError(text);
308
440
  if (!alreadyExists && attempt < MAX_RETRIES && (RETRYABLE_CODES.has(resp.status) || retryable403)) {
309
441
  const delay = BASE_DELAY_MS * Math.pow(2, attempt) + Math.random() * 200;
310
- log2(`query retry ${attempt + 1}/${MAX_RETRIES} (${resp.status}) in ${delay.toFixed(0)}ms`);
311
- await sleep(delay);
442
+ log3(`query retry ${attempt + 1}/${MAX_RETRIES} (${resp.status}) in ${delay.toFixed(0)}ms`);
443
+ await sleep2(delay);
312
444
  continue;
313
445
  }
446
+ maybeSignalBalanceExhausted(resp.status, text);
314
447
  throw new Error(`Query failed: ${resp.status}: ${text.slice(0, 200)}`);
315
448
  }
316
449
  throw lastError ?? new Error("Query failed: max retries exceeded");
@@ -331,7 +464,7 @@ var DeeplakeApi = class {
331
464
  const chunk = rows.slice(i, i + CONCURRENCY);
332
465
  await Promise.allSettled(chunk.map((r) => this.upsertRowSql(r)));
333
466
  }
334
- log2(`commit: ${rows.length} rows`);
467
+ log3(`commit: ${rows.length} rows`);
335
468
  }
336
469
  async upsertRowSql(row) {
337
470
  const ts = (/* @__PURE__ */ new Date()).toISOString();
@@ -387,7 +520,7 @@ var DeeplakeApi = class {
387
520
  markers.writeIndexMarker(markerPath);
388
521
  return;
389
522
  }
390
- log2(`index "${indexName}" skipped: ${e.message}`);
523
+ log3(`index "${indexName}" skipped: ${e.message}`);
391
524
  }
392
525
  }
393
526
  /**
@@ -477,13 +610,13 @@ var DeeplakeApi = class {
477
610
  };
478
611
  }
479
612
  if (attempt < MAX_RETRIES && RETRYABLE_CODES.has(resp.status)) {
480
- await sleep(BASE_DELAY_MS * Math.pow(2, attempt) + Math.random() * 200);
613
+ await sleep2(BASE_DELAY_MS * Math.pow(2, attempt) + Math.random() * 200);
481
614
  continue;
482
615
  }
483
616
  return { tables: [], cacheable: false };
484
617
  } catch {
485
618
  if (attempt < MAX_RETRIES) {
486
- await sleep(BASE_DELAY_MS * Math.pow(2, attempt));
619
+ await sleep2(BASE_DELAY_MS * Math.pow(2, attempt));
487
620
  continue;
488
621
  }
489
622
  return { tables: [], cacheable: false };
@@ -511,9 +644,9 @@ var DeeplakeApi = class {
511
644
  } catch (err) {
512
645
  lastErr = err;
513
646
  const msg = err instanceof Error ? err.message : String(err);
514
- log2(`CREATE TABLE "${label}" attempt ${attempt + 1}/${OUTER_BACKOFFS_MS.length + 1} failed: ${msg}`);
647
+ log3(`CREATE TABLE "${label}" attempt ${attempt + 1}/${OUTER_BACKOFFS_MS.length + 1} failed: ${msg}`);
515
648
  if (attempt < OUTER_BACKOFFS_MS.length) {
516
- await sleep(OUTER_BACKOFFS_MS[attempt]);
649
+ await sleep2(OUTER_BACKOFFS_MS[attempt]);
517
650
  }
518
651
  }
519
652
  }
@@ -524,9 +657,9 @@ var DeeplakeApi = class {
524
657
  const tbl = sqlIdent(name ?? this.tableName);
525
658
  const tables = await this.listTables();
526
659
  if (!tables.includes(tbl)) {
527
- log2(`table "${tbl}" not found, creating`);
660
+ log3(`table "${tbl}" not found, creating`);
528
661
  await this.createTableWithRetry(`CREATE TABLE IF NOT EXISTS "${tbl}" (id TEXT NOT NULL DEFAULT '', path TEXT NOT NULL DEFAULT '', filename TEXT NOT NULL DEFAULT '', summary TEXT NOT NULL DEFAULT '', summary_embedding FLOAT4[], author TEXT NOT NULL DEFAULT '', mime_type TEXT NOT NULL DEFAULT 'text/plain', size_bytes BIGINT NOT NULL DEFAULT 0, project TEXT NOT NULL DEFAULT '', description TEXT NOT NULL DEFAULT '', agent TEXT NOT NULL DEFAULT '', plugin_version TEXT NOT NULL DEFAULT '', creation_date TEXT NOT NULL DEFAULT '', last_update_date TEXT NOT NULL DEFAULT '') USING deeplake`, tbl);
529
- log2(`table "${tbl}" created`);
662
+ log3(`table "${tbl}" created`);
530
663
  if (!tables.includes(tbl))
531
664
  this._tablesCache = [...tables, tbl];
532
665
  }
@@ -539,9 +672,9 @@ var DeeplakeApi = class {
539
672
  const safe = sqlIdent(name);
540
673
  const tables = await this.listTables();
541
674
  if (!tables.includes(safe)) {
542
- log2(`table "${safe}" not found, creating`);
675
+ log3(`table "${safe}" not found, creating`);
543
676
  await this.createTableWithRetry(`CREATE TABLE IF NOT EXISTS "${safe}" (id TEXT NOT NULL DEFAULT '', path TEXT NOT NULL DEFAULT '', filename TEXT NOT NULL DEFAULT '', message JSONB, message_embedding FLOAT4[], author TEXT NOT NULL DEFAULT '', mime_type TEXT NOT NULL DEFAULT 'application/json', size_bytes BIGINT NOT NULL DEFAULT 0, project TEXT NOT NULL DEFAULT '', description TEXT NOT NULL DEFAULT '', agent TEXT NOT NULL DEFAULT '', plugin_version TEXT NOT NULL DEFAULT '', creation_date TEXT NOT NULL DEFAULT '', last_update_date TEXT NOT NULL DEFAULT '') USING deeplake`, safe);
544
- log2(`table "${safe}" created`);
677
+ log3(`table "${safe}" created`);
545
678
  if (!tables.includes(safe))
546
679
  this._tablesCache = [...tables, safe];
547
680
  }
@@ -564,9 +697,9 @@ var DeeplakeApi = class {
564
697
  const safe = sqlIdent(name);
565
698
  const tables = await this.listTables();
566
699
  if (!tables.includes(safe)) {
567
- log2(`table "${safe}" not found, creating`);
700
+ log3(`table "${safe}" not found, creating`);
568
701
  await this.createTableWithRetry(`CREATE TABLE IF NOT EXISTS "${safe}" (id TEXT NOT NULL DEFAULT '', name TEXT NOT NULL DEFAULT '', project TEXT NOT NULL DEFAULT '', project_key TEXT NOT NULL DEFAULT '', local_path TEXT NOT NULL DEFAULT '', install TEXT NOT NULL DEFAULT 'project', source_sessions TEXT NOT NULL DEFAULT '[]', source_agent TEXT NOT NULL DEFAULT '', scope TEXT NOT NULL DEFAULT 'me', author TEXT NOT NULL DEFAULT '', description TEXT NOT NULL DEFAULT '', trigger_text TEXT NOT NULL DEFAULT '', body TEXT NOT NULL DEFAULT '', version BIGINT NOT NULL DEFAULT 1, created_at TEXT NOT NULL DEFAULT '', updated_at TEXT NOT NULL DEFAULT '') USING deeplake`, safe);
569
- log2(`table "${safe}" created`);
702
+ log3(`table "${safe}" created`);
570
703
  if (!tables.includes(safe))
571
704
  this._tablesCache = [...tables, safe];
572
705
  }
@@ -576,13 +709,13 @@ var DeeplakeApi = class {
576
709
 
577
710
  // dist/src/utils/stdin.js
578
711
  function readStdin() {
579
- return new Promise((resolve, reject) => {
712
+ return new Promise((resolve2, reject) => {
580
713
  let data = "";
581
714
  process.stdin.setEncoding("utf-8");
582
715
  process.stdin.on("data", (chunk) => data += chunk);
583
716
  process.stdin.on("end", () => {
584
717
  try {
585
- resolve(JSON.parse(data));
718
+ resolve2(JSON.parse(data));
586
719
  } catch (err) {
587
720
  reject(new Error(`Failed to parse hook input: ${err}`));
588
721
  }
@@ -592,15 +725,15 @@ function readStdin() {
592
725
  }
593
726
 
594
727
  // dist/src/utils/wiki-log.js
595
- import { mkdirSync as mkdirSync3, appendFileSync as appendFileSync2 } from "node:fs";
596
- import { join as join5 } from "node:path";
728
+ import { mkdirSync as mkdirSync4, appendFileSync as appendFileSync2 } from "node:fs";
729
+ import { join as join6 } from "node:path";
597
730
  function makeWikiLogger(hooksDir, filename = "deeplake-wiki.log") {
598
- const path = join5(hooksDir, filename);
731
+ const path = join6(hooksDir, filename);
599
732
  return {
600
733
  path,
601
734
  log(msg) {
602
735
  try {
603
- mkdirSync3(hooksDir, { recursive: true });
736
+ mkdirSync4(hooksDir, { recursive: true });
604
737
  appendFileSync2(path, `[${utcTimestamp()}] ${msg}
605
738
  `);
606
739
  } catch {
@@ -612,8 +745,8 @@ function makeWikiLogger(hooksDir, filename = "deeplake-wiki.log") {
612
745
  // dist/src/hooks/shared/autoupdate.js
613
746
  import { spawn } from "node:child_process";
614
747
  import { existsSync as existsSync3 } from "node:fs";
615
- import { join as join6 } from "node:path";
616
- var log3 = (msg) => log("autoupdate", msg);
748
+ import { join as join7 } from "node:path";
749
+ var log4 = (msg) => log("autoupdate", msg);
617
750
  var defaultSpawn = (cmd, args) => {
618
751
  const child = spawn(cmd, args, {
619
752
  detached: true,
@@ -628,7 +761,7 @@ function findHivemindOnPath() {
628
761
  const PATH = process.env.PATH ?? "";
629
762
  const dirs = PATH.split(":").filter(Boolean);
630
763
  for (const dir of dirs) {
631
- const candidate = join6(dir, "hivemind");
764
+ const candidate = join7(dir, "hivemind");
632
765
  if (existsSync3(candidate))
633
766
  return candidate;
634
767
  }
@@ -636,45 +769,45 @@ function findHivemindOnPath() {
636
769
  }
637
770
  async function autoUpdate(creds, opts) {
638
771
  const t0 = Date.now();
639
- log3(`agent=${opts.agent} entered`);
772
+ log4(`agent=${opts.agent} entered`);
640
773
  if (!creds?.token) {
641
- log3(`agent=${opts.agent} skip: no creds.token (${Date.now() - t0}ms)`);
774
+ log4(`agent=${opts.agent} skip: no creds.token (${Date.now() - t0}ms)`);
642
775
  return;
643
776
  }
644
777
  if (creds.autoupdate === false) {
645
- log3(`agent=${opts.agent} skip: autoupdate=false (${Date.now() - t0}ms)`);
778
+ log4(`agent=${opts.agent} skip: autoupdate=false (${Date.now() - t0}ms)`);
646
779
  return;
647
780
  }
648
781
  const binaryPath = opts.hivemindBinaryPath !== void 0 ? opts.hivemindBinaryPath : findHivemindOnPath();
649
782
  if (!binaryPath) {
650
- log3(`agent=${opts.agent} skip: hivemind binary not on PATH (${Date.now() - t0}ms)`);
783
+ log4(`agent=${opts.agent} skip: hivemind binary not on PATH (${Date.now() - t0}ms)`);
651
784
  return;
652
785
  }
653
- log3(`agent=${opts.agent} binary=${binaryPath} \u2192 dispatching detached update`);
786
+ log4(`agent=${opts.agent} binary=${binaryPath} \u2192 dispatching detached update`);
654
787
  const spawnFn = opts.spawn ?? defaultSpawn;
655
788
  let pid;
656
789
  try {
657
790
  pid = spawnFn(binaryPath, ["update"]).pid;
658
791
  } catch (e) {
659
- log3(`agent=${opts.agent} dispatch threw: ${e?.message ?? e} (${Date.now() - t0}ms)`);
792
+ log4(`agent=${opts.agent} dispatch threw: ${e?.message ?? e} (${Date.now() - t0}ms)`);
660
793
  return;
661
794
  }
662
- log3(`agent=${opts.agent} dispatched (pid=${pid ?? "?"}) (${Date.now() - t0}ms total)`);
795
+ log4(`agent=${opts.agent} dispatched (pid=${pid ?? "?"}) (${Date.now() - t0}ms total)`);
663
796
  }
664
797
 
665
798
  // dist/src/utils/version-check.js
666
- import { readFileSync as readFileSync4 } from "node:fs";
667
- import { dirname, join as join7 } from "node:path";
799
+ import { readFileSync as readFileSync5 } from "node:fs";
800
+ import { dirname, join as join8 } from "node:path";
668
801
  function getInstalledVersion(bundleDir, pluginManifestDir) {
669
802
  try {
670
- const pluginJson = join7(bundleDir, "..", pluginManifestDir, "plugin.json");
671
- const plugin = JSON.parse(readFileSync4(pluginJson, "utf-8"));
803
+ const pluginJson = join8(bundleDir, "..", pluginManifestDir, "plugin.json");
804
+ const plugin = JSON.parse(readFileSync5(pluginJson, "utf-8"));
672
805
  if (plugin.version)
673
806
  return plugin.version;
674
807
  } catch {
675
808
  }
676
809
  try {
677
- const stamp = readFileSync4(join7(bundleDir, "..", ".hivemind_version"), "utf-8").trim();
810
+ const stamp = readFileSync5(join8(bundleDir, "..", ".hivemind_version"), "utf-8").trim();
678
811
  if (stamp)
679
812
  return stamp;
680
813
  } catch {
@@ -689,9 +822,9 @@ function getInstalledVersion(bundleDir, pluginManifestDir) {
689
822
  ]);
690
823
  let dir = bundleDir;
691
824
  for (let i = 0; i < 5; i++) {
692
- const candidate = join7(dir, "package.json");
825
+ const candidate = join8(dir, "package.json");
693
826
  try {
694
- const pkg = JSON.parse(readFileSync4(candidate, "utf-8"));
827
+ const pkg = JSON.parse(readFileSync5(candidate, "utf-8"));
695
828
  if (HIVEMIND_PKG_NAMES.has(pkg.name) && pkg.version)
696
829
  return pkg.version;
697
830
  } catch {
@@ -705,8 +838,8 @@ function getInstalledVersion(bundleDir, pluginManifestDir) {
705
838
  }
706
839
 
707
840
  // dist/src/hooks/codex/session-start-setup.js
708
- var log4 = (msg) => log("codex-session-setup", msg);
709
- var { log: wikiLog } = makeWikiLogger(join8(homedir4(), ".codex", "hooks"));
841
+ var log5 = (msg) => log("codex-session-setup", msg);
842
+ var { log: wikiLog } = makeWikiLogger(join9(homedir5(), ".codex", "hooks"));
710
843
  var __bundleDir = dirname2(fileURLToPath(import.meta.url));
711
844
  var PLUGIN_VERSION = getInstalledVersion(__bundleDir, ".codex-plugin") ?? "";
712
845
  async function createPlaceholder(api, table, sessionId, cwd, userName, orgName, workspaceId) {
@@ -737,7 +870,7 @@ async function main() {
737
870
  const input = await readStdin();
738
871
  const creds = loadCredentials();
739
872
  if (!creds?.token) {
740
- log4("no credentials");
873
+ log5("no credentials");
741
874
  return;
742
875
  }
743
876
  if (!creds.userName) {
@@ -745,7 +878,7 @@ async function main() {
745
878
  const { userInfo: userInfo2 } = await import("node:os");
746
879
  creds.userName = userInfo2().username ?? "unknown";
747
880
  saveCredentials(creds);
748
- log4(`backfilled userName: ${creds.userName}`);
881
+ log5(`backfilled userName: ${creds.userName}`);
749
882
  } catch {
750
883
  }
751
884
  }
@@ -761,15 +894,15 @@ async function main() {
761
894
  if (captureEnabled) {
762
895
  await createPlaceholder(api, config.tableName, input.session_id, input.cwd ?? "", config.userName, config.orgName, config.workspaceId);
763
896
  }
764
- log4("setup complete");
897
+ log5("setup complete");
765
898
  }
766
899
  } catch (e) {
767
- log4(`setup failed: ${e.message}`);
900
+ log5(`setup failed: ${e.message}`);
768
901
  wikiLog(`SessionSetup: failed for ${input.session_id}: ${e.message}`);
769
902
  }
770
903
  }
771
904
  }
772
905
  main().catch((e) => {
773
- log4(`fatal: ${e.message}`);
906
+ log5(`fatal: ${e.message}`);
774
907
  process.exit(0);
775
908
  });