open-agents-ai 0.187.328 → 0.187.329
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 +53 -21
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -299522,23 +299522,14 @@ sleep 1
|
|
|
299522
299522
|
if (r3.ok) {
|
|
299523
299523
|
renderInfo2(`Deleted scheduled task ${task.id}`);
|
|
299524
299524
|
try {
|
|
299525
|
-
const
|
|
299526
|
-
const
|
|
299527
|
-
|
|
299528
|
-
|
|
299529
|
-
|
|
299530
|
-
|
|
299531
|
-
|
|
299532
|
-
|
|
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
|
-
});
|
|
299525
|
+
const dir = (task.file || "").split("/").slice(0, -1).join("/") || task.file;
|
|
299526
|
+
const resp = await doFetch("/v1/scheduled/kill", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ pattern: dir.replace(/[.*+?^${}()|[\]\\]/g, "\\$&") }) });
|
|
299527
|
+
try {
|
|
299528
|
+
const j = await resp.json();
|
|
299529
|
+
const cnt = (Array.isArray(j.killed) ? j.killed.length : 0) + (Array.isArray(j.additionally) ? j.additionally.length : 0);
|
|
299530
|
+
if (cnt > 0) renderInfo2(`Killed ${cnt} residual process(es).`);
|
|
299531
|
+
} catch {
|
|
299532
|
+
}
|
|
299542
299533
|
} catch {
|
|
299543
299534
|
}
|
|
299544
299535
|
done(true);
|
|
@@ -329073,6 +329064,7 @@ function deleteScheduledById(id) {
|
|
|
329073
329064
|
const json = JSON.parse(raw);
|
|
329074
329065
|
const arr = Array.isArray(json?.tasks) ? json.tasks : Array.isArray(json) ? json : [];
|
|
329075
329066
|
if (!arr[target.index]) return false;
|
|
329067
|
+
const entry = arr[target.index];
|
|
329076
329068
|
arr.splice(target.index, 1);
|
|
329077
329069
|
if (Array.isArray(json?.tasks)) {
|
|
329078
329070
|
json.tasks = arr;
|
|
@@ -329082,12 +329074,28 @@ function deleteScheduledById(id) {
|
|
|
329082
329074
|
} else {
|
|
329083
329075
|
writeFileSync45(target.file, JSON.stringify({ tasks: arr }, null, 2));
|
|
329084
329076
|
}
|
|
329077
|
+
const candidates = [];
|
|
329078
|
+
if (id) candidates.push(id);
|
|
329079
|
+
if (typeof entry?.id === "string" && entry.id && !candidates.includes(entry.id)) candidates.push(entry.id);
|
|
329085
329080
|
try {
|
|
329086
|
-
|
|
329081
|
+
const { createHash: createHash11 } = __require("node:crypto");
|
|
329082
|
+
const fallback = createHash11("sha1").update(`${target.file}#${target.index}`).digest("hex").slice(0, 16);
|
|
329083
|
+
if (!candidates.includes(fallback)) candidates.push(fallback);
|
|
329087
329084
|
} catch {
|
|
329088
329085
|
}
|
|
329086
|
+
for (const cid of candidates) {
|
|
329087
|
+
try {
|
|
329088
|
+
removeCronByMarker(cid);
|
|
329089
|
+
} catch {
|
|
329090
|
+
}
|
|
329091
|
+
try {
|
|
329092
|
+
disableUserTimerById(cid);
|
|
329093
|
+
} catch {
|
|
329094
|
+
}
|
|
329095
|
+
}
|
|
329089
329096
|
try {
|
|
329090
|
-
|
|
329097
|
+
const dir = target.file.split("/").slice(0, -1).join("/") || target.file;
|
|
329098
|
+
removeCronByDirectory(dir);
|
|
329091
329099
|
} catch {
|
|
329092
329100
|
}
|
|
329093
329101
|
return true;
|
|
@@ -329095,6 +329103,21 @@ function deleteScheduledById(id) {
|
|
|
329095
329103
|
return false;
|
|
329096
329104
|
}
|
|
329097
329105
|
}
|
|
329106
|
+
function removeCronByDirectory(dir) {
|
|
329107
|
+
try {
|
|
329108
|
+
const lines = getCurrentCrontabLines();
|
|
329109
|
+
if (!lines.length) return 0;
|
|
329110
|
+
const quoted = `cd "${dir}"`;
|
|
329111
|
+
const single = `cd '${dir}'`;
|
|
329112
|
+
const next = lines.filter((l2) => !(l2.includes(CRON_MARKER2) && (l2.includes(quoted) || l2.includes(single) || l2.includes(dir))));
|
|
329113
|
+
if (next.length !== lines.length) {
|
|
329114
|
+
writeCrontabLines(next);
|
|
329115
|
+
return lines.length - next.length;
|
|
329116
|
+
}
|
|
329117
|
+
} catch {
|
|
329118
|
+
}
|
|
329119
|
+
return 0;
|
|
329120
|
+
}
|
|
329098
329121
|
function killProcessGroups(pids, pattern) {
|
|
329099
329122
|
const killed = [];
|
|
329100
329123
|
try {
|
|
@@ -330055,9 +330078,18 @@ function removeCronByMarker(id) {
|
|
|
330055
330078
|
}
|
|
330056
330079
|
function disableUserTimerById(id) {
|
|
330057
330080
|
try {
|
|
330058
|
-
const unit = `oa-${id}.timer`;
|
|
330059
330081
|
const { execSync: es } = __require("node:child_process");
|
|
330060
|
-
|
|
330082
|
+
const names = [`oa-${id}`, `oa-sched-${id}`, id];
|
|
330083
|
+
for (const n2 of names) {
|
|
330084
|
+
try {
|
|
330085
|
+
es(`systemctl --user disable --now ${n2}.timer`, { stdio: "pipe" });
|
|
330086
|
+
} catch {
|
|
330087
|
+
}
|
|
330088
|
+
try {
|
|
330089
|
+
es(`systemctl --user stop ${n2}.service`, { stdio: "pipe" });
|
|
330090
|
+
} catch {
|
|
330091
|
+
}
|
|
330092
|
+
}
|
|
330061
330093
|
} catch {
|
|
330062
330094
|
}
|
|
330063
330095
|
}
|
package/package.json
CHANGED