@cortex-context/cli 0.0.7 → 0.0.9

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/dist/index.js CHANGED
@@ -18210,7 +18210,17 @@ var import_child_process = require("child_process");
18210
18210
  var import_fs5 = require("fs");
18211
18211
  var import_path5 = require("path");
18212
18212
  var import_os3 = require("os");
18213
- async function deployLocalStack(workspacePath) {
18213
+ function tryFixLxcSysctl() {
18214
+ try {
18215
+ (0, import_child_process.execSync)("sysctl -w net.ipv4.ip_unprivileged_port_start=0", {
18216
+ stdio: "ignore"
18217
+ });
18218
+ return { applied: true };
18219
+ } catch {
18220
+ return { applied: false };
18221
+ }
18222
+ }
18223
+ async function deployLocalStack(workspacePath, opts = {}) {
18214
18224
  const templatePath = (0, import_path5.join)(
18215
18225
  __dirname,
18216
18226
  "templates",
@@ -18224,19 +18234,29 @@ async function deployLocalStack(workspacePath) {
18224
18234
  if (!(0, import_fs5.existsSync)(destPath)) {
18225
18235
  (0, import_fs5.cpSync)(templatePath, destPath);
18226
18236
  }
18237
+ const imageTag = opts.embeddings ? "latest-embeddings" : "latest";
18238
+ const cortexImage = `ghcr.io/rodrigoroldan/cortex-context:${imageTag}`;
18227
18239
  try {
18228
18240
  (0, import_child_process.execSync)(
18229
18241
  `docker compose --project-name cortex-local -f "${destPath}" up -d`,
18230
18242
  {
18231
18243
  cwd: workspacePath,
18232
- stdio: "inherit"
18244
+ // stdout → terminal (user sees progress), stderr → captured for error detection
18245
+ stdio: ["inherit", "inherit", "pipe"],
18246
+ env: { ...process.env, CORTEX_IMAGE: cortexImage }
18233
18247
  }
18234
18248
  );
18235
18249
  return { started: true };
18236
18250
  } catch (err) {
18251
+ const stderr = err instanceof Error && "stderr" in err ? err.stderr?.toString() ?? "" : "";
18252
+ const msg = err instanceof Error ? err.message : String(err);
18253
+ const combined = stderr + msg;
18254
+ const isLxcSysctlError = combined.includes("ip_unprivileged_port_start") || combined.includes("sysctl net.ipv4");
18237
18255
  return {
18238
18256
  started: false,
18239
- error: `docker compose failed: ${err instanceof Error ? err.message : String(err)}`
18257
+ isLxcSysctlError,
18258
+ error: `docker compose failed: ${msg}${stderr ? `
18259
+ ${stderr.trim()}` : ""}`
18240
18260
  };
18241
18261
  }
18242
18262
  }
@@ -28043,6 +28063,13 @@ async function serverCommand(options) {
28043
28063
  " Installs and starts the Cortex stack (Neo4j + Cortex API) via Docker."
28044
28064
  )
28045
28065
  );
28066
+ if (options.embeddings) {
28067
+ console.log(
28068
+ source_default.dim(
28069
+ " Mode: embeddings (sentence-transformers + all-MiniLM-L6-v2 baked in, ~1.5 GB image)"
28070
+ )
28071
+ );
28072
+ }
28046
28073
  console.log("");
28047
28074
  const defaultDir = (0, import_path13.join)((0, import_os4.homedir)(), ".cortex-context");
28048
28075
  const workDir = options.dir ?? defaultDir;
@@ -28146,12 +28173,59 @@ async function serverCommand(options) {
28146
28173
  }
28147
28174
  console.log("");
28148
28175
  console.log(source_default.bold(" Step 3: Starting Cortex stack"));
28176
+ const sysctlFix = tryFixLxcSysctl();
28177
+ if (sysctlFix.applied) {
28178
+ console.log(
28179
+ source_default.dim(
28180
+ " (applied net.ipv4.ip_unprivileged_port_start=0 for LXC compatibility)"
28181
+ )
28182
+ );
28183
+ }
28149
28184
  const startSpinner = ora(" Running docker compose up -d...").start();
28150
- const startResult = await deployLocalStack(workDir);
28185
+ const startResult = await deployLocalStack(workDir, {
28186
+ embeddings: options.embeddings ?? false
28187
+ });
28151
28188
  if (!startResult.started) {
28152
- startSpinner.fail(
28153
- source_default.red(` \u2717 Docker Compose failed: ${startResult.error}`)
28154
- );
28189
+ startSpinner.fail(source_default.red(" \u2717 Docker Compose failed"));
28190
+ if (startResult.isLxcSysctlError) {
28191
+ console.log("");
28192
+ console.log(
28193
+ source_default.bold.yellow(" \u26A0 Proxmox LXC sysctl restriction detected")
28194
+ );
28195
+ console.log("");
28196
+ console.log(
28197
+ source_default.dim(
28198
+ " runc >= 1.1 tries to configure net.ipv4.ip_unprivileged_port_start"
28199
+ )
28200
+ );
28201
+ console.log(
28202
+ source_default.dim(
28203
+ " inside each container's network namespace. Proxmox LXC containers"
28204
+ )
28205
+ );
28206
+ console.log(
28207
+ source_default.dim(
28208
+ " block this unless the sysctl is explicitly allowed in the LXC config."
28209
+ )
28210
+ );
28211
+ console.log("");
28212
+ console.log(source_default.bold(" Fix (run on the Proxmox host):"));
28213
+ console.log("");
28214
+ console.log(source_default.cyan(" CTID=<your-container-id>"));
28215
+ console.log(
28216
+ source_default.cyan(
28217
+ ' echo "lxc.sysctl.net.ipv4.ip_unprivileged_port_start = 0" \\'
28218
+ )
28219
+ );
28220
+ console.log(source_default.cyan(" >> /etc/pve/lxc/${CTID}.conf"));
28221
+ console.log(source_default.cyan(" pct restart ${CTID}"));
28222
+ console.log("");
28223
+ console.log(
28224
+ source_default.dim(" Then run cortex-context server again inside the LXC.")
28225
+ );
28226
+ } else {
28227
+ console.log(source_default.dim(` ${startResult.error}`));
28228
+ }
28155
28229
  process.exit(1);
28156
28230
  }
28157
28231
  startSpinner.succeed(source_default.green(" \u2713 Containers started"));
@@ -28420,6 +28494,9 @@ function createCli() {
28420
28494
  ).option(
28421
28495
  "--skip-docker-install",
28422
28496
  "Fail instead of auto-installing Docker when it is not found"
28497
+ ).option(
28498
+ "--embeddings",
28499
+ "Use the embeddings-enabled image (includes sentence-transformers + all-MiniLM-L6-v2, ~1.5 GB)"
28423
28500
  ).action(serverCommand);
28424
28501
  program3.command("sync").description("Ingest latest git diff into the Cortex Knowledge Graph").option("--repo <path>", "Repository path (defaults to current directory)").option("--dry-run", "Show diff without sending to Cortex API").action(syncCommand);
28425
28502
  program3.command("update").description(