@deeplake/hivemind 0.7.20 → 0.7.22

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.
@@ -507,13 +507,14 @@ var DeeplakeApi = class {
507
507
  const tables = await this.listTables();
508
508
  if (!tables.includes(tbl)) {
509
509
  log2(`table "${tbl}" not found, creating`);
510
- 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 '', creation_date TEXT NOT NULL DEFAULT '', last_update_date TEXT NOT NULL DEFAULT '') USING deeplake`, tbl);
510
+ 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);
511
511
  log2(`table "${tbl}" created`);
512
512
  if (!tables.includes(tbl))
513
513
  this._tablesCache = [...tables, tbl];
514
514
  }
515
515
  await this.ensureEmbeddingColumn(tbl, SUMMARY_EMBEDDING_COL);
516
516
  await this.ensureColumn(tbl, "agent", "TEXT NOT NULL DEFAULT ''");
517
+ await this.ensureColumn(tbl, "plugin_version", "TEXT NOT NULL DEFAULT ''");
517
518
  }
518
519
  /** Create the sessions table (uses JSONB for message since every row is a JSON event). */
519
520
  async ensureSessionsTable(name) {
@@ -521,13 +522,14 @@ var DeeplakeApi = class {
521
522
  const tables = await this.listTables();
522
523
  if (!tables.includes(safe)) {
523
524
  log2(`table "${safe}" not found, creating`);
524
- 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 '', creation_date TEXT NOT NULL DEFAULT '', last_update_date TEXT NOT NULL DEFAULT '') USING deeplake`, safe);
525
+ 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);
525
526
  log2(`table "${safe}" created`);
526
527
  if (!tables.includes(safe))
527
528
  this._tablesCache = [...tables, safe];
528
529
  }
529
530
  await this.ensureEmbeddingColumn(safe, MESSAGE_EMBEDDING_COL);
530
531
  await this.ensureColumn(safe, "agent", "TEXT NOT NULL DEFAULT ''");
532
+ await this.ensureColumn(safe, "plugin_version", "TEXT NOT NULL DEFAULT ''");
531
533
  await this.ensureLookupIndex(safe, "path_creation_date", `("path", "creation_date")`);
532
534
  }
