@metaphi-ai/hum 0.1.11 → 0.1.13

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 (2) hide show
  1. package/dist/cli.mjs +235 -84
  2. package/package.json +1 -1
package/dist/cli.mjs CHANGED
@@ -22744,10 +22744,10 @@ var require_react_reconciler_development = __commonJS({
22744
22744
  var setErrorHandler = null;
22745
22745
  var setSuspenseHandler = null;
22746
22746
  {
22747
- var copyWithDeleteImpl = function(obj, path4, index2) {
22748
- var key = path4[index2];
22747
+ var copyWithDeleteImpl = function(obj, path5, index2) {
22748
+ var key = path5[index2];
22749
22749
  var updated = isArray(obj) ? obj.slice() : assign({}, obj);
22750
- if (index2 + 1 === path4.length) {
22750
+ if (index2 + 1 === path5.length) {
22751
22751
  if (isArray(updated)) {
22752
22752
  updated.splice(key, 1);
22753
22753
  } else {
@@ -22755,11 +22755,11 @@ var require_react_reconciler_development = __commonJS({
22755
22755
  }
22756
22756
  return updated;
22757
22757
  }
22758
- updated[key] = copyWithDeleteImpl(obj[key], path4, index2 + 1);
22758
+ updated[key] = copyWithDeleteImpl(obj[key], path5, index2 + 1);
22759
22759
  return updated;
22760
22760
  };
22761
- var copyWithDelete = function(obj, path4) {
22762
- return copyWithDeleteImpl(obj, path4, 0);
22761
+ var copyWithDelete = function(obj, path5) {
22762
+ return copyWithDeleteImpl(obj, path5, 0);
22763
22763
  };
22764
22764
  var copyWithRenameImpl = function(obj, oldPath, newPath, index2) {
22765
22765
  var oldKey = oldPath[index2];
@@ -22797,17 +22797,17 @@ var require_react_reconciler_development = __commonJS({
22797
22797
  }
22798
22798
  return copyWithRenameImpl(obj, oldPath, newPath, 0);
22799
22799
  };
22800
- var copyWithSetImpl = function(obj, path4, index2, value) {
22801
- if (index2 >= path4.length) {
22800
+ var copyWithSetImpl = function(obj, path5, index2, value) {
22801
+ if (index2 >= path5.length) {
22802
22802
  return value;
22803
22803
  }
22804
- var key = path4[index2];
22804
+ var key = path5[index2];
22805
22805
  var updated = isArray(obj) ? obj.slice() : assign({}, obj);
22806
- updated[key] = copyWithSetImpl(obj[key], path4, index2 + 1, value);
22806
+ updated[key] = copyWithSetImpl(obj[key], path5, index2 + 1, value);
22807
22807
  return updated;
22808
22808
  };
22809
- var copyWithSet = function(obj, path4, value) {
22810
- return copyWithSetImpl(obj, path4, 0, value);
22809
+ var copyWithSet = function(obj, path5, value) {
22810
+ return copyWithSetImpl(obj, path5, 0, value);
22811
22811
  };
22812
22812
  var findHook = function(fiber, id) {
22813
22813
  var currentHook2 = fiber.memoizedState;
@@ -22817,10 +22817,10 @@ var require_react_reconciler_development = __commonJS({
22817
22817
  }
22818
22818
  return currentHook2;
22819
22819
  };
22820
- overrideHookState = function(fiber, id, path4, value) {
22820
+ overrideHookState = function(fiber, id, path5, value) {
22821
22821
  var hook = findHook(fiber, id);
22822
22822
  if (hook !== null) {
22823
- var newState = copyWithSet(hook.memoizedState, path4, value);
22823
+ var newState = copyWithSet(hook.memoizedState, path5, value);
22824
22824
  hook.memoizedState = newState;
22825
22825
  hook.baseState = newState;
22826
22826
  fiber.memoizedProps = assign({}, fiber.memoizedProps);
@@ -22830,10 +22830,10 @@ var require_react_reconciler_development = __commonJS({
22830
22830
  }
22831
22831
  }
22832
22832
  };
22833
- overrideHookStateDeletePath = function(fiber, id, path4) {
22833
+ overrideHookStateDeletePath = function(fiber, id, path5) {
22834
22834
  var hook = findHook(fiber, id);
22835
22835
  if (hook !== null) {
22836
- var newState = copyWithDelete(hook.memoizedState, path4);
22836
+ var newState = copyWithDelete(hook.memoizedState, path5);
22837
22837
  hook.memoizedState = newState;
22838
22838
  hook.baseState = newState;
22839
22839
  fiber.memoizedProps = assign({}, fiber.memoizedProps);
@@ -22856,8 +22856,8 @@ var require_react_reconciler_development = __commonJS({
22856
22856
  }
22857
22857
  }
22858
22858
  };
22859
- overrideProps = function(fiber, path4, value) {
22860
- fiber.pendingProps = copyWithSet(fiber.memoizedProps, path4, value);
22859
+ overrideProps = function(fiber, path5, value) {
22860
+ fiber.pendingProps = copyWithSet(fiber.memoizedProps, path5, value);
22861
22861
  if (fiber.alternate) {
22862
22862
  fiber.alternate.pendingProps = fiber.pendingProps;
22863
22863
  }
@@ -22866,8 +22866,8 @@ var require_react_reconciler_development = __commonJS({
22866
22866
  scheduleUpdateOnFiber(root, fiber, SyncLane, NoTimestamp);
22867
22867
  }
22868
22868
  };
22869
- overridePropsDeletePath = function(fiber, path4) {
22870
- fiber.pendingProps = copyWithDelete(fiber.memoizedProps, path4);
22869
+ overridePropsDeletePath = function(fiber, path5) {
22870
+ fiber.pendingProps = copyWithDelete(fiber.memoizedProps, path5);
22871
22871
  if (fiber.alternate) {
22872
22872
  fiber.alternate.pendingProps = fiber.pendingProps;
22873
22873
  }
@@ -29136,7 +29136,7 @@ var require_utils = __commonJS({
29136
29136
  state[info.set] = info.to;
29137
29137
  }
29138
29138
  }
29139
- function readState(line) {
29139
+ function readState2(line) {
29140
29140
  let code = codeRegex(true);
29141
29141
  let controlChars = code.exec(line);
29142
29142
  let state = {};
@@ -29336,7 +29336,7 @@ var require_utils = __commonJS({
29336
29336
  let output = [];
29337
29337
  for (let i = 0; i < input.length; i++) {
29338
29338
  let line = rewindState(state, input[i]);
29339
- state = readState(line);
29339
+ state = readState2(line);
29340
29340
  let temp = Object.assign({}, state);
29341
29341
  output.push(unwindState(temp, line));
29342
29342
  }
@@ -29446,7 +29446,7 @@ var require_has_flag = __commonJS({
29446
29446
  var require_supports_colors = __commonJS({
29447
29447
  "node_modules/@colors/colors/lib/system/supports-colors.js"(exports, module) {
29448
29448
  "use strict";
29449
- var os5 = __require("os");
29449
+ var os6 = __require("os");
29450
29450
  var hasFlag2 = require_has_flag();
29451
29451
  var env3 = process.env;
29452
29452
  var forceColor = void 0;
@@ -29484,7 +29484,7 @@ var require_supports_colors = __commonJS({
29484
29484
  }
29485
29485
  var min = forceColor ? 1 : 0;
29486
29486
  if (process.platform === "win32") {
29487
- var osRelease = os5.release().split(".");
29487
+ var osRelease = os6.release().split(".");
29488
29488
  if (Number(process.versions.node.split(".")[0]) >= 8 && Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
29489
29489
  return Number(osRelease[2]) >= 14931 ? 3 : 2;
29490
29490
  }
@@ -73569,15 +73569,15 @@ var require_route = __commonJS({
73569
73569
  };
73570
73570
  }
73571
73571
  function wrapConversion(toModel, graph) {
73572
- const path4 = [graph[toModel].parent, toModel];
73572
+ const path5 = [graph[toModel].parent, toModel];
73573
73573
  let fn = conversions[graph[toModel].parent][toModel];
73574
73574
  let cur = graph[toModel].parent;
73575
73575
  while (graph[cur].parent) {
73576
- path4.unshift(graph[cur].parent);
73576
+ path5.unshift(graph[cur].parent);
73577
73577
  fn = link3(conversions[graph[cur].parent][cur], fn);
73578
73578
  cur = graph[cur].parent;
73579
73579
  }
73580
- fn.conversion = path4;
73580
+ fn.conversion = path5;
73581
73581
  return fn;
73582
73582
  }
73583
73583
  module.exports = function(fromModel) {
@@ -73817,7 +73817,7 @@ var require_has_flag2 = __commonJS({
73817
73817
  var require_supports_color = __commonJS({
73818
73818
  "node_modules/supports-color/index.js"(exports, module) {
73819
73819
  "use strict";
73820
- var os5 = __require("os");
73820
+ var os6 = __require("os");
73821
73821
  var tty2 = __require("tty");
73822
73822
  var hasFlag2 = require_has_flag2();
73823
73823
  var { env: env3 } = process;
@@ -73865,7 +73865,7 @@ var require_supports_color = __commonJS({
73865
73865
  return min;
73866
73866
  }
73867
73867
  if (process.platform === "win32") {
73868
- const osRelease = os5.release().split(".");
73868
+ const osRelease = os6.release().split(".");
73869
73869
  if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
73870
73870
  return Number(osRelease[2]) >= 14931 ? 3 : 2;
73871
73871
  }
@@ -80406,8 +80406,8 @@ function Text({ color, backgroundColor, dimColor = false, bold = false, italic =
80406
80406
  }
80407
80407
 
80408
80408
  // node_modules/ink/build/components/ErrorOverview.js
80409
- var cleanupPath = (path4) => {
80410
- return path4?.replace(`file://${cwd()}/`, "");
80409
+ var cleanupPath = (path5) => {
80410
+ return path5?.replace(`file://${cwd()}/`, "");
80411
80411
  };
80412
80412
  var stackUtils = new import_stack_utils.default({
80413
80413
  cwd: cwd(),
@@ -81353,9 +81353,9 @@ var import_react21 = __toESM(require_react(), 1);
81353
81353
 
81354
81354
  // src/app.jsx
81355
81355
  var import_react24 = __toESM(require_react(), 1);
81356
- import fs2 from "node:fs";
81357
- import os3 from "node:os";
81358
- import path from "node:path";
81356
+ import fs3 from "node:fs";
81357
+ import os4 from "node:os";
81358
+ import path2 from "node:path";
81359
81359
 
81360
81360
  // node_modules/ink-spinner/build/index.js
81361
81361
  var import_react22 = __toESM(require_react(), 1);
@@ -83566,6 +83566,129 @@ function renderMarkdown(text, width) {
83566
83566
  return renderBlocks(tokens, Math.max(20, width)).join("\n\n").replace(/\s+$/, "");
83567
83567
  }
83568
83568
 
83569
+ // src/wordmark.js
83570
+ var WORDMARK = [
83571
+ "\u2588\u2588\u2557 \u2588\u2588\u2557\u2588\u2588\u2557 \u2588\u2588\u2557\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2557",
83572
+ "\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2551",
83573
+ "\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2554\u2588\u2588\u2588\u2588\u2554\u2588\u2588\u2551",
83574
+ "\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551\u255A\u2588\u2588\u2554\u255D\u2588\u2588\u2551",
83575
+ "\u2588\u2588\u2551 \u2588\u2588\u2551\u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2551 \u255A\u2550\u255D \u2588\u2588\u2551",
83576
+ "\u255A\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u255D"
83577
+ ];
83578
+ var TAGLINE = "\u0939\u092E \xB7 human and model, one harness";
83579
+
83580
+ // src/update.js
83581
+ import fs2 from "node:fs";
83582
+ import os3 from "node:os";
83583
+ import path from "node:path";
83584
+ import { spawn, spawnSync } from "node:child_process";
83585
+ var dist = (env3 = process.env) => (env3.HUM_DIST || "https://storage.googleapis.com/hum-dist").replace(/\/+$/, "");
83586
+ var humHome = (env3 = process.env) => env3.HUM_HOME || path.join(os3.homedir(), ".hum");
83587
+ var win = () => process.platform === "win32";
83588
+ async function latestVersion(fetchImpl = globalThis.fetch, env3 = process.env) {
83589
+ if (env3.HUM_NO_UPDATE_CHECK || typeof fetchImpl !== "function") return "";
83590
+ try {
83591
+ const r = await fetchImpl(`${dist(env3)}/releases/latest`, { signal: AbortSignal.timeout(2500) });
83592
+ if (!r.ok) return "";
83593
+ const v = (await r.text()).trim();
83594
+ return /^\d+\.\d+\.\d+$/.test(v) ? v : "";
83595
+ } catch {
83596
+ return "";
83597
+ }
83598
+ }
83599
+ var newer = (a, b) => {
83600
+ const pa = String(a).split(".").map(Number), pb = String(b).split(".").map(Number);
83601
+ for (let i = 0; i < 3; i += 1) {
83602
+ if ((pa[i] || 0) !== (pb[i] || 0)) return (pa[i] || 0) > (pb[i] || 0);
83603
+ }
83604
+ return false;
83605
+ };
83606
+ function installLayout(execPath = process.execPath, env3 = process.env) {
83607
+ const exe = String(execPath).split(/[\\/]/).pop();
83608
+ if (/^(node|bun)(\.exe)?$/i.test(exe)) return { kind: env3.HUM_ENGINE_PORT ? "python" : "npm" };
83609
+ let real = execPath;
83610
+ try {
83611
+ real = fs2.realpathSync(execPath);
83612
+ } catch {
83613
+ }
83614
+ return { kind: "native", exe, dir: path.dirname(real), base: path.dirname(path.dirname(real)) };
83615
+ }
83616
+ var updateCommand = (layout = installLayout(), platform2 = process.platform) => {
83617
+ if (layout.kind === "native") return platform2 === "win32" ? `irm ${dist()}/install.ps1 | iex` : `curl -fsSL ${dist()}/install.sh | sh`;
83618
+ if (layout.kind === "python") return "uv tool upgrade hum-cli (or: pip install -U hum-cli)";
83619
+ return "npm i -g @metaphi-ai/hum@latest";
83620
+ };
83621
+ var readyVersion = (layout, version) => layout.kind === "native" && version && fs2.existsSync(path.join(layout.base, version, layout.exe)) ? version : "";
83622
+ var stateFile = (env3 = process.env) => path.join(humHome(env3), "update.json");
83623
+ var readState = (env3 = process.env) => {
83624
+ try {
83625
+ return JSON.parse(fs2.readFileSync(stateFile(env3), "utf8"));
83626
+ } catch {
83627
+ return {};
83628
+ }
83629
+ };
83630
+ var writeState = (s, env3 = process.env) => {
83631
+ try {
83632
+ fs2.mkdirSync(humHome(env3), { recursive: true });
83633
+ fs2.writeFileSync(stateFile(env3), JSON.stringify(s));
83634
+ } catch {
83635
+ }
83636
+ };
83637
+ function installerArgv(version, platform2 = process.platform) {
83638
+ const base = dist();
83639
+ if (platform2 === "win32") return ["powershell", ["-NoProfile", "-ExecutionPolicy", "Bypass", "-Command", `irm ${base}/install.ps1 | iex`]];
83640
+ return ["/bin/sh", ["-c", `curl -fsSL "${base}/install.sh" | sh`]];
83641
+ }
83642
+ function startBackgroundUpdate(version, { env: env3 = process.env, now = Date.now(), spawnImpl = spawn } = {}) {
83643
+ if (env3.HUM_NO_AUTO_UPDATE) return false;
83644
+ const s = readState(env3);
83645
+ if (s.version === version && now - (s.started || 0) < 30 * 60 * 1e3) return false;
83646
+ const log = path.join(humHome(env3), "update.log");
83647
+ let out = "ignore";
83648
+ try {
83649
+ fs2.mkdirSync(humHome(env3), { recursive: true });
83650
+ out = fs2.openSync(log, "w");
83651
+ } catch {
83652
+ }
83653
+ const [bin, args2] = installerArgv(version);
83654
+ try {
83655
+ const child = spawnImpl(bin, args2, {
83656
+ detached: true,
83657
+ stdio: ["ignore", out, out],
83658
+ windowsHide: true,
83659
+ env: { ...env3, HUM_VERSION: version, HUM_DIST: dist(env3) }
83660
+ });
83661
+ child.unref();
83662
+ writeState({ version, started: now }, env3);
83663
+ return true;
83664
+ } catch {
83665
+ return false;
83666
+ }
83667
+ }
83668
+ async function updateNotice(mine, { env: env3 = process.env, fetchImpl = globalThis.fetch, layout = installLayout(process.execPath, env3), spawnImpl = spawn } = {}) {
83669
+ const latest = await latestVersion(fetchImpl, env3);
83670
+ if (!latest || !newer(latest, mine)) return "";
83671
+ if (layout.kind !== "native") return `hum ${latest} is out (this is ${mine}) \xB7 ${updateCommand(layout)}`;
83672
+ if (readyVersion(layout, latest)) return `hum ${latest} is ready \xB7 restart hum to use it`;
83673
+ if (startBackgroundUpdate(latest, { env: env3, spawnImpl })) return `hum ${latest} is downloading in the background \xB7 it takes effect the next time you start hum`;
83674
+ const s = readState(env3);
83675
+ if (s.version === latest && !env3.HUM_NO_AUTO_UPDATE) return `hum ${latest} is still installing in the background (${path.join(humHome(env3), "update.log")} has the details)`;
83676
+ return `hum ${latest} is out (this is ${mine}) \xB7 ${updateCommand(layout)}`;
83677
+ }
83678
+ function updateNow(layout = installLayout()) {
83679
+ if (layout.kind === "native") {
83680
+ const [bin, args2] = installerArgv();
83681
+ return spawnSync(bin, args2, { stdio: "inherit", env: { ...process.env, HUM_DIST: dist() } }).status ?? 1;
83682
+ }
83683
+ if (layout.kind === "python") {
83684
+ process.stdout.write(`update with your package manager: ${updateCommand(layout)}
83685
+ `);
83686
+ return 0;
83687
+ }
83688
+ const r = spawnSync(win() ? "npm.cmd" : "npm", ["i", "-g", "@metaphi-ai/hum@latest"], { stdio: "inherit", shell: win() });
83689
+ return r.status ?? 1;
83690
+ }
83691
+
83569
83692
  // src/input.jsx
83570
83693
  var import_react23 = __toESM(require_react(), 1);
83571
83694
  var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
@@ -83707,15 +83830,22 @@ var fmtDur = (s) => s < 60 ? `${Math.max(1, Math.round(s))}s` : `${Math.floor(s
83707
83830
  var plural = (n, w) => `${n} ${w}${n === 1 ? "" : "s"}`;
83708
83831
  var shortSession = (name) => (name || "").replace(/\.jsonl$/, "");
83709
83832
  var homeRel = (p) => {
83710
- const h = os3.homedir();
83833
+ const h = os4.homedir();
83711
83834
  return p && h && p.startsWith(h) ? "~" + p.slice(h.length) : p;
83712
83835
  };
83836
+ var handEdit = (stat) => {
83837
+ const s = String(stat || "").trim();
83838
+ if (!s) return "you changed files by hand";
83839
+ const lines = s.split("\n");
83840
+ return lines.length === 1 ? `you edited ${s}` : `you edited files:
83841
+ ${lines.join("\n ")}`;
83842
+ };
83713
83843
  var fmtCost = (c) => c >= 0.01 ? `$${c.toFixed(2)}` : c > 0 ? `$${c.toFixed(4)}` : "$0";
83714
- var HISTORY_PATH = path.join(os3.homedir(), ".hum", "history.json");
83844
+ var HISTORY_PATH = path2.join(os4.homedir(), ".hum", "history.json");
83715
83845
  var HISTORY_MAX = 300;
83716
83846
  var loadHistory = () => {
83717
83847
  try {
83718
- const a = JSON.parse(fs2.readFileSync(HISTORY_PATH, "utf8"));
83848
+ const a = JSON.parse(fs3.readFileSync(HISTORY_PATH, "utf8"));
83719
83849
  return Array.isArray(a) ? a.filter((x) => typeof x === "string") : [];
83720
83850
  } catch {
83721
83851
  return [];
@@ -83723,8 +83853,8 @@ var loadHistory = () => {
83723
83853
  };
83724
83854
  var saveHistory = (arr) => {
83725
83855
  try {
83726
- fs2.mkdirSync(path.dirname(HISTORY_PATH), { recursive: true });
83727
- fs2.writeFileSync(HISTORY_PATH, JSON.stringify(arr.slice(-HISTORY_MAX)));
83856
+ fs3.mkdirSync(path2.dirname(HISTORY_PATH), { recursive: true });
83857
+ fs3.writeFileSync(HISTORY_PATH, JSON.stringify(arr.slice(-HISTORY_MAX)));
83728
83858
  } catch {
83729
83859
  }
83730
83860
  };
@@ -83858,11 +83988,13 @@ function App2({ engine: engine2, task, resume, images = [] }) {
83858
83988
  setGate(ev.gate === "approve" ? "approve" : "off");
83859
83989
  if (ev.session) setSession(ev.session);
83860
83990
  const state = ev.state && ev.state !== "new" && ev.state !== "idle" ? ` \xB7 ${ev.state}` : "";
83991
+ if (ev.fresh) append({ kind: "wordmark" });
83861
83992
  append({
83862
83993
  kind: "banner",
83863
- text: `${ev.model}${ev.user ? ` \xB7 ${ev.user}` : ""} \xB7 ${homeRel(ev.cwd)} \xB7 tools: ${ev.tools.join(", ")}${ev.sandbox ? ` \xB7 sandbox: ${ev.sandbox}` : ""}${state}`,
83994
+ text: `${ev.model}${ev.user ? ` \xB7 ${ev.user}` : ""} \xB7 ${homeRel(ev.cwd)} \xB7 tools: ${ev.tools.join(", ")}${ev.sandbox ? ` \xB7 sandbox: ${ev.sandbox}` : ""}${ev.workspace ? ` \xB7 ${ev.workspace}` : ""}${state}`,
83864
83995
  instruction: ev.session ? ev.instruction : null
83865
83996
  });
83997
+ if (ev.note) append({ kind: "warn", text: ev.note });
83866
83998
  preHello.current.forEach((it) => append(it));
83867
83999
  preHello.current = [];
83868
84000
  if (ev.session) {
@@ -83932,7 +84064,7 @@ function App2({ engine: engine2, task, resume, images = [] }) {
83932
84064
  append({ kind: "info", text: `context summarised and restarted${it.prompt_tokens_before ? ` at ${it.prompt_tokens_before.toLocaleString()} tokens` : ""}` });
83933
84065
  break;
83934
84066
  case "human_edit":
83935
- append({ kind: "info", text: `you edited files: ${it.stat}` });
84067
+ append({ kind: "info", text: handEdit(it.stat) });
83936
84068
  break;
83937
84069
  case "paused":
83938
84070
  append({ kind: "paused", text: it.detail, trip: it.kind });
@@ -84049,7 +84181,7 @@ function App2({ engine: engine2, task, resume, images = [] }) {
84049
84181
  append({ kind: "info", text: ev.mode === "approve" ? "approvals on: changes and commands wait for you first" : "approvals off: the agent acts, you steer" });
84050
84182
  break;
84051
84183
  case "human_edit":
84052
- append({ kind: "info", text: `you edited files: ${ev.stat}` });
84184
+ append({ kind: "info", text: handEdit(ev.stat) });
84053
84185
  break;
84054
84186
  case "compaction":
84055
84187
  append({ kind: "info", text: `context summarised and restarted${ev.prompt_tokens_before ? ` at ${ev.prompt_tokens_before.toLocaleString()} tokens` : ""} (the session keeps everything)` });
@@ -84113,6 +84245,17 @@ function App2({ engine: engine2, task, resume, images = [] }) {
84113
84245
  (0, import_react24.useEffect)(() => {
84114
84246
  engine2.on(handle);
84115
84247
  }, []);
84248
+ (0, import_react24.useEffect)(() => {
84249
+ if (!hello) return void 0;
84250
+ let live = true;
84251
+ updateNotice(true ? "0.1.13" : hello.version || "0.0.0").then((line) => {
84252
+ if (live && line) append({ kind: "info", text: line });
84253
+ }).catch(() => {
84254
+ });
84255
+ return () => {
84256
+ live = false;
84257
+ };
84258
+ }, [hello]);
84116
84259
  const quit = () => {
84117
84260
  if (phaseRef.current === "dead") return;
84118
84261
  const busy = phaseRef.current === "busy";
@@ -84315,6 +84458,10 @@ function App2({ engine: engine2, task, resume, images = [] }) {
84315
84458
  const spinnerLabel = phase === "connecting" ? " starting \u2026" : ` ${status || "working"}${elapsed >= 2 ? ` \xB7 ${fmtDur(elapsed)}` : ""}` + (thinkChars.current > 4e3 ? ` \xB7 ${(thinkChars.current / 1e3).toFixed(0)}k thinking` : "");
84316
84459
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Box_default, { flexDirection: "column", children: [
84317
84460
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Static, { items, children: (item) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Box_default, { flexDirection: "column", marginBottom: ["hum", "you", "banner", "turn"].includes(item.kind) ? 1 : 0, children: [
84461
+ item.kind === "wordmark" && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Box_default, { flexDirection: "column", paddingLeft: 1, children: [
84462
+ WORDMARK.map((row, i) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Text, { color: ACCENT, bold: true, children: row }, i)),
84463
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Text, { dimColor: true, children: TAGLINE })
84464
+ ] }),
84318
84465
  item.kind === "banner" && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Box_default, { borderStyle: "round", borderColor: ACCENT, paddingX: 2, flexDirection: "column", alignSelf: "flex-start", children: [
84319
84466
  /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Text, { children: [
84320
84467
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Text, { color: ACCENT, bold: true, children: "\u2733 hum " }),
@@ -84352,10 +84499,13 @@ function App2({ engine: engine2, task, resume, images = [] }) {
84352
84499
  " \u23BF ",
84353
84500
  item.text
84354
84501
  ] }),
84355
- item.kind === "tool" && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Text, { dimColor: true, children: [
84356
- item.agent ? " \xB7 " : " \xB7 ",
84502
+ item.kind === "tool" && (item.agent ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Text, { dimColor: true, children: [
84503
+ " \xB7 ",
84357
84504
  item.text
84358
- ] }),
84505
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Box_default, { children: [
84506
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Box_default, { width: 2, flexShrink: 0, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Text, { color: ACCENT, children: "\u25CF" }) }),
84507
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Text, { bold: true, children: item.text })
84508
+ ] })),
84359
84509
  item.kind === "plan" && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Box_default, { flexDirection: "column", paddingLeft: 2, children: [
84360
84510
  item.explanation ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Text, { dimColor: true, children: item.explanation }) : null,
84361
84511
  item.steps.map((st, i) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
@@ -84374,10 +84524,10 @@ function App2({ engine: engine2, task, resume, images = [] }) {
84374
84524
  ))
84375
84525
  ] }),
84376
84526
  item.kind === "tool_result" && (item.isError ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Text, { color: "red", dimColor: true, children: [
84377
- item.agent ? " \u23BF " : " \u23BF ",
84527
+ item.agent ? " \u23BF " : " \u23BF ",
84378
84528
  item.text
84379
84529
  ] }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Text, { dimColor: true, children: [
84380
- item.agent ? " \u23BF " : " \u23BF ",
84530
+ item.agent ? " \u23BF " : " \u23BF ",
84381
84531
  item.text
84382
84532
  ] })),
84383
84533
  item.kind === "diff" && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Box_default, { flexDirection: "column", paddingLeft: 4, children: [
@@ -84474,7 +84624,7 @@ function App2({ engine: engine2, task, resume, images = [] }) {
84474
84624
  ] }),
84475
84625
  picker.items.map((it, i) => {
84476
84626
  const live = it.live ? it.live.here ? " \xB7 here" : ` \xB7 ${it.live.state || "running"}` : "";
84477
- const tail2 = (it.steps != null ? ` \xB7 ${plural(it.steps, "step")}` : " \xB7 on the server") + (it.cost_usd ? ` \xB7 ${fmtCost(it.cost_usd)}` : "") + (it.cwd ? ` \xB7 ${path.basename(it.cwd)}` : "") + live;
84627
+ const tail2 = (it.steps != null ? ` \xB7 ${plural(it.steps, "step")}` : " \xB7 on the server") + (it.cost_usd ? ` \xB7 ${fmtCost(it.cost_usd)}` : "") + (it.cwd ? ` \xB7 ${path2.basename(it.cwd)}` : "") + live;
84478
84628
  const room = Math.max(16, width - 13 - tail2.length - 1);
84479
84629
  const what = (it.instruction || "(untitled)").replace(/\s+/g, " ");
84480
84630
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Box_default, { children: [
@@ -84487,7 +84637,7 @@ function App2({ engine: engine2, task, resume, images = [] }) {
84487
84637
  ] }, it.name);
84488
84638
  })
84489
84639
  ] }),
84490
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Box_default, { borderStyle: "round", borderColor: "gray", paddingX: 1, marginTop: 1, children: [
84640
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Box_default, { borderStyle: "single", borderColor: "gray", borderLeft: false, borderRight: false, paddingX: 1, marginTop: 1, children: [
84491
84641
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Text, { color: "cyan", children: "\u276F " }),
84492
84642
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
84493
84643
  input_default,
@@ -84519,26 +84669,26 @@ function App2({ engine: engine2, task, resume, images = [] }) {
84519
84669
  }
84520
84670
 
84521
84671
  // src/engine.js
84522
- import fs3 from "node:fs";
84672
+ import fs4 from "node:fs";
84523
84673
  import net from "node:net";
84524
- import os4 from "node:os";
84525
- import path2 from "node:path";
84674
+ import os5 from "node:os";
84675
+ import path3 from "node:path";
84526
84676
  import crypto from "node:crypto";
84527
- import { spawn, spawnSync } from "node:child_process";
84528
- var runDir = () => path2.join(process.env.HUM_HOME || path2.join(os4.homedir(), ".hum"), "run");
84677
+ import { spawn as spawn2, spawnSync as spawnSync2 } from "node:child_process";
84678
+ var runDir = () => path3.join(process.env.HUM_HOME || path3.join(os5.homedir(), ".hum"), "run");
84529
84679
  var readRun = (id) => {
84530
84680
  try {
84531
- return JSON.parse(fs3.readFileSync(path2.join(runDir(), `${id}.json`), "utf8"));
84681
+ return JSON.parse(fs4.readFileSync(path3.join(runDir(), `${id}.json`), "utf8"));
84532
84682
  } catch {
84533
84683
  return null;
84534
84684
  }
84535
84685
  };
84536
84686
  var EngineError = class extends Error {
84537
84687
  };
84538
- var win = process.platform === "win32";
84688
+ var win2 = process.platform === "win32";
84539
84689
  var exists = (p) => {
84540
84690
  try {
84541
- fs3.accessSync(p);
84691
+ fs4.accessSync(p);
84542
84692
  return true;
84543
84693
  } catch {
84544
84694
  return false;
@@ -84547,13 +84697,13 @@ var exists = (p) => {
84547
84697
  function uvToolDirs() {
84548
84698
  const dirs = [];
84549
84699
  if (process.env.UV_TOOL_DIR) dirs.push(process.env.UV_TOOL_DIR);
84550
- if (win) {
84551
- for (const base of [process.env.APPDATA, process.env.LOCALAPPDATA]) if (base) dirs.push(path2.join(base, "uv", "tools"));
84552
- } else dirs.push(path2.join(process.env.XDG_DATA_HOME || path2.join(os4.homedir(), ".local", "share"), "uv", "tools"));
84700
+ if (win2) {
84701
+ for (const base of [process.env.APPDATA, process.env.LOCALAPPDATA]) if (base) dirs.push(path3.join(base, "uv", "tools"));
84702
+ } else dirs.push(path3.join(process.env.XDG_DATA_HOME || path3.join(os5.homedir(), ".local", "share"), "uv", "tools"));
84553
84703
  if (!dirs.some(exists)) {
84554
- for (const uv of ["uv", path2.join(os4.homedir(), ".local", "bin", win ? "uv.exe" : "uv")]) {
84704
+ for (const uv of ["uv", path3.join(os5.homedir(), ".local", "bin", win2 ? "uv.exe" : "uv")]) {
84555
84705
  try {
84556
- const r = spawnSync(uv, ["tool", "dir"], { encoding: "utf8", windowsHide: true });
84706
+ const r = spawnSync2(uv, ["tool", "dir"], { encoding: "utf8", windowsHide: true });
84557
84707
  if (r.status === 0 && r.stdout.trim()) {
84558
84708
  dirs.push(r.stdout.trim());
84559
84709
  break;
@@ -84566,7 +84716,7 @@ function uvToolDirs() {
84566
84716
  }
84567
84717
  function enginePython(dirs = uvToolDirs()) {
84568
84718
  for (const dir of dirs) for (const name of ["hum-cli", "hum"]) {
84569
- const py = win ? path2.join(dir, name, "Scripts", "python.exe") : path2.join(dir, name, "bin", "python");
84719
+ const py = win2 ? path3.join(dir, name, "Scripts", "python.exe") : path3.join(dir, name, "bin", "python");
84570
84720
  if (exists(py)) return py;
84571
84721
  }
84572
84722
  return null;
@@ -84574,16 +84724,16 @@ function enginePython(dirs = uvToolDirs()) {
84574
84724
  function siblingEngine(execPath = process.execPath) {
84575
84725
  let dir;
84576
84726
  try {
84577
- dir = path2.dirname(fs3.realpathSync(execPath));
84727
+ dir = path3.dirname(fs4.realpathSync(execPath));
84578
84728
  } catch {
84579
84729
  return null;
84580
84730
  }
84581
- const p = path2.join(dir, "engine", win ? "hum-engine.exe" : "hum-engine");
84731
+ const p = path3.join(dir, "engine", win2 ? "hum-engine.exe" : "hum-engine");
84582
84732
  return exists(p) ? p : null;
84583
84733
  }
84584
84734
  function homeEngine(env3 = process.env) {
84585
- const home = env3.HUM_HOME || path2.join(os4.homedir(), ".hum");
84586
- const py = win ? path2.join(home, "engine", "Scripts", "python.exe") : path2.join(home, "engine", "bin", "python");
84735
+ const home = env3.HUM_HOME || path3.join(os5.homedir(), ".hum");
84736
+ const py = win2 ? path3.join(home, "engine", "Scripts", "python.exe") : path3.join(home, "engine", "bin", "python");
84587
84737
  return exists(py) ? py : null;
84588
84738
  }
84589
84739
  function engineCandidates(env3 = process.env) {
@@ -84599,7 +84749,7 @@ function engineCandidates(env3 = process.env) {
84599
84749
  const py = enginePython();
84600
84750
  if (py) out.push({ bin: py, args: ["-m", "hum.cli", "engine"], where: "the engine's interpreter" });
84601
84751
  out.push({ bin: "hum-engine", args: [], where: "PATH" });
84602
- out.push({ bin: path2.join(os4.homedir(), ".local", "bin", win ? "hum-engine.exe" : "hum-engine"), args: [], where: "uv's bin dir" });
84752
+ out.push({ bin: path3.join(os5.homedir(), ".local", "bin", win2 ? "hum-engine.exe" : "hum-engine"), args: [], where: "uv's bin dir" });
84603
84753
  return out;
84604
84754
  }
84605
84755
  function engineCommand(argv, candidates = engineCandidates()) {
@@ -84618,11 +84768,11 @@ function startFailure(failures) {
84618
84768
  const lines = [
84619
84769
  `Hum's engine is installed (${refused.bin}) but this machine would not start it: ${what}.`
84620
84770
  ];
84621
- if (win) {
84771
+ if (win2) {
84622
84772
  lines.push("On a managed Windows machine that is usually Device Guard / WDAC refusing an executable it does not know.");
84623
84773
  lines.push(`To see the policy's own message, run: "${refused.bin}" --help`);
84624
84774
  const dir = uvToolDirs()[0];
84625
- lines.push(`If uv's environment is elsewhere, point Hum at its interpreter: set HUM_ENGINE=${path2.join(dir || "<uv tool dir>", "hum-cli", "Scripts", "python.exe")} -m hum.cli engine`);
84775
+ lines.push(`If uv's environment is elsewhere, point Hum at its interpreter: set HUM_ENGINE=${path3.join(dir || "<uv tool dir>", "hum-cli", "Scripts", "python.exe")} -m hum.cli engine`);
84626
84776
  } else {
84627
84777
  lines.push('Set HUM_ENGINE to a command that starts it, e.g. HUM_ENGINE="python -m hum.cli engine"');
84628
84778
  }
@@ -84631,9 +84781,9 @@ function startFailure(failures) {
84631
84781
  function attempt({ bin, args: args2 }, cwd2, { task, images, resume }) {
84632
84782
  return new Promise((resolve, reject) => {
84633
84783
  const runId = crypto.randomBytes(6).toString("hex");
84634
- fs3.mkdirSync(runDir(), { recursive: true });
84635
- const logPath = path2.join(runDir(), `${runId}.log`);
84636
- const log = fs3.openSync(logPath, "a");
84784
+ fs4.mkdirSync(runDir(), { recursive: true });
84785
+ const logPath = path3.join(runDir(), `${runId}.log`);
84786
+ const log = fs4.openSync(logPath, "a");
84637
84787
  const argv = [...args2, "-C", cwd2, "--run-id", runId];
84638
84788
  if (task) argv.push("--task", task);
84639
84789
  for (const p of images) argv.push("--image", p);
@@ -84647,13 +84797,13 @@ function attempt({ bin, args: args2 }, cwd2, { task, images, resume }) {
84647
84797
  };
84648
84798
  let child;
84649
84799
  try {
84650
- child = spawn(bin, argv, { stdio: ["ignore", log, log], detached: true, windowsHide: true });
84800
+ child = spawn2(bin, argv, { stdio: ["ignore", log, log], detached: true, windowsHide: true });
84651
84801
  } catch (e) {
84652
- fs3.closeSync(log);
84802
+ fs4.closeSync(log);
84653
84803
  reject({ spawn: e });
84654
84804
  return;
84655
84805
  }
84656
- fs3.closeSync(log);
84806
+ fs4.closeSync(log);
84657
84807
  let died = false;
84658
84808
  child.on("error", (e) => settle(() => reject({ spawn: e })));
84659
84809
  child.on("exit", () => {
@@ -84692,7 +84842,7 @@ function failureMessage(error) {
84692
84842
  function diedMessage(logPath, text = null) {
84693
84843
  let tail2 = "";
84694
84844
  try {
84695
- tail2 = (text ?? fs3.readFileSync(logPath, "utf8")).trim().split("\n").slice(-3).join("\n").trim();
84845
+ tail2 = (text ?? fs4.readFileSync(logPath, "utf8")).trim().split("\n").slice(-3).join("\n").trim();
84696
84846
  } catch {
84697
84847
  }
84698
84848
  return `the engine did not start${tail2 ? `:
@@ -84789,23 +84939,24 @@ var Engine = class {
84789
84939
 
84790
84940
  // src/cli.jsx
84791
84941
  var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1);
84792
- import fs4 from "node:fs";
84793
- import path3 from "node:path";
84794
- import { spawnSync as spawnSync2 } from "node:child_process";
84942
+ import fs5 from "node:fs";
84943
+ import path4 from "node:path";
84944
+ import { spawnSync as spawnSync3 } from "node:child_process";
84795
84945
  var ENGINE_COMMANDS = /* @__PURE__ */ new Set(["run", "login", "logout", "whoami", "model", "key", "sessions", "show", "sync", "skill", "ps", "stop", "hooks", "engine"]);
84796
84946
  var argv0 = process.argv.slice(2);
84797
84947
  if (argv0[0] === "--version" || argv0[0] === "-V") {
84798
- process.stdout.write(`hum ${true ? "0.1.11" : "0.0.0"}
84948
+ process.stdout.write(`hum ${true ? "0.1.13" : "0.0.0"}
84799
84949
  `);
84800
84950
  process.exit(0);
84801
84951
  }
84952
+ if (argv0[0] === "update") process.exit(updateNow());
84802
84953
  if (ENGINE_COMMANDS.has(argv0[0])) {
84803
84954
  const cmd = engineCommand(argv0);
84804
84955
  if (!cmd) {
84805
84956
  process.stderr.write(startFailure([]) + "\n");
84806
84957
  process.exit(1);
84807
84958
  }
84808
- const r = spawnSync2(cmd.bin, cmd.args, { stdio: "inherit", windowsHide: true });
84959
+ const r = spawnSync3(cmd.bin, cmd.args, { stdio: "inherit", windowsHide: true });
84809
84960
  if (r.error) {
84810
84961
  process.stderr.write(startFailure([{ bin: cmd.bin, error: r.error }]) + "\n");
84811
84962
  process.exit(1);
@@ -84839,10 +84990,10 @@ if (!process.stdin.isTTY) {
84839
84990
  var liveRuns = () => {
84840
84991
  let out = [];
84841
84992
  try {
84842
- for (const f of fs4.readdirSync(runDir())) {
84993
+ for (const f of fs5.readdirSync(runDir())) {
84843
84994
  if (!f.endsWith(".json")) continue;
84844
84995
  try {
84845
- const r = JSON.parse(fs4.readFileSync(path3.join(runDir(), f), "utf8"));
84996
+ const r = JSON.parse(fs5.readFileSync(path4.join(runDir(), f), "utf8"));
84846
84997
  if (r.port && r.session) out.push(r);
84847
84998
  } catch {
84848
84999
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metaphi-ai/hum",
3
- "version": "0.1.11",
3
+ "version": "0.1.13",
4
4
  "description": "Hum (हम): a self-improving coding agent for your terminal.",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",