open-agents-ai 0.187.325 → 0.187.327
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 +79 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -299423,9 +299423,17 @@ sleep 1
|
|
|
299423
299423
|
const tokens = (arg || "").trim().length ? (arg || "").trim().split(/\s+/) : [];
|
|
299424
299424
|
const sub = (tokens[0] || "menu").toLowerCase();
|
|
299425
299425
|
const base3 = `http://127.0.0.1:${process.env["OA_PORT"] || "11435"}`;
|
|
299426
|
+
const defaultHeaders = () => {
|
|
299427
|
+
const h = {};
|
|
299428
|
+
const token = process.env["OA_API_KEY"] || "";
|
|
299429
|
+
if (token) h["Authorization"] = `Bearer ${token}`;
|
|
299430
|
+
return h;
|
|
299431
|
+
};
|
|
299426
299432
|
const doFetch = async (path5, init2) => {
|
|
299427
299433
|
const url = base3 + path5;
|
|
299428
|
-
|
|
299434
|
+
const merged = init2 || {};
|
|
299435
|
+
merged.headers = { ...defaultHeaders(), ...init2?.headers || {} };
|
|
299436
|
+
return await fetch(url, merged);
|
|
299429
299437
|
};
|
|
299430
299438
|
if (sub === "menu") {
|
|
299431
299439
|
try {
|
|
@@ -299449,6 +299457,7 @@ sleep 1
|
|
|
299449
299457
|
const result = await tuiSelect({
|
|
299450
299458
|
items,
|
|
299451
299459
|
title: "Scheduled Tasks",
|
|
299460
|
+
customKeyHint: " Del delete",
|
|
299452
299461
|
onAction: (item, action) => {
|
|
299453
299462
|
if (item.key === "__kill__") return false;
|
|
299454
299463
|
const task = tasks.find((t2) => t2.id === item.key);
|
|
@@ -299497,6 +299506,32 @@ sleep 1
|
|
|
299497
299506
|
})();
|
|
299498
299507
|
return true;
|
|
299499
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
|
+
done(true);
|
|
299525
|
+
} else {
|
|
299526
|
+
renderWarning2(`Failed to delete ${task.id}`);
|
|
299527
|
+
done(false);
|
|
299528
|
+
}
|
|
299529
|
+
} catch {
|
|
299530
|
+
renderWarning2(`Failed to delete ${task.id}`);
|
|
299531
|
+
done(false);
|
|
299532
|
+
}
|
|
299533
|
+
})();
|
|
299534
|
+
},
|
|
299500
299535
|
onEnter: (item, { done }) => {
|
|
299501
299536
|
(async () => {
|
|
299502
299537
|
if (item.key === "__kill__") {
|
|
@@ -327893,7 +327928,7 @@ async function handleRequest(req2, res, ollamaUrl, verbose) {
|
|
|
327893
327928
|
if (pathname === "/v1/scheduled/kill" && method === "POST") {
|
|
327894
327929
|
const body = await parseJsonBody(req2);
|
|
327895
327930
|
const pids = Array.isArray(body?.pids) ? body.pids.filter((n2) => Number.isInteger(n2)) : void 0;
|
|
327896
|
-
const pattern = typeof body?.pattern === "string" && body.pattern.trim() ? body.pattern.trim() : "(/bin/oa|open-agents-ai|nexus-daemon|OPEN-AGENTS-SCHEDULED|ollama)";
|
|
327931
|
+
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)";
|
|
327897
327932
|
const timersDisabled = disableAllOaTimers();
|
|
327898
327933
|
const cronRemoved = removeAllOaCrons();
|
|
327899
327934
|
const procsBefore = listMatchingProcesses(pattern);
|
|
@@ -327957,6 +327992,17 @@ async function handleRequest(req2, res, ollamaUrl, verbose) {
|
|
|
327957
327992
|
});
|
|
327958
327993
|
return;
|
|
327959
327994
|
}
|
|
327995
|
+
if (pathname?.startsWith("/v1/scheduled/") && method === "DELETE") {
|
|
327996
|
+
const parts = pathname.split("/");
|
|
327997
|
+
const id = parts[3] ?? "";
|
|
327998
|
+
if (!id) {
|
|
327999
|
+
jsonResponse(res, 400, { error: "Missing id" });
|
|
328000
|
+
return;
|
|
328001
|
+
}
|
|
328002
|
+
const ok2 = deleteScheduledById(id);
|
|
328003
|
+
jsonResponse(res, ok2 ? 200 : 404, ok2 ? { id, deleted: true } : { error: "Not found" });
|
|
328004
|
+
return;
|
|
328005
|
+
}
|
|
327960
328006
|
if (pathname === "/v1/scheduled/reconcile" && (method === "GET" || method === "POST")) {
|
|
327961
328007
|
const body = method === "POST" ? await parseJsonBody(req2) : {};
|
|
327962
328008
|
const apply = Boolean(body?.apply);
|
|
@@ -328981,6 +329027,37 @@ function setScheduledEnabled(id, enabled2) {
|
|
|
328981
329027
|
return false;
|
|
328982
329028
|
}
|
|
328983
329029
|
}
|
|
329030
|
+
function deleteScheduledById(id) {
|
|
329031
|
+
const tasks = listScheduledTasks();
|
|
329032
|
+
const target = tasks.find((t2) => t2.id === id);
|
|
329033
|
+
if (!target) return false;
|
|
329034
|
+
try {
|
|
329035
|
+
const raw = readFileSync65(target.file, "utf-8");
|
|
329036
|
+
const json = JSON.parse(raw);
|
|
329037
|
+
const arr = Array.isArray(json?.tasks) ? json.tasks : Array.isArray(json) ? json : [];
|
|
329038
|
+
if (!arr[target.index]) return false;
|
|
329039
|
+
arr.splice(target.index, 1);
|
|
329040
|
+
if (Array.isArray(json?.tasks)) {
|
|
329041
|
+
json.tasks = arr;
|
|
329042
|
+
writeFileSync45(target.file, JSON.stringify(json, null, 2));
|
|
329043
|
+
} else if (Array.isArray(json)) {
|
|
329044
|
+
writeFileSync45(target.file, JSON.stringify(arr, null, 2));
|
|
329045
|
+
} else {
|
|
329046
|
+
writeFileSync45(target.file, JSON.stringify({ tasks: arr }, null, 2));
|
|
329047
|
+
}
|
|
329048
|
+
try {
|
|
329049
|
+
removeCronByMarker(id);
|
|
329050
|
+
} catch {
|
|
329051
|
+
}
|
|
329052
|
+
try {
|
|
329053
|
+
disableUserTimerById(id);
|
|
329054
|
+
} catch {
|
|
329055
|
+
}
|
|
329056
|
+
return true;
|
|
329057
|
+
} catch {
|
|
329058
|
+
return false;
|
|
329059
|
+
}
|
|
329060
|
+
}
|
|
328984
329061
|
function killProcessGroups(pids, pattern) {
|
|
328985
329062
|
const killed = [];
|
|
328986
329063
|
try {
|
package/package.json
CHANGED