@metaphi-ai/hum 0.2.41 → 0.2.42

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.mjs CHANGED
@@ -17,9 +17,9 @@ var __esm = (fn, res) => function __init() {
17
17
  var __commonJS = (cb, mod) => function __require2() {
18
18
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
19
19
  };
20
- var __export = (target, all) => {
20
+ var __export = (target2, all) => {
21
21
  for (var name in all)
22
- __defProp(target, name, { get: all[name], enumerable: true });
22
+ __defProp(target2, name, { get: all[name], enumerable: true });
23
23
  };
24
24
  var __copyProps = (to, from, except, desc) => {
25
25
  if (from && typeof from === "object" || typeof from === "function") {
@@ -29,12 +29,12 @@ var __copyProps = (to, from, except, desc) => {
29
29
  }
30
30
  return to;
31
31
  };
32
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
32
+ var __toESM = (mod, isNodeMode, target2) => (target2 = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
33
33
  // If the importer is in node compatibility mode or this is not an ESM
34
34
  // file that has been converted to a CommonJS file using a Babel-
35
35
  // compatible transform (i.e. "__esModule" has not been set), then set
36
36
  // "default" to the CommonJS "module.exports" for node compatibility.
37
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
37
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target2, "default", { value: mod, enumerable: true }) : target2,
38
38
  mod
39
39
  ));
40
40
 
@@ -6986,8 +6986,8 @@ var require_react_reconciler_production = __commonJS({
6986
6986
  var lane = concurrentQueues[i];
6987
6987
  concurrentQueues[i++] = null;
6988
6988
  if (null !== queue && null !== update) {
6989
- var pending = queue.pending;
6990
- null === pending ? update.next = update : (update.next = pending.next, pending.next = update);
6989
+ var pending2 = queue.pending;
6990
+ null === pending2 ? update.next = update : (update.next = pending2.next, pending2.next = update);
6991
6991
  queue.pending = update;
6992
6992
  }
6993
6993
  0 !== lane && markUpdateLaneFromFiberToRoot(fiber, update, lane);
@@ -7053,8 +7053,8 @@ var require_react_reconciler_production = __commonJS({
7053
7053
  if (null === updateQueue) return null;
7054
7054
  updateQueue = updateQueue.shared;
7055
7055
  if (0 !== (executionContext & 2)) {
7056
- var pending = updateQueue.pending;
7057
- null === pending ? update.next = update : (update.next = pending.next, pending.next = update);
7056
+ var pending2 = updateQueue.pending;
7057
+ null === pending2 ? update.next = update : (update.next = pending2.next, pending2.next = update);
7058
7058
  updateQueue.pending = update;
7059
7059
  update = getRootForUpdatedFiber(fiber);
7060
7060
  markUpdateLaneFromFiberToRoot(fiber, null, lane);
@@ -8133,8 +8133,8 @@ var require_react_reconciler_production = __commonJS({
8133
8133
  }
8134
8134
  function enqueueRenderPhaseUpdate(queue, update) {
8135
8135
  didScheduleRenderPhaseUpdateDuringThisPass = didScheduleRenderPhaseUpdate = true;
8136
- var pending = queue.pending;
8137
- null === pending ? update.next = update : (update.next = pending.next, pending.next = update);
8136
+ var pending2 = queue.pending;
8137
+ null === pending2 ? update.next = update : (update.next = pending2.next, pending2.next = update);
8138
8138
  queue.pending = update;
8139
8139
  }
8140
8140
  function entangleTransitionUpdate(root, queue, lane) {
@@ -13553,10 +13553,10 @@ var require_react_reconciler_development = __commonJS({
13553
13553
  fiber = fiber.next, id--;
13554
13554
  return fiber;
13555
13555
  }
13556
- function copyWithSetImpl(obj, path9, index, value) {
13557
- if (index >= path9.length) return value;
13558
- var key = path9[index], updated = isArrayImpl(obj) ? obj.slice() : assign({}, obj);
13559
- updated[key] = copyWithSetImpl(obj[key], path9, index + 1, value);
13556
+ function copyWithSetImpl(obj, path10, index, value) {
13557
+ if (index >= path10.length) return value;
13558
+ var key = path10[index], updated = isArrayImpl(obj) ? obj.slice() : assign({}, obj);
13559
+ updated[key] = copyWithSetImpl(obj[key], path10, index + 1, value);
13560
13560
  return updated;
13561
13561
  }
13562
13562
  function copyWithRename(obj, oldPath, newPath) {
@@ -13583,11 +13583,11 @@ var require_react_reconciler_development = __commonJS({
13583
13583
  );
13584
13584
  return updated;
13585
13585
  }
13586
- function copyWithDeleteImpl(obj, path9, index) {
13587
- var key = path9[index], updated = isArrayImpl(obj) ? obj.slice() : assign({}, obj);
13588
- if (index + 1 === path9.length)
13586
+ function copyWithDeleteImpl(obj, path10, index) {
13587
+ var key = path10[index], updated = isArrayImpl(obj) ? obj.slice() : assign({}, obj);
13588
+ if (index + 1 === path10.length)
13589
13589
  return isArrayImpl(updated) ? updated.splice(key, 1) : delete updated[key], updated;
13590
- updated[key] = copyWithDeleteImpl(obj[key], path9, index + 1);
13590
+ updated[key] = copyWithDeleteImpl(obj[key], path10, index + 1);
13591
13591
  return updated;
13592
13592
  }
13593
13593
  function shouldSuspendImpl() {
@@ -16899,8 +16899,8 @@ var require_react_reconciler_development = __commonJS({
16899
16899
  var lane = concurrentQueues[i];
16900
16900
  concurrentQueues[i++] = null;
16901
16901
  if (null !== queue && null !== update) {
16902
- var pending = queue.pending;
16903
- null === pending ? update.next = update : (update.next = pending.next, pending.next = update);
16902
+ var pending2 = queue.pending;
16903
+ null === pending2 ? update.next = update : (update.next = pending2.next, pending2.next = update);
16904
16904
  queue.pending = update;
16905
16905
  }
16906
16906
  0 !== lane && markUpdateLaneFromFiberToRoot(fiber, update, lane);
@@ -18492,8 +18492,8 @@ var require_react_reconciler_development = __commonJS({
18492
18492
  }
18493
18493
  function enqueueRenderPhaseUpdate(queue, update) {
18494
18494
  didScheduleRenderPhaseUpdateDuringThisPass = didScheduleRenderPhaseUpdate = true;
18495
- var pending = queue.pending;
18496
- null === pending ? update.next = update : (update.next = pending.next, pending.next = update);
18495
+ var pending2 = queue.pending;
18496
+ null === pending2 ? update.next = update : (update.next = pending2.next, pending2.next = update);
18497
18497
  queue.pending = update;
18498
18498
  }
18499
18499
  function entangleTransitionUpdate(root, queue, lane) {
@@ -26864,29 +26864,29 @@ var require_react_reconciler_development = __commonJS({
26864
26864
  var didWarnAboutNestedUpdates = false;
26865
26865
  var didWarnAboutFindNodeInStrictMode = {};
26866
26866
  var overrideHookState = null, overrideHookStateDeletePath = null, overrideHookStateRenamePath = null, overrideProps = null, overridePropsDeletePath = null, overridePropsRenamePath = null, scheduleUpdate = null, scheduleRetry = null, setErrorHandler = null, setSuspenseHandler = null;
26867
- overrideHookState = function(fiber, id, path9, value) {
26867
+ overrideHookState = function(fiber, id, path10, value) {
26868
26868
  id = findHook(fiber, id);
26869
- null !== id && (path9 = copyWithSetImpl(id.memoizedState, path9, 0, value), id.memoizedState = path9, id.baseState = path9, fiber.memoizedProps = assign({}, fiber.memoizedProps), path9 = enqueueConcurrentRenderForLane(fiber, 2), null !== path9 && scheduleUpdateOnFiber(path9, fiber, 2));
26869
+ null !== id && (path10 = copyWithSetImpl(id.memoizedState, path10, 0, value), id.memoizedState = path10, id.baseState = path10, fiber.memoizedProps = assign({}, fiber.memoizedProps), path10 = enqueueConcurrentRenderForLane(fiber, 2), null !== path10 && scheduleUpdateOnFiber(path10, fiber, 2));
26870
26870
  };
26871
- overrideHookStateDeletePath = function(fiber, id, path9) {
26871
+ overrideHookStateDeletePath = function(fiber, id, path10) {
26872
26872
  id = findHook(fiber, id);
26873
- null !== id && (path9 = copyWithDeleteImpl(id.memoizedState, path9, 0), id.memoizedState = path9, id.baseState = path9, fiber.memoizedProps = assign({}, fiber.memoizedProps), path9 = enqueueConcurrentRenderForLane(fiber, 2), null !== path9 && scheduleUpdateOnFiber(path9, fiber, 2));
26873
+ null !== id && (path10 = copyWithDeleteImpl(id.memoizedState, path10, 0), id.memoizedState = path10, id.baseState = path10, fiber.memoizedProps = assign({}, fiber.memoizedProps), path10 = enqueueConcurrentRenderForLane(fiber, 2), null !== path10 && scheduleUpdateOnFiber(path10, fiber, 2));
26874
26874
  };
26875
26875
  overrideHookStateRenamePath = function(fiber, id, oldPath, newPath) {
26876
26876
  id = findHook(fiber, id);
26877
26877
  null !== id && (oldPath = copyWithRename(id.memoizedState, oldPath, newPath), id.memoizedState = oldPath, id.baseState = oldPath, fiber.memoizedProps = assign({}, fiber.memoizedProps), oldPath = enqueueConcurrentRenderForLane(fiber, 2), null !== oldPath && scheduleUpdateOnFiber(oldPath, fiber, 2));
26878
26878
  };
26879
- overrideProps = function(fiber, path9, value) {
26880
- fiber.pendingProps = copyWithSetImpl(fiber.memoizedProps, path9, 0, value);
26879
+ overrideProps = function(fiber, path10, value) {
26880
+ fiber.pendingProps = copyWithSetImpl(fiber.memoizedProps, path10, 0, value);
26881
26881
  fiber.alternate && (fiber.alternate.pendingProps = fiber.pendingProps);
26882
- path9 = enqueueConcurrentRenderForLane(fiber, 2);
26883
- null !== path9 && scheduleUpdateOnFiber(path9, fiber, 2);
26882
+ path10 = enqueueConcurrentRenderForLane(fiber, 2);
26883
+ null !== path10 && scheduleUpdateOnFiber(path10, fiber, 2);
26884
26884
  };
26885
- overridePropsDeletePath = function(fiber, path9) {
26886
- fiber.pendingProps = copyWithDeleteImpl(fiber.memoizedProps, path9, 0);
26885
+ overridePropsDeletePath = function(fiber, path10) {
26886
+ fiber.pendingProps = copyWithDeleteImpl(fiber.memoizedProps, path10, 0);
26887
26887
  fiber.alternate && (fiber.alternate.pendingProps = fiber.pendingProps);
26888
- path9 = enqueueConcurrentRenderForLane(fiber, 2);
26889
- null !== path9 && scheduleUpdateOnFiber(path9, fiber, 2);
26888
+ path10 = enqueueConcurrentRenderForLane(fiber, 2);
26889
+ null !== path10 && scheduleUpdateOnFiber(path10, fiber, 2);
26890
26890
  };
26891
26891
  overridePropsRenamePath = function(fiber, oldPath, newPath) {
26892
26892
  fiber.pendingProps = copyWithRename(
@@ -27243,11 +27243,11 @@ var require_react_reconciler_development = __commonJS({
27243
27243
  exports2.observeVisibleRects = function(hostRoot, selectors, callback, options2) {
27244
27244
  function commitHook() {
27245
27245
  var nextInstanceRoots = findAllNodes(hostRoot, selectors);
27246
- instanceRoots.forEach(function(target) {
27247
- 0 > nextInstanceRoots.indexOf(target) && unobserve(target);
27246
+ instanceRoots.forEach(function(target2) {
27247
+ 0 > nextInstanceRoots.indexOf(target2) && unobserve(target2);
27248
27248
  });
27249
- nextInstanceRoots.forEach(function(target) {
27250
- 0 > instanceRoots.indexOf(target) && observe(target);
27249
+ nextInstanceRoots.forEach(function(target2) {
27250
+ 0 > instanceRoots.indexOf(target2) && observe(target2);
27251
27251
  });
27252
27252
  }
27253
27253
  if (!supportsTestSelectors)
@@ -29600,17 +29600,17 @@ var require_buffer_util = __commonJS({
29600
29600
  function concat(list2, totalLength) {
29601
29601
  if (list2.length === 0) return EMPTY_BUFFER;
29602
29602
  if (list2.length === 1) return list2[0];
29603
- const target = Buffer.allocUnsafe(totalLength);
29603
+ const target2 = Buffer.allocUnsafe(totalLength);
29604
29604
  let offset = 0;
29605
29605
  for (let i = 0; i < list2.length; i++) {
29606
29606
  const buf = list2[i];
29607
- target.set(buf, offset);
29607
+ target2.set(buf, offset);
29608
29608
  offset += buf.length;
29609
29609
  }
29610
29610
  if (offset < totalLength) {
29611
- return new FastBuffer(target.buffer, target.byteOffset, offset);
29611
+ return new FastBuffer(target2.buffer, target2.byteOffset, offset);
29612
29612
  }
29613
- return target;
29613
+ return target2;
29614
29614
  }
29615
29615
  function _mask(source, mask, output, offset, length) {
29616
29616
  for (let i = 0; i < length; i++) {
@@ -31039,29 +31039,29 @@ var require_sender = __commonJS({
31039
31039
  offset += 2;
31040
31040
  payloadLength = 126;
31041
31041
  }
31042
- const target = Buffer.allocUnsafe(merge ? dataLength + offset : offset);
31043
- target[0] = options2.fin ? options2.opcode | 128 : options2.opcode;
31044
- if (options2.rsv1) target[0] |= 64;
31045
- target[1] = payloadLength;
31042
+ const target2 = Buffer.allocUnsafe(merge ? dataLength + offset : offset);
31043
+ target2[0] = options2.fin ? options2.opcode | 128 : options2.opcode;
31044
+ if (options2.rsv1) target2[0] |= 64;
31045
+ target2[1] = payloadLength;
31046
31046
  if (payloadLength === 126) {
31047
- target.writeUInt16BE(dataLength, 2);
31047
+ target2.writeUInt16BE(dataLength, 2);
31048
31048
  } else if (payloadLength === 127) {
31049
- target[2] = target[3] = 0;
31050
- target.writeUIntBE(dataLength, 4, 6);
31051
- }
31052
- if (!options2.mask) return [target, data];
31053
- target[1] |= 128;
31054
- target[offset - 4] = mask[0];
31055
- target[offset - 3] = mask[1];
31056
- target[offset - 2] = mask[2];
31057
- target[offset - 1] = mask[3];
31058
- if (skipMasking) return [target, data];
31049
+ target2[2] = target2[3] = 0;
31050
+ target2.writeUIntBE(dataLength, 4, 6);
31051
+ }
31052
+ if (!options2.mask) return [target2, data];
31053
+ target2[1] |= 128;
31054
+ target2[offset - 4] = mask[0];
31055
+ target2[offset - 3] = mask[1];
31056
+ target2[offset - 2] = mask[2];
31057
+ target2[offset - 1] = mask[3];
31058
+ if (skipMasking) return [target2, data];
31059
31059
  if (merge) {
31060
- applyMask(data, mask, target, offset, dataLength);
31061
- return [target];
31060
+ applyMask(data, mask, target2, offset, dataLength);
31061
+ return [target2];
31062
31062
  }
31063
31063
  applyMask(data, mask, data, 0, dataLength);
31064
- return [target, data];
31064
+ return [target2, data];
31065
31065
  }
31066
31066
  /**
31067
31067
  * Sends a close message to the other peer.
@@ -33379,8 +33379,8 @@ var init_devtools = __esm({
33379
33379
  // node_modules/ink/build/reconciler.js
33380
33380
  import process4 from "node:process";
33381
33381
  async function loadPackageJson() {
33382
- const fs10 = await import("node:fs");
33383
- const content = fs10.readFileSync(new URL("../package.json", import.meta.url), "utf8");
33382
+ const fs11 = await import("node:fs");
33383
+ const content = fs11.readFileSync(new URL("../package.json", import.meta.url), "utf8");
33384
33384
  const parsedContent = JSON.parse(content);
33385
33385
  return {
33386
33386
  name: parsedContent?.name,
@@ -35826,26 +35826,26 @@ var init_input_parser = __esm({
35826
35826
  };
35827
35827
  };
35828
35828
  createInputParser = () => {
35829
- let pending = "";
35829
+ let pending2 = "";
35830
35830
  return {
35831
35831
  push(chunk) {
35832
- const parsedInput = parseKeypresses(pending + chunk);
35833
- pending = parsedInput.pending;
35832
+ const parsedInput = parseKeypresses(pending2 + chunk);
35833
+ pending2 = parsedInput.pending;
35834
35834
  return parsedInput.events;
35835
35835
  },
35836
35836
  hasPendingEscape() {
35837
- return pending.startsWith(escape) && !pending.startsWith(pasteStart) && pending !== "\x1B[200";
35837
+ return pending2.startsWith(escape) && !pending2.startsWith(pasteStart) && pending2 !== "\x1B[200";
35838
35838
  },
35839
35839
  flushPendingEscape() {
35840
- if (!pending.startsWith(escape)) {
35840
+ if (!pending2.startsWith(escape)) {
35841
35841
  return void 0;
35842
35842
  }
35843
- const pendingEscape = pending;
35844
- pending = "";
35843
+ const pendingEscape = pending2;
35844
+ pending2 = "";
35845
35845
  return pendingEscape;
35846
35846
  },
35847
35847
  reset() {
35848
- pending = "";
35848
+ pending2 = "";
35849
35849
  }
35850
35850
  };
35851
35851
  };
@@ -36552,8 +36552,8 @@ var init_ErrorOverview = __esm({
36552
36552
  init_dist3();
36553
36553
  init_Box();
36554
36554
  init_Text();
36555
- cleanupPath = (path9) => {
36556
- return path9?.replace(`file://${cwd()}/`, "");
36555
+ cleanupPath = (path10) => {
36556
+ return path10?.replace(`file://${cwd()}/`, "");
36557
36557
  };
36558
36558
  stackUtils = new import_stack_utils.default({
36559
36559
  cwd: cwd(),
@@ -43370,7 +43370,7 @@ var require_supports_colors = __commonJS({
43370
43370
  "node_modules/@colors/colors/lib/system/supports-colors.js"(exports, module) {
43371
43371
  "use strict";
43372
43372
  init_define_HUM_CORE_SUBS();
43373
- var os9 = __require("os");
43373
+ var os10 = __require("os");
43374
43374
  var hasFlag2 = require_has_flag();
43375
43375
  var env3 = process.env;
43376
43376
  var forceColor = void 0;
@@ -43408,7 +43408,7 @@ var require_supports_colors = __commonJS({
43408
43408
  }
43409
43409
  var min = forceColor ? 1 : 0;
43410
43410
  if (process.platform === "win32") {
43411
- var osRelease = os9.release().split(".");
43411
+ var osRelease = os10.release().split(".");
43412
43412
  if (Number(process.versions.node.split(".")[0]) >= 8 && Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
43413
43413
  return Number(osRelease[2]) >= 14931 ? 3 : 2;
43414
43414
  }
@@ -87728,15 +87728,15 @@ var require_route = __commonJS({
87728
87728
  };
87729
87729
  }
87730
87730
  function wrapConversion(toModel, graph) {
87731
- const path9 = [graph[toModel].parent, toModel];
87731
+ const path10 = [graph[toModel].parent, toModel];
87732
87732
  let fn = conversions[graph[toModel].parent][toModel];
87733
87733
  let cur = graph[toModel].parent;
87734
87734
  while (graph[cur].parent) {
87735
- path9.unshift(graph[cur].parent);
87735
+ path10.unshift(graph[cur].parent);
87736
87736
  fn = link3(conversions[graph[cur].parent][cur], fn);
87737
87737
  cur = graph[cur].parent;
87738
87738
  }
87739
- fn.conversion = path9;
87739
+ fn.conversion = path10;
87740
87740
  return fn;
87741
87741
  }
87742
87742
  module.exports = function(fromModel) {
@@ -87980,7 +87980,7 @@ var require_supports_color = __commonJS({
87980
87980
  "node_modules/supports-color/index.js"(exports, module) {
87981
87981
  "use strict";
87982
87982
  init_define_HUM_CORE_SUBS();
87983
- var os9 = __require("os");
87983
+ var os10 = __require("os");
87984
87984
  var tty3 = __require("tty");
87985
87985
  var hasFlag2 = require_has_flag2();
87986
87986
  var { env: env3 } = process;
@@ -88028,7 +88028,7 @@ var require_supports_color = __commonJS({
88028
88028
  return min;
88029
88029
  }
88030
88030
  if (process.platform === "win32") {
88031
- const osRelease = os9.release().split(".");
88031
+ const osRelease = os10.release().split(".");
88032
88032
  if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
88033
88033
  return Number(osRelease[2]) >= 14931 ? 3 : 2;
88034
88034
  }
@@ -89452,6 +89452,23 @@ function prune(env3 = process.env, { keep = MINE, say = () => {
89452
89452
  }
89453
89453
  return gone.sort((a, b) => newer(a, b) ? -1 : newer(b, a) ? 1 : 0);
89454
89454
  }
89455
+ function ownInstaller(env3 = process.env, version = MINE, execPath = process.execPath) {
89456
+ if (version === MINE || !/^node(\.exe)?$/i.test(path.basename(execPath))) return null;
89457
+ const p = path.join(pkgDir(env3, version), "dist", "install.mjs");
89458
+ return fs3.existsSync(p) ? p : null;
89459
+ }
89460
+ function buildCore(version, { env: env3 = process.env, say = (m) => console.log(`hum: ${m}`), runImpl = run, now = Date.now(), execPath = process.execPath } = {}) {
89461
+ const theirs = ownInstaller(env3, version, execPath);
89462
+ if (theirs) {
89463
+ const r = runImpl(execPath, [theirs, "core", version], { stdio: "inherit", env: env3 }) || {};
89464
+ if (r.status !== 0) {
89465
+ const s = readInstallState(env3);
89466
+ return { ok: false, version, error: s && s.wanted === version && s.error || `hum ${version}'s installer did not finish` };
89467
+ }
89468
+ if (installedVersion(env3, version, runImpl) === version) return { ok: true, version, error: null };
89469
+ }
89470
+ return installCore(version, { env: env3, say, runImpl, now });
89471
+ }
89455
89472
  function installVersion(version, { env: env3 = process.env, say = (m) => console.log(`hum: ${m}`), runImpl = run, now = Date.now(), retries = 0, every = 90 * 1e3, wait = pause } = {}) {
89456
89473
  if (!isVersion(version)) return { ok: false, error: `not a version: ${version}` };
89457
89474
  try {
@@ -89474,7 +89491,7 @@ function installVersion(version, { env: env3 = process.env, say = (m) => console
89474
89491
  if (!p.ok) return p;
89475
89492
  }
89476
89493
  if (installedVersion(env3, version, runImpl) !== version) {
89477
- const c = attempt2("the part of hum that does the work", () => installCore(version, { env: env3, say, runImpl, now }));
89494
+ const c = attempt2("the part of hum that does the work", () => buildCore(version, { env: env3, say, runImpl, now }));
89478
89495
  if (!c.ok) return { ok: false, error: c.error };
89479
89496
  }
89480
89497
  fs3.writeFileSync(readyFile(env3, version), `${version}
@@ -89491,7 +89508,7 @@ var init_install = __esm({
89491
89508
  "src/install.js"() {
89492
89509
  init_define_HUM_CORE_SUBS();
89493
89510
  win = process.platform === "win32";
89494
- MINE = true ? "0.2.41" : "";
89511
+ MINE = true ? "0.2.42" : "";
89495
89512
  npmFix = (version = "") => `npm i -g @metaphi-ai/hum@${version || "latest"} --foreground-scripts`;
89496
89513
  NPM_FIX = npmFix("latest");
89497
89514
  humHome = (env3 = process.env) => env3.HUM_HOME || path.join(os3.homedir(), ".hum");
@@ -89541,6 +89558,10 @@ var init_install = __esm({
89541
89558
  } catch {
89542
89559
  }
89543
89560
  };
89561
+ if (process.argv[1] && /install\.mjs$/.test(process.argv[1]) && process.argv[2] === "core") {
89562
+ const r = installCore(process.argv[3] || "");
89563
+ process.exit(r.ok ? 0 : 1);
89564
+ }
89544
89565
  if (process.argv[1] && /install\.mjs$/.test(process.argv[1]) && process.argv[2] === "install") {
89545
89566
  const log = path.join(humHome(), "update.log");
89546
89567
  const say = (m) => {
@@ -89842,10 +89863,10 @@ function clientEnv() {
89842
89863
  platform: process.platform,
89843
89864
  arch: process.arch,
89844
89865
  terminal: process.env.TERM_PROGRAM || (process.env.WT_SESSION ? "Windows Terminal" : process.env.TERM || ""),
89845
- tui: true ? "0.2.41" : ""
89866
+ tui: true ? "0.2.42" : ""
89846
89867
  };
89847
89868
  }
89848
- function startFailure(failures, { npm = /^(node|bun)(\.exe)?$/i.test(String(process.execPath).split(/[\\/]/).pop()), platform: platform2 = process.platform, version = true ? "0.2.41" : "" } = {}) {
89869
+ function startFailure(failures, { npm = /^(node|bun)(\.exe)?$/i.test(String(process.execPath).split(/[\\/]/).pop()), platform: platform2 = process.platform, version = true ? "0.2.42" : "" } = {}) {
89849
89870
  const refused = failures.find((f) => f.error && f.error.code !== "ENOENT");
89850
89871
  const fix = npm ? npmFix(version) : updateCommand({ kind: "native" }, platform2);
89851
89872
  if (!refused) {
@@ -90393,9 +90414,9 @@ async function diagnose({
90393
90414
  const launcher = isWin(platform2) ? path8.join(env3.LOCALAPPDATA || path8.join(homedir, "AppData", "Local"), "hum", "bin", "hum.cmd") : path8.join(homedir, ".local", "bin", "hum");
90394
90415
  if (!exists2(launcher)) checks.push(check2("warn", `no launcher at ${launcher}`, updateCommand(layout2, platform2)));
90395
90416
  else {
90396
- const target = isWin(platform2) ? (fs9.readFileSync(launcher, "utf8").match(new RegExp('"([^"]+)"')) || [])[1] || "" : realpath(launcher);
90397
- const insideVersions = target && realpath(target).startsWith(realpath(layout2.base));
90398
- checks.push(insideVersions ? check2("ok", `launcher ${launcher} \u2192 ${target}`) : check2("warn", `launcher ${launcher} is not the installer's (it points at ${target || "?"})`, updateCommand(layout2, platform2)));
90417
+ const target2 = isWin(platform2) ? (fs9.readFileSync(launcher, "utf8").match(new RegExp('"([^"]+)"')) || [])[1] || "" : realpath(launcher);
90418
+ const insideVersions = target2 && realpath(target2).startsWith(realpath(layout2.base));
90419
+ checks.push(insideVersions ? check2("ok", `launcher ${launcher} \u2192 ${target2}`) : check2("warn", `launcher ${launcher} is not the installer's (it points at ${target2 || "?"})`, updateCommand(layout2, platform2)));
90399
90420
  }
90400
90421
  }
90401
90422
  const hits = onPath(env3, { platform: platform2 });
@@ -90554,21 +90575,21 @@ function sandboxCheck(platform2, env3) {
90554
90575
  if (restricted) return check2("warn", "bubblewrap is installed but unprivileged user namespaces are restricted", "sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0");
90555
90576
  return check2("ok", `sandbox: bubblewrap (${bwrap})`);
90556
90577
  }
90557
- function render2(report) {
90578
+ function render2(report2) {
90558
90579
  const out = [];
90559
- for (const s of report.sections) {
90580
+ for (const s of report2.sections) {
90560
90581
  out.push(s.title);
90561
90582
  for (const c of s.checks) out.push(` ${MARK[c.status]} ${c.text}${c.fix ? `
90562
90583
  \u2192 ${c.fix}` : ""}`);
90563
90584
  out.push("");
90564
90585
  }
90565
- out.push(`${report.summary.ok} ok \xB7 ${report.summary.warn} warn \xB7 ${report.summary.fail} fail`);
90586
+ out.push(`${report2.summary.ok} ok \xB7 ${report2.summary.warn} warn \xB7 ${report2.summary.fail} fail`);
90566
90587
  return out.join("\n") + "\n";
90567
90588
  }
90568
90589
  async function doctor({ json = false, mine, write = (t) => process.stdout.write(t), ...opts } = {}) {
90569
- const report = await diagnose({ mine, ...opts });
90570
- write(json ? JSON.stringify(report, null, 2) + "\n" : render2(report));
90571
- return report.summary.fail ? 1 : 0;
90590
+ const report2 = await diagnose({ mine, ...opts });
90591
+ write(json ? JSON.stringify(report2, null, 2) + "\n" : render2(report2));
90592
+ return report2.summary.fail ? 1 : 0;
90572
90593
  }
90573
90594
  var isWin, npmFix2, exists2, realpath, tail, check2, PARSE_CONFIG, MARK;
90574
90595
  var init_doctor = __esm({
@@ -91360,7 +91381,7 @@ var after = (ms, fn) => {
91360
91381
 
91361
91382
  // src/app.jsx
91362
91383
  var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1);
91363
- var MINE2 = true ? "0.2.41" : "";
91384
+ var MINE2 = true ? "0.2.42" : "";
91364
91385
  var fmtDur = (s) => s < 60 ? `${Math.max(1, Math.round(s))}s` : `${Math.floor(s / 60)}m ${Math.round(s % 60)}s`;
91365
91386
  var plural = (n, w) => `${n} ${w}${n === 1 ? "" : "s"}`;
91366
91387
  var shortSession = (name) => (name || "").replace(/\.jsonl$/, "");
@@ -93830,10 +93851,114 @@ ${r.content}`).join("\n\n") };
93830
93851
  init_core();
93831
93852
  init_update();
93832
93853
  init_install();
93854
+
93855
+ // src/health.js
93856
+ init_define_HUM_CORE_SUBS();
93857
+ init_install();
93858
+ import crypto2 from "node:crypto";
93859
+ import fs10 from "node:fs";
93860
+ import os9 from "node:os";
93861
+ import path9 from "node:path";
93862
+ var RETRY_MS2 = 60 * 60 * 1e3;
93863
+ var SEND_TIMEOUT_MS = 5e3;
93864
+ var DOCTOR_TIMEOUT_MS = 3e4;
93865
+ var readJson = (p) => {
93866
+ try {
93867
+ return JSON.parse(fs10.readFileSync(p, "utf8"));
93868
+ } catch {
93869
+ return null;
93870
+ }
93871
+ };
93872
+ var writeJson = (p, v) => {
93873
+ try {
93874
+ fs10.mkdirSync(path9.dirname(p), { recursive: true });
93875
+ fs10.writeFileSync(p, JSON.stringify(v));
93876
+ } catch {
93877
+ }
93878
+ };
93879
+ function installId(env3 = process.env) {
93880
+ const p = path9.join(humHome(env3), "install-id");
93881
+ try {
93882
+ const id2 = fs10.readFileSync(p, "utf8").trim();
93883
+ if (id2) return id2;
93884
+ } catch {
93885
+ }
93886
+ const id = crypto2.randomUUID();
93887
+ try {
93888
+ fs10.mkdirSync(path9.dirname(p), { recursive: true });
93889
+ fs10.writeFileSync(p, `${id}
93890
+ `);
93891
+ } catch {
93892
+ }
93893
+ return id;
93894
+ }
93895
+ function pending(env3 = process.env, { now = Date.now(), start = null } = {}) {
93896
+ const home = humHome(env3);
93897
+ const sent = readJson(path9.join(home, "health.json")) || {};
93898
+ const found = [];
93899
+ const install = readJson(path9.join(home, "core-install.json"));
93900
+ if (install && install.ok === false && install.at) found.push({ kind: "install", at: install.at, error: install.error || "", wanted: install.wanted || install.version || "" });
93901
+ const core2 = readJson(path9.join(home, "failure.json"));
93902
+ if (core2 && core2.at) found.push({ kind: "core", at: core2.at, error: `${core2.code}: ${core2.message}`, command: core2.command || "", core: core2.version || "" });
93903
+ if (start) found.push({ kind: "start", at: now, error: start });
93904
+ return found.filter((f) => {
93905
+ const s = sent[f.kind] || {};
93906
+ return f.at > (s.at || 0) && (!s.tried || now - s.tried >= RETRY_MS2);
93907
+ }).sort((a, b) => a.at - b.at);
93908
+ }
93909
+ function target(env3) {
93910
+ const cred = readJson(path9.join(humHome(env3), "credentials.json")) || {};
93911
+ const url = (env3.HUM_AUTH_URL || cred.auth_url || "https://hum.metaphi.ai").replace(/\/+$/, "");
93912
+ return { url, token: cred.access_token || "" };
93913
+ }
93914
+ async function sendPending({
93915
+ env: env3 = process.env,
93916
+ mine = "",
93917
+ start = null,
93918
+ now = Date.now(),
93919
+ fetchImpl = globalThis.fetch,
93920
+ diagnoseImpl = null
93921
+ } = {}) {
93922
+ try {
93923
+ const due = pending(env3, { now, start });
93924
+ if (!due.length || typeof fetchImpl !== "function") return 0;
93925
+ const diag = diagnoseImpl || (async (o) => (await Promise.resolve().then(() => (init_doctor(), doctor_exports))).diagnose(o));
93926
+ const doctor2 = await Promise.race([
93927
+ diag({ env: env3, mine }).catch((e) => ({ error: String(e && e.message ? e.message : e) })),
93928
+ new Promise((resolve) => setTimeout(() => resolve({ error: "doctor did not finish in time" }), DOCTOR_TIMEOUT_MS).unref())
93929
+ ]);
93930
+ const { url, token: token2 } = target(env3);
93931
+ const statePath2 = path9.join(humHome(env3), "health.json");
93932
+ const state = readJson(statePath2) || {};
93933
+ let sent = 0;
93934
+ for (const f of due) {
93935
+ const body = { ...f, version: mine, platform: `${process.platform}-${process.arch}`, os: os9.release(), install: installId(env3), doctor: doctor2 };
93936
+ let ok = false;
93937
+ try {
93938
+ const r = await fetchImpl(`${url}/health`, {
93939
+ method: "POST",
93940
+ body: JSON.stringify(body),
93941
+ signal: AbortSignal.timeout(SEND_TIMEOUT_MS),
93942
+ headers: { "Content-Type": "application/json", "X-Hum-Client": `hum-cli/${mine}`, ...token2 ? { Authorization: `Bearer ${token2}` } : {} }
93943
+ });
93944
+ ok = !!(r && r.ok);
93945
+ } catch {
93946
+ }
93947
+ state[f.kind] = ok ? { at: f.at, tried: now } : { ...state[f.kind] || {}, tried: now };
93948
+ if (ok) sent += 1;
93949
+ }
93950
+ writeJson(statePath2, state);
93951
+ return sent;
93952
+ } catch {
93953
+ return 0;
93954
+ }
93955
+ }
93956
+
93957
+ // src/cli.jsx
93833
93958
  await init_theme();
93834
93959
  var import_jsx_runtime5 = __toESM(require_jsx_runtime(), 1);
93835
93960
  import { spawnSync as spawnSync6 } from "node:child_process";
93836
- var MINE3 = true ? "0.2.41" : "0.0.0";
93961
+ var MINE3 = true ? "0.2.42" : "0.0.0";
93837
93962
  var layout = installLayout();
93838
93963
  function completeInstall() {
93839
93964
  if (layout.kind !== "npm" || !needsInstall(MINE3)) return;
@@ -93843,6 +93968,7 @@ function completeInstall() {
93843
93968
  const r = installCore(MINE3, { say });
93844
93969
  if (!r.ok) say(`the update did not finish: ${r.error} \xB7 ${npmFix(MINE3)}`);
93845
93970
  }
93971
+ var report = (start = null) => sendPending({ mine: MINE3, start });
93846
93972
  var CORE_COMMANDS = new Set(typeof define_HUM_CORE_SUBS_default === "undefined" ? [] : define_HUM_CORE_SUBS_default);
93847
93973
  var argv0 = process.argv.slice(2);
93848
93974
  if (argv0[0] === "--version" || argv0[0] === "-V") {
@@ -93865,14 +93991,19 @@ if (CORE_COMMANDS.has(argv0[0]) || argv0[0] === "agents" && argv0.includes("--js
93865
93991
  completeInstall();
93866
93992
  const cmd = coreCommand(argv0);
93867
93993
  if (!cmd) {
93868
- process.stderr.write(startFailure([]) + "\n");
93994
+ const why = startFailure([]);
93995
+ process.stderr.write(why + "\n");
93996
+ await report(why);
93869
93997
  process.exit(1);
93870
93998
  }
93871
93999
  const r = spawnSync6(cmd.bin, cmd.args, { stdio: "inherit", windowsHide: true });
93872
94000
  if (r.error) {
93873
- process.stderr.write(startFailure([{ bin: cmd.bin, error: r.error }]) + "\n");
94001
+ const why = startFailure([{ bin: cmd.bin, error: r.error }]);
94002
+ process.stderr.write(why + "\n");
94003
+ await report(why);
93874
94004
  process.exit(1);
93875
94005
  }
94006
+ await report();
93876
94007
  process.exit(r.status === null ? 1 : r.status);
93877
94008
  }
93878
94009
  setTheme(await detectTheme());
@@ -93941,6 +94072,7 @@ var startedHere = false;
93941
94072
  try {
93942
94073
  if (!port) {
93943
94074
  completeInstall();
94075
+ await report();
93944
94076
  const rec = await startSession(args.cwd, { task: args.task, images: args.images, resume: args.resume && args.resume !== "pick" ? args.resume : null });
93945
94077
  startedHere = true;
93946
94078
  port = rec.port;
@@ -93949,6 +94081,7 @@ try {
93949
94081
  } catch (exc) {
93950
94082
  if (exc instanceof EngineError) {
93951
94083
  if (exc.message) process.stderr.write(exc.message + "\n");
94084
+ if (exc.exit === 1 || exc.exit === 3) await report(exc.message || "the session did not start");
93952
94085
  process.exit(exc.exit);
93953
94086
  }
93954
94087
  throw exc;
package/dist/install.mjs CHANGED
@@ -257,6 +257,23 @@ var pause = (ms) => {
257
257
  } catch {
258
258
  }
259
259
  };
260
+ function ownInstaller(env = process.env, version = MINE, execPath = process.execPath) {
261
+ if (version === MINE || !/^node(\.exe)?$/i.test(path.basename(execPath))) return null;
262
+ const p = path.join(pkgDir(env, version), "dist", "install.mjs");
263
+ return fs.existsSync(p) ? p : null;
264
+ }
265
+ function buildCore(version, { env = process.env, say = (m) => console.log(`hum: ${m}`), runImpl = run, now = Date.now(), execPath = process.execPath } = {}) {
266
+ const theirs = ownInstaller(env, version, execPath);
267
+ if (theirs) {
268
+ const r = runImpl(execPath, [theirs, "core", version], { stdio: "inherit", env }) || {};
269
+ if (r.status !== 0) {
270
+ const s = readInstallState(env);
271
+ return { ok: false, version, error: s && s.wanted === version && s.error || `hum ${version}'s installer did not finish` };
272
+ }
273
+ if (installedVersion(env, version, runImpl) === version) return { ok: true, version, error: null };
274
+ }
275
+ return installCore(version, { env, say, runImpl, now });
276
+ }
260
277
  function installVersion(version, { env = process.env, say = (m) => console.log(`hum: ${m}`), runImpl = run, now = Date.now(), retries = 0, every = 90 * 1e3, wait = pause } = {}) {
261
278
  if (!isVersion(version)) return { ok: false, error: `not a version: ${version}` };
262
279
  try {
@@ -279,7 +296,7 @@ function installVersion(version, { env = process.env, say = (m) => console.log(`
279
296
  if (!p.ok) return p;
280
297
  }
281
298
  if (installedVersion(env, version, runImpl) !== version) {
282
- const c = attempt("the part of hum that does the work", () => installCore(version, { env, say, runImpl, now }));
299
+ const c = attempt("the part of hum that does the work", () => buildCore(version, { env, say, runImpl, now }));
283
300
  if (!c.ok) return { ok: false, error: c.error };
284
301
  }
285
302
  fs.writeFileSync(readyFile(env, version), `${version}
@@ -291,6 +308,10 @@ function installVersion(version, { env = process.env, say = (m) => console.log(`
291
308
  return { ok: false, error: e && e.message ? e.message : String(e) };
292
309
  }
293
310
  }
311
+ if (process.argv[1] && /install\.mjs$/.test(process.argv[1]) && process.argv[2] === "core") {
312
+ const r = installCore(process.argv[3] || "");
313
+ process.exit(r.ok ? 0 : 1);
314
+ }
294
315
  if (process.argv[1] && /install\.mjs$/.test(process.argv[1]) && process.argv[2] === "install") {
295
316
  const log = path.join(humHome(), "update.log");
296
317
  const say = (m) => {
@@ -315,6 +336,7 @@ export {
315
336
  MINE,
316
337
  NPM_FIX,
317
338
  SIGNED_PYTHON,
339
+ buildCore,
318
340
  chosenEntry,
319
341
  coreDir,
320
342
  corePython,
@@ -328,6 +350,7 @@ export {
328
350
  needsInstall,
329
351
  newer,
330
352
  npmFix,
353
+ ownInstaller,
331
354
  pkgDir,
332
355
  prune,
333
356
  readInstallState,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metaphi-ai/hum",
3
- "version": "0.2.41",
3
+ "version": "0.2.42",
4
4
  "description": "Hum: a self-improving coding agent for your terminal.",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",