nexus-agents 2.59.0 → 2.60.0

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.
@@ -0,0 +1,22 @@
1
+ // src/config/nexus-data-dir.ts
2
+ import { homedir } from "os";
3
+ import { join, resolve } from "path";
4
+ function getNexusDataDir() {
5
+ const fromEnv = process.env["NEXUS_DATA_DIR"]?.trim();
6
+ if (fromEnv !== void 0 && fromEnv !== "") {
7
+ return resolve(fromEnv);
8
+ }
9
+ return join(homedir(), ".nexus-agents");
10
+ }
11
+ function resetNexusDataDirCache() {
12
+ }
13
+ function nexusDataPath(...segments) {
14
+ return join(getNexusDataDir(), ...segments);
15
+ }
16
+
17
+ export {
18
+ getNexusDataDir,
19
+ resetNexusDataDirCache,
20
+ nexusDataPath
21
+ };
22
+ //# sourceMappingURL=chunk-FDNWRZNJ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/config/nexus-data-dir.ts"],"sourcesContent":["/**\n * Nexus runtime data directory resolver (#2302, child of #2301).\n *\n * Returns the absolute path under which nexus-agents stores all runtime\n * state — memory, learning, audit, voting, sessions, checkpoints, traces,\n * model registry. Single source of truth so portable / sandbox / CI\n * deployments can redirect state to a workspace-local folder via the\n * `NEXUS_DATA_DIR` environment variable.\n *\n * Resolution order (first match wins):\n * 1. `NEXUS_DATA_DIR` env var if set + non-empty (resolved against `cwd`).\n * 2. `<homedir>/.nexus-agents` (zero-breakage fallback).\n *\n * No caching, no filesystem walks, no discovery. The contrarian-narrowed\n * scope (#2301 vote) explicitly defers ancestor-walking to a separate\n * child with a security design pass per CVE-2022-24765. Recomputing the\n * trivial env-or-homedir lookup on each call is ~100ns and avoids cache\n * coordination issues with tests that mock `homedir()`.\n *\n * @module config/nexus-data-dir\n */\n\nimport { homedir } from 'node:os';\nimport { join, resolve } from 'node:path';\n\n/** Returns the absolute path to the nexus-agents data directory. */\nexport function getNexusDataDir(): string {\n const fromEnv = process.env['NEXUS_DATA_DIR']?.trim();\n if (fromEnv !== undefined && fromEnv !== '') {\n return resolve(fromEnv);\n }\n return join(homedir(), '.nexus-agents');\n}\n\n/**\n * No-op kept for source-compatibility with consumers that called this\n * earlier in development. The resolver is no longer cached, so resetting\n * is unnecessary. Kept exported (rather than removed) to avoid breaking\n * imports in tests that may have already adopted it.\n */\nexport function resetNexusDataDirCache(): void {\n // intentionally empty — see module docstring\n}\n\n/** Returns a path joined under the resolved data directory. */\nexport function nexusDataPath(...segments: string[]): string {\n return join(getNexusDataDir(), ...segments);\n}\n"],"mappings":";AAsBA,SAAS,eAAe;AACxB,SAAS,MAAM,eAAe;AAGvB,SAAS,kBAA0B;AACxC,QAAM,UAAU,QAAQ,IAAI,gBAAgB,GAAG,KAAK;AACpD,MAAI,YAAY,UAAa,YAAY,IAAI;AAC3C,WAAO,QAAQ,OAAO;AAAA,EACxB;AACA,SAAO,KAAK,QAAQ,GAAG,eAAe;AACxC;AAQO,SAAS,yBAA+B;AAE/C;AAGO,SAAS,iBAAiB,UAA4B;AAC3D,SAAO,KAAK,gBAAgB,GAAG,GAAG,QAAQ;AAC5C;","names":[]}
@@ -6,6 +6,9 @@ import {
6
6
  import {
7
7
  CUSTOM_API_DEFAULT_MODEL
8
8
  } from "./chunk-H43PABG4.js";
9
+ import {
10
+ nexusDataPath
11
+ } from "./chunk-FDNWRZNJ.js";
9
12
  import {
10
13
  SessionMemory
11
14
  } from "./chunk-7Y36JLES.js";
@@ -862,8 +865,8 @@ var COMPILED_PATH_PATTERNS = UNBYPASSABLE_PATH_PATTERNS.map((pattern) => ({
862
865
  pattern,
863
866
  regex: compileGlobToRegex(pattern)
864
867
  }));
865
- function isPathDenied(path4) {
866
- const normalized = path4.toLowerCase();
868
+ function isPathDenied(path3) {
869
+ const normalized = path3.toLowerCase();
867
870
  return COMPILED_PATH_PATTERNS.some((c) => c.regex.test(normalized));
868
871
  }
869
872
  function isToolDenied(toolName) {
@@ -973,8 +976,8 @@ function denyToToolResult(decision, requestId) {
973
976
  // src/security/access-constraint-deriver/chain-adapter.ts
974
977
  function toGuardArgs(args) {
975
978
  if (typeof args !== "object" || args === null) return void 0;
976
- const path4 = args["path"];
977
- return typeof path4 === "string" && path4.length > 0 ? { path: path4 } : void 0;
979
+ const path3 = args["path"];
980
+ return typeof path3 === "string" && path3.length > 0 ? { path: path3 } : void 0;
978
981
  }
979
982
  function createAccessPolicyChainMiddleware(toolName) {
980
983
  return async (args, ctx, next) => {
@@ -7863,11 +7866,9 @@ function createCorrelationTracker(config) {
7863
7866
 
7864
7867
  // src/consensus/correlation-persistence.ts
7865
7868
  import * as fs from "fs";
7866
- import * as path from "path";
7867
- import * as os from "os";
7868
7869
  import { z as z7 } from "zod";
7869
7870
  var logger5 = createLogger({ component: "correlation-persistence" });
7870
- var VOTING_DIR = path.join(".nexus-agents", "voting");
7871
+ var VOTING_SUBDIR = "voting";
7871
7872
  var CORRELATIONS_FILE = "correlations.json";
7872
7873
  var FILE_MODE = 384;
7873
7874
  var DIR_MODE = 448;
@@ -7889,10 +7890,10 @@ var PersistedCorrelationDataSchema = z7.object({
7889
7890
  savedAt: z7.iso.datetime()
7890
7891
  });
7891
7892
  function getCorrelationDataPath() {
7892
- return path.join(os.homedir(), VOTING_DIR, CORRELATIONS_FILE);
7893
+ return nexusDataPath(VOTING_SUBDIR, CORRELATIONS_FILE);
7893
7894
  }
7894
7895
  function ensureVotingDirectory() {
7895
- const dirPath = path.join(os.homedir(), VOTING_DIR);
7896
+ const dirPath = nexusDataPath(VOTING_SUBDIR);
7896
7897
  try {
7897
7898
  fs.mkdirSync(dirPath, { recursive: true, mode: DIR_MODE });
7898
7899
  return ok(void 0);
@@ -8147,8 +8148,7 @@ function buildResponse(input, result) {
8147
8148
 
8148
8149
  // src/mcp/tools/tool-memory.ts
8149
8150
  import * as fs3 from "fs";
8150
- import * as os3 from "os";
8151
- import * as path3 from "path";
8151
+ import * as path2 from "path";
8152
8152
 
8153
8153
  // src/context/belief-core-types.ts
8154
8154
  import { z as z9 } from "zod";
@@ -9338,11 +9338,11 @@ function getNextKeys(currentKey, edges, opts) {
9338
9338
  }
9339
9339
  return next;
9340
9340
  }
9341
- function buildTraversalResult(entry, depth, path4, edge) {
9341
+ function buildTraversalResult(entry, depth, path3, edge) {
9342
9342
  if (edge !== void 0) {
9343
- return { entry, depth, path: path4, edge };
9343
+ return { entry, depth, path: path3, edge };
9344
9344
  }
9345
- return { entry, depth, path: path4 };
9345
+ return { entry, depth, path: path3 };
9346
9346
  }
9347
9347
  function bfsTraverse(config) {
9348
9348
  const { db, startKey, opts } = config;
@@ -9559,8 +9559,8 @@ var GraphMemoryBackend = class {
9559
9559
  if (!memoryExists(db, to))
9560
9560
  return Promise.resolve(err(new MemoryError(`To key not found: ${to}`)));
9561
9561
  const resolved = resolveTraversalOptions(opts);
9562
- const path4 = findShortestPath(db, from, to, resolved);
9563
- return Promise.resolve(ok(path4));
9562
+ const path3 = findShortestPath(db, from, to, resolved);
9563
+ return Promise.resolve(ok(path3));
9564
9564
  } catch (error) {
9565
9565
  const cause = error instanceof Error ? error : new Error(String(error));
9566
9566
  return Promise.resolve(err(new MemoryError("Path finding failed", { cause })));
@@ -10345,8 +10345,8 @@ var AgenticMemoryBackend = class {
10345
10345
 
10346
10346
  // src/context/belief-memory-persistence.ts
10347
10347
  import * as fs2 from "fs";
10348
- import * as os2 from "os";
10349
- import * as path2 from "path";
10348
+ import * as os from "os";
10349
+ import * as path from "path";
10350
10350
 
10351
10351
  // src/context/belief-persistence-types.ts
10352
10352
  import { z as z16 } from "zod";
@@ -10424,7 +10424,7 @@ var BeliefSnapshotSchema = z16.object({
10424
10424
  });
10425
10425
 
10426
10426
  // src/context/belief-memory-persistence.ts
10427
- var BELIEFS_DIR = path2.join(os2.homedir(), ".nexus-agents", "memory", "beliefs");
10427
+ var BELIEFS_DIR = path.join(os.homedir(), ".nexus-agents", "memory", "beliefs");
10428
10428
  var MAX_SNAPSHOT_FILES = 10;
10429
10429
  var SNAPSHOT_VERSION = 1;
10430
10430
  function optProp(key, value) {
@@ -10616,7 +10616,7 @@ function enforceRetention(logger11) {
10616
10616
  const files = getSnapshotFiles();
10617
10617
  if (files.length <= MAX_SNAPSHOT_FILES) return;
10618
10618
  const toDelete = files.slice(MAX_SNAPSHOT_FILES);
10619
- for (const file of toDelete) fs2.unlinkSync(path2.join(BELIEFS_DIR, file));
10619
+ for (const file of toDelete) fs2.unlinkSync(path.join(BELIEFS_DIR, file));
10620
10620
  logger11.debug("Belief snapshot retention enforced", {
10621
10621
  kept: MAX_SNAPSHOT_FILES,
10622
10622
  deleted: toDelete.length
@@ -10633,7 +10633,7 @@ function saveBeliefSnapshot(data, logger11) {
10633
10633
  const snapshot = createSnapshot(data);
10634
10634
  const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
10635
10635
  const filename = `beliefs-${timestamp}.json`;
10636
- const filepath = path2.join(BELIEFS_DIR, filename);
10636
+ const filepath = path.join(BELIEFS_DIR, filename);
10637
10637
  fs2.writeFileSync(filepath, JSON.stringify(snapshot, null, 2), "utf-8");
10638
10638
  logger11.info("Belief memory snapshot saved", { filename, beliefs: snapshot.beliefs.length });
10639
10639
  enforceRetention(logger11);
@@ -10653,7 +10653,7 @@ function loadBeliefSnapshot(logger11) {
10653
10653
  }
10654
10654
  for (const file of files.slice(0, 3)) {
10655
10655
  try {
10656
- const filepath = path2.join(BELIEFS_DIR, file);
10656
+ const filepath = path.join(BELIEFS_DIR, file);
10657
10657
  const raw = JSON.parse(fs2.readFileSync(filepath, "utf-8"));
10658
10658
  const validation = BeliefSnapshotSchema.safeParse(raw);
10659
10659
  if (!validation.success) {
@@ -11774,13 +11774,13 @@ async function queryAdaptiveMemory(adaptive, query, keywords, limit, log) {
11774
11774
  }
11775
11775
 
11776
11776
  // src/mcp/tools/tool-memory.ts
11777
- var MEMORY_BASE = path3.join(os3.homedir(), ".nexus-agents", "memory");
11778
- var DEFAULT_MEMORY_DIR = path3.join(MEMORY_BASE, "sessions");
11779
- var AGENTIC_DB_PATH = path3.join(MEMORY_BASE, "agentic.db");
11780
- var ADAPTIVE_DB_PATH = path3.join(MEMORY_BASE, "adaptive.db");
11781
- var TYPED_DB_PATH = path3.join(MEMORY_BASE, "typed.db");
11782
- var MOBIMEM_DB_PATH = path3.join(MEMORY_BASE, "mobimem.db");
11783
- var MARKDOWN_DIR = path3.join(MEMORY_BASE, "markdown");
11777
+ var MEMORY_BASE = nexusDataPath("memory");
11778
+ var DEFAULT_MEMORY_DIR = path2.join(MEMORY_BASE, "sessions");
11779
+ var AGENTIC_DB_PATH = path2.join(MEMORY_BASE, "agentic.db");
11780
+ var ADAPTIVE_DB_PATH = path2.join(MEMORY_BASE, "adaptive.db");
11781
+ var TYPED_DB_PATH = path2.join(MEMORY_BASE, "typed.db");
11782
+ var MOBIMEM_DB_PATH = path2.join(MEMORY_BASE, "mobimem.db");
11783
+ var MARKDOWN_DIR = path2.join(MEMORY_BASE, "markdown");
11784
11784
  var sharedInstance = null;
11785
11785
  function getToolMemory(logger11) {
11786
11786
  sharedInstance ??= new ToolMemoryManager(logger11);
@@ -13228,4 +13228,4 @@ export {
13228
13228
  CONSENSUS_VOTE_OUTPUT_SCHEMA,
13229
13229
  registerConsensusVoteTool
13230
13230
  };
13231
- //# sourceMappingURL=chunk-L3NHOUEX.js.map
13231
+ //# sourceMappingURL=chunk-FEWWXGFE.js.map