@metaphi-ai/hum 0.2.14 → 0.2.16

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 +37 -9
  2. package/package.json +1 -1
package/dist/cli.mjs CHANGED
@@ -88634,7 +88634,7 @@ var win, MINE, npmFix, NPM_FIX, humHome, versionsDir, versionDir, pkgDir, coreDi
88634
88634
  var init_install = __esm({
88635
88635
  "src/install.js"() {
88636
88636
  win = process.platform === "win32";
88637
- MINE = true ? "0.2.14" : "";
88637
+ MINE = true ? "0.2.16" : "";
88638
88638
  npmFix = (version = "") => `npm i -g @metaphi-ai/hum@${version || "latest"} --foreground-scripts`;
88639
88639
  NPM_FIX = npmFix("latest");
88640
88640
  humHome = (env3 = process.env) => env3.HUM_HOME || path.join(os3.homedir(), ".hum");
@@ -88970,10 +88970,10 @@ function clientEnv() {
88970
88970
  platform: process.platform,
88971
88971
  arch: process.arch,
88972
88972
  terminal: process.env.TERM_PROGRAM || (process.env.WT_SESSION ? "Windows Terminal" : process.env.TERM || ""),
88973
- tui: true ? "0.2.14" : ""
88973
+ tui: true ? "0.2.16" : ""
88974
88974
  };
88975
88975
  }
88976
- function startFailure(failures, { npm = /^(node|bun)(\.exe)?$/i.test(String(process.execPath).split(/[\\/]/).pop()), platform: platform2 = process.platform, version = true ? "0.2.14" : "" } = {}) {
88976
+ function startFailure(failures, { npm = /^(node|bun)(\.exe)?$/i.test(String(process.execPath).split(/[\\/]/).pop()), platform: platform2 = process.platform, version = true ? "0.2.16" : "" } = {}) {
88977
88977
  const refused = failures.find((f) => f.error && f.error.code !== "ENOENT");
88978
88978
  const fix = npm ? npmFix(version) : updateCommand({ kind: "native" }, platform2);
88979
88979
  if (!refused) {
@@ -89080,7 +89080,7 @@ async function spawnCore(cwd2, { task = null, images = [], resume = null, candid
89080
89080
  failures.push({ ...cand, error: f.spawn });
89081
89081
  continue;
89082
89082
  }
89083
- if (f && f.failed) throw new EngineError(failureMessage(f.failed));
89083
+ if (f && f.failed) throw new EngineError(failureMessage(f.failed), { error: f.failed, exit: 2 });
89084
89084
  if (f && f.died) throw new EngineError(diedMessage(f.died));
89085
89085
  if (f && f.timeout) throw new EngineError("the session did not start in time");
89086
89086
  throw f;
@@ -89088,6 +89088,28 @@ async function spawnCore(cwd2, { task = null, images = [], resume = null, candid
89088
89088
  }
89089
89089
  throw new EngineError(startFailure(failures));
89090
89090
  }
89091
+ function runLogin(candidates = coreCandidates()) {
89092
+ const cmd = coreCommand(["login"], candidates);
89093
+ if (!cmd) return 1;
89094
+ const r = spawnSync3(cmd.bin, cmd.args, { stdio: "inherit", windowsHide: true });
89095
+ return r.error ? 1 : r.status === null ? 1 : r.status;
89096
+ }
89097
+ async function startSession(cwd2, opts = {}, {
89098
+ login = runLogin,
89099
+ interactive = process.stdin.isTTY && process.stdout.isTTY && !process.env.HUM_NO_AUTO_LOGIN,
89100
+ say = (m) => process.stderr.write(`${m}
89101
+ `)
89102
+ } = {}) {
89103
+ try {
89104
+ return await spawnCore(cwd2, opts);
89105
+ } catch (e) {
89106
+ if (!(e instanceof EngineError) || e.code !== "no_model_access" || !interactive) throw e;
89107
+ }
89108
+ say("Sign in to use Hum.");
89109
+ const status = login();
89110
+ if (status !== 0) throw new EngineError("", { exit: status });
89111
+ return spawnCore(cwd2, opts);
89112
+ }
89091
89113
  var runDir, readRun, EngineError, win3, exists, Core;
89092
89114
  var init_core = __esm({
89093
89115
  "src/core.js"() {
@@ -89102,6 +89124,12 @@ var init_core = __esm({
89102
89124
  }
89103
89125
  };
89104
89126
  EngineError = class extends Error {
89127
+ constructor(message, { error = null, exit = 1 } = {}) {
89128
+ super(message);
89129
+ this.code = error ? error.code || null : null;
89130
+ this.error = error;
89131
+ this.exit = exit;
89132
+ }
89105
89133
  };
89106
89134
  win3 = process.platform === "win32";
89107
89135
  exists = (p) => {
@@ -90431,7 +90459,7 @@ var input_default = MultilineInput;
90431
90459
 
90432
90460
  // src/app.jsx
90433
90461
  var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1);
90434
- var MINE2 = true ? "0.2.14" : "";
90462
+ var MINE2 = true ? "0.2.16" : "";
90435
90463
  var fmtDur = (s) => s < 60 ? `${Math.max(1, Math.round(s))}s` : `${Math.floor(s / 60)}m ${Math.round(s % 60)}s`;
90436
90464
  var plural = (n, w) => `${n} ${w}${n === 1 ? "" : "s"}`;
90437
90465
  var firstResp = (e) => e.first_response_s ? ` \xB7 first response ${e.first_response_s.toFixed(1)}s` : "";
@@ -92256,7 +92284,7 @@ init_update();
92256
92284
  init_install();
92257
92285
  var import_jsx_runtime4 = __toESM(require_jsx_runtime(), 1);
92258
92286
  import { spawnSync as spawnSync5 } from "node:child_process";
92259
- var MINE3 = true ? "0.2.14" : "0.0.0";
92287
+ var MINE3 = true ? "0.2.16" : "0.0.0";
92260
92288
  var layout = installLayout();
92261
92289
  function completeInstall() {
92262
92290
  if (layout.kind !== "npm" || !needsInstall(MINE3)) return;
@@ -92363,15 +92391,15 @@ var startedHere = false;
92363
92391
  try {
92364
92392
  if (!port) {
92365
92393
  completeInstall();
92366
- const rec = await spawnCore(args.cwd, { task: args.task, images: args.images, resume: args.resume && args.resume !== "pick" ? args.resume : null });
92394
+ const rec = await startSession(args.cwd, { task: args.task, images: args.images, resume: args.resume && args.resume !== "pick" ? args.resume : null });
92367
92395
  startedHere = true;
92368
92396
  port = rec.port;
92369
92397
  token = rec.token || "";
92370
92398
  }
92371
92399
  } catch (exc) {
92372
92400
  if (exc instanceof EngineError) {
92373
- process.stderr.write(exc.message + "\n");
92374
- process.exit(1);
92401
+ if (exc.message) process.stderr.write(exc.message + "\n");
92402
+ process.exit(exc.exit);
92375
92403
  }
92376
92404
  throw exc;
92377
92405
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metaphi-ai/hum",
3
- "version": "0.2.14",
3
+ "version": "0.2.16",
4
4
  "description": "Hum: a self-improving coding agent for your terminal.",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",