@yemi33/minions 0.1.2241 → 0.1.2242

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/bin/minions.js CHANGED
@@ -1358,6 +1358,15 @@ ${fs.existsSync(path.join(PKG_ROOT, '.git')) ? `
1358
1358
  // Clear stale beacons AFTER the kill so the old dashboard's last writes
1359
1359
  // can't repopulate the file in the gap between clear and shutdown.
1360
1360
  _clearDashboardBrowserState(MINIONS_HOME);
1361
+ // Respawn-race guard: the watchdog (or a surviving supervisor) can spawn a
1362
+ // fresh engine/dashboard during the kill→spawn window — those become ORPHANS
1363
+ // the new stack never reaps, and orphan engines keep dispatching agents +
1364
+ // spawning copilot (the root of the recurring multi-engine / MCP-auth storms).
1365
+ // stop-intent is STILL set here, so any respawn has already stood down or is
1366
+ // about to; reap once more so the stack we spawn below is the ONLY one. Scoped
1367
+ // by command-line to engine/dashboard/supervisor — never touches agent/copilot
1368
+ // children, preserving the re-attach invariant.
1369
+ killMinionsProcesses(['engine.js', 'dashboard.js', 'supervisor.js']);
1361
1370
  // Clear stop-intent so the freshly-spawned supervisor resumes guarding.
1362
1371
  clearStopIntent();
1363
1372
  spawnFullStackAndVerify({ rest, forceOpen, dashWasUp, restartStartMs });
package/engine/shared.js CHANGED
@@ -5666,6 +5666,30 @@ function resolveAgentCopilotHome(minionsDir) {
5666
5666
  return path.join(base, '.minions-agent-copilot-home');
5667
5667
  }
5668
5668
 
5669
+ /**
5670
+ * Derive a scratch/temp base dir on the same volume agent work already lives on
5671
+ * — the configured worktree location (engine.worktreeRoot, default
5672
+ * `../worktrees`). Agents (copilot/node/git + JVM-based MCP servers) write heavy
5673
+ * temp under %TEMP% / $TMPDIR; when that resolves to a full system drive (e.g.
5674
+ * C:), operations thrash or fail and routinely overrun the CLI's per-command
5675
+ * timeout, surfacing to the operator as "Operation cancelled". Anchoring agent
5676
+ * temp next to the worktrees keeps scratch on the operator's work volume with NO
5677
+ * config knob and NO hardcoded path — it simply follows wherever worktrees
5678
+ * already go (a location the operator already placed off the system drive).
5679
+ *
5680
+ * Returns an absolute dir path, or null when no anchor can be resolved — callers
5681
+ * MUST treat null as "leave the inherited TEMP untouched" (fail-open).
5682
+ */
5683
+ function resolveAgentTempBaseDir(project, engine, minionsDir) {
5684
+ let projectRoot;
5685
+ try { projectRoot = resolveProjectRootDir(project && project.localPath, minionsDir); }
5686
+ catch { return null; }
5687
+ const wtRel = (engine && engine.worktreeRoot) || ENGINE_DEFAULTS.worktreeRoot;
5688
+ let anchor;
5689
+ try { anchor = path.resolve(projectRoot, wtRel); } catch { return null; }
5690
+ return path.join(anchor, '.agent-temp');
5691
+ }
5692
+
5669
5693
  // Seed the agent COPILOT_HOME's mcp-config (copy of `~/.copilot/mcp-config.json`
5670
5694
  // MINUS `engine.copilotAgentDisabledMcpServers`) and return the home path. This
5671
5695
  // is the single source of truth for "what MCP servers may a minions-spawned
@@ -8995,6 +9019,7 @@ module.exports = {
8995
9019
  assertWorktreeOutsideProject,
8996
9020
  resolveProjectRootDir,
8997
9021
  resolveAgentCopilotHome,
9022
+ resolveAgentTempBaseDir,
8998
9023
  ensureAgentCopilotHome,
8999
9024
  resolveSpawnPaths,
9000
9025
  validateWorkItemWorkdir,
package/engine.js CHANGED
@@ -1915,6 +1915,25 @@ function _applyAgentCopilotHome(childEnv) {
1915
1915
  catch { /* leave inherited COPILOT_HOME untouched */ }
1916
1916
  }
1917
1917
 
1918
+ // Point a spawned agent's TEMP/TMP/TMPDIR at a scratch dir on the worktree
1919
+ // volume instead of the (often full) system drive — see
1920
+ // shared.resolveAgentTempBaseDir. copilot/node/git + JVM-based MCP servers write
1921
+ // heavy temp there; on a full C: that thrashes and overruns the CLI's per-command
1922
+ // timeout ("Operation cancelled"). Best-effort + fail-open: any resolution/mkdir
1923
+ // failure leaves the inherited TEMP in place. Sets all three vars to cover
1924
+ // Windows (TEMP/TMP) and POSIX (TMPDIR).
1925
+ function _applyAgentTempEnv(childEnv, project) {
1926
+ try {
1927
+ const agentTmp = shared.resolveAgentTempBaseDir(project, getConfig()?.engine, MINIONS_DIR);
1928
+ if (agentTmp) {
1929
+ fs.mkdirSync(agentTmp, { recursive: true });
1930
+ childEnv.TEMP = agentTmp;
1931
+ childEnv.TMP = agentTmp;
1932
+ childEnv.TMPDIR = agentTmp;
1933
+ }
1934
+ } catch { /* leave inherited TEMP untouched */ }
1935
+ }
1936
+
1918
1937
  async function spawnAgent(dispatchItem, config) {
1919
1938
  const { id, agent: agentId, type, meta } = dispatchItem;
1920
1939
  // Resolve prompt — prefers sidecar file when dispatchItem._promptFile is set
@@ -3750,6 +3769,9 @@ async function spawnAgent(dispatchItem, config) {
3750
3769
  // MCP-free copilot config so agents never pop a per-spawn Microsoft auth
3751
3770
  // window — see _applyAgentCopilotHome / shared.resolveAgentCopilotHome.
3752
3771
  _applyAgentCopilotHome(childEnv);
3772
+ // Keep agent scratch off a (possibly full) system drive — anchors TEMP/TMP to
3773
+ // the worktree volume. See _applyAgentTempEnv / shared.resolveAgentTempBaseDir.
3774
+ _applyAgentTempEnv(childEnv, project);
3753
3775
 
3754
3776
  if (getRepoHost(project) === 'ado') {
3755
3777
  // Inject cached ADO token so ADO agents skip re-authentication (#998).
@@ -4262,6 +4284,8 @@ async function spawnAgent(dispatchItem, config) {
4262
4284
  childEnv.MINIONS_NO_AUTO_OPEN = '1';
4263
4285
  // Same MCP-free copilot home on steering resume (see the initial spawn site).
4264
4286
  _applyAgentCopilotHome(childEnv);
4287
+ // Same agent-scratch redirect on steering resume.
4288
+ _applyAgentTempEnv(childEnv, project);
4265
4289
  if (getRepoHost(project) === 'ado') {
4266
4290
  // Inject cached ADO token for steering session too (#998)
4267
4291
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yemi33/minions",
3
- "version": "0.1.2241",
3
+ "version": "0.1.2242",
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"