open-agents-ai 0.187.321 → 0.187.322

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.
Files changed (2) hide show
  1. package/dist/index.js +86 -25
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -327818,26 +327818,42 @@ async function handleRequest(req2, res, ollamaUrl, verbose) {
327818
327818
  const body = await parseJsonBody(req2);
327819
327819
  const pids = Array.isArray(body?.pids) ? body.pids.filter((n2) => Number.isInteger(n2)) : void 0;
327820
327820
  const pattern = typeof body?.pattern === "string" && body.pattern.trim() ? body.pattern.trim() : "(/bin/oa|open-agents-ai|nexus-daemon|OPEN-AGENTS-SCHEDULED|ollama)";
327821
+ const timersDisabled = disableAllOaTimers();
327822
+ const cronRemoved = removeAllOaCrons();
327821
327823
  const procsBefore = listMatchingProcesses(pattern);
327822
327824
  const gpuBefore = sampleGpuUtil();
327823
- const killed = killScheduledProcesses(pids, pattern);
327825
+ const killed = killProcessGroups(pids, pattern);
327824
327826
  const additionally = [];
327825
327827
  try {
327826
327828
  for (const [rid, child] of Array.from(runningProcesses.entries())) {
327827
327829
  const pid = child?.pid ?? 0;
327828
327830
  if (pid > 0) {
327829
327831
  try {
327830
- process.kill(pid, "SIGTERM");
327831
- additionally.push({ pid, ok: true, signal: "TERM", run_id: rid });
327832
+ process.kill(-child.pid, "SIGTERM");
327833
+ additionally.push({ pid, ok: true, signal: "PGRP-TERM", run_id: rid });
327834
+ } catch {
327835
+ try {
327836
+ process.kill(pid, "SIGTERM");
327837
+ additionally.push({ pid, ok: true, signal: "TERM", run_id: rid });
327838
+ } catch {
327839
+ additionally.push({ pid, ok: false, signal: "TERM", run_id: rid });
327840
+ }
327841
+ }
327842
+ try {
327843
+ await new Promise((r2) => setTimeout(r2, 250));
327832
327844
  } catch {
327833
- additionally.push({ pid, ok: false, signal: "TERM", run_id: rid });
327834
327845
  }
327835
327846
  try {
327836
327847
  process.kill(pid, 0);
327837
327848
  try {
327838
- process.kill(pid, "SIGKILL");
327839
- additionally.push({ pid, ok: true, signal: "KILL", run_id: rid });
327849
+ process.kill(-child.pid, "SIGKILL");
327850
+ additionally.push({ pid, ok: true, signal: "PGRP-KILL", run_id: rid });
327840
327851
  } catch {
327852
+ try {
327853
+ process.kill(pid, "SIGKILL");
327854
+ additionally.push({ pid, ok: true, signal: "KILL", run_id: rid });
327855
+ } catch {
327856
+ }
327841
327857
  }
327842
327858
  } catch {
327843
327859
  }
@@ -327847,12 +327863,14 @@ async function handleRequest(req2, res, ollamaUrl, verbose) {
327847
327863
  } catch {
327848
327864
  }
327849
327865
  try {
327850
- await new Promise((r2) => setTimeout(r2, 600));
327866
+ await new Promise((r2) => setTimeout(r2, 800));
327851
327867
  } catch {
327852
327868
  }
327853
327869
  const procsAfter = listMatchingProcesses(pattern);
327854
327870
  const gpuAfter = sampleGpuUtil();
327855
327871
  jsonResponse(res, 200, {
327872
+ timers_disabled: timersDisabled,
327873
+ cron_lines_removed: cronRemoved,
327856
327874
  killed_count: killed.length + additionally.length,
327857
327875
  killed,
327858
327876
  additionally,
@@ -328887,47 +328905,59 @@ function setScheduledEnabled(id, enabled2) {
328887
328905
  return false;
328888
328906
  }
328889
328907
  }
328890
- function killScheduledProcesses(pids, pattern) {
328908
+ function killProcessGroups(pids, pattern) {
328891
328909
  const killed = [];
328892
328910
  try {
328893
328911
  const { execSync: es } = __require("node:child_process");
328894
- const targets = /* @__PURE__ */ new Set();
328912
+ const targets = /* @__PURE__ */ new Map();
328895
328913
  if (pids && pids.length > 0) {
328896
- for (const pid of pids) if (Number.isInteger(pid)) targets.add(pid);
328914
+ for (const pid of pids) {
328915
+ try {
328916
+ const out = es(`ps -o pgid= -p ${pid}`, { encoding: "utf8", stdio: "pipe" }).trim();
328917
+ const pg = parseInt(out, 10);
328918
+ if (pg > 0) targets.set(pid, pg);
328919
+ } catch {
328920
+ }
328921
+ }
328897
328922
  } else {
328898
328923
  try {
328899
- const ps = es("ps -eo pid,command", { encoding: "utf8", stdio: "pipe" });
328924
+ const ps = es("ps -eo pid,pgid,command", { encoding: "utf8", stdio: "pipe" });
328900
328925
  const re = new RegExp(pattern, "i");
328901
328926
  for (const line of ps.split("\n")) {
328902
- const m2 = line.trim().match(/^(\d+)\s+(.*)$/);
328927
+ const m2 = line.trim().match(/^(\d+)\s+(\d+)\s+(.+)$/);
328903
328928
  if (!m2) continue;
328904
328929
  const pid = parseInt(m2[1], 10);
328905
- const cmd = m2[2] || "";
328906
- if (!isFinite(pid)) continue;
328907
- if (re.test(cmd)) targets.add(pid);
328930
+ const pg = parseInt(m2[2], 10);
328931
+ const cmd = m2[3] || "";
328932
+ if (!isFinite(pid) || !isFinite(pg)) continue;
328933
+ if (!re.test(cmd)) continue;
328934
+ targets.set(pid, pg);
328908
328935
  }
328909
328936
  } catch {
328910
328937
  }
328911
328938
  }
328912
- for (const pid of targets) {
328939
+ const seenPg = /* @__PURE__ */ new Set();
328940
+ for (const [, pg] of targets) {
328941
+ if (seenPg.has(pg)) continue;
328942
+ seenPg.add(pg);
328913
328943
  try {
328914
- process.kill(pid, "SIGTERM");
328915
- killed.push({ pid, ok: true, signal: "TERM" });
328944
+ process.kill(-pg, "SIGTERM");
328945
+ killed.push({ pid: -pg, ok: true, signal: "PGRP-TERM" });
328916
328946
  } catch {
328917
- killed.push({ pid, ok: false, signal: "TERM" });
328947
+ killed.push({ pid: -pg, ok: false, signal: "PGRP-TERM" });
328918
328948
  }
328919
328949
  }
328920
328950
  const start2 = Date.now();
328921
- while (Date.now() - start2 < 500) {
328951
+ while (Date.now() - start2 < 600) {
328922
328952
  }
328923
- for (const pid of targets) {
328953
+ for (const pg of seenPg) {
328924
328954
  try {
328925
- process.kill(pid, 0);
328955
+ process.kill(-pg, 0);
328926
328956
  try {
328927
- process.kill(pid, "SIGKILL");
328928
- killed.push({ pid, ok: true, signal: "KILL" });
328957
+ process.kill(-pg, "SIGKILL");
328958
+ killed.push({ pid: -pg, ok: true, signal: "PGRP-KILL" });
328929
328959
  } catch {
328930
- killed.push({ pid, ok: false, signal: "KILL" });
328960
+ killed.push({ pid: -pg, ok: false, signal: "PGRP-KILL" });
328931
328961
  }
328932
328962
  } catch {
328933
328963
  }
@@ -328936,6 +328966,37 @@ function killScheduledProcesses(pids, pattern) {
328936
328966
  }
328937
328967
  return killed;
328938
328968
  }
328969
+ function disableAllOaTimers() {
328970
+ let disabled = 0;
328971
+ try {
328972
+ const timers = listOaUserTimers();
328973
+ for (const t2 of timers) {
328974
+ try {
328975
+ userServiceAction(`${t2.name}.timer`, "disable");
328976
+ disabled++;
328977
+ } catch {
328978
+ }
328979
+ try {
328980
+ userServiceAction(`${t2.name}.timer`, "stop");
328981
+ } catch {
328982
+ }
328983
+ }
328984
+ } catch {
328985
+ }
328986
+ return disabled;
328987
+ }
328988
+ function removeAllOaCrons() {
328989
+ try {
328990
+ const lines = getCurrentCrontabLines();
328991
+ const next = lines.filter((l2) => !l2.includes(CRON_MARKER2));
328992
+ if (next.length !== lines.length) {
328993
+ writeCrontabLines(next);
328994
+ return lines.length - next.length;
328995
+ }
328996
+ } catch {
328997
+ }
328998
+ return 0;
328999
+ }
328939
329000
  function listMatchingProcesses(pattern) {
328940
329001
  const list = [];
328941
329002
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "open-agents-ai",
3
- "version": "0.187.321",
3
+ "version": "0.187.322",
4
4
  "description": "AI coding agent powered by open-source models (Ollama/vLLM) — interactive TUI with agentic tool-calling loop",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",