533
535
  /**
@@ -839,7 +841,7 @@ function embeddingsDisabled() {
839
841
 
840
842
  // dist/src/hooks/cursor/capture.js
841
843
  import { fileURLToPath as fileURLToPath3 } from "node:url";
842
- import { dirname as dirname3, join as join14 } from "node:path";
844
+ import { dirname as dirname4, join as join15 } from "node:path";
843
845
 
844
846
  // dist/src/hooks/summary-state.js
845
847
  import { readFileSync as readFileSync4, writeFileSync as writeFileSync2, writeSync as writeSync2, mkdirSync as mkdirSync2, renameSync, existsSync as existsSync4, unlinkSync as unlinkSync2, openSync as openSync2, closeSync as closeSync2 } from "node:fs";
@@ -978,7 +980,7 @@ function releaseLock(sessionId) {
978
980
  // dist/src/hooks/cursor/spawn-wiki-worker.js
979
981
  import { spawn as spawn2, execSync } from "node:child_process";
980
982
  import { fileURLToPath } from "node:url";
981
- import { dirname, join as join8 } from "node:path";
983
+ import { dirname as dirname2, join as join9 } from "node:path";
982
984
  import { writeFileSync as writeFileSync3, mkdirSync as mkdirSync4 } from "node:fs";
983
985
  import { homedir as homedir6, tmpdir as tmpdir2 } from "node:os";
984
986
 
@@ -1000,9 +1002,51 @@ function makeWikiLogger(hooksDir, filename = "deeplake-wiki.log") {
1000
1002
  };
1001
1003
  }
1002
1004
 
1005
+ // dist/src/utils/version-check.js
1006
+ import { readFileSync as readFileSync5 } from "node:fs";
1007
+ import { dirname, join as join8 } from "node:path";
1008
+ function getInstalledVersion(bundleDir, pluginManifestDir) {
1009
+ try {
1010
+ const pluginJson = join8(bundleDir, "..", pluginManifestDir, "plugin.json");
1011
+ const plugin = JSON.parse(readFileSync5(pluginJson, "utf-8"));
1012
+ if (plugin.version)
1013
+ return plugin.version;
1014
+ } catch {
1015
+ }
1016
+ try {
1017
+ const stamp = readFileSync5(join8(bundleDir, "..", ".hivemind_version"), "utf-8").trim();
1018
+ if (stamp)
1019
+ return stamp;
1020
+ } catch {
1021
+ }
1022
+ const HIVEMIND_PKG_NAMES = /* @__PURE__ */ new Set([
1023
+ "hivemind",
1024
+ "hivemind-codex",
1025
+ "@deeplake/hivemind",
1026
+ "@deeplake/hivemind-codex",
1027
+ "@activeloop/hivemind",
1028
+ "@activeloop/hivemind-codex"
1029
+ ]);
1030
+ let dir = bundleDir;
1031
+ for (let i = 0; i < 5; i++) {
1032
+ const candidate = join8(dir, "package.json");
1033
+ try {
1034
+ const pkg = JSON.parse(readFileSync5(candidate, "utf-8"));
1035
+ if (HIVEMIND_PKG_NAMES.has(pkg.name) && pkg.version)
1036
+ return pkg.version;
1037
+ } catch {
1038
+ }
1039
+ const parent = dirname(dir);
1040
+ if (parent === dir)
1041
+ break;
1042
+ dir = parent;
1043
+ }
1044
+ return null;
1045
+ }
1046
+
1003
1047
  // dist/src/hooks/cursor/spawn-wiki-worker.js
1004
1048
  var HOME = homedir6();
1005
- var wikiLogger = makeWikiLogger(join8(HOME, ".cursor", "hooks"));
1049
+ var wikiLogger = makeWikiLogger(join9(HOME, ".cursor", "hooks"));
1006
1050
  var WIKI_LOG = wikiLogger.path;
