@yemi33/minions 0.1.28 → 0.1.29
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/CHANGELOG.md +5 -0
- package/dashboard.js +29 -17
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dashboard.js
CHANGED
|
@@ -596,6 +596,7 @@ function jsonReply(res, code, data, req) {
|
|
|
596
596
|
*/
|
|
597
597
|
function cleanDispatchEntries(matchFn) {
|
|
598
598
|
const dispatchPath = path.join(MINIONS_DIR, 'engine', 'dispatch.json');
|
|
599
|
+
const engineDir = path.join(MINIONS_DIR, 'engine');
|
|
599
600
|
try {
|
|
600
601
|
let removed = 0;
|
|
601
602
|
mutateJsonFileLocked(dispatchPath, (dispatch) => {
|
|
@@ -606,16 +607,18 @@ function cleanDispatchEntries(matchFn) {
|
|
|
606
607
|
const before = dispatch[queue].length;
|
|
607
608
|
if (queue === 'active') {
|
|
608
609
|
for (const d of dispatch[queue]) {
|
|
609
|
-
if (matchFn(d)
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
}
|
|
610
|
+
if (!matchFn(d)) continue;
|
|
611
|
+
// Kill the running agent process via PID file
|
|
612
|
+
const pidFile = path.join(engineDir, `pid-${d.id}.pid`);
|
|
613
|
+
try {
|
|
614
|
+
const pid = parseInt(fs.readFileSync(pidFile, 'utf8').trim());
|
|
615
|
+
if (pid) process.kill(pid, 'SIGTERM');
|
|
616
|
+
} catch {}
|
|
617
|
+
try { fs.unlinkSync(pidFile); } catch {}
|
|
618
|
+
// Clean up temp prompt files
|
|
619
|
+
try { fs.unlinkSync(path.join(engineDir, 'tmp', `prompt-${d.id}.md`)); } catch {}
|
|
620
|
+
try { fs.unlinkSync(path.join(engineDir, 'tmp', `sysprompt-${d.id}.md`)); } catch {}
|
|
621
|
+
try { fs.unlinkSync(path.join(engineDir, 'tmp', `sysprompt-${d.id}.md.tmp`)); } catch {}
|
|
619
622
|
}
|
|
620
623
|
}
|
|
621
624
|
dispatch[queue] = dispatch[queue].filter(d => !matchFn(d));
|
|
@@ -814,15 +817,24 @@ const server = http.createServer(async (req, res) => {
|
|
|
814
817
|
safeWrite(wiPath, items);
|
|
815
818
|
|
|
816
819
|
// Clean dispatch entries + kill running agent
|
|
817
|
-
const
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
d.meta?.dispatchKey === dispatchKey ||
|
|
821
|
-
(d.meta?.parentKey && d.meta.parentKey === dispatchKey) ||
|
|
822
|
-
d.meta?.item?.id === id
|
|
820
|
+
const dispatchRemoved = cleanDispatchEntries(d =>
|
|
821
|
+
d.meta?.item?.id === id ||
|
|
822
|
+
d.meta?.dispatchKey?.endsWith(id)
|
|
823
823
|
);
|
|
824
824
|
|
|
825
|
-
|
|
825
|
+
// Clean cooldown entries so item can be re-created immediately
|
|
826
|
+
try {
|
|
827
|
+
const cooldownPath = path.join(MINIONS_DIR, 'engine', 'cooldowns.json');
|
|
828
|
+
const cooldowns = JSON.parse(safeRead(cooldownPath) || '{}');
|
|
829
|
+
let cleaned = false;
|
|
830
|
+
for (const key of Object.keys(cooldowns)) {
|
|
831
|
+
if (key.includes(id)) { delete cooldowns[key]; cleaned = true; }
|
|
832
|
+
}
|
|
833
|
+
if (cleaned) safeWrite(cooldownPath, cooldowns);
|
|
834
|
+
} catch {}
|
|
835
|
+
|
|
836
|
+
invalidateStatusCache();
|
|
837
|
+
return jsonReply(res, 200, { ok: true, id, dispatchRemoved });
|
|
826
838
|
} catch (e) { return jsonReply(res, 400, { error: e.message }); }
|
|
827
839
|
}
|
|
828
840
|
|
package/package.json
CHANGED