@mu-crew/mu 4.0.0 → 4.1.0

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.
Files changed (34) hide show
  1. package/README.md +1 -1
  2. package/dist/{chunk-5HECDBK3.js → chunk-4ULY3ZKO.js} +16 -16
  3. package/dist/{chunk-AW2NONYU.js → chunk-7M634JMD.js} +81 -7
  4. package/dist/chunk-7M634JMD.js.map +1 -0
  5. package/dist/{chunk-GQNHIPJN.js → chunk-SS7NQSSZ.js} +21 -421
  6. package/dist/chunk-SS7NQSSZ.js.map +1 -0
  7. package/dist/{chunk-S424D5EP.js → chunk-UCZPJX7K.js} +628 -141
  8. package/dist/chunk-UCZPJX7K.js.map +1 -0
  9. package/dist/{cli-GB2CAVVW.js → cli-TV3N47AZ.js} +340 -42
  10. package/dist/cli-TV3N47AZ.js.map +1 -0
  11. package/dist/cli.js +1 -1
  12. package/dist/{errors-KHOYKD7D.js → errors-GRONKWFS.js} +2 -2
  13. package/dist/extension/mu-pi.js +28 -14
  14. package/dist/extension/mu-pi.js.map +1 -1
  15. package/dist/index.d.ts +63 -11
  16. package/dist/index.js +15 -15
  17. package/dist/{tui-ALPHYTA2.js → tui-FUBQ326D.js} +102 -27
  18. package/dist/tui-FUBQ326D.js.map +1 -0
  19. package/docs/ARCHITECTURE.md +5 -4
  20. package/docs/VOCABULARY.md +6 -5
  21. package/docs/guide/cleanup.md +8 -0
  22. package/docs/guide/delegate.md +11 -3
  23. package/docs/guide/remote.md +19 -12
  24. package/docs/reference/env.md +1 -0
  25. package/docs/reference/naming.md +2 -0
  26. package/package.json +1 -1
  27. package/skills/mu/recipes/remote-workers.md +7 -6
  28. package/dist/chunk-AW2NONYU.js.map +0 -1
  29. package/dist/chunk-GQNHIPJN.js.map +0 -1
  30. package/dist/chunk-S424D5EP.js.map +0 -1
  31. package/dist/cli-GB2CAVVW.js.map +0 -1
  32. package/dist/tui-ALPHYTA2.js.map +0 -1
  33. /package/dist/{chunk-5HECDBK3.js.map → chunk-4ULY3ZKO.js.map} +0 -0
  34. /package/dist/{errors-KHOYKD7D.js.map → errors-GRONKWFS.js.map} +0 -0
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-GB2CAVVW.js");
50
+ var { runCli } = await import("./cli-TV3N47AZ.js");
51
51
  await runCli(process.argv);
52
52
  //# sourceMappingURL=cli.js.map
@@ -29,7 +29,7 @@ import {
29
29
  SpawnReceiptConflictError,
30
30
  SpawnTaskStateError,
31
31
  SpawnTrustDialogError
32
- } from "./chunk-S424D5EP.js";
32
+ } from "./chunk-UCZPJX7K.js";
33
33
  import "./chunk-PZ5GOCWH.js";
34
34
  export {
35
35
  AgentAbortNeedsCtlError,
@@ -62,4 +62,4 @@ export {
62
62
  SpawnTaskStateError,
63
63
  SpawnTrustDialogError
64
64
  };
65
- //# sourceMappingURL=errors-KHOYKD7D.js.map
65
+ //# sourceMappingURL=errors-GRONKWFS.js.map
@@ -903,7 +903,8 @@ ${recordedLine(call2, finErr)}`,
903
903
  inflight.set(key, entry2);
904
904
  if (o.tracked === void 0) reportPending();
905
905
  await o.tracked?.();
906
- const started = Date.now();
906
+ const started = o.startedAt ?? Date.now();
907
+ const left = Math.max(1, Math.ceil(o.timeoutS - (Date.now() - started) / 1e3));
907
908
  const waiting = mu(
908
909
  [
909
910
  "agent",
@@ -913,7 +914,7 @@ ${recordedLine(call2, finErr)}`,
913
914
  ws,
914
915
  "--json",
915
916
  "--timeout",
916
- String(o.timeoutS),
917
+ String(left),
917
918
  "--after-runs",
918
919
  String(runs)
919
920
  ],