1007
1051
  var WIKI_PROMPT_TEMPLATE = `You are building a personal wiki from a coding session. Your goal is to extract every piece of knowledge \u2014 entities, decisions, relationships, and facts \u2014 into a structured, searchable wiki entry.
1008
1052
 
@@ -1064,9 +1108,10 @@ function findCursorBin() {
1064
1108
  function spawnCursorWikiWorker(opts) {
1065
1109
  const { config, sessionId, cwd, bundleDir, reason } = opts;
1066
1110
  const projectName = cwd.split("/").pop() || "unknown";
1067
- const tmpDir = join8(tmpdir2(), `deeplake-wiki-${sessionId}-${Date.now()}`);
1111
+ const tmpDir = join9(tmpdir2(), `deeplake-wiki-${sessionId}-${Date.now()}`);
1068
1112
  mkdirSync4(tmpDir, { recursive: true });
1069
- const configFile = join8(tmpDir, "config.json");
1113
+ const pluginVersion = getInstalledVersion(bundleDir, ".claude-plugin") ?? "";
1114
+ const configFile = join9(tmpDir, "config.json");
1070
1115
  writeFileSync3(configFile, JSON.stringify({
1071
1116
  apiUrl: config.apiUrl,
1072
1117
  token: config.token,
@@ -1077,15 +1122,16 @@ function spawnCursorWikiWorker(opts) {
1077
1122
  sessionId,
1078
1123
  userName: config.userName,
1079
1124
  project: projectName,
1125
+ pluginVersion,
1080
1126
  tmpDir,
1081
1127
  cursorBin: findCursorBin(),
1082
1128
  cursorModel: process.env.HIVEMIND_CURSOR_MODEL ?? "auto",
1083
1129
  wikiLog: WIKI_LOG,
1084
- hooksDir: join8(HOME, ".cursor", "hooks"),
1130
+ hooksDir: join9(HOME, ".cursor", "hooks"),
1085
1131
  promptTemplate: WIKI_PROMPT_TEMPLATE
1086
1132
  }));
1087
1133
  wikiLog(`${reason}: spawning summary worker for ${sessionId}`);
1088
- const workerPath = join8(bundleDir, "wiki-worker.js");
1134
+ const workerPath = join9(bundleDir, "wiki-worker.js");
1089
1135
  spawn2("nohup", ["node", workerPath, configFile], {
1090
1136
  detached: true,
1091
1137
  stdio: ["ignore", "ignore", "ignore"]
@@ -1093,13 +1139,13 @@ function spawnCursorWikiWorker(opts) {
1093
1139
  wikiLog(`${reason}: spawned summary worker for ${sessionId}`);
1094
1140
  }
1095
1141
  function bundleDirFromImportMeta(importMetaUrl) {
1096
- return dirname(fileURLToPath(importMetaUrl));
1142
+ return dirname2(fileURLToPath(importMetaUrl));
1097
1143
  }
1098
1144
 
1099
1145
  // dist/src/skillify/spawn-skillify-worker.js
1100
1146
  import { spawn as spawn3 } from "node:child_process";
1101
1147
  import { fileURLToPath as fileURLToPath2 } from "node:url";
1102
- import { dirname as dirname2, join as join10 } from "node:path";
1148
+ import { dirname as dirname3, join as join11 } from "node:path";
1103
1149
  import { writeFileSync as writeFileSync4, mkdirSync as mkdirSync5, appendFileSync as appendFileSync3, chmodSync } from "node:fs";
1104
1150
  import { homedir as homedir8, tmpdir as tmpdir3 } from "node:os";
1105
1151
 
@@ -1107,7 +1153,7 @@ import { homedir as homedir8, tmpdir as tmpdir3 } from "node:os";
1107
1153
  import { execFileSync } from "node:child_process";
1108
1154
  import { existsSync as existsSync5 } from "node:fs";
1109
1155
  import { homedir as homedir7 } from "node:os";
1110
- import { join as join9 } from "node:path";
1156
+ import { join as join10 } from "node:path";
1111
1157
  function findAgentBin(agent) {
1112
1158
  const which = (name) => {
1113
1159
  try {
@@ -1122,24 +1168,24 @@ function findAgentBin(agent) {
1122
1168
  };
1123
1169
  switch (agent) {
1124
1170
  case "claude_code":
1125
- return which("claude") ?? join9(homedir7(), ".claude", "local", "claude");
1171
+ return which("claude") ?? join10(homedir7(), ".claude", "local", "claude");
1126
1172
  case "codex":
1127
1173
  return which("codex") ?? "/usr/local/bin/codex";
1128
1174
  case "cursor":
1129
1175
  return which("cursor-agent") ?? "/usr/local/bin/cursor-agent";
1130
1176
  case "hermes":
1131
- return which("hermes") ?? join9(homedir7(), ".local", "bin", "hermes");
1177
+ return which("hermes") ?? join10(homedir7(), ".local", "bin", "hermes");
1132
1178
  case "pi":
1133
- return which("pi") ?? join9(homedir7(), ".local", "bin", "pi");
1179
+ return which("pi") ?? join10(homedir7(), ".local", "bin", "pi");
1134
1180
  }
1135
1181
  }
1136
1182
 
1137
1183
  // dist/src/skillify/spawn-skillify-worker.js
1138
1184
  var HOME2 = homedir8();
1139
- var SKILLIFY_LOG = join10(HOME2, ".claude", "hooks", "skillify.log");
1185
+ var SKILLIFY_LOG = join11(HOME2, ".claude", "hooks", "skillify.log");
1140
1186
  function skillifyLog(msg) {
1141
1187
  try {
1142
- mkdirSync5(dirname2(SKILLIFY_LOG), { recursive: true });
1188
+ mkdirSync5(dirname3(SKILLIFY_LOG), { recursive: true });
1143
1189
  appendFileSync3(SKILLIFY_LOG, `[${utcTimestamp()}] ${msg}
