open-agents-ai 0.187.306 → 0.187.309
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 +89 -11
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -299193,12 +299193,64 @@ The session corrections MUST become hard rules in the SKILL.md Rules section.`;
|
|
|
299193
299193
|
return "handled";
|
|
299194
299194
|
}
|
|
299195
299195
|
case "scheduler": {
|
|
299196
|
-
const
|
|
299196
|
+
const tokens = (arg || "").trim().length ? (arg || "").trim().split(/\s+/) : [];
|
|
299197
|
+
const sub = (tokens[0] || "menu").toLowerCase();
|
|
299197
299198
|
const base3 = `http://127.0.0.1:${process.env["OA_PORT"] || "11435"}`;
|
|
299198
299199
|
const doFetch = async (path5, init2) => {
|
|
299199
299200
|
const url = base3 + path5;
|
|
299200
299201
|
return await fetch(url, init2);
|
|
299201
299202
|
};
|
|
299203
|
+
if (sub === "menu") {
|
|
299204
|
+
try {
|
|
299205
|
+
const r2 = await doFetch("/v1/scheduled");
|
|
299206
|
+
const d2 = await r2.json();
|
|
299207
|
+
const tasks = Array.isArray(d2.tasks) ? d2.tasks : [];
|
|
299208
|
+
if (!tasks.length) {
|
|
299209
|
+
renderInfo2("No scheduled tasks found.");
|
|
299210
|
+
return "handled";
|
|
299211
|
+
}
|
|
299212
|
+
const items = tasks.map((t2) => ({
|
|
299213
|
+
key: t2.id,
|
|
299214
|
+
label: `${t2.enabled ? "●" : "○"} ${t2.name || "(task)"} ${t2.schedule ? "[" + t2.schedule + "]" : ""}`,
|
|
299215
|
+
detail: `${t2.file}#${t2.index}`
|
|
299216
|
+
}));
|
|
299217
|
+
items.push({ key: "__kill__", label: "Kill OA schedulers", detail: "Stop scheduler/nexus background processes" });
|
|
299218
|
+
const result = await tuiSelect({
|
|
299219
|
+
items,
|
|
299220
|
+
title: "Scheduled Tasks",
|
|
299221
|
+
onEnter: (item, { done }) => {
|
|
299222
|
+
(async () => {
|
|
299223
|
+
if (item.key === "__kill__") {
|
|
299224
|
+
await doFetch("/v1/scheduled/kill", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({}) });
|
|
299225
|
+
renderInfo2("Kill signal sent to OA scheduler processes.");
|
|
299226
|
+
done();
|
|
299227
|
+
return;
|
|
299228
|
+
}
|
|
299229
|
+
const task = tasks.find((t2) => t2.id === item.key);
|
|
299230
|
+
if (!task) {
|
|
299231
|
+
done();
|
|
299232
|
+
return;
|
|
299233
|
+
}
|
|
299234
|
+
const next = !task.enabled;
|
|
299235
|
+
const rr = await doFetch(`/v1/scheduled/${encodeURIComponent(task.id)}`, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ enabled: next }) });
|
|
299236
|
+
if (rr.ok) {
|
|
299237
|
+
task.enabled = next;
|
|
299238
|
+
item.label = `${next ? "●" : "○"} ${task.name || "(task)"} ${task.schedule ? "[" + task.schedule + "]" : ""}`;
|
|
299239
|
+
renderInfo2(`${next ? "Enabled" : "Disabled"} ${task.id}`);
|
|
299240
|
+
} else {
|
|
299241
|
+
renderWarning2(`Failed to toggle ${task.id}`);
|
|
299242
|
+
}
|
|
299243
|
+
done();
|
|
299244
|
+
})();
|
|
299245
|
+
return true;
|
|
299246
|
+
}
|
|
299247
|
+
});
|
|
299248
|
+
void result;
|
|
299249
|
+
} catch (e2) {
|
|
299250
|
+
renderError2(e2?.message || String(e2));
|
|
299251
|
+
}
|
|
299252
|
+
return "handled";
|
|
299253
|
+
}
|
|
299202
299254
|
if (sub === "list") {
|
|
299203
299255
|
try {
|
|
299204
299256
|
const r2 = await doFetch("/v1/scheduled");
|
|
@@ -299217,8 +299269,8 @@ The session corrections MUST become hard rules in the SKILL.md Rules section.`;
|
|
|
299217
299269
|
}
|
|
299218
299270
|
return "handled";
|
|
299219
299271
|
}
|
|
299220
|
-
if ((sub === "enable" || sub === "disable") &&
|
|
299221
|
-
const id =
|
|
299272
|
+
if ((sub === "enable" || sub === "disable") && tokens[1]) {
|
|
299273
|
+
const id = tokens[1];
|
|
299222
299274
|
try {
|
|
299223
299275
|
const r2 = await doFetch(`/v1/scheduled/${encodeURIComponent(id)}`, { method: "POST", body: JSON.stringify({ enabled: sub === "enable" }), headers: { "Content-Type": "application/json" } });
|
|
299224
299276
|
if (r2.ok) renderInfo2(`${sub}d ${id}`);
|
|
@@ -328350,18 +328402,44 @@ function killScheduledProcesses(pids, pattern) {
|
|
|
328350
328402
|
const killed = [];
|
|
328351
328403
|
try {
|
|
328352
328404
|
const { execSync: es } = __require("node:child_process");
|
|
328405
|
+
const targets = /* @__PURE__ */ new Set();
|
|
328353
328406
|
if (pids && pids.length > 0) {
|
|
328354
|
-
for (const pid of pids)
|
|
328355
|
-
|
|
328356
|
-
|
|
328357
|
-
|
|
328358
|
-
|
|
328359
|
-
|
|
328407
|
+
for (const pid of pids) if (Number.isInteger(pid)) targets.add(pid);
|
|
328408
|
+
} else {
|
|
328409
|
+
try {
|
|
328410
|
+
const ps = es("ps -eo pid,command", { encoding: "utf8", stdio: "pipe" });
|
|
328411
|
+
const re = new RegExp(pattern, "i");
|
|
328412
|
+
for (const line of ps.split("\n")) {
|
|
328413
|
+
const m2 = line.trim().match(/^(\d+)\s+(.*)$/);
|
|
328414
|
+
if (!m2) continue;
|
|
328415
|
+
const pid = parseInt(m2[1], 10);
|
|
328416
|
+
const cmd = m2[2] || "";
|
|
328417
|
+
if (!isFinite(pid)) continue;
|
|
328418
|
+
if (re.test(cmd)) targets.add(pid);
|
|
328360
328419
|
}
|
|
328420
|
+
} catch {
|
|
328361
328421
|
}
|
|
328362
|
-
}
|
|
328422
|
+
}
|
|
328423
|
+
for (const pid of targets) {
|
|
328363
328424
|
try {
|
|
328364
|
-
|
|
328425
|
+
process.kill(pid, "SIGTERM");
|
|
328426
|
+
killed.push({ pid, ok: true, signal: "TERM" });
|
|
328427
|
+
} catch {
|
|
328428
|
+
killed.push({ pid, ok: false, signal: "TERM" });
|
|
328429
|
+
}
|
|
328430
|
+
}
|
|
328431
|
+
const start2 = Date.now();
|
|
328432
|
+
while (Date.now() - start2 < 500) {
|
|
328433
|
+
}
|
|
328434
|
+
for (const pid of targets) {
|
|
328435
|
+
try {
|
|
328436
|
+
process.kill(pid, 0);
|
|
328437
|
+
try {
|
|
328438
|
+
process.kill(pid, "SIGKILL");
|
|
328439
|
+
killed.push({ pid, ok: true, signal: "KILL" });
|
|
328440
|
+
} catch {
|
|
328441
|
+
killed.push({ pid, ok: false, signal: "KILL" });
|
|
328442
|
+
}
|
|
328365
328443
|
} catch {
|
|
328366
328444
|
}
|
|
328367
328445
|
}
|
package/package.json
CHANGED