@cortex-context/cli 0.0.9 → 0.0.10
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 +90 -14
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -18220,6 +18220,67 @@ function tryFixLxcSysctl() {
|
|
|
18220
18220
|
return { applied: false };
|
|
18221
18221
|
}
|
|
18222
18222
|
}
|
|
18223
|
+
function tryConfigureCrunRuntime() {
|
|
18224
|
+
const result = {
|
|
18225
|
+
attempted: false,
|
|
18226
|
+
crunInstalled: false,
|
|
18227
|
+
daemonUpdated: false,
|
|
18228
|
+
dockerRestarted: false
|
|
18229
|
+
};
|
|
18230
|
+
if ((0, import_os3.platform)() !== "linux") return result;
|
|
18231
|
+
result.attempted = true;
|
|
18232
|
+
const hasCrun = (() => {
|
|
18233
|
+
try {
|
|
18234
|
+
(0, import_child_process.execSync)("which crun", { stdio: "ignore" });
|
|
18235
|
+
return true;
|
|
18236
|
+
} catch {
|
|
18237
|
+
return false;
|
|
18238
|
+
}
|
|
18239
|
+
})();
|
|
18240
|
+
if (hasCrun) {
|
|
18241
|
+
result.crunInstalled = true;
|
|
18242
|
+
} else {
|
|
18243
|
+
try {
|
|
18244
|
+
(0, import_child_process.execSync)("apt-get install -y crun", { stdio: "ignore" });
|
|
18245
|
+
result.crunInstalled = true;
|
|
18246
|
+
} catch (e) {
|
|
18247
|
+
result.error = `crun install: ${e instanceof Error ? e.message : String(e)}`;
|
|
18248
|
+
return result;
|
|
18249
|
+
}
|
|
18250
|
+
}
|
|
18251
|
+
const daemonPath = "/etc/docker/daemon.json";
|
|
18252
|
+
let cfg = {};
|
|
18253
|
+
try {
|
|
18254
|
+
if ((0, import_fs5.existsSync)(daemonPath)) {
|
|
18255
|
+
cfg = JSON.parse((0, import_fs5.readFileSync)(daemonPath, "utf-8"));
|
|
18256
|
+
}
|
|
18257
|
+
} catch {
|
|
18258
|
+
cfg = {};
|
|
18259
|
+
}
|
|
18260
|
+
if (cfg["default-runtime"] === "crun") {
|
|
18261
|
+
result.daemonUpdated = true;
|
|
18262
|
+
result.dockerRestarted = true;
|
|
18263
|
+
return result;
|
|
18264
|
+
}
|
|
18265
|
+
const runtimes = cfg["runtimes"] ?? {};
|
|
18266
|
+
runtimes["crun"] = { path: "/usr/bin/crun" };
|
|
18267
|
+
cfg["runtimes"] = runtimes;
|
|
18268
|
+
cfg["default-runtime"] = "crun";
|
|
18269
|
+
try {
|
|
18270
|
+
(0, import_fs5.writeFileSync)(daemonPath, JSON.stringify(cfg, null, 2) + "\n", "utf-8");
|
|
18271
|
+
result.daemonUpdated = true;
|
|
18272
|
+
} catch (e) {
|
|
18273
|
+
result.error = `daemon.json: ${e instanceof Error ? e.message : String(e)}`;
|
|
18274
|
+
return result;
|
|
18275
|
+
}
|
|
18276
|
+
try {
|
|
18277
|
+
(0, import_child_process.execSync)("systemctl restart docker", { stdio: "ignore" });
|
|
18278
|
+
result.dockerRestarted = true;
|
|
18279
|
+
} catch (e) {
|
|
18280
|
+
result.error = `docker restart: ${e instanceof Error ? e.message : String(e)}`;
|
|
18281
|
+
}
|
|
18282
|
+
return result;
|
|
18283
|
+
}
|
|
18223
18284
|
async function deployLocalStack(workspacePath, opts = {}) {
|
|
18224
18285
|
const templatePath = (0, import_path5.join)(
|
|
18225
18286
|
__dirname,
|
|
@@ -28181,6 +28242,20 @@ async function serverCommand(options) {
|
|
|
28181
28242
|
)
|
|
28182
28243
|
);
|
|
28183
28244
|
}
|
|
28245
|
+
const crunSetup = tryConfigureCrunRuntime();
|
|
28246
|
+
if (crunSetup.attempted) {
|
|
28247
|
+
if (crunSetup.dockerRestarted) {
|
|
28248
|
+
console.log(
|
|
28249
|
+
source_default.dim(
|
|
28250
|
+
" (configured crun as Docker runtime for LXC compatibility \u2014 daemon restarted)"
|
|
28251
|
+
)
|
|
28252
|
+
);
|
|
28253
|
+
} else if (crunSetup.error) {
|
|
28254
|
+
console.log(
|
|
28255
|
+
source_default.dim(` (crun setup skipped: ${crunSetup.error})`)
|
|
28256
|
+
);
|
|
28257
|
+
}
|
|
28258
|
+
}
|
|
28184
28259
|
const startSpinner = ora(" Running docker compose up -d...").start();
|
|
28185
28260
|
const startResult = await deployLocalStack(workDir, {
|
|
28186
28261
|
embeddings: options.embeddings ?? false
|
|
@@ -28195,33 +28270,34 @@ async function serverCommand(options) {
|
|
|
28195
28270
|
console.log("");
|
|
28196
28271
|
console.log(
|
|
28197
28272
|
source_default.dim(
|
|
28198
|
-
" runc >= 1.1
|
|
28273
|
+
" runc >= 1.1 writes net.ipv4.ip_unprivileged_port_start in each new"
|
|
28199
28274
|
)
|
|
28200
28275
|
);
|
|
28201
28276
|
console.log(
|
|
28202
28277
|
source_default.dim(
|
|
28203
|
-
"
|
|
28278
|
+
" Docker network namespace. Unprivileged Proxmox LXC blocks this write."
|
|
28204
28279
|
)
|
|
28205
28280
|
);
|
|
28281
|
+
console.log("");
|
|
28206
28282
|
console.log(
|
|
28207
28283
|
source_default.dim(
|
|
28208
|
-
"
|
|
28284
|
+
" Attempted automatic fix (crun) \u2014 but it was not enough."
|
|
28209
28285
|
)
|
|
28210
28286
|
);
|
|
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
28287
|
console.log(
|
|
28216
|
-
source_default.
|
|
28217
|
-
|
|
28288
|
+
source_default.dim(
|
|
28289
|
+
" Manual fix: install crun and configure Docker daemon on this LXC:"
|
|
28218
28290
|
)
|
|
28219
28291
|
);
|
|
28220
|
-
console.log(
|
|
28221
|
-
console.log(source_default.cyan("
|
|
28292
|
+
console.log("");
|
|
28293
|
+
console.log(source_default.cyan(" apt-get install -y crun"));
|
|
28294
|
+
console.log(source_default.cyan(" cat > /etc/docker/daemon.json << 'EOF'"));
|
|
28295
|
+
console.log(source_default.cyan(' {"default-runtime":"crun","runtimes":{"crun":{"path":"/usr/bin/crun"}}}'));
|
|
28296
|
+
console.log(source_default.cyan(" EOF"));
|
|
28297
|
+
console.log(source_default.cyan(" systemctl restart docker"));
|
|
28222
28298
|
console.log("");
|
|
28223
28299
|
console.log(
|
|
28224
|
-
source_default.dim(" Then run cortex-context server again
|
|
28300
|
+
source_default.dim(" Then run cortex-context server again.")
|
|
28225
28301
|
);
|
|
28226
28302
|
} else {
|
|
28227
28303
|
console.log(source_default.dim(` ${startResult.error}`));
|
|
@@ -28412,8 +28488,8 @@ async function uninstallCommand(options) {
|
|
|
28412
28488
|
if (!options.keepHook && hasHook) {
|
|
28413
28489
|
const hookPath = (0, import_path14.join)(workspacePath, ".git", "hooks", "post-commit");
|
|
28414
28490
|
try {
|
|
28415
|
-
const { readFileSync:
|
|
28416
|
-
const hookContent =
|
|
28491
|
+
const { readFileSync: readFileSync8 } = await import("fs");
|
|
28492
|
+
const hookContent = readFileSync8(hookPath, "utf-8");
|
|
28417
28493
|
if (hookContent.includes("cortex-context")) {
|
|
28418
28494
|
(0, import_fs13.unlinkSync)(hookPath);
|
|
28419
28495
|
console.log(source_default.green(" \u2713 .git/hooks/post-commit \u2014 removed"));
|