1144
1190
  `);
1145
1191
  } catch {
@@ -1147,10 +1193,10 @@ function skillifyLog(msg) {
1147
1193
  }
1148
1194
  function spawnSkillifyWorker(opts) {
1149
1195
  const { config, cwd, projectKey, project, bundleDir, agent, scopeConfig, currentSessionId, reason } = opts;
1150
- const tmpDir = join10(tmpdir3(), `deeplake-skillify-${projectKey}-${Date.now()}`);
1196
+ const tmpDir = join11(tmpdir3(), `deeplake-skillify-${projectKey}-${Date.now()}`);
1151
1197
  mkdirSync5(tmpDir, { recursive: true, mode: 448 });
1152
1198
  const gateBin = findAgentBin(agent);
1153
- const configFile = join10(tmpDir, "config.json");
1199
+ const configFile = join11(tmpDir, "config.json");
1154
1200
  writeFileSync4(configFile, JSON.stringify({
1155
1201
  apiUrl: config.apiUrl,
1156
1202
  token: config.token,
@@ -1181,7 +1227,7 @@ function spawnSkillifyWorker(opts) {
1181
1227
  } catch {
1182
1228
  }
1183
1229
  skillifyLog(`${reason}: spawning skillify worker for project=${project} key=${projectKey}`);
1184
- const workerPath = join10(bundleDir, "skillify-worker.js");
1230
+ const workerPath = join11(bundleDir, "skillify-worker.js");
1185
1231
  spawn3("nohup", ["node", workerPath, configFile], {
1186
1232
  detached: true,
1187
1233
  stdio: ["ignore", "ignore", "ignore"]
@@ -1190,25 +1236,25 @@ function spawnSkillifyWorker(opts) {
1190
1236
  }
1191
1237
 
1192
1238
  // dist/src/skillify/state.js
1193
- import { readFileSync as readFileSync5, writeFileSync as writeFileSync5, writeSync as writeSync3, mkdirSync as mkdirSync6, renameSync as renameSync3, existsSync as existsSync7, unlinkSync as unlinkSync3, openSync as openSync3, closeSync as closeSync3 } from "node:fs";
1239
+ import { readFileSync as readFileSync6, writeFileSync as writeFileSync5, writeSync as writeSync3, mkdirSync as mkdirSync6, renameSync as renameSync3, existsSync as existsSync7, unlinkSync as unlinkSync3, openSync as openSync3, closeSync as closeSync3 } from "node:fs";
1194
1240
  import { execSync as execSync2 } from "node:child_process";
1195
1241
  import { homedir as homedir10 } from "node:os";
1196
1242
  import { createHash } from "node:crypto";
1197
- import { join as join12, basename } from "node:path";
1243
+ import { join as join13, basename } from "node:path";
1198
1244
 
1199
1245
  // dist/src/skillify/legacy-migration.js
1200
1246
  import { existsSync as existsSync6, renameSync as renameSync2 } from "node:fs";
1201
1247
  import { homedir as homedir9 } from "node:os";
1202
- import { join as join11 } from "node:path";
1248
+ import { join as join12 } from "node:path";
1203
1249
  var dlog2 = (msg) => log("skillify-migrate", msg);
1204
1250
  var attempted = false;
1205
1251
  function migrateLegacyStateDir() {
1206
1252
  if (attempted)
1207
1253
  return;
1208
1254
  attempted = true;
1209
- const root = join11(homedir9(), ".deeplake", "state");
1210
- const legacy = join11(root, "skilify");
1211
- const current = join11(root, "skillify");
1255
+ const root = join12(homedir9(), ".deeplake", "state");
1256
+ const legacy = join12(root, "skilify");
1257
+ const current = join12(root, "skillify");
1212
1258
  if (!existsSync6(legacy))
1213
1259
  return;
1214
1260
  if (existsSync6(current))
@@ -1228,17 +1274,17 @@ function migrateLegacyStateDir() {
1228
1274
 
1229
1275
  // dist/src/skillify/state.js
1230
1276
  var dlog3 = (msg) => log("skillify-state", msg);
1231
- var STATE_DIR2 = join12(homedir10(), ".deeplake", "state", "skillify");
1277
+ var STATE_DIR2 = join13(homedir10(), ".deeplake", "state", "skillify");
1232
1278
  var YIELD_BUF2 = new Int32Array(new SharedArrayBuffer(4));
1233
1279
  var TRIGGER_THRESHOLD = (() => {
1234
1280
  const n = Number(process.env.HIVEMIND_SKILLIFY_EVERY_N_TURNS ?? "");
1235
1281
  return Number.isInteger(n) && n > 0 ? n : 20;
1236
1282
  })();
1237
1283
  function statePath2(projectKey) {
1238
- return join12(STATE_DIR2, `${projectKey}.json`);
1284
+ return join13(STATE_DIR2, `${projectKey}.json`);
1239
1285
  }
1240
1286
  function lockPath2(projectKey) {
1241
- return join12(STATE_DIR2, `${projectKey}.lock`);
1287
+ return join13(STATE_DIR2, `${projectKey}.lock`);
1242
1288
  }
1243
1289
  var DEFAULT_PORTS = {
1244
1290
  http: "80",
@@ -1287,7 +1333,7 @@ function readState2(projectKey) {
1287
1333
  if (!existsSync7(p))
1288
1334
  return null;
1289
1335
  try {
1290
- return JSON.parse(readFileSync5(p, "utf-8"));
1336
+ return JSON.parse(readFileSync6(p, "utf-8"));
1291
1337
  } catch {
1292
1338
  return null;
1293
1339
  }
@@ -1366,7 +1412,7 @@ function tryAcquireWorkerLock(projectKey, maxAgeMs = 10 * 60 * 1e3) {
1366
1412
  const p = lockPath2(projectKey);
1367
1413
  if (existsSync7(p)) {
1368
1414
  try {
1369
- const ageMs = Date.now() - parseInt(readFileSync5(p, "utf-8"), 10);
1415
+ const ageMs = Date.now() - parseInt(readFileSync6(p, "utf-8"), 10);
1370
1416
  if (Number.isFinite(ageMs) && ageMs < maxAgeMs)
1371
1417
  return false;
1372
1418
  } catch (readErr) {
@@ -1400,18 +1446,18 @@ function releaseWorkerLock(projectKey) {
1400
1446
  }
1401
1447
 
1402
1448
  // dist/src/skillify/scope-config.js
1403
- import { existsSync as existsSync8, mkdirSync as mkdirSync7, readFileSync as readFileSync6, writeFileSync as writeFileSync6 } from "node:fs";
1449
+ import { existsSync as existsSync8, mkdirSync as mkdirSync7, readFileSync as readFileSync7, writeFileSync as writeFileSync6 } from "node:fs";
1404
1450
  import { homedir as homedir11 } from "node:os";
1405
- import { join as join13 } from "node:path";
1406
- var STATE_DIR3 = join13(homedir11(), ".deeplake", "state", "skillify");
1407
- var CONFIG_PATH = join13(STATE_DIR3, "config.json");
1451
+ import { join as join14 } from "node:path";
1452
+ var STATE_DIR3 = join14(homedir11(), ".deeplake", "state", "skillify");
1453
+ var CONFIG_PATH = join14(STATE_DIR3, "config.json");
1408
1454
  var DEFAULT = { scope: "me", team: [], install: "project" };
1409
1455
  function loadScopeConfig() {
1410
1456
  migrateLegacyStateDir();
1411
1457
  if (!existsSync8(CONFIG_PATH))
1412
1458
  return DEFAULT;
1413
1459
  try {
1414
- const raw = JSON.parse(readFileSync6(CONFIG_PATH, "utf-8"));
1460
+ const raw = JSON.parse(readFileSync7(CONFIG_PATH, "utf-8"));
1415
1461
  const scope = raw.scope === "team" || raw.scope === "org" ? raw.scope : "me";
1416
1462
  const team = Array.isArray(raw.team) ? raw.team.filter((s) => typeof s === "string") : [];
1417
1463
  const install = raw.install === "global" ? "global" : "project";
@@ -1464,8 +1510,10 @@ function tryStopCounterTrigger(opts) {
1464
1510
  // dist/src/hooks/cursor/capture.js
1465
1511
  var log4 = (msg) => log("cursor-capture", msg);
1466
1512
  function resolveEmbedDaemonPath() {
1467
- return join14(dirname3(fileURLToPath3(import.meta.url)), "embeddings", "embed-daemon.js");
1513
+ return join15(dirname4(fileURLToPath3(import.meta.url)), "embeddings", "embed-daemon.js");
1468
1514
  }
1515
+ var __bundleDir = dirname4(fileURLToPath3(import.meta.url));
1516
+ var PLUGIN_VERSION = getInstalledVersion(__bundleDir, ".claude-plugin") ?? "";
1469
1517
  var CAPTURE = process.env.HIVEMIND_CAPTURE !== "false";
1470
1518
  function resolveCwd(input) {
1471
1519
  if (typeof input.cwd === "string" && input.cwd)
@@ -1538,7 +1586,7 @@ async function main() {
1538
1586
  const jsonForSql = line.replace(/'/g, "''");
1539
1587
  const embedding = embeddingsDisabled() ? null : await new EmbedClient({ daemonEntry: resolveEmbedDaemonPath() }).embed(line, "document");
1540
1588
  const embeddingSql = embeddingSqlLiteral(embedding);
1541
- const insertSql = `INSERT INTO "${sessionsTable}" (id, path, filename, message, message_embedding, author, size_bytes, project, description, agent, creation_date, last_update_date) VALUES ('${crypto.randomUUID()}', '${sqlStr(sessionPath)}', '${sqlStr(filename)}', '${jsonForSql}'::jsonb, ${embeddingSql}, '${sqlStr(config.userName)}', ${Buffer.byteLength(line, "utf-8")}, '${sqlStr(projectName)}', '${sqlStr(event)}', 'cursor', '${ts}', '${ts}')`;
1589
+ const insertSql = `INSERT INTO "${sessionsTable}" (id, path, filename, message, message_embedding, author, size_bytes, project, description, agent, plugin_version, creation_date, last_update_date) VALUES ('${crypto.randomUUID()}', '${sqlStr(sessionPath)}', '${sqlStr(filename)}', '${jsonForSql}'::jsonb, ${embeddingSql}, '${sqlStr(config.userName)}', ${Buffer.byteLength(line, "utf-8")}, '${sqlStr(projectName)}', '${sqlStr(event)}', 'cursor', '${sqlStr(PLUGIN_VERSION)}', '${ts}', '${ts}')`;
1542
1590
  try {
1543
1591
  await api.query(insertSql);
1544
1592
  } catch (e) {
@@ -697,13 +697,14 @@ var DeeplakeApi = class {
697
697
  const tables = await this.listTables();
698
698
  if (!tables.includes(tbl)) {
699
699
  log2(`table "${tbl}" not found, creating`);
700
- 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 '', creation_date TEXT NOT NULL DEFAULT '', last_update_date TEXT NOT NULL DEFAULT '') USING deeplake`, tbl);
700
+ 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);
701
701
  log2(`table "${tbl}" created`);