@@ -1542,9 +1543,11 @@ ${evidence.join("\n")}`;
1542
1543
  const call2 = callInfoOf(row);
1543
1544
  if (call2.caller !== `pi:${session}` || inflight.has(inflightKey(call2.workstream, row.agent)))
1544
1545
  continue;
1546
+ const since = typeof row.updatedAt === "string" ? Date.parse(row.updatedAt) : Number.NaN;
1545
1547
  await watch(call2, row.agent, 0, {
1546
1548
  keep: call2.request.keep === true,
1547
- timeoutS: call2.request.timeoutS ?? DELEGATE_TIMEOUT_S
1549
+ timeoutS: call2.request.timeoutS ?? DELEGATE_TIMEOUT_S,
1550
+ ...Number.isFinite(since) ? { startedAt: since } : {}
1548
1551
  });
1549
1552
  }
1550
1553
  });
@@ -1645,7 +1648,7 @@ function keepDrivingRule(skillMd) {
1645
1648
  const i = skillMd.indexOf(MARK_START);
1646
1649
  const j = skillMd.indexOf(MARK_END);
1647
1650
  if (i < 0 || j < i) return void 0;
1648
- const text = skillMd.slice(i + MARK_START.length, j).trim();
1651
+ const text = skillMd.slice(i + MARK_START.length, j).trim().split(/\n\s*\n/).map((p) => p.replace(/\s*\n\s*/g, " ")).join("\n\n");
1649
1652
  return text === "" ? void 0 : text;
1650
1653
  }
1651
1654
  function readSkill() {
@@ -1821,6 +1824,9 @@ function waveSummary(wave, rows) {
1821
1824
  );
1822
1825
  return [`Wave ${wave}: ${counts}.`, ...lines].join("\n");
1823
1826
  }
1827
+ function noticesOf(d) {
1828
+ return Array.isArray(d.notices) ? d.notices.filter((n) => typeof n === "string") : [];
1829
+ }
1824
1830
  function firingDelegate(d) {
1825
1831
  const f = d.firing;
1826
1832
  if (f?.kind !== "delegate" || typeof f.ref !== "string") return void 0;
@@ -1886,6 +1892,7 @@ function registerNudge(pi, run = defaultRunner(), skillMd = readSkill(), nested
1886
1892
  return Array.isArray(items) ? items : [c];
1887
1893
  };
1888
1894
  const after = [];
1895
+ const notices = new Set(noticesOf(first));
1889
1896
  let stop = false;
1890
1897
  let rows = await listed();
1891
1898
  let picture = pictureOf(first);
@@ -1902,6 +1909,7 @@ function registerNudge(pi, run = defaultRunner(), skillMd = readSkill(), nested
1902
1909
  break;
1903
1910
  }
1904
1911
  if (d.interrupted === true || d.drained === true) break;
1912
+ for (const n of noticesOf(d)) notices.add(n);
1905
1913
  picture = pictureOf(d);
1906
1914
  if (d.timedOut === true) continue;
1907
1915
  if (Array.isArray(d.humanNeeds) && d.humanNeeds.length > 0) stop = true;
@@ -1919,10 +1927,15 @@ ${JSON.stringify(d)}`);
1919
1927
  break;
1920
1928
  }
1921
1929
  rows = await listed();
1930
+ const complete = !ctl.signal.aborted && after.length === 0 && !rows.some(owedRow);
1922
1931
  const bodies = await Promise.all(
1923
1932
  rows.filter((x) => shown.has(x.callId)).map((x) => answerBlock(mu, x, WAVE_REPORT_CAP))
1924
1933
  );
1925
- return { blocks: [waveSummary(wave, rows), ...bodies, ...after], stop };
1934
+ return {
1935
+ blocks: [waveSummary(wave, rows), ...bodies, ...after],
1936
+ stop,
1937
+ wave: { label: wave, complete, notices: [...notices] }
1938
+ };
1926
1939
  };
1927
1940
  const ready = async () => {
1928
1941
  const blocks = [];
@@ -1995,14 +2008,15 @@ ${JSON.stringify(d)}`);
1995
2008
  const got = callId === void 0 ? void 0 : await answers(callId, shown, d);
1996
2009
  const blocks = got?.blocks ?? [];
1997
2010
  if (shown.size > 0) delivered([...shown]);
1998
- const stop = Array.isArray(d.humanNeeds) && d.humanNeeds.length > 0 || got?.stop === true;
1999
- const text = [
2000
- `[mu] ${rule}`,
2001
- "",
2002
- `Work you own is still running, so the settle ran \`mu ${SETTLE_WAIT_ARGS.join(" ")}\` for you. Its result:`,
2003
- JSON.stringify(d),
2004
- ...blocks.flatMap((b) => ["", b])
2005
- ].join("\n");
2011
+ const humanStop = Array.isArray(d.humanNeeds) && d.humanNeeds.length > 0;
2012
+ const stop = humanStop || got?.stop === true;
2013
+ const ran = `Work you own is still running, so the settle ran \`mu ${SETTLE_WAIT_ARGS.join(" ")}\` for you.`;
2014
+ const w = got?.wave;
2015
+ const head = w !== void 0 && !humanStop ? [
2016
+ 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
+ ...w.notices.map((n) => `Notice: ${n}`)
2018
+ ] : [`${ran} Its result:`, JSON.stringify(d)];
2019
+ const text = [`[mu] ${rule}`, "", ...head, ...blocks.flatMap((b) => ["", b])].join("\n");
2006
2020
  return { entries: [entry(text)], ...stop ? {} : { continue: true }, receipt: true };
2007
2021
  }
2008
2022
  })();
@@ -2088,7 +2102,7 @@ function registerCloseNudge(pi, run = defaultRunner(), env = process.env, nested
2088
2102
  }
2089
2103
 
2090
2104
  // extension/mu-pi.ts
2091
- var EXT_VERSION = true ? "4.0.0" : void 0;
2105
+ var EXT_VERSION = true ? "4.1.0" : void 0;
2092
2106
  var FRESH_COMMAND = "mu-fresh";
2093
2107
  var FRESH_TIMEOUT_MS = 3e4;
2094
2108
  function commandName(name) {