@yemi33/minions 0.1.409 → 0.1.411

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 CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.411 (2026-04-06)
4
+
5
+ ### Fixes
6
+ - steering messages retry instead of being silently dropped
7
+
8
+ ### Other
9
+ - refactor: simplify steering — remove redundant session read, fix TOCTOU
10
+
3
11
  ## 0.1.409 (2026-04-06)
4
12
 
5
13
  ### Fixes
package/engine/cli.js CHANGED
@@ -149,8 +149,8 @@ const commands = {
149
149
  if (agentPid && agentPid > 0) {
150
150
  try {
151
151
  if (process.platform === 'win32') {
152
- const out = exec(`tasklist /FI "PID eq ${agentPid}" /NH`, { encoding: 'utf8', timeout: 3000 });
153
- if (!out.includes(String(agentPid))) agentPid = null;
152
+ const out = exec(`tasklist /FI "PID eq ${agentPid}" /NH`, { encoding: 'utf8', timeout: 3000 }).trim();
153
+ if (!new RegExp(`\\b${agentPid}\\b`).test(out)) agentPid = null;
154
154
  } else {
155
155
  process.kill(agentPid, 0);
156
156
  }
@@ -158,7 +158,13 @@ const commands = {
158
158
  }
159
159
 
160
160
  if (agentPid) {
161
- e.activeProcesses.set(item.id, { proc: { pid: agentPid > 0 ? agentPid : null }, agentId, startedAt: item.created_at, reattached: true });
161
+ // Load sessionId from session.json for steering support
162
+ let sessionId = null;
163
+ try {
164
+ const sj = safeJson(path.join(AGENTS_DIR, agentId, 'session.json'));
165
+ if (sj?.sessionId) sessionId = sj.sessionId;
166
+ } catch {}
167
+ e.activeProcesses.set(item.id, { proc: { pid: agentPid > 0 ? agentPid : null }, agentId, startedAt: item.created_at, reattached: true, sessionId });
162
168
  // Sync work item status to dispatched — direct file write to avoid lifecycle lazy init issues
163
169
  if (item.meta?.item?.id && item.meta?.project?.localPath) {
164
170
  try {
package/engine/timeout.js CHANGED
@@ -58,18 +58,24 @@ function checkSteering(config) {
58
58
  const activeProcesses = engine().activeProcesses;
59
59
  for (const [id, info] of activeProcesses) {
60
60
  const steerPath = path.join(AGENTS_DIR, info.agentId, 'steer.md');
61
- if (!fs.existsSync(steerPath)) continue;
62
-
63
- const message = safeRead(steerPath);
64
- try { fs.unlinkSync(steerPath); } catch { /* cleanup */ }
65
- if (!message) continue;
61
+ let steerMtime;
62
+ try { steerMtime = fs.statSync(steerPath).mtimeMs; } catch { continue; } // ENOENT = no steering message
66
63
 
67
64
  const sessionId = info.sessionId;
68
65
  if (!sessionId) {
69
- log('warn', `Steering: no sessionId for ${info.agentId} cannot resume. Message dropped.`);
66
+ // No sessionId yetcheck stale (>5 min means it'll never arrive)
67
+ if (Date.now() - steerMtime > 300000) {
68
+ log('warn', `Steering: no sessionId for ${info.agentId} after 5m — deleting stale message`);
69
+ try { fs.unlinkSync(steerPath); } catch {}
70
+ }
71
+ // Leave steer.md in place — retry next tick when sessionId may be available
70
72
  continue;
71
73
  }
72
74
 
75
+ const message = safeRead(steerPath);
76
+ try { fs.unlinkSync(steerPath); } catch { /* cleanup */ }
77
+ if (!message) continue;
78
+
73
79
  log('info', `Steering: killing ${info.agentId} (${id}) for session resume with human message`);
74
80
 
75
81
  // Kill current process
package/engine.js CHANGED
@@ -462,12 +462,14 @@ function spawnAgent(dispatchItem, config) {
462
462
  }
463
463
 
464
464
  // Session resume: reuse last session if same branch and recent enough (< 2 hours)
465
+ let cachedSessionId = null;
465
466
  // Only resume when the context is relevant — same branch means the agent is
466
467
  // continuing work on the same PR/feature (e.g., author fixing their own build failure)
467
468
  if (!agentId.startsWith('temp-')) {
468
469
  try {
469
470
  const sessionFile = safeJson(path.join(AGENTS_DIR, agentId, 'session.json'));
470
471
  if (sessionFile?.sessionId && sessionFile.savedAt) {
472
+ cachedSessionId = sessionFile.sessionId;
471
473
  const sessionAge = Date.now() - new Date(sessionFile.savedAt).getTime();
472
474
  const sameBranch = branchName && sessionFile.branch && sessionFile.branch === branchName;
473
475
  if (sessionAge < 2 * 60 * 60 * 1000 && sameBranch) {
@@ -655,10 +657,12 @@ function spawnAgent(dispatchItem, config) {
655
657
  }
656
658
 
657
659
  // Parse output and run all post-completion hooks
658
- const { resultSummary } = runPostCompletionHooks(dispatchItem, agentId, code, stdout, config);
660
+ const { resultSummary, autoRecovered } = runPostCompletionHooks(dispatchItem, agentId, code, stdout, config);
659
661
 
660
662
  // Move from active to completed in dispatch (single source of truth for agent status)
661
- completeDispatch(id, code === 0 ? DISPATCH_RESULT.SUCCESS : DISPATCH_RESULT.ERROR, '', resultSummary);
663
+ // autoRecovered: agent failed (e.g. heartbeat timeout) but created PRs treat as success
664
+ const effectiveResult = (code === 0 || autoRecovered) ? DISPATCH_RESULT.SUCCESS : DISPATCH_RESULT.ERROR;
665
+ completeDispatch(id, effectiveResult, '', resultSummary);
662
666
 
663
667
  // Cleanup temp files (including PID file now that dispatch is complete)
664
668
  try { fs.unlinkSync(sysPromptPath); } catch { /* cleanup */ }
@@ -696,7 +700,7 @@ function spawnAgent(dispatchItem, config) {
696
700
  }, 3000);
697
701
 
698
702
  // Track process — even if PID isn't available yet (async on Windows)
699
- activeProcesses.set(id, { proc, agentId, startedAt });
703
+ activeProcesses.set(id, { proc, agentId, startedAt, sessionId: cachedSessionId });
700
704
 
701
705
  // Log PID and persist to registry
702
706
  if (proc.pid) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yemi33/minions",
3
- "version": "0.1.409",
3
+ "version": "0.1.411",
4
4
  "description": "Multi-agent AI dev team that runs from ~/.minions/ — five autonomous agents share a single engine, dashboard, and knowledge base",
5
5
  "bin": {
6
6
  "minions": "bin/minions.js"