702
702
  if (!tables.includes(tbl))
703
703
  this._tablesCache = [...tables, tbl];
704
704
  }
705
705
  await this.ensureEmbeddingColumn(tbl, SUMMARY_EMBEDDING_COL);
706
706
  await this.ensureColumn(tbl, "agent", "TEXT NOT NULL DEFAULT ''");
707
+ await this.ensureColumn(tbl, "plugin_version", "TEXT NOT NULL DEFAULT ''");
707
708
  }
708
709
  /** Create the sessions table (uses JSONB for message since every row is a JSON event). */
709
710
  async ensureSessionsTable(name) {
@@ -711,13 +712,14 @@ var DeeplakeApi = class {
711
712
  const tables = await this.listTables();
712
713
  if (!tables.includes(safe)) {
713
714
  log2(`table "${safe}" not found, creating`);
714
- 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 '', creation_date TEXT NOT NULL DEFAULT '', last_update_date TEXT NOT NULL DEFAULT '') USING deeplake`, safe);
715
+ 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);
715
716
  log2(`table "${safe}" created`);
716
717
  if (!tables.includes(safe))
717
718
  this._tablesCache = [...tables, safe];
718
719
  }
719
720
  await this.ensureEmbeddingColumn(safe, MESSAGE_EMBEDDING_COL);
720
721
  await this.ensureColumn(safe, "agent", "TEXT NOT NULL DEFAULT ''");
722
+ await this.ensureColumn(safe, "plugin_version", "TEXT NOT NULL DEFAULT ''");
721
723
  await this.ensureLookupIndex(safe, "path_creation_date", `("path", "creation_date")`);
722
724
  }
723
725
  /**
@@ -506,13 +506,14 @@ var DeeplakeApi = class {
506
506
  const tables = await this.listTables();
507
507
  if (!tables.includes(tbl)) {
508
508
  log2(`table "${tbl}" not found, creating`);
509
- 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 '', creation_date TEXT NOT NULL DEFAULT '', last_update_date TEXT NOT NULL DEFAULT '') USING deeplake`, tbl);
509
+ 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);
510
510
  log2(`table "${tbl}" created`);
