open-agents-ai 0.187.326 → 0.187.328
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 +108 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -299457,6 +299457,7 @@ sleep 1
|
|
|
299457
299457
|
const result = await tuiSelect({
|
|
299458
299458
|
items,
|
|
299459
299459
|
title: "Scheduled Tasks",
|
|
299460
|
+
customKeyHint: " Del delete",
|
|
299460
299461
|
onAction: (item, action) => {
|
|
299461
299462
|
if (item.key === "__kill__") return false;
|
|
299462
299463
|
const task = tasks.find((t2) => t2.id === item.key);
|
|
@@ -299505,6 +299506,52 @@ sleep 1
|
|
|
299505
299506
|
})();
|
|
299506
299507
|
return true;
|
|
299507
299508
|
},
|
|
299509
|
+
onDelete: (item, done) => {
|
|
299510
|
+
if (item.key === "__kill__") {
|
|
299511
|
+
done(false);
|
|
299512
|
+
return;
|
|
299513
|
+
}
|
|
299514
|
+
const task = tasks.find((t2) => t2.id === item.key);
|
|
299515
|
+
if (!task) {
|
|
299516
|
+
done(false);
|
|
299517
|
+
return;
|
|
299518
|
+
}
|
|
299519
|
+
(async () => {
|
|
299520
|
+
try {
|
|
299521
|
+
const r3 = await doFetch(`/v1/scheduled/${encodeURIComponent(task.id)}`, { method: "DELETE", headers: { "Content-Type": "application/json" } });
|
|
299522
|
+
if (r3.ok) {
|
|
299523
|
+
renderInfo2(`Deleted scheduled task ${task.id}`);
|
|
299524
|
+
try {
|
|
299525
|
+
const id = String(task.id || "");
|
|
299526
|
+
const unit = id.startsWith("timer:") ? id.slice(6) : "";
|
|
299527
|
+
const script = `set -e
|
|
299528
|
+
sudo -v
|
|
299529
|
+
` + (unit ? `sudo bash -lc 'systemctl disable --now "${unit}.timer" 2>/dev/null || true'
|
|
299530
|
+
sudo bash -lc 'systemctl disable --now "${unit}.service" 2>/dev/null || true'
|
|
299531
|
+
rm -f "$HOME/.config/systemd/user/${unit}.timer" "$HOME/.config/systemd/user/${unit}.service" 2>/dev/null || true
|
|
299532
|
+
systemctl --user daemon-reload || true
|
|
299533
|
+
` : `for n in oa-${id} oa-sched-${id}; do sudo bash -lc "systemctl disable --now "$n.timer" 2>/dev/null || true"; done
|
|
299534
|
+
for n in oa-${id} oa-sched-${id}; do sudo bash -lc "systemctl disable --now "$n.service" 2>/dev/null || true"; done
|
|
299535
|
+
`) + `sudo bash -lc 'crontab -l 2>/dev/null | sed '/OPEN-AGENTS-SCHEDULED:${id.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&")}/d' | crontab -' || true
|
|
299536
|
+
`;
|
|
299537
|
+
const { spawn: spawn27 } = await import("node:child_process");
|
|
299538
|
+
await new Promise((resolve40) => {
|
|
299539
|
+
const c7 = spawn27("bash", ["-lc", script], { stdio: "inherit" });
|
|
299540
|
+
c7.on("exit", () => resolve40());
|
|
299541
|
+
});
|
|
299542
|
+
} catch {
|
|
299543
|
+
}
|
|
299544
|
+
done(true);
|
|
299545
|
+
} else {
|
|
299546
|
+
renderWarning2(`Failed to delete ${task.id}`);
|
|
299547
|
+
done(false);
|
|
299548
|
+
}
|
|
299549
|
+
} catch {
|
|
299550
|
+
renderWarning2(`Failed to delete ${task.id}`);
|
|
299551
|
+
done(false);
|
|
299552
|
+
}
|
|
299553
|
+
})();
|
|
299554
|
+
},
|
|
299508
299555
|
onEnter: (item, { done }) => {
|
|
299509
299556
|
(async () => {
|
|
299510
299557
|
if (item.key === "__kill__") {
|
|
@@ -327901,7 +327948,7 @@ async function handleRequest(req2, res, ollamaUrl, verbose) {
|
|
|
327901
327948
|
if (pathname === "/v1/scheduled/kill" && method === "POST") {
|
|
327902
327949
|
const body = await parseJsonBody(req2);
|
|
327903
327950
|
const pids = Array.isArray(body?.pids) ? body.pids.filter((n2) => Number.isInteger(n2)) : void 0;
|
|
327904
|
-
const pattern = typeof body?.pattern === "string" && body.pattern.trim() ? body.pattern.trim() : "(/bin/oa|open-agents-ai|nexus-daemon|OPEN-AGENTS-SCHEDULED|oa-sched-|ollama)";
|
|
327951
|
+
const pattern = typeof body?.pattern === "string" && body.pattern.trim() ? body.pattern.trim() : "(/bin/oa\\b|open-agents-ai(.*)/dist|nexus-daemon|OPEN-AGENTS-SCHEDULED|oa-sched-|ollama)";
|
|
327905
327952
|
const timersDisabled = disableAllOaTimers();
|
|
327906
327953
|
const cronRemoved = removeAllOaCrons();
|
|
327907
327954
|
const procsBefore = listMatchingProcesses(pattern);
|
|
@@ -327965,6 +328012,32 @@ async function handleRequest(req2, res, ollamaUrl, verbose) {
|
|
|
327965
328012
|
});
|
|
327966
328013
|
return;
|
|
327967
328014
|
}
|
|
328015
|
+
if (pathname?.startsWith("/v1/scheduled/") && method === "DELETE") {
|
|
328016
|
+
const parts = pathname.split("/");
|
|
328017
|
+
const id = parts[3] ?? "";
|
|
328018
|
+
if (!id) {
|
|
328019
|
+
jsonResponse(res, 400, { error: "Missing id" });
|
|
328020
|
+
return;
|
|
328021
|
+
}
|
|
328022
|
+
let ok2 = false;
|
|
328023
|
+
if (id.startsWith("timer:")) {
|
|
328024
|
+
const name11 = id.slice("timer:".length);
|
|
328025
|
+
try {
|
|
328026
|
+
userServiceAction(`${name11}.timer`, "disable");
|
|
328027
|
+
ok2 = true;
|
|
328028
|
+
} catch {
|
|
328029
|
+
ok2 = false;
|
|
328030
|
+
}
|
|
328031
|
+
try {
|
|
328032
|
+
userServiceAction(`${name11}.timer`, "stop");
|
|
328033
|
+
} catch {
|
|
328034
|
+
}
|
|
328035
|
+
} else {
|
|
328036
|
+
ok2 = deleteScheduledById(id);
|
|
328037
|
+
}
|
|
328038
|
+
jsonResponse(res, ok2 ? 200 : 404, ok2 ? { id, deleted: true } : { error: "Not found" });
|
|
328039
|
+
return;
|
|
328040
|
+
}
|
|
327968
328041
|
if (pathname === "/v1/scheduled/reconcile" && (method === "GET" || method === "POST")) {
|
|
327969
328042
|
const body = method === "POST" ? await parseJsonBody(req2) : {};
|
|
327970
328043
|
const apply = Boolean(body?.apply);
|
|
@@ -328896,7 +328969,9 @@ function listScheduledTasks() {
|
|
|
328896
328969
|
const name11 = String(t2?.name || t2?.task || t2?.command || `task-${i2}`);
|
|
328897
328970
|
const schedule = String(t2?.schedule || t2?.cron || t2?.when || "");
|
|
328898
328971
|
const enabled2 = typeof t2?.enabled === "boolean" ? t2.enabled : true;
|
|
328899
|
-
const
|
|
328972
|
+
const realId = typeof t2?.id === "string" && t2.id ? t2.id : null;
|
|
328973
|
+
const fallbackId = createHash9("sha1").update(`${file}#${i2}`).digest("hex").slice(0, 16);
|
|
328974
|
+
const uid = realId || fallbackId;
|
|
328900
328975
|
const key = `${uid}`;
|
|
328901
328976
|
if (seen.has(key)) return;
|
|
328902
328977
|
seen.add(key);
|
|
@@ -328989,6 +329064,37 @@ function setScheduledEnabled(id, enabled2) {
|
|
|
328989
329064
|
return false;
|
|
328990
329065
|
}
|
|
328991
329066
|
}
|
|
329067
|
+
function deleteScheduledById(id) {
|
|
329068
|
+
const tasks = listScheduledTasks();
|
|
329069
|
+
const target = tasks.find((t2) => t2.id === id);
|
|
329070
|
+
if (!target) return false;
|
|
329071
|
+
try {
|
|
329072
|
+
const raw = readFileSync65(target.file, "utf-8");
|
|
329073
|
+
const json = JSON.parse(raw);
|
|
329074
|
+
const arr = Array.isArray(json?.tasks) ? json.tasks : Array.isArray(json) ? json : [];
|
|
329075
|
+
if (!arr[target.index]) return false;
|
|
329076
|
+
arr.splice(target.index, 1);
|
|
329077
|
+
if (Array.isArray(json?.tasks)) {
|
|
329078
|
+
json.tasks = arr;
|
|
329079
|
+
writeFileSync45(target.file, JSON.stringify(json, null, 2));
|
|
329080
|
+
} else if (Array.isArray(json)) {
|
|
329081
|
+
writeFileSync45(target.file, JSON.stringify(arr, null, 2));
|
|
329082
|
+
} else {
|
|
329083
|
+
writeFileSync45(target.file, JSON.stringify({ tasks: arr }, null, 2));
|
|
329084
|
+
}
|
|
329085
|
+
try {
|
|
329086
|
+
removeCronByMarker(id);
|
|
329087
|
+
} catch {
|
|
329088
|
+
}
|
|
329089
|
+
try {
|
|
329090
|
+
disableUserTimerById(id);
|
|
329091
|
+
} catch {
|
|
329092
|
+
}
|
|
329093
|
+
return true;
|
|
329094
|
+
} catch {
|
|
329095
|
+
return false;
|
|
329096
|
+
}
|
|
329097
|
+
}
|
|
328992
329098
|
function killProcessGroups(pids, pattern) {
|
|
328993
329099
|
const killed = [];
|
|
328994
329100
|
try {
|
package/package.json
CHANGED