@mu-crew/mu 4.2.0 → 4.2.2

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/cli.js CHANGED
@@ -47,6 +47,6 @@ function enableCompileCacheIn(dir, enable = nodeEnable ?? null) {
47
47
 
48
48
  // src/main.ts
49
49
  enableCompileCacheIn(join(defaultStateDir(), "compile-cache"));
50
- var { runCli } = await import("./cli-72EJ3CKW.js");
50
+ var { runCli } = await import("./cli-HKBFJISN.js");
51
51
  await runCli(process.argv);
52
52
  //# sourceMappingURL=cli.js.map
@@ -32,7 +32,7 @@ import {
32
32
  SpawnReceiptConflictError,
33
33
  SpawnTaskStateError,
34
34
  SpawnTrustDialogError
35
- } from "./chunk-SFV5RPZW.js";
35
+ } from "./chunk-4ZWBLTZK.js";
36
36
  import "./chunk-PZ5GOCWH.js";
37
37
  export {
38
38
  AgentAbortNeedsCtlError,
@@ -68,4 +68,4 @@ export {
68
68
  SpawnTaskStateError,
69
69
  SpawnTrustDialogError
70
70
  };
71
- //# sourceMappingURL=errors-LY4OZVQU.js.map
71
+ //# sourceMappingURL=errors-MDQZHB42.js.map
@@ -1728,16 +1728,7 @@ function outcomeOf(event) {
1728
1728
  }
1729
1729
  var SETTLE_DRAIN_MS = 3e3;
1730
1730
  var SETTLE_WAIT_ARGS = ["wait", "--first", "--on-stall", "exit", "--json"];
1731
- var SETTLE_READY_ARGS = [
1732
- "wait",
1733
- "--first",
1734
- "--on-stall",
1735
- "exit",
1736
- "--timeout",
1737
- "1",
1738
- "--json"
1739
- ];
1740
- var READY_MAX = 50;
1731
+ var HUMAN_STOP_DRAIN = "A human stop is open (mu human-needed). Collect and merge what you already started; start nothing new (no `mu next`, no spawn, no new delegate, no restart of a stalled or dead worker: tell the human). The settle keeps waiting while work you own is still running, and ends the turn when nothing is.";
1741
1732
  var ESC = /^\u001b(\[27(;\d+)*u)?$/;
1742
1733
  function envelopeOf(stdout) {
1743
1734
  try {
@@ -1881,11 +1872,10 @@ function registerNudge(pi, run = defaultRunner(), skillMd = readSkill(), nested
1881
1872
  return {
1882
1873
  blocks: [
1883
1874
  `Delegate answer: call ${callId}. Its row is unreadable here: mu delegates show ${callId}`
1884
- ],
1885
- stop: false
1875
+ ]
1886
1876
  };
1887
1877
  const wave = c.wave;
1888
- if (!wave) return { blocks: [await answerBlock(mu, c, REPORT_CAP)], stop: false };
1878
+ if (!wave) return { blocks: [await answerBlock(mu, c, REPORT_CAP)] };
1889
1879
  const listed = async () => {
1890
1880
  const v = await mu(["delegates", "list", "--wave", wave, "--json"]);
1891
1881
  const items = v?.ok === true ? v.data?.items : void 0;
@@ -1893,7 +1883,6 @@ function registerNudge(pi, run = defaultRunner(), skillMd = readSkill(), nested
1893
1883
  };
1894
1884
  const after = [];
1895
1885
  const notices = new Set(noticesOf(first));
1896
- let stop = false;
1897
1886
  let rows = await listed();
1898
1887
  let picture = pictureOf(first);
1899
1888
  const owedRow = (r) => PENDING_STATES.has(r.state) || r.state !== "refused" && !shown.has(r.callId) && picture?.has(r.callId) !== false;
@@ -1912,11 +1901,10 @@ function registerNudge(pi, run = defaultRunner(), skillMd = readSkill(), nested
1912
1901
  for (const n of noticesOf(d)) notices.add(n);
1913
1902
  picture = pictureOf(d);
1914
1903
  if (d.timedOut === true) continue;
1915
- if (Array.isArray(d.humanNeeds) && d.humanNeeds.length > 0) stop = true;
1916
1904
  const id = firingDelegate(d);
1917
1905
  const sibling = id !== void 0 && rows.some((x) => x.callId === id);
1918
1906
  if (id !== void 0) shown.add(id);
1919
- if (sibling && !stop) {
1907
+ if (sibling) {
1920
1908
  rows = await listed();
1921
1909
  continue;
1922
1910
  }
@@ -1933,46 +1921,9 @@ ${JSON.stringify(d)}`);
1933
1921
  );
1934
1922
  return {
1935
1923
  blocks: [waveSummary(wave, rows), ...bodies, ...after],
1936
- stop,
1937
1924
  wave: { label: wave, complete, notices: [...notices] }
1938
1925
  };
1939
1926
  };
1940
- const ready = async () => {
1941
- const blocks = [];
1942
- const shown = [];
1943
- for (let i = 0; i < READY_MAX && !ctl.signal.aborted; i++) {
1944
- const started = Date.now();
1945
- const r = await wait(SETTLE_READY_ARGS);
1946
- const v = envelopeOf(r.stdout);
1947
- if (v?.ok === false && v.error === "WaitNothingError") {
1948
- delivered({ before: started });
1949
- break;
1950
- }
1951
- const d = v?.ok === true ? v.data : void 0;
1952
- if (d === void 0) {
1953
- const why = (r.stdout.trim() || r.stderr.trim()).slice(0, 2e3);
1954
- blocks.push(`mu wait failed (exit ${r.code}): ${why}`);
1955
- break;
1956
- }
1957
- if (d.drained === true) delivered({ before: started });
1958
- if (d.interrupted === true || d.drained === true || d.timedOut === true) break;
1959
- blocks.push(JSON.stringify(d));
1960
- const id = firingDelegate(d);
1961
- if (id === void 0) continue;
1962
- shown.push(id);
1963
- const c = await call2(id);
1964
- blocks.push(
1965
- c === void 0 ? `Delegate answer: call ${id}. Its row is unreadable here: mu delegates show ${id}` : await answerBlock(mu, c, REPORT_CAP)
1966
- );
1967
- }
1968
- if (shown.length > 0) delivered(shown);
1969
- if (blocks.length === 0) return void 0;
1970
- const text = [
1971
- "[mu] A human stop is open (mu human-needed), so the settle did not wait. It showed what was already ready:",
1972
- ...blocks.flatMap((b) => ["", b])
1973
- ].join("\n");
1974
- return { entries: [entry(text)], receipt: true };
1975
- };
1976
1927
  let result;
1977
1928
  try {
1978
1929
  result = await (async () => {
@@ -1987,7 +1938,6 @@ ${JSON.stringify(d)}`);
1987
1938
  )
1988
1939
  ]
1989
1940
  };
1990
- if (needs > 0) return ready();
1991
1941
  const started = Date.now();
1992
1942
  const r = await wait(SETTLE_WAIT_ARGS);
1993
1943
  const v = envelopeOf(r.stdout);
@@ -2008,16 +1958,22 @@ ${JSON.stringify(d)}`);
2008
1958
  const got = callId === void 0 ? void 0 : await answers(callId, shown, d);
2009
1959
  const blocks = got?.blocks ?? [];
2010
1960
  if (shown.size > 0) delivered([...shown]);
2011
- const humanStop = Array.isArray(d.humanNeeds) && d.humanNeeds.length > 0;
2012
- const stop = humanStop || got?.stop === true;
1961
+ const stops = Array.isArray(d.humanNeeds) ? d.humanNeeds : [];
1962
+ const humanStop = needs > 0 || stops.length > 0;
2013
1963
  const ran = `Work you own is still running, so the settle ran \`mu ${SETTLE_WAIT_ARGS.join(" ")}\` for you.`;
2014
1964
  const w = got?.wave;
2015
- const head = w !== void 0 && !humanStop ? [
1965
+ const head = w !== void 0 ? [
2016
1966
  w.complete ? `${ran} It waited until wave ${w.label} was in:` : `${ran} It waited for wave ${w.label}, which is not all in (below):`,
2017
1967
  ...w.notices.map((n) => `Notice: ${n}`)
2018
1968
  ] : [`${ran} Its result:`, JSON.stringify(d)];
2019
- const text = [`[mu] ${rule}`, "", ...head, ...blocks.flatMap((b) => ["", b])].join("\n");
2020
- return { entries: [entry(text)], ...stop ? {} : { continue: true }, receipt: true };
1969
+ const lead = humanStop ? [
1970
+ `[mu] ${HUMAN_STOP_DRAIN}`,
1971
+ ...stops.flatMap(
1972
+ (h) => typeof h.reason === "string" ? [`Stop: ${h.reason}`] : []
1973
+ )
1974
+ ] : [`[mu] ${rule}`];
1975
+ const text = [...lead, "", ...head, ...blocks.flatMap((b) => ["", b])].join("\n");
1976
+ return { entries: [entry(text)], continue: true, receipt: true };
2021
1977
  }
2022
1978
  })();
2023
1979
  } finally {
@@ -2102,7 +2058,7 @@ function registerCloseNudge(pi, run = defaultRunner(), env = process.env, nested
2102
2058
  }
2103
2059
 
2104
2060
  // extension/mu-pi.ts
2105
- var EXT_VERSION = true ? "4.2.0" : void 0;
2061
+ var EXT_VERSION = true ? "4.2.2" : void 0;
2106
2062
  var FRESH_COMMAND = "mu-fresh";
2107
2063
  var FRESH_TIMEOUT_MS = 3e4;
2108
2064
  function commandName(name) {
@@ -2113,6 +2069,14 @@ var LAST_TEXT_MAX_BYTES = 64 * 1024;
2113
2069
  var LAST_TEXT_TRUNCATED = "[truncated, see pane]";
2114
2070
  var LIVE_PROBE_MS = 500;
2115
2071
  var V = CTL_PROTOCOL_VERSION;
2072
+ function toolStatus(t) {
2073
+ if (t === void 0) return null;
2074
+ return {
2075
+ name: t.name,
2076
+ since: t.since,
2077
+ quiet_ms: Math.max(0, Date.now() - (t.output ?? t.since))
2078
+ };
2079
+ }
2116
2080
  function fail(error) {
2117
2081
  return { v: V, ok: false, error };
2118
2082
  }
@@ -2317,7 +2281,7 @@ function serveCtl(pi) {
2317
2281
  since: g.since,
2318
2282
  runs: g.runs,
2319
2283
  pending: g.ctx?.hasPendingMessages() ?? false,
2320
- tool: [...g.tools.values()].at(-1) ?? null,
2284
+ tool: toolStatus([...g.tools.values()].at(-1)),
2321
2285
  ...sessionFileOf(g.ctx),
2322
2286
  ...blockedField()
2323
2287
  });
@@ -2358,7 +2322,16 @@ function serveCtl(pi) {
2358
2322
  pi.on("tool_execution_start", (e) => {
2359
2323
  const { toolCallId, toolName } = e ?? {};
2360
2324
  if (typeof toolCallId === "string" && typeof toolName === "string") {
2361
- g.tools.set(toolCallId, { name: toolName, since: Date.now() });
2325
+ const now = Date.now();
2326
+ g.tools.set(toolCallId, { name: toolName, since: now, output: now });
2327
+ }
2328
+ });
2329
+ pi.on("tool_execution_update", (e) => {
2330
+ const { toolCallId, parentToolCallId } = e ?? {};
2331
+ const now = Date.now();
2332
+ for (const id of [toolCallId, parentToolCallId]) {
2333
+ const t = typeof id === "string" ? g.tools.get(id) : void 0;
2334
+ if (t) t.output = now;
2362
2335
  }
2363
2336
  });
2364
2337
  pi.on("tool_execution_end", (e) => {