511
511
  if (!tables.includes(tbl))
512
512
  this._tablesCache = [...tables, tbl];
513
513
  }
514
514
  await this.ensureEmbeddingColumn(tbl, SUMMARY_EMBEDDING_COL);
515
515
  await this.ensureColumn(tbl, "agent", "TEXT NOT NULL DEFAULT ''");
516
+ await this.ensureColumn(tbl, "plugin_version", "TEXT NOT NULL DEFAULT ''");
516
517
  }
517
518
  /** Create the sessions table (uses JSONB for message since every row is a JSON event). */
518
519
  async ensureSessionsTable(name) {
@@ -520,13 +521,14 @@ var DeeplakeApi = class {
520
521
  const tables = await this.listTables();
521
522
  if (!tables.includes(safe)) {
522
523
  log2(`table "${safe}" not found, creating`);
523
- 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 '', creation_date TEXT NOT NULL DEFAULT '', last_update_date TEXT NOT NULL DEFAULT '') USING deeplake`, safe);
524
+ 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);
524
525
  log2(`table "${safe}" created`);
525
526
  if (!tables.includes(safe))
526
527
  this._tablesCache = [...tables, safe];
527
528
  }
528
529
  await this.ensureEmbeddingColumn(safe, MESSAGE_EMBEDDING_COL);
529
530
  await this.ensureColumn(safe, "agent", "TEXT NOT NULL DEFAULT ''");
531
+ await this.ensureColumn(safe, "plugin_version", "TEXT NOT NULL DEFAULT ''");
530
532
  await this.ensureLookupIndex(safe, "path_creation_date", `("path", "creation_date")`);
531
533
  }
532
534
  /**