@metaphi-ai/hum 0.1.12 → 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 +171 -86
  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);
@@ -83578,11 +83578,17 @@ var WORDMARK = [
83578
83578
  var TAGLINE = "\u0939\u092E \xB7 human and model, one harness";
83579
83579
 
83580
83580
  // src/update.js
83581
- var DIST = "https://storage.googleapis.com/hum-dist";
83582
- async function latestVersion(fetchImpl = globalThis.fetch) {
83583
- if (process.env.HUM_NO_UPDATE_CHECK || typeof fetchImpl !== "function") return "";
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 "";
83584
83590
  try {
83585
- const r = await fetchImpl(`${DIST}/releases/latest`, { signal: AbortSignal.timeout(2500) });
83591
+ const r = await fetchImpl(`${dist(env3)}/releases/latest`, { signal: AbortSignal.timeout(2500) });
83586
83592
  if (!r.ok) return "";
83587
83593
  const v = (await r.text()).trim();
83588
83594
  return /^\d+\.\d+\.\d+$/.test(v) ? v : "";
@@ -83597,12 +83603,91 @@ var newer = (a, b) => {
83597
83603
  }
83598
83604
  return false;
83599
83605
  };
83600
- var updateCommand = (execPath = process.execPath, platform2 = process.platform) => {
83601
- const native = !/^(node|bun)(\.exe)?$/i.test(String(execPath).split(/[\\/]/).pop());
83602
- if (native) return platform2 === "win32" ? `irm ${DIST}/install.ps1 | iex` : `curl -fsSL ${DIST}/install.sh | sh`;
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)";
83603
83619
  return "npm i -g @metaphi-ai/hum@latest";
83604
83620
  };
83605
- var updateLine = (latest, mine) => latest && newer(latest, mine) ? `hum ${latest} is out (this is ${mine}) \xB7 ${updateCommand()}` : "";
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
+ }
83606
83691
 
83607
83692
  // src/input.jsx
83608
83693
  var import_react23 = __toESM(require_react(), 1);
@@ -83745,7 +83830,7 @@ var fmtDur = (s) => s < 60 ? `${Math.max(1, Math.round(s))}s` : `${Math.floor(s
83745
83830
  var plural = (n, w) => `${n} ${w}${n === 1 ? "" : "s"}`;
83746
83831
  var shortSession = (name) => (name || "").replace(/\.jsonl$/, "");
83747
83832
  var homeRel = (p) => {
83748
- const h = os3.homedir();
83833
+ const h = os4.homedir();
83749
83834
  return p && h && p.startsWith(h) ? "~" + p.slice(h.length) : p;
83750
83835
  };
83751
83836
  var handEdit = (stat) => {
@@ -83756,11 +83841,11 @@ var handEdit = (stat) => {
83756
83841
  ${lines.join("\n ")}`;
83757
83842
  };
83758
83843
  var fmtCost = (c) => c >= 0.01 ? `$${c.toFixed(2)}` : c > 0 ? `$${c.toFixed(4)}` : "$0";
83759
- var HISTORY_PATH = path.join(os3.homedir(), ".hum", "history.json");
83844
+ var HISTORY_PATH = path2.join(os4.homedir(), ".hum", "history.json");
83760
83845
  var HISTORY_MAX = 300;
83761
83846
  var loadHistory = () => {
83762
83847
  try {
83763
- const a = JSON.parse(fs2.readFileSync(HISTORY_PATH, "utf8"));
83848
+ const a = JSON.parse(fs3.readFileSync(HISTORY_PATH, "utf8"));
83764
83849
  return Array.isArray(a) ? a.filter((x) => typeof x === "string") : [];
83765
83850
  } catch {
83766
83851
  return [];
@@ -83768,8 +83853,8 @@ var loadHistory = () => {
83768
83853
  };
83769
83854
  var saveHistory = (arr) => {
83770
83855
  try {
83771
- fs2.mkdirSync(path.dirname(HISTORY_PATH), { recursive: true });
83772
- 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)));
83773
83858
  } catch {
83774
83859
  }
83775
83860
  };
