open-agents-ai 0.103.71 → 0.103.73
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 +137 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -26934,6 +26934,8 @@ function renderSlashHelp() {
|
|
|
26934
26934
|
["/endpoint <url>", "Set backend URL (auto-detects type)"],
|
|
26935
26935
|
["/endpoint <url> --auth <t>", "Set endpoint with Bearer auth"],
|
|
26936
26936
|
["/config", "Show current configuration"],
|
|
26937
|
+
["/parallel", "Show current Ollama parallel inference slots"],
|
|
26938
|
+
["/parallel <1-15>", "Set parallel slots (restarts Ollama, max 15)"],
|
|
26937
26939
|
["/update", "Check for updates and auto-install"],
|
|
26938
26940
|
["/update auto", "Enable auto-update after task completion (default)"],
|
|
26939
26941
|
["/update manual", "Disable auto-update (only update on /update)"],
|
|
@@ -34092,6 +34094,9 @@ async function handleSlashCommand(input, ctx) {
|
|
|
34092
34094
|
case "ep":
|
|
34093
34095
|
await handleEndpoint(arg, ctx, hasLocal);
|
|
34094
34096
|
return "handled";
|
|
34097
|
+
case "parallel":
|
|
34098
|
+
await handleParallel(arg, ctx);
|
|
34099
|
+
return "handled";
|
|
34095
34100
|
case "update":
|
|
34096
34101
|
case "upgrade":
|
|
34097
34102
|
await handleUpdate(arg, ctx);
|
|
@@ -35515,6 +35520,137 @@ async function handlePeerEndpoint(peerId, authKey, ctx, local) {
|
|
|
35515
35520
|
renderWarning("Active task aborted \u2014 endpoint changed. Send a new prompt to continue.");
|
|
35516
35521
|
}
|
|
35517
35522
|
}
|
|
35523
|
+
async function handleParallel(arg, ctx) {
|
|
35524
|
+
const { execSync: execSync29 } = await import("node:child_process");
|
|
35525
|
+
const baseUrl = ctx.config.backendUrl || "http://localhost:11434";
|
|
35526
|
+
const isRemote = ctx.config.backendType === "nexus";
|
|
35527
|
+
if (isRemote) {
|
|
35528
|
+
renderInfo("Parallel slots are configured on the remote provider's Ollama, not locally.");
|
|
35529
|
+
renderInfo("The remote provider controls OLLAMA_NUM_PARALLEL on their end.");
|
|
35530
|
+
return;
|
|
35531
|
+
}
|
|
35532
|
+
if (!arg) {
|
|
35533
|
+
const envVal = process.env.OLLAMA_NUM_PARALLEL;
|
|
35534
|
+
let runningInfo = "";
|
|
35535
|
+
try {
|
|
35536
|
+
const psResp = await fetch(baseUrl + "/api/ps", { signal: AbortSignal.timeout(3e3) });
|
|
35537
|
+
if (psResp.ok) {
|
|
35538
|
+
const ps = await psResp.json();
|
|
35539
|
+
const models = ps.models || [];
|
|
35540
|
+
if (models.length > 0) {
|
|
35541
|
+
runningInfo = models.map((m) => ` ${c2.cyan(m.name)} \u2014 ${m.size_vram ? (m.size_vram / 1e9).toFixed(1) + " GB VRAM" : "CPU"}`).join("\n");
|
|
35542
|
+
}
|
|
35543
|
+
}
|
|
35544
|
+
} catch {
|
|
35545
|
+
}
|
|
35546
|
+
let systemdVal = "";
|
|
35547
|
+
try {
|
|
35548
|
+
const out = execSync29("systemctl show ollama.service -p Environment 2>/dev/null || true", { encoding: "utf8" });
|
|
35549
|
+
const match = out.match(/OLLAMA_NUM_PARALLEL=(\d+)/);
|
|
35550
|
+
if (match)
|
|
35551
|
+
systemdVal = match[1];
|
|
35552
|
+
} catch {
|
|
35553
|
+
}
|
|
35554
|
+
const effective = envVal || systemdVal || "1 (default)";
|
|
35555
|
+
console.log("");
|
|
35556
|
+
console.log(` ${c2.bold("Parallel Inference Slots")}`);
|
|
35557
|
+
console.log("");
|
|
35558
|
+
console.log(` ${c2.dim("OLLAMA_NUM_PARALLEL:")} ${c2.bold(c2.cyan(effective))}`);
|
|
35559
|
+
console.log(` ${c2.dim("Endpoint:")} ${baseUrl}`);
|
|
35560
|
+
if (runningInfo) {
|
|
35561
|
+
console.log(` ${c2.dim("Running models:")}`);
|
|
35562
|
+
console.log(runningInfo);
|
|
35563
|
+
}
|
|
35564
|
+
console.log("");
|
|
35565
|
+
console.log(` ${c2.dim("Set with:")} ${c2.cyan("/parallel <1-15>")}`);
|
|
35566
|
+
console.log(` ${c2.dim("Each slot multiplies context memory usage per model.")}`);
|
|
35567
|
+
console.log("");
|
|
35568
|
+
return;
|
|
35569
|
+
}
|
|
35570
|
+
const n = parseInt(arg, 10);
|
|
35571
|
+
if (isNaN(n) || n < 1 || n > 15) {
|
|
35572
|
+
renderError("Parallel slots must be between 1 and 15. Usage: /parallel <1-15>");
|
|
35573
|
+
return;
|
|
35574
|
+
}
|
|
35575
|
+
const isSystemd = (() => {
|
|
35576
|
+
try {
|
|
35577
|
+
const out = execSync29("systemctl is-active ollama.service 2>/dev/null", { encoding: "utf8" }).trim();
|
|
35578
|
+
return out === "active" || out === "inactive";
|
|
35579
|
+
} catch {
|
|
35580
|
+
return false;
|
|
35581
|
+
}
|
|
35582
|
+
})();
|
|
35583
|
+
if (isSystemd) {
|
|
35584
|
+
renderInfo(`Setting OLLAMA_NUM_PARALLEL=${n} via systemd override...`);
|
|
35585
|
+
try {
|
|
35586
|
+
const overrideDir = "/etc/systemd/system/ollama.service.d";
|
|
35587
|
+
const overrideFile = `${overrideDir}/parallel.conf`;
|
|
35588
|
+
const overrideContent = `[Service]
|
|
35589
|
+
Environment="OLLAMA_NUM_PARALLEL=${n}"
|
|
35590
|
+
`;
|
|
35591
|
+
execSync29(`sudo mkdir -p ${overrideDir}`, { stdio: "pipe" });
|
|
35592
|
+
execSync29(`echo '${overrideContent}' | sudo tee ${overrideFile} > /dev/null`, { stdio: "pipe" });
|
|
35593
|
+
execSync29("sudo systemctl daemon-reload", { stdio: "pipe" });
|
|
35594
|
+
execSync29("sudo systemctl restart ollama.service", { stdio: "pipe" });
|
|
35595
|
+
let ready = false;
|
|
35596
|
+
for (let i = 0; i < 30 && !ready; i++) {
|
|
35597
|
+
await new Promise((r) => setTimeout(r, 500));
|
|
35598
|
+
try {
|
|
35599
|
+
const resp = await fetch(baseUrl + "/api/tags", { signal: AbortSignal.timeout(2e3) });
|
|
35600
|
+
if (resp.ok)
|
|
35601
|
+
ready = true;
|
|
35602
|
+
} catch {
|
|
35603
|
+
}
|
|
35604
|
+
}
|
|
35605
|
+
if (ready) {
|
|
35606
|
+
renderInfo(`Ollama restarted with OLLAMA_NUM_PARALLEL=${n}. ${n > 4 ? "Note: memory usage scales with parallel slots." : ""}`);
|
|
35607
|
+
} else {
|
|
35608
|
+
renderWarning(`Ollama service restarted but not responding yet. Check: sudo systemctl status ollama`);
|
|
35609
|
+
}
|
|
35610
|
+
} catch (e) {
|
|
35611
|
+
renderError(`Failed to set systemd override: ${e.message || e}`);
|
|
35612
|
+
renderInfo(`Manual steps:
|
|
35613
|
+
sudo mkdir -p /etc/systemd/system/ollama.service.d
|
|
35614
|
+
echo '[Service]\\nEnvironment="OLLAMA_NUM_PARALLEL=${n}"' | sudo tee /etc/systemd/system/ollama.service.d/parallel.conf
|
|
35615
|
+
sudo systemctl daemon-reload && sudo systemctl restart ollama`);
|
|
35616
|
+
}
|
|
35617
|
+
} else {
|
|
35618
|
+
renderInfo(`Setting OLLAMA_NUM_PARALLEL=${n}...`);
|
|
35619
|
+
try {
|
|
35620
|
+
try {
|
|
35621
|
+
execSync29("pkill -f 'ollama serve' 2>/dev/null || true", { stdio: "pipe" });
|
|
35622
|
+
} catch {
|
|
35623
|
+
}
|
|
35624
|
+
await new Promise((r) => setTimeout(r, 1e3));
|
|
35625
|
+
process.env.OLLAMA_NUM_PARALLEL = String(n);
|
|
35626
|
+
const { spawn: spawn19 } = await import("node:child_process");
|
|
35627
|
+
const child = spawn19("ollama", ["serve"], {
|
|
35628
|
+
stdio: "ignore",
|
|
35629
|
+
detached: true,
|
|
35630
|
+
env: { ...process.env, OLLAMA_NUM_PARALLEL: String(n) }
|
|
35631
|
+
});
|
|
35632
|
+
child.unref();
|
|
35633
|
+
let ready = false;
|
|
35634
|
+
for (let i = 0; i < 30 && !ready; i++) {
|
|
35635
|
+
await new Promise((r) => setTimeout(r, 500));
|
|
35636
|
+
try {
|
|
35637
|
+
const resp = await fetch(baseUrl + "/api/tags", { signal: AbortSignal.timeout(2e3) });
|
|
35638
|
+
if (resp.ok)
|
|
35639
|
+
ready = true;
|
|
35640
|
+
} catch {
|
|
35641
|
+
}
|
|
35642
|
+
}
|
|
35643
|
+
if (ready) {
|
|
35644
|
+
renderInfo(`Ollama restarted with OLLAMA_NUM_PARALLEL=${n}. ${n > 4 ? "Note: memory usage scales with parallel slots." : ""}`);
|
|
35645
|
+
} else {
|
|
35646
|
+
renderWarning(`Ollama restarted but not responding yet. Try: OLLAMA_NUM_PARALLEL=${n} ollama serve`);
|
|
35647
|
+
}
|
|
35648
|
+
} catch (e) {
|
|
35649
|
+
renderError(`Failed to restart Ollama: ${e.message || e}`);
|
|
35650
|
+
renderInfo(`Set manually: OLLAMA_NUM_PARALLEL=${n} ollama serve`);
|
|
35651
|
+
}
|
|
35652
|
+
}
|
|
35653
|
+
}
|
|
35518
35654
|
async function handleUpdate(subcommand, ctx) {
|
|
35519
35655
|
const repoRoot = ctx.repoRoot;
|
|
35520
35656
|
if (subcommand === "auto") {
|
|
@@ -46730,6 +46866,7 @@ ${entry.fullContent}`
|
|
|
46730
46866
|
"ep",
|
|
46731
46867
|
"update",
|
|
46732
46868
|
"upgrade",
|
|
46869
|
+
"parallel",
|
|
46733
46870
|
"telegram",
|
|
46734
46871
|
"tg",
|
|
46735
46872
|
"call",
|
package/package.json
CHANGED