@@ -84163,9 +84248,8 @@ function App2({ engine: engine2, task, resume, images = [] }) {
84163
84248
  (0, import_react24.useEffect)(() => {
84164
84249
  if (!hello) return void 0;
84165
84250
  let live = true;
84166
- latestVersion().then((v) => {
84167
- const line = live ? updateLine(v, true ? "0.1.12" : hello.version || "0.0.0") : "";
84168
- if (line) append({ kind: "info", text: line });
84251
+ updateNotice(true ? "0.1.13" : hello.version || "0.0.0").then((line) => {
84252
+ if (live && line) append({ kind: "info", text: line });
84169
84253
  }).catch(() => {
84170
84254
  });
84171
84255
  return () => {
@@ -84540,7 +84624,7 @@ function App2({ engine: engine2, task, resume, images = [] }) {
84540
84624
  ] }),
84541
84625
  picker.items.map((it, i) => {
84542
84626
  const live = it.live ? it.live.here ? " \xB7 here" : ` \xB7 ${it.live.state || "running"}` : "";
84543
- 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;
84544
84628
  const room = Math.max(16, width - 13 - tail2.length - 1);
84545
84629
  const what = (it.instruction || "(untitled)").replace(/\s+/g, " ");
84546
84630
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Box_default, { children: [
@@ -84585,26 +84669,26 @@ function App2({ engine: engine2, task, resume, images = [] }) {
84585
84669
  }
84586
84670
 
84587
84671
  // src/engine.js
84588
- import fs3 from "node:fs";
84672
+ import fs4 from "node:fs";
84589
84673
  import net from "node:net";
84590
- import os4 from "node:os";
84591
- import path2 from "node:path";
84674
+ import os5 from "node:os";
84675
+ import path3 from "node:path";
84592
84676
  import crypto from "node:crypto";
84593
- import { spawn, spawnSync } from "node:child_process";
84594
- 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");
84595
84679
  var readRun = (id) => {
84596
84680
  try {
84597
- return JSON.parse(fs3.readFileSync(path2.join(runDir(), `${id}.json`), "utf8"));
84681
+ return JSON.parse(fs4.readFileSync(path3.join(runDir(), `${id}.json`), "utf8"));
84598
84682
  } catch {
84599
84683
  return null;
84600
84684
  }
84601
84685
  };
84602
84686
  var EngineError = class extends Error {
84603
84687
  };
84604
- var win = process.platform === "win32";
84688
+ var win2 = process.platform === "win32";
84605
84689
  var exists = (p) => {
84606
84690
  try {
84607
- fs3.accessSync(p);
84691
+ fs4.accessSync(p);
84608
84692
  return true;
84609
84693
  } catch {
84610
84694
  return false;
@@ -84613,13 +84697,13 @@ var exists = (p) => {
84613
84697
  function uvToolDirs() {
84614
84698
  const dirs = [];
84615
84699
  if (process.env.UV_TOOL_DIR) dirs.push(process.env.UV_TOOL_DIR);
84616
- if (win) {
84617
- for (const base of [process.env.APPDATA, process.env.LOCALAPPDATA]) if (base) dirs.push(path2.join(base, "uv", "tools"));
84618
- } 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"));
84619
84703
  if (!dirs.some(exists)) {
84620
- 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")]) {
84621
84705
  try {
84622
- const r = spawnSync(uv, ["tool", "dir"], { encoding: "utf8", windowsHide: true });
84706
+ const r = spawnSync2(uv, ["tool", "dir"], { encoding: "utf8", windowsHide: true });
84623
84707
  if (r.status === 0 && r.stdout.trim()) {
84624
84708
  dirs.push(r.stdout.trim());
84625
84709
  break;
@@ -84632,7 +84716,7 @@ function uvToolDirs() {
84632
84716
  }
84633
84717
  function enginePython(dirs = uvToolDirs()) {
84634
84718
  for (const dir of dirs) for (const name of ["hum-cli", "hum"]) {
84635
- 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");
84636
84720
  if (exists(py)) return py;
84637
84721
  }
84638
84722
  return null;
@@ -84640,16 +84724,16 @@ function enginePython(dirs = uvToolDirs()) {
84640
84724
  function siblingEngine(execPath = process.execPath) {
84641
84725
  let dir;
84642
84726
  try {
84643
- dir = path2.dirname(fs3.realpathSync(execPath));
84727
+ dir = path3.dirname(fs4.realpathSync(execPath));
84644
84728
  } catch {
84645
84729
  return null;
84646
84730
  }
84647
- 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");
84648
84732
  return exists(p) ? p : null;
84649
84733
  }
84650
84734
  function homeEngine(env3 = process.env) {
84651
- const home = env3.HUM_HOME || path2.join(os4.homedir(), ".hum");
84652
- 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");
84653
84737
  return exists(py) ? py : null;
84654
84738
  }
84655
84739
  function engineCandidates(env3 = process.env) {
@@ -84665,7 +84749,7 @@ function engineCandidates(env3 = process.env) {
84665
84749
  const py = enginePython();
84666
84750
  if (py) out.push({ bin: py, args: ["-m", "hum.cli", "engine"], where: "the engine's interpreter" });
84667
84751
  out.push({ bin: "hum-engine", args: [], where: "PATH" });
84668
- 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" });
84669
84753
  return out;
84670
84754
  }
84671
84755
  function engineCommand(argv, candidates = engineCandidates()) {
@@ -84684,11 +84768,11 @@ function startFailure(failures) {
84684
84768
  const lines = [
84685
84769
  `Hum's engine is installed (${refused.bin}) but this machine would not start it: ${what}.`
84686
84770
  ];
84687
- if (win) {
84771
+ if (win2) {
84688
84772
  lines.push("On a managed Windows machine that is usually Device Guard / WDAC refusing an executable it does not know.");
84689
84773
  lines.push(`To see the policy's own message, run: "${refused.bin}" --help`);
84690
84774
  const dir = uvToolDirs()[0];
84691
- 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`);
84692
84776
  } else {
84693
84777
  lines.push('Set HUM_ENGINE to a command that starts it, e.g. HUM_ENGINE="python -m hum.cli engine"');
84694
84778
  }
@@ -84697,9 +84781,9 @@ function startFailure(failures) {
84697
84781
  function attempt({ bin, args: args2 }, cwd2, { task, images, resume }) {
84698
84782
  return new Promise((resolve, reject) => {
84699
84783
  const runId = crypto.randomBytes(6).toString("hex");
84700
- fs3.mkdirSync(runDir(), { recursive: true });
84701
- const logPath = path2.join(runDir(), `${runId}.log`);
84702
- 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");
84703
84787
  const argv = [...args2, "-C", cwd2, "--run-id", runId];
84704
84788
  if (task) argv.push("--task", task);
84705
84789
  for (const p of images) argv.push("--image", p);
@@ -84713,13 +84797,13 @@ function attempt({ bin, args: args2 }, cwd2, { task, images, resume }) {
84713
84797
  };
84714
84798
  let child;
84715
84799
  try {
84716
- 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 });
84717
84801
  } catch (e) {
84718
- fs3.closeSync(log);
84802
+ fs4.closeSync(log);
84719
84803
  reject({ spawn: e });
84720
84804
  return;
84721
84805
  }
84722
- fs3.closeSync(log);
84806
+ fs4.closeSync(log);
84723
84807
  let died = false;
84724
84808
  child.on("error", (e) => settle(() => reject({ spawn: e })));
84725
84809
  child.on("exit", () => {
@@ -84758,7 +84842,7 @@ function failureMessage(error) {
84758
84842
  function diedMessage(logPath, text = null) {
84759
84843
  let tail2 = "";
84760
84844
  try {
84761
- 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();
84762
84846
  } catch {
84763
84847
  }
84764
84848
  return `the engine did not start${tail2 ? `:
@@ -84855,23 +84939,24 @@ var Engine = class {
84855
84939
 
84856
84940
  // src/cli.jsx
84857
84941
  var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1);
84858
- import fs4 from "node:fs";
84859
- import path3 from "node:path";
84860
- 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";
84861
84945
  var ENGINE_COMMANDS = /* @__PURE__ */ new Set(["run", "login", "logout", "whoami", "model", "key", "sessions", "show", "sync", "skill", "ps", "stop", "hooks", "engine"]);
84862
84946
  var argv0 = process.argv.slice(2);
84863
84947
  if (argv0[0] === "--version" || argv0[0] === "-V") {
84864
- process.stdout.write(`hum ${true ? "0.1.12" : "0.0.0"}
84948
+ process.stdout.write(`hum ${true ? "0.1.13" : "0.0.0"}
84865
84949
  `);
84866
84950
  process.exit(0);
84867
84951
  }
84952
+ if (argv0[0] === "update") process.exit(updateNow());
84868
84953
  if (ENGINE_COMMANDS.has(argv0[0])) {
84869
84954
  const cmd = engineCommand(argv0);
84870
84955
  if (!cmd) {
84871
84956
  process.stderr.write(startFailure([]) + "\n");
84872
84957
  process.exit(1);
84873
84958
  }
84874
- const r = spawnSync2(cmd.bin, cmd.args, { stdio: "inherit", windowsHide: true });
84959
+ const r = spawnSync3(cmd.bin, cmd.args, { stdio: "inherit", windowsHide: true });
84875
84960
  if (r.error) {
84876
84961
  process.stderr.write(startFailure([{ bin: cmd.bin, error: r.error }]) + "\n");
84877
84962
  process.exit(1);
@@ -84905,10 +84990,10 @@ if (!process.stdin.isTTY) {
84905
84990
  var liveRuns = () => {
84906
84991
  let out = [];
84907
84992
  try {
84908
- for (const f of fs4.readdirSync(runDir())) {
84993
+ for (const f of fs5.readdirSync(runDir())) {
84909
84994
  if (!f.endsWith(".json")) continue;
84910
84995
  try {
84911
- const r = JSON.parse(fs4.readFileSync(path3.join(runDir(), f), "utf8"));
84996
+ const r = JSON.parse(fs5.readFileSync(path4.join(runDir(), f), "utf8"));
84912
84997
  if (r.port && r.session) out.push(r);
84913
84998
  } catch {
84914
84999
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metaphi-ai/hum",
3
- "version": "0.1.12",
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",